mirror of
https://github.com/bitbaum/loki.git
synced 2026-12-04 12:07:28 +01:00
* fix(loki): the composer draft survives a discarded tab
On a phone, tapping the paperclip hands control to Android's file picker,
and the browser tab is fair game for the memory killer while it is away
("Zu wenig Speicher für vorherige Operation", 2026-10-03). The open thread
came back — it lives in ?c= — but every word in the composer was React
state and went with the tab.
The draft is now mirrored to localStorage on each change, keyed per
thread (the start page has its own key), and restored once on mount. A
prefill wins over a stale draft. The workspace clears the draft under the
key it was WRITTEN in at send time, because a first message creates the
thread and moves the composer to the new key before chatkit's own
clear-after-send runs — without that, the next /loki visit would offer an
already-sent message back.
Text only: staged images are base64 in memory and would exceed the storage
quota; the picker reopens them in one tap.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01TtBnGxwf5ddXTzRNyjHVP7
* feat(loki): attach a voice recording and it is transcribed into the composer
What the screenshots on 2026-10-03 were trying to do: tap the paperclip,
browse to Recordings, hand Loki a voice memo. The paperclip filtered audio
out, and a file that arrived anyway (Android hands over .m4a typeless) was
treated as text and refused as too large.
chatkit b30c843 (v0.3.0) teaches the shared composer that a recording picked
as a file is dictation that happened earlier: it goes to the same Whisper
server leg as the mic, under its own name, and the words land in the box.
This pins it.
The server leg had its own ceiling: 10 MB on the route and Groq's ~25 MB
request cap, against a phone recorder that writes ~1 MB a minute. The route
now takes 120 MB (chatkit's upload cap, the same number), and
lib/transcribe downmixes anything over Groq's cap to 16 kHz mono Opus
(~11 MB an hour; Whisper resamples to that itself) and, if still over,
segments it on twenty-minute cuts and transcribes them in order. Both steps
need ffmpeg, which the box has for the local-Whisper fallback, and only run
past the cap, so the widget's 3 MB clips never reach them. A segment that
fails loses the take rather than leaving a silent twenty minutes that reads
as if nothing was said.
The lockfile entry for chatkit was computed from the codeload tarball
(sha512 of the exact archive, version from its package.json) because pnpm
cannot resolve a second, private git dep from this sandbox; CI's frozen
install is the check.
Test: pure decisions, plus a real ffmpeg downmix of a synthetic 25.6 MB WAV
that reaches the Groq step.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01TtBnGxwf5ddXTzRNyjHVP7
* feat(loki): the thread shows what Loki said and ran, live and reopened
The operator reads one rhythm all day in the Claude Code app: a sentence,
a collapsed group of commands with a chevron, a sentence, the answer. Loki
threw that away twice. What the model SAID in a gathering round ("Found it
— checking who owns them") was discarded at the next round's `reset`, so
the operator watched a spinner where they should have read the thinking.
And the tools it ran lived only in the live spinner and a list of names in
provenance: a reopened thread showed an answer that had apparently cost
nothing.
lib/loki/work.ts is the shape, pure and client-safe: one list in turn
order of notes (what Loki said while gathering) and tools (what it ran,
with the outcome). The loop keeps a gathering round's prose as a note and
streams it as one before the reset; tool steps join the same list; the
whole `work` returns with the answer and is persisted in provenance. The
hook applies note and tool events to the identical list live, and
WorkTrail renders segments — notes as prose in the trail's voice,
consecutive tools folded into one collapsible group, the running group
open — for the live turn and the reopened one alike, so nothing changes
between watching a turn and coming back to it.
A note is never the answer: grounding verifies only `text`, Copy copies
only `text`, and the note is styled as the trail, not the bubble.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01TtBnGxwf5ddXTzRNyjHVP7
* feat(loki): queue the next message while a turn runs; show the command under each step
Two more places the thread differed from the chat the operator uses all
day, closed.
Queue. A send during a turn was refused — Send went dark until the spinner
stopped, the one place a chat makes the person wait on the machine. Now
the composer takes it (chatkit 5f9d737, `queue`: Send stays live beside
Stop, placeholder "Queue a message…"), the workspace holds it in order and
shows it as a pill with a way to take it back, and sends it through the
same `send` when the turn ends. Held, not dropped, when the turn failed:
the error and its Try again stand in front of it. The draft is cleared
under the key it was typed in, like any send.
Detail. Each tool step in the work trail now carries its arguments as one
short line (`query: "Elena"`) — the command under the step — in the code
face, cut to one line, streamed live and persisted with the rest of the
work. Empty arguments are no line rather than `{}`.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01TtBnGxwf5ddXTzRNyjHVP7
* feat(loki): elapsed time on the live turn, Listen under every answer, the rail shows where each thread stopped
Three more details from the chat the operator uses all day.
Elapsed. The live status line now reads "2m 3s · Working on it". Without
the number, forty seconds and four minutes are the same three dots, and
the operator cannot tell patience from a hang.
Listen. A play button under every answer reads it with the browser's own
voices — no upload, no key, offline. Markdown is flattened first
(lib/loki/speech-text.ts: headings, emphasis, citations, URLs and fenced
code are not prose), the voice language is guessed from the text so a
German answer is not read in an English voice, one utterance at a time,
stopped on unmount. Hidden where there is no speechSynthesis rather than
shown dead.
Rail. Each thread shows its last line under the title — a title says what
a thread is about, the last message says where it stopped, which is what
decides whether to reopen it — via one correlated subquery, and the thread
with a turn in flight shows a spinner.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01TtBnGxwf5ddXTzRNyjHVP7
* fix(loki): drain the send queue after a turn lands, not from an effect
CI lint on 09f77adc: LokiWorkspace crossed the 510-line cap, and the queue
flush set state synchronously inside an effect watching `sending` — a
cascade React may run twice, and one that could not tell whether the turn
that just ended had succeeded.
The queue is its own hook (use-send-queue: state mirrored in a ref so an
async send reads the current list) and its pills their own component. The
stream's `send` now resolves to whether a turn landed, and the workspace
drains the queue right there, as an event, through the same `send`. A
failed or stopped turn leaves the queue standing behind the error.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01TtBnGxwf5ddXTzRNyjHVP7
* refactor(loki): dispatch-outcome polling is its own hook
LokiWorkspace was still seven code lines over the 510 cap after the queue
moved out. The poll that re-reads a thread while its newest turn is a
dispatch is self-contained; it is now hooks/use-dispatch-outcome.ts,
unchanged in behaviour.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01TtBnGxwf5ddXTzRNyjHVP7
---------
Co-authored-by: Claude <noreply@anthropic.com>
25 lines
1.2 KiB
TypeScript
25 lines
1.2 KiB
TypeScript
/**
|
|
* An answer read aloud is prose, not markdown syntax. Pure.
|
|
*/
|
|
import assert from "node:assert/strict";
|
|
import { guessSpeechLang, plainTextForSpeech } from "../../src/lib/loki/speech-text";
|
|
|
|
const spoken = plainTextForSpeech(
|
|
"## Summary\n\n- **Two runs** failed [F8] on `sink` [D1].\n- See [the log](https://x.y/z).\n\n```sh\nls\n```\n\n> quoted\n\n| a | b |",
|
|
);
|
|
assert.equal(spoken.includes("#"), false, "no heading marks");
|
|
assert.equal(spoken.includes("*"), false, "no emphasis marks");
|
|
assert.equal(spoken.includes("[F8]"), false, "no citations");
|
|
assert.equal(spoken.includes("https://"), false, "no urls");
|
|
assert.equal(spoken.includes("`"), false, "no backticks");
|
|
assert.match(spoken, /Two runs failed on sink/, "the words survive");
|
|
assert.match(spoken, /the log/, "link text survives");
|
|
assert.match(spoken, /\(code\)/, "code is named, not read");
|
|
assert.equal(plainTextForSpeech(" "), "");
|
|
|
|
assert.equal(guessSpeechLang("Die zwei Runs sind nicht mehr auf der Liste und das ist gut."), "de");
|
|
assert.equal(guessSpeechLang("The two runs are not on the list and that is fine."), "en");
|
|
assert.equal(guessSpeechLang("ok", "fr"), "fr", "too short to tell → the page's language");
|
|
|
|
console.log("loki-speech-text: ok");
|