Skip to content

feat(chat): hydrate commit/run GitHub cards from their W2a routes (cave-w91n)#3750

Merged
BunsDev merged 1 commit into
mainfrom
feat/gh-card-commit-run-hydrate
Jul 24, 2026
Merged

feat(chat): hydrate commit/run GitHub cards from their W2a routes (cave-w91n)#3750
BunsDev merged 1 commit into
mainfrom
feat/gh-card-commit-run-hydrate

Conversation

@BunsDev

@BunsDev BunsDev commented Jul 24, 2026

Copy link
Copy Markdown
Member

Closes bead cave-w91n — W2a shipped /api/github/commit + /api/github/runs, but commit/run chat cards still rendered attrs-only. This hydrates them the way PR/issue cards do.

What changed

/api/github/runs — optional id param. A run card needs one exact run, not a page of twenty; ?repo=&id= fetches GET /repos/{repo}/actions/runs/{id} (id validated ^\d{1,16}$, safe positive integer) and normalizes through the same runs[] shape as the list. 404 → not_found, 403 stays 403, PAT never echoed — all unchanged.

github-card.tsx — two new hooks, same idiom as useGitHubItem:

  • useCommitDetail — one-shot fetch (commits are immutable; nothing to re-poll), cancelled-guarded, 401/403 → unauth.
  • useRunDetail — fetches the exact run; re-polls on the checks cadence (usePausablePoll, 30s, hidden tabs pause) only while status !== "completed"; a failed refresh keeps the last good detail.

Card render:

  • Title: hydrated item → commit first message line → run name → descriptor title → URL fallback.
  • Commit sub-row: author, relative date, +adds −dels (success/warning tints — sign is the primary channel), file count.
  • Run sub-row: status/conclusion text, branch, relative created time; ref shows real run #N when hydrated.
  • Run glyph joins the checks-strip vocabulary: ph:check-circle success tint / ph:x-circle-fill warning tint via the shared isFailConclusion / spinner while in flight.
  • Degradation rows (loading… / connect GitHub to hydrate / details unavailable) now gate on a shared detailPhase across pr/issue/commit/run; review-thread keeps reporting inside its own body.
  • Link-out prefers hydrated htmlUrl.

Validation

  • github-card-wiring.test.ts + github-card-reward.test.ts + both route tests green (--import ./scripts/test-alias-register.mjs; reward pins need the css-source-contract hook, as in the suite runner)
  • pnpm typecheck clean, pnpm lint clean (design gates included)
  • New pins: commit hook endpoint, runs id param, in-flight-only poll gating, first-line title, stats row, shared degradation gate, hydrated run glyph labels; runs route pins id validation + by-id normalization

…ve-w91n)

Commit cards now fetch /api/github/commit (first message line as title,
author, relative date, +adds/−dels, file count — one shot, commits are
immutable). Run cards fetch one exact run via a new /api/github/runs?id=
lookup (validated positive int, same normalized runs[] shape) and re-poll
on the checks cadence (30s pausable) only while the run is in flight;
the leading glyph takes the checks-strip vocabulary (success tint /
fail tint via isFailConclusion / neutral spinner). Both kinds share the
PR/issue degradation rows (loading… / connect GitHub to hydrate /
details unavailable) and prefer hydrated htmlUrl for the link-out.

Pins: wiring test covers both hooks, the id param, poll gating, and the
degradation gate; runs route test pins id validation + normalization.
Doc: /runs table row updated, "Commit/Run card hydration" residual gap
removed.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings July 24, 2026 05:50

Copilot AI 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.

Pull request overview

Hydrates GitHub commit and workflow run chat cards so they render real commit/run details (and degrade consistently) instead of attrs-only, aligning them with existing PR/issue card hydration.

Changes:

  • Add useCommitDetail and useRunDetail to fetch commit/run detail from /api/github/commit and /api/github/runs?id=, including in-flight-only polling for runs.
  • Extend /api/github/runs to support fetching a single run by id, normalized through the existing runs[] response shape.
  • Update wiring/tests/docs to pin the new hydration behavior and route contract.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
src/components/github-card.tsx Adds commit/run hydration hooks, run glyph semantics, and unified degradation gating across hydrating card kinds.
src/components/github-card-wiring.test.ts Pins new commit/run hydration behavior and polling/title/stats/degradation wiring.
src/app/api/github/runs/route.ts Adds optional id param for by-id run fetch and normalizes by-id vs list responses.
src/app/api/github/runs/route.test.ts Adds contract pins for id validation, by-id endpoint, and normalization behavior.
docs/chat-github-integration.md Updates API contract table and removes the now-closed “commit/run hydration” gap.
Comments suppressed due to low confidence (1)

src/components/github-card.tsx:780

  • Same state-leak issue as commits: when enabled becomes false, runState can remain ready and run will stay non-null, which can incorrectly influence url, title, and the glyph for non-run descriptors. Gate the derived run value by descriptor.kind.
    descriptor.kind === "run",
  );
  const run = runState.phase === "ready" ? runState.run : null;

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +772 to +774
descriptor.kind === "commit",
);
const commit = commitState.phase === "ready" ? commitState.commit : null;
) : null}
{run ? (
<>
<span>{run.status === "completed" ? (run.conclusion ?? "completed") : run.status.replace(/_/g, " ")}</span>
@BunsDev
BunsDev merged commit fe93b2d into main Jul 24, 2026
16 checks passed
@BunsDev
BunsDev deleted the feat/gh-card-commit-run-hydrate branch July 24, 2026 05:59
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