Skip to content

fix(flows): show "awaiting approval" state in runs lists when a run is halted at an approval gate - #4932

Merged
graycyrus merged 2 commits into
tinyhumansai:mainfrom
graycyrus:fix/flows-runs-awaiting-approval-indicator
Jul 15, 2026
Merged

graycyrus merged 2 commits into
tinyhumansai:mainfrom
graycyrus:fix/flows-runs-awaiting-approval-indicator

Conversation

@graycyrus

@graycyrus graycyrus commented Jul 15, 2026 •

Copy link
Copy Markdown
Contributor

Summary

When a flow run is halted at an interactive ApprovalGate (e.g. a SLACK_SEND_MESSAGE node awaiting Approve/Deny), the run's persisted FlowRun.status stays "running" — only the shared approval queue (openhuman.approval_list_pending) knows the run is actually parked. As a result, every runs-list surface (canvas sidebar, run-history drawer, all-runs page) showed a generic green "Running" pill instead of the amber "Awaiting approval" state that already exists for pending_approval (FLOW_RUN_STATUS_DOT/_ACCENT/_KEY in FlowRunInspectorDrawer.tsx, i18n in all locales) — it was just never reached for this gate type.

This is a frontend-only fix: cross-reference the shared approval queue with each runs list and override the display status, without touching the persisted run.status or the DB.

Changes

  • New app/src/hooks/useRunsPendingApprovalSet.ts:

    • useRunsPendingApprovalSet(runs: FlowRun[]): Set<string> — while any run in the list is status === 'running', polls fetchPendingApprovals() (openhuman.approval_list_pending, via app/src/services/api/approvalApi.ts) every 3s and collects the run_ids of entries whose source_context?.kind === 'flow' into a Set. Stops polling once no run is running (teardown via effect cleanup) and on unmount. Best-effort: a failed poll is logged and simply retried next tick, keeping the last-known Set instead of surfacing an error.
    • resolveDisplayStatus(run: FlowRun, pendingRunIds: Set<string>): FlowRunStatus — returns 'pending_approval' when run.status === 'running' && pendingRunIds.has(run.id), else run.status unchanged.
    • Mirrors the poll-loop + cleanup shape of useFlowPendingApprovals.ts and the gate-on-activity contract of useFlowRunsLiveRefresh.ts.
  • Wired into the three list surfaces — each calls useRunsPendingApprovalSet(runs) after its existing useFlowRunsLiveRefresh(...) call, then substitutes resolveDisplayStatus(run, pendingRunIds) for run.status at the status-dot / accent / label render sites only:

    • app/src/components/flows/FlowRunsSidebar.tsx
    • app/src/components/flows/FlowRunsDrawer.tsx
    • app/src/pages/WorkflowRunsPage.tsx
  • useFlowRunsLiveRefresh is untouched — it still reads the original runs array, so 'running' stays non-terminal there and the list keeps refetching until the run actually finishes. No backend changes.

Tests

  • New app/src/hooks/__tests__/useRunsPendingApprovalSet.test.ts (11 tests, fake timers): no poll when all runs terminal / list empty; polls every 3s while a run is running; includes a run with a matching flow-origin approval; excludes a running run with no match; excludes a chat-origin approval (no source_context); keeps the last-known set on a poll failure and keeps polling; tears down once runs settle to terminal; cleans up on unmount; resolveDisplayStatus unit cases.
  • Extended FlowRunsSidebar.test.tsx, FlowRunsDrawer.test.tsx, WorkflowRunsPage.test.tsx with a fetchPendingApprovals mock and new cases asserting a running run with a matching flow approval renders "Awaiting approval" and a running run without a match still renders "Running".

All 40 new/updated tests pass; the full flows domain suite (224 tests, 22 files) still passes.

Test plan

  • pnpm typecheck clean
  • pnpm lint — 0 errors (104 pre-existing warnings unrelated to this diff, confirmed identical before/after via git stash)
  • pnpm format / format:check clean
  • New hook tests pass: useRunsPendingApprovalSet.test.ts (11/11)
  • Updated surface tests pass: FlowRunsSidebar.test.tsx, FlowRunsDrawer.test.tsx, WorkflowRunsPage.test.tsx
  • Full flows domain test suite passes (224/224)

Summary by CodeRabbit

  • New Features
    • Running workflow and flow runs now show “Awaiting approval” (with matching status pill/dot styling) when their execution is paused at a pending approval gate, updating automatically while runs remain in-progress.
    • If no matching pending approval is found, they display “Running”.
    • Consistent behavior is applied across Workflow Runs Page, Flow Runs Sidebar, and Flow Runs Drawer.
  • Tests
    • Added coverage to verify the “Awaiting approval” vs “Running” status behavior.

…s halted at an approval gate

