Skip to content

A personal assistant that lives on your desktop, remembers what matters, and can use your Mac for you.

TypeScript

fix(voice): tolerate an app that reports no local-model status

Alan Buscagliabd819a8dd41a
diff --git a/packages/ui/src/components/VoiceModel.tsx b/packages/ui/src/components/VoiceModel.tsx
index 57d1e98..cdc1ecb 100644
--- a/packages/ui/src/components/VoiceModel.tsx
+++ b/packages/ui/src/components/VoiceModel.tsx
@@ -38,6 +38,11 @@ export function VoiceModelEntry() {
const refresh = useCallback(() => {
voiceModelStatus().then(
(next) => {
+ // An app without the local model support answers nothing usable.
+ if (!next || typeof next !== "object" || typeof next.engine !== "string") {
+ setStatus(undefined);
+ return;
+ }
setStatus(next);
if (next.downloading) {
const percent = next.total ? Math.floor(((next.received ?? 0) / next.total) * 100) : 0;
diff --git a/packages/ui/test/voice-model.test.tsx b/packages/ui/test/voice-model.test.tsx
index 56b0b5e..03024dc 100644
--- a/packages/ui/test/voice-model.test.tsx
+++ b/packages/ui/test/voice-model.test.tsx
@@ -95,6 +95,14 @@ describe("local voice model (S30.5)", () => {
expect(screen.getByRole("button", { name: "Download local voice model (487 MB)" })).toBeInTheDocument();
});
+ it("shows nothing to act on, and does not fail, when the app reports no status", async () => {
+ h.status = null as unknown as Record<string, unknown>;
+ render(<VoiceModelEntry />);
+ await waitFor(() => expect(h.invoke).toHaveBeenCalledWith("voice_model_status", undefined));
+ expect(screen.queryByRole("button")).toBeNull();
+ expect(screen.getByText("Voice")).toBeInTheDocument();
+ });
+
it("appears in Connectors only when the desktop app offers it", () => {
const props = {
connectors: { open: true, list: [] },