* 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>
261 lines
7.4 KiB
TypeScript
261 lines
7.4 KiB
TypeScript
import { describe, expect, it, vi } from "vitest";
|
|
import {
|
|
finalizeRoutineFailureNotification,
|
|
finalizeRoutineNotification,
|
|
handleRoutineSelfHealing,
|
|
MAX_ROUTINE_ATTEMPTS,
|
|
} from "./executor-routine.js";
|
|
import type { ExecutorDeps } from "./executor-types.js";
|
|
|
|
describe("finalizeRoutineNotification", () => {
|
|
it("suppresses notification and unread badge when on_change detects no delta", async () => {
|
|
const notifySend = vi.fn().mockResolvedValue(true);
|
|
const mockDeps = {
|
|
notifications: { send: notifySend },
|
|
prisma: {
|
|
run: {
|
|
findFirst: vi.fn().mockResolvedValue({
|
|
bot: { notifyOnFinish: true },
|
|
thread: { groupId: null },
|
|
}),
|
|
},
|
|
},
|
|
} as unknown as ExecutorDeps;
|
|
|
|
const result = await finalizeRoutineNotification({
|
|
deps: mockDeps,
|
|
run: {
|
|
id: "run-1",
|
|
spaceId: "space-1",
|
|
botId: "bot-1",
|
|
threadId: "thread-1",
|
|
userId: "user-1",
|
|
routineId: "routine-1",
|
|
},
|
|
bot: { id: "bot-1", name: "Monitor Bot" },
|
|
routine: { id: "routine-1", name: "Health Check", notify: true },
|
|
notifyMode: "on_change",
|
|
outputText: "All systems operational",
|
|
hasChanged: false,
|
|
});
|
|
|
|
expect(result.markUnread).toBe(false);
|
|
expect(result.isQuiet).toBe(true);
|
|
expect(notifySend).not.toHaveBeenCalled();
|
|
});
|
|
|
|
it("dispatches notification and sets unread when on_change detects delta", async () => {
|
|
const notifySend = vi.fn().mockResolvedValue(true);
|
|
const mockDeps = {
|
|
notifications: { send: notifySend },
|
|
prisma: {
|
|
run: {
|
|
findFirst: vi.fn().mockResolvedValue({
|
|
bot: { notifyOnFinish: true },
|
|
thread: { groupId: null },
|
|
}),
|
|
},
|
|
},
|
|
} as unknown as ExecutorDeps;
|
|
|
|
const result = await finalizeRoutineNotification({
|
|
deps: mockDeps,
|
|
run: {
|
|
id: "run-1",
|
|
spaceId: "space-1",
|
|
botId: "bot-1",
|
|
threadId: "thread-1",
|
|
userId: "user-1",
|
|
routineId: "routine-1",
|
|
},
|
|
bot: { id: "bot-1", name: "Monitor Bot" },
|
|
routine: { id: "routine-1", name: "Health Check", notify: true },
|
|
notifyMode: "on_change",
|
|
outputText: "New alert: CPU high",
|
|
hasChanged: true,
|
|
deltaSummary: "CPU high",
|
|
});
|
|
|
|
expect(result.markUnread).toBe(true);
|
|
expect(result.isQuiet).toBe(false);
|
|
expect(notifySend).toHaveBeenCalledTimes(1);
|
|
expect(notifySend).toHaveBeenCalledWith(
|
|
expect.objectContaining({
|
|
kind: "completion",
|
|
title: "Monitor Bot",
|
|
body: "CPU high",
|
|
}),
|
|
expect.anything(),
|
|
);
|
|
});
|
|
|
|
it("suppresses notifications when routine.notify is false", async () => {
|
|
const notifySend = vi.fn().mockResolvedValue(true);
|
|
const mockDeps = {
|
|
notifications: { send: notifySend },
|
|
prisma: {
|
|
run: {
|
|
findFirst: vi.fn().mockResolvedValue({
|
|
bot: { notifyOnFinish: true },
|
|
thread: { groupId: null },
|
|
}),
|
|
},
|
|
},
|
|
} as unknown as ExecutorDeps;
|
|
|
|
const result = await finalizeRoutineNotification({
|
|
deps: mockDeps,
|
|
run: {
|
|
id: "run-1",
|
|
spaceId: "space-1",
|
|
botId: "bot-1",
|
|
threadId: "thread-1",
|
|
userId: "user-1",
|
|
routineId: "routine-1",
|
|
},
|
|
bot: { id: "bot-1", name: "Monitor Bot" },
|
|
routine: { id: "routine-1", name: "Health Check", notify: false },
|
|
notifyMode: "always",
|
|
outputText: "Changed output",
|
|
hasChanged: true,
|
|
});
|
|
|
|
expect(result.markUnread).toBe(false);
|
|
expect(result.isQuiet).toBe(true);
|
|
expect(notifySend).not.toHaveBeenCalled();
|
|
});
|
|
});
|
|
|
|
describe("finalizeRoutineFailureNotification", () => {
|
|
it("dispatches notification on failure when notifyMode permits", async () => {
|
|
const notifySend = vi.fn().mockResolvedValue(true);
|
|
const mockDeps = {
|
|
notifications: { send: notifySend },
|
|
prisma: {
|
|
run: {
|
|
findFirst: vi.fn().mockResolvedValue({
|
|
bot: { notifyOnFinish: true },
|
|
thread: { groupId: null },
|
|
}),
|
|
},
|
|
},
|
|
} as unknown as ExecutorDeps;
|
|
|
|
const notified = await finalizeRoutineFailureNotification(
|
|
mockDeps,
|
|
{
|
|
spaceId: "space-1",
|
|
botId: "bot-1",
|
|
threadId: "thread-1",
|
|
userId: "user-1",
|
|
routineId: "routine-1",
|
|
},
|
|
{ id: "bot-1", name: "Monitor Bot" },
|
|
{ id: "routine-1", name: "Health Check", notify: true },
|
|
"on_failure",
|
|
"Network connection refused",
|
|
);
|
|
|
|
expect(notified).toBe(true);
|
|
expect(notifySend).toHaveBeenCalledTimes(1);
|
|
});
|
|
|
|
it("suppresses failure notification when notifyMode is never", async () => {
|
|
const notifySend = vi.fn().mockResolvedValue(true);
|
|
const mockDeps = {
|
|
notifications: { send: notifySend },
|
|
} as unknown as ExecutorDeps;
|
|
|
|
const notified = await finalizeRoutineFailureNotification(
|
|
mockDeps,
|
|
{
|
|
spaceId: "space-1",
|
|
botId: "bot-1",
|
|
threadId: "thread-1",
|
|
userId: "user-1",
|
|
routineId: "routine-1",
|
|
},
|
|
{ id: "bot-1", name: "Monitor Bot" },
|
|
{ id: "routine-1", name: "Health Check", notify: true },
|
|
"never",
|
|
"Network connection refused",
|
|
);
|
|
|
|
expect(notified).toBe(false);
|
|
expect(notifySend).not.toHaveBeenCalled();
|
|
});
|
|
});
|
|
|
|
describe("handleRoutineSelfHealing", () => {
|
|
it("requeues transient error with backoff when under MAX_ROUTINE_ATTEMPTS", async () => {
|
|
const updateRun = vi.fn().mockResolvedValue({});
|
|
const enqueueJob = vi.fn().mockResolvedValue({});
|
|
const mockDeps = {
|
|
prisma: { run: { update: updateRun } },
|
|
jobs: { enqueue: enqueueJob },
|
|
} as unknown as ExecutorDeps;
|
|
|
|
const recovered = await handleRoutineSelfHealing(
|
|
mockDeps,
|
|
"run-123",
|
|
1,
|
|
new Error("ECONNRESET: socket hang up"),
|
|
);
|
|
|
|
expect(recovered).toBe(true);
|
|
expect(updateRun).toHaveBeenCalledWith({
|
|
where: { id: "run-123" },
|
|
data: expect.objectContaining({
|
|
status: "queued",
|
|
leaseOwner: null,
|
|
leaseExpiresAt: null,
|
|
}),
|
|
});
|
|
expect(enqueueJob).toHaveBeenCalledWith(
|
|
expect.objectContaining({
|
|
name: "run.continue",
|
|
payload: { runId: "run-123" },
|
|
availableAt: expect.any(Date),
|
|
}),
|
|
);
|
|
});
|
|
|
|
it("fails fast on terminal errors without retrying", async () => {
|
|
const updateRun = vi.fn();
|
|
const enqueueJob = vi.fn();
|
|
const mockDeps = {
|
|
prisma: { run: { update: updateRun } },
|
|
jobs: { enqueue: enqueueJob },
|
|
} as unknown as ExecutorDeps;
|
|
|
|
const recovered = await handleRoutineSelfHealing(mockDeps, "run-123", 1, {
|
|
status: 401,
|
|
message: "Unauthorized API key",
|
|
});
|
|
|
|
expect(recovered).toBe(false);
|
|
expect(updateRun).not.toHaveBeenCalled();
|
|
expect(enqueueJob).not.toHaveBeenCalled();
|
|
});
|
|
|
|
it("does not retry when attemptNumber reaches MAX_ROUTINE_ATTEMPTS", async () => {
|
|
const updateRun = vi.fn();
|
|
const enqueueJob = vi.fn();
|
|
const mockDeps = {
|
|
prisma: { run: { update: updateRun } },
|
|
jobs: { enqueue: enqueueJob },
|
|
} as unknown as ExecutorDeps;
|
|
|
|
const recovered = await handleRoutineSelfHealing(
|
|
mockDeps,
|
|
"run-123",
|
|
MAX_ROUTINE_ATTEMPTS,
|
|
new Error("fetch failed"),
|
|
);
|
|
|
|
expect(recovered).toBe(false);
|
|
expect(updateRun).not.toHaveBeenCalled();
|
|
expect(enqueueJob).not.toHaveBeenCalled();
|
|
});
|
|
});
|