Keep an open browser tab's ok start server alive. The web editor now…#357
Merged
Conversation
…erver alive (PRD-7198) (#2221) * feat(app): hold a persistent /collab/keepalive WS so an open tab keeps its server alive The web app now mounts a single, app-lifetime, presence-invisible /collab/keepalive WebSocket (the same startKeepalive primitive desktop and the MCP shim use), so an `ok start` server's 30-minute idle-shutdown can't fire out from under an open browser tab when no document is focused or during a transient reconnect. - core: make `pid` browser-safe. It is now an opt-in KeepaliveOptions field and the URL query is assembled from a params array; the primitive no longer references `process` (undefined in a Vite build). Node callers (desktop main, MCP shim) pass `pid: process.pid` — on-the-wire behavior unchanged. `pid` is informational only (never used for the idle count). - app: useServerKeepalive hook wired into ConfigProviderHost. Reads the latest collabUrl via a ref so a server restart on a new port is picked up on the primitive's next reconnect with no socket churn; strips the trailing /collab; gated to non-desktop; presence-invisible. Closes PRD-7198. Claude-Session: https://claude.ai/code/session_01STkdCtzMsBpdbV4CFd5578 * chore: fix pre-existing gate breakage on the branch base Two failures in `bun run check` that are independent of the keepalive change and block the gate for any PR off this base: - docs/src/components/overview-blocks.tsx: Biome format drift introduced by #2219 (a copy-edit left a JSX text line unwrapped). Re-formatted. - ng-anchors-catalog.json: the committed catalog's testFileCount was stale (181) versus a fresh build (184) — test files were added to the globbed dirs without regenerating the catalog (the turbo `test` cache masks this in CI but cold-cache `bun run check` fails on it). Regenerated via `md-audit enumerate-ng-anchors`. Claude-Session: https://claude.ai/code/session_01STkdCtzMsBpdbV4CFd5578 * test: harden keepalive coverage per review (resolver/ctor error paths, transform boundaries) Address the two optional suggestions from the claude PR reviewer: - core: cover the two connect-path catch blocks — resolveWsUrl rejecting and the WebSocket constructor throwing must both schedule a reconnect (not rethrow / self-close), which is the keepalive's reason for being. - app: pin keepaliveBaseFromCollabUrl boundaries — strips /collab from a port-less same-origin URL, and passes non-/collab URLs through verbatim (guards against a future over-broad regex dropping the `$` anchor). Claude-Session: https://claude.ai/code/session_01STkdCtzMsBpdbV4CFd5578 --------- GitOrigin-RevId: 1f88496149dac11c1c3eee01a49f03e5724e081b
Contributor
There was a problem hiding this comment.
Automated approval from agents-private public-mirror-sync (run: https://github.com/inkeep/agents-private/actions/runs/28309086782). Source of truth is the monorepo; direct edits on inkeep/open-knowledge are overwritten on next sync.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Keep an open browser tab's
ok startserver alive. The web editor now holds a single, app-lifetime/collab/keepaliveWebSocket — the same presence-invisible keepalive the desktop app and MCP shim already use — so the server's 30-minute idle-shutdown can no longer fire out from under an open tab when no document is focused or during a brief reconnect. Previously, with no doc open the only liveness signal was the per-document collab connections, so an idle tab could lose its server and every editor/tool call would fail until reload. Closing the tab still lets the server idle-shut-down normally, and the keepalive reconnects across a server restart on a new port. Multiple tabs each hold their own keepalive. The keepalive adds no presence-bar entry.