* fix: add useOptionalMessagesOperations hook for context-safe message operations
Add a variant of useMessagesOperations that returns no-op functions
when MessagesViewProvider is absent instead of throwing, enabling
shared components to render safely outside the chat route.
* fix: use optional message operations in ToolCallInfo and UIResourceCarousel
Switch ToolCallInfo and UIResourceCarousel from useMessagesOperations
to useOptionalMessagesOperations so they no longer crash when rendered
in the /search route, which lacks MessagesViewProvider.
* fix: update test mocks to use useOptionalMessagesOperations
* fix: consolidate noops and narrow useMemo dependency in useOptionalMessagesOperations
- Replace three noop variants (noopAsync, noopReturn, noop) with a single
`const noop = () => undefined` that correctly returns void/undefined
- Destructure individual fields from context before the useMemo so the
dependency array tracks stable operation references, not the full
context object (avoiding unnecessary re-renders on unrelated state changes)
- Add useOptionalMessagesConversation for components that need conversation
data outside MessagesViewProvider
* fix: use optional hooks in MCPUIResource components to prevent search crash
MCPUIResource and MCPUIResourceCarousel render inside Markdown prose and
can appear in the /search route. Switch them from the strict
useMessagesOperations/useMessagesConversation hooks to the optional
variants that return safe defaults when MessagesViewProvider is absent.
* test: update test mocks for optional hook renames
* fix: update ToolCallInfo and UIResourceCarousel test mocks to useOptionalMessagesOperations
* fix: use optional message operations in useConversationUIResources
useConversationUIResources internally called the strict
useMessagesOperations(), which still threw when MCPUIResource rendered
outside MessagesViewProvider. Switch to useOptionalMessagesOperations
so the entire MCPUIResource render chain is safe in the /search route.
* style: fix import order per project conventions
* fix: replace as-unknown-as casts with typed NOOP_OPS stubs
- Define OptionalMessagesOps type and NOOP_OPS constant with properly
typed no-op functions, eliminating all `as unknown as T` casts
- Use conversationId directly from useOptionalMessagesConversation
instead of re-deriving it from conversation object
- Update JSDoc to reflect search route support
* test: add no-provider regression tests for optional message hooks
Verify useOptionalMessagesOperations and useOptionalMessagesConversation
return safe defaults when rendered outside MessagesViewProvider, covering
the core crash path this PR fixes.
* 💻 feat: deeper MCP UI integration in the chat UI using plugins
---------
Co-authored-by: Samuel Path <samuel.path@shopify.com>
Co-authored-by: Pierre-Luc Godin <pierreluc.godin@shopify.com>
* 💻 refactor: Migrate MCP UI resources from index-based to ID-based referencing
- Replace index-based resource markers with stable resource IDs
- Update plugin to parse \ui{resourceId} format instead of \ui0
- Refactor components to use useMessagesOperations instead of useSubmitMessage
- Add ShareMessagesProvider for UI resources in share view
- Add useConversationUIResources hook for cross-turn resource lookups
- Update parsers to generate resource IDs from content hashes
- Update all tests to use resource IDs instead of indices
- Add sandbox permissions for iframe popups
- Remove deprecated MCP tool context instructions
---------
Co-authored-by: Pierre-Luc Godin <pierreluc.godin@shopify.com>