Skip to content

feat: choose the initial session mode with ZCODE_ACP_MODE - #189

Closed
jbellis wants to merge 2 commits into
william0wang:mainfrom
BrokkAi:feat/initial-mode
Closed

jbellis wants to merge 2 commits into
william0wang:mainfrom
BrokkAi:feat/initial-mode

Conversation

@jbellis

@jbellis jbellis commented Sep 14, 2026

Copy link
Copy Markdown
Contributor

Problem

session/create hardcodes mode: "yolo", so every new session starts unrestricted. There is no way to start a session in plan or build without switching after the fact.

Change

ZCODE_ACP_MODE supplies the create-time mode. Unset still means yolo, and the mode dropdown keeps switching modes per session. Values are the backend's own mode ids. The README documents the variable.

Tests

tests/session-lazy.test.ts asserts the default stays yolo and that the variable overrides it.

🤖 Generated with Claude Code

https://claude.ai/code/session_01DLQ3W2owia4SJBvzxSqvVc

session/create hardcoded `mode: "yolo"`, so every new session started
unrestricted with no way to start it in `plan` or `build` instead.

`ZCODE_ACP_MODE` now supplies the create-time mode. It is opt-in: unset
still means `yolo`, and the mode dropdown switches modes per session as
before. Values are the backend's own mode ids.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DLQ3W2owia4SJBvzxSqvVc

@william0wang william0wang left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Reviewed (typecheck pass; session-lazy tests 35/35; invalid modes are rejected by the backend with a clear error and resume never clobbers the stored session's mode — both verified).

One small blocking inconsistency: the create-time mode isn't reflected in the session/new response. buildModes() (src/config/options.ts:230-246) returns a hardcoded currentModeId: "yolo" for pending sessions (zcodeSid === null), so a client is told the session is in yolo while it was actually created in ZCODE_ACP_MODE — the stale value stands until the first materialized mode read. Please thread the create-time mode through the pending branch (e.g. seed server.lastMode at create, or pass the env mode as buildModes' pending default).

Review follow-up: buildModes hardcoded currentModeId "yolo" for pending
sessions, so a client was told "yolo" while the session was actually
created in ZCODE_ACP_MODE — the stale value stood until the first
materialized mode read, and the mode configOption's currentValue had the
same staleness.

The create-time mode now lives in one helper, initialSessionMode(), used
by the session/create call, buildModes' pending branch, and
buildConfigOptions' pending branch. lastMode seeding at session/new
follows automatically (it reads buildModes' output). The existing
ZCODE_ACP_MODE test now also asserts the response's currentModeId and
mode currentValue.
@jbellis

jbellis commented Sep 15, 2026

Copy link
Copy Markdown
Contributor Author

Thanks! Addressed in 37e8565 — the create-time mode now lives in a single helper (initialSessionMode() in options.ts) used by the session/create call, buildModes' pending branch, and buildConfigOptions' pending mode currentValue, so session/new advertises the mode the create will actually use (both places had the stale hardcoded value). The lastMode seeding at create follows automatically since it reads buildModes' output.

The existing ZCODE_ACP_MODE test now also asserts the response's currentModeId and the mode configOption's currentValue.

@william0wang

Copy link
Copy Markdown
Owner

Verified the fix: typecheck clean, targeted suites green (41/41) — initialSessionMode() as the single source for both the create call and the pending-session advertisement is exactly right.

Same housekeeping as #188: #187's README table reformat leaves this branch conflicting on README.md only (re-insert the ZCODE_ACP_MODE row into the reformatted table). Rebase onto main and I'll merge immediately.

william0wang pushed a commit that referenced this pull request Sep 16, 2026
## Problem

`session/create` hardcodes `mode: "yolo"`, so every new session starts unrestricted. There is no way to start a session in `plan` or `build` without switching after the fact.

## Change

`ZCODE_ACP_MODE` supplies the create-time mode. Unset still means `yolo`, and the mode dropdown keeps switching modes per session. Values are the backend's own mode ids. The README documents the variable.

## Tests

`tests/session-lazy.test.ts` asserts the default stays `yolo` and that the variable overrides it.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

https://claude.ai/code/session_01DLQ3W2owia4SJBvzxSqvVc
@william0wang

Copy link
Copy Markdown
Owner

Landing this directly on main as a1aa2e0 (squash, authorship preserved) for the same reason as #188 — identical content to your branch head, with initialSessionMode() as the single source for create + advertisement. Verified: typecheck clean, full suite 1188/1188. Thanks!

william0wang pushed a commit that referenced this pull request Sep 16, 2026
🤖 I have created a release *beep* *boop*
---


## [0.39.0](v0.38.0...v0.39.0) (2026-09-16)


### Features

* choose the initial session mode with ZCODE_ACP_MODE ([#189](#189)) ([a1aa2e0](a1aa2e0))
* honor ZCODE_HOME for the config and lazy-session store paths ([#187](#187)) ([0593488](0593488))
* pin the provider and model with ZCODE_PROVIDER and ZCODE_MODEL ([#188](#188)) ([6aa8999](6aa8999))

---
This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please).
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.

2 participants