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/adaptive/segmented_bar_overflow.dart';
|
||||||
import '../ui/sessions/chat_adaptive.dart';
|
import '../ui/sessions/chat_adaptive.dart';
|
||||||
import 'chat_bar_tint.dart';
|
import 'chat_bar_tint.dart';
|
||||||
|
import '../workspace/chat_workspace_pane_scope.dart';
|
||||||
|
|
||||||
/// The open conversation's bar: the app's [SegmentedBar] above the
|
/// The open conversation's bar: the app's [SegmentedBar] above the
|
||||||
/// transcript.
|
/// transcript.
|
||||||
@@ -92,30 +93,36 @@ class ChatThreadHeader extends StatelessWidget {
|
|||||||
separateActionIslands: true,
|
separateActionIslands: true,
|
||||||
actions: [
|
actions: [
|
||||||
if (controls.isNotEmpty)
|
if (controls.isNotEmpty)
|
||||||
_ControlIsland(
|
ChatWorkspacePaneActionBar(
|
||||||
key: const Key('chat-model-permission-island'),
|
child: _ControlIsland(
|
||||||
children: controls,
|
key: const Key('chat-model-permission-island'),
|
||||||
|
children: controls,
|
||||||
|
),
|
||||||
),
|
),
|
||||||
if (actions.isNotEmpty || moreActions.isNotEmpty)
|
if (actions.isNotEmpty || moreActions.isNotEmpty)
|
||||||
Row(
|
ChatWorkspacePaneActionBar(
|
||||||
key: const Key('chat-actions-island'),
|
child: Row(
|
||||||
mainAxisSize: MainAxisSize.min,
|
key: const Key('chat-actions-island'),
|
||||||
children: [
|
mainAxisSize: MainAxisSize.min,
|
||||||
...actions,
|
children: [
|
||||||
// Unknown action widgets retain their original behavior and stay
|
...actions,
|
||||||
// visible; only the explicit overflow contract becomes a menu.
|
// Unknown action widgets retain their original behavior and stay
|
||||||
for (final action in moreActions)
|
// visible; only the explicit overflow contract becomes a menu.
|
||||||
if (action is! SegmentedOverflowable) action,
|
for (final action in moreActions)
|
||||||
if (moreActions.whereType<SegmentedOverflowable>().isNotEmpty)
|
if (action is! SegmentedOverflowable) action,
|
||||||
SegmentedMoreButton(
|
if (moreActions
|
||||||
cupertino: cupertino,
|
.whereType<SegmentedOverflowable>()
|
||||||
entries: [
|
.isNotEmpty)
|
||||||
for (final action
|
SegmentedMoreButton(
|
||||||
in moreActions.whereType<SegmentedOverflowable>())
|
cupertino: cupertino,
|
||||||
action.overflowEntry,
|
entries: [
|
||||||
],
|
for (final action
|
||||||
),
|
in moreActions.whereType<SegmentedOverflowable>())
|
||||||
],
|
action.overflowEntry,
|
||||||
|
],
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
bottomPadding: compact ? 8 : 16,
|
bottomPadding: compact ? 8 : 16,
|
||||||
|
|||||||
@@ -462,39 +462,59 @@ class _ChatWorkspaceState extends State<ChatWorkspace>
|
|||||||
required Set<String> edges,
|
required Set<String> edges,
|
||||||
Map<ChatPaneDirection, String>? moveTargets,
|
Map<ChatPaneDirection, String>? moveTargets,
|
||||||
FocusNode? focusParent,
|
FocusNode? focusParent,
|
||||||
}) => KeyedSubtree(
|
}) {
|
||||||
key: _views.putIfAbsent(pane.id, () => GlobalKey(debugLabel: pane.id)),
|
var actionBarPointerDown = false;
|
||||||
child: FocusScope(
|
bool preservesStageForActionBar() =>
|
||||||
parentNode: focusParent,
|
_stage.stage != null && _stage.stage!.stageId != pane.id;
|
||||||
node: _panes.putIfAbsent(
|
return KeyedSubtree(
|
||||||
pane.id,
|
key: _views.putIfAbsent(pane.id, () => GlobalKey(debugLabel: pane.id)),
|
||||||
() => FocusScopeNode(debugLabel: pane.id),
|
child: FocusScope(
|
||||||
),
|
parentNode: focusParent,
|
||||||
onFocusChange: (focused) {
|
node: _panes.putIfAbsent(
|
||||||
if (focused && !mobile) widget.controller.activate(pane.id);
|
pane.id,
|
||||||
},
|
() => FocusScopeNode(debugLabel: pane.id),
|
||||||
child: Listener(
|
),
|
||||||
behavior: HitTestBehavior.translucent,
|
onFocusChange: (focused) {
|
||||||
// A press in the peek scrolls or taps; the tap alone activates.
|
final inActionBar = ChatWorkspacePaneActionBar.contains(
|
||||||
onPointerDown: peek ? null : (_) => widget.controller.activate(pane.id),
|
primaryFocus?.context,
|
||||||
child: Semantics(
|
);
|
||||||
identifier: 'chat-pane-${pane.id}',
|
if (focused &&
|
||||||
container: true,
|
!mobile &&
|
||||||
sortKey: mobile ? const OrdinalSortKey(0) : null,
|
(!inActionBar || !preservesStageForActionBar())) {
|
||||||
child: ChatWorkspacePaneScope(
|
widget.controller.activate(pane.id);
|
||||||
topEdgeShared: edges.contains('top'),
|
}
|
||||||
bottomEdgeShared: edges.contains('bottom'),
|
},
|
||||||
leftEdgeShared: edges.contains('left'),
|
child: Listener(
|
||||||
rightEdgeShared: edges.contains('right'),
|
behavior: HitTestBehavior.translucent,
|
||||||
movable: moveTargets != null,
|
// A press in the peek scrolls or taps; the tap alone activates.
|
||||||
moveTargets: moveTargets ?? const {},
|
onPointerDown: peek
|
||||||
child: Builder(
|
? null
|
||||||
builder: (paneContext) =>
|
: (_) {
|
||||||
widget.paneBuilder(paneContext, pane, active),
|
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,
|
required this.rightEdgeShared,
|
||||||
this.movable = false,
|
this.movable = false,
|
||||||
this.moveTargets = const {},
|
this.moveTargets = const {},
|
||||||
|
this.onActionBarPointerDown,
|
||||||
|
this.onActionBarPointerUp,
|
||||||
required super.child,
|
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.
|
/// The pane id a move in each direction swaps with; an outer edge has none.
|
||||||
final Map<ChatPaneDirection, String> moveTargets;
|
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) =>
|
static ChatWorkspacePaneScope? maybeOf(BuildContext context) =>
|
||||||
context.dependOnInheritedWidgetOfExactType<ChatWorkspacePaneScope>();
|
context.dependOnInheritedWidgetOfExactType<ChatWorkspacePaneScope>();
|
||||||
|
|
||||||
@@ -39,5 +45,31 @@ class ChatWorkspacePaneScope extends InheritedWidget {
|
|||||||
leftEdgeShared != oldWidget.leftEdgeShared ||
|
leftEdgeShared != oldWidget.leftEdgeShared ||
|
||||||
rightEdgeShared != oldWidget.rightEdgeShared ||
|
rightEdgeShared != oldWidget.rightEdgeShared ||
|
||||||
movable != oldWidget.movable ||
|
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.
|
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
|
Opening a new chat from the list replaces the staged chat, as in the split
|
||||||
layout.
|
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
|
- Ctrl/Cmd+Alt+Shift+Left/Right (pane moves) moves the staged chat along the
|
||||||
strip order. Up/down have no neighbours on stage.
|
strip order. Up/down have no neighbours on stage.
|
||||||
- The floating chat (Ctrl/Cmd+Y) is not tiled, so it is never staged or
|
- The floating chat (Ctrl/Cmd+Y) is not tiled, so it is never staged or
|
||||||
@@ -26,9 +29,8 @@ unchanged.
|
|||||||
|
|
||||||
## Checks
|
## Checks
|
||||||
|
|
||||||
- `tool/memwatch/full.sh 'test/features/chat test/shell'`: 1356 passed, 1
|
- `tool/memwatch/full.sh 'test/features/chat/workspace'`: 87 passed, 0 failed.
|
||||||
failed (the new float/dock test's own wrong expectation, fixed after). Then
|
`tool/analyze.sh`: clean.
|
||||||
`test/features/chat/workspace`: 85 passed, 0 failed. `tool/analyze.sh`: clean.
|
|
||||||
- Captures (`chats=3&rich=1&colors=1`, 1440x900, three panes, headless Chrome,
|
- 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
|
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
|
api refactor, and back to the same split sizes, plus filmed toggle-on, switch
|
||||||
|
|||||||
@@ -49,6 +49,7 @@ Widget host(
|
|||||||
bool singlePane = false,
|
bool singlePane = false,
|
||||||
bool reduceMotion = false,
|
bool reduceMotion = false,
|
||||||
List<KeyEvent>? fieldKeys,
|
List<KeyEvent>? fieldKeys,
|
||||||
|
bool actionBars = false,
|
||||||
}) => MaterialApp(
|
}) => MaterialApp(
|
||||||
home: MediaQuery(
|
home: MediaQuery(
|
||||||
data: MediaQueryData(disableAnimations: reduceMotion),
|
data: MediaQueryData(disableAnimations: reduceMotion),
|
||||||
@@ -71,9 +72,18 @@ Widget host(
|
|||||||
fieldKeys?.add(event);
|
fieldKeys?.add(event);
|
||||||
return KeyEventResult.ignored;
|
return KeyEventResult.ignored;
|
||||||
},
|
},
|
||||||
child: _Draft(
|
child: Column(
|
||||||
key: ValueKey(pane.sessionId),
|
children: [
|
||||||
name: pane.sessionId,
|
_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);
|
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(
|
testWidgets(
|
||||||
'the floating chat is not staged; a docked chat takes the stage',
|
'the floating chat is not staged; a docked chat takes the stage',
|
||||||
(tester) async {
|
(tester) async {
|
||||||
|
|||||||
Reference in New Issue
Block a user