feat(plan): wire editMode="plan" into the ToolRegistry dispatch gate#1681
Merged
Conversation
`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
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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/planslash command. PersistededitMode = "plan"(set via config edit or a settings UI that surfaces it) was previously inert — the registry's_planModestayedfalseacross boots, so the model could still callwrite_file/edit_file/multi_edit/run_command.This change extends
EditModeto 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.ts—EditModegains"plan";loadEditModeaccepts itsrc/code/setup.ts— newapplyPlanMode(tools, editMode)helper;buildCodeToolsetcalls it on init, threaded via newconfigPathoption so tests can pin a tmp configsrc/cli/commands/desktop.ts— callsapplyPlanModeinemitSettings,buildRuntimeFor, and thesettings_saveeditMode branch so changes take effect livetests/code-setup-lazy-subagent.test.ts— regression:editMode: "plan"in config blockswrite_filedispatch with theunavailable in plan modeerrorSupersedes #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 --noEmitnpx 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)