Skip to content

Conversation

@duckduckhero
Copy link
Contributor

@duckduckhero duckduckhero commented Aug 22, 2025

Summary by cubic

Enables Hypr MCP tool execution in chat for licensed users and adds a quick Edit button in the transcript bar to focus the editor. Also exposes jsonSchema to support MCP tool schemas.

  • New Features

    • Auto-connects to Hypr MCP at pro.hyprnote.com when the API base matches and the license is valid; sends x-hyprnote-license-key and registers the tools for use in generateText.
    • Converts MCP tools to Vercel-style dynamic tools via a new MCP HTTP wrapper and lists them in the tool UI; cleans up the client after runs.
    • Adds an Edit button in the transcript header that focuses the editor.
  • Dependencies

    • Added @modelcontextprotocol/sdk ^1.17.3.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Aug 22, 2025

Note

Other AI code review bot(s) detected

CodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review.

📝 Walkthrough

Walkthrough

Adds conditional HyprMCP client initialization and tool ingestion for pro.hyprnote.com, a utility to wrap MCP tools as Vercel dynamic tools, a Pencil action to focus the transcript editor, re-exports jsonSchema from utils, and adds @modelcontextprotocol/sdk to desktop dependencies.

Changes

Cohort / File(s) Summary
Desktop: Chat MCP integration
apps/desktop/src/components/right-panel/hooks/useChatLogic.ts, apps/desktop/src/components/right-panel/utils/mcp-http-wrapper.ts
Conditionally initialize a HyprMCP Client (StreamableHTTPClientTransport) when API base is pro.hyprnote.com and license is valid; fetch license key, build Vercel dynamic tools from MCP tools, merge HyprMCP tools into streamText tool list, add init error handling and client cleanup on finish; adds buildVercelToolsFromMcp utility.
Desktop: Transcript UI action
apps/desktop/src/components/right-panel/views/transcript-view.tsx
Add PencilIcon button and handleFocusEditor callback to focus the transcript editor via editorRef; update imports.
Utils: AI exports
packages/utils/src/ai.ts
Re-export jsonSchema from the ai module (adds to public exports).
Desktop: Package manifest
apps/desktop/package.json
Add dependency @modelcontextprotocol/sdk@^1.17.3.
Desktop: Chat empty state
apps/desktop/src/components/right-panel/components/chat/empty-chat-state.tsx
Change settings navigation target from ?tab=ai to ?tab=ai-llm.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  participant UI as Chat UI
  participant Hook as useChatLogic
  participant Lic as License API
  participant MCP as HyprMCP Server
  participant Stream as streamText

  UI->>Hook: start chat (shouldUseTools?)
  alt apiBase includes pro.hyprnote.com AND license valid
    Hook->>Lic: getLicenseKey()
    Lic-->>Hook: licenseKey
    Hook->>MCP: connect via StreamableHTTPClientTransport (Authorization: licenseKey)
    Note over Hook,MCP: listTools() and buildVercelToolsFromMcp()
    MCP-->>Hook: tools[]
    Hook->>Hook: create hyprMcpTools
  else
    Note over Hook: Skip HyprMCP init
  end

  Hook->>Stream: streamText({ tools: newMcpTools + hyprMcpTools })
  Stream-->>Hook: stream events
  Hook-->>UI: update chat stream

  UI-->>Hook: finish
  Hook->>MCP: close() (if initialized)
  Note over Hook,MCP: Cleanup HyprMCP client
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

Possibly related PRs

Tip

🔌 Remote MCP (Model Context Protocol) integration is now available!

Pro plan users can now connect to remote MCP servers from the Integrations page. Connect with popular remote MCPs such as Notion and Linear to add more context to your reviews and chats.

✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch minor-fixes-0821

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
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

‼️ IMPORTANT
Auto-reply has been disabled for this repository in the CodeRabbit settings. The CodeRabbit bot will not respond to your replies unless it is explicitly tagged.

  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR/Issue comments)

Type @coderabbitai help to get the list of available commands.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

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

1 issue found across 6 files

React with 👍 or 👎 to teach cubic. You can also tag @cubic-dev-ai to give feedback, ask questions, or re-run the review.

Copy link
Contributor

