Skip to content

fix(vscode): reliable cancel and preserved session model on attach#1845

Merged
wbxl2000 merged 1 commit into
mainfrom
qer/vscode-cancel-model-fix
Jul 17, 2026
Merged

fix(vscode): reliable cancel and preserved session model on attach#1845
wbxl2000 merged 1 commit into
mainfrom
qer/vscode-cancel-model-fix

Conversation

@wbxl2000

Copy link
Copy Markdown
Collaborator

Related Issue

No issue — the problem is explained in the next section (reported by extension users in feedback).

Problem

Two reported correctness problems in the VS Code extension (split out of #1839 to land the bug fixes promptly; the conversation-undo feature stays in that PR):

  1. "Stop" sometimes does nothing. SessionRuntime.cancel() returned early whenever the host-side bookkeeping showed no active work. After an abnormal error path, host and engine state can drift apart — the UI shows a running turn while the host thinks the session is idle, so Stop silently never reaches the engine. Additionally abortChat returned { aborted: true } even when no runtime existed, so the UI claimed the task was stopped while nothing was cancelled.
  2. Resumed sessions get their model overwritten. Opening or resuming a session force-applied the globally configured default model, stomping a model the user had picked for that session (e.g. via the CLI over the shared session storage). Thinking effort had the same bug and was fixed earlier; model is the symmetric case.

What changed

  • Cancel is unconditional (session-runtime.ts): the early return only skips when the runtime is closed — session.cancel() is always invoked (a harmless no-op when the engine is idle), so Stop always converges the engine and the UI even if host bookkeeping drifted. abortChat returns aborted: false when the view has no runtime instead of pretending.
  • Session model is preserved on attach (kimi-runtime.ts): the configured default model is only applied at session creation, matching the thinking-effort fix and CLI/TUI resume semantics.
  • Composer-submitted model/effort is applied before the turn starts (chat.handler.ts): since attach no longer syncs modes, the streamChat preflight applies the model/effort sent with the prompt (previously a picker change followed immediately by Send could race onto the old model). resume-vs-prompt semantics stay distinct: reopening preserves the session's modes, sending applies what the composer shows.

Tests: idle-cancel still reaching the engine, abortChat honesty at the bridge boundary, preserved-model on resume, and an end-to-end integration test that submits a different model/effort with a prompt and asserts the session adopts them.

Checklist

  • I have read the CONTRIBUTING document.
  • I have linked a related issue, or explained the problem above.
  • I have added tests that prove my feature works.
  • Ran gen-changesets skill, or this PR needs no changeset. (No changeset: vscode-extension-only change, nothing enters the CLI bundle.)
  • Ran gen-docs skill, or this PR needs no doc update. (Extension behavior fix; no user-facing docs affected.)

@changeset-bot

changeset-bot Bot commented Jul 17, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: 5381933

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@pkg-pr-new

pkg-pr-new Bot commented Jul 17, 2026

Copy link
Copy Markdown
pnpm dlx https://pkg.pr.new/@moonshot-ai/kimi-code@5381933
npx https://pkg.pr.new/@moonshot-ai/kimi-code@5381933

commit: 5381933

@wbxl2000
wbxl2000 merged commit 18d3374 into main Jul 17, 2026
15 checks passed
@wbxl2000
wbxl2000 deleted the qer/vscode-cancel-model-fix branch July 17, 2026 11:55
@wbxl2000 wbxl2000 mentioned this pull request Jul 17, 2026
5 tasks
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.

1 participant