Conversation
|
Caution Review failedThe pull request is closed. 📝 WalkthroughWalkthroughAdds a new chat system in apps/desktop2 (UI components, session, transport, route), integrates a Chat window in the Tauri/Hypr Windows plugin, introduces a useAutoCloser hook, updates dependencies, removes legacy floating chat/org components, and tweaks navigation/devtools wiring and sidebar/profile logic. Changes
Sequence Diagram(s)sequenceDiagram
autonumber
actor User
participant Trigger as ChatFloatingButton
participant Container as InteractiveContainer
participant View as ChatView
participant Session as ChatSession
participant Transport as CustomChatTransport
participant Model as Local Model (lmstudio)
User->>Trigger: click open
Trigger->>Container: open panel
Container->>View: render UI
View->>Session: sendMessage(content)
Session->>Transport: sendMessages(messages, options)
Transport-->>Model: streamText(...)
Model-->>Transport: stream chunks
Transport-->>Session: UI message chunks
Session-->>View: update messages
View-->>User: render messages
alt sustained drag to edge
Container->>Trigger: onPopOut()
Trigger->>Windows: request chat window show
Trigger->>Windows: emit navigate event (delayed)
end
sequenceDiagram
autonumber
participant Hypr as Hypr Windows Plugin
participant Webview as Tauri Webview
participant Router as TanStack Router
Hypr-->>Webview: emit(navigate {path,search})
Webview->>Router: useNavigationEvents -> navigate(path, search)
Estimated code review effort🎯 4 (Complex) | ⏱️ ~60 minutes Possibly related PRs
Pre-merge checks and finishing touches❌ Failed checks (2 warnings)
✅ Passed checks (1 passed)
📜 Recent review detailsConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro ⛔ Files ignored due to path filters (7)
📒 Files selected for processing (39)
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: 5
🧹 Nitpick comments (3)
apps/desktop2/src/hooks/useAutoCloser.ts (1)
1-37: Hook implementation looks solid.The
useAutoCloserhook is well-structured with proper cleanup and dependency management. Both ESC key and outside-click dismissal work correctly.Optional micro-optimization: The inline options object
{ enabled: esc }on Line 17 is recreated on every render. You could memoize it withuseMemoif you want to avoid potential re-registrations:+const hotkeyOptions = useMemo(() => ({ enabled: esc }), [esc]); -useHotkeys("esc", handleClose, { enabled: esc }, [handleClose]); +useHotkeys("esc", handleClose, hotkeyOptions, [handleClose]);However, this is a very minor optimization and the current implementation works correctly.
apps/desktop2/src/transport.ts (2)
5-8: Consider making provider configuration dynamic.The base URL and provider name are currently hardcoded. For better flexibility across environments or different local model setups, consider making these configurable through environment variables or user settings.
Example approach:
const provider = createOpenAICompatible({ name: process.env.AI_PROVIDER_NAME || "lmstudio", baseURL: process.env.AI_BASE_URL || "http://localhost:1234/v1", });
21-21: Consider making model name configurable.The model name
"local-model"is hardcoded. Consider making it configurable to support different model setups or allow users to switch models.
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (7)
apps/desktop2/src/routeTree.gen.tsis excluded by!**/*.gen.tsplugins/windows/js/bindings.v1.gen.tsis excluded by!**/*.gen.tsplugins/windows/permissions/autogenerated/commands/window_is_exists.tomlis excluded by!plugins/**/permissions/**plugins/windows/permissions/autogenerated/reference.mdis excluded by!plugins/**/permissions/**plugins/windows/permissions/default.tomlis excluded by!plugins/**/permissions/**plugins/windows/permissions/schemas/schema.jsonis excluded by!plugins/**/permissions/**pnpm-lock.yamlis excluded by!**/pnpm-lock.yaml
📒 Files selected for processing (38)
.gitignore(0 hunks)apps/desktop/package.json(3 hunks)apps/desktop/src/routes/__root.tsx(0 hunks)apps/desktop2/.cursor/rules/style.mdc(1 hunks)apps/desktop2/package.json(4 hunks)apps/desktop2/src/components/chat/body.tsx(1 hunks)apps/desktop2/src/components/chat/header.tsx(1 hunks)apps/desktop2/src/components/chat/index.tsx(1 hunks)apps/desktop2/src/components/chat/input.tsx(1 hunks)apps/desktop2/src/components/chat/interactive.tsx(1 hunks)apps/desktop2/src/components/chat/session.tsx(1 hunks)apps/desktop2/src/components/chat/trigger.tsx(1 hunks)apps/desktop2/src/components/chat/view.tsx(1 hunks)apps/desktop2/src/components/floating-chat-button.tsx(0 hunks)apps/desktop2/src/components/main/sidebar/index.tsx(1 hunks)apps/desktop2/src/components/main/sidebar/profile/index.tsx(1 hunks)apps/desktop2/src/components/org.tsx(0 hunks)apps/desktop2/src/hooks/useAutoCloser.ts(1 hunks)apps/desktop2/src/routes/__root.tsx(2 hunks)apps/desktop2/src/routes/app.tsx(0 hunks)apps/desktop2/src/routes/app/chat.tsx(1 hunks)apps/desktop2/src/routes/app/main/_layout.index.tsx(2 hunks)apps/desktop2/src/store/tinybase/persisted.ts(1 hunks)apps/desktop2/src/styles/globals.css(1 hunks)apps/desktop2/src/transport.ts(1 hunks)apps/pro/package.json(1 hunks)apps/web/package.json(2 hunks)package.json(1 hunks)packages/db/package.json(1 hunks)packages/nango/.cursor/rules/nango.mdc(1 hunks)packages/tiptap/package.json(2 hunks)packages/ui/package.json(1 hunks)packages/utils/package.json(2 hunks)plugins/windows/build.rs(1 hunks)plugins/windows/src/commands.rs(1 hunks)plugins/windows/src/ext.rs(2 hunks)plugins/windows/src/lib.rs(1 hunks)plugins/windows/src/window/v1.rs(5 hunks)
💤 Files with no reviewable changes (5)
- apps/desktop2/src/routes/app.tsx
- .gitignore
- apps/desktop/src/routes/__root.tsx
- apps/desktop2/src/components/org.tsx
- apps/desktop2/src/components/floating-chat-button.tsx
🧰 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/desktop2/src/hooks/useAutoCloser.tsplugins/windows/src/lib.rsapps/desktop2/src/components/chat/session.tsxapps/desktop2/src/components/chat/body.tsxapps/desktop2/src/components/chat/interactive.tsxapps/desktop2/src/transport.tsapps/desktop2/src/components/chat/input.tsxapps/desktop2/src/routes/app/main/_layout.index.tsxplugins/windows/build.rsapps/desktop2/src/components/chat/index.tsxapps/desktop2/src/store/tinybase/persisted.tsapps/desktop2/src/components/chat/trigger.tsxapps/desktop2/src/routes/app/chat.tsxapps/desktop2/src/components/chat/header.tsxapps/desktop2/src/routes/__root.tsxplugins/windows/src/ext.rsplugins/windows/src/window/v1.rsapps/desktop2/src/components/main/sidebar/index.tsxapps/desktop2/src/components/chat/view.tsxplugins/windows/src/commands.rsapps/desktop2/src/components/main/sidebar/profile/index.tsx
🧬 Code graph analysis (17)
plugins/windows/src/lib.rs (3)
plugins/windows/js/bindings.v1.gen.ts (1)
commands(9-31)plugins/windows/src/commands.rs (1)
window_is_exists(49-55)plugins/windows/src/ext.rs (2)
window_is_exists(129-129)window_is_exists(239-241)
apps/desktop2/src/components/chat/session.tsx (2)
apps/desktop2/src/transport.ts (1)
CustomChatTransport(10-40)apps/desktop2/src/store/tinybase/persisted.ts (1)
ChatMessageStorage(128-128)
apps/desktop2/src/components/chat/body.tsx (1)
packages/utils/src/ai.ts (1)
UIMessage(25-25)
apps/desktop2/src/components/chat/interactive.tsx (1)
packages/ui/src/lib/utils.ts (1)
cn(4-6)
apps/desktop2/src/transport.ts (1)
packages/utils/src/ai.ts (6)
ChatTransport(12-12)UIMessage(25-25)ChatRequestOptions(11-11)UIMessageChunk(26-26)streamText(23-23)convertToModelMessages(13-13)
apps/desktop2/src/components/chat/input.tsx (2)
packages/tiptap/src/transcript/extensions/speaker.ts (1)
handleKeyDown(22-148)packages/ui/src/lib/utils.ts (1)
cn(4-6)
apps/desktop2/src/routes/app/main/_layout.index.tsx (1)
apps/desktop2/src/components/chat/index.tsx (1)
ChatFloatingButton(11-56)
apps/desktop2/src/components/chat/index.tsx (4)
apps/desktop2/src/hooks/useAutoCloser.ts (1)
useAutoCloser(4-37)apps/desktop2/src/components/chat/trigger.tsx (1)
ChatTrigger(3-28)apps/desktop2/src/components/chat/interactive.tsx (1)
InteractiveContainer(11-177)apps/desktop2/src/components/chat/view.tsx (1)
ChatView(14-135)
apps/desktop2/src/components/chat/trigger.tsx (1)
packages/ui/src/lib/utils.ts (1)
cn(4-6)
apps/desktop2/src/routes/app/chat.tsx (1)
apps/desktop2/src/components/chat/view.tsx (1)
ChatView(14-135)
apps/desktop2/src/components/chat/header.tsx (2)
plugins/windows/src/window/v1.rs (1)
title(75-82)packages/ui/src/components/ui/dropdown-menu.tsx (3)
DropdownMenu(180-180)DropdownMenuTrigger(194-194)DropdownMenuContent(182-182)
apps/desktop2/src/routes/__root.tsx (2)
apps/desktop2/src/auth.tsx (1)
AuthProvider(63-122)plugins/windows/src/ext.rs (1)
navigate(19-41)
plugins/windows/src/ext.rs (4)
plugins/windows/src/commands.rs (1)
window_is_exists(49-55)plugins/windows/src/events.rs (2)
window(14-14)window(34-34)plugins/windows/js/bindings.v1.gen.ts (1)
AppWindow(52-52)plugins/windows/js/bindings.gen.ts (1)
AppWindow(49-49)
plugins/windows/src/window/v1.rs (1)
plugins/windows/src/events.rs (3)
window(14-14)window(34-34)app(32-32)
apps/desktop2/src/components/chat/view.tsx (7)
plugins/db/js/bindings.gen.ts (1)
createChatGroup(124-126)apps/desktop2/src/store/tinybase/persisted.ts (1)
ChatMessageStorage(128-128)packages/utils/src/ai.ts (1)
UIMessage(25-25)apps/desktop2/src/components/chat/header.tsx (1)
ChatHeader(11-70)apps/desktop2/src/components/chat/session.tsx (1)
ChatSession(20-134)apps/desktop2/src/components/chat/body.tsx (1)
ChatBody(6-26)apps/desktop2/src/components/chat/input.tsx (1)
ChatMessageInput(7-89)
plugins/windows/src/commands.rs (1)
plugins/windows/src/ext.rs (2)
window_is_exists(129-129)window_is_exists(239-241)
apps/desktop2/src/components/main/sidebar/profile/index.tsx (2)
apps/desktop2/src/store/zustand/tabs.ts (1)
useTabs(31-121)apps/desktop2/src/hooks/useAutoCloser.ts (1)
useAutoCloser(4-37)
⏰ 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). (4)
- GitHub Check: ci (macos, macos-14)
- GitHub Check: ci (windows, windows-latest)
- GitHub Check: ci (windows, windows-latest)
- GitHub Check: ci (macos, macos-14)
🔇 Additional comments (28)
packages/ui/package.json (1)
44-44: Dependency updates look good.The react-hook-form and @types/node updates are minor version bumps consistent with updates across the monorepo.
Also applies to: 52-52
apps/pro/package.json (1)
13-13: Dependency updates look good.The version bumps for @modelcontextprotocol/sdk, exa-js, and @types/node are consistent with the broader dependency refresh in this PR.
Also applies to: 16-16, 22-22
packages/utils/package.json (1)
15-15: Dependency updates look good.The AI SDK package updates align with the new chat transport implementation introduced in this PR.
Also applies to: 24-24
packages/db/package.json (1)
23-23: Dependency update looks good.The @types/node patch update maintains type definition consistency across the monorepo.
apps/desktop2/src/components/main/sidebar/index.tsx (1)
29-34: Refactor to clsx looks good.The transition from a static className string to clsx-based composition improves maintainability while preserving the same visual output. The explicit padding handling (p-1 pr-0) is clear and correct.
apps/web/package.json (1)
12-48: Dependency updates look good.The version bumps across multiple packages are consistent with the broader dependency refresh in this PR. All updates appear to be minor or patch releases.
plugins/windows/src/ext.rs (1)
129-129: New window existence check looks good.The
window_is_existsmethod follows the existing window management pattern and provides a clean way to check window existence. The implementation correctly returnsOk(true)when the window exists andOk(false)otherwise.Also applies to: 239-241
apps/desktop/package.json (1)
42-43: LGTM!Minor dependency updates are appropriate. All Lingui packages are updated consistently to 5.5.1, maintaining version alignment across the package ecosystem.
Also applies to: 44-45, 91-91, 95-95, 106-108, 115-115
apps/desktop2/src/components/main/sidebar/profile/index.tsx (1)
3-3: LGTM!The refactor to use
useAutoCloseris a good improvement that:
- Eliminates boilerplate for outside-click and Esc key handling
- Centralizes auto-close logic in a reusable hook
- Updates to the versioned plugin import path (
/v1)The hook implementation (verified in context) properly handles both Esc key presses and outside clicks.
Also applies to: 5-6, 21-21
apps/desktop2/package.json (2)
15-16: LGTM!New dependencies appropriately support the chat feature implementation:
@ai-sdk/openai-compatibleand@ai-sdk/react: AI SDK for chat functionalityai: Core AI SDK packagere-resizable: For draggable/resizable chat containerstreamdown: For streaming Markdown rendering in chatAlso applies to: 39-39, 44-44, 48-48
26-26: LGTM!Patch version updates are appropriate and maintain compatibility.
Also applies to: 49-49, 60-60
plugins/windows/build.rs (1)
6-6: LGTM!The addition of
window_is_existscommand is correctly registered in the build configuration. Implementation verified in related files (commands.rs, ext.rs, lib.rs).package.json (1)
7-7: LGTM!Version update aligns with workspace dependencies (apps/desktop2 uses the same version).
apps/desktop2/src/routes/app/main/_layout.index.tsx (1)
5-5: LGTM!The component refactor from
FloatingChatButtontoChatFloatingButtonaligns with the new chat module structure. The new implementation (verified in context) maintains equivalent functionality with enhanced window management (existence checks, pop-out support).Also applies to: 29-29
plugins/windows/src/lib.rs (1)
55-55: LGTM!The
window_is_existscommand is properly registered in the specta builder. Complete implementation chain verified:
- Build configuration (build.rs)
- Command implementation (commands.rs)
- Trait definition and implementation (ext.rs)
- TypeScript bindings (bindings.v1.gen.ts)
apps/desktop2/src/styles/globals.css (1)
7-7: Verify Lightning CSS @source import
The@source "../../node_modules/streamdown/dist/index.js"directive requires confirming:
- Your build tool (Vite/PostCSS) supports Lightning CSS’s
@sourcesyntaxstreamdown/dist/index.jsactually exports CSS for extraction
If it doesn’t, import a dedicated.cssfile or adjust the path.apps/desktop2/src/store/tinybase/persisted.ts (1)
545-545: LGTM!Exposing
user_idin the return value allows downstream components to access it directly alongside the config object.packages/tiptap/package.json (1)
24-52: Verify TipTap upgrade compatibility with new chat components.The TipTap dependencies have been upgraded from 3.6.5 to 3.6.6. Since the new chat UI components (e.g., ChatInput) rely on TipTap, ensure the upgrades work as expected with the newly added features.
plugins/windows/src/commands.rs (1)
47-55: LGTM!The
window_is_existscommand follows the same pattern as other window management commands and correctly delegates to the trait implementation.apps/desktop2/src/components/chat/body.tsx (2)
9-13: LGTM!The auto-scroll implementation correctly updates scroll position when messages change.
40-61: LGTM!Message rendering and content extraction from parts is correctly implemented with proper role-based alignment.
apps/desktop2/src/components/chat/view.tsx (4)
27-28: LGTM!The session key initialization and ref pattern correctly handles both new and existing chat groups.
102-134: LGTM!The component composition and prop passing are well-structured, with proper error handling and conditional rendering.
92-100: Add missing dependency to useCallback.The
handleSelectChatcallback usessetChatGroupId(line 95) but does not include it in the dependency array (line 99).Apply this diff:
- [onChatGroupChange], + [setChatGroupId, onChatGroupChange],Likely an incorrect or invalid review comment.
85-90: Add missing dependency to useCallback.The
handleNewChatcallback usessetChatGroupId(line 87) but does not include it in the dependency array (line 90).Apply this diff:
- }, [onChatGroupChange]); + }, [setChatGroupId, onChatGroupChange]);Likely an incorrect or invalid review comment.
apps/desktop2/src/components/chat/header.tsx (3)
72-90: LGTM!The
ChatActionButtoncomponent is a clean, reusable implementation with appropriate styling and accessibility attributes.
165-212: LGTM!The
ChatGroupItemproperly handles missing data (lines 176-178) and provides a well-structured chat selection UI with relative time formatting.
24-35: Replace magic 1000ms delay with an explicit event or named constantThe 1000 ms
setTimeoutrisks emitting navigation before the chat window is ready or waiting longer than necessary. Since the current windows plugin doesn’t expose a “window ready” event, either:
- Extract
1000into a named constant (e.g.POP_OUT_NAVIGATE_DELAY) and document why that value is required- Extend the plugin to emit a ready/show event and listen for it before calling
windowEmitNavigate
c35c33f to
270298f
Compare
No description provided.