-
Notifications
You must be signed in to change notification settings - Fork 37.7k
ButtonBar - add support to set the context for the widget #292661
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this 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
contextproperty onButtonBarand forwards it when running actions / showing overflow menus inWorkbenchButtonBar. - Simplifies menu action argument plumbing by removing
IMenuActionOptions.argsand relying onarg+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. |
| private _context: unknown; | ||
|
|
||
| get context(): unknown { | ||
| return this._context; | ||
| } | ||
|
|
||
| set context(context: unknown) { |
Copilot
AI
Feb 3, 2026
There was a problem hiding this comment.
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.
| 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) { |
|
Thanks. Agree, the changes in |
|
@jrieken, closing the PR as discussed. |
Pull request was closed
action.tsmade in Pass metadata to agent session commands #291554 as those did not feel rightcontextfor the ButtonBar widget matching the implementation of the ActionBar