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
+24 -6
View File
@@ -25,9 +25,11 @@ void main() {
const Rect.fromLTWH(100, 80, 360, 420),
);
expect(find.byTooltip('Probe action'), findsOneWidget);
for (final tip in ['Minimise', 'Maximise', 'Close']) {
for (final tip in ['Minimise', 'Maximise']) {
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);
// The title bar, the content and the app behind all keep their
// semantics (a page route's barrier hides what is behind it).
@@ -172,14 +174,30 @@ void main() {
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');
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();
expect(manager.windows, isEmpty);
expect(find.byType(ProbeContent, skipOffstage: false), findsNothing);
expect((manager.kinds['probe']! as ProbeWindowKind).closed_, [entry.id]);
expect(manager.windows.single.id, entry.id);
expect(manager.byId(entry.id)!.minimized, isTrue);
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', (
@@ -209,14 +209,17 @@ void main() {
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));
expect(find.text('Close'), findsOneWidget);
expect(find.text('Minimise'), findsOneWidget);
// Not clipped to the window: tooltips paint in an overlay as large
// as the app.
final overlay = tester.renderObject<RenderBox>(
find
.ancestor(of: find.text('Close'), matching: find.byType(Overlay))
.ancestor(
of: find.text('Minimise'),
matching: find.byType(Overlay),
)
.first,
);
expect(overlay.size, const Size(1280, 800));