Skip to content

Group useChatSession props into ExecutionConfig and HostedRuntimeContext#1925

Merged
chelojimenez merged 1 commit intomainfrom
refactor/group-chat-session-props
Apr 25, 2026
Merged

Group useChatSession props into ExecutionConfig and HostedRuntimeContext#1925
chelojimenez merged 1 commit intomainfrom
refactor/group-chat-session-props

Conversation

@chelojimenez
Copy link
Copy Markdown
Contributor

@chelojimenez chelojimenez commented Apr 25, 2026

Summary

  • Fix EvalChatHandoff missing requireToolApproval — continuing an eval in chat now preserves tool approval state. The field will be undefined until evals gain tool approval support, but the plumbing is ready.
  • Group 4 initial* props into executionConfig: ExecutionConfigmodelId, systemPrompt, temperature, requireToolApproval travel as one object through useChatSession, MultiModelChatCard, MultiModelPlaygroundCard, and all chatbox/hosted surfaces.
  • Group 6 hosted* props into hostedContext: HostedRuntimeContextworkspaceId, selectedServerIds, oauthTokens, shareToken, chatboxToken, chatboxSurface travel as one object through the same surfaces.
  • No behavior changes. No backend changes. Clean cutover with no backwards-compat fallbacks.

Prep work for a future Host abstraction — ExecutionConfig becomes the execution slice, HostedRuntimeContext becomes the runtime slice.

Test plan

  • All 64 existing unit tests pass (hosted, fork, minimal-mode, multi-model cards, chatbox editor, chatbox chat page)
  • Manual: workspace chat — model/prompt/temperature/tool approval work
  • Manual: multi-model compare — both cards respond
  • Manual: chatbox preview — locked config loads correctly
  • Manual: chatbox share link — loads and chats
  • Manual: shared server chat — loads
  • Manual: playground single + compare mode
  • Manual: eval continue-in-chat — model/prompt/temperature carry over

🤖 Generated with Claude Code


Note

Medium Risk
Broad prop-shape refactor across chat, hosted, chatbox, and playground surfaces; risk is mainly regressions from missing/incorrectly forwarded fields (model/prompt/temperature/tool approval or hosted tokens) rather than logic changes.

Overview
Refactors chat session wiring by replacing scattered initial* and hosted* props with two typed objects: executionConfig (model/system prompt/temperature/tool approval) and hostedContext (workspace/server IDs/OAuth + share/chatbox scope) across ChatTabV2, useChatSession, multi-model cards, playground, and hosted/chatbox entrypoints.

Fixes eval handoff completeness by adding requireToolApproval to EvalChatHandoff and applying it when continuing an eval in chat.

Adds new shared types ExecutionConfig and HostedRuntimeContext, and updates affected unit tests to use the new prop shapes.

Reviewed by Cursor Bugbot for commit f8944a7. Bugbot is set up for automated code reviews on this repo. Configure here.

Reduces prop sprawl across all useChatSession call sites by grouping
related props into two typed objects:

- ExecutionConfig: modelId, systemPrompt, temperature, requireToolApproval
- HostedRuntimeContext: workspaceId, selectedServerIds, oauthTokens,
  shareToken, chatboxToken, chatboxSurface

Also fixes EvalChatHandoff missing requireToolApproval — continuing an
eval in chat now preserves the tool approval setting.

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
@dosubot dosubot Bot added the size:L This PR changes 100-499 lines, ignoring generated files. label Apr 25, 2026
@chelojimenez
Copy link
Copy Markdown
Contributor Author

Snyk checks have passed. No issues have been found so far.

Status Scan Engine Critical High Medium Low Total (0)
Open Source Security 0 0 0 0 0 issues

💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse.

@dosubot dosubot Bot added the enhancement New feature or request label Apr 25, 2026
@github-actions
Copy link
Copy Markdown

Internal preview

Preview URL: https://mcp-inspector-pr-1925.up.railway.app
Deployed commit: 11bec59
PR head commit: f8944a7
Backend target: staging fallback.
Health: ❌ Convex unreachable — see upsert-preview job logs (staging may need convex deploy)
Access is employee-only in non-production environments.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Apr 25, 2026

