Skip to content

fix: keep every manual activity when the lines arrive together - #35

Draft
DamengRandom wants to merge 1 commit into
masterfrom
fix/scan-manual-kpi-multiline-input
Draft

fix: keep every manual activity when the lines arrive together#35
DamengRandom wants to merge 1 commit into
masterfrom
fix/scan-manual-kpi-multiline-input

Conversation

@DamengRandom

Copy link
Copy Markdown
Owner

Closes #34

The bug

promptUser built a new readline.Interface for 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 typed done.

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 close handler: on a /dev/null stdin the iterator simply ends, the loop body never runs, and the tool returns zero activities.

Observed vs reasoned

Observed, by running the real manualKpiTool from src/:

  • Before the fix, a single-chunk stdin of Reviewed 3 PRs\nRan the release\nMentored a junior\ndone\n returned ["Reviewed 3 PRs"]. After the fix it returns all three.
  • Through a real pty (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.
  • With stdin at /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 tsc and pnpm format:check all pass. The new test in src/tools/manual-kpi.test.ts fails on master (not ok 4) and passes here.

Reasoned, not observed: the downstream consequence described in the issue — that runDailyJobs then writes a KPI report and kpi.activities from the truncated list — follows from reading src/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

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
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.

Manual KPI input silently keeps only the first activity when the lines arrive together (paste or pipe)

2 participants