Skip to content

feat(frontend): surface multiple PRs per session#237

Open
Pritom14 wants to merge 2 commits into
feat/multi-pr-per-sessionfrom
feat/multi-pr-frontend
Open

feat(frontend): surface multiple PRs per session#237
Pritom14 wants to merge 2 commits into
feat/multi-pr-per-sessionfrom
feat/multi-pr-frontend

Conversation

@Pritom14

Copy link
Copy Markdown
Collaborator

Stacked on #230 (the backend multi-PR-per-session work). Base this on feat/multi-pr-per-session; retarget to main once #230 merges.

Summary

The frontend modelled a session as owning at most one PR (pullRequest?). The backend now attributes a list of PRs to a session (a stack, or several independent PRs), so this wires prs: PullRequestFacts[] through every PR surface. Note useWorkspaceQuery never mapped PRs at all before this, so the live app surfaced zero PRs regardless of backend state. This turns them on.

Ordering everywhere is actionable-first: open, draft, merged, closed.

What changed

  • types/workspace.ts: PRState / PullRequestFacts types and sortedPRs / openPRs / mergedPRCount / primaryPR helpers.
  • hooks/useWorkspaceQuery.ts: map the live /api/v1/sessions prs[] into the query.
  • components/SessionInspector.tsx: render a stack of single-PR cards (one card per PR with state badge, CI / merge / review facts, and an Open link), replacing the old single-PR fetch.
  • components/PullRequestsPage.tsx: one row per attributed PR; merge / resolve act on each PR by its own number.
  • components/SessionsBoard.tsx: card footer shows a PR count summary.
  • Mock-data fixture plus unit tests (SessionInspector, PullRequestsPage) and a Playwright e2e spec.

User flow

  1. An agent session opens one or more PRs (for example a stacked change: a base PR plus a child PR). The backend attributes every open PR whose head branch matches the session branch or the session-branch/... namespace.
  2. On the board, the session card footer reads "2 PRs - 1 open" instead of a single PR line, so you can see at a glance which sessions own a stack.
  3. Opening the session shows the inspector rail. The PR section heading reads "Pull requests (2)" and stacks one card per PR, ordered open then draft then merged. Each card shows the PR number, a state badge, CI / mergeability / review facts, and an Open link to GitHub.
  4. The Pull requests page lists one row per PR across all sessions, actionable PRs (open / draft) first. Each row has its own Merge and Resolve actions that target that PR's number, so merging the child does not touch the base.
  5. Everything stays live: the existing CDC / SSE PR events already invalidate the workspaces query, so opening, merging, or updating a PR refreshes all three surfaces without a reload.

Test plan

  • pnpm test (unit + functional) green, including the new inspector and PR-board tests
  • pnpm typecheck clean
  • Playwright e2e (e2e/multi-pr.spec.ts) renders the inspector stack and the PR board from mock data
  • Live end-to-end against a real GitHub repo: ran the daemon, spawned one session on a namespace branch, opened two real PRs (one open, one draft), confirmed the backend attributed both and the running frontend rendered the board rows and the "Pull requests (2)" inspector stack with no console errors

Pritom14 and others added 2 commits June 15, 2026 12:40
Replace the single optional pullRequest on a session with a prs[] list and
render it across every PR surface: the inspector stacks one card per PR, the
PR board lists one row per attributed PR, and the board card shows a PR count
summary. useWorkspaceQuery now maps the live /api/v1/sessions prs[] into the
query (the frontend surfaced no PRs before this). Ordering is actionable-first
(open, draft, merged, closed).

Adds unit tests (SessionInspector, PullRequestsPage), a Playwright e2e spec,
and a multi-PR mock-data fixture.

@greptile-apps greptile-apps 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.

Your free trial has ended. If you'd like to continue receiving code reviews, you can add a payment method here.

@greptile-apps greptile-apps 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.

Your free trial has ended. If you'd like to continue receiving code reviews, you can add a payment method here.

@Pritom14

Copy link
Copy Markdown
Collaborator Author
image image

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.

1 participant