merge(app): land chat conversation bar order
This commit is contained in:
@@ -291,7 +291,8 @@ class _ChatThreadViewState extends State<ChatThreadView> {
|
||||
/// The runner for this session's `/new`, `/close` and `/rename`, rebuilt per
|
||||
/// build so an adopted row's directory and title are the current ones.
|
||||
ChatCommandActions _commandActions() {
|
||||
final session = widget.session ?? {'id': widget.sessionId, 'title': widget.title};
|
||||
final session =
|
||||
widget.session ?? {'id': widget.sessionId, 'title': widget.title};
|
||||
final onCreated = widget.onCreatedSession;
|
||||
return ChatCommandActions(
|
||||
repository: ChatRepository(widget.gateway),
|
||||
@@ -299,8 +300,8 @@ class _ChatThreadViewState extends State<ChatThreadView> {
|
||||
directory: '${session['directory'] ?? ''}'.trim(),
|
||||
showNotice: _showCommandNotice,
|
||||
confirmClose: () => confirmCloseChat(context, session),
|
||||
openCreatedSession: onCreated ??
|
||||
(created, notice) => _showCommandNotice(notice),
|
||||
openCreatedSession:
|
||||
onCreated ?? (created, notice) => _showCommandNotice(notice),
|
||||
onRenamed: widget.onSessionRenamed,
|
||||
onClosed: widget.onSessionClosed,
|
||||
newOperationId: widget.newOperationId,
|
||||
@@ -552,8 +553,7 @@ class _ChatThreadViewState extends State<ChatThreadView> {
|
||||
/// table's horizontal scroll bubbles through this listener too and must not
|
||||
/// release the conversation's follow intent.
|
||||
bool _onScrollNotification(ScrollNotification notification) {
|
||||
if (notification.depth != 0 ||
|
||||
notification.metrics.axis != Axis.vertical) {
|
||||
if (notification.depth != 0 || notification.metrics.axis != Axis.vertical) {
|
||||
return false;
|
||||
}
|
||||
if (notification is UserScrollNotification) {
|
||||
@@ -662,6 +662,70 @@ class _ChatThreadViewState extends State<ChatThreadView> {
|
||||
_scheduleFollow();
|
||||
return Column(
|
||||
children: [
|
||||
// The conversation's own bar first, outside the transcript's scroller,
|
||||
// as on the web (chat-bar, then background tasks, then transcript).
|
||||
Padding(
|
||||
key: const Key('chat-thread-header'),
|
||||
padding: const EdgeInsetsDirectional.fromSTEB(4, 8, 4, 4),
|
||||
child: LayoutBuilder(
|
||||
builder: (context, constraints) {
|
||||
final title = widget.title.trim();
|
||||
final session = widget.session;
|
||||
final hasModel =
|
||||
session != null &&
|
||||
supportsChatModels('${session['backend'] ?? ''}');
|
||||
// One compact row, as on the web: back, the conversation's
|
||||
// name, its model and the information action. The title
|
||||
// takes the remaining width and ellipsises; the model keeps
|
||||
// a bounded share so neither control is pushed off a narrow
|
||||
// 2x phone and the header never wraps onto a second line.
|
||||
return Row(
|
||||
children: [
|
||||
_backButton(cupertino),
|
||||
Expanded(
|
||||
child: Padding(
|
||||
padding: const EdgeInsetsDirectional.only(start: 4),
|
||||
child: title.isEmpty
|
||||
? const SizedBox.shrink()
|
||||
: Text(
|
||||
title,
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style: cupertino
|
||||
? CupertinoTheme.of(
|
||||
context,
|
||||
).textTheme.navTitleTextStyle
|
||||
: Theme.of(context).textTheme.titleLarge,
|
||||
),
|
||||
),
|
||||
),
|
||||
if (hasModel)
|
||||
ConstrainedBox(
|
||||
constraints: BoxConstraints(
|
||||
maxWidth: constraints.maxWidth * 0.4,
|
||||
),
|
||||
child: ChatModelControl(
|
||||
key: ValueKey<String>(
|
||||
'chat-model-${widget.sessionId}',
|
||||
),
|
||||
gateway: widget.gateway,
|
||||
sessionId: widget.sessionId,
|
||||
session: session,
|
||||
onChanged: widget.onModelChanged,
|
||||
),
|
||||
),
|
||||
ChatBarAction(
|
||||
key: const Key('chat-info'),
|
||||
label: 'Chat information',
|
||||
onPressed: _openInfo,
|
||||
materialIcon: Icons.info_outline,
|
||||
cupertinoIcon: CupertinoIcons.info,
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
// The session's still-running background tasks, above the transcript
|
||||
// and outside its scroller (web C11). It removes itself when the last
|
||||
// task exits and never draws a finished task.
|
||||
@@ -683,72 +747,6 @@ class _ChatThreadViewState extends State<ChatThreadView> {
|
||||
controller: _scroll,
|
||||
padding: const EdgeInsets.symmetric(vertical: 8),
|
||||
children: [
|
||||
Padding(
|
||||
key: const Key('chat-thread-header'),
|
||||
padding: const EdgeInsetsDirectional.fromSTEB(4, 0, 4, 4),
|
||||
child: LayoutBuilder(
|
||||
builder: (context, constraints) {
|
||||
final title = widget.title.trim();
|
||||
final session = widget.session;
|
||||
final hasModel =
|
||||
session != null &&
|
||||
supportsChatModels('${session['backend'] ?? ''}');
|
||||
// One compact row, as on the web: back, the conversation's
|
||||
// name, its model and the information action. The title
|
||||
// takes the remaining width and ellipsises; the model keeps
|
||||
// a bounded share so neither control is pushed off a narrow
|
||||
// 2x phone and the header never wraps onto a second line.
|
||||
return Row(
|
||||
children: [
|
||||
_backButton(cupertino),
|
||||
Expanded(
|
||||
child: Padding(
|
||||
padding: const EdgeInsetsDirectional.only(
|
||||
start: 4,
|
||||
),
|
||||
child: title.isEmpty
|
||||
? const SizedBox.shrink()
|
||||
: Text(
|
||||
title,
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style: cupertino
|
||||
? CupertinoTheme.of(
|
||||
context,
|
||||
).textTheme.navTitleTextStyle
|
||||
: Theme.of(
|
||||
context,
|
||||
).textTheme.titleLarge,
|
||||
),
|
||||
),
|
||||
),
|
||||
if (hasModel)
|
||||
ConstrainedBox(
|
||||
constraints: BoxConstraints(
|
||||
maxWidth: constraints.maxWidth * 0.4,
|
||||
),
|
||||
child: ChatModelControl(
|
||||
key: ValueKey<String>(
|
||||
'chat-model-${widget.sessionId}',
|
||||
),
|
||||
gateway: widget.gateway,
|
||||
sessionId: widget.sessionId,
|
||||
session: session,
|
||||
onChanged: widget.onModelChanged,
|
||||
),
|
||||
),
|
||||
ChatBarAction(
|
||||
key: const Key('chat-info'),
|
||||
label: 'Chat information',
|
||||
onPressed: _openInfo,
|
||||
materialIcon: Icons.info_outline,
|
||||
cupertinoIcon: CupertinoIcons.info,
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
if (initialLoad)
|
||||
Padding(
|
||||
key: const Key('chat-thread-loading'),
|
||||
@@ -813,7 +811,9 @@ class _ChatThreadViewState extends State<ChatThreadView> {
|
||||
rows[index],
|
||||
onDismissCompaction:
|
||||
compactionNotice != null &&
|
||||
chatNoticeActivityCondition(rows[index]) ==
|
||||
chatNoticeActivityCondition(
|
||||
rows[index],
|
||||
) ==
|
||||
compactionNotice.condition
|
||||
? () => _dismiss(compactionNotice)
|
||||
: null,
|
||||
@@ -840,17 +840,17 @@ class _ChatThreadViewState extends State<ChatThreadView> {
|
||||
),
|
||||
],
|
||||
),
|
||||
if (showJump)
|
||||
PositionedDirectional(
|
||||
end: 16,
|
||||
bottom: 16,
|
||||
child: _ChatJumpToLatest(
|
||||
key: const Key('chat-jump-to-latest'),
|
||||
label: chatJumpToLatestLabel(newMessages),
|
||||
cupertino: cupertino,
|
||||
onPressed: _followLatest,
|
||||
if (showJump)
|
||||
PositionedDirectional(
|
||||
end: 16,
|
||||
bottom: 16,
|
||||
child: _ChatJumpToLatest(
|
||||
key: const Key('chat-jump-to-latest'),
|
||||
label: chatJumpToLatestLabel(newMessages),
|
||||
cupertino: cupertino,
|
||||
onPressed: _followLatest,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
@@ -278,7 +278,19 @@ void main() {
|
||||
final control = find.byKey(
|
||||
const ValueKey<String>('chat-activity-toggle'),
|
||||
);
|
||||
await tester.ensureVisible(control);
|
||||
// Drag like an operator: a programmatic scroll is undone by the
|
||||
// view's follow-to-latest, while a user drag stops following.
|
||||
final list = find.byKey(const ValueKey<String>('chat-thread-s'));
|
||||
final viewport = tester.getRect(list);
|
||||
for (var i = 0; i < 10; i++) {
|
||||
final rect = tester.getRect(control);
|
||||
if (rect.top >= viewport.top && rect.bottom <= viewport.bottom) break;
|
||||
await tester.drag(
|
||||
list,
|
||||
Offset(0, rect.top < viewport.top ? 200 : -200),
|
||||
);
|
||||
await tester.pumpAndSettle();
|
||||
}
|
||||
await tester.tap(control);
|
||||
await tester.pumpAndSettle();
|
||||
}
|
||||
|
||||
@@ -579,4 +579,25 @@ void main() {
|
||||
expect(find.text('Background tasks'), findsOneWidget);
|
||||
expect(find.text('1 running'), findsOneWidget);
|
||||
});
|
||||
|
||||
testWidgets('the conversation bar leads, above the task bar', (tester) async {
|
||||
final gateway = _TasksGateway();
|
||||
gateway.shells = () async => _snapshot([_running('sh1')]);
|
||||
addTearDown(gateway.close);
|
||||
|
||||
await tester.pumpWidget(_thread(gateway));
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
final header = tester.getRect(find.byKey(const Key('chat-thread-header')));
|
||||
final tasks = tester.getRect(
|
||||
find.byKey(const Key('chat-background-tasks')),
|
||||
);
|
||||
final list = tester.getRect(
|
||||
find.byKey(const ValueKey<String>('chat-thread-s')),
|
||||
);
|
||||
expect(header.top, 0);
|
||||
expect(tasks.top, greaterThanOrEqualTo(header.bottom));
|
||||
// The bar sits outside the transcript's scroller, as the web's chat-bar.
|
||||
expect(list.top, greaterThanOrEqualTo(tasks.bottom));
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user