Skip to content

Conversation

@viniciusventura29
Copy link
Contributor

@viniciusventura29 viniciusventura29 commented Dec 8, 2025

What is this contribution about?

Describe your changes and why they're needed.

Screenshots/Demonstration

Update mcp status - Watch Video

Review Checklist

  • PR title is clear and descriptive
  • Changes are tested and working
  • Documentation is updated (if needed)
  • No breaking changes

Summary by CodeRabbit

  • New Features

    • Automatically transition a connection to "active" when required tools are present and authentication completes.
    • Detect OAuth requirements for apps and set connection status to "inactive" when OAuth/configuration is needed.
  • Bug Fixes

    • Connection creation no longer forces status to "active"; status is optional at creation so stored value reflects actual configuration.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Dec 8, 2025

Walkthrough

Removed forced "active" on connection creation, made create-schema status optional, added UI effect to flip inactive connections to active when MCP tools/auth are present, and added OAuth detection to return inactive connections when OAuth/config is required.

Changes

Cohort / File(s) Summary
Storage
apps/mesh/src/storage/connection.ts
Removed explicit status: "active" from serialized payload during connection creation so inserted status is no longer forced.
Schema
apps/mesh/src/tools/connection/schema.ts
Moved status into partial(...), making status optional in ConnectionCreateDataSchema and the inferred ConnectionCreateData type.
UI — connection details
apps/mesh/src/web/components/details/connection.tsx
Added effect that sets draft.status = "active" and persists when a connection exists, its status is "inactive", MCP tools are present, and MCP auth state is valid.
UI — store route / OAuth
apps/mesh/src/web/routes/orgs/store-app-detail.tsx
Added detection for DECO_CHAT_OAUTH_START in publisher meta, computed needsOAuth, and return status as "inactive" when OAuth/config is required; otherwise "active".
SDK minor
packages/sdk/src/mcp/teams/api.ts
Small formatting/optional-chaining tweak in domain validation; no behavior change.

Sequence Diagram(s)

sequenceDiagram
  actor User
  participant Browser as Browser UI
  participant MCP as MCP (tools & auth)
  participant API as Mesh API (routes/storage)
  participant DB as Database

  User->>Browser: Create or edit app/connection
  Browser->>MCP: Read tools list & auth state
  alt MCP has tools and auth state is valid and connection is inactive
    Browser->>API: PATCH connection with draft.status="active"
    API->>DB: update connection row (status = "active")
    DB-->>API: success
    API-->>Browser: success (show toast)
  else OAuth required or oauth_config present
    Browser->>API: create/extract connection (compute status = "inactive")
    API->>DB: insert connection row (status omitted or inactive)
    DB-->>API: success
    API-->>Browser: success
  end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

  • Check DB schema/default for status when omitted (apps/mesh/src/storage/connection.ts).
  • Confirm TypeScript/runtime validation for optional status in schema (apps/mesh/src/tools/connection/schema.ts).
  • Verify UI effect guards and idempotence (apps/mesh/src/web/components/details/connection.tsx).
  • Validate OAuth detection and returned status computation (apps/mesh/src/web/routes/orgs/store-app-detail.tsx).

Possibly related PRs

Suggested reviewers

  • viktormarinho

Poem

🐰
A status once forced now hops free,
Optional and patient as fields should be.
OAuth hides, MCP tools cheer,
Inactive drafts spring active near.
A rabbit nods — code updated, 🥕 hooray!

Pre-merge checks and finishing touches

