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
@@ -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),
),
);
},
);