Skip to content

feat(droid): run Orca's Plan mode as Droid Spec - #47845

Open
noter wants to merge 2 commits into
stablyai:mainfrom
codeious:ac/09-b1-droid-spec-mode
Open

noter wants to merge 2 commits into
stablyai:mainfrom
codeious:ac/09-b1-droid-spec-mode

Conversation

@noter

@noter noter commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

ELI5

Orca's Plan mode now works in Droid chats. Droid plans first (its "Spec" mode), shows the plan as Orca's plan card, and starts building only after you approve.

What Changed

Rebased onto main at 3d3d28c. It depends on #47843; until it merges, this diff also shows its commit. Review only this PR's commit f757b75af5.

  • Plan maps to Droid's spec autonomy level through a new dialect field planPermissionMode. Build returns to the level the chat ran at before Plan, and a permission picked during Plan waits for Build.
  • Droid's spec approval request (ExitSpecMode) shows as Orca's plan card ("Approve plan" / "Keep planning").
  • Approve answers with the option that keeps the chat's Build level: proceed_auto_run_<risk> for auto levels, proceed_once for Auto (Off). Keep planning answers cancel and stays in Spec.
  • The validated-plan store rule now covers Droid as well as Claude, so the Plan chip clears after approval.

Review fixes since the first push:

  • Plan/Build and permission picks are written to Droid one at a time, so a quick permission pick cannot land after Plan's switch to Spec and leave the chat in the wrong mode.

Why

Droid supports a spec-first flow over ACP, but Droid chats had no Plan mode, and approving a spec with the wrong option drops the chat to Auto (Off).

Linked Issue

Part of #37354

Visual Proof

In a scratch repo with calc.py holding only add: /plan ("Switch to Plan mode") turned on the Plan chip. "Add a subtract(a, b) function to calc.py." came back as a plan card with Approve plan / Keep planning. Keep planning kept Plan on and Droid revised the plan. Approve plan cleared the Plan chip, Droid added subtract with a docstring and checked it, and the permission picker read Full access afterwards.

  1. /plan in a Droid chat:

Slash menu offering /plan

  1. Droid's spec arrives as the plan card:

Plan card with Approve plan and Keep planning

  1. After Approve plan: Plan is off, Droid made the edit, and the composer is back in Build:

Approved plan and the resulting edit

Testing

Local macOS only.

  • ORCA_CODE_QUALITY_BASE=ac/07-b9-droid-model-list pnpm check:changed passed on this commit after the rebase (format, oxlint, typecheck, tests importing the change, selected ratchets).
  • Full unit suite (pnpm test --maxWorkers=6) on this branch: 1310 test files passed, 3 failed, 15 skipped. The failing files also fail on main at 3d3d28c on this machine: agent-cli-update-timeout (timing), bot-upcoming-copy (locale), worktree-removal-real-git (temp-dir cleanup).
  • Each added test was mutation-checked: reverting the production change it covers made it fail.
  • Golden E2E journeys ran on the previous stack tip (main at 59f3122): 8 passed, 4 skipped (Windows-only), and golden-fresh-profile-terminal failed the same way on main. Not rerun after the rebase.
  • Live check, before the rebase: dev build of the previous stack tip, launched hidden with ORCA_BACKGROUND_LAUNCH=1 and an isolated profile, driven over CDP at 1440x900, with a real Droid 1.17.2 login and model Claude Opus 5.5. Details under Visual Proof.

Not run: Linux, Windows, or SSH remote hosts.

  • I manually tested these changes locally
  • Automated tests added/updated, or explained why not below
  • Every added test fails without this change and avoids the test anti-patterns

Changed test files:

  • src/main/acp/acp-dialects/droid-spec-approval.test.ts
  • src/main/acp/options/acp-structured-options-droid-spec.test.ts

Performance

None, because the mode check before each send already existed; Plan only changes which config value it writes.

Risk

Level: Medium

Touches shared ACP option and prompt paths (acp-select-choices, acp-structured-options, acp-structured-prompts), but only dialects that declare planPermissionMode (Droid) take the new branch. A bug would leave a Droid chat in Spec or at the wrong autonomy level after approval. Back out with a plain revert.

AI Disclosure

Review

Self-reviewed this PR's single commit for correctness, security, and performance. Merge order:

Agent skill upstream boundary

  • Not applicable, or this change copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.

Notes

Considered security, macOS/Linux/Windows paths, SSH remote hosts, mobile compatibility, folder workspaces, and performance. Execution coverage is limited to the checks listed under Testing.

Checklist

  • This PR is small and focused
  • I explained what changed and why (ELI5, the user-facing before/after, the mechanism, and why over the alternatives)
  • I stated the risk: what could break, for whom, and how to back it out
  • Before/after screenshots or videos attached for UI changes, or N/A with reason
  • Self-reviewed for correctness, security, and performance
  • Cross-platform, SSH/remote, and path/shortcut impact considered (or N/A)
  • pnpm lint, pnpm typecheck, pnpm test, and pnpm build pass (or CI will cover; local preferred)

Merge message

feat(droid): run Orca's Plan mode as Droid Spec

Droid has a spec-first autonomy level, but Droid chats had no Plan
mode. Map Plan to spec and return Build to the pre-Plan level, show
Droid's spec approval as the plan card, approve with the option that
keeps the chat's Build level, and clear the Plan chip on approval.

@noter
noter marked this pull request as ready for review November 23, 2026 21:53
This was referenced Nov 23, 2026
@coderabbitai

coderabbitai Bot commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

Walkthrough

Droid ACP now reads model options and reasoning-effort choices from the account’s model catalog. ACP Plan and Build handling now retains the Build permission mode while Plan is active and passes it to prompt replies. Droid spec permission requests receive approval choices based on the Build mode. Droid sessions are also included in validated-plan interaction-mode updates.

Merge Risk: Moderate · up to f757b

With Droid Plan mode, changing the model or reasoning effort while Plan is being entered can leave the chat's stored permission state out of step with the agent. A later permission change can then take the agent out of Spec unexpectedly. Several smaller Droid session-tracking and permission-ordering issues also remain open. These should be addressed or explicitly accepted before merge.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title "feat(droid): run Orca's Plan mode as Droid Spec" matches the main change. The PR maps Orca's Plan mode to Droid's spec autonomy level, and the diff adds spec approval handling. The title is…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Description check Passed The description follows the repository template closely. It has ELI5, What Changed, Why, Linked Issue, Visual Proof, Testing, Performance, Risk, AI Disclosure, Review, Agent skill upstream boundary, N…
Full details: Title check

Explanation

The title "feat(droid): run Orca's Plan mode as Droid Spec" matches the main change. The PR maps Orca's Plan mode to Droid's spec autonomy level, and the diff adds spec approval handling. The title is specific and follows a conventional commit style. It names the Droid scope and the mapping, but not the approval card or the Build-level restore, which the title does not need to cover.

Full details: Description check

Explanation

The description follows the repository template closely. It has ELI5, What Changed, Why, Linked Issue, Visual Proof, Testing, Performance, Risk, AI Disclosure, Review, Agent skill upstream boundary, Notes, and Checklist sections, and each is substantively filled in. The change scope, mechanism, testing, live check, and risk level are all described. Gaps: the Linked Issue says 'Part of #37354' rather than the 'Fixes #' form the template asks for, and the template asks for a complete issue link, so this is a partial match. The 'Review' section is an unusual addition but harmless. The AI Disclosure section still contains the template's HTML comments with no answer. The final checklist item for lint, typecheck, test, and build is unchecked. The description also cites a commit hash (f757b75) that differs from the commit hash in the objectives (80ee86c), which is a consistency issue for reviewers. Overall, the description is mostly complete.

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 10

Review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: a54ba390-2c36-4b4a-9d7b-dcc53ca84784
Commits

Reviewing files that changed from the base of the PR and between 50f0c54 and 80ee86c.

Files selected for processing: 74

  • config/main-blocking-helper-baseline.txt
  • config/scripts/test-runtime/environment/vitest-real-agent-home-write-guard.ts
  • src/main/acp/acp-dialects/acp-dialect.ts
  • src/main/acp/acp-dialects/droid-dialect.ts
  • src/main/acp/acp-dialects/droid-model-catalog.ts
  • src/main/acp/acp-dialects/droid-spec-approval.test.ts
  • src/main/acp/acp-dialects/droid-spec-approval.ts
  • src/main/acp/options/acp-live-permission-mode.ts
  • src/main/acp/options/acp-select-choices.ts
  • src/main/acp/options/acp-structured-options-droid-spec.test.ts
  • src/main/acp/options/acp-structured-options.ts
  • src/main/acp/requests/acp-structured-prompts.ts
  • src/main/acp/session/acp-structured-agent-definitions.ts
  • src/main/acp/session/acp-structured-session-adapter.ts
  • src/main/agent-hooks/installation/remote-managed-hook-installers.ts
  • src/main/agent-hooks/server/agent-hook-server.ts
  • src/main/agent-hooks/server/server-cleanup.ts
  • src/main/agent-hooks/server/server-lifecycle.ts
  • src/main/agent-hooks/server/server-status-row-mutation.ts
  • src/main/agent-hooks/wsl-relay/wsl-hook-fs-adapter.ts
  • src/main/droid/droid-acp-launch-spec.ts
  • src/main/droid/droid-hook-config.ts
  • src/main/droid/droid-hook-file-remote.ts
  • src/main/droid/droid-hook-script.ts
  • src/main/droid/droid-hook-status.ts
  • src/main/droid/droid-hooks-file.test-fixture.ts
  • src/main/droid/droid-org-policy.ts
  • src/main/droid/hook-service.test.ts
  • src/main/droid/hook-service.ts
  • src/main/runtime/agent-session/records/agent-session-store-mutation.ts
  • src/shared/__fixtures__/droid-parent-process-hooks.jsonl
  • src/shared/__fixtures__/droid-parent-process-hooks.meta.json
  • src/shared/__fixtures__/droid-slow-start-hooks.jsonl
  • src/shared/__fixtures__/droid-slow-start-hooks.meta.json
  • src/shared/__fixtures__/droid-subagent-hooks.jsonl
  • src/shared/__fixtures__/droid-subagent-hooks.meta.json
  • src/shared/agent-hook-listener/hook-normalization-policy.ts
  • src/shared/agent-hook-listener/leases/agent-lease-expiry-timers.ts
  • src/shared/agent-hook-listener/leases/hook-lease-expiry-timers.ts
  • src/shared/agent-hook-listener/listener-state.ts
  • src/shared/agent-hook-listener/normalization/agent-hook-listener-droid-driver.test-support.ts
  • src/shared/agent-hook-listener/normalization/agent-hook-listener-droid-exit.test.ts
  • src/shared/agent-hook-listener/normalization/agent-hook-listener-droid-ownership.test.ts
  • src/shared/agent-hook-listener/normalization/hook-prompt-identity.ts
  • src/shared/agent-hook-listener/normalization/normalize-hook-payload.ts
  • src/shared/agent-hook-listener/pane-provider-session.ts
  • src/shared/agent-hook-listener/pane-state-claims.ts
  • src/shared/agent-hook-listener/provider-dispatch.ts
  • src/shared/agent-hook-listener/provider-hook-capabilities.ts
  • src/shared/agent-hook-listener/provider-hook-session.ts
  • src/shared/agent-hook-listener/providers/claude/background-tasks/claude-owed-notification-expiry-timers.ts
  • src/shared/agent-hook-listener/providers/droid/droid-events.ts
  • src/shared/agent-hook-listener/providers/droid/droid-hook-session.ts
  • src/shared/agent-hook-listener/providers/droid/droid-lease-expiry.ts
  • src/shared/agent-hook-listener/providers/droid/droid-probe-log-replay.test-fixture.ts
  • src/shared/agent-hook-listener/providers/droid/droid-session-owner.ts
  • src/shared/agent-hook-listener/providers/droid/droid-session-status.ts
  • src/shared/agent-hook-listener/providers/droid/droid-sessions.ts
  • src/shared/agent-hook-listener/providers/droid/droid-transcript-origin.ts
  • src/shared/agent-hook-listener/state/provider-hook-state-slots.ts
  • src/shared/agent-hook-listener/transport/agent-hook-policy-read-paths.ts
  • src/shared/agent-launch/startup/agent-resume-argv.ts
  • src/shared/agent-status/process/agent-process-exit-watch.test.ts
  • src/shared/agent-status/process/agent-process-exit-watch.ts
  • src/shared/agent-status/process/agent-process-presence.ts
  • src/shared/droid/droid-org-settings-path.ts
  • src/wsl-guest/agent-hooks/presence/relay-agent-presence.ts
  • src/wsl-guest/agent-hooks/results/agent-hook-result-retry-scheduler.ts
  • src/wsl-guest/agent-hooks/server/agent-hook-request.ts
  • src/wsl-guest/agent-hooks/server/agent-hook-server.ts
  • src/wsl-guest/agent-hooks/server/agent-hook-spool-ingest.ts
  • src/wsl-guest/agent-hooks/server/relay-droid-exit-watch.test.ts
  • src/wsl-guest/agent-hooks/status/agent-hook-event-admission.ts
  • src/wsl-guest/commands/wsl-hook-fs-bridge.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 1 remain after this review.

