Make floating-window close buttons minimise

Remove the separate minimise control and make the title-bar X hide windows while preserving their state and reachability. Update window behavior documentation and focused tests for chat, terminal, and window layering.
This commit is contained in:
2026-11-12 01:45:42 +00:00
parent 2330f50268
commit e4f3ebdcab
12 changed files with 123 additions and 43 deletions
@@ -17,7 +17,7 @@ const _terminalContent = 'terminal';
/// ///
/// [TerminalLayout] stays the terminal's own state (shown, panel or float): /// [TerminalLayout] stays the terminal's own state (shown, panel or float):
/// showing it in float mode opens or shows the window, hiding minimises it, /// showing it in float mode opens or shows the window, hiding minimises it,
/// and the window's Minimise and Close hide the terminal. /// and the window's X (minimise) hides the terminal.
class TerminalWindows { class TerminalWindows {
TerminalWindows({ TerminalWindows({
required this.manager, required this.manager,
@@ -110,7 +110,7 @@ class TerminalWindows {
if (legacy && layout.maximized) manager.setMaximized(entry.id, true); if (legacy && layout.maximized) manager.setMaximized(entry.id, true);
} }
/// The window's Minimise or Close (or the windows' own show and hide) /// The window's X or Minimise (or the windows' own show and hide)
/// hides the terminal. /// hides the terminal.
void _windowsChanged() { void _windowsChanged() {
if (!_started || !_ready || _syncing || !_wanted) return; if (!_started || !_ready || _syncing || !_wanted) return;
+1 -1
View File
@@ -37,7 +37,7 @@ class WindowEntry {
/// The saved frame; it is drawn fitted inside the window area. /// The saved frame; it is drawn fitted inside the window area.
final Rect frame; final Rect frame;
/// Hidden by its minimise button; still listed and shown again with its /// Hidden by the title bar's X; still listed and shown again with its
/// group. /// group.
final bool minimized; final bool minimized;
final bool maximized; final bool maximized;
+7 -11
View File
@@ -11,8 +11,9 @@ double windowTitleBarHeight(BuildContext context) =>
MediaQuery.textScalerOf(context).scale(40).clamp(40.0, 64.0); MediaQuery.textScalerOf(context).scale(40).clamp(40.0, 64.0);
/// A floating window's card and title bar: the title (drag to move, double /// A floating window's card and title bar: the title (drag to move, double
/// click to maximise), the kind's actions, then Minimise, Maximise and /// click to maximise), the kind's actions, then Maximise and the X. The X
/// Close. The content is drawn over the card's body by the window's /// minimises: it hides the window and keeps its state, like the chord does
/// in reverse. The content is drawn over the card's body by the window's
/// navigator. /// navigator.
class WindowFrame extends StatelessWidget { class WindowFrame extends StatelessWidget {
const WindowFrame({ const WindowFrame({
@@ -25,7 +26,6 @@ class WindowFrame extends StatelessWidget {
required this.onMoveEnd, required this.onMoveEnd,
required this.onMinimize, required this.onMinimize,
required this.onToggleMaximized, required this.onToggleMaximized,
required this.onClose,
}); });
final String title; final String title;
@@ -36,9 +36,10 @@ class WindowFrame extends StatelessWidget {
/// The drag's delta and the pointer's global position. /// The drag's delta and the pointer's global position.
final void Function(Offset delta, Offset globalPosition) onMove; final void Function(Offset delta, Offset globalPosition) onMove;
final VoidCallback onMoveEnd; final VoidCallback onMoveEnd;
/// The X: hides the window, keeping it listed and its state.
final VoidCallback onMinimize; final VoidCallback onMinimize;
final VoidCallback onToggleMaximized; final VoidCallback onToggleMaximized;
final VoidCallback onClose;
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
@@ -69,11 +70,6 @@ class WindowFrame extends StatelessWidget {
onPressed: action.onPressed, onPressed: action.onPressed,
icon: Icon(action.icon), icon: Icon(action.icon),
), ),
IconButton(
tooltip: 'Minimise',
onPressed: onMinimize,
icon: const Icon(Icons.minimize),
),
IconButton( IconButton(
tooltip: maximized ? 'Restore size' : 'Maximise', tooltip: maximized ? 'Restore size' : 'Maximise',
onPressed: onToggleMaximized, onPressed: onToggleMaximized,
@@ -82,8 +78,8 @@ class WindowFrame extends StatelessWidget {
), ),
), ),
IconButton( IconButton(
tooltip: 'Close', tooltip: 'Minimise',
onPressed: onClose, onPressed: onMinimize,
icon: const Icon(Icons.close), icon: const Icon(Icons.close),
), ),
const SizedBox(width: 4), const SizedBox(width: 4),
+3 -3
View File
@@ -2,7 +2,7 @@ import 'package:flutter/widgets.dart';
import 'window_entry.dart'; import 'window_entry.dart';
/// One action in a window's title bar, before Minimise and Close (Dock on a /// One action in a window's title bar, before Maximise and the X (Dock on a
/// chat, a kind's own menu). /// chat, a kind's own menu).
class WindowAction { class WindowAction {
const WindowAction({ const WindowAction({
@@ -42,7 +42,7 @@ abstract class WindowKind {
/// The window's content, below the title bar. /// The window's content, below the title bar.
Widget build(BuildContext context, WindowEntry entry); Widget build(BuildContext context, WindowEntry entry);
/// Title-bar actions before Minimise and Close. /// Title-bar actions before Maximise and the X.
List<WindowAction> actions(BuildContext context, WindowEntry entry) => List<WindowAction> actions(BuildContext context, WindowEntry entry) =>
const []; const [];
@@ -57,7 +57,7 @@ abstract class WindowKind {
/// as its window takes focus. The default leaves it on the window. /// as its window takes focus. The default leaves it on the window.
void focusContent(WindowEntry entry) {} void focusContent(WindowEntry entry) {}
/// Called after the user closes the window (the X). /// Called after the window is closed (Dock, Close all, a chat's /close).
void closed(WindowEntry entry) {} void closed(WindowEntry entry) {}
/// Validates a saved window's [WindowEntry.data]; null drops the window. /// Validates a saved window's [WindowEntry.data]; null drops the window.
-1
View File
@@ -259,7 +259,6 @@ class _WindowLayerState extends State<WindowLayer>
onMinimize: () => manager.setMinimized(_id, true), onMinimize: () => manager.setMinimized(_id, true),
onToggleMaximized: () => onToggleMaximized: () =>
manager.setMaximized(_id, !entry.maximized), manager.setMaximized(_id, !entry.maximized),
onClose: () => manager.close(_id),
), ),
), ),
), ),
+6 -5
View File
@@ -15,13 +15,14 @@ every destination and come back at app start without Chat being opened.
chat's window last was, else at the default frame stepped 32 px per chat chat's window last was, else at the default frame stepped 32 px per chat
window already open. window already open.
- **Window**: drag the title bar to move, the lower right corner to resize, - **Window**: drag the title bar to move, the lower right corner to resize,
double click the title to maximise. The title bar has Dock, Minimise, double click the title to maximise. The title bar has Dock, Maximise and
Maximise and Close. the X.
- **Dock** puts the chat back into the tiling, right of the active pane. When - **Dock** puts the chat back into the tiling, right of the active pane. When
the Chat destination is not built it opens the chat there instead. the Chat destination is not built it opens the chat there instead.
- **Minimise** hides that window; the chord brings it back. - **X** (tooltip and semantics: Minimise) hides that window, keeping its state;
- **Close (X)** closes the window and returns nothing to the tiling. The chat it stays listed in the Windows menu and the chord brings it back. It never
itself is not closed on the server. closes the window, the chat or the tiling: nothing returns to the tiling.
The chat itself is not closed on the server.
- **Chord**: Alt+Y, Ctrl+Y, and Cmd+Y on Apple platforms (`chatFloatShortcut`). - **Chord**: Alt+Y, Ctrl+Y, and Cmd+Y on Apple platforms (`chatFloatShortcut`).
With chat windows open it hides or shows all of them. With none it floats the With chat windows open it hides or shows all of them. With none it floats the
active tiled pane, when that pane can float and Chat has the keyboard; active tiled pane, when that pane can float and Chat has the keyboard;
+4 -3
View File
@@ -15,7 +15,8 @@ mode (below). `FloatingLayer`, the overlay the old windows used, is gone.
- `WindowHost`: the windows as plain children of the terminal stage's stack, in - `WindowHost`: the windows as plain children of the terminal stage's stack, in
the shell page (not an overlay above it), outside every destination. the shell page (not an overlay above it), outside every destination.
- `WindowLayer` / `WindowFrame`: one window's card, title bar (drag, double - `WindowLayer` / `WindowFrame`: one window's card, title bar (drag, double
click to maximise, kind actions, Minimise, Maximise, Close) and resize corner. click to maximise, kind actions, Maximise, the X = minimise) and resize corner.
There is no separate Minimise button; the X hides the window and keeps it.
- `WindowNavigator`: each window's own page stack. - `WindowNavigator`: each window's own page stack.
- `WindowFocus`: a focus scope per window; the keyboard follows the top window - `WindowFocus`: a focus scope per window; the keyboard follows the top window
and returns to what had it when the last one hides. and returns to what had it when the last one hides.
@@ -73,8 +74,8 @@ the device, not a server) and `TerminalWindows`, which keeps it in step with
float, panel height); the bottom panel is still a shell panel. float, panel height); the bottom panel is still a shell panel.
- Showing the terminal in float mode opens or shows the window; hiding it - Showing the terminal in float mode opens or shows the window; hiding it
(Alt+T, Ctrl+`, the options menu) minimises it. The window's Minimise and (Alt+T, Ctrl+`, the options menu) minimises it. The window's X (minimise)
Close both hide the terminal. Its shells and tabs live in `TerminalHub`, so hides the terminal. Its shells and tabs live in `TerminalHub`, so
nothing is lost either way, and the window comes back where it was. nothing is lost either way, and the window comes back where it was.
- The frame and maximised state are the window system's. The first window - The frame and maximised state are the window system's. The first window
takes the ones `pipelines.terminal-layout.v1` saved before; that record is takes the ones `pipelines.terminal-layout.v1` saved before; that record is
+55
View File
@@ -0,0 +1,55 @@
# Window X minimises (no separate Minimise button)
## Change
- The title bar of a floating window is now: kind actions (Dock on a chat),
Maximise / Restore size, then the X.
- The X hides the window and keeps its state, exactly as Minimise did. Its
tooltip and semantics are `Minimise`. It keeps the X glyph (`Icons.close`).
- The X never calls the kind's `closed` hook, so a chat window keeps its chat
open on the server and returns nothing to the tiling.
- `WindowFrame` no longer takes `onClose`; `WindowLayer` wires the X to
`manager.setMinimized(id, true)`.
- Unchanged: the chord (Alt+Y) shows hidden chat windows; the Windows menu
still lists minimised windows with a minimise mark and shows them on choice;
Show all, Minimise all and Close all stay in that menu. Terminal windows
still hide the terminal when their window is hidden by the X.
Changed paths (under `app/`):
- `lib/shell/windows/window_frame.dart`, `window_layer.dart`, `window_kind.dart`,
`window_entry.dart` (comments and the frame's parameters)
- `lib/features/terminal/terminal_window.dart` (comment only)
- `test/shell/windows/window_host_test.dart`, `window_layering_test.dart`
- `test/features/chat/chat_floating_pane_test.dart`
- `test/features/terminal/terminal_surface_test.dart`
- `notes/floating-windows.md`, `notes/chat-floating-pane.md`
## Focused results
- `tool/memwatch/full.sh 'test/shell/windows/window_host_test.dart
test/shell/windows/window_layering_test.dart
test/shell/windows/window_conveniences_test.dart
test/features/chat/chat_floating_pane_test.dart
test/features/terminal/terminal_surface_test.dart'`:
PASS, 72 passed, 0 failed, 0 skipped, exit 0.
- `tool/analyze.sh`: clean, exit 0.
- Not run: the full suite (the land gate runs it). No Cupertino code or tests
touched.
## Affected states (widget-test coverage only)
- Window title bar: no `Close` tooltip; `Minimise` on the X; `Maximise` /
`Restore size` unchanged.
- Chat window: X hides it; the chat stays open, is not docked and sends no
`chat_close`; the chord shows it again with the same frame and composer.
- Probe window: X keeps the entry (minimised), the content state survives, and
the group toggle brings it back.
- Terminal float window: X hides the terminal and keeps its tabs; the chord
shows it again at the same frame.
## Limitations
- No browser or device capture here; `ui-review` owns the title-bar captures.
- The X glyph with a Minimise tooltip is a deliberate choice; a minimise glyph
would be a one-line change in `window_frame.dart` if preferred.
@@ -390,19 +390,24 @@ void main() {
await app.stop(tester); await app.stop(tester);
}); });
testWidgets('X closes the window and returns nothing to the tiling', ( testWidgets('X minimises the window: the chat stays open, returns nothing '
tester, 'to the tiling, and the chord brings the window back', (tester) async {
) async {
await _saved('a', 'b'); await _saved('a', 'b');
final app = _App(_Store()); final app = _App(_Store());
await app.start(tester); await app.start(tester);
await _menu(tester, 'b', 'Float (Alt+Y)'); await _menu(tester, 'b', 'Float (Alt+Y)');
await tester.tap(find.byTooltip('Close')); await tester.tap(find.byTooltip('Minimise'));
await tester.pumpAndSettle(); await tester.pumpAndSettle();
expect(app.floating, isEmpty); // Still a window, hidden; not closed and not docked.
expect(app.floating, ['b']);
expect(app.windows.windows.single.minimized, isTrue);
expect(_shown('Chat b'), findsNothing);
expect(_workspace(tester).panes.map((p) => p.sessionId), ['a']); expect(_workspace(tester).panes.map((p) => p.sessionId), ['a']);
expect(_thread('b'), findsNothing);
expect(app.gateway.calls.where((c) => c.type == 'chat_close'), isEmpty); expect(app.gateway.calls.where((c) => c.type == 'chat_close'), isEmpty);
await _chord(tester);
expect(_shown('Chat b'), findsOneWidget);
expect(_thread('b').hitTestable(), findsOneWidget);
expect(app.floating, ['b']);
await app.stop(tester); await app.stop(tester);
}); });
@@ -167,10 +167,12 @@ void main() {
expect(floatFinder, findsOneWidget); expect(floatFinder, findsOneWidget);
expect(frame().size, start.size + const Offset(80, 50)); expect(frame().size, start.size + const Offset(80, 50));
await tester.tap(find.byTooltip('Close')); // The X minimises too: the window stays listed, hidden, with its shells.
await tester.tap(find.byTooltip('Minimise'));
await tester.pumpAndSettle(); await tester.pumpAndSettle();
expect(layout.visible, isFalse); expect(layout.visible, isFalse);
expect(manager.windows, isEmpty); expect(manager.windows.single.minimized, isTrue);
expect(floatFinder, findsNothing);
expect(hub.tabs, hasLength(2)); expect(hub.tabs, hasLength(2));
await ctrlBacktick(tester); await ctrlBacktick(tester);
expect(floatFinder, findsOneWidget); expect(floatFinder, findsOneWidget);
+24 -6
View File
@@ -25,9 +25,11 @@ void main() {
const Rect.fromLTWH(100, 80, 360, 420), const Rect.fromLTWH(100, 80, 360, 420),
); );
expect(find.byTooltip('Probe action'), findsOneWidget); expect(find.byTooltip('Probe action'), findsOneWidget);
for (final tip in ['Minimise', 'Maximise', 'Close']) { for (final tip in ['Minimise', 'Maximise']) {
expect(find.byTooltip(tip), findsOneWidget); expect(find.byTooltip(tip), findsOneWidget);
} }
// There is no separate Minimise button: the X is the one minimise.
expect(find.byTooltip('Close'), findsNothing);
expect(find.text('sheet').hitTestable(), findsOneWidget); expect(find.text('sheet').hitTestable(), findsOneWidget);
// The title bar, the content and the app behind all keep their // The title bar, the content and the app behind all keep their
// semantics (a page route's barrier hides what is behind it). // semantics (a page route's barrier hides what is behind it).
@@ -172,14 +174,30 @@ void main() {
expect(find.text('typed'), findsOneWidget); expect(find.text('typed'), findsOneWidget);
}); });
testWidgets('X closes the window', (tester) async { testWidgets('X minimises the window and never closes it', (tester) async {
final entry = manager.open('probe', 'a'); final entry = manager.open('probe', 'a');
await pumpProbe(tester, manager); await pumpProbe(tester, manager);
await tester.tap(find.byTooltip('Close')); await tester.enterText(find.byKey(const ValueKey('a-field')), 'kept');
final state = tester.state<ProbeContentState>(find.byType(ProbeContent));
await tester.tap(find.byTooltip('Minimise'));
await tester.pumpAndSettle(); await tester.pumpAndSettle();
expect(manager.windows, isEmpty); expect(manager.windows.single.id, entry.id);
expect(find.byType(ProbeContent, skipOffstage: false), findsNothing); expect(manager.byId(entry.id)!.minimized, isTrue);
expect((manager.kinds['probe']! as ProbeWindowKind).closed_, [entry.id]); expect(find.text('Probe a').hitTestable(), findsNothing);
// Not a close: the kind's closed hook does not run, and the content
// stays alive with its state.
expect((manager.kinds['probe']! as ProbeWindowKind).closed_, isEmpty);
expect(
tester.state<ProbeContentState>(
find.byType(ProbeContent, skipOffstage: false),
),
same(state),
);
// Listed and brought back by the group, as Minimise always was.
manager.toggleGroup('probe');
await tester.pumpAndSettle();
expect(find.text('Probe a').hitTestable(), findsOneWidget);
expect(find.text('kept'), findsOneWidget);
}); });
testWidgets('pressing a window brings it to the top and keeps both alive', ( testWidgets('pressing a window brings it to the top and keeps both alive', (
@@ -209,14 +209,17 @@ void main() {
probeTooltipColor, probeTooltipColor,
); );
await mouse.moveTo(tester.getCenter(find.byTooltip('Close').last)); await mouse.moveTo(tester.getCenter(find.byTooltip('Minimise').last));
await tester.pumpAndSettle(const Duration(seconds: 1)); await tester.pumpAndSettle(const Duration(seconds: 1));
expect(find.text('Close'), findsOneWidget); expect(find.text('Minimise'), findsOneWidget);
// Not clipped to the window: tooltips paint in an overlay as large // Not clipped to the window: tooltips paint in an overlay as large
// as the app. // as the app.
final overlay = tester.renderObject<RenderBox>( final overlay = tester.renderObject<RenderBox>(
find find
.ancestor(of: find.text('Close'), matching: find.byType(Overlay)) .ancestor(
of: find.text('Minimise'),
matching: find.byType(Overlay),
)
.first, .first,
); );
expect(overlay.size, const Size(1280, 800)); expect(overlay.size, const Size(1280, 800));