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(projects): one drag-droppable project order shared by tab bar + sidebar
enesb1b85dae91d4
diff --git a/src/renderer/canvas/Canvas.tsx b/src/renderer/canvas/Canvas.tsxindex 0df5d6c8e..c778f7d4f 100644--- a/src/renderer/canvas/Canvas.tsx+++ b/src/renderer/canvas/Canvas.tsx@@ -4732,6 +4732,16 @@ export function Canvas() {// Sidebar reorder: place draggedId immediately before beforeId (sidebar order = node order),// joining the target's container if they differ.+ // Reorder a project (tab-bar drag or sidebar header drag — both surfaces share the projects+ // array, so a change in one immediately reflects in the other). Persisted like reorderNode.+ const reorderProject = useCallback(+ (draggedId: string, beforeId: string | null) => {+ useProjects.getState().reorderProject(draggedId, beforeId)+ void writeDisk()+ },+ [writeDisk]+ )+const reorderSession = useCallback((projectId: string, draggedId: string, beforeId: string) => {if (projectId === activeProjectId) {@@ -5454,6 +5464,7 @@ export function Canvas() {<TabBaronSwitch={switchProject}onReconnect={reconnectRelay}+ onReorder={reorderProject}onOpenWelcome={() => setWelcomeOpen(true)}onRename={renameProject}onSetFolder={setProjectFolder}@@ -5883,6 +5894,7 @@ export function Canvas() {onFocusNode={focusNodeById}onCloseSession={closeSession}onRenameSession={renameSession}+ onReorderProject={reorderProject}onAiNameSession={aiNameSession}onAiNameGroup={aiNameGroup}onMoveToGroup={moveSessionToGroup}diff --git a/src/renderer/components/SessionsSidebar.tsx b/src/renderer/components/SessionsSidebar.tsxindex d4ea26cfc..5db84f57f 100644--- a/src/renderer/components/SessionsSidebar.tsx+++ b/src/renderer/components/SessionsSidebar.tsx@@ -32,6 +32,9 @@ export interface SessionsSidebarProps {onAiNameGroup(projectId: string, groupId: string, memberIds: string[], cwd?: string): void | Promise<void>/** Reorder a session to sit immediately before another (within/across containers). */onReorder(projectId: string, draggedId: string, beforeId: string): void+ /** Reorder a project to sit before another (null = to the end). Shared order with the+ * tab bar: both render the projects array, so one drag updates both surfaces. */+ onReorderProject(draggedId: string, beforeId: string | null): voidonMouseEnter?(): voidonMouseLeave?(): void}@@ -57,6 +60,10 @@ export function SessionsSidebar(props: SessionsSidebarProps): JSX.Element | null// Drag-to-group: the session being dragged, and the current drop target for highlighting.const [drag, setDrag] = useState<{ projectId: string; nodeId: string } | null>(null)const [dropKey, setDropKey] = useState<string | null>(null)+ // Project reorder: the project being dragged (by its header) + the project it would land+ // before ('' = end of the list). Distinct from the session drag above — one at a time.+ const [dragProj, setDragProj] = useState<string | null>(null)+ const [dropProj, setDropProj] = useState<string | null>(null)// Inline group rename: the group node id being edited + its draft title.const [editGroup, setEditGroup] = useState<{ id: string; draft: string } | null>(null)@@ -135,6 +142,27 @@ export function SessionsSidebar(props: SessionsSidebarProps): JSX.Element | nullconst dropClass = (projectId: string, groupId: string | null): string =>dropKey === dropTargetKey(projectId, groupId) ? ' is-drop-target' : ''+ // Project-header drop wiring while a PROJECT drag is in flight (the session dropProps above+ // take the header otherwise — only one kind of drag happens at a time).+ const projDropProps = (projectId: string): React.HTMLAttributes<HTMLDivElement> => ({+ onDragOver: (e) => {+ if (!dragProj) return+ e.stopPropagation()+ if (dragProj === projectId) return+ e.preventDefault()+ if (dropProj !== projectId) setDropProj(projectId)+ },+ onDragLeave: () => setDropProj((d) => (d === projectId ? null : d)),+ onDrop: (e) => {+ if (!dragProj || dragProj === projectId) return+ e.preventDefault()+ e.stopPropagation()+ props.onReorderProject(dragProj, projectId)+ setDragProj(null)+ setDropProj(null)+ }+ })+// A row is both draggable and a drop target: dropping another row onto it reorders the// dragged session to sit immediately before this one. stopPropagation keeps the enclosing// group/ungrouped drop zone (which appends) from also firing.@@ -211,18 +239,49 @@ export function SessionsSidebar(props: SessionsSidebarProps): JSX.Element | null/></div>- <div className="sessions-sidebar__body">+ <div+ className="sessions-sidebar__body"+ // The body's empty space is the project drag's "drop at the end" zone (headers+ // stopPropagation their own drops).+ onDragOver={(e) => {+ if (!dragProj) return+ e.preventDefault()+ if (dropProj !== '') setDropProj('')+ }}+ onDrop={(e) => {+ if (!dragProj) return+ e.preventDefault()+ props.onReorderProject(dragProj, null)+ setDragProj(null)+ setDropProj(null)+ }}+ >{groups.length === 0 && <div className="sessions-sidebar__empty">No sessions yet.</div>}{groups.map((g) => {const isCollapsed = isGroupCollapsed(overrides, g.projectId, g.isActive)const signals = projectSignalCounts(g)return (- <div key={g.projectId} className={`ss-group${g.isActive ? ' is-active' : ''}`}>+ <div+ key={g.projectId}+ className={`ss-group${g.isActive ? ' is-active' : ''}${dropProj === g.projectId ? ' is-drop-before' : ''}`}+ // While a project drag is in flight the whole block is a REORDER target (the+ // session drop handlers below no-op and let the events bubble up here).+ {...(dragProj ? projDropProps(g.projectId) : {})}+ ><divclassName={`ss-group__head${dropClass(g.projectId, null)}`}onClick={() => toggleCollapse(g.projectId, isCollapsed)}onContextMenu={(e) => props.onProjectContextMenu(e, g.projectId)}title={drag?.projectId === g.projectId ? 'Drop here to remove from group' : undefined}+ draggable+ onDragStart={(e) => {+ e.dataTransfer.effectAllowed = 'move'+ setDragProj(g.projectId)+ }}+ onDragEnd={() => {+ setDragProj(null)+ setDropProj(null)+ }}{...dropProps(g.projectId, null)}><span className="ss-group__chev">{isCollapsed ? '▶' : '▼'}</span>diff --git a/src/renderer/components/TabBar.tsx b/src/renderer/components/TabBar.tsxindex 50b261912..f84ce426b 100644--- a/src/renderer/components/TabBar.tsx+++ b/src/renderer/components/TabBar.tsx@@ -20,6 +20,9 @@ interface TabBarProps {/** 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: () => voidonRename: (id: string, name: string) => void@@ -59,6 +62,7 @@ function TabSessionLabel({ projectId }: { projectId: string }) {export function TabBar({onSwitch,onReconnect,+ onReorder,onOpenWelcome,onRename,onSetFolder,@@ -85,6 +89,9 @@ export function TabBar({const [menuPos, setMenuPos] = useState<{ top: number; left: number } | null>(null)const [editingId, setEditingId] = useState<string | null>(null)const [draft, setDraft] = 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).@@ -207,6 +214,19 @@ export function TabBar({// already produce deltaX). Nothing above the canvas scrolls vertically anyway.if (Math.abs(e.deltaY) > Math.abs(e.deltaX)) e.currentTarget.scrollLeft += e.deltaY}}+ // The strip itself is the "drop at the end" zone (per-tab handlers stopPropagation).+ onDragOver={(e) => {+ if (!dragId) return+ e.preventDefault()+ if (dropId !== '') setDropId('')+ }}+ onDrop={(e) => {+ if (!dragId) return+ e.preventDefault()+ onReorder(dragId, null)+ setDragId(null)+ setDropId(null)+ }}>{projects.map((p) => {const active = p.id === activeId@@ -214,8 +234,35 @@ export function TabBar({return (<divkey={p.id}- className={`tab${active ? ' active' : ''}${p.unavailable ? ' unavailable' : ''}`}+ className={`tab${active ? ' active' : ''}${p.unavailable ? ' unavailable' : ''}${dropId === p.id ? ' is-drop-before' : ''}`}style={active ? { color: p.color } : undefined}+ draggable={editingId !== p.id}+ onDragStart={(e) => {+ 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// An unavailable tab distinguishes by its bound session source: a dropped RELAYdiff --git a/src/renderer/lib/sessionList.test.ts b/src/renderer/lib/sessionList.test.tsindex 729747bfd..69ddb5c0c 100644--- a/src/renderer/lib/sessionList.test.ts+++ b/src/renderer/lib/sessionList.test.ts@@ -44,10 +44,10 @@ describe('isGroupCollapsed', () => {})describe('buildSessionList', () => {- it('groups by project with the active project first', () => {+ it('keeps store order (mirrors the tab bar) regardless of which project is active', () => {const groups = buildSessionList(projects(), null, 'p2', {}, '')- expect(groups.map((g) => g.projectId)).toEqual(['p2', 'p1'])- expect(groups[0].isActive).toBe(true)+ expect(groups.map((g) => g.projectId)).toEqual(['p1', 'p2'])+ expect(groups.find((g) => g.projectId === 'p2')!.isActive).toBe(true)})it('keeps only terminal/agent nodes and flags agents', () => {diff --git a/src/renderer/lib/sessionList.ts b/src/renderer/lib/sessionList.tsindex 6fc47d294..f35ed1bab 100644--- a/src/renderer/lib/sessionList.ts+++ b/src/renderer/lib/sessionList.ts@@ -184,8 +184,7 @@ export function buildSessionList(}})- const ordered = [...groups.filter((g) => g.isActive), ...groups.filter((g) => !g.isActive)]- return needle- ? ordered.filter((g) => g.groups.length > 0 || g.ungrouped.length > 0)- : ordered+ // Store order, NOT active-first: the sidebar mirrors the tab bar (both read the projects+ // array), and hoisting the active project to the top made every click reshuffle the list.+ return needle ? groups.filter((g) => g.groups.length > 0 || g.ungrouped.length > 0) : groups}diff --git a/src/renderer/state/projects.ts b/src/renderer/state/projects.tsindex 7b2d7f2ec..3fea76f29 100644--- a/src/renderer/state/projects.ts+++ b/src/renderer/state/projects.ts@@ -81,6 +81,9 @@ interface ProjectsState {/** Reorders a node to sit immediately before another (sidebar order = array order),* joining the target's container if they differ. */reorderNode(projectId: string, draggedId: string, beforeId: string): void+ /** Reorders a project to sit immediately before another (tab bar + sidebar order = array+ * order), or to the end with beforeId = null. Closed projects keep their slots. */+ reorderProject(draggedId: string, beforeId: string | null): void/** Removes a project permanently; returns the id that should become active ('' = welcome). */deleteProject(id: string): string/** Hides a project from the tab bar without destroying it; returns the next active open@@ -327,6 +330,19 @@ export const useProjects = create<ProjectsState>((set, get) => ({}))},+ reorderProject(draggedId, beforeId) {+ set((s) => {+ if (draggedId === beforeId) return s+ const dragged = s.projects.find((p) => p.id === draggedId)+ if (!dragged) return s+ const without = s.projects.filter((p) => p.id !== draggedId)+ const idx = beforeId ? without.findIndex((p) => p.id === beforeId) : -1+ // Unknown/null target → append (the "drop at the end" zone).+ const at = idx === -1 ? without.length : idx+ return { projects: [...without.slice(0, at), dragged, ...without.slice(at)] }+ })+ },+deleteProject(id) {const { projects, activeProjectId } = get()const index = projects.findIndex((p) => p.id === id)diff --git a/src/renderer/styles.css b/src/renderer/styles.cssindex 0807b0d75..248470d6f 100644--- a/src/renderer/styles.css+++ b/src/renderer/styles.css@@ -4893,6 +4893,11 @@ body,/* Reorder: insertion line above the row the dragged session will land before */.ss-rowdrop { position: relative; }.ss-rowdrop.is-drop-before::before { content: ''; position: absolute; top: -1px; left: 6px; right: 6px; height: 2px; border-radius: 1px; background: var(--accent); pointer-events: none; }+/* Project reorder: vertical insertion line before the tab / horizontal line above the+ sidebar project header the dragged project will land before */+.tab.is-drop-before::before { content: ''; position: absolute; left: -3px; top: 4px; bottom: 4px; width: 2px; border-radius: 1px; background: var(--accent); pointer-events: none; }+.ss-group { position: relative; }+.ss-group.is-drop-before::before { content: ''; position: absolute; top: -1px; left: 6px; right: 6px; height: 2px; border-radius: 1px; background: var(--accent); pointer-events: none; z-index: 1; }.sessions-icon-cluster { position: absolute; top: 54px; left: 14px; z-index: 11; }.sessions-icon-cluster button { width: 34px; height: 34px; display: inline-flex; align-items: center; justify-content: center; background: rgba(40, 40, 42, 0.92); border: 1px solid var(--border); border-radius: 9px; color: var(--text); cursor: pointer; box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3); }