feat: Add torch system for multi-browser MCP control

- Add TorchButton component to header (replaces dropdowns)
- Add torch store for managing torch state
- Add torch service for requesting/releasing torch
- Add torch event handlers in WebMCP service
- Remove ComponentsDropdown and ToolsDropdown from header

The torch system allows controlling which browser receives
MCP tool calls when multiple browsers are connected.
Requires WebMCP library update to fully function.
This commit is contained in:
2026-02-14 16:25:43 -06:00
parent 50f670f66c
commit 647fb03516
5 changed files with 332 additions and 5 deletions

View File

@@ -1,4 +1,5 @@
import { useCanvasStore } from '../stores/canvas'
import { useTorchStore } from '../stores/torch'
import { endpoints, isSecure, wsProtocol, hostname } from '../config/endpoints'
// WebMCP HTTP API base for direct token requests
@@ -117,6 +118,43 @@ function setupEventHandlers() {
updateConnectionInfo()
})
)
// Torch events
const torchStore = useTorchStore()
eventUnsubscribers.push(
webmcpInstance.on('clientId', (data: { id: string }) => {
console.log('[WebMCP] Client ID assigned:', data.id)
torchStore.setClientId(data.id)
})
)
eventUnsubscribers.push(
webmcpInstance.on('torchUpdate', (data: { holderId: string | null; clients: any[] }) => {
console.log('[WebMCP] Torch state updated:', data.holderId)
torchStore.setClients(data.clients)
})
)
eventUnsubscribers.push(
webmcpInstance.on('torchGranted', () => {
console.log('[WebMCP] Torch granted!')
torchStore.setRequesting(false)
})
)
eventUnsubscribers.push(
webmcpInstance.on('torchDenied', (data: { reason: string }) => {
console.warn('[WebMCP] Torch denied:', data.reason)
torchStore.setRequesting(false)
})
)
eventUnsubscribers.push(
webmcpInstance.on('torchReleased', () => {
console.log('[WebMCP] Torch released')
})
)
}
function updateConnectionInfo() {