Skip to content

feat(plan): wire editMode="plan" into the ToolRegistry dispatch gate#1681

Merged
esengine merged 1 commit into
mainfrom
feat/plan-mode-dispatch-gate
May 24, 2026
Merged

feat(plan): wire editMode="plan" into the ToolRegistry dispatch gate#1681
esengine merged 1 commit into
mainfrom
feat/plan-mode-dispatch-gate

Conversation

@esengine

Copy link
Copy Markdown
Owner

Summary

ToolRegistry.setPlanMode(true) (src/tools.ts:86) already blocks every non-readonly tool at dispatch, but the only path that ever turned it on was the /plan slash command. Persisted editMode = "plan" (set via config edit or a settings UI that surfaces it) was previously inert — the registry's _planMode stayed false across boots, so the model could still call write_file / edit_file / multi_edit / run_command.

This change extends EditMode to include "plan" and mirrors the loaded mode into the registry whenever a toolset is constructed or the user toggles edit mode. Minimal foundation; the discoverability surface (settings UI / Shift+Tab cycle / i18n) can land separately when needed.

Changes

  • src/config.tsEditMode gains "plan"; loadEditMode accepts it
  • src/code/setup.ts — new applyPlanMode(tools, editMode) helper; buildCodeToolset calls it on init, threaded via new configPath option so tests can pin a tmp config
  • src/cli/commands/desktop.ts — calls applyPlanMode in emitSettings, buildRuntimeFor, and the settings_save editMode branch so changes take effect live
  • tests/code-setup-lazy-subagent.test.ts — regression: editMode: "plan" in config blocks write_file dispatch with the unavailable in plan mode error

Supersedes #1668

That PR opened before #1657 (preset abstraction drop) and ended up CONFLICTING + bundling 29 files / +445 lines including stale preset-cleanup that was already done on main and a UI surface (4-stop edit-mode cycle, composer button, 3-locale i18n) that's a larger design decision. Took the genuinely valuable core (dispatch-gate wiring + regression test) and shipped it standalone; co-authored credit preserved.

Test plan

  • npx tsc --noEmit
  • npx vitest run tests/code-setup-lazy-subagent.test.ts tests/config.test.ts — 88 passed / 1 skipped (new case proves the gate engages on config-set plan mode)

`ToolRegistry.setPlanMode(true)` (src/tools.ts:86) already blocks every
non-readonly tool at dispatch — but the only path that ever turned it
on was the `/plan` slash command. Persisted `editMode = "plan"` (set via
config edit or a settings UI that surfaces it) was previously inert:
the registry's `_planMode` stayed false across boots, so the model
could still call `write_file` etc.

Extend `EditMode` to include "plan", and have `buildCodeToolset` mirror
the loaded mode into the registry on construction. Desktop host calls
the new `applyPlanMode` helper in three places: on `emitSettings`, on
every `buildRuntimeFor`, and inside the `settings_save` handler when
the user toggles edit mode — so live changes take effect without a
rebuild. CLI's `/plan` slash continues to work as the direct toggle.

This is the minimal foundation needed before a settings UI in desktop
or dashboard can offer "plan" as a 4th edit-mode option.

Co-authored-by: T1anjiu <84212214+T1anjiu@users.noreply.github.com>
@esengine esengine merged commit 4068b9d into main May 24, 2026
3 checks passed
@esengine esengine deleted the feat/plan-mode-dispatch-gate branch May 24, 2026 11:33
esengine pushed a commit that referenced this pull request May 24, 2026
…moved, persisted usage stats, plan dispatch gate

Headline themes:
- Desktop: bundle the CLI-hosted React dashboard, retire Tauri+Preact duplicate (#1418)
- Config: drop preset abstraction; flash/pro are direct model selections (#1657, #1630)
- Stats: persist cumulative usage to session meta + auto-restore on startup (#1667, #1680, #1643, #1628)
- Plans: editMode="plan" enforced at the ToolRegistry dispatch gate (#1681); step advance fix (#1629)
- Context: fold once at turn start, drop pre-flight + byte-ceiling (#1642, #1646); collapsible compacted card (#1649)
- Subagents: per-skill flash/pro override + Settings UI (#1632)
- Desktop polish: sidebar drag-resize (#1688), responsive collapse (#1585), copy/edit overlay + msg-history nav (#1645), Esc closes modal not turn (#1685), QQ tab isolation (#1672), DiffCard for edits (#1662), theme-aware highlighting (#1655), system events toggle (#1654/#1650), macOS TCC inheritance (#1614), dashboard.enabled (#1612)
- Dashboard polish: persistent session URL (#1586, #1589, #1599), theme-aware highlighting (#1664), IME confirm-enter guard (#1689), code-fence lang fix (#1677), vendor chunk split (#1587), markdown table h-scroll (#1562)
- TUI: Alt+S input stash/recall; static history isolated from input rerenders (#1635); legacy mouse drop (#1637, #1648); multi-edit gated in review (#1647)
- Diff: SplitDiff column border holds under CJK (#1686)
- MCP: workspace roots passed to servers (#1625); codeCommand honors mcpServers (#1603)
- Config plumbing: (baseUrl, apiKey) resolved as a tuple (#1658); stale model id self-heal (#1663)

See CHANGELOG for the full list.
esengine added a commit that referenced this pull request May 24, 2026
…1699)

* fix(api): self-heal stale model id in settings GET

#1663 added `loadModel()` which maps unsupported model ids (e.g. v3
`deepseek-chat` / `deepseek-reasoner` left over in a user's config)
to `DEFAULT_MODEL` when no custom endpoint is set. The CLI uses it,
but the dashboard/desktop `/settings` GET endpoint still returned the
raw `cfg.model`, so users upgrading from a pre-v4 config saw their
desktop landing on the stale id and the model picker rendering it as
"custom" — looks like the app forgot which model it's on.

Route the GET through `loadModel(ctx.configPath)` so the same
self-heal applies on the wire. Custom-baseUrl users still keep their
custom ids unchanged (`loadModel` trusts non-empty `baseUrl`).

* feat(plan): expose plan as a 4th editMode in API + desktop + dashboard UIs

#1681 wired `editMode === "plan"` into the ToolRegistry dispatch gate
so plan mode is now a persisted state, not a slash-only toggle. The
desktop and dashboard surfaces never grew a control to set it though —
the settings API + edit-mode API still rejected "plan" with a 400, the
composer's ModeSwitch hardcoded review/auto/yolo, and the settings
page tri-state only listed the same three. Net: plan mode was
reachable from the CLI's `/plan` slash and direct config edits, but
not from either GUI surface.

Admit "plan" in both validation sets (`src/server/api/settings.ts`,
`src/server/api/edit-mode.ts`) and the `/mode` slash completer
(`src/cli/ui/slash/commands.ts`). Add a "plan" entry to MODE_INFO in
both composers with `I.list` and a planHint string. Add "plan" to the
settings page button maps. Extend the local `EditMode` string unions
in `desktop/src/{protocol,App,ui/composer}.tsx` and the dashboard
equivalents so TS accepts it everywhere.

i18n: add `editMode.plan` + `editMode.planHint` (and `planDesc` on
desktop) in both en + zh-CN for each surface.

---------

Co-authored-by: reasonix <reasonix@deepseek.com>
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