Skip to content

Conversation

@yujonglee
Copy link
Contributor

No description provided.

The app was hitting React's "Maximum update depth exceeded" when stopping listening due to frequent calls to updateSessionTabState that triggered repeated re-renders. To fix this, replace direct uses of changing props/state in handlers with stable refs and memoized callbacks: useRef is used to hold the current tab/sessionTab in note-input, useAutoEnhance, and useRunBatch, and handleTabChange is wrapped with useCallback. Also remove an unnecessary sessionTab dependency from a hook return to avoid re-triggering updates. These changes prevent excessive state updates and stop creation of many enhanced notes.
ㅍ
@netlify
Copy link

netlify bot commented Nov 19, 2025

Deploy Preview for hyprnote ready!

Name Link
🔨 Latest commit 12634bb
🔍 Latest deploy log https://app.netlify.com/projects/hyprnote/deploys/691d43a38314880008034a5a
😎 Deploy Preview https://deploy-preview-1728--hyprnote.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@coderabbitai
Copy link

coderabbitai bot commented Nov 19, 2025

📝 Walkthrough

Walkthrough

The changes introduce LLM connection status monitoring across the enhanced note input component hierarchy. A new ConfigError component renders connection errors with configuration options. Multiple hooks and components are refactored to use stable refs for tab and session state to prevent closure over stale data.

Changes

Cohort / File(s) Change Summary
LLM Connection Status Management
apps/desktop/src/hooks/useLLMConnection.ts
Exported LLMConnectionStatus type and new useLLMConnectionStatus() hook for accessing LLM connection status.
Enhanced Component Error Handling
apps/desktop/src/components/main/body/sessions/note-input/enhanced/config-error.tsx
New ConfigError component renders user-facing messages and Configure button based on LLMConnectionStatus. Includes navigation logic to open settings and jump to intelligence tab.
Enhanced Component Integration
apps/desktop/src/components/main/body/sessions/note-input/enhanced/index.tsx
Integrated LLM connection status checking; renders ConfigError when idle with connection errors. Updated Enhanced component's forwardRef signature to include editor prop of type TiptapEditor | null.
Header Component Integration
apps/desktop/src/components/main/body/sessions/note-input/header.tsx
Added useLLMConnectionStatus usage to track config/auth errors alongside existing error conditions for determining error state.
Ref-based State Management
apps/desktop/src/components/main/body/sessions/note-input/index.tsx, apps/desktop/src/hooks/useAutoEnhance.ts, apps/desktop/src/hooks/useRunBatch.ts
Introduced stable refs (tabRef/sessionTabRef) synchronized on each render to replace direct state usage in closures, preventing stale data. Updated dependency arrays to reflect ref-based approach.

Sequence Diagram

sequenceDiagram
    participant Enhanced as Enhanced Component
    participant LLM as useLLMConnectionStatus Hook
    participant ConfigErr as ConfigError Component
    participant Nav as Window Navigation

    Enhanced->>LLM: Get LLM connection status
    LLM-->>Enhanced: Return status (pending/error/connected)
    
    alt Task Idle + Config Error
        Enhanced->>ConfigErr: Render with status
        ConfigErr-->>Enhanced: Show error message + button
        Note over ConfigErr: User clicks Configure
        ConfigErr->>Nav: Open settings window
        Nav->>Nav: Jump to intelligence tab
    else Task Generating
        Enhanced->>Enhanced: Render StreamingView
    else Normal State
        Enhanced->>Enhanced: Render EnhancedEditor
    end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

  • Multiple files with mixed patterns (new component, ref synchronization, hook exports)
  • Logic density concentrated in LLM status checking and ConfigError message mapping
  • Enhanced component's forwardRef signature change requires verification of all call sites
  • Homogeneous ref pattern applied across multiple hooks reduces per-file review burden
  • Areas requiring extra attention:
    • Enhanced component's forwardRef generic parameter change and caller compatibility
    • LLM status error conditions in header.tsx and their interaction with existing error logic
    • ConfigError component's navigation and settings flow correctness
    • Ref synchronization consistency across useAutoEnhance.ts, useRunBatch.ts, and note-input/index.tsx

