Skip to content

fix(factory): replay existing Slack triage answers#36

Merged
khaliqgant merged 1 commit into
mainfrom
fix/replay-existing-slack-triage-reply
Jun 22, 2026
Merged

fix(factory): replay existing Slack triage answers#36
khaliqgant merged 1 commit into
mainfrom
fix/replay-existing-slack-triage-reply

Conversation

@miyaontherelay

@miyaontherelay miyaontherelay commented Jun 22, 2026

Copy link
Copy Markdown
Contributor

Summary

  • replay the latest pre-existing human reply when a pre-dispatch Slack triage escalation watcher starts
  • return the replay-triggered dispatch result from manual dispatch, so the CLI reports spawned agents instead of an empty escalation result
  • avoid self-waiting on the watcher startup promise when replay dispatches while the watcher is being established

Why

AR-287 had already been answered in Slack before the upgraded factory process started. The watcher seeded existing Slack events and ignored them, so only a brand-new reply would unblock dispatch. This preserves old-reply suppression for normal dispatched agent threads, but lets triage escalation threads consume the existing human clarification.

Testing

  • npm test -- src/orchestrator/factory.test.ts
  • npm run build
  • npm test

@gemini-code-assist

Copy link
Copy Markdown

Warning

You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again!

@coderabbitai

coderabbitai Bot commented Jun 22, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: bbc64da0-5eda-4010-b199-049050578881

📥 Commits

Reviewing files that changed from the base of the PR and between 355acb1 and ad7ad14.

📒 Files selected for processing (2)
  • src/orchestrator/factory.test.ts
  • src/orchestrator/factory.ts

📝 Walkthrough

Walkthrough

The PR refactors the Slack triage escalation path in factory.ts so that pre-existing human replies are replayed when a watcher starts. A new #slackWatcherStarts map coordinates watcher startup; private methods are updated to return DispatchResult | undefined; #replayLatestSlackTriageAnswer scans ordered pre-existing reply paths and routes the latest qualifying reply to implementers. A matching test covers the end-to-end replay behavior.

Changes

Slack Triage Escalation Reply Replay

Layer / File(s) Summary
DispatchResult return type propagation
src/orchestrator/factory.ts
#escalateTriageToSlack, #postAndWatchSlackEscalationThread, #routeSlackAnswerToImplementers, and #handleTriageEscalationSlackAnswer change return types from Promise<void> to Promise<DispatchResult | undefined>; callers return rather than only await the result from #startOrQueueSlackClarifiedDecision.
#slackWatcherStarts coordination
src/orchestrator/factory.ts
Adds a #slackWatcherStarts map to FactoryLoop; #ensureSlackDispatchThread and #escalateTriageToSlack use slackWatcherStarts.get(key) to detect and await in-flight watcher startup before rearming.
Pre-existing path ordering and #replayLatestSlackTriageAnswer
src/orchestrator/factory.ts
#watchSlackThread gains preExistingPathOrder for deterministic reply-path ordering; new #replayLatestSlackTriageAnswer scans that list for the latest qualifying triage escalation reply, routes it to implementers, increments slackTriageAnswersReplayed, and returns the DispatchResult; #postAndWatchSlackEscalationThread captures and returns replayedResult.
dispatch() wiring and test
src/orchestrator/factory.ts, src/orchestrator/factory.test.ts
dispatch() captures the DispatchResult from #escalateTriageToSlack and returns it or an empty-agent fallback; new test seeds a persisted Slack reply, dispatches a triage-escalation issue, asserts agent spawns, injected <integration-event source="slack"> payload, and slackTriageAnswersReplayed/dispatched/injected counters.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

  • AgentWorkforce/factory#11: Introduced the <integration-event source="slack"> payload framing that this PR's triage escalation replay routing injects into the implementer agent.
  • AgentWorkforce/factory#34: Both PRs modify factory.ts and factory.test.ts to handle Slack triage escalation replies arriving before dispatch via #routeSlackAnswerToImplementers / #handleTriageEscalationSlackAnswer and assert the matching Slack counters.
  • AgentWorkforce/factory#35: Both PRs modify the Slack triage escalation/human-clarification handling in factory.ts and factory.test.ts, specifically around routing and injecting Slack replies to spawned implementer/workflow agents.

Poem

🐇 Hop, hop! A reply arrived before the watcher's eye,
So I stored it in order, then replayed it on the fly.
The escalation tunnel now returns a dispatch too,
No lost triage answer—every path flows through!
A map of startup promises keeps the race at bay,
And counters tick correctly at the end of the day. 🎉

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately summarizes the main change: replaying existing Slack triage answers when a watcher starts, which is the primary objective of the PR.
Description check ✅ Passed The description is directly related to the changeset, explaining the motivation, implementation approach, and testing steps for replaying pre-existing Slack triage answers.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/replay-existing-slack-triage-reply

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

Comment @coderabbitai help to get the list of available commands and usage tips.

@khaliqgant khaliqgant merged commit bf9f068 into main Jun 22, 2026
3 checks passed
@khaliqgant khaliqgant deleted the fix/replay-existing-slack-triage-reply branch June 22, 2026 20:39
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.

2 participants