You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
feat(droid): open Droid chats in a terminal from a copy - #47844
"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.
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.
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:
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.
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: 4
Check name
Status
Explanation
Title check
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
Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check
Check skipped because no linked issues were found for this pull request.
Description check
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.
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 5 remain after this review.
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 2 remain after this review.
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.
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.
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'.
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.
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_idR, 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.
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.
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.
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 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
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.
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.droidtoFORKS_THROUGH_CHATinsrc/shared/agent-launch/startup/agent-resume-argv.ts.session/forkand runsdroid --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.
Testing
Local macOS only.
ORCA_CODE_QUALITY_BASE=stablyai/main pnpm check:changedpassed on this commit after the rebase (format, oxlint, typecheck, tests importing the change, selected ratchets).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-fresh-profile-terminalfailed the same way on main. Not rerun after the rebase.ORCA_BACKGROUND_LAUNCH=1and 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.
Changed test files:
Performance
None, because this runs only when the user picks Continue in terminal.
Risk
Level: Low
Droid versions without
session/forkget 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
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
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)Merge message