mirror of
https://github.com/multica-ai/multica.git
synced 2026-07-27 13:06:20 +02:00
A complete UX upgrade for chat sending → receiving → recovering.
* StatusPill replaces the orphan spinner — stage-aware copy
("Reading files · 12s", "Searching the web · 14s", "Typing · 24s"),
shimmer text, monotonic timer, derived effective status, > 60s
warning tone, > 5min cancel button.
* WS writethrough on task:queued / task:dispatch / task:cancelled so
pendingTask cache stays in sync with the daemon state machine without
invalidate-refetch latency. broadcastTaskDispatch now includes
chat_session_id when the task is for a chat session — the existing
payload only carried it on the generic task: events, leaving the pill
stuck at "Queued" until completion.
* Failure fallback — FailTask writes a chat_message tagged with
failure_reason (mirrors the issue path's system comment, gated on
retried==nil). Front-end renders an inline note ("Connection failed",
with a Show details collapsible) instead of the previous black hole.
* Elapsed timing — chat_message.elapsed_ms persists task.completed_at -
task.created_at on success/failure rows. UI shows "Replied in 38s" /
"Failed after 12s" beneath assistant bubbles. Format helper shared
between StatusPill and the persisted caption so the live timer and
final reading never disagree.
* Optimistic burst rebalanced — pendingTask seed + created_at moved
before the HTTP roundtrip so the pill appears the instant the user
hits send; handleStop is fire-and-forget so cancel feels immediate
(server confirmation arrives via task:cancelled WS).
* Presence integration — chat avatars use ActorAvatar (status dot +
hover card); OfflineBanner above the input on offline/unstable;
SessionDropdown shows per-row in-flight/unread pip plus a
cross-session aggregate pip on the closed trigger.
* Editor blur on send so the caret stops competing with the StatusPill
/ streaming reply for the user's attention.
* Chat panel isOpen now persists globally; defaults to OPEN for new
users (storage key absence) so the feature is discoverable. Existing
users' prior choice is respected.
* DB: migrations 062 (failure_reason) + 063 (elapsed_ms), both
ADD COLUMN NULL — fast, non-blocking, backwards compatible.
* WS: task:failed chat path now invalidates chatKeys.messages — fixes
a pre-existing bug where the failure bubble required a page refresh
to appear.
Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
48 lines
1.4 KiB
TypeScript
48 lines
1.4 KiB
TypeScript
"use client";
|
|
|
|
import { useEffect, useState } from "react";
|
|
import spinners, { type BrailleSpinnerName } from "unicode-animations";
|
|
|
|
interface Props {
|
|
name?: BrailleSpinnerName;
|
|
className?: string;
|
|
/** Stop advancing frames without unmounting (e.g., when an outer state freezes). */
|
|
paused?: boolean;
|
|
}
|
|
|
|
// Inline-rendered braille spinner. Each frame is a unicode string from the
|
|
// `unicode-animations` package; we tick frames on the spinner's own `interval`
|
|
// and render the current one inside a fixed-width monospace span so different
|
|
// frames never reflow neighbouring text. Width-jitter is the main reason this
|
|
// component exists rather than dropping the raw strings into Tailwind classes.
|
|
export function UnicodeSpinner({ name = "braille", className, paused }: Props) {
|
|
const spec = spinners[name];
|
|
const [frame, setFrame] = useState(0);
|
|
|
|
useEffect(() => {
|
|
if (paused) return;
|
|
setFrame(0);
|
|
const timer = setInterval(
|
|
() => setFrame((f) => (f + 1) % spec.frames.length),
|
|
spec.interval,
|
|
);
|
|
return () => clearInterval(timer);
|
|
}, [name, paused, spec]);
|
|
|
|
return (
|
|
<span
|
|
aria-hidden="true"
|
|
className={className}
|
|
style={{
|
|
fontFamily: "ui-monospace, SFMono-Regular, Menlo, Consolas, monospace",
|
|
display: "inline-block",
|
|
minWidth: "1ch",
|
|
textAlign: "center",
|
|
fontVariantNumeric: "tabular-nums",
|
|
}}
|
|
>
|
|
{spec.frames[frame]}
|
|
</span>
|
|
);
|
|
}
|