Skip to content

emrg: GUI open-sessions state + gui_state.json persistence — P4 slice 1 (GUI multi-session rant P4) - #637

Merged
argszero merged 3 commits into
masterfrom
feature/gui-p4-open-sessions-state
Aug 10, 2026
Merged

emrg: GUI open-sessions state + gui_state.json persistence — P4 slice 1 (GUI multi-session rant P4)#637
argszero merged 3 commits into
masterfrom
feature/gui-p4-open-sessions-state

Conversation

@argszero

Copy link
Copy Markdown
Owner

Summary

P4 slice 1 of the GUI multi-session rant (2026-08-10T15:07:19): the WRITE path for the open-sessions model — keep session connections open across switches (browser-tab semantics), persist them to gui_state.json, and expose close/get IPC for the sidebar (slice 2).

Changes

emrg/gui/gui-state.js (new, pure Node) — gui_state.json persistence:

emrg/gui/main.js

  • openSessions: Map<sid, {projectName, projectPath, lastActive}> bookkeeping with touchOpenSession / markSessionActive / schedulePersistGuiState (1s debounce) / persistGuiStateNow (capped via sanitize)
  • switchSession no longer closes the old session connection — multi-session keep-open (close now via emrg:closeSession); marks active + persists
  • New emrg:closeSession IPC: disconnect + remove + persist, keeps disk data (distinct from delete_session)
  • New emrg:getOpenSessions IPC: cross-project open list (sidebar data source for slice 2)
  • sendMessage marks session active; done/delta events refresh lastActive via the event bridge (onOpen hook now passes projectPath)
  • deleteSession / newSession update the open-sessions bookkeeping; flush persist on app quit

emrg/gui/conn-manager.jsonOpen hook now receives projectPath (3rd arg) so main.js can track per-session project paths.

emrg/gui/preload.js — expose closeSession / getOpenSessions.

test/gui-state.test.js (new) — 7 tests: path, invalid-entry filtering, lastActive desc + cap 20, missing-lastActive ordering, atomic write + dir auto-create, overwrite, persist-side cap.

Verification

  • GUI: 160 tests pass (153 + 7 gui-state); 680 pytest green; node --check clean on all touched JS
  • README/Agent/README.cn counts updated to 160

P4 remaining (slice 2): sidebar open-sessions list (跨项目), restore on boot from gui_state.json, activate/close/rename context menu, cap-20 restore, window-title sync.

@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-174555 (author). P4 slice 1: open-sessions state + gui_state.json persistence; 160 GUI (153+7) + 680 pytest green.

@pm25coder

Copy link
Copy Markdown
Contributor

Tested this PR end-to-end on Windows — P4 slice 1 (open-sessions state + gui_state.json persistence) verified. One merge-blocking issue: CONFLICTING (doc-count positional).

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

Rebased on master (was CONFLICTING after #636's doc-count bump): resolved Agent.md/README.md/README.cn.md to true counts 163 = 43 dc + 17 cm + 22 app-commands + 46 renderer smoke + 15 i18n + 7 integration + 3 commands + 3 build-config + 7 gui-state (merged HEAD e6cd99b).

Verified locally on the resolved head: GUI suite 163/163 (7 new gui-state tests: guiStatePath, invalid-entry filtering, lastActive desc + cap-20, missing-lastActive ordering, atomic write + dir auto-create, overwrite, persist-side cap), 680 pytest green, doc-count guard passes, node --check clean.

Code review: gui-state.js is pure-Node atomic persistence mirroring install-info.json (#569 .tmp + rename); main.js openSessions Map bookkeeping with touchOpenSession/markSessionActive + 1s debounced persist; switchSession no longer closes the old connection (multi-session keep-open, browser-tab semantics); emrg:closeSession disconnects + persists but keeps disk data (correctly distinct from delete_session); emrg:getOpenSessions is the sidebar data source for slice 2; onOpen hook now passes projectPath. Matches the rant P4 write-path plan.

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

Re-verified on head e6cd99b (rebase on master after #636 merge): GUI suite 163/163 (43 dc + 17 cm + 22 app-commands + 46 renderer smoke + 15 i18n + 7 integration + 3 commands + 3 build-config + 7 gui-state), 680 pytest green, doc-count guard passes (163 synced in Agent.md/README/README.cn). P4 slice 1: open-sessions state + gui_state.json persistence — solid.

@argszero
argszero merged commit 4c6dda7 into master Aug 10, 2026
1 check passed
@pm25coder

Copy link
Copy Markdown
Contributor

Rebased branch (e6cd99b) re-verified — my conflict resolution applied exactly as predicted.

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