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.

fix(watch-link): say when viewers cannot watch, and what the create dialog promises

review4698f55d89ff
diff --git a/src/core/watch-link/link-host.test.ts b/src/core/watch-link/link-host.test.ts
index 60f9d8844..f047a8ada 100644
--- a/src/core/watch-link/link-host.test.ts
+++ b/src/core/watch-link/link-host.test.ts
@@ -107,6 +107,7 @@ function setup(o: SetupOpts = {}) {
const joinArgs: [number, string, string][] = []
const joinTimes: number[] = []
let mints = 0
+ let changes = 0
const clock = o.clock
const now = clock ? clock.now : () => Date.now()
const pty: WatchPty = {
@@ -159,7 +160,9 @@ function setup(o: SetupOpts = {}) {
now,
setTimeout: clock ? clock.setTimeout : (fn, ms) => setTimeout(fn, ms),
clearTimeout: clock ? clock.clearTimeout : (h) => clearTimeout(h as ReturnType<typeof setTimeout>),
- onChange: () => {},
+ onChange: () => {
+ changes++
+ },
onChat: (m) => chats.push(m),
onViewerJoined: (n) => joined.push(n),
onGone: (r) => gone.push(r)
@@ -169,6 +172,8 @@ function setup(o: SetupOpts = {}) {
record, host, peers, sinks, left, calls, joinArgs, joinTimes, chats, joined, gone,
keys: deriveWatchLinkKeys(secret),
mints: () => mints,
+ /** How many times the host reported a change to the registry (`onChange`). */
+ changes: () => changes,
/** The n-th attached viewer's sink (attach order). */
sink: (n = 0) => [...sinks.values()][n]
}
@@ -383,6 +388,45 @@ describe('createLinkHost — joining, waiting, rejoining', () => {
expect(v.named(WATCH_EVENT.meta)[0]).toMatchObject({ cols: 80, rows: 24 })
})
+ // R63: the OWNER is told a viewer has no session to watch — on a backend with no watcher client of
+ // its own (Windows' session host, no local tmux, Zellij) only a terminal open in the app can be
+ // watched. Reported by a REFUSED join, once per episode, and cleared by a join that lands.
+ it("a refused join marks the viewer waiting in the owner's view, once; a join that lands clears it", async () => {
+ const clock = manualClock()
+ let running = false
+ const t = setup({ clock, join: () => (running ? { sessionId: 's9', cols: 80, rows: 24, altScreen: false } : null) })
+ t.host.start()
+ await vi.waitFor(() => expect(t.peers).toHaveLength(1))
+ const v = viewer(t.peers[0], t.keys)
+ await vi.waitFor(() => expect(t.host.viewers().map((x) => x.waiting)).toEqual([true]))
+ const changesAfterFirst = t.changes()
+ await clock.advance(REJOIN_BACKOFF_MS[0])
+ await clock.advance(REJOIN_BACKOFF_MS[1])
+ expect(t.joinArgs.length).toBeGreaterThanOrEqual(3)
+ expect(t.changes()).toBe(changesAfterFirst) // a failing rejoin loop reports nothing new
+ running = true
+ await clock.advance(REJOIN_BACKOFF_MS[2])
+ await vi.waitFor(() => expect(v.named(WATCH_EVENT.meta)).toHaveLength(1))
+ expect(t.host.viewers().map((x) => x.waiting)).toEqual([false])
+ expect(t.changes()).toBeGreaterThan(changesAfterFirst)
+ })
+
+ it('a session that ENDS is not "waiting" for the owner until a rejoin is refused (a quick rejoin is no news)', async () => {
+ const clock = manualClock()
+ let n = 0
+ let up = true
+ const t = setup({ clock, join: () => (up ? { sessionId: `s${++n}`, cols: 80, rows: 24, altScreen: true } : null) })
+ t.host.start()
+ const v = await openViewer(t)
+ ptyEvent(t.sink(), IPC.ptyExit('s1'), 0)
+ await clock.flush()
+ expect(v.named(WATCH_EVENT.waiting)).toHaveLength(1) // the VIEWER is told at once
+ expect(t.host.viewers().map((x) => x.waiting)).toEqual([false]) // the owner is not, yet
+ up = false
+ await clock.advance(REJOIN_BACKOFF_MS[0])
+ expect(t.host.viewers().map((x) => x.waiting)).toEqual([true]) // the rejoin was refused
+ })
+
it('every join starts the filter mid-stream: the first join AND a rejoin after the session ended', async () => {
const clock = manualClock()
let n = 0
diff --git a/src/core/watch-link/link-host.ts b/src/core/watch-link/link-host.ts
index fab64367e..3314154c4 100644
--- a/src/core/watch-link/link-host.ts
+++ b/src/core/watch-link/link-host.ts
@@ -58,7 +58,10 @@
// drains must not grow the host's memory. meta, keyframe, waiting and end are small and rare.
//
// REJOIN. A session that ends (exit, closed, recycled, or found gone after a join or a capture — R30)
-// sends the viewer `watch:waiting` and rejoins on a backoff. The backoff is reset only once a joined
+// sends the viewer `watch:waiting` and rejoins on a backoff. A join that is REFUSED (no session it may
+// join) also marks the viewer `waiting` for the OWNER (`LinkViewer.waiting`, R63): on a backend with no
+// watcher client of its own (Windows' session host, no local tmux, Zellij) only a terminal this app has
+// open can be watched, and the owner is the one who can open it — a LIVE chip alone would say nothing. The backoff is reset only once a joined
// session stayed up for REJOIN_STABLE_MS from its join keyframe (R26), never on a join or a lifecycle
// event: an old remote tmux that rejects the client flags, or an owner's repeated `-D`, attaches then
// exits at once, and resetting on success turned that into a spawn + read + capture every 2 s forever.
@@ -178,6 +181,11 @@ export interface LinkViewer {
viewerId: string
name: string | null
joinedAt: number
+ /** Connected, but its last join found no session to watch (R63): what the owner must be told,
+ * because only the owner can fix it — on a backend with no watcher client (Windows' session host,
+ * no local tmux, Zellij) a viewer can co-attach only to a terminal this app has OPEN. Set by a
+ * REFUSED join, never by a session merely ending: that rejoins in seconds, usually successfully. */
+ waiting: boolean
}
export interface LinkHost {
start(): void
@@ -209,6 +217,8 @@ interface Conn {
altScreen: boolean
joining: boolean
waiting: boolean
+ /** The last join answered no session (LinkViewer.waiting). Cleared by a join that lands. */
+ joinRefused: boolean
streaming: boolean
filter: StreamFilter
bucket: TokenBucket
@@ -510,6 +520,13 @@ export function createLinkHost(record: WatchLinkRecord, deps: LinkHostDeps): Lin
c.waiting = true
send(c, WATCH_EVENT.waiting, {})
}
+ /** The owner's view of a viewer with nothing to watch (LinkViewer.waiting): reported on a change only,
+ * so a rejoin loop that keeps failing costs one push, not one per attempt. */
+ function setJoinRefused(c: Conn, refused: boolean): void {
+ if (c.joinRefused === refused) return
+ c.joinRefused = refused
+ if (c.joinedAt !== null && !c.ended) safe('onChange', deps.onChange)
+ }
function scheduleRejoin(c: Conn): void {
if (c.ended || stopped || c.rejoinTimer !== null) return
const delay = REJOIN_BACKOFF_MS[Math.min(c.rejoinAttempt, REJOIN_BACKOFF_MS.length - 1)]
@@ -548,9 +565,11 @@ export function createLinkHost(record: WatchLinkRecord, deps: LinkHostDeps): Lin
}
if (!res) {
enterWaiting(c)
+ setJoinRefused(c, true)
scheduleRejoin(c)
return
}
+ setJoinRefused(c, false)
const sid = res.sessionId
// EVERY join restarts the filter mid-stream (R12): this is a running session.
c.filter.reset({ midStream: true, onSettled: () => onSettled(c, sid) })
@@ -680,6 +699,7 @@ export function createLinkHost(record: WatchLinkRecord, deps: LinkHostDeps): Lin
altScreen: false,
joining: false,
waiting: false,
+ joinRefused: false,
streaming: false,
filter: createStreamFilter({ midStream: true }),
bucket: createTokenBucket({ ratePerSec: RATE, burst: BURST, now: deps.now }),
@@ -801,7 +821,10 @@ export function createLinkHost(record: WatchLinkRecord, deps: LinkHostDeps): Lin
function viewers(): LinkViewer[] {
const out: LinkViewer[] = []
- for (const c of conns) if (c.joinedAt !== null && !c.ended) out.push({ viewerId: c.viewerId, name: c.name, joinedAt: c.joinedAt })
+ for (const c of conns) {
+ if (c.joinedAt === null || c.ended) continue
+ out.push({ viewerId: c.viewerId, name: c.name, joinedAt: c.joinedAt, waiting: c.joinRefused && c.sessionId === null })
+ }
return out
}
function gone(reason: 'revoked' | 'expired'): void {
diff --git a/src/core/watch-link/service.test.ts b/src/core/watch-link/service.test.ts
index 34a52a034..a04000639 100644
--- a/src/core/watch-link/service.test.ts
+++ b/src/core/watch-link/service.test.ts
@@ -741,15 +741,27 @@ describe('createWatchLinkService — the host seams', () => {
expect(chat?.[1]).toEqual([r.link.linkId, { id: 'x', name: 'Eve', text: 'hi there \u{1F468}\u200d\u{1F469}', at: 1, from: 'viewer' }])
h.chat = [{ id: 'y', name: '\u200fMal', text: 'a\u202ab', at: 2, from: 'viewer' }]
expect(t.s.chatHistory(r.link.linkId)).toEqual([{ id: 'y', name: 'Mal', text: 'ab', at: 2, from: 'viewer' }])
- h.viewers = [{ viewerId: 'v-1', name: 'E\u202eve', joinedAt: 5 }]
- expect(t.s.list()[0].viewers).toEqual([{ viewerId: 'v-1', name: 'Eve', joinedAt: 5 }])
+ h.viewers = [{ viewerId: 'v-1', name: 'E\u202eve', joinedAt: 5, waiting: false }]
+ expect(t.s.list()[0].viewers).toEqual([{ viewerId: 'v-1', name: 'Eve', joinedAt: 5, waiting: false }])
+ })
+
+ // R63: a viewer the host could not join to a session reaches the owner's view as `waiting`.
+ it("a viewer's waiting state reaches the owner's view", async () => {
+ const t = service()
+ const r = await t.s.create(req())
+ if (!r.ok) throw new Error('create failed')
+ t.hosts.made[0].viewers = [
+ { viewerId: 'v-1', name: null, joinedAt: 5, waiting: true },
+ { viewerId: 'v-2', name: null, joinedAt: 6, waiting: false }
+ ]
+ expect(t.s.list()[0].viewers.map((v) => v.waiting)).toEqual([true, false])
})
it('kick, owner chat and history go to the link host; an unknown link answers nothing', async () => {
const t = service()
const r = await t.s.create(req({ role: 'commenter' }))
if (!r.ok) throw new Error('create failed')
- t.hosts.made[0].viewers = [{ viewerId: 'v-1', name: null, joinedAt: 1 }]
+ t.hosts.made[0].viewers = [{ viewerId: 'v-1', name: null, joinedAt: 1, waiting: false }]
expect(t.s.kick(r.link.linkId, 'v-1')).toBe(true)
expect(t.s.kick(r.link.linkId, 'v-9')).toBe(false)
expect(t.s.sendChat(r.link.linkId, 'hello')).toMatchObject({ text: 'hello', from: 'sharer' })
diff --git a/src/core/watch-link/service.ts b/src/core/watch-link/service.ts
index a56069a0c..ae4eb828b 100644
--- a/src/core/watch-link/service.ts
+++ b/src/core/watch-link/service.ts
@@ -279,7 +279,8 @@ export function createWatchLinkService(deps: WatchLinkServiceDeps): WatchLinkSer
viewers = h.viewers().map((v) => ({
viewerId: v.viewerId,
name: v.name === null ? null : stripBidiControls(v.name),
- joinedAt: v.joinedAt
+ joinedAt: v.joinedAt,
+ waiting: v.waiting === true
}))
} catch (err) {
warn(`reading a link's state failed: ${errorText(err)}`)
diff --git a/src/renderer/canvas/Canvas.tsx b/src/renderer/canvas/Canvas.tsx
index 41a80d6c5..ad469c024 100644
--- a/src/renderer/canvas/Canvas.tsx
+++ b/src/renderer/canvas/Canvas.tsx
@@ -18570,6 +18570,9 @@ export function Canvas() {
? 'relay'
: 'desktop'
}
+ // R63: an SSH project's node runs in the HOST's tmux, which gives a viewer a client of its
+ // own — the "only while open" note is about this machine's local terminals.
+ remoteNode={!!useProjects.getState().getProject(liveLinkDialog.projectId)?.ssh}
prepare={liveLinkPrepareFor(liveLinkDialog)}
// No license layer in the Server Edition (R43): never an Upgrade button there.
onUpgrade={isBrowserRuntime() ? undefined : () => void useEntitlement.getState().upgrade('pro')}
diff --git a/src/renderer/canvas/live-link-wiring.test.ts b/src/renderer/canvas/live-link-wiring.test.ts
index 715401950..db8a6f73c 100644
--- a/src/renderer/canvas/live-link-wiring.test.ts
+++ b/src/renderer/canvas/live-link-wiring.test.ts
@@ -51,6 +51,10 @@ describe('Canvas live-link wiring', () => {
expect(src).toContain('prepare={liveLinkPrepareFor(liveLinkDialog)}')
})
+ it("R63: the dialog knows an SSH project's node from its project (the host's tmux serves its viewers)", () => {
+ expect(src).toContain('remoteNode={!!useProjects.getState().getProject(liveLinkDialog.projectId)?.ssh}')
+ })
+
it('R43: no Upgrade button from the dialog on the Server Edition', () => {
expect(src).toContain("onUpgrade={isBrowserRuntime() ? undefined : () => void useEntitlement.getState().upgrade('pro')}")
})
diff --git a/src/renderer/components/LiveLinkChip.surfaces.test.tsx b/src/renderer/components/LiveLinkChip.surfaces.test.tsx
index 92d503ade..4caf52ac6 100644
--- a/src/renderer/components/LiveLinkChip.surfaces.test.tsx
+++ b/src/renderer/components/LiveLinkChip.surfaces.test.tsx
@@ -40,7 +40,7 @@ const link = (over: Partial<WatchLinkView> = {}): WatchLinkView => ({
expiresAt: Date.now() + 3_600_000,
url: 'u',
status: 'live',
- viewers: [{ viewerId: 'v', name: null, joinedAt: 0 }],
+ viewers: [{ viewerId: 'v', name: null, joinedAt: 0, waiting: false }],
...over
})
const session: KanbanSession = { id: 'n1', title: 'build', color: '#fff', kind: 'terminal', spawn: {} } as KanbanSession
diff --git a/src/renderer/components/LiveLinkChip.test.tsx b/src/renderer/components/LiveLinkChip.test.tsx
index 429417348..f1f896680 100644
--- a/src/renderer/components/LiveLinkChip.test.tsx
+++ b/src/renderer/components/LiveLinkChip.test.tsx
@@ -128,7 +128,7 @@ describe('LiveLinkChip', () => {
// state (empty), so `renderToStaticMarkup` can never show a link.
it('shows LIVE with the viewer count, as a no-drag button', () => {
render(<LiveLinkChip nodeId="n1" source="local" className="extra" />)
- setLinks([link({ viewers: [{ viewerId: 'v', name: null, joinedAt: 0 }] })])
+ setLinks([link({ viewers: [{ viewerId: 'v', name: null, joinedAt: 0, waiting: false }] })])
const c = chip()!
expect(c.tagName).toBe('BUTTON')
expect(c.textContent).toBe('LIVE · 1')
@@ -162,7 +162,7 @@ describe('LiveLinkChip', () => {
describe('LiveLinkPopover', () => {
it('opens on click with role, time, the controls and the kick note', () => {
render(<LiveLinkChip nodeId="n1" source="local" />)
- setLinks([link({ viewers: [{ viewerId: 'v1', name: null, joinedAt: 0 }, { viewerId: 'v2', name: 'Cy', joinedAt: 0 }] })])
+ setLinks([link({ viewers: [{ viewerId: 'v1', name: null, joinedAt: 0, waiting: false }, { viewerId: 'v2', name: 'Cy', joinedAt: 0, waiting: false }] })])
click(chip()!)
const p = pop()!
expect(p.textContent).toContain('Can watch')
@@ -196,6 +196,32 @@ describe('LiveLinkPopover', () => {
expect(pop()!.querySelector('.live-pop__status')!.textContent).toContain("won't host this link")
})
+ // R63: a viewer with no session to join is the owner's to fix — the chip and the popover say how.
+ it('viewers waiting for the terminal: an amber chip, a status line and the viewer marked', () => {
+ render(<LiveLinkChip nodeId="n1" source="local" />)
+ setLinks([
+ link({
+ viewers: [
+ { viewerId: 'v1', name: null, joinedAt: 0, waiting: true },
+ { viewerId: 'v2', name: null, joinedAt: 0, waiting: false }
+ ]
+ })
+ ])
+ const c = chip()!
+ expect(c.textContent).toBe('LIVE · 1 waiting')
+ expect(c.className).toContain('live-chip--waiting')
+ expect(c.title).toBe('Viewers are waiting — open this terminal in nodeterm to let them watch.')
+ click(c)
+ const p = pop()!
+ expect(p.querySelector('.live-pop__status')!.textContent).toBe(
+ 'Viewers are waiting — open this terminal in nodeterm to let them watch.'
+ )
+ expect(p.querySelector('.live-pop__status')!.className).toContain('live-pop__status--waiting')
+ const rows = [...p.querySelectorAll('.live-pop__viewers li')].map((e) => e.textContent)
+ expect(rows[0]).toContain('waiting for the terminal')
+ expect(rows[1]).not.toContain('waiting')
+ })
+
it('Stop sharing revokes; a stop that did not reach nodeterm says so (H23)', async () => {
render(<LiveLinkChip nodeId="n1" source="local" />)
setLinks([link()])
@@ -302,7 +328,7 @@ describe('LiveLinkPopover', () => {
it('a failed Kick says so: not reached, or nobody to kick (M3)', async () => {
render(<LiveLinkChip nodeId="n1" source="local" />)
- setLinks([link({ viewers: [{ viewerId: 'v1', name: null, joinedAt: 0 }] })])
+ setLinks([link({ viewers: [{ viewerId: 'v1', name: null, joinedAt: 0, waiting: false }] })])
click(chip()!)
api.kick.mockImplementationOnce(async () => {
throw new Error('socket down')
@@ -343,7 +369,7 @@ describe('LiveLinkPopover', () => {
describe('LiveLinkPopover — Commenter chat', () => {
it('renders every viewer string as text, never as markup', () => {
render(<LiveLinkChip nodeId="n1" source="local" />)
- setLinks([link({ role: 'commenter', label: '<b>Ada</b>', viewers: [{ viewerId: 'v', name: '<i>Eve</i>', joinedAt: 0 }] })])
+ setLinks([link({ role: 'commenter', label: '<b>Ada</b>', viewers: [{ viewerId: 'v', name: '<i>Eve</i>', joinedAt: 0, waiting: false }] })])
act(() => useWatchLinks.getState().addChat('L', msg('1', { name: '<u>Eve</u>', text: '<img src=x onerror=alert(1)>' })))
click(chip()!)
const p = pop()!
diff --git a/src/renderer/components/LiveLinkDialog.test.tsx b/src/renderer/components/LiveLinkDialog.test.tsx
index 4d3fab046..881e80e50 100644
--- a/src/renderer/components/LiveLinkDialog.test.tsx
+++ b/src/renderer/components/LiveLinkDialog.test.tsx
@@ -30,13 +30,27 @@ describe('LiveLinkDialogBody', () => {
it('shows the URL with Copy and Stop, and until when anyone with it can watch (H25)', () => {
const expiresAt = new Date(2026, 9, 1, 15, 42, 0).getTime()
- const html = body({ phase: 'done', url: 'https://nodeterm.dev/s/x#1.y', linkId: 'x', expiresAt })
+ const now = new Date(2026, 9, 1, 14, 42, 0).getTime()
+ const html = body({ phase: 'done', url: 'https://nodeterm.dev/s/x#1.y', linkId: 'x', expiresAt }, { now })
expect(html).toContain('https://nodeterm.dev/s/x#1.y')
expect(html).toContain('Copy')
expect(html).toContain('Stop sharing')
expect(html).toContain(`Anyone with this link can watch until ${formatClock(expiresAt)}.`)
})
+ // R64/M1: a 24 h link made at 15:43 read "until 15:43" — it looks like it ends now.
+ it('names the day when the link ends on another day', () => {
+ const now = new Date(2026, 9, 1, 15, 43, 0).getTime()
+ const expiresAt = now + 24 * 3_600_000
+ const html = body({ phase: 'done', url: 'https://nodeterm.dev/s/x#1.y', linkId: 'x', expiresAt }, { now })
+ expect(html).toContain(`Anyone with this link can watch until tomorrow ${formatClock(expiresAt)}.`)
+ })
+
+ it('R63: the "only while open" note shows in the form when the caller has one', () => {
+ expect(body(FORM, { whileOpenNote: 'NOTE-X' })).toContain('NOTE-X')
+ expect(body(FORM)).not.toContain('live-dialog__note')
+ })
+
it('the header title loses its bidi controls (H26)', () => {
const html = renderToStaticMarkup(
<LiveLinkDialogBody title={'bu‮ild'} state={FORM} onChange={noop} onSubmit={noop} onClose={noop} onStop={noop} />
@@ -81,14 +95,23 @@ let api: {
create: ReturnType<typeof vi.fn<(r: CreateWatchLinkRequest) => Promise<CreateWatchLinkResult>>>
revoke: ReturnType<typeof vi.fn<(id: string) => Promise<void>>>
}
+/** What the local core's `tmuxStatus` reports (R63); `undefined` = the read rejects. */
+let persistence: { enabled: boolean; backend: string | null } | undefined
let host: HTMLDivElement
let root: Root
beforeEach(() => {
resetDialogStack()
api = { create: vi.fn(async () => created()), revoke: vi.fn(async () => {}) }
+ persistence = { enabled: true, backend: 'tmux' }
;(window as unknown as { nodeTerminal: unknown }).nodeTerminal = {
watchLink: api,
- clipboard: { writeText: vi.fn() }
+ clipboard: { writeText: vi.fn() },
+ pty: {
+ tmuxStatus: vi.fn(async () => {
+ if (!persistence) throw new Error('no core')
+ return { available: true, installCommand: null, installLabel: null, platform: 'linux', persistence }
+ })
+ }
}
localStorage.clear()
host = document.createElement('div')
@@ -120,6 +143,7 @@ function mount(o: {
onUpgrade?: () => void
onClose?: () => void
surface?: 'desktop' | 'server' | 'relay'
+ remoteNode?: boolean
} = {}): { onClose: ReturnType<typeof vi.fn> } {
const onClose = vi.fn(o.onClose ?? (() => {}))
act(() =>
@@ -128,6 +152,7 @@ function mount(o: {
nodeId="n1"
title="build"
surface={o.surface ?? 'desktop'}
+ remoteNode={o.remoteNode}
prepare={o.prepare ?? (async () => null)}
onUpgrade={o.onUpgrade}
onClose={onClose}
@@ -151,6 +176,45 @@ describe('LiveLinkDialog', () => {
expect(document.querySelector<HTMLInputElement>('.live-dialog__label input')!.value).toBe('x'.repeat(40))
})
+ it('D2/M3: the prefill never splits an emoji at the label limit', () => {
+ localStorage.setItem('nodeterm.presence.me', JSON.stringify({ name: 'x'.repeat(39) + '\u{1F600}', color: '#fff' }))
+ mount()
+ expect(document.querySelector<HTMLInputElement>('.live-dialog__label input')!.value).toBe('x'.repeat(39))
+ })
+
+ it('D2/M3: focus lands in the dialog — the label on open, Copy once created', async () => {
+ mount()
+ expect(document.activeElement).toBe(document.querySelector('.live-dialog__label input'))
+ setLabel('Ada')
+ click(btn('Create live link'))
+ await flush()
+ expect(document.activeElement).toBe(btn('Copy'))
+ })
+
+ // R63: on a machine with no watcher client for a local node (Windows' session host, tmux off or
+ // missing, Zellij), a link works only while the terminal is open here — said before it is created.
+ it('R63: says "only while open" where this machine has no watcher client, and nowhere else', async () => {
+ const note = (): string | null =>
+ [...document.querySelectorAll('.live-dialog__note')].map((e) => e.textContent).join('|') || null
+ for (const [p, remote, shown] of [
+ [{ enabled: true, backend: 'session-host' }, false, true],
+ [{ enabled: true, backend: 'zellij' }, false, true],
+ [{ enabled: false, backend: 'tmux' }, false, true],
+ [{ enabled: true, backend: null }, false, true],
+ [{ enabled: true, backend: 'tmux' }, false, false],
+ [{ enabled: true, backend: 'session-host' }, true, false], // an SSH node: the host's tmux
+ [undefined, false, false] // unknown claims nothing
+ ] as const) {
+ persistence = p
+ act(() => root.unmount())
+ root = createRoot(host)
+ mount({ remoteNode: remote })
+ await flush()
+ if (shown) expect(note(), JSON.stringify(p)).toMatch(/only while it is open in nodeterm/)
+ else expect(note(), JSON.stringify(p)).toBeNull()
+ }
+ })
+
it('R47: prepares BEFORE create, then creates this node with the chosen options', async () => {
const order: string[] = []
const prepare = vi.fn(async () => {
diff --git a/src/renderer/components/LiveLinkDialog.tsx b/src/renderer/components/LiveLinkDialog.tsx
index 8efbce373..00820c33f 100644
--- a/src/renderer/components/LiveLinkDialog.tsx
+++ b/src/renderer/components/LiveLinkDialog.tsx
@@ -10,13 +10,16 @@ import { useCallback, useEffect, useRef, useState } from 'react'
import { createPortal } from 'react-dom'
import { useDialogStack } from './dialog-stack'
import {
+ capUnits,
createErrorMessage,
DEFAULT_TTL,
- formatClock,
+ formatUntil,
LIVE_LINK_WARNING,
ROLE_LABEL,
SAVE_FIRST_MESSAGE,
TTL_OPTIONS,
+ watchableOnlyWhileOpen,
+ watchWhileOpenNote,
type LiveLinkSurface
} from '../lib/liveLink'
import { stopLiveLinks } from '../lib/liveLinkEntry'
@@ -56,6 +59,11 @@ export function LiveLinkDialogBody(p: {
onStop: (linkId: string) => void
onCopy?: (url: string) => void
onUpgrade?: () => void
+ /** R63: on a machine with no watcher client for this node, the link works only while the terminal
+ * is open in this app — said before the owner creates it. Absent: nothing to say (or not known). */
+ whileOpenNote?: string | null
+ /** "now" for the end's day (tomorrow, a weekday): the caller's clock. */
+ now?: number
}): React.JSX.Element {
const s = p.state
// The title is the node's own (git-shared, hand-editable): shown as TEXT, bidi controls stripped.
@@ -72,11 +80,14 @@ export function LiveLinkDialogBody(p: {
value={s.url}
onFocus={(e) => e.currentTarget.select()}
/>
- <button className="confirm__btn primary" onClick={() => p.onCopy?.(s.url)}>
+ {/* Keyboard focus lands here once the link exists (D2/M3): Enter copies it. */}
+ <button className="confirm__btn primary" data-autofocus="" onClick={() => p.onCopy?.(s.url)}>
{s.copied ? 'Copied!' : 'Copy'}
</button>
</div>
- <p className="live-dialog__note">Anyone with this link can watch until {formatClock(s.expiresAt)}.</p>
+ <p className="live-dialog__note">
+ Anyone with this link can watch until {formatUntil(s.expiresAt, p.now ?? Date.now())}.
+ </p>
{s.error && (
<p className="live-dialog__error" role="alert">
{s.error}
@@ -116,8 +127,11 @@ export function LiveLinkDialogBody(p: {
</fieldset>
<label className="live-dialog__label">
Shown to viewers as
+ {/* Keyboard focus lands here when the dialog opens (D2/M3): keys stay inside the dialog
+ instead of reaching the canvas behind it. */}
<input
className="confirm__input"
+ data-autofocus=""
maxLength={LABEL_MAX}
value={s.label}
disabled={s.busy}
@@ -125,6 +139,7 @@ export function LiveLinkDialogBody(p: {
/>
</label>
<p className="live-dialog__warning">{LIVE_LINK_WARNING}</p>
+ {p.whileOpenNote && <p className="live-dialog__note">{p.whileOpenNote}</p>}
{s.error && (
<p className="live-dialog__error" role="alert">
{s.error}
@@ -151,6 +166,7 @@ export function LiveLinkDialog({
nodeId,
title,
surface,
+ remoteNode = false,
prepare,
onUpgrade,
onClose
@@ -159,6 +175,8 @@ export function LiveLinkDialog({
title: string
/** Where it was opened — decides how `unsupported` reads (H1). */
surface: LiveLinkSurface
+ /** The node runs on an SSH project's host, whose own tmux gives a viewer a client of its own (R63). */
+ remoteNode?: boolean
/** R47: publish pending canvas edits before core looks the node up. A sentence = do NOT create. */
prepare: () => Promise<string | null>
/** Absent on the Server Edition (R43): no Upgrade button there. */
@@ -169,7 +187,7 @@ export function LiveLinkDialog({
phase: 'form',
role: 'viewer',
ttl: DEFAULT_TTL,
- label: (loadIdentity()?.name ?? '').slice(0, LABEL_MAX),
+ label: capUnits(loadIdentity()?.name ?? '', LABEL_MAX),
busy: false,
error: null
}))
@@ -179,6 +197,29 @@ export function LiveLinkDialog({
const isTop = useDialogStack()
const copiedTimer = useRef<ReturnType<typeof setTimeout>>()
useEffect(() => () => clearTimeout(copiedTimer.current), [])
+ // R63: does THIS machine have a watcher client for this node? Read once from the local core (the
+ // core that creates the link). Unknown — not read yet, or unreadable — says nothing.
+ const [whileOpenOnly, setWhileOpenOnly] = useState(false)
+ useEffect(() => {
+ let live = true
+ Promise.resolve()
+ .then(() => window.nodeTerminal.pty.tmuxStatus())
+ .then(
+ (st) => {
+ if (live) setWhileOpenOnly(watchableOnlyWhileOpen({ persistence: st?.persistence, remoteNode }))
+ },
+ () => {}
+ )
+ return () => {
+ live = false
+ }
+ }, [remoteNode])
+ // D2/M3: focus lands in the dialog — the label on open, Copy once created — so keys stay inside
+ // it (a bare-key canvas command could otherwise fire behind the overlay).
+ const panelRef = useRef<HTMLDivElement>(null)
+ useEffect(() => {
+ panelRef.current?.querySelector<HTMLElement>('[data-autofocus]')?.focus({ preventScroll: true })
+ }, [state.phase])
const busy = state.phase === 'form' && state.busy
// Every dismissal goes through here: a create in flight cannot be walked away from (H24).
@@ -246,9 +287,10 @@ export function LiveLinkDialog({
}
return createPortal(
- <div className="confirm-overlay" onClick={dismiss}>
+ <div className="confirm-overlay" ref={panelRef} onClick={dismiss}>
<LiveLinkDialogBody
title={title}
+ whileOpenNote={whileOpenOnly ? watchWhileOpenNote() : null}
state={state}
onChange={(next) => {
if (!busy) setState(next)
diff --git a/src/renderer/components/LiveLinkPopover.tsx b/src/renderer/components/LiveLinkPopover.tsx
index 12ebd50c1..06c68902d 100644
--- a/src/renderer/components/LiveLinkPopover.tsx
+++ b/src/renderer/components/LiveLinkPopover.tsx
@@ -17,7 +17,8 @@ import {
ROLE_LABEL,
statusLine,
STOP_FAILED_MESSAGE,
- viewerName
+ viewerName,
+ waitingViewers
} from '../lib/liveLink'
import { thisMachine } from '../lib/machineName'
import { EMPTY_LINKS, useWatchLinks, viewLinkThread } from '../state/watchLinks'
@@ -179,7 +180,8 @@ const LinkBlock = memo(function LinkBlock({
const api = window.nodeTerminal.watchLink
const [copied, setCopied] = useState(false)
const [error, setError] = useState<string | null>(null)
- const status = statusLine(link.status)
+ const status = statusLine(link)
+ const waiting = waitingViewers([link]) > 0
useEffect(() => {
if (!copied) return
const t = setTimeout(() => setCopied(false), 1500)
@@ -195,7 +197,7 @@ const LinkBlock = memo(function LinkBlock({
Shown to viewers as {stripBidiControls(link.label)}
</p>
{status && (
- <p className={`live-pop__status live-pop__status--${link.status}`} role="status">
+ <p className={`live-pop__status live-pop__status--${link.status === 'live' && waiting ? 'waiting' : link.status}`} role="status">
{status}
</p>
)}
@@ -237,7 +239,10 @@ const LinkBlock = memo(function LinkBlock({
{link.viewers.map((v, i) => (
<li key={v.viewerId}>
<span className="live-pop__who">{viewerName(v, i)}</span>
- <span className="live-pop__muted">since {formatClock(v.joinedAt)}</span>
+ <span className="live-pop__muted">
+ since {formatClock(v.joinedAt)}
+ {v.waiting ? ' · waiting for the terminal' : ''}
+ </span>
<button
type="button"
className="confirm__btn live-pop__btn live-pop__kick"
diff --git a/src/renderer/components/settings/sections/LiveLinksSection.test.tsx b/src/renderer/components/settings/sections/LiveLinksSection.test.tsx
index 26a10fd7d..1bbe570f8 100644
--- a/src/renderer/components/settings/sections/LiveLinksSection.test.tsx
+++ b/src/renderer/components/settings/sections/LiveLinksSection.test.tsx
@@ -54,8 +54,8 @@ const link = (over: Partial<WatchLinkView> = {}): WatchLinkView => ({
url: 'https://nodeterm.dev/s/L1#1.SECRET',
status: 'live',
viewers: [
- { viewerId: 'a', name: null, joinedAt: 0 },
- { viewerId: 'b', name: null, joinedAt: 0 }
+ { viewerId: 'a', name: null, joinedAt: 0, waiting: false },
+ { viewerId: 'b', name: null, joinedAt: 0, waiting: false }
],
...over
})
diff --git a/src/renderer/components/settings/sections/LiveLinksSection.tsx b/src/renderer/components/settings/sections/LiveLinksSection.tsx
index 0179dcae9..6b27e06f2 100644
--- a/src/renderer/components/settings/sections/LiveLinksSection.tsx
+++ b/src/renderer/components/settings/sections/LiveLinksSection.tsx
@@ -50,7 +50,7 @@ export function liveLinkProjectLabel(projects: readonly Project[], nodeId: strin
function LinkRow({ link, now, projects }: { link: WatchLinkView; now: number; projects: readonly Project[] }): React.JSX.Element {
const [error, setError] = useState<string | null>(null)
const [stopping, setStopping] = useState(false)
- const status = statusLine(link.status)
+ const status = statusLine(link)
return (
<div className="live-settings__row flex items-center justify-between gap-3">
<div className="min-w-0">
diff --git a/src/renderer/lib/liveLink.test.ts b/src/renderer/lib/liveLink.test.ts
index ce579924f..8bda60472 100644
--- a/src/renderer/lib/liveLink.test.ts
+++ b/src/renderer/lib/liveLink.test.ts
@@ -3,8 +3,12 @@
// through lib/machineName, and a literal "this computer" must not depend on the OS running the suite.
import { describe, it, expect } from 'vitest'
import {
+ capUnits,
CHAT_NOT_SENT_MESSAGE,
chipView,
+ formatUntil,
+ LIVE_LINK_WARNING,
+ watchableOnlyWhileOpen,
commentFromChat,
createErrorMessage,
DEFAULT_TTL,
@@ -47,7 +51,7 @@ const link = (over: Partial<WatchLinkView> = {}): WatchLinkView => ({
viewers: [],
...over
})
-const viewer = (id: string) => ({ viewerId: id, name: null, joinedAt: 0 })
+const viewer = (id: string) => ({ viewerId: id, name: null, joinedAt: 0, waiting: false })
const RELAY_SENTENCE = 'Live links are created on the machine that runs this terminal.'
const R43 = 'Live links need a Pro license on this server — not available in the Server Edition yet'
@@ -94,14 +98,38 @@ describe('chipView', () => {
describe('statusLine (H9)', () => {
it('explains reconnecting and refused, and says nothing for a live link', () => {
- expect(statusLine('live')).toBeNull()
- expect(statusLine('reconnecting')).toBe(
+ expect(statusLine(link())).toBeNull()
+ expect(statusLine(link({ status: 'reconnecting' }))).toBe(
"Reconnecting to nodeterm's relay — viewers see no updates until it's back."
)
- expect(statusLine('refused')).toBe(
+ expect(statusLine(link({ status: 'refused' }))).toBe(
"nodeterm's service won't host this link — the Pro plan may have lapsed, or this build can't relay. Viewers can't join."
)
})
+ // R63: a viewer with no session to join is the owner's to fix — never a silent LIVE.
+ it('a live link with viewers waiting for the terminal says how to let them watch', () => {
+ const waiting = { ...viewer('w'), waiting: true }
+ expect(statusLine(link({ viewers: [viewer('a'), waiting] }))).toBe(
+ 'Viewers are waiting — open this terminal in nodeterm to let them watch.'
+ )
+ expect(statusLine(link({ viewers: [viewer('a')] }))).toBeNull()
+ // A worse state still wins: refused or reconnecting say THAT.
+ expect(statusLine(link({ status: 'refused', viewers: [waiting] }))).toMatch(/won't host this link/)
+ })
+})
+
+describe('chipView: viewers waiting (R63)', () => {
+ it('a waiting viewer turns LIVE into an amber "waiting" chip whose title says what to do', () => {
+ const waiting = { ...viewer('w'), waiting: true }
+ expect(chipView([link({ viewers: [viewer('a'), waiting] })])).toEqual({
+ label: 'LIVE · 1 waiting',
+ tone: 'waiting',
+ title: 'Viewers are waiting — open this terminal in nodeterm to let them watch.'
+ })
+ // refused and reconnecting still win (they need the relay or the service, not an open terminal).
+ expect(chipView([link({ status: 'reconnecting', viewers: [waiting] })]).tone).toBe('offline')
+ expect(chipView([link({ viewers: [viewer('a')] })]).tone).toBe('live')
+ })
})
describe('time', () => {
@@ -248,9 +276,9 @@ describe('copy Task 17 reads (R47, R48, R52, H11, H23, H26)', () => {
describe('viewerName', () => {
it('a viewer who has not chatted is numbered; a name loses its bidi controls', () => {
- expect(viewerName({ viewerId: 'a', name: null, joinedAt: 0 }, 0)).toBe('Viewer 1')
- expect(viewerName({ viewerId: 'a', name: ' ', joinedAt: 0 }, 2)).toBe('Viewer 3')
- expect(viewerName({ viewerId: 'a', name: 'Bob⁦', joinedAt: 0 }, 0)).toBe('Bob')
+ expect(viewerName({ viewerId: 'a', name: null, joinedAt: 0, waiting: false }, 0)).toBe('Viewer 1')
+ expect(viewerName({ viewerId: 'a', name: ' ', joinedAt: 0, waiting: false }, 2)).toBe('Viewer 3')
+ expect(viewerName({ viewerId: 'a', name: 'Bob⁦', joinedAt: 0, waiting: false }, 0)).toBe('Bob')
})
})
@@ -267,3 +295,50 @@ describe('commentFromChat', () => {
expect(text).toContain('Deploy')
})
})
+
+// R64/M1: the "until" of a link that ends on another day names the day.
+describe('formatUntil', () => {
+ const at = (d: number, h: number, m: number): number => new Date(2026, 9, d, h, m, 0).getTime()
+ it('the same day reads as the time alone; the next day as "tomorrow"; later days by date', () => {
+ expect(formatUntil(at(1, 16, 43), at(1, 15, 43))).toBe(formatClock(at(1, 16, 43)))
+ expect(formatUntil(at(2, 15, 43), at(1, 15, 43))).toBe(`tomorrow ${formatClock(at(2, 15, 43))}`)
+ // An 8 h link made at 20:00 ends after midnight: not today.
+ expect(formatUntil(at(2, 4, 0), at(1, 20, 0))).toBe(`tomorrow ${formatClock(at(2, 4, 0))}`)
+ const far = formatUntil(at(4, 9, 0), at(1, 9, 0))
+ expect(far).not.toBe(formatClock(at(4, 9, 0)))
+ expect(far.endsWith(formatClock(at(4, 9, 0)))).toBe(true)
+ expect(far.startsWith('tomorrow')).toBe(false)
+ })
+})
+
+describe('capUnits (D2/M3)', () => {
+ it('caps by UTF-16 units without splitting a surrogate pair', () => {
+ expect(capUnits('abc', 5)).toBe('abc')
+ expect(capUnits('x'.repeat(39) + '\u{1F600}', 40)).toBe('x'.repeat(39))
+ expect(capUnits('x'.repeat(38) + '\u{1F600}', 40)).toBe('x'.repeat(38) + '\u{1F600}')
+ })
+})
+
+// R63: the dialog's "only while open" note — on for a machine with no watcher client of its own.
+describe('watchableOnlyWhileOpen', () => {
+ it('only a local node on a machine whose local terminals are tmux has a watcher client', () => {
+ const p = (enabled: boolean, backend: string | null) => ({ enabled, backend })
+ expect(watchableOnlyWhileOpen({ persistence: p(true, 'tmux'), remoteNode: false })).toBe(false)
+ expect(watchableOnlyWhileOpen({ persistence: p(true, 'session-host'), remoteNode: false })).toBe(true)
+ expect(watchableOnlyWhileOpen({ persistence: p(true, 'zellij'), remoteNode: false })).toBe(true)
+ expect(watchableOnlyWhileOpen({ persistence: p(false, 'tmux'), remoteNode: false })).toBe(true)
+ expect(watchableOnlyWhileOpen({ persistence: p(true, null), remoteNode: false })).toBe(true)
+ // An SSH node: the host's tmux. Unknown: say nothing.
+ expect(watchableOnlyWhileOpen({ persistence: p(true, 'session-host'), remoteNode: true })).toBe(false)
+ expect(watchableOnlyWhileOpen({ persistence: undefined, remoteNode: false })).toBe(false)
+ expect(watchableOnlyWhileOpen({ persistence: null, remoteNode: false })).toBe(false)
+ })
+})
+
+// R64/M3: the stream follows the terminal CLIENT, so tmux's chooser and a session switch reach viewers.
+describe('the create warning', () => {
+ it("names tmux's session chooser and a session switch", () => {
+ expect(LIVE_LINK_WARNING).toMatch(/session chooser/)
+ expect(LIVE_LINK_WARNING).toMatch(/switch sessions/)
+ })
+})
diff --git a/src/renderer/lib/liveLink.ts b/src/renderer/lib/liveLink.ts
index 53f6a1efc..3e4b57931 100644
--- a/src/renderer/lib/liveLink.ts
+++ b/src/renderer/lib/liveLink.ts
@@ -40,8 +40,12 @@ export const TTL_OPTIONS: { value: WatchLinkTtl; label: string }[] = WATCH_LINK_
}))
export const DEFAULT_TTL: WatchLinkTtl = DEFAULT_WATCH_LINK_TTL
+/** Always on the create dialog. "Everything this terminal shows" is meant literally (R64/M3): the
+ * stream is the terminal CLIENT's output, so tmux's session chooser (`C-b s` / `C-b w`, a live
+ * preview of every session — other projects' agents included) or a session switch inside it reaches
+ * viewers as well. */
export const LIVE_LINK_WARNING =
- "Anyone with the link sees everything this terminal shows: what's on screen now, anything printed later (tokens, env dumps), and anything you scroll back to. They can't type or resize it."
+ "Anyone with the link sees everything this terminal shows: what's on screen now, anything printed later (tokens, env dumps), anything you scroll back to — and, if you open tmux's session chooser or switch sessions in it, those other sessions too. They can't type or resize it."
export const KICK_NOTE =
'Kick ends this connection; anyone with the link can rejoin. Stop sharing to end it for everyone.'
@@ -116,15 +120,27 @@ export function stopAllOutcomeText(o: RevokeAllOutcome | unknown): { ok: boolean
/** H11: a Settings row whose node no open project holds. */
export const NOT_IN_OPEN_PROJECT = 'not in an open project'
-export type LiveLinkTone = 'live' | 'offline' | 'refused'
+export type LiveLinkTone = 'live' | 'offline' | 'refused' | 'waiting'
+
+/** R63: a connected viewer with no session it may join. On a machine with no watcher client of its
+ * own (Windows' session host, no local tmux, Zellij) only a terminal open in this app can be
+ * watched, so the owner is the one who can fix it — and is told how. */
+export const VIEWERS_WAITING_MESSAGE = 'Viewers are waiting — open this terminal in nodeterm to let them watch.'
+
+/** How many of a link's (or node's) connected viewers are waiting for a session (R63). */
+export function waitingViewers(links: readonly Pick<WatchLinkView, 'viewers'>[]): number {
+ return links.reduce((n, l) => n + l.viewers.filter((v) => v.waiting === true).length, 0)
+}
/**
* What the chip says for one node's links. The WORST state wins: `refused` will not come back on
- * its own and needs the owner; `reconnecting` will. The titles send the owner to the popover, which
- * carries the status line that explains it (H9).
+ * its own and needs the owner; `reconnecting` will; `waiting` (R63) needs the owner to open the
+ * terminal. The titles send the owner to the popover, which carries the status line that explains
+ * it (H9).
*/
export function chipView(links: readonly WatchLinkView[]): { label: string; tone: LiveLinkTone; title: string } {
const viewers = links.reduce((n, l) => n + l.viewers.length, 0)
+ const waiting = waitingViewers(links)
if (links.some((l) => l.status === 'refused')) {
return {
label: 'LIVE · refused',
@@ -139,6 +155,7 @@ export function chipView(links: readonly WatchLinkView[]): { label: string; tone
title: "A live link on this terminal is reconnecting to nodeterm's relay. Open it for details."
}
}
+ if (waiting > 0) return { label: `LIVE · ${waiting} waiting`, tone: 'waiting', title: VIEWERS_WAITING_MESSAGE }
const shared = links.length > 1 ? `This terminal is shared by ${links.length} live links` : 'This terminal is shared by a live link'
return {
label: viewers > 0 ? `LIVE · ${viewers}` : 'LIVE',
@@ -147,12 +164,14 @@ export function chipView(links: readonly WatchLinkView[]): { label: string; tone
}
}
-/** One line per link in the popover explaining a state that is not `live` (H9); null when live. */
-export function statusLine(status: WatchLinkView['status']): string | null {
- if (status === 'reconnecting') return "Reconnecting to nodeterm's relay — viewers see no updates until it's back."
- if (status === 'refused') {
+/** One line per link in the popover (and Settings) explaining a state that needs explaining (H9):
+ * not `live`, or live with viewers waiting for a session (R63). null when there is nothing to say. */
+export function statusLine(link: Pick<WatchLinkView, 'status' | 'viewers'>): string | null {
+ if (link.status === 'reconnecting') return "Reconnecting to nodeterm's relay — viewers see no updates until it's back."
+ if (link.status === 'refused') {
return "nodeterm's service won't host this link — the Pro plan may have lapsed, or this build can't relay. Viewers can't join."
}
+ if (waitingViewers([link]) > 0) return VIEWERS_WAITING_MESSAGE
return null
}
@@ -174,6 +193,55 @@ export function formatClock(ms: number): string {
return new Date(ms).toLocaleTimeString([], { hour: '2-digit', minute: '2-digit' })
}
+/**
+ * When a link ends, for "Anyone with this link can watch until …" (R64/M1). The time alone is the
+ * time TODAY: a 24 h link made at 15:43 read "until 15:43", which looks like it ends now, and an 8 h
+ * link past midnight read like today. So a different day is named — "tomorrow 15:43", or the weekday
+ * and date further out.
+ */
+export function formatUntil(expiresAt: number, now: number): string {
+ const end = new Date(expiresAt)
+ const today = new Date(now)
+ const dayStart = (d: Date): number => new Date(d.getFullYear(), d.getMonth(), d.getDate()).getTime()
+ const days = Math.round((dayStart(end) - dayStart(today)) / 86_400_000)
+ const time = formatClock(expiresAt)
+ if (days === 0) return time
+ if (days === 1) return `tomorrow ${time}`
+ return `${end.toLocaleDateString([], { weekday: 'short', month: 'short', day: 'numeric' })} ${time}`
+}
+
+/**
+ * At most `max` UTF-16 units — the unit `LABEL_MAX` and the input's `maxLength` count — cut BETWEEN
+ * code points (D2/M3): a plain `slice` of a prefilled name can split an emoji's surrogate pair.
+ */
+export function capUnits(s: string, max: number): string {
+ if (s.length <= max) return s
+ let out = ''
+ for (const ch of s) {
+ if (out.length + ch.length > max) break
+ out += ch
+ }
+ return out
+}
+
+/**
+ * R63: whether a link to a node can be watched ONLY while the node is open in this app. A viewer joins
+ * a session this process holds (the canvas node, a parked view) or — with nothing held — spawns its
+ * own read-only tmux client; a machine whose LOCAL terminals are not tmux (Windows' session host, tmux
+ * switched off or missing, Zellij) has no such client. An SSH project's node runs in the HOST's tmux,
+ * which does. Unknown (the status not read yet, or unreadable) claims nothing: the popover's waiting
+ * line still tells the truth at runtime.
+ */
+export function watchableOnlyWhileOpen(o: {
+ persistence: { enabled: boolean; backend: string | null } | null | undefined
+ remoteNode: boolean
+}): boolean {
+ if (o.remoteNode || !o.persistence) return false
+ return !(o.persistence.enabled && o.persistence.backend === 'tmux')
+}
+export function watchWhileOpenNote(): string {
+ return `On ${thisMachine()}, viewers can watch this terminal only while it is open in nodeterm; otherwise they wait until you open it.`
+}
/** Which surface a create or a share affordance is on — read by the caller, never by this module. */
export type LiveLinkSurface = 'desktop' | 'server' | 'relay'
diff --git a/src/renderer/state/watchLinks.test.ts b/src/renderer/state/watchLinks.test.ts
index 627b04d19..53e3ae743 100644
--- a/src/renderer/state/watchLinks.test.ts
+++ b/src/renderer/state/watchLinks.test.ts
@@ -39,13 +39,13 @@ describe('watchLinks store', () => {
s.setLinks([link('a', 'n1'), link('c', 'n2')])
const before = useWatchLinks.getState()
// A fresh deserialized list (new objects, same content) except n2's link gained a viewer.
- s.setLinks([link('a', 'n1'), link('c', 'n2', { viewers: [{ viewerId: 'v', name: null, joinedAt: 1 }] })])
+ s.setLinks([link('a', 'n1'), link('c', 'n2', { viewers: [{ viewerId: 'v', name: null, joinedAt: 1, waiting: false }] })])
const after = useWatchLinks.getState()
expect(after.byNode.n1).toBe(before.byNode.n1)
expect(after.byNode.n1[0]).toBe(before.byNode.n1[0])
expect(after.byNode.n2).not.toBe(before.byNode.n2)
// A push identical in content changes nothing at all.
- s.setLinks([link('a', 'n1'), link('c', 'n2', { viewers: [{ viewerId: 'v', name: null, joinedAt: 1 }] })])
+ s.setLinks([link('a', 'n1'), link('c', 'n2', { viewers: [{ viewerId: 'v', name: null, joinedAt: 1, waiting: false }] })])
expect(useWatchLinks.getState()).toBe(after)
})
@@ -53,10 +53,18 @@ describe('watchLinks store', () => {
// A fixture with every field of the type, iterated by key: a field added to WatchLinkView (and
// to this fixture, which the type forces) is covered without editing the comparison.
const base: WatchLinkView = link('a', 'n1', {
- viewers: [{ viewerId: 'v', name: 'Eve', joinedAt: 5 }]
+ viewers: [{ viewerId: 'v', name: 'Eve', joinedAt: 5, waiting: false }]
})
const bump = (v: unknown): unknown =>
- typeof v === 'number' ? v + 1 : typeof v === 'string' ? `${v}x` : Array.isArray(v) ? [] : v
+ typeof v === 'number'
+ ? v + 1
+ : typeof v === 'string'
+ ? `${v}x`
+ : typeof v === 'boolean'
+ ? !v
+ : Array.isArray(v)
+ ? []
+ : v
for (const key of Object.keys(base) as (keyof WatchLinkView)[]) {
useWatchLinks.setState({ links: [], byNode: {}, chats: {}, unread: {}, hydrated: false })
useWatchLinks.getState().setLinks([base])
diff --git a/src/renderer/styles.css b/src/renderer/styles.css
index 827b3a5bc..15c9b03bb 100644
--- a/src/renderer/styles.css
+++ b/src/renderer/styles.css
@@ -11529,6 +11529,10 @@ button.pull-checks__name {
.live-chip--offline {
--live-tone: var(--state-warning);
}
+/* Viewers are waiting for a session they may join (R63): the owner has to open the terminal. */
+.live-chip--waiting {
+ --live-tone: var(--state-warning);
+}
/* Refused: nodeterm's service will not host the link — muted, the owner opens it to see why. */
.live-chip--refused {
--live-tone: var(--muted);
diff --git a/src/shared/watch-link-types.ts b/src/shared/watch-link-types.ts
index 65c4e87ca..68a320d9d 100644
--- a/src/shared/watch-link-types.ts
+++ b/src/shared/watch-link-types.ts
@@ -64,6 +64,10 @@ export interface WatchLinkViewerView {
/** The name the viewer chatted under, if it has chatted; null otherwise ("Viewer 1"…). */
name: string | null
joinedAt: number
+ /** Connected, but there is no session it may join (R63): on a machine with no watcher client of its
+ * own (Windows' session host, no local tmux, Zellij) the terminal must be OPEN in this app. The
+ * owner is told ("Viewers are waiting — open this terminal in nodeterm to let them watch"). */
+ waiting: boolean
}
export interface WatchLinkView {