Skip to content

fix(client-runtime): file previews refresh when a background command finishes late - #49458

Merged
juliusmarminge merged 3 commits into
pingdotgg:mainfrom
StiensWout:wf/find-5955836e4fcef0022493631f
Dec 5, 2026
Merged

juliusmarminge merged 3 commits into
pingdotgg:mainfrom
StiensWout:wf/find-5955836e4fcef0022493631f

Conversation

@StiensWout

Copy link
Copy Markdown
Contributor

File previews and host images refresh based on a workspace mutation id. That id only looked at the latest settled tool in the timeline, so when a background command finished after a later command had already completed, the id stayed the same and open previews kept showing old contents. The id now also counts tools that are still running before the latest settled one, so it changes when such a tool finishes. In the common case the value is unchanged, so this adds no extra refreshes.

Related: #49073, #21564

Reproduction on main

Commit c0eed7328d (main). The preview keeps showing the earlier contents until another workspace refresh or a manual refresh. Expected: The open preview refreshes to show the file written by the finished background command.

  1. Open a thread with a text file in its file preview.
  2. Ask the agent to start a background command that waits before rewriting that file.
  3. Ask the agent to run a second, short command while the background command is still waiting.
  4. Keep the preview open after the agent replies and let the background command rewrite the file and finish.

The cause is at packages/client-runtime/src/state/threadDetail.ts:77: deriveWorkspaceMutationId stops at the last settled tool in timeline order. Completing an earlier background command leaves both that tool id and the checkpoint timestamp unchanged, so readers do not invalidate their cached file contents or image URLs.. Ran cd packages/client-runtime && pnpm exec vp test run src/state/threadDetail.test.ts with the repro test added: it failed in 2 of 2 runs on a clean checkout, with expected '["check",null]' not to be '["check",null]' in the output.

Evidence

Environment: Linux x64, the repository's own tests.

Proven: the repro fails at the test commit b372eb3dc0 and passes on the head 5d110455ff, both on main 8b306d5d8f.

Before After
Commit b372eb3dc0 5d110455ff
Result failed with "expected '["check",null]' not to be '["check",null]'" passed

Not shown: the bug in the running web app.

Tests

  • b372eb3dc0 adds the failing test, alone, before the fix.
  • pnpm exec vp run check:changed 8b306d5d8fa44f4e038671fbbf729e65da3f750f passed on head.

Not in this change

  • A tool that starts running later in the timeline still does not change the id until it settles; that path already works because it becomes the latest settled tool.

Who did the work

  • Repro written by GPT 6.1 Sol, in Codex
  • Duplicate check judged by Gemini 4 Neon, in Antigravity
  • Written by Claude Opus 5.5, in Claude Code
  • Reviewed by Gemini 4 Neon, in Antigravity, and by GPT 6.1 Sol, in Codex
  • Reproduction, checks and proof run by a program on base and head, not by an agent

Made in T3 Code by Gemini 4 Neon, GPT 6.1 Sol and Claude Opus 5.5

StiensWout and others added 2 commits December 5, 2026 15:51
…hes out of order

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
…finishes late

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions github-actions Bot added vouch:trusted Author is trusted by repo permissions or the VOUCHED list. size:S 10-29 changed lines (additions + deletions). labels Dec 5, 2026
macroscopeapp[bot]
macroscopeapp Bot previously approved these changes Dec 5, 2026
@macroscopeapp

macroscopeapp Bot commented Dec 5, 2026 •

Copy link
Copy Markdown
Contributor

Approvability

Verdict: Approved at f0bc2e0

Macroscope's review found this PR approvable — The change refreshes workspace previews and related cached reads when an older background tool finishes after a newer one. Its effects are limited to refresh signaling, with no new workspace writes or product-default changes.

Notes:

  • No code objects were reviewed. Approvability was decided on eligibility alone.

You can add or adjust custom eligibility rules. Learn more.

@coderabbitai

coderabbitai Bot commented Dec 5, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The mutation ID derivation now counts unsettled workspace-mutating items encountered after a settled item. A regression test checks that completing a running command changes the derived ID when another completed command remains present.

Changes: Workspace Mutation ID

Layer / File(s) Summary
Mutation ID derivation and regression coverage
packages/client-runtime/src/state/threadDetail.ts, packages/client-runtime/src/state/threadDetail.test.ts
The scan counts unsettled mutating items after finding a settled item and adds the count to the ID when nonzero. The test checks that completing a running command changes the ID.

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix

Suggested reviewers: juliusmarminge, saphid

Merge Risk: Minimal · up to f0bc2

This change makes file previews refresh when a background command finishes after a later command, and it keeps the ID unchanged in the common case. I found no merge-blocking risk.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title names the fix (file previews refreshing when a background command finishes late) and matches the change, which makes deriveWorkspaceMutationId count still-running tools so the mutation ID ch…
Description check Passed The description follows the template's main sections: Problem (stale previews after a late background command), Change (mutation ID counts still-running tools before the latest settled one), Verificat…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title names the fix (file previews refreshing when a background command finishes late) and matches the change, which makes deriveWorkspaceMutationId count still-running tools so the mutation ID changes when a background command settles. It follows the conventional commit form and is specific, though it omits the mechanism.

Full details: Description check

Explanation

The description follows the template's main sections: Problem (stale previews after a late background command), Change (mutation ID counts still-running tools before the latest settled one), Verification (repro on main, failing test before and passing after, check:changed run), and an agent attribution at the end. The Scope section is weak: it links related issues #49073 and #21564 but does not say whether they show this bug or whether a maintainer requested the PR, and it gives no reason a CI test was kept or why no issue is needed. Verification also states the environment is Linux only and that the running web app was not checked. The model attribution is present in the 'Who did the work' section.

Resolution

Optional improvements: in Scope, state what #49073 and #21564 show and whether they are the bug being fixed, or say that no issue exists and why. In Verification, state whether a permanent test is kept in the change, and note that the running web app was not checked by hand.

Finishing Touches

Generate unit tests (beta)

  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Recent review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between 5d11045 and f0bc2e0.

Files selected for processing: 1

  • packages/client-runtime/src/state/threadDetail.test.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 3 remain after this review.

@juliusmarminge juliusmarminge added the takeover:in-progress A takeover lead is working on this PR label Dec 5, 2026
…e-completion case

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@macroscopeapp
macroscopeapp Bot dismissed their stale review December 5, 2026 15:15

Dismissing prior approval to re-evaluate f0bc2e0

@juliusmarminge

Copy link
Copy Markdown
Member

Evidence

Environment: real web app in Chromium, 1280×800, light theme, fresh isolated database and identical synthetic project on each commit. Real Codex CLI 0.174.0 with gpt-6-luna; no invented provider responses.

On each commit: seed demo with note.txt containing OLD CONTENTS v1; start a real Codex gpt-6-luna thread; open right panel → Files → note.txt; ask Codex to run sleep 45 followed by a printf rewrite to NEW CONTENTS v2 with yield_time_ms=1000, run echo quick-check separately, then reply STARTED without waiting. On completion, the automatic continuation writes a long story without tools. Confirm the disk rewrite, wait five seconds, capture the still-open preview, and assert it contains v2 while the continuation remains active.

Scenario: An open preview refreshes when an earlier background command finishes late

Proven: the scenario fails on base 8b306d5d8f and passes on head f0bc2e0faf.

Before 8b306d5d8f After f0bc2e0faf
Result ❌ failed
ASSERTION_FAILED: expect.poll(...).toContain(...) timed out after 3000 ms
last: expected "OLD CONTENTS v1The background command has not finished." to contain "NEW CONTENTS v2"
✅ passed
preview before command Base 8b306d5d8f: preview before command Head f0bc2e0faf: preview before command
preview after background completion Base 8b306d5d8f: preview after background completion Head f0bc2e0faf: preview after background completion
failure Base 8b306d5d8f: failure
Recording Before recording After recording

Scenario driver

The base preview still showed v1 five seconds after the disk rewrite and remained stale through the additional three-second assertion window. Head showed v2 at the same capture point, while the continuation was still streaming.

Not shown:

  • Desktop and mobile clients, other providers, and completion while the original turn remains active were not exercised; this proves the reported after-reply web reproduction.

@juliusmarminge juliusmarminge added takeover:ready Takeover done; auto-lands when gates pass and removed takeover:in-progress A takeover lead is working on this PR labels Dec 5, 2026
@juliusmarminge
juliusmarminge merged commit 04e8681 into pingdotgg:main Dec 5, 2026
60 checks passed
@juliusmarminge juliusmarminge removed the takeover:ready Takeover done; auto-lands when gates pass label Dec 5, 2026
github-actions Bot added a commit to omarcresp/t3code-flake that referenced this pull request Dec 6, 2026
**v0.1.15-nightly.20261205.5786** · 61 changes from 12 contributors

