fix(web): the Chat / Terminal switch is off by default

Owner decision for 1.52.1: the chat view's switch must not appear for
every desktop user on every local Claude session. showChatViewSwitch now
shows it only when true (an absent key means hidden), on both the reader
(_chatViewSwitchShown) and the App Settings checkbox. The chat view
itself was already off by default; Alt+Shift+C still switches views with
the switch hidden. Docs and tests follow; the two default tests fail
with the old !== false reader.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Codeman maintainer committed 2026-12-03 10:54:17 +01:00
1 parent 15ea44e5c1
commit 3994196341
6 files changed
+20 -18

No files matched your search

+3 -3
View File
@@ -24,9 +24,9 @@ Each Claude session gets two views of the same pane:
A toggle switches between them, and a keyboard shortcut does the same. The choice
is remembered per session on this device. The toggle floats at the top right of the
terminal. A second per-device setting shows or hides it. It shows by default, and a
user who never uses the chat view can turn it off. The shortcut still switches views
while the toggle is hidden. A per-device setting picks the view for every session
terminal. A second per-device setting shows or hides it. It is hidden by default
(owner decision for 1.52.1), so nobody sees the toggle without choosing it, and a user
who wants it turns it on. The shortcut still switches views while the toggle is hidden. A per-device setting picks the view for every session
this browser has no choice for yet, so a user who prefers chat never has to switch by
hand. The setting defaults to Terminal. Chat replaces the main view and still sends
some dialogs to the terminal in phase 1, so nobody gets it without choosing it.
+3 -3
View File
@@ -132,9 +132,9 @@ and the second pane of a split. Each session remembers its own choice in this br
Another browser or device opens the same session in its own default until you choose there too.
This setting decides only where a session with no choice of its own starts.
**Show the Chat / Terminal switch** (per device, on by default, never on phones) shows that switch
at the top right of a Claude session. Turn it off to keep the switch from covering the
terminal's corner. Each session keeps the view it had, and `Alt+Shift+C` still switches views.
**Show the Chat / Terminal switch** (per device, off by default, never on phones) shows that switch
at the top right of a Claude session. Turn it on to switch views with a click. Without it, each
session keeps the view it had, and `Alt+Shift+C` still switches views.
Most header chips default to off. The stock desktop header is system stats, File Viewer, Tiles, and the gear.
**Header Stats Style** picks how the system stats and plan usage are drawn: *Compact*
+1 -1
View File
@@ -14,7 +14,7 @@
**Tile grid** (`showTileGridButton`, header Tiles button + `Ctrl+Shift+G`, default ON on desktop and OFF on handhelds and touch-primary tablets (primary pointer coarse, `getDefaultSettings()`; a touchscreen laptop keeps ON), desktop-only at 1180px, per-device; tile-grid.js, design `docs/tile-grid-plan.md`): 1 to 6 live sessions side by side (the cap is ONE constant, `TILE_GRID_MAX` in constants.js, owner decision; the layout table still covers 7 to 9, unreachable), each a `TerminalTile` with a header (state dot, harness logo, name, model, menu, zoom, ×; no +, owner decision), laid out by count (`CodemanTileGrid`, constants.js) with draggable column/row dividers, zoom (tmux-style), an Attach overlay, and per-browser persistence (`codeman:tile-grid`, localStorage only: cells with `null` holes, `count`, focus, user zoom, divider fractions, never content; written on every change, kept by EVERY close, restored INSIDE `handleInit` in place of the single-view select, so the main terminal never loads on that page load). While the grid is open the main terminal is PARKED: `activeSessionId` is the focused tile's session, and every main-terminal path that would write, fetch, resize or reconnect stands aside through `_tilesOwnTerminal()` (the WebGL long-task observer included). ⚠️ Every capture a tile fetches (initial, reconnect refresh, `{t:'r'}`, history pull) goes through ONE `TileLoadQueue` (concurrency 1, a deadline covering the body), because each is a synchronous tmux call on the server. ⚠️ Only a USER-initiated pick of a non-tiled session (or `leaveTiles`, a followed link) leaves the grid; an `auto` selection never collapses it, and every app-driven fallback (close, delete, restore) picks a tile. A caller of `closeTileGrid({ reselect: false })` must null `activeSessionId` before any `_cleanupPreviousSession`, or the parked terminal's stale content is saved as a snapshot. ⚠️ The grid and the split are never open together. ⚠️ Tile chords go through `tileShortcutFor` and are swallowed in every xterm key handler BEFORE the Shift+Enter gate; the toggle follows `showTileGridButton` (owner decision: OFF makes the chord inert, it passes through like any unbound key). ⚠️ The Tiles button's click and Ctrl+Shift+G are ONE function, `toggleTileGrid` (owner decision): they open the grid AT ONCE on `tileGridOpenSet` (constants.js): the stored grid EXACTLY as the user left it (owner decision 11: `restoreTileGridCells`, never filled to the count nor trimmed to the window; a cell whose session is gone since is filled from the ranking, a hole the user made stays), else an open split's two, else the open sessions as `rankTileSessions` orders them (working first, keyed off `lastSubmitAt` ONLY, then needing input, then most recent; `_mobileOverviewState`'s states), the active one focused, filled to the remembered count (`codeman:tile-count`, default 6, at most `_tileGridLimit()`) by `tileGridSetForCount`, never a menu. ⚠️ `removeTile(..., { gone: true })` (a session deleted, popped out or refused) keeps the stored `count` so the next open refills that cell; a removal by hand lowers it. Right-click is the 2 / 4 / 6 count menu (`openTileCountMenu`, owner decision 10), which owns its Escape. The button has no native title: its hover card (`_installTileGridHint`, `#tileGridHint`) says it, is its `aria-describedby` (always present, hidden, kept current) and hides in the capture phase on any press, click or right-click, so the menu never opens beside it. ⚠️ The open, the count menu and the toggle's close animate opacity and transform only (the close leaves an inert cloned still copy until the single view's selection settles, at most 700 ms); nothing moves under `prefers-reduced-motion`. ⚠️ Opening builds one tile terminal per frame (`_connectTilesPaced`), so `openTileGrid` returns before the terminals exist: focus is handed over in `_connectTile` (`focusOnConnect`). ⚠️ A divider drag reflows locally per frame and sends ONE resize per affected tile at pointer-up. ⚠️ The grid is CELLS (owner: an empty cell can be any cell): `grid.cells` (id or `null`) is the one source of truth, `grid.ids` a derived getter, never written; the shape still comes from the tile count, a shape change goes through `fitTileCells`, and the stored `ids` carry the cells with `null` holes. ⚠️ A tile moves (its header dragged or its tab dropped onto another tile or an empty cell, `Ctrl+Shift+Arrows`) ONLY through `_reorderTiles`: never a remount, reconnect or reload, and since sizes belong to the cells only a tile whose cell size changed fits; off while a tile is zoomed. The header drag carries its own type, never text, and is not `draggedTabId`; the header focuses on click, never on press, so a cancelled drag changes nothing. The arrow chords skip text fields. ⚠️ Sessions Run from this tab join the open grid (`_joinTileGridFromRun`, called from `_ensureCreatedSessionVisible`); sessions created elsewhere never do. SuchLine truncated
**Chat view** (`chat-view.js`, per-device `chatViewDefault`, default OFF, never on phones; design in [`docs/chat-view-plan.md`](../../docs/chat-view-plan.md)): a local or Docker Claude session in the main view can show its conversation, read from the transcript, as text; to type, the user switches to the Terminal view. `chatViewEligible()` takes the modes whose CLI declares `transcript: 'claude-jsonl'` (`window.__codemanChatViewModes`, never a mode id) and refuses a remote or an adopted session and a phone. The per-device `showChatViewSwitch` (an ABSENT key means ON, read as `!== false`) hides only the Chat / Terminal switch; the view and Alt+Shift+C keep working. ⚠️ The terminal stays mounted, attached and sized under the chat layer, so switching views never resizes the PTY. Focus that lands on the hidden terminal moves to the conversation, and `body.chat-view-showing` hides the keyboard accessory bar and, on touch devices, the CJK input field while Chat shows, because both write into the pane. While the tile grid owns the terminal, the chat view is hidden whatever the session's choice (`_tilesOwnTerminal()`, synced from tile-grid.js). A pending `permission_prompt` or `elicitation_dialog` hook shows a notice whose button switches to the terminal. Codeman's keep-alive turn shows no status line. i18n.js skips the `data-i18n-skip` conversation, so the strings drawn there go through `_chatViewT()`. Tests: `test/chat-view.test.ts`, `test/chat-view-i18n.test.ts`.
**Chat view** (`chat-view.js`, per-device `chatViewDefault`, default OFF, never on phones; design in [`docs/chat-view-plan.md`](../../docs/chat-view-plan.md)): a local or Docker Claude session in the main view can show its conversation, read from the transcript, as text; to type, the user switches to the Terminal view. `chatViewEligible()` takes the modes whose CLI declares `transcript: 'claude-jsonl'` (`window.__codemanChatViewModes`, never a mode id) and refuses a remote or an adopted session and a phone. The per-device `showChatViewSwitch` (default OFF, owner decision for 1.52.1: only an explicit `true` shows the switch, read as `=== true`, so nobody sees it without choosing it) shows or hides only the Chat / Terminal switch; the view and Alt+Shift+C work either way. ⚠️ The terminal stays mounted, attached and sized under the chat layer, so switching views never resizes the PTY. Focus that lands on the hidden terminal moves to the conversation, and `body.chat-view-showing` hides the keyboard accessory bar and, on touch devices, the CJK input field while Chat shows, because both write into the pane. While the tile grid owns the terminal, the chat view is hidden whatever the session's choice (`_tilesOwnTerminal()`, synced from tile-grid.js). A pending `permission_prompt` or `elicitation_dialog` hook shows a notice whose button switches to the terminal. Codeman's keep-alive turn shows no status line. i18n.js skips the `data-i18n-skip` conversation, so the strings drawn there go through `_chatViewT()`. Tests: `test/chat-view.test.ts`, `test/chat-view-i18n.test.ts`.
**Terminal touch gestures: link taps and text selection**: on touch devices xterm's linkifier and SelectionService never see the gesture, so both are driven explicitly (terminal-ui.js). ⚠️ A tap activates the link under it through the SAME provider as the hover linkifier (`_terminalLinkAtPoint`), synchronously inside `touchend` (keeps the user gesture `window.open` needs) and BEFORE any mouse report; the caret's logical line (`_tapIsOnCaretLine`) and TUI-owned rows (`_isActionableMobileTerminalTap`) keep their meaning. ⚠️ Gate on the caret line, never on tap intent (a shell calls every tap `'input'`). ⚠️ Long-press selects via xterm's public `select()`; keep the three guards: suppress the compat mouse pair after `touchend`, the bounded focus guard + `contextmenu` suppression for the platform long-press, and no closing `terminal.focus()` on phones. ⚠️ A sideways drag belongs to the session swipe (`SwipeHandler`, mobile-handlers.js): the touch handler locks the dominant axis on the first travel past the tap slop (`panAxis`: `y` scrolls, `x` pans a terminal wider than its box, `swipe` otherwise) and publishes it as `app._terminalGestureAxis`; a `swipe` drag neither scrolls nor ends as a tap on the session being left until it passes the swipe's own vertical drift limit (`SwipeHandler.maxVerticalDrift`), where it is handed back to the scroll as `y` (a scroll that opens on a thumb arc), and the swipe stands aside for `x`/`y`, a touch selection, a second finger and surfaces with controls of their own (`IGNORE_SELECTOR`; the phone overview and welcome screen are deliberately not listed). A swipe is 80 px within 500 ms with at most 50 px of vertical drift at any point; a touch starting outside the terminal (the home screen) resets the published axis, and a lift the terminal consumed (`defaultPrevented`, its selection gesture) is never a swipe (`test/session-swipe-gesture.test.ts`). Tests: `test/terminal-touch-tap.test.ts`. → [architecture-invariants#terminal-touch-gestures-link-taps-and-text-selection](../../docs/architecture-invariants.md#terminal-touch-gestures-link-taps-and-text-selection)
+6 -5
View File
@@ -12,9 +12,10 @@
* - Which view a session shows: the per-device choice remembered for that session
* (`codeman:chatViewModes` in localStorage), else the per-device setting `chatViewDefault`
* (default off, so a session opens in Terminal until the user picks Chat).
* - The Chat / Terminal switch: shown on an eligible session unless the per-device setting
* `showChatViewSwitch` is false (an absent key means shown). Hiding it changes nothing else:
* the session keeps its view, and Alt+Shift+C still switches.
* - The Chat / Terminal switch: shown on an eligible session only when the per-device setting
* `showChatViewSwitch` is true (default off: an absent key means hidden, so nobody sees the
* switch without choosing it). Hidden, it changes nothing else: the session keeps its view,
* and Alt+Shift+C still switches.
* - Live updates: the conversation is re-read (debounced) on the session's `transcript:update`,
* `session:working` and `session:idle`. Nothing is read while the chat view is hidden.
* - Typing: the chat view has no message box yet, so the user types in the terminal. A focus
@@ -107,9 +108,9 @@ Object.assign(CodemanApp.prototype, {
if (Object.keys(kept).length !== Object.keys(modes).length) this._chatViewStoreModes(kept);
},
/** Whether this device shows the Chat / Terminal switch. An absent setting means it does. */
/** Whether this device shows the Chat / Terminal switch. Off by default: an absent setting means it does not. */
_chatViewSwitchShown() {
return this.loadAppSettingsFromStorage?.().showChatViewSwitch !== false;
return this.loadAppSettingsFromStorage?.().showChatViewSwitch === true;
},
/** The Alt+Shift+C action: flip the active session between Chat and Terminal. */
+1 -1
View File
@@ -620,7 +620,7 @@ Object.assign(CodemanApp.prototype, {
document.getElementById('appSettingsShowEditHistory').checked = settings.showEditHistory ?? defaults.showEditHistory ?? false;
document.getElementById('appSettingsChatViewDefault').checked = settings.chatViewDefault === true;
// Absent means ON: the switch shows until this device turns it off.
document.getElementById('appSettingsShowChatViewSwitch').checked = settings.showChatViewSwitch !== false;
document.getElementById('appSettingsShowChatViewSwitch').checked = settings.showChatViewSwitch === true;
// Gesture control lives in the Input section (alongside Local Echo / CJK Input)
// but is only available when the instance runs with CODEMAN_GESTURE=1 (server sets
// window.__codemanGestureAvailable). Hide just this item otherwise so the toggle
+6 -5
View File
@@ -279,7 +279,8 @@ describe('chat view module', () => {
const { win, app } = loadModule({ messages: [[{ role: 'user', text: 'Hi', turn: 1 }]] });
app.onChatViewActiveSession('s1');
expect(app.chatViewModeFor('s1')).toBe('terminal');
expect(app._chatView.toggle.hidden).toBe(false);
// The switch is off by default (no showChatViewSwitch on this device); its own tests are below.
expect(app._chatView.toggle.hidden).toBe(true);
expect(app._chatView.root.hidden).toBe(true);
app.setChatViewMode('s1', 'chat');
@@ -324,11 +325,11 @@ describe('chat view module', () => {
expect(init).toContain('this._chatViewPruneModes?.(new Set(data.sessions.map((s) => s.id)));');
});
it('shows the Chat / Terminal switch when the device has no showChatViewSwitch setting', () => {
it('hides the Chat / Terminal switch when the device has no showChatViewSwitch setting (off by default)', () => {
const { app } = loadModule();
app.loadAppSettingsFromStorage = () => ({});
app.onChatViewActiveSession('s1');
expect(app._chatView.toggle.hidden).toBe(false);
expect(app._chatView.toggle.hidden).toBe(true);
app.loadAppSettingsFromStorage = () => ({ showChatViewSwitch: true });
app._chatViewSync();
expect(app._chatView.toggle.hidden).toBe(false);
@@ -774,12 +775,12 @@ describe('chat view wiring', () => {
expect(schemas).not.toContain('chatViewDefault');
});
it('keeps showChatViewSwitch per device, out of the server PUT, and on when absent', () => {
it('keeps showChatViewSwitch per device, out of the server PUT, and off when absent', () => {
const settings = read('settings-ui.js');
expect(settings).toMatch(/'showEditHistory', 'chatViewDefault', 'showChatViewSwitch',/);
expect(settings).toContain('showChatViewSwitch: _scvs,');
expect(settings).toContain(
"document.getElementById('appSettingsShowChatViewSwitch').checked = settings.showChatViewSwitch !== false;"
"document.getElementById('appSettingsShowChatViewSwitch').checked = settings.showChatViewSwitch === true;"
);
const schemas = readFileSync(resolve(import.meta.dirname, '../src/web/schemas.ts'), 'utf8');
expect(schemas).not.toContain('showChatViewSwitch');