feat(tui): pull request panel with Summary, Timeline and Checks tabs

Merged
HK
16d ago
+1544-0

Summary

The TUI gets a right panel for the pull requests linked to the open thread, with Summary, Timeline and Checks tabs. Other features add tabs through a new prPanelTabs field; the Code tab from #32 uses it.

Preview

Summary:

summary

Timeline (newest first, the rail stops at the last event, commit runs folded):

timeline

Checks with a GitHub Actions job log open:

checks

Captured headless from a playground server with pingdotgg/t3code#33263 linked to a thread in the copy (read-only GitHub calls).

Changes

  • features/pr-panel/ (new):
    • PrPanel.tsx: the panel. Shows the PR line (1/2 · n next when the thread has more than one link), the tab bar with a checks count badge, and the active tab. Empty states for no thread and no linked PR.
    • SummaryTab.tsx: title, state or draft, author, base ← head, files and +/-, checks summary, mergeability (open PRs), reviewers with their latest verdict, labels, and the description as terminal markdown.
    • TimelineTab.tsx: events grouped by local day, marker glyph and color per type, review verdicts, review threads as one row with path:line and reply count, runs of 3+ commits folded (e expands), repeated "Merge branch 'main' into" commits merged into one dimmed row. The rail runs from the first marker to the last and stops there. Comment bodies show 8 lines, then "N more lines".
    • ChecksTab.tsx: summary line ("21 passed · 13 skipped" wording from #12), sections Needs attention / Running / Completed, j/k select, enter opens the job log. Every log state (loading, error, host-only, no log, empty, loaded) uses the same frame with one header line, as in #13.
    • ansi.ts: log lines keep SGR colors mapped onto theme tokens (bold, italic, underline too). 256-color and RGB codes, cursor moves, OSC (titles, links) and other control characters are dropped. ##[error] and ##[warning] lines get danger and warning colors.
    • model.ts: thread links to targets, checks grouping and wording, timeline building and rows. Trimmed copies of pullRequestDetail.logic.ts and pullRequestPresentation.tsx; the web file imports web-only modules (~/reviewCommentContext, composer helpers), so I could not import it. Candidate for client-runtime.
    • view.tsx: data hook (detail with newer checks merged through resolvePullRequestDetailChecks, as web does), a line viewport, scroll keys, and PR markdown without raw HTML blocks.
  • app/feature.ts, app/registry.ts: prPanelTabs?: TuiPrPanelTab[] on TuiFeature ({ id, title, order, component }, component gets { target, focused, width, height }). The registry merges them sorted by order and throws on duplicate ids.
  • state/pullRequests.ts (new): pullRequestAtoms = createPullRequestEnvironmentAtoms(connectionAtomRuntime), shared with the Code tab.
  • connection/runtime.ts: PullRequestDiffLoader.layer in layerSnapshotLoaders, which createPullRequestEnvironmentAtoms needs.
  • features/index.ts: one line.
  • CONTRIBUTING-TUI.md: "Pull request panel tabs" section (the tab contract, key order, shared atoms). README.md: panel keys.

Keys added:

  • Global: ctrl+y toggles the panel (pr-panel.toggle, also in the palette) and focuses it on open.
  • Panel focus: [ / ] and 1-9 switch tabs, n next linked PR, r reloads detail, activity and checks. j/k, arrows, ctrl+d/ctrl+u, page keys and g/G scroll. Timeline: e expands commit runs. Checks: enter/space toggle the log, escape hides it, r reloads the open log.

Tests

  • features/pr-panel/model.test.ts (fixture PR data): thread link targets (newest first, stack-dismissed hidden, legacy fallback), check summary wording (passed/skipped, failing, running, workflow approval), timeline rows (commit run folding, sync commit merging), the rail ending at the last marker, and the ANSI parser (theme colors, escapes and controls stripped, style carried across lines).
  • app/App.test.tsx still passes with the new feature registered (catches id and key conflicts).
  • vp run check:changed: format, lint, knip, typecheck (41 packages), tests (19 files) pass.
  • Manual: headless run against a playground copy with providers disabled (screenshots above).

Scope affected

TUI only. Shell files touched: app/feature.ts and app/registry.ts (new optional field), connection/runtime.ts (one layer). No web, mobile, server or contract changes. #32 has the same state/pullRequests.ts and runtime line; whichever merges second keeps one copy and #32 swaps its stand-in panel for prPanelTabs.

Reasoning

  • The panel draws the tab bar, and features contribute tabs, so the Code tab lives in its own folder and needs no panel of its own. The panel's key handler mounts after the active tab (both keyed by tab and PR), so the tab sees keys first. The Code tab uses n/p for hunks while a diff is open.
  • ctrl+y: the web rightPanel.toggle key (mod+alt+b) does not reach most terminals, and the other free ctrl keys are taken or are terminal controls.
  • No auto polling of checks: the atoms refetch when stale, and r reloads on demand. Polling can follow if it is needed.

Summary by cubic

Adds a right panel to the TUI showing the pull requests linked to the open thread, with Summary, Timeline and Checks tabs. ctrl+y toggles the panel; [/] and 1-9 switch tabs, n cycles linked PRs, r reloads.

  • Summary shows state, author, branches, changes, checks, mergeability, reviewers and the description as terminal markdown.
  • Timeline groups events by day, folds runs of 3+ commits and merges back-to-back sync commits.
  • Checks groups checks by status and shows GitHub Actions job logs with ANSI colors mapped onto theme tokens.
  • Other features add tabs through a new prPanelTabs field; the Code tab uses it with order: 40.