Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions src/vs/base/browser/ui/button/button.ts
Original file line number Diff line number Diff line change
Expand Up @@ -574,6 +574,16 @@ export class ButtonBar {
private readonly _buttons: IButton[] = [];
private readonly _buttonStore = new DisposableStore();

private _context: unknown;

get context(): unknown {
return this._context;
}

set context(context: unknown) {
Comment on lines +577 to +583
Copy link

Copilot AI Feb 3, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

_context is declared but never definitely assigned. With strict TS settings this will fail strictPropertyInitialization for ButtonBar. Initialize it (e.g. to undefined) and/or widen the type to include undefined so callers can omit context safely.

Suggested change
private _context: unknown;
get context(): unknown {
return this._context;
}
set context(context: unknown) {
private _context: unknown | undefined = undefined;
get context(): unknown | undefined {
return this._context;
}
set context(context: unknown | undefined) {

Copilot uses AI. Check for mistakes.
this._context = context;
}

constructor(private readonly container: HTMLElement, private readonly options?: { alignment?: ButtonBarAlignment }) { }

dispose(): void {
Expand Down
5 changes: 3 additions & 2 deletions src/vs/platform/actions/browser/buttonbar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -141,12 +141,12 @@ export class WorkbenchButtonBar extends ButtonBar {
if (this._options?.disableWhileRunning) {
btn.enabled = false;
try {
await this._actionRunner.run(action);
await this._actionRunner.run(action, this.context);
} finally {
btn.enabled = action.enabled;
}
} else {
this._actionRunner.run(action);
this._actionRunner.run(action, this.context);
}
}));
}
Expand All @@ -168,6 +168,7 @@ export class WorkbenchButtonBar extends ButtonBar {
this._contextMenuService.showContextMenu({
getAnchor: () => btn.element,
getActions: () => secondary,
getActionsContext: () => this.context,
actionRunner: this._actionRunner,
onHide: () => btn.element.setAttribute('aria-expanded', 'false')
});
Expand Down
5 changes: 1 addition & 4 deletions src/vs/platform/actions/common/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,6 @@ export class MenuId {

export interface IMenuActionOptions {
arg?: unknown;
args?: unknown[];
shouldForwardArgs?: boolean;
renderShortTitle?: boolean;
}
Expand Down Expand Up @@ -614,9 +613,7 @@ export class MenuItemAction implements IAction {
run(...args: unknown[]): Promise<void> {
let runArgs: unknown[] = [];

if (this._options?.args) {
runArgs = [...runArgs, ...this._options.args];
} else if (this._options?.arg) {
if (this._options?.arg) {
runArgs = [...runArgs, this._options.arg];
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2562,16 +2562,20 @@ export class ChatInputPart extends Disposable implements IHistoryNavigationWidge

store.add(autorun(reader => {
const isSessionMenu = topLevelIsSessionMenu.read(reader);
reader.store.add(scopedInstantiationService.createInstance(MenuWorkbenchButtonBar, actionsContainer, isSessionMenu ? MenuId.ChatEditingSessionChangesToolbar : MenuId.ChatEditingWidgetToolbar, {

const menuId = isSessionMenu ? MenuId.ChatEditingSessionChangesToolbar : MenuId.ChatEditingWidgetToolbar;
const buttonBar = scopedInstantiationService.createInstance(MenuWorkbenchButtonBar, actionsContainer, menuId, {
telemetrySource: this.options.menus.telemetrySource,
small: true,
menuOptions: sessionResource ? (isSessionMenu ? {
args: [sessionResource, this.agentSessionsService.getSession(sessionResource)?.metadata],
arg: sessionResource,
shouldForwardArgs: true
} : {
arg: {
$mid: MarshalledId.ChatViewContext,
sessionResource,
} satisfies IChatViewTitleActionContext,
shouldForwardArgs: true
}) : undefined,
disableWhileRunning: isSessionMenu,
buttonConfigProvider: (action) => {
Expand All @@ -2580,7 +2584,13 @@ export class ChatInputPart extends Disposable implements IHistoryNavigationWidge
}
return undefined;
}
}));
});

buttonBar.context = sessionResource
? this.agentSessionsService.getSession(sessionResource)?.metadata
: undefined;

reader.store.add(buttonBar);
}));

store.add(autorun(reader => {
Expand Down
Loading