❌ Failed checks (2 warnings)
Check name Status Explanation Resolution
Description check ⚠️ Warning The description is largely incomplete, lacking substantive details about the changes and their rationale despite following the template structure. Fill in the 'What is this contribution about?' section with clear details explaining the changes made, their purpose, and why they are needed.
Docstring Coverage ⚠️ Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (1 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and specifically describes the main change: updating connection status handling across multiple components and schemas.
✨ 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 fix/status-mcp

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 407bde4 and f253620.

📒 Files selected for processing (1)
  • packages/sdk/src/mcp/teams/api.ts (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • packages/sdk/src/mcp/teams/api.ts
⏰ 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). (1)
  • GitHub Check: Cloudflare Pages

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.

@cloudflare-workers-and-pages
Copy link

cloudflare-workers-and-pages bot commented Dec 8, 2025

Deploying decocms-admin-frontend with  Cloudflare Pages  Cloudflare Pages

Latest commit: e734361
Status: ✅  Deploy successful!
Preview URL: https://38142dba.admin-decocms-frontend.pages.dev
Branch Preview URL: https://fix-status-mcp.admin-decocms-frontend.pages.dev

View logs

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: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
apps/mesh/src/web/components/details/connection.tsx (1)

707-721: Fix formatting of status update block to satisfy biome fmt and keep style consistent

The new CONNECTIONS_COLLECTION.update block is correctly setting status to "active", but its indentation and brace/semicolon style are what biome fmt is flagging (pipeline error at lines 716‑721). Reformat this block (or run bun run fmt) so it matches the rest of the file:

-      const tx = CONNECTIONS_COLLECTION.update(connection.id, (draft) => {
-      draft.status = "active";
-      })
-      await tx.isPersisted.promise;
-      
+      const tx = CONNECTIONS_COLLECTION.update(connection.id, (draft) => {
+        draft.status = "active";
+      });
+      await tx.isPersisted.promise;

This should clear the formatter failure while preserving the intended behavior.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 5f7315e and c7fc176.

📒 Files selected for processing (4)
  • apps/mesh/src/storage/connection.ts (0 hunks)
  • apps/mesh/src/tools/connection/schema.ts (1 hunks)
  • apps/mesh/src/web/components/details/connection.tsx (2 hunks)
  • apps/mesh/src/web/routes/orgs/store-app-detail.tsx (2 hunks)
💤 Files with no reviewable changes (1)
  • apps/mesh/src/storage/connection.ts
🧰 Additional context used
📓 Path-based instructions (7)
**/*.{tsx,jsx}

📄 CodeRabbit inference engine (.cursor/rules/data-flow.mdc)

Handle loading and error states appropriately when using React Query hooks in components

Files:

  • apps/mesh/src/web/components/details/connection.tsx
  • apps/mesh/src/web/routes/orgs/store-app-detail.tsx
**/*.{ts,tsx,js,jsx,css}

📄 CodeRabbit inference engine (.cursor/rules/structure.mdc)

Run formatting with bun run fmt before opening pull requests

Keep Tailwind design tokens consistent per plugins/ensure-tailwind-design-system-tokens.ts which will fail builds otherwise

Files:

  • apps/mesh/src/web/components/details/connection.tsx
  • apps/mesh/src/web/routes/orgs/store-app-detail.tsx
  • apps/mesh/src/tools/connection/schema.ts
**/*.{ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/structure.mdc)

Run type checking with bun run check before opening pull requests

Favor TypeScript types over any keyword

**/*.{ts,tsx}: Write concise, maintainable, and technically accurate TypeScript code with relevant examples
Use functional and declarative programming patterns; avoid classes
Favor iteration and modularization to adhere to DRY principles and avoid code duplication
Use descriptive variable names with auxiliary verbs (e.g., isLoading, hasError)
Organize files systematically: each file should contain only related content, such as exported components, subcomponents, helpers, static content, and types
Favor named exports for functions
Use TypeScript for all code
Prefer interfaces over types for their extendability and ability to merge
Avoid enums; use maps instead for better type safety and flexibility
Use the "function" keyword for pure functions to benefit from hoisting and clarity

Files:

  • apps/mesh/src/web/components/details/connection.tsx
  • apps/mesh/src/web/routes/orgs/store-app-detail.tsx
  • apps/mesh/src/tools/connection/schema.ts
**/*.{ts,tsx,js,jsx}

📄 CodeRabbit inference engine (.cursor/rules/structure.mdc)

Run linting with bun run lint before opening pull requests

**/*.{ts,tsx,js,jsx}: Use PascalCase for component and class names
Use camelCase for hooks and utility function names

Files:

  • apps/mesh/src/web/components/details/connection.tsx
  • apps/mesh/src/web/routes/orgs/store-app-detail.tsx
  • apps/mesh/src/tools/connection/schema.ts
**/*.{js,jsx,ts,tsx}

📄 CodeRabbit inference engine (AGENTS.md)

Keep imports sorted in all code files

Files:

  • apps/mesh/src/web/components/details/connection.tsx
  • apps/mesh/src/web/routes/orgs/store-app-detail.tsx
  • apps/mesh/src/tools/connection/schema.ts
**/*.tsx

📄 CodeRabbit inference engine (.cursor/rules/react-ts.mdc)

**/*.tsx: Use functional components with TypeScript interfaces
Favor using the already-present ui components in packages/ui folder instead of creating custom components
Use useMemo for expensive computations like filtering and sorting operations to optimize performance in data-intensive applications
Memoize objects and arrays using useMemo to maintain stable references across renders
Use useDeferredValue for search operations to prevent blocking user input during filtering
Follow MCP (Model Context Protocol) patterns for consistent data fetching with hooks like useAgents, useIntegrations, and useUpdateAgent
Use react-hook-form with Zod validation instead of manual useState for form management
Avoid prop drilling by using Form Context to share form state across components
Use design system Form components (Form, FormControl, FormField, FormItem, FormLabel, FormMessage) from @deco/ui with proper error handling
Apply Single Responsibility Principle to components: each component should have a focused purpose and be composable
Ensure dependency arrays contain stable references; avoid creating inline objects or arrays that cause unnecessary re-renders
Implement consistent error and loading state handling with proper UI feedback (loading spinners, error messages, empty states)
Apply changes immediately to DOM for instant visual feedback, then debounce state updates for features like theme editors and live previews
Use custom events dispatched via window.dispatchEvent and window.addEventListener for cross-component communication of state updates
Implement single-level undo that reverts to the saved state, not just the previous change; use refs to track original saved values
Use useSetThreadContextEffect to inject rules and toolsets into AI chat threads; use explicit union types for context items
Extract complex logic from JSX into separate components instead of using IIFEs (immediately invoked function expressions)

Files:

  • apps/mesh/src/web/components/details/connection.tsx
  • apps/mesh/src/web/routes/orgs/store-app-detail.tsx
**/*.ts

📄 CodeRabbit inference engine (.cursor/rules/api-development.mdc)

Define both input and output Zod schemas for all API operations with appropriate type constraints (min/max length, optional fields, descriptions) and map them to TypeScript interfaces

Files:

  • apps/mesh/src/tools/connection/schema.ts
🧠 Learnings (3)
📓 Common learnings
Learnt from: CR
Repo: decocms/admin PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-01T21:10:09.298Z
Learning: Include succinct summary, testing notes, and relevant screenshots for UI changes in pull request descriptions
📚 Learning: 2025-12-01T21:08:08.813Z
Learnt from: CR
Repo: decocms/admin PR: 0
File: .cursor/rules/deconfig.mdc:0-0
Timestamp: 2025-12-01T21:08:08.813Z
Learning: Applies to packages/sdk/src/mcp/deconfig/**/*.ts : Implement modular composition where merge() reuses diff() + transactionalWrite(), and transactionalWrite() has internal method for different scenarios to ensure code reuse and consistency

Applied to files:

  • apps/mesh/src/web/components/details/connection.tsx
📚 Learning: 2025-12-01T21:08:08.813Z
Learnt from: CR
Repo: decocms/admin PR: 0
File: .cursor/rules/deconfig.mdc:0-0
Timestamp: 2025-12-01T21:08:08.813Z
Learning: Applies to packages/sdk/src/mcp/deconfig/**/*.ts : Namespace Durable Object must maintain SQLite state with two tables: namespace_state (current tree state and metadata) and patches (historical changes with delta-based storage)

Applied to files:

  • apps/mesh/src/web/components/details/connection.tsx
🧬 Code graph analysis (2)
apps/mesh/src/web/components/details/connection.tsx (1)
apps/mesh/src/web/hooks/collections/use-connection.ts (1)
  • CONNECTIONS_COLLECTION (20-24)
apps/mesh/src/web/routes/orgs/store-app-detail.tsx (1)
packages/ai/src/tools.ts (1)
  • tools (872-881)
🪛 GitHub Actions: Tests
apps/mesh/src/web/components/details/connection.tsx

[error] 716-721: Formatter would have printed different content. Code formatting issues detected by biome fmt:check.

apps/mesh/src/web/routes/orgs/store-app-detail.tsx

[error] 98-105: Formatter would have printed different content. Code formatting issues detected by biome fmt:check.

⏰ 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). (1)
  • GitHub Check: Cloudflare Pages
