Skip to content

emrg: GUI renderer per-session chat state isolation — P3 slice 0 (GUI multi-session rant P3) - #630

Merged
argszero merged 2 commits into
masterfrom
feature/gui-p3-chat-session-isolation
Aug 10, 2026
Merged

emrg: GUI renderer per-session chat state isolation — P3 slice 0 (GUI multi-session rant P3)#630
argszero merged 2 commits into
masterfrom
feature/gui-p3-chat-session-isolation

Conversation

@argszero

Copy link
Copy Markdown
Owner

Summary

First slice of P3 (multi-container chat views) from the GUI multi-session rant (2026-08-10T15:07:19): per-session chat state isolation in the renderer. This is the renderer-side foundation for per-session event routing — events carrying sid (added by #629's main-process event bridge) now scope their group/tool/typing state per session. Fully backward-compatible: no sid → identical legacy behavior.

Changes

renderer/js/chat.js

  • Session-scoped state: sessionState Map (sid → {groupNodes, toolRows, doneRids}); sid=null = legacy single-session bucket (all existing callers unaffected)
  • All Chat handlers accept optional sid: handleDelta(chunks, sid), handleDone(data, sid), handleToolStart(data, sid), handleToolEnd(data, sid), clearTyping(sid), clear(sid), addSystemMessage(text, sid), addUserMessage(text, sid), createAssistantNode(isOwn, sid)
  • Container routing groundwork (P4 openSessions): registerContainer(sid, el) / unregisterContainer(sid) / chatContainer(sid) — registered container receives that session's nodes; unregistered/undefined sid falls back to default #chat-view
  • groupNodesFor(sid) / toolRowsFor(sid) accessors; legacy groupNodes/toolRows getters delegate to the null bucket

renderer/js/app.js

  • handleEvent passes evt.sid through to Chat calls (delta/done/tool_started/tool_finished/cancelled/error/disconnected)
  • Disconnected handler scopes group-map clear + running-tool-row failure marking per sid

Tests

  • renderer.smoke 32→36 (+4): per-sid delta groups isolated (same request_id in two sessions); done clears only its session's group (other session's same-rid group + residual delta preserved); clearTyping(sid) scoped; registerContainer routes nodes to the registered container with default-container fallback after unregister
  • GUI 127→131 (37 dc + 8 cm + 36 renderer smoke + 22 + 15 + 7 + 3 + 3); 680 pytest green (doc-count guard); node --check clean
  • No overlap with emrg: GUI main.js rewire to ConnManager — P2 per-session connections (GUI multi-session rant P2) #629's files (main.js/conn-manager.js/daemon_client.js) — merges cleanly in either order (doc counts resolve to actual at merge)

@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-165036

Verified locally on the PR head: GUI suite 131/131 (36 renderer smoke — per-sid delta groups isolated, done clears only its session, clearTyping(sid) scoped, registerContainer routing + default fallback; all 127 pre-existing tests green = zero regression), 680 pytest green (doc-count guard 131 breakdown), node --check clean. Design matches rant P3: renderer state 改造 first step — per-sid state maps + container routing groundwork, forward-compatible with #629's sid-tagged events (no sid → legacy behavior identical).

@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-165615

Rebased on master (was CONFLICTING after #629's doc-count bump): resolved Agent.md/README.md/README.cn.md to true counts 146 = 43 daemon_client + 17 conn-manager + 36 renderer smoke + 22 + 15 + 7 + 3 + 3 (merged HEAD d3cd786).

Verified locally on the resolved head: GUI suite 146/146 (36 renderer smoke: per-sid delta group isolation — same request_id in two sessions stays separate; done clears only its session's group, other session's same-rid group + residual delta preserved; clearTyping(sid) scoped; registerContainer routes to the registered container with default-container fallback after unregister), 680 pytest green, doc-count guard passes, node --check clean.

Code review: sessionState Map with sid=null legacy bucket is backward-compatible (no sid → identical behavior); containers groundwork is clean for P4 openSessions; disconnected handler now scopes group-map clear + running-tool failure marking per sid. No overlap with #629's files, design matches the rant P3 (renderer-side foundation for per-session event routing).

@pm25coder

Copy link
Copy Markdown
Contributor

Tested branch `feature/gui-p3-chat-session-isolation` (e69f6b3) locally — full suite green:

@pm25coder

Copy link
Copy Markdown
Contributor

Re-tested after the rebase onto master 2840017 (head d3cd786) — the doc-count resolution (146: 43 daemon_client + 17 conn-manager + 36 renderer smoke + 22 app-commands + 15 i18n + 7 integration + 3 commands + 3 build-config) is exactly right and everything is 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-170611

Re-verified on head d3cd786 (doc-count merge commit, 146): GUI suite 146/146 (36 renderer smoke — per-sid delta group isolation with same request_id across two sessions, done clears only its session's group while other session's same-rid group + residual delta preserved, clearTyping(sid) scoped, registerContainer routing with default-container fallback after unregister; all pre-existing tests green = zero regression), 680 pytest green (doc-count guard reads 43 dc + 17 cm + 36 renderer + 22 + 15 + 7 + 3 + 3), node --check clean. PR CI 31372473987 SUCCESS. Matches rant P3: renderer per-session state isolation + container routing groundwork, forward-compatible with #629's sid-tagged events.

@argszero
argszero merged commit 2f46e81 into master Aug 10, 2026
1 check passed
@pm25coder

Copy link
Copy Markdown
Contributor

Post-merge verification on master 2f46e81:

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