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: remove retired live-link data from the data dir and localStorage

review5edfd9f96810
diff --git a/src/core/retired-data-cleanup.test.ts b/src/core/retired-data-cleanup.test.ts
new file mode 100644
index 000000000..94813b02d
--- /dev/null
+++ b/src/core/retired-data-cleanup.test.ts
@@ -0,0 +1,109 @@
+import fs from 'fs'
+import path from 'path'
+import { describe, expect, it, vi } from 'vitest'
+import { testTmpDir } from './test-tmp'
+import { isRetiredLiveLinkFile, removeRetiredLiveLinkData } from './retired-data-cleanup'
+
+const RETIRED = [
+ 'watch-links.json',
+ 'watch-links.json.corrupt-1767225600000',
+ 'watch-links.json.tmp',
+ 'watch-links.json.4242.7.tmp',
+ 'watch-links.json.4242.7.0b9c8f2e-1d3a-4c5b-9e7f-0123456789ab.tmp'
+]
+const LOOK_ALIKES = [
+ 'watch-links.json.bak',
+ 'my-watch-links.json',
+ 'watch-links.jsonx',
+ 'watch-links.json.corrupt-',
+ 'watch-links.json.corrupt-1.bak',
+ 'watch-links.json.x.tmp'
+]
+
+describe('isRetiredLiveLinkFile', () => {
+ it('matches the store, its sidelines and its atomic-write temps, and nothing else', () => {
+ for (const name of RETIRED) expect(isRetiredLiveLinkFile(name), name).toBe(true)
+ for (const name of LOOK_ALIKES) expect(isRetiredLiveLinkFile(name), name).toBe(false)
+ })
+})
+
+describe('removeRetiredLiveLinkData', () => {
+ it('removes the store, its sidelines and its temps', async () => {
+ const dir = testTmpDir('retired-data-')
+ for (const name of [...RETIRED, ...LOOK_ALIKES]) fs.writeFileSync(path.join(dir, name), 'x')
+ const warn = vi.fn()
+ expect(await removeRetiredLiveLinkData(dir, warn)).toBe(5)
+ for (const name of RETIRED) expect(fs.existsSync(path.join(dir, name)), name).toBe(false)
+ for (const name of LOOK_ALIKES) expect(fs.existsSync(path.join(dir, name)), name).toBe(true)
+ expect(warn).not.toHaveBeenCalled()
+ })
+
+ it('leaves a directory with a matching name alone', async () => {
+ const dir = testTmpDir('retired-data-')
+ fs.mkdirSync(path.join(dir, 'watch-links.json.corrupt-1'))
+ expect(await removeRetiredLiveLinkData(dir, vi.fn())).toBe(0)
+ expect(fs.statSync(path.join(dir, 'watch-links.json.corrupt-1')).isDirectory()).toBe(true)
+ })
+
+ it.skipIf(process.platform === 'win32')('removes a symlink as a link and never touches its target', async () => {
+ // Skipped on Windows: creating a symlink there needs Developer Mode or elevation.
+ const dir = testTmpDir('retired-data-')
+ const outside = testTmpDir('retired-target-')
+ const target = path.join(outside, 'target.json')
+ fs.writeFileSync(target, 'keep me')
+ fs.symlinkSync(target, path.join(dir, 'watch-links.json'))
+ expect(await removeRetiredLiveLinkData(dir, vi.fn())).toBe(1)
+ expect(fs.existsSync(path.join(dir, 'watch-links.json'))).toBe(false)
+ expect(fs.readFileSync(target, 'utf8')).toBe('keep me')
+ })
+
+ it('does not recurse', async () => {
+ const dir = testTmpDir('retired-data-')
+ fs.mkdirSync(path.join(dir, 'sub'))
+ fs.writeFileSync(path.join(dir, 'sub', 'watch-links.json'), 'x')
+ expect(await removeRetiredLiveLinkData(dir, vi.fn())).toBe(0)
+ expect(fs.existsSync(path.join(dir, 'sub', 'watch-links.json'))).toBe(true)
+ })
+
+ it('an absent dir answers 0 and warns nothing', async () => {
+ const warn = vi.fn()
+ expect(await removeRetiredLiveLinkData(path.join(testTmpDir('retired-data-'), 'missing'), warn)).toBe(0)
+ expect(warn).not.toHaveBeenCalled()
+ })
+
+ // Skipped on Windows (chmod does not make a directory unreadable there) and as root (root reads
+ // a mode-000 directory anyway, so the error path cannot be reached).
+ it.skipIf(process.platform === 'win32' || process.getuid?.() === 0)(
+ 'an unreadable dir answers 0, warns once, never throws',
+ async () => {
+ const dir = testTmpDir('retired-data-')
+ fs.writeFileSync(path.join(dir, 'watch-links.json'), 'x')
+ fs.chmodSync(dir, 0o000)
+ const warn = vi.fn()
+ try {
+ expect(await removeRetiredLiveLinkData(dir, warn)).toBe(0)
+ } finally {
+ fs.chmodSync(dir, 0o700)
+ }
+ expect(warn).toHaveBeenCalledTimes(1)
+ }
+ )
+
+ it('a failed unlink is reported once with a count and a code, never a file body', async () => {
+ const dir = testTmpDir('retired-data-')
+ fs.writeFileSync(path.join(dir, 'watch-links.json'), 'SECRET-BODY')
+ fs.writeFileSync(path.join(dir, 'watch-links.json.tmp'), 'SECRET-BODY')
+ const warn = vi.fn()
+ const unlink = vi.spyOn(fs.promises, 'unlink').mockRejectedValue(Object.assign(new Error('nope'), { code: 'EPERM' }))
+ try {
+ expect(await removeRetiredLiveLinkData(dir, warn)).toBe(0)
+ } finally {
+ unlink.mockRestore()
+ }
+ expect(warn).toHaveBeenCalledTimes(1)
+ const message = String(warn.mock.calls[0][0])
+ expect(message).toContain('2')
+ expect(message).toContain('EPERM')
+ expect(message).not.toContain('SECRET-BODY')
+ })
+})
diff --git a/src/core/retired-data-cleanup.ts b/src/core/retired-data-cleanup.ts
new file mode 100644
index 000000000..d54a9c7bc
--- /dev/null
+++ b/src/core/retired-data-cleanup.ts
@@ -0,0 +1,58 @@
+// Live links were retired in 2026-11. An install that used them kept `watch-links.json` in its data
+// dir: sealed link secrets and the scrypt hashes of Control passwords, which nothing reads any more.
+// Both shells call this once per boot (desktop: userData, Server Edition: its data dir, where the
+// file almost certainly never existed) and it removes exactly three name shapes from the dir's TOP
+// level: the store, its `.corrupt-<ts>` sidelines, and the atomic-write temps a crash may have left
+// (they can hold the same secrets). Nothing wider, never recursive, never through a symlink (a link
+// is removed as a link), never a directory. It never throws: ENOENT is the normal case and says
+// nothing; any other failure is one warning naming a count and an error code, never a file's body.
+import fs from 'fs'
+import path from 'path'
+
+const UUID = '[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}'
+// The temp shapes are fs-atomic's `tempNameFor` (`<target>.<pid>.<seq>.<uuid>.tmp`), the older
+// pid+sequence form, and the legacy fixed `<target>.tmp`.
+const RETIRED_NAME = new RegExp(`^watch-links\\.json(?:\\.corrupt-\\d+|(?:\\.\\d+\\.\\d+(?:\\.${UUID})?)?\\.tmp)?$`)
+
+/** Is this top-level data-dir entry name one of the retired live-link store's files? */
+export function isRetiredLiveLinkFile(name: string): boolean {
+ return RETIRED_NAME.test(name)
+}
+
+function codeOf(err: unknown): string {
+ const code = (err as { code?: unknown } | null)?.code
+ return typeof code === 'string' && /^[A-Z0-9_]{1,32}$/.test(code) ? code : 'unknown'
+}
+
+/** Remove the retired live-link files from `dir`'s top level. Answers how many were removed. */
+export async function removeRetiredLiveLinkData(
+ dir: string,
+ warn: (message: string) => void = (m) => console.warn(m)
+): Promise<number> {
+ let names: string[]
+ try {
+ names = await fs.promises.readdir(dir)
+ } catch (err) {
+ if (codeOf(err) !== 'ENOENT') warn(`[retired-data] could not list the data dir for old live-link files (${codeOf(err)})`)
+ return 0
+ }
+ let removed = 0
+ let failed = 0
+ let firstCode = ''
+ for (const name of names) {
+ if (!isRetiredLiveLinkFile(name)) continue
+ const file = path.join(dir, name)
+ try {
+ const st = await fs.promises.lstat(file)
+ if (!st.isFile() && !st.isSymbolicLink()) continue
+ await fs.promises.unlink(file)
+ removed++
+ } catch (err) {
+ if (codeOf(err) === 'ENOENT') continue
+ failed++
+ if (!firstCode) firstCode = codeOf(err)
+ }
+ }
+ if (failed > 0) warn(`[retired-data] could not remove ${failed} old live-link file(s) (${firstCode})`)
+ return removed
+}
diff --git a/src/renderer/lib/retiredStorage.test.ts b/src/renderer/lib/retiredStorage.test.ts
new file mode 100644
index 000000000..1a474e89e
--- /dev/null
+++ b/src/renderer/lib/retiredStorage.test.ts
@@ -0,0 +1,28 @@
+import { describe, expect, it } from 'vitest'
+import { RETIRED_STORAGE_KEYS, removeRetiredStorageKeys } from './retiredStorage'
+
+describe('removeRetiredStorageKeys', () => {
+ it('removes exactly the three live-link keys, in order', () => {
+ const removed: string[] = []
+ removeRetiredStorageKeys({ removeItem: (k: string) => void removed.push(k) })
+ expect(removed).toEqual(['nodeterm.liveLinkDefaults', 'nodeterm.liveChatPinned', 'nodeterm.liveChatLink'])
+ expect([...RETIRED_STORAGE_KEYS]).toEqual(removed)
+ })
+
+ it('a storage that throws costs that key only, never the boot', () => {
+ const tried: string[] = []
+ const storage = {
+ removeItem: (k: string) => {
+ tried.push(k)
+ if (k === 'nodeterm.liveLinkDefaults') throw new Error('SecurityError')
+ }
+ }
+ expect(() => removeRetiredStorageKeys(storage)).not.toThrow()
+ expect(tried).toEqual([...RETIRED_STORAGE_KEYS])
+ })
+
+ it('no storage at all is a no-op', () => {
+ expect(() => removeRetiredStorageKeys(null)).not.toThrow()
+ expect(() => removeRetiredStorageKeys(undefined)).not.toThrow()
+ })
+})
diff --git a/src/renderer/lib/retiredStorage.ts b/src/renderer/lib/retiredStorage.ts
new file mode 100644
index 000000000..3b086f246
--- /dev/null
+++ b/src/renderer/lib/retiredStorage.ts
@@ -0,0 +1,16 @@
+// Live links were retired in 2026-11. These localStorage keys held their per-viewer conveniences
+// (link defaults, the pinned and last-open Live chat); nothing reads them any more. Removed once at
+// renderer boot. Each removal is its own try/catch: a storage that throws (private mode, a blocked
+// origin) costs that key, never the boot.
+export const RETIRED_STORAGE_KEYS = ['nodeterm.liveLinkDefaults', 'nodeterm.liveChatPinned', 'nodeterm.liveChatLink'] as const
+
+export function removeRetiredStorageKeys(storage: Pick<Storage, 'removeItem'> | null | undefined): void {
+ if (!storage) return
+ for (const key of RETIRED_STORAGE_KEYS) {
+ try {
+ storage.removeItem(key)
+ } catch {
+ // A storage that refuses one key may still take the next.
+ }
+ }
+}