Skip to content

fix(ai-vault-search): prevent parent-string retention during indexing - #22545

Merged
OrcaWin merged 1 commit into
mainfrom
OrcaWin/bug-session-scanner-ooms-on-large-codex-transcri
Sep 23, 2026
Merged

OrcaWin merged 1 commit into
mainfrom
OrcaWin/bug-session-scanner-ooms-on-large-codex-transcri

Conversation

@OrcaWin

@OrcaWin OrcaWin commented Sep 23, 2026 •

Copy link
Copy Markdown
Collaborator
Files Added Deleted Net
Test 0 0 0 0
Prod 1 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​3 0 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​3

ELI5

Large transcript messages were being stored as short string slices that still kept the full JSONL record alive. The search scanner now stores an independent copy of each bounded row, so indexing releases the large source string.

What Changed

The session search writer detaches every row's text with a UTF-16 round trip immediately before buffering it. This applies at the shared writer boundary used by all local Agent Session History providers, including Codex, Claude, Cursor, Gemini, OpenCode, and the other indexed readers.

Why

The scanner's 32 MiB character counter measured only visible slices, while V8 retained their multi-megabyte parent strings. Copying at the buffer boundary fixes the retention without changing searchable text or requiring a larger heap. The JSONL reader already copies partial byte tails; no separate reader-specific fix is needed.

Linked Issue

Fixes #22296

Visual Proof

N/A — this is a background indexing memory fix with no UI change.

Testing

  • Automated tests added/updated, or explained why not below
  • pnpm test src/main/ai-vault-search/session-search-index-writer.test.ts src/main/ai-vault-search/session-search-file-write.test.ts src/main/ai-vault-search/session-search-message-rows.test.ts
  • pnpm tc:node
  • pnpm run check:code-quality:changed
  • git diff --check

AI Disclosure

Codex (GPT-6) assisted with investigation and implementation.

Review

The change is intentionally at the shared indexing boundary so all local transcript readers receive the same protection. UTF-16 round-tripping preserves JavaScript code units, including unpaired surrogates.

Agent skill upstream boundary

  • Not applicable

Notes

No SSH or remote-wire behavior changes. Remote history listing does not feed the local session search writer. The change is platform-neutral Node code.

Checklist

  • This PR is small and focused
  • I explained what changed and why
  • 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 (CI will cover full repository checks; focused checks above pass)

@pullfrog

pullfrog Bot commented Sep 23, 2026 •

Copy link
Copy Markdown
Contributor

This run was cancelled 🛑

The workflow was cancelled before completion. Please check the link below for details.

Pullfrog  | View workflow run | via Pullfrog | 𝕏

Co-authored-by: Andre Ambrósio <56239028+sirambrosio@users.noreply.github.com>
@OrcaWin
OrcaWin force-pushed the OrcaWin/bug-session-scanner-ooms-on-large-codex-transcri branch from 38b1561 to 03bdcd9 Compare September 23, 2026 20:24
@coderabbitai

coderabbitai Bot commented Sep 23, 2026

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

✨ Finishing Touches
📝 Generate docstrings
  • Commit to this branch
  • Create a new PR

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.

@OrcaWin
OrcaWin merged commit 19e8bf3 into main Sep 23, 2026
3 checks passed
@OrcaWin
OrcaWin deleted the OrcaWin/bug-session-scanner-ooms-on-large-codex-transcri branch September 23, 2026 20:28
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.

[Bug]: Session scanner OOMs on large Codex transcripts because buffered slices retain parent strings

1 participant