PWA, one send/stop button, audio in and out, web search as a tool
Four pieces of work.
**Installable.** A manifest carrying the instance name, PWA icons rasterised
from the existing mark at design time, a service worker and a themed offline
page. The worker caches the shell only and bails out on /api/, /auth/, /admin/
and anything accepting text/event-stream -- passing a reply stream through a
worker turns it into one delivery at the end, or nothing. It is served from
GET /sw.js rather than the static mount because a worker's scope is the path it
came from.
**Send and Stop are one button.** They were two, and the hidden one was never
hidden: `.btn` is display: inline-flex, which outranks the browser's own
`[hidden] { display: none }`, so Stop sat permanently beside Send. app.css now
forces the attribute to win -- every control toggled with `hidden` depended on
that -- and the composer renders one button carrying both icons, with ui.js
flipping data-composer-action and the type with it.
**Audio.** Speech to text and text to speech against any OpenAI-shaped
/v1/audio/* endpoint: dictate into the composer, have a reply read out.
Instance settings in Admin, per-reader overrides in Settings, with the voice
list discovered from the server where it offers one. Recorded audio is capped
and never written to disk -- it is not an attachment, it has no owner, and
nothing would ever sweep it.
**Web search, as a tool.** This is the tool loop PLAN.md described as the real
work: one reply is now a bounded sequence of requests rather than one. The model
asks, the tool runs, the result goes back and it is asked again, up to three
rounds. Providers are DuckDuckGo (no setup), SearXNG and Firecrawl.
Two decisions worth stating. Tools are only offered to models flagged `tools`,
because an endpoint without support rejects the whole request rather than
ignoring the array -- the same reason images only reach models flagged
`vision`. And tool results are not replayed as context on the next turn, for the
same reasons reasoning is not: the answer already contains what the model made
of them, and replaying stale results into every later request wastes the window
and reliably sends a small model into a search loop. The sources stay visible in
the transcript instead.
Search results are untrusted third-party text and are treated as such: escaped,
and only http/https URLs rendered as links.
338 tests, ruff clean.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.8
parent
ca3e4fd04f
commit
436226370a
@@ -0,0 +1,61 @@
|
||||
{% from "_macros.html" import icon %}
|
||||
{#
|
||||
What the model did before answering.
|
||||
|
||||
Rendered both live (streamed as a whole block, like the reasoning and the
|
||||
answer) and from the stored message afterwards, so the sources behind an
|
||||
answer stay in the transcript rather than vanishing when the stream ends.
|
||||
|
||||
EVERYTHING in here comes from a search provider and is untrusted, exactly as
|
||||
much as model output is. Jinja autoescaping covers the text; the URL is
|
||||
checked separately, because `is_linkable` is the only thing standing between
|
||||
a result carrying a javascript: URL and an anchor pointing at it.
|
||||
#}
|
||||
{% for event in tool_events %}
|
||||
<details class="tool-activity {{ 'tool-activity--error' if event.status == 'error' }}">
|
||||
<summary class="tool-activity__summary">
|
||||
{{ icon("globe", "icon--sm tool-activity__icon") }}
|
||||
<span class="tool-activity__label">
|
||||
{% if event.status == "error" %}
|
||||
Web search failed
|
||||
{% elif event.query %}
|
||||
Searched the web for “{{ event.query }}”
|
||||
{% else %}
|
||||
Searched the web
|
||||
{% endif %}
|
||||
{% if event.results %}
|
||||
<span class="tool-activity__count">
|
||||
· {{ event.results | length }} result{{ '' if event.results | length == 1 else 's' }}
|
||||
</span>
|
||||
{% endif %}
|
||||
</span>
|
||||
{{ icon("chevron-down", "icon--sm reasoning__chevron") }}
|
||||
</summary>
|
||||
|
||||
<div class="tool-activity__body">
|
||||
{% if event.error %}
|
||||
<p class="tool-activity__error">{{ event.error }}</p>
|
||||
{% elif not event.results %}
|
||||
<p class="tool-activity__error">Nothing was found.</p>
|
||||
{% endif %}
|
||||
|
||||
{% for result in event.results %}
|
||||
<div class="tool-result">
|
||||
{% set scheme = result.url.split(":")[0] | lower %}
|
||||
{% if scheme in ("http", "https") %}
|
||||
<a class="tool-result__title" href="{{ result.url }}"
|
||||
target="_blank" rel="noopener noreferrer nofollow">{{ result.title }}</a>
|
||||
{% else %}
|
||||
{# Not a link. A search result is third-party text and its URL is not
|
||||
trusted to be safe to click. #}
|
||||
<span class="tool-result__title">{{ result.title }}</span>
|
||||
{% endif %}
|
||||
<span class="tool-result__host">{{ result.host }}</span>
|
||||
{% if result.snippet %}
|
||||
<p class="tool-result__snippet">{{ result.snippet }}</p>
|
||||
{% endif %}
|
||||
</div>
|
||||
{% endfor %}
|
||||
</div>
|
||||
</details>
|
||||
{% endfor %}
|
||||
Reference in New Issue
Block a user