Skip to content

fix(tui): skip re-entering plan mode on resume and scope startup flags to startup#692

Merged
liruifengv merged 1 commit into
mainfrom
fix/resume-plan-mode-startup-flags
Jun 12, 2026
Merged

fix(tui): skip re-entering plan mode on resume and scope startup flags to startup#692
liruifengv merged 1 commit into
mainfrom
fix/resume-plan-mode-startup-flags

Conversation

@liruifengv

Copy link
Copy Markdown
Collaborator

Related Issue

N/A — follow-up to #683.

Problem

Two issues with how #683 applies --auto/--yolo/--plan to resumed sessions:

  1. Resuming a session that was already in plan mode with --plan crashed at startup with error: Internal error / Already in plan mode. Session replay restores the active plan state, and the resume path then called setPlanMode(true) unconditionally; PlanMode.enter() throws when plan mode is already active.
  2. The /sessions picker shares mountSessionPicker with the startup picker, so the startup flags were also re-applied on every mid-session switch, overriding the picked session's own persisted modes (e.g. plan mode toggled off interactively got forced back on).

What changed

  • Extracted applyStartupModesToResumedSession(): applies --auto/--yolo (idempotent on the core side), and for --plan checks getStatus().planMode first, only calling setPlanMode(true) when plan mode is not active yet. This follows the existing guard-before-enter pattern (EnterPlanModeTool checks planMode.isActive; /new passes planMode via createSession). Used by both the resume startup path and the startup picker.
  • mountSessionPicker now takes an options object with an applyStartupModes switch: only the startup picker (bare --session) enables it; /sessions switches keep the picked session's own persisted modes, with the footer synced from getStatus().
  • The picker's onSelect promise chain now surfaces post-switch setup failures via showError instead of leaving them as unhandled rejections.
  • Other mode setters were audited: setPermission and setModel are idempotent and need no guard.

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.
  • Ran gen-docs skill, or this PR needs no doc update.

…s to startup

Resuming a session that was already in plan mode with --plan crashed with
"Already in plan mode": the resume path called setPlanMode(true)
unconditionally while session replay had already restored the active plan
state. Check the session status first and only enable plan mode when it is
not active yet, in both the resume startup path and the startup session
picker.

The /sessions picker shared the same onSelect callback, so startup flags
were also re-applied on every mid-session switch, overriding the picked
session's own persisted modes. Gate the flag application behind an
applyStartupModes option that only the startup picker enables, and surface
post-switch setup errors instead of leaving them as unhandled rejections.
@changeset-bot

changeset-bot Bot commented Jun 12, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 85b10e5

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@moonshot-ai/kimi-code Patch

Not sure what this means? Click here to learn what changesets are.

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

@pkg-pr-new

pkg-pr-new Bot commented Jun 12, 2026

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

commit: 85b10e5

@liruifengv liruifengv merged commit 7ca9bdf into main Jun 12, 2026
9 checks passed
@liruifengv liruifengv deleted the fix/resume-plan-mode-startup-flags branch June 12, 2026 09:41
@github-actions github-actions Bot mentioned this pull request Jun 12, 2026
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