perf(shared): avoid redundant visibility work on status updates #28965
main fromrefs/pull/28965/head·merged by maria-rcks View on GitHubProblem#
Every run/attempt status update rebuilds transcript visibility indexes. The factory records ordinary historical statuses and scans all turn items for interrupt requests even when no hiding rule can apply. CPU profiles put most of the affected reducer workload in this visibility work. The refreshed open-PR catalog and targeted current diffs found no existing factory-allocation optimization.
Solution#
Index only rolled-back/cancelled statuses, preserving duplicate-ID last-wins behavior. Return an all-visible predicate when no hidden status or superseded attempt exists, and scan interrupt requests only when superseded roots exist. Keep the visible-row walk, row identity and all existing hiding rules. No cache, new exports, wire changes or provider-specific behavior.
The parent rerun of the actual exported reducer applies distinct status events to evolving, schema-decoded projections. A generated 39-run/356-item fixture uses counts from a sanitized local database—not recorded traffic. Across nine alternating batches of 10,000 calls, baseline 75.40 ms [74.15–80.03] → 25.97 ms [22.41–29.68], or 2.90× faster. Three collected-object allocation samples give 124.28 → 58.37 MB, or 53.03% fewer sampled V8 allocated bytes. An independent final-source run measured 3.06×/53.17%. Complete outputs are consumed and compared. Small/rollback/cancellation/superseded controls show no observed slowdown; the small control does not independently qualify. These are local reducer results, not retained heap, full synchronization latency, SQL/network/rendering or whole-app gains. Benchmarks and raw profiles remain local-only and are not committed.
Tests were expanded before production edits: 156 focused helper/reducer/stream-resume tests pass before and after, plus 4 selected server rollback/fork/context cases. vp run check:changed passes; a fresh batch of three independent Codex reviews is clean. The PR contains only the helper and its prewritten tests.
Related correctness PR #23420 changes queued-input visibility in this same helper. This PR preserves current main's behavior and does not include that fix. If #23420 lands first, preserve its queued predicate and include queued status in this sparse index during integration. #25374 and #27425 optimize independent lookup/publication paths.
TLDR#
https://github.com/user-attachments/assets/3c74c03f-8223-4b83-958f-1ee8ac1e9cc3
Built with GPT-6.1 Sol in the Codex harness through T3 Code.
- 1
github-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:unvouched
github-actions[bot](GitHub profile, opens in a new tab) added labelssize:S
macroscopeapp[bot](GitHub profile, opens in a new tab) approved these changes
Approvability#
Verdict: Approved at
9a348c8Macroscope's review found this PR approvable — This optimizes shared transcript-visibility indexing while preserving the existing rollback, cancellation, and superseded-interrupt rules. Its effects are limited to reducing local computation, with no new product defaults or persistent-data operations.
You can add or adjust custom eligibility rules. [Learn more](https://docs.macroscope.com/approvability#example-custom-eligibility-rules).No actionable comments were generated in the recent review.
Recent review info-
Run configuration-
- Source mode: Auto
- Repository: pingdotgg/t3code
- Branch: main
- File: .coderabbit.config.ts
- Commit: fa31b66
- Layers: Repository TS config
- Review profile: CHILL
- Plan: Advanced
- Run ID:
0fb94a99-c8a0-4c11-9da6-0635b3d0914d
Commits-
Reviewing files that changed from the base of the PR and between fa31b66bbb2ae5234205a8628a78e038d917202f and 9a348c82c66186eae99e7cfa9dabaaa0474e646d.
Files selected for processing: 2-
packages/shared/src/orchestrationV2Timeline.test.tspackages/shared/src/orchestrationV2Timeline.ts
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.
-
Walkthrough
-
The timeline visibility predicate now tracks cancelled and rolled-back run statuses and collects interruption-request run IDs only when superseded roots exist. Tests cover status precedence, transcript filtering, superseded-root matching, missing history, and input immutability.
Changes: Timeline visibility
Layer / File(s) Summary Run status and superseded-root handling
packages/shared/src/orchestrationV2Timeline.tsThe predicate retains only cancelled or rolled-back statuses, returns an always-visible predicate when no relevant statuses or superseded roots exist, and gathers interruption-request run IDs only when superseded roots exist. Visibility filtering tests
packages/shared/src/orchestrationV2Timeline.test.tsTests cover status precedence, transcript-row visibility, superseded-root and request matching, missing history, frozen inputs, and unchanged item identity. Estimated code review effort: 2 (Simple) | ~12 minutes
Change: Refactor
Suggested reviewers:
maria-rcks,juliusmarminge
Merge Risk:
Minimal · up to9a348-
The change optimizes visibility indexing while retaining the existing filtering rules. No merge-blocking risk is established.
Pre-merge checks:
4-
Check name Status Explanation Title check The title is concise, specific, and accurately identifies the performance change to shared visibility processing. Description check The description clearly explains the problem, implementation, scope, benchmark results, tests, limitations, and integration considerations. It uses a “Solution” heading instead of “Change” and does no… Linked Issues check Check skipped because no linked issues were found for this pull request. Out of Scope Changes check Check skipped because no linked issues were found for this pull request. Full details: Description check
-
Explanation
The description clearly explains the problem, implementation, scope, benchmark results, tests, limitations, and integration considerations. It uses a “Solution” heading instead of “Change” and does not provide explicit maintainer approval evidence, but it is otherwise mostly complete and relevant.
-
Finishing Touches
-
Generate unit tests (beta)
-
- Create a new PR
-
- Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
-
Action not completed
-
Already reviewed the last commit. Use
@coderabbitai full reviewto rerun a review of the entire changeset.Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.
-
@maria-rcks could you review the sparse visibility index, especially duplicate-ID last-wins behavior, cancellation and superseded-interrupt filtering? Head
9a348c82c66186eae99e7cfa9dabaaa0474e646dhas green runnable CI, a clean CodeRabbit review and more than 15 minutes without a new real finding. The PR contains only the helper and its prewritten tests—no local benchmarks.Integration note: #23420 changes queued-input correctness in this same helper. If it lands first, retain its queued predicate and include queued status in the sparse index. #25374 optimizes separate entity lookups; this change targets visibility-index construction.
Note
Written by
gpt-6.1-solon behalf of MariaVerified in a real dev environment#
Verified exact head
9a348c82c66186eae99e7cfa9dabaaa0474e646don Linux using the real Vite/server app, repository Playwright, Google Chrome, and Codexgpt-6.1-solthrough the local provider proxy. No mocks, replay provider, fixtures, or source changes.First ran
github/mainatf6503f0e71in a separate worktree, installed dependencies, and created a local git project through the app. Real Codex turns completed. Runtime Chrome coverage observed eight visibility-factory calls and 46 executions of the original interrupt-request scan callback during status updates. Then stopped main and started the exact PR head with the same task-owned app data. Coverage reached the new all-visible predicate 28 times. These observations establish the changed path executes; they are not an end-to-end speedup measurement.On both versions, ordinary responses remained visible, a queued message removed through the UI stayed absent, and edit-from-here removed the later transcript while preserving the first response. On the PR, also stopped a real terminal turn, observed “Run interrupted · Stopped by user”, resumed to completion, rewound through “Revert and keep changes”, confirmed the prompt returned, and sent a replacement response. Navigation and reload preserved the replacement and did not resurrect cancelled or rolled-back rows.
Blacksmith: 110 focused helper/client reducer tests passed.
vp run check:changed fa31b66bbb2ae5234205a8628a78e038d917202fpassed format, lint, both knip checks, affected typechecks, and selected tests. The initial default comparison lacked history in the snapshot; fetching the PR history and using its explicit base resolved that setup issue. Existing CI reports 30 successful checks.Before, main with matching prompts:

After, PR with matching prompts:

Queue creation and removal during a real Codex turn:

Not verified#
Native iOS/Android and desktop shells, other providers, remote/relay connections, legacy superseded-attempt recovery, and duplicate run IDs were not exercised through a real client here. Defensive helper cases are covered by the focused tests. No whole-app performance or allocation claim is verified by this pass; the PR's reducer benchmark numbers were not independently reproduced through the real app.
maria-rcks merged this0a86e15
maria-rcks closed this
Sign in to join this conversation.
@coderabbitai review