feat: add the 通用 settings page and rename the group to 常规

- 常规 now holds two pages: 通用 (the agent's tools and what it may know,
  as the web client's General page) and 聊天 (the follow-up behavior)
- 通用 covers diagrams/prototypes, images with their model, secrets,
  notifications, memory with its background tidying (model and thinking
  level), project knowledge and usage limits
- every switch reads and writes /api/config/settings, the same keys the
  web UI uses; keys the server does not store take its defaults
- image models come from /api/model?types=image and the tidying model
  from the chat model list, both chosen in a sheet and clearable
- bump to 0.5.0
This commit is contained in:
blumia committed 2026-11-25 14:30:29 +08:00
1 parent 2185054aab
commit 2f5ce61692
7 files changed
+486 -7

No files matched your search

+58 -3
View File
@@ -108,6 +108,25 @@ class AppState extends ChangeNotifier {
/// `allowPromptingSubagentSessions`).
bool allowPromptingSubagentSessions = false;
/// OpenChamber's own agent tools — the web client's 通用 page: what the
/// agent may do inside a chat, and what it may know about the person and the
/// project. Server-backed (`/api/config/settings`), shared with the web UI;
/// keys the server does not send keep the same defaults it starts from.
bool renderToolEnabled = true;
bool imageToolEnabled = false;
String imageModel = '';
bool secretToolEnabled = true;
bool notifyToolEnabled = false;
bool memoryToolEnabled = false;
bool memoryDreamingEnabled = false;
String memoryDreamingModel = '';
String memoryDreamingVariant = '';
bool knowledgeToolEnabled = true;
bool usageToolEnabled = false;
/// The server's memory feature: absent, the memory switch is not offered.
bool memoryToolsAvailable = false;
/// Projects the server knows, for the new-session picker and the sidebar's
/// group headers.
List<ProjectInfo> projects = [];
@@ -169,7 +188,9 @@ class AppState extends ChangeNotifier {
return 'queue';
}
Future<void> refreshFollowUpBehavior() async {
/// Reads the chat settings the web UI also writes: the follow-up behavior
/// and OpenChamber's agent tools.
Future<void> refreshChatSettings() async {
final cl = client;
if (cl == null) return;
try {
@@ -178,10 +199,44 @@ class AppState extends ChangeNotifier {
followUpBehavior = normalizeFollowUp(settings['followUpBehavior']);
allowPromptingSubagentSessions =
settings['allowPromptingSubagentSessions'] == true;
_applyToolSettings(settings);
notifyListeners();
} catch (_) {}
}
void _applyToolSettings(Map<String, dynamic> s) {
renderToolEnabled = s['agentRenderToolEnabled'] as bool? ?? true;
imageToolEnabled = s['agentImageToolEnabled'] as bool? ?? false;
imageModel = s['agentImageModel'] as String? ?? '';
secretToolEnabled = s['agentSecretToolEnabled'] as bool? ?? true;
notifyToolEnabled = s['agentNotifyToolEnabled'] as bool? ?? false;
memoryToolEnabled = s['agentMemoryToolEnabled'] as bool? ?? false;
memoryDreamingEnabled = s['agentMemoryDreamingEnabled'] as bool? ?? false;
memoryDreamingModel = s['agentMemoryDreamingModel'] as String? ?? '';
memoryDreamingVariant = s['agentMemoryDreamingVariant'] as String? ?? '';
knowledgeToolEnabled = s['agentKnowledgeToolEnabled'] as bool? ?? true;
usageToolEnabled = s['agentUsageToolEnabled'] as bool? ?? false;
memoryToolsAvailable = s['agentMemoryFeatureAvailable'] == true;
}
/// Writes one tool switch or model choice; the server answers with the
/// settings now in force, which are applied here. The caller reports a
/// failure from [lastError].
Future<bool> setAgentToolSetting(String key, Object value) async {
final cl = client;
if (cl == null) return false;
try {
final settings = await cl.saveSettings({key: value});
if (client != cl) return false;
_applyToolSettings(settings);
notifyListeners();
return true;
} catch (e) {
_lastError = e is ApiError ? e.message : '$e';
return false;
}
}
/// Saves the choice to the server and keeps it locally; a failed save puts
/// the previous value back.
Future<bool> setFollowUpBehavior(String value) async {
@@ -453,7 +508,7 @@ class AppState extends ChangeNotifier {
refreshActive();
refreshPerms();
refreshModels();
refreshFollowUpBehavior();
refreshChatSettings();
notifyListeners();
}
@@ -1095,7 +1150,7 @@ class AppState extends ChangeNotifier {
Future<void> onResumed() async {
if (client == null) return;
_startStream();
refreshFollowUpBehavior();
refreshChatSettings();
await refreshSessions();
await _resyncActivity();
if (chat != null) await chat!.reloadInbox();