Merge branch 'main' into floating-chats-global
# Conflicts: # app/lib/features/chat/workspace/chat_workspace.dart
This commit is contained in:
@@ -6,6 +6,7 @@ import '../../../ui/adaptive/segmented_bar.dart';
|
||||
import '../../../ui/adaptive/segmented_bar_overflow.dart';
|
||||
import '../ui/sessions/chat_adaptive.dart';
|
||||
import 'chat_bar_tint.dart';
|
||||
import '../workspace/chat_workspace_pane_scope.dart';
|
||||
|
||||
/// The open conversation's bar: the app's [SegmentedBar] above the
|
||||
/// transcript.
|
||||
@@ -92,30 +93,36 @@ class ChatThreadHeader extends StatelessWidget {
|
||||
separateActionIslands: true,
|
||||
actions: [
|
||||
if (controls.isNotEmpty)
|
||||
_ControlIsland(
|
||||
key: const Key('chat-model-permission-island'),
|
||||
children: controls,
|
||||
ChatWorkspacePaneActionBar(
|
||||
child: _ControlIsland(
|
||||
key: const Key('chat-model-permission-island'),
|
||||
children: controls,
|
||||
),
|
||||
),
|
||||
if (actions.isNotEmpty || moreActions.isNotEmpty)
|
||||
Row(
|
||||
key: const Key('chat-actions-island'),
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
...actions,
|
||||
// Unknown action widgets retain their original behavior and stay
|
||||
// visible; only the explicit overflow contract becomes a menu.
|
||||
for (final action in moreActions)
|
||||
if (action is! SegmentedOverflowable) action,
|
||||
if (moreActions.whereType<SegmentedOverflowable>().isNotEmpty)
|
||||
SegmentedMoreButton(
|
||||
cupertino: cupertino,
|
||||
entries: [
|
||||
for (final action
|
||||
in moreActions.whereType<SegmentedOverflowable>())
|
||||
action.overflowEntry,
|
||||
],
|
||||
),
|
||||
],
|
||||
ChatWorkspacePaneActionBar(
|
||||
child: Row(
|
||||
key: const Key('chat-actions-island'),
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
...actions,
|
||||
// Unknown action widgets retain their original behavior and stay
|
||||
// visible; only the explicit overflow contract becomes a menu.
|
||||
for (final action in moreActions)
|
||||
if (action is! SegmentedOverflowable) action,
|
||||
if (moreActions
|
||||
.whereType<SegmentedOverflowable>()
|
||||
.isNotEmpty)
|
||||
SegmentedMoreButton(
|
||||
cupertino: cupertino,
|
||||
entries: [
|
||||
for (final action
|
||||
in moreActions.whereType<SegmentedOverflowable>())
|
||||
action.overflowEntry,
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
bottomPadding: compact ? 8 : 16,
|
||||
|
||||
@@ -462,39 +462,59 @@ class _ChatWorkspaceState extends State<ChatWorkspace>
|
||||
required Set<String> edges,
|
||||
Map<ChatPaneDirection, String>? moveTargets,
|
||||
FocusNode? focusParent,
|
||||
}) => KeyedSubtree(
|
||||
key: _views.putIfAbsent(pane.id, () => GlobalKey(debugLabel: pane.id)),
|
||||
child: FocusScope(
|
||||
parentNode: focusParent,
|
||||
node: _panes.putIfAbsent(
|
||||
pane.id,
|
||||
() => FocusScopeNode(debugLabel: pane.id),
|
||||
),
|
||||
onFocusChange: (focused) {
|
||||
if (focused && !mobile) widget.controller.activate(pane.id);
|
||||
},
|
||||
child: Listener(
|
||||
behavior: HitTestBehavior.translucent,
|
||||
// A press in the peek scrolls or taps; the tap alone activates.
|
||||
onPointerDown: peek ? null : (_) => widget.controller.activate(pane.id),
|
||||
child: Semantics(
|
||||
identifier: 'chat-pane-${pane.id}',
|
||||
container: true,
|
||||
sortKey: mobile ? const OrdinalSortKey(0) : null,
|
||||
child: ChatWorkspacePaneScope(
|
||||
topEdgeShared: edges.contains('top'),
|
||||
bottomEdgeShared: edges.contains('bottom'),
|
||||
leftEdgeShared: edges.contains('left'),
|
||||
rightEdgeShared: edges.contains('right'),
|
||||
movable: moveTargets != null,
|
||||
moveTargets: moveTargets ?? const {},
|
||||
child: Builder(
|
||||
builder: (paneContext) =>
|
||||
widget.paneBuilder(paneContext, pane, active),
|
||||
}) {
|
||||
var actionBarPointerDown = false;
|
||||
bool preservesStageForActionBar() =>
|
||||
_stage.stage != null && _stage.stage!.stageId != pane.id;
|
||||
return KeyedSubtree(
|
||||
key: _views.putIfAbsent(pane.id, () => GlobalKey(debugLabel: pane.id)),
|
||||
child: FocusScope(
|
||||
parentNode: focusParent,
|
||||
node: _panes.putIfAbsent(
|
||||
pane.id,
|
||||
() => FocusScopeNode(debugLabel: pane.id),
|
||||
),
|
||||
onFocusChange: (focused) {
|
||||
final inActionBar = ChatWorkspacePaneActionBar.contains(
|
||||
primaryFocus?.context,
|
||||
);
|
||||
if (focused &&
|
||||
!mobile &&
|
||||
(!inActionBar || !preservesStageForActionBar())) {
|
||||
widget.controller.activate(pane.id);
|
||||
}
|
||||
},
|
||||
child: Listener(
|
||||
behavior: HitTestBehavior.translucent,
|
||||
// A press in the peek scrolls or taps; the tap alone activates.
|
||||
onPointerDown: peek
|
||||
? null
|
||||
: (_) {
|
||||
if (!actionBarPointerDown || !preservesStageForActionBar()) {
|
||||
widget.controller.activate(pane.id);
|
||||
}
|
||||
},
|
||||
child: Semantics(
|
||||
identifier: 'chat-pane-${pane.id}',
|
||||
container: true,
|
||||
sortKey: mobile ? const OrdinalSortKey(0) : null,
|
||||
child: ChatWorkspacePaneScope(
|
||||
topEdgeShared: edges.contains('top'),
|
||||
bottomEdgeShared: edges.contains('bottom'),
|
||||
leftEdgeShared: edges.contains('left'),
|
||||
rightEdgeShared: edges.contains('right'),
|
||||
movable: moveTargets != null,
|
||||
moveTargets: moveTargets ?? const {},
|
||||
onActionBarPointerDown: () => actionBarPointerDown = true,
|
||||
onActionBarPointerUp: () => actionBarPointerDown = false,
|
||||
child: Builder(
|
||||
builder: (paneContext) =>
|
||||
widget.paneBuilder(paneContext, pane, active),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,6 +14,8 @@ class ChatWorkspacePaneScope extends InheritedWidget {
|
||||
required this.rightEdgeShared,
|
||||
this.movable = false,
|
||||
this.moveTargets = const {},
|
||||
this.onActionBarPointerDown,
|
||||
this.onActionBarPointerUp,
|
||||
required super.child,
|
||||
});
|
||||
|
||||
@@ -29,6 +31,10 @@ class ChatWorkspacePaneScope extends InheritedWidget {
|
||||
/// The pane id a move in each direction swaps with; an outer edge has none.
|
||||
final Map<ChatPaneDirection, String> moveTargets;
|
||||
|
||||
/// Lets a live pane's toolbar consume the pointer without selecting the pane.
|
||||
final VoidCallback? onActionBarPointerDown;
|
||||
final VoidCallback? onActionBarPointerUp;
|
||||
|
||||
static ChatWorkspacePaneScope? maybeOf(BuildContext context) =>
|
||||
context.dependOnInheritedWidgetOfExactType<ChatWorkspacePaneScope>();
|
||||
|
||||
@@ -39,5 +45,31 @@ class ChatWorkspacePaneScope extends InheritedWidget {
|
||||
leftEdgeShared != oldWidget.leftEdgeShared ||
|
||||
rightEdgeShared != oldWidget.rightEdgeShared ||
|
||||
movable != oldWidget.movable ||
|
||||
!mapEquals(moveTargets, oldWidget.moveTargets);
|
||||
!mapEquals(moveTargets, oldWidget.moveTargets) ||
|
||||
onActionBarPointerDown != oldWidget.onActionBarPointerDown ||
|
||||
onActionBarPointerUp != oldWidget.onActionBarPointerUp;
|
||||
}
|
||||
|
||||
/// Marks a pane header/toolbar. Its controls remain interactive, but focusing
|
||||
/// or pressing them must not make a live side pane the staged chat.
|
||||
class ChatWorkspacePaneActionBar extends StatelessWidget {
|
||||
const ChatWorkspacePaneActionBar({super.key, required this.child});
|
||||
|
||||
final Widget child;
|
||||
|
||||
static bool contains(BuildContext? context) =>
|
||||
context?.findAncestorWidgetOfExactType<ChatWorkspacePaneActionBar>() !=
|
||||
null;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final scope = ChatWorkspacePaneScope.maybeOf(context);
|
||||
return Listener(
|
||||
behavior: HitTestBehavior.translucent,
|
||||
onPointerDown: (_) => scope?.onActionBarPointerDown?.call(),
|
||||
onPointerUp: (_) => scope?.onActionBarPointerUp?.call(),
|
||||
onPointerCancel: (_) => scope?.onActionBarPointerUp?.call(),
|
||||
child: child,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,6 +18,9 @@ unchanged.
|
||||
already-open chat from the list, quick switch, or the Open chats picker.
|
||||
Opening a new chat from the list replaces the staged chat, as in the split
|
||||
layout.
|
||||
- On a wide center-stage layout, action-bar controls in a live side chat remain
|
||||
usable without staging that chat. Transcript and composer presses retain the
|
||||
existing click-to-activate behavior; covered strips still stage their chat.
|
||||
- Ctrl/Cmd+Alt+Shift+Left/Right (pane moves) moves the staged chat along the
|
||||
strip order. Up/down have no neighbours on stage.
|
||||
- The floating chat (Ctrl/Cmd+Y) is not tiled, so it is never staged or
|
||||
@@ -26,9 +29,8 @@ unchanged.
|
||||
|
||||
## Checks
|
||||
|
||||
- `tool/memwatch/full.sh 'test/features/chat test/shell'`: 1356 passed, 1
|
||||
failed (the new float/dock test's own wrong expectation, fixed after). Then
|
||||
`test/features/chat/workspace`: 85 passed, 0 failed. `tool/analyze.sh`: clean.
|
||||
- `tool/memwatch/full.sh 'test/features/chat/workspace'`: 87 passed, 0 failed.
|
||||
`tool/analyze.sh`: clean.
|
||||
- Captures (`chats=3&rich=1&colors=1`, 1440x900, three panes, headless Chrome,
|
||||
macOS platform, so Cmd+E): normal split, center stage on, stage moved to
|
||||
api refactor, and back to the same split sizes, plus filmed toggle-on, switch
|
||||
|
||||
@@ -49,6 +49,7 @@ Widget host(
|
||||
bool singlePane = false,
|
||||
bool reduceMotion = false,
|
||||
List<KeyEvent>? fieldKeys,
|
||||
bool actionBars = false,
|
||||
}) => MaterialApp(
|
||||
home: MediaQuery(
|
||||
data: MediaQueryData(disableAnimations: reduceMotion),
|
||||
@@ -71,9 +72,18 @@ Widget host(
|
||||
fieldKeys?.add(event);
|
||||
return KeyEventResult.ignored;
|
||||
},
|
||||
child: _Draft(
|
||||
key: ValueKey(pane.sessionId),
|
||||
name: pane.sessionId,
|
||||
child: Column(
|
||||
children: [
|
||||
_Draft(key: ValueKey(pane.sessionId), name: pane.sessionId),
|
||||
if (actionBars)
|
||||
ChatWorkspacePaneActionBar(
|
||||
child: TextButton(
|
||||
key: ValueKey('action-${pane.sessionId}'),
|
||||
onPressed: () {},
|
||||
child: const Text('Action'),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
@@ -219,6 +229,48 @@ void main() {
|
||||
expect(find.text('kept'), findsOneWidget);
|
||||
});
|
||||
|
||||
testWidgets('a live side action bar does not move center stage', (
|
||||
tester,
|
||||
) async {
|
||||
wide(tester);
|
||||
tester.view.physicalSize = const Size(2400, 1000);
|
||||
final workspace = threePanes();
|
||||
final stage = ChatCenterStageController(store: _MemoryStore())
|
||||
..value = true;
|
||||
addTearDown(workspace.dispose);
|
||||
addTearDown(stage.dispose);
|
||||
await tester.pumpWidget(
|
||||
host(workspace, stage, width: 2400, actionBars: true),
|
||||
);
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
expect(widthOf(tester, 'three'), 950);
|
||||
await tester.tap(find.byKey(const ValueKey('action-one')));
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
expect(workspace.activePane?.sessionId, 'three');
|
||||
expect(widthOf(tester, 'three'), 950);
|
||||
|
||||
await tester.tap(find.byKey(const ValueKey('input-one')));
|
||||
await tester.pumpAndSettle();
|
||||
expect(workspace.activePane?.sessionId, 'one');
|
||||
});
|
||||
|
||||
testWidgets('a normal split action bar still activates its pane', (
|
||||
tester,
|
||||
) async {
|
||||
wide(tester);
|
||||
final workspace = threePanes();
|
||||
final stage = ChatCenterStageController(store: _MemoryStore());
|
||||
addTearDown(workspace.dispose);
|
||||
addTearDown(stage.dispose);
|
||||
await tester.pumpWidget(host(workspace, stage, actionBars: true));
|
||||
await tester.tap(find.byKey(const ValueKey('action-one')));
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
expect(workspace.activePane?.sessionId, 'one');
|
||||
});
|
||||
|
||||
testWidgets(
|
||||
'the floating chat is not staged; a docked chat takes the stage',
|
||||
(tester) async {
|
||||
|
||||
Reference in New Issue
Block a user