Skip to content

Commit 97c3485

Browse files
feat(banner): add error variant and local STT connection status
1 parent 6a69e20 commit 97c3485

File tree

4 files changed

+31
-3
lines changed

4 files changed

+31
-3
lines changed

apps/desktop/src/components/main/sidebar/banner/component.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,10 @@ export function Banner({
1717
className={cn([
1818
"relative group overflow-hidden rounded-lg",
1919
"flex flex-col gap-2",
20-
"bg-white border border-neutral-200 shadow-sm p-4",
20+
"bg-white p-4",
21+
banner.variant === "error"
22+
? "border border-red-300 shadow-sm shadow-red-100"
23+
: "border border-neutral-200 shadow-sm",
2124
])}
2225
>
2326
{banner.dismissible && onDismiss && (

apps/desktop/src/components/main/sidebar/banner/index.tsx

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
1+
import type { ServerStatus } from "@hypr/plugin-local-stt";
12
import { AnimatePresence, motion } from "motion/react";
23
import { useCallback, useEffect, useMemo, useState } from "react";
34

45
import { cn } from "@hypr/utils";
56

67
import { useAuth } from "../../../../auth";
78
import { useConfigValues } from "../../../../config/use-config";
9+
import { useSTTConnection } from "../../../../hooks/useSTTConnection";
810
import { useTabs } from "../../../../store/zustand/tabs";
911
import { Banner } from "./component";
1012
import { createBannerRegistry, getBannerToShow } from "./registry";
@@ -32,7 +34,18 @@ export function BannerArea({
3234
"current_stt_model",
3335
] as const);
3436
const hasLLMConfigured = !!(current_llm_provider && current_llm_model);
35-
const hasSttConfigured = !!(current_stt_provider && current_stt_model);
37+
38+
const { conn: sttConnection, local: sttLocal } = useSTTConnection();
39+
const sttServerStatus = sttLocal.data?.status as ServerStatus | undefined;
40+
41+
const isLocalSttModel =
42+
current_stt_provider === "hyprnote" &&
43+
!!current_stt_model &&
44+
current_stt_model !== "cloud";
45+
46+
const hasSttConfigured = isLocalSttModel
47+
? !!sttConnection
48+
: !!(current_stt_provider && current_stt_model && sttConnection);
3649

3750
const currentTab = useTabs((state) => state.currentTab);
3851
const isAiTranscriptionTabActive =
@@ -72,6 +85,8 @@ export function BannerArea({
7285
isAuthenticated,
7386
hasLLMConfigured,
7487
hasSttConfigured,
88+
sttServerStatus,
89+
isLocalSttModel,
7590
isAiTranscriptionTabActive,
7691
isAiIntelligenceTabActive,
7792
onSignIn: handleSignIn,
@@ -82,6 +97,8 @@ export function BannerArea({
8297
isAuthenticated,
8398
hasLLMConfigured,
8499
hasSttConfigured,
100+
sttServerStatus,
101+
isLocalSttModel,
85102
isAiTranscriptionTabActive,
86103
isAiIntelligenceTabActive,
87104
handleSignIn,

apps/desktop/src/components/main/sidebar/banner/registry.tsx

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import type { ServerStatus } from "@hypr/plugin-local-stt";
2+
13
import type { BannerCondition, BannerType } from "./types";
24

35
type BannerRegistryEntry = {
@@ -9,6 +11,8 @@ type BannerRegistryParams = {
911
isAuthenticated: boolean;
1012
hasLLMConfigured: boolean;
1113
hasSttConfigured: boolean;
14+
sttServerStatus: ServerStatus | undefined;
15+
isLocalSttModel: boolean;
1216
isAiTranscriptionTabActive: boolean;
1317
isAiIntelligenceTabActive: boolean;
1418
onSignIn: () => void | Promise<void>;
@@ -20,6 +24,8 @@ export function createBannerRegistry({
2024
isAuthenticated,
2125
hasLLMConfigured,
2226
hasSttConfigured,
27+
sttServerStatus,
28+
isLocalSttModel,
2329
isAiTranscriptionTabActive,
2430
isAiIntelligenceTabActive,
2531
onSignIn,
@@ -43,7 +49,8 @@ export function createBannerRegistry({
4349
},
4450
dismissible: false,
4551
},
46-
condition: () => !hasSttConfigured && !isAiTranscriptionTabActive,
52+
condition: () =>
53+
!hasSttConfigured && !isLocalSttModel && !isAiTranscriptionTabActive,
4754
},
4855
{
4956
banner: {

apps/desktop/src/components/main/sidebar/banner/types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ export type BannerType = {
1313
primaryAction?: BannerAction;
1414
secondaryAction?: BannerAction;
1515
dismissible: boolean;
16+
variant?: "default" | "error";
1617
};
1718

1819
export type BannerCondition = () => boolean;

0 commit comments

Comments
 (0)