feat: a settings page, a server footer in the sidebar, and follow-up behaviour

- The sidebar's server switch moves to a footer bar: the connected server's
  name on the left (tap for the server sheet) and a settings key on the
  right, matching the first-party phone layout.
- Settings has three groups: 外观 (theme mode and seed colour, stored on the
  device only in shared_preferences), 聊天 (the server's followUpBehavior:
  steer or queue) and a 宠物 placeholder. The app theme now reads the seed
  and mode.
- The chat's short send while a turn runs uses the configured follow-up
  behaviour; the long-press sheet offers both and marks the default. The
  value is read from GET /api/config/settings?surface=mobile on connect, on
  resume and when the page opens, and written back with PUT.
- Tests: settings page groups and choice, sidebar footer naming the server
  and opening settings, follow-up normalization.
- 0.3.17 (317).
This commit is contained in:
blumia committed 2026-11-21 19:17:22 +08:00
1 parent 1aa84a53e5
commit e646130d1f
13 files changed
+544 -15

No files matched your search

+13
View File
@@ -0,0 +1,13 @@
import 'package:flutter_test/flutter_test.dart';
import 'package:openchamber/state.dart';
void main() {
test('follow-up behavior reads as the first-party default when unknown', () {
expect(AppState.normalizeFollowUp('steer'), 'steer');
// The removed "immediate" mode was wire-identical to steer.
expect(AppState.normalizeFollowUp('immediate'), 'steer');
expect(AppState.normalizeFollowUp('queue'), 'queue');
expect(AppState.normalizeFollowUp(null), 'queue');
expect(AppState.normalizeFollowUp('bogus'), 'queue');
});
}
+33
View File
@@ -0,0 +1,33 @@
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:openchamber/screens/settings_screen.dart';
import 'package:openchamber/state.dart';
void main() {
testWidgets('settings shows appearance, chat and the pet placeholder',
(tester) async {
final app = AppState();
addTearDown(app.dispose);
await tester.pumpWidget(MaterialApp(home: SettingsScreen(app: app)));
expect(find.text('外观'), findsOneWidget);
expect(find.text('聊天'), findsOneWidget);
expect(find.text('宠物'), findsOneWidget);
expect(find.text('主题模式'), findsOneWidget);
expect(find.text('主题色'), findsOneWidget);
expect(find.text('追问处理行为'), findsOneWidget);
expect(find.text('暂未提供设置'), findsOneWidget);
// The choice is the server-backed follow-up behavior.
ChoiceChip chip(String label) =>
tester.widget<ChoiceChip>(find.widgetWithText(ChoiceChip, label));
expect(chip('排队').selected, isTrue);
await tester.tap(find.text('转向'));
await tester.pumpAndSettle();
expect(app.followUpBehavior, 'steer');
expect(chip('转向').selected, isTrue);
expect(chip('排队').selected, isFalse);
});
}
+33
View File
@@ -0,0 +1,33 @@
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:openchamber/screens/sessions_screen.dart';
import 'package:openchamber/state.dart';
import 'package:openchamber/storage.dart';
void main() {
testWidgets('the sidebar footer names the server and opens settings',
(tester) async {
final app = AppState();
app.conn = Connection(
id: 'c1',
label: '家里的服务器',
url: 'http://127.0.0.1:3000',
);
addTearDown(app.dispose);
await tester.pumpWidget(MaterialApp(
home: Scaffold(body: SessionListPane(app: app)),
));
expect(find.text('家里的服务器'), findsOneWidget);
expect(find.byIcon(Icons.dns_outlined), findsOneWidget);
expect(find.byTooltip('设置'), findsOneWidget);
await tester.tap(find.byTooltip('设置'));
await tester.pumpAndSettle();
// The settings page replaced the shell.
expect(find.text('外观'), findsOneWidget);
expect(find.text('聊天'), findsOneWidget);
expect(find.text('宠物'), findsOneWidget);
});
}