Skip to content

fix(cli): resolve archive worktrees from machine Flock - #382

Open
UniversePeak wants to merge 1 commit into
LodyAI:mainfrom
UniversePeak:fix/archive-worktree-flock
Open

fix(cli): resolve archive worktrees from machine Flock#382
UniversePeak wants to merge 1 commit into
LodyAI:mainfrom
UniversePeak:fix/archive-worktree-flock

Conversation

@UniversePeak

Copy link
Copy Markdown

Related issue

Closes #377

Problem / pressure

Archiving a local-project session did not remove its worktree or run the configured cleanup script when the project metadata was stored only in the machine Flock document. The archive path resolved local projects from legacy machine metadata but did not load the Flock rows that are authoritative for current local projects.

Summary

Load the machine Flock command snapshot's localProject rows while processing archive requests and pass them to worktree cleanup target resolution. Add a regression that creates a real local Git worktree with project metadata available only through the machine Flock and verifies archiving removes that worktree.

Before / after

Before After
Archive cleanup could not resolve a local project's root path when it existed only in Machine Flock, so cleanup and worktree removal were skipped. Archive cleanup resolves the root path from the same Machine Flock local-project catalog used by deletion, then removes the archived worktree.

Test plan

  • corepack pnpm install --frozen-lockfile --ignore-scripts — passed.
  • corepack pnpm --dir packages/acp-extension-core build, plus Claude, Codex, Grok, and DSH adapter builds — passed; required for the CLI test imports.
  • corepack pnpm --dir apps/cli exec vitest run tests/message-handler-terminal-cleanup.test.ts — 13 tests passed, including the new archive regression.
  • corepack pnpm --filter lody typecheck — passed.
  • corepack pnpm lint:fast — 0 errors (465 existing warnings).
  • corepack pnpm check:public-boundary — passed.
  • Prettier check on changed files and git diff --check — passed.

Context handoff

Instructions for reviewing agents

  • Review focus: Check that archive processing reads localProject rows from Machine Flock and passes them to resolveWorktreeCleanupTarget, matching the existing permanent-delete path.
  • Decisions to challenge: Confirm that one shared command-row reader should include the local-project catalog while preserving the existing legacy metadata fallback.
  • Plausible failures / evidence gaps: The regression exercises native worktree removal; a configured user cleanup script is not needed to prove the previously skipped target-resolution branch.

Authoring context

  • User goal / directives: Make archived local-project sessions clean up their worktree instead of leaving the directory and branch registered.
  • Constraints / non-goals: Keep the change limited to archive target resolution; do not alter dirty-worktree safety, cleanup script semantics, or the deletion path.
  • Risk-bearing decisions: Read the authoritative local-project catalog from Machine Flock and retain legacy machine metadata as a fallback for older clients.
  • Destructive or irreversible behavior: Archive now removes the Lody-owned worktree through the existing forced archive path; the preserved branch behavior and configured cleanup hook remain unchanged.
  • Deliberately not done or tested: No live desktop release was run; the focused MessageHandler suite uses synthetic session metadata and a real temporary Git repository.
  • Unknowns / confidence: High confidence in the missing-row diagnosis and focused regression; broader Electron UI behavior remains covered by existing integration paths.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] Archived sessions cannot be cleared from worktree

1 participant