A suggestion card sends its prompt

Filling the composer and waiting for Enter made the card a form to review
rather than a thing to press. One click, one reply.

That changes what a prompt has to be. The built-ins ended mid-sentence --
"My plan: " -- because nothing was sent until the person finished the
thought; sent cold they are a model guessing at material nobody gave it. All
three are rewritten to ask for what they need, so the first reply is the
right question instead. There is a test that they end as complete sentences,
since the failure is silent and only visible in the answer.

requestSubmit, not submit: it fires the submit event, which is what htmx
listens for. Same call the Enter key already makes.

Version bumped because app.js is what changed, and the service worker caches
it -- without the bump the first load after this would still only fill the
box.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
Jaroslav Beneš
2026-08-01 01:12:02 +02:00
parent 584beca22d
commit d9f274ec1a
7 changed files with 45 additions and 30 deletions
+9 -5
View File
@@ -384,9 +384,11 @@
return;
}
/* A suggestion card fills the composer and stops there. It deliberately
does not submit: the prompts end mid-sentence, because a card is a
starting point rather than a question somebody already asked. */
/* A suggestion card sends its prompt. One click, one reply -- filling the
box and waiting for Enter makes the card a form to review rather than a
thing to press. The built-in prompts are written to work sent cold: each
asks for what it needs, so the answer is a question back rather than a
guess at material nobody has given yet. */
var suggestion = event.target.closest("[data-suggestion]");
if (suggestion) {
event.preventDefault();
@@ -394,8 +396,10 @@
if (!input) return;
input.value = suggestion.dataset.suggestion;
autosize(input);
input.focus();
input.setSelectionRange(input.value.length, input.value.length);
var form = input.closest("form");
/* requestSubmit, not submit(): it fires the submit event, which is what
htmx is listening for. Same call the Enter key makes. */
if (form) form.requestSubmit();
return;
}
@@ -7,9 +7,9 @@
{% block admin_content %}
<p class="admin-lede">
Cards on the new-chat screen. Clicking one puts its prompt in the composer
without sending it — the built-in ones deliberately end mid-sentence, so the
caret lands where the person has to start typing. The first
Cards on the new-chat screen. Clicking one sends its prompt straight away, so
each has to work on its own — write one that asks for whatever it needs, and
the first reply becomes the right question rather than a guess. The first
{{ max_shown }} enabled ones are shown, in this order.
</p>
@@ -64,8 +64,8 @@
<textarea class="textarea" id="prompt-{{ suggestion.id }}" name="prompt"
rows="4">{{ suggestion.prompt }}</textarea>
<p class="field__hint">
Put in the composer, not sent. Ending it mid-sentence is usually right:
the person still has to say what they are asking about.
Sent as the first message. Nothing is added to it, so a prompt that needs
material should ask for it.
</p>
</div>
@@ -104,7 +104,7 @@
<div class="field">
<label class="field__label" for="new-prompt">Prompt</label>
<textarea class="textarea" id="new-prompt" name="prompt" rows="4"
placeholder="What lands in the composer when the card is clicked."></textarea>
placeholder="Sent as the first message when the card is clicked."></textarea>
</div>
<div class="card__footer">
<button class="btn btn--primary" type="submit">Add</button>