Skip to content

fix(web): persist 'ask to fix' CI button based on live GitHub CI data#694

Open
i-trytoohard wants to merge 3 commits intomainfrom
feat/590
Open

fix(web): persist 'ask to fix' CI button based on live GitHub CI data#694
i-trytoohard wants to merge 3 commits intomainfrom
feat/590

Conversation

@i-trytoohard
Copy link
Collaborator

Summary

Fixes the 'ask to fix' CI failure button disappearing before users can click it.

Root cause: The button visibility was tied to session.status === "ci_failed", which transitions away when the orchestrator auto-reacts and starts working — even though CI is still red on GitHub. The button should persist as long as GitHub reports CI as failing, independent of the orchestrator lifecycle.

Changes:

  • /api/events/route.ts — SSE polling (every 5s) now includes prCiStatus and prCiChecks in each snapshot via cache-only PR enrichment (zero extra GitHub API calls — pure in-memory cache lookup from the prCache populated by /api/sessions)
  • useSessionEvents.ts — Reducer patches pr.ciStatus/pr.ciChecks from SSE snapshots, keeping client CI state in sync every ~5s instead of waiting for the 15s+ stale full-refresh
  • SessionCard.tsx (getAlerts) — Button condition is pr.ciStatus === FAILING only — decoupled from session.status entirely. When pr.ciStatus=failing but ciChecks is empty (API inconsistency), shows "CI failing" + "ask to fix" since pr.ciStatus is the authoritative GitHub signal
  • eslint.config.js — Fixed 66 pre-existing no-undef lint errors by declaring Node.js globals for plugin/CLI packages; added dist-server/** to ignore list

Test plan

  • pnpm lint — 0 errors (was 66 errors pre-existing on main)
  • pnpm typecheck — passes
  • pnpm build — passes
  • Web unit tests — 427 tests pass
  • Web server integration tests — 137 tests pass
  • New tests: button shows when pr.ciStatus=failing regardless of session status; button hidden when pr.ciStatus≠failing even if session.status=ci_failed

Closes #590

🤖 Generated with Claude Code

AO Bot and others added 3 commits March 25, 2026 14:55
Previously, the CI failure 'ask to fix' button only appeared when the PR's
enriched ciStatus was "failing" — which requires a full /api/sessions refresh
(up to 15s). The SSE snapshot updates session.status to "ci_failed" in ~5s,
but that wasn't being used to show the button.

Now getAlerts() checks both session.status === "ci_failed" (SSE-updated,
real-time) and pr.ciStatus === CI_STATUS.FAILING (enrichment-based), so the
button appears as soon as the SSE snapshot reflects the CI failure and
persists for the entire ci_failed state — even before PR data is enriched.

When session.status is ci_failed but no specific check details are available
yet (ciChecks empty), show "CI failing" + "ask to fix" rather than the
non-actionable "CI unknown" label.

Closes #590

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…st-server

All 66 no-undef lint errors were caused by two missing configurations:
1. Plugin packages and CLI use Node.js globals (console, process, URL,
   setTimeout, clearTimeout) but the ESLint config had no globals declared
   for these packages — added a languageOptions.globals block covering all
   Node.js standard globals for packages/plugins/** and packages/cli/**
2. packages/web/dist-server/** (compiled server output) was being linted
   as source — added it to the global ignores alongside dist/**

Result: 0 errors, 18 warnings (all pre-existing no-console/non-null-assertion)

Refs #590

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…e pr.ciStatus

The 'ask to fix' button was disappearing when the agent started working on a
CI fix because session.status transitioned away from ci_failed, even though
the PR still had red CI on GitHub. The button should be visible to humans
whenever GitHub says CI is failing, independent of the orchestrator lifecycle.

Root cause: pr.ciStatus (GitHub data) was only refreshed during full session
fetches (~15s stale interval), so there was a window where the button could
appear/disappear based on stale cache rather than current GitHub CI state.

Fix:
- SSE /api/events polling (5s) now includes pr.ciStatus and pr.ciChecks in
  each snapshot using cache-only PR enrichment (zero GitHub API calls — just
  a Map lookup into the prCache populated by /api/sessions)
- useSessionEvents reducer patches pr.ciStatus/pr.ciChecks from SSE snapshots,
  keeping the client in sync with GitHub data every ~5 seconds
- getAlerts() uses only pr.ciStatus === FAILING as the button condition —
  session.status is not consulted (reverts wrong approach from prior commit)
- When pr.ciStatus=failing but ciChecks is empty (API inconsistency), show
  "CI failing" + "ask to fix" rather than the non-actionable "CI unknown",
  since pr.ciStatus is the authoritative GitHub signal

Closes #590

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
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.

bug: 'Ask to fix' button disappears too quickly on CI failure

1 participant