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
fix(bots): route --item mail and its files to the Home Chat once the item's chat is closed - #52378
When you message a bot about one of its items, Orca sends the message to the chat where the item was made. If that chat was closed, for example after the bot started a fresh Home Chat, the message was refused. Now it goes to the bot's current Home Chat, which is where the item's other updates already go. Any files you attach go there too.
What Changed
Before: orca orchestration send --to bot:<name> --item <n> fell back to the Home Chat only when the item's chat record had been deleted. A closed chat keeps its record (an older Home Chat replaced by bot new-chat, or a side chat whose tab was closed), so the mail was addressed to that closed chat and refused with has ended: its chat was closed. No message was sent. With --file, it was refused earlier with This item's chat was deleted, so files can't be attached here.
After: both sends go to the Home Chat, and the files are claimed for the Home Chat.
How it works:
bot-chat-address.tschatForItem: uses the item's chat only while it takes mail (botChatTakingMail). Otherwise it returns no chat, so the mail goes to bot:<name>, which is the Home Chat.
bot-item-mail-files.tswithItemMailFiles: now takes the chat routeBotMail chose and claims the files for that same chat, so files and mail can never end up in different chats. For the Home Chat it uses botHomeMailSession.
bot-mail-chat.ts: the Home Chat half of botMailSession is split out as botHomeMailSession, so nothing is reimplemented.
peer-mail-files.ts and the local --file refusal now say the files go to the item's chat, or the Home Chat once that chat is closed.
--chat <id> is unchanged: mail sent to a closed chat by id is still refused. If the item's chat closes after it was chosen but before its files are claimed, the send is refused, as on main.
Why
The item's own change mail and owner comments already pick their chat with botMailSession: the item's chat while it takes mail, else the Home Chat. #47967 moved the sidebar's item replies with screenshots onto that rule. --item mail was the last path still on the old rule. This puts it on the same rule and reuses the existing Home Chat lookup.
N/A. This changes which chat a CLI orchestration send --item is routed to. There is no UI change.
Testing
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
No test is committed. The routing test from the first revision was dropped during review. The behavior was checked with a throwaway probe that runs routeBotMail against a real chat record store and attachment store, with only delivery mocked:
Case
main
this PR
item's side chat open
that chat
that chat
item's chat is a replaced (closed) Home Chat
closed chat, delivery refused: has ended: its chat was closed
bot:Nightly (Home)
same, with --file
refused: This item's chat was deleted
bot:Nightly, file claimed for Home
item's chat record deleted, with --file
refused
bot:Nightly, file claimed for Home
item's chat closes after routing, before file claim
refused
refused, nothing claimed for Home
Re-ran the probe on this commit rebased onto current main. Results match the table.
oxfmt, anti-slop oxlint, code-quality oxlint, ast-grep and the changed-code quality gate are clean on the 4 changed files.
Platforms: macOS, unit level. There is no platform-specific code.
Performance
None that matters. This only runs on orchestration send --item, a one-off CLI request, never on a hot path. It adds one chat-record lookup (botChatTakingMail) while routing. Probe benchmark per send: 0.002 ms on main and 0.010 ms here with 10 chats, and 0.002 ms vs 0.057 ms with 2000 chats. Main's number is the early refusal, so it is not a like-for-like comparison. Either way the cost stays far below 1 ms, with no new polling, subprocess or sync disk work.
Risk
Level: Low
If an item's chat can't take mail for another reason (it runs on another host, its /clear lineage can't be verified, or it was a Look around run), its --item mail now goes to the Home Chat instead of being refused. Item change mail already behaves this way.
Files are claimed for the Home Chat before the mail is stored. If a bot new-chat lands in that window, the files stay claimed for the old Home Chat.
Mixed versions: the change is host-side routing only. A paired Orca still uploads files the same way, and only the refusal text changed.
Back out with a plain revert. No saved data or settings change.
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
Ensure no issues in: Security, Cross-platform support (Linux, Windows, Mac), Remote SSH, Mobile, general backwards compatibility, performance
Original fix by @yeong-chae in #52378. Their authorship is kept as a co-author on the squashed commit.
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)
[Medium impact] The PR appears safe to merge, with no new actionable issues found.
Summary
Routes --item mail to the item's chat while it takes mail, otherwise to the bot's Home Chat.
Bot item messages go to the Home Chat when their chat closes.
Diagram
%%{init: {'theme': 'neutral'}}%%
flowchart TD
A["Send mail with --item"] --> B{"Item's chat takes mail?"}
B -->|Yes| C["Choose item's chat"]
B -->|No| D["Choose Home Chat"]
C --> E["Claim files for chosen chat"]
D --> E
E --> F["Route mail"]
No actionable comments were generated in the recent review.
Walkthrough
Item mail now uses the item’s recorded chat only while that chat takes mail. Otherwise, routing selects the bot’s Home Chat. Attachment claims use the selected chat or the Home mail session when no chat was selected. The refusal messages now describe the Home Chat destination.
Severity of issue fixed: Medium
Merge Risk: Low · up to 45e53
Item mail now falls back to the Home Chat when the item's chat is closed, as the linked issue requests. One rare case remains: if the Home Chat is replaced during a send, attached files may stay claimed for the old Home Chat. The author has acknowledged this.
Pre-merge checks: 4
Check name
Status
Explanation
Linked Issues check
Issue #52377 requires orchestration send --to bot:<name> --item <n> to reach the bot's current Home Chat when the item's chat is closed, with --file attachments following the same destination. At …
Out of Scope Changes check
Each changed area ties to #52377. bot-chat-address.ts changes the routing condition and passes the chosen chat to the file step. bot-item-mail-files.ts takes the chat as a parameter and claims fil…
Title check
The title names the main change: when an item's chat is closed, --item mail and its files go to the bot's Home Chat. It also states the fix type and scope. It matches the raw summary and the PR obje…
Description check
The description follows the repository template and fills every required section. It has an ELI5, a before/after in What Changed, the mechanism per file, a Why, a linked issue (Fixes #52377), N/A visu…
Full details: Linked Issues check
Explanation
Issue #52377 requires orchestration send --to bot:<name> --item <n> to reach the bot's current Home Chat when the item's chat is closed, with --file attachments following the same destination. At head 45e53ce, chatForItem in bot-chat-address.ts returns the item's chat only when it is not gone and botChatTakingMail accepts it. Otherwise it returns undefined, so mail goes to bot:<name>. routeBotMail passes the chosen chat to withItemMailFiles in bot-item-mail-files.ts, which claims files for that chat, or for botHomeMailSession when no item chat is chosen. This removes the commentChatDeleted refusal for closed item chats. The new bot-chat-address.test.ts covers the closed-chat mail and file cases. Explicit --chat <id> handling is unchanged. The PR discloses a known gap: if the Home Chat is replaced between file claim and mail storage, files stay on the old chat. The issue does not state a requirement for that case. The test suite was not run during this assessment; the conclusion rests on source inspection and the PR's reported test results.
Full details: Out of Scope Changes check
Explanation
Each changed area ties to #52377. bot-chat-address.ts changes the routing condition and passes the chosen chat to the file step. bot-item-mail-files.ts takes the chat as a parameter and claims files for the same destination as the mail. bot-mail-chat.ts extracts botHomeMailSession from botMailSession. Source diff confirms the refactor keeps behavior: the original chat session is returned when it takes mail, and otherwise the Home Chat session is returned. The extracted function is needed for the Home claim. peer-mail-files.ts changes only the refusal message text for the --file path, which describes the new fallback. The new test file tests the changed behavior. No unrelated paths, configuration, or interfaces change.
Full details: Title check
Explanation
The title names the main change: when an item's chat is closed, --item mail and its files go to the bot's Home Chat. It also states the fix type and scope. It matches the raw summary and the PR objectives, which both describe routing to the Home Chat when the item's chat stops taking mail.
Full details: Description check
Explanation
The description follows the repository template and fills every required section. It has an ELI5, a before/after in What Changed, the mechanism per file, a Why, a linked issue (Fixes #52377), N/A visual proof with reason, detailed testing with a case table, a performance line, and a risk section with level and back-out plan. The AI Disclosure section is left empty, which is acceptable for an internal contributor. Some template comment text was kept only in the unchanged form, and the Review heading is empty, but these are non-critical.
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; 0 remain after this review.
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 8 remain after this review.
…item's chat is closed
`orchestration send --to bot:<name> --item <n>` fell back to the Home Chat
only when the item's chat record was deleted. A closed chat (a Home Chat
replaced by `bot new-chat`, or a side chat whose tab was closed) keeps its
record, so the mail was addressed to it and refused, and `--file` was
refused with "This item's chat was deleted".
chatForItem now uses the item's chat only while it takes mail
(botChatTakingMail), else the Home Chat, the rule item change mail already
follows via botMailSession. routeBotMail passes that choice to
withItemMailFiles so the files are claimed for the same chat the mail goes
to; the Home Chat lookup is split out of botMailSession as
botHomeMailSession.
Fixesstablyai#52377
Co-authored-by: yeong-chae <[email protected]>
nwparker
changed the title
fix(bots): send --item mail and its files to the Home Chat once the item's chat closed
fix(bots): route --item mail and its files to the Home Chat once the item's chat is closed
Nov 29, 2026
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
When you message a bot about one of its items, Orca sends the message to the chat where the item was made. If that chat was closed, for example after the bot started a fresh Home Chat, the message was refused. Now it goes to the bot's current Home Chat, which is where the item's other updates already go. Any files you attach go there too.
What Changed
Before:
orca orchestration send --to bot:<name> --item <n>fell back to the Home Chat only when the item's chat record had been deleted. A closed chat keeps its record (an older Home Chat replaced bybot new-chat, or a side chat whose tab was closed), so the mail was addressed to that closed chat and refused withhas ended: its chat was closed. No message was sent.With--file, it was refused earlier withThis item's chat was deleted, so files can't be attached here.After: both sends go to the Home Chat, and the files are claimed for the Home Chat.
How it works:
bot-chat-address.tschatForItem: uses the item's chat only while it takes mail (botChatTakingMail). Otherwise it returns no chat, so the mail goes tobot:<name>, which is the Home Chat.bot-item-mail-files.tswithItemMailFiles: now takes the chatrouteBotMailchose and claims the files for that same chat, so files and mail can never end up in different chats. For the Home Chat it usesbotHomeMailSession.bot-mail-chat.ts: the Home Chat half ofbotMailSessionis split out asbotHomeMailSession, so nothing is reimplemented.peer-mail-files.tsand the local--filerefusal now say the files go to the item's chat, or the Home Chat once that chat is closed.--chat <id>is unchanged: mail sent to a closed chat by id is still refused. If the item's chat closes after it was chosen but before its files are claimed, the send is refused, as on main.Why
The item's own change mail and owner comments already pick their chat with
botMailSession: the item's chat while it takes mail, else the Home Chat. #47967 moved the sidebar's item replies with screenshots onto that rule.--itemmail was the last path still on the old rule. This puts it on the same rule and reuses the existing Home Chat lookup.Linked Issue
Fixes #52377
Visual Proof
N/A. This changes which chat a CLI
orchestration send --itemis routed to. There is no UI change.Testing
No test is committed. The routing test from the first revision was dropped during review. The behavior was checked with a throwaway probe that runs
routeBotMailagainst a real chat record store and attachment store, with only delivery mocked:has ended: its chat was closedbot:Nightly(Home)--fileThis item's chat was deletedbot:Nightly, file claimed for Home--filebot:Nightly, file claimed for Homebot-items-runtime,bot-group-mail-root,bots-items-self-echo-mail,bots-items-worker-origin,remote-owned-route,send-params,agent-session-attachment-sweep(7 files, 19 tests) pass.Performance
None that matters. This only runs on
orchestration send --item, a one-off CLI request, never on a hot path. It adds one chat-record lookup (botChatTakingMail) while routing. Probe benchmark per send: 0.002 ms on main and 0.010 ms here with 10 chats, and 0.002 ms vs 0.057 ms with 2000 chats. Main's number is the early refusal, so it is not a like-for-like comparison. Either way the cost stays far below 1 ms, with no new polling, subprocess or sync disk work.Risk
Level: Low
/clearlineage can't be verified, or it was a Look around run), its--itemmail now goes to the Home Chat instead of being refused. Item change mail already behaves this way.bot new-chatlands in that window, the files stay claimed for the old Home Chat.Review
Agent skill upstream boundary
Notes
Ensure no issues in: Security, Cross-platform support (Linux, Windows, Mac), Remote SSH, Mobile, general backwards compatibility, performance
Original fix by @yeong-chae in #52378. Their authorship is kept as a co-author on the squashed commit.
Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)