feat: add advanced context actions and optional translation

This commit is contained in:
golem
2026-10-05 15:38:16 -06:00
parent 33c4dad00f
commit 5308932bf1
34 changed files with 1579 additions and 159 deletions
+6 -12
View File
@@ -23,13 +23,9 @@ test("an empty or whitespace-only query omits q entirely", () => {
}
});
test("model is sent only when non-empty after trimming", () => {
assert.equal(queryOf(buildChatGptUrl(withSettings({ model: "auto" }), "hi")), "hi");
assert.equal(new URL(buildChatGptUrl(withSettings({ model: "auto" }), "hi")).searchParams.get("model"), "auto");
assert.equal(new URL(buildChatGptUrl(withSettings({ model: " auto " }), "hi")).searchParams.get("model"), "auto");
for (const model of ["", " "]) {
assert.equal(paramsOf(buildChatGptUrl(withSettings({ model }), "hi")).includes("model"), false);
}
test("legacy model values never add a model URL parameter", () => {
assert.equal(buildChatGptUrl(withSettings({ model: "gpt-5.6-sol" }), "hi"),
buildChatGptUrl(DEFAULT_SETTINGS, "hi"));
});
test("temporaryChat and webSearch each appear only when enabled", () => {
@@ -43,17 +39,16 @@ test("temporaryChat and webSearch each appear only when enabled", () => {
assert.equal(search.searchParams.get("hints"), "search");
});
test("all four URL-affecting settings combine, q first", () => {
test("all three URL-affecting settings combine, q first", () => {
const url = buildChatGptUrl(
withSettings({
model: "auto",
temporaryChat: true,
webSearch: true,
promptTemplate: "Explain: {query}",
}),
"entropy",
);
assert.deepEqual(paramsOf(url), ["q", "model", "temporary-chat", "hints"]);
assert.deepEqual(paramsOf(url), ["q", "temporary-chat", "hints"]);
assert.equal(queryOf(url), "Explain: entropy");
});
@@ -100,10 +95,9 @@ test("an over-long prompt is truncated to fit the URL budget", () => {
});
test("truncation accounts for the other parameters", () => {
const settings = withSettings({ model: "some-long-model-slug", temporaryChat: true, webSearch: true });
const settings = withSettings({ temporaryChat: true, webSearch: true });
const url = buildChatGptUrl(settings, "x".repeat(20000));
assert.ok(url.length <= MAX_URL_CHARS, `length was ${url.length}`);
assert.equal(new URL(url).searchParams.get("model"), "some-long-model-slug");
assert.equal(new URL(url).searchParams.get("hints"), "search");
});