Keep chat workspace above Android navigation and use pane chat color

This commit is contained in:
2026-11-07 02:46:38 +00:00
parent 9e6d55942f
commit 0be9f3c1ce
3 changed files with 200 additions and 28 deletions
@@ -243,34 +243,46 @@ mixin _ChatScreenWorkspace on State<ChatScreen> {
onSelected: _openBelow,
);
Widget _workspaceView() => ChatWorkspace(
key: _workspaceKey,
controller: _workspace,
shortcutsEnabled: _workspaceVisible,
singlePane: !showsListBesideDetail(context),
mobilePeeks: !showsListBesideDetail(context),
paneTitle: (pane) =>
'${_rowFor(pane.sessionId)?['title'] ?? pane.sessionId}',
onFocusPane: (pane) => _composerFocus.request(pane.sessionId),
paneBuilder: (context, pane, active) => Semantics(
selected: active,
child: DecoratedBox(
position: DecorationPosition.foreground,
decoration: BoxDecoration(
border: Border.all(
color: _workspace.paneCount > 1 && active
? (chatControlsStyleOf(context) == ChatControlsStyle.cupertino
? CupertinoTheme.of(context).primaryColor
: Theme.of(context).colorScheme.primary)
: Colors.transparent,
Widget _workspaceView() => SafeArea(
top: false,
child: ChatWorkspace(
key: _workspaceKey,
controller: _workspace,
shortcutsEnabled: _workspaceVisible,
singlePane: !showsListBesideDetail(context),
mobilePeeks: !showsListBesideDetail(context),
paneTitle: (pane) =>
'${_rowFor(pane.sessionId)?['title'] ?? pane.sessionId}',
onFocusPane: (pane) => _composerFocus.request(pane.sessionId),
paneBuilder: (context, pane, active) => Semantics(
selected: active,
child: DecoratedBox(
position: DecorationPosition.foreground,
decoration: BoxDecoration(
border: Border.all(
color: _workspace.paneCount > 1 && active
? chatColorShade(
context,
chatSessionColor(_rowFor(pane.sessionId)),
) ??
(chatControlsStyleOf(context) ==
ChatControlsStyle.cupertino
? CupertinoTheme.of(context).primaryColor
: Theme.of(context).colorScheme.primary)
: Colors.transparent,
),
),
child: DetailPane(
key: ValueKey('chat-pane-detail-${pane.id}'),
destination: AppDestination.chat,
implyBack: false,
builder: (context) => _thread(
pane.sessionId,
_back,
pane: pane,
paneContext: context,
),
),
),
child: DetailPane(
key: ValueKey('chat-pane-detail-${pane.id}'),
destination: AppDestination.chat,
implyBack: false,
builder: (context) =>
_thread(pane.sessionId, _back, pane: pane, paneContext: context),
),
),
),
+6 -1
View File
@@ -31,6 +31,8 @@ import 'conversation/composer_selection_focus.dart';
import 'data/chat_repository.dart';
import 'domain/chat_commands.dart';
import 'domain/chat_cycle.dart';
import 'domain/chat_colors.dart';
import 'ui/sessions/chat_color_palette.dart';
import 'ui/sessions/chat_sessions_body.dart';
import 'ui/sessions/chat_sessions_controller.dart';
import 'ui/sessions/chat_sessions_screen.dart';
@@ -550,7 +552,10 @@ class _ChatScreenState extends State<ChatScreen>
excluding: selected == null,
child: MediaQuery(
data: media.copyWith(
padding: media.padding.copyWith(top: system.top),
padding: media.padding.copyWith(
top: system.top,
bottom: system.bottom,
),
),
child: _workspaceView(),
),
@@ -0,0 +1,155 @@
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:shared_preferences/shared_preferences.dart';
import 'package:pipelines_app/core/api_gateway.dart';
import 'package:pipelines_app/features/chat/screen.dart';
import 'package:pipelines_app/features/chat/conversation/chat_composer_bar.dart';
import 'package:pipelines_app/features/chat/conversation/chat_thread_view.dart';
import 'package:pipelines_app/features/chat/ui/sessions/chat_color_palette.dart';
import 'package:pipelines_app/features/chat/workspace/chat_workspace.dart';
import 'package:pipelines_app/shell/adaptive_shell.dart';
import 'package:pipelines_app/shell/destination.dart';
import 'conversation/chat_thread_fixtures.dart';
class _Gateway extends FakeChatGateway {
@override
Future<JsonMap> call(String type, [JsonMap fields = const {}]) {
if (type == 'chat_sessions') {
return Future.value({
'chat_sessions': [
{
'id': 'a',
'title': 'Chat a',
'directory': '/home/a',
'color': 'orange',
},
{
'id': 'b',
'title': 'Chat b',
'directory': '/home/b',
'color': 'teal',
},
{'id': 'c', 'title': 'Chat c', 'directory': '/home/c'},
],
});
}
if (type == 'chat_shells') return Future.value({'chat_shells': []});
return super.call(type, fields);
}
}
Finder _thread(String id) => find.byWidgetPredicate(
(widget) => widget is ChatThreadView && widget.sessionId == id,
);
Future<void> _mount(WidgetTester tester, Size size) async {
SharedPreferences.setMockInitialValues({});
tester.view.physicalSize = size;
tester.view.devicePixelRatio = 1;
tester.view.viewPadding = const FakeViewPadding(top: 24, bottom: 24);
tester.view.padding = const FakeViewPadding(top: 24, bottom: 24);
addTearDown(tester.view.reset);
final gateway = _Gateway()..history = (_) async => chatPage([]);
addTearDown(gateway.close);
await tester.pumpWidget(
MaterialApp(
theme: ThemeData(platform: TargetPlatform.android),
home: AdaptiveShell(
cupertino: false,
destination: AppDestination.chat,
destinationBodies: {
AppDestination.chat: (_) => ChatScreen(gateway: gateway),
},
),
),
);
await tester.pumpAndSettle();
await tester.tap(find.text('Chat a').first);
await tester.pumpAndSettle();
}
void _expectComposerBottom(WidgetTester tester, double expected) {
final pill = find.descendant(
of: _thread('a'),
matching: find.byKey(const Key('chat-composer-pill')),
);
expect(tester.getBottomLeft(pill).dy, closeTo(expected, 1));
expect(tester.takeException(), isNull);
}
Color _border(WidgetTester tester, String id) {
final box = tester.widget<DecoratedBox>(
find
.ancestor(
of: _thread(id),
matching: find.byWidgetPredicate(
(widget) =>
widget is DecoratedBox &&
widget.position == DecorationPosition.foreground &&
widget.decoration is BoxDecoration &&
(widget.decoration as BoxDecoration).border is Border,
),
)
.first,
);
return ((box.decoration as BoxDecoration).border! as Border).top.color;
}
void main() {
testWidgets(
'Android pushed chat clears gesture bar once and keyboard correctly',
(tester) async {
await _mount(tester, const Size(390, 844));
_expectComposerBottom(tester, 844 - 24 - kChatComposerBottomMargin);
tester.view.viewInsets = const FakeViewPadding(bottom: 300);
tester.view.padding = const FakeViewPadding(top: 24);
await tester.pumpAndSettle();
_expectComposerBottom(tester, 844 - 300 - kChatComposerBottomMargin);
},
);
testWidgets(
'retained workspace restores Android bottom safe area on phone resize',
(tester) async {
await _mount(tester, const Size(1400, 900));
final state = tester.state(_thread('a'));
tester.view.physicalSize = const Size(390, 844);
await tester.pumpAndSettle();
expect(tester.state(_thread('a')), same(state));
_expectComposerBottom(tester, 844 - 24 - kChatComposerBottomMargin);
},
);
testWidgets('active pane border follows chat color and uncolored fallback', (
tester,
) async {
await _mount(tester, const Size(1800, 1000));
final controller = tester
.widget<ChatWorkspace>(find.byType(ChatWorkspace))
.controller;
controller.splitActive('b', ChatSplitAxis.horizontal);
await tester.pumpAndSettle();
expect(_border(tester, 'a'), Colors.transparent);
expect(
_border(tester, 'b'),
chatColorShade(tester.element(_thread('b')), 'teal'),
);
controller.activate(
controller.panes.firstWhere((p) => p.sessionId == 'a').id,
);
await tester.pumpAndSettle();
expect(
_border(tester, 'a'),
chatColorShade(tester.element(_thread('a')), 'orange'),
);
expect(_border(tester, 'b'), Colors.transparent);
controller.splitActive('c', ChatSplitAxis.vertical);
await tester.pumpAndSettle();
expect(
_border(tester, 'c'),
Theme.of(tester.element(_thread('c'))).colorScheme.primary,
);
expect(tester.takeException(), isNull);
});
}