Terminal round 3: readable palettes, panel and card sizing, rail, tabs
- Colours: terminal background is the theme's lowest surface; the 16 ANSI colours come from a chosen palette (Theme colours, Classic, Calm, Vivid; Settings > Terminal > Colours, saved as `palette`) adjusted in lightness to the background: colours 4.5:1, bright ones lighter than normal, white light and black dark in both themes so white-on-red/blue/magenta and black-on-green/yellow/cyan (ls setuid, setgid, sticky) keep 3:1. Selection, find matches and the current match keep text at 4.5:1. - Bottom panel opens at 40% of the window, at least 16 rows, until dragged; the dragged height is remembered (old saved 300 px default reads as never resized). - Navigation rail scrolls its tabs (and below 240 px Settings too), so items never overlap under a tall panel. - Chat command cards: Expand / Collapse grows a live terminal to 60% of the window (finished output only to its rows); collapsed stays 12 rows. - Terminal tabs: ellipsised titles (220 px) with the whole title in the tooltip, selected tab filled, outlined and bold, close buttons are IconButtons (48 px touch, 40 px desktop). - Capture fixture: ?terminalColors=1 and ?terminalPalette=. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -7,6 +7,8 @@ import 'package:pipelines_app/features/terminal/terminal_layout.dart';
|
||||
import 'terminal_app.dart';
|
||||
import 'terminal_fixtures.dart';
|
||||
|
||||
const double _height = 300;
|
||||
|
||||
void main() {
|
||||
late TerminalGateway mac;
|
||||
late TerminalHub hub;
|
||||
@@ -15,14 +17,15 @@ void main() {
|
||||
setUp(() {
|
||||
mac = TerminalGateway()..add('term_a', cwd: '/Users/op/src');
|
||||
hub = TerminalHub(TestMachines([machine('mac', mac, name: 'Mac')]));
|
||||
layout = TerminalLayout(store: MemoryLayoutStore());
|
||||
// A set height keeps the motion's arithmetic simple.
|
||||
layout = TerminalLayout(store: MemoryLayoutStore())..panelHeight = _height;
|
||||
});
|
||||
tearDown(() async {
|
||||
hub.dispose();
|
||||
await mac.close();
|
||||
});
|
||||
|
||||
const shown = 800 - terminalPanelDefaultHeight;
|
||||
const shown = 800 - _height;
|
||||
double appBottom(WidgetTester tester) =>
|
||||
tester.getRect(find.byType(Scaffold).first).bottom;
|
||||
double panelOpacity(WidgetTester tester) => tester
|
||||
@@ -55,7 +58,7 @@ void main() {
|
||||
// panel (at its full height) is partly below the window's edge.
|
||||
expect(appBottom(tester), inExclusiveRange(shown, 800));
|
||||
expect(tester.getRect(panelFinder).top, closeTo(appBottom(tester), 1));
|
||||
expect(tester.getSize(panelFinder).height, terminalPanelDefaultHeight);
|
||||
expect(tester.getSize(panelFinder).height, _height);
|
||||
expect(panelOpacity(tester), inExclusiveRange(0.4, 1));
|
||||
await tester.pumpAndSettle();
|
||||
expect(appBottom(tester), shown);
|
||||
|
||||
@@ -0,0 +1,133 @@
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:pipelines_app/features/terminal/terminal_hub.dart';
|
||||
import 'package:pipelines_app/features/terminal/terminal_layout.dart';
|
||||
import 'package:pipelines_app/features/terminal/terminal_panel.dart';
|
||||
import 'package:pipelines_app/features/terminal/terminal_tab_chip.dart';
|
||||
|
||||
import 'terminal_app.dart';
|
||||
import 'terminal_fixtures.dart';
|
||||
|
||||
/// The bottom panel's default height (40 % of the window, at least 16 rows)
|
||||
/// and the tab strip's tabs: long titles ellipsised with the whole title in
|
||||
/// the tooltip, the selected tab marked, close buttons of touch size.
|
||||
void main() {
|
||||
late TerminalGateway mac;
|
||||
late TerminalHub hub;
|
||||
late TerminalLayout layout;
|
||||
|
||||
setUp(() {
|
||||
mac = TerminalGateway()
|
||||
..add('term_a', cwd: '/Users/op/src', text: r'$ ')
|
||||
..add(
|
||||
'term_b',
|
||||
cwd: '/Users/op/a/rather/deep/folder/with/a/long/name/that/goes/on',
|
||||
text: r'$ ',
|
||||
);
|
||||
layout = TerminalLayout(store: MemoryLayoutStore())..visible = true;
|
||||
hub = TerminalHub(
|
||||
TestMachines([machine('mac', mac, name: 'Mac')]),
|
||||
layout: layout,
|
||||
);
|
||||
});
|
||||
tearDown(() async {
|
||||
hub.dispose();
|
||||
await mac.close();
|
||||
});
|
||||
|
||||
test('the default height is 40 % of the window, at least 16 rows', () {
|
||||
expect(terminalPanelDefaultHeight(1000, 17), 400);
|
||||
expect(terminalPanelDefaultHeight(600, 17), 16 * 17 + terminalPanelChrome);
|
||||
// A short window still leaves the app its share.
|
||||
expect(
|
||||
terminalPanelHeight(null, 400, rowHeight: 17),
|
||||
400 - terminalPanelAppMin,
|
||||
);
|
||||
expect(terminalPanelHeight(500, 1000, rowHeight: 17), 500);
|
||||
});
|
||||
|
||||
test('a layout saved with the old fixed default reads as never resized; '
|
||||
'a dragged height is restored', () async {
|
||||
final store = MemoryLayoutStore();
|
||||
await store.save(jsonEncode({'panel_height': 300}));
|
||||
final legacy = TerminalLayout(store: store);
|
||||
await legacy.restore();
|
||||
expect(legacy.panelHeight, isNull);
|
||||
await store.save(jsonEncode({'panel_height': 412.5}));
|
||||
final dragged = TerminalLayout(store: store);
|
||||
await dragged.restore();
|
||||
expect(dragged.panelHeight, 412.5);
|
||||
});
|
||||
|
||||
for (final size in const [Size(1280, 900), Size(1920, 1080)]) {
|
||||
testWidgets('at ${size.width.round()}x${size.height.round()} the panel '
|
||||
'opens at 40 % of the window and shows at least 16 rows', (
|
||||
tester,
|
||||
) async {
|
||||
await pumpTerminalApp(tester, hub: hub, layout: layout, size: size);
|
||||
await tester.pumpAndSettle();
|
||||
final panel = tester.getSize(panelFinder).height;
|
||||
expect(panel, greaterThanOrEqualTo(size.height * 0.4 - 1));
|
||||
// The emulator lays out its rows after the debounced resize.
|
||||
await tester.pump(const Duration(milliseconds: 300));
|
||||
expect(
|
||||
hub.selected!.session.terminal.viewHeight,
|
||||
greaterThanOrEqualTo(16),
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
testWidgets('a long tab title ends in an ellipsis and its tooltip has it '
|
||||
'whole; the selected tab is marked; close buttons are at least 40 px', (
|
||||
tester,
|
||||
) async {
|
||||
await pumpTerminalApp(tester, hub: hub, layout: layout);
|
||||
await tester.pumpAndSettle();
|
||||
final chips = find.byType(TerminalTabChip);
|
||||
expect(chips, findsNWidgets(2));
|
||||
final long = tester.widget<TerminalTabChip>(chips.last);
|
||||
final title = find.descendant(of: chips.last, matching: find.byType(Text));
|
||||
expect(
|
||||
tester.getSize(title.first).width,
|
||||
lessThanOrEqualTo(terminalTabTitleMaxWidth),
|
||||
);
|
||||
expect(tester.widget<Text>(title.first).overflow, TextOverflow.ellipsis);
|
||||
expect(long.tooltip, contains(long.title));
|
||||
expect(long.tooltip, contains('Mac: /Users/op/a/rather/deep'));
|
||||
|
||||
expect(tester.widget<TerminalTabChip>(chips.first).selected, isTrue);
|
||||
expect(long.selected, isFalse);
|
||||
final selectedText = tester.widget<Text>(
|
||||
find.descendant(of: chips.first, matching: find.byType(Text)).first,
|
||||
);
|
||||
expect(selectedText.style?.fontWeight, FontWeight.w700);
|
||||
|
||||
for (final close
|
||||
in tester
|
||||
.elementList(find.byTooltip('Close terminal'))
|
||||
.map((element) => element.renderObject! as RenderBox)) {
|
||||
expect(close.size.width, greaterThanOrEqualTo(40));
|
||||
expect(close.size.height, greaterThanOrEqualTo(40));
|
||||
}
|
||||
// Selecting by the title.
|
||||
await tester.tap(title.first);
|
||||
await tester.pumpAndSettle();
|
||||
expect(hub.selected!.info.id, 'term_b');
|
||||
});
|
||||
|
||||
testWidgets(
|
||||
'on a touch platform the close buttons are 48 px',
|
||||
(tester) async {
|
||||
await pumpTerminalApp(tester, hub: hub, layout: layout);
|
||||
await tester.pumpAndSettle();
|
||||
final close = tester.getSize(
|
||||
find.widgetWithIcon(IconButton, Icons.close).first,
|
||||
);
|
||||
expect(close.width, greaterThanOrEqualTo(48));
|
||||
expect(close.height, greaterThanOrEqualTo(48));
|
||||
},
|
||||
variant: TargetPlatformVariant.only(TargetPlatform.android),
|
||||
);
|
||||
}
|
||||
@@ -7,6 +7,7 @@ import 'package:pipelines_app/features/chat/shell/chat_shell_terminal_keys.dart'
|
||||
import 'package:pipelines_app/features/settings/settings_terminal_section.dart';
|
||||
import 'package:pipelines_app/features/terminal/terminal_hub.dart';
|
||||
import 'package:pipelines_app/features/terminal/terminal_layout.dart';
|
||||
import 'package:pipelines_app/features/terminal/terminal_panel.dart';
|
||||
import 'package:pipelines_app/features/terminal/terminal_toggle_button.dart';
|
||||
import 'package:xterm/xterm.dart';
|
||||
|
||||
@@ -95,7 +96,9 @@ void main() {
|
||||
final before = tester
|
||||
.getSize(find.byKey(const ValueKey('terminal-panel')))
|
||||
.height;
|
||||
expect(before, terminalPanelDefaultHeight);
|
||||
// Never resized: the default follows the window, and is not saved.
|
||||
expect(before, greaterThanOrEqualTo(800 * terminalPanelDefaultFraction));
|
||||
expect(saved().containsKey('panel_height'), isFalse);
|
||||
await tester.drag(
|
||||
find.byKey(const ValueKey('terminal-panel-resize')),
|
||||
const Offset(0, -120),
|
||||
|
||||
@@ -81,7 +81,7 @@ void main() {
|
||||
await drain(tester);
|
||||
expect(find.text('app'), findsOneWidget);
|
||||
expect(hub.tabs.first.cwd, '/Users/op/src/app');
|
||||
expect(find.byTooltip('Mac: /Users/op/src/app'), findsOneWidget);
|
||||
expect(find.byTooltip('app\nMac: /Users/op/src/app'), findsOneWidget);
|
||||
mac.write('term_a', '\x1b]0;vim notes\x07');
|
||||
await drain(tester);
|
||||
expect(find.text('vim notes'), findsOneWidget);
|
||||
|
||||
Reference in New Issue
Block a user