Bound terminal output flow across Electron and xterm#169
Merged
Conversation
This was referenced Jun 20, 2026
luckeyfaraday
pushed a commit
that referenced
this pull request
Jun 20, 2026
readHermesSessions() re-ran the entire workspace-independent ~/.hermes scan -- reading and JSON-decoding up to MAX_PROVIDER_ROWS session files -- once per open workspace. After PR #154 began refreshing agent sessions for every open workspace tab, an N-workspace review fanned this into N concurrent full re-reads of the same corpus, multiplying peak heap by the workspace count. Scan the corpus once per CACHE_TTL_MS via a new memoizeAsyncWithTtl helper and apply the per-workspace match to the shared result. This closes the last unbounded per-workspace session-scan path from the v0.1.9 OOM investigation, complementing the codex/claude bounding in #169. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This was referenced Jun 20, 2026
JJPuertas
pushed a commit
to JJPuertas/Athena
that referenced
this pull request
Jun 20, 2026
The codex `~/.codex/sessions` metadata scan (bounded in luckeyfaraday#169) carried its own inline TTL cache with identical semantics to the `memoizeAsyncWithTtl` helper added for the Hermes scan dedup (luckeyfaraday#170): share one in-flight promise per TTL window, never cache rejections. Fold the codex cache into the shared helper to remove the duplicated cache bookkeeping. No behavior change. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Two unbounded-memory paths could drive the Electron main process to V8 heap OOM. This branch bounds both.
Terminal output flow (
aafdaac,a5f9b64).grok/Agent session transcript scans (
ee83d09)readFilePrefix(512 KB cap viafs.open/read) and replace whole-filereadFile(…, "utf8")reads in the codex, claude, and grok session scanners (plus the terminal-restore path)mapWithConcurrency(cap 8) in place of unboundedPromise.allover session files~/.codex/sessionsmetadata scan in a 30s cache so it runs once instead of once per workspaceRoot cause (transcript scans)
PR #154 (
b4c801c, "Improve multi-workspace review handoffs", first shipped in v0.1.9) replaced the single active-workspace session scan with an all-workspaces fan-out:With N saved workspace tabs this issues N concurrent
listAgentSessionscalls. Each one re-scanned the global~/.codex/sessionscorpus and materialized every file via an unboundedPromise.all(files.map(readFile(…, "utf8"))), so N workspaces produced N concurrent full copies of the same transcript corpus. The per-workspace 30s session cache does not help (it is keyed by workspace), and theutf8decode path matches the crash stackStringDecoder::DecodeData → NewStringFromUtf8 → NewRawTwoByteString.Evidence
Terminal output flow
The Electron main process hit V8 heap OOM at 12:45:12, 14:48:07, and 15:15:31 CEST. The 15:15 recurrence ran the initial backlog-cap build, showing retained strings were bounded but Electron IPC and xterm write queues were still unbounded.
Transcript scans (identical corpus, 2 GB heap, v0.1.9)
Verification
npm run build:electronnpm run test:electron— 135 tests across 20 files pass (incl.terminal-buffer,file-prefix)npm run buildclient/release/ATHENA-0.1.9.AppImageFollow-up
The Hermes provider scan had the same global-corpus-rescanned-per-workspace shape; it is deduplicated separately in #170.