A run parked at an interactive ApprovalGate keeps status "running" in the
DB (only the shared approval queue knows it's halted), so the sidebar,
drawer, and all-runs list showed a generic "Running" instead of the
existing amber "Awaiting approval" styling. Cross-reference the shared
approval queue (openhuman.approval_list_pending) against each running run
via source_context.kind === "flow" and override the DISPLAY status only,
leaving run.status (and useFlowRunsLiveRefresh's terminal check) intact.
@graycyrus
graycyrus requested a review from a team July 15, 2026 20:40
@coderabbitai

coderabbitai Bot commented Jul 15, 2026 •

Copy link
Copy Markdown
Contributor

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

Run ID: d0d59f16-8c9a-42c4-b920-01136bf26d85

📥 Commits

Reviewing files that changed from the base of the PR and between e1ab995 and d737a08.

📒 Files selected for processing (1)
  • app/src/hooks/useRunsPendingApprovalSet.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • app/src/hooks/useRunsPendingApprovalSet.ts

📝 Walkthrough

Walkthrough

Running flow runs now poll pending approvals, filter flow-origin gates, and display “Awaiting approval” with pending styling when a matching gate exists. Drawers, sidebars, and the workflow runs page use the shared status resolver with new polling and UI coverage.

Changes

Pending approval run status

Layer / File(s) Summary
Approval polling and status resolution
app/src/hooks/useRunsPendingApprovalSet.ts, app/src/hooks/__tests__/useRunsPendingApprovalSet.test.ts
Adds 3-second polling for flow-origin pending approvals, retains state across failures, stops when no runs are active, and resolves matching running runs to pending_approval.
Run list status integration
app/src/components/flows/FlowRunsDrawer.tsx, app/src/components/flows/FlowRunsSidebar.tsx, app/src/pages/WorkflowRunsPage.tsx, app/src/components/flows/*.test.tsx, app/src/pages/WorkflowRunsPage.test.tsx
Applies resolved statuses to run labels, colors, badges, and dots across all run-list views, with matching and non-matching approval coverage.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Suggested labels: bug

Sequence Diagram(s)

sequenceDiagram
  participant RunList
  participant useRunsPendingApprovalSet
  participant approvalApi
  participant StatusResolver
  RunList->>useRunsPendingApprovalSet: pass running flow runs
  useRunsPendingApprovalSet->>approvalApi: fetchPendingApprovals()
  approvalApi-->>useRunsPendingApprovalSet: pending approval records
  useRunsPendingApprovalSet->>StatusResolver: provide pending run IDs
  StatusResolver-->>RunList: render pending_approval or running
Loading

Poem

I’m a rabbit with a status to show,
Pending gates make the soft dot glow.
Polling hops every three seconds bright,
Running stays running when gates aren’t in sight.
“Awaiting approval!” I cheer with delight.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 66.67% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly matches the main change: showing an awaiting-approval state for halted flow runs in run lists.
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.

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

ESLint install failed: private package registry requires authentication. Disable ESLint in CodeRabbit settings or use public packages.


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

@coderabbitai coderabbitai Bot added the feature Net-new user-facing capability or product behavior. label Jul 15, 2026

@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: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@app/src/hooks/useRunsPendingApprovalSet.ts`:
- Around line 56-89: Update the useEffect polling flow in
useRunsPendingApprovalSet to add grep-friendly diagnostics for the no-running
branch, poll start/stop, fetchPendingApprovals outbound calls, retry timeout
scheduling, and pending-run state updates. Replace raw err serialization in the
poll-failure log with only a safe error type or code, avoiding sensitive error
content while preserving the existing retry and last-known-state behavior.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: d0233e44-4cb2-492f-8809-20c29a20c89f

📥 Commits

Reviewing files that changed from the base of the PR and between 4135cfc and e1ab995.

📒 Files selected for processing (8)
  • app/src/components/flows/FlowRunsDrawer.test.tsx
  • app/src/components/flows/FlowRunsDrawer.tsx
  • app/src/components/flows/FlowRunsSidebar.test.tsx
  • app/src/components/flows/FlowRunsSidebar.tsx
  • app/src/hooks/__tests__/useRunsPendingApprovalSet.test.ts
  • app/src/hooks/useRunsPendingApprovalSet.ts
  • app/src/pages/WorkflowRunsPage.test.tsx
  • app/src/pages/WorkflowRunsPage.tsx

…ng in useRunsPendingApprovalSet (addresses @coderabbitai on app/src/hooks/useRunsPendingApprovalSet.ts:56-89)
@coderabbitai coderabbitai Bot added bug and removed feature Net-new user-facing capability or product behavior. labels Jul 15, 2026
@graycyrus
graycyrus merged commit 1feb873 into tinyhumansai:main Jul 15, 2026
22 of 26 checks passed
@github-project-automation github-project-automation Bot moved this from Todo to Done in Team Openhuman Jul 15, 2026
senamakel pushed a commit to M3gA-Mind/openhuman that referenced this pull request Jul 18, 2026
senamakel pushed a commit to nocstah/openhuman that referenced this pull request Sep 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

1 participant