Skip to content

feat(connectors): post a short status line in a bot's Slack thread while its work runs on - #51414

Merged
AmethystLiang merged 14 commits into
mainfrom
AmethystLiang/thread-status-lines
Nov 28, 2026
Merged

AmethystLiang merged 14 commits into
mainfrom
AmethystLiang/thread-status-lines

Conversation

@AmethystLiang

@AmethystLiang AmethystLiang commented Nov 28, 2026 •

Copy link
Copy Markdown
Contributor

ELI5

A bot can say "on it" in a Slack thread, then hand the work to workers that run for hours. Until now the thread heard nothing until the very end, so the bot looked stalled. With this change, Orca posts a short status line in that thread while the work keeps going. It slows down over time, says once when it stops, and stays quiet whenever the bot itself is about to talk.

Files Added Deleted Net
Test 8 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​1546 0 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​1546
Prod 27 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​1676 $\color{#cf222e}{\Huge{\mathbf{−}}}$​108 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​1568

What Changed

Before: after a bot's turn ended with connector workers still open, the Slack thread got no word at all until the bot's next answer, which could be hours away.

After: Orca posts a short status line in the thread while that work goes on. The only variable in a line is the elapsed time, so it never includes item text, paths, IDs or links. There are three lines:

  • Still working on this (35 min).: workers are running, or a worker waits on helpers it started.
  • Still open (1 h 30 min), but nothing is running on it right now. Reply here to ask where it stands.: work is open but idle.
  • Pausing these automatic updates for now. Reply here to ask where it stands.: posted once, when the run stops. That happens 6 h after the last turn end, when the workers' own cap closes them, or at 12 lines a day.

Cadence: a line goes 30 min after the last visible line in the thread, then 60, then 120. Any bot line resets that clock to 30. An unchanged run posts 5 lines in 6 h. Once the work settles, the run ends silently.

Never posted:

  • while a turn is running, or while the bot's answer is still being sent or held;
  • in the first 2 min after a turn ends;
  • for muted, left or mirror-blocked threads, or for refused bots.

How it works:

  • Workers view (external-conversation-workers.ts, connector-worker-candidates.ts). ConversationWorkers now exposes a view for each pane: activity, whether it is open, helpers running, and the last turn id. Each worker candidate reports whether it has open child dispatches.
  • Line observer (connector-sent-calls.ts, thread-status-lines.ts). One hook in ConnectorAccountTransport.call sees every connector call after it settles. It can't fail a call. From the replies, events and actions calls it reads which visible lines went into which thread, and which prompts are open.
  • Thread fact (external-conversation-link.ts, parser, writes). The link stores a threadStatus fact: seq, the day count, the armed clocks and a saved pending line.
  • Decision (thread-status-decide.ts). A pure decide table returns wait, disarm or post.
  • Sender (thread-status.ts and its helpers). ThreadStatus arms on a heard turn end, runs on every workers update and a 60 s timer, and saves the line before it sends. It re-checks every hold on the fresh link after each wait, and posts only if the same line is still owed. The reply id is status-<hash(thread, seq)>, so a retry can't duplicate a line.
  • Bot rule (bot-preamble.ts). When thread-bound mail is a worker's blocker or ends a step (the last review of a round, a PR opened), the bot writes one plain line for that thread, once per round.

Why

A thread that asked for work should be able to see that the work is still alive, without asking. The host posts the heartbeat itself instead of relying on the bot to remember: it already knows when workers are open, and it also covers bots that don't follow prompt rules. The bot rule covers the moments only the bot can describe, such as a review round finishing, a blocker, or a PR link. Lines are new posts, not edits, because an edited line doesn't notify anyone and is easy to miss. Checked against how comparable products handle this.

Linked Issue

Internal maintainer change; there is no public issue.

Visual Proof

N/A. The change adds Slack thread text and nothing in Orca's UI. The exact line copy is above, and the UX design review passed it.

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

New tests (vitest):

  • thread-status-decide.test.ts: every decide-table row, plus the unchanged 6 h run: lines at 0:30, 1:30, 3:30 and 5:30, then the stop line.
  • thread-status-lines.test.ts: which calls count as host lines and which as bot lines.
  • thread-status.test.ts:
    • the incident replay;
    • holds and the settle window;
    • saved-line resend, staleness and replacement;
    • each await racing a turn start, a turn end, a bot answer or settling;
    • 409 handling and the retry guard.
  • thread-status-counted.test.ts: how a saved line that may or may not be in the thread is counted when it is resent, dropped or its run stops, including after a restart and a failed save.
  • Also: the link round-trip, ConversationWorkers views, and worker candidates with open children.

Fail-before: the new tests were checked failing against the code before each fix.

Local checks on the head: targeted vitest (54/54 across the thread-status files, the link round-trip and the workers tests), node typecheck, and lint on the changed files. Hosted CI covers the full suites.

Performance

None that matters. A 60 s unref'd timer runs only while some thread is armed, and each tick does a few in-memory checks for each armed link. The observer does a constant amount of parsing for each connector call that has already settled. There is one extra indexed SELECT DISTINCT per worker-candidate read, which uses idx_dispatch_creator_mailbox_work. Link writes happen only on change: arming, turn ends and lines.

Risk

Level: Medium

The riskiest part is posting a line in a thread at the wrong moment, for example next to a turn that just started. Every check runs synchronously right before the reply call, so at worst one extra status line posts. It never duplicates a line and never carries private content.

Known follow-ups (tracked separately; none of them can post private content or duplicate a line):

  • Token step. Inside the one reply call, the connector transport may mint or renew its auth token before the request leaves. Nothing re-checks the line during that step. Closing it needs a pre-send guard in the shared connector transport.
  • One clock read. A due line's text and its saved time come from two clock reads. If those land on either side of a minute boundary, the saved line fails its own text check and is dropped, and it goes out a tick later. The fix is to use one timestamp.
  • Cleanup when the cloud is missing. When the cloud connection or the conversation is missing right after a save, a stale saved line is cleaned up on a later tick instead of at once. Sending still re-checks it.
  • Retry wait. When a status reply hits a retryable error, the reply helper waits out its backoff before it sees that the caller allows no retry. A 429 therefore waits twice as long. The fix is to check before sleeping.
  • Offline ticks. While the cloud connection is down, a due tick still saves a new pending line about every 11 min. Nothing is posted. The fix is to check that the cloud is there before saving.
  • Late acceptance after a timeout. If a status reply times out at 15 s and the server still accepts it later, after Orca has dropped and counted the line, the next line can come a little earlier than its usual wait from the real delivery. It can't duplicate a line. Closing it needs the server to reconcile late replies, or a delivery deadline it enforces.
  • Stop line after a restart. Orca counts a saved line read back after a restart as possibly posted, because nothing on disk says whether it went. If the workers had already closed, the run can then post its stop line although no update was visible, and that uses two of the day's lines. This is the same conservative rule that keeps a line from following an unseen one too soon. A delivery receipt from the cloud would let Orca tell the two apart.
  • Late cleanup. In a few cases a disarm or a pending drop waits for the next 60 s tick instead of happening at once: a stale line that is also owed a disarm, a turn that ends and settles during the answer read, and an overtaken line while the next one isn't due. In all of these, nothing stale can be sent.

The new threadStatus field on the link is optional, and older builds ignore it. To back out, revert the PR. A leftover threadStatus field is harmless.

AI Disclosure

Review

  • Code review: passed on the final head with no blocking findings; minor notes are listed under the known follow-ups.
  • UX review: the line copy passed.

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: lines contain only fixed text and the elapsed time.
  • Platforms: main-process only; there is nothing platform-specific.
  • Remote SSH and mobile: not affected.
  • Backwards compatibility: the new link field is optional.

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)

