Template after recording + Refactored template selection #1099
Template after recording + Refactored template selection #1099duckduckhero wants to merge 13 commits intomainfrom
Conversation
…ix-progress-template-selector
…ix-progress-template-selector
📝 WalkthroughWalkthroughThis change refactors template selection and enhancement logic in the editor area and recording controls. It removes configuration mutation side effects, introduces explicit template ID passing for enhancement, adds "auto enhance template" selection on recording stop, and updates the ongoing session store to support this new state. Query invalidation for "llm-connection" is removed. Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant RecordingControls
participant OngoingSessionStore
participant EditorArea
User->>RecordingControls: Clicks Stop Recording
RecordingControls->>OngoingSessionStore: setAutoEnhanceTemplate(selectedTemplateId)
RecordingControls->>EditorArea: onStop(selectedTemplateId)
EditorArea->>EditorArea: useAutoEnhance triggers
EditorArea->>OngoingSessionStore: Reads autoEnhanceTemplate
EditorArea->>EditorArea: Calls enhance.mutate({ triggerType: "auto", templateId: autoEnhanceTemplate })
EditorArea->>OngoingSessionStore: setAutoEnhanceTemplate(null)
Possibly related PRs
✨ Finishing Touches
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. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
Documentation and Community
|
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (1)
apps/desktop/src/components/editor-area/note-header/listen-button.tsx (1)
294-304: Consider adding error handling for template queries.While the implementation is solid, the queries lack error handling. If either query fails, the UI might not reflect the error state appropriately.
Consider adding error states:
const configQuery = useQuery({ queryKey: ["config"], queryFn: () => dbCommands.getConfig(), refetchOnWindowFocus: true, }); const templatesQuery = useQuery({ queryKey: ["templates"], queryFn: () => dbCommands.listTemplates(), refetchOnWindowFocus: true, }); + +if (configQuery.isError || templatesQuery.isError) { + console.error("Failed to load config or templates", configQuery.error, templatesQuery.error); +}Also consider disabling the Select when queries are loading:
-<Select value={selectedTemplate} onValueChange={setSelectedTemplate}> +<Select value={selectedTemplate} onValueChange={setSelectedTemplate} disabled={configQuery.isLoading || templatesQuery.isLoading}>Also applies to: 334-350
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (4)
apps/desktop/src/components/editor-area/floating-button.tsx(0 hunks)apps/desktop/src/components/editor-area/index.tsx(6 hunks)apps/desktop/src/components/editor-area/note-header/listen-button.tsx(8 hunks)packages/utils/src/stores/ongoing-session.ts(3 hunks)
💤 Files with no reviewable changes (1)
- apps/desktop/src/components/editor-area/floating-button.tsx
🧰 Additional context used
📓 Path-based instructions (1)
`**/*.{js,ts,tsx,rs}`: 1. No error handling. 2. No unused imports, variables, or functions. 3. For comments, keep it minimal. It should be about "Why", not "What".
**/*.{js,ts,tsx,rs}: 1. No error handling.
2. No unused imports, variables, or functions.
3. For comments, keep it minimal. It should be about "Why", not "What".
⚙️ Source: CodeRabbit Configuration File
List of files the instruction was applied to:
packages/utils/src/stores/ongoing-session.tsapps/desktop/src/components/editor-area/note-header/listen-button.tsxapps/desktop/src/components/editor-area/index.tsx
⏰ 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: ci (windows, windows-latest)
- GitHub Check: ci (macos, macos-latest)
🔇 Additional comments (5)
packages/utils/src/stores/ongoing-session.ts (1)
16-16: LGTM! Clean addition of template state management.The new
autoEnhanceTemplatestate property and its setter follow the existing store patterns consistently. The implementation correctly uses the mutative library for state updates.Also applies to: 23-23, 38-38, 60-66
apps/desktop/src/components/editor-area/note-header/listen-button.tsx (1)
227-227: Well-implemented template selection integration.The controlled popover and template ID passing through
handleStopSessionare clean implementations. The conditional setting ofautoEnhanceTemplatebefore stopping the session ensures proper sequencing.Also applies to: 237-248, 251-251
apps/desktop/src/components/editor-area/index.tsx (3)
249-255: Excellent refactoring of template handling.The explicit template ID passing eliminates the need for config mutations and side effects. The fallback logic correctly distinguishes between
undefined(use config) andnull(no template), which is a clean design pattern.Also applies to: 286-291, 296-299
116-119: Clean simplification of enhancement handlers.The handlers are now more straightforward with explicit parameter passing. The "auto" to
nullconversion maintains backward compatibility while being explicit about the intent.Also applies to: 122-122
503-503: Well-implemented auto-enhancement with template selection.The hook correctly integrates with the ongoing session store to retrieve and use the selected template. The one-time usage pattern (use then clear) prevents unintended template reuse and maintains clean state management.
Also applies to: 506-507, 518-527, 534-537
No description provided.