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:
1 parent
2185054aab
commit
2f5ce61692
7 files changed
+486
-7
No files matched your search
@@ -5,6 +5,21 @@
|
|||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
|
## 0.5.0 设置「常规」分组与「通用」页(分支 `flutter`)
|
||||||
|
|
||||||
|
| 项 | 结果 |
|
||||||
|
| --- | --- |
|
||||||
|
| 分组 | 原来的【通用】分组改名【常规】,其下第一项新增【通用】页(智能体工具与记忆),第二项仍是【聊天】 |
|
||||||
|
| 通用页 | 对照网页端的「通用」页补齐:**在聊天中** —— 图表和原型、图像(开启时可选图像模型)、密钥、通知;**智能体知道的内容** —— 记忆(服务端支持时才出现;开启时带「整理记忆」勾选、模型与思考级别)、项目知识、用量限额。每项都有与网页端一致的一句说明 |
|
||||||
|
| 数据 | 全部走 `/api/config/settings?surface=mobile`,与网页端读写同一份设置;服务器未返回的键用网页端的默认值(图表/密钥/项目知识默认开,图像/通知/记忆/用量/整理记忆默认关),保存后以服务器返回的设置回填 |
|
||||||
|
| 模型选择 | 图像模型取 `/api/model?types=image`,整理记忆模型取会话的模型列表,都在底部弹层里选;可以清空回「不指定 / 默认模型」;换模型会清空思考级别 |
|
||||||
|
| 版本 | 版本号改为 **0.5.0(code 500)**,之后按 0.5.x 递增 |
|
||||||
|
| 测试 | `test/settings_screen_test.dart` 增加「通用」页:分组标题、六个开关与网页端一致的默认值(记忆需要服务端能力才显示);88 项全过 |
|
||||||
|
| 验证 | 模拟器(真实服务端):常规 → 通用;开关显示服务端当前值(图表关、图像开 + 图像模型 SenseNova U1.5 Lite、密钥开、通知关、记忆开、项目知识开、用量限额关)。开「图表和原型」后服务端 `agentRenderToolEnabled` 变 true;勾「整理记忆」出现模型行(AxonHub::deepseek-flash / 默认);图像模型弹层列出 Grok Imagine 与 SenseNova 并可清空回「不指定」;整理记忆弹层列出会话模型与「默认模型」。验证后把这两项改回原值 |
|
||||||
|
| 版本 | **0.5.0(code 500)** |
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
## 0.4.17 设置按分组拆页,新增「关于」(分支 `flutter`)
|
## 0.4.17 设置按分组拆页,新增「关于」(分支 `flutter`)
|
||||||
|
|
||||||
| 项 | 结果 |
|
| 项 | 结果 |
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ Android first. This branch (`flutter`) is a framework evaluation: the same
|
|||||||
feature set as the earlier Asuka/Go and MyGo attempts, reimplemented in
|
feature set as the earlier Asuka/Go and MyGo attempts, reimplemented in
|
||||||
Flutter to compare mobile UI maturity.
|
Flutter to compare mobile UI maturity.
|
||||||
|
|
||||||
Status: 0.4.17 — servers (passwordless / password login, HTTP/HTTPS and
|
Status: 0.5.0 — servers (passwordless / password login, HTTP/HTTPS and
|
||||||
SOCKS5/socks5h proxy, self-signed certificates and pinning, or a pairing link
|
SOCKS5/socks5h proxy, self-signed certificates and pinning, or a pairing link
|
||||||
over the OpenChamber private relay with end-to-end encryption; the pairing
|
over the OpenChamber private relay with end-to-end encryption; the pairing
|
||||||
link is pasted or scanned with the camera), session list with search and live
|
link is pasted or scanned with the camera), session list with search and live
|
||||||
|
|||||||
@@ -247,6 +247,18 @@ class Client {
|
|||||||
.toList();
|
.toList();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// The models that generate or edit images (`types=image`), for the image
|
||||||
|
/// tool's model choice in 设置 → 通用.
|
||||||
|
Future<List<ModelInfo>> imageModels(String directory) async {
|
||||||
|
final r = await _json('GET', '/api/model', query: {
|
||||||
|
'types': 'image',
|
||||||
|
if (directory.isNotEmpty) 'location[directory]': directory,
|
||||||
|
});
|
||||||
|
return (r['data'] as List? ?? [])
|
||||||
|
.map((e) => ModelInfo.fromJson(e as Map<String, dynamic>))
|
||||||
|
.toList();
|
||||||
|
}
|
||||||
|
|
||||||
Future<List<AgentInfo>> agents(String directory) async {
|
Future<List<AgentInfo>> agents(String directory) async {
|
||||||
final r = await _json('GET', '/api/agent',
|
final r = await _json('GET', '/api/agent',
|
||||||
query: directory.isNotEmpty ? {'location[directory]': directory} : null);
|
query: directory.isNotEmpty ? {'location[directory]': directory} : null);
|
||||||
|
|||||||
@@ -24,8 +24,14 @@ class SettingsScreen extends StatelessWidget {
|
|||||||
body: ListView(
|
body: ListView(
|
||||||
padding: const EdgeInsets.only(top: 4, bottom: 32),
|
padding: const EdgeInsets.only(top: 4, bottom: 32),
|
||||||
children: [
|
children: [
|
||||||
const _SectionHeader('通用'),
|
const _SectionHeader('常规'),
|
||||||
_Section(children: [
|
_Section(children: [
|
||||||
|
_NavTile(
|
||||||
|
icon: Icons.tune,
|
||||||
|
title: '通用',
|
||||||
|
subtitle: '智能体工具与记忆',
|
||||||
|
builder: (_) => GeneralSettingsPage(app: app),
|
||||||
|
),
|
||||||
_NavTile(
|
_NavTile(
|
||||||
icon: Icons.chat_bubble_outline,
|
icon: Icons.chat_bubble_outline,
|
||||||
title: '聊天',
|
title: '聊天',
|
||||||
@@ -63,6 +69,369 @@ class SettingsScreen extends StatelessWidget {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------- general
|
||||||
|
|
||||||
|
/// OpenChamber's own agent tools: what the agent may do inside a chat, and
|
||||||
|
/// what it may know about the person and the project. The web client keeps
|
||||||
|
/// these on its 通用 page; the keys and wording follow it.
|
||||||
|
class GeneralSettingsPage extends StatefulWidget {
|
||||||
|
final AppState app;
|
||||||
|
const GeneralSettingsPage({super.key, required this.app});
|
||||||
|
|
||||||
|
@override
|
||||||
|
State<GeneralSettingsPage> createState() => _GeneralSettingsPageState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _GeneralSettingsPageState extends State<GeneralSettingsPage> {
|
||||||
|
/// Image models the provider offers, for the 图像模型 row. Null until the
|
||||||
|
/// first load; empty means the provider has none.
|
||||||
|
List<ModelInfo>? _imageModels;
|
||||||
|
|
||||||
|
AppState get app => widget.app;
|
||||||
|
|
||||||
|
@override
|
||||||
|
void initState() {
|
||||||
|
super.initState();
|
||||||
|
app.refreshChatSettings();
|
||||||
|
if (app.modelList.isEmpty) app.refreshModels();
|
||||||
|
_loadImageModels();
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> _loadImageModels() async {
|
||||||
|
final client = app.client;
|
||||||
|
if (client == null) return;
|
||||||
|
try {
|
||||||
|
final models = await client.imageModels(app.directory);
|
||||||
|
if (!mounted) return;
|
||||||
|
setState(() => _imageModels = models);
|
||||||
|
} catch (_) {
|
||||||
|
if (!mounted) return;
|
||||||
|
setState(() => _imageModels = const []);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> _save(String key, Object value) async {
|
||||||
|
final ok = await app.setAgentToolSetting(key, value);
|
||||||
|
if (!ok && mounted) {
|
||||||
|
ScaffoldMessenger.of(context).showSnackBar(
|
||||||
|
SnackBar(content: Text('保存失败:${app.lastError ?? '未知错误'}')),
|
||||||
|
);
|
||||||
|
app.clearLastError();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
final theme = Theme.of(context);
|
||||||
|
return Scaffold(
|
||||||
|
appBar: AppBar(title: const Text('通用')),
|
||||||
|
body: ListenableBuilder(
|
||||||
|
listenable: app,
|
||||||
|
builder: (context, _) => ListView(
|
||||||
|
padding: const EdgeInsets.only(top: 4, bottom: 32),
|
||||||
|
children: [
|
||||||
|
const _SectionHeader('在聊天中'),
|
||||||
|
_Section(children: [
|
||||||
|
_switch(
|
||||||
|
icon: Icons.bar_chart,
|
||||||
|
title: '图表和原型',
|
||||||
|
subtitle: '让智能体在聊天中展示图表、表格、示意图和界面草图(与你的文件隔离),并请你在其中选择一个选项。',
|
||||||
|
value: app.renderToolEnabled,
|
||||||
|
key: 'agentRenderToolEnabled',
|
||||||
|
),
|
||||||
|
_switch(
|
||||||
|
icon: Icons.image_outlined,
|
||||||
|
title: '图像',
|
||||||
|
subtitle: '让智能体用你选择的模型生成和编辑图像,费用由该模型的提供商收取。',
|
||||||
|
value: app.imageToolEnabled,
|
||||||
|
key: 'agentImageToolEnabled',
|
||||||
|
),
|
||||||
|
if (app.imageToolEnabled)
|
||||||
|
ListTile(
|
||||||
|
contentPadding: const EdgeInsets.fromLTRB(52, 0, 16, 4),
|
||||||
|
title: const Text('图像模型'),
|
||||||
|
subtitle: Text(_imageModelName(),
|
||||||
|
maxLines: 1, overflow: TextOverflow.ellipsis),
|
||||||
|
trailing: const Icon(Icons.chevron_right, size: 20),
|
||||||
|
onTap: _pickImageModel,
|
||||||
|
),
|
||||||
|
_switch(
|
||||||
|
icon: Icons.shield_outlined,
|
||||||
|
title: '密钥',
|
||||||
|
subtitle: '允许智能体在聊天中的私密卡片上向你索取 API 密钥、令牌或密码。值不会进入对话。',
|
||||||
|
value: app.secretToolEnabled,
|
||||||
|
key: 'agentSecretToolEnabled',
|
||||||
|
),
|
||||||
|
_switch(
|
||||||
|
icon: Icons.notifications_none,
|
||||||
|
title: '通知',
|
||||||
|
subtitle: '工作完成或卡住时,智能体会通知你。',
|
||||||
|
value: app.notifyToolEnabled,
|
||||||
|
key: 'agentNotifyToolEnabled',
|
||||||
|
),
|
||||||
|
]),
|
||||||
|
const _SectionHeader('智能体知道的内容'),
|
||||||
|
_Section(children: [
|
||||||
|
if (app.memoryToolsAvailable) ...[
|
||||||
|
_switch(
|
||||||
|
icon: Icons.psychology_outlined,
|
||||||
|
title: '记忆',
|
||||||
|
subtitle: '跨会话记住关于你和每个项目的事实。',
|
||||||
|
value: app.memoryToolEnabled,
|
||||||
|
key: 'agentMemoryToolEnabled',
|
||||||
|
),
|
||||||
|
if (app.memoryToolEnabled) ..._dreaming(theme),
|
||||||
|
],
|
||||||
|
_switch(
|
||||||
|
icon: Icons.sticky_note_2_outlined,
|
||||||
|
title: '项目知识',
|
||||||
|
subtitle: '让智能体读取并更新项目的笔记、待办和计划。',
|
||||||
|
value: app.knowledgeToolEnabled,
|
||||||
|
key: 'agentKnowledgeToolEnabled',
|
||||||
|
),
|
||||||
|
_switch(
|
||||||
|
icon: Icons.insert_chart_outlined,
|
||||||
|
title: '用量限额',
|
||||||
|
subtitle: '让智能体查看各提供商的限额及重置时间。',
|
||||||
|
value: app.usageToolEnabled,
|
||||||
|
key: 'agentUsageToolEnabled',
|
||||||
|
),
|
||||||
|
]),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget _switch({
|
||||||
|
required IconData icon,
|
||||||
|
required String title,
|
||||||
|
required String subtitle,
|
||||||
|
required bool value,
|
||||||
|
required String key,
|
||||||
|
}) {
|
||||||
|
return SwitchListTile(
|
||||||
|
value: value,
|
||||||
|
onChanged: (v) => _save(key, v),
|
||||||
|
secondary: Icon(icon, size: 20),
|
||||||
|
title: Text(title),
|
||||||
|
subtitle: Text(subtitle),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
String _imageModelName() {
|
||||||
|
final value = app.imageModel;
|
||||||
|
if (value.isEmpty) return '未选择';
|
||||||
|
for (final m in _imageModels ?? const <ModelInfo>[]) {
|
||||||
|
if ('${m.providerId}/${m.id}' == value) return m.name;
|
||||||
|
}
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// The memory-tidying switch with its model and thinking level, shown under
|
||||||
|
/// 记忆 the way the web client draws it.
|
||||||
|
List<Widget> _dreaming(ThemeData theme) {
|
||||||
|
final variants = _dreamingVariants();
|
||||||
|
final name = app.memoryDreamingModel.isEmpty
|
||||||
|
? '默认模型'
|
||||||
|
: (app.modelNames[app.memoryDreamingModel] ?? app.memoryDreamingModel);
|
||||||
|
return [
|
||||||
|
InkWell(
|
||||||
|
onTap: () =>
|
||||||
|
_save('agentMemoryDreamingEnabled', !app.memoryDreamingEnabled),
|
||||||
|
child: Padding(
|
||||||
|
padding: const EdgeInsets.fromLTRB(44, 0, 4, 0),
|
||||||
|
child: Row(
|
||||||
|
children: [
|
||||||
|
Checkbox(
|
||||||
|
value: app.memoryDreamingEnabled,
|
||||||
|
onChanged: (v) =>
|
||||||
|
_save('agentMemoryDreamingEnabled', v ?? false),
|
||||||
|
),
|
||||||
|
Expanded(child: Text('整理记忆')),
|
||||||
|
IconButton(
|
||||||
|
icon: const Icon(Icons.info_outline, size: 18),
|
||||||
|
tooltip: '整理记忆',
|
||||||
|
onPressed: _dreamingInfo,
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
if (app.memoryDreamingEnabled)
|
||||||
|
Padding(
|
||||||
|
padding: const EdgeInsets.fromLTRB(56, 0, 16, 10),
|
||||||
|
child: Row(
|
||||||
|
children: [
|
||||||
|
Expanded(
|
||||||
|
child: OutlinedButton(
|
||||||
|
onPressed: _pickDreamingModel,
|
||||||
|
style: OutlinedButton.styleFrom(
|
||||||
|
alignment: Alignment.centerLeft,
|
||||||
|
padding: const EdgeInsets.symmetric(horizontal: 12),
|
||||||
|
),
|
||||||
|
child: Text(name,
|
||||||
|
maxLines: 1,
|
||||||
|
overflow: TextOverflow.ellipsis,
|
||||||
|
style: const TextStyle(fontSize: 13)),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
if (variants.isNotEmpty) ...[
|
||||||
|
const SizedBox(width: 8),
|
||||||
|
DropdownButton<String>(
|
||||||
|
value: variants.contains(app.memoryDreamingVariant)
|
||||||
|
? app.memoryDreamingVariant
|
||||||
|
: '',
|
||||||
|
underline: const SizedBox.shrink(),
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize: 13, color: theme.colorScheme.onSurface),
|
||||||
|
items: [
|
||||||
|
const DropdownMenuItem(value: '', child: Text('默认')),
|
||||||
|
for (final v in variants)
|
||||||
|
DropdownMenuItem(value: v, child: Text(v)),
|
||||||
|
],
|
||||||
|
onChanged: (v) => _save('agentMemoryDreamingVariant', v ?? ''),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
List<String> _dreamingVariants() {
|
||||||
|
for (final m in app.modelList) {
|
||||||
|
if ('${m.providerId}/${m.id}' == app.memoryDreamingModel) {
|
||||||
|
return m.variants;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return const [];
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> _dreamingInfo() async {
|
||||||
|
await showDialog<void>(
|
||||||
|
context: context,
|
||||||
|
builder: (dialog) => AlertDialog(
|
||||||
|
title: const Text('整理记忆'),
|
||||||
|
content: const Text(
|
||||||
|
'每天一次,在没有会话运行时,智能体会在后台整理记忆:合并重复条目,删除已过时或项目文档中已有的内容。'),
|
||||||
|
actions: [
|
||||||
|
TextButton(
|
||||||
|
onPressed: () => Navigator.pop(dialog), child: const Text('知道了')),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> _pickImageModel() async {
|
||||||
|
final models = _imageModels ??= await _fetchImageModels();
|
||||||
|
if (!mounted) return;
|
||||||
|
if (models.isEmpty) {
|
||||||
|
ScaffoldMessenger.of(context).showSnackBar(
|
||||||
|
const SnackBar(content: Text('你的提供商中没有图像模型')),
|
||||||
|
);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
final picked = await _chooseFromSheet(
|
||||||
|
context: context,
|
||||||
|
title: '图像模型',
|
||||||
|
noneLabel: '不指定',
|
||||||
|
selected: app.imageModel,
|
||||||
|
options: [
|
||||||
|
for (final m in models)
|
||||||
|
(value: '${m.providerId}/${m.id}', name: m.name, note: m.providerId),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
if (picked == null) return;
|
||||||
|
await _save('agentImageModel', picked);
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<List<ModelInfo>> _fetchImageModels() async {
|
||||||
|
final client = app.client;
|
||||||
|
if (client == null) return const [];
|
||||||
|
try {
|
||||||
|
return await client.imageModels(app.directory);
|
||||||
|
} catch (_) {
|
||||||
|
return const [];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> _pickDreamingModel() async {
|
||||||
|
if (app.modelList.isEmpty) await app.refreshModels();
|
||||||
|
if (!mounted) return;
|
||||||
|
final picked = await _chooseFromSheet(
|
||||||
|
context: context,
|
||||||
|
title: '整理记忆使用的模型',
|
||||||
|
noneLabel: '默认模型',
|
||||||
|
selected: app.memoryDreamingModel,
|
||||||
|
options: [
|
||||||
|
for (final m in app.modelList)
|
||||||
|
(value: '${m.providerId}/${m.id}', name: m.name, note: m.providerId),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
if (picked == null) return;
|
||||||
|
// A model change drops the thinking level: the new model may not offer
|
||||||
|
// the old one.
|
||||||
|
await _save('agentMemoryDreamingModel', picked);
|
||||||
|
if (app.memoryDreamingVariant.isNotEmpty) {
|
||||||
|
await _save('agentMemoryDreamingVariant', '');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// A sheet of model choices; the first row clears the choice. Null when the
|
||||||
|
/// sheet is dismissed.
|
||||||
|
Future<String?> _chooseFromSheet({
|
||||||
|
required BuildContext context,
|
||||||
|
required String title,
|
||||||
|
required String noneLabel,
|
||||||
|
required String selected,
|
||||||
|
required List<({String value, String name, String note})> options,
|
||||||
|
}) {
|
||||||
|
return showModalBottomSheet<String>(
|
||||||
|
context: context,
|
||||||
|
isScrollControlled: true,
|
||||||
|
showDragHandle: true,
|
||||||
|
builder: (sheet) => FractionallySizedBox(
|
||||||
|
heightFactor: 0.65,
|
||||||
|
child: Column(
|
||||||
|
children: [
|
||||||
|
Padding(
|
||||||
|
padding: const EdgeInsets.fromLTRB(16, 0, 16, 8),
|
||||||
|
child: Text(title,
|
||||||
|
style: const TextStyle(
|
||||||
|
fontSize: 16, fontWeight: FontWeight.w600)),
|
||||||
|
),
|
||||||
|
Expanded(
|
||||||
|
child: ListView(
|
||||||
|
padding: const EdgeInsets.only(bottom: 24),
|
||||||
|
children: [
|
||||||
|
ListTile(
|
||||||
|
title: Text(noneLabel),
|
||||||
|
trailing: selected.isEmpty
|
||||||
|
? const Icon(Icons.check, size: 20)
|
||||||
|
: null,
|
||||||
|
onTap: () => Navigator.pop(sheet, ''),
|
||||||
|
),
|
||||||
|
for (final option in options)
|
||||||
|
ListTile(
|
||||||
|
title: Text(option.name,
|
||||||
|
maxLines: 1, overflow: TextOverflow.ellipsis),
|
||||||
|
subtitle: option.note.isEmpty ? null : Text(option.note),
|
||||||
|
trailing: selected == option.value
|
||||||
|
? const Icon(Icons.check, size: 20)
|
||||||
|
: null,
|
||||||
|
onTap: () => Navigator.pop(sheet, option.value),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------- chat
|
// ------------------------------------------------------------------- chat
|
||||||
|
|
||||||
class ChatSettingsPage extends StatefulWidget {
|
class ChatSettingsPage extends StatefulWidget {
|
||||||
@@ -78,7 +447,7 @@ class _ChatSettingsPageState extends State<ChatSettingsPage> {
|
|||||||
void initState() {
|
void initState() {
|
||||||
super.initState();
|
super.initState();
|
||||||
// Pick up a change made on another client while this page opens.
|
// Pick up a change made on another client while this page opens.
|
||||||
widget.app.refreshFollowUpBehavior();
|
widget.app.refreshChatSettings();
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
|
|||||||
+58
-3
@@ -108,6 +108,25 @@ class AppState extends ChangeNotifier {
|
|||||||
/// `allowPromptingSubagentSessions`).
|
/// `allowPromptingSubagentSessions`).
|
||||||
bool allowPromptingSubagentSessions = false;
|
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
|
/// Projects the server knows, for the new-session picker and the sidebar's
|
||||||
/// group headers.
|
/// group headers.
|
||||||
List<ProjectInfo> projects = [];
|
List<ProjectInfo> projects = [];
|
||||||
@@ -169,7 +188,9 @@ class AppState extends ChangeNotifier {
|
|||||||
return 'queue';
|
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;
|
final cl = client;
|
||||||
if (cl == null) return;
|
if (cl == null) return;
|
||||||
try {
|
try {
|
||||||
@@ -178,10 +199,44 @@ class AppState extends ChangeNotifier {
|
|||||||
followUpBehavior = normalizeFollowUp(settings['followUpBehavior']);
|
followUpBehavior = normalizeFollowUp(settings['followUpBehavior']);
|
||||||
allowPromptingSubagentSessions =
|
allowPromptingSubagentSessions =
|
||||||
settings['allowPromptingSubagentSessions'] == true;
|
settings['allowPromptingSubagentSessions'] == true;
|
||||||
|
_applyToolSettings(settings);
|
||||||
notifyListeners();
|
notifyListeners();
|
||||||
} catch (_) {}
|
} 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
|
/// Saves the choice to the server and keeps it locally; a failed save puts
|
||||||
/// the previous value back.
|
/// the previous value back.
|
||||||
Future<bool> setFollowUpBehavior(String value) async {
|
Future<bool> setFollowUpBehavior(String value) async {
|
||||||
@@ -453,7 +508,7 @@ class AppState extends ChangeNotifier {
|
|||||||
refreshActive();
|
refreshActive();
|
||||||
refreshPerms();
|
refreshPerms();
|
||||||
refreshModels();
|
refreshModels();
|
||||||
refreshFollowUpBehavior();
|
refreshChatSettings();
|
||||||
notifyListeners();
|
notifyListeners();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1095,7 +1150,7 @@ class AppState extends ChangeNotifier {
|
|||||||
Future<void> onResumed() async {
|
Future<void> onResumed() async {
|
||||||
if (client == null) return;
|
if (client == null) return;
|
||||||
_startStream();
|
_startStream();
|
||||||
refreshFollowUpBehavior();
|
refreshChatSettings();
|
||||||
await refreshSessions();
|
await refreshSessions();
|
||||||
await _resyncActivity();
|
await _resyncActivity();
|
||||||
if (chat != null) await chat!.reloadInbox();
|
if (chat != null) await chat!.reloadInbox();
|
||||||
|
|||||||
+1
-1
@@ -2,7 +2,7 @@ name: openchamber
|
|||||||
description: "A lightweight OpenChamber client for phones."
|
description: "A lightweight OpenChamber client for phones."
|
||||||
publish_to: 'none'
|
publish_to: 'none'
|
||||||
|
|
||||||
version: 0.4.17+417
|
version: 0.5.0+500
|
||||||
|
|
||||||
environment:
|
environment:
|
||||||
sdk: ^3.14.0
|
sdk: ^3.14.0
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ void main() {
|
|||||||
(tester) async {
|
(tester) async {
|
||||||
await pumpSettings(tester);
|
await pumpSettings(tester);
|
||||||
|
|
||||||
|
expect(find.text('常规'), findsOneWidget);
|
||||||
expect(find.text('通用'), findsOneWidget);
|
expect(find.text('通用'), findsOneWidget);
|
||||||
expect(find.text('外观'), findsOneWidget);
|
expect(find.text('外观'), findsOneWidget);
|
||||||
expect(find.text('帮助与关于'), findsOneWidget);
|
expect(find.text('帮助与关于'), findsOneWidget);
|
||||||
@@ -28,6 +29,33 @@ void main() {
|
|||||||
expect(find.byType(Switch), findsNothing);
|
expect(find.byType(Switch), findsNothing);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
testWidgets('通用 opens the agent-tool page with the web defaults',
|
||||||
|
(tester) async {
|
||||||
|
final app = await pumpSettings(tester);
|
||||||
|
app.memoryToolsAvailable = true;
|
||||||
|
await tester.pump();
|
||||||
|
|
||||||
|
await tester.tap(find.text('通用'));
|
||||||
|
await tester.pumpAndSettle();
|
||||||
|
|
||||||
|
expect(find.text('在聊天中'), findsOneWidget);
|
||||||
|
expect(find.text('图表和原型'), findsOneWidget);
|
||||||
|
expect(find.text('密钥'), findsOneWidget);
|
||||||
|
expect(find.text('项目知识'), findsOneWidget);
|
||||||
|
expect(find.text('用量限额'), findsOneWidget);
|
||||||
|
|
||||||
|
SwitchListTile tile(String title) => tester
|
||||||
|
.widget<SwitchListTile>(find.widgetWithText(SwitchListTile, title));
|
||||||
|
// The same defaults the web client starts from.
|
||||||
|
expect(tile('图表和原型').value, isTrue);
|
||||||
|
expect(tile('图像').value, isFalse);
|
||||||
|
expect(tile('密钥').value, isTrue);
|
||||||
|
expect(tile('通知').value, isFalse);
|
||||||
|
expect(tile('记忆').value, isFalse);
|
||||||
|
expect(tile('项目知识').value, isTrue);
|
||||||
|
expect(tile('用量限额').value, isFalse);
|
||||||
|
});
|
||||||
|
|
||||||
testWidgets('聊天 opens the follow-up behavior page', (tester) async {
|
testWidgets('聊天 opens the follow-up behavior page', (tester) async {
|
||||||
final app = await pumpSettings(tester);
|
final app = await pumpSettings(tester);
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user