🔇 Additional comments (2)
apps/mesh/src/tools/connection/schema.ts (1)

103-124: Status now optional on create data looks consistent with new flows

Making status optional in ConnectionCreateDataSchema.partial({ status: true, ... }) aligns with the PR’s intent to compute/set status in specific flows instead of always forcing "active" at creation. Just double‑check all connection creation paths either pass an explicit status when needed or apply a sensible default server‑side when status is omitted.

apps/mesh/src/web/components/details/connection.tsx (1)

214-221: Marking connection active after successful OAuth is appropriate

Updating draft.status = "active" in the OAuth completion path is consistent with treating successful token acquisition as an activation event and matches the new status semantics across the PR.

Comment on lines 99 to 105
// Check if MCP needs OAuth by looking for DECO_CHAT_OAUTH_START tool
const tools = publisherMeta?.tools as Array<{ name: string }> | null | undefined;
const needsOAuth = tools?.some((tool) => tool.name === "DECO_CHAT_OAUTH_START") ?? false;

// Status: inactive if needs OAuth or has config state to fill
const status = needsOAuth || oauthConfig || configState ? "inactive" : "active";

Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

# First, let's look at the file and the specific lines mentioned
head -150 apps/mesh/src/web/routes/orgs/store-app-detail.tsx | tail -60

