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:
blumia committed 2026-11-26 11:48:16 +08:00
1 parent 7b5bccf28f
commit 511c3b006b
43 files changed
+1620 -1791

No files matched your search

+66 -66
View File
@@ -81,13 +81,13 @@ class _SessionListPaneState extends State<SessionListPane> {
children: [
const SizedBox(width: 12),
const Expanded(
child: AppText('会话',
child: AppText('Sessions',
style: TextStyle(
fontSize: 20, fontWeight: FontWeight.w600)),
),
IconButton(
icon: Icon(_searchOpen ? Icons.close : Icons.search),
tooltip: tr('搜索'),
tooltip: tr('Search'),
onPressed: () {
setState(() {
_searchOpen = !_searchOpen;
@@ -100,7 +100,7 @@ class _SessionListPaneState extends State<SessionListPane> {
),
IconButton(
icon: const Icon(Icons.add),
tooltip: tr('新会话'),
tooltip: tr('New session'),
onPressed: () => _newSession(),
),
],
@@ -114,7 +114,7 @@ class _SessionListPaneState extends State<SessionListPane> {
autofocus: true,
onChanged: _onSearchChanged,
decoration: InputDecoration(
hintText: tr('搜索会话'),
hintText: tr('Search sessions'),
prefixIcon: const Icon(Icons.search),
border: const OutlineInputBorder(),
isDense: true,
@@ -127,13 +127,13 @@ class _SessionListPaneState extends State<SessionListPane> {
child: Row(
children: [
Expanded(
child: AppText(_app.error!,
child: Text(_app.error!,
style: TextStyle(
color: scheme.error, fontSize: 13)),
),
TextButton(
onPressed: _app.refreshSessions,
child: const AppText('重试')),
child: const AppText('Retry')),
],
),
),
@@ -189,12 +189,12 @@ class _SessionListPaneState extends State<SessionListPane> {
),
IconButton(
icon: const Icon(Icons.widgets_outlined),
tooltip: tr('全部功能'),
tooltip: tr('All features'),
onPressed: _openFeatures,
),
IconButton(
icon: const Icon(Icons.settings_outlined),
tooltip: tr('设置'),
tooltip: tr('Settings'),
onPressed: _openSettings,
),
],
@@ -242,10 +242,10 @@ class _SessionListPaneState extends State<SessionListPane> {
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
AppText(_searchCtrl.text.isEmpty ? '暂无会话' : '没有匹配的会话'),
AppText(_searchCtrl.text.isEmpty ? 'No sessions' : 'No matching sessions'),
const SizedBox(height: 8),
FilledButton(
onPressed: () => _newSession(), child: const AppText('新会话')),
onPressed: () => _newSession(), child: const AppText('New session')),
],
),
);
@@ -284,7 +284,7 @@ class _SessionListPaneState extends State<SessionListPane> {
_SessionGroup(
key: entry.key,
label: entry.key == AppState.chatTarget
? '聊天'
? tr('Chat')
: _app.projectLabelFor(entry.value.first.directory),
// The first session's own path: the server knows that spelling.
path: entry.key == AppState.chatTarget
@@ -350,8 +350,8 @@ class _SessionListPaneState extends State<SessionListPane> {
),
],
),
title: AppText(
group.label.isEmpty ? '未命名项目' : group.label,
title: Text(
group.label.isEmpty ? tr('Untitled project') : group.label,
maxLines: 1,
overflow: TextOverflow.ellipsis,
style: TextStyle(
@@ -362,7 +362,7 @@ class _SessionListPaneState extends State<SessionListPane> {
),
subtitle: group.path.isEmpty
? null
: AppText(
: Text(
group.path,
maxLines: 1,
overflow: TextOverflow.ellipsis,
@@ -377,8 +377,8 @@ class _SessionListPaneState extends State<SessionListPane> {
icon: const Icon(Icons.add, size: 20),
padding: EdgeInsets.zero,
tooltip: group.key == AppState.chatTarget
? tr('新建聊天')
: tr('在此项目新会话'),
? tr('New chat')
: tr('New session in this project'),
onPressed: () => _newSession(
directory: group.key == AppState.chatTarget
? AppState.chatTarget
@@ -413,10 +413,10 @@ class _SessionListPaneState extends State<SessionListPane> {
final yesterday = today.subtract(const Duration(days: 1));
final weekAgo = today.subtract(const Duration(days: 7));
final buckets = <String, List<Session>>{
'今天': [],
'昨天': [],
'本周早些时候': [],
'更早': [],
'Today': [],
'Yesterday': [],
'Earlier this week': [],
'Earlier': [],
};
for (final session in sessions) {
final time = session.updated > 0
@@ -424,12 +424,12 @@ class _SessionListPaneState extends State<SessionListPane> {
: DateTime.fromMillisecondsSinceEpoch(session.created);
final day = DateTime(time.year, time.month, time.day);
final key = day == today
? '今天'
? 'Today'
: day == yesterday
? '昨天'
? 'Yesterday'
: day.isAfter(weekAgo)
? '本周早些时候'
: '更早';
? 'Earlier this week'
: 'Earlier';
buckets[key]!.add(session);
}
return [
@@ -459,7 +459,7 @@ class _SessionListPaneState extends State<SessionListPane> {
size: 13, color: Theme.of(context).hintColor),
const SizedBox(width: 5),
Expanded(
child: AppText('已置顶',
child: AppText('Pinned',
style: TextStyle(
fontSize: 12.5,
fontWeight: FontWeight.w700,
@@ -478,25 +478,25 @@ class _SessionListPaneState extends State<SessionListPane> {
Widget _draftRow(SessionDraft draft) {
final theme = Theme.of(context);
final label = draft.firstLine.isEmpty ? tr('新会话') : draft.firstLine;
final label = draft.firstLine.isEmpty ? tr('New session') : draft.firstLine;
final project = _app.projectLabelFor(draft.directory);
return ListTile(
selected: _app.draftOpen,
leading: Icon(Icons.edit_outlined, size: 18, color: theme.hintColor),
title: AppText(
title: Text(
label,
maxLines: 1,
overflow: TextOverflow.ellipsis,
style: const TextStyle(fontStyle: FontStyle.italic),
),
subtitle: AppText(
project.isEmpty ? '草稿' : trArgs('草稿 · {0}', [project]),
project.isEmpty ? 'Draft' : trArgs('Draft · {0}', [project]),
maxLines: 1,
overflow: TextOverflow.ellipsis,
),
trailing: IconButton(
icon: const Icon(Icons.close, size: 18),
tooltip: tr('丢弃草稿'),
tooltip: tr('Discard draft'),
onPressed: () => _app.discardDraft(),
),
onTap: () {
@@ -569,21 +569,21 @@ class _SessionListPaneState extends State<SessionListPane> {
SlidableAction(
onPressed: (_) => _app.togglePin(session),
icon: Icons.push_pin_outlined,
label: session.isPinned ? tr('取消置顶') : tr('置顶'),
label: session.isPinned ? tr('Unpin') : tr('Pin'),
backgroundColor: scheme.secondaryContainer,
foregroundColor: scheme.onSecondaryContainer,
),
SlidableAction(
onPressed: (_) => _archive(session, archived),
icon: archived ? Icons.unarchive_outlined : Icons.archive_outlined,
label: archived ? tr('取消归档') : tr('归档'),
label: archived ? tr('Unarchive') : tr('Archive'),
backgroundColor: scheme.surfaceContainerHighest,
foregroundColor: scheme.onSurface,
),
SlidableAction(
onPressed: (_) => _confirmDelete(session),
icon: Icons.delete_outline,
label: tr('删除'),
label: tr('Delete'),
backgroundColor: scheme.errorContainer,
foregroundColor: scheme.onErrorContainer,
),
@@ -615,7 +615,7 @@ class _SessionListPaneState extends State<SessionListPane> {
? Icons.expand_more
: Icons.chevron_right,
size: 18),
tooltip: expanded ? tr('收起子代理') : tr('展开子代理'),
tooltip: expanded ? tr('Collapse subagents') : tr('Expand subagents'),
padding: EdgeInsets.zero,
visualDensity: VisualDensity.compact,
constraints:
@@ -629,8 +629,8 @@ class _SessionListPaneState extends State<SessionListPane> {
}),
),
),
title: AppText(
session.title.isEmpty ? '(无标题会话)' : session.title,
title: Text(
session.title.isEmpty ? tr('(Untitled session)') : session.title,
maxLines: 1,
overflow: TextOverflow.ellipsis,
style: TextStyle(
@@ -638,8 +638,8 @@ class _SessionListPaneState extends State<SessionListPane> {
fontWeight: selected ? FontWeight.w600 : FontWeight.w400,
),
),
subtitle: AppText(
child ? trArgs('子代理 · {0}', [_subtitle(session)]) : _subtitle(session),
subtitle: Text(
child ? trArgs('Subagent · {0}', [_subtitle(session)]) : _subtitle(session),
maxLines: 1,
overflow: TextOverflow.ellipsis),
trailing: Row(
@@ -696,22 +696,22 @@ class _SessionListPaneState extends State<SessionListPane> {
case 'copy':
Clipboard.setData(ClipboardData(text: session.id));
ScaffoldMessenger.of(context).showSnackBar(
const SnackBar(content: AppText('已复制会话 ID')));
const SnackBar(content: AppText('Session ID copied')));
break;
}
},
itemBuilder: (_) => [
if (!archived) ...[
const PopupMenuItem(value: 'rename', child: AppText('重命名')),
const PopupMenuItem(value: 'rename', child: AppText('Rename')),
PopupMenuItem(
value: 'pin',
child: AppText(session.isPinned ? '取消置顶' : '置顶')),
child: AppText(session.isPinned ? 'Unpin' : 'Pin')),
],
PopupMenuItem(
value: 'archive',
child: AppText(archived ? '取消归档' : '归档')),
const PopupMenuItem(value: 'delete', child: AppText('删除')),
const PopupMenuItem(value: 'copy', child: AppText('复制会话 ID')),
child: AppText(archived ? 'Unarchive' : 'Archive')),
const PopupMenuItem(value: 'delete', child: AppText('Delete')),
const PopupMenuItem(value: 'copy', child: AppText('Copy session ID')),
],
),
);
@@ -731,7 +731,7 @@ class _SessionListPaneState extends State<SessionListPane> {
width: 16,
height: 16,
child: CircularProgressIndicator(strokeWidth: 2))
: const AppText('载入更多'),
: const AppText('Load more'),
),
TextButton.icon(
icon: Icon(
@@ -741,10 +741,10 @@ class _SessionListPaneState extends State<SessionListPane> {
size: 16),
label: AppText(
_showArchived
? '隐藏已归档'
? 'Hide archived'
: archivedCount == null
? '显示已归档'
: trArgs('显示已归档 ({0})', [archivedCount]),
? 'Show archived'
: trArgs('Show archived ({0})', [archivedCount]),
style: const TextStyle(fontSize: 12.5),
),
onPressed: app.archivedLoading ? null : _toggleArchived,
@@ -765,7 +765,7 @@ class _SessionListPaneState extends State<SessionListPane> {
app.archivedSessions.isEmpty)
Padding(
padding: const EdgeInsets.only(bottom: 8),
child: AppText('没有已归档的会话',
child: AppText('No archived sessions',
style: TextStyle(fontSize: 12, color: scheme.outline)),
),
],
@@ -785,7 +785,7 @@ class _SessionListPaneState extends State<SessionListPane> {
final parts = <String>[];
if (s.agent.isNotEmpty) parts.add(s.agent);
final children = _childrenOf(s).length;
if (children > 0) parts.add(trArgs('{0} 个子代理', [children]));
if (children > 0) parts.add(trArgs('{0} subagents', [children]));
if (s.model != null) parts.add(_app.modelName(s.model));
if (s.updated > 0) {
final t = DateTime.fromMillisecondsSinceEpoch(s.updated);
@@ -812,18 +812,18 @@ class _SessionListPaneState extends State<SessionListPane> {
showDialog(
context: context,
builder: (context) => AlertDialog(
title: const AppText('重命名'),
title: const AppText('Rename'),
content: TextField(controller: ctrl, autofocus: true),
actions: [
TextButton(
onPressed: () => Navigator.pop(context),
child: const AppText('取消')),
child: const AppText('Cancel')),
FilledButton(
onPressed: () {
Navigator.pop(context);
_app.client?.updateSession(s.id, title: ctrl.text);
},
child: const AppText('保存'),
child: const AppText('Save'),
),
],
),
@@ -834,12 +834,12 @@ class _SessionListPaneState extends State<SessionListPane> {
showDialog(
context: context,
builder: (context) => AlertDialog(
title: const AppText('删除会话?'),
content: AppText(trArgs('“{0}”及其子会话将被删除,且无法恢复。', [s.title])),
title: const AppText('Delete session?'),
content: AppText(trArgs('“{0}” and its subagent sessions will be deleted permanently.', [s.title])),
actions: [
TextButton(
onPressed: () => Navigator.pop(context),
child: const AppText('取消')),
child: const AppText('Cancel')),
FilledButton(
onPressed: () {
Navigator.pop(context);
@@ -848,7 +848,7 @@ class _SessionListPaneState extends State<SessionListPane> {
_app.archivedSessions.removeWhere((x) => x.id == s.id);
_app.touch();
},
child: const AppText('删除'),
child: const AppText('Delete'),
),
],
),
@@ -865,20 +865,20 @@ class _SessionListPaneState extends State<SessionListPane> {
children: [
const Padding(
padding: EdgeInsets.all(12),
child: AppText('服务器',
child: AppText('Servers',
style:
TextStyle(fontSize: 18, fontWeight: FontWeight.bold)),
),
for (final c in app.connections) ...[
ListTile(
title: AppText(c.label),
subtitle: AppText(c.isRelay
? trArgs('经由 Relay · {0}', [c.serverId])
title: Text(c.label),
subtitle: Text(c.isRelay
? trArgs('Via Relay · {0}', [c.serverId])
: (c.proxy.isEmpty
? c.url
: trArgs('{0}\n经由 {1}', [c.url, c.proxy]))),
: trArgs('{0}\nvia {1}', [c.url, c.proxy]))),
trailing: app.conn?.id == c.id
? AppText('已连接',
? AppText('Connected',
style: TextStyle(
color: Theme.of(context).colorScheme.primary))
: null,
@@ -890,7 +890,7 @@ class _SessionListPaneState extends State<SessionListPane> {
],
ListTile(
leading: const Icon(Icons.add),
title: const AppText('添加服务器'),
title: const AppText('Add server'),
onTap: () {
Navigator.pop(context);
Navigator.of(context).push(MaterialPageRoute(
@@ -900,8 +900,8 @@ class _SessionListPaneState extends State<SessionListPane> {
),
ListTile(
leading: const Icon(Icons.qr_code_2),
title: const AppText('配对链接'),
subtitle: const AppText('直连地址或 OpenChamber Relay'),
title: const AppText('Pairing link'),
subtitle: const AppText('Direct address or OpenChamber Relay'),
onTap: () {
Navigator.pop(context);
showPairingDialog(context, app);
@@ -910,7 +910,7 @@ class _SessionListPaneState extends State<SessionListPane> {
if (app.client != null)
ListTile(
leading: const Icon(Icons.link_off),
title: const AppText('断开当前连接'),
title: const AppText('Disconnect'),
onTap: () {
Navigator.pop(context);
app.disconnect();