What's broken
copyToClipboard() in src/screens/repl.ts:803-815 always returns true unless the spawnSync call itself throws — it never checks the exit status or error field of the result:
function copyToClipboard(text: string): boolean {
try {
if (process.platform === "darwin") {
spawnSync("pbcopy", [], { input: text, encoding: "utf-8" });
} else if (process.platform === "win32") {
spawnSync("clip", [], { input: text, encoding: "utf-8", shell: true });
} else {
const r = spawnSync("xclip", ["-selection", "clipboard"], { input: text, encoding: "utf-8" });
if (r.error) spawnSync("xsel", ["--clipboard", "--input"], { input: text, encoding: "utf-8" });
}
return true; // <-- always true, even if xclip AND xsel are both missing
} catch { return false; }
}
On a Linux box with neither xclip nor xsel installed, both spawn calls fail silently (non-zero exit / ENOENT), but the function still returns true. Every caller (/copy command, "copy last response", clipboard menu actions) then shows "Copied to clipboard." when nothing was copied.
Suggested fix
Check the actual result before returning success:
const r1 = spawnSync("xclip", ["-selection", "clipboard"], { input: text, encoding: "utf-8" });
if (!r1.error && r1.status === 0) return true;
const r2 = spawnSync("xsel", ["--clipboard", "--input"], { input: text, encoding: "utf-8" });
return !r2.error && r2.status === 0;
Same pattern for the darwin/win32 branches (pbcopy/clip — check status === 0 before returning true).
Acceptance criteria
- Returns
false when the platform clipboard tool is missing or exits non-zero.
- Existing successful-copy behavior unchanged on macOS/Windows/Linux-with-xclip.
- A test or two covering the failure path (mock
spawnSync to return a non-zero status / error).
What's broken
copyToClipboard()insrc/screens/repl.ts:803-815always returnstrueunless thespawnSynccall itself throws — it never checks the exit status orerrorfield of the result:On a Linux box with neither
xclipnorxselinstalled, both spawn calls fail silently (non-zero exit / ENOENT), but the function still returnstrue. Every caller (/copycommand, "copy last response", clipboard menu actions) then shows "Copied to clipboard." when nothing was copied.Suggested fix
Check the actual result before returning success:
Same pattern for the darwin/win32 branches (
pbcopy/clip— checkstatus === 0before returningtrue).Acceptance criteria
falsewhen the platform clipboard tool is missing or exits non-zero.spawnSyncto return a non-zero status /error).