- **Large file previews.** Load remote files that exceed the automatic preview limit.
- **Project-specific MCP servers.** Import configurations with the same name and command but different credentials or headers.
- **GitHub issue forms.** Use issue templates with numeric or boolean options and empty optional fields.
- **Cursor text generation.** Generate commit messages, branch names, and thread titles with Cursor again.
- **Workflow reasons.** Unsent workflow question reasons now survive an environment reconnect.
- **Shared worktree protection.** Deleting a thread no longer removes a worktree another thread started using during confirmation.

### Plus 53 more bug fixes and performance improvements.

<details>
<summary>Full changelog</summary>

## What's Changed
* fix(server): stopping Codex during startup no longer loses its accepted turn by @StiensWout in pingdotgg/t3code#49435
* fix(workflows): open invoked runs from older workflows by @UtkarshUsername in pingdotgg/t3code#49437
* fix(web): omit inverted line range on empty file reads by @only21mil in pingdotgg/t3code#49452
* perf(server): t3 --version no longer loads the whole CLI by @juliusmarminge in pingdotgg/t3code#49461
* fix(preview): let users load oversized files by @Yash-Singh1 in pingdotgg/t3code#49470
* fix(mobile): a saved draft waits for a project choice when its project is removed by @StiensWout in pingdotgg/t3code#49455
* fix(client-runtime): file previews refresh when a background command finishes late by @StiensWout in pingdotgg/t3code#49458
* fix(server): fixed-time scheduled tasks interrupted before dispatch no longer skip the slot by @taogezhizun in pingdotgg/t3code#49417
* perf(web): reuse the read-only file preview cache key by @UtkarshUsername in pingdotgg/t3code#49464
* fix(shared): thread find no longer matches across line breaks in user HTML by @only21mil in pingdotgg/t3code#49449
* fix(web): ignore Shift and Alt on prompt stash delete shortcut by @only21mil in pingdotgg/t3code#49473
* fix(server): failed updates no longer lose recent data when the database is symlinked by @StiensWout in pingdotgg/t3code#49459
* fix(shared): relative file links with ../ resolve to the normalized path by @juliusmarminge in pingdotgg/t3code#49479
* fix(test): VcsStatusBroadcaster checkout test no longer flakes when HEAD.lock events arrive apart by @t3dotgg in pingdotgg/t3code#49494
* fix(server): fresh-session task waits while its previous occurrence awaits background work by @juliusmarminge in pingdotgg/t3code#49490
* fix(server): finish force stop when the target run settles by @UtkarshUsername in pingdotgg/t3code#49486
* perf(client-runtime): recording a thread open no longer replaces quiet thread shells by @shivamhwp in pingdotgg/t3code#49475
* perf(server): Read saved previews for live workflow lists by @UtkarshUsername in pingdotgg/t3code#49484
* fix(server): commit on new branch waits for a multi-repository worktree thread by @StiensWout in pingdotgg/t3code#49482
* fix(web): only capture keybindings while recording a SnapShot shortcut by @only21mil in pingdotgg/t3code#49489
* fix(web): ignore extra modifiers on workflow editor save shortcut by @only21mil in pingdotgg/t3code#49506
* fix(server): SSH readiness check retries after an interrupted response by @StiensWout in pingdotgg/t3code#49512
* fix(web): importing an MCP server keeps other projects' configurations available by @StiensWout in pingdotgg/t3code#49516
* fix(web): ignore Shift, Alt, and IME composition on spreadsheet copy by @only21mil in pingdotgg/t3code#49520
* fix(web): Word previews handle malformed links and spaced internal parts by @only21mil in pingdotgg/t3code#49519
* fix(shared): byte sizes just under the next unit no longer read "1024 KB" by @dev-dami in pingdotgg/t3code#49524
* fix(server): connecting during a checkout keeps the current Git status by @StiensWout in pingdotgg/t3code#49526
* fix(server): keep content search highlights and whole-word matches accurate on non-UTF-8 lines by @only21mil in pingdotgg/t3code#49535
* fix(web): image annotation shortcuts ignore extra modifiers and work with CapsLock by @only21mil in pingdotgg/t3code#49534
* fix(web): show the linked workflow run in All runs by @UtkarshUsername in pingdotgg/t3code#49543
* fix(provider-core): surface Codex managed requirements rejections for granular approval policies by @vibecodooor in pingdotgg/t3code#49540
* fix(web,mobile): choosing a question option sets an image-only answer aside by @juliusmarminge in pingdotgg/t3code#49517
* fix(server): MCP PR review comments preserve the old path on renamed files by @only21mil in pingdotgg/t3code#49557
* fix(server): creating a missing workflow helper makes its workflow load by @StiensWout in pingdotgg/t3code#49562
* fix(github): accept YAML scalars and empty keys in issue templates by @only21mil in pingdotgg/t3code#49558
* fix(server): a stalled cancellation cleanup no longer holds up other workflows' timeouts by @StiensWout in pingdotgg/t3code#49561
* fix(mobile): Usage cache savings ratio uses the app language's decimal separator by @tiliakoos in pingdotgg/t3code#49560
* fix(server): restarting after a pool place is given back keeps the requested resume by @StiensWout in pingdotgg/t3code#49567
* fix(server): retrying a failed project action save now saves it by @StiensWout in pingdotgg/t3code#49573
* fix(server): client connections no longer start Xwayland on Linux by @juliusmarminge in pingdotgg/t3code#49596
* fix(mobile-nitro): Android draft screen matches React Native's header, font and composer by @juliusmarminge in pingdotgg/t3code#49441
* fix(workflows): an agent step's turn no longer waits on its issue tracker by @Kamo2323 in pingdotgg/t3code#49582
* fix(mobile-nitro): a list shows its new rows at once when all of them are replaced on Android by @juliusmarminge in pingdotgg/t3code#49454
* fix(mobile-nitro): Android text fields are readable in dark mode by @juliusmarminge in pingdotgg/t3code#49466
* fix(web): unsent workflow reasons survive an environment reconnect by @StiensWout in pingdotgg/t3code#49603
* fix(server): service install after uninstall no longer refuses as a downgrade by @juliusmarminge in pingdotgg/t3code#49611
* fix(web): deleting a thread keeps a worktree another thread started using by @StiensWout in pingdotgg/t3code#49599
* fix(web,mobile): voice model benchmarks use the app language's decimal separator by @tiliakoos in pingdotgg/t3code#49581
* fix(cursor): Cursor text generation uses Composer 2.5 instead of the retired Composer 2 by @juliusmarminge in pingdotgg/t3code#49614
* fix(mobile-nitro): iOS text inputs use the app theme's colors by @juliusmarminge in pingdotgg/t3code#49509
* fix(mobile-nitro): Android survives Activity recreation (blank screen, colour scheme crash) by @juliusmarminge in pingdotgg/t3code#49572
* fix(mobile-nitro): a tap on a markdown link opens it, and thread links open their thread by @juliusmarminge in pingdotgg/t3code#49546
* fix(server): device access error says the setting is in desktop or web settings by @juliusmarminge in pingdotgg/t3code#49616
* fix(server): OpenCode commands no longer stay running after a failed status check by @StiensWout in pingdotgg/t3code#49602
* feat(mobile-nitro): user message links, thread chips and mentions match React Native by @juliusmarminge in pingdotgg/t3code#49569
* fix(mobile-nitro): Android markdown draws chips, mentions and quoted links like iOS by @juliusmarminge in pingdotgg/t3code#49590
* fix(mobile): guide file links open hidden test files by @StiensWout in pingdotgg/t3code#49600
* fix(server): workflows retry an engine that did not start after a reload by @StiensWout in pingdotgg/t3code#49563
* fix(mobile-nitro): choosing another project drops the draft's pull request by @StiensWout in pingdotgg/t3code#49597
* fix(mobile): pull request diffs no longer mix revisions after reconnecting by @StiensWout in pingdotgg/t3code#49607

## New Contributors
* @dev-dami made their first contribution in pingdotgg/t3code#49524
* @vibecodooor made their first contribution in pingdotgg/t3code#49540

**Full Changelog**: pingdotgg/t3code@v0.1.14-nightly.20261205.5772...v0.1.15-nightly.20261205.5786

</details>


Upstream release: https://github.com/pingdotgg/t3code/releases/tag/v0.1.15-nightly.20261205.5786
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:S 10-29 changed lines (additions + deletions). vouch:trusted Author is trusted by repo permissions or the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants