Skip to content

Conversation

@lszomoru
Copy link
Member

@lszomoru lszomoru commented Feb 3, 2026

  • This pull request reverts the changes to action.ts made in Pass metadata to agent session commands #291554 as those did not feel right
  • Added support to set the context for the ButtonBar widget matching the implementation of the ActionBar
  • Adopted the context for the working set ButtonBar so that we can pass session metadata to the actions

Copilot AI review requested due to automatic review settings February 3, 2026 20:03
@lszomoru lszomoru self-assigned this Feb 3, 2026
@lszomoru lszomoru requested review from alexr00 and jrieken February 3, 2026 20:03
@lszomoru lszomoru enabled auto-merge (squash) February 3, 2026 20:03
@vs-code-engineering vs-code-engineering bot added this to the February 2026 milestone Feb 3, 2026
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds a way to attach and forward “context” through ButtonBar/WorkbenchButtonBar so actions (and overflow context menu actions) can run with widget-specific context (e.g., chat session metadata).

Changes:

  • Introduces a context property on ButtonBar and forwards it when running actions / showing overflow menus in WorkbenchButtonBar.
  • Simplifies menu action argument plumbing by removing IMenuActionOptions.args and relying on arg + shouldForwardArgs.
  • Updates the chat editing widget button bar to set buttonBar.context (session metadata) and forward it to actions.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

File Description
src/vs/workbench/contrib/chat/browser/widget/input/chatInputPart.ts Sets up MenuWorkbenchButtonBar with shouldForwardArgs and assigns buttonBar.context to session metadata.
src/vs/platform/actions/common/actions.ts Removes IMenuActionOptions.args and updates MenuItemAction.run to only use arg + forwarded args.
src/vs/platform/actions/browser/buttonbar.ts Passes this.context into ActionRunner.run and into overflow context menu execution context.
src/vs/base/browser/ui/button/button.ts Adds context getter/setter to the base ButtonBar.

Comment on lines +577 to +583
private _context: unknown;

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

set context(context: unknown) {
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.
@jrieken
Copy link
Member

jrieken commented Feb 4, 2026

Thanks. Agree, the changes in action.ts are bad most go out asap. Tho, IMO context is an anti-pattern (which is unfortunately wide-spread) because it means actions work different when clicked (from the button/tool bar) vs when invoked via keybinding. For the latter case actions already need to be able to discover/lookup their context and that logic should also work when a button is clicked

@lszomoru
Copy link
Member Author

lszomoru commented Feb 4, 2026

@jrieken, closing the PR as discussed.

@lszomoru lszomoru closed this Feb 4, 2026
auto-merge was automatically disabled February 4, 2026 10:50

Pull request was closed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants