Skip to content

fix(ai-vault): re-read a transcript rewritten to its previous size - #20261

Merged
Jinwoo-H merged 1 commit into
mainfrom
session-search-reader-same-size
Sep 13, 2026
Merged

Jinwoo-H merged 1 commit into
mainfrom
session-search-reader-same-size

Conversation

@Jinwoo-H

@Jinwoo-H Jinwoo-H commented Sep 12, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 1 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​35 $\color{#cf222e}{\Huge{\mathbf{−}}}$​1 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​34
Prod 2 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​12 $\color{#cf222e}{\Huge{\mathbf{−}}}$​1 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​11

ELI5

If a transcript is replaced with different text of exactly the same length, Orca now reads the new text instead of keeping the old sidebar preview and search content.

What Changed

Record the observed mtime and file size in the in-memory resume point. Resume only when mtime has not moved backward and the existing size/newline checks pass; a changed mtime also requires growth beyond the previously observed size. Recording file size separately from the consumed offset covers unfinished final lines.

Why

A same-size rewrite can leave the old cursor at EOF immediately after a newline. The old guard accepted that cursor and published an empty append. Checking only mtime >= previous mtime would still accept a newer same-size rewrite, so growth is required when mtime changes. Normal appends retain incremental parsing.

Linked Issue

N/A: standalone fix requested in the supplied reader bug brief; no issue number supplied.

Visual Proof

N/A: reader logic

Testing

  • I manually tested these changes locally
  • Automated tests added/updated, or explained why not below

On macOS, using only temporary synthetic transcripts and ORCA_BACKGROUND_LAUNCH=1:

  • Before the fix, both new same-size regression cases failed: expected replace, received append.
  • After the fix, same-size rewrite and truncate-then-regrow start at byte zero, publish the replacement text, and match a fresh sidebar parse.
  • The existing append test now explicitly advances mtime and still verifies resuming at the previous byte offset.
  • pnpm tc
  • pnpm test src/main/ai-vault
  • pnpm run check:code-quality:changed
  • pnpm run check:react-doctor:changed

AI Disclosure

Review

Self-reviewed the resume guard, cache producer, native/WSL stat discovery, and separate SSH parse cache.

Agent skill upstream boundary

  • Not applicable, or this change follows docs/reference/agent-skill-sharing-upstream-boundary.md and copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.

Notes

Native and WSL reader candidates already require mtime; no missing-mtime fallback is needed. SSH uses a separate mtime/size cache and reparses changed transcripts. Resume points are in-memory only, so there is no persisted or remote wire format change. Folder workspaces and git worktrees use the same reader.

As before, a rewrite preserving both mtime and size cannot be detected by these stats, and a growing rewrite retaining the old newline boundary can resemble an append. Linux, Windows, WSL, and SSH were not exercised live.

Checklist

  • This PR is small and focused
  • I explained what changed and why (including ELI5)
  • Before/after screenshots or videos attached for UI changes, or N/A with reason
  • Self-reviewed for correctness, security, and performance
  • Cross-platform, SSH/remote, and path/shortcut impact considered (or N/A)
  • pnpm lint, pnpm typecheck, pnpm test, and pnpm build pass (or CI will cover; local preferred)

Local checks are the four scoped gates above; CI covers full lint, the remaining tests, and build.

@coderabbitai

coderabbitai Bot commented Sep 12, 2026

Copy link
Copy Markdown
Contributor

Review Change StackReview Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Advanced

Run ID: 5b315165-5e70-40b8-bfad-bf470aadd213

📥 Commits

Reviewing files that changed from the base of the PR and between fa3d29f and 84e5c0d.

📒 Files selected for processing (3)
  • src/main/ai-vault/session-parse-cache-store.ts
  • src/main/ai-vault/session-transcript-consumers.test.ts
  • src/main/ai-vault/session-transcript-reader.ts

Included review availability: Your plan provides up to 10 included reviews per hour; 5 remain after this review.


📝 Walkthrough

Walkthrough

The change adds mtimeMs and sizeBytes to transcript resume state. Resume validation now rejects rewrites when the timestamp changes without sufficient file growth. Tests cover timestamp updates, direct same-size rewrites, and truncate-then-regrow rewrites. Rejected resumes trigger a replacement read from byte offset zero.

Priority: ⬇️ Low

Merge Risk: ⚪ Minimal · up to 84e5c

Transcript rewrites are reread from the beginning, while normal append parsing remains incremental. No actionable merge-blocking risk remains.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description is mostly complete and explains the fix, rationale, tests, scope, and checklist status. However, the required Linked Issue section contains N/A, while the template requires an issue li… Add a valid linked issue reference in the Linked Issue section, such as Fixes #123``. If no issue exists, create one before merging and link it here.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the primary change: rereading transcripts rewritten to their previous size.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 1 functions across 3 files.
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: Description check

Explanation

The description is mostly complete and explains the fix, rationale, tests, scope, and checklist status. However, the required Linked Issue section contains N/A, while the template requires an issue link.

  • Fix all pre-merge checks with AI
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch

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.

@pullfrog pullfrog 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.

✅ No new issues found.

Reviewed changes

  • Same-size rewrite detection — readResumableTranscript records the observed mtimeMs and full file sizeBytes on the in-memory resume point and declines to resume when the timestamp moved but the file did not grow past its previously observed size, forcing a whole-file replace.
  • Separate size from consumed offset — storing full file size alongside byteOffset is what keeps the guard correct when the prior read ended on a trailing partial line (byteOffset < sizeBytes); comparing to byteOffset alone would misread the rewrite as growth.
  • Regression coverage — a parameterized rewrite / truncate then regrow test asserts a same-size rewrite re-reads from zero and publishes the replacement text, and the existing append test now advances mtime explicitly.

I verified the new test is not theatre: reverting only the guard makes both cases fail with expected 'append' to be 'replace', and the full src/main/ai-vault suite (122 files, 1056 tests) plus check:code-quality:changed pass. The remote/SSH cache is unaffected — its reuse already requires mtimeMs equality and size equality, so it reparses on any mtime change.

Pullfrog  | View workflow run | Using openrouter/deepseek/deepseek-v4.1-flash (free via Pullfrog for OSS) | 𝕏

@Jinwoo-H
Jinwoo-H merged commit a1d135e into main Sep 13, 2026
29 checks passed
@Jinwoo-H
Jinwoo-H deleted the session-search-reader-same-size branch September 13, 2026 18:08
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