fix(webui): persist Terminal/Chat/Program view selection per session#620
Merged
Conversation
The web UI view-mode selector (Terminal / Chat / Program) treated Program as a global mode: it lived only in the global `state.mode` and was never recorded in the per-session `viewModeById` map. Terminal/Chat were already per-session, but Program was not, so: - switching sessions while in Program carried Program onto the next session (via `selectSession`'s `state.mode === "program"` check) regardless of what that session last showed, and - a session you had left in Program reopened in Terminal/Chat, because its Program choice was never stored or restored. Make Program a real per-session preference, peer to Terminal and Chat (spec 0059): - include "program" in the load/save filters for `viewModeById`; - store "program" against the session when entering Program mode, and drop a stale "program" entry when a single-surface session leaves it; - `preferredViewModeForSession` returns "program" when stored (it wins for any session, since every session owns a Program); - `selectSession` restores the *incoming* session's preferred view instead of carrying the outgoing session's global `state.mode`; - `renderViewModeToggle` highlights the per-session preference so the toggle is correct mid-switch, before the new surface is entered. Add spec 0062 recording the per-session view-mode persistence semantic.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
In the web UI, the view-mode selector (Terminal / Chat / Program) didn't fully follow the focused session. Terminal and Chat were already per-session (stored in
viewModeById), but Program was treated as a global mode — it lived only in the globalstate.modeand was never written toviewModeById(both the load and save filters dropped"program").Two concrete symptoms:
selectSessionkeyed offstate.mode === "program"(the outgoing session's mode) instead of the incoming session's own preference — so a terminal/chat session would render as Program just because the previous session was in Program.Fix
Make Program a real per-session preference, peer to Terminal and Chat — which is exactly what spec 0059 already declares it to be ("a third per-session view mode, peer to Terminal and Chat"). The implementation simply wasn't honoring it.
"program"in theloadViewModePrefs/saveViewModePrefsfilters forviewModeById."program"against the current session when entering Program mode; drop a stale"program"entry when a single-surface session leaves Program (so it reverts to its natural surface).preferredViewModeForSessionreturns"program"when stored — it wins for any session, since every session owns a Program.selectSessionrestores the incoming session's preferred view, not the outgoing session's globalstate.mode.renderViewModeTogglehighlights the per-session preference (notstate.mode), so the toggle is correct during a switch, before the new surface is entered.The session-deleted handler already cleaned up
viewModeById, so removed sessions still drop their stored preference.Behavior after
Each session independently remembers Terminal / Chat / Program and reopens in that view when you switch back to it. New sessions still default to their natural surface (Terminal for PTY-backed, otherwise Chat).
Spec
Adds
specs/0062-webui-view-mode-is-per-session.mdrecording the per-session view-mode persistence/restore semantic so it isn't regressed back to a global toggle.Testing
cargo build(debug) green in the worktree.index.htmlisinclude_str!'d into the daemon, so it ships in theconstructbinary (construct daemon run).index.htmlpasses.Only touches
crates/daemon/assets/index.html(+ a new spec) → relevant binary isconstruct.