feat: write the UI in English, select only conversation content
- source strings are English again; Chinese comes from lib/l10n/zh.dart through tr()/trArgs() and AppText, and a language without a table (Spanish, ...) reads English instead of Chinese - server and user data (titles, messages, file names, notes, task names) is drawn with plain Text, so it is never looked up in the table - SelectionArea moved from the whole message list to the messages, the answer text, an opened tool call's details and the turn footer; status lines and folded tool rows no longer start a selection - a message the transcript does not know (its start event was lost while the stream was down) fetches the tail once, so a turn continued from another client comes in with its prompt - bump to 0.5.3
This commit is contained in:
1 parent
7b5bccf28f
commit
511c3b006b
43 files changed
+1620
-1791
No files matched your search
@@ -49,7 +49,7 @@ class _KnowledgePanelState extends State<KnowledgePanel> {
|
||||
if (client == null || _projectId.isEmpty) {
|
||||
setState(() {
|
||||
_loading = false;
|
||||
_error = tr('这个会话没有关联目录');
|
||||
_error = tr('This session has no directory');
|
||||
});
|
||||
return;
|
||||
}
|
||||
@@ -91,7 +91,7 @@ class _KnowledgePanelState extends State<KnowledgePanel> {
|
||||
void _fail(Object error) {
|
||||
if (!mounted) return;
|
||||
ScaffoldMessenger.of(context)
|
||||
.showSnackBar(SnackBar(content: AppText('$error')));
|
||||
.showSnackBar(SnackBar(content: Text('$error')));
|
||||
}
|
||||
|
||||
bool _matches(Iterable<String> fields) {
|
||||
@@ -117,8 +117,8 @@ class _KnowledgePanelState extends State<KnowledgePanel> {
|
||||
decoration: InputDecoration(
|
||||
isDense: true,
|
||||
hintText: _memory == null
|
||||
? tr('搜索笔记、待办与计划')
|
||||
: tr('搜索笔记、待办、计划与记忆'),
|
||||
? tr('Search notes, todos, and plans')
|
||||
: tr('Search notes, todos, plans, and memory'),
|
||||
prefixIcon: const Icon(Icons.search, size: 18),
|
||||
suffixIcon: _query.isEmpty
|
||||
? null
|
||||
@@ -135,7 +135,7 @@ class _KnowledgePanelState extends State<KnowledgePanel> {
|
||||
),
|
||||
),
|
||||
IconButton(
|
||||
tooltip: tr('刷新'),
|
||||
tooltip: tr('Refresh'),
|
||||
visualDensity: VisualDensity.compact,
|
||||
icon: const Icon(Icons.refresh, size: 20),
|
||||
onPressed: _load,
|
||||
@@ -152,11 +152,11 @@ class _KnowledgePanelState extends State<KnowledgePanel> {
|
||||
List<(String, String, int)> get _sectionsList {
|
||||
final context = _context;
|
||||
return [
|
||||
('notes', tr('笔记'), context?.notes.length ?? 0),
|
||||
('todos', tr('待办'), context?.todos.length ?? 0),
|
||||
('plans', tr('计划'), context?.plans.length ?? 0),
|
||||
('notes', tr('Notes'), context?.notes.length ?? 0),
|
||||
('todos', tr('Todos'), context?.todos.length ?? 0),
|
||||
('plans', tr('Plans'), context?.plans.length ?? 0),
|
||||
if (_memory != null)
|
||||
('memory', tr('记忆'),
|
||||
('memory', tr('Memory'),
|
||||
(_memory!.global.length + _memory!.project.length)),
|
||||
];
|
||||
}
|
||||
@@ -190,11 +190,11 @@ class _KnowledgePanelState extends State<KnowledgePanel> {
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
AppText(_error!,
|
||||
Text(_error!,
|
||||
textAlign: TextAlign.center,
|
||||
style: TextStyle(color: theme.colorScheme.error, fontSize: 13)),
|
||||
const SizedBox(height: 8),
|
||||
FilledButton(onPressed: _load, child: const AppText('重试')),
|
||||
FilledButton(onPressed: _load, child: const AppText('Retry')),
|
||||
],
|
||||
),
|
||||
),
|
||||
@@ -224,12 +224,12 @@ class _KnowledgePanelState extends State<KnowledgePanel> {
|
||||
});
|
||||
return Column(
|
||||
children: [
|
||||
_sectionHeader(theme, trArgs('{0} 条笔记', [notes.length]),
|
||||
'新建笔记', _addNote),
|
||||
_sectionHeader(theme, trArgs('{0} notes', [notes.length]),
|
||||
'New note', _addNote),
|
||||
Expanded(
|
||||
child: notes.isEmpty
|
||||
? _empty(theme, Icons.sticky_note_2_outlined,
|
||||
_query.isEmpty ? '还没有笔记' : '没有匹配的笔记')
|
||||
_query.isEmpty ? 'No notes yet' : 'No matching notes')
|
||||
: ListView.builder(
|
||||
padding: const EdgeInsets.fromLTRB(12, 0, 12, 12),
|
||||
itemCount: notes.length,
|
||||
@@ -259,7 +259,7 @@ class _KnowledgePanelState extends State<KnowledgePanel> {
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
AppText(
|
||||
Text(
|
||||
note.body.trim(),
|
||||
maxLines: 5,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
@@ -274,7 +274,7 @@ class _KnowledgePanelState extends State<KnowledgePanel> {
|
||||
child: Icon(Icons.push_pin,
|
||||
size: 12, color: scheme.primary),
|
||||
),
|
||||
AppText(
|
||||
Text(
|
||||
_stamp(note.updatedAt),
|
||||
style:
|
||||
TextStyle(fontSize: 11, color: theme.hintColor),
|
||||
@@ -309,10 +309,10 @@ class _KnowledgePanelState extends State<KnowledgePanel> {
|
||||
}
|
||||
},
|
||||
itemBuilder: (_) => [
|
||||
const PopupMenuItem(value: 'edit', child: AppText('编辑')),
|
||||
const PopupMenuItem(value: 'edit', child: AppText('Edit')),
|
||||
PopupMenuItem(
|
||||
value: 'pin', child: AppText(note.pinned ? '取消置顶' : '置顶')),
|
||||
const PopupMenuItem(value: 'delete', child: AppText('删除')),
|
||||
value: 'pin', child: AppText(note.pinned ? 'Unpin' : 'Pin')),
|
||||
const PopupMenuItem(value: 'delete', child: AppText('Delete')),
|
||||
],
|
||||
),
|
||||
],
|
||||
@@ -331,12 +331,12 @@ class _KnowledgePanelState extends State<KnowledgePanel> {
|
||||
final done = todos.where((todo) => todo.completed).length;
|
||||
return Column(
|
||||
children: [
|
||||
_sectionHeader(theme, trArgs('{0}/{1} 已完成', [done, todos.length]),
|
||||
'新建待办', _addTodo),
|
||||
_sectionHeader(theme, trArgs('{0}/{1} done', [done, todos.length]),
|
||||
'New todo', _addTodo),
|
||||
Expanded(
|
||||
child: todos.isEmpty
|
||||
? _empty(theme, Icons.checklist,
|
||||
_query.isEmpty ? '还没有待办' : '没有匹配的待办')
|
||||
_query.isEmpty ? 'No todos yet' : 'No matching todos')
|
||||
: ListView.builder(
|
||||
padding: const EdgeInsets.fromLTRB(8, 0, 8, 12),
|
||||
itemCount: todos.length,
|
||||
@@ -373,7 +373,7 @@ class _KnowledgePanelState extends State<KnowledgePanel> {
|
||||
}
|
||||
},
|
||||
itemBuilder: (_) => const [
|
||||
PopupMenuItem(value: 'delete', child: AppText('删除')),
|
||||
PopupMenuItem(value: 'delete', child: AppText('Delete')),
|
||||
],
|
||||
),
|
||||
);
|
||||
@@ -407,12 +407,12 @@ class _KnowledgePanelState extends State<KnowledgePanel> {
|
||||
});
|
||||
return Column(
|
||||
children: [
|
||||
_sectionHeader(theme, trArgs('{0} 份计划', [plans.length]),
|
||||
'新建计划', _newPlan),
|
||||
_sectionHeader(theme, trArgs('{0} plans', [plans.length]),
|
||||
'New plan', _newPlan),
|
||||
Expanded(
|
||||
child: plans.isEmpty
|
||||
? _empty(theme, Icons.description_outlined,
|
||||
_query.isEmpty ? '还没有计划' : '没有匹配的计划')
|
||||
_query.isEmpty ? 'No plans yet' : 'No matching plans')
|
||||
: ListView.builder(
|
||||
padding: const EdgeInsets.fromLTRB(8, 0, 8, 12),
|
||||
itemCount: plans.length,
|
||||
@@ -438,7 +438,7 @@ class _KnowledgePanelState extends State<KnowledgePanel> {
|
||||
child: Icon(Icons.push_pin, size: 13, color: scheme.primary),
|
||||
),
|
||||
Expanded(
|
||||
child: AppText(plan.title.isEmpty ? plan.file : plan.title,
|
||||
child: Text(plan.title.isEmpty ? plan.file : plan.title,
|
||||
maxLines: 2, overflow: TextOverflow.ellipsis),
|
||||
),
|
||||
],
|
||||
@@ -461,7 +461,7 @@ class _KnowledgePanelState extends State<KnowledgePanel> {
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 6),
|
||||
AppText('${plan.progressDone}/${plan.progressTotal}',
|
||||
Text('${plan.progressDone}/${plan.progressTotal}',
|
||||
style:
|
||||
TextStyle(fontSize: 11, color: theme.hintColor)),
|
||||
],
|
||||
@@ -469,7 +469,7 @@ class _KnowledgePanelState extends State<KnowledgePanel> {
|
||||
],
|
||||
const SizedBox(height: 2),
|
||||
AppText(
|
||||
plan.source == 'shared' ? '团队共享' : '个人',
|
||||
plan.source == 'shared' ? 'Shared' : 'Personal',
|
||||
style: TextStyle(fontSize: 11, color: theme.hintColor),
|
||||
),
|
||||
],
|
||||
@@ -497,8 +497,8 @@ class _KnowledgePanelState extends State<KnowledgePanel> {
|
||||
},
|
||||
itemBuilder: (_) => [
|
||||
PopupMenuItem(
|
||||
value: 'pin', child: AppText(plan.pinned ? '取消置顶' : '置顶')),
|
||||
const PopupMenuItem(value: 'delete', child: AppText('删除')),
|
||||
value: 'pin', child: AppText(plan.pinned ? 'Unpin' : 'Pin')),
|
||||
const PopupMenuItem(value: 'delete', child: AppText('Delete')),
|
||||
],
|
||||
),
|
||||
onTap: () => _viewPlan(plan),
|
||||
@@ -511,7 +511,7 @@ class _KnowledgePanelState extends State<KnowledgePanel> {
|
||||
Widget _memoryBody(ThemeData theme) {
|
||||
final snapshot = _memory;
|
||||
if (snapshot == null) {
|
||||
return _empty(theme, Icons.psychology_outlined, '记忆功能未启用');
|
||||
return _empty(theme, Icons.psychology_outlined, 'Memory is not enabled');
|
||||
}
|
||||
final global = snapshot.global
|
||||
.where((m) => _matches([m.title, m.body]))
|
||||
@@ -523,20 +523,20 @@ class _KnowledgePanelState extends State<KnowledgePanel> {
|
||||
return _empty(
|
||||
theme,
|
||||
Icons.psychology_outlined,
|
||||
_query.isEmpty ? '还没有记忆' : '没有匹配的记忆');
|
||||
_query.isEmpty ? 'No memories yet' : 'No matching memories');
|
||||
}
|
||||
return ListView(
|
||||
padding: const EdgeInsets.fromLTRB(12, 0, 12, 12),
|
||||
children: [
|
||||
_memoryGroup(theme, tr('全局记忆'), global, 'global',
|
||||
_memoryGroup(theme, tr('Global memory'), global, 'global',
|
||||
failed: snapshot.globalFailed),
|
||||
const SizedBox(height: 8),
|
||||
_memoryGroup(theme, tr('项目记忆'), project, 'project',
|
||||
_memoryGroup(theme, tr('Project memory'), project, 'project',
|
||||
failed: snapshot.projectFailed),
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(top: 6),
|
||||
child: AppText(
|
||||
'记忆由 agent 在会话中记录;你可以在这里修改或删除它。',
|
||||
'Memory is recorded by the agent during sessions; you can edit or delete it here.',
|
||||
style: TextStyle(fontSize: 11.5, color: theme.hintColor),
|
||||
),
|
||||
),
|
||||
@@ -552,20 +552,20 @@ class _KnowledgePanelState extends State<KnowledgePanel> {
|
||||
children: [
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(bottom: 4),
|
||||
child: AppText(trArgs('{0}({1})', [title, entries.length]),
|
||||
child: AppText(trArgs('{0} ({1})', [title, entries.length]),
|
||||
style: TextStyle(fontSize: 12, color: theme.hintColor)),
|
||||
),
|
||||
if (failed)
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(bottom: 4),
|
||||
child: AppText('读取失败,请刷新',
|
||||
child: AppText('Could not load, refresh to retry',
|
||||
style: TextStyle(
|
||||
fontSize: 12, color: theme.colorScheme.error)),
|
||||
)
|
||||
else if (entries.isEmpty)
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(bottom: 4),
|
||||
child: AppText('暂无', style: TextStyle(fontSize: 12, color: theme.hintColor)),
|
||||
child: AppText('None', style: TextStyle(fontSize: 12, color: theme.hintColor)),
|
||||
),
|
||||
for (final entry in entries) _memoryCard(theme, entry, scope),
|
||||
],
|
||||
@@ -591,7 +591,7 @@ class _KnowledgePanelState extends State<KnowledgePanel> {
|
||||
Row(
|
||||
children: [
|
||||
Flexible(
|
||||
child: AppText(entry.title,
|
||||
child: Text(entry.title,
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style: const TextStyle(
|
||||
@@ -605,7 +605,7 @@ class _KnowledgePanelState extends State<KnowledgePanel> {
|
||||
color: scheme.surfaceContainerHighest,
|
||||
borderRadius: BorderRadius.circular(4),
|
||||
),
|
||||
child: AppText(entry.typeLabel,
|
||||
child: Text(entry.typeLabel,
|
||||
style: TextStyle(
|
||||
fontSize: 10, color: theme.hintColor)),
|
||||
),
|
||||
@@ -618,7 +618,7 @@ class _KnowledgePanelState extends State<KnowledgePanel> {
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 3),
|
||||
AppText(entry.body,
|
||||
Text(entry.body,
|
||||
maxLines: 4,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style: const TextStyle(fontSize: 12.5, height: 1.35)),
|
||||
@@ -635,8 +635,8 @@ class _KnowledgePanelState extends State<KnowledgePanel> {
|
||||
}
|
||||
},
|
||||
itemBuilder: (_) => const [
|
||||
PopupMenuItem(value: 'edit', child: AppText('编辑')),
|
||||
PopupMenuItem(value: 'delete', child: AppText('删除')),
|
||||
PopupMenuItem(value: 'edit', child: AppText('Edit')),
|
||||
PopupMenuItem(value: 'delete', child: AppText('Delete')),
|
||||
],
|
||||
),
|
||||
],
|
||||
@@ -741,13 +741,13 @@ class _KnowledgePanelState extends State<KnowledgePanel> {
|
||||
final text = await showDialog<String>(
|
||||
context: context,
|
||||
builder: (_) => _TextPromptDialog(
|
||||
title: note == null ? '新建笔记' : '编辑笔记',
|
||||
hint: tr('记点什么,供之后的会话参考'),
|
||||
title: note == null ? 'New note' : 'Edit note',
|
||||
hint: tr('Write something for later sessions to read'),
|
||||
initial: note?.body ?? '',
|
||||
maxLength: 3000,
|
||||
maxLines: 10,
|
||||
minLines: 4,
|
||||
action: '保存',
|
||||
action: 'Save',
|
||||
),
|
||||
);
|
||||
if (text == null || text.isEmpty) return;
|
||||
@@ -770,12 +770,12 @@ class _KnowledgePanelState extends State<KnowledgePanel> {
|
||||
final text = await showDialog<String>(
|
||||
context: context,
|
||||
builder: (_) => _TextPromptDialog(
|
||||
title: '新建待办',
|
||||
hint: tr('要做什么'),
|
||||
title: 'New todo',
|
||||
hint: tr('What needs doing'),
|
||||
maxLength: 1000,
|
||||
maxLines: 1,
|
||||
minLines: 1,
|
||||
action: '保存',
|
||||
action: 'Save',
|
||||
),
|
||||
);
|
||||
if (text == null || text.isEmpty) return;
|
||||
@@ -876,7 +876,7 @@ class _PlanPageState extends State<_PlanPage> {
|
||||
} catch (error) {
|
||||
if (mounted) {
|
||||
ScaffoldMessenger.of(context)
|
||||
.showSnackBar(SnackBar(content: AppText('$error')));
|
||||
.showSnackBar(SnackBar(content: Text('$error')));
|
||||
}
|
||||
} finally {
|
||||
if (mounted) setState(() => _saving = false);
|
||||
@@ -887,18 +887,18 @@ class _PlanPageState extends State<_PlanPage> {
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: AppText(widget.title, maxLines: 1, overflow: TextOverflow.ellipsis),
|
||||
title: Text(widget.title, maxLines: 1, overflow: TextOverflow.ellipsis),
|
||||
actions: [
|
||||
if (_editing)
|
||||
TextButton(
|
||||
onPressed: _saving ? null : () => setState(() => _editing = false),
|
||||
child: const AppText('取消'),
|
||||
child: const AppText('Cancel'),
|
||||
),
|
||||
TextButton(
|
||||
onPressed: _saving
|
||||
? null
|
||||
: (_editing ? _save : () => setState(() => _editing = true)),
|
||||
child: AppText(_saving ? '保存中…' : (_editing ? '保存' : '编辑')),
|
||||
child: AppText(_saving ? 'Saving…' : (_editing ? 'Save' : 'Edit')),
|
||||
),
|
||||
],
|
||||
),
|
||||
@@ -983,7 +983,7 @@ class _TextPromptDialogState extends State<_TextPromptDialog> {
|
||||
actions: [
|
||||
TextButton(
|
||||
onPressed: () => Navigator.pop(context),
|
||||
child: const AppText('取消')),
|
||||
child: const AppText('Cancel')),
|
||||
FilledButton(
|
||||
onPressed: () => Navigator.pop(context, _controller.text.trim()),
|
||||
child: AppText(widget.action)),
|
||||
@@ -1014,7 +1014,7 @@ class _NewPlanDialogState extends State<_NewPlanDialog> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return AlertDialog(
|
||||
title: const AppText('新建计划'),
|
||||
title: const AppText('New plan'),
|
||||
content: SizedBox(
|
||||
width: double.maxFinite,
|
||||
child: Column(
|
||||
@@ -1025,7 +1025,7 @@ class _NewPlanDialogState extends State<_NewPlanDialog> {
|
||||
autofocus: true,
|
||||
maxLength: 160,
|
||||
decoration: InputDecoration(
|
||||
labelText: tr('标题'),
|
||||
labelText: tr('Title'),
|
||||
border: const OutlineInputBorder(),
|
||||
),
|
||||
),
|
||||
@@ -1036,7 +1036,7 @@ class _NewPlanDialogState extends State<_NewPlanDialog> {
|
||||
minLines: 6,
|
||||
decoration: InputDecoration(
|
||||
alignLabelWithHint: true,
|
||||
labelText: tr('计划正文(Markdown)'),
|
||||
labelText: tr('Plan body (Markdown)'),
|
||||
border: const OutlineInputBorder(),
|
||||
),
|
||||
),
|
||||
@@ -1046,11 +1046,11 @@ class _NewPlanDialogState extends State<_NewPlanDialog> {
|
||||
actions: [
|
||||
TextButton(
|
||||
onPressed: () => Navigator.pop(context),
|
||||
child: const AppText('取消')),
|
||||
child: const AppText('Cancel')),
|
||||
FilledButton(
|
||||
onPressed: () => Navigator.pop(
|
||||
context, (_title.text.trim(), _body.text)),
|
||||
child: const AppText('创建')),
|
||||
child: const AppText('Create')),
|
||||
],
|
||||
);
|
||||
}
|
||||
@@ -1082,7 +1082,7 @@ class _MemoryDialogState extends State<_MemoryDialog> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return AlertDialog(
|
||||
title: const AppText('编辑记忆'),
|
||||
title: const AppText('Edit memory'),
|
||||
content: SizedBox(
|
||||
width: double.maxFinite,
|
||||
child: Column(
|
||||
@@ -1093,7 +1093,7 @@ class _MemoryDialogState extends State<_MemoryDialog> {
|
||||
autofocus: true,
|
||||
maxLength: 120,
|
||||
decoration: InputDecoration(
|
||||
labelText: tr('标题'),
|
||||
labelText: tr('Title'),
|
||||
border: const OutlineInputBorder(),
|
||||
),
|
||||
),
|
||||
@@ -1105,9 +1105,9 @@ class _MemoryDialogState extends State<_MemoryDialog> {
|
||||
tapTargetSize: MaterialTapTargetSize.shrinkWrap,
|
||||
),
|
||||
segments: const [
|
||||
ButtonSegment(value: 'fact', label: AppText('事实')),
|
||||
ButtonSegment(value: 'preference', label: AppText('偏好')),
|
||||
ButtonSegment(value: 'reference', label: AppText('参考')),
|
||||
ButtonSegment(value: 'fact', label: AppText('Fact')),
|
||||
ButtonSegment(value: 'preference', label: AppText('Preference')),
|
||||
ButtonSegment(value: 'reference', label: AppText('Reference')),
|
||||
],
|
||||
selected: {_type},
|
||||
onSelectionChanged: (value) =>
|
||||
@@ -1121,7 +1121,7 @@ class _MemoryDialogState extends State<_MemoryDialog> {
|
||||
minLines: 4,
|
||||
decoration: InputDecoration(
|
||||
alignLabelWithHint: true,
|
||||
labelText: tr('内容'),
|
||||
labelText: tr('Content'),
|
||||
border: const OutlineInputBorder(),
|
||||
),
|
||||
),
|
||||
@@ -1130,14 +1130,14 @@ class _MemoryDialogState extends State<_MemoryDialog> {
|
||||
),
|
||||
actions: [
|
||||
TextButton(
|
||||
onPressed: () => Navigator.pop(context), child: const AppText('取消')),
|
||||
onPressed: () => Navigator.pop(context), child: const AppText('Cancel')),
|
||||
FilledButton(
|
||||
onPressed: () {
|
||||
final title = _title.text.trim();
|
||||
if (title.isEmpty) return;
|
||||
Navigator.pop(context, (title, _body.text.trim(), _type));
|
||||
},
|
||||
child: const AppText('保存'),
|
||||
child: const AppText('Save'),
|
||||
),
|
||||
],
|
||||
);
|
||||
|
||||
Reference in new issue
Block a user