Walkthrough

This pull request consolidates fragmented configuration props across chat components and hooks into two structured objects: hostedContext (consolidating hosted environment details like tokens and workspace context) and executionConfig (grouping model, prompt, temperature, and tool-approval settings). The refactoring affects ChatTabV2, MultiModelChatCard, and related playground/chatbox components, their tests, and the useChatSession hook. Two new TypeScript types—HostedRuntimeContext and ExecutionConfig—formalize these structures. The EvalChatHandoff type gains an optional requireToolApproval field for handoff scenarios.


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.

Copy link
Copy Markdown
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.

🧹 Nitpick comments (2)
mcpjam-inspector/client/src/components/hosted/SharedServerChatPage.tsx (1)

486-491: Consolidate override props into hostedContext for uniform structure.

hostedWorkspaceIdOverride, hostedSelectedServerIdsOverride, and hostedOAuthTokensOverride are computed into "effective" values and merged into hostedContext before every downstream pass (lines 381–385, 2173–2176). Passing three as flat props while shareToken rides in hostedContext creates an unnecessary asymmetry—all six fields HostedRuntimeContext was designed to hold belong together.

In SharedServerChatPage, this becomes a partial migration: three workspace/token slots passed as *Override while only shareToken enters hostedContext.

Suggested consolidation:

♻️ Fold all four into hostedContext
-          hostedWorkspaceIdOverride={session.payload.workspaceId}
-          hostedSelectedServerIdsOverride={[session.payload.serverId]}
-          hostedOAuthTokensOverride={oauthTokensForChat}
-          hostedContext={{ shareToken: session.token }}
+          hostedContext={{
+            workspaceId: session.payload.workspaceId,
+            selectedServerIds: [session.payload.serverId],
+            oauthTokens: oauthTokensForChat,
+            shareToken: session.token,
+          }}

