Skip to content

feat(cli): read and message agent chats with orca chat list/read/send - #33115

Closed
YangNuoCheng wants to merge 9 commits into
stablyai:mainfrom
YangNuoCheng:feat/cli-chat-commands
Closed

YangNuoCheng wants to merge 9 commits into
stablyai:mainfrom
YangNuoCheng:feat/cli-chat-commands

Conversation

@YangNuoCheng

@YangNuoCheng YangNuoCheng commented Oct 24, 2026 •

Copy link
Copy Markdown
Contributor

ELI5

Managing coding agents by voice through another assistant (Grok Bot, Muse, and similar personal agents on the same machine) is becoming a normal way to work: you ask from your phone what your agents are doing and tell them what to do next. Orca's chat agents, the default, cannot be reached this way today. This PR adds the missing CLI surface so any local assistant can read and message them.

Orca agents usually run as chats. Scripts and other assistants could read and type into terminal agents with orca terminal, but had no way to read a chat or send it a message. This adds orca chat list, orca chat read and orca chat send.

What Changed

Before: orca worktree ps showed that a chat was working and its last reply, and nothing more; the CLI had no way to read the conversation or message it.

After:

orca chat list [--worktree <name-or-id>] [--state <state>] [--json]
orca chat read --session <id-or-handle> [--limit <n>] [--json]
orca chat send --session <id-or-handle> --text <text> [--json]

Mechanism (CLI only, no host changes):

  • chat list projects the top-level chat rows of worktree.ps (session, workspace, agent, state, title, last reply). Terminal agents and subagents are left out.
  • chat read calls agentSession.history (tail) and returns messages, tool calls, and approvals/questions, marking ones still pending. Provider status frames and turn markers are dropped; --limit counts the entries shown, so the read fetches more journal rows than it displays.
  • chat send reads the chat's fence from agentSession.history, then sends through the shared structuredAgentSessionMessageSendMutation / structuredAgentSessionSendBody with an id from createStructuredAgentSessionOperationId, the same path the mobile client uses. It adds delivery: 'queue-if-active' only when the host advertises agent-session.queued-messages.v1, so a working agent gets the message after its turn instead of mid-turn. A host refusal is raised as an error with the host's code; it is never reported as sent.
  • --session accepts the session id from chat list, the handle agent launch returns, or a pane key.
  • Registered in the command specs, handler manifest, root help, CLI_COMMAND_NAMES, the CLI reference docs, and the bundled orca-cli guide (regenerated). The guide also tells an outside assistant relaying for a user to confirm an instruction with the user before chat send.

Why

