Skip to content

emrg: DaemonClient per-connection delta batching (GUI multi-session rant P2 slice 3) - #626

Merged
argszero merged 1 commit into
masterfrom
feature/delta-batching
Aug 10, 2026
Merged

emrg: DaemonClient per-connection delta batching (GUI multi-session rant P2 slice 3)#626
argszero merged 1 commit into
masterfrom
feature/delta-batching

Conversation

@argszero

Copy link
Copy Markdown
Owner

Third slice of P2 (connection layer) from the GUI multi-session rant (2026-08-10T15:07:19): the rant specifies deltaBuf batching (G122 16ms) must live per connection (deltaBuf 批量(G122 16ms)每连接一份) so each session's stream batches independently under connManager.

Changes (emrg/gui/daemon_client.js):

  • New constructor option deltaBatchMs = 0 — default 0 = per-frame emit (existing behavior + tests unchanged); >0 = this DaemonClient batches message_delta frames into a { chunks: [...] } event every deltaBatchMs
  • Terminal-event ordering guarantee (rant 14:11 lesson): done / error / cancelled all flush the pending delta buffer before emitting, so deltas never arrive after the terminal event (prevents orphan nodes in the renderer)
  • close() flushes pending deltas (no loss on disconnect)
  • Batched event shape { type: "message_delta", data: { chunks } } matches what main.js already sends to the renderer — the main.js rewire slice can consume this directly.

Tests (+6 daemon_client, 31→37): batched merge (multiple deltas → one {chunks}), done-flush ordering, cancelled-flush ordering, error-flush ordering, default mode regression (per-frame), close-flush.

Doc counts synced 118→124 (README/README.cn/Agent). 680 pytest + 124 GUI green.

@argszero argszero left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

✅ LGTM — cycle 20260810-160626

Verified locally: 37/37 daemon_client tests pass (6 new deltaBatchMs tests: batch merge, done/cancelled/error flush ordering, default regression, close flush), full GUI suite 124 (37 dc + 5 cm + 22 + 32 + 15 + 7 + 3 + 3), 680 pytest + import + CLI + node --check all green. Batched shape matches main.js's existing {chunks} renderer contract.

@argszero argszero left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

✅ LGTM — cycle 20260810-161305

Head e4762cd re-verified: deltaBatchMs opt-in batching (default 0 unchanged), terminal events (done/error/cancelled) flush buffer before emitting, close() flushes. 37/37 daemon_client tests pass locally, GUI 124 total, 680 pytest + node --check green. Test CI 31368947986 SUCCESS.

@pm25coder

Copy link
Copy Markdown
Contributor

I tested this PR on Windows (zh-CN): checked out feature/delta-batching, ran `npm test` in emrg/gui → 124 pass / 0 fail (including the 6 new delta-batching tests), and `uv run pytest tests/` → 625 passed + 55 skipped = 680. The batching behavior works as described: deltaBatchMs>0 merges deltas into {chunks}, default 0 stays per-frame, and done/cancelled/error/close all flush the pending buffer before emitting — the ordering guarantee (deltas never after terminal event) holds, which aligns with the G122/14:11 orphan-node lesson.

@argszero argszero left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

✅ LGTM — cycle 20260810-161226

Independently verified on feature/delta-batching (e4762cd): node --check passes; full GUI suite 124/124 (37 daemon_client incl. 6 new deltaBatchMs tests: batch merge, done/cancelled/error flush-ordering, default per-frame regression, close-flush); 680 pytest + doc-count guard (118→124) green; import check OK. Terminal-event flush ordering correctly embodies the rant 14:11 orphan-node lesson (delta never emitted after done/error/cancelled), close() flushes to avoid loss, and the {chunks} batched shape matches main.js's existing renderer contract — ready for the main.js rewire slice to consume directly.

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.

2 participants