Files
pipelines/app/lib/application/open_in_chat_preferences.dart
T
alan 6cd7774811 Open in chat opens beside the active chat and uses a chosen harness
A chat opened from a run or pipeline now goes in a new pane beside the
active chat instead of replacing it, becomes active and takes the
keyboard once built. Settings > Open in chat chooses its harness and
model (models listed from that harness's most recent chat).
2026-11-13 13:34:26 +00:00

44 lines
1.3 KiB
Dart

import 'package:shared_preferences/shared_preferences.dart';
import '../core/api_gateway.dart';
import '../core/servers/server_scope.dart';
const openInChatPreferenceKey = 'pipelines.openInChat.v1';
/// The harness and model Open in chat starts its chats with, per server and
/// device. Empty fields mean the default: the New chat dialog's harness and
/// the harness's own default model.
class OpenInChatPreferences {
const OpenInChatPreferences({
this.harness = '',
this.provider = '',
this.model = '',
});
final String harness;
final String provider;
final String model;
bool get hasModel => provider.isNotEmpty && model.isNotEmpty;
static String _key(ApiGateway gateway) => scopedServerKey(
openInChatPreferenceKey,
serverStorageScope(serverIdentity(gateway)),
);
static Future<OpenInChatPreferences> load(ApiGateway gateway) async {
final values =
(await SharedPreferences.getInstance()).getStringList(_key(gateway)) ??
const [];
String at(int index) => index < values.length ? values[index].trim() : '';
return OpenInChatPreferences(harness: at(0), provider: at(1), model: at(2));
}
Future<bool> save(ApiGateway gateway) async =>
(await SharedPreferences.getInstance()).setStringList(_key(gateway), [
harness,
provider,
model,
]);
}