Voice is handled by assistants that already do it well (Grok Bot's voice mode, for example), so Orca does not need to build or maintain speech, a phone client, or spoken summaries. Three CLI commands over existing RPC methods are enough for any of them to drive Orca. Fixes the use case in the linked issue: the user talks by voice (from a phone) to a personal assistant agent running on the same machine, such as Grok Bot or a similar assistant, which reports what the Orca agents are doing and relays the user's instructions to them. Most agents are chats. The runtime already exposes agentSession.history and agentSession.send with workspace permission, so this only adds the CLI surface and reuses the shared envelope and fingerprint code instead of re-implementing it. Approvals and cancel are left for a follow-up to keep this change small.

Linked Issue

Fixes #33114

Visual Proof

N/A: CLI-only change with no UI. Output against a running Orca 1.4.238 desktop host:

$ orca chat list --state working
orcatex-composite-lead · codex · working
  session: 9a2d16d2-c345-4e9b-b87e-e6fd27dd3ead
  last reply: Targeted rule regressions and adjacent rule tests passed (69) ...

$ orca chat send --session codex_8eb631ab_59c5_41e4_8672_01cfe0a6fd5f --text "Third test from orca chat send. Reply with exactly: CLI OK"
Sent to codex_8eb631ab_59c5_41e4_8672_01cfe0a6fd5f.

$ orca chat read --session codex_8eb631ab_59c5_41e4_8672_01cfe0a6fd5f --limit 2
user: Third test from orca chat send. Reply with exactly: CLI OK
assistant: CLI OK

Testing

  • I manually tested these changes locally

  • Automated tests added/updated, or explained why not below

  • src/cli/handlers/chat.test.ts (9 tests): selector parsing; list excludes terminal agents and subagents and filters by state; read keeps messages, tools and pending approvals and drops status frames, and returns the newest N entries; send produces params that pass the host's own SendParams schema with the fence it read, uses queue-if-active only when advertised, raises a host refusal as an error, and rejects empty text before any call.

  • Manual on macOS against Orca 1.4.238: list, read and send on a live Codex chat; the chat replied to each sent message, including a send while idle and through an external assistant driving the CLI.

  • pnpm lint, pnpm tc, pnpm verify:bundled-skill-guides and pnpm build:electron-vite pass. Vitest over src/cli, src/main/startup and src/shared: 18853 passed; one run had a single failure in git-branch-cleanup-real-git.test.ts (real git, unrelated), which passes 7/7 when rerun alone.

  • Linux, Windows and SSH not tested manually. The commands are platform-neutral RPC calls; for a paired host, --environment/--pairing-code route the same calls.

AI Disclosure

Implemented with an AI coding agent (Claude, claude-opus-5-5) under my direction; I reviewed the change and ran the manual tests.

Review

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

Security: no new RPC methods or permissions; chat send uses the existing workspace-permission agentSession.send with its fence and fingerprint checks. Backwards compatibility: hosts without the message queue receive an ordinary send; a host without a history fence is refused with incompatible_runtime before sending. Performance: one worktree.ps call for list, two calls for send.

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

@coderabbitai

coderabbitai Bot commented Oct 24, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

No actionable comments were generated in the recent review.

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: c71afbff-f3c2-4bb9-8391-dedb63206455
Commits

Reviewing files that changed from the base of the PR and between 096ae84 and 9e66b4b.

Files selected for processing: 2
  • src/cli/handlers/chat.test.ts
  • src/cli/handlers/chat.ts
Files skipped from review as they are similar to previous changes: 2
  • src/cli/handlers/chat.test.ts
  • src/cli/handlers/chat.ts

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

Walkthrough

The CLI adds orca chat list, orca chat read, and orca chat send. These commands list chat sessions, read recent messages and interaction entries, and send text to a session. Sends use a session history fence and request queued delivery when the runtime supports message queues. The change also adds command registration, help text, documentation, and tests.

Severity of issue fixed: Medium

Merge Risk: Minimal · previous review 9e66b

No outstanding issue identified here blocks merging the chat commands after normal checks.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 23.08% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 13 functions across 8 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Title check Passed The title clearly and concisely describes the primary change: adding CLI commands to list, read, and message agent chats.
Description check Passed The description follows the required template and explains the user impact, implementation, rationale, linked issue, testing, limitations, and checklist status.
Linked Issues check Passed Issue [#33114] requires CLI support for listing, reading, and messaging chat agents through existing RPC methods. The reviewed head implements all three commands.

- chat list calls worktree.ps, f…
Out of Scope Changes check Passed The changes remain within issue [#33114]. Handler, selector, formatting, command registration, help, reference documentation, and bundled CLI guidance directly support chat list, chat read, and `c…
Full details: Linked Issues check

Explanation

Issue [#33114] requires CLI support for listing, reading, and messaging chat agents through existing RPC methods. The reviewed head implements all three commands.

  • chat list calls worktree.ps, filters worktree and state, and keeps top-level chat sessions while excluding terminal agents and subagents.
  • chat read calls agentSession.history, removes status frames and turn markers, returns messages, tools, approvals, and questions, marks pending interactions, and pages backward when readable entries do not fill --limit. Reset pages replace the current window before paging continues.
  • chat send reads the session fence, uses the shared structured send envelope and operation ID, adds queue-if-active only for capable hosts, and converts host refusals to errors.
  • Session selectors accept IDs, handles, and pane keys. The tests cover the required filters, transcript behavior, pagination reset, send schema, queue behavior, refusals, and empty text.

The PR adds no RPC method or permission. It does not add approval responses or turn cancellation, which the issue leaves for later.

Full details: Out of Scope Changes check

Explanation

The changes remain within issue [#33114]. Handler, selector, formatting, command registration, help, reference documentation, and bundled CLI guidance directly support chat list, chat read, and chat send. The tests validate these commands and their pagination and delivery behavior. The bundled guide changes for chat-send delivery receipts and user confirmation are directly related to safe use of the new command. No unrelated feature, new permission, new RPC method, approval response, or turn cancellation is included.

  • 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: 2


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: 3f8bb6ad-5764-4e21-a4f9-bee9fd2dac14
Commits

Reviewing files that changed from the base of the PR and between 6ed2e6d and 3fb8e9a.

Files selected for processing: 11
  • docs/site/content/docs/cli/reference.mdx
  • skill-guides/orca-cli.md
  • src/cli/bundled-skill-guides.ts
  • src/cli/chat-sessions.ts
  • src/cli/handler-group-manifest.ts
  • src/cli/handlers/chat.test.ts
  • src/cli/handlers/chat.ts
  • src/cli/root-help-text-primary.ts
  • src/cli/specs/chat.ts
  • src/cli/specs/index.ts
  • src/main/startup/cli-command-names.ts

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

Comment thread skill-guides/orca-cli.md Resolved
Comment thread src/cli/handlers/chat.ts Resolved

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

Caution

Some comments are outside the diff and can’t be posted inline due to GitHub limitations.

⚠️ Outside diff range comments (1)

Minor · Page backward when filtering leaves the requested limit unfilled. · chat.ts:67

src/cli/handlers/chat.ts:67
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Page backward when filtering leaves the requested limit unfilled.

For orca chat read --limit 100, the handler fetches only the newest 200 journal rows. If more than 100 of those rows are provider status frames, turn markers, or other omitted rows, the command returns fewer than 100 entries even when older readable entries exist. The history page exposes hasOlder and an older cursor, but this handler never uses them.

Suggested fix
     const result = await client.call<HistoryResult>('agentSession.history', {
       sessionId: session,
       direction: 'tail',
       limit: Math.min(limit * HISTORY_ROWS_PER_ENTRY, MAX_HISTORY_ROWS)
     })
+    let page = result.result.page
+    let entries = chatTranscript(page.items)
+    while (entries.length < limit && page.hasOlder && page.window.oldest) {
+      const cursor = page.window.oldest
+      const older = await client.call<HistoryResult>('agentSession.history', {
+        sessionId: session,
+        direction: 'before',
+        cursor,
+        limit: MAX_HISTORY_ROWS
+      })
+      const olderPage = older.result.page
+      if (
+        olderPage.window.oldest?.epoch === cursor.epoch &&
+        olderPage.window.oldest?.sequence === cursor.sequence
+      ) {
+        break
+      }
+      entries = [...chatTranscript(olderPage.items), ...entries]
+      page = olderPage
+    }
     printResult(
       {
         ...result,
-        result: { session, entries: chatTranscript(result.result.page.items).slice(-limit) }
+        result: { session, entries: entries.slice(-limit) }
       },

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: 5cad02cc-95f6-426c-9c19-4781577a5b98
Commits

Reviewing files that changed from the base of the PR and between 857f995 and 9d3381b.

Files selected for processing: 3
  • skill-guides/orca-cli.md
  • src/cli/bundled-skill-guides.ts
  • src/cli/handlers/chat.ts
Files skipped from review as they are similar to previous changes: 2
  • skill-guides/orca-cli.md
  • src/cli/handlers/chat.ts

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

@YangNuoCheng

Copy link
Copy Markdown
Contributor Author

Addressed in 096ae84: chat read now pages backward with direction: "before" using page.hasOlder / window.oldest whenever the transcript entries are still short of --limit, stopping when the journal is exhausted or a page echoes the request cursor back. Entries are trimmed to the newest limit, and a test covers the status-frame-heavy case.

@YangNuoCheng

Copy link
Copy Markdown
Contributor Author

Fixed in 096ae84: chat read now pages backward with the history page's hasOlder/window.oldest cursor until the requested entry count is filled or the journal is exhausted, so status frames and turn markers on the newest page no longer leave the limit unfilled. An empty backward page (which reports the request cursor back) stops the loop. Covered by a new test in src/cli/handlers/chat.test.ts; affected tests, pnpm lint, and pnpm tc pass.

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


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: 3034c6c0-6243-462e-9aeb-51154753e82c
Commits

Reviewing files that changed from the base of the PR and between 9d3381b and 096ae84.

Files selected for processing: 2
  • src/cli/handlers/chat.test.ts
  • src/cli/handlers/chat.ts

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

Comment thread src/cli/handlers/chat.ts Resolved
@YangNuoCheng

Copy link
Copy Markdown
Contributor Author

Thanks for the catch — fixed in 9e66b4b.

chat read now checks older.result.ok before combining pages: a reset response replaces the accumulated window with its fresh tail page and paging resumes from that page's cursor, instead of prepending reset rows into the older window. Added a regression test covering a reset mid-backward-paging; chat handler tests, pnpm lint, and pnpm tc all pass.

@YangNuoCheng

Copy link
Copy Markdown
Contributor Author

Hi maintainers, gentle ping on this one. I have been using orca chat list/read/send daily: a voice assistant on my machine (Grok Bot) reads the progress of my Orca agent chats and relays my spoken instructions back into them, so I can manage running agents from my phone. CodeRabbit feedback is addressed and CI is green. Happy to adjust the command shape or naming if you prefer a different design.

@YangNuoCheng

Copy link
Copy Markdown
Contributor Author

Pushed a merge of current main into this branch to clear the merge conflict. The only conflicting file was src/cli/bundled-skill-guides.ts, where main reformatted the guide from one string literal into a line array; I kept main's array format and re-expressed the chat additions in it (the existing-chat handoff line and the ## Chats section). The chat list/read/send code and tests are unchanged.

Verified on a clean checkout of the branch (node config/scripts/build-workspace-packages.mjs first): src/cli/handlers/chat.test.ts, src/cli/skills.test.ts and src/cli/specs/bundled-guide-flags.test.ts pass (30 tests), and pnpm typecheck:node passes. The CI runs for the new commit are waiting on maintainer approval.

@YangNuoCheng

Copy link
Copy Markdown
Contributor Author

Thanks. I am leaving the docstring-coverage warning unchanged: AGENTS.md asks contributors to avoid comments unless the code needs explanation. Adding docstrings solely to reach the bot's 80% threshold would conflict with that guidance.

@YangNuoCheng

Copy link
Copy Markdown
Contributor Author

Cross-linking #37407 — opened as an umbrella issue for super-agent workflows, where this external monitor/control surface is the entry point.

@AmoabaKelvin

Copy link
Copy Markdown
Collaborator

Thanks for this, @YangNuoCheng. It had fallen behind main and needed rebasing, so we carried it over in #40836 with your commit kept as the first one. It also adds chat wait, --wait and stdin text. Please take a look if you can.

AmoabaKelvin pushed a commit that referenced this pull request Nov 10, 2026
Carried over from #33115 (squashed onto current main; conflicts with chat rename resolved).
AmoabaKelvin added a commit that referenced this pull request Nov 10, 2026
…read/send/wait (#40836)

* feat(cli): read and message agent chats with orca chat list/read/send

Carried over from #33115 (squashed onto current main; conflicts with chat rename resolved).

* feat(cli): wait for a chat to settle, read text from stdin, refuse paired hosts

chat send --wait and chat wait poll the history's working flag until the
chat is idle or waits on a question, keeping a queued message pending until
it runs. chat read is one history fetch and returns a cursor. Unattached
and paired-host refusals say what they mean.

* fix(cli): settle a held queued message, skip subagent rows, resolve chat list --worktree

* fix(cli): show chat errors, keep waiting through queue handoffs, return the whole settled turn

* fix(cli): settle any queued message the host will not send, show grouped questions and only answerable prompts

* test(cli): drive chat tests through a real client and fake timers

* fix(cli): describe chat --session, --wait and --state in command help

* fix(cli): report chat wait in chat list's states, reject unknown --state, flag truncated reads

* docs(cli): say chat wait settles on the chat's own turn; no truncated flag on held

* fix(cli): chat rename help asks for a session id, not a handle

---------

Co-authored-by: YangNuoCheng <[email protected]>
@AmoabaKelvin

Copy link
Copy Markdown
Collaborator

Closing in favour of #40836, which is merged now. It carries your commit with you as the author, plus a trim and chat wait / send --wait on top. Thanks @YangNuoCheng, and sorry it took so long.

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.

[Feature]: Read and message agent chats from the CLI (orca chat list/read/send)

2 participants