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): list Droid models before a chat starts - #47843
New tab → Droid listed the account's 35 models (Fable 5.2 first) before any chat existed. The ~/.factory/sessions count was 304 before discovery and 304 after.
After: the Droid submenu lists the models with no chat open.
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
Less work: one _factory/models/list call replaces creating a session to read models.
Risk
Level: Low
If Droid drops _factory/models/list, the picker shows no models before a chat starts; models still arrive once a chat opens. 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): list Droid models before a chat starts
Droid lists the account's models over _factory/models/list without a
session, so model discovery no longer creates sessions Droid cannot
delete. Read each model's reasoning efforts from the listing and
from session models so the picker offers the right levels.
The changes add Droid model catalog discovery and hook management across hooks.json and settings.json. They add provider-aware Droid session admission, lead and child status tracking, and pane-scoped provider state. Lease expiry and process-exit monitoring are wired into main and WSL relay servers. Platform and organization-policy handling, related tests, and recorded hook fixtures are also updated.
Merge Risk: Moderate · up to 53676
Installing Droid hooks can silently disable a user's existing legacy hooks file. Droid session tracking can misidentify a child session as the lead in some timing cases. Remote installs can overwrite a save made while the install runs. These should be fixed or explicitly accepted before merge.
Pre-merge checks: 4
Check name
Status
Explanation
Title check
The title 'feat(droid): list Droid models before a chat starts' matches the main change: the Droid model list is now read via _factory/models/list without a session, so models appear before a chat ope…
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 is mostly complete and follows the repository template. It has a clear ELI5, a What Changed section that explains the mechanism (Droid's _factory/models/list replaces session-based d…
Full details: Title check
Explanation
The title 'feat(droid): list Droid models before a chat starts' matches the main change: the Droid model list is now read via _factory/models/list without a session, so models appear before a chat opens. It follows the conventional-commit style and is specific enough for a teammate scanning history. The changeset is broad, but the title names the primary user-visible change.
Full details: Description check
Explanation
The description is mostly complete and follows the repository template. It has a clear ELI5, a What Changed section that explains the mechanism (Droid's _factory/models/list replaces session-based discovery, with per-model reasoning efforts read from the listing and session models), a Why section that explains the stray-session problem, a linked issue (Part of #37354), a Visual Proof section with a before/after description and screenshot, Testing details with platforms tested (local macOS only) and skipped (Linux, Windows, SSH), a Performance line, a Risk section with level and rollback, and completed checklists. Gaps: the Linked Issue uses 'Part of' rather than 'Fixes', and the template asks for a linked issue with 'Fixes #'. The 'Changed test files' item says no tests were added, and the test-anti-pattern checkbox is unchecked without a clear reason beyond 'No test meets the repo's bar.' The AI Disclosure section is left as the unfilled template comment. The lint/typecheck/test/build checkbox is unchecked, though the Testing section reports partial runs. The 'Visual Proof' before/after is one screenshot with a textual before-state, not a switchable before/after pair.
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; 3 remain after this review.
The reason will be displayed to describe this comment to others. Learn more.
Major · Data Integrity & Integration · Heavy lift
Keep legacy hooks/hooks.json user hooks active when install creates hooks.json.
When ~/.factory/hooks.json does not exist, install() and installRemote() create it. Droid loads the legacy ~/.factory/hooks/hooks.json only while hooks.json is absent. After this write, Droid ignores the legacy file. Those user hooks stop running, and Orca never reads or migrates them. The same change applies to remote installs.
Before writing hooks.json, carry the legacy file's events into it, as carrySettingsHooksIntoHooksFile already does for settings.json. Apply this on the local and SSH paths. Keep Orca's managed entries separate from user entries.
The reason will be displayed to describe this comment to others. Learn more.
Major · Data Integrity & Integration · Quick win
Guard the remote hooks publish against a save that lands after the read.
writeDroidHookFileRemote reads the destination at line 14 and publishes at line 21 through writeHooksJsonRemote. That function re-reads only to skip identical content, then renames over the path without checking that the file still matches the value it was built from. A /hooks save that lands in between is replaced by the merged content. The .bak file keeps the older content, so the save is lost.
The race predates this change. The narrower window left by the re-read in installRemote still exists on this path.
Publish conditionally on the bytes the edit was computed from. writeTextFileRemoteAtomic already supports this through computedFrom (hook-text-files-remote.ts:50-76). Its contract says the caller redoes its edit on conflict. Use computedFrom: existing for the hooks publish. On a conflict, rerun the merge from a fresh read and do not report success. The check still leaves one round trip before the rename, so the window shrinks but does not close.
The reason will be displayed to describe this comment to others. Learn more.
Minor · Functional Correctness · Quick win
Guard nested hook entries before scanning them.
readHooksJson returns any JSON object, including arrays containing null or a hooks value that is not an array. loadedDefinitions returns the hooks.json event array without checking its elements. The scan at line 49 then reads definition.hooks or calls .some on a non-array value, which throws. A malformed user file should yield a missing-event result, not a crash in the status path.
Check each entry and its hooks field before scanning them:
Suggested fix
--- "a/src/main/droid/droid-hook-status.ts"+++ "b/src/main/droid/droid-hook-status.ts"@@ -43,12 +43,15 @@
command: string,
orgAllowsManagedHooksOnly: boolean
): DroidHookCoverage {
const missing = DROID_EVENTS.map((event) => event.eventName).filter(
(eventName) =>
- !loadedDefinitions(files, eventName).some((definition) =>- (definition.hooks ?? []).some((hook) => hook.command === command)- )+ !loadedDefinitions(files, eventName).some(+ (definition) =>+ isPlainObject(definition) &&+ Array.isArray(definition.hooks) &&+ definition.hooks.some((hook) => isPlainObject(hook) && hook.command === command)+ )
)
const presentCount = DROID_EVENTS.length - missing.length
// Why: report a silenced Droid in every branch, or a user would think a reinstall fixed it.
The reason will be displayed to describe this comment to others. Learn more.
Minor · Functional Correctness · Quick win
Limit the Claude owed-notification lease to Claude rows.
The Claude lease provider does not check the pane's current row provider. The timer lists the Claude provider first and returns the first lease it finds. If Claude owed-task state remains when a Droid row is current, the Claude lease hides the Droid lease, so Droid child-lease expiry does not run at its own deadline. The Claude settle step can also write a Claude-built payload onto the Droid row.
Add the same row-provider guard that the Droid lease uses:
Suggested fix
lease(state, paneKey) {
+ const row = state.lastStatusByPaneKey.get(paneKey)+ if (row?.payload.agentType !== 'claude') {+ return undefined+ }
// Only an idle main agent has one: the lease does not run while it is in a turn.
const idleSince = mainAgentIdleSince(state.claudeLeadStateByPaneKey.get(paneKey))
The reason will be displayed to describe this comment to others. Learn more.
Minor · Functional Correctness · Quick win
Child AskUser PreToolUse events do not set the child row to waiting.
In applyDroidChildEvent, every PreToolUse sets the child to working, including AskUser. The lead path in normalizeDroidEvent treats the same AskUserPreToolUse as waiting, because the tool needs user input at that point. A child can therefore show working on its roster row while Droid waits for the user's answer.
Make the child branch use the same rule. When a child emits PreToolUse for a tool where isDroidAskUserTool is true, the child state must be waiting. Pass the tool name, or the flag derived from it, into applyDroidChildEvent. Read the tool name before the child branch, because the current child call does not receive it.
The reason will be displayed to describe this comment to others. Learn more.
Major · Functional Correctness · Quick win
Preserve known child identity when a start lacks parent evidence.
If C is already registered as L's child, a delayed SessionStart for C can still reach this replacement. This occurs when the hook omits calling_session_id and its transcript cannot be read. createSessions then replaces lead L with C and discards the existing session graph. L's subsequent ordinary hooks return SKIP.
Before the parentless-start fallback, reject starts for ids already recorded in children or finished. Continue to accept a new, unknown parentless lead.
The reason will be displayed to describe this comment to others. Learn more.
Minor · Functional Correctness · Quick win
Keep the lead's exit marker when a child hook arrives.
A child hook clears the lead's exit marker. The lead's SessionEnd set that marker, and the field documentation says only the owner's later hooks clear it. Once the marker clears, the pending exit watch stops at its next probe. The lead can then exit without a further exit observation from this watch, and the row may keep its last state until another presence check runs.
Lead events already clear the marker in the lead branch, so the clear at lines 213-215 is only needed for child and unrelated events. Remove it. The no-session-id branch keeps its own clear.
The reason will be displayed to describe this comment to others. Learn more.
Major · Functional Correctness · Quick win
Recheck transcript origin while the lead is provisional.
If C's first ordinary hook arrives before its transcript is readable, admission creates provisional lead C. On later hooks from C, unseen is false. This condition prevents admission from reading the now-readable callingSessionId=L.
C remains the lead, and L's ordinary hooks return SKIP. Include provisional sessions in the transcript-recheck condition. Preserve the existing fast path for confirmed sessions.
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.
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
The Droid model picker can now show your models before you open a chat, without creating a throwaway Droid session.
What Changed
Standalone. Rebased onto main at 3d3d28c; it has no dependencies and can merge on its own. Commit
f0c647695d._factory/models/list, which needs no session, and sets the launch spec's model discovery toinitialize.Why
Discovery opened a session to read models, and Droid cannot delete sessions over ACP, so each discovery left a stray session in
~/.factory/sessions.Linked Issue
Part of #37354
Visual Proof
New tab → Droid listed the account's 35 models (Fable 5.2 first) before any chat existed. The
~/.factory/sessionscount was 304 before discovery and 304 after.After: the Droid submenu lists the models with no chat open.
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
Less work: one
_factory/models/listcall replaces creating a session to read models.Risk
Level: Low
If Droid drops
_factory/models/list, the picker shows no models before a chat starts; models still arrive once a chat opens. 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