Possibly related PRs

Pre-merge checks and finishing touches

❌ Failed checks (1 warning, 1 inconclusive)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
Description check ❓ Inconclusive No pull request description was provided by the author; the PR lacks documentation explaining the changes, rationale, or context. Add a description explaining why this change is needed, what problem it solves, and how the config error handling improves the user experience.
✅ Passed checks (1 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and specifically describes the main change: adding an LLM config error component rendered in the editor area, which matches the PR's core modification.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch config-error-llm-status

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (4)
apps/desktop/src/hooks/useLLMConnection.ts (1)

243-246: Thin useLLMConnectionStatus wrapper is fine; watch for duplicated work at call sites

This hook cleanly exposes just the status while reusing useLLMConnection. If you later have components that need both status and conn, consider calling useLLMConnection directly there to avoid subscribing twice to the same underlying state.

apps/desktop/src/components/main/body/sessions/note-input/header.tsx (1)

21-24: Config‑error awareness in useEnhanceLogic is good; consider sharing logic and surfacing a message

Wiring llmStatus into useEnhanceLogic so that isError also covers idle config/auth problems is a good fit with the new editor‑area ConfigError. Two small follow‑ups to consider:

  • isError can be true via isIdleWithConfigError while error stays null, so the red regenerate icon shows with no tooltip content. You might want to derive a simple message from llmStatus in that branch (e.g., reuse the same mapping as ConfigError) so the tooltip explains what’s wrong.
  • The isConfigError predicate is duplicated here and in Enhanced; extracting a tiny helper like isLLMConfigError(llmStatus) would keep header and editor behavior in lockstep and make it easy to add cases like provider_not_found later if you decide that should present as a config issue too.

Also applies to: 415-478

apps/desktop/src/components/main/body/sessions/note-input/enhanced/config-error.tsx (1)

1-70: ConfigError implementation is clear; consider explicit provider_not_found handling and shared navigation helper

This component cleanly surfaces config/auth problems in the editor with an obvious “Configure” action, which fits the new flow well. Two optional tweaks:

  • getMessageForStatus doesn’t special‑case provider_not_found, so that scenario would get the generic fallback. If you ever treat provider_not_found as a config error, adding a dedicated message here would make debugging mis‑spelled/custom providers easier.
  • The handleConfigureClick sequence mirrors handleGoToTemplates in header.tsx (same windowShow + timeout + windowEmitNavigate pattern with a different tab query). If this pattern spreads further, a small shared helper for “open settings tab X” would reduce duplication and keep timing behavior consistent.
apps/desktop/src/components/main/body/sessions/note-input/enhanced/index.tsx (1)

6-8: Editor‑area ConfigError gating is implemented well; centralize isConfigError logic

Using llmStatus to short‑circuit the Enhanced view with <ConfigError> when the enhance task is idle and the LLM is misconfigured/unauthenticated gives a much clearer UX than silently doing nothing. Since the isConfigError condition here matches the one in useEnhanceLogic, consider extracting a shared helper (or exposing an isConfigError boolean from useLLMConnectionStatus) so behavior stays consistent and it’s easy to expand the set of “config error” reasons (like provider_not_found) in one place.

Also applies to: 17-28

📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between c0bce3b and 12634bb.

📒 Files selected for processing (7)
  • apps/desktop/src/components/main/body/sessions/note-input/enhanced/config-error.tsx (1 hunks)
  • apps/desktop/src/components/main/body/sessions/note-input/enhanced/index.tsx (2 hunks)
  • apps/desktop/src/components/main/body/sessions/note-input/header.tsx (3 hunks)
  • apps/desktop/src/components/main/body/sessions/note-input/index.tsx (2 hunks)
  • apps/desktop/src/hooks/useAutoEnhance.ts (3 hunks)
  • apps/desktop/src/hooks/useLLMConnection.ts (2 hunks)
  • apps/desktop/src/hooks/useRunBatch.ts (3 hunks)
🧰 Additional context used
🧠 Learnings (1)
📓 Common learnings
Learnt from: plyght
Repo: fastrepl/hyprnote PR: 921
File: plugins/location-connectivity/src/error.rs:1-41
Timestamp: 2025-06-06T16:31:46.457Z
Learning: In the location-connectivity plugin (plugins/location-connectivity/), comprehensive error handling via LocationConnectivityError is necessary despite the "no error handling" guideline, as the plugin performs system-level operations (WiFi detection, persistent storage) that require proper error propagation to the frontend.
🧬 Code graph analysis (4)
apps/desktop/src/components/main/body/sessions/note-input/index.tsx (1)
apps/desktop/src/store/zustand/tabs/schema.ts (1)
  • EditorView (18-18)
apps/desktop/src/components/main/body/sessions/note-input/enhanced/config-error.tsx (1)
apps/desktop/src/hooks/useLLMConnection.ts (1)
  • LLMConnectionStatus (29-40)
apps/desktop/src/components/main/body/sessions/note-input/header.tsx (1)
apps/desktop/src/hooks/useLLMConnection.ts (1)
  • useLLMConnectionStatus (243-246)
apps/desktop/src/components/main/body/sessions/note-input/enhanced/index.tsx (3)
apps/desktop/src/hooks/useLLMConnection.ts (1)
  • useLLMConnectionStatus (243-246)
apps/desktop/src/hooks/useAITaskTask.ts (1)
  • useAITaskTask (39-105)
apps/desktop/src/components/main/body/sessions/note-input/enhanced/config-error.tsx (1)
  • ConfigError (8-41)
⏰ 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). (2)
  • GitHub Check: fmt
  • GitHub Check: ci (macos, macos-14)
🔇 Additional comments (6)
apps/desktop/src/hooks/useRunBatch.ts (3)

1-1: LGTM: Import addition is correct.

The useRef import is necessary for the ref-based stability pattern implemented below.


37-38: LGTM: Ref pattern correctly prevents stale closures.

The ref is properly initialized and kept synchronized with sessionTab on every render. This ensures the memoized callback always accesses the latest tab state without requiring sessionTab in the dependency array, maintaining stable callback identity.


68-72: LGTM: Ref usage is correct and safe.

The callback correctly reads the latest sessionTab value via sessionTabRef.current, includes a null check for safety, and the dependency array properly excludes sessionTab since it's accessed through the ref.

apps/desktop/src/hooks/useLLMConnection.ts (1)

29-40: Exporting LLMConnectionStatus union looks correct and future‑proof

The union variants align with all branches in useLLMConnection, so making this type public is safe and enables consistent status handling across consumers.

apps/desktop/src/hooks/useAutoEnhance.ts (1)

36-38: tabRef + deferred model requirement make auto‑enhance more robust

Using tabRef.current inside the memoized createAndStartEnhance is a good way to avoid stale tab closures while keeping handleTabChange‑style callbacks stable. Dropping the immediate model precondition and relying on the useEffect that checks autoEnhancedNoteId && model && !startedTasksRef.current.has(...) means the enhanced note is created as soon as there’s a transcript, and the task starts once an LLM is configured, which matches the new config‑error UX.

To be safe, please manually verify:

  • Recordings that finish while LLM config is missing create exactly one enhanced note per session.
  • Once the user configures the LLM, those pending notes start and complete enhancement without needing another recording.

Also applies to: 58-71

apps/desktop/src/components/main/body/sessions/note-input/index.tsx (1)

1-1: Stabilizing handleTabChange with tabRef is a solid cleanup

Memoizing handleTabChange and reading tabRef.current avoids stale tab issues in keyboard shortcuts while preventing unnecessary re‑bindings; this is a nice consistency improvement with the other tabRef usages in the PR.

Also applies to: 31-39

@yujonglee yujonglee merged commit 12aee08 into main Nov 19, 2025
11 checks passed
@yujonglee yujonglee deleted the config-error-llm-status branch November 19, 2025 04:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants