Conversation
📬 CODENOTIFYThe following users are being notified based on files changed in this PR: @jriekenMatched files:
|
There was a problem hiding this comment.
Pull request overview
Adds a new chat editing command for restoring to the most recent checkpoint and wires it into existing chat UX surfaces (tips + accessibility help).
Changes:
- Add
workbench.action.chat.restoreLastCheckpointaction to restore the current editing session back to the last checkpoint. - Ensure the “undo changes” tip is dismissed when the new restore command is used.
- Document the new command in chat accessibility help for edits/agent views.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
src/vs/workbench/contrib/chat/browser/chatTipService.ts |
Extends the undo-changes tip exclusion list to include the new restore-last-checkpoint command. |
src/vs/workbench/contrib/chat/browser/chatEditing/chatEditingActions.ts |
Registers a new Action2 command that restores the session to the last checkpoint. |
src/vs/workbench/contrib/chat/browser/actions/chatAccessibilityHelp.ts |
Adds the new command to the “helpful commands” list for accessibility help text. |
| precondition: ContextKeyExpr.and( | ||
| ChatContextKeys.inChatSession, | ||
| ContextKeyExpr.equals(`config.${ChatConfiguration.CheckpointsEnabled}`, true), | ||
| ChatContextKeys.lockedToCodingAgent.negate() | ||
| ) | ||
| }); | ||
| } | ||
|
|
||
| async run(accessor: ServicesAccessor, ...args: unknown[]) { | ||
| let item = args[0] as ChatTreeItem | undefined; | ||
| const chatWidgetService = accessor.get(IChatWidgetService); | ||
| const chatService = accessor.get(IChatService); | ||
| const widget = (isChatTreeItem(item) && chatWidgetService.getWidgetBySessionResource(item.sessionResource)) || chatWidgetService.lastFocusedWidget; | ||
| if (!isResponseVM(item) && !isRequestVM(item)) { | ||
| item = widget?.getFocus(); | ||
| } | ||
|
|
||
| const sessionResource = widget?.viewModel?.sessionResource ?? (isChatTreeItem(item) ? item.sessionResource : undefined); | ||
| if (!sessionResource) { | ||
| return; | ||
| } | ||
|
|
||
| const chatModel = chatService.getSession(sessionResource); | ||
| if (!chatModel?.editingSession) { | ||
| return; | ||
| } |
There was a problem hiding this comment.
workbench.action.chat.restoreLastCheckpoint can become enabled in the chat widget even when there is no active editing session (e.g. Ask mode). In that case run returns early on !chatModel?.editingSession and the command becomes a no-op. Consider tightening the action precondition to only allow Edit/Agent sessions (e.g. require chatModeKind to be Edit/Agent) or provide user feedback when no editing session is available.
|
|
||
| const checkpointRequest = chatModel.checkpoint; | ||
| if (!checkpointRequest) { | ||
| alert(localize('chat.restoreCheckpoint.none', 'There is no checkpoint to restore.')); |
There was a problem hiding this comment.
The localization key 'chat.restoreCheckpoint.none' is introduced here but is used for the new “Restore to Last Checkpoint” action. Using a key/name that matches the command (e.g. chat.restoreLastCheckpoint.none) will make the string easier to find and maintain, and avoid confusion with the existing restore-checkpoint command.
| alert(localize('chat.restoreCheckpoint.none', 'There is no checkpoint to restore.')); | |
| alert(localize('chat.restoreLastCheckpoint.none', 'There is no checkpoint to restore.')); |
| registerAction2(class RestoreLastCheckpoint extends Action2 { | ||
| constructor() { | ||
| super({ | ||
| id: 'workbench.action.chat.restoreLastCheckpoint', | ||
| title: localize2('chat.restoreLastCheckpoint.label', "Restore to Last Checkpoint"), |
There was a problem hiding this comment.
Class name RestoreLastCheckpoint is inconsistent with the surrounding action classes in this file (e.g. RestoreCheckpointAction, RemoveAction, EditAction). Renaming to RestoreLastCheckpointAction would better match the established naming pattern for Action2 registrations.
cc @meganrogge
fixes #288433