Skip to content

Commit f140090

Browse files
feat(banner): add error variant and local STT connection status
1 parent 890f25b commit f140090

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
@@ -11,7 +11,10 @@ export function Banner({ banner, onDismiss }: { banner: BannerType; onDismiss?:
1111
className={cn([
1212
"relative group overflow-hidden rounded-lg",
1313
"flex flex-col gap-2",
14-
"bg-white border border-neutral-200 shadow-sm p-4",
14+
"bg-white p-4",
15+
banner.variant === "error"
16+
? "border border-red-300 shadow-sm shadow-red-100"
17+
: "border border-neutral-200 shadow-sm",
1518
])}
1619
>
1720
{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";
@@ -24,7 +26,18 @@ export function BannerArea({ isProfileExpanded }: { isProfileExpanded: boolean }
2426
"current_stt_model",
2527
] as const);
2628
const hasLLMConfigured = !!(current_llm_provider && current_llm_model);
27-
const hasSttConfigured = !!(current_stt_provider && current_stt_model);
29+
30+
const { conn: sttConnection, local: sttLocal } = useSTTConnection();
31+
const sttServerStatus = sttLocal.data?.status as ServerStatus | undefined;
32+
33+
const isLocalSttModel =
34+
current_stt_provider === "hyprnote" &&
35+
!!current_stt_model &&
36+
current_stt_model !== "cloud";
37+
38+
const hasSttConfigured = isLocalSttModel
39+
? !!sttConnection
40+
: !!(current_stt_provider && current_stt_model && sttConnection);
2841

2942
const currentTab = useTabs((state) => state.currentTab);
3043
const isAiTranscriptionTabActive =
@@ -64,6 +77,8 @@ export function BannerArea({ isProfileExpanded }: { isProfileExpanded: boolean }
6477
isAuthenticated,
6578
hasLLMConfigured,
6679
hasSttConfigured,
80+
sttServerStatus,
81+
isLocalSttModel,
6782
isAiTranscriptionTabActive,
6883
isAiIntelligenceTabActive,
6984
onSignIn: handleSignIn,
@@ -74,6 +89,8 @@ export function BannerArea({ isProfileExpanded }: { isProfileExpanded: boolean }
7489
isAuthenticated,
7590
hasLLMConfigured,
7691
hasSttConfigured,
92+
sttServerStatus,
93+
isLocalSttModel,
7794
isAiTranscriptionTabActive,
7895
isAiIntelligenceTabActive,
7996
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)