Add opposing arc swap animation for chat quick switch

This commit is contained in:
2026-11-08 01:00:08 +00:00
parent 2fe08226f2
commit d6006bb1f8
6 changed files with 147 additions and 47 deletions
@@ -6,6 +6,7 @@ const quickSwitchAnimationKey = 'pipelines.quick-switch-animation.v1';
enum QuickSwitchAnimation {
tape('Tape', 'Chats travel together in a continuous vertical loop.'),
swap('Swap', 'Chats slide past each other into their new positions.'),
arcSwap('Arc swap', 'Chats trade places along opposite left and right arcs.'),
cardStack(
'Card deck',
'Lift the front card, slide it aside and tuck it behind.',
@@ -85,6 +85,14 @@ QuickSwitchPose quickSwitchPose(
case QuickSwitchAnimation.tape:
case QuickSwitchAnimation.swap:
return const QuickSwitchPose();
case QuickSwitchAnimation.arcSwap:
// Vertical travel is the same as Swap. This half-sine bows both paths
// outwards, meeting their exact endpoints without a hinge or 3D filter.
return QuickSwitchPose(
translation: Offset(direction * .38 * wave, 0),
rotationZ: direction * .035 * wave,
shadow: .4 * wave,
);
case QuickSwitchAnimation.cardStack:
return QuickSwitchPose(
translation: Offset(
+35
View File
@@ -0,0 +1,35 @@
# Arc swap quick switch
`Arc swap` is a new persisted choice beside Swap. The outgoing active chat bows
left while the incoming chat bows right, trading vertical positions together.
The paths use opposite half-sines and a slight planar card rotation. They remain
opaque and settle to the exact prior Swap endpoints. Paint transforms use the
existing affine path; no hinge rotation or new 3D/backdrop path is introduced.
The 440 ms base clock, quintic easing, global speed control, reduced-motion
behavior and Tape default are unchanged. Existing persisted style names remain
valid. The Settings picker enumerates the new choice automatically and its
preview renders the same real workspace/motion code as chat.
Verification:
- 74 focused motion/workspace/preview tests passed (`/tmp/memwatch/out.x37AcW`).
Coverage includes persistence, exact endpoints, finite/bounded geometry,
opposite arc sides, retained live drafts and style selection in the preview.
- The subsequent 13-test style rerun passed (`/tmp/memwatch/out.38HNQA`) after
strengthening the three-pane cycle test to retain every draft and a custom
0.12 peek ratio. Reduced motion settles instantly.
- Analyzer clean (`flutter-analyze.vbo9ds`; final rerun recorded by manager).
- Full-app fake-gateway fixture build passed at `build/probe-arc`.
- Phone-layout browser switch-and-return passed, with the original draft read
back after both exchanges. Inspected contact sheets and returned-state PNG:
`/tmp/review/arc-swap-full-app/`. Script `/tmp/arc-swap-capture.json`.
- Settings browser interaction chose Swap, then Arc swap through the real
dropdown, asserted the stored `arcSwap` value, and filmed Replay. Inspected
selection PNG and preview contact sheet: `/tmp/review/arc-swap-settings-v3/`.
Script `/tmp/arc-swap-settings-capture.json`. An earlier capture overscrolled
the picker under the pinned header; corrected to a 100px scroll.
Software Chrome is qualitative browser evidence, not Android FPS or wall-time
measurement. No native device test, live chat mutation, server restart, pipeline
change, or deployment was performed. Capture drivers completed and cleaned up
owned browsers and loopback servers.
@@ -159,51 +159,63 @@ void main() {
});
}
testWidgets('card stack cycles all added panes and settles reduced motion', (
tester,
) async {
phone(tester);
SharedPreferences.setMockInitialValues({});
await QuickSwitchAnimationController.instance.setAnimation(
QuickSwitchAnimation.cardStack,
);
addTearDown(
() => QuickSwitchAnimationController.instance.setAnimation(
QuickSwitchAnimation.tape,
),
);
final controller = ChatWorkspaceController()..open('a');
for (final id in ['b', 'c']) {
controller.splitActive(id, ChatSplitAxis.horizontal);
}
await tester.pumpWidget(_host(controller));
await tester.pumpAndSettle();
final states = {
for (final id in ['a', 'b', 'c'])
id: tester.state<_DraftState>(
find.byKey(ValueKey(id), skipOffstage: false),
),
};
for (final id in ['a', 'b', 'c', 'a']) {
final pane = controller.panes.firstWhere((p) => p.sessionId == id);
await tester.tap(find.byKey(ValueKey('chat-peek-${pane.id}')));
await tester.pumpAndSettle();
expect(controller.activePane!.sessionId, id);
for (final entry in states.entries) {
expect(
tester.state(find.byKey(ValueKey(entry.key), skipOffstage: false)),
same(entry.value),
for (final ringStyle in [
QuickSwitchAnimation.cardStack,
QuickSwitchAnimation.arcSwap,
]) {
testWidgets(
'${ringStyle.name} cycles all added panes and settles reduced motion',
(tester) async {
phone(tester);
SharedPreferences.setMockInitialValues({});
await QuickSwitchAnimationController.instance.setAnimation(ringStyle);
addTearDown(
() => QuickSwitchAnimationController.instance.setAnimation(
QuickSwitchAnimation.tape,
),
);
}
}
await tester.pumpWidget(_host(controller, reduced: true));
controller.activate(
controller.panes.firstWhere((p) => p.sessionId == 'b').id,
final controller = ChatWorkspaceController()..open('a');
for (final id in ['b', 'c']) {
controller.splitActive(id, ChatSplitAxis.horizontal);
}
await tester.pumpWidget(_host(controller));
await tester.pumpAndSettle();
final states = {
for (final id in ['a', 'b', 'c'])
id: tester.state<_DraftState>(
find.byKey(ValueKey(id), skipOffstage: false),
),
};
controller.resizeMobilePeek(.12);
for (final entry in states.entries) {
entry.value.controller.text = 'Draft ${entry.key}';
}
for (final id in ['a', 'b', 'c', 'a']) {
final pane = controller.panes.firstWhere((p) => p.sessionId == id);
await tester.tap(find.byKey(ValueKey('chat-peek-${pane.id}')));
await tester.pumpAndSettle();
expect(controller.activePane!.sessionId, id);
for (final entry in states.entries) {
expect(
tester.state(
find.byKey(ValueKey(entry.key), skipOffstage: false),
),
same(entry.value),
);
expect(entry.value.controller.text, 'Draft ${entry.key}');
}
expect(controller.mobilePeekFraction, .12);
}
await tester.pumpWidget(_host(controller, reduced: true));
controller.activate(
controller.panes.firstWhere((p) => p.sessionId == 'b').id,
);
await tester.pump();
expect(tester.getRect(rect(controller.activePaneId!)).top, 0);
expect(find.byKey(const ValueKey('chat-swap-exit')), findsNothing);
await tester.pumpWidget(const SizedBox());
controller.dispose();
},
);
await tester.pump();
expect(tester.getRect(rect(controller.activePaneId!)).top, 0);
expect(find.byKey(const ValueKey('chat-swap-exit')), findsNothing);
await tester.pumpWidget(const SizedBox());
controller.dispose();
});
}
}
@@ -27,7 +27,7 @@ void main() {
await tester.pumpAndSettle();
expect(workspace.controller.activePaneId, isNot(active));
expect(tester.binding.transientCallbackCount, 0);
await tester.pumpWidget(_host(QuickSwitchAnimation.swap));
await tester.pumpWidget(_host(QuickSwitchAnimation.arcSwap));
await tester.pumpAndSettle();
expect(
tester.widget<ChatWorkspace>(find.byType(ChatWorkspace)).controller,
@@ -35,7 +35,7 @@ void main() {
);
expect(
tester.widget<ChatWorkspace>(find.byType(ChatWorkspace)).animationStyle,
QuickSwitchAnimation.swap,
QuickSwitchAnimation.arcSwap,
);
expect(tester.takeException(), isNull);
});
@@ -39,6 +39,50 @@ void main() {
}
});
test(
'arc swap bows to opposite sides while both cards travel vertically',
() {
const style = QuickSwitchAnimation.arcSwap;
for (final t in [.25, .5, .75]) {
final outgoing = quickSwitchPose(style, t, outgoing: true);
final incoming = quickSwitchPose(style, t, outgoing: false);
expect(outgoing.translation.dx, lessThan(0));
expect(incoming.translation.dx, greaterThan(0));
expect(
outgoing.translation.dx,
closeTo(-incoming.translation.dx, 1e-9),
);
expect(outgoing.rotationX, 0);
expect(outgoing.rotationY, 0);
expect(outgoing.transform(full.size).entry(3, 2), 0);
expect(outgoing.opacity, 1);
expect(incoming.opacity, 1);
expect(
quickSwitchRect(style, t, full, peek, outgoing: true),
Rect.lerp(full, peek, t),
);
expect(
quickSwitchRect(style, t, peek, full, outgoing: false),
Rect.lerp(peek, full, t),
);
}
final quarter = quickSwitchPose(
style,
.25,
outgoing: false,
).translation.dx;
final middle = quickSwitchPose(style, .5, outgoing: false).translation.dx;
final threeQuarter = quickSwitchPose(
style,
.75,
outgoing: false,
).translation.dx;
expect(quarter, closeTo(threeQuarter, 1e-9));
expect(middle, greaterThan(quarter));
expect(middle, closeTo(.38, 1e-9));
},
);
test('every style settles without residual transforms or missing cards', () {
for (final style in QuickSwitchAnimation.values) {
for (final outgoing in [true, false]) {