…ile its work runs on

When a bot's thread turn ends with workers still open, Orca now posts a short
reply in that thread after 30, then 60, then every 120 quiet minutes, and one
stop line after 6 hours. Lines are Orca's own (turnFor none), never wake the
bot, hold while the turn or its answer is still on its way, and are kept on
the thread's link so a restart neither repeats nor drops one. The bot rules
also ask for one line when a worker reports a blocker or ends a step.
…ids unique and never race a turn's answer

- A turn end arms only while the day has room for an update and the stop
  line; the stop line is the day's last, and a run that posted no update
  ends quietly instead.
- Reply ids include the run's start, so a dropped link that restarts the
  numbering never repeats one.
- The turn-ended read never decides a line: it restarts the wait, and the
  next tick decides once the answer is on its way.
- A run that can neither read its workers nor stop for 30 minutes past its
  end disarms; Retry-After is honoured; watcher and evaluation errors are
  contained.
…'s words

- A test pins the two bot-rule sentences for the items variant and leaves
  the plain variant unchanged.
- The stop line says it pauses the updates, as specified.
- The backoff step and the worker-candidate test drop their casts and the
  wall clock.
…alse

It also ends a run at the day's line cap or when the workers read closes,
where "no change for a while" isn't true.
…ved line waits like a new one

- A turn end restarts only the 6 hour clock. The thread's own lines, the
  turn's answer included, restart the wait for the next one, so turn ends
  that post nothing no longer silence or flatten the backoff.
- Lines wait 2 minutes from the moment a turn ends, before its answer is
  read, so none lands beside that answer.
- A saved line is sent again only while a new one could go: not during a
  running turn, not after the work settles, and never once it is older
  than 10 minutes or a line reached the thread after it.
