Preserve session target when using Send to New Chat#295185
Conversation
When clicking the "Send to New Chat" tip or using the Ctrl+Shift+Enter shortcut, the Session Target (e.g., Claude, Background, Cloud) was resetting to Local because widget.clear() always creates a new local session. Now the SendToNewChatAction checks the current session type and, for non-local sessions in the sidebar, calls view.loadSession() with a new resource of the same type instead of widget.clear(). This follows the same pattern already used by the New Chat action (chatNewActions.ts). Co-authored-by: meganrogge <29464607+meganrogge@users.noreply.github.com>
|
@copilot should we share code between this and the newChatAction so it's not redundant? |
Extracted the session-type-preservation logic into a shared clearChatSessionPreservingType function in chatActions.ts, used by both SendToNewChatAction and runNewChatAction to avoid duplication. Co-authored-by: meganrogge <29464607+meganrogge@users.noreply.github.com>
Extracted the shared logic into |
There was a problem hiding this comment.
Pull request overview
This pull request fixes an issue where the "Send to New Chat" action and the "Create new session" tip were resetting the Session Target to Local instead of preserving the user's selected session type (e.g., Claude, Cloud, Background).
Changes:
- Extracted a shared helper function
clearChatSessionPreservingType()to avoid code duplication betweenSendToNewChatActionandrunNewChatAction - Updated both actions to use the new helper, ensuring session type is preserved when creating new chat sessions
- Removed the now-unused
getResourceForNewChatSession()helper fromchatNewActions.ts
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| src/vs/workbench/contrib/chat/browser/actions/chatActions.ts | Added the new shared clearChatSessionPreservingType() helper function and necessary imports |
| src/vs/workbench/contrib/chat/browser/actions/chatNewActions.ts | Removed duplicated logic and unused helper, now uses shared clearChatSessionPreservingType() |
| src/vs/workbench/contrib/chat/browser/actions/chatExecuteActions.ts | Updated SendToNewChatAction to use shared clearChatSessionPreservingType() helper |
SendToNewChatActionalways callswidget.clear()which creates a local sessionSendToNewChatActionclearChatSessionPreservingTypehelper used by bothSendToNewChatActionandrunNewChatActionto avoid code duplication (per reviewer feedback)Original prompt
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.