Then remove the now-unused *Override props from ChatTabProps.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@mcpjam-inspector/client/src/components/hosted/SharedServerChatPage.tsx`
around lines 486 - 491, Consolidate the three override props into the
hostedContext object so all HostedRuntimeContext fields travel together: in
SharedServerChatPage replace hostedWorkspaceIdOverride,
hostedSelectedServerIdsOverride and hostedOAuthTokensOverride by merging their
computed "effective" values into the existing hostedContext (which currently
contains shareToken) before passing to the child ChatTab component; update the
ChatTabProps usage to accept the expanded hostedContext (HostedRuntimeContext)
and remove the now-unused
hostedWorkspaceIdOverride/hostedSelectedServerIdsOverride/hostedOAuthTokensOverride
props, keeping onOAuthRequired/handleOAuthRequired as-is and preserving existing
names for clarity.
mcpjam-inspector/client/src/components/ChatTabV2.tsx (1)

2167-2177: Forward-compat nit: rebuild the child executionConfig from the prop, not just from local state.

Today the three live state values (systemPrompt, temperature, requireToolApproval) are equivalent to whatever the parent supplied via executionConfig, since useChatSession syncs them in effects. Functionally correct. The brittleness is structural: the day ExecutionConfig grows another field, this site silently drops it for multi-model cards while the single-model path keeps working. Spreading the prop and letting state win on the three already-tracked fields is a one-line hedge.

♻️ Suggested forward-compatible shape
-                          executionConfig={{
-                            systemPrompt,
-                            temperature,
-                            requireToolApproval,
-                          }}
+                          executionConfig={{
+                            ...executionConfig,
+                            systemPrompt,
+                            temperature,
+                            requireToolApproval,
+                          }}

Note: modelId is intentionally not propagated here — MultiModelChatCard overrides it per card with String(model.id), so an inherited executionConfig.modelId would be harmlessly overwritten downstream.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@mcpjam-inspector/client/src/components/ChatTabV2.tsx` around lines 2167 -
2177, The current inline executionConfig object only uses local state
(systemPrompt, temperature, requireToolApproval) and drops any other fields from
the incoming prop; change the JSX to build executionConfig by spreading the
incoming prop executionConfig first and then overriding the three tracked fields
so other future fields are preserved, e.g. use {...executionConfig,
systemPrompt, temperature, requireToolApproval}; keep in mind MultiModelChatCard
still overrides modelId downstream.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@mcpjam-inspector/client/src/components/ChatTabV2.tsx`:
- Around line 2167-2177: The current inline executionConfig object only uses
local state (systemPrompt, temperature, requireToolApproval) and drops any other
fields from the incoming prop; change the JSX to build executionConfig by
spreading the incoming prop executionConfig first and then overriding the three
tracked fields so other future fields are preserved, e.g. use
{...executionConfig, systemPrompt, temperature, requireToolApproval}; keep in
mind MultiModelChatCard still overrides modelId downstream.

In `@mcpjam-inspector/client/src/components/hosted/SharedServerChatPage.tsx`:
- Around line 486-491: Consolidate the three override props into the
hostedContext object so all HostedRuntimeContext fields travel together: in
SharedServerChatPage replace hostedWorkspaceIdOverride,
hostedSelectedServerIdsOverride and hostedOAuthTokensOverride by merging their
computed "effective" values into the existing hostedContext (which currently
contains shareToken) before passing to the child ChatTab component; update the
ChatTabProps usage to accept the expanded hostedContext (HostedRuntimeContext)
and remove the now-unused
hostedWorkspaceIdOverride/hostedSelectedServerIdsOverride/hostedOAuthTokensOverride
props, keeping onOAuthRequired/handleOAuthRequired as-is and preserving existing
names for clarity.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 52753a68-993f-4cdb-b0dc-11421fecd7d3

📥 Commits

Reviewing files that changed from the base of the PR and between b5196e2 and f8944a7.

📒 Files selected for processing (20)
  • mcpjam-inspector/client/src/components/ChatTabV2.tsx
  • mcpjam-inspector/client/src/components/chat-v2/__tests__/multi-model-chat-card.test.tsx
  • mcpjam-inspector/client/src/components/chat-v2/multi-model-chat-card.tsx
  • mcpjam-inspector/client/src/components/chatboxes/ChatboxEditor.tsx
  • mcpjam-inspector/client/src/components/chatboxes/__tests__/ChatboxEditor.test.tsx
  • mcpjam-inspector/client/src/components/chatboxes/builder/ChatboxBuilderView.tsx
  • mcpjam-inspector/client/src/components/evals/test-template-editor.tsx
  • mcpjam-inspector/client/src/components/hosted/ChatboxChatPage.tsx
  • mcpjam-inspector/client/src/components/hosted/SharedServerChatPage.tsx
  • mcpjam-inspector/client/src/components/hosted/__tests__/ChatboxChatPage.test.tsx
  • mcpjam-inspector/client/src/components/ui-playground/PlaygroundMain.tsx
  • mcpjam-inspector/client/src/components/ui-playground/__tests__/multi-model-playground-card.test.tsx
  • mcpjam-inspector/client/src/components/ui-playground/multi-model-playground-card.tsx
  • mcpjam-inspector/client/src/hooks/__tests__/use-chat-session.fork.test.tsx
  • mcpjam-inspector/client/src/hooks/__tests__/use-chat-session.hosted.test.tsx
  • mcpjam-inspector/client/src/hooks/__tests__/use-chat-session.minimal-mode.test.tsx
  • mcpjam-inspector/client/src/hooks/use-chat-session.ts
  • mcpjam-inspector/client/src/lib/chat-execution-config.ts
  • mcpjam-inspector/client/src/lib/eval-chat-handoff.ts
  • mcpjam-inspector/client/src/lib/hosted-runtime-context.ts

@chelojimenez chelojimenez merged commit a50f25e into main Apr 25, 2026
12 checks passed
@chelojimenez chelojimenez deleted the refactor/group-chat-session-props branch April 25, 2026 17:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request size:L This PR changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant