refactor(tabs): remove legacy tab migration functionality and associated tests for codebase cleanup

This commit is contained in:
Anish Sarkar 2026-07-16 17:58:18 +05:30
parent 1b62352d0d
commit 0ca696f3fc
2 changed files with 0 additions and 40 deletions

View file

@ -1,21 +0,0 @@
import assert from "node:assert/strict";
import { test } from "node:test";
import { migrateLegacyTabs } from "./migrate-tabs";
// Run with: pnpm exec tsx --test atoms/tabs/migrate-tabs.test.ts
test("maps legacy searchSpaceId to workspaceId on read", () => {
const migrated = migrateLegacyTabs({
tabs: [{ id: "chat-new", type: "chat", searchSpaceId: 7 } as never],
activeTabId: "chat-new",
});
const tab = migrated.tabs[0] as { workspaceId?: number };
assert.equal(tab.workspaceId, 7);
});
test("leaves an already-migrated workspaceId untouched", () => {
const migrated = migrateLegacyTabs({
tabs: [{ id: "d1", type: "document", workspaceId: 3, searchSpaceId: 9 } as never],
});
const tab = migrated.tabs[0] as { workspaceId?: number };
assert.equal(tab.workspaceId, 3);
});

View file

@ -1,19 +0,0 @@
/**
* One-time read-migration for persisted tabs: legacy state stored the workspace
* as `searchSpaceId`. Map it to `workspaceId` on read so already-open tabs keep
* their workspace association after the rename. Pure + dependency-free so it can
* be unit-checked without loading the atom module.
*/
export function migrateLegacyTabs<T extends { tabs: Array<{ workspaceId?: number }> }>(
state: T
): T {
return {
...state,
tabs: state.tabs.map((t) => {
const legacy = t as { workspaceId?: number; searchSpaceId?: number };
return legacy.workspaceId === undefined && legacy.searchSpaceId !== undefined
? { ...t, workspaceId: legacy.searchSpaceId }
: t;
}),
};
}