Skip to content

feat(webapp,core,cli): filter runs by region in dashboard, API, and MCP#3612

Open
ericallam wants to merge 1 commit into
mainfrom
feat/runs-list-region-filter
Open

feat(webapp,core,cli): filter runs by region in dashboard, API, and MCP#3612
ericallam wants to merge 1 commit into
mainfrom
feat/runs-list-region-filter

Conversation

@ericallam
Copy link
Copy Markdown
Member

@ericallam ericallam commented May 13, 2026

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 matching region input on the MCP list_runs tool. Each run's executing region is also surfaced as a new optional region field on the runs list and run retrieve responses, populated from the worker instance group's masterQueue identifier.

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 masterQueue identifier (the same string already persisted on TaskRun and replicated to ClickHouse as worker_queue), so the query just becomes worker_queue IN (...) with no server-side translation. The Region dropdown options come from a new resource loader backed by RegionsPresenter, which now also exposes masterQueue alongside the existing region metadata.

// public API
const runs = await runs.list({ region: ["us-east-1", "eu-west-1"] });
// each item: { id, status, ..., region?: "us-east-1" }
// MCP
list_runs({ environment: "prod", region: "us-east-1" })

Test plan

  • Dashboard: open the runs list, confirm the new Region column renders the friendly region name (or for legacy runs with empty masterQueue).
  • Dashboard: open More filters → Region, multi-select a couple of regions, confirm the URL gains ?regions=<masterQueue> and the list narrows.
  • Combine with Queues / Statuses / time filters — no interaction regressions.
  • API: GET /api/v1/runs?filter[region]=<masterQueue> returns only matching runs, and each item has a region field set.
  • API: GET /api/v1/runs/<id> returns region for a run that has a non-empty workerQueue.
  • MCP: call list_runs with region: "..."; verify the formatted output line includes region:<value>.

This is part 1 of 5 in a stack made with GitButler:

@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented May 13, 2026

🦋 Changeset detected

Latest commit: 2493552

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 32 packages
Name Type
trigger.dev Patch
@trigger.dev/core Patch
@trigger.dev/sdk Patch
references-ai-chat Patch
d3-chat Patch
references-d3-openai-agents Patch
references-nextjs-realtime Patch
references-realtime-hooks-test Patch
references-realtime-streams Patch
references-telemetry Patch
@trigger.dev/build Patch
@trigger.dev/plugins Patch
@trigger.dev/python Patch
@trigger.dev/redis-worker Patch
@trigger.dev/schema-to-json Patch
@internal/cache Patch
@internal/clickhouse Patch
@internal/llm-model-catalog Patch
@trigger.dev/rbac Patch
@internal/redis Patch
@internal/replication Patch
@internal/run-engine Patch
@internal/schedule-engine Patch
@internal/testcontainers Patch
@internal/tracing Patch
@internal/tsql Patch
@internal/zod-worker Patch
@internal/sdk-compat-tests Patch
@trigger.dev/react-hooks Patch
@trigger.dev/rsc Patch
@trigger.dev/database Patch
@trigger.dev/otlp-importer Patch

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

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 13, 2026

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: d828f002-29eb-4c9f-bae7-e24d63a04ee1

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/runs-list-region-filter

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@ericallam ericallam force-pushed the feat/runs-list-region-filter branch 2 times, most recently from 125a478 to cd003da Compare May 13, 2026 15:15
@ericallam ericallam force-pushed the feature/ai-chat-reference-and-cli branch from 36ccf22 to a90949b Compare May 13, 2026 15:46
@ericallam ericallam force-pushed the feat/runs-list-region-filter branch 3 times, most recently from aac03ef to 4fb9480 Compare May 13, 2026 21:56
@ericallam ericallam force-pushed the feature/ai-chat-reference-and-cli branch from 75369f3 to cf2fa07 Compare May 14, 2026 09:11
@ericallam ericallam force-pushed the feat/runs-list-region-filter branch from 4fb9480 to eb1cffa Compare May 14, 2026 09:19
@ericallam ericallam force-pushed the feature/ai-chat-reference-and-cli branch from cf2fa07 to fef74f4 Compare May 14, 2026 09:33
@ericallam ericallam force-pushed the feat/runs-list-region-filter branch from eb1cffa to df25e74 Compare May 14, 2026 09:33
@ericallam ericallam force-pushed the feature/ai-chat-reference-and-cli branch from fef74f4 to 343c204 Compare May 14, 2026 11:06
@ericallam ericallam force-pushed the feat/runs-list-region-filter branch from df25e74 to cd06bb3 Compare May 14, 2026 11:06
@ericallam ericallam marked this pull request as ready for review May 14, 2026 11:07
Copy link
Copy Markdown
Contributor

@devin-ai-integration devin-ai-integration Bot left a comment

Choose a reason for hiding this comment

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

Devin Review found 3 potential issues.

View 2 additional findings in Devin Review.

Open in Devin Review

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.

🟡 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)

Open in Devin Review

Was this helpful? React with 👍 or 👎 to provide feedback.

variant?: TableVariant;
disableAdjacentRows?: boolean;
additionalTableState?: Record<string, string>;
regions?: { masterQueue: string; name: string; location?: string }[];
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.

🚩 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.

Open in Devin Review

Was this helpful? React with 👍 or 👎 to provide feedback.

