The menu that never appeared, and the reason it never did

composer.js built its menu lazily inside show(), and refresh() wrote
list.innerHTML before calling it. `list` is null until build() has run, so the
first `/` or `@` ever typed threw a TypeError and took the handler with it. The
menu has never appeared in any browser. That is why /compact "isn't there":
nothing was. I shipped it having only run `node --check`, which parses the file
happily.

So this also brings the thing that catches it: a DOM stub driven under node --
not committed, hard rule 1 stands, it is an instrument like curl. It reproduced
the crash in one run and immediately found two more: choosing a command from the
menu left `/help` sitting in the box so the next Enter ran it again, and Tab
completed nothing. Tab now completes and Enter runs, which is the split that
matters for a command taking an argument.

`.select--sm` was used three times and defined nowhere. I deleted the copy in
chat.css and left a comment saying it "is defined once, in app.css", where it
did not exist -- so those selects fell back to plain `.select`: width 100% in a
flex row where four siblings wanted the same, all of them shrinking together
until each was a few characters wide, and half a rem taller than everything
beside them. That was the whole of "the connection switch needs to be wider".

The connection and directory move to the topbar. They cannot change -- update_chat
refuses both with a 409 -- so they are facts about the chat, of a kind with the
Temporary badge, not controls on the message. The mode stays by the box.

Compaction says it is working. It makes a model call that takes seconds and had
no indicator anywhere: `hx-indicator` appears nowhere in this codebase, and the
Generation.status channel that says "Summarising earlier messages…" for the
automatic path cannot be borrowed, because it lives in the streaming bubble and
this endpoint refuses to run while any message is unfinished. The overflow menu
now runs the same code as /compact rather than posting for itself, so there is
one implementation, one spinner, and one place the endpoint's four carefully
written 409s finally reach somebody.

/effort, low medium high, per chat with a per-model default. It goes out twice
because there is no field that works everywhere: OpenAI and vLLM read
reasoning_effort, llama.cpp's own docs say other values "have no effect" and its
maintainer says the field "simply gets dropped without error or logging" -- what
reaches gpt-oss behind it is chat_template_kwargs. Both are sent, and only once
an effort has been chosen, so a provider strict about unknown parameters sees
exactly the request it always did until somebody opts in. The control appears
only on a model marked `reasoning`, a flag that has existed since the beginning
with no reader at all.

Mentions and recognised commands are marked as you type -- a mirror behind the
textarea holding the same text with every character transparent, contributing
nothing but a rounded rectangle, so a pixel of drift is a misplaced rectangle
rather than a doubled glyph. A command is marked only when it resolves, so
`/thoughts on this` visibly is not one before you send it. And again in the
transcript, where user turns had no render step at all and now escape before
they inject.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
Jaroslav Beneš
2026-08-02 18:17:04 +02:00
parent a4cfb2eea4
commit 0bee366488
24 changed files with 968 additions and 79 deletions
+104 -19
View File
@@ -69,25 +69,14 @@
name: "compact",
summary: "Summarise the earlier turns so they stop costing context",
when: function () { return !!chat() && !!el("#thread .msg"); },
run: function () {
window.lembas.confirm(
"Summarise everything before the last reply? The messages stay in the " +
"transcript; they just stop being sent to the model.",
{ title: "Compact this chat", label: "Compact" }
).then(function (yes) {
if (!yes) return;
post("/api/chats/" + chat() + "/compact")
.then(function (r) { return r.ok ? r.text() : Promise.reject(r); })
.then(function (html) {
el("#thread").innerHTML = html;
if (window.htmx) window.htmx.process(el("#thread"));
})
.catch(function (r) {
if (r && r.json) r.json().then(function (body) { note(body.detail, "error"); });
else note("Could not compact this chat.", "error");
});
});
}
run: compact
},
{
name: "effort",
summary: "How hard a reasoning model should think",
argument: "low | medium | high",
when: function () { return !!chat() && !!el("[data-effort]"); },
run: function (rest) { setEffort(rest); }
},
{
name: "mode",
@@ -174,6 +163,102 @@
return function () { window.location = url; };
}
/* --- Reasoning effort ---------------------------------------------------
The command drives the same select the composer shows, so there is one
piece of state and the control updates itself when the command is used. */
var EFFORTS = ["low", "medium", "high"];
function setEffort(rest) {
var select = el("[data-effort]");
if (!select) {
return note("This model is not marked as a reasoning model.", "error");
}
var wanted = (rest || "").trim().toLowerCase();
if (!wanted) {
return note(
select.value
? "Effort is " + select.value + ". /effort low, medium, high, or default."
: "Effort is whatever the model does by default. Try low, medium or high."
);
}
if (wanted === "default" || wanted === "none") wanted = "";
else if (EFFORTS.indexOf(wanted) === -1) {
return note("“" + wanted + "” is not an effort. Try low, medium or high.", "error");
}
select.value = wanted;
select.dispatchEvent(new Event("change", { bubbles: true }));
note(
wanted
? "Effort set to " + wanted + "."
: "Effort cleared; the model decides."
);
}
/* --- Compacting --------------------------------------------------------
One implementation, reached from the command and from the overflow menu
alike. The menu used to do its own hx-post, which meant two code paths and
a spinner on neither -- so after confirming, the menu closed and nothing
visible happened for however long the summarising model took.
The `Generation.status` channel that says "Summarising earlier messages…"
during *automatic* compaction cannot be borrowed: it lives inside the
streaming bubble, and this endpoint refuses to run while any message is
unfinished, so there is no bubble to put it in. */
var compacting = false;
function compact() {
if (compacting) return note("Already summarising.");
var thread = el("#thread");
if (!thread) return;
window.lembas.confirm(
"Summarise everything before the last reply? The messages stay in the " +
"transcript; they just stop being sent to the model.",
{ title: "Compact this chat", label: "Compact" }
).then(function (yes) {
if (!yes) return;
compacting = true;
var working = document.createElement("div");
working.className = "thread__working";
// The same words the automatic path uses, so the two do not look like
// different features.
working.innerHTML =
'<span class="dots"><i></i><i></i><i></i></span>' +
"<span>Summarising the earlier messages…</span>";
thread.appendChild(working);
if (window.lembas.scrollThread) window.lembas.scrollThread(true);
function done() {
compacting = false;
working.remove();
}
post("/api/chats/" + chat() + "/compact")
.then(function (r) { return r.ok ? r.text() : Promise.reject(r); })
.then(function (html) {
compacting = false;
// The response replaces the thread wholesale, placeholder included.
thread.innerHTML = html;
if (window.htmx) window.htmx.process(thread);
if (window.lembas.scrollThread) window.lembas.scrollThread(true);
})
.catch(function (r) {
done();
/* The endpoint's four 409s are written for a person to read -- "Wait
for the current reply to finish, then compact." -- and until now
reached nobody at all. */
if (r && r.json) {
r.json()
.then(function (body) { note(body.detail || "Could not compact.", "error"); })
.catch(function () { note("Could not compact this chat.", "error"); });
} else {
note("Could not compact this chat.", "error");
}
});
});
}
function toggle(selector, group) {
var panel = el(selector);
if (panel && window.lembas.setPanel) {