Repository: decocms/admin

Length of output: 1999


🏁 Script executed:

# Get the full context around lines 99-105 and 135
cat -n apps/mesh/src/web/routes/orgs/store-app-detail.tsx | sed -n '85,145p'

Repository: decocms/admin

Length of output: 2532


🏁 Script executed:

# Check if there's a biome configuration
fd -e json -e toml | grep -E "(biome|\.biomerc)" | head -5

Repository: decocms/admin

Length of output: 67


🏁 Script executed:

# Look for variable declarations of oauthConfig and configState
rg -n "oauthConfig|configState" apps/mesh/src/web/routes/orgs/store-app-detail.tsx | head -20

Repository: decocms/admin

Length of output: 334


🏁 Script executed:

# Read the biome.json to understand formatting rules
cat biome.json | head -100

Repository: decocms/admin

Length of output: 688


🏁 Script executed:

# Check line lengths of the problematic lines
cat -n apps/mesh/src/web/routes/orgs/store-app-detail.tsx | sed -n '99,104p' | awk '{print length($0) " chars: " $0}'

Repository: decocms/admin

Length of output: 554


🏁 Script executed:

# Let's also check the exact function signature to understand the return type
rg -B 10 "Check if MCP needs OAuth" apps/mesh/src/web/routes/orgs/store-app-detail.tsx | head -30

Repository: decocms/admin

Length of output: 349


🏁 Script executed:

# Check if biome would actually format these lines
# First, let's see the entire function to understand its return type
rg -A 50 "Check if MCP needs OAuth" apps/mesh/src/web/routes/orgs/store-app-detail.tsx | head -60

Repository: decocms/admin

Length of output: 1788


🏁 Script executed:

# Let's look at the function signature/return type
cat -n apps/mesh/src/web/routes/orgs/store-app-detail.tsx | sed -n '50,110p'

Repository: decocms/admin

Length of output: 2307


🏁 Script executed:

# Find the function signature
cat -n apps/mesh/src/web/routes/orgs/store-app-detail.tsx | sed -n '1,60p'

Repository: decocms/admin

Length of output: 2758


🏁 Script executed:

# Search for the function definition that contains this code
rg -B 30 "Check if MCP needs OAuth" apps/mesh/src/web/routes/orgs/store-app-detail.tsx | head -50

