# Chat terminal buttons (narrow duplicate, bar styling) ## Findings (from the code and the ui-review captures) - The terminal toggle is the shell's bar action, passed as `barActions` from `application/pipelines_app.dart` on the Chat tab. The shell draws that bar only where it is not covered: - Wide (>= 600, `kListDetailMinWidth`): the shell bar sits over the list column while a chat is open, so the terminal shows there beside New chat and Refresh (capture: `Terminal (Option+T)` at x 287). The chat's own bar holds only Files and More. - Narrow (< 600): the open chat is a pushed page with its own bar (`ShellBar(barless: true)`), which covers the shell bar. A shell-bar terminal button therefore never shows on a phone chat, even though it was listed in `barActions`. This is why the first attempt (keeping it in `barActions` for an open chat) rendered nothing on phone. - Narrow chat list: the shell bar shows the toggle beside New chat and Refresh (the duplicate this change removes). - The styling difference: `TerminalToggleButton` passed `isSelected: shown`, which tints the icon while the terminal is shown. Files and More (`ChatBarAction`, `SegmentedMoreButton`) are plain IconButtons with no selected state. ## Changes - `lib/application/app_terminals.dart`: `barToggle(context)` returns the shell toggle only on a wide layout; null on narrow (chat list and open chat). - `lib/application/pipelines_app.dart`: the Chat tab's `barActions` uses `?_terminals.barToggle(context)`. - `lib/features/terminal/terminal_open_action.dart`: new `terminalChatBarAction(context)`: on narrow, with a terminal surface, a `ChatBarAction` (the same widget as Files) that toggles the terminal (identifier `chat-terminal-toggle`). Null on wide or without a surface. - `lib/features/chat/conversation/chat_thread_view.dart`: the chat header's actions are Files followed by `?terminalChatBarAction(context)`, so a narrow open chat shows the terminal beside Files. - `lib/features/terminal/terminal_toggle_button.dart`: drops `isSelected`; the shown state is exposed as `Semantics(toggled:)` only. ## Tests - `test/application/app_terminals_test.dart`: wide 1000 px offers the shell toggle; narrow 390 px offers none. - `test/features/terminal/terminal_chat_bar_action_test.dart`, light and dark: phone 390 px: the chat bar's terminal button is present, the same size as Files, the same icon colour, not selected, and tapping it toggles the terminal; wide 1000 px and no terminal surface: no chat-bar terminal button. - `test/features/terminal/terminal_toggle_button_test.dart`, light and dark: the shell's terminal button has no `isSelected`, its icon colour equals Files' in hidden and shown states, both are 48 px, and the shown state is announced as toggled. - Affected users re-run: `terminal_first_open_test.dart`, `terminal_surface_test.dart`, `chat_floating_chrome_test.dart`, `chat_floating_pane_test.dart`. ## Focused results `tool/memwatch/full.sh` with the seven paths above as one argument: 57 passed, 0 failed (peak 1877 MB, 53 s; verdict names only those paths). `tool/analyze.sh`: clean. ## Expected states (from the code; not captured here) - Phone chat list: no terminal in the bar; the shortcut bubble remains. - Phone open chat: the chat bar reads Files, terminal, More; the terminal is the same 48 px plain IconButton style as Files. - Wide chat list and wide open chat: placement unchanged; the shell bar's terminal button is plain (no selected tint). ## Not verified here - Rendered states at phone and desktop sizes, light and dark, and hover and pressed states: not captured (ui-review owns captures). - `pipelines_app.dart` wiring has no direct test. `test/application/pipelines_app_test.dart` fails on untouched main (pending launch-update timer), so it was not run.