Skip to content

fix: don't silently truncate parses or resume in the wrong directory#6

Merged
brtkwr merged 1 commit into
mainfrom
fix/robustness
Jun 22, 2026
Merged

fix: don't silently truncate parses or resume in the wrong directory#6
brtkwr merged 1 commit into
mainfrom
fix/robustness

Conversation

@brtkwr

@brtkwr brtkwr commented Jun 22, 2026

Copy link
Copy Markdown
Collaborator

What

Two robustness bugs surfaced by the reliability lens of the codebase review.

1. Silent parse truncation

parseConversationFile never checked scanner.Err(). A JSONL line larger than the buffer cap (10MB) stops scanner.Scan(), and the function returned whatever it had parsed so far as if the file were complete. A single big turn - a large tool result or a base64 image - silently drops the rest of the conversation, so searching for a phrase past that line reports "no match". Worst kind of bug in a search tool: wrong answer, no error.

  • Buffer cap raised to 64MB (a turn can legitimately be tens of MB).
  • scanner.Err() is now checked; a scan error skips the file rather than trusting a half-parse.

2. Resume in the wrong directory

os.Chdir(cwd) ran after printing Resuming conversation … in <cwd> and, if it failed, only printed a warning then syscall.Exec'd claude anyway - in whatever directory ccs happened to be in, silently giving claude the wrong project config / MCP servers. For a tool whose whole point is "resume in the right place", that quietly defeats the feature.

  • os.Chdir now runs before the announcement and exits with a clear error if the directory is gone, instead of resuming in the wrong place.

Scope

previewScroll's discarded clamp (a separate review finding) is not here - the clean fix needs a small render refactor and it's lower stakes (a UI scroll annoyance, no data loss). Left as a follow-up.

Tests

None added: the scanner path needs a >64MB line and the resume path calls os.Exit/syscall.Exec from main() - both impractical to unit test without restructuring. Existing parse tests pass as regression cover; go test -cover = 68.7%.

Two robustness bugs from the codebase review:

- parseConversationFile never checked scanner.Err(). A JSONL line over
  the buffer cap stops the scan, and the function returned the partial
  parse as if complete - silent data loss in a search tool (a phrase
  past the truncation point reports "no match"). Now the buffer cap is
  64MB and a scan error skips the file instead of trusting a partial
  read.

- On resume, os.Chdir ran after printing "Resuming in <cwd>" and, on
  failure, only warned then exec'd claude anyway - in the wrong
  directory, silently handing claude the wrong project config/MCP
  servers. Now chdir runs first and fails loudly if the directory is
  gone.

No unit tests: the scanner path needs a >64MB line and the resume path
calls os.Exit/syscall.Exec in main(); both are impractical to unit
test. Existing parse tests still pass as regression cover.
@brtkwr brtkwr merged commit e710e4b into main Jun 22, 2026
1 check passed
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