Agents - add open file/open changes actions#311648
Conversation
There was a problem hiding this comment.
Pull request overview
Adds “Open File” / “Open Changes” actions intended to improve navigation from the Agents/Sessions changes UI, and adjusts command ordering in the Copilot menu contribution.
Changes:
- Register new
Open FileandOpen Changesactions for session change entries. - Implement editor-opening logic for selected change resources.
- Reorder
github.copilot.sessions.discardChangeswithin the per-change toolbar menu.
Show a summary per file
| File | Description |
|---|---|
| src/vs/sessions/contrib/changes/browser/changesViewActions.ts | Adds new Actions (OpenFileAction, OpenChangesAction) and wires them into a chat editing session changes menu. |
| extensions/copilot/package.json | Adjusts group ordering for github.copilot.sessions.discardChanges under chat/input/editing/sessionChangeToolbar. |
Copilot's findings
Comments suppressed due to low confidence (3)
src/vs/sessions/contrib/changes/browser/changesViewActions.ts:230
OpenFileAction.runcurrently opens the rawresourceURIs. In this view, the selection URI can beGitDiffChange.uri(working-tree path) even when the change represents a deletion, where the file may not exist. Consider looking up the matching change (asOpenChangesActiondoes) and openingchange.modifiedUri ?? change.uri ?? change.originalUri(and specificallyoriginalUrifor deletions) so the command works for added/deleted files too.
async run(accessor: ServicesAccessor, _sessionResource: URI, _ref: string, ...resources: URI[]): Promise<void> {
const editorService = accessor.get(IEditorService);
await Promise.all(resources.map(resource => editorService.openEditor({ resource })));
}
src/vs/sessions/contrib/changes/browser/changesViewActions.ts:257
- The change lookup in
OpenChangesActionusesisEqual(change.modifiedUri ?? change.originalUri, resource), but forIChatSessionFileChange2the selectable URI is typicallychange.uri(workspace path) whileoriginalUri/modifiedUriare oftengit:URIs with refs (seetoIChatSessionFileChange2). This means the action won’t find a matching change for many entries. Match onfsPath(or includechange.uriin the comparison) similar to other session-change matching code.
for (const resource of resources) {
const change = changes?.find(change =>
isEqual(change.modifiedUri ?? change.originalUri, resource));
src/vs/sessions/contrib/changes/browser/changesViewActions.ts:265
OpenChangesActionalways callseditorService.openEditor({ original: { resource: change.originalUri }, modified: { resource: change.modifiedUri } })even thoughoriginalUriormodifiedUrican beundefinedfor added/deleted changes (and forIChatSessionFileChange2they’re optional). This can end up opening an unintended untitled editor or failing to open the diff. Handle the add/delete cases explicitly (open single editor when one side is missing) or reuse the existing open logic fromChangesViewPane._openFileItem/openChanges().
await editorService.openEditor({
original: { resource: change.originalUri },
modified: { resource: change.modifiedUri },
});
- Files reviewed: 2/2 changed files
- Comments generated: 2
| menu: { | ||
| id: MenuId.ChatEditingSessionChangesToolbar, | ||
| group: 'navigation', | ||
| order: 1, | ||
| when: IsSessionsWindowContext, | ||
| alt: { |
There was a problem hiding this comment.
OpenFileAction is contributed to MenuId.ChatEditingSessionChangesToolbar (session-level toolbar), but its run expects arguments shaped like ChangesViewActionRunner provides (sessionResource, discardRef, ...selected URIs). The session changes toolbar is invoked with args [sessionResource, metadata] (no selected resources), so this action will effectively be a no-op there. This looks like it should be contributed to MenuId.ChatEditingSessionChangeToolbar (per-change row toolbar) instead, consistent with the related chat/input/editing/sessionChangeToolbar menu contribution in extensions/copilot/package.json.
This issue also appears in the following locations of the same file:
- line 227
- line 254
- line 262
| { | ||
| "command": "github.copilot.sessions.discardChanges", | ||
| "when": "chatSessionType == copilotcli && isSessionsWindow && sessions.hasGitRepository && sessions.changesVersionMode == branchChanges", | ||
| "group": "navigation@1" | ||
| "group": "navigation@2" | ||
| } |
There was a problem hiding this comment.
This menu contribution change reorders github.copilot.sessions.discardChanges within chat/input/editing/sessionChangeToolbar (per-change toolbar). However, the new core actions in this PR are currently contributed to MenuId.ChatEditingSessionChangesToolbar (session-level toolbar) instead of MenuId.ChatEditingSessionChangeToolbar, so the intended ordering change may not take effect as expected. Either move the new actions to the ...sessionChangeToolbar menu or revert/adjust this group change accordingly.
See below for a potential fix:
"when": "chatSessionType == copilotcli && isSessionsWindow && sessions.hasGitRepository && sessions.changesVersionMode == branchChanges"
No description provided.