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:
2026-10-22 12:28:13 +01:00
parent 81b2805cdd
commit 2a66be7b27
11 changed files with 1415 additions and 30 deletions
@@ -0,0 +1,370 @@
import 'dart:async';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import '../../../core/api_gateway.dart';
import '../../../core/error_reason.dart';
import '../data/chat_repository.dart';
import 'chat_models.dart';
/// The native model chooser.
///
/// It loads the recorded catalog once, offers the web's search over name, id
/// and provider, shows the server's rows in server order, and keeps the
/// previous model when a switch is refused. Acceptance is reported to the
/// conversation even when the operator dismisses the chooser while the switch
/// is still in flight, because the server has already applied it.
class ChatModelChooser extends StatefulWidget {
const ChatModelChooser({
super.key,
required this.gateway,
required this.sessionId,
required this.backend,
required this.currentProvider,
required this.currentModel,
required this.cupertino,
required this.onAccepted,
});
final ApiGateway gateway;
final String sessionId;
final String backend;
final String currentProvider;
final String currentModel;
final bool cupertino;
final ValueChanged<ChatModelSelection> onAccepted;
@override
State<ChatModelChooser> createState() => _ChatModelChooserState();
}
class _ChatModelChooserState extends State<ChatModelChooser> {
final TextEditingController _search = TextEditingController();
List<JsonMap> _models = const [];
bool _loading = true;
bool _busy = false;
String? _error;
@override
void initState() {
super.initState();
unawaited(_load());
}
@override
void dispose() {
_search.dispose();
super.dispose();
}
Future<void> _load() async {
try {
final catalog = await ChatRepository(
widget.gateway,
).models(widget.sessionId);
if (!mounted) return;
setState(() {
_models = catalog;
_loading = false;
});
} catch (error) {
if (!mounted) return;
setState(() {
_loading = false;
_error = describeErrorReason(
error,
fallback: 'The model list could not be loaded.',
);
});
}
}
bool _isCurrent(JsonMap model) {
final id = '${model['id'] ?? ''}'.trim();
if (id != widget.currentModel) return false;
final provider = '${model['provider'] ?? ''}'.trim();
return widget.currentProvider.isEmpty || provider == widget.currentProvider;
}
Key _optionKey(JsonMap model) => ValueKey<String>(
'chat-model-option-${model['provider'] ?? ''}/${model['id'] ?? ''}',
);
Future<void> _choose(JsonMap model) async {
if (_busy) return;
setState(() {
_busy = true;
_error = null;
});
final provider = '${model['provider'] ?? ''}'.trim();
final id = '${model['id'] ?? ''}'.trim();
try {
final reply = await ChatRepository(
widget.gateway,
).selectModel(widget.sessionId, provider, id);
final applied = _appliedSelection(reply, provider: provider, model: id);
// The accepted switch belongs to the conversation, not to this dialog.
widget.onAccepted(applied);
if (!mounted) return;
Navigator.of(context).pop();
} catch (error) {
if (!mounted) return;
setState(() {
_busy = false;
_error = describeErrorReason(
error,
fallback: 'The model was not changed.',
);
});
}
}
/// The server's echo wins; a reply that omits a field keeps the value the
/// request carried, matching the web repository's fallback.
ChatModelSelection _appliedSelection(
JsonMap reply, {
required String provider,
required String model,
}) {
final echoed = reply['chat_model'];
final body = echoed is Map
? Map<String, dynamic>.from(echoed)
: const <String, dynamic>{};
final replyProvider = '${body['provider'] ?? ''}'.trim();
final replyModel = '${body['model'] ?? ''}'.trim();
return (
provider: replyProvider.isEmpty ? provider : replyProvider,
model: replyModel.isEmpty ? model : replyModel,
selection: '${body['selection'] ?? ''}'.trim(),
);
}
@override
Widget build(BuildContext context) =>
widget.cupertino ? _cupertinoChooser(context) : _materialChooser(context);
/// Whether the catalog loaded far enough to search it.
bool get _hasCatalog => !_loading && _error == null && _models.isNotEmpty;
Widget _materialChooser(BuildContext context) {
final theme = Theme.of(context);
final secondary = theme.colorScheme.onSurfaceVariant;
final matches = filterChatModels(_models, _search.text);
final needle = _search.text.trim();
return SimpleDialog(
key: const Key('chat-model-chooser'),
title: const Text('Change model'),
children: [
Padding(
padding: const EdgeInsetsDirectional.fromSTEB(24, 0, 24, 8),
child: Text(
chatModelSelectionNote(widget.backend),
style: theme.textTheme.bodySmall?.copyWith(color: secondary),
),
),
if (_loading)
Padding(
padding: const EdgeInsetsDirectional.fromSTEB(24, 8, 24, 8),
child: Row(
children: [
const CircularProgressIndicator(),
const SizedBox(width: 12),
const Expanded(child: Text('Loading models…')),
],
),
)
else if (_error != null)
Padding(
padding: const EdgeInsetsDirectional.fromSTEB(24, 0, 24, 8),
child: Text(
_error!,
key: const Key('chat-model-error'),
style: theme.textTheme.bodyMedium?.copyWith(
color: theme.colorScheme.error,
),
),
)
else if (_models.isEmpty)
Padding(
padding: const EdgeInsetsDirectional.fromSTEB(24, 0, 24, 8),
child: Text(
'No models are available for this chat.',
style: theme.textTheme.bodyMedium?.copyWith(color: secondary),
),
)
else ...[
Padding(
padding: const EdgeInsetsDirectional.fromSTEB(24, 0, 24, 8),
child: TextField(
key: const Key('chat-model-search'),
controller: _search,
onChanged: (_) => setState(() {}),
decoration: const InputDecoration(
prefixIcon: Icon(Icons.search),
hintText: 'Search models',
),
),
),
for (final model in matches)
SimpleDialogOption(
key: _optionKey(model),
onPressed: _busy ? null : () => _choose(model),
child: _optionRow(context, model, cupertino: false),
),
if (matches.isEmpty && needle.isNotEmpty)
Padding(
padding: const EdgeInsetsDirectional.fromSTEB(24, 0, 24, 8),
child: Text(
'No models match "$needle".',
key: const Key('chat-model-no-match'),
style: theme.textTheme.bodyMedium?.copyWith(color: secondary),
),
),
],
Padding(
padding: const EdgeInsetsDirectional.fromSTEB(16, 4, 16, 8),
child: Align(
alignment: AlignmentDirectional.centerEnd,
child: TextButton(
key: const Key('chat-model-cancel'),
onPressed: () => Navigator.of(context).pop(),
child: const Text('Cancel'),
),
),
),
],
);
}
Widget _cupertinoChooser(BuildContext context) {
final secondary = CupertinoColors.secondaryLabel.resolveFrom(context);
final error = CupertinoColors.systemRed.resolveFrom(context);
final matches = filterChatModels(_models, _search.text);
final needle = _search.text.trim();
return CupertinoActionSheet(
key: const Key('chat-model-chooser'),
title: const Text('Change model'),
message: Column(
mainAxisSize: MainAxisSize.min,
children: [
Text(
chatModelSelectionNote(widget.backend),
textAlign: TextAlign.center,
),
if (_hasCatalog)
Padding(
padding: const EdgeInsetsDirectional.only(top: 12),
// The search field sits in the sheet's message slot: a native
// search field is the only way to type here, and the sheet's own
// scroll keeps a long catalog reachable.
child: CupertinoSearchTextField(
key: const Key('chat-model-search'),
controller: _search,
placeholder: 'Search models',
onChanged: (_) => setState(() {}),
),
),
if (_loading)
const Padding(
padding: EdgeInsetsDirectional.only(top: 12),
child: Row(
mainAxisSize: MainAxisSize.min,
mainAxisAlignment: MainAxisAlignment.center,
children: [
CupertinoActivityIndicator(),
SizedBox(width: 8),
Flexible(child: Text('Loading models…')),
],
),
)
else if (_error != null)
Padding(
padding: const EdgeInsetsDirectional.only(top: 8),
child: Text(
_error!,
key: const Key('chat-model-error'),
textAlign: TextAlign.center,
style: TextStyle(color: error),
),
)
else if (_models.isEmpty)
Padding(
padding: const EdgeInsetsDirectional.only(top: 8),
child: Text(
'No models are available for this chat.',
textAlign: TextAlign.center,
style: TextStyle(color: secondary),
),
)
else if (matches.isEmpty && needle.isNotEmpty)
Padding(
padding: const EdgeInsetsDirectional.only(top: 8),
child: Text(
'No models match "$needle".',
key: const Key('chat-model-no-match'),
textAlign: TextAlign.center,
style: TextStyle(color: secondary),
),
),
],
),
actions: _hasCatalog
? [
for (final model in matches)
CupertinoActionSheetAction(
key: _optionKey(model),
isDefaultAction: _isCurrent(model),
onPressed: () {
if (!_busy) _choose(model);
},
child: _optionRow(context, model, cupertino: true),
),
]
: null,
cancelButton: CupertinoActionSheetAction(
key: const Key('chat-model-cancel'),
onPressed: () => Navigator.of(context).pop(),
child: const Text('Cancel'),
),
);
}
Widget _optionRow(
BuildContext context,
JsonMap model, {
required bool cupertino,
}) {
final selected = _isCurrent(model);
final secondary = cupertino
? CupertinoColors.secondaryLabel.resolveFrom(context)
: Theme.of(context).colorScheme.onSurfaceVariant;
final accent = cupertino
? CupertinoTheme.of(context).primaryColor
: Theme.of(context).colorScheme.primary;
final provider = '${model['provider'] ?? ''}'.trim();
return Semantics(
selected: selected,
child: Row(
children: [
Expanded(
child: Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(chatModelName(model)),
if (provider.isNotEmpty)
Text(provider, style: TextStyle(color: secondary)),
],
),
),
if (selected)
Icon(
cupertino ? CupertinoIcons.check_mark : Icons.check,
color: accent,
),
],
),
);
}
}
@@ -0,0 +1,138 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import '../../../core/api_gateway.dart';
import '../ui/sessions/chat_adaptive.dart';
import 'chat_model_chooser.dart';
import 'chat_models.dart';
/// The conversation header's model control.
///
/// It shows the opened row's recorded model (with the web's next-turn suffix)
/// and opens the harness's own catalog in a native chooser. Choosing an entry
/// sends the web's `chat_model` request. A refusal leaves this control's model
/// untouched and reports the reason in the chooser; an acceptance adopts the
/// server's echoed model instead of the row that was tapped and reports it, so
/// the destination's opened row keeps up with the server.
class ChatModelControl extends StatefulWidget {
const ChatModelControl({
super.key,
required this.gateway,
required this.sessionId,
required this.session,
this.onChanged,
});
final ApiGateway gateway;
final String sessionId;
/// The opened row's recorded facts: `backend`, `model`, `model_provider` and
/// `model_selection`.
final JsonMap session;
/// The server's echo after an accepted switch.
final ValueChanged<ChatModelSelection>? onChanged;
@override
State<ChatModelControl> createState() => _ChatModelControlState();
}
class _ChatModelControlState extends State<ChatModelControl> {
late String _provider;
late String _model;
late String _selection;
@override
void initState() {
super.initState();
_adopt(widget.session);
}
@override
void didUpdateWidget(covariant ChatModelControl oldWidget) {
super.didUpdateWidget(oldWidget);
// The destination replaces the opened row after an accepted switch (and may
// re-read the list), so a changed row is adopted instead of only read once.
if (chatModelRecordedFacts(oldWidget.session) !=
chatModelRecordedFacts(widget.session)) {
_adopt(widget.session);
}
}
void _adopt(JsonMap session) {
final facts = chatModelRecordedFacts(session);
_provider = facts.provider;
_model = facts.model;
_selection = facts.selection;
}
Future<void> _open() async {
final cupertino =
chatControlsStyleOf(context) == ChatControlsStyle.cupertino;
final chooser = ChatModelChooser(
gateway: widget.gateway,
sessionId: widget.sessionId,
backend: '${widget.session['backend'] ?? ''}'.trim(),
currentProvider: _provider,
currentModel: _model,
cupertino: cupertino,
onAccepted: _accept,
);
if (cupertino) {
await showCupertinoModalPopup<void>(
context: context,
builder: (_) => chooser,
);
return;
}
await showDialog<void>(context: context, builder: (_) => chooser);
}
void _accept(ChatModelSelection applied) {
// The server has applied the switch, so the destination is told even if
// this conversation was left while the request was in flight.
widget.onChanged?.call(applied);
if (!mounted) return;
setState(() {
_provider = applied.provider;
_model = applied.model;
_selection = applied.selection;
});
}
@override
Widget build(BuildContext context) {
final cupertino =
chatControlsStyleOf(context) == ChatControlsStyle.cupertino;
final label = chatModelLabel(_model, _selection);
final content = Row(
mainAxisSize: MainAxisSize.min,
children: [
Flexible(child: Text(label, overflow: TextOverflow.ellipsis)),
const SizedBox(width: 4),
Icon(cupertino ? CupertinoIcons.chevron_down : Icons.expand_more),
],
);
const key = Key('chat-model');
if (cupertino) {
return Semantics(
container: true,
button: true,
label: 'Change model, currently $label',
onTap: _open,
child: ExcludeSemantics(
child: CupertinoButton(
key: key,
padding: const EdgeInsets.symmetric(horizontal: 8),
onPressed: _open,
child: content,
),
),
);
}
return Tooltip(
message: 'Change model (currently $label)',
child: TextButton(key: key, onPressed: _open, child: content),
);
}
}
@@ -0,0 +1,62 @@
import '../../../core/api_gateway.dart';
/// A model switch the server accepted, as its own reply reported it.
typedef ChatModelSelection = ({
String provider,
String model,
String selection,
});
/// Harnesses with a verified catalog and model-selection path, matching the
/// web's `supportsChatModels`.
bool supportsChatModels(String backend) =>
const ['', 'opencode', 'codex'].contains(backend.trim());
/// The recorded current model, or the web's "Model" when none was recorded.
String chatModelLabel(String model, String selection) {
final recorded = model.trim();
final label = recorded.isEmpty ? 'Model' : recorded;
return selection == 'next_turn' ? '$label · next turn' : label;
}
/// The helper shown above the catalog, verbatim from the web.
String chatModelSelectionNote(String backend) => backend.trim() == 'codex'
? 'Saved by Pipelines for the next turn you send. Does not resume this '
'thread or edit global Codex configuration.'
: 'Applies to the next turn in this chat.';
/// A model's display name, or its id when the server gave no name.
String chatModelName(JsonMap model) {
final name = '${model['name'] ?? ''}'.trim();
return name.isNotEmpty ? name : '${model['id'] ?? ''}'.trim();
}
/// The rows a query matches: a case-insensitive substring over the display
/// name, id and provider, in the server's order. A blank query keeps the whole
/// catalog, and a row with neither name nor id is never offered.
List<JsonMap> filterChatModels(List<JsonMap> models, String query) {
final needle = query.trim().toLowerCase();
final result = <JsonMap>[];
for (final model in models) {
if (chatModelName(model).isEmpty) continue;
if (needle.isNotEmpty) {
final name = '${model['name'] ?? ''}';
final id = '${model['id'] ?? ''}';
final provider = '${model['provider'] ?? ''}';
final haystack = '$name\u0000$id\u0000$provider'.toLowerCase();
if (!haystack.contains(needle)) continue;
}
result.add(model);
}
return result;
}
/// The recorded facts a model control displays, so a row replaced with the
/// same values never resets a newer local choice.
({String provider, String model, String selection}) chatModelRecordedFacts(
JsonMap session,
) => (
provider: '${session['model_provider'] ?? ''}'.trim(),
model: '${session['model'] ?? ''}'.trim(),
selection: '${session['model_selection'] ?? ''}'.trim(),
);
@@ -13,6 +13,8 @@ import '../ui/transcript/chat_message_view.dart';
import 'chat_composer_bar.dart';
import 'chat_composer_controller.dart';
import 'chat_draft_store.dart';
import 'chat_model_control.dart';
import 'chat_models.dart';
import 'chat_row_keys.dart';
import 'chat_thread_controller.dart';
import 'chat_transcript_card.dart';
@@ -34,6 +36,8 @@ class ChatThreadView extends StatefulWidget {
required this.sessionId,
required this.onBack,
this.title = '',
this.session,
this.onModelChanged,
this.syncToken = 0,
this.drafts,
this.newOperationId,
@@ -46,6 +50,15 @@ class ChatThreadView extends StatefulWidget {
/// The list row's title when this visit knows it; a deep link may not.
final String title;
/// The opened row's recorded facts when this visit knows them. The model
/// control reads its current model from this row; the destination supplies
/// it from the tapped row or from the list's loaded rows for a routed id.
final JsonMap? session;
/// The server's echo after an accepted model switch, so the destination can
/// keep the row it opened current for the next visit.
final ValueChanged<ChatModelSelection>? onModelChanged;
/// Advances when the shared socket is replaced, keeping this selection.
final int syncToken;
@@ -300,6 +313,19 @@ class _ChatThreadViewState extends State<ChatThreadView> {
).textTheme.navTitleTextStyle
: Theme.of(context).textTheme.titleLarge,
),
if (widget.session != null &&
supportsChatModels(
'${widget.session!['backend'] ?? ''}',
))
ChatModelControl(
key: ValueKey<String>(
'chat-model-${widget.sessionId}',
),
gateway: widget.gateway,
sessionId: widget.sessionId,
session: widget.session!,
onChanged: widget.onModelChanged,
),
ChatBarAction(
key: const Key('chat-info'),
label: 'Chat information',
+30 -15
View File
@@ -15,25 +15,40 @@ class ChatRepository {
Future<List<JsonMap>> sessions() async =>
_maps((await gateway.call('chat_sessions'))['chat_sessions']);
Future<JsonMap> models(String sessionId) async {
/// The models the session's harness offers, in the server's order.
///
/// `chat_models` is a JSON list, the same shape the web client reads. A
/// missing or wrong-typed field is an empty catalog, never invented rows.
Future<List<JsonMap>> models(String sessionId) async {
final session = sessionId.trim();
if (session.isEmpty) {
throw ArgumentError('Select a chat session first.');
}
final reply = await gateway.call('chat_models', {
'chat_query': {'session_id': sessionId},
'chat_query': {'session_id': session},
});
final value = reply['chat_models'];
return value is List ? _maps(value) : const [];
}
Future<JsonMap> selectModel(String sessionId, String provider, String model) {
final session = sessionId.trim();
if (session.isEmpty) {
throw ArgumentError('Select a chat session first.');
}
if (provider.trim().isEmpty || model.trim().isEmpty) {
throw ArgumentError('Choose a model first.');
}
return gateway.call('chat_model', {
'chat_model': {
'session_id': session,
'provider': provider.trim(),
'model': model.trim(),
},
});
final catalog = reply['chat_models'];
return catalog is Map ? Map<String, dynamic>.from(catalog) : {};
}
Future<JsonMap> selectModel(
String sessionId,
String provider,
String model,
) => gateway.call('chat_model', {
'chat_model': {
'session_id': sessionId,
'provider': provider,
'model': model,
},
});
Future<List<JsonMap>> shells(String sessionId) async => _maps(
(await gateway.call('chat_shells', {
'chat_query': {'session_id': sessionId},
+49 -6
View File
@@ -1,6 +1,7 @@
import 'package:flutter/material.dart';
import '../../core/api_gateway.dart';
import 'conversation/chat_models.dart';
import 'conversation/chat_thread_view.dart';
import 'ui/sessions/chat_sessions_screen.dart';
@@ -37,9 +38,16 @@ class ChatScreen extends StatefulWidget {
}
class _ChatScreenState extends State<ChatScreen> {
/// Rows opened in this visit, used only for the native title. A deep link has
/// no title until the list loads, and this screen waits for no list request.
final Map<String, String> _titles = {};
/// Rows this visit has opened, used for the native title and the recorded
/// model facts. The mounted list also reports its loaded rows, so a routed id
/// (a deep link) resolves the same row without a second list request.
final Map<String, JsonMap> _openedSessions = {};
/// Model switches the server accepted after a row was opened. The row that
/// opened the conversation may still carry the pre-switch model, so these win
/// for the rest of this visit, including when the same chat is reopened.
final Map<String, ChatModelSelection> _acceptedModels = {};
String? _standaloneSelection;
String? get _selected {
@@ -51,8 +59,7 @@ class _ChatScreenState extends State<ChatScreen> {
void _open(JsonMap session) {
final id = '${session['id'] ?? ''}';
if (id.isEmpty) return;
final title = '${session['title'] ?? ''}'.trim();
if (title.isNotEmpty) _titles[id] = title;
_openedSessions[id] = session;
final select = widget.onSessionSelected;
if (select != null) {
select(id);
@@ -61,6 +68,38 @@ class _ChatScreenState extends State<ChatScreen> {
}
}
/// Adopts the list's loaded rows for the routed session: a deep link opens
/// the conversation before any row has been tapped, and the header's title
/// and model control come from that row. Called after a frame, never during
/// the list's own build.
void _adoptRows(List<JsonMap> rows) {
final id = _selected;
if (id == null || _openedSessions.containsKey(id)) return;
for (final row in rows) {
if ('${row['id'] ?? ''}' != id) continue;
setState(() => _openedSessions[id] = row);
return;
}
}
void _modelChanged(String id, ChatModelSelection applied) {
if (!mounted) return;
setState(() => _acceptedModels[id] = applied);
}
/// The row to open for [id], with an accepted model folded in.
JsonMap? _rowFor(String id) {
final row = _openedSessions[id];
final accepted = _acceptedModels[id];
if (row == null || accepted == null) return row;
return {
...row,
'model': accepted.model,
'model_provider': accepted.provider,
'model_selection': accepted.selection,
};
}
void _back() {
final back = widget.onBack;
if (back != null) {
@@ -73,6 +112,7 @@ class _ChatScreenState extends State<ChatScreen> {
@override
Widget build(BuildContext context) {
final selected = _selected;
final row = selected == null ? null : _rowFor(selected);
return Stack(
children: [
Offstage(
@@ -82,6 +122,7 @@ class _ChatScreenState extends State<ChatScreen> {
embedded: true,
syncToken: widget.syncToken,
onOpen: _open,
onSessions: _adoptRows,
),
),
if (selected != null)
@@ -89,9 +130,11 @@ class _ChatScreenState extends State<ChatScreen> {
key: ValueKey<String>('chat-session-$selected'),
gateway: widget.gateway,
sessionId: selected,
title: _titles[selected] ?? '',
title: '${row?['title'] ?? ''}'.trim(),
session: row,
syncToken: widget.syncToken,
onBack: _back,
onModelChanged: (applied) => _modelChanged(selected, applied),
),
],
);
@@ -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();