Skip to content

refactor: consolidate transcript file reads from 3x to 1x per session#16

Merged
K-dash merged 1 commit into
mainfrom
refactor/consolidate-transcript-reads
Feb 8, 2026
Merged

refactor: consolidate transcript file reads from 3x to 1x per session#16
K-dash merged 1 commit into
mainfrom
refactor/consolidate-transcript-reads

Conversation

@K-dash
Copy link
Copy Markdown
Owner

@K-dash K-dash commented Feb 8, 2026

Summary

  • Consolidate 3 separate transcript file reads into a single read per session refresh
  • Introduce TranscriptSnapshot to read JSONL file once and extract status, prompt, and output from in-memory buffer
  • Add transcript/info.rs as orchestration layer between parser and state modules to avoid circular dependencies
  • Existing standalone functions (detect_session_status, get_last_user_prompt, get_last_assistant_text) remain as thin wrappers for backward compatibility

Motivation

Each call to detect_session_info() was opening/reading/parsing the same transcript file 3 times:

  1. detect_session_status()read_lines_from_end(path, 20)
  2. get_last_user_prompt()read_lines_from_end(path, 30)
  3. get_last_assistant_text()read_lines_from_end(path, 30)

With N sessions, this meant 3N file opens per refresh cycle. Now it's 1N.

Test plan

  • All 100 existing tests pass unchanged (original functions delegate to extracted logic)
  • 4 new tests added including equivalence test (read_transcript_info vs individual functions)
  • make all passes (fmt + clippy -D warnings + test)
  • daemon/watcher.rs unaffected (uses detect_session_status(path) standalone)

Each session refresh was opening, reading, and parsing the same
transcript JSONL file three times (status, prompt, output). Introduce
TranscriptSnapshot to read the file once and extract all data from the
in-memory buffer. Existing standalone functions remain as thin wrappers
for backward compatibility (daemon uses detect_session_status alone).
@K-dash K-dash merged commit 13fbb07 into main Feb 8, 2026
1 check passed
@K-dash K-dash deleted the refactor/consolidate-transcript-reads branch February 8, 2026 01:01
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