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): the right machine for remote nodes, popover focus and small cleanups

reviewd4162b1cfa24
diff --git a/src/renderer/canvas/Canvas.tsx b/src/renderer/canvas/Canvas.tsx
index 931067894..6d65caf41 100644
--- a/src/renderer/canvas/Canvas.tsx
+++ b/src/renderer/canvas/Canvas.tsx
@@ -251,6 +251,7 @@ import {
liveLinkCommands,
liveLinkMenuItemsFor,
liveLinkPrepare,
+ liveLinkRemoteFacts,
openLiveLink,
stopAllConfirm,
stopAllLiveLinks,
@@ -3749,6 +3750,21 @@ export function Canvas() {
/** R63: the create dialog's "only while open" note reads the LOCAL core's session protection — the
* core that hosts the link (never a relay tab's peer). Stable, so the dialog reads it once. */
const readLocalPersistence = useCallback(() => localSession.api.pty.tmuxStatus(), [])
+ /** Where the dialog's node runs — R63 (`remoteNode`) and the machine the Control warning names
+ * (`sshTarget`) — from the NODE's own SSH binding first, then its project's (lib/liveLinkEntry).
+ * The node is read from the live canvas for the active project, else the stored copy. */
+ const liveLinkRemoteFor = useCallback((target: LiveLinkTarget) => {
+ const store = useProjects.getState()
+ const project = store.getProject(target.projectId)
+ return liveLinkRemoteFacts({
+ nodeId: target.nodeId,
+ projectId: target.projectId,
+ activeProjectId: store.activeProjectId,
+ live: nodesRef.current,
+ stored: project?.nodes,
+ projectSsh: project?.ssh?.server
+ })
+ }, [])
/** R48: "Stop all" revokes every link of the LICENSE — other machines' included — and cannot be
* undone, so the palette asks first, with the same sentence and danger button as Settings. R62:
@@ -19321,11 +19337,10 @@ 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}
- // The Control warning names where a controller's commands run: the SSH host, else here.
- sshTarget={useProjects.getState().getProject(liveLinkDialog.projectId)?.ssh?.server ?? null}
+ // R63: a node in a HOST's tmux gets a viewer client of its own (the "only while open" note
+ // is about this machine's local terminals); the Control warning names where a
+ // controller's commands run. Both from where the NODE runs, not only its project.
+ {...liveLinkRemoteFor(liveLinkDialog)}
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 9bd7c5f71..80f188032 100644
--- a/src/renderer/canvas/live-link-wiring.test.ts
+++ b/src/renderer/canvas/live-link-wiring.test.ts
@@ -61,10 +61,16 @@ 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}')
- // …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}')
+ it("R63 and the Control warning: where the NODE runs — its own SSH binding, then its project's", () => {
+ // One decision (lib/liveLinkEntry, behaviour-tested there) gives the dialog both facts: a node
+ // attached to an SSH host in a LOCAL project, or a standalone ssh node, is not "this machine".
+ expect(src).toContain('{...liveLinkRemoteFor(liveLinkDialog)}')
+ const remote = callback('liveLinkRemoteFor')
+ expect(remote).toContain('liveLinkRemoteFacts({')
+ expect(remote).toContain('live: nodesRef.current,')
+ expect(remote).toContain('stored: project?.nodes,')
+ expect(remote).toContain('projectSsh: project?.ssh?.server')
+ expect(src).not.toContain('remoteNode={!!useProjects.getState().getProject(liveLinkDialog.projectId)?.ssh}')
// …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 a17bc0916..cd32a38cd 100644
--- a/src/renderer/components/LiveLinkChip.test.tsx
+++ b/src/renderer/components/LiveLinkChip.test.tsx
@@ -736,6 +736,90 @@ describe('LiveLinkPopover — a Control link', () => {
expect(pop()).toBeNull()
})
+ it('keyboard focus follows the Change password flow', async () => {
+ render(<LiveLinkChip nodeId="n1" source="local" />)
+ setLinks([controller()])
+ click(chip()!)
+ const field = (): HTMLInputElement => pop()!.querySelector<HTMLInputElement>('.live-pop__password input')!
+ // Entering the flow: the new field.
+ click(button('Change password…'))
+ expect(document.activeElement).toBe(field())
+ // Cancel: back to "Change password…".
+ click(button('Cancel'))
+ expect(document.activeElement).toBe(button('Change password…'))
+ // Saved: Copy password, the one thing to do next.
+ click(button('Change password…'))
+ typeInto(field(), 'longenough1')
+ click(button('Save'))
+ await flush()
+ expect(document.activeElement).toBe(button('Copy password'))
+ // Done: back to "Change password…".
+ click(button('Done'))
+ expect(document.activeElement).toBe(button('Change password…'))
+ })
+
+ it('the validation line is tied to the field (aria-describedby)', () => {
+ render(<LiveLinkChip nodeId="n1" source="local" />)
+ setLinks([controller()])
+ click(chip()!)
+ click(button('Change password…'))
+ const field = pop()!.querySelector<HTMLInputElement>('.live-pop__password input')!
+ typeInto(field, 'short')
+ const id = field.getAttribute('aria-describedby')!
+ expect(document.getElementById(id)!.textContent).toBe('Use at least 8 characters.')
+ typeInto(field, 'longenough1')
+ expect(field.hasAttribute('aria-describedby')).toBe(false)
+ })
+
+ it('the Typing switch stays focusable while a change is in flight, and ignores clicks then', async () => {
+ let answer!: (ok: boolean) => void
+ api.setControl.mockImplementationOnce(() => new Promise<boolean>((r) => (answer = r)))
+ render(<LiveLinkChip nodeId="n1" source="local" />)
+ setLinks([controller()])
+ click(chip()!)
+ const sw = (): HTMLButtonElement => pop()!.querySelector<HTMLButtonElement>('[role="switch"]')!
+ act(() => sw().focus())
+ click(sw())
+ await flush()
+ expect(sw().disabled).toBe(false)
+ expect(sw().getAttribute('aria-disabled')).toBe('true')
+ expect(document.activeElement).toBe(sw())
+ click(sw())
+ await flush()
+ expect(api.setControl).toHaveBeenCalledTimes(1)
+ await act(async () => answer(true))
+ expect(sw().hasAttribute('aria-disabled')).toBe(false)
+ click(sw())
+ await flush()
+ expect(api.setControl).toHaveBeenCalledTimes(2)
+ })
+
+ it('a password save that never settles lets the popover go after 30 s, and says what to check', 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')
+ vi.useFakeTimers()
+ try {
+ click(button('Save'))
+ await act(async () => {})
+ act(() => vi.advanceTimersByTime(29_999))
+ click(document.querySelector('.live-pop__scrim')!)
+ expect(pop()).not.toBeNull()
+ act(() => vi.advanceTimersByTime(1))
+ expect(pop()!.querySelector('[role="alert"]')!.textContent).toBe(
+ "Couldn't confirm the new password. Check the link before sharing it."
+ )
+ expect(button('Save')).toBeTruthy()
+ click(document.querySelector('.live-pop__scrim')!)
+ expect(pop()).toBeNull()
+ } finally {
+ vi.useRealTimers()
+ }
+ })
+
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 110f2d448..ae0185295 100644
--- a/src/renderer/components/LiveLinkDialog.test.tsx
+++ b/src/renderer/components/LiveLinkDialog.test.tsx
@@ -49,7 +49,7 @@ 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 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 })
+ const html = body({ phase: 'done', role: 'viewer', 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')
@@ -60,7 +60,7 @@ describe('LiveLinkDialogBody', () => {
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 })
+ const html = body({ phase: 'done', role: 'viewer', 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)}.`)
})
@@ -396,6 +396,29 @@ describe('LiveLinkDialog — Control', () => {
expect(warnings()).toEqual([LIVE_LINK_WARNING])
})
+ it('the validation line is tied to the password field (aria-describedby)', async () => {
+ mount()
+ await flush()
+ setLabel('Ada')
+ pick('Control')
+ expect(pwInput()!.hasAttribute('aria-describedby')).toBe(false)
+ typeInto(pwInput()!, 'short')
+ const id = pwInput()!.getAttribute('aria-describedby')!
+ expect(document.getElementById(id)!.textContent).toBe('Use at least 8 characters.')
+ expect(document.getElementById(id)!.className).toContain('live-dialog__invalid')
+ typeInto(pwInput()!, 'longenough1')
+ expect(pwInput()!.hasAttribute('aria-describedby')).toBe(false)
+ })
+
+ it('a disabled Control choice is described by its reason', async () => {
+ api.controlSupport.mockResolvedValue('unsupported')
+ mount()
+ await flush()
+ const id = radio('Control').getAttribute('aria-describedby')!
+ expect(document.getElementById(id)!.textContent).toBe(CONTROL_UNSUPPORTED_REASON)
+ expect(radio('Viewer').hasAttribute('aria-describedby')).toBe(false)
+ })
+
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()
@@ -595,8 +618,19 @@ describe('LiveLinkDialog — Unlimited', () => {
)
})
+ it('the done step tells Control apart by its ROLE', () => {
+ const done = { phase: 'done', url: 'https://nodeterm.dev/s/x#1.y', linkId: 'x', expiresAt: null } as const
+ const control = body({ ...done, role: 'controller', password: 'longenough1' })
+ expect(control).toContain('Anyone with this link and the password can type until you stop it.')
+ expect(control).toContain('live-dialog__password')
+ // A password on a non-Control state (none is ever built) shows nothing of it.
+ const watch = body({ ...done, role: 'viewer', password: 'longenough1' })
+ expect(watch).toContain('Anyone with this link can watch until you stop it.')
+ expect(watch).not.toContain('longenough1')
+ })
+
it('the done step of an Unlimited watch link says until it is stopped', () => {
- const html = body({ phase: 'done', url: 'https://nodeterm.dev/s/x#1.y', linkId: 'x', expiresAt: null })
+ const html = body({ phase: 'done', role: 'viewer', url: 'https://nodeterm.dev/s/x#1.y', linkId: 'x', expiresAt: null })
expect(html).toContain('Anyone with this link can watch until you stop it.')
expect(html).not.toContain('live-dialog__password')
})
diff --git a/src/renderer/components/LiveLinkDialog.tsx b/src/renderer/components/LiveLinkDialog.tsx
index 484bf32bd..850766f23 100644
--- a/src/renderer/components/LiveLinkDialog.tsx
+++ b/src/renderer/components/LiveLinkDialog.tsx
@@ -10,9 +10,10 @@
// A Control link's PASSWORD is plaintext only in this component's state: typed or generated in the
// form, shown once in the done step, and dropped on every close (`dismiss`) and with the component.
// It is never written to localStorage, settings, a log or a notice; core keeps only its hash.
-import { useCallback, useEffect, useRef, useState } from 'react'
+import { useCallback, useEffect, useId, useRef, useState } from 'react'
import { createPortal } from 'react-dom'
import { useDialogStack } from './dialog-stack'
+import { newControlPassword, PasswordField, useCopied } from './LiveLinkPassword'
import {
capUnits,
CONTROL_UNSUPPORTED_REASON,
@@ -45,38 +46,6 @@ import {
type WatchLinkRole,
type WatchLinkTtl
} from '@shared/watch-link-types'
-import { PASSWORD_MAX } from '@shared/watch-link/protocol'
-import { generateControlPassword } from '@shared/watch-link-password'
-
-/** Generate: 16 symbols from the platform CSPRNG (spec §2.2). */
-export function newControlPassword(): string {
- return generateControlPassword((n) => crypto.getRandomValues(new Uint8Array(n)))
-}
-
-/** The password field shared by the form and the done step (and, read-only, the popover's change). */
-export function PasswordField(p: {
- value: string
- readOnly?: boolean
- disabled?: boolean
- onChange?: (v: string) => void
- label?: string
-}): React.JSX.Element {
- return (
- <input
- className="confirm__input"
- type="text"
- autoComplete="off"
- spellCheck={false}
- maxLength={PASSWORD_MAX}
- aria-label={p.label ?? 'Password'}
- value={p.value}
- readOnly={p.readOnly}
- disabled={p.disabled}
- onFocus={p.readOnly ? (e) => e.currentTarget.select() : undefined}
- onChange={p.onChange ? (e) => p.onChange?.(e.target.value) : undefined}
- />
- )
-}
/** 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 {
@@ -109,14 +78,14 @@ export type DialogState =
}
| {
phase: 'done'
+ /** The link's role: the done step reads Control off THIS, never off whether a password is set. */
+ role: WatchLinkRole
url: string
linkId: string
/** null: an Unlimited link. */
expiresAt: number | null
/** A Control link's password, shown this once (core keeps only its hash). Absent otherwise. */
password?: string
- copied?: boolean
- passwordCopied?: boolean
stopping?: boolean
error?: string | null
}
@@ -130,6 +99,9 @@ export function LiveLinkDialogBody(p: {
onStop: (linkId: string) => void
onCopy?: (url: string) => void
onCopyPassword?: (password: string) => void
+ /** The "Copied!" flashes of the link's and the password's Copy buttons. */
+ copied?: boolean
+ passwordCopied?: boolean
onUpgrade?: () => void
/** `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). */
@@ -144,9 +116,13 @@ export function LiveLinkDialogBody(p: {
now?: number
}): React.JSX.Element {
const s = p.state
+ // Ids for aria-describedby: the password's validation line, and why Control is disabled.
+ const invalidId = useId()
+ const reasonId = useId()
// The title is the node's own (git-shared, hand-editable): shown as TEXT, bidi controls stripped.
const title = stripBidiControls(p.title)
if (s.phase === 'done') {
+ const control = s.role === 'controller'
return (
<div className="confirm live-dialog" onClick={(e) => e.stopPropagation()}>
<p className="confirm__msg live-dialog__title">Live link to {title}</p>
@@ -160,15 +136,15 @@ export function LiveLinkDialogBody(p: {
/>
{/* 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'}
+ {p.copied ? 'Copied!' : 'Copy'}
</button>
</div>
- {s.password !== undefined && (
+ {control && (
<>
<div className="live-dialog__url live-dialog__password">
- <PasswordField value={s.password} readOnly />
+ <PasswordField value={s.password ?? ''} readOnly />
<button className="confirm__btn" onClick={() => p.onCopyPassword?.(s.password ?? '')}>
- {s.passwordCopied ? 'Copied!' : 'Copy password'}
+ {p.passwordCopied ? 'Copied!' : 'Copy password'}
</button>
</div>
<p className="live-dialog__note live-dialog__note--tight">{PASSWORD_SHOWN_ONCE}</p>
@@ -176,7 +152,7 @@ export function LiveLinkDialogBody(p: {
</>
)}
<p className="live-dialog__note">
- {s.password !== undefined
+ {control
? `Anyone with this link and the password can type until ${formatUntil(s.expiresAt, p.now ?? Date.now())}.`
: `Anyone with this link can watch until ${formatUntil(s.expiresAt, p.now ?? Date.now())}.`}
</p>
@@ -198,6 +174,8 @@ export function LiveLinkDialogBody(p: {
}
const control = s.role === 'controller'
const problem = control ? passwordProblemText(s.password) : null
+ // Nothing nags an empty field: Create is disabled, which says enough until something is typed.
+ const showProblem = s.password !== '' && problem !== null
return (
<div className="confirm live-dialog" onClick={(e) => e.stopPropagation()}>
<p className="confirm__msg live-dialog__title">Share a live link to {title}</p>
@@ -212,24 +190,38 @@ export function LiveLinkDialogBody(p: {
name="live-role"
checked={s.role === r}
disabled={off}
+ aria-describedby={off ? reasonId : undefined}
onChange={() => p.onChange({ ...s, role: r })}
/>{' '}
{ROLE_NAME[r]} <span className="live-dialog__hint">· {ROLE_LABEL[r]}</span>
</label>
)
})}
- {p.controlUnsupported && <p className="live-dialog__reason">{CONTROL_UNSUPPORTED_REASON}</p>}
+ {p.controlUnsupported && (
+ <p className="live-dialog__reason" id={reasonId}>
+ {CONTROL_UNSUPPORTED_REASON}
+ </p>
+ )}
</fieldset>
{control && (
<div className="live-dialog__pw">
Password
<div className="live-dialog__url live-dialog__password">
- <PasswordField value={s.password} disabled={s.busy} onChange={(v) => p.onChange({ ...s, password: v })} />
+ <PasswordField
+ value={s.password}
+ disabled={s.busy}
+ describedBy={showProblem ? invalidId : undefined}
+ onChange={(v) => p.onChange({ ...s, password: v })}
+ />
<button className="confirm__btn" disabled={s.busy} onClick={() => p.onChange({ ...s, password: newControlPassword() })}>
Generate
</button>
</div>
- {s.password !== '' && problem && <p className="live-dialog__invalid">{problem}</p>}
+ {showProblem && (
+ <p className="live-dialog__invalid" id={invalidId}>
+ {problem}
+ </p>
+ )}
</div>
)}
<fieldset className="live-dialog__group" disabled={s.busy}>
@@ -329,8 +321,8 @@ export function LiveLinkDialog({
const stateRef = useRef(state)
stateRef.current = state
const isTop = useDialogStack()
- const copiedTimer = useRef<ReturnType<typeof setTimeout>>()
- useEffect(() => () => clearTimeout(copiedTimer.current), [])
+ const [copied, copy] = useCopied()
+ const [passwordCopied, copyPassword] = useCopied()
// 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)
@@ -427,6 +419,7 @@ export function LiveLinkDialog({
if (r.ok) {
setState({
phase: 'done',
+ role: form.role,
url: r.link.url,
linkId: r.link.linkId,
expiresAt: r.link.expiresAt,
@@ -450,24 +443,6 @@ export function LiveLinkDialog({
if (ok) onClose()
}
- const copy = (url: string): void => {
- window.nodeTerminal.clipboard.writeText(url)
- setState((s) => (s.phase === 'done' ? { ...s, copied: true } : s))
- clearTimeout(copiedTimer.current)
- copiedTimer.current = setTimeout(() => setState((s) => (s.phase === 'done' ? { ...s, copied: false } : s)), 1500)
- }
- const passwordCopiedTimer = useRef<ReturnType<typeof setTimeout>>()
- useEffect(() => () => clearTimeout(passwordCopiedTimer.current), [])
- const copyPassword = (password: string): void => {
- window.nodeTerminal.clipboard.writeText(password)
- setState((s) => (s.phase === 'done' ? { ...s, passwordCopied: true } : s))
- clearTimeout(passwordCopiedTimer.current)
- passwordCopiedTimer.current = setTimeout(
- () => setState((s) => (s.phase === 'done' ? { ...s, passwordCopied: false } : s)),
- 1500
- )
- }
-
return createPortal(
<div className="confirm-overlay" ref={panelRef} onClick={dismiss}>
<LiveLinkDialogBody
@@ -482,6 +457,8 @@ export function LiveLinkDialog({
onStop={(id) => void stop(id)}
onCopy={copy}
onCopyPassword={copyPassword}
+ copied={copied}
+ passwordCopied={passwordCopied}
onUpgrade={onUpgrade}
controlUnsupported={controlUnsupported}
controlMachine={controlWarningMachine(sshTarget)}
diff --git a/src/renderer/components/LiveLinkPassword.tsx b/src/renderer/components/LiveLinkPassword.tsx
new file mode 100644
index 000000000..78773f8c7
--- /dev/null
+++ b/src/renderer/components/LiveLinkPassword.tsx
@@ -0,0 +1,62 @@
+// A Control link's password field and its generator — shared by the create dialog, the chip's popover
+// and the Live chat drawer. The plaintext only ever lives in the state of the component that shows
+// it; nothing here stores, logs or announces it. Core keeps only a hash.
+import { useCallback, useEffect, useRef, useState, type Ref } from 'react'
+import { PASSWORD_MAX } from '@shared/watch-link/protocol'
+import { generateControlPassword } from '@shared/watch-link-password'
+
+/** Generate: 16 symbols from the platform CSPRNG (spec §2.2). */
+export function newControlPassword(): string {
+ return generateControlPassword((n) => crypto.getRandomValues(new Uint8Array(n)))
+}
+
+/** A password field: plain text (the owner must be able to read what they send), no autocomplete or
+ * spell check, capped at the unlock cast's limit. Read-only selects its text on focus. */
+export function PasswordField(p: {
+ value: string
+ readOnly?: boolean
+ disabled?: boolean
+ onChange?: (v: string) => void
+ label?: string
+ /** The id of the line that explains what is wrong with it (aria-describedby); absent when nothing is. */
+ describedBy?: string
+ inputRef?: Ref<HTMLInputElement>
+}): React.JSX.Element {
+ return (
+ <input
+ ref={p.inputRef}
+ className="confirm__input"
+ type="text"
+ autoComplete="off"
+ spellCheck={false}
+ maxLength={PASSWORD_MAX}
+ aria-label={p.label ?? 'Password'}
+ aria-describedby={p.describedBy}
+ value={p.value}
+ readOnly={p.readOnly}
+ disabled={p.disabled}
+ onFocus={p.readOnly ? (e) => e.currentTarget.select() : undefined}
+ onChange={p.onChange ? (e) => p.onChange?.(e.target.value) : undefined}
+ />
+ )
+}
+
+/** How long a copy button reads "Copied!". */
+export const COPIED_FLASH_MS = 1500
+
+/**
+ * A copy button's "Copied!" flash: `copy(text)` puts the text on the clipboard and flips `copied`
+ * for `COPIED_FLASH_MS`; a second copy restarts the flash. The timer dies with the component.
+ */
+export function useCopied(): [boolean, (text: string) => void] {
+ const [copied, setCopied] = useState(false)
+ const timer = useRef<ReturnType<typeof setTimeout>>()
+ useEffect(() => () => clearTimeout(timer.current), [])
+ const copy = useCallback((text: string) => {
+ window.nodeTerminal.clipboard.writeText(text)
+ setCopied(true)
+ clearTimeout(timer.current)
+ timer.current = setTimeout(() => setCopied(false), COPIED_FLASH_MS)
+ }, [])
+ return [copied, copy]
+}
diff --git a/src/renderer/components/LiveLinkPopover.tsx b/src/renderer/components/LiveLinkPopover.tsx
index 61ec3c7cb..0bad82203 100644
--- a/src/renderer/components/LiveLinkPopover.tsx
+++ b/src/renderer/components/LiveLinkPopover.tsx
@@ -1,11 +1,11 @@
-import { createContext, memo, useCallback, useContext, useEffect, useRef, useState } from 'react'
+import { createContext, memo, useCallback, useContext, useEffect, useId, 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'
import { stripBidiControls } from '@shared/watch-link-types'
import { CHAT_TEXT_MAX, type WatchChatMessage } from '@shared/watch-link/protocol'
import { useDialogStack } from './dialog-stack'
-import { newControlPassword, PasswordField } from './LiveLinkDialog'
+import { newControlPassword, PasswordField, useCopied } from './LiveLinkPassword'
import { useMenuFlip } from '../ui/useMenuFlip'
import { Switch } from '../ui/Switch'
import {
@@ -20,6 +20,8 @@ import {
KICK_NOTE,
PASSWORD_CHANGE_FAILED_MESSAGE,
PASSWORD_CHANGE_NOTE,
+ PASSWORD_SAVE_TIMEOUT_MS,
+ PASSWORD_UNCONFIRMED_MESSAGE,
PASSWORD_SEPARATE_NOTE,
PASSWORD_SHOWN_ONCE,
passwordProblemText,
@@ -226,15 +228,10 @@ const LinkBlock = memo(function LinkBlock({
requestClose: () => boolean
}): React.JSX.Element {
const api = window.nodeTerminal.watchLink
- const [copied, setCopied] = useState(false)
+ const [copied, copy] = useCopied()
const [error, setError] = useState<string | null>(null)
const status = statusLine(link)
const waiting = waitingViewers([link]) > 0
- useEffect(() => {
- if (!copied) return
- const t = setTimeout(() => setCopied(false), 1500)
- return () => clearTimeout(t)
- }, [copied])
return (
<section className="live-pop__link" data-link-id={link.linkId}>
<header className="live-pop__head">
@@ -256,10 +253,7 @@ const LinkBlock = memo(function LinkBlock({
<button
type="button"
className="confirm__btn live-pop__btn"
- onClick={() => {
- window.nodeTerminal.clipboard.writeText(link.url)
- setCopied(true)
- }}
+ onClick={() => copy(link.url)}
>
{copied ? 'Copied!' : 'Copy link'}
</button>
@@ -350,6 +344,7 @@ 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 invalidId = useId()
const [busy, setBusy] = useState(false)
/** A password save is in flight: the popover holds open, Save reads "Saving…". */
const [saving, setSaving] = useState(false)
@@ -357,30 +352,95 @@ export function ControlSection({ linkId, control }: { linkId: string; control: W
const [editing, setEditing] = useState(false)
const [draft, setDraft] = useState('')
const [shown, setShown] = useState<string | null>(null)
- const [copied, setCopied] = useState(false)
+ const [copied, copy] = useCopied()
+ // Keyboard focus follows the flow: the new field on entering it, Copy password once a new one is
+ // shown, "Change password…" again on Cancel or Done (whose button would otherwise take the focus
+ // with it as it unmounts). Applied after the render that mounts the target.
+ const [focusTo, setFocusTo] = useState<'field' | 'copy' | 'change' | null>(null)
+ const fieldRef = useRef<HTMLInputElement>(null)
+ const copyRef = useRef<HTMLButtonElement>(null)
+ const changeRef = useRef<HTMLButtonElement>(null)
useEffect(() => {
- if (!copied) return
- const t = setTimeout(() => setCopied(false), 1500)
- return () => clearTimeout(t)
- }, [copied])
- // A hold this section took and has not released — released on unmount too (the link went away).
+ if (!focusTo) return
+ const el = focusTo === 'field' ? fieldRef.current : focusTo === 'copy' ? copyRef.current : changeRef.current
+ el?.focus({ preventScroll: true })
+ setFocusTo(null)
+ }, [focusTo])
+ // A hold and a deadline this section took and has not given back — both go on unmount too (the
+ // link went away: nothing is owed for it).
const releaseRef = useRef<(() => void) | null>(null)
- useEffect(() => () => releaseRef.current?.(), [])
- const run = (call: () => Promise<boolean>, failed: string, done?: () => void, settled?: () => void): void => {
+ const deadlineRef = useRef<ReturnType<typeof setTimeout>>()
+ useEffect(
+ () => () => {
+ releaseRef.current?.()
+ clearTimeout(deadlineRef.current)
+ },
+ []
+ )
+ /** Which save is current: a late answer to an older one is not shown. */
+ const saveGen = useRef(0)
+ const run = (call: () => Promise<boolean>, failed: string): void => {
setBusy(true)
setError(null)
void Promise.resolve()
.then(call)
.then(
- (ok) => (ok ? done?.() : setError(failed)),
+ (ok) => !ok && setError(failed),
() => setError(failed)
)
- .finally(() => {
- setBusy(false)
- settled?.()
- })
+ .finally(() => setBusy(false))
+ }
+ /**
+ * Save a new password, holding the popover open until the answer is in and, on success, shown —
+ * its plaintext exists nowhere else. Bounded: with no answer after `PASSWORD_SAVE_TIMEOUT_MS` the
+ * hold is released and the owner is told the outcome is unknown. An answer that lands later still
+ * counts: a new password that did take is shown, one refused says so.
+ */
+ const save = (): void => {
+ const next = draft
+ const gen = ++saveGen.current
+ const release = hold?.() ?? null
+ releaseRef.current = release
+ let open = true
+ const settle = (): void => {
+ if (!open) return
+ open = false
+ clearTimeout(deadlineRef.current)
+ setSaving(false)
+ setBusy(false)
+ release?.()
+ if (releaseRef.current === release) releaseRef.current = null
+ }
+ setSaving(true)
+ setBusy(true)
+ setError(null)
+ deadlineRef.current = setTimeout(() => {
+ if (!open) return
+ settle()
+ setError(PASSWORD_UNCONFIRMED_MESSAGE)
+ }, PASSWORD_SAVE_TIMEOUT_MS)
+ void Promise.resolve()
+ .then(() => api.setPassword(linkId, next))
+ .then(
+ (ok) => {
+ settle()
+ if (gen !== saveGen.current) return
+ if (ok) {
+ setError(null)
+ setShown(next)
+ setDraft('')
+ setEditing(false)
+ setFocusTo('copy')
+ } else setError(PASSWORD_CHANGE_FAILED_MESSAGE)
+ },
+ () => {
+ settle()
+ if (gen === saveGen.current) setError(PASSWORD_CHANGE_FAILED_MESSAGE)
+ }
+ )
}
const problem = passwordProblemText(draft)
+ const showProblem = draft !== '' && problem !== null
return (
<div className="live-pop__control">
{control.locked && (
@@ -405,10 +465,11 @@ export function ControlSection({ linkId, control }: { linkId: string; control: W
{control.enabled ? 'Anyone with the password can type.' : 'Off: viewers can watch and chat.'}
</span>
</span>
+ {/* `pending`, not `disabled`: a switch the owner just toggled from the keyboard keeps the focus. */}
<Switch
checked={control.enabled}
ariaLabel="Typing"
- disabled={busy}
+ pending={busy}
onChange={(on) => run(() => api.setControl(linkId, on), CONTROL_CHANGE_FAILED_MESSAGE)}
/>
</div>
@@ -416,21 +477,21 @@ export function ControlSection({ linkId, control }: { linkId: string; control: W
<>
<div className="live-pop__password">
<PasswordField value={shown} readOnly label="New password" />
- <button
- type="button"
- className="confirm__btn live-pop__btn"
- onClick={() => {
- window.nodeTerminal.clipboard.writeText(shown)
- setCopied(true)
- }}
- >
+ <button type="button" ref={copyRef} className="confirm__btn live-pop__btn" onClick={() => copy(shown)}>
{copied ? 'Copied!' : 'Copy password'}
</button>
</div>
<p className="live-pop__muted live-pop__note">{PASSWORD_SHOWN_ONCE}</p>
<p className="live-pop__muted live-pop__note">{PASSWORD_SEPARATE_NOTE}</p>
<div className="live-pop__actions">
- <button type="button" className="confirm__btn live-pop__btn" onClick={() => setShown(null)}>
+ <button
+ type="button"
+ className="confirm__btn live-pop__btn"
+ onClick={() => {
+ setShown(null)
+ setFocusTo('change')
+ }}
+ >
Done
</button>
</div>
@@ -438,12 +499,23 @@ export function ControlSection({ linkId, control }: { linkId: string; control: W
) : editing ? (
<>
<div className="live-pop__password">
- <PasswordField value={draft} disabled={busy} onChange={setDraft} label="New password" />
+ <PasswordField
+ inputRef={fieldRef}
+ value={draft}
+ disabled={busy}
+ onChange={setDraft}
+ label="New password"
+ describedBy={showProblem ? invalidId : undefined}
+ />
<button type="button" className="confirm__btn live-pop__btn" disabled={busy} onClick={() => setDraft(newControlPassword())}>
Generate
</button>
</div>
- {draft !== '' && problem && <p className="live-pop__invalid">{problem}</p>}
+ {showProblem && (
+ <p className="live-pop__invalid" id={invalidId}>
+ {problem}
+ </p>
+ )}
<p className="live-pop__muted live-pop__note">{PASSWORD_CHANGE_NOTE}</p>
<div className="live-pop__actions">
<button
@@ -454,6 +526,7 @@ export function ControlSection({ linkId, control }: { linkId: string; control: W
setEditing(false)
setDraft('')
setError(null)
+ setFocusTo('change')
}}
>
Cancel
@@ -462,26 +535,7 @@ export function ControlSection({ linkId, control }: { linkId: string; control: W
type="button"
className="confirm__btn primary live-pop__btn"
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,
- () => {
- setShown(next)
- setDraft('')
- setEditing(false)
- },
- () => {
- setSaving(false)
- releaseRef.current?.()
- releaseRef.current = null
- }
- )
- }}
+ onClick={save}
>
{saving ? 'Saving…' : 'Save'}
</button>
@@ -489,7 +543,15 @@ export function ControlSection({ linkId, control }: { linkId: string; control: W
</>
) : (
<div className="live-pop__actions">
- <button type="button" className="confirm__btn live-pop__btn" onClick={() => setEditing(true)}>
+ <button
+ type="button"
+ ref={changeRef}
+ className="confirm__btn live-pop__btn"
+ onClick={() => {
+ setEditing(true)
+ setFocusTo('field')
+ }}
+ >
Change password…
</button>
</div>
diff --git a/src/renderer/lib/liveLink.test.ts b/src/renderer/lib/liveLink.test.ts
index e11b12f6c..fb19395e1 100644
--- a/src/renderer/lib/liveLink.test.ts
+++ b/src/renderer/lib/liveLink.test.ts
@@ -455,6 +455,20 @@ describe('who is typing', () => {
})
})
+ it('only a name the viewer gave itself is quoted: the "Viewer N" placeholder is ours, not a claim', () => {
+ const nameless = (id: string, name: string | null) => ({ ...viewer(id), name, controlling: true, typing: true })
+ expect(chipView([link({ viewers: [nameless('a', null)] })]).title).toBe(
+ 'Viewer 1 is typing. This terminal is shared by a live link — 1 watching.'
+ )
+ expect(chipView([link({ viewers: [typing('a', 'Mert'), nameless('b', ' ')] })]).title).toBe(
+ '\u201cMert\u201d and Viewer 2 are typing. This terminal is shared by a live link — 2 watching.'
+ )
+ // A viewer who CALLS itself "Viewer 1" made a claim like any other: quoted.
+ expect(chipView([link({ viewers: [typing('a', 'Viewer 1')] })]).title).toBe(
+ '\u201cViewer 1\u201d is typing. This terminal is shared by a live link — 1 watching.'
+ )
+ })
+
it('the worst state still wins: refused > offline > waiting > typing > count', () => {
const t = typing('t', 'Mert')
const w = { ...viewer('w'), waiting: true }
diff --git a/src/renderer/lib/liveLink.ts b/src/renderer/lib/liveLink.ts
index d6a69f3e4..1bbd62840 100644
--- a/src/renderer/lib/liveLink.ts
+++ b/src/renderer/lib/liveLink.ts
@@ -107,6 +107,11 @@ export const PASSWORD_CHANGE_NOTE = 'Anyone typing now goes back to watching unt
export const CONTROL_CHANGE_FAILED_MESSAGE = "That change didn't take — try again."
/** `setPassword` answered false, or did not answer: the old password still works. */
export const PASSWORD_CHANGE_FAILED_MESSAGE = "The password wasn't changed — try again. The old one still works."
+/** How long a password save may hold the popover open before it lets go (`PASSWORD_UNCONFIRMED_MESSAGE`). */
+export const PASSWORD_SAVE_TIMEOUT_MS = 30_000
+/** A password save with no answer after `PASSWORD_SAVE_TIMEOUT_MS`: whether the old or the new one
+ * is in force is unknown, so the owner is told to check before handing either out. */
+export const PASSWORD_UNCONFIRMED_MESSAGE = "Couldn't confirm the new password. Check the link before sharing it."
const PASSWORD_PROBLEM_TEXT: Record<ControlPasswordProblem, string> = {
// Not reachable from a text field; named so a `Record` over the shared union compiles.
@@ -210,8 +215,19 @@ export function waitingViewers(links: readonly Pick<WatchLinkView, 'viewers'>[])
* name is the one it unlocked with). Bidi-stripped; a nameless one is "Viewer N" like in the list.
*/
export function typingNames(links: readonly Pick<WatchLinkView, 'viewers'>[]): string[] {
- const out: string[] = []
- for (const l of links) l.viewers.forEach((v, i) => v.typing && out.push(viewerName(v, i)))
+ return typingViewers(links).map((t) => t.name)
+}
+/** The typing viewers with whether the name is one the viewer GAVE itself (a claim, quoted in a
+ * sentence) or our "Viewer N" placeholder (ours, never quoted). */
+function typingViewers(links: readonly Pick<WatchLinkView, 'viewers'>[]): { name: string; claimed: boolean }[] {
+ const out: { name: string; claimed: boolean }[] = []
+ for (const l of links) {
+ l.viewers.forEach((v, i) => {
+ if (!v.typing) return
+ const name = viewerName(v, i)
+ out.push({ name, claimed: v.name !== null && stripBidiControls(v.name).trim() !== '' })
+ })
+ }
return out
}
@@ -219,9 +235,10 @@ export function typingNames(links: readonly Pick<WatchLinkView, 'viewers'>[]): s
function quoted(name: string): string {
return `\u201c${name}\u201d`
}
-/** "“A” is typing." / "“A” and “B” are typing." / "“A”, “B” and “C” are typing." */
-function typingSentence(names: readonly string[]): string {
- const q = names.map(quoted)
+/** "“A” is typing." / "“A” and “B” are typing." / "“A”, “B” and “C” are typing." — a name the
+ * viewer gave itself quoted, our "Viewer N" placeholder not. */
+function typingSentence(names: readonly { name: string; claimed: boolean }[]): string {
+ const q = names.map((n) => (n.claimed ? quoted(n.name) : n.name))
if (q.length === 1) return `${q[0]} is typing.`
return `${q.slice(0, -1).join(', ')} and ${q[q.length - 1]} are typing.`
}
@@ -252,7 +269,7 @@ export function chipView(links: readonly WatchLinkView[]): { label: string; tone
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'
const watching = viewers > 0 ? `${shared} — ${viewers} watching.` : `${shared}.`
- const typing = typingNames(links)
+ const typing = typingViewers(links)
if (typing.length > 0) {
return {
label: `LIVE · ${viewers} · ${typing.length} typing`,
diff --git a/src/renderer/lib/liveLinkEntry.test.tsx b/src/renderer/lib/liveLinkEntry.test.tsx
index d821c4b12..1727bec72 100644
--- a/src/renderer/lib/liveLinkEntry.test.tsx
+++ b/src/renderer/lib/liveLinkEntry.test.tsx
@@ -7,6 +7,7 @@ import {
liveLinkMenuRow,
liveLinkNodeFor,
liveLinkPrepare,
+ liveLinkRemoteFacts,
liveLinkUnavailable,
openLiveLink,
stopAllConfirm,
@@ -333,3 +334,85 @@ describe('liveLinkCommands (palette)', () => {
expect(confirmStopAll).toHaveBeenCalledTimes(1)
})
})
+
+// Where a node runs, for the create dialog: R63 (does the HOST's tmux give a viewer a client of its
+// own?) and the Control warning (on which machine would a controller's commands run?).
+describe('liveLinkRemoteFacts', () => {
+ const box = { user: 'ada', host: 'box.example', port: 22 }
+ const facts = (o: {
+ live?: { id: string; data?: Record<string, unknown> }[]
+ stored?: { id: string; [k: string]: unknown }[]
+ projectSsh?: unknown
+ active?: boolean
+ }) =>
+ liveLinkRemoteFacts({
+ nodeId: 'n1',
+ projectId: 'p',
+ activeProjectId: o.active === false ? 'other' : 'p',
+ live: o.live ?? [],
+ stored: o.stored,
+ projectSsh: o.projectSsh
+ })
+
+ it('a node on an SSH host attached to a LOCAL project: its own host, served by the host tmux', () => {
+ expect(facts({ live: [{ id: 'n1', data: { ssh: box, sshRemoteTmux: true } }] })).toEqual({
+ remoteNode: true,
+ sshTarget: { user: 'ada', host: 'box.example' }
+ })
+ })
+
+ it('a standalone ssh terminal node: its own host, but R63 stays local (ssh is a LOCAL pty program)', () => {
+ expect(facts({ live: [{ id: 'n1', data: { ssh: box } }] })).toEqual({
+ remoteNode: false,
+ sshTarget: { user: 'ada', host: 'box.example' }
+ })
+ })
+
+ it("an SSH project's node: the project's binding on its own host (how THIS user reaches it)", () => {
+ const server = { user: 'bob', host: 'box.example' }
+ // The node's `ssh` is a snapshot of whoever created it (sshConnectionIdForProject's rule).
+ expect(
+ facts({ live: [{ id: 'n1', data: { ssh: { user: 'alice', host: 'box.example' }, sshRemoteTmux: true } }], projectSsh: server })
+ ).toEqual({ remoteNode: true, sshTarget: { user: 'bob', host: 'box.example' } })
+ // No binding on the node: the project's.
+ expect(facts({ live: [{ id: 'n1', data: {} }], projectSsh: server })).toEqual({
+ remoteNode: true,
+ sshTarget: { user: 'bob', host: 'box.example' }
+ })
+ // A node attached to ANOTHER host inside the SSH project: that host.
+ expect(
+ facts({ live: [{ id: 'n1', data: { ssh: { user: 'cy', host: 'gpu.example' }, sshRemoteTmux: true } }], projectSsh: server })
+ ).toEqual({ remoteNode: true, sshTarget: { user: 'cy', host: 'gpu.example' } })
+ })
+
+ it('a local node in a local project: this machine', () => {
+ expect(facts({ live: [{ id: 'n1', data: {} }] })).toEqual({ remoteNode: false, sshTarget: null })
+ expect(facts({ live: [] })).toEqual({ remoteNode: false, sshTarget: null })
+ })
+
+ it("a non-active project's node is read from its stored copy", () => {
+ expect(facts({ active: false, stored: [{ id: 'n1', ssh: box, sshRemoteTmux: true }] })).toEqual({
+ remoteNode: true,
+ sshTarget: { user: 'ada', host: 'box.example' }
+ })
+ // The live canvas belongs to another project: never read for this one.
+ expect(facts({ active: false, live: [{ id: 'n1', data: { ssh: box } }], stored: [{ id: 'n1' }] })).toEqual({
+ remoteNode: false,
+ sshTarget: null
+ })
+ })
+
+ it('a malformed binding (hand-editable, git-shared input) claims nothing', () => {
+ for (const ssh of ['box', 5, null, { host: 5, user: 'a' }, { host: '', user: 'a' }, { user: 'a' }]) {
+ expect(facts({ live: [{ id: 'n1', data: { ssh, sshRemoteTmux: 'yes' } }] }), JSON.stringify(ssh)).toEqual({
+ remoteNode: false,
+ sshTarget: null
+ })
+ }
+ // A host with no usable user still names the host.
+ expect(facts({ live: [{ id: 'n1', data: { ssh: { host: 'box.example', user: 7 } } }] }).sshTarget).toEqual({
+ user: '',
+ host: 'box.example'
+ })
+ })
+})
diff --git a/src/renderer/lib/liveLinkEntry.tsx b/src/renderer/lib/liveLinkEntry.tsx
index a653e9615..b20b9ad0f 100644
--- a/src/renderer/lib/liveLinkEntry.tsx
+++ b/src/renderer/lib/liveLinkEntry.tsx
@@ -104,6 +104,53 @@ export function liveLinkNodeFor(o: {
return n ? { id: n.id, kind: n.kind, title: n.title } : null
}
+/** An SSH binding read off a node or a project: only the two fields the dialog names. */
+export interface LiveLinkSshTarget {
+ user: string
+ host: string
+}
+/** A binding read from hand-editable, git-shared data: a non-empty string host, else nothing. */
+function sshTargetOf(v: unknown): LiveLinkSshTarget | null {
+ if (typeof v !== 'object' || v === null) return null
+ const { host, user } = v as { host?: unknown; user?: unknown }
+ if (typeof host !== 'string' || !host) return null
+ return { user: typeof user === 'string' ? user : '', host }
+}
+
+/**
+ * Where a node runs, for the create dialog — the NODE's own SSH binding first, then its project's:
+ * - `remoteNode` (R63): the node runs in a HOST's tmux, which gives a viewer a client of its own.
+ * An SSH project's node, and a node attached to an SSH host in a local project (`sshRemoteTmux`).
+ * NOT a standalone ssh terminal node: `ssh` is a LOCAL pty program there, in this machine's tmux.
+ * - `sshTarget`: the machine a controller's commands would run on (the Control warning) — the
+ * remote shell of every one of those, the standalone ssh node included. On its project's own host
+ * a remote-tmux node runs as the PROJECT's user: its `ssh` is a snapshot of whoever created it,
+ * and the project's binding is how THIS user reaches that host (`sshConnectionIdForProject`).
+ * Null: this machine.
+ * The node comes from the live canvas for the active project, else from the stored copy (R49).
+ */
+export function liveLinkRemoteFacts(o: {
+ nodeId: string
+ projectId: string
+ activeProjectId: string | null
+ live: readonly { id: string; data?: unknown }[]
+ stored: readonly { id: string; ssh?: unknown; sshRemoteTmux?: unknown }[] | undefined
+ projectSsh: unknown
+}): { remoteNode: boolean; sshTarget: LiveLinkSshTarget | null } {
+ let node: { ssh?: unknown; sshRemoteTmux?: unknown } | undefined
+ if (o.projectId === o.activeProjectId) {
+ const data = o.live.find((x) => x.id === o.nodeId)?.data
+ node = typeof data === 'object' && data !== null ? (data as { ssh?: unknown; sshRemoteTmux?: unknown }) : undefined
+ } else {
+ node = Array.isArray(o.stored) ? o.stored.find((x) => x?.id === o.nodeId) : undefined
+ }
+ const project = sshTargetOf(o.projectSsh)
+ const own = sshTargetOf(node?.ssh)
+ const remoteTmux = !!own && node?.sshRemoteTmux === true
+ const sshTarget = own ? (remoteTmux && project?.host === own.host ? project : own) : project
+ return { remoteNode: !!project || remoteTmux, sshTarget }
+}
+
/**
* The "Share live link…" row for one node — the ONE builder behind the canvas node menu, the
* sessions-sidebar row (active and non-active projects) and both boards' card menus. Terminal nodes
diff --git a/src/renderer/styles.css b/src/renderer/styles.css
index 7a0f133b5..102327b7c 100644
--- a/src/renderer/styles.css
+++ b/src/renderer/styles.css
@@ -11879,9 +11879,14 @@ button.pull-checks__name {
min-width: 0;
margin: 0;
padding: 4px 8px;
- font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
font-size: 12px;
}
+/* A Control link's password, wherever it is typed or shown (create dialog, popover, drawer):
+ monospace, so a 0 and an o, or a 1 and an l, never read alike. One rule for every field. */
+.live-dialog__password .confirm__input,
+.live-pop__password .confirm__input {
+ font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
+}
.live-pop p.live-pop__invalid {
margin: 4px 0 0;
color: var(--danger);
@@ -11996,9 +12001,6 @@ button.pull-checks__name {
.live-dialog__url.live-dialog__password {
margin: 4px 0 10px;
}
-.live-dialog__password .confirm__input {
- font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
-}
.live-dialog__invalid {
margin: -6px 0 10px;
color: var(--danger);
diff --git a/src/renderer/ui/Switch.tsx b/src/renderer/ui/Switch.tsx
index ffa656f5f..a25fb506f 100644
--- a/src/renderer/ui/Switch.tsx
+++ b/src/renderer/ui/Switch.tsx
@@ -4,7 +4,8 @@ export function Switch({
checked,
onChange,
ariaLabel,
- disabled = false
+ disabled = false,
+ pending = false
}: {
checked: boolean
onChange: (v: boolean) => void
@@ -12,6 +13,9 @@ export function Switch({
/** Renders inert (native `disabled` + aria): for a switch whose subject does not currently
* exist, e.g. a per-project capability while no project is open. */
disabled?: boolean
+ /** A change is in flight: announced as disabled and busy, clicks ignored — but NOT natively
+ * disabled, so a switch that has the keyboard focus keeps it (a disabled button drops it). */
+ pending?: boolean
}): React.JSX.Element {
return (
<button
@@ -20,11 +24,14 @@ export function Switch({
aria-checked={checked}
aria-label={ariaLabel}
disabled={disabled}
- aria-disabled={disabled || undefined}
- onClick={() => onChange(!checked)}
+ aria-disabled={disabled || pending || undefined}
+ aria-busy={pending || undefined}
+ onClick={() => {
+ if (!pending) onChange(!checked)
+ }}
className={cn(
'relative box-border block h-[24px] w-[42px] shrink-0 rounded-full border-0 p-0 outline-none transition-colors duration-200',
- disabled ? 'cursor-not-allowed opacity-50' : 'cursor-pointer',
+ disabled ? 'cursor-not-allowed opacity-50' : pending ? 'cursor-progress opacity-70' : 'cursor-pointer',
checked ? 'bg-accent' : 'bg-fill'
)}
>