- The day's last line, the stop line, goes when the next update would be due.
- A turn end clears only prompts shown before it in the same batch.
- A new run starts with no conflict left from an earlier one.
- Drops the bot-rules copy test: copy is not tested here.
Waiting for its save or the answer read could let a line out that no longer
fits: a turn started or ended, the bot answered, or the work settled
meanwhile. Every attempt now asks again, with nothing awaited before the post
and before each retry, whether a fresh decision would post this same line
with nothing holding it.
…nothing goes first

- An answer read counts only for the pane's turn it read, and not once a
  turn has ended since it began.
- A saved line posts only if the workers' state would still give the same
  words; a working line is never sent for idle work, or the reverse.
- A saved line no longer owed is dropped, or its run stopped, at once, and a
  read that lands mid-decision is decided straight after.
- The checks run on the link as it is after each wait, and the cloud is
  asked again after the save.
- One try per tick: the next tick sends the same id again with every check.
- A bot line in the same moment as a saved line overtakes it.
@coderabbitai

coderabbitai Bot commented Nov 28, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

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.

Walkthrough

The change adds persisted thread-status facts, worker activity tracking, and connector-call observation for external conversations. A status process uses this data to decide when to post thread updates and handles pending replies, retries, and conflicts. Connector action classification is shared with thread-line extraction. Bot instructions also change when workers should send thread updates or chat replies.

Merge Risk: Minimal · up to 2864f

This adds periodic thread status updates for long-running connector workers. Earlier review concerns about duplicate or miscounted status lines were reported as fixed. No remaining merge-blocking risk was identified.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title names the main change: a short status line posted in a bot's Slack thread while connector work runs. It follows the conventional type(scope) prefix, and the changeset adds exactly this statu…
Description check Passed The description follows the template structure: ELI5, What Changed, Why, Linked Issue, Visual Proof, Testing, Performance, Risk, AI Disclosure, Review, Agent skill upstream boundary, Notes, and Checkl…
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.
Full details: Title check

Explanation

The title names the main change: a short status line posted in a bot's Slack thread while connector work runs. It follows the conventional type(scope) prefix, and the changeset adds exactly this status-post mechanism, so it is clearly related to the main change.

Full details: Description check

Explanation

The description follows the template structure: ELI5, What Changed, Why, Linked Issue, Visual Proof, Testing, Performance, Risk, AI Disclosure, Review, Agent skill upstream boundary, Notes, and Checklist are all present and substantively filled in. The Performance section gives a reasoned answer, and the Risk section names the riskiest part and how to back it out. Gaps are minor: the Linked Issue section says there is no public issue, the Risk level is set, the AI Disclosure section is empty, and the final lint/typecheck/test/build checklist item is unchecked.

  • 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: b2cd2902-527d-4f96-a159-aeb26e906489
Commits

Reviewing files that changed from the base of the PR and between dc526d1 and 2864fa0.

Files selected for processing: 3

  • src/main/connector-cloud/connector-action-into-thread.test.ts
  • src/main/connector-cloud/connector-action-into-thread.ts
  • src/main/runtime/rpc/methods/connector-act.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.

@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: f0121130-5760-4939-961f-5355d1b94979
Commits

Reviewing files that changed from the base of the PR and between c78d85c and 61989b7.

Files selected for processing: 32

  • src/main/bots/bot-preamble.ts
  • src/main/connector-cloud/connector-action-into-thread.ts
  • src/main/connector-cloud/connector-sent-calls.ts
  • src/main/connector-cloud/connector-transport.ts
  • src/main/external-conversations/external-conversation-chat-turns.ts
  • src/main/external-conversations/external-conversation-leave-lines.ts
  • src/main/external-conversations/external-conversation-link-parser.ts
  • src/main/external-conversations/external-conversation-link-thread-status.test.ts
  • src/main/external-conversations/external-conversation-link-writes.ts
  • src/main/external-conversations/external-conversation-worker-activities.ts
  • src/main/external-conversations/external-conversation-worker-view.ts
  • src/main/external-conversations/external-conversation-workers.test.ts
  • src/main/external-conversations/external-conversation-workers.ts
  • src/main/external-conversations/external-conversations-install.ts
  • src/main/external-conversations/thread-status/thread-status-decide.test.ts
  • src/main/external-conversations/thread-status/thread-status-decide.ts
  • src/main/external-conversations/thread-status/thread-status-deps.ts
  • src/main/external-conversations/thread-status/thread-status-fact.ts
  • src/main/external-conversations/thread-status/thread-status-hold.ts
  • src/main/external-conversations/thread-status/thread-status-lines.test.ts
  • src/main/external-conversations/thread-status/thread-status-lines.ts
  • src/main/external-conversations/thread-status/thread-status-owed.ts
  • src/main/external-conversations/thread-status/thread-status-send.ts
  • src/main/external-conversations/thread-status/thread-status-start.ts
  • src/main/external-conversations/thread-status/thread-status-waits.ts
  • src/main/external-conversations/thread-status/thread-status.test.ts
  • src/main/external-conversations/thread-status/thread-status.ts
  • src/main/runtime/orchestration/db/connector-workers/connector-worker-candidates.test.ts
  • src/main/runtime/orchestration/db/connector-workers/connector-worker-candidates.ts
  • src/main/runtime/rpc/methods/connector-act.ts
  • src/main/runtime/rpc/methods/orchestration/worker/connector-worker-activity.ts
  • src/shared/connectors/external-conversation-link.ts

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

