feat(webapp,core,cli): filter runs by region in dashboard, API, and MCP#3612
feat(webapp,core,cli): filter runs by region in dashboard, API, and MCP#3612ericallam wants to merge 1 commit into
Conversation
🦋 Changeset detectedLatest commit: 2493552 The changes in this PR will be included in the next version bump. This PR includes changesets to release 32 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
125a478 to
cd003da
Compare
36ccf22 to
a90949b
Compare
aac03ef to
4fb9480
Compare
75369f3 to
cf2fa07
Compare
4fb9480 to
eb1cffa
Compare
cf2fa07 to
fef74f4
Compare
eb1cffa to
df25e74
Compare
fef74f4 to
343c204
Compare
df25e74 to
cd06bb3
Compare
There was a problem hiding this comment.
🟡 Missing regions in hasFilters check prevents "Clear all filters" button from appearing
The hasFilters variable in RunsFilters (apps/webapp/app/components/runs/v3/RunFilters.tsx:377-389) determines whether the "Clear all filters" button is shown. The PR added regions as a new filter type throughout the codebase (filter menu, applied filter pill, search params parsing, ClickHouse query, etc.) but did not add searchParams.has("regions") to this check. When a user applies only a region filter, the "Clear all filters" button will not appear, leaving the user without a quick way to reset filters.
(Refers to lines 377-389)
Was this helpful? React with 👍 or 👎 to provide feedback.
| variant?: TableVariant; | ||
| disableAdjacentRows?: boolean; | ||
| additionalTableState?: Record<string, string>; | ||
| regions?: { masterQueue: string; name: string; location?: string }[]; |
There was a problem hiding this comment.
🚩 Other TaskRunsTable call sites don't pass regions prop — graceful fallback
The TaskRunsTable component is used in three other routes (errors, waitpoints, schedules) that don't pass the new regions prop. Since regions defaults to undefined and the regionByMasterQueue map is built from regions ?? [], this is safe. The region column will still appear for non-DEVELOPMENT environments, but will show raw masterQueue strings (e.g. 'us-east-1') instead of friendly names with flag icons. This is an acceptable degradation — the data is still correct, just less pretty.
Was this helpful? React with 👍 or 👎 to provide feedback.
| triggerFunction: resolveTriggerFunction(run), | ||
| batchId: run.batch?.friendlyId, | ||
| metadata, | ||
| region: run.workerQueue || undefined, |
There was a problem hiding this comment.
🚩 ApiRetrieveRunPresenter exposes workerQueue as region for both detail and related runs
In createCommonRunStructure at apps/webapp/app/presenters/v3/ApiRetrieveRunPresenter.server.ts:467, region: run.workerQueue || undefined is set. Since commonRunSelect now includes workerQueue: true and createCommonRunStructure is used for both the main run and related runs (parent/root/children), the region field will appear on all related run objects in the API response. The workerQueue column has a Prisma @default("main") so it will always have a value — meaning region will be set to "main" for most runs rather than undefined. This is the || undefined check using falsy, and since "main" is truthy, it will pass through. This seems intentional but worth noting: even runs that haven't been assigned to a specific region will show "main" as their region.
Was this helpful? React with 👍 or 👎 to provide feedback.
343c204 to
480c5ea
Compare
cd06bb3 to
f13d871
Compare
480c5ea to
8954526
Compare
f13d871 to
73a1b2e
Compare
8954526 to
289ab08
Compare
73a1b2e to
a6c3bfc
Compare
…3542) ## Summary A `/sessions` dashboard for inspecting durable Sessions, an `AGENT` / `SCHEDULED` task-kind filter for the runs list, and the server-side hardening (rate-limit exemption for packets, retry-with-backoff on stream appends, typed too-large-chunk error) that the `chat.agent` runtime in #3543 needs. Builds on the Sessions primitive shipped in #3417. ## Design The Sessions list + detail routes mirror the run inspector pattern. `TaskTriggerSource` gains `AGENT` and `SCHEDULED` values, persisted on `BackgroundWorker.taskKind` and `TaskRun.taskKind` (plus a matching Clickhouse column), so the runs list can filter by kind. New `@trigger.dev/core` modules — `sessionStreams`, `inputStreams`, a `sessionStreamInstance` for realtime streams, and the `realtime-streams-api` / `session-streams-api` surfaces — expose the typed shapes that chat.agent will use to drive `session.out`. `ChatChunkTooLargeError` lets the runtime drop oversized chunks with a typed surface instead of failing the run. `s2Append` retries transient failures with exponential backoff. `/api/v[12]/packets/*` is exempt from customer rate limits so chat snapshot reads and writes don't get throttled under load. ## Stack Part of a 4-PR stack. Merge bottom-up. 1. **This PR** (#3542) → `main` 2. #3543 → #3542 — `chat.agent` runtime + browser transport 3. #3545 → #3543 — agent-view dashboard 4. #3546 → #3545 — ai-chat reference + MCP tooling Replaces #3173 (closed). <!-- GitButler Footer Boundary Top --> --- This is **part 5 of 5 in a stack** made with GitButler: - <kbd> 5 </kbd> #3612 - <kbd> 4 </kbd> #3546 - <kbd> 3 </kbd> #3545 - <kbd> 2 </kbd> #3543 - <kbd> 1 </kbd> #3542 👈 <!-- GitButler Footer Boundary Bottom -->
289ab08 to
e373556
Compare
a6c3bfc to
899e37f
Compare
| if (options.regions && options.regions.length > 0) { | ||
| queryBuilder.where("worker_queue IN {regions: Array(String)}", { regions: options.regions }); | ||
| } |
There was a problem hiding this comment.
🚩 ClickHouse vs Prisma data inconsistency for pre-existing runs' region values
The Prisma schema defines workerQueue String @default("main"), so all pre-existing PostgreSQL rows have workerQueue = "main". However, the ClickHouse column worker_queue defaults to "" (empty string) per taskRuns.ts:50. The new ClickHouse filter (clickhouseRunsRepository.server.ts:328-330) queries worker_queue IN {regions}, which means filtering by region "main" would miss pre-migration ClickHouse rows (which have worker_queue = ""). Meanwhile, the dashboard table reads from Prisma and shows "main" for those same runs. This inconsistency only matters for runs created before the worker_queue column was populated in ClickHouse.
Was this helpful? React with 👍 or 👎 to provide feedback.
e373556 to
55d9543
Compare
899e37f to
95abd6c
Compare
55d9543 to
2cd4c8f
Compare
95abd6c to
2075e5e
Compare
2cd4c8f to
d3f90d7
Compare
2075e5e to
0da7de8
Compare
d3f90d7 to
43e9f21
Compare
0da7de8 to
a2f958b
Compare
43e9f21 to
c252b96
Compare
a2f958b to
2a28ac0
Compare
c252b96 to
6f62bc9
Compare
2a28ac0 to
ac2d3de
Compare
6f62bc9 to
ccadd9f
Compare
ac2d3de to
c13927e
Compare
ccadd9f to
9acd6cd
Compare
c13927e to
270e95c
Compare
Adds a "Region" column and "Region" filter (under More filters) to the runs list, plus the same filter on the public runs list API (filter[region]) and the MCP list_runs tool (region input). Each run's executing region is exposed as a new optional region field on the runs list and run retrieve responses, populated from the worker instance group's masterQueue identifier.
9acd6cd to
8673d42
Compare
270e95c to
2493552
Compare
Summary
Adds a Region column and Region filter (under More filters) to the runs list dashboard, the same filter on the public runs list API (
filter[region]), and a matchingregioninput on the MCPlist_runstool. Each run's executing region is also surfaced as a new optionalregionfield on the runs list and run retrieve responses, populated from the worker instance group'smasterQueueidentifier.Useful when you run tasks across multiple regions and want to slice the runs list — or your existing run-querying scripts — by where the run actually executed.
Design
The filter value in the URL / API is the
masterQueueidentifier (the same string already persisted onTaskRunand replicated to ClickHouse asworker_queue), so the query just becomesworker_queue IN (...)with no server-side translation. The Region dropdown options come from a new resource loader backed byRegionsPresenter, which now also exposesmasterQueuealongside the existing region metadata.Test plan
–for legacy runs with emptymasterQueue).?regions=<masterQueue>and the list narrows.GET /api/v1/runs?filter[region]=<masterQueue>returns only matching runs, and each item has aregionfield set.GET /api/v1/runs/<id>returnsregionfor a run that has a non-emptyworkerQueue.list_runswithregion: "..."; verify the formatted output line includesregion:<value>.This is part 1 of 5 in a stack made with GitButler: