Skip to content

fix: resolve planMode from the agent's preset isolate - #2

Closed
sujalmandal wants to merge 1 commit into
eightHundreds:mainfrom
sujalmandal:fix/plan-mode-preset-isolate
Closed

sujalmandal wants to merge 1 commit into
eightHundreds:mainfrom
sujalmandal:fix/plan-mode-preset-isolate

Conversation

@sujalmandal

Copy link
Copy Markdown

Summary

dsh-plannotator never intercepts exit_plan_mode on dsh web, so the native plan-review card always runs and the plannotator UI is never reached. Two independent reads in lib/plan.js are both dead on current DSH; this fixes both.

1. resolvePlanMode cannot see the service on dsh web

const fromAgent = asPlanModeService(agent?.ctx?.get?.('planMode'))
if (fromAgent) return fromAgent
return asPlanModeService(ctx.get('planMode'))

Both lookups miss. Plan mode is published per preset, inside a group carrying isolate: {planMode: true} (upstream-standard, present since the earliest DSH releases — @deepseek-ai/dsh-web-app/presets/{standard,ptc,cordis}.patch.yml:42-48), which keys the service under a private realm symbol. The host-plane plan-mode row is disabled: true (dsh-web-app/cordis.patch.yml), so the profile-root lookup returns nothing either. This is not a custom-setup problem — a stock dsh web profile behaves the same way.

Resolve it through the registry accessor instead, which is a public Service method and is registered at profile root:

ctx.get('agentPresets').serviceFor(agent, 'planMode')

2. The session.events fallback no longer exists

isPlanModeActive read agent.session?.events ?? []. @deepseek-ai/dsh-session had

get events() { this.eventsSnapshot ??= Object.freeze([...this.log]); return this.eventsSnapshot }

at lib/index.js:1397-1400 through 0.1.2-alpha.2, and removed it in 0.1.2-rc.1 (2026-09-03), replacing it with snapshotEvents(). Because the access is optional-chained, the removal did not throw — it degraded to [], isPlanModeActive returned false, and the intercept was skipped silently. 0.2.0 shipped 2026-08-18, so this rotted ~2 weeks after release.

Read snapshotEvents() and keep accepting the old session.events shape so pre-0.1.2-rc.1 hosts still work.

3. The test suite hid the regression

tests/plan.test.js mocked session: { events: [...] } — the shape that had already been deleted. The suite stayed green while production was broken. Updated to snapshotEvents().

The resolvePlanMode precedence test also predates the isolate: it asserts "agent context, then ctx.get", which on dsh web are exactly the two paths that miss. New precedence is preset isolate → agent context → profile root.

Testing

node --test — 53 pass, 0 fail (node v24.21.0).

Direct probe of the fixed module against the three shapes:

case result
agentPresets.serviceFor(agent, 'planMode') present service found, intercept fires
session.snapshotEvents() only isPlanModeActive → true
legacy session.events only isPlanModeActive → true
no session false, no throw
no agentPresets service undefined, no throw

Notes

Kept as one commit / one concern. Separately, issue #1 (feedback injection rejected because source.kind is 'plugin') is unrelated to this path and unfixed here — the V4 validator requires a producer-owned kind, so kind: 'plugin:plannotator' is the correct shape per dsh-session-format-v3-to-v4/lib/index.js:87-107.

`resolvePlanMode` only looked at `agent.ctx.get('planMode')` and the
profile-root `ctx.get('planMode')`. On `dsh web` both miss: the
model-facing plan-mode service is published per preset inside a group
carrying `isolate: {planMode: true}`, while the host-plane row is
disabled. The intercept therefore never fired and the native
plan-review card always ran.

The `agent.session?.events` fallback that used to carry the check is
also gone: `@deepseek-ai/dsh-session` removed `get events()` in
0.1.2-rc.1 and replaced it with `snapshotEvents()`. Because the read
was optional-chained, it degraded to `[]` and disabled the plugin
silently instead of throwing.

- read the preset-scoped service through
  `ctx.get('agentPresets').serviceFor(agent, 'planMode')`, the public
  registry accessor, ahead of the two context lookups
- read the session log through `snapshotEvents()` and keep accepting
  the old `session.events` shape for pre-0.1.2-rc.1 hosts
- update `tests/plan.test.js`, which still mocked the removed
  `session.events` property and so kept CI green over the regression
@sujalmandal sujalmandal closed this Oct 6, 2026
@sujalmandal
sujalmandal deleted the fix/plan-mode-preset-isolate branch October 6, 2026 10:20
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