Skip to content

fix(client): flag files edited after being marked viewed in the same comparison - #468

Open
cvmocanu wants to merge 1 commit into
yoshiko-pg:mainfrom
dbschema-pro:fix/changed-since-viewed-same-comparison
Open

cvmocanu wants to merge 1 commit into
yoshiko-pg:mainfrom
dbschema-pro:fix/changed-since-viewed-same-comparison

Conversation

@cvmocanu

@cvmocanu cvmocanu commented Sep 4, 2026

Copy link
Copy Markdown

Mark a file viewed, edit it, open difit again at the same HEAD: the file is still
Viewed, still collapsed, and carries no changed indicator, so the edit is hidden. This is
the ordinary review-edit-look-again loop, where the storage key
${repositoryId}:${diffSelectionKey}:${currentCommitHash} does not change.

Records loaded from that key went into the viewed set by path, with their
diffContentHash never compared against the file's current hash. The
"changed since you viewed" loop then skipped every path loaded from storage
(if (knownPaths.has(file.path)) continue), so the indicator only ever fired for files
hydrated from the cross-comparison hash index.

useViewedFiles now hashes the displayed files before building knownPaths, drops the
records whose file no longer hashes to the recorded value, and seeds
changedSinceViewedFiles from those paths as well as from the index.

Such a file becomes un-viewed and flagged, rather than viewed and flagged, because the
Updated badge is hidden while a file is marked viewed — leaving it viewed would keep the
new content behind a collapsed entry, which is the bug. Nothing is discarded: the per-repo
hash index keeps the (path, old hash) entry, so reverting the edit re-hydrates the viewed
state, and a record for a path absent from the diff is left untouched.

Test: useViewedFiles.test.ts, describe('changed since viewed within one comparison'),
two cases — a stored record whose hash no longer matches is flagged and un-viewed, and one
whose hash still matches stays viewed and unflagged. The first fails before the change.

…comparison

A file marked viewed and then edited kept its viewed state on the next run,
with no indicator, because the stored record's hash was never compared with
the file's current hash. The "changed since you viewed" check ran only
against the cross-comparison hash index, and skipped every path loaded from
storage. Such a file now becomes un-viewed and flagged, so its diff is
expanded again; the per-repo hash index is left intact, so reverting the edit
restores the viewed state.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@cvmocanu

Copy link
Copy Markdown
Author

Hi @yoshiko-pg, do you think this PR is ok? difit works pretty badly currently between branches of the same project.

This branch has not been deployed

No deployments
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.

1 participant