Match chat terminal buttons to responsive UI

Remove the duplicate terminal action from narrow shell bars and expose the terminal in open chat bars only where appropriate. Use the shared plain bar-button styling and add focused light/dark responsive widget coverage.
This commit is contained in:
2026-11-12 02:16:23 +00:00
parent 2330f50268
commit a233733966
9 changed files with 459 additions and 8 deletions
+9
View File
@@ -8,6 +8,7 @@ import '../features/terminal/terminal_machines.dart';
import '../features/terminal/terminal_surface.dart';
import '../features/terminal/terminal_toggle_button.dart';
import '../features/terminal/terminal_window.dart';
import '../shell/list_detail_policy.dart';
import '../shell/windows/window_manager.dart';
/// The app's machine terminals: one hub over every connected machine (the
@@ -66,6 +67,14 @@ class AppTerminals {
/// The bar button showing or hiding the terminal.
Widget toggle() => TerminalToggleButton(layout: layout);
/// The Chat tab's shell-bar button. Only a wide layout shows the shell bar
/// over an open chat, so only there is it kept. A narrow layout has none:
/// its open chat's own bar carries the terminal (see
/// `terminalChatBarAction`), and a chat list's bar has none (the shortcut
/// still shows the terminal).
Widget? barToggle(BuildContext context) =>
showsListBesideDetail(context) ? toggle() : null;
void dispose() {
floating?.dispose();
hub.dispose();
+3 -2
View File
@@ -820,13 +820,14 @@ class _PipelinesAppState extends State<PipelinesApp>
final runsRoute = tab(AppDestination.runs);
final chatRoute = tab(AppDestination.chat);
return AdaptiveShell(
// The terminal button sits on the Chat tab only; the keyboard
// The terminal button sits on the Chat tab's shell bar on wide layouts;
// a narrow layout has it in the chat's own bar instead. The keyboard
// shortcut still toggles the terminal everywhere.
barActions: [
// Shown on every tab while the app has floating windows.
WindowsMenuButton(manager: _windows),
if (_destinationOf(route.kind) == AppDestination.chat)
_terminals.toggle(),
?_terminals.barToggle(context),
],
attentionCount: counts.attention,
runningRunCount: counts.running,
@@ -1476,6 +1476,9 @@ class _ChatThreadViewState extends State<ChatThreadView> {
onPressed: _toggleFiles,
materialIcon: _filesVisible ? Icons.folder : Icons.folder_outlined,
),
// A narrow layout's terminal button, beside Files; wide keeps the
// shell bar's.
?terminalChatBarAction(context),
],
moreActions: [
?widget.sidebarControl,
@@ -3,9 +3,12 @@ import 'dart:async';
import 'package:flutter/material.dart';
import '../../core/api_gateway.dart';
import '../../shell/list_detail_policy.dart';
import '../../ui/adaptive/segmented_bar_overflow.dart';
import '../chat/ui/sessions/chat_adaptive.dart';
import 'terminal_hub.dart';
import 'terminal_scope.dart';
import 'terminal_toggle_button.dart';
/// The first time the terminal is shown in an app run it starts one
/// terminal, as New terminal does (it shows the machine's login prompt),
@@ -49,6 +52,23 @@ void openInTerminal(
);
}
/// The open chat's own bar button that shows or hides the terminal, on a
/// narrow layout. It is a plain [ChatBarAction] like Files and More, so it
/// matches them in style, size and states. A wide layout returns null: its
/// shell bar keeps the terminal button over the list column. Null too with
/// no terminal surface.
Widget? terminalChatBarAction(BuildContext context) {
if (showsListBesideDetail(context)) return null;
final actions = TerminalScope.maybeOf(context);
if (actions == null) return null;
return ChatBarAction(
label: TerminalToggleButton.label,
identifier: 'chat-terminal-toggle',
onPressed: actions.toggle,
materialIcon: Icons.terminal,
);
}
/// The chat actions menu's "Open in terminal" for the chat's folder, or
/// null when the app has no terminal surface or the chat no folder.
Widget? terminalOpenMenuAction(
@@ -6,6 +6,9 @@ import 'terminal_shortcuts.dart';
/// The shell bar's Terminal button: shows or hides the terminal (also
/// Alt+T, Ctrl+T, Cmd+T and Ctrl+`, where the platform delivers them).
///
/// It is a plain bar IconButton like Files and More: no selected tint, so
/// its shown state is announced to assistive technology only.
class TerminalToggleButton extends StatelessWidget {
const TerminalToggleButton({super.key, required this.layout});
@@ -22,12 +25,14 @@ class TerminalToggleButton extends StatelessWidget {
listenable: layout,
builder: (context, _) {
final shown = layout.visible;
return IconButton(
key: const ValueKey('shell.terminal'),
tooltip: label,
isSelected: shown,
onPressed: actions.toggle,
icon: const Icon(Icons.terminal),
return Semantics(
toggled: shown,
child: IconButton(
key: const ValueKey('shell.terminal'),
tooltip: label,
onPressed: actions.toggle,
icon: const Icon(Icons.terminal),
),
);
},
);