fix: switching a session's model, and put the model row in the composer

- POST /api/session/:id/model takes the reference under `model`; sending it
  at the top level was rejected with "Missing key at [model]".
- The chat now shows the model/agent row above the input (revealed while
  typing or running, as dsh-Go does) instead of in the app bar; the draft
  keeps the same row, with its project chip first.
- Thinking levels: /api/model's variants become a 思考 chip and sheet; the
  choice travels as ModelRef.variant on the switch or the create, and the
  last level per model is remembered on the device.
- The model picker groups providers, adds 收藏 and 最近 (device-local), shows
  each model's context size and reasoning mark, and collapses sections.
- The `/` palette is shared by the chat and the draft (new slash_palette
  widget); the draft lists commands and skills but not the client-local
  /compact, which needs an existing session.
- 0.3.14 (314).
This commit is contained in:
blumia committed 2026-11-21 17:03:22 +08:00
1 parent fff6562cbc
commit 7f2f454539
12 files changed
+962 -344

No files matched your search

+3 -1
View File
@@ -305,8 +305,10 @@ class Client {
}
Future<void> switchModel(String sessionId, ModelRef model, {String? directory}) async {
// The route takes the reference under `model`; sending it at the top level
// is rejected with "Missing key at [model]".
await _json('POST', '/api/session/${Uri.encodeComponent(sessionId)}/model',
directory: directory, body: model.toJson());
directory: directory, body: {'model': model.toJson()});
}
Future<void> switchAgent(String sessionId, String agent, {String? directory}) async {
+20 -1
View File
@@ -803,17 +803,36 @@ class ModelInfo {
final String name;
final int context;
final int output;
ModelInfo(this.id, this.providerId, this.name, this.context, this.output);
/// Thinking levels this model offers (`minimal`, `low`, `medium`, …), as
/// v2's model variants. Empty means the model has no effort choice.
final List<String> variants;
/// The provider says the model reasons; worth a mark in the picker.
final bool reasoning;
ModelInfo(this.id, this.providerId, this.name, this.context, this.output,
{this.variants = const [], this.reasoning = false});
factory ModelInfo.fromJson(Map<String, dynamic> j) {
final lim = j['limit'] as Map<String, dynamic>? ?? {};
final capabilities = j['capabilities'];
return ModelInfo(
j['id'] as String,
j['providerID'] as String? ?? '',
j['name'] as String? ?? (j['id'] as String? ?? ''),
(lim['context'] as num?)?.toInt() ?? 0,
(lim['output'] as num?)?.toInt() ?? 0,
variants: [
for (final v in (j['variants'] as List? ?? []))
if (v is Map && v['id'] is String) v['id'] as String,
],
reasoning:
capabilities is Map && capabilities['reasoning'] == true,
);
}
bool get hasEffort => variants.isNotEmpty;
}
class AgentInfo {