fix: keep every manual activity when the lines arrive together - #35
Draft
DamengRandom wants to merge 1 commit into
Draft
fix: keep every manual activity when the lines arrive together#35DamengRandom wants to merge 1 commit into
DamengRandom wants to merge 1 commit into
Conversation
promptUser built a new readline interface per line and closed it after each answer, discarding the lines readline had already buffered from the same stdin chunk. A pasted or piped list recorded only its first entry. Closes #34 Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01VApAvCjp7qDWftMrdtnzHt
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.
Closes #34
The bug
promptUserbuilt a newreadline.Interfacefor every line and closed it after each answer. Node's readline reads a whole chunk off stdin and buffers the lines inside it;rl.close()throws that buffer away. Any line that shared a stdin chunk with the first one was silently discarded, and the loop exited as though the engineer had typeddone.That covers pasting a list into the terminal and piping input. Typing line by line happened to work, because each line was its own chunk.
The fix
One interface for the whole loop, iterated with
for await. Readline's async iterator queues lines as they are emitted, so a burst is consumed in order instead of being dropped.The EOF behaviour from #32 is preserved without the explicit
closehandler: on a/dev/nullstdin the iterator simply ends, the loop body never runs, and the tool returns zero activities.Observed vs reasoned
Observed, by running the real
manualKpiToolfromsrc/:Reviewed 3 PRs\nRan the release\nMentored a junior\ndone\nreturned["Reviewed 3 PRs"]. After the fix it returns all three.script -qec): the same four lines pasted in one burst returned["first"]before and["first","second","third"]after. Typed with 2s pauses it returned all three both before and after — confirming the trigger is stdin chunking, not the terminal./dev/null, the tool still settles and returns{"activities":[]}— the Daily KPI run hangs then exits 0 when the activities input is left blank — nothing is saved, no alert #32 regression guard.pnpm test(80 tests),pnpm tscandpnpm format:checkall pass. The new test insrc/tools/manual-kpi.test.tsfails onmaster(not ok 4) and passes here.Reasoned, not observed: the downstream consequence described in the issue — that
runDailyJobsthen writes a KPI report andkpi.activitiesfrom the truncated list — follows from readingsrc/agent/index.ts:38-52,138. It was not executed, since that path needs a database, an LLM and Telegram, none of which are configured here.Generated by Claude Code