feat: queue a message for the running turn, and fold the composer when the IME closes
- A send while a turn runs joins it (delivery "steer") on a short press; a long press offers steer or queue. Queue/steer prompts wait in the server's inbox and show as a pending bubble at the end of the transcript, with 改为排队/转为转向 and 撤回 (which puts the text back into the composer). The inbox is read on open and resume and kept current by the session.inbox.* events; delivery reloads the tail. - The send key is stop only while running with an empty draft; with text it sends (as dsh-Go does), leaving the long press for the delivery choice. - The composer also folds to one line when the phone's back gesture closes the keyboard while the field keeps focus: the page passes the keyboard height (a Scaffold strips the bottom inset from its body) and the composer treats a fall below half the peak as a dismissal. - The Build/Plan chip now opens a bottom sheet with icons, hints and a check, instead of a popup menu. - Tests: composer_box_test (focus opens, IME dismissal folds, typing reopens) and inbox_item_test (list items, enqueued events, delivery changes). - 0.3.16 (316).
This commit is contained in:
1 parent
ea3b1f0f5e
commit
1aa84a53e5
13 files changed
+655
-49
No files matched your search
@@ -0,0 +1,60 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:openchamber/widgets/composer_box.dart';
|
||||
|
||||
void main() {
|
||||
testWidgets('the composer opens on focus and folds when the IME closes',
|
||||
(tester) async {
|
||||
final controller = TextEditingController();
|
||||
final focus = FocusNode();
|
||||
final keyboard = ValueNotifier<double>(0);
|
||||
addTearDown(controller.dispose);
|
||||
addTearDown(focus.dispose);
|
||||
addTearDown(keyboard.dispose);
|
||||
|
||||
// A stand-in for the second row's contents: it only exists while open.
|
||||
const model = Text('MODEL');
|
||||
|
||||
// The page owns the keyboard inset (a Scaffold removes it from the body),
|
||||
// so the test feeds it in as the screens do.
|
||||
await tester.pumpWidget(MaterialApp(
|
||||
home: ValueListenableBuilder<double>(
|
||||
valueListenable: keyboard,
|
||||
builder: (context, inset, _) => Scaffold(
|
||||
body: ComposerBox(
|
||||
controller: controller,
|
||||
focusNode: focus,
|
||||
hint: 'hi',
|
||||
keyboardInset: inset,
|
||||
leading: const Icon(Icons.attach_file),
|
||||
model: model,
|
||||
trailing: const Icon(Icons.send),
|
||||
),
|
||||
),
|
||||
),
|
||||
));
|
||||
// Unfocused: one line, no model pill.
|
||||
expect(find.text('MODEL'), findsNothing);
|
||||
|
||||
// Focus: the composer opens into two rows.
|
||||
focus.requestFocus();
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.text('MODEL'), findsOneWidget);
|
||||
|
||||
// The soft keyboard rises, then the back gesture closes it while the
|
||||
// field keeps focus: the composer folds back to one line.
|
||||
keyboard.value = 300;
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.text('MODEL'), findsOneWidget);
|
||||
|
||||
keyboard.value = 0;
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.text('MODEL'), findsNothing);
|
||||
expect(focus.hasFocus, isTrue);
|
||||
|
||||
// Typing again brings the keyboard back: the composer opens.
|
||||
keyboard.value = 300;
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.text('MODEL'), findsOneWidget);
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:openchamber/api/models.dart';
|
||||
|
||||
void main() {
|
||||
test('an inbox list item parses its text, delivery and files', () {
|
||||
final item = InboxItem.fromJson({
|
||||
'id': 'msg_1',
|
||||
'sessionID': 'ses_1',
|
||||
'time': {'created': 123},
|
||||
'type': 'user',
|
||||
'delivery': 'queue',
|
||||
'payload': {
|
||||
'text': 'hello',
|
||||
'files': [
|
||||
{'name': 'a.png', 'mime': 'image/png', 'data': 'AAAA'},
|
||||
],
|
||||
},
|
||||
});
|
||||
expect(item.id, 'msg_1');
|
||||
expect(item.text, 'hello');
|
||||
expect(item.delivery, 'queue');
|
||||
expect(item.created, 123);
|
||||
expect(item.files.single.name, 'a.png');
|
||||
});
|
||||
|
||||
test('an enqueued event carries the id beside the item', () {
|
||||
final item = InboxItem.fromEvent(
|
||||
'msg_2',
|
||||
{
|
||||
'type': 'user',
|
||||
'delivery': 'steer',
|
||||
'payload': {'text': 'steer me'},
|
||||
},
|
||||
456,
|
||||
);
|
||||
expect(item.id, 'msg_2');
|
||||
expect(item.text, 'steer me');
|
||||
expect(item.delivery, 'steer');
|
||||
expect(item.created, 456);
|
||||
});
|
||||
|
||||
test('withDelivery keeps the rest', () {
|
||||
final item = const InboxItem(id: 'm', text: 't', delivery: 'queue');
|
||||
expect(item.withDelivery('steer').delivery, 'steer');
|
||||
expect(item.withDelivery('steer').text, 't');
|
||||
});
|
||||
}
|
||||
Reference in new issue
Block a user