mirror of
https://github.com/jparkerweb/plan2code.git
synced 2026-12-05 08:15:41 -08:00
Tell a failed macOS folder picker from a cancel, and start Browse at a folder that exists
AI Assisted
This commit is contained in:
1 parent
91479b21a1
commit
ddbc85f73d
5 files changed
+202
-42
No files matched your search
@@ -948,6 +948,34 @@ test("launcher app: modelFrom reads --model, --model= and Codex's -m", () => {
|
||||
assert.equal(modelFrom(["--verbose"], "claude"), null);
|
||||
});
|
||||
|
||||
// osascript exits 1 both on a cancel and on a failure; only the cancel has -128.
|
||||
test("launcher picker: on macOS an exit 1 is a cancel only with osascript's (-128); elsewhere an exit 1 with nothing picked stays a cancel", () => {
|
||||
const { pickerCancelled } = require(LAUNCHER);
|
||||
const cancel = "0:17: execution error: User canceled. (-128)\n";
|
||||
const failure = "0:4: execution error: The variable this is not defined. (-2753)\n";
|
||||
assert.equal(pickerCancelled(1, "", cancel, "darwin"), true);
|
||||
assert.equal(pickerCancelled(1, "", failure, "darwin"), false, "a failure falls through to the typed prompt");
|
||||
assert.equal(pickerCancelled(1, "", "", "darwin"), false);
|
||||
assert.equal(pickerCancelled(1, null, null, "darwin"), false);
|
||||
for (const platform of ["linux", "win32"]) {
|
||||
assert.equal(pickerCancelled(1, "", "", platform), true, platform);
|
||||
assert.equal(pickerCancelled(1, "", "Gtk-WARNING\n", platform), true, platform);
|
||||
assert.equal(pickerCancelled(3, "", "", platform), false, platform);
|
||||
}
|
||||
for (const platform of ["darwin", "linux", "win32"]) {
|
||||
assert.equal(pickerCancelled(0, "", "", platform), true, `${platform}: exit 0 with nothing picked`);
|
||||
assert.equal(pickerCancelled(0, "/some/folder\n", "", platform), false, `${platform}: a pick`);
|
||||
assert.equal(pickerCancelled(1, "/some/folder\n", cancel, platform), false, `${platform}: something printed is no cancel`);
|
||||
}
|
||||
});
|
||||
|
||||
test("launcher picker: pickFolder decides a cancel through pickerCancelled", () => {
|
||||
const source = fs.readFileSync(require.resolve(LAUNCHER), "utf8");
|
||||
const body = source.slice(source.indexOf("async function pickFolder"), source.indexOf("async function projectCwd"));
|
||||
assert.match(body, /pickerCancelled\(result\.status, result\.stdout, result\.stderr\)/);
|
||||
assert.doesNotMatch(body, /result\.status === 1/, "no cancel rule left beside it");
|
||||
});
|
||||
|
||||
test("launcher app: an app that starts and then exits with a failure falls back to the terminal flow", (t) => {
|
||||
const box = sandbox(["claude"]);
|
||||
t.after(box.cleanup);
|
||||
|
||||
Reference in new issue
Block a user