Skip to content

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

feat(team): Settings → Team Access section (invite, seats, per-peer revoke) (team-access Task 4)

enes6a5c2cabed0e
diff --git a/src/renderer/components/settings/SettingsIcons.tsx b/src/renderer/components/settings/SettingsIcons.tsx
index ab1abf8a2..b01cafd2a 100644
--- a/src/renderer/components/settings/SettingsIcons.tsx
+++ b/src/renderer/components/settings/SettingsIcons.tsx
@@ -74,6 +74,13 @@ const PATHS: Record<SettingsSectionId, React.JSX.Element> = {
<path d="M2.5 8h11M8 2.5c1.9 1.7 1.9 9.3 0 11M8 2.5c-1.9 1.7-1.9 9.3 0 11" />
</>
),
+ 'team-access': (
+ <>
+ <circle cx="6" cy="5.5" r="2.2" />
+ <path d="M2.2 12.5c0-2.1 1.7-3.4 3.8-3.4s3.8 1.3 3.8 3.4" />
+ <path d="M10.6 3.6a2.2 2.2 0 0 1 0 4.2M11.4 9.3c1.5.4 2.4 1.6 2.4 3.2" />
+ </>
+ ),
ssh: (
<>
<rect x="2" y="3" width="12" height="10" rx="2" />
diff --git a/src/renderer/components/settings/SettingsPage.tsx b/src/renderer/components/settings/SettingsPage.tsx
index d1c554d03..2831f1b17 100644
--- a/src/renderer/components/settings/SettingsPage.tsx
+++ b/src/renderer/components/settings/SettingsPage.tsx
@@ -17,6 +17,7 @@ import { CommitSection } from './sections/CommitSection'
import { TmuxSection } from './sections/TmuxSection'
import { LicenseSection } from './sections/LicenseSection'
import { RemoteSection } from './sections/RemoteSection'
+import { TeamAccessSection } from './sections/TeamAccessSection'
import { SshSection } from './sections/SshSection'
import { UpdatesSection } from './sections/UpdatesSection'
import { PrivacySection } from './sections/PrivacySection'
@@ -75,6 +76,7 @@ export function SettingsPage({
<TmuxSection isActive={active === 'tmux'} />
<LicenseSection isActive={active === 'license'} />
<RemoteSection isActive={active === 'remote'} onClose={onClose} />
+ <TeamAccessSection isActive={active === 'team-access'} onClose={onClose} />
<SshSection isActive={active === 'ssh'} />
<UpdatesSection isActive={active === 'updates'} />
<PrivacySection isActive={active === 'privacy'} />
diff --git a/src/renderer/components/settings/nav.test.ts b/src/renderer/components/settings/nav.test.ts
index 6ee8bab70..49d6204df 100644
--- a/src/renderer/components/settings/nav.test.ts
+++ b/src/renderer/components/settings/nav.test.ts
@@ -2,10 +2,10 @@ import { describe, it, expect } from 'vitest'
import { SETTINGS_GROUPS, allSectionIds, FIRST_SECTION_ID } from './nav'
describe('SETTINGS_GROUPS', () => {
- it('lists exactly 16 sections with no duplicates', () => {
+ it('lists exactly 17 sections with no duplicates', () => {
const ids = allSectionIds()
- expect(ids).toHaveLength(16)
- expect(new Set(ids).size).toBe(16)
+ expect(ids).toHaveLength(17)
+ expect(new Set(ids).size).toBe(17)
})
it('starts at a section that exists in the groups', () => {
expect(allSectionIds()).toContain(FIRST_SECTION_ID)
diff --git a/src/renderer/components/settings/nav.ts b/src/renderer/components/settings/nav.ts
index 707afd554..8863794dc 100644
--- a/src/renderer/components/settings/nav.ts
+++ b/src/renderer/components/settings/nav.ts
@@ -12,6 +12,7 @@ export type SettingsSectionId =
| 'tmux'
| 'license'
| 'remote'
+ | 'team-access'
| 'ssh'
| 'updates'
| 'privacy'
@@ -56,6 +57,7 @@ export const SETTINGS_GROUPS: SettingsGroup[] = [
sections: [
{ id: 'license', title: 'License' },
{ id: 'remote', title: 'Remote access' },
+ { id: 'team-access', title: 'Team Access' },
{ id: 'ssh', title: 'Remote (SSH)' }
]
},
diff --git a/src/renderer/components/settings/sections/TeamAccessSection.tsx b/src/renderer/components/settings/sections/TeamAccessSection.tsx
new file mode 100644
index 000000000..4075c02ff
--- /dev/null
+++ b/src/renderer/components/settings/sections/TeamAccessSection.tsx
@@ -0,0 +1,203 @@
+import { useState } from 'react'
+import { useEntitlement } from '../../../state/entitlement'
+import { useTeamAccess } from '../../../state/teamAccess'
+import { listSeats, usedCount, type SeatEntry } from '../../../state/teamAccessCore'
+import { inviteShare, seatFullMessage, teamAccessView } from '../teamAccessView'
+import { SettingsSection } from '../SettingsSection'
+import { SearchableRow } from '../SearchableRow'
+import { FieldRow } from '../FieldRow'
+import { Button } from '@renderer/ui/Button'
+import { CopyButton } from '@renderer/ui/CopyButton'
+import { Input } from '@renderer/ui/Input'
+
+const ROWS = {
+ team: {
+ title: 'Team Access',
+ keywords: ['team', 'seat', 'invite', 'share', 'collaborate', 'remote']
+ }
+}
+const ENTRIES = Object.values(ROWS)
+
+function SeatRow({ seat }: { seat: SeatEntry }): React.JSX.Element {
+ const label = seat.email?.trim() || 'Teammate'
+ const connected = seat.status === 'connected'
+ return (
+ <div className="flex items-center justify-between gap-3">
+ <div className="min-w-0">
+ <div className="truncate text-sm text-text">{label}</div>
+ <div className="text-xs text-muted">
+ {connected ? 'connected' : 'waiting to connect…'}
+ </div>
+ </div>
+ <Button onClick={() => window.nodeTerminal.relayHost.revoke(seat.id)}>Remove</Button>
+ </div>
+ )
+}
+
+export function TeamAccessSection({
+ isActive
+}: {
+ isActive: boolean
+ onClose?: () => void
+}): React.JSX.Element {
+ const ent = useEntitlement()
+ const seats = useEntitlement((s) => s.seats)
+ const used = useTeamAccess((s) => usedCount(s.seats))
+ const seatList = useTeamAccess((s) => listSeats(s.seats))
+ const view = teamAccessView({ premium: ent.isPremium, seats, used })
+
+ const [email, setEmail] = useState('')
+ const [offer, setOffer] = useState('')
+ const [offerEmail, setOfferEmail] = useState('')
+ const [busy, setBusy] = useState(false)
+ const [atCap, setAtCap] = useState(false)
+ const [error, setError] = useState('')
+
+ const generateInvite = async () => {
+ setError('')
+ setAtCap(false)
+ setBusy(true)
+ const invitedEmail = email.trim()
+ try {
+ const { offer: code, id } = await window.nodeTerminal.relayHost.invite({
+ email: invitedEmail || undefined
+ })
+ // Show the pending row immediately — the store also flips it to connected on relay:host:open.
+ useTeamAccess.getState().addPending(id, invitedEmail || undefined)
+ setOffer(code)
+ setOfferEmail(invitedEmail)
+ setEmail('')
+ } catch (err) {
+ if (seatFullMessage(err)) setAtCap(true)
+ else setError((err as Error).message)
+ } finally {
+ setBusy(false)
+ }
+ }
+
+ const share = offer ? inviteShare({ offer, email: offerEmail }) : null
+
+ return (
+ <SettingsSection
+ id="team-access"
+ title="Team Access"
+ description="Share this Mac with your team — one seat per teammate, $5/seat/month."
+ isActive={isActive}
+ searchEntries={ENTRIES}
+ >
+ <SearchableRow {...ROWS.team}>
+ {!view.gated ? (
+ <div className="space-y-5">
+ {/* Seat counter */}
+ <div className="flex items-center justify-between gap-3">
+ <div>
+ <h4 className="text-[13px] font-medium text-text">Seats</h4>
+ <p className="text-sm text-muted">{view.counterText}</p>
+ </div>
+ <Button onClick={() => void ent.upgrade()}>Add seats</Button>
+ </div>
+
+ {/* Connected devices */}
+ <div className="space-y-2">
+ <h4 className="text-[13px] font-medium text-text">Connected devices</h4>
+ {seatList.length === 0 ? (
+ <p className="text-sm text-muted">No teammates connected yet.</p>
+ ) : (
+ <div className="space-y-2">
+ {seatList.map((seat) => (
+ <SeatRow key={seat.id} seat={seat} />
+ ))}
+ </div>
+ )}
+ </div>
+
+ {/* Invite */}
+ <div className="space-y-3">
+ <h4 className="text-[13px] font-medium text-text">Invite a teammate</h4>
+ <p className="text-sm text-muted">
+ A teammate on a seat can run commands on this Mac — the same as giving them SSH
+ access. Only invite people you trust.
+ </p>
+ <FieldRow
+ label="Teammate email"
+ control={
+ <Input
+ className="w-72"
+ type="email"
+ placeholder="[email protected] (optional)"
+ value={email}
+ onChange={(e) => setEmail(e.target.value)}
+ />
+ }
+ />
+ <Button
+ variant="primary"
+ disabled={busy || !view.canInvite}
+ onClick={() => void generateInvite()}
+ >
+ {busy ? 'Generating…' : 'Generate invite'}
+ </Button>
+ {!view.canInvite ? (
+ <p className="text-sm text-muted">All seats in use — add a seat.</p>
+ ) : null}
+ {atCap ? (
+ <p className="text-sm" style={{ color: '#ff9f0a' }}>
+ All seats in use — add a seat.
+ </p>
+ ) : null}
+ {error ? (
+ <p className="text-sm" style={{ color: '#ff9f0a' }}>
+ {error}
+ </p>
+ ) : null}
+ {offer && share ? (
+ <div className="space-y-2">
+ <p className="text-sm text-muted">
+ Share this single-use pairing code with{' '}
+ <strong className="text-text">{offerEmail || 'your teammate'}</strong> — they
+ paste it in nodeterm → New Remote Connection:
+ </p>
+ <FieldRow
+ label="Pairing code"
+ control={
+ <Input
+ className="w-72"
+ readOnly
+ value={offer}
+ onFocus={(e) => e.target.select()}
+ />
+ }
+ />
+ <div className="flex gap-2">
+ <CopyButton text={share.copyText} label="Copy" />
+ <Button onClick={() => window.nodeTerminal.shell.openExternal(share.mailtoUrl)}>
+ Open in Mail
+ </Button>
+ </div>
+ </div>
+ ) : null}
+ </div>
+ </div>
+ ) : (
+ <div className="space-y-3">
+ <h4 className="text-[13px] font-medium text-text">
+ Share this Mac with your team
+ </h4>
+ <p className="text-sm text-muted">
+ One seat per teammate, $5/seat/month. Each teammate connects from their own device
+ over the end-to-end encrypted relay.
+ </p>
+ <p className="text-sm text-muted">
+ A seat grants shell access: a teammate on a seat can run commands on this Mac — the
+ same as giving them SSH access. Every connection is still verified with a one-time
+ pairing code you compare together.
+ </p>
+ <Button variant="primary" onClick={() => void ent.upgrade()}>
+ Get Team Access
+ </Button>
+ </div>
+ )}
+ </SearchableRow>
+ </SettingsSection>
+ )
+}
diff --git a/src/renderer/components/settings/teamAccessView.test.ts b/src/renderer/components/settings/teamAccessView.test.ts
new file mode 100644
index 000000000..ce001a909
--- /dev/null
+++ b/src/renderer/components/settings/teamAccessView.test.ts
@@ -0,0 +1,51 @@
+import { describe, expect, it } from 'vitest'
+import { inviteShare, seatFullMessage, teamAccessView } from './teamAccessView'
+
+describe('teamAccessView', () => {
+ it('gates a non-premium host and forbids inviting', () => {
+ const v = teamAccessView({ premium: false, seats: 0, used: 0 })
+ expect(v.gated).toBe(true)
+ expect(v.canInvite).toBe(false)
+ })
+
+ it('allows inviting a premium host with a free seat', () => {
+ const v = teamAccessView({ premium: true, seats: 5, used: 2 })
+ expect(v.gated).toBe(false)
+ expect(v.canInvite).toBe(true)
+ expect(v.counterText).toBe('Used 2 / 5')
+ })
+
+ it('forbids inviting at cap', () => {
+ const v = teamAccessView({ premium: true, seats: 3, used: 3 })
+ expect(v.canInvite).toBe(false)
+ expect(v.counterText).toBe('Used 3 / 3')
+ })
+})
+
+describe('inviteShare', () => {
+ it('builds a mailto with the encoded code, the invitee, and a body', () => {
+ const { copyText, mailtoUrl } = inviteShare({ offer: 'ABC-123-xyz', email: '[email protected]' })
+ expect(copyText).toContain('ABC-123-xyz')
+ expect(mailtoUrl.startsWith('mailto:[email protected]?')).toBe(true)
+ expect(mailtoUrl).toContain(encodeURIComponent('ABC-123-xyz'))
+ expect(mailtoUrl).toContain('body=')
+ expect(mailtoUrl).toContain('subject=')
+ })
+
+ it('produces a recipientless mailto for a blank email', () => {
+ const { mailtoUrl } = inviteShare({ offer: 'CODE9', email: '' })
+ expect(mailtoUrl.startsWith('mailto:?')).toBe(true)
+ expect(mailtoUrl).toContain(encodeURIComponent('CODE9'))
+ })
+})
+
+describe('seatFullMessage', () => {
+ it('recognizes the E_SEATS_FULL coded error', () => {
+ expect(seatFullMessage(new Error('E_SEATS_FULL: no seats left'))).toBe(true)
+ })
+
+ it('is false for an unrelated error', () => {
+ expect(seatFullMessage(new Error('network down'))).toBe(false)
+ expect(seatFullMessage('some string')).toBe(false)
+ })
+})
diff --git a/src/renderer/components/settings/teamAccessView.ts b/src/renderer/components/settings/teamAccessView.ts
new file mode 100644
index 000000000..f3185d8b2
--- /dev/null
+++ b/src/renderer/components/settings/teamAccessView.ts
@@ -0,0 +1,61 @@
+/**
+ * Pure view-model for the Settings → Team Access section
+ * (docs/superpowers/plans/2026-07-15-team-access.md, Task 4). Kept free of React/DOM so the
+ * gate/counter/invite-share logic is unit-tested without a renderer. The section component is a thin
+ * shell over these + the stores.
+ */
+
+export interface TeamAccessView {
+ /** Not premium → show the pitch/CTA, hide the seat panel. */
+ gated: boolean
+ /** Seat usage line, e.g. "Used 2 / 5" (used = pending + connected, matching the seat cap). */
+ counterText: string
+ /** Premium AND a seat is free → the invite button is enabled. */
+ canInvite: boolean
+}
+
+export function teamAccessView({
+ premium,
+ seats,
+ used
+}: {
+ premium: boolean
+ seats: number
+ used: number
+}): TeamAccessView {
+ return {
+ gated: !premium,
+ counterText: `Used ${used} / ${seats}`,
+ canInvite: premium && used < seats
+ }
+}
+
+export interface InviteShare {
+ /** A friendly, copyable message carrying the pairing code. */
+ copyText: string
+ /** A `mailto:` URL (recipientless when no email) prefilled with subject + body + the code. */
+ mailtoUrl: string
+}
+
+const SHARE_INSTRUCTION = 'In nodeterm, choose "New Remote Connection" and paste this pairing code:'
+
+export function inviteShare({ offer, email }: { offer: string; email?: string }): InviteShare {
+ const copyText = `You're invited to my nodeterm session.\n\n${SHARE_INSTRUCTION}\n\n${offer}`
+ const subject = "You're invited to a nodeterm Team Access seat"
+ const body = `${SHARE_INSTRUCTION}\n\n${offer}`
+ const recipient = (email ?? '').trim()
+ const query = `subject=${encodeURIComponent(subject)}&body=${encodeURIComponent(body)}`
+ return {
+ copyText,
+ mailtoUrl: `mailto:${recipient}?${query}`
+ }
+}
+
+/**
+ * Map a rejected `relayHost.invite()` to the "All seats in use" UI: true when the coded seat-cap
+ * error surfaces (Task 2 rejects with a message CONTAINING `E_SEATS_FULL`).
+ */
+export function seatFullMessage(err: unknown): boolean {
+ const msg = (err as { message?: unknown } | null)?.message
+ return String(msg ?? err).includes('E_SEATS_FULL')
+}
diff --git a/src/renderer/state/entitlement.ts b/src/renderer/state/entitlement.ts
index 6352d848f..7fa693324 100644
--- a/src/renderer/state/entitlement.ts
+++ b/src/renderer/state/entitlement.ts
@@ -5,6 +5,9 @@ interface EntitlementState {
status: LicenseStatus
/** True when an active Pro entitlement is present — features gate on this. */
isPremium: boolean
+ /** Team Access seat cap (premium → N, premium-no-field → 1, free/inactive → 0). Mirrors
+ * `status.seats` so the Team Access section can select it directly. */
+ seats: number
hydrate(): Promise<void>
/** Open Stripe checkout for this device; Pro arrives via onChange when the purchase lands. */
upgrade(): Promise<void>
@@ -15,12 +18,14 @@ interface EntitlementState {
const EMPTY: LicenseStatus = { tier: null, active: false, expiresAt: null, seats: 0, error: null }
export const useEntitlement = create<EntitlementState>((set) => {
- const apply = (status: LicenseStatus) => set({ status, isPremium: status.active })
+ const apply = (status: LicenseStatus) =>
+ set({ status, isPremium: status.active, seats: status.seats })
// Live updates from the main process (launch refresh, offline grace).
window.nodeTerminal.license.onChange(apply)
return {
status: EMPTY,
isPremium: false,
+ seats: 0,
async hydrate() {
apply(await window.nodeTerminal.license.getStatus())
},