perf: open long sessions without re-reading every tool result

A chat page carried every finished tool result, and the app fetched it
twice when opening a chat, with a 20 second deadline. On a slow link a
long session (this one was ~530 KB per page) timed out.

- ask for shelled pages (x-openchamber-part-shells: v1), which drops
  finished tool results: ~180 KB for the same page
- fetch one message by id when its tool row is opened
- keep tool and step updates local from events instead of re-reading
  the page on every step, and only resync after a real disconnect
- 60 second deadline with a retry button

Bump version to 0.1.11 (build 12).
This commit is contained in:
blumia committed 2026-11-16 20:04:42 +08:00
1 parent 0e34d82a06
commit e67490e768
8 files changed
+256 -20

No files matched your search

+25 -1
View File
@@ -64,7 +64,10 @@ func newChatServer(t *testing.T) *chatServer {
{"id":"msg_1","type":"user","text":"What is this?","time":{"created":10}},
{"id":"msg_2","type":"assistant","agent":"build","model":{"id":"gpt-4","providerID":"openai"},
"time":{"created":11,"completed":12000},
"content":[{"type":"text","text":"**Hello** from the agent"}]}
"content":[{"type":"text","text":"**Hello** from the agent"},
{"type":"tool","id":"call_1","name":"shell","state":{"status":"completed",
"input":{"command":"echo hi"},"content":[],
"metadata":{"openchamberContentShell":{}}}}]}
],"cursor":{}}`)
})
mux.HandleFunc("/api/session/ses_new/message", func(w http.ResponseWriter, r *http.Request) {
@@ -120,6 +123,13 @@ func newChatServer(t *testing.T) *chatServer {
fmt.Fprint(w, `{"data":{"id":"ses_new","title":"New chat","time":{"created":3,"updated":3},
"location":{"directory":"/home/me/project"}}}`)
})
mux.HandleFunc("/api/session/ses_1/message/msg_2", func(w http.ResponseWriter, r *http.Request) {
fmt.Fprint(w, `{"id":"msg_2","type":"assistant","agent":"build","model":{"id":"gpt-4","providerID":"openai"},
"time":{"created":11,"completed":12000},
"content":[{"type":"text","text":"**Hello** from the agent"},
{"type":"tool","id":"call_1","name":"shell","state":{"status":"completed",
"input":{"command":"echo hi"},"content":[{"type":"text","text":"tool output here"}]}}]}`)
})
mux.HandleFunc("/api/session/ses_1/fork", func(w http.ResponseWriter, r *http.Request) {
var body map[string]any
_ = json.NewDecoder(r.Body).Decode(&body)
@@ -348,3 +358,17 @@ func TestUserMessageActions(t *testing.T) {
a.Expect("复制消息")
a.Back()
}
func TestToolResultLoadsOnExpand(t *testing.T) {
srv := newChatServer(t)
a := uitest.Mount(t, func() ui.Node { return rootWithStore(&memStore{}) }, uitest.Platform(ui.PlatformAndroid))
connectViaForm(t, a, srv.URL)
a.WaitFor("First session")
a.Tap("First session")
a.WaitFor("Hello from the agent")
// The list page shells the tool result; opening the row fetches it.
a.ExpectNo("tool output here")
a.Tap("✓ shell echo hi ▸")
a.WaitFor("tool output here")
}