Skip to content

feat(droid): open Droid chats in a terminal from a copy - #47844

Open
noter wants to merge 1 commit into
stablyai:mainfrom
codeious:ac/08-b8-droid-cli-fork
Open

noter wants to merge 1 commit into
stablyai:mainfrom
codeious:ac/08-b8-droid-cli-fork

Conversation

@noter

@noter noter commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

ELI5

"Continue in terminal" on a Droid chat now opens the Droid terminal on a copy of the chat, so the chat and the terminal don't write to the same conversation.

What Changed

Standalone. Rebased onto main at 3d3d28c; it has no dependencies and can merge on its own. Commit a12f7ff0c5.

  • Adds droid to FORKS_THROUGH_CHAT in src/shared/agent-launch/startup/agent-resume-argv.ts.
  • Continue in terminal forks the chat over ACP session/fork and runs droid --resume <copy id>, like OpenCode and OMP.

Why

Droid 1.17.2 advertises session/fork, and its CLI continues the returned copy. Resuming the chat's own session from a terminal would put two writers on one conversation.

Linked Issue

Part of #37354

Visual Proof

After the Plan-mode chat below, Continue in terminal created a new session file next to the chat's and started droid --auto high --resume <copy id>. Asked "which function did you add to calc.py earlier in this conversation?", the terminal answered "I added subtract(a, b), which returns a - b and has a docstring." The chat's own session file was last written before the copy was made.

After: the terminal opened on the copy answers from the chat's history.

Droid terminal answering from the chat's history

Testing

Local macOS only.

  • ORCA_CODE_QUALITY_BASE=stablyai/main 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: 1308 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).
  • 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:

  • None. No test meets the repo's bar for this change.

Performance

None, because this runs only when the user picks Continue in terminal.

Risk

Level: Low

Droid versions without session/fork get the existing refusal path. 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): open Droid chats in a terminal from a copy

Droid 1.17.2 advertises ACP session/fork and its CLI continues the
copy that fork returns, so Continue in terminal forks through the
chat like OpenCode and OMP instead of resuming the chat's session.

@coderabbitai

coderabbitai Bot commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The chat-based fork set now includes droid. Existing fork-query functions therefore classify Droid as using the chat-based fork path.

Merge Risk: Moderate · up to a12f7

Droid chats can now continue in a terminal from a copy. Several earlier-flagged issues in Droid hook handling, session lead tracking and status reporting remain open and should be addressed or explicitly accepted before merge. None is expected to cause severe failures.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title "feat(droid): open Droid chats in a terminal from a copy" matches the main change. The PR adds droid to FORKS_THROUGH_CHAT, so Continue in terminal forks the chat over ACP session/fork and r…
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 and fills in most required sections. It has a plain-language ELI5, a what-changed section that names the file and the ACP session/fork mechanism, a why …
Full details: Title check

Explanation

The title "feat(droid): open Droid chats in a terminal from a copy" matches the main change. The PR adds droid to FORKS_THROUGH_CHAT, so Continue in terminal forks the chat over ACP session/fork and resumes the copy instead of the chat's own session. The title is specific, concise, and uses a conventional commit prefix. It does not mention the ACP fork mechanism, but it covers the primary user-facing behavior.

Full details: Description check

Explanation

The description follows the repository template and fills in most required sections. It has a plain-language ELI5, a what-changed section that names the file and the ACP session/fork mechanism, a why section, a risk section with level and rollback, a performance line, a testing section listing platforms tested (local macOS only) and not tested (Linux, Windows, SSH), a visual proof section with before/after description and an image, and a merge order note. The Linked Issue section says 'Part of #37354', which does not use the template's required 'Fixes #' form. The Testing checkbox for added tests is unchecked with a stated reason, and the lint/typecheck/test/build checklist item is unchecked. The AI Disclosure section was left as template placeholder text. These gaps are non-critical, so 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

Recent 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: a014a7bd-f90d-4607-a75f-862955bb21f5
Commits

Reviewing files that changed from the base of the PR and between c3e203e and a12f7ff.

Files selected for processing: 1

  • src/shared/agent-launch/startup/agent-resume-argv.ts

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

@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: 7

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: 37afec23-a237-4a89-a555-c8dbe8d16722
Commits

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

Files selected for processing: 63

  • config/main-blocking-helper-baseline.txt
  • config/scripts/test-runtime/environment/vitest-real-agent-home-write-guard.ts
  • src/main/acp/acp-dialects/droid-dialect.ts
  • src/main/acp/acp-dialects/droid-model-catalog.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/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; 2 remain after this review.

if (existing !== null) {
await writeTextFileRemoteAtomic(sftp, `${path}.bak`, existing)
}
await writeHooksJsonRemote(sftp, path, config, { serialized })

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

Guard the remote Droid config write against a concurrent save.

installRemote computes the managed hook update from the configuration it reads at hook-service.ts:137. The wrapper then replaces the live file with that computed config. A Droid save that lands between the read and the rename is backed up to <path>.bak, but the live file loses the saved hook. The same pattern applies to settings.json at line 148.

The write path has no baseline check. The wrapper compares only against fresh bytes, and writeHooksJsonRemote writes unconditionally when the content differs. Before the rename, the write must confirm the live file still matches the content the update was derived from. When it changed, the managed hooks must be merged into the current content and the check retried. The merge policy and the retry limit are for the author to choose.

Comment thread src/main/droid/hook-service.ts Outdated
if (!settings) {
return { error: errorStatus(configPath, 'Could not parse Factory settings.json') }
}
return { hooksFile, settings }

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 · Stability & Availability · Quick win

Reject malformed hook definitions before publishing the script.

The readers accept any root JSON object. A hooks.json or settings.json with {"Stop":[null]} therefore passes. resolveDroidHookCoverage then reads definition.hooks on null and throws a TypeError. Local getStatus() and install() have no try around this path, so the exception propagates. Local install() publishes the managed script before the throw. Remote installRemote() converts the throw into an error status, but it also publishes the script first.

Validate each event's definitions and their nested hooks arrays in both readers. Return errorStatus for invalid structure before the script is published. Do not write the file, so the user can correct it.

Comment on lines +46 to +47
if (lease) {
return { provider, lease }

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

Stop the Claude lease from hiding a Droid lease in the shared timer.

The timer is wired. src/main/agent-hooks/server/server-status-row-mutation.ts:32 and src/wsl-guest/agent-hooks/results/agent-hook-result-retry-scheduler.ts:76 construct HookLeaseExpiryTimers. That class lists the Claude provider first and the Droid provider second.

AgentLeaseExpiryTimers.lease() returns the first provider that returns a lease. restate() settles only that provider. When the Claude provider returns a lease for a pane, the Droid provider is never consulted for that pane, so its lease does not settle through this timer.

The Claude lease reads only claudeLeadStateByPaneKey and claudeLaunchedBackgroundTasksByPaneKey. It does not check the stored row's agentType. Droid admission clears only the pane turn cache, and that cache does not include these two Claude maps. After a Droid takeover, leftover idle Claude state can keep returning a lease.

A pane must have one lease owner, and that owner must match the stored row's provider. The Claude lease must return no lease when the stored row is not a Claude row. The Droid lease already applies the same kind of check for payload.agentType === 'droid'.

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

Apply the AskUser and high-risk waiting classification to child PreToolUse events.

At droid-session-status.ts:36, every child PreToolUse sets the child to working. The lead path in droid-events.ts:148-153 sets waiting for an AskUser tool or a high-risk tool call, because those calls need the user at PreToolUse. A child call to one of these tools can reach the child branch and be shown as working while it waits for user input. The lead path's classification is not applied to child events.

Child events must use the same classification as lead events for these tools, so a blocked child row shows waiting. Other child PreToolUse events keep the working state.

sessions.leadId = root
sessions.lead = undefined
}
sessions.provisional = 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 · Data Integrity & Integration · Heavy lift

A grandchild's start clears provisional before the lead's own parent is known, so a later parent report for the lead is ignored.

When a child's start names the provisional lead as its parent, confirmOrRepointLead sets provisional = false even though the lead's own parent is still unrecorded. If the lead C later starts with calling_session_id R, adoptChild skips the repoint because provisional is false. C is the lead, so it is not recorded as a child, and the function returns undefined. The pane keeps C as the lead. Ordinary activity from the actual root R then reaches the final branch and is skipped, because R is neither the lead nor a recorded child.

A provisional lead must stay repointable until its own parent is known. A child's parent report must not clear provisional while the lead's parent is unrecorded. A later start that names a different parent for the lead must still repoint it.

Comment on lines +221 to +223
const parentId =
(isStart ? readString(hookPayload, 'calling_session_id') : undefined) ??
(isStart || unseen ? readDroidTranscriptCallingSessionId(hookPayload) : undefined)

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

Retry transcript discovery for a provisional lead.

While the pane's lead is provisional, unseen is false for that lead's later hooks. readDroidTranscriptCallingSessionId therefore never runs for it. If its transcript becomes readable later, the lead stays wrong. Hooks from the real lead then reach the final skip branch, and the row keeps the wrong resume identity.

Treat a provisional lead as unseen so that its next hook can repoint the lead. A lead with no readable parent keeps its current behavior.

Suggested fix

   const unseen =
     eventName !== 'SessionEnd' &&
-    sessionId !== sessions?.leadId &&
+    (sessions?.provisional || sessionId !== sessions?.leadId) &&
     !sessions?.children.has(sessionId)

The transcript is read on every hook while the lead stays provisional. A repoint happens only on a hook from the child, because the lead's own transcript cannot name the real lead.

agentPresence: suspended ? { ...unsuspended, suspended: true } : unsuspended
})
}
return verdict

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 · Stability & Availability · Quick win

Keep the exit watch polling when the probed row was superseded.

When current() !== owner, the probe callback skips the AgentProcessExit publication. It still returns 'exited'. The exit watch treats 'exited' as terminal and stops polling. The watch contract requires that 'exited' has already ended the row, and this row was not ended.

A foreign-sender hook can replace the stored row during a probe without clearing the exit marker. The watch remains current in that case, so the stale 'exited' verdict stops it. The row can then keep showing the agent as running until a later hook or replay checks it.

For a superseded owner, return a verdict that the watch does not treat as terminal. The watch then keeps polling the current row. Keep the existing exit publication for an unchanged owner.

Droid 1.17.2 advertises ACP session/fork, and its CLI continues the copy
that fork returns by id, so "Resume in New CLI" forks through the chat like
OpenCode and OMP instead of resuming the chat's own conversation.

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