Comment thread src/main/bots/bot-preamble.ts Resolved
- A saved line notes when it was last sent. If it is dropped later, with no
  bot line since, it counts as Orca's line: the next one keeps the backoff
  and never follows it under a new id minutes later. A stop line that may
  have posted ends the run.
- The bot rule's silence clause yields to the thread line for a worker's
  blocker or a finished step.

@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: 298d32d1-c7e0-4658-8818-c510784f854f
Commits

Reviewing files that changed from the base of the PR and between 61989b7 and 6f31fb5.

Files selected for processing: 7

  • src/main/bots/bot-preamble.ts
  • src/main/external-conversations/external-conversation-link-parser.ts
  • src/main/external-conversations/external-conversation-link-thread-status.test.ts
  • src/main/external-conversations/thread-status/thread-status-fact.ts
  • src/main/external-conversations/thread-status/thread-status.test.ts
  • src/main/external-conversations/thread-status/thread-status.ts
  • src/shared/connectors/external-conversation-link.ts

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

Comment thread src/main/bots/bot-preamble.ts Resolved
…ver went

- A saved line that is dropped counts as Orca's line as of the drop,
  whatever bot lines came meanwhile. The one exception is a line this
  process saved and never handed to the cloud. Nothing on disk has to say
  so: a line saved before a restart, or by an older Orca, counts too.
- A stop line that may have posted ends the run the normal way, so its
  conflicts and backoff never carry into the next run.
- The attempt marker on the link is gone.

@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: 79191ad5-b9a0-4345-9cbe-620114d75caa
Commits

Reviewing files that changed from the base of the PR and between 6f31fb5 and acaaf15.

Files selected for processing: 7

  • src/main/external-conversations/external-conversation-link-parser.ts
  • src/main/external-conversations/external-conversation-link-thread-status.test.ts
  • src/main/external-conversations/thread-status/thread-status-fact.ts
  • src/main/external-conversations/thread-status/thread-status-waits.ts
  • src/main/external-conversations/thread-status/thread-status.test.ts
  • src/main/external-conversations/thread-status/thread-status.ts
  • src/shared/connectors/external-conversation-link.ts

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

…it stops

The first update can go out with no answer seen, leaving the run's line count unset. If the
workers then closed, the 6 hour stop came or the day filled before that line settled, the run
ended quietly as if it had never posted. A saved line that may have posted now counts for that
choice, so the stop line still goes; only a line this process knows it never sent stays quiet.
…status-lines

# Conflicts:
#	src/main/bots/bot-preamble.ts
…y have posted

- A muted thread, settled work or a stuck run stopped its status lines without counting a saved
  line the cloud may have taken, so a later run that day could go one past the cap. It now counts,
  unless this process knows the line never went or the cloud refused it.
- A saved line is marked unsent only once it is on the link: a failed save no longer makes the
  never-sent line before it look posted.
- The bot rule asks for a blocker's thread line at once, even while other reviews of the round are
  still out.
- The ThreadStatus tests share a harness; the saved-line counting cases move to their own file.
…d still counts it

A refusal or conflict answers only the try it came back for. When an earlier try of the same line
got no answer, the cloud may already have posted it, so the dropped line now counts for the day
and the backoff, as any dropped line that may have posted does.
@AmethystLiang

Copy link
Copy Markdown
Contributor Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Nov 28, 2026 •

Copy link
Copy Markdown
Contributor
Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

…status-lines

Conflict in connector-act.ts: main (#51597) kept a scheduled post out of the chat's own answer
inline, where this branch calls the shared connectorActionIntoThread. The exclusion moves into
that helper, so both of its callers keep it; connector-act keeps its own `scheduled` for the
request-post note below.
@AmethystLiang

Copy link
Copy Markdown
Contributor Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Nov 28, 2026 •

Copy link
Copy Markdown
Contributor
Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@AmethystLiang
AmethystLiang merged commit 50dc738 into main Nov 28, 2026
57 checks passed
AmethystLiang added a commit that referenced this pull request Nov 29, 2026
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