Skip to content

feat(gastown): redesign Merge Queue page with Needs Attention + Refinery Activity Log#1369

Open
jrf0110 wants to merge 3 commits intomainfrom
convoy/redesign-merge-queue-needs-attention-ref/e0d20455/head
Open

feat(gastown): redesign Merge Queue page with Needs Attention + Refinery Activity Log#1369
jrf0110 wants to merge 3 commits intomainfrom
convoy/redesign-merge-queue-needs-attention-ref/e0d20455/head

Conversation

@jrf0110
Copy link
Contributor

@jrf0110 jrf0110 commented Mar 21, 2026

Summary

  • Add getMergeQueueData tRPC procedure backed by a new SQL query in review-queue.ts that returns MR beads needing attention (open PRs, failed reviews, stale PRs) and a chronological refinery activity log — both enriched with convoy, agent, rig, and source bead context via JOINs.
  • Build the Needs Your Attention section (NeedsAttention.tsx) with convoy-grouped cards, category badges (open PR / failed / stale), inline retry/fail actions with confirmation dialogs, and a per-rig filter dropdown.
  • Build the Refinery Activity Log (RefineryActivityLog.tsx) showing review-lifecycle events (submitted, completed, PR created, rework requested) in a timeline view grouped by convoy, with paginated "show more" that keeps convoy groups intact.
  • Refactor TerminalBar to use a shared TerminalBarPadding wrapper for consistent bottom padding across layouts.

Verification

  • pnpm typecheck — passes across all packages (tsgo --noEmit)
  • pnpm run lint:oxlint — 0 warnings, 0 errors on 1844 files
  • pnpm run format:check — no formatting issues

Visual Changes

N/A (no screenshots available from this environment — the changes add new UI sections to the Merge Queue page)

Reviewer Notes

  • Minor polish opportunities identified during review (non-blocking):
    • NeedsAttention.tsx:293: Retry mutation sends rigId: '' when rig_id is null — will hit Zod UUID validation and show a confusing toast. Consider disabling retry when rig_id is absent.
    • NeedsAttention.tsx:367-377: Clickable buttons that silently do nothing when sourceBead is null — consider disabling or rendering as <span> in that case.
    • RefineryActivityLog.tsx:344-346: "Show more" remaining count can show 0 or negative when a convoy group overshoots the page budget — use Math.max(0, ...).
    • MergesPageClient.tsx:129: isLoading={false} is hardcoded, making the skeleton in RefineryActivityLog dead code.
    • router.ts:908: since parameter accepts any string — consider z.string().datetime() for validation.

jrf0110 added 3 commits March 21, 2026 03:53
Add a dedicated tRPC query that returns structured merge queue data:
- needsAttention section with openPRs, failedReviews, and stalePRs
- activityLog with enriched review-related bead events
- Full JOINs to review_metadata, source beads, convoy_metadata, agents, rigs
- Input params: townId (required), rigId, limit, since for filtering/polling
- Zod schemas with rpcSafe wrappers and type declarations for frontend
…age (#1365)

* feat(gastown): configurable terminal orientation with drag-to-resize (#1299)

* feat(gastown): configurable terminal orientation and drag-to-resize (#1237)

Terminal bar can be positioned at bottom/top/left/right with drag-to-resize.
Position and size persisted to localStorage. Collapsed state only reserves
the tab bar strip. Dynamic page padding replaces static pb-[340px].
DrawerStack offsets when terminal is on the right.

* fix(gastown): clamp size on orientation switch, add vertical close button

Re-clamp persisted size when switching position so horizontal minimum
(100px) doesn't persist as a too-small vertical width (min 200px).
Show close button on agent tabs in vertical mode via absolute positioning
on hover.

* fix(gastown): fix terminal resize handle and position picker for left/right orientations

- Make resize handle a flex child instead of absolute positioned to avoid
  z-index conflicts with framer-motion stacking contexts
- Add visible hover indicator pill on resize handle for discoverability
- Remove width/height from CSS transition so drag resize is immediate
- Use fixed positioning with viewport clamping for position picker popup
  to prevent overflow on left/right orientations

* chore: cherry-pick getMergeQueueData types from bead 0

* feat(gastown): build 'Needs Your Attention' section for Merge Queue page

Add NeedsAttention component with:
- Three attention categories: open PRs, failed reviews, stale PRs
- Convoy grouping with header cards showing progress, branch, merge mode
- Action buttons: Open PR, Retry Review, Fail Bead, View Bead
- DrawerStack integration for bead and convoy drawer opening
- Confirmation dialogs for destructive actions
- Empty state when no items need attention

Rewrite MergesPageClient to use getMergeQueueData tRPC procedure
with 5s polling interval.
…ue page (#1366)

* feat(gastown): add convoy grouping and per-rig filtering to Merge Queue page

- Add RefineryActivityLog with convoy grouping: entries grouped by convoy
  with header cards showing title, branch, progress, clickable to open
  convoy drawer
- Add per-rig filter dropdown using listRigs query and shadcn Select,
  passes rigId to getMergeQueueData for server-side filtering
- Include status_changed ActionType with type guard (no unsafe 'as' cast)
- Polish layout: page title, rig filter, Needs Attention, Activity Log
  sections with consistent headers and empty states

* fix(gastown): move hooks above early returns and paginate by convoy groups

- Move all useMemo hooks above isLoading/empty early returns to prevent
  React crash when entries transition from 0 to non-zero (hooks must be
  called in the same order on every render)
- Replace flat-entry pagination with group-based pagination: convoy
  groups (sorted by most recent activity) are kept whole, and standalone
  entries fill remaining page budget. This ensures recently active
  convoys appear on page 1 regardless of other convoys' sizes.
if (!confirmAction) return;
if (confirmAction.action === 'retry') {
retryMutation.mutate({
rigId,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

WARNING: Retry action can fail for entries without a rig id

This mutation sends rigId through updateBead, but that procedure requires a UUID and verifies the bead belongs to that rig. Here rigId falls back to an empty string when mrBead.rig_id is missing, so retrying those cards will fail validation or come back FORBIDDEN instead of recovering the review. Consider hiding or disabling retry when the MR has no rig id, or using a town-scoped recovery mutation for this path.

ON rig.id = b.${beads.columns.rig_id}
WHERE ${bead_events.event_type} IN (
'review_submitted', 'review_completed', 'pr_created',
'pr_creation_failed', 'rework_requested', 'status_changed'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

WARNING: This will pull unrelated bead transitions into the refinery log

updateBeadStatus() records status_changed for every bead type, so including that event here means ordinary issue, convoy, and escalation transitions will show up in a page that is supposed to represent refinery activity. Once a town has normal bead traffic, the review history becomes noisy and much harder to follow.

</AnimatePresence>

{/* Standalone entries */}
{visibleStandalone.length > 0 && (
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

WARNING: Standalone events are no longer rendered in chronological order

This component sorts convoy groups by latest activity, but then renders every convoy group before every standalone entry. A newer standalone event will therefore appear below older convoy groups, which breaks the activity log ordering. The grouped and standalone rows need to be merged into one time-ordered list before rendering.

@kilo-code-bot
Copy link
Contributor

kilo-code-bot bot commented Mar 21, 2026

Code Review Summary

Status: 3 Issues Found | Recommendation: Address before merge

Fix these issues in Kilo Cloud

Overview

Severity Count
CRITICAL 0
WARNING 3
SUGGESTION 0
Issue Details (click to expand)

WARNING

File Line Issue
src/app/(app)/gastown/[townId]/merges/NeedsAttention.tsx 336 Retry uses updateBead with an empty/non-UUID rigId when the MR lacks rig ownership, so the recovery action can fail instead of reopening the review.
cloudflare-gastown/src/dos/town/review-queue.ts 1126 Including status_changed here pulls generic bead transitions into a refinery-specific activity log.
src/app/(app)/gastown/[townId]/merges/RefineryActivityLog.tsx 322 Convoy groups render before standalone entries, so newer standalone events can appear below older convoy activity.
Other Observations (not in diff)

N/A

Files Reviewed (14 files)
  • cloudflare-gastown/src/dos/Town.do.ts - 0 issues
  • cloudflare-gastown/src/dos/town/review-queue.ts - 1 issue
  • cloudflare-gastown/src/trpc/router.ts - 0 issues
  • cloudflare-gastown/src/trpc/schemas.ts - 0 issues
  • src/app/(app)/gastown/[townId]/layout.tsx - 0 issues
  • src/app/(app)/gastown/[townId]/merges/MergesPageClient.tsx - 0 issues
  • src/app/(app)/gastown/[townId]/merges/NeedsAttention.tsx - 1 issue
  • src/app/(app)/gastown/[townId]/merges/RefineryActivityLog.tsx - 1 issue
  • src/app/(app)/organizations/[id]/gastown/[townId]/layout.tsx - 0 issues
  • src/components/gastown/DrawerStack.tsx - 0 issues
  • src/components/gastown/TerminalBar.tsx - 0 issues
  • src/components/gastown/TerminalBarContext.tsx - 0 issues
  • src/components/gastown/TerminalBarPadding.tsx - 0 issues
  • src/lib/gastown/types/router.d.ts - 0 issues

Reviewed by gpt-5.4-20260305 · 2,747,754 tokens

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