Skip to content

Fix editable file focus and live syntax highlighting - #3979

Merged
juliusmarminge merged 1 commit into
pingdotgg:mainfrom
jakeleventhal:t3code/fix-diff-pane-keyboard-focus
Jul 29, 2026
Merged

Fix editable file focus and live syntax highlighting#3979
juliusmarminge merged 1 commit into
pingdotgg:mainfrom
jakeleventhal:t3code/fix-diff-pane-keyboard-focus

Conversation

@jakeleventhal

@jakeleventhal jakeleventhal commented Jul 14, 2026

Copy link
Copy Markdown
Contributor

Summary

  • upgrade @pierre/diffs from 1.3.0-beta.5 to 1.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
  • route the diff gutter + action through controlled selection so it reliably opens a review comment
  • keep editable-file editor state and cache identity stable while file contents change
  • preserve comment annotation identity so comment UI updates do not force redundant editor renders
  • keep Pierre's internal file contents synchronized after local edits and avoid controlled-selection feedback
  • apply resolved token colors during in-place retokenization so syntax highlighting updates immediately

Root 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.10 includes 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 typecheck
  • pnpm exec vp test run apps/web/src/reviewCommentContext.test.ts apps/web/src/components/files/FilePreviewPanel.test.ts (15 tests)
  • pnpm install --frozen-lockfile
  • manual browser verification of focus retention, stable line DOM, live token-classification changes, and direct diff-gutter + comment creation

Note

Fix editable file focus and live syntax highlighting in FilePreviewPanel

  • Replaces EditorProvider with EditProvider and adds persistState: true (in-memory) to the editor constructor in FilePreviewPanel.tsx so editor state survives re-renders.
  • Adds projectFileEditorCacheKey in 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.
  • Updates the @pierre/diffs patch (bumped to 1.3.0-beta.10) so the editor no longer forcibly disables gutter utilities, line selection, or hover highlighting, and keeps file.contents in sync with the text buffer during render updates.
  • Behavioral Change: gutter pointerdown is now ignored when enableLineSelection is true, and programmatic selection updates are suppressed when controlledSelection is 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/diffs to 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 the File component a projectFileEditorCacheKey that 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 projectFileEditorCacheKey identity 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.

@coderabbitai

coderabbitai Bot commented Jul 14, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on this repository. 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 Plus

Run ID: a9075ed2-d325-426b-8c18-fe07077b4262

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

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.

@github-actions github-actions Bot added vouch:unvouched PR author is not yet trusted in the VOUCHED list. size:XXL 1,000+ changed lines (additions + deletions). labels Jul 14, 2026
@github-actions github-actions Bot added size:L 100-499 changed lines (additions + deletions). and removed size:XXL 1,000+ changed lines (additions + deletions). labels Jul 16, 2026
@jakeleventhal
jakeleventhal marked this pull request as ready for review July 16, 2026 02:51
Comment thread apps/web/src/components/files/fileCommentAnnotations.ts Outdated
Comment thread apps/web/src/components/files/fileContentRevision.ts
@macroscopeapp

macroscopeapp Bot commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

Approvability

Verdict: 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.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 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),

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge 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 👍 / 👎.

@cursor cursor Bot left a comment

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.

Cursor Bugbot has reviewed your changes using high effort and found 1 potential issue.

Fix All in Cursor

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

Comment thread apps/web/src/components/files/FilePreviewPanel.tsx Outdated
- Persist editor state with stable file cache keys
- Preserve annotation identity during unchanged edits
- Upgrade the Pierre diffs patch
@jakeleventhal
jakeleventhal force-pushed the t3code/fix-diff-pane-keyboard-focus branch from 37d4a57 to aa442f3 Compare July 29, 2026 16:53
@juliusmarminge
juliusmarminge merged commit fc28abf into pingdotgg:main Jul 29, 2026
16 of 17 checks passed
ohbentos pushed a commit to ohbentos/t3code that referenced this pull request Jul 29, 2026
github-actions Bot added a commit to omarcresp/t3code-flake that referenced this pull request Jul 29, 2026
## 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
github-actions Bot added a commit to omarcresp/t3code-flake that referenced this pull request Jul 29, 2026
## 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
tarik02 added a commit to tarik02-org/t3code that referenced this pull request Jul 30, 2026
* fix(desktop): restore T3 Connect sign-in (pingdotgg#4809)

Co-authored-by: Julius Marminge <julius0216@outlook.com>
Co-authored-by: Claude Fable 5 <noreply@anthropic.com>

* Simplify files panel header (pingdotgg#4828)

* build(desktop): reduce installed app size by ~300MB (pingdotgg#4824)

* Update model version from claude-opus-4-8 to claude-opus-5 (pingdotgg#4832)

* Preserve the thread shell while detail loads (pingdotgg#4830)

* Reduce idle work and disk churn with native resource diagnostics (pingdotgg#2679)

Co-authored-by: codex <codex@users.noreply.github.com>

* fix(server): detect repositories after initialization (pingdotgg#4848)

* perf(server): merge separate staged/unstaged numstat calls into single diff HEAD --numstat (pingdotgg#4843)

* fix(git): disable external diff for review diff previews (pingdotgg#4854)

* Fix editable file focus and live syntax highlighting (pingdotgg#3979)

* fix(web): remember the rendered-markdown choice across threads (pingdotgg#4853)

Co-authored-by: Simon Doba <simon.doba@orbit.de>
Co-authored-by: Claude Opus 5 <noreply@anthropic.com>

* chore(release): prepare v0.0.31

* fix(mobile): reduce thread feed scroll jank (pingdotgg#4874)

* fix(web): restore sidebar v2 thread actions and terminal icon (pingdotgg#4712)

* fix(web): settle button now works on hover, not just right-click (pingdotgg#4905)

Co-authored-by: Claude Fable 5 <noreply@anthropic.com>

* fix(clients): disable add project while disconnected (pingdotgg#4834)

* fix(composer): hide default Codex service tier (pingdotgg#4784)

* docs: link iOS and Android app store downloads (pingdotgg#4902)

Co-authored-by: Claude Fable 5 <noreply@anthropic.com>

* fix(web): align remote server update action (pingdotgg#4731)

* fix(connect): suggest a serve command that matches how you ran connect (pingdotgg#4897)

Co-authored-by: Claude Fable 5 <noreply@anthropic.com>

* fix(mobile): stop shared content errors in Personal Team builds (pingdotgg#4943)

* perf(mobile): sends respond instantly, thread opens stop freezing (pingdotgg#4882)

Co-authored-by: Claude Fable 5 <noreply@anthropic.com>

* fix(web): show Codex fast mode as a bolt (pingdotgg#4947)

* docs: seed worktrees with a copy of real userdata instead of banning it (pingdotgg#4949)

Co-authored-by: Claude Fable 5 <noreply@anthropic.com>

* fix(mobile): support dragged images in the composer (pingdotgg#4953)

* fix(mobile): stop long iOS threads from jumping while scrolling up (pingdotgg#4867)

Co-authored-by: Claude Fable 5 <noreply@anthropic.com>

* fix(web): keep worktree default when switching a draft's machine (pingdotgg#4964)

Co-authored-by: Claude Fable 5 <noreply@anthropic.com>

* perf(mobile): reconnect environments immediately on resume (pingdotgg#4878)

* feat(web): pasting a huge screenshot now compresses it instead of erroring (pingdotgg#4967)

Co-authored-by: Claude Fable 5 <noreply@anthropic.com>

* feat(web): regenerate thread titles from sidebar (pingdotgg#4810)

* fix(web): show server update progress through reconnect (pingdotgg#4903)

---------

Co-authored-by: Alex <me@pixp.cc>
Co-authored-by: Julius Marminge <julius0216@outlook.com>
Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
Co-authored-by: wukko <me@wukko.me>
Co-authored-by: codex <codex@users.noreply.github.com>
Co-authored-by: Wout Stiens <71498452+StiensWout@users.noreply.github.com>
Co-authored-by: Utkarsh Patil <73941998+UtkarshUsername@users.noreply.github.com>
Co-authored-by: ohbentos <72638975+ohbentos@users.noreply.github.com>
Co-authored-by: Jake Leventhal <jakeleventhal@me.com>
Co-authored-by: Simon Doba <simon.doba@hotmail.de>
Co-authored-by: Simon Doba <simon.doba@orbit.de>
Co-authored-by: t3-code[bot] <269035359+t3-code[bot]@users.noreply.github.com>
Co-authored-by: Gabriel De Andrade <30420087+gabrielelpidio@users.noreply.github.com>
Co-authored-by: Jono Kemball <Noojuno@users.noreply.github.com>
Co-authored-by: Theo Browne <me@t3.gg>
Co-authored-by: Max Katz <me@maxkatz.me>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:L 100-499 changed lines (additions + deletions). vouch:unvouched PR author is not yet trusted in the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants