Skip to content

fix(vscode): preserve mode on first send - #12009

Merged
marius-kilocode merged 1 commit into
mainfrom
fix/vscode-first-send-agent-scope
Jul 7, 2026
Merged

fix(vscode): preserve mode on first send#12009
marius-kilocode merged 1 commit into
mainfrom
fix/vscode-first-send-agent-scope

Conversation

@marius-kilocode

Copy link
Copy Markdown
Collaborator

When the VS Code webview starts a new task, the mode and model selectors operate before the first backend session exists. The draft-id recovery change made first sends allocate a draft UUID before resolving the agent, which meant the model still came from the visible pending mode while the agent lookup fell back to the default mode for the new draft scope. That could run Plan with Code instructions, or Code with Ask instructions when Ask is configured as the default.

This preserves the pending mode by seeding the generated draft scope with the pending agent before resolving the first send agent and variant. When the backend creates the real session, the seeded draft selection is migrated normally and the pending selection is cleared. Existing draft scopes, including Agent Manager pending scopes, are not overwritten.

Fixes #11967
Related to #11974

Comment thread packages/kilo-vscode/webview-ui/src/context/session.tsx Outdated
Comment thread packages/kilo-vscode/webview-ui/src/context/session.tsx Outdated
@kilo-code-bot

kilo-code-bot Bot commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

Code Review Summary

Status: No Issues Found | Recommendation: Merge

Both previously reported WARNINGs remain resolved. The only change since the last review is a pure Prettier reformat of the drop: arrow function in session.tsx (wrapping it across multiple lines) — no logic change.

Files Reviewed (5 files)
  • .changeset/vscode-first-send-agent-scope.md
  • packages/kilo-vscode/tests/unit/prompt-send-contract.test.ts
  • packages/kilo-vscode/tests/unit/session-agent.test.ts
  • packages/kilo-vscode/webview-ui/src/context/session-agent.ts
  • packages/kilo-vscode/webview-ui/src/context/session.tsx
Previous Review Summaries (2 snapshots, latest commit 5d5c03f)

Current summary above is authoritative. Previous snapshots are kept for context only.

Previous review (commit 5d5c03f)

Status: No Issues Found | Recommendation: Merge

Both previously reported WARNINGs are resolved in this update. seedDraftAgent/seededDrafts were replaced with a createDraftAgentSeed helper (session-agent.ts) that: (1) no longer nulls the global pendingAgentSelection signal on session-created migration, avoiding the clobber of a different pending draft's mode; and (2) adds explicit agentDrafts.prune() calls at every draft-abandoning site (createSession, clearCurrentSession, selectSession, selectCloudSession, and the failed-send handler), guarded by an active() check against submissionMap so in-flight retries are preserved. New unit tests in session-agent.test.ts and prompt-send-contract.test.ts cover the seed/promote/prune behavior directly.

Files Reviewed (4 files)
  • packages/kilo-vscode/tests/unit/prompt-send-contract.test.ts
  • packages/kilo-vscode/tests/unit/session-agent.test.ts
  • packages/kilo-vscode/webview-ui/src/context/session-agent.ts
  • packages/kilo-vscode/webview-ui/src/context/session.tsx

Previous review (commit d6fac4a)

Status: 2 Issues Found | Recommendation: Address before merge

Overview

Severity Count
CRITICAL 0
WARNING 2
SUGGESTION 0
Issue Details (click to expand)

WARNING

File Line Issue
packages/kilo-vscode/webview-ui/src/context/session.tsx 1332 Nulling the global pendingAgentSelection on migration can clobber a different, still-pending draft's mode selection if the user starts a new task before the seeded draft's session-created event arrives
packages/kilo-vscode/webview-ui/src/context/session.tsx 566 seededDrafts and the seeded agentSelections[draftID] entry are never cleaned up when the first send fails, leaking one entry per failed send
Files Reviewed (5 files)
  • .changeset/vscode-first-send-agent-scope.md
  • packages/kilo-vscode/tests/unit/prompt-send-contract.test.ts
  • packages/kilo-vscode/tests/unit/session-agent.test.ts
  • packages/kilo-vscode/webview-ui/src/context/session-agent.ts
  • packages/kilo-vscode/webview-ui/src/context/session.tsx - 2 issues

Fix these issues in Kilo Cloud


Reviewed by claude-sonnet-5 · Input: 24 · Output: 3.9K · Cached: 446K

Review guidance: REVIEW.md from base branch main

@johnnyeric

Copy link
Copy Markdown
Contributor

Validated in latest main that the agent goes direct to implement as it was in code mode.
image

Validated in this PR branch that the agent creates the plan correctly since it is in plan mode.
image

@marius-kilocode
marius-kilocode force-pushed the fix/vscode-first-send-agent-scope branch from d6fac4a to 38ec57c Compare July 7, 2026 13:58
@marius-kilocode
marius-kilocode force-pushed the fix/vscode-first-send-agent-scope branch from 38ec57c to 5d5c03f Compare July 7, 2026 14:05
@marius-kilocode
marius-kilocode enabled auto-merge July 7, 2026 14:53
@marius-kilocode
marius-kilocode force-pushed the fix/vscode-first-send-agent-scope branch from 5d5c03f to 130b256 Compare July 7, 2026 14:55
@marius-kilocode
marius-kilocode merged commit cc37a99 into main Jul 7, 2026
20 of 21 checks passed
@marius-kilocode
marius-kilocode deleted the fix/vscode-first-send-agent-scope branch July 7, 2026 14:59
marius-kilocode added a commit to mjnaderi/kilocode that referenced this pull request Jul 7, 2026
Revert the stylistic `const fresh` introduced by Kilo-Org#12009 to the inline
ternary at both send sites so session.tsx drops back under the 3000-line
max-lines lint cap (3001 -> 2999). The draft-agent seeding contract is
preserved: a draftID is minted when there is no session, and the pending
agent is seeded before promptAgent(scope) resolves.

Update the two prompt-send-contract assertions to the compacted shape.
marius-kilocode added a commit that referenced this pull request Jul 7, 2026
* fix(vscode): handle multiline bidi prompt input

* fix(vscode): resolve pending prompt arrow snaps

* fix(vscode): compact session draft-agent seeding under max-lines

Revert the stylistic `const fresh` introduced by #12009 to the inline
ternary at both send sites so session.tsx drops back under the 3000-line
max-lines lint cap (3001 -> 2999). The draft-agent seeding contract is
preserved: a draftID is minted when there is no session, and the pending
agent is seeded before promptAgent(scope) resolves.

Update the two prompt-send-contract assertions to the compacted shape.

---------

Co-authored-by: Marius <marius@kilocode.ai>
t7tran pushed a commit to t7tran/kilocode that referenced this pull request Aug 14, 2026
…-agent-scope

fix(vscode): preserve mode on first send
t7tran pushed a commit to t7tran/kilocode that referenced this pull request Aug 14, 2026
* fix(vscode): handle multiline bidi prompt input

* fix(vscode): resolve pending prompt arrow snaps

* fix(vscode): compact session draft-agent seeding under max-lines

Revert the stylistic `const fresh` introduced by Kilo-Org#12009 to the inline
ternary at both send sites so session.tsx drops back under the 3000-line
max-lines lint cap (3001 -> 2999). The draft-agent seeding contract is
preserved: a draftID is minted when there is no session, and the pending
agent is seeded before promptAgent(scope) resolves.

Update the two prompt-send-contract assertions to the compacted shape.

---------

Co-authored-by: Marius <marius@kilocode.ai>
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.

Plan Agent behaves like Code Agent and ignores rules.md in latest version.

2 participants