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(projects): non-destructive Close project + Recently closed reopen

enes53373e38ff6c
diff --git a/src/renderer/canvas/Canvas.tsx b/src/renderer/canvas/Canvas.tsx
index 13fcb23e6..311132959 100644
--- a/src/renderer/canvas/Canvas.tsx
+++ b/src/renderer/canvas/Canvas.tsx
@@ -221,7 +221,10 @@ export function Canvas() {
useReactFlow()
const activeProjectId = useProjects((s) => s.activeProjectId)
- const hasProjects = useProjects((s) => s.projects.length > 0)
+ // "Has projects" = at least one OPEN (non-closed) tab. With only closed projects left, the
+ // welcome screen shows (and lists them under "Recently closed" for reopening).
+ const hasProjects = useProjects((s) => s.projects.some((p) => !p.closed))
+ const closedProjects = useProjects((s) => s.projects.filter((p) => p.closed))
// The active project's SSH server (if it's an SSH project) — drives the connection banner.
const activeSshServer = useProjects(
(s) => s.projects.find((p) => p.id === s.activeProjectId)?.ssh?.server
@@ -2246,6 +2249,34 @@ export function Canvas() {
[persist]
)
+ // Close a project: hide it from the tab bar but keep it (and its tmux/agent sessions) intact
+ // so it can be reopened later from the start screen. Non-destructive — the inverse of the old
+ // "Delete project". Switching away unmounts its nodes (a detach, not a kill); the sessions
+ // survive exactly like a project switch, and a cold restart later reconstructs them.
+ const closeProject = useCallback(
+ (id: string) => {
+ const store = useProjects.getState()
+ if (id === store.activeProjectId) commitActiveToStore()
+ store.closeProject(id)
+ void writeDisk()
+ },
+ [commitActiveToStore, writeDisk]
+ )
+
+ // Reopen a previously closed project and make it active — the active-project effect reloads its
+ // serialized nodes, whose TerminalNodes reattach to the surviving tmux sessions (or cold-restore).
+ const reopenProject = useCallback(
+ (id: string) => {
+ commitActiveToStore()
+ useProjects.getState().reopenProject(id)
+ setWelcomeOpen(false)
+ void writeDisk()
+ },
+ [commitActiveToStore, writeDisk]
+ )
+
+ // Permanently remove a project (from the "Recently closed" list): end every terminal's tmux
+ // session, drop persisted agent status, tear down any SSH master, then delete it from disk.
const deleteProject = useCallback(
(id: string) => {
const store = useProjects.getState()
@@ -2382,7 +2413,7 @@ export function Canvas() {
onOpenWelcome={() => setWelcomeOpen(true)}
onRename={renameProject}
onSetFolder={setProjectFolder}
- onDelete={deleteProject}
+ onCloseProject={closeProject}
onRemoteAccess={() => setRemoteDialogOpen(true)}
/>
@@ -2553,6 +2584,9 @@ export function Canvas() {
setWelcomeOpen(false)
setSshDialogOpen(true)
}}
+ closedProjects={closedProjects.map((p) => ({ id: p.id, name: p.name, cwd: p.cwd }))}
+ onReopen={reopenProject}
+ onDeleteClosed={deleteProject}
onClose={hasProjects ? () => setWelcomeOpen(false) : undefined}
/>
)}
diff --git a/src/renderer/components/TabBar.tsx b/src/renderer/components/TabBar.tsx
index b75a7f9c0..cbb654e4b 100644
--- a/src/renderer/components/TabBar.tsx
+++ b/src/renderer/components/TabBar.tsx
@@ -9,7 +9,8 @@ interface TabBarProps {
onOpenWelcome: () => void
onRename: (id: string, name: string) => void
onSetFolder: (id: string) => void
- onDelete: (id: string) => 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
}
@@ -25,10 +26,11 @@ export function TabBar({
onOpenWelcome,
onRename,
onSetFolder,
- onDelete,
+ onCloseProject,
onRemoteAccess
}: TabBarProps) {
- const projects = useProjects((s) => s.projects)
+ // Closed projects are hidden here (reopen them from the start screen's "Recently closed").
+ const projects = useProjects((s) => s.projects.filter((p) => !p.closed))
const activeId = useProjects((s) => s.activeProjectId)
const statusById = useAgentStatus((s) => s.byId)
const [menuId, setMenuId] = useState<string | null>(null)
@@ -190,13 +192,12 @@ export function TabBar({
Remote access…
</button>
<button
- className="danger"
onClick={() => {
- onDelete(menuProject.id)
+ onCloseProject(menuProject.id)
closeMenu()
}}
>
- Delete project
+ Close project
</button>
</div>,
document.body
diff --git a/src/renderer/components/WelcomeScreen.tsx b/src/renderer/components/WelcomeScreen.tsx
index 4d46eaf34..486260327 100644
--- a/src/renderer/components/WelcomeScreen.tsx
+++ b/src/renderer/components/WelcomeScreen.tsx
@@ -6,6 +6,12 @@ interface WelcomeScreenProps {
onCloneRepo: () => void
/** Open the "Connect over SSH…" flow to create a project hosted on a remote server. */
onConnectSsh: () => void
+ /** Closed projects that can be reopened (id + display name + folder). */
+ closedProjects?: { id: string; name: string; cwd?: string }[]
+ /** Reopen a closed project (restores its nodes + sessions). */
+ onReopen?: (id: string) => void
+ /** Permanently delete a closed project (ends its tmux sessions). */
+ onDeleteClosed?: (id: string) => void
/**
* When provided, the screen is dismissable (opened on demand via "+", over existing projects)
* — adds a close button, Escape, and click-outside. Omitted for the permanent no-projects screen.
@@ -19,6 +25,9 @@ export function WelcomeScreen({
onOpenFolder,
onCloneRepo,
onConnectSsh,
+ closedProjects = [],
+ onReopen,
+ onDeleteClosed,
onClose
}: WelcomeScreenProps) {
useEffect(() => {
@@ -112,6 +121,46 @@ export function WelcomeScreen({
<span>Connect over SSH…</span>
</button>
</div>
+
+ {closedProjects.length > 0 && (
+ <div className="welcome__recent">
+ <div className="welcome__recent-title">Recently closed</div>
+ <div className="welcome__recent-list">
+ {closedProjects.map((p) => (
+ <div
+ key={p.id}
+ className="welcome__recent-item"
+ role="button"
+ tabIndex={0}
+ title={p.cwd || p.name}
+ onClick={() => onReopen?.(p.id)}
+ onKeyDown={(e) => {
+ if (e.key === 'Enter' || e.key === ' ') onReopen?.(p.id)
+ }}
+ >
+ <svg viewBox="0 0 24 24" width="15" height="15" fill="none" stroke="currentColor" strokeWidth="1.6" strokeLinecap="round" strokeLinejoin="round">
+ <path d="M3 7a2 2 0 0 1 2-2h4l2 2h8a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z" />
+ </svg>
+ <span className="welcome__recent-name">{p.name}</span>
+ {p.cwd && <span className="welcome__recent-path">{p.cwd}</span>}
+ {onDeleteClosed && (
+ <button
+ className="welcome__recent-del"
+ title="Delete permanently (ends its sessions)"
+ aria-label="Delete permanently"
+ onClick={(e) => {
+ e.stopPropagation()
+ onDeleteClosed(p.id)
+ }}
+ >
+ ×
+ </button>
+ )}
+ </div>
+ ))}
+ </div>
+ </div>
+ )}
</div>
)
}
diff --git a/src/renderer/state/projects.ts b/src/renderer/state/projects.ts
index 6dab235b5..6686fd7fe 100644
--- a/src/renderer/state/projects.ts
+++ b/src/renderer/state/projects.ts
@@ -30,8 +30,13 @@ 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
- /** Removes a project; returns the id that should become active (never deletes the last one). */
+ /** 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
+ * project id ('' = welcome screen). The project (and its sessions) is kept for reopening. */
+ closeProject(id: string): string
+ /** Restores a closed project and makes it active. No-op if the id is unknown. */
+ reopenProject(id: string): void
toWorkspace(): Workspace
}
@@ -195,6 +200,33 @@ export const useProjects = create<ProjectsState>((set, get) => ({
return nextActive
},
+ closeProject(id) {
+ const { projects, activeProjectId } = get()
+ const index = projects.findIndex((p) => p.id === id)
+ const next = projects.map((p) => (p.id === id ? { ...p, closed: true } : p))
+ let nextActive = activeProjectId
+ if (activeProjectId === id) {
+ // Move focus to the nearest still-open project (search outward), or the welcome screen.
+ const open = next.filter((p) => !p.closed)
+ const byDistance = open
+ .map((p) => ({ id: p.id, d: Math.abs(next.findIndex((q) => q.id === p.id) - index) }))
+ .sort((a, b) => a.d - b.d)
+ nextActive = byDistance.length ? byDistance[0].id : ''
+ }
+ set({ projects: next, activeProjectId: nextActive })
+ return nextActive
+ },
+
+ reopenProject(id) {
+ set((s) => {
+ if (!s.projects.some((p) => p.id === id)) return s
+ return {
+ projects: s.projects.map((p) => (p.id === id ? { ...p, closed: false } : p)),
+ activeProjectId: id
+ }
+ })
+ },
+
toWorkspace() {
const { projects, activeProjectId } = get()
return { version: 2, activeProjectId, projects }
diff --git a/src/renderer/styles.css b/src/renderer/styles.css
index 804aa4ab7..8cd98fff7 100644
--- a/src/renderer/styles.css
+++ b/src/renderer/styles.css
@@ -1427,6 +1427,95 @@ body,
color: var(--accent);
}
+/* ---- "Recently closed" projects list on the start screen ---- */
+.welcome__recent {
+ margin-top: 28px;
+ width: 100%;
+ max-width: 480px;
+}
+
+.welcome__recent-title {
+ font-size: 11px;
+ font-weight: 600;
+ letter-spacing: 0.04em;
+ text-transform: uppercase;
+ color: var(--muted);
+ margin-bottom: 8px;
+ padding-left: 2px;
+}
+
+.welcome__recent-list {
+ display: flex;
+ flex-direction: column;
+ gap: 4px;
+ max-height: 220px;
+ overflow-y: auto;
+}
+
+.welcome__recent-item {
+ display: flex;
+ align-items: center;
+ gap: 8px;
+ padding: 8px 10px;
+ border-radius: 8px;
+ border: 1px solid transparent;
+ color: var(--text);
+ cursor: pointer;
+ transition: background 0.12s, border-color 0.12s;
+}
+
+.welcome__recent-item:hover {
+ background: var(--panel);
+ border-color: var(--border);
+}
+
+.welcome__recent-item svg {
+ color: var(--muted);
+ flex: none;
+}
+
+.welcome__recent-name {
+ font-size: 13px;
+ flex: none;
+}
+
+.welcome__recent-path {
+ font-size: 11px;
+ color: var(--muted);
+ overflow: hidden;
+ text-overflow: ellipsis;
+ white-space: nowrap;
+ flex: 1;
+}
+
+.welcome__recent-del {
+ margin-left: auto;
+ flex: none;
+ width: 20px;
+ height: 20px;
+ display: flex;
+ align-items: center;
+ justify-content: center;
+ background: transparent;
+ border: none;
+ border-radius: 5px;
+ color: var(--muted);
+ font-size: 16px;
+ line-height: 1;
+ cursor: pointer;
+ opacity: 0;
+ transition: opacity 0.12s, background 0.12s, color 0.12s;
+}
+
+.welcome__recent-item:hover .welcome__recent-del {
+ opacity: 1;
+}
+
+.welcome__recent-del:hover {
+ background: rgba(255, 69, 58, 0.15);
+ color: #ff453a;
+}
+
/* ---- Right-click context menu ---- */
.ctx-backdrop {
position: fixed;