triggerFunction: resolveTriggerFunction(run),
batchId: run.batch?.friendlyId,
metadata,
region: run.workerQueue || undefined,
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.

🚩 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.

Open in Devin Review

Was this helpful? React with 👍 or 👎 to provide feedback.

@ericallam ericallam force-pushed the feature/ai-chat-reference-and-cli branch from 343c204 to 480c5ea Compare May 14, 2026 12:13
@ericallam ericallam force-pushed the feat/runs-list-region-filter branch from cd06bb3 to f13d871 Compare May 14, 2026 12:13
@ericallam ericallam force-pushed the feature/ai-chat-reference-and-cli branch from 480c5ea to 8954526 Compare May 14, 2026 12:30
@ericallam ericallam force-pushed the feat/runs-list-region-filter branch from f13d871 to 73a1b2e Compare May 14, 2026 12:30
@ericallam ericallam force-pushed the feature/ai-chat-reference-and-cli branch from 8954526 to 289ab08 Compare May 14, 2026 12:32
@ericallam ericallam force-pushed the feat/runs-list-region-filter branch from 73a1b2e to a6c3bfc Compare May 14, 2026 12:32
ericallam added a commit that referenced this pull request May 14, 2026
…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>&nbsp;5&nbsp;</kbd> #3612
- <kbd>&nbsp;4&nbsp;</kbd> #3546
- <kbd>&nbsp;3&nbsp;</kbd> #3545
- <kbd>&nbsp;2&nbsp;</kbd> #3543
- <kbd>&nbsp;1&nbsp;</kbd> #3542 👈 
<!-- GitButler Footer Boundary Bottom -->
@ericallam ericallam force-pushed the feature/ai-chat-reference-and-cli branch from 289ab08 to e373556 Compare May 14, 2026 12:45
@ericallam ericallam force-pushed the feat/runs-list-region-filter branch from a6c3bfc to 899e37f Compare May 14, 2026 12:45
Copy link
Copy Markdown
Contributor

@devin-ai-integration devin-ai-integration Bot left a comment

Choose a reason for hiding this comment

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

Devin Review found 1 new potential issue.

View 4 additional findings in Devin Review.

Open in Devin Review

Comment on lines +328 to +330
if (options.regions && options.regions.length > 0) {
queryBuilder.where("worker_queue IN {regions: Array(String)}", { regions: options.regions });
}
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.

🚩 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.

Open in Devin Review

Was this helpful? React with 👍 or 👎 to provide feedback.

@ericallam ericallam force-pushed the feature/ai-chat-reference-and-cli branch from e373556 to 55d9543 Compare May 14, 2026 13:11
@ericallam ericallam force-pushed the feat/runs-list-region-filter branch from 899e37f to 95abd6c Compare May 14, 2026 13:11
@ericallam ericallam force-pushed the feature/ai-chat-reference-and-cli branch from 55d9543 to 2cd4c8f Compare May 14, 2026 14:11
@ericallam ericallam force-pushed the feat/runs-list-region-filter branch from 95abd6c to 2075e5e Compare May 14, 2026 14:11
@ericallam ericallam force-pushed the feature/ai-chat-reference-and-cli branch from 2cd4c8f to d3f90d7 Compare May 14, 2026 14:31
@ericallam ericallam force-pushed the feat/runs-list-region-filter branch from 2075e5e to 0da7de8 Compare May 14, 2026 14:31
@ericallam ericallam force-pushed the feature/ai-chat-reference-and-cli branch from d3f90d7 to 43e9f21 Compare May 14, 2026 14:58
@ericallam ericallam force-pushed the feat/runs-list-region-filter branch from 0da7de8 to a2f958b Compare May 14, 2026 14:58
@ericallam ericallam force-pushed the feature/ai-chat-reference-and-cli branch from 43e9f21 to c252b96 Compare May 14, 2026 15:46
@ericallam ericallam force-pushed the feat/runs-list-region-filter branch from a2f958b to 2a28ac0 Compare May 14, 2026 15:46
@ericallam ericallam force-pushed the feature/ai-chat-reference-and-cli branch from c252b96 to 6f62bc9 Compare May 14, 2026 15:59
@ericallam ericallam force-pushed the feat/runs-list-region-filter branch from 2a28ac0 to ac2d3de Compare May 14, 2026 15:59
@ericallam ericallam force-pushed the feature/ai-chat-reference-and-cli branch from 6f62bc9 to ccadd9f Compare May 14, 2026 16:09
@ericallam ericallam force-pushed the feat/runs-list-region-filter branch from ac2d3de to c13927e Compare May 14, 2026 16:09
@ericallam ericallam force-pushed the feature/ai-chat-reference-and-cli branch from ccadd9f to 9acd6cd Compare May 14, 2026 16:25
@ericallam ericallam force-pushed the feat/runs-list-region-filter branch from c13927e to 270e95c Compare May 14, 2026 16:25
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.
@ericallam ericallam force-pushed the feature/ai-chat-reference-and-cli branch from 9acd6cd to 8673d42 Compare May 14, 2026 16:39
@ericallam ericallam force-pushed the feat/runs-list-region-filter branch from 270e95c to 2493552 Compare May 14, 2026 16:40
Base automatically changed from feature/ai-chat-reference-and-cli to main May 14, 2026 16:55
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.

2 participants