fix: keep loaded tool output when the tail page only has its shell
List responses ask the server to elide large tool output (`x-openchamber-part-shells: v1`): the part comes back as an empty text plus an `openchamberContentShell` marker, and the full text is fetched when a step is expanded. Every tail refresh (a turn starting, the app returning) then replaced the loaded message with that shell again, so an expanded step fell back to "无输出" — the more the session was used, the more it looked like shell steps never had output. reloadTail now keeps an already-loaded tool part when the server's copy of that part is a shell (matched by position and call id), and the pending state reads "输出较大,正在载入…" instead of claiming there was no output. Version 0.3.7 (code 307).
This commit is contained in:
1 parent
6c00e5e026
commit
fbadf6f858
5 files changed
+68
-4
No files matched your search
@@ -27,6 +27,18 @@
|
|||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
|
## 0.3.7 工具输出被“壳”覆盖(分支 `flutter`)
|
||||||
|
|
||||||
|
| 项 | 结果 |
|
||||||
|
| --- | --- |
|
||||||
|
| 现象 | 会话列表接口带 `x-openchamber-part-shells: v1` 时,大一点的工具输出只给一个空壳:`content:[{type:'text',text:''}]` + `metadata.openchamberContentShell`。展开步骤时客户端会单条拉完整消息(`/message/:id`,不带壳),输出就出来了 |
|
||||||
|
| 根因 | 每次 `reloadTail()`(每轮 `execution.started`、回到前台等)都用**带壳**的列表覆盖本地消息,把刚加载出来的输出又盖回空壳,于是展开着的那一步变回「无输出」——看起来就像“始终无输出” |
|
||||||
|
| 修复 | `reloadTail` 合并消息时,如果服务端给的是壳、本地这一条已经加载过完整内容,就保留本地那条(按 part 顺序与 call id 对齐),不再降级;真没有输出的命令仍然显示「无输出」 |
|
||||||
|
| 提示 | 壳还没加载完时不再显示「无输出」,而是「输出较大,正在载入…」 |
|
||||||
|
| 版本 | **0.3.7(code 307)** |
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
## 0.3.6 斜杠指令与错误显示(分支 `flutter`)
|
## 0.3.6 斜杠指令与错误显示(分支 `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.3.6 — servers (passwordless / password login, HTTP/HTTPS and
|
Status: 0.3.7 — servers (passwordless / password login, HTTP/HTTPS and
|
||||||
SOCKS5/socks5h proxy, self-signed certificates and pinning), session list with search and live
|
SOCKS5/socks5h proxy, self-signed certificates and pinning), session list with search and live
|
||||||
events, chat with streaming Markdown and full history paging, tool steps
|
events, chat with streaming Markdown and full history paging, tool steps
|
||||||
grouped per turn (icon, one-line summary, foldable run) with image previews, a
|
grouped per turn (icon, one-line summary, foldable run) with image previews, a
|
||||||
|
|||||||
@@ -770,6 +770,10 @@ class _ChatScreenState extends State<ChatScreen> {
|
|||||||
final shell = _isShell(p);
|
final shell = _isShell(p);
|
||||||
final command = shell ? '${input['command'] ?? ''}'.trim() : '';
|
final command = shell ? '${input['command'] ?? ''}'.trim() : '';
|
||||||
final output = toolOutput(p);
|
final output = toolOutput(p);
|
||||||
|
// A big output arrives as an empty shell until the message is fetched;
|
||||||
|
// that is not the same as a command that printed nothing.
|
||||||
|
final shelled = shell &&
|
||||||
|
(p.state?.metadata?.containsKey('openchamberContentShell') ?? false);
|
||||||
const mono = TextStyle(fontSize: 12, height: 1.45, fontFamily: 'monospace');
|
const mono = TextStyle(fontSize: 12, height: 1.45, fontFamily: 'monospace');
|
||||||
return Padding(
|
return Padding(
|
||||||
padding: const EdgeInsets.fromLTRB(10, 2, 10, 8),
|
padding: const EdgeInsets.fromLTRB(10, 2, 10, 8),
|
||||||
@@ -796,7 +800,11 @@ class _ChatScreenState extends State<ChatScreen> {
|
|||||||
),
|
),
|
||||||
if (extras.isNotEmpty) const SizedBox(height: 4),
|
if (extras.isNotEmpty) const SizedBox(height: 4),
|
||||||
SelectableText(
|
SelectableText(
|
||||||
output.isEmpty ? (shell ? '无输出' : '无内容') : output,
|
output.isNotEmpty
|
||||||
|
? output
|
||||||
|
: shelled
|
||||||
|
? '输出较大,正在载入…'
|
||||||
|
: (shell ? '无输出' : '无内容'),
|
||||||
style: mono.copyWith(
|
style: mono.copyWith(
|
||||||
color: p.state?.error != null
|
color: p.state?.error != null
|
||||||
? theme.colorScheme.error
|
? theme.colorScheme.error
|
||||||
|
|||||||
+45
-1
@@ -602,6 +602,46 @@ class ChatState extends ChangeNotifier {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// A page keeps large tool outputs out (`x-openchamber-part-shells`); the
|
||||||
|
/// message itself still carries them. Such a part reads as an empty text.
|
||||||
|
static bool _shelledPart(ContentPart p) =>
|
||||||
|
p.type == 'tool' &&
|
||||||
|
(p.state?.metadata?.containsKey('openchamberContentShell') ?? false);
|
||||||
|
|
||||||
|
/// The server's copy of a message, except that a tool output already loaded
|
||||||
|
/// in full is kept: taking the shell back would turn the step's output into
|
||||||
|
/// "无输出" again on the next tail refresh.
|
||||||
|
static Message _keepLoadedOutput(Message local, Message server) {
|
||||||
|
if (!server.content.any(_shelledPart)) return server;
|
||||||
|
final parts = <ContentPart>[];
|
||||||
|
for (var i = 0; i < server.content.length; i++) {
|
||||||
|
final s = server.content[i];
|
||||||
|
final l = i < local.content.length ? local.content[i] : null;
|
||||||
|
final loaded = l != null &&
|
||||||
|
l.type == 'tool' &&
|
||||||
|
l.id == s.id &&
|
||||||
|
(l.state?.content.any((c) => c.text.isNotEmpty) ?? false);
|
||||||
|
parts.add(_shelledPart(s) && loaded ? l : s);
|
||||||
|
}
|
||||||
|
return Message(
|
||||||
|
id: server.id,
|
||||||
|
type: server.type,
|
||||||
|
created: server.created,
|
||||||
|
completed: server.completed,
|
||||||
|
agent: server.agent,
|
||||||
|
model: server.model,
|
||||||
|
content: parts,
|
||||||
|
text: server.text,
|
||||||
|
files: server.files,
|
||||||
|
finish: server.finish,
|
||||||
|
cost: server.cost,
|
||||||
|
tokens: server.tokens,
|
||||||
|
error: server.error,
|
||||||
|
status: server.status,
|
||||||
|
reason: server.reason,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
/// Refreshes the newest page without dropping the older pages that were
|
/// Refreshes the newest page without dropping the older pages that were
|
||||||
/// already loaded; the server's copy wins for messages it returns.
|
/// already loaded; the server's copy wins for messages it returns.
|
||||||
Future<void> reloadTail() async {
|
Future<void> reloadTail() async {
|
||||||
@@ -612,7 +652,11 @@ class ChatState extends ChangeNotifier {
|
|||||||
} else {
|
} else {
|
||||||
final fresh = {for (final m in page.data) m.id: m};
|
final fresh = {for (final m in page.data) m.id: m};
|
||||||
final merged = <Message>[
|
final merged = <Message>[
|
||||||
for (final m in msgs) fresh.remove(m.id) ?? m,
|
for (final m in msgs)
|
||||||
|
switch (fresh.remove(m.id)) {
|
||||||
|
final Message s => _keepLoadedOutput(m, s),
|
||||||
|
null => m,
|
||||||
|
},
|
||||||
for (final m in page.data)
|
for (final m in page.data)
|
||||||
if (fresh.containsKey(m.id)) m,
|
if (fresh.containsKey(m.id)) m,
|
||||||
];
|
];
|
||||||
|
|||||||
+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.3.6+306
|
version: 0.3.7+307
|
||||||
|
|
||||||
environment:
|
environment:
|
||||||
sdk: ^3.14.0
|
sdk: ^3.14.0
|
||||||
|
|||||||
Reference in new issue
Block a user