Repository: decocms/admin

Length of output: 1041


🏁 Script executed:

# Look for the complete function signature with return type
cat -n apps/mesh/src/web/routes/orgs/store-app-detail.tsx | sed -n '31,140p' | grep -A 120 "function extractConnectionData"

Repository: decocms/admin

Length of output: 4141


🏁 Script executed:

# Check if there's a TypeScript return type annotation or if it's inferred
ast-grep --pattern 'function extractConnectionData($_) {
  $$$
}'

Repository: decocms/admin

Length of output: 39


🏁 Script executed:

# Verify the exact return type that TypeScript infers
# Check if there are any type definitions or interfaces used
rg -n "interface|type" apps/mesh/src/web/routes/orgs/store-app-detail.tsx | head -20

Repository: decocms/admin

Length of output: 734


🏁 Script executed:

# Check the broader context to see if this function's return type is defined elsewhere
rg -B 5 "extractConnectionData" apps/mesh/src/web/routes/orgs/store-app-detail.tsx | head -40

Repository: decocms/admin

Length of output: 469


Add explicit type annotation to status to eliminate the unnecessary cast at line 135

The status variable should be explicitly typed as "inactive" | "active". This allows TypeScript to properly infer the type and removes the need for the cast at line 135. Additionally, several variable declarations on lines 99–104 exceed the default line length and should be split across multiple lines per your formatter configuration:

-  // Check if MCP needs OAuth by looking for DECO_CHAT_OAUTH_START tool
-  const tools = publisherMeta?.tools as Array<{ name: string }> | null | undefined;
-  const needsOAuth = tools?.some((tool) => tool.name === "DECO_CHAT_OAUTH_START") ?? false;
-
-  // Status: inactive if needs OAuth or has config state to fill
-  const status = needsOAuth || oauthConfig || configState ? "inactive" : "active";
+  // Check if MCP needs OAuth by looking for DECO_CHAT_OAUTH_START tool
+  const tools =
+    publisherMeta?.tools as Array<{ name: string }> | null | undefined;
+  const needsOAuth =
+    tools?.some((tool) => tool.name === "DECO_CHAT_OAUTH_START") ?? false;
+
+  // Status: inactive if needs OAuth or has config state to fill
+  const status: "inactive" | "active" =
+    needsOAuth || oauthConfig || configState ? "inactive" : "active";

Then at line 135, remove the type cast:

-    status: status as "inactive" | "active",
+    status,

Run bun run fmt to ensure consistent formatting across the file.

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
// Check if MCP needs OAuth by looking for DECO_CHAT_OAUTH_START tool
const tools = publisherMeta?.tools as Array<{ name: string }> | null | undefined;
const needsOAuth = tools?.some((tool) => tool.name === "DECO_CHAT_OAUTH_START") ?? false;
// Status: inactive if needs OAuth or has config state to fill
const status = needsOAuth || oauthConfig || configState ? "inactive" : "active";
// Check if MCP needs OAuth by looking for DECO_CHAT_OAUTH_START tool
const tools =
publisherMeta?.tools as Array<{ name: string }> | null | undefined;
const needsOAuth =
tools?.some((tool) => tool.name === "DECO_CHAT_OAUTH_START") ?? false;
// Status: inactive if needs OAuth or has config state to fill
const status: "inactive" | "active" =
needsOAuth || oauthConfig || configState ? "inactive" : "active";
🧰 Tools
🪛 GitHub Actions: Tests

[error] 98-105: Formatter would have printed different content. Code formatting issues detected by biome fmt:check.

🤖 Prompt for AI Agents
In apps/mesh/src/web/routes/orgs/store-app-detail.tsx around lines 99–105, the
inferred type of status is too broad and requires a later cast; explicitly
annotate status as the union type "inactive" | "active" (e.g. const status:
"inactive" | "active" = ...), split the long variable declarations on lines
99–104 across multiple lines to satisfy the formatter line-length rules, then
remove the unnecessary cast at line 135, and finally run bun run fmt to apply
consistent formatting.

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