Skip to content

refactor: Copilot CLI simplify preselectModelFromSessionHistory#304378

Merged
DonJayamanne merged 1 commit intomainfrom
don/involved-kangaroo
Mar 24, 2026
Merged

refactor: Copilot CLI simplify preselectModelFromSessionHistory#304378
DonJayamanne merged 1 commit intomainfrom
don/involved-kangaroo

Conversation

@DonJayamanne
Copy link
Contributor

No description provided.

Copilot AI review requested due to automatic review settings March 24, 2026 07:30
@DonJayamanne DonJayamanne self-assigned this Mar 24, 2026
@DonJayamanne DonJayamanne marked this pull request as ready for review March 24, 2026 07:31
@DonJayamanne DonJayamanne enabled auto-merge (squash) March 24, 2026 07:31
@vs-code-engineering vs-code-engineering bot added this to the 1.114.0 milestone Mar 24, 2026
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 with findLast(...).
  • Removes the session-type gate that previously limited when history-based model/mode preselection runs.

Comment on lines 1179 to 1183
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;
}
Copy link

Copilot AI Mar 24, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot uses AI. Check for mistakes.
@DonJayamanne DonJayamanne merged commit d1c2013 into main Mar 24, 2026
23 checks passed
@DonJayamanne DonJayamanne deleted the don/involved-kangaroo branch March 24, 2026 07:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants