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:
1 parent
fff6562cbc
commit
7f2f454539
12 files changed
+962
-344
No files matched your search
+54
-29
@@ -351,6 +351,59 @@ class AppState extends ChangeNotifier {
|
||||
|
||||
bool get hasMoreSessions => _sessionsNext != null;
|
||||
|
||||
/// Commands and skills of one directory, cached. The chat and the draft
|
||||
/// both read this; the client-local `compact` is left out for a session
|
||||
/// that does not exist yet.
|
||||
final Map<String, List<SlashItem>> _slashCache = {};
|
||||
|
||||
Future<List<SlashItem>> slashItemsFor(String directory,
|
||||
{bool includeLocal = true}) async {
|
||||
final key = '${includeLocal ? 1 : 0}:$directory';
|
||||
final cached = _slashCache[key];
|
||||
if (cached != null) return cached;
|
||||
final cl = client;
|
||||
if (cl == null) return const [];
|
||||
final results = await Future.wait([
|
||||
cl.commands(directory: directory),
|
||||
cl.skills(directory: directory),
|
||||
]);
|
||||
const local = [
|
||||
SlashItem(
|
||||
name: 'compact',
|
||||
description: '使用 AI 压缩会话历史以减少上下文大小',
|
||||
action: 'compact',
|
||||
),
|
||||
];
|
||||
final localNames = {for (final c in local) c.name};
|
||||
final items = [
|
||||
if (includeLocal) ...local,
|
||||
for (final c in results[0])
|
||||
if ((c['name'] ?? '').isNotEmpty && !localNames.contains(c['name']))
|
||||
SlashItem(name: c['name']!, description: c['description'] ?? ''),
|
||||
for (final k in results[1])
|
||||
if ((k['name'] ?? '').isNotEmpty)
|
||||
SlashItem(
|
||||
name: k['name']!,
|
||||
description: k['description'] ?? '',
|
||||
skill: true,
|
||||
id: k['id'] ?? '',
|
||||
),
|
||||
];
|
||||
_slashCache[key] = items;
|
||||
return items;
|
||||
}
|
||||
|
||||
/// The catalog entry for a model reference, when the list has it.
|
||||
ModelInfo? modelInfo(ModelRef? ref) {
|
||||
if (ref == null) return null;
|
||||
for (final model in modelList) {
|
||||
if (model.id == ref.id && model.providerId == ref.providerId) {
|
||||
return model;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
String projectLabelFor(String directory) {
|
||||
if (directory.isEmpty) return '';
|
||||
for (final project in projects) {
|
||||
@@ -915,35 +968,7 @@ class ChatState extends ChangeNotifier {
|
||||
slashLoading = true;
|
||||
notifyListeners();
|
||||
try {
|
||||
final results = await Future.wait([
|
||||
cl.commands(directory: dir),
|
||||
cl.skills(directory: dir),
|
||||
]);
|
||||
const local = [
|
||||
SlashItem(
|
||||
name: 'compact',
|
||||
description: '使用 AI 压缩会话历史以减少上下文大小',
|
||||
action: 'compact',
|
||||
),
|
||||
];
|
||||
final localNames = {for (final c in local) c.name};
|
||||
slashItems = [
|
||||
...local,
|
||||
for (final c in results[0])
|
||||
if ((c['name'] ?? '').isNotEmpty && !localNames.contains(c['name']))
|
||||
SlashItem(
|
||||
name: c['name']!,
|
||||
description: c['description'] ?? '',
|
||||
),
|
||||
for (final k in results[1])
|
||||
if ((k['name'] ?? '').isNotEmpty)
|
||||
SlashItem(
|
||||
name: k['name']!,
|
||||
description: k['description'] ?? '',
|
||||
skill: true,
|
||||
id: k['id'] ?? '',
|
||||
),
|
||||
];
|
||||
slashItems = await app.slashItemsFor(dir);
|
||||
_slashLoaded = true;
|
||||
} catch (_) {
|
||||
// Keep the palette empty; a send falls back to a plain prompt.
|
||||
|
||||
Reference in new issue
Block a user