feat(gastown): add convoy grouping and per-rig filtering to Merge Queue page#1366
Conversation
…ue 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
| } | ||
|
|
||
| // Flatten all entries for pagination: convoy groups first, then standalone | ||
| const allGroupedEntries = useMemo(() => { |
There was a problem hiding this comment.
CRITICAL: Hooks are called conditionally after early returns
useMemo is invoked again after the isLoading and entries.length === 0 returns. When this component first renders with an empty log and later re-renders with entries, React will hit Rendered more hooks than during the previous render and crash the activity log. Move the later memoized calculations above the early returns, or compute them without hooks.
| // Flatten all entries for pagination: convoy groups first, then standalone | ||
| const allGroupedEntries = useMemo(() => { | ||
| const result: Array<{ entry: ActivityLogEntry; convoyId: string | null }> = []; | ||
| for (const group of convoyGroups) { |
There was a problem hiding this comment.
WARNING: Client-side pagination no longer preserves activity recency
This flattens entries by convoy group, so every entry from the first convoy is emitted before any entry from the next convoy or the standalone list. Because the page then slices the first 20 flattened items, a busy convoy can push newer events from other convoys or standalone activity off the first page, so the Refinery Activity Log stops reflecting the most recent events.
Code Review SummaryStatus: 2 Issues Found | Recommendation: Address before merge Overview
Fix these issues in Kilo Cloud Issue Details (click to expand)WARNING
Other Observations (not in diff)N/A Files Reviewed (1 file)
Reviewed by gpt-5.4-20260305 · 199,267 tokens |
…roups - 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.
| visibleConvoyGroups: visibleConvoys, | ||
| visibleStandalone: standaloneSlice, | ||
| totalEntryCount: total, | ||
| hasMore: visibleCount < total, |
There was a problem hiding this comment.
WARNING: hasMore can stay true after every entry is already visible
This pagination logic spends a visibleCount budget, but it still renders an entire convoy even when that convoy is larger than the remaining budget. In that case the component can show more than visibleCount entries while hasMore and the "remaining" label are still computed from visibleCount, so a convoy with 21 entries will render all 21 items on page 1 but still show a no-op "Show more" button with 1 remaining.
e3b5cf0
into
convoy/redesign-merge-queue-needs-attention-ref/e0d20455/head
… log (#1378) * feat(gastown): add getMergeQueueData tRPC procedure for merge queue page 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 * feat(gastown): build 'Needs Your Attention' section for Merge Queue page (#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. * feat(gastown): add convoy grouping and per-rig filtering to Merge Queue 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. * fix(gastown): interleave convoy groups and standalone entries by recency in pagination The previous pagination showed all convoy groups before any standalone entries regardless of timestamps. A standalone entry more recent than all convoy groups would still appear below them on page 1. Merge convoy groups and standalone entries into a unified DisplayItem list sorted by most-recent timestamp, then paginate over that list. Convoy groups use their latestTimestamp as sort key; standalone entries use their event.created_at. This ensures the most recently active items appear first on page 1 regardless of whether they are convoy-grouped or standalone. Hooks were already correctly placed before early returns (no conditional hooks issue in the current code). * fix(gastown): gate fail button behind admin check and fix pagination remaining count Hide the admin-only 'Fail Bead' button for non-admin users by checking isAdmin from the session. Fix the activity log pagination to compute hasMore and remaining count based on actual visible entries rather than the budget, preventing incorrect 'Show more' state when a convoy group exceeds the page budget.
|
Refinery code review passed. All quality gates pass. |
Summary
RefineryActivityLogcomponent that groups activity log entries by convoy, with clickable convoy header cards showing title, branch, and a progress bar. Standalone (non-convoy) entries render below convoy groups. Uses a type guard (isActionType) for safe action type resolution instead ofascasts.MergesPageClientto include a per-rig filter dropdown (usinglistRigsquery + shadcn Select), passingrigIdtogetMergeQueueDatafor server-side filtering. Integrates both Needs Attention and Activity Log sections with consistent section headers and visual hierarchy.Verification
pnpm typecheck— passes across all workspace projectsascasts or!assertions in new codeNeedsAttention.tsxpatterns (convoy grouping, DrawerStack, motion animations)Visual Changes
N/A
Reviewer Notes
isLoadingprop onRefineryActivityLogis alwaysfalsewhen called fromMergesPageClient(parent guards onmergeQueueQuery.data). The loading skeleton exists for potential reuse elsewhere — acceptable defensive pattern.RefineryActivityLogmirrors the same pattern used inNeedsAttention.tsxfor consistency.