Skip to content

A GitHub repo link stranded at cloneStatus 'cloning' can never be re-cloned #5463

Description

@atomantic

Problem

cloneRepoInBackground (server/services/brain.js) stamps cloneStatus: 'cloning' and only resets it from the promise callbacks of githubCloner.cloneRepo. If the server restarts (or is killed) while a clone is running, those callbacks never fire and the link record stays at cloning forever.

That state has no exit:

  • POST /api/brain/links/:id/clone (server/routes/brainLinks.js:177-182) rejects with 409 CLONE_IN_PROGRESS whenever cloneStatus === 'cloning'.
  • The Links tab only renders a Clone button for cloneStatus === 'none' and a Retry button for 'failed' — a cloning record gets neither (client/src/components/brain/tabs/LinksTab.jsx).

So the bookmark is permanently stuck showing a clone spinner with no way to retry short of editing the record by hand.

Fix

Give a stale cloning record a way back. Options, in order of preference:

  1. Reconcile at boot. On server start, sweep links with cloneStatus === 'cloning' and reset them to failed with a cloneError explaining the interruption — no in-process clone can survive a restart, so any such record at boot is by definition orphaned. This alone restores the existing Retry affordance with no new UI or API.
  2. Optionally, let the clone route force-restart a clone whose record has been cloning past a staleness threshold, instead of a blanket 409.

Note this is a record-state sweep, not an AI or network call, so it is fine to run at boot (no cold-bootstrap LLM concern).

Acceptance criteria

  • After a server restart mid-clone, the affected link reports Clone failed with an explanatory cloneError and offers Retry.
  • Retry actually starts a new clone (no 409).
  • A test covers the boot-time reconcile: a record left at cloning is reset, and records in every other cloneStatus are untouched.

Related to #5442 — that issue bounded the client poll for a stuck clone (it now gives up after 10 minutes and labels the badge (stalled)), but deliberately left the stranded server-side record alone as out of scope.

Metadata

Metadata

Assignees

Labels

area:brainBrain notes/memories/goals/knowledge graphbugSomething isn't workingeffort:lowEffort: lowin-progressClaimed and being workedmodel:lightModel size: lightplanTracked by /do:replan

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions