Repository navigation
Keep tail-transcript -f from dropping a line caught mid-write - #259
Merged
Merged
Conversation
Follow mode now holds an unterminated tail until its newline arrives, the file is decoded as UTF-8 regardless of locale, and an unreadable file gets a one-line error instead of a traceback. Closes #258 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Member
Author
|
Self-review: no blocking issues found. The
This review was drafted during a Gardener session (https://github.com/Stephenson-Software/gardener). drafted by Claude on behalf of Daniel Stephenson |
Member
Author
|
Correction to the self-review above: two line references are off. The follow-branch notes refer to This comment was drafted during a Gardener session (https://github.com/Stephenson-Software/gardener). drafted by Claude on behalf of Daniel Stephenson |
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
iter_pretty_lines(gardener/transcript.py), the reader behindgardener tail-transcript, no longer drops a transcript line caught mid-write under-f. At EOFreadline()returns a partial line without its newline. That fragment, and its tail on the next poll, were each parsed as JSON, failed, and were skipped, so the event was lost silently. An unterminated tail is now held and joined to the next read, the same whole-lines rulelive.py'sTranscriptCacheapplies to the same files. Without-f, a final line with no newline is still parsed.encoding="utf-8", errors="replace"instead of the locale's encoding, matchinglive.py,dashboard.py,run_log.pyandtrace_client.py. Claude Code writes UTF-8 whatever the locale is.print_transcriptcatchesOSErrorfrom a file that exists but can't be read, and returns1with a one-linegardener:error instead of a traceback.BrokenPipeErroris anOSErrorsubclass, but it is still caught first by the existing clause and keeps exiting0.docs/TESTING.md'stest_transcript.pyparagraph describes the new coverage.The lost-event case was found by reading the code, not observed in a real transcript. The guard
live.pyalready carries for these files shows the case had been judged worth handling once before.Closes #258
Test plan
python3 -m unittest tests.test_transcript: 49 tests pass locally.git checkout origin/main -- gardener/transcript.pywas run, and aGrepfor the fix'spendingtoken returned nothing. Three of the four new tests then failed (mid-write join, UTF-8 decode, unreadable file).test_dump_mode_still_parses_a_final_line_with_no_newlinepasses on both sides because it is a regression guard for dump mode, not a test of the fix. Aftergit checkout HEAD -- gardener/transcript.py,git status --porcelainwas empty.python3 -m compileall gardenertests/andintegration/offline runs: the sandbox'spython3is 3.8, belowrequires-python >=3.10, so CI on this PR is the anchor of record (see the checks below).dispatch.py,dev_loop.pyand the prompt templates are untouched.This PR description was drafted during a Gardener session (https://github.com/Stephenson-Software/gardener).
🤖 Generated with Claude Code
drafted by Claude on behalf of Daniel Stephenson