refactor: Copilot CLI simplify preselectModelFromSessionHistory#304378
refactor: Copilot CLI simplify preselectModelFromSessionHistory#304378DonJayamanne merged 1 commit intomainfrom
Conversation
There was a problem hiding this comment.
Pull request overview
Refactors ChatInputPart.preselectModelFromSessionHistory to simplify how the last-used modelId is discovered from a session’s request history.
Changes:
- Removes manual reverse-iteration for the last
modelId, replacing it withfindLast(...). - Removes the session-type gate that previously limited when history-based model/mode preselection runs.
| private preselectModelFromSessionHistory(): void { | ||
| const sessionResource = this._widget?.viewModel?.model.sessionResource; | ||
| const ctx = sessionResource ? this.chatService.getChatSessionFromInternalUri(sessionResource) : undefined; | ||
| const requiresCustomModels = ctx && this.chatSessionsService.requiresCustomModelsForSessionType(getChatSessionType(ctx.chatSessionResource)); | ||
| if (!requiresCustomModels) { | ||
| return; | ||
| } | ||
|
|
||
| const requests = this._widget?.viewModel?.model.getRequests(); | ||
| if (!requests || requests.length === 0) { | ||
| return; | ||
| } |
There was a problem hiding this comment.
The earlier requiresCustomModelsForSessionType guard was removed, so this method now restores mode/model for any session with request history. That changes behavior outside contributed sessions (e.g. normal chat sessions) and can override the globally persisted model/mode selection when switching sessions. If the intent is still to only restore for contributed sessions that opted into custom models, reintroduce the guard (ideally via const sessionType = this.getCurrentSessionType(); + chatSessionsService.requiresCustomModelsForSessionType(sessionType)), and return early otherwise.
No description provided.