feat(chat): hydrate commit/run GitHub cards from their W2a routes (cave-w91n)#3750
Merged
Conversation
…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>
Contributor
There was a problem hiding this comment.
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
useCommitDetailanduseRunDetailto fetch commit/run detail from/api/github/commitand/api/github/runs?id=, including in-flight-only polling for runs. - Extend
/api/github/runsto support fetching a single run byid, normalized through the existingruns[]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
enabledbecomes false,runStatecan remainreadyandrunwill stay non-null, which can incorrectly influenceurl,title, and the glyph for non-run descriptors. Gate the derivedrunvalue bydescriptor.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> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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— optionalidparam. A run card needs one exact run, not a page of twenty;?repo=&id=fetchesGET /repos/{repo}/actions/runs/{id}(id validated^\d{1,16}$, safe positive integer) and normalizes through the sameruns[]shape as the list. 404 →not_found, 403 stays 403, PAT never echoed — all unchanged.github-card.tsx— two new hooks, same idiom asuseGitHubItem: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 whilestatus !== "completed"; a failed refresh keeps the last good detail.Card render:
+adds −dels(success/warning tints — sign is the primary channel), file count.run #Nwhen hydrated.ph:check-circlesuccess tint /ph:x-circle-fillwarning tint via the sharedisFailConclusion/ spinner while in flight.detailPhaseacross pr/issue/commit/run; review-thread keeps reporting inside its own body.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 typecheckclean,pnpm lintclean (design gates included)idparam, 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