fix: raise NDJSON parser scanner buffer to 10 MB

Merged
KE
5mo ago
+71-12

What type of PR is this?

/kind bug

What this PR does / why we need it:

The agent NDJSON log parsers in internal/cli/logparser*.go and internal/reporting/{activity,progress}.go previously capped the per-line bufio.Scanner buffer at 1 MB. Stream-json output from supported agents can produce single lines well over 1 MB โ€” e.g., a Read tool result on a large file or a Bash result with bulk output is emitted as one NDJSON line. When the scanner hits such a line it returns bufio.ErrTooLong and stops consuming the rest of the stream:

  • ParseAndFormat*Logs returns an error and the remaining log output is not formatted or forwarded.
  • extract*Activity and progress parsers return whatever was captured before the long line, so activity/progress reporting silently truncates from that point.

This PR raises the max buffer to 10 MB in all 12 NDJSON parser call sites, matching the ceiling already used in internal/capture/usage.go. Unit tests are added covering the claude-code parser in each affected file to verify a >1 MB single NDJSON line no longer trips the scanner.

Which issue(s) this PR is related to:

Fixes #1188

Special notes for your reviewer:

This is the minimal-change option (option 1) called out in the issue. If lines exceeding 10 MB are observed in practice, the follow-up is to switch to bufio.Reader.ReadBytes('\n') for an unbounded line size.

Does this PR introduce a user-facing change?

Raise the agent NDJSON log parser per-line scanner buffer from 1 MB to 10 MB so large stream-json lines (e.g., large Read or Bash tool results) no longer truncate log formatting, activity, or progress output.