{"record":{"id":"fdc62240a9d8b1a4","repo":"paperclipai/paperclip","slug":"source-worktree-selection-cancelled","errorCode":null,"errorMessage":"Source worktree selection cancelled.","messagePattern":"Source worktree selection cancelled\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"warning","filePath":"cli/src/commands/worktree.ts","lineNumber":2889,"sourceCode":"  const excluded = excludeWorktreePath ? path.resolve(excludeWorktreePath) : null;\n  const currentEndpoint = resolveCurrentWorktreeEndpoint();\n  const choices = toMergeSourceChoices(process.cwd())\n    .filter((choice) => choice.hasPaperclipConfig || choice.isCurrent)\n    .filter((choice) => path.resolve(choice.worktree) !== excluded)\n    .map((choice) => ({\n      value: choice.isCurrent ? \"__current__\" : choice.worktree,\n      label: choice.branchLabel,\n      hint: `${choice.worktree}${choice.isCurrent ? \" (current)\" : \"\"}`,\n    }));\n  if (choices.length === 0) {\n    throw new Error(\"No Paperclip worktrees were found. Run `paperclipai worktree:list` to inspect the repo worktrees.\");\n  }\n  const selection = await p.select<string>({\n    message: \"Choose the source worktree to import from\",\n    options: choices,\n  });\n  if (p.isCancel(selection)) {\n    throw new Error(\"Source worktree selection cancelled.\");\n  }\n  if (selection === \"__current__\") {\n    return currentEndpoint;\n  }\n  return resolveWorktreeEndpointFromSelector(selection, { allowCurrent: true });\n}\n\nasync function applyMergePlan(input: {\n  sourceStorages: ConfiguredStorage[];\n  targetStorage: ConfiguredStorage;\n  targetDb: ClosableDb;\n  company: ResolvedMergeCompany;\n  plan: Awaited<ReturnType<typeof collectMergePlan>>[\"plan\"];\n}) {\n  const companyId = input.company.id;\n\n  return await input.targetDb.transaction(async (tx) => {\n    const importedProjectIds = input.plan.projectImports.map((project) => project.source.id);","sourceCodeStart":2871,"sourceCodeEnd":2907,"githubUrl":"https://github.com/paperclipai/paperclip/blob/67001ec6eb96ae601aa27bc91d9b2415d665334a/cli/src/commands/worktree.ts#L2871-L2907","documentation":"Thrown by promptForSourceEndpoint when the user cancels the @clack/prompts select widget (Esc or Ctrl+C) while choosing a source worktree for merge-history. p.isCancel(selection) returns true. This is a user-initiated abort surfaced as a thrown Error so the CLI exits non-zero with a clear reason rather than proceeding with an undefined selection.","triggerScenarios":"Running `paperclipai worktree:merge-history` without --from, waiting for the 'Choose the source worktree to import from' prompt, then pressing Esc or Ctrl+C.","commonSituations":"A developer opens the interactive picker, realizes the wrong source is listed, and bails out. Or a terminal session where Ctrl+C is sent mid-prompt. Also triggered by non-TTY environments where @clack/prompts auto-cancel.","solutions":["Re-run the command and either pick an entry or pass --from to skip the prompt.","If running in CI/non-TTY, always supply --from and --to explicitly so no interactive prompt is needed.","Use --yes alongside explicit flags for fully non-interactive runs."],"exampleFix":"// before (interactive, cancelled)\npaperclipai worktree:merge-history\n// after (non-interactive)\npaperclipai worktree:merge-history --from feature-x --to current --apply --yes","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n  await runMergeHistory(opts);\n} catch (err) {\n  if (err instanceof Error && err.message === \"Source worktree selection cancelled.\") {\n    // user-initiated cancel; exit cleanly\n    process.exit(0);\n  }\n  throw err;\n}","preventionTips":["Run merge-history with --from/--to/--yes in non-interactive environments to skip the select prompt entirely.","Treat the literal cancellation message as a control-flow signal if you wrap the CLI in a parent process.","Ensure a TTY is attached when interactive prompts are expected."],"tags":["worktree","cli","interactive","cancellation"],"backgroundTag":null,"analyzedSha":"67001ec6eb96ae601aa27bc91d9b2415d665334a","analyzedAt":"2026-08-12T12:05:45.408Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}