-
Notifications
You must be signed in to change notification settings - Fork 450
Validate local stt models #2469
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
✅ Deploy Preview for hyprnote ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
|
Warning Rate limit exceeded@ComputelessComputer has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 8 minutes and 21 seconds before requesting another review. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. 📒 Files selected for processing (3)
📝 WalkthroughWalkthroughThis PR adds model validation for locally-downloaded STT models, automatically clearing selections when models become unavailable. It also refines the model display logic to filter by download status and adds user hints for hyprnote models, alongside text description updates for Parakeet v2 and v3 models. Changes
Sequence DiagramsequenceDiagram
participant UI as Select Component
participant Hook as useValidateSttModel Hook
participant Query as TanStack Query
participant Storage as Form/Storage
Note over UI,Storage: Component Initializes
UI->>Hook: Call with provider, model, onClearModel
rect rgb(200, 220, 255)
Note over Hook,Query: Validation Cycle (every 2s)
Hook->>Query: Check isModelDownloaded<br/>[stt-model-downloaded, model]
Query-->>Hook: Downloaded status
end
alt Model is local & not downloaded
Hook->>Storage: onClearModel() callback
Storage->>Storage: Reset form field & storage
Hook-->>UI: isModelValid = false
else Model valid (cloud or downloaded)
Hook-->>UI: isModelValid = true
end
UI->>UI: Update model Select<br/>enable/disable & show hints
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes
Possibly related PRs
Suggested reviewers
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
✅ Deploy Preview for hyprnote-storybook ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
🧹 Nitpick comments (3)
apps/desktop/src/hooks/useValidateSttModel.ts (1)
49-50: Consider more conservative polling interval.The
refetchInterval: 2000will continuously poll every 2 seconds while the query is enabled. For a file system check (model download status), this may be more aggressive than necessary.Consider increasing to 5000ms (5 seconds) or higher, unless there's a specific user experience requirement for near-real-time updates.
🔎 Suggested adjustment
- refetchInterval: 2000, - staleTime: 500, + refetchInterval: 5000, + staleTime: 2000,apps/desktop/src/components/settings/ai/stt/select.tsx (2)
55-65: Memoize getValidatedModel to prevent unnecessary recalculations.The
getValidatedModelfunction is called during form initialization (line 70) but isn't memoized. Since it accessesconfiguredProviderswhich is derived from a query, this function will execute on every render ofSelectProviderAndModel.🔎 Wrap in useCallback
+ const getValidatedModel = useCallback(() => { - const getValidatedModel = () => { if (!current_stt_provider || !current_stt_model) return ""; const providerModels = configuredProviders[current_stt_provider as ProviderId]?.models ?? []; const isModelValid = providerModels.some( (model) => model.id === current_stt_model && model.isDownloaded, ); return isModelValid ? current_stt_model : ""; - }; + }, [current_stt_provider, current_stt_model, configuredProviders]);
331-336: Consolidate duplicate isAppleSilicon check.The
am-whisper-large-v3model is added in a separateisAppleSiliconblock (lines 331-336) immediately after the firstisAppleSiliconblock (lines 318-329). These can be combined for better code organization.🔎 Merge into single isAppleSilicon block
if (isAppleSilicon) { models.push( { id: "am-parakeet-v2", isDownloaded: p2.data ?? false, }, { id: "am-parakeet-v3", isDownloaded: p3.data ?? false, }, + { + id: "am-whisper-large-v3", + isDownloaded: whisperLargeV3.data ?? false, + }, ); } - if (isAppleSilicon) { - models.push({ - id: "am-whisper-large-v3", - isDownloaded: whisperLargeV3.data ?? false, - }); - } - models.push(
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (3)
apps/desktop/src/components/settings/ai/stt/configure.tsxapps/desktop/src/components/settings/ai/stt/select.tsxapps/desktop/src/hooks/useValidateSttModel.ts
🧰 Additional context used
📓 Path-based instructions (5)
**/*
📄 CodeRabbit inference engine (AGENTS.md)
Format using
dprint fmtfrom the root. Do not usecargo fmt.
Files:
apps/desktop/src/components/settings/ai/stt/select.tsxapps/desktop/src/hooks/useValidateSttModel.tsapps/desktop/src/components/settings/ai/stt/configure.tsx
**/*.{ts,tsx}
📄 CodeRabbit inference engine (AGENTS.md)
**/*.{ts,tsx}: Avoid creating a bunch of types/interfaces if they are not shared. Especially for function props. Just inline them.
Never do manual state management for form/mutation. UseuseFormfrom tanstack-form anduseQuery/useMutationfrom tanstack-query for 99% cases.
Files:
apps/desktop/src/components/settings/ai/stt/select.tsxapps/desktop/src/hooks/useValidateSttModel.tsapps/desktop/src/components/settings/ai/stt/configure.tsx
**/*.{ts,tsx,rs,js,jsx}
📄 CodeRabbit inference engine (AGENTS.md)
By default, avoid writing comments at all. If you write one, it should be about 'Why', not 'What'.
Files:
apps/desktop/src/components/settings/ai/stt/select.tsxapps/desktop/src/hooks/useValidateSttModel.tsapps/desktop/src/components/settings/ai/stt/configure.tsx
**/*.{ts,tsx,js,jsx}
📄 CodeRabbit inference engine (AGENTS.md)
**/*.{ts,tsx,js,jsx}: If there are many classNames with conditional logic, usecn(import from@hypr/utils). Always pass an array and split by logical grouping.
Usemotion/reactinstead offramer-motion.
Files:
apps/desktop/src/components/settings/ai/stt/select.tsxapps/desktop/src/hooks/useValidateSttModel.tsapps/desktop/src/components/settings/ai/stt/configure.tsx
**/*.ts
📄 CodeRabbit inference engine (CLAUDE.md)
**/*.ts: Agent implementations should use TypeScript and follow the established architectural patterns defined in the agent framework
Agent communication should use defined message protocols and interfaces
Files:
apps/desktop/src/hooks/useValidateSttModel.ts
🧠 Learnings (2)
📚 Learning: 2025-12-16T07:24:36.000Z
Learnt from: CR
Repo: fastrepl/hyprnote PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-16T07:24:36.000Z
Learning: Applies to **/*.{ts,tsx} : Never do manual state management for form/mutation. Use `useForm` from tanstack-form and `useQuery`/`useMutation` from tanstack-query for 99% cases.
Applied to files:
apps/desktop/src/components/settings/ai/stt/select.tsx
📚 Learning: 2025-11-24T16:32:19.706Z
Learnt from: CR
Repo: fastrepl/hyprnote PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-11-24T16:32:19.706Z
Learning: Applies to **/*.{ts,tsx} : Never do manual state management for form/mutation. Use useForm (from tanstack-form) and useQuery/useMutation (from tanstack-query) for 99% of cases instead of setError and similar patterns.
Applied to files:
apps/desktop/src/components/settings/ai/stt/select.tsx
🧬 Code graph analysis (2)
apps/desktop/src/components/settings/ai/stt/select.tsx (2)
apps/desktop/src/components/settings/ai/stt/shared.tsx (2)
ProviderId(197-197)displayModelId(31-84)apps/desktop/src/hooks/useValidateSttModel.ts (1)
useValidateSttModel(22-61)
apps/desktop/src/hooks/useValidateSttModel.ts (1)
crates/transcribe-proxy/src/routes/mod.rs (1)
provider(38-40)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (9)
- GitHub Check: Redirect rules - hyprnote-storybook
- GitHub Check: Header rules - hyprnote-storybook
- GitHub Check: Pages changed - hyprnote-storybook
- GitHub Check: fmt
- GitHub Check: desktop_ci (linux, depot-ubuntu-24.04-8)
- GitHub Check: desktop_ci (linux, depot-ubuntu-22.04-8)
- GitHub Check: Redirect rules - hyprnote
- GitHub Check: Header rules - hyprnote
- GitHub Check: Pages changed - hyprnote
🔇 Additional comments (7)
apps/desktop/src/components/settings/ai/stt/configure.tsx (1)
121-121: LGTM! Improved model descriptions.The updated descriptions provide clearer guidance to users about when to use each model. "Optimized for English" and "Better for European languages" are more actionable than the previous wording.
Also applies to: 126-126
apps/desktop/src/hooks/useValidateSttModel.ts (1)
53-58: Ensure onClearModel callback is stable.The
useEffectdepends ononClearModel. If the caller doesn't memoize this callback (e.g., withuseCallback), the effect will run on every render, potentially causing unnecessary model clearing or performance issues.Verified in
select.tsxthathandleClearModelis properly wrapped withuseCallback(lines 90-93), so this is correctly handled. Good implementation!apps/desktop/src/components/settings/ai/stt/select.tsx (5)
90-93: LGTM! Properly memoized callback.The
handleClearModelcallback is correctly wrapped withuseCallbackand includes all necessary dependencies, ensuring stable reference foruseValidateSttModel.
95-99: LGTM! Validation hook integration.The
useValidateSttModelhook is correctly integrated, passing the current provider, model, and the stablehandleClearModelcallback. This will automatically clear invalid model selections when models become unavailable.
199-207: LGTM! Improved model filtering logic.The new filtering logic correctly shows all models for
hyprnote(allowing users to see what's available to download) while only showing downloaded models for other providers. Thecloudmodel is always shown regardless of download status, which is appropriate.
227-237: LGTM! Enhanced user feedback for unavailable models.The UI now provides helpful hints ("Start trial" for cloud, "Download model" for local models) when hovering over unavailable hyprnote models. The
groupclass and opacity transition create a polished user experience.
338-347: Verify intended model availability for non-Apple Silicon platforms.The code now unconditionally adds
QuantizedTinyEnandQuantizedSmallEnmodels to the list (lines 338-347), regardless of platform. Previously, based onconfigure.tsx(lines 154-167), these models were shown for non-Apple Silicon platforms.This appears intentional but represents a behavior change: these models are now available on all platforms for the
hyprnoteprovider in the model selector.Please confirm this is the intended behavior - that
QuantizedTinyEnandQuantizedSmallEnshould be available for selection on all platforms (both Apple Silicon and non-Apple Silicon).
cc890c9 to
49de27c
Compare
Overview
Changes