[PR #4878] [GUI] Keep quiet desktop chat streams alive #5227

Open
opened 2026-11-07 16:33:37 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Niko1221/Strata/pull/4878
Author: @rinesh
Created: 11/1/2026
Status: 🔄 Open

Base: main ← Head: fix/desktop-chat-stream-heartbeat


📝 Commits (1)

  • dafdbcb [GUI] Keep quiet desktop chat streams alive

📊 Changes

2 files changed (+65 additions, -2 deletions)

View changed files

📝 apps/host/server/index.mjs (+9 -0)
📝 apps/host/tests/agent-host.test.mjs (+56 -2)

📄 Description

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.

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:

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.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/Niko1221/Strata/pull/4878 **Author:** [@rinesh](https://github.com/rinesh) **Created:** 11/1/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `fix/desktop-chat-stream-heartbeat` --- ### 📝 Commits (1) - [`dafdbcb`](https://github.com/Niko1221/Strata/commit/dafdbcb8957f168073e45cdd9835b1c13cf14d4a) [GUI] Keep quiet desktop chat streams alive ### 📊 Changes **2 files changed** (+65 additions, -2 deletions) <details> <summary>View changed files</summary> 📝 `apps/host/server/index.mjs` (+9 -0) 📝 `apps/host/tests/agent-host.test.mjs` (+56 -2) </details> ### 📄 Description ## 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. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Niko1221/Strata#5227
No description provided.