Skip to content

feat(droid): list Droid models before a chat starts - #47843

Open
noter wants to merge 1 commit into
stablyai:mainfrom
codeious:ac/07-b9-droid-model-list
Open

noter wants to merge 1 commit into
stablyai:mainfrom
codeious:ac/07-b9-droid-model-list

Conversation

@noter

@noter noter commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

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.

  • Lists models through Droid's _factory/models/list, which needs no session, and sets the launch spec's model discovery to initialize.
  • Reads each model's own reasoning efforts from the listing and from session models, so the picker offers the right levels per model.

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/sessions count was 304 before discovery and 304 after.

After: the Droid submenu lists the models with no chat open.

Droid model list before any chat

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:

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): 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.

@coderabbitai

coderabbitai Bot commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

Walkthrough

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: Passed 4

Check name Status Explanation
Title check Passed 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 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 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.

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

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: 659bf815-9896-4314-9eb2-204137240676
Commits

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

Files selected for processing: 62

  • 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-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; 3 remain after this review.

Comment thread src/main/droid/droid-hook-config.ts Outdated
scriptFileName: string
): { settingsChanged: boolean } {
const isManagedCommand = createManagedCommandMatcher(scriptFileName)
carrySettingsHooksIntoHooksFile(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.

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.

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.

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.

Comment thread src/main/droid/droid-hook-status.ts Outdated
const missing = DROID_EVENTS.map((event) => event.eventName).filter(
(eventName) =>
!loadedDefinitions(files, eventName).some((definition) =>
(definition.hooks ?? []).some((hook) => hook.command === command)

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

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.

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

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))

Comment on lines +32 to +36
eventName === 'UserPromptSubmit' ||
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

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 AskUser PreToolUse 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.

return SKIP
}
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

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.

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

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.

Suggested fix

--- "a/src/shared/agent-hook-listener/providers/droid/droid-sessions.ts"
+++ "b/src/shared/agent-hook-listener/providers/droid/droid-sessions.ts"
@@ -210,10 +210,7 @@
     return { kind: 'lead' }
   }
   const sessions = droidPaneSessions(state, paneKey) ?? restoredSessions(state, paneKey, previous)
-  if (eventName !== 'SessionEnd' || sessionId !== sessions?.leadId) {
-    clearExitMarker(state, paneKey)
-  }
   const isStart = eventName === 'SessionStart'
   const unseen =
     eventName !== 'SessionEnd' &&
     sessionId !== sessions?.leadId &&

!sessions?.children.has(sessionId)
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

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.
@noter
noter force-pushed the ac/07-b9-droid-model-list branch from 5367670 to f0c6476 Compare November 26, 2026 11:29

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