Skip to content

Keep an open browser tab's ok start server alive. The web editor now…#357

Merged
inkeep-oss-sync[bot] merged 1 commit into
mainfrom
copybara/sync
Jun 28, 2026
Merged

Keep an open browser tab's ok start server alive. The web editor now…#357
inkeep-oss-sync[bot] merged 1 commit into
mainfrom
copybara/sync

Conversation

@inkeep-oss-sync

Copy link
Copy Markdown
Contributor

Keep an open browser tab's ok start server alive. The web editor now holds a single, app-lifetime /collab/keepalive WebSocket — 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.

…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
@inkeep-oss-sync inkeep-oss-sync Bot requested a review from nick-inkeep as a code owner June 28, 2026 02:42

@inkeep-internal-ci inkeep-internal-ci Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@inkeep-oss-sync inkeep-oss-sync Bot merged commit 07790c5 into main Jun 28, 2026
@inkeep-oss-sync inkeep-oss-sync Bot deleted the copybara/sync branch June 28, 2026 02:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant