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.

fix(kanban): guard inline (cwd-less) projects against v1/malformed board shapes

enesaf97e58846f2
diff --git a/src/core/workspace-files.ts b/src/core/workspace-files.ts
index 9c11bbcc2..795ad2973 100644
--- a/src/core/workspace-files.ts
+++ b/src/core/workspace-files.ts
@@ -117,6 +117,18 @@ export function projectToFile(p: Project, rev: number, savedAt: string): Project
}
}
+/** The kanban shape rule used on every load path (file refs, ssh cache, inline projects):
+ * anything but {columns: [], assignments: []} arrays — including v1 {columns, cards}
+ * boards — is dropped, so a legacy/hand-edited shape degrades to the fresh default
+ * instead of crashing the board render. */
+export function validKanban(k: unknown): k is ProjectKanban {
+ return (
+ !!k &&
+ Array.isArray((k as ProjectKanban).columns) &&
+ Array.isArray((k as ProjectKanban).assignments)
+ )
+}
+
export function fileToProject(
f: ProjectFileV1,
base: {
@@ -142,9 +154,7 @@ export function fileToProject(
...(f.defaultAccountId ? { defaultAccountId: f.defaultAccountId } : {}),
...(f.defaultPermissionMode ? { defaultPermissionMode: f.defaultPermissionMode } : {}),
...(f.dinoHighScore ? { dinoHighScore: f.dinoHighScore } : {}),
- ...(f.kanban && Array.isArray(f.kanban.columns) && Array.isArray(f.kanban.assignments)
- ? { kanban: f.kanban }
- : {}),
+ ...(validKanban(f.kanban) ? { kanban: f.kanban } : {}),
...(base.cwd ? { cwd: base.cwd } : {}),
...(base.ssh ? { ssh: base.ssh } : {}),
...(base.closed ? { closed: true } : {})
diff --git a/src/core/workspace-store.test.ts b/src/core/workspace-store.test.ts
index 95bc3880d..d988b195a 100644
--- a/src/core/workspace-store.test.ts
+++ b/src/core/workspace-store.test.ts
@@ -90,6 +90,46 @@ describe('v2 → v3 migration', () => {
// project.json while the index has no `localExec` for it. Without a migration the first load after
// the upgrade drops it (the connection breaks), and the next save erases it from disk and
// propagates the deletion to every teammate via `rev`. Silently.
+describe('inline (cwd-less) project kanban shape guard', () => {
+ const writeInlineIndex = async (kanban: unknown): Promise<void> => {
+ await fs.writeFile(
+ path.join(userData, 'workspace.json'),
+ JSON.stringify({
+ version: 3,
+ activeProjectId: 'p1',
+ entries: [
+ {
+ id: 'p1',
+ name: 'inline',
+ color: '#7aa2f7',
+ project: {
+ id: 'p1', name: 'inline', color: '#7aa2f7', viewport: { x: 0, y: 0, zoom: 1 },
+ nodes: [], kanban
+ }
+ }
+ ]
+ })
+ )
+ }
+
+ it('drops a v1-shaped kanban on an inline project (degrades to fresh default, no crash)', async () => {
+ await writeInlineIndex({ columns: [], cards: [] })
+ const loaded = await new WorkspaceStore().load()
+ expect(loaded.projects[0].id).toBe('p1')
+ expect('kanban' in loaded.projects[0]).toBe(false)
+ })
+
+ it('keeps a well-formed inline kanban verbatim (does not over-strip)', async () => {
+ const board = {
+ columns: [{ id: 'kcol-a', title: 'To Do', color: '#0a84ff' }],
+ assignments: [{ nodeId: 'term-abc', columnId: 'kcol-a' }]
+ }
+ await writeInlineIndex(board)
+ const loaded = await new WorkspaceStore().load()
+ expect(loaded.projects[0].kanban).toEqual(board)
+ })
+})
+
describe('one-time exec migration (pre-existing project files)', () => {
/** A v3 index + project file written the way the PRE-fix app wrote them. */
const writeLegacy = async (extraArgs: string): Promise<void> => {
diff --git a/src/core/workspace-store.ts b/src/core/workspace-store.ts
index 07a5e2366..7b6a53116 100644
--- a/src/core/workspace-store.ts
+++ b/src/core/workspace-store.ts
@@ -8,7 +8,7 @@ import {
} from '../shared/types'
import {
PROJECT_DIR, PROJECT_FILE, fileToProject, projectToFile, sameProjectContent,
- serializeProjectFile, splitWorkspace,
+ serializeProjectFile, splitWorkspace, validKanban,
type IndexEntryV3, type ProjectFileV1, type WorkspaceIndexV3
} from './workspace-files'
import { hoistLegacyNodeExec, type LocalNodeExecMap } from '../shared/node-exec'
@@ -114,7 +114,10 @@ export class WorkspaceStore {
const projects: Project[] = []
for (const e of index.entries) {
if (e.project) {
- projects.push(e.project)
+ // Inline projects are stored verbatim in the index (no fileToProject pass), so apply the
+ // same kanban shape guard here — a v1/hand-edited board would otherwise crash the render.
+ const { kanban, ...rest } = e.project
+ projects.push(validKanban(kanban) ? e.project : rest)
} else if (e.cwd) {
const p = await this.readProjectFile(e.cwd, sideline)
if (p) {