F1: settings.set refuses quoted, padded and control-character paths

Path settings get Kind::Path, checked by check_path in the engine: the one
validator for settings.set from agents, the CLI and the dialog. settings.list
marks them with path: true; the dialog uses that flag for Browse and shows
the engine's reason (userMessage drops the invalid-params prefix).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
danny 2026-11-02 19:02:08 +01:00
parent 750ecf5e51
commit 8a05f508c8
8 changed files with 150 additions and 51 deletions

View file

@ -19,7 +19,7 @@
import { defineStore } from "pinia";
import { reactive, ref } from "vue";
import { hasMessage, t } from "../i18n";
import { onEngineEvent, run, type EngineEventPayload } from "../ipc";
import { onEngineEvent, run, userMessage, type EngineError, type EngineEventPayload } from "../ipc";
import { setTokenOverride } from "../theme";
/** A setting value: settings are scalars. Values from the engine are unchecked. */
@ -48,6 +48,8 @@ export interface SettingDef {
descriptionKey: string;
/** Section id; shown with `settings.section.<id>`. */
section: string;
/** Whether a string setting holds a file path (the engine's `path` flag). */
path: boolean;
}
/** A section of the dialog with its settings, in engine order. */
@ -118,6 +120,7 @@ function toSettingDef(raw: unknown): SettingDef | null {
labelKey,
descriptionKey,
section,
path: type === "string" && entry.path === true,
};
}
@ -330,7 +333,8 @@ export const useSettingsStore = defineStore("settings", () => {
}
/**
* Stores the outcome of `settings.set` or `settings.reset`.
* Stores the outcome of `settings.set` or `settings.reset`. A refusal is
* kept as its reason, without the engine's command and key prefixes.
*
* @param key - the setting.
* @param result - the command's outcome.
@ -338,10 +342,11 @@ export const useSettingsStore = defineStore("settings", () => {
*/
function settle(
key: string,
result: { ok: true; value: unknown } | { ok: false; error: { message: string } },
result: { ok: true; value: unknown } | { ok: false; error: EngineError },
): boolean {
if (!result.ok) {
errors[key] = clip(result.error.message);
const message = userMessage(result.error);
errors[key] = clip(message.startsWith(`${key}: `) ? message.slice(key.length + 2) : message);
return false;
}
Reflect.deleteProperty(errors, key);