Fix editable file focus and live syntax highlighting - #3979
Conversation
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Plus 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 |
ApprovabilityVerdict: Needs human review An unresolved review comment identifies a potential bug where externally-refreshed file contents may render with stale line caches due to the new cacheKey stability approach. This substantive concern warrants human review before merging. You can customize Macroscope's approvability policy. Learn more. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 48adb40d64
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| name: relativePath, | ||
| contents, | ||
| cacheKey: projectFileCacheKey(cwd, relativePath, contents), | ||
| cacheKey: projectFileEditorCacheKey(cwd, relativePath), |
There was a problem hiding this comment.
Keep the file cache key tied to contents
For externally refreshed contents of the same path (for example an agent edits the file on disk and the readFile query updates while this pane stays mounted), this stable cacheKey violates @pierre/diffs' file contract: its renderer caches split lines by file.cacheKey and expects the key to change when contents changes. Local editor keystrokes are covered by the patched editor path, but non-editor updates will reuse the old line cache, so inserted/deleted lines can be omitted or render with stale line counts until the component remounts. Please keep the render cacheKey content-specific and use a separate stable key for persisted editor state.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using high effort and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit fd5a135. Configure here.
- Persist editor state with stable file cache keys - Preserve annotation identity during unchanged edits - Upgrade the Pierre diffs patch
37d4a57 to
aa442f3
Compare
## What's Changed * fix(server): detect repositories after initialization by @StiensWout in pingdotgg/t3code#4848 * perf(server): merge separate staged/unstaged numstat calls into single diff HEAD --numstat by @UtkarshUsername in pingdotgg/t3code#4843 * fix(git): disable external diff for review diff previews by @ohbentos in pingdotgg/t3code#4854 * Fix editable file focus and live syntax highlighting by @jakeleventhal in pingdotgg/t3code#3979 * fix(web): remember the rendered-markdown choice across threads by @Sy-D in pingdotgg/t3code#4853 ## New Contributors * @ohbentos made their first contribution in pingdotgg/t3code#4854 * @Sy-D made their first contribution in pingdotgg/t3code#4853 **Full Changelog**: pingdotgg/t3code@v0.0.31-nightly.20260729.946...v0.0.31-nightly.20260729.948 Upstream release: https://github.com/pingdotgg/t3code/releases/tag/v0.0.31-nightly.20260729.948
## What's Changed * Fix Connect sign-in settings label by @juliusmarminge in pingdotgg/t3code#4806 * fix(desktop): restore T3 Connect sign-in by @PixPMusic in pingdotgg/t3code#4809 * Simplify files panel header by @juliusmarminge in pingdotgg/t3code#4828 * build(desktop): reduce installed app size by ~300MB by @wukko in pingdotgg/t3code#4824 * Update model version from claude-opus-4-8 to claude-opus-5 by @juliusmarminge in pingdotgg/t3code#4832 * Preserve the thread shell while detail loads by @juliusmarminge in pingdotgg/t3code#4830 * Reduce idle work and disk churn with native resource diagnostics by @juliusmarminge in pingdotgg/t3code#2679 * fix(server): detect repositories after initialization by @StiensWout in pingdotgg/t3code#4848 * perf(server): merge separate staged/unstaged numstat calls into single diff HEAD --numstat by @UtkarshUsername in pingdotgg/t3code#4843 * fix(git): disable external diff for review diff previews by @ohbentos in pingdotgg/t3code#4854 * Fix editable file focus and live syntax highlighting by @jakeleventhal in pingdotgg/t3code#3979 * fix(web): remember the rendered-markdown choice across threads by @Sy-D in pingdotgg/t3code#4853 ## New Contributors * @wukko made their first contribution in pingdotgg/t3code#4824 * @ohbentos made their first contribution in pingdotgg/t3code#4854 * @Sy-D made their first contribution in pingdotgg/t3code#4853 **Full Changelog**: pingdotgg/t3code@v0.0.30...v0.0.31 ## What's Changed * Fix Connect sign-in settings label by @juliusmarminge in pingdotgg/t3code#4806 * fix(desktop): restore T3 Connect sign-in by @PixPMusic in pingdotgg/t3code#4809 * Simplify files panel header by @juliusmarminge in pingdotgg/t3code#4828 * build(desktop): reduce installed app size by ~300MB by @wukko in pingdotgg/t3code#4824 * Update model version from claude-opus-4-8 to claude-opus-5 by @juliusmarminge in pingdotgg/t3code#4832 * Preserve the thread shell while detail loads by @juliusmarminge in pingdotgg/t3code#4830 * Reduce idle work and disk churn with native resource diagnostics by @juliusmarminge in pingdotgg/t3code#2679 * fix(server): detect repositories after initialization by @StiensWout in pingdotgg/t3code#4848 * perf(server): merge separate staged/unstaged numstat calls into single diff HEAD --numstat by @UtkarshUsername in pingdotgg/t3code#4843 * fix(git): disable external diff for review diff previews by @ohbentos in pingdotgg/t3code#4854 * Fix editable file focus and live syntax highlighting by @jakeleventhal in pingdotgg/t3code#3979 * fix(web): remember the rendered-markdown choice across threads by @Sy-D in pingdotgg/t3code#4853 ## New Contributors * @wukko made their first contribution in pingdotgg/t3code#4824 * @ohbentos made their first contribution in pingdotgg/t3code#4854 * @Sy-D made their first contribution in pingdotgg/t3code#4853 **Full Changelog**: pingdotgg/t3code@v0.0.30...v0.0.31 Upstream release: https://github.com/pingdotgg/t3code/releases/tag/v0.0.31

Summary
@pierre/diffsfrom1.3.0-beta.5to1.3.0-beta.10, consume persisted editor state caching from [diffs/edit] Add persisted editor state caching pierrecomputer/pierre#976 directly, and reduce the local patch to T3-specific compatibility fixes+action through controlled selection so it reliably opens a review commentRoot cause
The editable file cache key included the current contents, so every keystroke changed the file identity seen by Pierre and fed the controlled render path back into the active editor. That caused focus loss, hover/text flicker, and comment regressions.
The diff panel also enabled Pierre’s gutter utility without wiring its click callback into the controlled selection state. That left the visible
+action dependent on pointer-event fallthrough, so physical clicks could do nothing even though line selection and file-panel comments worked. The diff panel now mirrors the file panel’s explicit gutter-selection path.After upgrading Pierre, live retokenization also emitted theme CSS variables that this compiled editor combination did not mount a consumer rule for. Initial file renders were colored, but edited tokens appeared unhighlighted until the file was reopened.
beta.10includes both persisted-state support and direct active-theme token colors, so the remaining local patch is limited to T3's interaction-option, controlled-selection, immediate-content-sync, and package-export compatibility.User impact
Typing in the editable file pane now retains keyboard focus without the line-hover or text flicker. Review comments continue to work, and syntax highlighting reacts to edits without switching files.
Validation
pnpm exec vp check(0 errors; 9 pre-existing warnings)pnpm exec vp run typecheckpnpm exec vp test run apps/web/src/reviewCommentContext.test.ts apps/web/src/components/files/FilePreviewPanel.test.ts(15 tests)pnpm install --frozen-lockfile+comment creationNote
Fix editable file focus and live syntax highlighting in FilePreviewPanel
EditorProviderwithEditProviderand addspersistState: true(in-memory) to the editor constructor in FilePreviewPanel.tsx so editor state survives re-renders.projectFileEditorCacheKeyin fileContentRevision.ts: returns a stable cache key when the editor's local contents match the current file, and rotates the key on external edits or environment changes.@pierre/diffspatch (bumped to1.3.0-beta.10) so the editor no longer forcibly disables gutter utilities, line selection, or hover highlighting, and keepsfile.contentsin sync with the text buffer during render updates.enableLineSelectionis true, and programmatic selection updates are suppressed whencontrolledSelectionis true.Macroscope summarized aa442f3.
Note
Medium Risk
Touches the core file-editing UX and a patched third-party editor dependency; regressions could affect focus, syntax highlighting, gutter comments, or selection behavior across editable files.
Overview
Upgrades
@pierre/diffsto 1.3.0-beta.10 and narrows the local patch so Pierre can keep gutter line selection, controlled selection, and in-place content sync while still using live token retokenization.The editable file surface now uses
EditProvider, enables in-memory persisted editor state, and feeds theFilecomponent aprojectFileEditorCacheKeythat stays stable across local keystrokes but rotates when contents change externally or the environment changes. That stops the editor from being treated as a new file on every edit, which was driving focus loss, flicker, and comment regressions.Adds unit tests for
projectFileEditorCacheKeyidentity rules. Lockfile and workspace catalog entries move to the new package version and patched hash.Reviewed by Cursor Bugbot for commit aa442f3. Bugbot is set up for automated code reviews on this repo. Configure here.