Repository navigation
fix(bots): stop listing precheck-skipped automation runs as chats - #51427
Conversation
|
No actionable comments were generated in the recent review. Walkthrough
Severity of issue fixed: Medium Merge Risk:
|
A bot automation run skipped before launch (failed precheck, missed, unavailable, needs interactive auth) has no chat or terminal, but terminalRunChats listed it as a title-only row in the bot's Chats tree. Leave out skipped runs with no launchedAt, terminal pane or terminal session; the skips remain in the automation's run history. Fixes stablyai#51428
cad6425 to
68fc293
Compare
ELI5
When a bot's scheduled automation has a precheck and the precheck says "nothing to do", the run is skipped and nothing starts. The bot's Chats list still added a row for every skip, named after the automation, with nothing behind it. A frequent automation filled the list with these empty rows. Now those skips are not listed as chats.
What Changed
skipped_precheck, and likewiseskipped_missed,skipped_unavailable,skipped_needs_interactive_auth) added a title-only row to the bot's right-panel Chats list. A 15-minute automation added dozens a day and pushed real chats down. Clicking one opened the run's details page, not a chat.dispatch_failedruns, terminal runs, and skips that did open a terminal are listed as before. Every skip is still in the automation's run history (Automations page,orca automations runs) and in the bot's Activity section.terminalRunChatsinsrc/main/bots/bot-chat-tree-rows.tslists automation runs that have no chat of their own (meant for terminal-only runs). It now drops a run whose status tone isskipped(getToneForAutomationRunStatus) when it has nolaunchedAt, noterminalPaneKeyand noterminalSessionId. The launch fields are checked first, so launched runs short-circuit before the status check. Older records may lacklaunchedAt, so the terminal fields still count as evidence.Why
The precheck fails in
runAutomationLaunchbefore the dispatcher runs, so a skipped run never gets achatSessionIdor a terminal.terminalRunChatsonly checked for a missingchatSessionIdand an existing automation, so it treated each skip like a terminal run.Alternatives considered:
chatSessionId: would also hide runs that failed to start, which are worth seeing, and would leave the same problem for terminal-surface automations with a precheck.bots.chatTreealso feeds the phone and paired clients, so fixing it on the host covers all of them.Linked Issue
Fixes #51428
Visual Proof
Same isolated profile and steps on both builds: a new bot with an every-minute automation (precheck
false), after 3 scheduled runs endedskipped_precheck. Right-panel Chats tab, cropped to the panel.Testing
Real app, macOS (by @yohangwak): built
mainand this branch with an isolated profile, created the bot and automation through the runtime RPC, waited for 3skipped_precheckruns and readbots.chatTree. main returned Home Chat plus 3run:<id>rows; this branch returned only Home Chat, andautomation.runsstill listed all 3 skips.Re-verified at landing with a scratch vitest against
terminalRunChats(old copy frommainvs new):skipped_precheck/skipped_missedwith no launch evidence are dropped; skips with aterminalPaneKey,terminalSessionIdorlaunchedAtare kept;dispatch_failed,completedanddispatchingrows are unchanged; runs with achatSessionIdstay excluded.src/main/botsvitest: 542 passed; the only failures aresharing/bot-package-archive.test.ts, which throw "no system keyring" in this sandboxed environment and do not touch the chat tree.Static gates on the touched file: anti-slop oxlint, code-quality oxlint, ast-grep, changed-code quality gate, oxfmt — all clean.
Not run on Linux/Windows; the change is platform-independent main-process logic.
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 — N/A, no test added: this is one list rule in a read model, below the repo's bar for unit tests.
Performance
None, because it adds an O(1) field check per automation run already iterated on each
bots.chatTreeread (main process, not a hot path); no I/O, no new polling, no fan-out across rows. MeasuredterminalRunChatsold vs new: 200 launched runs 12.4 vs 12.2 µs/call; 2000 runs with half precheck-skipped 119 vs 86 µs/call (faster, since skipped rows are no longer built).Risk
Level: Low
The riskiest part is hiding a row someone relied on: before, clicking a skip's row opened that run's details. Only skips with no launch evidence are dropped, and they stay in run history and the Activity section. Paired phones and SSH hosts get the same list from the host's
bots.chatTree. No saved data changes; back out with a plain revert.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 @yohangwak in #51427; squashed onto current
mainwith authorship preserved.Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)