mirror of
https://github.com/stablyai/orca.git
synced 2026-10-31 09:07:40 +00:00
Linked worktrees now get a per-worktree userData profile under
orca-dev-wt/<hash>, a deterministic collision-checked renderer port
(15200+) and CDP port (9333+), so parallel `pnpm dev` runs no longer hit
the single-instance lock. The main checkout keeps the shared orca-dev
profile; --shared-profile / --worktree-profile / ORCA_DEV_PROFILE override.
The runner prints `ORCA_DEV_INSTANCE {json}` on stdout and mirrors it to
out/dev-instance.json so agents can attach over CDP. orca-dev.mjs and the
terminal wrappers follow the profile the worktree's dev app used.
Adds profile seeding (pnpm dev:seed-profile, pnpm dev --seed-profile,
pnpm dev:fresh --seed-from): an allowlisted slim copy of projects,
workspaces, settings, SSH targets, and the account session, written as
orca-data.json for Orca's own import; the source is only read.
Storage reclaim removes per-worktree profiles once their worktree is gone
and no app, runtime, or daemon still uses them. dev-fresh-profile.sh is
replaced by a cross-platform dev-fresh-profile.mjs.
50 lines
2.1 KiB
JavaScript
50 lines
2.1 KiB
JavaScript
import { existsSync, mkdirSync, mkdtempSync, realpathSync, rmSync, writeFileSync } from 'node:fs'
|
|
import { tmpdir } from 'node:os'
|
|
import path from 'node:path'
|
|
import { afterEach, expect, it } from 'vitest'
|
|
import { writeWorktreeProfileMarker } from './dev-instance-isolation.mjs'
|
|
import { reclaimDevWorktreeProfiles } from './reclaim-dev-worktree-profiles.mjs'
|
|
|
|
const roots = []
|
|
afterEach(() => {
|
|
for (const root of roots.splice(0)) {
|
|
rmSync(root, { recursive: true, force: true })
|
|
}
|
|
})
|
|
|
|
it('removes only idle profiles whose worktree of this repository is gone', async () => {
|
|
const root = realpathSync(mkdtempSync(path.join(tmpdir(), 'orca-dev-profiles-')))
|
|
roots.push(root)
|
|
const commonDirectory = path.join(root, 'repo', '.git')
|
|
const otherCommonDirectory = path.join(root, 'other', '.git')
|
|
const liveWorktree = path.join(root, 'live')
|
|
mkdirSync(commonDirectory, { recursive: true })
|
|
mkdirSync(otherCommonDirectory, { recursive: true })
|
|
mkdirSync(liveWorktree)
|
|
const profilesRoot = path.join(root, 'orca-dev-wt')
|
|
const profile = (name, repoRoot, gitCommonDir) => {
|
|
const dir = path.join(profilesRoot, name)
|
|
writeWorktreeProfileMarker(dir, { repoRoot, instanceKey: repoRoot, gitCommonDir })
|
|
return dir
|
|
}
|
|
const removed = profile('aaaaaaaaaa', path.join(root, 'removed'), commonDirectory)
|
|
const live = profile('bbbbbbbbbb', liveWorktree, commonDirectory)
|
|
const otherRepo = profile('cccccccccc', path.join(root, 'gone-other'), otherCommonDirectory)
|
|
const running = profile('dddddddddd', path.join(root, 'removed-running'), commonDirectory)
|
|
writeFileSync(path.join(running, 'orca-runtime.json'), JSON.stringify({ pid: 4242 }))
|
|
|
|
const result = await reclaimDevWorktreeProfiles({
|
|
apply: true,
|
|
profilesRoot,
|
|
repository: { commonDirectory, worktrees: [liveWorktree] },
|
|
isAlive: (pid) => pid === 4242,
|
|
report: () => {}
|
|
})
|
|
|
|
expect(result).toEqual({ entries: 1, protected: 1 })
|
|
expect(existsSync(removed)).toBe(false)
|
|
expect(existsSync(live)).toBe(true)
|
|
expect(existsSync(otherRepo)).toBe(true)
|
|
expect(existsSync(running)).toBe(true)
|
|
})
|