Skip to content

refactor: extract daemon progress parsing#753

Merged
thymikee merged 1 commit into
mainfrom
codex/727-progress-seam
Jun 10, 2026
Merged

refactor: extract daemon progress parsing#753
thymikee merged 1 commit into
mainfrom
codex/727-progress-seam

Conversation

@thymikee

Copy link
Copy Markdown
Member

Summary

Moves socket progress stream parsing out of src/daemon-client.ts and into src/daemon-client-progress.ts, keeping daemon-client as the public facade for lifecycle, transport selection, timeout handling, and request dispatch. Adds focused coverage for split socket progress lines, response envelopes, ignored post-settle input, and invalid-line request context.

Touched files: 3. Scope stayed within the daemon-client progress seam.

Refs #727

Validation

Focused daemon-client/progress Vitest coverage passed. pnpm check:quick passed. pnpm check:fallow --base origin/main passed with no baseline changes. pnpm format completed, and git diff --check / staged whitespace check passed.

@github-actions

github-actions Bot commented Jun 10, 2026

Copy link
Copy Markdown

Size Report

Metric Base Current Diff
JS raw 1.2 MB 1.2 MB -12.4 kB
JS gzip 390.1 kB 385.4 kB -4.7 kB
npm tarball 501.4 kB 497.4 kB -4.1 kB
npm unpacked 1.7 MB 1.7 MB -12.5 kB

Startup median (7 runs, lower is better):

Scenario Base Current Diff
CLI --version 26.4 ms 26.6 ms +0.2 ms
CLI --help 41.6 ms 41.5 ms -0.1 ms

Top changed chunks:

Chunk Raw diff Gzip diff
dist/src/9533.js +70.4 kB +23.0 kB
dist/src/input-actions.js +9.4 kB +3.6 kB
dist/src/cli.js -9.5 kB -3.0 kB
dist/src/session.js +9.9 kB +2.9 kB
dist/src/2415.js +3.9 kB +1.2 kB

@thymikee thymikee left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed the extraction against the original sendSocketRequest handler — this is a faithful move with good seam design (daemon-client.ts keeps ownership of settled/timeout state, the helper only parses), and the new tests cover the cases that matter: split lines across chunks, progress-before-response ordering, post-settle input, and invalid-line request context. Overall LGTM. Two minor notes:

  1. settled ordering around socket.end() — in the original code, settled = true was set before socket.end(). In the extracted helper, the order is now clearTimeout()socket.end()resolve(response), and settled is only flipped inside the resolve wrapper. If socket.end() ever synchronously emitted 'error'/'close', the handlers in sendSocketRequest would still see settled === false and reject a request that was about to resolve. It's a narrow window in practice, but swapping to resolve(response) before socket.end() (or passing a markSettled callback invoked first) would restore the original guarantee.

  2. Test file location — the new test lives in src/utils/__tests__/daemon-client-progress.test.ts, but the module under test is src/daemon-client-progress.ts (note the ../../daemon-client-progress.ts import). Moving it to src/__tests__/ would match where the module sits and keep the utils test dir scoped to src/utils.

CI is green across the board (typecheck, unit, integration, coverage, Fallow) with a couple of Smoke Tests still running at review time — nothing blocking from my side once those finish.


Generated by Claude Code

@thymikee thymikee force-pushed the codex/727-progress-seam branch from 87295fd to 1c4cef0 Compare June 10, 2026 18:24
@thymikee

Copy link
Copy Markdown
Member Author

Addressed the two review notes:

  • Restored the original settled-before-end guarantee by calling the facade resolve callback before socket.end() in the extracted parser.
  • Moved the direct progress module test from src/utils/__tests__ to src/__tests__ and updated imports.

Re-ran:

  • pnpm exec vitest run src/__tests__/daemon-client-progress.test.ts src/utils/__tests__/daemon-client.test.ts src/utils/__tests__/daemon-client-lifecycle.test.ts
  • pnpm format
  • pnpm check:quick
  • pnpm check:fallow --base origin/main
  • git diff --check

@thymikee thymikee merged commit f661efd into main Jun 10, 2026
18 of 19 checks passed
@thymikee thymikee deleted the codex/727-progress-seam branch June 10, 2026 18:31
@github-actions

Copy link
Copy Markdown
PR Preview Action v1.8.1
Preview removed because the pull request was closed.
2026-06-10 18:31 UTC

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