fix(lanes): removing a lane deletes its record only, never the worktree
A lane's `remove` tore down what the lane pointed at: `git worktree remove --force`, a branch delete, and a drop of the lane's own database. One mis-click on a dashboard row cost a whole branch's unpushed code — and the row is the only thing AgentHub actually owns. `remove` now stops the run and the stack, clears AgentHub's own runtime bookkeeping under `LANES_ROOT/.state/lane<slot>/`, and deletes the row. The working tree, its branch, git's worktree records and the database stay exactly where they are, for the user to delete by hand when they mean to. That also fixes #28. Removal used to route through `assertDestroyable`, whose third check demands the cwd appear in `git worktree list`; a managed lane whose directory git no longer listed answered `ENOTWORKTREE` ("lane is not listed as a worktree in …") and could never be dropped from the dashboard at all. Removal no longer asks git anything, so no preflight blocker stops it, and the unpushed-commits force-gate now applies to `reset` alone — nothing `remove` does can discard a commit. The UI follows: one label for both lane kinds ("Delete lane record"), copy that says what survives, and no Force checkbox on removal. `removeWorktree`/`removeLaneData` remain in place as guarded primitives; no route calls them any more.
This commit is contained in:
+10
-5
@@ -1799,9 +1799,14 @@ async function cmdLanesLifecycle(action, args) {
|
||||
printLaneFacts(`Preflight for ${action} lane #${id}:`, preflight, fields);
|
||||
const keepDb = action === "reset" && args.includes("--keep-db");
|
||||
if (preflight.database) {
|
||||
const fate = action === "remove" ? "dropped" : keepDb ? "kept as-is" : "dropped and recreated";
|
||||
const fate = action === "remove" ? "kept" : keepDb ? "kept as-is" : "dropped and recreated";
|
||||
console.log(` database: ${preflight.database} (${fate})`);
|
||||
}
|
||||
if (action === "remove") {
|
||||
console.log(
|
||||
" Only the dashboard's record is dropped — the working tree, its branch and the database are left for you to delete yourself."
|
||||
);
|
||||
}
|
||||
if (Array.isArray(preflight.warnings) && preflight.warnings.length) {
|
||||
console.log("Warnings:");
|
||||
for (const warning of preflight.warnings) console.log(` ${warning}`);
|
||||
@@ -1813,9 +1818,9 @@ async function cmdLanesLifecycle(action, args) {
|
||||
return;
|
||||
}
|
||||
// Only `reset` is impossible for an adopted lane. `remove` IS supported by the
|
||||
// server: it drops the dashboard's record and never touches the directory
|
||||
// (server/routes/lanes.js scopes the worktree teardown to managed lanes), so
|
||||
// refusing it here would make a permitted action unreachable from the CLI.
|
||||
// server for every lane kind: it drops the dashboard's record and never touches
|
||||
// the directory, so refusing it here would make a permitted action unreachable
|
||||
// from the CLI.
|
||||
if (
|
||||
action === "reset" &&
|
||||
Array.isArray(preflight.blocked) &&
|
||||
@@ -2936,7 +2941,7 @@ const COMMAND_GROUPS = [
|
||||
[
|
||||
"lanes reset|remove|purge",
|
||||
"<id> [--force] [--keep-db] --yes",
|
||||
"Show preflight facts, then perform a destructive lane action (--keep-db: reset only)",
|
||||
"Show preflight facts, then perform a destructive lane action (--keep-db: reset only; remove drops the dashboard's record only — worktree, branch and database are left alone)",
|
||||
],
|
||||
[
|
||||
"lanes up|down",
|
||||
|
||||
Reference in New Issue
Block a user