paperclipai/paperclip · warning · Error
Source worktree selection cancelled.
Error message
Source worktree selection cancelled.
What it means
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.
Source
Thrown at cli/src/commands/worktree.ts:2889
const excluded = excludeWorktreePath ? path.resolve(excludeWorktreePath) : null;
const currentEndpoint = resolveCurrentWorktreeEndpoint();
const choices = toMergeSourceChoices(process.cwd())
.filter((choice) => choice.hasPaperclipConfig || choice.isCurrent)
.filter((choice) => path.resolve(choice.worktree) !== excluded)
.map((choice) => ({
value: choice.isCurrent ? "__current__" : choice.worktree,
label: choice.branchLabel,
hint: `${choice.worktree}${choice.isCurrent ? " (current)" : ""}`,
}));
if (choices.length === 0) {
throw new Error("No Paperclip worktrees were found. Run `paperclipai worktree:list` to inspect the repo worktrees.");
}
const selection = await p.select<string>({
message: "Choose the source worktree to import from",
options: choices,
});
if (p.isCancel(selection)) {
throw new Error("Source worktree selection cancelled.");
}
if (selection === "__current__") {
return currentEndpoint;
}
return resolveWorktreeEndpointFromSelector(selection, { allowCurrent: true });
}
async function applyMergePlan(input: {
sourceStorages: ConfiguredStorage[];
targetStorage: ConfiguredStorage;
targetDb: ClosableDb;
company: ResolvedMergeCompany;
plan: Awaited<ReturnType<typeof collectMergePlan>>["plan"];
}) {
const companyId = input.company.id;
return await input.targetDb.transaction(async (tx) => {
const importedProjectIds = input.plan.projectImports.map((project) => project.source.id);View on GitHub (pinned to 67001ec6eb)
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.
Example fix
// before (interactive, cancelled) paperclipai worktree:merge-history // after (non-interactive) paperclipai worktree:merge-history --from feature-x --to current --apply --yes
Defensive patterns
Strategy: try-catch
Try / catch
try {
await runMergeHistory(opts);
} catch (err) {
if (err instanceof Error && err.message === "Source worktree selection cancelled.") {
// user-initiated cancel; exit cleanly
process.exit(0);
}
throw err;
} Prevention
- 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.
When it happens
Trigger: Running `paperclipai worktree:merge-history` without --from, waiting for the 'Choose the source worktree to import from' prompt, then pressing Esc or Ctrl+C.
Common situations: 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.
Related errors
- Export cancelled.
- Import preview returned no data.
- `paperclipai connect` is interactive. For scripts, pass --ap
- Profile name is required
- This command requires --yes when not running in an interacti
AI-assisted analysis of paperclipai/paperclip@67001ec6eb (2026-08-12).
Data as JSON: /api/errors/fdc62240a9d8b1a4.
Report an issue: GitHub.