Skip to content

fix(cli): agent hooks status reports the running app and its SQLite file - #41445

Merged
AmoabaKelvin merged 2 commits into
mainfrom
sta-14557-hooks-status-offline
Nov 12, 2026
Merged

AmoabaKelvin merged 2 commits into
mainfrom
sta-14557-hooks-status-offline

Conversation

@AmoabaKelvin

@AmoabaKelvin AmoabaKelvin commented Nov 12, 2026 •

Copy link
Copy Markdown
Collaborator

Carries over #40411 by @innocarpe.

ELI5

orca agent hooks status said hooks were being reported "offline" and pointed at a settings file that doesn't exist, even while Orca was open and the hooks were working. Now, when Orca is running, it asks Orca for the setting and points at the file the setting actually lives in.

Files Added Deleted Net
Test 1 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​49 0 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​49
Prod 2 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​30 $\color{#cf222e}{\Huge{\mathbf{−}}}$​8 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​22

What Changed

Before, with the app running and settings in SQLite:

appliedBy: offline
settingsPath: ~/Library/Application Support/orca/profiles/local-default/orca-data.json

After:

appliedBy: runtime
settingsPath: ~/Library/Application Support/orca/profiles/local-default/profile-state.db
  • When the runtime answers, agent hooks status reads agentStatusHooksEnabled from the running app (settings.get) and reports appliedBy: runtime. When nothing answers, it reads the disk and reports offline, as before.
  • The rule for which file holds the settings (the JSON file for JSON-only or brand-new profiles, otherwise profile-state.db) now lives next to the offline settings reader, as resolveAgentHookSettingsPath. status uses it, and so do agent hooks on/off when the running app applied the change. Before this, on/off printed the JSON path too.

Why

The status handler hardcoded appliedBy: 'offline', and the CLI's getDataPath() always returned orca-data.json, even after the profile moved to SQLite. #40411 by @innocarpe fixed the path and the label. This carry-over keeps that commit, rebased onto main: the classification module had moved, and the test file conflicted. My commit on top does three things:

  • When the label says runtime, the value now comes from the runtime. Otherwise status would claim the running app's answer while still printing the disk value.
  • The path rule now sits beside the reader, so the two can't drift apart.
  • on/off get the same path fix, which fix(cli): report connected agent hook status from the sqlite file #40411 listed under its limits.

settings.get has returned agentStatusHooksEnabled since the hook opt-out controls (#2778), so it works against any runtime this CLI can talk to.

Linked Issue

Fixes #40401
Linear: STA-14557

Visual Proof

CLI output only, no UI. Run against the same connected app (Orca 1.4.257, runtime ready and reachable). Before, with the installed CLI:

$ orca agent hooks status
agentStatusHooksEnabled: true
appliedBy: offline
settingsPath: /Users/<me>/Library/Application Support/orca/profiles/local-default/orca-data.json

After, with this branch's CLI (bun src/cli/index.ts agent hooks status):

agentStatusHooksEnabled: true
appliedBy: runtime
settingsPath: /Users/<me>/Library/Application Support/orca/profiles/local-default/profile-state.db

Testing

  • Reproduced on the installed 1.4.257 build with the runtime connected (orca status: ready, reachable), then ran this branch's CLI against the same app (output above).

  • src/cli/handlers/agent-hooks.test.ts gets one table test with two rows, against a real SQLite-only profile:

    • Offline: reads the disk.
    • Connected: the running app returns false while the disk still says true.
    • Both rows check enabled, appliedBy and settingsPath, and both fail with main's handler.
  • Also ran profile-state-offline-settings.test.ts, profile-state-cutover-soak.test.ts and check:code-quality:changed.

  • macOS only. The change adds no platform-specific code, and it uses the same runtime transport as on/off, which is a Unix socket or a Windows named pipe.

  • 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

Risk

The riskiest part: if the runtime answers status.get but settings.get then fails (for example the runtime is still starting, or the terminal belongs to a different Orca instance), agent hooks status now exits with an error instead of printing the disk value. on/off already behave this way, and printing a possibly stale disk value as the app's answer is what this fixes. No saved data or wire format changes. Agent hooks commands are local only, since remote flags are rejected. A plain revert backs it out.

Level: Low

AI Disclosure

Review

review-loop: one round with Codex and Claude. Codex found nothing. Claude raised two P3s, and I left both:

  • Failing loudly when settings.get errors: matches on/off (see Risk).
  • The reader still classifies storage itself: it needs the classification for more than picking a path.

perf-scan: no findings. This is a one-shot CLI command: when the app is connected it adds one local RPC and skips one SQLite open.

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

Ensure no issues in: Security, Cross-platform support (Linux, Windows, Mac), Remote SSH, Mobile, general backwards compatibility, performance

  • Security: the only new call is a read-only settings.get over the CLI's own local runtime token.
  • Remote SSH and mobile: not touched. Agent hooks commands reject remote selection.
  • Backward compatibility: uses an RPC every supported runtime has.

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)

innocarpe and others added 2 commits November 12, 2026 07:26
Status always said appliedBy offline and named orca-data.json, even when the app was connected and the setting lived only in profile-state.db.
When the runtime answers, status takes agentStatusHooksEnabled from
settings.get instead of the disk, so appliedBy: runtime is true. The
settings path rule lives next to the reader, and on/off report the
SQLite file when the runtime applied the change.
@coderabbitai

coderabbitai Bot commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The CLI resolves the active profile’s settings file, with a fallback to the legacy profile-state location. The hooks status command reads the setting from the runtime when it is reachable and from disk otherwise. Its output identifies the source of the setting. Tests cover offline and connected status for a SQLite-backed profile.

Severity of issue fixed: Low

Merge Risk: Minimal · up to 9db10

The change makes agent hooks status reflect the running app and report an existing settings file path. No merge-blocking risk was identified.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title names the two things the fix changes: agent hooks status now reports the running app (runtime) and points at the SQLite file. The changeset matches this. It reads the live setting from setti…
Linked Issues check Passed Issue #40401 requires two things: (1) appliedBy must reflect the running app when connected, and (2) settingsPath must point to an existing file. The diff of src/cli/handlers/agent-hooks.ts (bas…
Out of Scope Changes check Passed All changes connect to the reported behavior. The settings.get read and appliedBy label address the runtime-state mismatch. resolveAgentHookSettingsPath in profile-state-offline-settings.ts an…
Description check Passed The description is thorough and covers the template sections. It has an ELI5, a What Changed section with before/after output, a Why section, a linked issue (Fixes #40401), visual proof with CLI befor…
Full details: Title check

Explanation

The title names the two things the fix changes: agent hooks status now reports the running app (runtime) and points at the SQLite file. The changeset matches this. It reads the live setting from settings.get when the runtime is reachable and resolves the SQLite profile-state.db path. The title uses the conventional fix(cli) prefix and is 72 characters, which is slightly long but clear.

Full details: Linked Issues check

Explanation

Issue #40401 requires two things: (1) appliedBy must reflect the running app when connected, and (2) settingsPath must point to an existing file. The diff of src/cli/handlers/agent-hooks.ts (base to head) covers both. readRunningRuntimeHooksEnabled checks runtime reachability with getOfflineRuntimeAdmission(), then calls settings.get and reads agentStatusHooksEnabled. The agent hooks status handler sets appliedBy: 'runtime' in that case and 'offline' only when no runtime answers. getSettingsPath() now uses resolveAgentHookSettingsPath, which returns the SQLite profile-state.db for SQLite-backed profiles, so the reported path is the file that stores the setting. The raw summary states a table test in src/cli/handlers/agent-hooks.test.ts covers offline and connected rows against a SQLite-only profile. I did not open that test file, so its content rests on the summary. The offline path is unchanged in behavior.

Full details: Out of Scope Changes check

Explanation

All changes connect to the reported behavior. The settings.get read and appliedBy label address the runtime-state mismatch. resolveAgentHookSettingsPath in profile-state-offline-settings.ts and the getSettingsPath helper fix the wrong settingsPath. The agent hooks on/off path change in setAgentHooksEnabled uses the same helper, and the PR description states that #40411 listed this as a remaining limit of the same path bug. The test additions cover the changed status behavior. The PR description discloses the fail-loud behavior when settings.get errors, which follows from the status change and is not an unrelated change. No unrelated file or feature changes appear in the reviewed evidence.

Full details: Description check

Explanation

The description is thorough and covers the template sections. It has an ELI5, a What Changed section with before/after output, a Why section, a linked issue (Fixes #40401), visual proof with CLI before/after output, testing steps, a risk section with a Low level and a rollback path, and filled-in review, notes and checklist sections. The AI Disclosure section is empty, but the template says to fill it in only for non-StablyAI team members. The author did not confirm the final lint/typecheck/test/build checklist item, and the PR is marked as carrying over a prior commit. These gaps are minor and 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: ba6b463f-fa25-47be-b8a4-d2f68f782a63
Commits

Reviewing files that changed from the base of the PR and between 4dcf689 and 9db10e2.

Files selected for processing: 3

  • src/cli/handlers/agent-hooks.test.ts
  • src/cli/handlers/agent-hooks.ts
  • src/main/persistence/profile-state/offline-access/profile-state-offline-settings.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.

@AmoabaKelvin
AmoabaKelvin merged commit 34ae456 into main Nov 12, 2026
58 checks passed
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.

[Bug]: orca agent hooks status reports appliedBy: offline while the runtime is connected

2 participants