fix: prefer the focused frame, bound model length, drop dead flag

This commit is contained in:
golem
2026-08-01 23:15:46 -06:00
parent d7821e3dc7
commit 51bf4d5c01
6 changed files with 37 additions and 13 deletions
+15 -1
View File
@@ -1,7 +1,7 @@
import test from "node:test";
import assert from "node:assert/strict";
import { DEFAULT_SETTINGS } from "../lib/defaults.js";
import { DEFAULT_SETTINGS, MAX_MODEL_CHARS } from "../lib/defaults.js";
import { mergeSettings } from "../lib/settings.js";
test("empty object yields the defaults", () => {
@@ -78,3 +78,17 @@ test("mergeSettings does not mutate DEFAULT_SETTINGS", () => {
mergeSettings({ model: "mutated" });
assert.equal(DEFAULT_SETTINGS.model, "");
});
// An unbounded model string can, on its own, push the finished URL over
// MAX_URL_CHARS (lib/build-url.js), which silently drops `q` — the user's
// selection vanishes with no signal. mergeSettings() must bound `model` the
// same way it already bounds an out-of-range openIn: fall back to the default.
test("a model at exactly MAX_MODEL_CHARS is accepted", () => {
const model = "m".repeat(MAX_MODEL_CHARS);
assert.equal(mergeSettings({ model }).model, model);
});
test("a model one character over MAX_MODEL_CHARS falls back to the default", () => {
const model = "m".repeat(MAX_MODEL_CHARS + 1);
assert.equal(mergeSettings({ model }).model, DEFAULT_SETTINGS.model);
});