Repository navigation
perf(automations): Page and index the Automations list, and expand rows in the new UI - #3570
Merged
Merged
Conversation
…omations faster The new UI's Automations list reads one page of 50 by latest activity, with a Mine / All toggle, Inbox-style date groups, infinite scroll, and rows that expand in place. List rows skip the per-Automation run totals, and only the attention filters pay for the trigger check. A partial index on (team_id, creator_slack_user_id) serves the Mine filter. The Automation page starts its runs and versions reads with the summary and paints the header from the list row while the summary loads. Co-Authored-By: BYK <[email protected]>
…-speed Co-Authored-By: BYK <[email protected]> # Conflicts: # packages/junior-dashboard/e2e/inbox/automations.spec.ts
…sertion baseline Co-Authored-By: BYK <[email protected]>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
BYK
approved these changes
Nov 17, 2026
BYK
enabled auto-merge (squash)
November 17, 2026 12:24
…-speed # Conflicts: # packages/junior/src/chat/automations/read.ts
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 2 potential issues.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 0f67ce6. Configure here.
BYK
added a commit
that referenced
this pull request
Nov 17, 2026
Turns the perf patterns from #3184, #2820, #2991, #3271, #2921 and #3449 into checks that fail CI, and fixes the code that breaks them. `policies/performance.md` lists each rule and the check behind it. The DB and request budgets come in a follow-up PR. | Rule | Where | Fixed | Left | | --- | --- | --- | --- | | `unicorn/no-array-for-each` | root + dashboard | 43 | 0 | | `query-invalidation/no-broad-query-invalidation` (new, dashboard JS plugin) | dashboard `src` | 20 calls | 5 disable comments with reasons | | `junior/bounded-fan-out` (new) | `packages/*/src` | 24 (19 behind `pLimit`, 5 batched reads) | 13 disable comments naming the cap | | `no-await-in-loop` | `packages/*/src` | 3 moved to bounded `Promise.all`, 2 dashboard disables | 467 sites in 137 files, baselined | **`query-invalidation/no-broad-query-invalidation`** fails on `invalidateQueries`, `refetchQueries`, `resetQueries` or `removeQueries` when the key is missing, a literal of 2 or fewer parts, or a bare prefix const, unless the call passes `exact: true`. The fixes: - `invalidateConversationFeeds` replaces each `["dashboard", "conversations"]` refresh. - Rename writes the response title into the feeds and does not refetch. - `reviewItemQueryKey` and `invalidateReviewItemCollections` let Review item actions write item details from the response and refresh only count, list and waiting conversations. **`junior/bounded-fan-out`** flags `Promise.all`/`allSettled(<list>.map(async …))` unless the callback calls a `p-limit` limiter. A literal array is not flagged. Fixes use limits of 5 for provider APIs and 8 for internal storage. Batched fixes are `readSubscriptions` (one `mGet`) in `chat/events/store.ts` and `getStateValues` in cache warming. `junior-github` gets a `p-limit` dependency. **`no-await-in-loop` uses a baseline** because 467 sites is too many to triage safely in one PR. Many are intentionally sequential: cursor pages, ordered writes, rate limits, stop-on-first-failure. `tools/oxlint/await-in-loop.json` turns the rule off only for the listed files, and `scripts/await-in-loop-baseline.json` holds their per-file counts. `pnpm await-in-loop:check` (part of `pnpm lint`) fails when: - a count goes up, - a count goes down and the entry is not lowered or removed, - the two file lists drift. New files get the rule with no exemption. **Automations exclusion:** Otto is rewriting this code in #3570, so it is left alone. In the dashboard, `pages/automations/**`, `inbox/pages/automations/**` and `review-desk/inboxQueries.ts` have `no-broad-query-invalidation` and `no-await-in-loop` turned off. The server-side Automations files sit in the `no-await-in-loop` baseline like any other file. None of them had fan-out sites. Remove the dashboard override when that rewrite lands. <!-- junior-request-attribution:start --> via @BYK. <!-- junior-request-attribution:end --> <!-- junior-session-footer:start --> <!-- junior-conversation-id:agent%3A7e1432c2f4a2110ee7bb48718f8b6fad --> -- [View Session](https://junior-prod.sentry.dev/conversations/agent%3A7e1432c2f4a2110ee7bb48718f8b6fad) [[Sentry]](https://sentry.sentry.io/explore/conversations/agent%3A7e1432c2f4a2110ee7bb48718f8b6fad/?project=4510944073809921) <!-- junior-session-footer:end --> Co-authored-by: sentry-junior[bot] <264270552+sentry-junior[bot]@users.noreply.github.com> Co-authored-by: BYK <[email protected]>
Contributor
|
21 screenshot changes — 15 changed · 6 added · 0 removed Review screenshots in Frameshift Show 9 more changed screenshots |
BYK
added a commit
that referenced
this pull request
Nov 17, 2026
Adds round-trip budgets for hot API routes and dashboard pages, so new code cannot quietly add SQL statements, serial rounds or page requests. #3573 added the matching lint rules. `expectSqlBudget` counts the SQL statements of one request and its serial rounds: the longest chain of statements where each one waits on the one before. It reads the `orchestrion:pg:query` and `orchestrion:pg-pool:connect` tracing channels. Sentry's Postgres integration reads the same channels to make database spans. In a production build, the Sentry Rollup plugin injects them into `pg`. In tests, `tests/fixtures/pg-tracing-hook.ts` injects them with the `--import` hook that Vitest passes to its workers. That hook uses Sentry's load-hook transform and covers only `pg` and `pg-pool`. Runtime code gets no wrapper, and the executor needs no test-only config. A `pool.query` statement starts when it is called, not when a client is free, so the count does not depend on the pool size. SQL budgets cover the conversation list, conversation detail, child agents, versions, and the review item list, count and waiting conversations. `expectRequestBudget` covers the first load of the home page, a conversation, and the review desk. Each budget equals the current value. The review desk read the selected item's Conversation twice on load: once for its full detail and once for its title. The title read now takes the title from the detail when the detail is cached or in flight, so the review desk budget drops from 10 requests to 9. Automations routes have no budget yet, because Otto's follow-up to #3570 still changes them. `policies/performance.md` gets the budget rules. <!-- junior-request-attribution:start --> via @BYK. <!-- junior-request-attribution:end --> <!-- junior-session-footer:start --> <!-- junior-conversation-id:agent%3A7e1432c2f4a2110ee7bb48718f8b6fad --> -- [View Session](https://junior-prod.sentry.dev/conversations/agent%3A7e1432c2f4a2110ee7bb48718f8b6fad) [[Sentry]](https://sentry.sentry.io/explore/conversations/agent%3A7e1432c2f4a2110ee7bb48718f8b6fad/?project=4510944073809921) <!-- junior-session-footer:end --> --------- Co-authored-by: sentry-junior[bot] <264270552+sentry-junior[bot]@users.noreply.github.com> Co-authored-by: BYK <[email protected]>
BYK
added a commit
that referenced
this pull request
Nov 17, 2026
…es (#3572) Follows #3570. It makes the Automation list and page cheaper to read and refresh, and fixes two Bugbot findings from #3570. Numbers are local, on a synthetic database (about 19k Automations, 3.1M runs, 700k Conversations), medians through the real API. They show relative change only. ## Changes **Last run by id.** Migration 0117 adds `last_run_id` to `junior_automations`, a foreign key to `junior_automation_runs` that a purged run clears (`ON DELETE SET NULL`). `refreshAutomationLastRun` sets it after each write that adds, settles or removes an execution. The attention filter reads the status of that run. The activity page does not sort every row by a joined value. It walks runs newest first through the existing `completed_at_ms` index and keeps each run that is a listed Automation's last run. A second branch lists Automations that have no run yet, by creation time. Migration 0118 adds the `last_run_id` index (`CONCURRENTLY`) that the walk and the foreign key use. The backfill is one bounded statement (3 s for 19k rows on the bench). What each attempt cost on the bench. The first numbers are the old newest-run probe on `main`; the others are on this branch: | Variant | All, activity | Mine | `scope=attention` | All, page 2 | | --- | --- | --- | --- | --- | | `main`, newest run per row | 275 ms | n/a | about 690 ms | 630 ms | | Copied `last_run_at_ms` and `last_run_status` | 61–76 ms | 43–53 ms | 160–205 ms | 41–55 ms | | `last_run_id`, plain join, sorted on the joined value | 136–139 ms | 61 ms | 193–206 ms | 97–102 ms | | Same, with a `(id) INCLUDE (completed_at_ms, status)` index on runs | 133 ms | 55 ms | 202 ms | 97 ms | | Same, with a forced hash join | about 377 ms in SQL alone | | | | | `last_run_id`, walk on the runs index (shipped) | 56–76 ms | 50–59 ms | 172–204 ms | 19–30 ms | The plain join reads the last run of each of the 19k rows before it sorts (about 77k buffers, 135 ms in SQL, against 21 ms for the copied columns). The covering index makes those reads index-only but not fewer. The walk reads about 1,060 runs for the first page of All (4 ms in SQL). For Mine the planner picks the viewer's 196 rows first and reads their last runs (5 ms in SQL). All and attention are within run-to-run noise of the copied columns, page 2 is faster, and Mine is about 4 ms slower in SQL, inside the noise of the request. Responses are byte-identical. **Facets once per list.** Pages after the first omit the total, counts and filter options; the client reads them from the first page. `automationListPageSchema` makes them optional only for those pages. The first page reads its rows while the facets load. - All, page 2: 630 ms → 44 ms. Mine, page 2: 66 ms → 40 ms. **Executions without the summary.** `/executions` no longer rebuilds the summary and its cost totals. The Runs tab reads the total and title from the summary the page already loads. The `get_automation` MCP tool reads the summary itself. - Busy Automation, `/executions`: 189 ms → 125 ms, before the cost column below. **Cost on the run.** Migration 0117 also adds `cost_micro_usd` (`bigint`) to `junior_automation_runs`, the Conversation's cost rounded to whole micro-USD. The write that updates a Conversation's `usage_json` is one statement with the copy: a data-modifying CTE returns the new cost, and the outer update sets it on the run. It commits with the usage write, adds no round trip, and changes nothing for a Conversation without a run. Run writes that link a Conversation set the cost in the same insert or upsert. The summary windows and the 90-day and hourly charts sum the column as integers from the `(automation_id, completed_at_ms)` index, and the read layer converts to USD, so the API and the UI are unchanged. The backfill touches only settled runs (50 s for 700k runs on the bench). - Busy Automation (25k runs): summary 108 ms → 21 ms; runs and 90-day chart 133 ms → 60–80 ms. The cost query went from a hash join that scanned every Conversation (about 18k buffers) to a bitmap scan of the Automation's runs (about 700 buffers). - Typical Automation (150 runs): about 10 ms either way. - On the bench, every stored cost equals the old per-run cost rounded to the micro-dollar, and the total is exactly 20400.000000. The float total was 20400.000000048, and that noise is gone. A real cost with digits past the sixth decimal now rounds per run, by at most half a micro-dollar. **Client.** Automation reads use `automationKeys`. A save, pause, resume, activate or delete writes the returned edit read and refreshes only the lists, the runs list and that Automation. New-UI rows prefetch the summary and runs on hover or focus. Attention pages after the first load in parallel through a `p-limit` pool of 8. The Automations code no longer has its own exclusion from `no-await-in-loop` and `no-broad-query-invalidation`. **Fixes from #3570.** In the new UI, a row's Change trigger and Open runs links keep the list query, so Back from an Automation on All returns to All. The expanded row names each event trigger filter once. ## Breaking changes - The `/api/automations/:id/executions` response no longer has `automation`. The dashboard and MCP tool are updated. - During the rollout, a run that the old runtime settles leaves an older last run, and no stored cost, until the Automation runs again or the Conversation's usage changes. A repair migration for the next release recomputes both for runs that ended after 0117 was written. ## Screenshots The expanded event row at 1440, before and after the filter fix. | | Before | After | | --- | --- | --- | | Light |  |  | | Dark |  |  | <!-- junior-request-attribution:start --> via @BYK. <!-- junior-request-attribution:end --> <!-- junior-session-footer:start --> <!-- junior-conversation-id:agent%3Ad0a5efe7c6a99aa6fc18bf071671119b --> -- [View Session](https://junior-prod.sentry.dev/conversations/agent%3Ad0a5efe7c6a99aa6fc18bf071671119b) [[Sentry]](https://sentry.sentry.io/explore/conversations/agent%3Ad0a5efe7c6a99aa6fc18bf071671119b/?project=4510944073809921) <!-- junior-session-footer:end --> --------- Co-authored-by: sentry-junior[bot] <264270552+sentry-junior[bot]@users.noreply.github.com> Co-authored-by: BYK <[email protected]>
24 tasks done
armcknight
added a commit
that referenced
this pull request
Nov 18, 2026
#3570 and #3572 removed `automation` from the `/automations/:id/executions` response. The mock getAutomation tool still read it and failed for every Automation, so testAutomationShowsRuns never saw Recent runs. Read `/automations/:id` and the executions in parallel, as the real tool does. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This branch was successfully deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

The new UI's Automations list now reads one page of 50 rows, newest activity first. It has a Mine / All toggle, Inbox-style date groups, infinite scroll, and rows that expand in place. The Automation page starts all of its reads at once and paints its header from the list row. The output of today's UI does not change. It gets the smaller list rows (it never showed their totals) and the cheaper attention prefetch.
Where the list time went
AutomationListItem) now omit the totals, and onlyGET /api/automations/:idreturns them. Recent runs and the last run come from a lateral read of the newest 20 runs.scope=attentionandstate=unavailable.(team_id, creator_slack_user_id) WHERE status <> 'deleted', built CONCURRENTLY. On the benchmark, the plan moves from a seq scan (27.6 ms, 3,337 buffers) to a BitmapOr (4.6 ms, 1,062 buffers).Local benchmark (medians on a synthetic local DB: 20k Automations, 3.1M runs, 700k Conversations)
sort=activitypage: 50 ms for Mine and 231 ms for All. About 198 ms of the All time is per-row newest-run probes over 12.1k rows (61k buffers). A stored last-run column would remove that; it is a follow-up, because four code paths write runs.API
sort=activityorders by latest run, then creation time, then ID.nextCursor, throughapi/page-cursor.runs,costUsd,totalRunsandtotalCostUsd.New UI
PageEnd.Screenshots (1440 wide)
Migration number: #3392 also uses 0115 and 0116. If it merges first, this migration gets a new number.
via @BYK.
--
View Session [Sentry]