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

+3 -3
View File
@@ -907,9 +907,9 @@ class AgentMemoryEntry {
);
String get typeLabel => switch (type) {
'preference' => tr('偏好'),
'reference' => tr('参考'),
_ => tr('事实'),
'preference' => tr('Preference'),
'reference' => tr('Reference'),
_ => tr('Fact'),
};
}
+1 -1
View File
@@ -84,7 +84,7 @@ class RelayTransport implements Transport {
final bytes = await response.body
.fold<List<int>>(<int>[], (all, chunk) => all..addAll(chunk));
if (response.status < 200 || response.status >= 300) {
throw RelayTunnelException(trArgs('无法获取 WebSocket 令牌({0})', [response.status]));
throw RelayTunnelException(trArgs('Could not get a WebSocket token ({0})', [response.status]));
}
try {
final decoded = jsonDecode(utf8.decode(bytes, allowMalformed: true));
+13 -13
View File
@@ -133,11 +133,11 @@ class RelayTunnel {
try {
decoded = jsonDecode(utf8.decode(payload));
} catch (_) {
finish(error: RelayTunnelException(tr('响应头无效')));
finish(error: RelayTunnelException(tr('Invalid response headers')));
return;
}
if (decoded is! Map) {
finish(error: RelayTunnelException(tr('响应头无效')));
finish(error: RelayTunnelException(tr('Invalid response headers')));
return;
}
final status = (decoded['status'] as num?)?.toInt() ?? 0;
@@ -162,7 +162,7 @@ class RelayTunnel {
controller.close();
break;
case RelayFrameType.streamAbort:
var reason = tr('传输被中断');
var reason = tr('Transfer interrupted');
try {
final decoded = jsonDecode(utf8.decode(payload));
if (decoded is Map && decoded['reason'] is String) {
@@ -269,7 +269,7 @@ class RelayTunnel {
ws = await WebSocket.connect(uri.toString(), customClient: _http)
.timeout(_connectTimeout);
} catch (error) {
throw RelayTunnelException(trArgs('无法连接 Relay:{0}', [error]));
throw RelayTunnelException(trArgs('Could not connect to the relay: {0}', [error]));
}
final channel = _RelayChannel(ws);
final ready = Completer<void>();
@@ -326,7 +326,7 @@ class RelayTunnel {
deadline?.cancel();
ready.complete();
} catch (error) {
closeWith(RelayTunnelException(trArgs('密钥协商失败:{0}', [error])));
closeWith(RelayTunnelException(trArgs('Key exchange failed: {0}', [error])));
}
}
return;
@@ -334,7 +334,7 @@ class RelayTunnel {
// After the channel is up the host may repeat `ready` for a retried
// hello; anything else plaintext is a protocol violation.
if (raw.contains('"ready"')) return;
closeWith(RelayTunnelException(tr('握手后收到明文帧')));
closeWith(RelayTunnelException(tr('Received a plaintext frame after the handshake')));
return;
}
if (raw is! List<int>) return;
@@ -344,24 +344,24 @@ class RelayTunnel {
final plaintext = channel.decryptor.decrypt(Uint8List.fromList(raw));
channel.handlePlaintext(plaintext);
} catch (error) {
closeWith(RelayTunnelException(trArgs('解密失败:{0}', [error])));
closeWith(RelayTunnelException(trArgs('Decryption failed: {0}', [error])));
}
}
subscription = ws.listen(
onData,
onError: (Object error) => closeWith(RelayTunnelException(trArgs('Relay 连接出错:{0}', [error]))),
onError: (Object error) => closeWith(RelayTunnelException(trArgs('Relay connection error: {0}', [error]))),
onDone: () {
if (!finished) {
closeWith(RelayTunnelException(trArgs(
'Relay 连接已关闭({0} {1})',
'Relay connection closed ({0} {1})',
[ws.closeCode ?? '-', ws.closeReason ?? ''])));
}
},
cancelOnError: true,
);
channel.onClosed = () =>
closeWith(RelayTunnelException(tr('Relay 连接已关闭')));
closeWith(RelayTunnelException(tr('Relay connection closed')));
void sendHello() {
if (finished) return;
@@ -373,13 +373,13 @@ class RelayTunnel {
sendHello();
helloTimer = Timer.periodic(const Duration(seconds: 1), (_) => sendHello());
deadline = Timer(_handshakeTimeout, () {
closeWith(RelayTunnelException(tr('Relay 握手超时')));
closeWith(RelayTunnelException(tr('Relay handshake timed out')));
});
await ready.future;
if (channel.dead) {
throw RelayTunnelException(trArgs(
'Relay 连接已关闭({0} {1})',
'Relay connection closed ({0} {1})',
[ws.closeCode ?? '-', ws.closeReason ?? '']));
}
channel.startKeepAlive();
@@ -604,7 +604,7 @@ class _RelaySocket implements TransportSocket {
_finish();
break;
case RelayFrameType.streamAbort:
_finish(error: RelayTunnelException(tr('WebSocket 子流被中断')));
_finish(error: RelayTunnelException(tr('WebSocket substream interrupted')));
break;
}
}
+26 -26
View File
@@ -166,57 +166,57 @@ class ScheduledTask {
/// The model line: a fixed choice, or that the run uses the session's.
String get modelLabel {
if (useDefaults || modelId.isEmpty) return tr('使用默认模型与智能体');
if (useDefaults || modelId.isEmpty) return tr('Use default model and agent');
final model = [providerId, modelId].where((s) => s.isNotEmpty).join('/');
return agent.isEmpty ? model : '$model · $agent';
}
}
const scheduledWeekdays = ['周日', '周一', '周二', '周三', '周四', '周五', '周六'];
const scheduledWeekdays = ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'];
const scheduledTaskKindLabels = {
'daily': '每天',
'weekly': '每周',
'once': '一次性',
'daily': 'Daily',
'weekly': 'Weekly',
'once': 'Once',
'cron': 'Cron',
};
/// '每天 09:00', '每周 周一、周三 09:00', '一次性 2026-12-01 09:00', …
String scheduledScheduleText(ScheduledTask task) {
final separator = tr('、');
final separator = tr(', ');
final times = task.times.isEmpty ? task.time : task.times.join(separator);
switch (task.kind) {
case 'daily':
return trArgs('每天 {0}', [times.isEmpty ? '--:--' : times]);
return trArgs('Daily {0}', [times.isEmpty ? '--:--' : times]);
case 'weekly':
final days = [
for (final day in task.weekdays)
if (day >= 0 && day < scheduledWeekdays.length)
tr(scheduledWeekdays[day]),
].join(separator);
return trArgs('每周 {0} {1}', [
days.isEmpty ? tr('未选') : days,
return trArgs('Weekly {0} {1}', [
days.isEmpty ? tr('no days') : days,
times.isEmpty ? '--:--' : times,
]);
case 'once':
return trArgs('一次性 {0} {1}', [
task.date.isEmpty ? tr('未选日期') : task.date,
return trArgs('Once {0} {1}', [
task.date.isEmpty ? tr('no date') : task.date,
task.time.isEmpty ? '--:--' : task.time,
]);
case 'cron':
return trArgs('Cron:{0}', [task.cron]);
return trArgs('Cron: {0}', [task.cron]);
}
return '';
}
String scheduledStatusLabel(String status) => switch (status) {
'success' || 'sent' => tr('成功'),
'error' || 'failed' => tr('错误'),
'running' => tr('运行中'),
'queued' => tr('已排队'),
'skipped' => tr('已跳过'),
'cancelled' => tr('已取消'),
_ => tr('空闲'),
'success' || 'sent' => tr('Success'),
'error' || 'failed' => tr('Error'),
'running' => tr('Running'),
'queued' => tr('Queued'),
'skipped' => tr('Skipped'),
'cancelled' => tr('Cancelled'),
_ => tr('Idle'),
};
/// How far away a moment is, in the words the web client uses.
@@ -228,24 +228,24 @@ String scheduledRelativeTime(int milliseconds) {
const hour = 60 * minute;
const day = 24 * hour;
final future = diff >= 0;
if (abs < minute) return future ? tr('不到 1 分钟后') : tr('刚刚');
if (abs < minute) return future ? tr('In less than a minute') : tr('Just now');
if (abs < hour) {
final m = (abs / minute).round();
return future
? trArgs('{0} 分钟后', [m])
: trArgs('{0} 分钟前', [m]);
? trArgs('In {0} min', [m])
: trArgs('{0} min ago', [m]);
}
if (abs < day) {
final h = abs ~/ hour;
final m = ((abs % hour) / minute).round();
final body =
m > 0 ? trArgs('{0} 小时 {1} 分钟', [h, m]) : trArgs('{0} 小时', [h]);
return future ? trArgs('{0}后', [body]) : trArgs('{0}前', [body]);
m > 0 ? trArgs('{0} hr {1} min', [h, m]) : trArgs('{0} hr', [h]);
return future ? trArgs('In {0}', [body]) : trArgs('{0} ago', [body]);
}
final d = abs ~/ day;
final h = ((abs % day) / hour).round();
final body = h > 0 ? trArgs('{0} 天 {1} 小时', [d, h]) : trArgs('{0} 天', [d]);
return future ? trArgs('{0}后', [body]) : trArgs('{0}前', [body]);
final body = h > 0 ? trArgs('{0} days {1} hr', [d, h]) : trArgs('{0} days', [d]);
return future ? trArgs('In {0}', [body]) : trArgs('{0} ago', [body]);
}
String scheduledClock(int milliseconds) {
+2 -2
View File
@@ -239,11 +239,11 @@ const shellOutputTailBytes = 256 * 1024;
/// `12秒`, `3分05秒`, `1:02:03`: the running clock a task row shows.
String formatElapsed(int milliseconds) {
final secs = milliseconds <= 0 ? 0 : milliseconds ~/ 1000;
if (secs < 60) return trArgs('{0}秒', [secs]);
if (secs < 60) return trArgs('{0}s', [secs]);
if (secs < 3600) {
final rest = secs % 60;
return trArgs(
'{0}分{1}秒', [secs ~/ 60, rest.toString().padLeft(2, '0')]);
'{0}m{1}s', [secs ~/ 60, rest.toString().padLeft(2, '0')]);
}
final hours = secs ~/ 3600;
final mins = (secs % 3600) ~/ 60;
+4 -4
View File
@@ -98,7 +98,7 @@ class CancelToken {
class DownloadCancelled implements Exception {
const DownloadCancelled();
@override
String toString() => tr('下载已取消');
String toString() => tr('Download cancelled');
}
/// A proxy as configured: an HTTP CONNECT proxy, or a SOCKS5 one.
@@ -120,14 +120,14 @@ ProxyConfig? parseProxy(String? raw) {
if (!normalized.contains('://')) normalized = 'http://$normalized';
final uri = Uri.tryParse(normalized);
if (uri == null || uri.host.isEmpty) {
throw ArgumentError(trArgs('代理地址无效:{0}', [raw]));
throw ArgumentError(trArgs('Invalid proxy address: {0}', [raw]));
}
final scheme = uri.scheme.toLowerCase();
final socks = scheme == 'socks' || scheme == 'socks5' || scheme == 'socks5h';
final http = scheme == 'http' || scheme == 'https';
if (!socks && !http) {
throw ArgumentError(trArgs(
'不支持的代理协议:{0}(支持 http、https、socks5、socks5h)', [scheme]));
'Unsupported proxy protocol: {0} (supported: http, https, socks5, socks5h)', [scheme]));
}
String? user;
String? pass;
@@ -193,7 +193,7 @@ class DirectTransport implements Transport {
if (_proxyAddress != null) return _proxyAddress!;
final addresses = await InternetAddress.lookup(_proxyConfig!.host);
if (addresses.isEmpty) {
throw SocketException(tr('无法解析代理主机'));
throw SocketException(tr('Could not resolve the proxy host'));
}
return _proxyAddress = addresses.first;
}