WIP: preserve remaining background task output work

This commit is contained in:
2026-10-18 17:42:15 +01:00
parent fd4c329eaf
commit ded7927778
12 changed files with 269 additions and 17 deletions
+27
View File
@@ -450,6 +450,33 @@ func TestChatShellOutputVerifiesOwnerAndBoundsPage(t *testing.T) {
}
}
func TestChatShellOutputRejectsMissingRequiredPageFields(t *testing.T) {
for _, body := range []string{
`{"data":{}}`,
`{"data":{"output":"","cursor":0,"size":0}}`,
`{"data":{"output":"","size":0,"truncated":false}}`,
`{"data":{"output":"","cursor":0,"truncated":false}}`,
} {
srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Content-Type", "application/json")
switch r.URL.Path {
case "/api/shell/sh_1":
_, _ = w.Write([]byte(`{"data":{"id":"sh_1","status":"running","metadata":{"sessionID":"ses_1"}}}`))
case "/api/shell/sh_1/output":
_, _ = w.Write([]byte(body))
default:
http.NotFound(w, r)
}
}))
chat := NewChat(&Connection{Backend: "v2", URL: srv.URL})
_, err := chat.ShellOutput(context.Background(), protocol.ChatShellOutputQuery{SessionID: "ses_1", ShellID: "sh_1", Limit: 1})
srv.Close()
if err == nil {
t.Fatalf("response %s was accepted", body)
}
}
}
func TestChatReleaseShellsBoundsDisconnectedState(t *testing.T) {
chat := NewChat(&Connection{})
state := chat.streamState("ses_1")