@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 (12)
apps/desktop/package.json (1)

43-45: Dependency addition LGTM; align deep-import usage across code

Adding @modelcontextprotocol/sdk@^1.17.3 is appropriate for the new client/HTTP transport usage.

You’re mixing deep imports with and without “.js” extensions in different files. Standardize on one form (prefer extensionless entrypoints) to avoid duplicate module instances in bundlers. See inline suggestions in the TS files’ comments.

apps/desktop/src/components/right-panel/views/transcript-view.tsx (1)

184-193: Add accessible label and unify icon size with neighbors

The icon-only button should expose an accessible name; also consider matching the 14px size used by other header icons for visual consistency.

Apply:

-                <Button
+                <Button
                   className="w-8 h-8"
                   variant="ghost"
                   size="icon"
                   onClick={handleFocusEditor}
+                  aria-label="Focus editor"
+                  title="Focus editor"
                 >
-                  <PencilIcon size={12} className="text-neutral-600" />
+                  <PencilIcon size={14} className="text-neutral-600" />
                 </Button>
apps/desktop/src/components/right-panel/utils/mcp-http-wrapper.ts (4)

2-2: Use a type-only import for Client to avoid an unnecessary runtime dependency

Client is only used for typing here; importing it as a value can pull runtime code into the bundle unnecessarily (and may trigger linter rules about unused value imports).

-import { Client } from "@modelcontextprotocol/sdk/client";
+import type { Client } from "@modelcontextprotocol/sdk/client";

5-6: Add an explicit return type for clarity and IDE help

Being explicit here makes call sites clearer and improves autocomplete.