Comment on lines +79 to +82
if (session.options.modeChoice.holds(current?.currentValue)) {
session.options.modeChoice.adoptBuild(value)
session.permission = mode
return

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Minor · Data Integrity & Integration · Heavy lift

A permission pick made during a pending Plan-to-Build write can be overwritten.

When a Build write is still in flight, the permission write reads the Plan value and only updates the local record. The Build reply then installs the higher autonomy level, and nothing in the inspected permission path reapplies the newer, lower choice. The agent can keep running at the Build level until another permission write, a restart, or a later send restores the chosen level.

Order the permission write after the pending interaction-mode write, or make the Build completion keep the newer permission choice. The required behavior is that the latest permission pick wins on the running agent.

Comment on lines +103 to +104
if (plan && modeOption && modeOption.currentValue !== plan.plan) {
this.lastBuild = modeOption.currentValue

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Minor · Data Integrity & Integration · Quick win

Record the Build level before an agent-initiated switch into Spec.

AcpInteractionModeChoice learns the Build level only from an Orca Plan write (write) or a deferred permission choice (adoptBuild). When the agent changes its own autonomy level to spec through config_option_update, adoptConfigOptions stores the new value and does not record the previous level. If the session adopted auto-high at launch or from a prior update, lastBuild stays unset. running('spec') then reports the Droid default normal, and build() returns normal when the plan is approved. The chat leaves Spec at normal, not at the level it had before Spec.

Record the non-Spec level when the observed mode changes into the plan value outside an Orca write. The exact recording point is a design choice. It must preserve the level for both Orca-initiated and agent-initiated Spec entry.

Comment thread src/main/droid/droid-hook-config.ts Outdated
Comment on lines +78 to +79
if (cleaned.length === 0) {
delete events[eventName]

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Minor · Data Integrity & Integration · Quick win

Keep an empty hooks.json event array after cleanup.

If hooks.json starts with PreToolUse: [], it suppresses a custom PreToolUse hook in settings.json. Installation adds Orca's hook to that empty array. Removal then deletes the event, so Droid loads the previously suppressed custom hook from settings.json.

For hooks.json cleanup, retain an empty array when the last managed definition is removed. Keep the settings.json cleanup separate. This preserves the event override without retaining Orca's command.


export class HookLeaseExpiryTimers extends AgentLeaseExpiryTimers {
constructor(state: HookListenerState) {
super(state, [CLAUDE_OWED_NOTIFICATION_LEASE_PROVIDER, DROID_BACKGROUND_CHILD_LEASE_PROVIDER])

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Minor · Functional Correctness · Quick win

Select the lease that belongs to the stored row, not the first provider in list order.

HookLeaseExpiryTimers passes Claude before Droid. AgentLeaseExpiryTimers.lease() returns the first provider that has a lease, so when both leases exist the Claude deadline controls the wakeup. A Droid child deadline that expires sooner is ignored until the Claude deadline, which can be up to 60 seconds later. The Claude lease also does not check that the row is a Claude row.

Droid session start clears turn-cache state but not Claude lead or owed-task state. A stale Claude lead can therefore remain on a Droid pane. The lease selection must not let that stale lead override the current row's own deadline.

Define the required behavior before changing the code. Either the lease must belong to the provider that owns the stored row, or the earliest valid deadline must win. Choose one rule and apply it in agent-lease-expiry-timers.ts, and ensure the Claude lease is inactive on a non-Claude row.

Comment on lines 63 to 81
previousOpenCodeMainAgent?: AgentMainAgentStatus
/** A new Claude prompt_id opened the turn on this event. */
opensTurn?: boolean
sessionNormalization?: HookSessionNormalization
}): ProviderDispatchResult {
const { state, source, promptText, paneKey, hookPayload, envelope, extractedPrompt } = input
if (input.sessionNormalization) {
return {
payload: input.sessionNormalization.normalize(),
resolvedPromptText: promptText,
hasTranscriptPromptEvidence: false,
eventName: input.eventName,
hostTurnSignals: readHostTurnSignals(source, hookPayload, undefined),
replyCandidate: undefined
}
}
// Ephemeral side chats share the pane but must not replace its recorded main turn.
const codexEventName =
source === 'codex'

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Minor · Functional Correctness · Quick win

Keep the Droid lead Stop reply in the session normalization branch.

For a Droid lead Stop with last_assistant_message, normalize() sets state.eventReplyCandidate. The sessionNormalization branch then returns replyCandidate: undefined, so the reply is not admitted as acceptedReply. getAcceptedReply returns undefined for that turn, where the base commit returned the reply. The retry path does not restore it. The retry re-enters this branch, and the Droid verdict read returns only a verdict.

Read the candidate after normalize() and clear it, as the normal path does.

Suggested fix

   if (input.sessionNormalization) {
+    const payload = input.sessionNormalization.normalize()
+    const replyCandidate = input.state.eventReplyCandidate
+    input.state.eventReplyCandidate = undefined
     return {
-      payload: input.sessionNormalization.normalize(),
+      payload,
       resolvedPromptText: promptText,
       hasTranscriptPromptEvidence: false,
       eventName: input.eventName,
       hostTurnSignals: readHostTurnSignals(source, hookPayload, undefined),
-      replyCandidate: undefined
+      replyCandidate
     }
   }
Committable suggestion

IMPORTANT
Review the replacement and indentation, then test before committing.

Suggested change
previousOpenCodeMainAgent?: AgentMainAgentStatus
/** A new Claude prompt_id opened the turn on this event. */
opensTurn?: boolean
sessionNormalization?: HookSessionNormalization
}): ProviderDispatchResult {
const { state, source, promptText, paneKey, hookPayload, envelope, extractedPrompt } = input
if (input.sessionNormalization) {
return {
payload: input.sessionNormalization.normalize(),
resolvedPromptText: promptText,
hasTranscriptPromptEvidence: false,
eventName: input.eventName,
hostTurnSignals: readHostTurnSignals(source, hookPayload, undefined),
replyCandidate: undefined
}
}
// Ephemeral side chats share the pane but must not replace its recorded main turn.
const codexEventName =
source === 'codex'
previousOpenCodeMainAgent?: AgentMainAgentStatus
/** A new Claude prompt_id opened the turn on this event. */
opensTurn?: boolean
sessionNormalization?: HookSessionNormalization
}): ProviderDispatchResult {
const { state, source, promptText, paneKey, hookPayload, envelope, extractedPrompt } = input
if (input.sessionNormalization) {
const payload = input.sessionNormalization.normalize()
const replyCandidate = input.state.eventReplyCandidate
input.state.eventReplyCandidate = undefined
return {
payload,
resolvedPromptText: promptText,
hasTranscriptPromptEvidence: false,
eventName: input.eventName,
hostTurnSignals: readHostTurnSignals(source, hookPayload, undefined),
replyCandidate
}
}
// Ephemeral side chats share the pane but must not replace its recorded main turn.
const codexEventName =
source === 'codex'

Comment on lines +188 to +189
stoppedByUser && status.stateName === 'done'
? droidVerdictFields('cancellation', Date.now())

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Minor · Functional Correctness · Quick win

Retain cancellation until the held-open turn completes.

If a child survives an earlier lead Stop, a later idle_prompt retains that child. The resolved row stays working, so this condition discards the cancellation verdict. When the child finishes and its lease expires, settleDroidLeaseExpiry emits done without that verdict.

Store the pending cancellation in the lead/session state and include it in the final completion payload. Clear it when a new lead turn starts. Keep immediate cancellation working when no child holds the row open.

eventName === 'PreToolUse' ||
eventName === 'PostToolUse'
) {
showChild(sessions, id, 'working')

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Minor · Functional Correctness · Quick win

Classify child AskUser and high-risk PreToolUse as waiting.

The child branch in normalizeDroidEvent skips the AskUser and high-risk check that the lead branch applies. applyDroidChildEvent records every child PreToolUse as working. A child that waits for an answer to AskUser, or for a high-risk approval, therefore shows as working in its roster entry. The lead path shows waiting for the same call. Compute the same classification for child PreToolUse, and pass it into the child helper.

Suggested fix

 export function applyDroidChildEvent(
   sessions: DroidPaneSessions,
   id: string,
   eventName: unknown,
-  notification: DroidNotification
+  notification: DroidNotification,
+  awaitsUser = false
 ): boolean {
   if (
     eventName === 'UserPromptSubmit' ||
     eventName === 'PreToolUse' ||
     eventName === 'PostToolUse'
   ) {
-    showChild(sessions, id, 'working')
+    showChild(sessions, id, awaitsUser ? 'waiting' : 'working')
     return true
   }
   if (admission.kind === 'child') {
     const { sessions, sessionId } = admission
-    if (!applyDroidChildEvent(sessions, sessionId, eventName, notification)) {
+    const childToolName = readString(hookPayload, 'tool_name') ?? readString(hookPayload, 'name')
+    // Why: a child's AskUser or high-risk call waits on the user at PreToolUse, as the lead's does.
+    const awaitsUser =
+      eventName === 'PreToolUse' &&
+      (isDroidAskUserTool(childToolName) || isDroidHighRiskToolUse(hookPayload))
+    if (!applyDroidChildEvent(sessions, sessionId, eventName, notification, awaitsUser)) {
       return null
     }

Comment on lines +150 to +151
if (known.provisional) {
confirmOrRepointLead(known, parentId)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Major · Functional Correctness · Heavy lift

A later parent name cannot repoint a lead that a child-named parent created.

If Droid's calling_session_id names the immediate parent, a child-first start can misassign the pane's lead. When a child start names parent B and the pane has no sessions, adoptChild creates B as a provisional lead (droid-sessions.ts:146). The same call then runs confirmOrRepointLead, which sets provisional = false (lines 150-152, 117). B becomes a confirmed lead.

If B later starts with calling_session_id naming its own parent A, line 150 skips the repoint because provisional is false. Line 154 then skips recording B as a child, since B is the lead. adoptChild returns undefined and admitStart returns SKIP. A is never promoted. Hooks from A do not match the lead or a child, so they can be dropped.

Required behavior: a later parent name that reaches above the current lead must repoint the lead to the top-level ancestor. This must hold even when the lead was created from a child-named parent.

Comment on lines +179 to +180
const hadChildWork = (sessions?.roster.size ?? 0) > 0
createSessions(state, paneKey, sessionId, false)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Major · Functional Correctness · Quick win

Reject starts for known and finished children before replacing the lead.

A SessionStart with no calling_session_id skips the parent-chain checks and reaches createSessions. This can occur when the transcript also names no parent, for example when the transcript is unreadable. For a session already tracked as a child, this replaces the pane's lead, discards the child roster, and marks the prior row done. The real lead's later hooks are then skipped at the final branch.

The finished-child rule at droid-sessions.ts:37-38 says a late start must not bring a finished child back. The no-parent path does not apply that rule.

Return SKIP for a known or finished child before the replacement. Keep the replacement for a new root session.

Suggested fix

--- "a/src/shared/agent-hook-listener/providers/droid/droid-sessions.ts"
+++ "b/src/shared/agent-hook-listener/providers/droid/droid-sessions.ts"
@@ -175,9 +175,12 @@
   const rowLacksOwner = previous !== undefined && droidRowOwner(previous) === undefined
   if (sessions?.leadId === sessionId && sender && !rowLacksOwner) {
     return SKIP
   }
+  if (sessions?.children.has(sessionId) || sessions?.finished.has(sessionId)) {
+    return SKIP
+  }
   const hadChildWork = (sessions?.roster.size ?? 0) > 0
   createSessions(state, paneKey, sessionId, false)
   clearPaneTurnCacheState(state, paneKey)
   return hadChildWork && previous ? { kind: 'restate', settled: true } : SKIP
 }
Committable suggestion

IMPORTANT
Review the replacement and indentation, then test before committing.

Suggested change
const hadChildWork = (sessions?.roster.size ?? 0) > 0
createSessions(state, paneKey, sessionId, false)
if (sessions?.children.has(sessionId) || sessions?.finished.has(sessionId)) {
return SKIP
}
const hadChildWork = (sessions?.roster.size ?? 0) > 0
createSessions(state, paneKey, sessionId, false)

Comment on lines +213 to +214
if (eventName !== 'SessionEnd' || sessionId !== sessions?.leadId) {
clearExitMarker(state, paneKey)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Minor · Functional Correctness · Quick win

Child-session hooks clear the lead's exit marker and stop its exit watch.

After the lead's SessionEnd sets the exit marker, any later hook for another session clears it. This happens at droid-sessions.ts:213-214, before the hook is checked for child linkage, so a hook that is later skipped also clears it. The exit watch captures that marker and treats its absence as isCurrent() === false. On the next probe, agent-process-exit-watch.ts:45-53 deletes the watch without rescheduling it. Child events do not restart it, so the process exit for the ended lead is no longer detected unless another reconciliation path runs.

Keep the exit marker for the ended lead while child events arrive. Clear it only when that lead's exit state is replaced, or when the watch has completed.

Droid lists the account's models over `_factory/models/list` without a
session, so model discovery no longer needs a session Droid cannot delete.
Read each model's own reasoning efforts from the listing and from session
models, so the picker offers the right levels for every model.
Plan maps to Droid's `spec` autonomy level. Build returns to the level
the chat ran at before Plan, and a permission picked during Plan waits
for Build instead of ending Spec.

Droid's spec approval shows as Orca's plan card. Approving answers with
the option that keeps the chat's Build level (proceed_auto_run_<risk>
for auto levels, proceed_once for Auto (Off)); "Keep planning" stays in
Spec. The validated-plan store rule now also covers Droid, so the Plan
chip clears after approval.
@noter
noter force-pushed the ac/09-b1-droid-spec-mode branch from 80ee86c to f757b75 Compare November 26, 2026 11:29

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

Review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 5a30af61-8715-442d-bf51-d3d0a882b1e1
Commits

Reviewing files that changed from the base of the PR and between 80ee86c and f757b75.

Files selected for processing: 4

  • src/main/acp/acp-dialects/acp-dialect.ts
  • src/main/acp/options/acp-live-permission-mode.ts
  • src/main/acp/session/acp-structured-agent-definitions.ts
  • src/main/acp/session/acp-structured-session-adapter.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 1 remain after this review.

const bound = { ...this.writeBound(session, input.signal), key: input.key, value: input.value }
await writeAcpSessionOption(session.connection, session.options, write, bound)
const send = (next = write) =>
writeAcpSessionOption(session.connection, session.options, next, bound)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Major · Data Integrity & Integration · Heavy lift

A superseded Plan write drops its state adoption, so a later permission pick can end Spec.

When a Plan write runs, boundAcpOptionWrite increments options.writeRevision. A model or effort setOption also increments that counter, and it does not wait for the mode-write queue. If such a write starts before the Plan reply returns, the Plan write throws option write was superseded at acp-session-option-write.ts:65-67. It skips its apply() step, so adoptConfigOptions never runs and options.configOptions keeps the Build value while the agent is in Spec. The caller receives a rejected Plan setOption.

The next permission write reads that stale state. In writeAcpSessionMode, modeChoice.holds(...) does not match the Build value, so the write sends setConfigOption directly at acp-live-permission-mode.ts:90-92. That write can end Spec instead of adopting Build. A model write does not refresh configOptions. An effort write refreshes it only when its reply reflects the agent after the Plan change, so neither write reliably restores the state.

A successful Plan write must leave the option state in agreement with the agent before a later permission write reads that state. A superseding write must not discard the Plan adoption unless it also supplies a complete newer configuration. Alternatively, the permission path must not decide from state that a superseded write left stale. The choice between these approaches is open.

This branch has not been deployed

No deployments
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