Repository navigation
feat(flows): FlowRunFinished event — fully event-driven runs rail (completes B35) - #5115
Conversation
…vent-driven
Completes B35. Adds DomainEvent::FlowRunFinished { flow_id, run_id, status }
emitted from finish_flow_run_row and bridged to Socket.IO (flow:run_finished),
plus a useFlowRunFinished hook (dedup-once over both aliases, PII-safe log).
FlowRunsSidebar/Drawer/WorkflowRunsPage subscribe to it so terminal status
updates arrive live, letting the short 2s/5s poll fallbacks be dropped in favor
of the start+progress+finish event stream.
|
Warning Review limit reachedYou’ve reached a temporary PR review limit under our Fair Usage Limits Policy. Next review available in: 37 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (15)
Comment |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: ff4f565972
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| crate::core::event_bus::publish_global(crate::core::event_bus::DomainEvent::FlowRunFinished { | ||
| flow_id: flow_id.to_string(), | ||
| run_id: thread_id.to_string(), | ||
| status: status.to_string(), | ||
| }); |
There was a problem hiding this comment.
Emit finish events only for terminal runs
When a workflow pauses for an approval gate, finalize_terminal_status returns "pending_approval", and this helper is still called with that status before the run later resumes using the same thread_id. Publishing FlowRunFinished here for the pause makes useFlowRunFinished cache the ${flow_id}:${run_id} key, so the real completion event after flows_resume is treated as an alias replay and ignored; approval-gated runs can then stay stale in the runs list until the 30s backstop. Please gate this publish to actual terminal statuses (or otherwise avoid de-duping the pause and final settle as the same finish).
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Confirmed and fixed — finish_flow_run_row now returns before publishing FlowRunFinished when status == "pending_approval". The row is still persisted either way (so poll-based fallbacks see the paused state), but the event only fires for actual terminal settles. Added a regression test (flows_run_finished_event_skips_pending_approval_and_fires_once_on_resume) that runs an approval-gated graph, asserts no FlowRunFinished fires at the pause, then resumes and asserts exactly one fires with status: "completed". Will push shortly.
There was a problem hiding this comment.
Fixed in 5477d6d — FlowRunFinished now only fires for genuinely TERMINAL statuses; a run that pauses at an approval gate (finalize_terminal_status → pending_approval) no longer emits a premature finish event.
What & why
Completes B35. B35 added
FlowRunStartedso a run appears in the RUNS rail the instant it starts; this adds the terminal companion so status updates (Completed / Failed / Completed-with-warnings / Cancelled) arrive live too — and lets the rail drop its short poll fallbacks.Changes
DomainEvent::FlowRunFinished { flow_id, run_id, status }(event_bus/events.rs), emitted fromfinish_flow_run_row(flows/ops.rs) with the terminal status, bridged to Socket.IO asflow:run_finished/flow_run_finished(core/socketio.rs) — mirroring theFlowRunStartedplumbing.useFlowRunFinishedhook (copiesuseFlowRunStarted, incl. the bounded dedup-over-both-aliases + PII-safe invalid-payload log).FlowRunsSidebar/FlowRunsDrawer/WorkflowRunsPagesubscribe to it (refetch on finish).useFlowRunPoller(2s) /useFlowRunsLiveRefresh(5s) fallbacks are dropped/relaxed (see the hook doc updates).Tests
cargo checkclean; frontendtypecheckclean.useFlowRunFinishedtest asserting single-invocation dedup over both aliases).