-export async function buildVercelToolsFromMcp(client: Client) {
+export async function buildVercelToolsFromMcp(
+  client: Client
+): Promise<Record<string, ReturnType<typeof dynamicTool>>> {

11-13: Avoid any cast on JSON Schema

Prefer unknown (or the concrete JSON Schema type if available) to reduce type unsafety while keeping flexibility.

-    const schema = mcpTool.inputSchema
-      ? jsonSchema(mcpTool.inputSchema as any)
+    const schema = mcpTool.inputSchema
+      ? jsonSchema(mcpTool.inputSchema as unknown)
       : z.any();

19-26: Consider normalizing tool return shape

Returning raw result.content (often an array of MCP content parts) is fine, but downstream tooling sometimes expects a JSON object. If you see odd rendering/serialization, wrap in an object (e.g., { content: result.content }). No change required now; just a heads-up.

apps/desktop/src/components/right-panel/hooks/useChatLogic.ts (6)

1-2: Standardize MCP SDK deep imports (avoid “.js” extensions)

You’re importing with extensions here, while other files use extensionless paths. Mixing styles can produce duplicate module instances in certain bundlers. Prefer extensionless entrypoints consistently.

-import { Client } from "@modelcontextprotocol/sdk/client/index.js";
-import { StreamableHTTPClientTransport } from "@modelcontextprotocol/sdk/client/streamableHttp.js";
+import { Client } from "@modelcontextprotocol/sdk/client";
+import { StreamableHTTPClientTransport } from "@modelcontextprotocol/sdk/client/streamableHttp";

179-183: Tighten hyprMcpTools typing for safety and editor hints

This narrows any to the actual dynamic tool type used elsewhere.

-      let hyprMcpTools: Record<string, any> = {};
+      let hyprMcpTools: Record<string, ReturnType<typeof dynamicTool>> = {};

194-221: HyprMCP client init looks solid; minor nits on identifiers

The transport, header injection, and connection flow look correct. Optional: pick a more specific client name (e.g., "hyprmcp-desktop") to make server-side diagnostics clearer.


358-360: Remove “what” comment; the code is self-explanatory

Per guidelines, prefer comments explaining “why.” This one narrates “what.”

-          // close hyprmcp client
           hyprMcpClient?.close();

184-189: Tooling activation predicate: extract to a helper for reuse and tests

The model-id checks and apiBase gating are getting long. Consider a tiny helper like supportsTools(modelId: string, apiBase?: string), making it easier to test and reuse.


264-271: Detect and warn on duplicate tool keys before merging

The spread merge at line 346 silently overrides any keys present in both newMcpTools and hyprMcpTools, which can hide unintended collisions.

• File: apps/desktop/src/components/right-panel/hooks/useChatLogic.ts
Location: around the tools: { ...newMcpTools, search_sessions_multi_keywords: searchTool, ...hyprMcpTools } statement (line 346).
• Risk: If a tool key exists in both sources, the HyprMCP version will overwrite the MCP server version without any notice.
• Recommendation: Before merging, compute the intersection of the two key sets and emit a warning (or throw) when duplicates are found. For example:

const hyprKeys = Object.keys(hyprMcpTools);
const mcpKeys = Object.keys(newMcpTools);
const dupKeys = mcpKeys.filter(key => hyprKeys.includes(key));

if (dupKeys.length > 0) {
  console.warn(
    `Duplicate tool keys detected (newMcpTools will be overwritten by hyprMcpTools): ${dupKeys.join(
      ', ',
    )}`,
  );
}

const mergedTools = {
  ...newMcpTools,
  search_sessions_multi_keywords: searchTool,
  ...hyprMcpTools,
};

This makes any name collision explicit and aids future debugging.

📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 8d948fd and 581bdbe.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (5)
  • apps/desktop/package.json (1 hunks)
  • apps/desktop/src/components/right-panel/hooks/useChatLogic.ts (8 hunks)
  • apps/desktop/src/components/right-panel/utils/mcp-http-wrapper.ts (1 hunks)
  • apps/desktop/src/components/right-panel/views/transcript-view.tsx (3 hunks)
  • packages/utils/src/ai.ts (1 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
**/*.{js,ts,tsx,rs}

⚙️ CodeRabbit configuration file

**/*.{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".

Files:

  • packages/utils/src/ai.ts
  • apps/desktop/src/components/right-panel/views/transcript-view.tsx
  • apps/desktop/src/components/right-panel/utils/mcp-http-wrapper.ts
  • apps/desktop/src/components/right-panel/hooks/useChatLogic.ts
🔇 Additional comments (2)
packages/utils/src/ai.ts (1)

8-19: jsonSchema re-export verified

  • Workspace packages (@hypr/admin and @hypr/utils) depend on ai@^5.0.21, which includes a root-level re-export of jsonSchema from @ai-sdk/provider-utils in its dist/index.js
  • No direct imports of jsonSchema from "ai" were detected anywhere in the codebase

The change to re-export jsonSchema from "ai" in packages/utils/src/ai.ts is fully supported by the versions in use and introduces no runtime impact. Resolving.

apps/desktop/src/components/right-panel/views/transcript-view.tsx (1)

134-139: Editor focus handler is simple and correct

The null checks against editorRef.current?.editor are sufficient, and gating via showActions prevents focusing during live sessions.

Copy link
Contributor

@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 (1)
apps/desktop/src/components/right-panel/components/chat/empty-chat-state.tsx (1)

35-35: Confirm new settings tab slug and consider centralizing it to avoid drift

Route changed to “/app/settings?tab=ai-llm”. Please verify that the router recognizes ai-llm and that any other deep-links (or default tab logic) have been updated from ai to ai-llm to keep navigation consistent. As a minor hardening against future renames, consider extracting this path into a shared constant.

Apply this minimal diff to reference a constant:

-      windowsCommands.windowNavigate({ type: "settings" }, "/app/settings?tab=ai-llm");
+      windowsCommands.windowNavigate({ type: "settings" }, SETTINGS_AI_LLM_TAB);

And add the constant near the imports (or in a shared routes/constants module if you have one):

const SETTINGS_AI_LLM_TAB = "/app/settings?tab=ai-llm";
📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 581bdbe and 1a8902c.

📒 Files selected for processing (1)
  • apps/desktop/src/components/right-panel/components/chat/empty-chat-state.tsx (1 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
**/*.{js,ts,tsx,rs}

⚙️ CodeRabbit configuration file

**/*.{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".

Files:

  • apps/desktop/src/components/right-panel/components/chat/empty-chat-state.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 (macos, macos-latest)
  • GitHub Check: ci (windows, windows-latest)

@duckduckhero duckduckhero merged commit 624c9b8 into main Aug 23, 2025
9 checks passed
This was referenced Aug 25, 2025
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