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.
TypeScript adhdagent-orchestrationai-agentscanvasclaude-codecodexcoding-agentsdeveloper-toolselectrongeminilinuxmacosmultiplexeropencodeparallel-agentsterminalterminal-emulatorterminal-multiplexertmuxworkspace-manager
feat(relay): show ConsentNotice + relayHost source in the host approval dialog (Stage 4 Task 8)
enesef3dc23bbd12
diff --git a/src/renderer/canvas/Canvas.tsx b/src/renderer/canvas/Canvas.tsxindex 2dc01aa98..d6ac023e4 100644--- a/src/renderer/canvas/Canvas.tsx+++ b/src/renderer/canvas/Canvas.tsx@@ -69,6 +69,8 @@ import { UpdateCard } from '../components/UpdateCard'import { AnnouncementBanner } from '../components/AnnouncementBanner'import { ConflictBar } from '../components/ConflictBar'import { ConfirmDialog } from '../components/ConfirmDialog'+import { ConsentNotice } from '../remote/ConsentNotice'+import { peerApprovalView } from '@shared/remote/approval'import { promptDialog } from '../components/promptDialog'import { UpgradeDialog } from '../components/UpgradeDialog'import { RemotePicker } from '../components/RemotePicker'@@ -246,6 +248,9 @@ interface MergeState {interface PendingPeerState {sas: string | nullid: string+ /** Human-facing peer name, if the tunnel carries one. The relay `RelayPeerPending` payload does+ * not yet, so this is undefined → the ConsentNotice falls back to a generic subject. */+ label?: string}/**@@ -1218,8 +1223,14 @@ export function Canvas() {// Host connection-approval gate: when a client finishes the handshake, prompt the host to// verify the SAS and allow/deny before any remote pty/fs RPC is served.+ //+ // Sourced off the NEW relay tunnel (`relayHost`, Stage 4 Task 2), NOT the legacy+ // `remoteHost.onPeerPending`. Migrating means the old standing-host (phone) path no longer raises+ // THIS dialog — deliberate: the phone is being moved to the relay tunnel separately+ // (docs/ios-protocol-migration.md) and Task 10 deletes the `remoteHost` dialect outright. So we+ // fully migrate rather than keep both sources alive (which would only complicate that removal).useEffect(() => {- return window.nodeTerminal.remoteHost.onPeerPending((info) => setPendingPeer(info))+ return window.nodeTerminal.relayHost.onPeerPending((info) => setPendingPeer(info))}, [])// ---- canvas sync (team) ----@@ -5523,12 +5534,10 @@ export function Canvas() {{pendingPeer && (<ConfirmDialog- message={- `A device wants to access this machine.\n\n` +- `Approve ONLY if you started this connection. The other device shows the same code:\n\n` +- ` ${pendingPeer.sas ?? '— — —'}\n\n` +- `If the codes don't match, deny it.`- }+ // ConsentNotice → describeGrant: the human reads WHAT they grant ("<peer> will be able to+ // run commands on this Mac — the same as SSH") above the SAS body, before confirming.+ body={<ConsentNotice peerLabel={pendingPeer.label ?? 'This device'} />}+ message={peerApprovalView(pendingPeer).message}confirmLabel="Allow"cancelLabel="Deny"// A REMOTE device raised this — the far side completing the pairing handshake pops it@@ -5539,11 +5548,14 @@ export function Canvas() {enterConfirms={false}dangeronConfirm={() => {- window.nodeTerminal.remoteHost.approve(pendingPeer.id)+ window.nodeTerminal.relayHost.confirm(peerApprovalView(pendingPeer).confirmId)setPendingPeer(null)}}+ // The relay host API offers no explicit reject (see main/remote/relay-host-service.ts):+ // declining is simply NOT confirming — the peer is only ever admitted once the host+ // confirms (`onOpen` fires after both humans match the SAS), so closing this dialog+ // without confirming leaves the pending peer un-admitted and it times out server-side.onCancel={() => {- window.nodeTerminal.remoteHost.reject(pendingPeer.id)setPendingPeer(null)}}/>diff --git a/src/renderer/components/ConfirmDialog.tsx b/src/renderer/components/ConfirmDialog.tsxindex 161e933fa..e20d6497a 100644--- a/src/renderer/components/ConfirmDialog.tsx+++ b/src/renderer/components/ConfirmDialog.tsx@@ -1,10 +1,13 @@-import { useEffect, useRef } from 'react'+import { useEffect, useRef, type ReactNode } from 'react'import { createPortal } from 'react-dom'import { confirmKeyAction } from './confirm-key'import { isTopDialog, nextDialogId, popDialog, pushDialog } from './dialog-stack'interface ConfirmDialogProps {message: string+ /** Optional content rendered ABOVE the message (e.g. the remote-access ConsentNotice), so the+ * human reads what they are granting before the SAS body + buttons. */+ body?: ReactNodeconfirmLabel?: stringcancelLabel?: stringdanger?: boolean@@ -30,6 +33,7 @@ interface ConfirmDialogProps {*/export function ConfirmDialog({message,+ body,confirmLabel = 'Delete',cancelLabel = 'Cancel',danger = true,@@ -78,6 +82,7 @@ export function ConfirmDialog({return createPortal(<div className="confirm-overlay" onClick={onCancel}><div className="confirm" ref={boxRef} onClick={(e) => e.stopPropagation()}>+ {body}<p className="confirm__msg">{message}</p>{option && (<label className="confirm__option">diff --git a/src/shared/remote/approval.test.ts b/src/shared/remote/approval.test.tsnew file mode 100644index 000000000..c84be5b94--- /dev/null+++ b/src/shared/remote/approval.test.ts@@ -0,0 +1,24 @@+import { describe, it, expect } from 'vitest'+import { peerApprovalView } from './approval'+import { describeGrant } from './consent'++describe('peerApprovalView', () => {+ it('names the peer for the consent notice and echoes the SAS + confirm target', () => {+ const view = peerApprovalView({ id: 'peer-1', sas: '12-34-56', label: "Ayşe's Mac" })+ // The consent sentence the human must read is derived from this label via describeGrant.+ expect(view.peerLabel).toBe("Ayşe's Mac")+ expect(describeGrant(view.peerLabel)).toContain('run commands on this Mac')+ // The SAS both humans compare is in the dialog body verbatim.+ expect(view.message).toContain('12-34-56')+ // Confirm acts on THIS pending peer's id (relayHost.confirm(id)).+ expect(view.confirmId).toBe('peer-1')+ })++ it('falls back to a generic subject when no label is provided', () => {+ const view = peerApprovalView({ id: 'peer-2', sas: null })+ expect(view.peerLabel).toBe('This device')+ // A missing SAS renders as a visible placeholder, never a blank line.+ expect(view.message).toContain('— — —')+ expect(view.confirmId).toBe('peer-2')+ })+})diff --git a/src/shared/remote/approval.ts b/src/shared/remote/approval.tsnew file mode 100644index 000000000..73a9b0906--- /dev/null+++ b/src/shared/remote/approval.ts@@ -0,0 +1,34 @@+// View-model for the HOST approval dialog (Stage 4 relay tunnel). Maps a `RelayPeerPending` payload+// (id + SAS, no label yet) to the three things the dialog needs: the peer label that feeds the+// ConsentNotice's describeGrant sentence, the SAS-comparison body text, and the confirm target id+// (`relayHost.confirm(id)`). Pure + shared so it is unit-testable without a jsdom harness — Canvas+// has none — and so the SAS copy lives in one place.++/** The pending-peer fields this view needs (a superset-friendly shape of `RelayPeerPending`). */+export interface PeerApprovalInput {+ id: string+ sas: string | null+ /** Human-facing name of the peer, if the tunnel carries one; else the generic fallback is used. */+ label?: string+}++export interface PeerApprovalView {+ /** Fed to `<ConsentNotice peerLabel>` → describeGrant("<peer> will be able to run commands…"). */+ peerLabel: string+ /** The SAS-comparison body shown in the ConfirmDialog. */+ message: string+ /** The pending peer id to pass to `relayHost.confirm(id)` on approval. */+ confirmId: string+}++export function peerApprovalView(peer: PeerApprovalInput): PeerApprovalView {+ return {+ peerLabel: peer.label?.trim() || 'This device',+ confirmId: peer.id,+ message:+ `A device wants to access this machine.\n\n` ++ `Approve ONLY if you started this connection. The other device shows the same code:\n\n` ++ ` ${peer.sas ?? '— — —'}\n\n` ++ `If the codes don't match, deny it.`+ }+}