Refine Settings destination shell integration

Keep Settings navigation independent while preserving shell actions and destination-specific state. Add the reviewed chat, run-entry, layout, and regression-test updates needed by the destination behavior.
This commit is contained in:
2026-11-12 11:21:26 +00:00
parent 95902e3e49
commit 26bb583f10
49 changed files with 2386 additions and 483 deletions
@@ -0,0 +1,182 @@
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:pipelines_app/features/chat/workspace/chat_pane_dim.dart';
import 'package:pipelines_app/features/chat/workspace/chat_workspace.dart';
import 'package:pipelines_app/ui/motion/motion.dart';
Widget host(
ChatWorkspaceController controller, {
bool disableAnimations = false,
}) => MaterialApp(
home: Scaffold(
body: SizedBox(
width: 1200,
height: 900,
child: Builder(
builder: (context) => MediaQuery(
data: MediaQuery.of(
context,
).copyWith(disableAnimations: disableAnimations),
child: ChatWorkspace(
controller: controller,
paneBuilder: (_, pane, active) =>
TextField(key: ValueKey('input-${pane.sessionId}')),
),
),
),
),
),
);
/// The dim overlay wrapping the pane that shows [session].
Finder dimOf(String session) => find.ancestor(
of: find.byKey(ValueKey('input-$session')),
matching: find.byType(ChatPaneDim),
);
/// The alpha of the scrim over [session]'s pane: zero when the pane is clear.
double scrimAlpha(WidgetTester tester, String session) {
final scrim = find.descendant(
of: dimOf(session),
matching: find.byKey(const ValueKey('chat-pane-dim-scrim')),
);
// AnimatedContainer builds a Container whose BoxDecoration holds the colour.
final container = tester.widget<Container>(
find.descendant(of: scrim, matching: find.byType(Container)),
);
final decoration = container.decoration as BoxDecoration?;
return (decoration?.color ?? container.color ?? const Color(0x00000000)).a;
}
void usePhoneSizedView(WidgetTester tester) {
tester.view.physicalSize = const Size(1200, 900);
tester.view.devicePixelRatio = 1;
addTearDown(tester.view.resetPhysicalSize);
addTearDown(tester.view.resetDevicePixelRatio);
}
void main() {
testWidgets('two panes: the inactive pane is dimmed and the active is not', (
tester,
) async {
final controller = ChatWorkspaceController()
..open('one')
..splitActive('two', ChatSplitAxis.horizontal);
addTearDown(controller.dispose);
await tester.pumpWidget(host(controller));
await tester.pumpAndSettle();
expect(controller.activePane?.sessionId, 'two');
expect(scrimAlpha(tester, 'one'), closeTo(chatPaneDimOpacity, 0.001));
expect(scrimAlpha(tester, 'two'), 0);
});
testWidgets('three panes: every inactive pane is dimmed, the active is not', (
tester,
) async {
final controller = ChatWorkspaceController()
..open('one')
..splitActive('two', ChatSplitAxis.horizontal)
..splitActive('three', ChatSplitAxis.horizontal);
addTearDown(controller.dispose);
await tester.pumpWidget(host(controller));
await tester.pumpAndSettle();
expect(controller.activePane?.sessionId, 'three');
expect(scrimAlpha(tester, 'one'), closeTo(chatPaneDimOpacity, 0.001));
expect(scrimAlpha(tester, 'two'), closeTo(chatPaneDimOpacity, 0.001));
expect(scrimAlpha(tester, 'three'), 0);
});
testWidgets('a single pane is never dimmed', (tester) async {
final controller = ChatWorkspaceController()..open('one');
addTearDown(controller.dispose);
await tester.pumpWidget(host(controller));
await tester.pumpAndSettle();
expect(scrimAlpha(tester, 'one'), 0);
});
testWidgets('tapping an inactive pane activates it and focuses its input', (
tester,
) async {
usePhoneSizedView(tester);
final controller = ChatWorkspaceController()
..open('one')
..splitActive('two', ChatSplitAxis.horizontal);
addTearDown(controller.dispose);
await tester.pumpWidget(host(controller));
await tester.pumpAndSettle();
final first = controller.panes.first.id;
expect(controller.activePaneId, isNot(first));
await tester.tap(find.byKey(const ValueKey('input-one')));
await tester.pumpAndSettle();
expect(controller.activePaneId, first);
expect(scrimAlpha(tester, 'one'), 0);
expect(scrimAlpha(tester, 'two'), closeTo(chatPaneDimOpacity, 0.001));
final editable = tester.widget<EditableText>(
find.descendant(
of: find.byKey(const ValueKey('input-one')),
matching: find.byType(EditableText),
),
);
expect(editable.focusNode.hasFocus, isTrue);
});
testWidgets('a tap on bare space in an inactive pane activates it', (
tester,
) async {
usePhoneSizedView(tester);
final controller = ChatWorkspaceController()
..open('one')
..splitActive('two', ChatSplitAxis.horizontal);
addTearDown(controller.dispose);
await tester.pumpWidget(host(controller));
await tester.pumpAndSettle();
final first = controller.panes.first.id;
final corner = tester.getTopLeft(dimOf('one')) + const Offset(2, 2);
await tester.tapAt(corner);
await tester.pumpAndSettle();
expect(controller.activePaneId, first);
});
testWidgets('reduced motion switches the dim at once, without a fade', (
tester,
) async {
final controller = ChatWorkspaceController()
..open('one')
..splitActive('two', ChatSplitAxis.horizontal);
addTearDown(controller.dispose);
await tester.pumpWidget(host(controller, disableAnimations: true));
await tester.pumpAndSettle();
final scrim = find.byKey(const ValueKey('chat-pane-dim-scrim')).first;
expect(tester.widget<AnimatedContainer>(scrim).duration, Duration.zero);
controller.activate(controller.panes.first.id);
await tester.pump();
expect(scrimAlpha(tester, 'one'), 0);
expect(scrimAlpha(tester, 'two'), closeTo(chatPaneDimOpacity, 0.001));
});
testWidgets('motion is on by default: the dim fades over the standard time', (
tester,
) async {
final controller = ChatWorkspaceController()
..open('one')
..splitActive('two', ChatSplitAxis.horizontal);
addTearDown(controller.dispose);
await tester.pumpWidget(host(controller));
await tester.pumpAndSettle();
final scrim = find.byKey(const ValueKey('chat-pane-dim-scrim')).first;
expect(
tester.widget<AnimatedContainer>(scrim).duration,
Motion.standard,
);
});
}