* media: check ffmpeg filter support before subtitle operations * sandbox: handle synchronous spawn errors safely in desktop sandbox * Voice-first streaming, non-blocking follow-ups, quiet routines and chat UX Why: questions blocked the chat, follow-up messages had no acknowledgement, message actions sat beside the bubble, and voice turn-taking added latency. What: waiting runs accept steering messages and the bot marks each claimed follow-up as seen; unclaimed follow-ups show as queued. Reaction, copy and reply controls sit under each message. Streaming voice (VAD endpointing, barge-in that stops the run, clause-based TTS), an optimistic input queue, procedural earcons and delta-based quiet routines were added. Onboarding can be skipped straight to the main conversation. Dual-surface layout and project pickers are included. Status colors use semantic tokens. Tested: unit suites for core, adapters, api and web pass, typecheck and Biome are clean. Browser end-to-end tests were not run locally. * Update translation catalogs Re-extracted catalogs for the new and moved strings; the catalog sync test passes. * Add project plan and test readiness notes Notes from the milestone work: feature inventory, test infrastructure and test readiness. No code changes. * fix(ci): align scale guards, space deletion, computer toggle, and mobile expo deps * fix(ci): restore space deletion guard, browser toggle, and run-steps contracts * fix(ci): restore model resolution errors, group stage, and onboarding flow * fix(ci): restore in-app-browser close button, disable stop button while sending, and sync lingui catalogs * fix(ci): address web e2e failures for bot-crud, choice cards, message quote, and voice onboarding * test(web): wait for avatar and rig visibility in oo-avatar motion spec * test(web): wait for persisted message IDs in message-hover-actions pagination spec * Onboarding: always drop the local voice when the voice step is skipped Skipping waited only for the latest voice load and disconnected only when the client saw the connect succeed. An earlier or client-failed connect could still persist the local credential, so a user who skipped voice was left with one. Wait for every load and always disconnect. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Wy1md9QE1ayJbDCwJ4vAQs * Shell: hide the optimistic copy once the transcript shows the send A message sent while the bot works streamed into the transcript before its send request resolved, so the same text showed twice until the optimistic bubble was removed. Drop an optimistic message as soon as a persisted user message with the same text appears. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Wy1md9QE1ayJbDCwJ4vAQs --------- Co-authored-by: Claude <noreply@anthropic.com>
92 lines
3.4 KiB
TypeScript
92 lines
3.4 KiB
TypeScript
import type { MessageBlock } from "@rakazo/contracts";
|
|
import { isToolActivityBlock } from "@rakazo/core";
|
|
|
|
/** Keep mid-turn progress beats short; prefer a few high-signal updates. */
|
|
export const USER_PROGRESS_MESSAGE_MAX_LENGTH = 500;
|
|
|
|
export function clampUserProgressMessage(text: string): string {
|
|
const trimmed = text.trim();
|
|
if (!trimmed) return "";
|
|
if (trimmed.length <= USER_PROGRESS_MESSAGE_MAX_LENGTH) return trimmed;
|
|
return `${trimmed.slice(0, USER_PROGRESS_MESSAGE_MAX_LENGTH - 1).trimEnd()}…`;
|
|
}
|
|
|
|
/**
|
|
* True when the raw text a caller tried to post as a mid-turn progress update
|
|
* would not fit and got cut off by clampUserProgressMessage. Callers should
|
|
* surface this back to the model (it gets no other signal that its message
|
|
* was mangled) rather than reporting a silent success.
|
|
*/
|
|
export function isProgressMessageTruncated(text: string): boolean {
|
|
return text.trim().length > USER_PROGRESS_MESSAGE_MAX_LENGTH;
|
|
}
|
|
|
|
/**
|
|
* Pull narration text out of the in-progress turn segments so it can be posted
|
|
* as a durable mid-turn message. Tool/step blocks stay for the final publish.
|
|
*/
|
|
|
|
/** clientNonce prefix for mid-turn progress messages (reconciler uses this). */
|
|
export const USER_PROGRESS_CLIENT_NONCE_PREFIX = "user-progress:";
|
|
|
|
export function userProgressClientNonce(runId: string, index = 0): string {
|
|
// Include entropy so a resumed executor turn cannot reuse an earlier nonce
|
|
// (threadId + clientNonce is unique).
|
|
return `${USER_PROGRESS_CLIENT_NONCE_PREFIX}${runId}:${index}:${Date.now().toString(36)}:${Math.random().toString(36).slice(2, 10)}`;
|
|
}
|
|
|
|
export function isUserProgressClientNonce(clientNonce: string | null | undefined): boolean {
|
|
return Boolean(clientNonce?.startsWith(USER_PROGRESS_CLIENT_NONCE_PREFIX));
|
|
}
|
|
|
|
export function extractNarrationText(
|
|
segments: readonly MessageBlock[],
|
|
currentText: string,
|
|
): { text: string; remaining: MessageBlock[] } {
|
|
const parts: string[] = [];
|
|
const remaining: MessageBlock[] = [];
|
|
for (const block of segments) {
|
|
if (block.kind === "text") {
|
|
if (block.text) parts.push(block.text);
|
|
continue;
|
|
}
|
|
remaining.push(block);
|
|
}
|
|
if (currentText) parts.push(currentText);
|
|
return { text: parts.join(""), remaining };
|
|
}
|
|
|
|
/**
|
|
* After mid-turn progress messages were already posted, skip a hollow final
|
|
* message that would only carry hidden tool-activity blocks (or nothing).
|
|
*/
|
|
export function finalBlocksAfterMidTurnProgress(
|
|
blocks: MessageBlock[],
|
|
publishedMidTurn: boolean,
|
|
): MessageBlock[] {
|
|
if (!publishedMidTurn || blocks.length === 0) return blocks;
|
|
const meaningfulBlocks = blocks.filter((b) => {
|
|
if (b.kind === "text") {
|
|
const trimmed = b.text.trim();
|
|
if (trimmed.length <= 3 && !/[.!?:]/.test(trimmed)) {
|
|
return false;
|
|
}
|
|
}
|
|
return true;
|
|
});
|
|
if (meaningfulBlocks.every((block) => isToolActivityBlock(block))) return [];
|
|
return meaningfulBlocks;
|
|
}
|
|
|
|
/** Outcome to return for a bot_message run after mid-turn progress posts. */
|
|
export function botMessageOutcomeFromMidTurn(
|
|
finalText: string,
|
|
midTurnTexts: readonly string[],
|
|
): { text: string; intent: "result" | "status" } | null {
|
|
const trimmed = finalText.trim();
|
|
if (trimmed) return { text: trimmed, intent: "result" };
|
|
const midTurn = midTurnTexts.map((part) => part.trim()).filter(Boolean);
|
|
if (midTurn.length === 0) return null;
|
|
return { text: midTurn.join("\n\n"), intent: "status" };
|
|
}
|