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(live-links): both warnings for Control, the right machine, a password save survives the popover

reviewaa9fa3ca3129
diff --git a/src/renderer/canvas/Canvas.tsx b/src/renderer/canvas/Canvas.tsx
index b416a4a14..931067894 100644
--- a/src/renderer/canvas/Canvas.tsx
+++ b/src/renderer/canvas/Canvas.tsx
@@ -19324,6 +19324,8 @@ export function Canvas() {
// 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}
+ // The Control warning names where a controller's commands run: the SSH host, else here.
+ sshTarget={useProjects.getState().getProject(liveLinkDialog.projectId)?.ssh?.server ?? null}
readPersistence={readLocalPersistence}
prepare={liveLinkPrepareFor(liveLinkDialog)}
// No license layer in the Server Edition (R43): never an Upgrade button there.
diff --git a/src/renderer/canvas/live-link-wiring.test.ts b/src/renderer/canvas/live-link-wiring.test.ts
index 167f9f4f8..9bd7c5f71 100644
--- a/src/renderer/canvas/live-link-wiring.test.ts
+++ b/src/renderer/canvas/live-link-wiring.test.ts
@@ -63,6 +63,8 @@ describe('Canvas live-link wiring', () => {
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}')
+ // …and names that host in the Control warning (a controller's commands run there, not here).
+ expect(src).toContain('sshTarget={useProjects.getState().getProject(liveLinkDialog.projectId)?.ssh?.server ?? null}')
// …and reads THIS machine's session protection from the local core, never a relay peer's.
expect(src).toContain('readPersistence={readLocalPersistence}')
expect(callback('readLocalPersistence')).toContain('localSession.api.pty.tmuxStatus()')
diff --git a/src/renderer/components/LiveLinkChip.test.tsx b/src/renderer/components/LiveLinkChip.test.tsx
index c40399c7c..a17bc0916 100644
--- a/src/renderer/components/LiveLinkChip.test.tsx
+++ b/src/renderer/components/LiveLinkChip.test.tsx
@@ -679,6 +679,63 @@ describe('LiveLinkPopover — a Control link', () => {
expect([...document.querySelectorAll('input')].map((i) => i.value)).not.toContain(generated)
})
+ it('while a password save is in flight the popover stays: an outside click and Escape are ignored', async () => {
+ let answer!: (ok: boolean) => void
+ api.setPassword.mockImplementationOnce(() => new Promise<boolean>((r) => (answer = r)))
+ render(<LiveLinkChip nodeId="n1" source="local" />)
+ setLinks([controller()])
+ click(chip()!)
+ click(button('Change password…'))
+ typeInto(pop()!.querySelector<HTMLInputElement>('.live-pop__password input')!, 'longenough1')
+ click(button('Save'))
+ await flush()
+ expect(button('Saving…')).toBeTruthy()
+ expect(button('Saving…').disabled).toBe(true)
+ click(document.querySelector('.live-pop__scrim')!)
+ expect(pop()).not.toBeNull()
+ act(() => void window.dispatchEvent(new KeyboardEvent('keydown', { key: 'Escape' })))
+ expect(pop()).not.toBeNull()
+ // Open chat would hand over to the drawer: not while the new password is still owed.
+ click(button('Open chat'))
+ expect(pop()).not.toBeNull()
+ await act(async () => answer(true))
+ expect(pop()!.querySelector<HTMLInputElement>('.live-pop__password input')!.value).toBe('longenough1')
+ expect(pop()!.textContent).toContain(PASSWORD_SHOWN_ONCE)
+ // Saved and shown: closing works again.
+ act(() => void window.dispatchEvent(new KeyboardEvent('keydown', { key: 'Escape' })))
+ expect(pop()).toBeNull()
+ })
+
+ it('a save that fails releases the popover too', async () => {
+ let answer!: (ok: boolean) => void
+ api.setPassword.mockImplementationOnce(() => new Promise<boolean>((r) => (answer = r)))
+ render(<LiveLinkChip nodeId="n1" source="local" />)
+ setLinks([controller()])
+ click(chip()!)
+ click(button('Change password…'))
+ typeInto(pop()!.querySelector<HTMLInputElement>('.live-pop__password input')!, 'longenough1')
+ click(button('Save'))
+ await flush()
+ click(document.querySelector('.live-pop__scrim')!)
+ expect(pop()).not.toBeNull()
+ await act(async () => answer(false))
+ click(document.querySelector('.live-pop__scrim')!)
+ expect(pop()).toBeNull()
+ })
+
+ it('the link going away mid-save closes it: nothing is owed for a link that no longer exists', async () => {
+ api.setPassword.mockImplementationOnce(() => new Promise<boolean>(() => {}))
+ render(<LiveLinkChip nodeId="n1" source="local" />)
+ setLinks([controller()])
+ click(chip()!)
+ click(button('Change password…'))
+ typeInto(pop()!.querySelector<HTMLInputElement>('.live-pop__password input')!, 'longenough1')
+ click(button('Save'))
+ await flush()
+ setLinks([])
+ expect(pop()).toBeNull()
+ })
+
it('a password core refused is not shown as set', async () => {
render(<LiveLinkChip nodeId="n1" source="local" />)
setLinks([controller()])
diff --git a/src/renderer/components/LiveLinkDialog.test.tsx b/src/renderer/components/LiveLinkDialog.test.tsx
index 9ef8b13ee..110f2d448 100644
--- a/src/renderer/components/LiveLinkDialog.test.tsx
+++ b/src/renderer/components/LiveLinkDialog.test.tsx
@@ -7,8 +7,9 @@ import type { ControlSupport, CreateWatchLinkRequest, CreateWatchLinkResult } fr
import { LiveLinkDialog, LiveLinkDialogBody } from './LiveLinkDialog'
import {
CONTROL_UNSUPPORTED_REASON,
- CONTROL_WARNING,
+ controlWarningText,
formatClock,
+ LIVE_LINK_EXPOSURE,
LIVE_LINK_WARNING,
PASSWORD_SEPARATE_NOTE,
PASSWORD_SHOWN_ONCE,
@@ -17,8 +18,10 @@ import {
UNLIMITED_NOTE
} from '../lib/liveLink'
import { resetDialogStack } from './dialog-stack'
+import { pinNeutralMachineNoun } from '../lib/testMachineNoun'
;(globalThis as { IS_REACT_ACT_ENVIRONMENT?: boolean }).IS_REACT_ACT_ENVIRONMENT = true
+pinNeutralMachineNoun()
const noop = (): void => {}
const body = (state: Parameters<typeof LiveLinkDialogBody>[0]['state'], extra: Partial<Parameters<typeof LiveLinkDialogBody>[0]> = {}) =>
@@ -38,7 +41,7 @@ describe('LiveLinkDialogBody', () => {
for (const r of ['Viewer', 'Commenter', 'Control']) expect(html).toContain(r)
// Neither Control's password field nor its warning until Control is picked.
expect(html).not.toContain('live-dialog__password')
- expect(html).not.toContain(CONTROL_WARNING)
+ expect(html).not.toContain('can type in this terminal as you')
expect(html).toContain(LIVE_LINK_WARNING.replace(/'/g, '&#x27;'))
expect(html).toContain('Create live link')
})
@@ -61,6 +64,12 @@ describe('LiveLinkDialogBody', () => {
expect(html).toContain(`Anyone with this link can watch until tomorrow ${formatClock(expiresAt)}.`)
})
+ it('Control: the "and" of the typing warning is bold, and the machine is the one the caller names', () => {
+ const html = body({ ...FORM, role: 'controller' }, { controlMachine: '[email protected]' })
+ expect(html).toContain('<strong>and</strong>')
+ expect(html).toContain('running any command on [email protected];')
+ })
+
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')
@@ -163,6 +172,7 @@ function mount(o: {
onClose?: () => void
surface?: 'desktop' | 'server' | 'relay'
remoteNode?: boolean
+ sshTarget?: { user: string; host: string } | null
} = {}): { onClose: ReturnType<typeof vi.fn> } {
const onClose = vi.fn(o.onClose ?? (() => {}))
act(() =>
@@ -172,6 +182,7 @@ function mount(o: {
title="build"
surface={o.surface ?? 'desktop'}
remoteNode={o.remoteNode}
+ sshTarget={o.sshTarget}
readPersistence={readPersistence}
prepare={o.prepare ?? (async () => null)}
onUpgrade={o.onUpgrade}
@@ -350,7 +361,8 @@ const typeInto = (input: HTMLInputElement, v: string): void =>
Object.getOwnPropertyDescriptor(HTMLInputElement.prototype, 'value')!.set!.call(input, v)
input.dispatchEvent(new Event('input', { bubbles: true }))
})
-const warning = (): string | null => document.querySelector('.live-dialog__warning')?.textContent ?? null
+const warnings = (): string[] => [...document.querySelectorAll('.live-dialog__warning')].map((e) => e.textContent ?? '')
+const warning = (): string | null => warnings()[0] ?? null
const createWith = (over: Partial<CreateWatchLinkRequest> = {}): CreateWatchLinkResult => ({
ok: true,
link: {
@@ -362,23 +374,35 @@ const createWith = (over: Partial<CreateWatchLinkRequest> = {}): CreateWatchLink
})
describe('LiveLinkDialog — Control', () => {
- it('Control shows the password field with Generate, and its own warning in place of the watch warning', async () => {
+ it('Control shows the password field with Generate, and BOTH warnings: what watching exposes, then typing', async () => {
mount()
await flush()
expect(pwInput()).toBeNull()
- expect(warning()).toBe(LIVE_LINK_WARNING)
+ expect(warnings()).toEqual([LIVE_LINK_WARNING])
pick('Control')
const input = pwInput()!
expect(input.type).toBe('text')
expect(input.getAttribute('autocomplete')).toBe('off')
expect(input.getAttribute('spellcheck')).toBe('false')
expect(input.maxLength).toBe(128)
- expect(warning()).toBe(CONTROL_WARNING)
+ // Anyone with the link alone still WATCHES a Control link: that warning stays (minus the
+ // sentence a Control link makes false), and the typing warning comes under it.
+ expect(warnings()).toEqual([LIVE_LINK_EXPOSURE, controlWarningText('this computer')])
+ expect(document.querySelectorAll('.live-dialog__warning')[1].querySelector('strong')!.textContent).toBe('and')
expect(btn('Generate')).toBeTruthy()
- // Back to Viewer: the watch warning again, no password field.
+ // Back to Viewer: the watch warning alone again, no password field.
pick('Viewer')
expect(pwInput()).toBeNull()
- expect(warning()).toBe(LIVE_LINK_WARNING)
+ expect(warnings()).toEqual([LIVE_LINK_WARNING])
+ })
+
+ it("an SSH project's node: the typing warning names the host its shell runs on", async () => {
+ mount({ remoteNode: true, sshTarget: { user: 'ada', host: 'build.example' } })
+ await flush()
+ pick('Control')
+ expect(warnings()[1]).toBe(controlWarningText('[email protected]'))
+ expect(warnings()[1]).toContain('running any command on [email protected];')
+ expect(warnings()[1]).not.toContain('this computer')
})
it('Generate fills 16 symbols from crypto.getRandomValues', async () => {
diff --git a/src/renderer/components/LiveLinkDialog.tsx b/src/renderer/components/LiveLinkDialog.tsx
index fc92e8e21..484bf32bd 100644
--- a/src/renderer/components/LiveLinkDialog.tsx
+++ b/src/renderer/components/LiveLinkDialog.tsx
@@ -16,10 +16,12 @@ import { useDialogStack } from './dialog-stack'
import {
capUnits,
CONTROL_UNSUPPORTED_REASON,
- CONTROL_WARNING,
+ controlWarning,
+ controlWarningMachine,
createErrorMessage,
DEFAULT_TTL,
formatUntil,
+ LIVE_LINK_EXPOSURE,
LIVE_LINK_WARNING,
PASSWORD_SEPARATE_NOTE,
PASSWORD_SHOWN_ONCE,
@@ -76,6 +78,18 @@ export function PasswordField(p: {
)
}
+/** Spec §2.7's typing warning, its "and" stressed. Text only: the machine is our own wording. */
+function ControlWarning({ machine }: { machine: string }): React.JSX.Element {
+ const [before, and, after] = controlWarning(machine)
+ return (
+ <p className="live-dialog__warning">
+ {before}
+ <strong>{and}</strong>
+ {after}
+ </p>
+ )
+}
+
export type DialogState =
| {
phase: 'form'
@@ -120,6 +134,9 @@ export function LiveLinkDialogBody(p: {
/** `watchLink.controlSupport` said this node's terminal cannot take typed input (a Zellij session):
* Control is shown disabled, with its reason. Absent / false: offered (unknown is offered too). */
controlUnsupported?: boolean
+ /** Where a controller's commands would run, for the typing warning (`controlWarningMachine`).
+ * Absent: this machine. */
+ controlMachine?: string
/** 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
@@ -238,7 +255,10 @@ export function LiveLinkDialogBody(p: {
onChange={(e) => p.onChange({ ...s, label: e.target.value })}
/>
</label>
- <p className="live-dialog__warning">{control ? CONTROL_WARNING : LIVE_LINK_WARNING}</p>
+ {/* Always what WATCHING exposes. A Control link is watched by anyone with the link alone, so
+ its warning keeps that (minus "They can't type", which it makes false) and adds typing. */}
+ <p className="live-dialog__warning">{control ? LIVE_LINK_EXPOSURE : LIVE_LINK_WARNING}</p>
+ {control && <ControlWarning machine={p.controlMachine ?? controlWarningMachine(null)} />}
{p.whileOpenNote && <p className="live-dialog__note">{p.whileOpenNote}</p>}
{s.error && (
<p className="live-dialog__error" role="alert">
@@ -271,6 +291,7 @@ export function LiveLinkDialog({
title,
surface,
remoteNode = false,
+ sshTarget,
readPersistence,
prepare,
onUpgrade,
@@ -282,6 +303,9 @@ export function LiveLinkDialog({
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
+ /** That SSH project's server, so the Control warning names the machine a controller's commands
+ * run on (`user@host`). Absent: a local node — this machine. */
+ sshTarget?: { user: string; host: string } | null
/** R63: the LOCAL core's session-protection status (`localSession.api.pty.tmuxStatus` — the core that
* creates the link, never a relay peer's). Absent, rejected or unreadable: no note (unknown claims
* nothing). */
@@ -460,6 +484,7 @@ export function LiveLinkDialog({
onCopyPassword={copyPassword}
onUpgrade={onUpgrade}
controlUnsupported={controlUnsupported}
+ controlMachine={controlWarningMachine(sshTarget)}
/>
</div>,
document.body
diff --git a/src/renderer/components/LiveLinkPopover.tsx b/src/renderer/components/LiveLinkPopover.tsx
index 0fc68c495..61ec3c7cb 100644
--- a/src/renderer/components/LiveLinkPopover.tsx
+++ b/src/renderer/components/LiveLinkPopover.tsx
@@ -1,4 +1,4 @@
-import { memo, useEffect, useRef, useState } from 'react'
+import { createContext, memo, useCallback, useContext, useEffect, useRef, useState } from 'react'
import { createPortal } from 'react-dom'
import type { NodeTerminalApi } from '@shared/types'
import type { WatchLinkControlView, WatchLinkRole, WatchLinkView } from '@shared/watch-link-types'
@@ -98,6 +98,15 @@ function commentTarget(nodeId: string): { projectId: string; api: NodeTerminalAp
return null
}
+/**
+ * Something inside the popover the owner must still be shown — a new Control password whose save is
+ * in flight: once core takes it, its plaintext exists nowhere else, so a popover closed under it
+ * would lose a password that was changed. `hold()` keeps the popover from closing on an outside
+ * click, Escape or Open chat until the returned release runs. The link going away still closes it
+ * (nothing is owed for a link that no longer exists). Absent (the drawer): nothing to hold.
+ */
+const PopoverHold = createContext<(() => () => void) | null>(null)
+
/** The roles whose viewers can chat: a Control link is a Commenter link plus typing (spec §2.1). */
export function hasChat(role: WatchLinkRole): boolean {
return role === 'commenter' || role === 'controller'
@@ -127,17 +136,35 @@ export function LiveLinkPopover({
const now = useNow(30_000)
// Below the chip; above it when there is no room below (the dropdown case of useMenuFlip).
const flip = useMenuFlip(anchor.bottom + 6, anchor.left, anchor.top - 6)
+ // Holds (see `PopoverHold`): a counter, not state — nothing renders from it.
+ const holds = useRef(0)
+ const hold = useCallback((): (() => void) => {
+ holds.current++
+ let released = false
+ return () => {
+ if (released) return
+ released = true
+ holds.current--
+ }
+ }, [])
+ /** Close unless something is held; says whether it closed. Every owner gesture comes here. */
+ const requestClose = useCallback((): boolean => {
+ if (holds.current > 0) return false
+ onClose()
+ return true
+ }, [onClose])
useEffect(() => {
const onKey = (e: KeyboardEvent): void => {
if (e.key !== 'Escape' || !isTop()) return
+ // Swallowed even while held: the Escape was meant for the popover, not what is behind it.
e.preventDefault()
e.stopPropagation()
- onClose()
+ requestClose()
}
// Capture phase: beat the canvas/global keydown listeners (and xterm) to the Escape.
window.addEventListener('keydown', onKey, true)
return () => window.removeEventListener('keydown', onKey, true)
- }, [isTop, onClose])
+ }, [isTop, requestClose])
useEffect(() => {
if (links.length === 0) onClose()
}, [links.length, onClose])
@@ -158,12 +185,12 @@ export function LiveLinkPopover({
className="live-pop__scrim"
onClick={(e) => {
e.stopPropagation()
- onClose()
+ requestClose()
}}
onContextMenu={(e) => {
e.preventDefault()
e.stopPropagation()
- onClose()
+ requestClose()
}}
/>
<div
@@ -175,9 +202,11 @@ export function LiveLinkPopover({
aria-label="Live links"
tabIndex={-1}
>
- {links.map((l) => (
- <LinkBlock key={l.linkId} link={l} now={now} nodeId={nodeId} onClose={onClose} />
- ))}
+ <PopoverHold.Provider value={hold}>
+ {links.map((l) => (
+ <LinkBlock key={l.linkId} link={l} now={now} nodeId={nodeId} requestClose={requestClose} />
+ ))}
+ </PopoverHold.Provider>
</div>
</>,
document.body
@@ -188,12 +217,13 @@ const LinkBlock = memo(function LinkBlock({
link,
now,
nodeId,
- onClose
+ requestClose
}: {
link: WatchLinkView
now: number
nodeId: string
- onClose: () => void
+ /** Close the popover unless something in it is held; true when it closed. */
+ requestClose: () => boolean
}): React.JSX.Element {
const api = window.nodeTerminal.watchLink
const [copied, setCopied] = useState(false)
@@ -238,9 +268,10 @@ const LinkBlock = memo(function LinkBlock({
type="button"
className="confirm__btn live-pop__btn"
onClick={() => {
- // The Live chat drawer (Task 8) listens; the popover gives way to it.
+ // The Live chat drawer (Task 8) listens; the popover gives way to it — unless a new
+ // password is still on its way to being shown here.
+ if (!requestClose()) return
window.dispatchEvent(new CustomEvent('nodeterm:live-chat', { detail: { linkId: link.linkId } }))
- onClose()
}}
>
Open chat
@@ -318,7 +349,10 @@ const LinkBlock = memo(function LinkBlock({
*/
export function ControlSection({ linkId, control }: { linkId: string; control: WatchLinkControlView }): React.JSX.Element {
const api = window.nodeTerminal.watchLink
+ const hold = useContext(PopoverHold)
const [busy, setBusy] = useState(false)
+ /** A password save is in flight: the popover holds open, Save reads "Saving…". */
+ const [saving, setSaving] = useState(false)
const [error, setError] = useState<string | null>(null)
const [editing, setEditing] = useState(false)
const [draft, setDraft] = useState('')
@@ -329,7 +363,10 @@ export function ControlSection({ linkId, control }: { linkId: string; control: W
const t = setTimeout(() => setCopied(false), 1500)
return () => clearTimeout(t)
}, [copied])
- const run = (call: () => Promise<boolean>, failed: string, done?: () => void): void => {
+ // A hold this section took and has not released — released on unmount too (the link went away).
+ const releaseRef = useRef<(() => void) | null>(null)
+ useEffect(() => () => releaseRef.current?.(), [])
+ const run = (call: () => Promise<boolean>, failed: string, done?: () => void, settled?: () => void): void => {
setBusy(true)
setError(null)
void Promise.resolve()
@@ -338,7 +375,10 @@ export function ControlSection({ linkId, control }: { linkId: string; control: W
(ok) => (ok ? done?.() : setError(failed)),
() => setError(failed)
)
- .finally(() => setBusy(false))
+ .finally(() => {
+ setBusy(false)
+ settled?.()
+ })
}
const problem = passwordProblemText(draft)
return (
@@ -424,6 +464,9 @@ export function ControlSection({ linkId, control }: { linkId: string; control: W
disabled={busy || problem !== null}
onClick={() => {
const next = draft
+ // Hold the popover open until the answer is in and, on success, shown.
+ releaseRef.current = hold?.() ?? null
+ setSaving(true)
run(
() => api.setPassword(linkId, next),
PASSWORD_CHANGE_FAILED_MESSAGE,
@@ -431,11 +474,16 @@ export function ControlSection({ linkId, control }: { linkId: string; control: W
setShown(next)
setDraft('')
setEditing(false)
+ },
+ () => {
+ setSaving(false)
+ releaseRef.current?.()
+ releaseRef.current = null
}
)
}}
>
- Save
+ {saving ? 'Saving…' : 'Save'}
</button>
</div>
</>
diff --git a/src/renderer/components/settings/sections/LiveLinksSection.test.tsx b/src/renderer/components/settings/sections/LiveLinksSection.test.tsx
index 5a888c224..82fc03fea 100644
--- a/src/renderer/components/settings/sections/LiveLinksSection.test.tsx
+++ b/src/renderer/components/settings/sections/LiveLinksSection.test.tsx
@@ -143,11 +143,13 @@ describe('LiveLinksSection', () => {
expect(rows).toHaveLength(4)
expect(rows[0].textContent).toContain('build')
expect(rows[0].textContent).toContain('Alpha')
- expect(rows[0].textContent).toContain('Can watch and chat')
+ // The role by its name (ruling 4), as the create dialog and the popover name it.
+ expect(rows[0].textContent).toContain('Commenter · 2 watching')
+ expect(rows[0].textContent).not.toContain('Can watch')
expect(rows[0].textContent).toContain('2 watching')
expect(rows[0].textContent).toContain('ends in 42 min')
expect(rows[1].textContent).toContain('Parked (closed)')
- expect(rows[1].textContent).toContain('Can watch')
+ expect(rows[1].textContent).toContain('Viewer · 0 watching')
expect(rows[2].textContent).toContain('not in an open project')
// A relay tab's project with the same node id is another machine's: never named for our link.
expect(rows[3].textContent).toContain('not in an open project')
@@ -155,6 +157,13 @@ describe('LiveLinksSection', () => {
expect(host.innerHTML).not.toContain('SECRET')
})
+ it('a Control link reads "Control", and an Unlimited one has no end time', () => {
+ render()
+ setLinks([link({ role: 'controller', control: { enabled: true, locked: false }, expiresAt: null, viewers: [] })])
+ const row = host.querySelector<HTMLElement>('.live-settings__row')!
+ expect(row.textContent).toContain('Control · 0 watching · No end time')
+ })
+
// D2/M2: closing a relay tab unbinds its session, so its source reads LOCAL — but it is still the
// other machine's canvas, and its copy of a git-shared node id is not this machine's node.
it("never names a CLOSED relay tab's project for this machine's link", () => {
diff --git a/src/renderer/components/settings/sections/LiveLinksSection.tsx b/src/renderer/components/settings/sections/LiveLinksSection.tsx
index ec1d48009..d639f7924 100644
--- a/src/renderer/components/settings/sections/LiveLinksSection.tsx
+++ b/src/renderer/components/settings/sections/LiveLinksSection.tsx
@@ -12,7 +12,7 @@ import { useWatchLinks } from '../../../state/watchLinks'
import {
formatRemaining,
NOT_IN_OPEN_PROJECT,
- ROLE_LABEL,
+ ROLE_NAME,
SERVER_EDITION_UNSUPPORTED,
showsStopAll,
statusLine,
@@ -67,7 +67,7 @@ function LinkRow({ link, now, projects }: { link: WatchLinkView; now: number; pr
<span className="text-muted"> · {liveLinkProjectLabel(projects, link.nodeId)}</span>
</div>
<div className="text-xs text-muted">
- {ROLE_LABEL[link.role]} · {link.viewers.length} watching · {formatRemaining(link.expiresAt, now)}
+ {ROLE_NAME[link.role]} · {link.viewers.length} watching · {formatRemaining(link.expiresAt, now)}
</div>
{status && <div className="text-xs text-muted">{status}</div>}
{error && (
diff --git a/src/renderer/lib/liveLink.test.ts b/src/renderer/lib/liveLink.test.ts
index b0fdc4364..e11b12f6c 100644
--- a/src/renderer/lib/liveLink.test.ts
+++ b/src/renderer/lib/liveLink.test.ts
@@ -32,8 +32,11 @@ import {
viewerName,
CONTROL_LOCKED_TEXT,
CONTROL_UNSUPPORTED_REASON,
- CONTROL_WARNING,
+ controlWarning,
+ controlWarningMachine,
+ controlWarningText,
controlTakenText,
+ LIVE_LINK_EXPOSURE,
liveLinkNoticeEffect,
PASSWORD_SEPARATE_NOTE,
PASSWORD_SHOWN_ONCE,
@@ -381,10 +384,21 @@ describe('the create warning', () => {
describe('Control and Unlimited copy', () => {
it('is the exact ruled text', () => {
- // Spec §2.7, verbatim.
- expect(CONTROL_WARNING).toBe(
- 'Anyone with this link and the password can type in this terminal as you. In a shell that means running any command on this machine; in an agent session, giving the agent any instruction. Send the password separately from the link.'
+ // Spec §2.7, with the machine named truthfully (ruling 2): this machine's noun for a local node…
+ expect(controlWarningText(controlWarningMachine(null))).toBe(
+ 'Anyone with this link and the password can type in this terminal as you. In a shell that means running any command on this computer; in an agent session, giving the agent any instruction. Send the password separately from the link.'
)
+ // …and the host for an SSH project's node, whose shell runs there.
+ expect(controlWarningText(controlWarningMachine({ user: 'ada', host: 'build.example' }))).toBe(
+ 'Anyone with this link and the password can type in this terminal as you. In a shell that means running any command on [email protected]; in an agent session, giving the agent any instruction. Send the password separately from the link.'
+ )
+ // "and" is the emphasised word: the parts say where it is.
+ expect(controlWarning('x')[1]).toBe('and')
+ expect(controlWarning('x').join('')).toBe(controlWarningText('x'))
+ // A Control link still shows what WATCHING exposes — without the sentence a Control link makes false.
+ expect(LIVE_LINK_WARNING.startsWith(LIVE_LINK_EXPOSURE)).toBe(true)
+ expect(LIVE_LINK_WARNING).toBe(`${LIVE_LINK_EXPOSURE} They can't type or resize it.`)
+ expect(LIVE_LINK_EXPOSURE).not.toMatch(/type/)
expect(PASSWORD_SEPARATE_NOTE).toBe('Send the password separately from the link.')
expect(PASSWORD_SHOWN_ONCE).toBe(
'This is the only time the password is shown. Change it later from the LIVE chip.'
@@ -404,6 +418,15 @@ describe('Control and Unlimited copy', () => {
})
})
+describe('controlWarningMachine', () => {
+ it("names the SSH host as user@host, bidi stripped; a host alone without a user; else this machine's noun", () => {
+ expect(controlWarningMachine(undefined)).toBe('this computer')
+ expect(controlWarningMachine({ user: 'ada', host: 'build.example' })).toBe('[email protected]')
+ expect(controlWarningMachine({ user: '', host: 'build.example' })).toBe('build.example')
+ expect(controlWarningMachine({ user: 'a\u202eda', host: 'bu\u2066ild' })).toBe('ada@build')
+ })
+})
+
describe('who is typing', () => {
const typing = (id: string, name: string | null) => ({ ...viewer(id), name, controlling: true, typing: true })
diff --git a/src/renderer/lib/liveLink.ts b/src/renderer/lib/liveLink.ts
index f75f7db76..d6a69f3e4 100644
--- a/src/renderer/lib/liveLink.ts
+++ b/src/renderer/lib/liveLink.ts
@@ -59,15 +59,39 @@ export const UNLIMITED_NOTE = 'This link works until you stop it.'
* 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), 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 LIVE_LINK_EXPOSURE =
+ "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."
+export const LIVE_LINK_WARNING = `${LIVE_LINK_EXPOSURE} 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.'
-/** The create dialog's warning while Control is picked, in place of `LIVE_LINK_WARNING` — spec §2.7,
- * verbatim. "This machine" is the neutral noun: no brand is assumed (lib/machineName). */
-export const CONTROL_WARNING =
- 'Anyone with this link and the password can type in this terminal as you. In a shell that means running any command on this machine; in an agent session, giving the agent any instruction. Send the password separately from the link.'
+/**
+ * The create dialog's typing warning while Control is picked — spec §2.7, with the machine named
+ * truthfully. It is shown UNDER `LIVE_LINK_EXPOSURE`, never instead of it: a Control link is a
+ * Commenter link plus typing, so anyone with the link alone still watches. Three parts so the
+ * dialog can stress the middle one ("and"); `controlWarningText` is the same words as one string.
+ */
+export function controlWarning(machine: string): [string, string, string] {
+ return [
+ 'Anyone with this link ',
+ 'and',
+ ` the password can type in this terminal as you. In a shell that means running any command on ${machine}; in an agent session, giving the agent any instruction. Send the password separately from the link.`
+ ]
+}
+export function controlWarningText(machine: string): string {
+ return controlWarning(machine).join('')
+}
+/**
+ * Where a controller's commands run, for the typing warning: an SSH project's node runs its shell on
+ * the HOST (`user@host`, bidi-stripped — a project's SSH config is the user's own, but it is still
+ * shown as text); any other node on this machine, named through lib/machineName.
+ */
+export function controlWarningMachine(ssh: { user: string; host: string } | null | undefined): string {
+ if (!ssh) return thisMachine()
+ const host = stripBidiControls(ssh.host)
+ const user = stripBidiControls(ssh.user)
+ return user ? `${user}@${host}` : host
+}
/** Beside a password shown once (the create dialog's done step, a changed password in the popover). */
export const PASSWORD_SEPARATE_NOTE = 'Send the password separately from the link.'
/** Core keeps only a hash (spec §2.2): there is no "show again". */
diff --git a/src/renderer/styles.css b/src/renderer/styles.css
index 4b6fa5328..7a0f133b5 100644
--- a/src/renderer/styles.css
+++ b/src/renderer/styles.css
@@ -11945,6 +11945,8 @@ button.pull-checks__name {
color: var(--text);
font-size: 12px;
line-height: 1.45;
+ /* The Control warning can name a long user@host, which has no break points. */
+ overflow-wrap: anywhere;
}
.live-dialog__error {
margin: 0 0 10px;