Skip to content

emrg: GUI multi-session deviations fix — new-chat/open-session entries + per-session drafts (rant 2026-08-10T21:59:11) - #656

Merged
argszero merged 1 commit into
masterfrom
feature/gui-multisession-deviation-fix
Aug 10, 2026
Merged

emrg: GUI multi-session deviations fix — new-chat/open-session entries + per-session drafts (rant 2026-08-10T21:59:11)#656
argszero merged 1 commit into
masterfrom
feature/gui-multisession-deviation-fix

Conversation

@argszero

Copy link
Copy Markdown
Owner

Summary

Fixes 3 implementation deviations found by the host in v0.2.22 (rant 2026-08-10T21:59:11, design doc f4e5d6c7). Core P1-P6 of the GUI multi-session feature were already merged; these are the leftover acceptance gaps.

Changes (emrg/gui/)

B1 — 新建会话入口 (host-verified): sidebar new-chat-btn + ⌘N were calling newSession() directly (creating a session with no project selection). Now both call Dialogs.showNewSessionDialog() — the existing project-picker dialog (active-sorted projects → click to create in that project, or create-new-project button).

B2 — 打开会话入口: the two-step open-session dialog (project → session) was only reachable via the /open command. Added a dedicated #open-chat-btn ghost button under the new-chat button in the sidebar → Dialogs.showOpenSessionDialog(), with zh/en i18n keys + CSS.

B3 — per-session drafts: the chat container was per-session but the composer input was a global singleton — switching sessions lost the draft. Added state.drafts: Map<sid, string>:

  • switchSession: saves current input to the old sid before switching, restores the target sid's draft after
  • newSession: saves old sid draft; new session starts with an empty draft
  • sendMessage: clears the draft for the session once the message is sent
  • Restore resets the auto-resize height like the normal input handler

Regression safety: the open-session dialog's internal + 新建会话… entry and the no-projectPath fallback paths (delete/close-session → newSession()) keep working unchanged.

Tests (renderer.smoke.test.js)

  • B1: new-chat-btn click opens the new-session dialog and does NOT call newSession() directly
  • B2: open-chat-btn click opens the open-session dialog
  • B3: switch s1 (with draft) → s2 (cleared) → back to s1 (draft restored)
  • B3: send clears the sid draft; new session starts with empty draft + cleared input

GUI tests: 179 → 183 (renderer smoke 59 → 63; README.md / README.cn.md / Agent.md synced). pytest unchanged: 687. Also adds the evolution_prompt quick-ref entry for merged #655 (mid-turn queue injection P1, user-facing daemon feature).

…s + per-session drafts (rant 2026-08-10T21:59:11)

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

Verified locally before push: pytest 687/687 green (incl. evolution_prompt placeholder guard), GUI 183/183 (4 new renderer.smoke tests: B1 dialog-not-direct-new / B2 open-session entry / B3 draft save-restore + send-clear/new-empty), import check + emrg --help OK. Diff 9 files +126/−7 covers all three deviations (B1/B2/B3) with regression safety; doc counts synced (179→183).

@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

Reviewed the full diff (126+/7-, 9 files) after CI SUCCESS (run 31397853180, 1m25s). All three host-verified deviations addressed cleanly:

  • B1: new-chat-btn + ⌘N both route through Dialogs.showNewSessionDialog() (project picker) instead of calling newSession() directly — matches the host's expected new-chat flow.
  • B2: dedicated #open-chat-btn ghost button wired to the two-step open-session dialog, with zh/en i18n keys + CSS. Test asserts dialog opens.
  • B3: per-session drafts via state.drafts: Map<sid, string> — saveDraft before switch/new, restoreDraft after, cleared on sendMessage; new sessions start empty. Auto-resize height restored like the normal input handler. Tests cover switch-away/switch-back restore and send-clears-draft in both directions.

Regression safety noted: open-session dialog's internal '+ 新对话' entry and no-projectPath fallbacks keep working (unchanged paths). Tests: 4 new renderer smoke (59→63, GUI 179→183) with positive+negative assertions; pytest 687 unchanged; doc counts synced across README.md/README.cn.md/Agent.md. Also includes the evolution_prompt quick-ref entry for merged #655 — good pattern. No issues found.

@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-222517 (3rd consecutive ✅, no ❌ interleaved)

Re-verified: head 3849d3a unchanged; diff 9 files +126/−7 (B1 new-chat-btn+⌘N→showNewSessionDialog / B2 #open-chat-btn entry / B3 per-session drafts Map + save/restore + send-clear + new-empty; i18n zh/en; CSS; 4 renderer.smoke tests; doc counts 179→183); quick-ref #655 entry included; CI test SUCCESS (run 31397853180). Merge condition satisfied.

@argszero
argszero merged commit 9e907aa into master Aug 10, 2026
1 check passed
@pm25coder

Copy link
Copy Markdown
Contributor

I tested PR #656 end-to-end on Windows (fresh checkout of feature/gui-multisession-deviation-fix @ 3849d3a) — all green:

  • GUI: 183 tests (182 pass, 0 fail, 1 cancelled — the cancelled one is the pre-existing integration flake, same as on master) — matches the claimed 179→183 (renderer smoke 59→63)
  • pytest: 687 collected (632 passed + 55 pre-existing skips) — unchanged as claimed
  • doc guard: 3/3 PASS (tests/test_doc_counts.py); Agent.md/README/README.cn counts consistent (183 / 63 renderer smoke)
  • import + CLI: from emrg.client.app import run_client OK, python -m emrg --help OK
  • CI: test run 31397853180 PASS (was pending during my first check, now green)

Code review notes (all non-blocking):

  1. B1/B2 wiring is clean. The new-chat-btn / ⌘N rewire to Dialogs.showNewSessionDialog() and the new #open-chat-btnshowOpenSessionDialog() are minimal, and the ?. optional chain on the open-chat-btn binding keeps older HTML safe. The regression surface is well covered: the dialog-internal + 新建会话… entry and the delete/close-session newSession() fallbacks are untouched, and the B1 test's negative assertion (newSession NOT called directly) is exactly the right discriminating check.

  2. B3 draft semantics are sound. Save-before-switch / restore-after-IPC / clear-on-send covers the realistic flows; the !sid guard on saveDraft handles the first-session case; on a failed switchSession IPC the old session's draft is already saved in the map and the input still holds the text, so nothing is lost. restoreDraft's height clamp (Math.min(scrollHeight, 150)) mirrors the input handler — good.

  3. Draft lifetime is in-memory only — closing the GUI drops unsent drafts. That matches the pre-PR behavior (global singleton input was also lost on exit), so it's not a regression, but since P4 already persists open sessions + lastActive to gui_state.json, persisting drafts there too would be a natural future slice (browser-tab parity).

  4. sendMessage clears the draft before the IPC round-trip completes — if the send errors, the text is still recoverable from the chat as the user message, so no data loss; just noting the ordering in case a later slice wants a rollback path.

Thanks — the host-verified deviations are all addressed with good test discrimination.

@argszero
argszero deleted the feature/gui-multisession-deviation-fix branch August 10, 2026 14:26
argszero added a commit that referenced this pull request Aug 10, 2026
…ns B1-B3) (#657)

Co-authored-by: EMRG Evolution <emrg@argszero.dev>
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