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
import { useEffect, useMemo, useRef, useState, type DragEvent } from 'react'
import { createPortal } from 'react-dom'
import { useProjects } from '../state/projects'
import { isOmniKanbanEnabled, toggleBoardView, useViewMode, viewFor } from '../state/viewMode'
import { useAgentStatusSig, type AgentStatusLookup } from '../session/agent-status-lookup'
import { usePauseCounts } from '../state/pauseCounts'
import { useSettings } from '../state/settings'
import { accountsForProject, sshAccountsHint, systemAccountDisplayOn } from '../state/workspace'
import { sshHostKey } from '@shared/ssh'
import { useSshConn } from '../state/sshConn'
import { sshAutoModeHint } from '../state/permissionMode'
import { useSystemAccount } from '../state/systemAccount'
import { sessionCount, sessionForProject, useProjectSession } from '../session/session'
import { tabClickAction } from '../session/relay-tab'
import { useMenuFlip } from '../ui/useMenuFlip'
import { commandTooltip } from '../lib/keybindingOverrides'
import { IconCanvasView, IconKanban, IconMoreVertical, IconPlus, IconUpdate } from './icons'
import { runPendingUpdate, usePendingUpdate } from '../state/pendingUpdate'
import { ProjectGlyph } from './ProjectGlyph'
import { useTooltip } from './Tooltip'
import { projectTabTooltip } from '../lib/projectTabTooltip'
import { useDragAutoScroll } from '../lib/dragAutoScroll'
import {
ALL_PERMISSION_MODES,
PERMISSION_MODE_LABELS,
type AgentPermissionMode
} from '@shared/agents/config'
import { bypassSandboxCaveat, permissionModeAgentsLabel } from '@shared/agents/approval-mode'
import { codexApprovalCaps } from '@renderer/state/codexCli'
import { PROJECT_NAME_MAX, clampProjectName } from '@shared/project-name'
import { CONFIRM_WAIVABLE_VERBS, WAIVABLE_VERB_ACTIONS, otherWaiverHint } from '@shared/control-confirm'
import { projectWaiverRow, setControlConfirmWaivedForProject } from '../state/controlConfirmGate'
import { useControlConfirm } from '../state/controlConfirm'
import { isBrowserRuntime } from '../bridge/runtime'
interface TabBarProps {
onSwitch: (id: string) => void
/** Reconnect an offline (dropped) relay tab in place (Stage 4 Task 7). Called when an
* "unavailable" tab whose session is a relay/server source is clicked. */
onReconnect: (id: string) => void
/** Reorder a project to sit before another (null = to the end). Shared with the sessions
* sidebar: both surfaces render the projects array, so one drag updates both. */
onReorder: (draggedId: string, beforeId: string | null) => void
/** Open the start screen (New project / Open folder / Clone repo), what "+" now shows. */
onOpenWelcome: () => void
onRename: (id: string, name: string) => void
onSetFolder: (id: string) => void
/** Issue #1145: move a local folder project's canvas into app data, or back into its folder. */
onMoveStorage?: (id: string, to: 'appData' | 'folder') => void
/** Close (hide) the project without destroying it, reopenable from the start screen. */
onCloseProject: (id: string) => void
/** Open the Remote access dialog (host/share + connect). Shown for every project. */
onRemoteAccess: () => void
/** Set (or clear, with undefined) the project's default Claude account for new nodes. */
onSetDefaultAccount: (id: string, accountId: string | undefined) => void
/** Set (or clear, with undefined = use the global setting) the project's default permission mode. */
onSetDefaultPermissionMode: (id: string, mode: AgentPermissionMode | undefined) => void
/** Deep-link to this project's own pane in Settings — everything this menu can change plus the
* shared/machine-local settings families, which have no other entry point. */
onOpenProjectSettings: (id: string) => void
/** Open "Share with team" for an SSH project. Absent = the row is not offered. */
onShareWithTeam?: (projectId: string) => void
/** Why the share cannot start for this project right now (the row is then disabled with it as
* its tooltip), or null when it can. */
shareBlockedReason?: (projectId: string) => string | null
/** Pause every agent session in the project (Canvas `pauseNodes`: one confirm, busy ones after
* their current turn). */
onPauseProject: (id: string) => void
/** Drop the project's "pause after the current turn" marks. */
onCancelPendingPauses: (id: string) => void
/** Resume every PAUSED session of the ACTIVE project (offered only there). */
onResumeAllProject: (id: string) => void
}
/**
* The unread count of every project that has one, as ONE primitive — the tab dots' selector shape,
* so a working/waiting flip of any agent does not re-render the tab bar. Each node is asked through
* ITS project (`lookup(project.id, node.id)`): a team tab's unread lives in its relay session's
* store, and its node ids are the handed-off SSH project's too, so counting one store for every tab
* put one project's dot on the other's tab. Written with `JSON.stringify` (`[[projectId, count]…]`),
* never a raw join — ids come from git-shared, hand-editable project files. `''` when nothing is
* unread. Counts `p.nodes` entries, exactly as the dot always did.
*/
export function unreadSigFor(
projects: readonly { id: string; nodes: readonly { id: string }[] }[],
lookup: AgentStatusLookup
): string {
const entries: Array<[string, number]> = []
for (const p of projects) {
let count = 0
for (const n of p.nodes) if (lookup(p.id, n.id)?.unread) count++
if (count > 0) entries.push([p.id, count])
}
return entries.length ? JSON.stringify(entries) : ''
}
/** Parse `unreadSigFor` back into projectId → unread count (projects with none are absent). */
export function parseUnreadSig(sig: string): ReadonlyMap<string, number> {
const out = new Map<string, number>()
if (!sig) return out
try {
const entries: unknown = JSON.parse(sig)
if (!Array.isArray(entries)) return out
for (const e of entries) {
if (Array.isArray(e) && typeof e[0] === 'string' && typeof e[1] === 'number') out.set(e[0], e[1])
}
} catch {
/* our own output; an unparseable one reads as nothing unread */
}
return out
}
/**
* The runtime session dimension of a tab (which core the project lives on). Rendered ONLY when
* more than one session exists, `sessionCount()` is 1 for a solo user today, so this never
* mounts and the solo tab bar is pixel-identical. Its own component because
* `useProjectSession` is a hook and the tabs render in a `.map()`. Nothing here is persisted:
* the project → session binding is resolved at runtime by `sessionForProject`.
*/
function TabSessionLabel({ projectId }: { projectId: string }) {
const session = useProjectSession(projectId)
return (
<span className="tab__session" title={`Session: ${session.label} (${session.status})`}>
{session.label}
</span>
)
}
/**
* Top tab bar, one tab per project. Click to switch, "+" to add. The active tab
* exposes a caret menu (Rename / Set folder / Delete). The menu is rendered in a body
* portal with fixed positioning so it is never clipped by the tab strip's overflow nor
* hidden behind the canvas.
*/
export function TabBar({
onSwitch,
onReconnect,
onReorder,
onOpenWelcome,
onRename,
onSetFolder,
onMoveStorage,
onCloseProject,
onRemoteAccess,
onSetDefaultAccount,
onSetDefaultPermissionMode,
onOpenProjectSettings,
onShareWithTeam,
shareBlockedReason,
onPauseProject,
onCancelPendingPauses,
onResumeAllProject
}: TabBarProps) {
// Select the raw array and filter in a memo, a `.filter()` inside the selector returns a
// fresh array every store snapshot, which re-rendered the TabBar on EVERY projects change.
const allProjects = useProjects((s) => s.projects)
// Closed projects are hidden here (reopen them from the start screen's "Recently closed").
const projects = useMemo(() => allProjects.filter((p) => !p.closed), [allProjects])
const activeId = useProjects((s) => s.activeProjectId)
const omniEnabled = useSettings((s) => isOmniKanbanEnabled(s.settings))
const globalKanban = useViewMode((s) => s.globalKanban)
const isGlobal = omniEnabled && globalKanban
const perProjectKanban = useViewMode((s) => !!activeId && viewFor(s, activeId) === 'kanban')
const kanbanActive = isGlobal || perProjectKanban
const highlightedId = useViewMode((s) => s.highlightedSwimlaneId)
// Unread dots need only each tab's unread count — subscribing to the whole status map re-rendered
// the TabBar on every working/waiting flip of any agent. Primitive signature → rare updates. Each
// tab counts from ITS project's session store (`unreadSigFor`).
const projectIds = useMemo(() => projects.map((p) => p.id), [projects])
const unreadSig = useAgentStatusSig(projectIds, (lookup) => unreadSigFor(projects, lookup))
const unreadCounts = useMemo(() => parseUnreadSig(unreadSig), [unreadSig])
// ⏸ badge + the "Cancel pending pauses" row. Computed HERE, not in Canvas: this component
// already holds the projects array, and Canvas subscribing to it would re-render the whole canvas
// on every node serialization.
const pauseCounts = usePauseCounts(projects)
const [menuId, setMenuId] = useState<string | null>(null)
// `flipBase` is the ANCHOR's top edge: when the menu would overflow the bottom of the window,
// it opens upward from the caret button instead (see useMenuFlip below).
const [menuPos, setMenuPos] = useState<{ top: number; left: number; flipBase: number } | null>(
null
)
const [editingId, setEditingId] = useState<string | null>(null)
// One tooltip for the whole strip: a resting pointer shows the hovered tab's location
// (projectTabTooltip). The label is set as the pointer enters a tab, before the dwell runs out.
const [tabTipLabel, setTabTipLabel] = useState('')
const tabTip = useTooltip(tabTipLabel, { delay: 500 })
const [draft, setDraft] = useState('')
// The stored name the editor opened on. Committing the cut draft of an over-long one
// (issue #940) stores that cut: the user asked to rename and sees what will be stored.
const [draftStart, setDraftStart] = useState('')
// Tab drag-reorder: the project id being dragged + the current drop target ('' = end zone).
const [dragId, setDragId] = useState<string | null>(null)
const [dropId, setDropId] = useState<string | null>(null)
// Whether the caret menu's "Default Claude account" group is expanded (inline, in-place).
const [acctOpen, setAcctOpen] = useState(false)
// Whether the caret menu's "Default permission mode" group is expanded (same idiom as acctOpen).
const [modeOpen, setModeOpen] = useState(false)
const [agentActsOpen, setAgentActsOpen] = useState(false)
// Per-project agent confirm rows read the live gate (`projectWaiverRow`) at render. These
// subscriptions are what re-render the menu when any input of that decision changes: the
// persisted waivers, the app-run ones, and the global permission mode (`globalMode` below; a
// project's own mode arrives with the projects store).
useSettings((s) => s.settings.controlConfirmWaivers)
useControlConfirm((s) => s.sessionWaived)
const claudeAccounts = useSettings((s) => s.settings.claudeAccounts)
// The mode a project without an override falls back to, shown in the "Use global (…)" entry.
const globalMode = useSettings((s) => s.settings.claudePermissionMode)
const systemLabelSetting = useSettings((s) => s.settings.systemAccountLabel)
const systemEmail = useSystemAccount((s) => s.email)
const remoteSystemEmails = useSystemAccount((s) => s.remoteEmails)
// Session labels appear only once a second session exists (4c: remote tabs). For a solo user
// this is always false, so the tab strip renders exactly as before. Plain call, not a
// subscription: sessions are registered at boot (and, in 4c, on connect, which re-renders
// through its own state), so no store is needed here.
const multiSession = sessionCount() > 1
const menuProject = projects.find((p) => p.id === menuId)
// Accounts eligible as the caret-menu project's default: local accounts for a local project, this
// host's accounts for an SSH project (pending logins always excluded).
const menuAccounts = accountsForProject(claudeAccounts, menuProject)
// The system row belongs to the machine the MENU's project runs on: an SSH project's is the
// host's own `~/.claude`, which this machine's label / email says nothing about.
const menuHostKey = menuProject?.ssh ? sshHostKey(menuProject.ssh.server) : undefined
const systemLabel = systemAccountDisplayOn(
menuHostKey,
{ label: systemLabelSetting, email: systemEmail },
menuHostKey ? remoteSystemEmails[menuHostKey] : undefined
)
// SSH project with no accounts on its host: say where accounts for this host come from instead
// of presenting a bare System-only list (which read as "multi-account is broken on SSH").
const menuAccountsHint = sshAccountsHint(menuProject, menuAccounts)
// Live remote-probe view for the Auto rows below: on an SSH project `auto` only applies once the
// REMOTE claude CLI is confirmed >= 2.1.71, and without a hint that silent fail-open degrade is
// indistinguishable from a broken dropdown. Subscribed (not getState) so the ⚠︎ clears the
// moment the probe answers while the menu is open.
const autoPermByProject = useSshConn((s) => s.autoPermByProject)
const remoteClaudeVersionByProject = useSshConn((s) => s.remoteClaudeVersionByProject)
const menuAutoHint = menuProject?.ssh
? sshAutoModeHint(
autoPermByProject[menuProject.id] === undefined
? 'unknown'
: autoPermByProject[menuProject.id]
? 'yes'
: 'no',
remoteClaudeVersionByProject[menuProject.id]
)
: null
const closeMenu = () => {
setMenuId(null)
setMenuPos(null)
setAcctOpen(false)
setModeOpen(false)
setAgentActsOpen(false)
}
const openMenu = (id: string, anchor: HTMLElement) => {
const r = anchor.getBoundingClientRect()
// Under Liquid Glass the bar is a visible glass slab and the caret sits inside it, so the menu
// hangs from the BAR's bottom edge rather than 3px inside it (visual QA N11). Still a plain
// position, so useMenuFlip keeps flipping/clamping a tall menu.
const glass = document.documentElement.dataset.ntGlass === 'on'
const bottom = glass ? Math.max(r.bottom, anchor.closest('.tabbar')?.getBoundingClientRect().bottom ?? 0) : r.bottom
setMenuId(id)
setMenuPos({ top: bottom + 4, left: r.left, flipBase: r.top - 4 })
}
// Viewport-edge flip for the caret menu, same behavior as the right-click ContextMenu. The
// hook runs unconditionally (menuPos may be null while closed; the ref is simply unattached
// then) and re-measures on size changes, so EXPANDING the account/permission sub-lists near
// the bottom edge lifts the menu instead of growing it off-screen.
const menuFlip = useMenuFlip(menuPos?.top ?? 0, menuPos?.left ?? 0, menuPos?.flipBase)
const startRename = (id: string, current: string) => {
setEditingId(id)
// Start from what a rename would store, so an over-long name (issue #940) is shown cut.
setDraft(clampProjectName(current))
setDraftStart(current)
closeMenu()
}
const commitRename = () => {
if (editingId) {
const name = draft.trim()
if (name && name !== draftStart) onRename(editingId, name)
}
setEditingId(null)
}
// Drop-at-end: the wrapper (gap between pill and +, empty title-bar to the right of +,
// and the + itself). Per-tab handlers stopPropagation, so a drop ON a tab is still
// insert-before. The + used to live inside the scroller, so a drop on it already meant
// "after the last tab".
const onEndZoneDragOver = (e: DragEvent) => {
if (!dragId) return
e.preventDefault()
if (dropId !== '') setDropId('')
}
const onEndZoneDrop = (e: DragEvent) => {
if (!dragId) return
e.preventDefault()
onReorder(dragId, null)
setDragId(null)
setDropId(null)
}
// The strip scrolls without a visible scrollbar (see .tabbar__tabs), so keep it navigable:
// a plain mouse wheel scrolls it horizontally, and the active tab is brought into view.
const tabsRef = useRef<HTMLDivElement>(null)
// While a tab is dragged the strip scrolls itself near (or past) its left/right edge, so a tab
// can travel from the far end to the front in one drag.
useDragAutoScroll(tabsRef, 'x', dragId !== null)
const pendingUpdate = usePendingUpdate((s) => s.pending)
useEffect(() => {
tabsRef.current
?.querySelector('.tab.active')
?.scrollIntoView({ behavior: 'smooth', inline: 'nearest', block: 'nearest' })
}, [activeId, projects.length])
// The backdrop deliberately sits BELOW the bar, so a click on another tab switches to it in one
// go instead of being swallowed as a dismiss — which leaves the bar itself (its empty stretch,
// the brand, the +) unable to close the menu. This covers exactly that gap, and it closes
// WITHOUT consuming the event, so the click still lands wherever it was aimed.
useEffect(() => {
if (!menuId) return
const onDown = (e: PointerEvent): void => {
const el = e.target as HTMLElement | null
// The caret owns its own toggle; closing here first would let its click re-open the menu.
if (el?.closest('.tab-menu, .tab__caret')) return
closeMenu()
}
document.addEventListener('pointerdown', onDown, true)
return () => document.removeEventListener('pointerdown', onDown, true)
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [menuId])
return (
<>
{(menuId || editingId) && (
<div
className="tab-backdrop"
onClick={() => {
closeMenu()
commitRename()
}}
/>
)}
<div className="tabbar">
{pendingUpdate && (
// Figma-style: first thing after the traffic lights, accent-filled, no ✕. It stays until
// the update is installed, the card's dismiss never reaches it.
<button
className="tabbar__update"
title={
pendingUpdate.kind === 'downloaded'
? `nodeterm v${pendingUpdate.version} is ready, restart to update`
: pendingUpdate.kind === 'available'
? `nodeterm v${pendingUpdate.version} is available, click to download it`
: pendingUpdate.kind === 'manual'
? `nodeterm v${pendingUpdate.version} is available, download it to update`
: 'This version is no longer supported, update to continue'
}
onClick={() => runPendingUpdate(pendingUpdate)}
>
<IconUpdate />
Update
</button>
)}
<div className="brand">
<svg className="brand__mark" viewBox="0 0 48 48" width="22" height="22" aria-hidden="true">
<defs>
<linearGradient id="ntg" x1="0" y1="0" x2="1" y2="1">
<stop offset="0" stopColor="#a38dff" />
<stop offset="1" stopColor="#622994" />
</linearGradient>
</defs>
<path
d="M13 12 L31 24 L13 36"
fill="none"
stroke="url(#ntg)"
strokeWidth="5"
strokeLinecap="round"
strokeLinejoin="round"
/>
<circle cx="13" cy="12" r="3.6" fill="#a38dff" />
<circle cx="13" cy="36" r="3.6" fill="#a38dff" />
<circle cx="31" cy="24" r="3.6" fill="#fff" />
<rect x="33.5" y="32.5" width="10.5" height="5" rx="2.5" fill="#a38dff" />
</svg>
<span className="brand__name">nodeterm</span>
</div>
{/* Projects group: the pill scrolls; the + is a SIBLING so it cannot scroll away
with the tabs (issue #375). End-zone drop lives on this wrapper (covers the
4px gap and the +); per-tab handlers still stopPropagation. */}
<div
className="tabbar__projects"
onDragOver={onEndZoneDragOver}
onDrop={onEndZoneDrop}
>
<div
className="tabbar__tabs"
ref={tabsRef}
onWheel={(e) => {
// Translate a vertical mouse wheel into horizontal strip scrolling (trackpads
// already produce deltaX). Nothing above the canvas scrolls vertically anyway.
if (Math.abs(e.deltaY) > Math.abs(e.deltaX)) e.currentTarget.scrollLeft += e.deltaY
}}
>
{projects.map((p) => {
const active = isGlobal ? (highlightedId ? p.id === highlightedId : p.id === activeId) : p.id === activeId
const swimlaneHighlight = isGlobal && p.id === highlightedId
const unreadCount = unreadCounts.get(p.id) ?? 0
return (
<div
key={p.id}
className={`tab${active ? ' active' : ''}${swimlaneHighlight ? ' tab--swimlane-highlight' : ''}${p.unavailable ? ' unavailable' : ''}${dropId === p.id ? ' is-drop-before' : ''}${menuId === p.id ? ' tab--menu-open' : ''}`}
// The project colour rides the GLYPH (below), not the label: `.tab.active` is
// neutral text on the page's own surface, like a browser tab. The one exception is
// the swimlane highlight, whose underline is `currentColor` and is meant to be the
// project's colour.
style={swimlaneHighlight ? { color: p.color } : undefined}
draggable={editingId !== p.id}
onMouseEnter={(e) => {
// Not over the rename box or this tab's own open menu, where it would cover them.
if (editingId === p.id || menuId === p.id) return
const label = projectTabTooltip(p, sessionForProject(p.id).source)
if (!label) return
setTabTipLabel(label)
tabTip.triggerProps.onMouseEnter(e)
}}
onMouseLeave={tabTip.triggerProps.onMouseLeave}
onMouseDown={tabTip.triggerProps.onMouseDown}
onDragStart={(e) => {
tabTip.triggerProps.onMouseLeave()
e.dataTransfer.effectAllowed = 'move'
setDragId(p.id)
}}
onDragEnd={() => {
setDragId(null)
setDropId(null)
}}
onDragOver={(e) => {
if (!dragId) return
// Swallow even over the dragged tab itself, so the strip's end-zone
// highlight doesn't flicker on while passing over it.
e.stopPropagation()
if (dragId === p.id) return
e.preventDefault()
if (dropId !== p.id) setDropId(p.id)
}}
onDragLeave={() => setDropId((d) => (d === p.id ? null : d))}
onDrop={(e) => {
if (!dragId || dragId === p.id) return
e.preventDefault()
e.stopPropagation()
onReorder(dragId, p.id)
setDragId(null)
setDropId(null)
}}
onClick={() => {
if (editingId) return
// In global swimlane overview, clicking the top project tab jumps to its
// swimlane instead of switching the canvas project (analog zu Cmd+1..9).
if (isGlobal) {
useViewMode.getState().setHighlightedSwimlaneId(p.id)
window.dispatchEvent(new CustomEvent('nodeterm:swimlane-jump', { detail: { projectId: p.id } }))
return
}
const action = tabClickAction(!!p.unavailable, sessionForProject(p.id).source)
if (action === 'switch') onSwitch(p.id)
else if (action === 'reconnect') onReconnect(p.id)
}}
>
<ProjectGlyph
icon={p.icon}
color={active ? p.color : undefined}
name={p.name}
variant="dot"
// With an icon set, the glyph needs a larger, tint-free box (--icon modifier);
// without one it stays the plain 9px fallback dot, byte-identical to before.
className={p.icon ? 'tab__dot tab__dot--icon' : 'tab__dot'}
/>
{/* An SSH project looks identical to a local one once it is named, and the
difference matters: its terminals, git and file ops all run on another
machine. The chip says so at a glance; the tab title carries user@host. */}
{p.ssh && (
<span className="tab__ssh" title={`${p.ssh.server.user}@${p.ssh.server.host}`}>
SSH
</span>
)}
{/* A relay tab of the host's SSH project: display strings only (relay-ssh.ts). */}
{!p.ssh && p.relaySsh && (
<span className="tab__ssh" title={`${p.relaySsh.user}@${p.relaySsh.host}`}>
SSH
</span>
)}
{editingId === p.id ? (
<input
className="tab__edit"
value={draft}
maxLength={PROJECT_NAME_MAX}
autoFocus
spellCheck={false}
onChange={(e) => setDraft(e.target.value)}
onKeyDown={(e) => {
if (e.key === 'Enter') commitRename()
if (e.key === 'Escape') setEditingId(null)
}}
onBlur={commitRename}
onClick={(e) => e.stopPropagation()}
/>
) : (
<span className="tab__name">{p.name}</span>
)}
{multiSession && <TabSessionLabel projectId={p.id} />}
{pauseCounts[p.id] && (
<span
className="tab__paused"
title={`${pauseCounts[p.id].paused} paused${pauseCounts[p.id].pending ? `, ${pauseCounts[p.id].pending} pausing after their current turn` : ''}`}
>
⏸ {pauseCounts[p.id].paused}
{pauseCounts[p.id].pending ? ` · ${pauseCounts[p.id].pending} pending` : ''}
</span>
)}
{unreadCount > 0 && (
<span className="tab__badge" title={`${unreadCount} unread`}>
{unreadCount}
</span>
)}
{editingId !== p.id && (
// The actions are one cluster with its own rhythm, not two more items in the
// tab's label row: they sit a hair apart from each other and further from the
// name than the name's own parts sit from one another.
<span className="tab__actions">
{active && (
// On the ACTIVE tab only: the toggle says which view you are looking at, and
// on an inactive tab it would flip a project's view without taking you
// there. The chord comes from `commandTooltip`, so a remap or an unbound
// command is not advertised as a chord that no longer works.
<button
className="tab__board-toggle"
title={commandTooltip(
kanbanActive ? 'Canvas view' : 'Kanban view',
'view.kanbanToggle'
)}
aria-label={kanbanActive ? 'Canvas view' : 'Kanban view'}
onClick={(e) => {
e.stopPropagation() // a tab click switches projects, this flips the view
// One decision with ⌘⇧B and the menu (state/viewMode.ts): from any board
// to the canvas, from the canvas into the board.
toggleBoardView(p.id)
}}
>
{kanbanActive ? <IconCanvasView /> : <IconKanban />}
</button>
)}
<button
className="tab__caret"
title="Project options"
aria-label="Project options"
onClick={(e) => {
e.stopPropagation()
if (menuId === p.id) closeMenu()
else openMenu(p.id, e.currentTarget)
}}
>
<IconMoreVertical />
</button>
</span>
)}
</div>
)
})}
{/* The end-of-strip drop zone (`dropId === ''`) had no marker at all — every other target
draws its line as the `::before` of the tab it lands in front of, and "after the last
one" has no such tab. It lives INSIDE the scroller so it lands after the last tab
rather than at the window edge. Rendered only mid-drag, and its negative margins
cancel its own width so appearing costs no layout shift. */}
{dragId && dropId === '' && <span className="tab__dropline" aria-hidden />}
</div>
<button
type="button"
className="tab__add"
title="New project"
aria-label="New project"
onClick={onOpenWelcome}
>
<IconPlus />
</button>
</div>
</div>
{tabTip.bubble}
{menuId &&
menuPos &&
menuProject &&
createPortal(
<div
ref={menuFlip.ref}
className="tab-menu"
style={{ top: menuFlip.top, left: menuFlip.left }}
onClick={(e) => e.stopPropagation()}
>
<button onClick={() => startRename(menuProject.id, menuProject.name)}>Rename</button>
<button
onClick={() => {
onSetFolder(menuProject.id)
closeMenu()
}}
>
Set folder…
</button>
{onMoveStorage &&
menuProject.cwd &&
!menuProject.ssh &&
!menuProject.remote &&
!menuProject.unavailable && (
<button
onClick={() => {
onMoveStorage(menuProject.id, menuProject.storeInAppData ? 'folder' : 'appData')
closeMenu()
}}
>
{menuProject.storeInAppData ? 'Store canvas in folder' : 'Store canvas in app data'}
</button>
)}
<button
onClick={() => {
onRemoteAccess()
closeMenu()
}}
>
Remote access…
</button>
{menuProject.ssh &&
!menuProject.remote &&
onShareWithTeam &&
(() => {
const blocked = shareBlockedReason?.(menuProject.id) ?? null
return (
<button
disabled={!!blocked}
title={blocked ?? undefined}
onClick={() => {
onShareWithTeam(menuProject.id)
closeMenu()
}}
>
Share with team…
</button>
)
})()}
{menuAccounts.length > 0 && (
<>
<button
className={`tab-menu__group${acctOpen ? ' open' : ''}`}
onClick={() => setAcctOpen((v) => !v)}
>
Default Claude account
<span className="tab-menu__caret">▸</span>
</button>
{acctOpen && (
<div className="tab-menu__sub">
<button
onClick={() => {
onSetDefaultAccount(menuProject.id, undefined)
closeMenu()
}}
>
<span className="tab-menu__check">
{menuProject.defaultAccountId ? '' : '✓'}
</span>
{systemLabel}
</button>
{menuAccounts.map((a) => (
<button
key={a.id}
onClick={() => {
onSetDefaultAccount(menuProject.id, a.id)
closeMenu()
}}
>
<span className="tab-menu__check">
{menuProject.defaultAccountId === a.id ? '✓' : ''}
</span>
{a.label}
</button>
))}
{menuAccountsHint && (
<button disabled title={menuAccountsHint}>
<span className="tab-menu__check" />
No accounts on this host yet
</button>
)}
</div>
)}
</>
)}
<button
className={`tab-menu__group${modeOpen ? ' open' : ''}`}
onClick={() => setModeOpen((v) => !v)}
>
Default permission mode
<span className="tab-menu__caret">▸</span>
</button>
{modeOpen && (
<div className="tab-menu__sub">
<button
// On an SSH project the global Auto only applies once the REMOTE CLI is
// confirmed, surface why it may currently do nothing (see menuAutoHint).
title={globalMode === 'auto' ? (menuAutoHint ?? undefined) : undefined}
onClick={() => {
onSetDefaultPermissionMode(menuProject.id, undefined)
closeMenu()
}}
>
<span className="tab-menu__check">
{menuProject.defaultPermissionMode ? '' : '✓'}
</span>
Use global ({PERMISSION_MODE_LABELS[globalMode]})
{globalMode === 'auto' && menuAutoHint ? ' ⚠︎' : ''}
</button>
{ALL_PERMISSION_MODES.map((m) => (
<button
key={m}
// A project override is written to <cwd>/.nodeterm/project.json, which is
// git-shared and mirrored to SSH servers, spell out for "Bypass all" that
// the choice travels to everyone who clones the repo. The Auto row instead
// explains when it will NOT apply on this SSH project's host (remote CLI too
// old / not found / not probed yet), still selectable: the setting is kept
// and applies the moment the host's CLI qualifies.
title={
m === 'bypassPermissions'
? // Both the agent list and the sandbox caveat are derived from the mapping
// (approval-mode.ts): the list names exactly the agents "Bypass all"
// actually reaches, so it cannot warn about an agent the mode never applies
// to — or fall silent about one it newly does. The caveat is owed because
// for codex the mode skips APPROVALS only: `--ask-for-approval never` does
// not touch `--sandbox`, which we deliberately leave alone, so "no
// permission checks" must not be read as "no sandbox either".
`Skips every permission prompt. This override is saved in the project file (.nodeterm/project.json), so if you commit it, everyone who clones the repo runs their ${permissionModeAgentsLabel({ mode: 'bypassPermissions', caps: codexApprovalCaps() })} sessions without permission checks too. ${bypassSandboxCaveat(codexApprovalCaps())}`.trim()
: m === 'auto'
? (menuAutoHint ?? undefined)
: undefined
}
onClick={() => {
onSetDefaultPermissionMode(menuProject.id, m)
closeMenu()
}}
>
<span className="tab-menu__check">
{menuProject.defaultPermissionMode === m ? '✓' : ''}
</span>
{m === 'bypassPermissions' || (m === 'auto' && menuAutoHint)
? `${PERMISSION_MODE_LABELS[m]} ⚠︎`
: PERMISSION_MODE_LABELS[m]}
</button>
))}
</div>
)}
{
// Agent canvas-control confirms, per project: the SAME machine-local waiver the
// dialog's "Don't ask again for agents in …" grants (settings.json, never the
// git-shared project.json), reachable before any dialog has appeared. ✓ means agents
// in this project do it WITHOUT asking — the EFFECTIVE answer, read through the gate's
// own table (`projectWaiverRow`), so an app-run, machine-wide or Bypass waiver shows
// here too instead of the row promising a dialog that will not come.
// Desktop only: in the browser Server Edition canvas control is headless and gated by
// creator ownership, not by these waivers (@shared/control-confirm), so the rows would
// change nothing. A relay tab is another machine's project and its confirms are that
// machine's to waive.
!menuProject.remote &&
!isBrowserRuntime() && (
<>
<button
className={`tab-menu__group${agentActsOpen ? ' open' : ''}`}
onClick={() => setAgentActsOpen((v) => !v)}
>
Agents may, without asking
<span className="tab-menu__caret">▸</span>
</button>
{agentActsOpen && (
<div className="tab-menu__sub">
{[...CONFIRM_WAIVABLE_VERBS].map((verb) => {
const row = projectWaiverRow(verb, menuProject.id)
// Another waiver still applies without this project's grant, so the row
// cannot make agents ask again — name it and where it is revoked.
const elsewhere = row.otherVia !== null
return (
<button
key={verb}
disabled={elsewhere && !row.granted}
title={
elsewhere
? otherWaiverHint(row.otherVia!)
: row.granted
? `Agents in "${menuProject.name}" do this without a confirm dialog (this computer only). Click to ask again.`
: `Agents in "${menuProject.name}" ask you first. Click to let them do this without asking (this computer only).`
}
onClick={() => {
setControlConfirmWaivedForProject(verb, menuProject.id, !row.granted)
}}
>
<span className="tab-menu__check">{row.skips ? '✓' : ''}</span>
{WAIVABLE_VERB_ACTIONS[verb] ?? verb}
</button>
)
})}
</div>
)}
</>
)
}
<button
onClick={() => {
onOpenProjectSettings(menuProject.id)
closeMenu()
}}
>
Project settings…
</button>
{/* The id a `nodeterm://open?project=<id>` link names (another app's config maps its
repositories to these ids). A relay tab's id belongs to the host, which a link here
cannot open. */}
{!menuProject.remote && (
<button
onClick={() => {
window.nodeTerminal.clipboard.writeText(menuProject.id)
closeMenu()
}}
>
Copy project id
</button>
)}
<button
onClick={() => {
onPauseProject(menuProject.id)
closeMenu()
}}
>
Pause project
</button>
{(pauseCounts[menuProject.id]?.pending ?? 0) > 0 && (
<button
onClick={() => {
onCancelPendingPauses(menuProject.id)
closeMenu()
}}
>
Cancel pending pauses
</button>
)}
{/* Chromium shows no `title` for a DISABLED button (it receives no pointer events), so
the reason sits on a wrapper the pointer can reach; the disabled button lets the
pointer through to it (`.tab-menu__reason > button:disabled`). */}
<span
className="tab-menu__reason"
title={menuProject.id !== activeId ? 'Open the project to resume' : undefined}
>
<button
// Resume needs each node's mounted terminal (it re-launches the CLI into the pane
// and guards the typing), and only the active project's nodes are mounted.
disabled={menuProject.id !== activeId}
onClick={() => {
onResumeAllProject(menuProject.id)
closeMenu()
}}
>
Resume all
</button>
</span>
<button
onClick={() => {
onCloseProject(menuProject.id)
closeMenu()
}}
>
Close project
</button>
</div>,
document.body
)}
</>
)
}