Skip to content

fix(tui): invalidate preview data after same-path file changes (#2118) - #2578

Closed
turkonthelurk wants to merge 4 commits into
tetsuo-ai:mainfrom
turkonthelurk:cursor/preview-same-path-invalidation-97e5
Closed

turkonthelurk wants to merge 4 commits into
tetsuo-ai:mainfrom
turkonthelurk:cursor/preview-same-path-invalidation-97e5

Conversation

@turkonthelurk

Copy link
Copy Markdown
Contributor

Closes #2118

Draft for review only. Not to be merged by automation; a maintainer decides when and whether it lands. Opened from fork turkonthelurk/agenc-core. Nothing pushed to main on either repo. Based on upstream main only. Independent of #2116 and draft #2576. Does not add startLine to highlight deps.

Problem

The preview surface only reread a file when its path or line window changed. Same-path edits (agent completion or another process) could keep showing stale content and diagnostics. PR #2020 covered path A→B→A; it does not invalidate when the selected path stays unchanged.

Verified still present on upstream main at 6a2a92d before changing anything.

Change

Two independent invalidation signals on the existing generation-fenced read effect:

  • Task epoch — stable key of tasks that may reference the selected path (id:status:endTime). Completing or starting such a task triggers one fresh read; unrelated task chatter does not.
  • File revision — per-path generation from fs.watch, a disk mtime/size/inode re-stat after project-tree snapshot updates, or notifyPreviewFileChanged. First stat does not notify, so mount does not double-read.

Late earlier reads still lose to a newer generation (A→B→A protection intact). Highlight deps stay [activePath, content].

Tests

Hermetic Vitest, fail-before / pass-after for the same-path cases: 7 files / 30 passed.

Coverage: same-path revision refreshes content + diagnostics; referencing task completion triggers one reread; unrelated tasks do not; late same-path reads stay fenced; A→B→A protection holds.

This does not merge.

Opened from fork turkonthelurk/agenc-core. Companion fork PR (to close): turkonthelurk#20

Reread the selected preview when a referencing task completes or the
file revision changes, while keeping generation fences so a late earlier
read cannot replace a newer result.

Co-authored-by: turk <turkonthelurk@users.noreply.github.com>
cursoragent and others added 3 commits September 18, 2026 10:25
Share one task fixture and a single preview mount so Sonar new-code
duplication drops without changing invalidation coverage or semantics.

Co-authored-by: turk <turkonthelurk@users.noreply.github.com>
Sonar typescript:S2871 marked the default Array.sort as a new-code
reliability bug. Use the same localeCompare ordering the workbench
already uses elsewhere.

Co-authored-by: turk <turkonthelurk@users.noreply.github.com>
Sonar typescript:S2871 still flagged the inline localeCompare comparator
as a new-code reliability bug. Use the shared UTF-16 code-unit helper
that already satisfies S2871 elsewhere for stable keys.

Co-authored-by: turk <turkonthelurk@users.noreply.github.com>
@sonarqubecloud

Copy link
Copy Markdown

@turkonthelurk
turkonthelurk marked this pull request as ready for review September 18, 2026 10:48

Copy link
Copy Markdown
Contributor Author

Closing as obsolete. Target surface was removed in #2618; see #2624. No merge.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(tui): invalidate preview data after same-path file changes

2 participants