Skip to content

Commit 920d2c5

Browse files
committed
fix(permissions): omit /yolo hint from exec skip-permissions warning
Exec cannot run slash commands, so the recovery hint is TUI-only. Default-source exec stays path-only; custom sources stay path-only.
1 parent 2bcfd85 commit 920d2c5

5 files changed

Lines changed: 44 additions & 13 deletions

File tree

‎src/exec/runner.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -611,7 +611,7 @@ export async function runExec(config: Config): Promise<ExecResult> {
611611

612612
if (config.skipPermissionsFromSettings) {
613613
stderr.write(
614-
`${savedSkipPermissionsWarning(config.globalSettingsPath)}\n`,
614+
`${savedSkipPermissionsWarning(config.globalSettingsPath, "exec")}\n`,
615615
);
616616
}
617617

‎src/permission/saved-skip-warning.test.ts‎

Lines changed: 38 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,36 +6,65 @@ import { SETTINGS_DIR_NAME } from "../branding.js";
66
import { savedSkipPermissionsWarning } from "./saved-skip-warning.js";
77

88
describe("savedSkipPermissionsWarning", () => {
9-
test("default machine-wide source appends the /yolo off hint", () => {
9+
test("TUI default machine-wide source appends the /yolo off hint", () => {
1010
const source = join(homedir(), SETTINGS_DIR_NAME, "settings.json");
1111

12-
const warning = savedSkipPermissionsWarning(source);
12+
const warning = savedSkipPermissionsWarning(source, "tui");
1313

1414
expect(warning).toContain(source);
1515
expect(warning).toContain("edit that file to re-enable");
1616
expect(warning).toContain("/yolo off");
1717
});
1818

19-
test("symlinked-home alias of the default source still appends the hint", async () => {
19+
test("TUI symlinked-home alias of the default source still appends the hint", async () => {
2020
const sandbox = await mkdtemp(join(tmpdir(), "corbits-skip-warning-"));
2121
const homeLink = join(sandbox, "home");
2222
await symlink(homedir(), homeLink);
2323
const aliased = join(homeLink, SETTINGS_DIR_NAME, "settings.json");
2424

25-
const warning = savedSkipPermissionsWarning(aliased);
25+
const warning = savedSkipPermissionsWarning(aliased, "tui");
2626

2727
expect(warning).toContain(aliased);
2828
expect(warning).toContain("edit that file to re-enable");
2929
expect(warning).toContain("/yolo off");
3030
});
3131

32-
test("custom source keeps file-path wording with no false provenance", () => {
33-
const warning = savedSkipPermissionsWarning(
34-
"/tmp/custom-corbits-settings.json",
32+
test("exec default source stays path-only with no slash", () => {
33+
const source = join(homedir(), SETTINGS_DIR_NAME, "settings.json");
34+
35+
const warning = savedSkipPermissionsWarning(source, "exec");
36+
37+
expect(warning).toContain(source);
38+
expect(warning).toContain("edit that file to re-enable");
39+
expect(warning).not.toContain("/yolo");
40+
expect(warning).toBe(
41+
`Warning: permission prompts are disabled by saved settings at ${source}; edit that file to re-enable.`,
3542
);
43+
});
44+
45+
test("exec symlinked-home alias of the default source stays path-only", async () => {
46+
const sandbox = await mkdtemp(join(tmpdir(), "corbits-skip-warning-"));
47+
const homeLink = join(sandbox, "home");
48+
await symlink(homedir(), homeLink);
49+
const aliased = join(homeLink, SETTINGS_DIR_NAME, "settings.json");
50+
51+
const warning = savedSkipPermissionsWarning(aliased, "exec");
3652

37-
expect(warning).toContain("/tmp/custom-corbits-settings.json");
53+
expect(warning).toContain(aliased);
3854
expect(warning).toContain("edit that file to re-enable");
39-
expect(warning).not.toMatch(/machine-wide|saved default|\/yolo off/i);
55+
expect(warning).not.toContain("/yolo");
56+
});
57+
58+
test("custom source keeps file-path wording with no false provenance on both surfaces", () => {
59+
for (const surface of ["tui", "exec"] as const) {
60+
const warning = savedSkipPermissionsWarning(
61+
"/tmp/custom-corbits-settings.json",
62+
surface,
63+
);
64+
65+
expect(warning).toContain("/tmp/custom-corbits-settings.json");
66+
expect(warning).toContain("edit that file to re-enable");
67+
expect(warning).not.toMatch(/machine-wide|saved default|\/yolo off/i);
68+
}
4069
});
4170
});

‎src/permission/saved-skip-warning.ts‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,10 @@ function isDefaultSettingsSource(sourcePath: string): boolean {
1212

1313
export function savedSkipPermissionsWarning(
1414
globalSettingsPath: string,
15+
surface: "tui" | "exec",
1516
): string {
1617
const base = `Warning: permission prompts are disabled by saved settings at ${globalSettingsPath}; edit that file to re-enable`;
17-
if (isDefaultSettingsSource(globalSettingsPath)) {
18+
if (surface === "tui" && isDefaultSettingsSource(globalSettingsPath)) {
1819
return `${base} (/yolo off to re-enable).`;
1920
}
2021
return `${base}.`;

‎src/tui/runner/wiring.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ export function surfaceSavedSkipPermissionsWarning(
9696
if (!config.skipPermissionsFromSettings) return;
9797
surfaceSystemNotice(
9898
shell,
99-
savedSkipPermissionsWarning(config.globalSettingsPath),
99+
savedSkipPermissionsWarning(config.globalSettingsPath, "tui"),
100100
);
101101
}
102102

‎tests/unit/exec/runner.test.ts‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -491,8 +491,9 @@ describe("runExec", () => {
491491
);
492492
const stderrOutput = stderrChunks.join("");
493493
expect(stderrOutput).toContain(
494-
`Warning: permission prompts are disabled by saved settings at ${defaultSettingsPath}; edit that file to re-enable (/yolo off to re-enable).\n`,
494+
`Warning: permission prompts are disabled by saved settings at ${defaultSettingsPath}; edit that file to re-enable.\n`,
495495
);
496+
expect(stderrOutput).not.toContain("/yolo");
496497
expect(stderrOutput).toMatch(/runtime dispose failed/i);
497498
expect(disposeCalls).toBe(1);
498499
expect(getActiveDisposeHost()).toBeNull();

0 commit comments

Comments
 (0)