#4878 [GUI] Keep quiet desktop chat streams alive
closed · @rinesh · 0 评论 · 去 GitHub 看
Setup & installServer & APIAMD / HIPNVIDIA / CUDAWindowsLinux
说明
## Problem and result
The Mac desktop app can show **“Load failed”** after a chat stream has been quiet for 60 seconds. The agent continues in the background, so a later message can then fail with **“This chat is still working. Stop it or wait for it to finish.”** Periodic NDJSON keep-alives now keep the connection open during prompt processing, tools, and approval waits.
Reproduced locally on packaged Strata 0.2.9, macOS 15.6.1, Apple M2 Max / 32 GB unified memory, using an OpenAI Chat Completions server on another Mac and `qwen3.8-flash-next-huihui-abliterated-gyro-s`. A follow-up sent at 11:09:13 failed at 11:10:13 with WebKit `NSURLErrorDomain Code=-1001` / `isTimeout=1`; the server remained healthy. Applying this same nine-line change to the installed app allowed the same conversation to complete successfully.
## Related discussion
Searched open and closed issues/PRs for the exact errors, WebKit, heartbeat, and keep-alive. No matching desktop-host fix was found, and `main` at `c62d5e3a15b40ea51c96aae9e8d36928965f53ab` still lacked this heartbeat. Related engine proposals #4196 and #4340 concern `serve/server.py` and the model API; this change covers the app host's NDJSON connection.
## Approach
- Send the existing `{"type":"beat"}` frame every 15 seconds on the shared `/api/chat/stream` and `/api/plan/start-goal` response path. The host already uses this frame for Time-skip streams, and the chat consumer ignores it.
- Unreference the timer and clear it on both `finish` and `close`.
- Preserve model requests, approval decisions, and the existing distinction between disconnecting and explicitly stopping an agent turn.
- Add real HTTP regression tests for a silent API model and an approval wait. They also check direct-request cancellation, a subsequent successful message, and that a heartbeat never approves the pending tool.
## Validation
Tested commit: `dafdbcb8957f168073e45cdd9835b1c13cf14d4a`, based on the `main` revision above. Node v26.13.0 on macOS 15.6.1; real packaged Harness 0.2.1-alpha.3 with a loopback scripted model. No model weights were downloaded for the tests.
**Passed:**
From `apps/host`:
```sh
STRATA_NO_ACQUIRE=1 STRATA_HARNESS_DIR=/Applications/Strata.app/Contents/Resources/harness node --test tests/agent-host.test.mjs tests/agent-status.test.mjs tests/stream-framing.test.mjs tests/request-flow.test.mjs tests/stream-speed.test.mjs tests/host-lifecycle.test.mjs
npm run typecheck
node --check server/index.mjs
```
The selected suite passed **44 tests, 0 failed, 0 skipped**. `git diff --check` also passed. The live Mac desktop reproduction succeeded with the identical server patch; the agent subsequently reported zero active turns and zero pending approvals.
**Failed:**
- Before the fix, the new silent-model regression failed against unmodified `main`: `a quiet model must not leave the desktop connection idle`.
- An initial broader test run could not load `esbuild` in the fresh checkout. After installing the locked dependencies with `npm ci --ignore-scripts --no-audit --no-fund --cache ../../../npm-cache`, the complete selected suite passed. No failures remain in that final run.
**Not run:**
- Full host test suite, a newly packaged desktop installer, or Windows/Linux desktop testing.
- CUDA/HIP/SYCL/Metal builds: no engine code or backend build configuration changed.
## Limits
This prevents quiet-stream timeouts. It does not reconnect an already disconnected page or change the existing background-agent lifecycle; an already stranded turn may still need Stop. The approval regression requires a built Harness and explicitly skips when one is unavailable.
本站相关内容
相关页面的快捷入口。