feat(app): choose a chat model from the conversation header
Native model control and chooser in the chat thread header, matching the web chat_models/chat_model exchange. Fixes the chat_models list parsing, keeps the accepted server echo across Back/reopen, and resolves the session row for /chat/:id deep links.
This commit is contained in:
@@ -21,6 +21,7 @@ class ChatSessionsScreen extends StatefulWidget {
|
||||
required this.onOpen,
|
||||
this.embedded = false,
|
||||
this.syncToken = 0,
|
||||
this.onSessions,
|
||||
this.localStore,
|
||||
});
|
||||
final ApiGateway gateway;
|
||||
@@ -33,6 +34,11 @@ class ChatSessionsScreen extends StatefulWidget {
|
||||
/// closed elsewhere during the gap must not stay invisible until Refresh.
|
||||
final int syncToken;
|
||||
|
||||
/// Reports the loaded rows after a frame. The destination resolves a routed
|
||||
/// session id (a deep link) from them, so that conversation gets the same
|
||||
/// title and model facts as a tapped row without a second list request.
|
||||
final ValueChanged<List<JsonMap>>? onSessions;
|
||||
|
||||
/// Overrides the device-local hidden/read store in tests.
|
||||
final ChatSessionLocalStore? localStore;
|
||||
|
||||
@@ -48,6 +54,22 @@ class _ChatSessionsScreenState extends State<ChatSessionsScreen> {
|
||||
final _search = TextEditingController();
|
||||
Timer? _undoTimer;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_controller.addListener(_reportSessions);
|
||||
}
|
||||
|
||||
/// Reports the loaded rows at the end of the frame: the destination learns a
|
||||
/// routed row without this screen calling back inside its own build.
|
||||
void _reportSessions() {
|
||||
if (widget.onSessions == null) return;
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
if (!mounted) return;
|
||||
widget.onSessions?.call(_controller.sessions);
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
void didUpdateWidget(covariant ChatSessionsScreen oldWidget) {
|
||||
super.didUpdateWidget(oldWidget);
|
||||
@@ -61,6 +83,7 @@ class _ChatSessionsScreenState extends State<ChatSessionsScreen> {
|
||||
@override
|
||||
void dispose() {
|
||||
_undoTimer?.cancel();
|
||||
_controller.removeListener(_reportSessions);
|
||||
_controller.dispose();
|
||||
_search.dispose();
|
||||
super.dispose();
|
||||
|
||||
Reference in New Issue
Block a user