-
Notifications
You must be signed in to change notification settings - Fork 620
[Dashboard] Add transaction filtering by Queue ID to engine v2 #8163
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Dashboard] Add transaction filtering by Queue ID to engine v2 #8163
Conversation
|
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
WalkthroughIntroduces an optional id parameter to the engine transactions hook to fetch a single transaction by ID. Updates the transactions table UI to include a “Filter by Queue ID” input, wiring it to the hook’s id parameter and resetting pagination when the filter changes. Changes
Sequence Diagram(s)sequenceDiagram
participant U as User
participant TT as TransactionsTable
participant H as useEngineTransactions
participant API as Engine API
U->>TT: Type in "Filter by Queue ID"
TT->>H: useEngineTransactions({ id: filterId, page, ... })
alt id provided
H->>API: GET /transaction/{id}
API-->>H: { result: Transaction }
H-->>TT: { transactions: [Transaction], totalCount: 1 }
else no id
H->>API: GET /transactions?queryParams
API-->>H: { results: Transaction[], totalCount }
H-->>TT: { transactions, totalCount }
end
TT-->>U: Render transactions table
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✨ Finishing touches
🧪 Generate unit tests
Warning Review ran into problems🔥 ProblemsErrors were encountered while retrieving linked issues. Errors (1)
Comment |
How to use the Graphite Merge QueueAdd either label to this PR to merge it via the merge queue:
You must have a Graphite account in order to use the merge queue. Sign up using this link. An organization admin has enabled the Graphite Merge Queue in this repository. Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue. This stack of pull requests is managed by Graphite. Learn more about stacking. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #8163 +/- ##
=======================================
Coverage 56.28% 56.28%
=======================================
Files 906 906
Lines 59208 59208
Branches 4180 4180
=======================================
Hits 33324 33324
Misses 25779 25779
Partials 105 105
🚀 New features to boost your workflow:
|
07f602b to
d3640f2
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
🧹 Nitpick comments (1)
apps/dashboard/src/app/(app)/team/[team_slug]/[project_slug]/(sidebar)/engine/(instance)/[engineId]/overview/components/transactions-table.tsx (1)
166-175: Consider debouncing the filter input for better UX.The input implementation is correct, but every keystroke triggers a new query. Since the filter fetches a specific transaction by ID, users typing a partial ID will get errors or empty results until the complete ID is entered.
Consider debouncing the filter to wait for the user to finish typing:
import { useMemo } from "react"; import { useDebounce } from "@/hooks/useDebounce"; // or install use-debounce // In component: const [filterIdInput, setFilterIdInput] = useState(""); const filterId = useDebounce(filterIdInput.trim() || undefined, 500); // In render: <Input className="max-w-[250px]" onChange={(e) => { setFilterIdInput(e.target.value); setPage(1); }} placeholder="Filter by Queue ID" value={filterIdInput} />Alternatively, use a search button pattern where users explicitly trigger the filter.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
Disabled knowledge base sources:
- Linear integration is disabled by default for public repositories
You can enable these sources in your CodeRabbit configuration.
📒 Files selected for processing (2)
apps/dashboard/src/@/hooks/useEngine.ts(1 hunks)apps/dashboard/src/app/(app)/team/[team_slug]/[project_slug]/(sidebar)/engine/(instance)/[engineId]/overview/components/transactions-table.tsx(4 hunks)
🧰 Additional context used
📓 Path-based instructions (5)
**/*.{ts,tsx}
📄 CodeRabbit inference engine (CLAUDE.md)
**/*.{ts,tsx}: Write idiomatic TypeScript with explicit function declarations and return types
Limit each file to one stateless, single-responsibility function for clarity
Re-use shared types from@/typesor localtypes.tsbarrels
Prefer type aliases over interface except for nominal shapes
Avoidanyandunknownunless unavoidable; narrow generics when possible
Choose composition over inheritance; leverage utility types (Partial,Pick, etc.)
Comment only ambiguous logic; avoid restating TypeScript in prose
**/*.{ts,tsx}: Use explicit function declarations and explicit return types in TypeScript
Limit each file to one stateless, single‑responsibility function
Re‑use shared types from@/typeswhere applicable
Prefertypealiases overinterfaceexcept for nominal shapes
Avoidanyandunknownunless unavoidable; narrow generics when possible
Prefer composition over inheritance; use utility types (Partial, Pick, etc.)
Lazy‑import optional features and avoid top‑level side‑effects to reduce bundle size
Files:
apps/dashboard/src/app/(app)/team/[team_slug]/[project_slug]/(sidebar)/engine/(instance)/[engineId]/overview/components/transactions-table.tsxapps/dashboard/src/@/hooks/useEngine.ts
**/*.{ts,tsx,js,jsx}
📄 CodeRabbit inference engine (CLAUDE.md)
Load heavy dependencies inside async paths to keep initial bundle lean (lazy loading)
Files:
apps/dashboard/src/app/(app)/team/[team_slug]/[project_slug]/(sidebar)/engine/(instance)/[engineId]/overview/components/transactions-table.tsxapps/dashboard/src/@/hooks/useEngine.ts
apps/{dashboard,playground-web}/**/*.{ts,tsx}
📄 CodeRabbit inference engine (CLAUDE.md)
apps/{dashboard,playground-web}/**/*.{ts,tsx}: Import UI primitives from@/components/ui/*(Button, Input, Select, Tabs, Card, Sidebar, Badge, Separator) in dashboard and playground apps
UseNavLinkfor internal navigation with automatic active states in dashboard and playground apps
Use Tailwind CSS only – no inline styles or CSS modules
Usecn()from@/lib/utilsfor conditional class logic
Use design system tokens (e.g.,bg-card,border-border,text-muted-foreground)
Server Components (Node edge): Start files withimport "server-only";
Client Components (browser): Begin files with'use client';
Always callgetAuthToken()to retrieve JWT from cookies on server side
UseAuthorization: Bearerheader – never embed tokens in URLs
Return typed results (e.g.,Project[],User[]) – avoidany
Wrap client-side data fetching calls in React Query (@tanstack/react-query)
Use descriptive, stablequeryKeysfor React Query cache hits
ConfigurestaleTime/cacheTimein React Query based on freshness (default ≥ 60s)
Keep tokens secret via internal API routes or server actions
Never importposthog-jsin server components
Files:
apps/dashboard/src/app/(app)/team/[team_slug]/[project_slug]/(sidebar)/engine/(instance)/[engineId]/overview/components/transactions-table.tsxapps/dashboard/src/@/hooks/useEngine.ts
apps/{dashboard,playground}/**/*.{ts,tsx}
📄 CodeRabbit inference engine (AGENTS.md)
apps/{dashboard,playground}/**/*.{ts,tsx}: Import UI primitives from@/components/ui/_(e.g., Button, Input, Tabs, Card)
UseNavLinkfor internal navigation to get active state handling
Use Tailwind CSS for styling; no inline styles
Merge class names withcn()from@/lib/utilsfor conditional classes
Stick to design tokens (e.g., bg-card, border-border, text-muted-foreground)
Server Components must start withimport "server-only"; usenext/headers, server‑only env, heavy data fetching, andredirect()where appropriate
Client Components must start with'use client'; handle interactivity with hooks and browser APIs
Server-side data fetching: callgetAuthToken()from cookies, sendAuthorization: Bearer <token>header, and return typed results (avoidany)
Client-side data fetching: wrap calls in React Query with descriptive, stablequeryKeysand set sensiblestaleTime/cacheTime(≥ 60s default); keep tokens secret via internal routes or server actions
Do not importposthog-jsin server components (client-side only)
Files:
apps/dashboard/src/app/(app)/team/[team_slug]/[project_slug]/(sidebar)/engine/(instance)/[engineId]/overview/components/transactions-table.tsxapps/dashboard/src/@/hooks/useEngine.ts
apps/{dashboard,playground}/**/*.tsx
📄 CodeRabbit inference engine (AGENTS.md)
Expose a
classNameprop on the root element of every component
Files:
apps/dashboard/src/app/(app)/team/[team_slug]/[project_slug]/(sidebar)/engine/(instance)/[engineId]/overview/components/transactions-table.tsx
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (8)
- GitHub Check: Size
- GitHub Check: E2E Tests (pnpm, webpack)
- GitHub Check: Unit Tests
- GitHub Check: E2E Tests (pnpm, esbuild)
- GitHub Check: E2E Tests (pnpm, vite)
- GitHub Check: Build Packages
- GitHub Check: Lint Packages
- GitHub Check: Analyze (javascript)
🔇 Additional comments (3)
apps/dashboard/src/@/hooks/useEngine.ts (1)
382-384: LGTM! Parameter addition looks good.The optional
idparameter is correctly typed and destructured, maintaining backward compatibility with existing callers.apps/dashboard/src/app/(app)/team/[team_slug]/[project_slug]/(sidebar)/engine/(instance)/[engineId]/overview/components/transactions-table.tsx (2)
1-1: LGTM! Import follows coding guidelines.The Input component is correctly imported from the workspace UI library as specified in the coding guidelines.
114-126: LGTM! Filter state and hook integration look correct.The
filterIdstate is properly typed and wired to theuseEngineTransactionshook. The optional string type matches the hook's parameter signature.
| if (id) { | ||
| const res = await fetch(`${instanceUrl}transaction/${id}`, { | ||
| headers: getEngineRequestHeaders(authToken), | ||
| method: "GET", | ||
| }); | ||
|
|
||
| const json = await res.json(); | ||
| const transaction = (json.result as Transaction) || {}; | ||
| return { | ||
| transactions: [transaction], | ||
| totalCount: 1, | ||
| }; | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add error handling and response validation.
The single-transaction fetch path lacks error handling and response validation. Consider these concerns:
- No HTTP status check - non-2xx responses are not handled
- No validation that
json.resultexists before casting - Empty object fallback (
|| {}) could return invalid Transaction shape
While the existing fetch-all path (lines 414-421) has similar patterns, this represents a good opportunity to add defensive checks.
Consider this approach:
if (id) {
const res = await fetch(`${instanceUrl}transaction/${id}`, {
headers: getEngineRequestHeaders(authToken),
method: "GET",
});
+ if (!res.ok) {
+ throw new Error(`Failed to fetch transaction: ${res.status} ${await res.text()}`);
+ }
+
const json = await res.json();
- const transaction = (json.result as Transaction) || {};
+
+ if (!json.result) {
+ throw new Error("Invalid response: missing result field");
+ }
+
+ const transaction = json.result as Transaction;
return {
transactions: [transaction],
totalCount: 1,
};
}📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| if (id) { | |
| const res = await fetch(`${instanceUrl}transaction/${id}`, { | |
| headers: getEngineRequestHeaders(authToken), | |
| method: "GET", | |
| }); | |
| const json = await res.json(); | |
| const transaction = (json.result as Transaction) || {}; | |
| return { | |
| transactions: [transaction], | |
| totalCount: 1, | |
| }; | |
| } | |
| if (id) { | |
| const res = await fetch(`${instanceUrl}transaction/${id}`, { | |
| headers: getEngineRequestHeaders(authToken), | |
| method: "GET", | |
| }); | |
| if (!res.ok) { | |
| throw new Error(`Failed to fetch transaction: ${res.status} ${await res.text()}`); | |
| } | |
| const json = await res.json(); | |
| if (!json.result) { | |
| throw new Error("Invalid response: missing result field"); | |
| } | |
| const transaction = json.result as Transaction; | |
| return { | |
| transactions: [transaction], | |
| totalCount: 1, | |
| }; | |
| } |
🤖 Prompt for AI Agents
In apps/dashboard/src/@/hooks/useEngine.ts around lines 389 to 401, the
single-transaction fetch path lacks HTTP status checking and response
validation; add a res.ok check and throw or handle non-2xx responses, parse json
and verify json.result exists and has the expected Transaction shape (at least
required fields like id), avoid using a blind || {} fallback, and return either
a validated transactions array with totalCount 1 or an empty array with
totalCount 0 (or propagate the error) — wrap the fetch in try/catch to surface
or log errors consistently with the fetch-all path and ensure the function
always returns the same response shape.
size-limit report 📦
|

PR-Codex overview
This PR introduces a new
idparameter to theuseEnginehook and enhances theTransactionsTablecomponent to filter transactions by thisid. It allows fetching a specific transaction when anidis provided and adds an input field for users to filter transactions based on the Queue ID.Detailed summary
id?: stringto the parameters of theuseEnginehook.useEngineto fetch a specific transaction whenidis present.filterIdstate inTransactionsTableto hold the Queue ID filter.TransactionsTablefor filtering transactions by Queue ID.Summary by CodeRabbit