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(project-limit): option-A limit dialog
review516898d8df41
diff --git a/src/renderer/canvas/Canvas.tsx b/src/renderer/canvas/Canvas.tsxindex d66552b51..41479ccc0 100644--- a/src/renderer/canvas/Canvas.tsx+++ b/src/renderer/canvas/Canvas.tsx@@ -287,6 +287,7 @@ import { admitPendingPeer } from '../lib/pendingPeerAdmission'import { SAS_COMPARE_HINT } from '@shared/remote/sas'import { promptDialog } from '../components/promptDialog'import { UpgradeDialog } from '../components/UpgradeDialog'+import { ProjectLimitDialog } from '../components/ProjectLimitDialog'import { LiveLinkDialog } from '../components/LiveLinkDialog'import { requireProOr } from '../state/upgradeGate'import { startWatchLinkSync, useWatchLinks } from '../state/watchLinks'@@ -20634,6 +20635,9 @@ export function Canvas() {)}<UpgradeDialog />+ {/* The free-tier limit moment (spec §7). Close is the ordinary non-destructive close — never+ `endSessions`: the limit only ever blocks a NEW open, it never ends anything. */}+ <ProjectLimitDialog onCloseProject={(id) => performCloseProject(id)} />{liveLinkDialog && (<LiveLinkDialogkey={`${liveLinkDialog.projectId}:${liveLinkDialog.nodeId}`}diff --git a/src/renderer/components/ProjectLimitDialog.test.tsx b/src/renderer/components/ProjectLimitDialog.test.tsxnew file mode 100644index 000000000..3b4ab29ed--- /dev/null+++ b/src/renderer/components/ProjectLimitDialog.test.tsx@@ -0,0 +1,387 @@+// @vitest-environment jsdom+//+// The limit dialog (spec §7, option A). The open gate (lib/projectLimitGate.ts) holds a promise for+// every dialog it shows and refuses every other open while that promise is pending, so the one rule+// above all others here: EVERY way out of the dialog goes through `resolveDialog`. A dialog that+// vanishes any other way (or stays unsettled behind an unmounted component) latches every later+// at-limit open to `false` for the rest of the session.+import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'+import { act } from 'react'+import { createRoot, type Root } from 'react-dom/client'+import type { Project } from '@shared/types'+import type { ProjectLimitState } from '@shared/project-limit'++// The project-limit store subscribes to `window.nodeTerminal.projectLimit.onChange` when it is+// created, so the bridge must exist before any import runs.+const h = vi.hoisted(() => {+ const upgrade = vi.fn(async () => {})+ ;(window as unknown as { nodeTerminal: unknown }).nodeTerminal = {+ projectLimit: { state: vi.fn(), claim: vi.fn(), onChange: () => () => {} }+ }+ return { upgrade }+})+// The real stores pull in the whole workspace / license bridge; the dialog only reads the project+// list and calls `upgrade`.+vi.mock('../state/projects', async () => {+ const { create } = await import('zustand')+ return { useProjects: create(() => ({ projects: [] })) }+})+vi.mock('../state/entitlement', async () => {+ const { create } = await import('zustand')+ return { useEntitlement: create(() => ({ upgrade: h.upgrade })) }+})++import { ProjectLimitDialog } from './ProjectLimitDialog'+import { useProjects } from '../state/projects'+import {+ setProjectLimitChecking,+ showProjectLimitDialog,+ useProjectLimit,+ type DialogOutcome,+ type LimitDialogRequest+} from '../state/projectLimit'+import { INACTIVE_PROJECT_LIMIT } from '@shared/project-limit'++;(globalThis as { IS_REACT_ACT_ENVIRONMENT?: boolean }).IS_REACT_ACT_ENVIRONMENT = true++const AT_LIMIT: ProjectLimitState = { active: true, pro: false, free: 5, allowance: 5, dnt: false }+/** No allowance claimed yet (the claim failed): at the limit this decides `claim`, not `allow`. */+const UNCLAIMED: ProjectLimitState = { ...AT_LIMIT, allowance: null }++function project(id: string, over: Partial<Project> = {}): Project {+ return { id, name: `Project ${id}`, color: '#888', viewport: { x: 0, y: 0, zoom: 1 }, nodes: [], ...over }+}++/** Five open projects, plus a relay tab and a closed project — neither of which ever counts. */+const PROJECTS: Project[] = [+ project('p1'),+ project('p2'),+ project('p3'),+ project('p4'),+ project('p5'),+ project('relay', { name: 'Host tab', remote: true }),+ project('gone', { name: 'Closed one', closed: true })+]++let root: Root+let host: HTMLElement+let onCloseProject: ReturnType<typeof vi.fn<(id: string) => void>>+let mounted = false++function mount(): void {+ root = createRoot(host)+ act(() => root.render(<ProjectLimitDialog onCloseProject={onCloseProject} />))+ mounted = true+}++function unmount(): void {+ if (!mounted) return+ act(() => root.unmount())+ mounted = false+}++function show(request: LimitDialogRequest): Promise<DialogOutcome> {+ let pending!: Promise<DialogOutcome>+ act(() => {+ pending = showProjectLimitDialog(request)+ })+ return pending+}++function box(): HTMLElement | null {+ return document.querySelector('.confirm')+}++function text(): string {+ return box()?.textContent ?? ''+}++function buttons(): HTMLButtonElement[] {+ return [...document.querySelectorAll<HTMLButtonElement>('.confirm button')]+}++function button(label: string): HTMLButtonElement {+ const el = buttons().find((b) => b.textContent === label)+ if (!el) throw new Error(`no button "${label}" in: ${buttons().map((b) => b.textContent).join(' | ')}`)+ return el+}++function rows(): HTMLElement[] {+ return [...document.querySelectorAll<HTMLElement>('.confirm li')]+}++function click(el: Element): void {+ act(() => {+ el.dispatchEvent(new MouseEvent('click', { bubbles: true }))+ })+}++beforeEach(() => {+ host = document.createElement('div')+ document.body.appendChild(host)+ onCloseProject = vi.fn<(id: string) => void>()+ h.upgrade.mockClear()+ useProjects.setState({ projects: PROJECTS })+ useProjectLimit.setState({ state: AT_LIMIT, checking: false })+ mount()+})++afterEach(() => {+ // A test that leaves a dialog up must not strand its promise for the next one.+ useProjectLimit.getState().resolveDialog('cancel')+ unmount()+ host.remove()+ useProjectLimit.setState({ state: INACTIVE_PROJECT_LIMIT, dialog: null, checking: false })+})++describe('ProjectLimitDialog — limit mode', () => {+ it('says how many of the allowance are open', () => {+ void show({ mode: 'limit' })+ expect(text()).toContain('5 of 5 free projects are open')+ expect(text()).toContain(+ 'Close one to make room. Closing never deletes anything — its terminals keep running and it stays one click away in Recently closed.'+ )+ })++ it('counts against the allowance, not FREE', () => {+ act(() => useProjectLimit.setState({ state: { ...AT_LIMIT, allowance: 7 } }))+ act(() =>+ useProjects.setState({+ projects: [...PROJECTS, project('p6'), project('p7')]+ })+ )+ void show({ mode: 'limit' })+ expect(text()).toContain('7 of 7 free projects are open')+ })++ it('lists every open project and never a relay tab or a closed project', () => {+ void show({ mode: 'limit' })+ const listed = rows().map((r) => r.textContent ?? '')+ expect(listed).toHaveLength(5)+ expect(listed.map((t) => t.replace(/Close$/, ''))).toEqual([+ 'Project p1',+ 'Project p2',+ 'Project p3',+ 'Project p4',+ 'Project p5'+ ])+ expect(text()).not.toContain('Host tab')+ expect(text()).not.toContain('Closed one')+ })++ it('Close calls onCloseProject with that project, and leaves the dialog to the open count', () => {+ void show({ mode: 'limit' })+ const row = rows().find((r) => r.textContent?.startsWith('Project p3'))!+ click(row.querySelector('button')!)+ expect(onCloseProject).toHaveBeenCalledTimes(1)+ expect(onCloseProject).toHaveBeenCalledWith('p3')+ })++ it('a Close that makes room resolves proceed', async () => {+ onCloseProject.mockImplementation((id) => {+ useProjects.setState({+ projects: useProjects.getState().projects.map((p) => (p.id === id ? { ...p, closed: true } : p))+ })+ })+ const pending = show({ mode: 'limit' })+ click(rows()[0].querySelector('button')!)+ await expect(pending).resolves.toBe('proceed')+ expect(useProjectLimit.getState().dialog).toBeNull()+ expect(box()).toBeNull()+ })++ it('a Close that still leaves it over the limit keeps the dialog up, with the new count', () => {+ act(() => useProjects.setState({ projects: [...PROJECTS, project('p6')] }))+ onCloseProject.mockImplementation((id) => {+ useProjects.setState({+ projects: useProjects.getState().projects.map((p) => (p.id === id ? { ...p, closed: true } : p))+ })+ })+ void show({ mode: 'limit' })+ expect(text()).toContain('6 of 5 free projects are open')+ click(rows()[0].querySelector('button')!)+ expect(useProjectLimit.getState().dialog).not.toBeNull()+ expect(text()).toContain('5 of 5 free projects are open')+ })++ it('Pro arriving through the license broadcast resolves proceed', async () => {+ const pending = show({ mode: 'limit' })+ act(() => useProjectLimit.setState({ state: { ...AT_LIMIT, pro: true } }))+ await expect(pending).resolves.toBe('proceed')+ expect(box()).toBeNull()+ })++ it('resolves proceed exactly once, however many pushes follow', async () => {+ const original = useProjectLimit.getState().resolveDialog+ const calls: DialogOutcome[] = []+ useProjectLimit.setState({+ resolveDialog: (outcome) => {+ calls.push(outcome)+ original(outcome)+ }+ })+ try {+ const pending = show({ mode: 'limit' })+ act(() => useProjectLimit.setState({ state: { ...AT_LIMIT, pro: true } }))+ act(() => useProjectLimit.setState({ state: { ...AT_LIMIT, pro: true, free: 6 } }))+ act(() => useProjects.setState({ projects: PROJECTS.slice(0, 3) }))+ await expect(pending).resolves.toBe('proceed')+ expect(calls).toEqual(['proceed'])+ } finally {+ useProjectLimit.setState({ resolveDialog: original })+ }+ })++ it('the Pro button starts the checkout and does not close the dialog by itself', () => {+ void show({ mode: 'limit' })+ click(button('Unlimited with Pro — $10/mo'))+ expect(h.upgrade).toHaveBeenCalledTimes(1)+ expect(useProjectLimit.getState().dialog).not.toBeNull()+ })++ it('Cancel resolves cancel', async () => {+ const pending = show({ mode: 'limit' })+ click(button('Cancel'))+ await expect(pending).resolves.toBe('cancel')+ expect(box()).toBeNull()+ })++ it('an overlay click resolves cancel; a click inside the box does not', async () => {+ const pending = show({ mode: 'limit' })+ click(box()!)+ expect(useProjectLimit.getState().dialog).not.toBeNull()+ click(document.querySelector('.confirm-overlay')!)+ await expect(pending).resolves.toBe('cancel')+ })++ it('Escape resolves cancel', async () => {+ const pending = show({ mode: 'limit' })+ act(() => {+ window.dispatchEvent(new KeyboardEvent('keydown', { key: 'Escape', bubbles: true }))+ })+ await expect(pending).resolves.toBe('cancel')+ })++ it('shows no Retry and no allowance notice when nothing failed', () => {+ void show({ mode: 'limit' })+ expect(buttons().some((b) => b.textContent === 'Retry')).toBe(false)+ expect(text()).not.toContain("Couldn't check")+ expect(text()).not.toContain('another computer')+ })++ it('is portaled to the body on the dialog overlay, so it sits over the kanban board', () => {+ void show({ mode: 'limit' })+ const overlay = document.querySelector('.confirm-overlay')!+ expect(overlay.parentElement).toBe(document.body)+ expect(host.contains(overlay)).toBe(false)+ })+})++describe('ProjectLimitDialog — error and mismatch', () => {+ it('error: says the allowance could not be checked and Retry resolves retry', async () => {+ act(() => useProjectLimit.setState({ state: UNCLAIMED }))+ const pending = show({ mode: 'error' })+ expect(text()).toContain('5 of 5 free projects are open')+ expect(text()).toContain("Couldn't check your free allowance with api.nodeterm.dev.")+ // Close and Pro still work (§7.3).+ expect(rows()).toHaveLength(5)+ expect(button('Unlimited with Pro — $10/mo')).toBeTruthy()+ click(button('Retry'))+ await expect(pending).resolves.toBe('retry')+ })++ it('error: a Close that makes room still resolves proceed', async () => {+ act(() => useProjectLimit.setState({ state: UNCLAIMED }))+ const pending = show({ mode: 'error' })+ act(() => useProjects.setState({ projects: PROJECTS.slice(1) }))+ await expect(pending).resolves.toBe('proceed')+ })++ it('mismatch: says the allowance is tied to another computer, with the date it can move', () => {+ const retryAfter = 1_800_000_000+ act(() => useProjectLimit.setState({ state: UNCLAIMED }))+ void show({ mode: 'mismatch', retryAfter })+ expect(text()).toContain('5 of 5 free projects are open')+ expect(text()).toContain(+ `Your free allowance is tied to another computer. It can move to this one on ${new Date(retryAfter * 1000).toLocaleDateString()}.`+ )+ expect(rows()).toHaveLength(5)+ })++ it('mismatch without a date never prints an invalid one', () => {+ act(() => useProjectLimit.setState({ state: UNCLAIMED }))+ void show({ mode: 'mismatch' })+ expect(text()).toContain('Your free allowance is tied to another computer.')+ expect(text()).not.toContain('Invalid Date')+ expect(text()).not.toContain('It can move')+ })+})++describe('ProjectLimitDialog — consent', () => {+ it('shows the connection copy, with no project list and no Pro button', () => {+ void show({ mode: 'consent' })+ expect(text()).toContain('Connection needed')+ expect(text()).toContain(+ 'Checking your free allowance and upgrading need a connection to api.nodeterm.dev. Only license checks are sent — telemetry stays off. You can turn this off in Settings → Privacy.'+ )+ expect(rows()).toHaveLength(0)+ expect(buttons().map((b) => b.textContent)).toEqual(['Cancel', 'Allow and check'])+ })++ it('Allow and check resolves consent', async () => {+ const pending = show({ mode: 'consent' })+ click(button('Allow and check'))+ await expect(pending).resolves.toBe('consent')+ })++ it('Cancel resolves cancel', async () => {+ const pending = show({ mode: 'consent' })+ click(button('Cancel'))+ await expect(pending).resolves.toBe('cancel')+ })++ it('is never resolved automatically: the user has to answer it', () => {+ void show({ mode: 'consent' })+ act(() => useProjectLimit.setState({ state: { ...AT_LIMIT, pro: true } }))+ expect(useProjectLimit.getState().dialog).toEqual({ mode: 'consent' })+ expect(text()).toContain('Connection needed')+ })+})++describe('ProjectLimitDialog — checking and lifecycle', () => {+ it('renders nothing with no dialog and no claim in flight', () => {+ expect(document.querySelector('.confirm-overlay')).toBeNull()+ })++ it('while a claim is in flight, shows the checking panel with no buttons', () => {+ act(() => setProjectLimitChecking(true))+ expect(text()).toBe('Checking your free allowance…')+ expect(buttons()).toHaveLength(0)+ act(() => setProjectLimitChecking(false))+ expect(box()).toBeNull()+ })++ it('a dialog replaces the checking panel', () => {+ act(() => setProjectLimitChecking(true))+ void show({ mode: 'limit' })+ expect(document.querySelectorAll('.confirm')).toHaveLength(1)+ expect(text()).not.toContain('Checking your free allowance…')+ })++ it('unmounting while a dialog is open resolves cancel, so the gate is never left waiting', async () => {+ const pending = show({ mode: 'limit' })+ unmount()+ await expect(pending).resolves.toBe('cancel')+ expect(useProjectLimit.getState().dialog).toBeNull()+ })++ it('a new request after one was answered is a fresh dialog', async () => {+ const first = show({ mode: 'limit' })+ click(button('Cancel'))+ await expect(first).resolves.toBe('cancel')+ const second = show({ mode: 'error' })+ expect(text()).toContain("Couldn't check your free allowance")+ click(button('Retry'))+ await expect(second).resolves.toBe('retry')+ })+})diff --git a/src/renderer/components/ProjectLimitDialog.tsx b/src/renderer/components/ProjectLimitDialog.tsxnew file mode 100644index 000000000..286c6d6b5--- /dev/null+++ b/src/renderer/components/ProjectLimitDialog.tsx@@ -0,0 +1,230 @@+import { useEffect, useRef } from 'react'+import { createPortal } from 'react-dom'+import { countOpenProjects, decideOpen, effectiveLimit } from '@shared/project-limit'+import type { Project } from '@shared/types'+import { useEntitlement } from '../state/entitlement'+import { useProjects } from '../state/projects'+import { useProjectLimit, type DialogOutcome, type LimitDialogRequest } from '../state/projectLimit'+import { confirmKeyAction } from './confirm-key'+import { useDialogStack } from './dialog-stack'++/**+ * The free-tier limit moment (spec §7, option A): the dialog the open gate+ * (lib/projectLimitGate.ts) shows when a new open would go past the allowance, plus the brief+ * "Checking…" panel while a person's claim is in flight. Mounted once, in Canvas, beside+ * `UpgradeDialog`; it renders only what `useProjectLimit` asks for.+ *+ * THE RULE: every way out of a dialog goes through `resolveDialog` — Cancel, an overlay click,+ * Escape, the automatic `proceed`, Pro arriving, and this component unmounting while one is up. The+ * gate holds a promise per dialog and refuses every other open while it is pending; a dialog cleared+ * any other way leaves that promise unsettled and every later at-limit open answers `false` forever.+ *+ * It never closes anything on its own: each row's Close is the user's click, and it is the ordinary+ * non-destructive close (sessions keep running, the project goes to Recently closed).+ */+export function ProjectLimitDialog({+ onCloseProject+}: {+ onCloseProject(id: string): void+}): React.JSX.Element | null {+ const dialog = useProjectLimit((s) => s.dialog)+ const checking = useProjectLimit((s) => s.checking)+ const state = useProjectLimit((s) => s.state)+ const projects = useProjects((s) => s.projects)+ const open = countOpenProjects(projects)++ // The automatic proceed: the open the user asked for may go ahead now — a Close made room, or Pro+ // arrived through the license broadcast (core pushes `pro: true`). Never for consent: that one is+ // a question only the user can answer.+ const allowed = dialog !== null && dialog.mode !== 'consent' && decideOpen(state, open) === 'allow'+ useEffect(() => {+ if (!allowed || !dialog) return+ // Exactly once, and only the dialog this render saw. `showProjectLimitDialog` stores a fresh+ // object per request, so identity tells two apart: once this one is resolved the store holds+ // `null` (or the gate's next request), and a second run for it — or a late one after the gate+ // has put up another dialog — resolves nothing.+ if (useProjectLimit.getState().dialog !== dialog) return+ useProjectLimit.getState().resolveDialog('proceed')+ }, [allowed, dialog])++ // Unmounted with a dialog up (Canvas going away): the open does not happen, and the gate must hear+ // so. `resolveDialog` with nothing shown is a no-op.+ useEffect(() => () => useProjectLimit.getState().resolveDialog('cancel'), [])++ // Fresh mount per request: its own place on the dialog stack, nothing carried over from the last.+ const keys = useRef(new WeakMap<LimitDialogRequest, number>())+ const seq = useRef(0)++ if (dialog) {+ // Being resolved this instant (the effect above) — do not flash it for a frame.+ if (allowed) return null+ let key = keys.current.get(dialog)+ if (key === undefined) {+ key = ++seq.current+ keys.current.set(dialog, key)+ }+ const listed = projects.filter((p) => !p.closed && !p.remote)+ return (+ <LimitDialog+ key={key}+ request={dialog}+ open={open}+ limit={effectiveLimit(state)}+ projects={listed}+ onCloseProject={onCloseProject}+ />+ )+ }++ if (!checking) return null+ // No buttons and no outcome: the claim behind it is bounded (core's claim timeout), and whatever+ // it answers replaces this panel with the dialog or with the open itself.+ return createPortal(+ <div className="confirm-overlay">+ <div className="confirm project-limit__checking" role="status" aria-live="polite">+ <p className="confirm__msg">Checking your free allowance…</p>+ </div>+ </div>,+ document.body+ )+}++function resolve(outcome: DialogOutcome): void {+ useProjectLimit.getState().resolveDialog(outcome)+}++function LimitDialog(props: {+ request: LimitDialogRequest+ open: number+ limit: number+ projects: Project[]+ onCloseProject(id: string): void+}): React.JSX.Element {+ const { request, open, limit, projects, onCloseProject } = props+ const isTop = useDialogStack()+ const boxRef = useRef<HTMLDivElement>(null)+ const shownAtRef = useRef(Date.now())++ // Escape cancels, under ConfirmDialog's rules (components/confirm-key). Enter answers nothing: this+ // dialog can appear under the user's hands — an agent's `open-project` refusal raises it too — and+ // none of its buttons is the one a stray Enter should press.+ useEffect(() => {+ const onKey = (e: KeyboardEvent): void => {+ const action = confirmKeyAction({+ key: e.key,+ repeat: e.repeat,+ top: isTop(),+ inDialog: !!(e.target instanceof Node && boxRef.current?.contains(e.target)),+ sinceMount: Date.now() - shownAtRef.current,+ enterConfirms: false+ })+ if (action !== 'cancel') return+ e.preventDefault()+ resolve('cancel')+ }+ window.addEventListener('keydown', onKey)+ return () => window.removeEventListener('keydown', onKey)+ }, [isTop])++ const consent = request.mode === 'consent'+ const titleId = 'project-limit-title'+ return createPortal(+ <div className="confirm-overlay" onClick={() => resolve('cancel')}>+ <div+ className="confirm project-limit"+ ref={boxRef}+ role="dialog"+ aria-modal="true"+ aria-labelledby={titleId}+ onClick={(e) => e.stopPropagation()}+ >+ {consent ? (+ <>+ <h2 className="project-limit__title" id={titleId}>+ Connection needed+ </h2>+ <p className="confirm__msg">+ Checking your free allowance and upgrading need a connection to api.nodeterm.dev. Only+ license checks are sent — telemetry stays off. You can turn this off in Settings →+ Privacy.+ </p>+ </>+ ) : (+ <>+ <h2 className="project-limit__title" id={titleId}>+ {`${open} of ${limit} free projects are open`}+ </h2>+ <p className="confirm__msg">+ Close one to make room. Closing never deletes anything — its terminals keep running and+ it stays one click away in Recently closed.+ </p>+ {request.mode === 'error' && (+ <div className="project-limit__notice" role="alert">+ <span>Couldn't check your free allowance with api.nodeterm.dev.</span>+ <button className="confirm__btn" onClick={() => resolve('retry')}>+ Retry+ </button>+ </div>+ )}+ {request.mode === 'mismatch' && (+ <div className="project-limit__notice" role="alert">+ <span>{mismatchLine(request.retryAfter)}</span>+ </div>+ )}+ <ul className="project-limit__list" aria-label="Open projects">+ {projects.map((p) => (+ <li key={p.id} className="project-limit__row">+ <span className="project-limit__name" title={p.name}>+ {p.name}+ </span>+ <button+ className="confirm__btn"+ aria-label={`Close ${p.name}`}+ onClick={() => onCloseProject(p.id)}+ >+ Close+ </button>+ </li>+ ))}+ </ul>+ </>+ )}+ <div className="confirm__actions">+ {/* Focus lands on Cancel, the safe answer: an agent's refusal can raise this while the user+ is typing, and their next Enter/Space must not start a checkout or grant consent. */}+ <button className="confirm__btn" autoFocus onClick={() => resolve('cancel')}>+ Cancel+ </button>+ {consent ? (+ <button className="confirm__btn primary" onClick={() => resolve('consent')}>+ Allow and check+ </button>+ ) : (+ // Starts the existing checkout. It resolves nothing by itself: Pro arriving through the+ // license broadcast is what lets the open proceed (the automatic rule above).+ <button className="confirm__btn primary" onClick={() => void startUpgrade()}>+ Unlimited with Pro — $10/mo+ </button>+ )}+ </div>+ </div>+ </div>,+ document.body+ )+}++/** The machine-mismatch line. Without a usable `retryAfter` it states the fact and no date — an+ * "Invalid Date" is worse than none. */+function mismatchLine(retryAfter: number | undefined): string {+ const base = 'Your free allowance is tied to another computer.'+ if (typeof retryAfter !== 'number' || !Number.isFinite(retryAfter)) return base+ return `${base} It can move to this one on ${new Date(retryAfter * 1000).toLocaleDateString()}.`+}++async function startUpgrade(): Promise<void> {+ try {+ await useEntitlement.getState().upgrade()+ } catch (err) {+ console.warn('[project-limit] upgrade failed', err instanceof Error ? err.message : String(err))+ }+}diff --git a/src/renderer/state/projectLimit.ts b/src/renderer/state/projectLimit.tsindex bb32760b7..3ce40829b 100644--- a/src/renderer/state/projectLimit.ts+++ b/src/renderer/state/projectLimit.ts@@ -30,7 +30,10 @@ export type DialogOutcome = 'proceed' | 'cancel' | 'retry' | 'consent'interface ProjectLimitStore {state: ProjectLimitState- /** The dialog the open gate (lib/projectLimitGate.ts) is waiting on, or `null`. At most one. */+ /** The dialog the open gate (lib/projectLimitGate.ts) is waiting on, or `null`. At most one.+ * Close it ONLY through `resolveDialog`: the gate holds a promise for it and refuses every other+ * open while that is pending, so clearing this field any other way (`setState({ dialog: null })`)+ * leaves the promise unsettled and latches every later at-limit open to `false`. */dialog: LimitDialogRequest | null/** §7's "brief spinner": a person's claim is still in flight after `CHECKING_DELAY_MS`. */checking: booleandiff --git a/src/renderer/styles.css b/src/renderer/styles.cssindex 6f9ff3e3b..6f6ed0b3f 100644--- a/src/renderer/styles.css+++ b/src/renderer/styles.css@@ -7052,6 +7052,58 @@ body,gap: 8px;}+/* Free-tier limit dialog (components/ProjectLimitDialog.tsx): the open projects, each with Close,+ inside the `.confirm` shell — which owns the surface, the z-order (over the kanban board) and the+ buttons. Only the title, the rows and the one-line notice need anything of their own. */+.project-limit__title {+ margin: 0 0 12px;+ font-size: 14px;+ font-weight: 600;+ color: var(--text);+}++.project-limit__list {+ list-style: none;+ margin: 0 0 16px;+ padding: 0;+ display: flex;+ flex-direction: column;+ gap: 6px;+ max-height: 40vh;+ overflow-y: auto;+}++.project-limit__row,+.project-limit__notice {+ display: flex;+ align-items: center;+ justify-content: space-between;+ gap: 8px;+ font-size: 13px;+ line-height: 1.5;+ color: var(--text);+}++.project-limit__notice {+ margin: 0 0 16px;+}++/* A long project name truncates instead of pushing its Close button out of the box. */+.project-limit__name {+ min-width: 0;+ overflow: hidden;+ text-overflow: ellipsis;+ white-space: nowrap;+}++.confirm.project-limit__checking {+ width: auto;+}++.project-limit__checking .confirm__msg {+ margin: 0;+}+.confirm__msg {margin: 0 0 16px;/* The scrollable region once the box hits its max-height, so the action buttons