Skip to content

Node-based terminal manager for AI coding agents — tmux-backed terminals and parallel agent sessions as draggable nodes on an infinite pan/zoom canvas. macOS, Linux, and a browser Server Edition.

feat: remove the live links IPC, preload, bridge and shell wiring; clean retired data at boot

review5e3677c97666
diff --git a/src/core/pty-manager.ts b/src/core/pty-manager.ts
index 3abb0000d..80ed350e8 100644
--- a/src/core/pty-manager.ts
+++ b/src/core/pty-manager.ts
@@ -257,7 +257,6 @@ import {
SessionHostProtocolCompatibilityError,
watchExistingSessionHostPty,
sessionHostSupportsWatch,
- sessionHostWatchKnown,
sessionHostCaptureVisible,
sessionHostPaneCwd,
sessionHostMouseTracking,
@@ -2441,7 +2440,7 @@ export class PtyManager {
}
}
- /** `tmuxStatus().persistence`: where a new local terminal goes, and what a viewer can join there. */
+ /** `tmuxStatus().persistence`: where a new local terminal goes. */
private persistenceStatus(available: boolean): NonNullable<TmuxStatus['persistence']> {
const backend =
// Zellij when it is selected AND found: that is where a new local terminal goes.
@@ -2452,10 +2451,7 @@ export class PtyManager {
: sessionHostSupported() ? 'session-host' : null
return {
enabled: this.getSettings().tmuxEnabled,
- backend,
- // Live links can join a session-host node nobody holds open (`watch-attach`). Only a
- // CONNECTED host's negotiated answer counts; unknown stays absent (the conservative note).
- ...(backend === 'session-host' && sessionHostWatchKnown() === true ? { watchJoin: true } : {})
+ backend
}
}
diff --git a/src/core/pty-persistence-status.test.ts b/src/core/pty-persistence-status.test.ts
index 32f0fdd94..61c06ce1a 100644
--- a/src/core/pty-persistence-status.test.ts
+++ b/src/core/pty-persistence-status.test.ts
@@ -43,21 +43,10 @@ describe('local persistence discovery (#575)', () => {
it('never treats a Windows tmux path as protection', () => {
expect(manager('win32', true).tmuxStatus().persistence?.backend).toBeNull()
})
- it('reports watchJoin only for a session-host backend whose CONNECTED host speaks watch-attach', () => {
+ it('reports no live-link join flag, whatever the connected host speaks', () => {
host.supported.mockReturnValue(true)
host.watchKnown.mockReturnValue(true)
- expect(manager('win32', false).tmuxStatus().persistence).toEqual({
- enabled: true,
- backend: 'session-host',
- watchJoin: true
- })
- // tmux has its own watcher client: the flag is never asked there.
- host.watchKnown.mockClear()
- expect(manager('linux', true).tmuxStatus().persistence).toEqual({ enabled: true, backend: 'tmux' })
- expect(host.watchKnown).not.toHaveBeenCalled()
- // An older host (false) or no connection yet (undefined): absent, the conservative note stays.
- host.watchKnown.mockReturnValue(false)
- expect(manager('win32', false).tmuxStatus().persistence).not.toHaveProperty('watchJoin')
+ expect(manager('win32', false).tmuxStatus().persistence).toEqual({ enabled: true, backend: 'session-host' })
})
it('keeps the user setting distinct from backend discovery', () => {
host.supported.mockReturnValue(true)
diff --git a/src/main/index.ts b/src/main/index.ts
index 19c50ff12..0c3f43cf2 100644
--- a/src/main/index.ts
+++ b/src/main/index.ts
@@ -2,6 +2,7 @@ import { registerUpdatePrepIpc } from './update-prep'
import { installOpenLinks } from './open-link-wiring'
import { nodetermUrlFromArgv } from '../shared/open-link'
import { createRemoteContextEnsure } from '../core/remote-context-ensure'
+import { removeRetiredLiveLinkData } from '../core/retired-data-cleanup'
import { isKnownRemoteCodexAccount } from '../core/remote-ssh/codex-home'
import { createRemoteCodexContext, type RemoteCodexContextTarget } from '../core/remote-ssh/codex-context'
import { subagentReplay } from '../core/subagent-replay'
@@ -124,18 +125,7 @@ import type { CardLabelEdit } from '../core/project-kanban-write'
import { WorkspaceWatcher } from '../core/workspace-watcher'
import { SettingsStore } from '../core/settings-store'
import { registerAgentEnvIpc } from '../core/agent-env-ipc'
-import { allocateRelayClientId, presenceHub } from '../core/presence/hub'
-import {
- createWatchLinkService,
- registerWatchLinkIpc,
- sendToOwners,
- workspaceNodeState,
- type WatchLinkService
-} from '../core/watch-link/service'
-import { createWatchLinkApi } from '../core/watch-link/api'
-import { WatchLinkStore } from '../core/watch-link/store'
-import { HISTORY_READ_BYTES } from '../core/watch-link/history'
-import { createWatchPty, watchRemoteFor, watchRemoteRecords, type WatchRemote } from '../core/watch-link/pty-seam'
+import { presenceHub } from '../core/presence/hub'
import { SshStore } from './ssh-store'
import { GitService } from '../core/git-service'
import { ProjectTrustStore } from '../core/project-trust-store'
@@ -311,7 +301,7 @@ import { codexHome } from '../core/usage/codex-usage'
import { isAsyncSubagentLaunch, isCursorPayload, grokRawFields, type NormalizedAgentEvent } from '../shared/agents/normalize'
import { applyGrokHookSession } from '../core/grok-hook-session'
import { agentAccountColor } from '../shared/agents/account-color'
-import { canChat, capabilityAgentId } from '../shared/agents/config'
+import { capabilityAgentId } from '../shared/agents/config'
import {
setRemoteTranscriptReader,
TITLE_TAIL_BYTES,
@@ -432,8 +422,7 @@ import {
loadOrCreateKeyPair,
relayAllowed,
API_BASE as RELAY_API_BASE,
- RELAY_URL,
- type HostChatOps
+ RELAY_URL
} from './remote/host-service'
import { initStandingHost } from './remote/standing-host'
import { initRelayHost } from './remote/relay-host-service'
@@ -461,7 +450,7 @@ import {
} from './media-protocol'
import { initPlatform, platform } from '../core/platform'
import { electronPlatform } from './platform-electron'
-import { registerPeerSink, unregisterPeerSink, wirePeerRegistry } from './peer-registry'
+import { wirePeerRegistry } from './peer-registry'
import { WEBGL_CONTEXT_CAP_DESKTOP } from '../shared/webgl'
// Dev-only: NT_MULTI lets a SECOND instance run (host + client testing on one machine) with an
@@ -607,10 +596,6 @@ wirePeerRegistry({
// Set once the app window is ready; used by the quit hooks to tear down SSH-project masters and
// (via the closures below) to resolve a live SSH project's ControlMaster for remote workspace IO.
let sshProjectManager: ReturnType<typeof initSshProject> | undefined
-// Live links (src/core/watch-link/service.ts). Assigned in `whenReady`; declared here because the
-// workspace store's `onPersist`, the license callback and the quit handler read it at call time (the
-// boot workspace load's `onPersist` runs before the assignment — a later `const` would be a TDZ throw).
-let watchLinks: WatchLinkService | null = null
// The standalone Codex relay bundle (`out/main/codex-relay.js`, built by scripts/build-codex-relay.mjs
// after electron-vite build), uploaded to a Linux host for managed Codex accounts. Read once, beside
@@ -663,8 +648,6 @@ const workspaceWatcher = new WorkspaceWatcher({
workspaceStore.onPersist = () => {
workspaceWatcher.sync()
refreshNodeTokens()
- // A node the store now provably holds nowhere (a delete, the canvas authority's op) ends its links.
- watchLinks?.onWorkspaceChanged()
}
// "Which host owns this node?", answered WITHOUT a live session — the persisted index, not the
// in-memory `Session`. A delete arrives precisely when there may be nothing attached (an app
@@ -2557,7 +2540,6 @@ app.whenReady().then(async () => {
// here, and its sender leg (board-log line in the sender's project) resolves projects through the
// index, which nothing else has loaded yet at this point of boot (the renderer's own
// `workspace.load` comes later). Read-only load (`sideline: false`), like the relay path's.
- // Shared with the live links' `init()` below, which must not judge a node gone before this read.
const bootWorkspaceLoad = workspaceStore.load({ sideline: false })
void restoreDeliveryQueue(messagingDeps.queue, deliveryQueueFile, {
ready: bootWorkspaceLoad
@@ -3691,67 +3673,9 @@ app.whenReady().then(async () => {
}
}
})
- // Live links (docs/live-links.md): a Pro, read-only, expiring browser link to one terminal, hosted
- // by this machine over the E2E relay. The viewer is a QUIET, SELF-PACED relay peer (never in a
- // broadcast, never a pause ticket); the pty seam and the node-gone rule are core's, shared with the
- // Server Edition. `init()` decides nothing before the boot workspace load (R40): an empty answer
- // while the index is still being read is not evidence that a node is gone.
- // Where a watcher join goes (core's ONE rule, over this machine's records and its live masters).
- // Read-back for a link's viewers (docs/live-links.md → Read-back) reads through the phone Chat
- // screen's page reader (host-chat.ts, `hostBridge.chat` below): the node from this machine's
- // records, the renderer's session id first, an SSH node read on its host and never here. That reader
- // is built later in boot, so it is bound late; a read-back before it exists is a failed read the
- // viewer may repeat. The link host cuts every page at the link's creation; this only reads.
- let watchHistoryChat: Pick<HostChatOps, 'page'> | null = null
- const watchRemote = (nodeId: string): WatchRemote =>
- watchRemoteFor(nodeId, watchRemoteRecords(workspaceStore, (connectionId) => sshProjectManager?.refForProject(connectionId)))
- watchLinks = createWatchLinkService({
- api: createWatchLinkApi({ apiBase: RELAY_API_BASE }),
- relayUrl: RELAY_URL,
- // Sealed through the keychain seam; if it refuses, links live in memory and the owner is told.
- store: new WatchLinkStore({
- file: join(corePlatform.userDataDir, 'watch-links.json'),
- seal: corePlatform.sealSecret?.bind(corePlatform),
- unseal: corePlatform.unsealSecret?.bind(corePlatform)
- }),
- entitlement: getStoredEntitlement,
- relayAllowed,
- nodeState: (nodeId) => workspaceNodeState(workspaceStore, nodeId),
- workspaceReady: () => bootWorkspaceLoad,
- clients: {
- attach: (sink) => {
- const id = allocateRelayClientId()
- // No presence join: a viewer puts no cursor or facepile on the owner's canvas.
- registerPeerSink(id, sink, { quiet: true, selfPaced: true })
- return id
- },
- // → presenceHub.leave (a no-op for an id that never joined) and PtyManager.dropClient.
- detach: (id) => unregisterPeerSink(id)
- },
- // A node whose session lives in a HOST's tmux — every node of an SSH project, and a remote-tmux node
- // in a LOCAL project (`ssh` + `sshRemoteTmux`, served by the project's host attachment) — is watched
- // on that host over the master this machine holds for it, or not at all: `requireRemote` for every
- // such node, the remote fields from this machine's own records (core's `watchRemoteFor`).
- pty: createWatchPty(ptyManager, watchRemote),
- // Can a Control link type into this node? A node in a HOST's tmux (the same `watchRemoteFor` answer:
- // Zellij is a local-only backend) is not decided by this machine's backend choice: 'ok' (a host
- // with no tmux at all answers every keystroke false, which the link host reports as dropped).
- controlSupport: (nodeId) => (watchRemote(nodeId).requireRemote ? 'ok' : ptyManager.nodeControlSupport(nodeId)),
- history: async (nodeId, before) => {
- const chat = watchHistoryChat
- if (!chat) throw new Error('read-back is not ready yet')
- const page = await chat.page(nodeId, before === null ? { maxBytes: HISTORY_READ_BYTES } : { before, maxBytes: HISTORY_READ_BYTES })
- return page === null || page === 'unsupported' ? { kind: 'unsupported' } : { kind: 'page', result: page }
- },
- // The same question host-chat's page asks before it reads: an agent the ⌘M view can render.
- historySupported: (nodeId) => {
- const agentId = workspaceStore.getNodeResolved(nodeId)?.agentId ?? mirrorEntry(nodeId)?.agentId
- return !!agentId && canChat(capabilityAgentId(agentId))
- },
- emit: (channel, ...args) => sendToOwners(corePlatform, channel, ...args)
- })
- registerWatchLinkIpc(corePlatform, watchLinks)
- void watchLinks.init()
+ // Live links were retired (2026-11): remove the old store's files (sealed link secrets, password
+ // hashes) from userData once per boot. Never throws; ENOENT is the normal case.
+ void removeRetiredLiveLinkData(corePlatform.userDataDir)
// Dev-server ports (CLAUDE.md → Dev-server ports). Same identity predicate and the same
// exit-code-gated runner shape as session memory above; forwarding rides the project's master.
const devPorts = startDevPortsService({
@@ -4927,11 +4851,8 @@ app.whenReady().then(async () => {
// none, so the next license call is the 6 h refresh, an activate or an upgrade; a claim reads the
// gate itself.)
setLicenseNetworkConsent(() => settingsStore.get().licenseNetworkConsent === true)
- // A license change (activate, refresh, a lapsed token replaced) re-arms every live link the API
- // refused: a link host whose 7-day entitlement expired under it stops minting until then (R41).
- // It can also change Pro for the project limit, which nothing else would tell the renderer.
+ // A license change can change Pro for the project limit, which nothing else would tell the renderer.
initLicense(() => {
- watchLinks?.onEntitlementChanged()
projectLimit.pushIfChanged()
})
// Lazy getter: sshProjectManager is created just below, so a remote account op (which only runs
@@ -5153,7 +5074,6 @@ app.whenReady().then(async () => {
// to have focused (that gap read as "cwd is outside the shared project roots" on the phone).
workspaceRoots: () => workspaceStore.localProjectCwds()
}
- watchHistoryChat = hostBridge.chat
// The renderer owns the Eco hibernation flag (persisted in ITS localStorage) and main only
// mirrors it — same direction as `terminalFocused`. Feeds the agent-status mirror so the phone
// renders SLEEPING (and re-fed at renderer boot from the persisted store, so a desktop restart
@@ -5661,10 +5581,6 @@ app.on('before-quit', (e) => {
}
quitFlushed = true
e.preventDefault()
- // Live links: tell every viewer the host is stopping while the relay sockets are still up, before
- // killAll tears their pty subscriptions out from under the link hosts. The records stay on disk (the
- // links resume at the next launch); the last write the service issued lands inside the raced flush.
- const watchLinksStopped = watchLinks?.shutdown()
// Pending throttled .nodeterm mirror writes must land BEFORE the ControlMasters die — killing
// a master mid-write used to leave a truncated project.json on the server. The masters are
// therefore kept up through the raced flush and dropped on the second before-quit pass.
@@ -5680,8 +5596,7 @@ app.on('before-quit', (e) => {
const flush = Promise.allSettled([
requestRendererFlush(getMainWindow()?.webContents, ipcMain).then(() => remoteWorkspaceIO.flush()),
remoteWorkspaceIO.flush(),
- ptyManager.killAll(),
- watchLinksStopped
+ ptyManager.killAll()
])
void Promise.race([flush, new Promise((r) => setTimeout(r, 1500))])
// Then let whisper go. A dictation still transcribing when Electron tears down the main
diff --git a/src/main/project-limit-wiring.test.ts b/src/main/project-limit-wiring.test.ts
index 8eabc088b..67cab3d48 100644
--- a/src/main/project-limit-wiring.test.ts
+++ b/src/main/project-limit-wiring.test.ts
@@ -44,7 +44,7 @@ describe('project-limit wiring (source)', () => {
it('a license change and a settings change both push it, only when it changed', () => {
// pushIfChanged, not refresh: settings change on every save, and the windows need only news.
expect(main).toMatch(
- /initLicense\(\(\) => \{\s*watchLinks\?\.onEntitlementChanged\(\)\s*projectLimit\.pushIfChanged\(\)\s*\}\)/
+ /initLicense\(\(\) => \{\s*projectLimit\.pushIfChanged\(\)\s*\}\)/
)
expect(main).toMatch(/settingsStore\.onChange\(\(\) => projectLimit\.pushIfChanged\(\)\)/)
expect(main).not.toMatch(/projectLimit\.refresh\(\)/)
diff --git a/src/main/retired-data-cleanup-wiring.test.ts b/src/main/retired-data-cleanup-wiring.test.ts
new file mode 100644
index 000000000..250135a54
--- /dev/null
+++ b/src/main/retired-data-cleanup-wiring.test.ts
@@ -0,0 +1,29 @@
+// Source-level, house style: a dropped call compiles, so only reading the shell finds it.
+// Live links were retired; both shells remove the old store's files from their data dir at boot
+// (core/retired-data-cleanup.ts) and neither boots the live-link service any more.
+import fs from 'fs'
+import path from 'path'
+import { describe, expect, it } from 'vitest'
+
+const read = (rel: string): string => fs.readFileSync(path.join(__dirname, '..', rel), 'utf8').replace(/\r\n/g, '\n')
+
+describe('retired live-link data cleanup wiring', () => {
+ it('the desktop removes it from userData', () => {
+ const src = read('main/index.ts')
+ expect(src).toContain('removeRetiredLiveLinkData(corePlatform.userDataDir')
+ })
+
+ it('the Server Edition removes it from its data dir', () => {
+ const src = read('server/index.ts')
+ expect(src).toContain('removeRetiredLiveLinkData(config.dataDir')
+ })
+
+ it('neither shell boots the live-link service or its store', () => {
+ for (const shell of ['main/index.ts', 'server/index.ts']) {
+ const src = read(shell)
+ expect(src, shell).not.toContain('createWatchLinkService')
+ expect(src, shell).not.toContain('WatchLinkStore')
+ expect(src, shell).not.toContain("watch-links.json'")
+ }
+ })
+})
diff --git a/src/main/station-outcome-wiring.test.ts b/src/main/station-outcome-wiring.test.ts
index 2066417cb..233b6cff1 100644
--- a/src/main/station-outcome-wiring.test.ts
+++ b/src/main/station-outcome-wiring.test.ts
@@ -72,8 +72,7 @@ describe('desktop main', () => {
expect(withdraw).toBeGreaterThan(-1)
expect(withdraw).toBeLessThan(main.indexOf('corePlatform.broadcast(IPC.agentStatus, enriched)'))
expect(main).toContain('flushAllDurableFactsSync()')
- // The restore waits for the workspace index, or a restore-time expiry reaches no sender. The boot
- // read is shared with the live links' init (which must not judge a node gone before it either).
+ // The restore waits for the workspace index, or a restore-time expiry reaches no sender.
expect(main.slice(queue, queue + 200)).toContain('ready: bootWorkspaceLoad')
const bootLoad = main.indexOf('const bootWorkspaceLoad = workspaceStore.load({ sideline: false })')
expect(bootLoad).toBeGreaterThan(holds)
diff --git a/src/main/watch-link-control-wiring.test.ts b/src/main/watch-link-control-wiring.test.ts
deleted file mode 100644
index 476763210..000000000
--- a/src/main/watch-link-control-wiring.test.ts
+++ /dev/null
@@ -1,74 +0,0 @@
-// Source-level: a Control link's hops close over shell objects no unit test can build (PtyManager, the
-// workspace store, the Electron and Server Edition platforms), and a dropped hop compiles fine while
-// shipping the feature inert — no `controlSupport` and every Zellij node is offered Control; a channel
-// left out of `registerWatchLinkIpc` and the owner's button answers nothing. Same remedy as
-// watch-link-wiring.test.ts and hook-verified-parity.test.ts.
-import { describe, it, expect } from 'vitest'
-import { readFileSync } from 'node:fs'
-import { join } from 'node:path'
-
-const read = (p: string) => readFileSync(join(__dirname, '..', '..', p), 'utf8').replace(/\r\n/g, '\n')
-/** The source from `marker` up to the next line that closes a block at column `indent`. */
-function blockAfter(src: string, marker: string, indent: string): string {
- const start = src.indexOf(marker)
- if (start < 0) throw new Error(`not found: ${marker}`)
- const end = src.indexOf(`\n${indent}}`, start)
- return src.slice(start, end < 0 ? undefined : end)
-}
-
-const MAIN = 'src/main/index.ts'
-const SERVER = 'src/server/index.ts'
-
-const CONTROL_CHANNELS = ['watchLinkSetControl', 'watchLinkSetPassword', 'watchLinkAllowControl', 'watchLinkControlSupport']
-const ALL_CHANNELS = [
- 'watchLinkCreate', 'watchLinkList', 'watchLinkRevoke', 'watchLinkRevokeAll', 'watchLinkKick',
- 'watchLinkChatSend', 'watchLinkChatHistory', ...CONTROL_CHANNELS
-]
-
-describe('live-link Control wiring', () => {
- for (const shell of [MAIN, SERVER]) {
- it(`${shell} hands the service PtyManager's control check, local nodes only`, () => {
- const block = blockAfter(read(shell), 'watchLinks = createWatchLinkService({', ' ')
- expect(block).toMatch(/controlSupport: \(nodeId\) =>/)
- expect(block).toMatch(/ptyManager\.nodeControlSupport\(nodeId\)/)
- // A node in a HOST's tmux (an SSH project's, or a remote-tmux node in a local project — core's
- // `watchRemoteFor`, the rule the join uses): the local backend choice says nothing about it.
- expect(block).toMatch(/watchRemote\(nodeId\)\.requireRemote \? 'ok' : ptyManager\.nodeControlSupport\(nodeId\)/)
- expect(block).toMatch(/pty: createWatchPty\(ptyManager, watchRemote\)/)
- expect(read(shell)).toMatch(/const watchRemote = \(nodeId: string\): WatchRemote =>\s*watchRemoteFor\(nodeId, watchRemoteRecords\(workspaceStore, /)
- })
- }
-
- it('registerWatchLinkIpc registers all eleven owner request channels, each behind the owner check', () => {
- const src = read('src/core/watch-link/service.ts')
- const reg = src.slice(src.indexOf('export function registerWatchLinkIpc('))
- for (const ch of ALL_CHANNELS) {
- const at = reg.indexOf(`p.handleWithSender(IPC.${ch},`)
- expect(at, ch).toBeGreaterThan(-1)
- // The handler's own line(s) up to the next registration ask `owner(sender)` first.
- const next = reg.indexOf('p.handleWithSender(', at + 1)
- expect(reg.slice(at, next < 0 ? undefined : next), ch).toMatch(/owner\(sender\)/)
- }
- expect(reg.match(/p\.handleWithSender\(IPC\.watchLink/g)).toHaveLength(ALL_CHANNELS.length)
- })
-
- it('the preload, the Server Edition bridge and the relay stub all carry the four Control members', () => {
- const preload = read('src/preload/index.ts')
- for (const ch of CONTROL_CHANNELS) expect(preload, ch).toContain(`IPC.${ch}`)
- const bridge = read('src/renderer/bridge/ws-bridge.ts')
- const api = bridge.slice(bridge.indexOf('export function buildWatchLinkApi('))
- for (const ch of CONTROL_CHANNELS) expect(api, ch).toContain(`client.request(IPC.${ch}`)
- // A dropped socket answers the safe value, never a rejection the UI did not expect.
- expect(api).toMatch(/IPC\.watchLinkControlSupport, nodeId\) as Promise<ControlSupport>\)\.catch\(\(\): ControlSupport => 'unknown'\)/)
- const stub = read('src/renderer/bridge/stubs.ts')
- const relay = stub.slice(stub.indexOf(' watchLink: {'))
- for (const m of ['setControl', 'setPassword', 'allowControl', 'controlSupport']) expect(relay, m).toMatch(new RegExp(`${m}: async`))
- })
-
- it('the pty seam hands joins their input route and input to the pane, from PtyManager', () => {
- const seam = read('src/core/watch-link/pty-seam.ts')
- expect(seam).toMatch(/input: pty\.watcherInputRoute\(res\.sessionId\)/)
- // The link host's `isCurrent` rides along: PtyManager asks it right before the step runs.
- expect(seam).toMatch(/input: \(sessionId, chunk, isCurrent\) => pty\.controlInput\(sessionId, chunk, isCurrent\)/)
- })
-})
diff --git a/src/main/watch-link-wiring.test.ts b/src/main/watch-link-wiring.test.ts
deleted file mode 100644
index a37ea1bdd..000000000
--- a/src/main/watch-link-wiring.test.ts
+++ /dev/null
@@ -1,129 +0,0 @@
-// Source-level: the live-link wiring closes over shell objects no unit test can build (the Electron
-// app, the Server Edition's platform, PtyManager, the workspace store), and an unwired service
-// compiles fine while doing nothing — the hook-verified-parity.test.ts remedy for the same hole.
-import { describe, it, expect } from 'vitest'
-import { readFileSync } from 'node:fs'
-import { join } from 'node:path'
-
-const read = (p: string) => readFileSync(join(__dirname, '..', '..', p), 'utf8').replace(/\r\n/g, '\n')
-/** The source of the arrow function assigned at `marker`, up to its closing `}` at column `indent`. */
-function blockAfter(src: string, marker: string, indent: string): string {
- const start = src.indexOf(marker)
- if (start < 0) throw new Error(`not found: ${marker}`)
- const end = src.indexOf(`\n${indent}}`, start)
- return src.slice(start, end < 0 ? undefined : end)
-}
-
-const MAIN = 'src/main/index.ts'
-const SERVER = 'src/server/index.ts'
-
-describe('live-link wiring', () => {
- for (const shell of [MAIN, SERVER]) {
- it(`${shell} creates, registers and inits the service over the shared seams`, () => {
- const s = read(shell)
- expect(s).toMatch(/createWatchLinkService\(\{/)
- expect(s).toMatch(/registerWatchLinkIpc\((corePlatform|platform), watchLinks\)/)
- expect(s).toMatch(/void watchLinks\.init\(\)/)
- // The viewer is a QUIET, SELF-PACED client: absent from broadcasts and clientIds, and the registry
- // never pauses a shared pty for it.
- expect(s).toMatch(/quiet: true, selfPaced: true/)
- // ONE join rule set (pty-seam.ts) and ONE node-gone rule (tri-state, R40) for both shells.
- expect(s).toMatch(/pty: createWatchPty\(ptyManager,/)
- expect(s).toMatch(/nodeState: \(nodeId\) => workspaceNodeState\(workspaceStore, nodeId\)/)
- // Owner state to OWNER clients only: every view carries its link's secret.
- expect(s).toMatch(/emit: \(channel, \.\.\.args\) => sendToOwners\((corePlatform|platform), channel, \.\.\.args\)/)
- })
-
- it(`${shell} tells the service about every workspace load/save`, () => {
- const s = read(shell)
- const onPersist = blockAfter(s, 'workspaceStore.onPersist = () => {', shell === MAIN ? '' : ' ')
- expect(onPersist).toMatch(/watchLinks\?\.onWorkspaceChanged\(\)/)
- // Declared BEFORE the closure (it runs at the boot load — a later `const` would be a TDZ throw).
- expect(s.indexOf('let watchLinks: WatchLinkService | null = null')).toBeGreaterThan(-1)
- expect(s.indexOf('let watchLinks: WatchLinkService | null = null')).toBeLessThan(s.indexOf('workspaceStore.onPersist = () => {'))
- })
- }
-
- it('the desktop waits for the boot workspace load, hosts SSH nodes over their own master, and re-arms on a license change', () => {
- const s = read(MAIN)
- expect(s).toMatch(/const bootWorkspaceLoad = workspaceStore\.load\(\{ sideline: false \}\)/)
- expect(s).toMatch(/workspaceReady: \(\) => bootWorkspaceLoad/)
- expect(s).toMatch(/entitlement: getStoredEntitlement/)
- // The license callback is a block since it also re-sends the project-limit state
- // (project-limit-wiring.test.ts pins that half); a license change must still re-arm the links.
- expect(s).toMatch(/initLicense\(\(\) => \{[^}]*\bwatchLinks\?\.onEntitlementChanged\(\)[^}]*\}\)/)
- // A node in a HOST's tmux is watched on its host, or not at all — an SSH project's node AND a
- // remote-tmux node in a local project (final review, Minor 4): core's ONE rule, fed the shell's own
- // records — the SSH project, every persisted copy's binding with its project's server, the masters.
- expect(s).toMatch(/pty: createWatchPty\(ptyManager, watchRemote\)/)
- expect(s).toMatch(
- /const watchRemote = \(nodeId: string\): WatchRemote =>\s*watchRemoteFor\(nodeId, watchRemoteRecords\(workspaceStore, \(connectionId\) => sshProjectManager\?\.refForProject\(connectionId\)\)\)/
- )
- // Control support asks the same rule: a node in a host's tmux is not decided by local Zellij.
- expect(s).toMatch(/controlSupport: \(nodeId\) => \(watchRemote\(nodeId\)\.requireRemote \? 'ok' : ptyManager\.nodeControlSupport\(nodeId\)\)/)
- // The secret is sealed through the keychain seam.
- expect(s).toMatch(/seal: corePlatform\.sealSecret\?\.bind\(corePlatform\)/)
- expect(s).toMatch(/unseal: corePlatform\.unsealSecret\?\.bind\(corePlatform\)/)
- })
-
- it('the desktop wires read-back through the phone Chat screen\'s page reader, bound late', () => {
- const s = read(MAIN)
- const block = blockAfter(s, 'watchLinks = createWatchLinkService({', ' ')
- // Both deps are optional: dropping either compiles and ships read-back inert.
- expect(block).toMatch(/history: async \(nodeId, before\) => \{/)
- expect(block).toMatch(/chat\.page\(nodeId, /)
- expect(block).toMatch(/historySupported: \(nodeId\) => \{/)
- expect(block).toMatch(/canChat\(capabilityAgentId\(agentId\)\)/)
- // Declared before the service, assigned once host-chat exists (a later const would be a TDZ throw).
- const decl = s.indexOf("let watchHistoryChat: Pick<HostChatOps, 'page'> | null = null")
- expect(decl).toBeGreaterThan(-1)
- expect(decl).toBeLessThan(s.indexOf('watchLinks = createWatchLinkService({'))
- expect(s.indexOf('watchHistoryChat = hostBridge.chat')).toBeGreaterThan(s.indexOf('chat: createHostChat({'))
- })
-
- it('the desktop stops the hosts on the FIRST quit pass, inside the raced flush and before killAll', () => {
- const s = read(MAIN)
- const quit = s.slice(s.indexOf("app.on('before-quit'"))
- const firstPass = quit.slice(quit.indexOf('quitFlushed = true'))
- const stop = firstPass.indexOf('watchLinks?.shutdown()')
- expect(stop).toBeGreaterThan(-1)
- expect(stop).toBeLessThan(firstPass.indexOf('ptyManager.killAll()'))
- expect(firstPass).toMatch(/Promise\.allSettled\(\[[^\]]*watchLinksStopped/)
- })
-
- it('the Server Edition registers the service UNSUPPORTED with no entitlement (R43), and never inits it on a data dir it does not own', () => {
- const s = read(SERVER)
- const block = blockAfter(s, 'watchLinks = createWatchLinkService({', ' ')
- expect(block).toMatch(/entitlement: \(\) => null/)
- expect(block).toMatch(/unsupported: true/)
- expect(block).toMatch(/detach: \(id\) => \{\s*dropUiClient\(id\)\s*platform\.detach\(id\)/)
- expect(s).toMatch(/if \(otherServerHere\) \{\s*console\.error\('Live links: NOT started — another nodeterm server owns this data directory\.'\)\s*\} else void watchLinks\.init\(\)/)
- // Both close paths stop the hosts after hosting ends and before the pty layer goes — bounded
- // (R46/M6): a hung last write must not hold the server's close.
- expect(s).toMatch(/const WATCH_LINKS_STOP_MS = 2_000/)
- expect(s).not.toMatch(/await watchLinks\?\.shutdown\(\)/)
- const closes = s.split('async close()').slice(1)
- expect(closes).toHaveLength(2)
- for (const c of closes) {
- const stop = c.indexOf('await shutdownWithin(watchLinks, WATCH_LINKS_STOP_MS)')
- expect(stop).toBeGreaterThan(c.indexOf('hosted.stop()'))
- expect(stop).toBeLessThan(c.indexOf('await ptyManager.killAll()'))
- }
- })
-
- it('the preload exposes every owner channel', () => {
- const p = read('src/preload/index.ts')
- for (const ch of [
- 'watchLinkCreate', 'watchLinkList', 'watchLinkRevoke', 'watchLinkRevokeAll', 'watchLinkKick',
- 'watchLinkChatSend', 'watchLinkChatHistory', 'watchLinkState', 'watchLinkChat', 'watchLinkNotice'
- ]) {
- expect(p).toContain(`IPC.${ch}`)
- }
- })
-
- it('the relay tab takes the inert stub and never names the channels', () => {
- const r = read('src/renderer/bridge/relay-api.ts')
- expect(r).toMatch(/watchLink: stub\.watchLink/)
- expect(r).not.toMatch(/IPC\.watchLink/)
- })
-})
diff --git a/src/preload/index.ts b/src/preload/index.ts
index c9e4ae539..23f4191e6 100644
--- a/src/preload/index.ts
+++ b/src/preload/index.ts
@@ -28,7 +28,6 @@ import type {
} from '../shared/types'
import type { ClientId, PeerDiff, PeerIdentity, PeerState } from '../shared/presence'
import type { ProjectConsentRequest, ProjectSetupEvent } from '../shared/project-settings'
-import type { WatchChatMessage, WatchLinkNotice, WatchLinkView } from '../shared/watch-link-types'
import type { DevPortForwardRequest, DevPortsQuery } from '../shared/dev-ports'
// Fan a single ipcRenderer listener per channel out to many renderer subscribers. Without
@@ -84,9 +83,6 @@ const subscribeProjectSetupConsentDismiss = subscribe<[{ requestId: string }]>(
// the renderer cache subscribes ahead of the emitter.
const subscribeProjectTrustChanged = subscribe<[{ projectId: string }]>(IPC.projectTrustChanged)
// Live links: owner-only pushes from core (the node chip, the popover and Settings all listen).
-const subscribeWatchLinkState = subscribe<[WatchLinkView[]]>(IPC.watchLinkState)
-const subscribeWatchLinkChat = subscribe<[string, WatchChatMessage]>(IPC.watchLinkChat)
-const subscribeWatchLinkNotice = subscribe<[WatchLinkNotice]>(IPC.watchLinkNotice)
const api: NodeTerminalApi = {
pty: {
@@ -1069,23 +1065,6 @@ const api: NodeTerminalApi = {
ipcRenderer.on(IPC.stationHandoverChanged, handler)
return () => ipcRenderer.removeListener(IPC.stationHandoverChanged, handler)
}
- },
- // Live links (src/core/watch-link/service.ts). Owner-only IPC; the service answers this window.
- watchLink: {
- create: (req) => ipcRenderer.invoke(IPC.watchLinkCreate, req),
- list: () => ipcRenderer.invoke(IPC.watchLinkList),
- revoke: (linkId) => ipcRenderer.invoke(IPC.watchLinkRevoke, linkId),
- revokeAll: () => ipcRenderer.invoke(IPC.watchLinkRevokeAll),
- kick: (linkId, viewerId) => ipcRenderer.invoke(IPC.watchLinkKick, linkId, viewerId),
- sendChat: (linkId, text) => ipcRenderer.invoke(IPC.watchLinkChatSend, linkId, text),
- chatHistory: (linkId) => ipcRenderer.invoke(IPC.watchLinkChatHistory, linkId),
- setControl: (linkId, enabled) => ipcRenderer.invoke(IPC.watchLinkSetControl, linkId, enabled),
- setPassword: (linkId, password) => ipcRenderer.invoke(IPC.watchLinkSetPassword, linkId, password),
- allowControl: (linkId) => ipcRenderer.invoke(IPC.watchLinkAllowControl, linkId),
- controlSupport: (nodeId) => ipcRenderer.invoke(IPC.watchLinkControlSupport, nodeId),
- onState: subscribeWatchLinkState,
- onChat: subscribeWatchLinkChat,
- onNotice: subscribeWatchLinkNotice
}
}
diff --git a/src/renderer/bridge/relay-api.test.ts b/src/renderer/bridge/relay-api.test.ts
index 3d0fb6f16..dbb451f54 100644
--- a/src/renderer/bridge/relay-api.test.ts
+++ b/src/renderer/bridge/relay-api.test.ts
@@ -156,26 +156,6 @@ describe('buildRelayApi', () => {
expect((local.relayClient.disconnect as ReturnType<typeof vi.fn>)).toHaveBeenCalledWith('conn-7')
})
- it('live links: a relay tab takes the inert stub, never the LOCAL preload member, and sends nothing', async () => {
- const { local } = fakeLocalApi()
- const localWatchLink = { NAME: 'local-watch-link', create: vi.fn(), list: vi.fn() }
- ;(local as unknown as { watchLink: unknown }).watchLink = localWatchLink
- ;(globalThis as Record<string, unknown>).window = { nodeTerminal: local }
- const t = new FakeTransport()
- const { api } = buildRelayApi('conn-1', t)
- expect(api.watchLink).not.toBe(localWatchLink)
- await expect(
- api.watchLink.create({ nodeId: 'n1', role: 'viewer', ttlSeconds: 3600, label: 'Ada', title: 'build' })
- ).resolves.toEqual({ ok: false, error: 'unsupported' })
- await expect(api.watchLink.list()).resolves.toEqual([])
- await expect(api.watchLink.kick('l', 'v')).resolves.toBe(false)
- await expect(api.watchLink.sendChat('l', 'x')).resolves.toBeNull()
- await expect(api.watchLink.chatHistory('l')).resolves.toEqual([])
- expect(typeof api.watchLink.onState(() => {})).toBe('function')
- expect(localWatchLink.create).not.toHaveBeenCalled()
- expect(t.sent).toEqual([]) // nothing crossed the relay
- })
-
it('share with team: a relay tab takes the E_UNSUPPORTED stub, never the LOCAL preload member', async () => {
const { local } = fakeLocalApi()
const localShareTeam = { probe: vi.fn() }
diff --git a/src/renderer/bridge/relay-api.ts b/src/renderer/bridge/relay-api.ts
index 98d9739f5..310ef6866 100644
--- a/src/renderer/bridge/relay-api.ts
+++ b/src/renderer/bridge/relay-api.ts
@@ -213,10 +213,6 @@ export function buildRelayApi(
boardDispatch: stub.boardDispatch,
stationOutcome: stub.stationOutcome,
stationHandover: stub.stationHandover,
- // Live links publish THIS machine's terminals; a relay tab shows another machine's, so it takes
- // the inert stub (create answers `unsupported`). Never the local preload's real member, which
- // `...local` would otherwise hand it: that would offer to publish a node id this core does not run.
- watchLink: stub.watchLink,
// Share with team drives THIS machine's ssh for one of THIS machine's SSH projects; a relay
// tab's projects are the host's, so `...local` would aim a host project id at the local ssh
// manager. The stub answers E_UNSUPPORTED instead.
diff --git a/src/renderer/bridge/stubs.ts b/src/renderer/bridge/stubs.ts
index 86b9efbb1..74e496f94 100644
--- a/src/renderer/bridge/stubs.ts
+++ b/src/renderer/bridge/stubs.ts
@@ -735,25 +735,6 @@ export function buildStubApi(): Omit<
list: async () => [],
onChanged: noopUnsub
},
- // Live links are created on the machine that runs the terminal. The Server Edition overrides this
- // with the real bridge (`buildWatchLinkApi`); a relay tab keeps it — the peer's terminals are not
- // this machine's to publish (and every `watchLink:` channel is host-only on the peer anyway).
- watchLink: {
- create: async () => ({ ok: false, error: 'unsupported' }),
- list: async () => [],
- revoke: async () => {},
- revokeAll: async () => 'unsupported' as const,
- kick: async () => false,
- sendChat: async () => null,
- chatHistory: async () => [],
- setControl: async () => false,
- setPassword: async () => false,
- allowControl: async () => false,
- controlSupport: async () => 'unknown' as const,
- onState: noopUnsub,
- onChat: noopUnsub,
- onNotice: noopUnsub
- },
// Governs nothing by default. The Server Edition overrides it with the real bridge
// (`buildCanvasAuthorityApi`); a relay tab answers from its own connection (relay-api.ts).
canvasAuthority: {
diff --git a/src/renderer/bridge/ws-bridge.namespaces.test.ts b/src/renderer/bridge/ws-bridge.namespaces.test.ts
index 1f3dace7a..a39d05e47 100644
--- a/src/renderer/bridge/ws-bridge.namespaces.test.ts
+++ b/src/renderer/bridge/ws-bridge.namespaces.test.ts
@@ -5,8 +5,7 @@ import {
buildClaudeAccountsApi,
buildFilesApi,
buildRealApi,
- buildSessionMemoryApi,
- buildWatchLinkApi
+ buildSessionMemoryApi
} from './ws-bridge'
import { buildStubApi } from './stubs'
import { E_UNSUPPORTED } from '../../shared/rpc'
@@ -240,59 +239,3 @@ describe('buildHostedApi and the Server Edition', () => {
expect(install).not.toMatch(/\bhosted\s*:/)
})
})
-
-// Live links in the Server Edition: a REAL bridge over the owner-only `watchLink:*` channels (the
-// service answers create `unsupported` there until that edition has a license layer — R43).
-describe('buildWatchLinkApi', () => {
- it('every member rides its own watchLink channel, with its arguments', async () => {
- const c = fakeClient()
- const api = buildWatchLinkApi(c as never).watchLink
- const req = { nodeId: 'n1', role: 'viewer' as const, ttlSeconds: 3600 as const, label: 'Ada', title: 't' }
- await api.create(req)
- await api.list()
- await api.revoke('L1')
- await api.revokeAll()
- await api.kick('L1', 'v-1')
- await api.sendChat('L1', 'hi')
- await api.chatHistory('L1')
- api.onState(() => {})
- api.onChat(() => {})
- api.onNotice(() => {})
- expect(c.calls).toEqual([
- { kind: 'request', method: IPC.watchLinkCreate, args: [req] },
- { kind: 'request', method: IPC.watchLinkList, args: [] },
- { kind: 'request', method: IPC.watchLinkRevoke, args: ['L1'] },
- { kind: 'request', method: IPC.watchLinkRevokeAll, args: [] },
- { kind: 'request', method: IPC.watchLinkKick, args: ['L1', 'v-1'] },
- { kind: 'request', method: IPC.watchLinkChatSend, args: ['L1', 'hi'] },
- { kind: 'request', method: IPC.watchLinkChatHistory, args: ['L1'] },
- { kind: 'subscribe', method: IPC.watchLinkState, args: [] },
- { kind: 'subscribe', method: IPC.watchLinkChat, args: [] },
- { kind: 'subscribe', method: IPC.watchLinkNotice, args: [] }
- ])
- })
-
- it('a dropped socket: create answers network and the reads answer empty, never an unhandled rejection', async () => {
- const down = { request: () => Promise.reject(new Error('E_DISCONNECTED')), subscribe: () => () => {} }
- const api = buildWatchLinkApi(down as never).watchLink
- await expect(api.create({ nodeId: 'n1', role: 'viewer', ttlSeconds: 3600, label: 'A', title: 't' })).resolves.toEqual({
- ok: false,
- error: 'network'
- })
- await expect(api.list()).resolves.toEqual([])
- await expect(api.kick('L', 'v')).resolves.toBe(false)
- await expect(api.sendChat('L', 'x')).resolves.toBeNull()
- await expect(api.chatHistory('L')).resolves.toEqual([])
- // A stop that did not reach the server must be visible to the UI.
- await expect(api.revoke('L')).rejects.toThrow()
- await expect(api.revokeAll()).rejects.toThrow()
- })
-
- it('is spread into the Server Edition api, and into no builder a relay tab shares', () => {
- const src = readFileSync(join(__dirname, 'ws-bridge.ts'), 'utf8').replace(/\r\n/g, '\n')
- const install = src.slice(src.indexOf('export async function installWsBridge'))
- expect(install).toContain('...buildWatchLinkApi(client)')
- const relay = readFileSync(join(__dirname, 'relay-api.ts'), 'utf8').replace(/\r\n/g, '\n')
- expect(relay).not.toContain('buildWatchLinkApi')
- })
-})
diff --git a/src/renderer/bridge/ws-bridge.ts b/src/renderer/bridge/ws-bridge.ts
index 20ee8596e..dc6369776 100644
--- a/src/renderer/bridge/ws-bridge.ts
+++ b/src/renderer/bridge/ws-bridge.ts
@@ -99,15 +99,6 @@ import { buildStubApi, unsupported } from './stubs'
import { sanitizeStationNotices } from '@shared/station-notice'
import { sanitizeOutcomeRecords } from '@shared/station-outcome'
import { sanitizeHandoverRecords } from '@shared/station-handover'
-import type {
- ControlChangeResult,
- ControlSupport,
- CreateWatchLinkResult,
- RevokeAllOutcome,
- WatchChatMessage,
- WatchLinkNotice,
- WatchLinkView
-} from '@shared/watch-link-types'
import { mountPickerRoot, openDirectoryPicker } from './dialog-picker'
import { encodePcmForWire } from './speech-encode'
import { type FrameTransport, WebSocketFrameTransport } from './frame-transport'
@@ -1106,50 +1097,6 @@ export function buildTriggersApi(client: RpcClient): Pick<NodeTerminalApi, 'trig
}
}
-/**
- * The Server Edition's live links — the REAL bridge, backed by the same core service the desktop
- * registers (src/core/watch-link/service.ts). Its browser tabs are the server's own user (owner
- * clients), so the host-only `watchLink:` prefix does not refuse them. Until that edition has a license
- * layer the service answers create `unsupported` and list `[]` (R43). Kept OUT of every builder a relay
- * tab spreads (and out of the scoped-guest / access-policy BUILDERS lists): a relay tab shows another
- * machine's terminals, which are not this browser's to publish — relay-api.ts takes the inert stub.
- * A dropped socket answers create `network`; revoke and revokeAll reject, so the UI can say the stop
- * did not reach the server.
- */
-export function buildWatchLinkApi(client: RpcClient): Pick<NodeTerminalApi, 'watchLink'> {
- return {
- watchLink: {
- create: (req) =>
- (client.request(IPC.watchLinkCreate, req) as Promise<CreateWatchLinkResult>).catch(
- (): CreateWatchLinkResult => ({ ok: false, error: 'network' })
- ),
- list: () => (client.request(IPC.watchLinkList) as Promise<WatchLinkView[]>).catch(() => []),
- revoke: async (linkId) => {
- await client.request(IPC.watchLinkRevoke, linkId)
- },
- // Rejects on a dropped socket, like revoke: the server half did not happen and the UI must say so.
- revokeAll: () => client.request(IPC.watchLinkRevokeAll) as Promise<RevokeAllOutcome>,
- kick: (linkId, viewerId) =>
- (client.request(IPC.watchLinkKick, linkId, viewerId) as Promise<boolean>).catch(() => false),
- sendChat: (linkId, text) =>
- (client.request(IPC.watchLinkChatSend, linkId, text) as Promise<WatchChatMessage | null>).catch(() => null),
- chatHistory: (linkId) =>
- (client.request(IPC.watchLinkChatHistory, linkId) as Promise<WatchChatMessage[]>).catch(() => []),
- setControl: (linkId, enabled) =>
- (client.request(IPC.watchLinkSetControl, linkId, enabled) as Promise<ControlChangeResult>).catch(() => false),
- setPassword: (linkId, password) =>
- (client.request(IPC.watchLinkSetPassword, linkId, password) as Promise<ControlChangeResult>).catch(() => false),
- allowControl: (linkId) => (client.request(IPC.watchLinkAllowControl, linkId) as Promise<boolean>).catch(() => false),
- controlSupport: (nodeId) =>
- (client.request(IPC.watchLinkControlSupport, nodeId) as Promise<ControlSupport>).catch((): ControlSupport => 'unknown'),
- onState: (cb) => client.subscribe(IPC.watchLinkState, ((links: WatchLinkView[]) => cb(links)) as Listener),
- onChat: (cb) =>
- client.subscribe(IPC.watchLinkChat, ((linkId: string, msg: WatchChatMessage) => cb(linkId, msg)) as Listener),
- onNotice: (cb) => client.subscribe(IPC.watchLinkNotice, ((n: WatchLinkNotice) => cb(n)) as Listener)
- }
- }
-}
-
export function buildSessionMemoryApi(client: RpcClient): Pick<NodeTerminalApi, 'sessionMemory'> {
return {
sessionMemory: {
@@ -1506,7 +1453,6 @@ export async function installWsBridge(): Promise<boolean> {
...buildSpeechApi(client),
...buildUsageApi(client),
...buildSessionMemoryApi(client),
- ...buildWatchLinkApi(client),
...buildRecentConversationsApi(client),
...buildWallpaperApi(client),
...buildRunConfigApi(client),
diff --git a/src/server/auth.test.ts b/src/server/auth.test.ts
index 6e1404aaa..63d535d53 100644
--- a/src/server/auth.test.ts
+++ b/src/server/auth.test.ts
@@ -35,7 +35,7 @@ describe('Auth', () => {
it('verifies OFF the event loop and at most two at a time (S1)', async () => {
// A synchronous scrypt per login froze every terminal's WebSocket for ~35 ms per guess, and a
// burst of held requests froze the whole server. The event loop must stay free while verifying,
- // and the libuv pool must not be flooded (two at a time, the live-link gate's number).
+ // and the libuv pool must not be flooded (two at a time).
const a = new Auth(dir)
a.setPassword('correct horse')
let ticks = 0
diff --git a/src/server/auth.ts b/src/server/auth.ts
index ae109bc55..d0e27b1d3 100644
--- a/src/server/auth.ts
+++ b/src/server/auth.ts
@@ -43,8 +43,7 @@ export const GLOBAL_MAX_ATTEMPTS = 50
export const CLIENT_MEMORY_MS = 60 * 60_000
/** Bounded memory: past this many tracked clients, the least recently seen are forgotten. */
export const MAX_TRACKED_CLIENTS = 10_000
-/** Concurrent scrypt verifications (each is ~16 MiB and a libuv pool thread) — the live-link
- * service gates its own scrypt at the same number (core/watch-link/service.ts SCRYPT_SLOTS). */
+/** Concurrent scrypt verifications (each is ~16 MiB and a libuv pool thread). */
export const SCRYPT_SLOTS = 2
export type LoginOutcome = 'success' | 'failure' | 'abandoned'
@@ -62,8 +61,7 @@ interface ClientState {
lastSeen: number
}
-/** A FIFO gate: at most `slots` tasks run at once, the rest wait in order. Same shape as the
- * live-link service's `createFifoGate` (core/watch-link/service.ts). */
+/** A FIFO gate: at most `slots` tasks run at once, the rest wait in order. */
function fifoGate(slots: number): { run<T>(task: () => Promise<T>): Promise<T>; active(): number } {
let active = 0
const waiting: (() => void)[] = []
diff --git a/src/server/index.ts b/src/server/index.ts
index 1789ba749..9b22582d4 100644
--- a/src/server/index.ts
+++ b/src/server/index.ts
@@ -134,17 +134,7 @@ import { launchHeadless } from '../core/headless-launch'
import { HEADLESS_COLS, HEADLESS_ROWS, localNodePtyOptions } from '../shared/node-pty-options'
import { assembleResumeCommand } from '../shared/agents/launch'
import { gatePermissionMode, type AgentId, type BuiltinAgentId } from '../shared/agents/config'
-import {
- createWatchLinkService,
- registerWatchLinkIpc,
- sendToOwners,
- shutdownWithin,
- workspaceNodeState,
- type WatchLinkService
-} from '../core/watch-link/service'
-import { createWatchLinkApi } from '../core/watch-link/api'
-import { WatchLinkStore } from '../core/watch-link/store'
-import { createWatchPty, watchRemoteFor, watchRemoteRecords, type WatchRemote } from '../core/watch-link/pty-seam'
+import { removeRetiredLiveLinkData } from '../core/retired-data-cleanup'
// Same env-override + default as src/core/check.ts / license.ts / src/main/telemetry.ts — each
// shell derives it locally rather than sharing an import (src/server must not import src/main).
@@ -152,8 +142,6 @@ const API_BASE = process.env.NODETERM_API_BASE || 'https://api.nodeterm.dev'
// The hosted team relay's wss endpoint. Same env override + default as the desktop's RELAY_URL
// (src/main/remote/host-service.ts), derived locally for the same reason as API_BASE.
const RELAY_URL = process.env.NODETERM_RELAY_URL || 'wss://relay.nodeterm.dev'
-/** How long close() waits for the live-link service's last write (the desktop races 1.5 s). */
-const WATCH_LINKS_STOP_MS = 2_000
/**
* App version fed to ServerPlatform (surfaced to the renderer as the desktop app's
@@ -813,21 +801,15 @@ export async function startServer(
(project) => platform.broadcast(IPC.workspaceServerChange, project)
)
})
- // Live links (src/core/watch-link/service.ts). Assigned after the hosted-team block below; declared
- // here because the onPersist closure runs at the boot load just below (a later `const` would be a
- // TDZ throw inside that load, which it would then report as a failed load).
- let watchLinks: WatchLinkService | null = null
- // Every load()/save() is a canvas change as far as links are concerned: a browser drawing a
- // bridge edge reaches us as the workspace save it triggers. It also refreshes the local-ref
- // watcher set, so projects added or removed while the server runs get the same hand-edit path.
+ // Every load()/save() refreshes the local-ref watcher set, so projects added or removed while the
+ // server runs get the same hand-edit path.
workspaceStore.onPersist = () => {
workspaceWatcher.sync()
contextLink.refresh()
refreshNodeTokens()
- watchLinks?.onWorkspaceChanged()
}
// Nothing has read the workspace index yet — the desktop gets its first load from the renderer,
- // and this shell may never have one. Read it once so links are live before any browser connects.
+ // and this shell may never have one. Read it once, before any browser connects.
// Read-only: boot must not sideline a conflict-marked project.json (that stays a renderer/probe
// decision). The onPersist above turns this load into the initial refresh.
await workspaceStore.load({ sideline: false }).catch((e) => {
@@ -1155,45 +1137,9 @@ export async function startServer(
authority.sharedChanged()
}
- // Live links (docs/live-links.md): the SAME core service the desktop registers, over the real seams.
- // This edition has no license layer yet (`initLicense` is desktop-only), so the service is registered
- // UNSUPPORTED with no entitlement (controller ruling R43): create answers `unsupported` — the browser
- // shows "Live links need a Pro license on this server — not available in the Server Edition yet",
- // never an Upgrade button — list answers [], and nothing is loaded, hosted or revoked. A server
- // license layer (a named follow-up) changes `entitlement` and drops `unsupported`, nothing else.
- // Headless, no keychain: the links file is a 0600 file in the data dir (spec D8). The workspace
- // index was read above, so there is no load to wait for.
- const watchRemote = (nodeId: string): WatchRemote => watchRemoteFor(nodeId, watchRemoteRecords(workspaceStore, () => undefined))
- watchLinks = createWatchLinkService({
- api: createWatchLinkApi({ apiBase: API_BASE }),
- relayUrl: RELAY_URL,
- store: new WatchLinkStore({ file: path.join(config.dataDir, 'watch-links.json') }),
- entitlement: () => null,
- relayAllowed: () => true,
- nodeState: (nodeId) => workspaceNodeState(workspaceStore, nodeId),
- clients: {
- attach: (sink) => platform.attach(sink, { quiet: true, selfPaced: true }),
- // The per-client drops a departed client is owed (its pty subscriptions), then the sink.
- detach: (id) => {
- dropUiClient(id)
- platform.detach(id)
- }
- },
- // The desktop's rule (core's `watchRemoteFor`), with no SSH-project manager here (no master): a node
- // in a HOST's tmux — an SSH project's, or a remote-tmux node in a local project — is joinable only
- // while this core holds its session live (join-only never spawns), and never through the local tmux.
- pty: createWatchPty(ptyManager, watchRemote),
- // The same check as the desktop (links stay unsupported here, but the member answers): a node in a
- // host's tmux would run there, never in this core's Zellij.
- controlSupport: (nodeId) => (watchRemote(nodeId).requireRemote ? 'ok' : ptyManager.nodeControlSupport(nodeId)),
- emit: (channel, ...args) => sendToOwners(platform, channel, ...args),
- unsupported: true
- })
- registerWatchLinkIpc(platform, watchLinks)
- // Two servers on one data dir would host (and revoke) each other's links.
- if (otherServerHere) {
- console.error('Live links: NOT started — another nodeterm server owns this data directory.')
- } else void watchLinks.init()
+ // Live links were retired (2026-11): remove an old store's files from the data dir once per boot
+ // (they almost certainly never existed here). Never throws.
+ void removeRetiredLiveLinkData(config.dataDir)
// Headless notification host: every core service above (incl. the loopback hook server, which
// is its own listener and MUST run) is booted, but we bind NO public HTTP/WS listener — no
@@ -1211,9 +1157,6 @@ export async function startServer(
// pty subscriptions) while the pty layer is still up. Same two lines in the serving close().
await teamAdmin.close()
hosted.stop()
- // Stop the live-link hosts while the pty layer is still up (their viewers leave cleanly),
- // bounded: the links file's last write must not hold the close on a stalled disk.
- await shutdownWithin(watchLinks, WATCH_LINKS_STOP_MS)
// Detach PTY clients — tmux sessions keep running (Phase 1 contract).
sessionReaper.stop()
pressure.stop()
@@ -1280,8 +1223,6 @@ export async function startServer(
// headless close() above).
await teamAdmin.close()
hosted.stop()
- // Stop the live-link hosts while the pty layer is still up (see the headless close() above).
- await shutdownWithin(watchLinks, WATCH_LINKS_STOP_MS)
// End the browser WebSockets next, BEFORE the canvas authority stops (N3). Once it has stopped
// and been detached, a save from a still-attached tab is written un-overlaid, over its final
// flush. Ending the sockets stops new saves; the `idle()` below lets the ones already queued
diff --git a/src/shared/types.ts b/src/shared/types.ts
index 5e0d0baef..1d83d6e92 100644
--- a/src/shared/types.ts
+++ b/src/shared/types.ts
@@ -1319,9 +1319,6 @@ export interface TmuxStatus {
persistence?: {
enabled: boolean
backend: 'tmux' | 'zellij' | 'session-host' | null
- /** Session host only: the CONNECTED host speaks `watch-attach`, so a live link viewer can join a
- * node nobody holds open. Absent = no / not known yet. */
- watchJoin?: boolean
} | null
/**
* The optional Zellij backend (@shared/session-backend): whether a `zellij` binary was found and
@@ -5040,9 +5037,4 @@ export interface NodeTerminalApi {
list(): Promise<import('./station-handover').StationHandoverRecord[]>
onChanged(cb: (records: import('./station-handover').StationHandoverRecord[]) => void): () => void
}
- /** Live links (src/core/watch-link/service.ts): a read-only, expiring browser link to one terminal,
- * hosted by THIS machine. Owner-only (`watchLink:*` is host-only). Desktop: real. Server Edition:
- * the real bridge, whose create answers `unsupported` until that edition has a license layer.
- * Relay tab: an inert stub (a peer's terminals are not this machine's to publish). */
- watchLink: import('./watch-link-types').WatchLinkApi
}