Conversation
📝 WalkthroughWalkthroughRefactors template dropdown handling in enhanced note header: introduces a centralized open/close handler that triggers template refetch on open, updates regeneration flow to use it, simplifies dropdown content labels, and removes commented UI. Separately, adjusts ChatInput model button layout to truncate long model names without shrinking the icon. Changes
Sequence Diagram(s)sequenceDiagram
autonumber
actor User
participant RegenerateBtn as Regenerate Button
participant Dropdown as Template Dropdown (Popover)
participant Handler as handleTemplateDropdownChange
participant Templates as Templates Store/Fetcher
User->>RegenerateBtn: Click
RegenerateBtn->>Handler: open=true
Handler->>Dropdown: Set isOpen=true
alt opening dropdown
Handler->>Templates: refetch()
Templates-->>Dropdown: updated templates (sorted: custom then built-in)
end
Note over Dropdown: User selects template or adds new one
User->>Dropdown: Close (UI interaction)
Dropdown->>Handler: onOpenChange(false)
Handler->>Dropdown: Set isOpen=false
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Pre-merge checks and finishing touches❌ Failed checks (2 warnings, 1 inconclusive)
✨ Finishing touches
🧪 Generate unit tests (beta)
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 |
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (1)
apps/desktop/src/components/editor-area/note-header/sub-headers/enhanced-note-sub-header.tsx (1)
42-62: Template sorting logic is correct but could be refactored.The inline sorting works correctly (custom templates first, then built-in). However, since
TemplateServicealready hasgetTemplatesByCategory()that understands custom vs. builtin distinction, consider moving the sorting logic into the service layer for better separation of concerns.This could be done by adding a
getSortedTemplates()method toTemplateService:static async getSortedTemplates(): Promise<Template[]> { const allTemplates = await this.getAllTemplates(); return allTemplates.sort((a, b) => { const aIsBuiltin = a.tags?.includes("builtin") || false; const bIsBuiltin = b.tags?.includes("builtin") || false; if (aIsBuiltin === bIsBuiltin) return 0; return aIsBuiltin ? 1 : -1; }); }Then simplify the query to:
queryFn: () => TemplateService.getSortedTemplates().then((templates) => templates.map((template) => { const title = template.title || "Untitled"; const truncatedTitle = title.length > 30 ? title.substring(0, 30) + "..." : title; return { id: template.id, title: truncatedTitle, fullTitle: template.title || "", }; }) ),
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
apps/desktop/src/components/editor-area/note-header/sub-headers/enhanced-note-sub-header.tsx(5 hunks)apps/desktop/src/components/right-panel/components/chat/chat-input.tsx(1 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
**/*.{js,ts,tsx,rs}
⚙️ CodeRabbit configuration file
**/*.{js,ts,tsx,rs}: 1. Do not add any error handling. Keep the existing one.
2. No unused imports, variables, or functions.
3. For comments, keep it minimal. It should be about "Why", not "What".
Files:
apps/desktop/src/components/editor-area/note-header/sub-headers/enhanced-note-sub-header.tsxapps/desktop/src/components/right-panel/components/chat/chat-input.tsx
🧬 Code graph analysis (1)
apps/desktop/src/components/editor-area/note-header/sub-headers/enhanced-note-sub-header.tsx (1)
apps/desktop/src/utils/template-service.ts (1)
TemplateService(5-66)
⏰ 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-14)
🔇 Additional comments (4)
apps/desktop/src/components/right-panel/components/chat/chat-input.tsx (1)
508-513: LGTM! Model button truncation implemented correctly.The layout changes properly handle long model names by:
- Using
min-w-0to allow the button to shrink- Keeping the icon fixed with
flex-shrink-0- Truncating the text with a max width constraint
This matches the pattern used for the entity badge at line 418.
apps/desktop/src/components/editor-area/note-header/sub-headers/enhanced-note-sub-header.tsx (3)
74-79: LGTM! Centralized dropdown handler improves consistency.The new
handleTemplateDropdownChangehandler centralizes dropdown state management and intelligently refetches templates only when opening. This ensures fresh template data and simplifies the state management flow throughout the component.
103-103: LGTM! Handler usage is consistent and correct.All callsites properly use
handleTemplateDropdownChange:
- Lines 103, 107: Close dropdown before actions
- Line 169: Wire to Popover's
onOpenChange- Line 174: Correctly branches based on
isEnhancingstate (cancel vs. open dropdown)Also applies to: 107-107, 169-169, 174-174
269-269: LGTM! Label simplification aligns with unified template display.The change from "Custom templates" to "Templates" reflects the unified dropdown that now shows both custom and built-in templates in a single sorted list.
No description provided.