Add instructions to the extensions update info notification (#14907)

This commit is contained in:
christine betts
2025-12-30 14:50:33 -05:00
committed by GitHub
parent 90eb1e0281
commit ec79fe1ab2
2 changed files with 7 additions and 9 deletions

View File

@@ -107,7 +107,7 @@ describe('useExtensionUpdates', () => {
expect(addItem).toHaveBeenCalledWith(
{
type: MessageType.INFO,
text: 'You have 1 extension with an update available, run "/extensions list" for more information.',
text: `You have 1 extension with an update available. Run "/extensions update test-extension".`,
},
expect.any(Number),
);
@@ -319,7 +319,7 @@ describe('useExtensionUpdates', () => {
expect(addItem).toHaveBeenCalledWith(
{
type: MessageType.INFO,
text: 'You have 2 extensions with an update available, run "/extensions list" for more information.',
text: `You have 2 extensions with an update available. Run "/extensions update test-extension-1 test-extension-2".`,
},
expect.any(Number),
);

View File

@@ -133,10 +133,9 @@ export const useExtensionUpdates = (
}
}
let extensionsWithUpdatesCount = 0;
// We only notify if we have unprocessed extensions in the UPDATE_AVAILABLE
// state.
let shouldNotifyOfUpdates = false;
const pendingUpdates = [];
const updatePromises: Array<Promise<ExtensionUpdateInfo | undefined>> = [];
for (const extension of extensions) {
const currentState = extensionsUpdateState.extensionStatuses.get(
@@ -150,14 +149,13 @@ export const useExtensionUpdates = (
}
const shouldUpdate = shouldDoUpdate(extension);
if (!shouldUpdate) {
extensionsWithUpdatesCount++;
if (!currentState.notified) {
// Mark as processed immediately to avoid re-triggering.
dispatchExtensionStateUpdate({
type: 'SET_NOTIFIED',
payload: { name: extension.name, notified: true },
});
shouldNotifyOfUpdates = true;
pendingUpdates.push(extension.name);
}
} else {
const updatePromise = updateExtension(
@@ -190,12 +188,12 @@ export const useExtensionUpdates = (
});
}
}
if (shouldNotifyOfUpdates) {
const s = extensionsWithUpdatesCount > 1 ? 's' : '';
if (pendingUpdates.length > 0) {
const s = pendingUpdates.length > 1 ? 's' : '';
addItem(
{
type: MessageType.INFO,
text: `You have ${extensionsWithUpdatesCount} extension${s} with an update available, run "/extensions list" for more information.`,
text: `You have ${pendingUpdates.length} extension${s} with an update available. Run "/extensions update ${pendingUpdates.join(' ')}".`,
},
Date.now(),
);