diff --git a/src/vs/workbench/contrib/update/browser/update.contribution.ts b/src/vs/workbench/contrib/update/browser/update.contribution.ts index a21a2294257..4d5801ef372 100644 --- a/src/vs/workbench/contrib/update/browser/update.contribution.ts +++ b/src/vs/workbench/contrib/update/browser/update.contribution.ts @@ -9,6 +9,8 @@ import { Registry } from '../../../../platform/registry/common/platform.js'; import { IWorkbenchContributionsRegistry, Extensions as WorkbenchExtensions } from '../../../common/contributions.js'; import { Categories } from '../../../../platform/action/common/actionCommonCategories.js'; import { MenuId, registerAction2, Action2 } from '../../../../platform/actions/common/actions.js'; +import { ICommandService } from '../../../../platform/commands/common/commands.js'; +import { IQuickInputService } from '../../../../platform/quickinput/common/quickInput.js'; import { ProductContribution, UpdateContribution, CONTEXT_UPDATE_STATE, SwitchProductQualityContribution, showReleaseNotesInEditor, DefaultAccountUpdateContribution } from './update.js'; import { UpdateTitleBarContribution } from './updateTitleBarEntry.js'; import { LifecyclePhase } from '../../../services/lifecycle/common/lifecycle.js'; @@ -241,3 +243,25 @@ if (isWindows) { registerAction2(DeveloperApplyUpdateAction); } + +registerAction2(class ShowUpdateInfoAction extends Action2 { + constructor() { + super({ + id: 'update.showUpdateInfo', + title: localize2('showUpdateInfo', "Show Update Info"), + category: Categories.Developer, + f1: true, + precondition: IsWebContext.negate(), + }); + } + + async run(accessor: ServicesAccessor): Promise { + const commandService = accessor.get(ICommandService); + const quickInputService = accessor.get(IQuickInputService); + const markdown = await quickInputService.input({ prompt: localize('showUpdateInfo.prompt', "Enter markdown to render (leave empty to load from URL)") }); + if (markdown === undefined) { + return; // cancelled + } + await commandService.executeCommand('_update.showUpdateInfo', markdown || undefined); + } +}); diff --git a/src/vs/workbench/contrib/update/browser/updateTitleBarEntry.ts b/src/vs/workbench/contrib/update/browser/updateTitleBarEntry.ts index c1e985bfa7d..1c3a9f1b900 100644 --- a/src/vs/workbench/contrib/update/browser/updateTitleBarEntry.ts +++ b/src/vs/workbench/contrib/update/browser/updateTitleBarEntry.ts @@ -13,7 +13,7 @@ import { isWeb } from '../../../../base/common/platform.js'; import { localize } from '../../../../nls.js'; import { IActionViewItemService } from '../../../../platform/actions/browser/actionViewItemService.js'; import { Action2, MenuId, registerAction2 } from '../../../../platform/actions/common/actions.js'; -import { ICommandService } from '../../../../platform/commands/common/commands.js'; +import { CommandsRegistry, ICommandService } from '../../../../platform/commands/common/commands.js'; import { IContextKey, IContextKeyService, RawContextKey } from '../../../../platform/contextkey/common/contextkey.js'; import { IHoverService } from '../../../../platform/hover/browser/hover.js'; import { IInstantiationService } from '../../../../platform/instantiation/common/instantiation.js'; @@ -115,9 +115,20 @@ export class UpdateTitleBarContribution extends Disposable implements IWorkbench } )); + this._register(CommandsRegistry.registerCommand('_update.showUpdateInfo', (_accessor, markdown?: string) => this.showUpdateInfo(markdown))); + void this.onStateChange(true); } + private async showUpdateInfo(markdown?: string) { + const rendered = await this.tooltip.renderPostInstall(markdown); + if (rendered) { + this.tooltipVisible = true; + this.context.set(true); + this.entry?.showTooltip(true); + } + } + private async onStateChange(startup = false) { this.pendingShow.clear(); if (ACTIONABLE_STATES.includes(this.state.type)) { diff --git a/src/vs/workbench/contrib/update/browser/updateTooltip.ts b/src/vs/workbench/contrib/update/browser/updateTooltip.ts index dee3128ab03..b64a06871d4 100644 --- a/src/vs/workbench/contrib/update/browser/updateTooltip.ts +++ b/src/vs/workbench/contrib/update/browser/updateTooltip.ts @@ -382,19 +382,21 @@ export class UpdateTooltip extends Disposable { this.renderMessage(localize('updateTooltip.restartingPleaseWait', "Restarting to update, please wait...")); } - public async renderPostInstall(): Promise { + public async renderPostInstall(markdown?: string): Promise { this.hideAll(); this.renderTitleAndInfo(localize('updateTooltip.installedDefaultTitle', "New Update Installed")); this.renderMessage( localize('updateTooltip.installedDefaultMessage', "See release notes for details on what's new in this release."), Codicon.info); - let text: string | null = null; - try { - const url = getUpdateInfoUrl(this.productService.version); - const context = await this.requestService.request({ url, callSite: 'updateTooltip' }, CancellationToken.None); - text = await asTextOrError(context); - } catch { } + let text: string | null = markdown ?? null; + if (!text) { + try { + const url = getUpdateInfoUrl(this.productService.version); + const context = await this.requestService.request({ url, callSite: 'updateTooltip' }, CancellationToken.None); + text = await asTextOrError(context); + } catch { } + } if (!text) { return false;