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): unhideProject — un-close without activating (#925)

review0c1ca12d6edc
diff --git a/src/renderer/state/projects.test.ts b/src/renderer/state/projects.test.ts
index 346cd5158..13c70f21c 100644
--- a/src/renderer/state/projects.test.ts
+++ b/src/renderer/state/projects.test.ts
@@ -259,3 +259,27 @@ describe('capability setters schedule a workspace save', () => {
}
})
})
+
+// #925: canvas-control `--run-now` into a "Recently closed" project restores its tab but must not
+// travel the user's view — `reopenProject` is the human path and also activates.
+describe('unhideProject (#925)', () => {
+ it('restores a closed project WITHOUT activating it', () => {
+ const a = useProjects.getState().addProject('A')
+ const b = useProjects.getState().addProject('B')
+ useProjects.getState().closeProject(b.id)
+ useProjects.getState().setActive(a.id)
+
+ useProjects.getState().unhideProject(b.id)
+ const s = useProjects.getState()
+ expect(s.projects.find((p) => p.id === b.id)?.closed).toBe(false)
+ expect(s.activeProjectId).toBe(a.id)
+ })
+
+ it('is a no-op for an unknown id', () => {
+ const a = useProjects.getState().addProject('A')
+ useProjects.getState().setActive(a.id)
+ useProjects.getState().unhideProject('zzz')
+ expect(useProjects.getState().projects).toHaveLength(1)
+ expect(useProjects.getState().activeProjectId).toBe(a.id)
+ })
+})
diff --git a/src/renderer/state/projects.ts b/src/renderer/state/projects.ts
index 5de7eb695..1b02d773b 100644
--- a/src/renderer/state/projects.ts
+++ b/src/renderer/state/projects.ts
@@ -185,6 +185,10 @@ interface ProjectsState {
closeProject(id: string): string
/** Restores a closed project and makes it active. No-op if the id is unknown. */
reopenProject(id: string): void
+ /** Un-close a project WITHOUT making it active: a closed tab reappears, the camera stays put.
+ * For work that landed while the user was elsewhere (`registerProject`, canvas-control
+ * `--run-now` #925). `reopenProject` is the human path and also activates. */
+ unhideProject(id: string): void
/** Records freshly deleted sessions into the project's history (newest-first, capped at
* `CLOSED_SESSIONS_CAP`). No-op if `entries` is empty or the project no longer exists. */
@@ -860,6 +864,13 @@ export const useProjects = create<ProjectsState>((set, get) => ({
})
},
+ unhideProject(id) {
+ set((s) => {
+ if (!s.projects.some((p) => p.id === id && p.closed)) return s
+ return { projects: s.projects.map((p) => (p.id === id ? { ...p, closed: false } : p)) }
+ })
+ },
+
registerProject({ resolvedCwd, name, color, probed }) {
// The same exact-match rule as `openFolderProject` (a folder maps to one project), with the
// trailing slash stripped so `/a/b/` and `/a/b` cannot mint two tabs for one directory.
@@ -870,9 +881,7 @@ export const useProjects = create<ProjectsState>((set, get) => ({
if (existing.closed) {
// Un-close WITHOUT activation — reopenProject also activates, which is the exact
// mutation the register tests are checked against (spec P6).
- set((s) => ({
- projects: s.projects.map((p) => (p.id === existing.id ? { ...p, closed: false } : p))
- }))
+ get().unhideProject(existing.id)
}
return {
project: get().projects.find((p) => p.id === existing.id) ?? existing,