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

@@ -0,0 +1,72 @@
import { defineStore } from 'pinia'
import { ref, computed } from 'vue'
export interface TorchClient {
id: string
userAgent: string
hostname: string
url: string
connectedAt: string
hasTorch: boolean
}
export const useTorchStore = defineStore('torch', () => {
// State
const clientId = ref<string | null>(null)
const hasTorch = ref(false)
const torchHolderId = ref<string | null>(null)
const clients = ref<TorchClient[]>([])
const isRequesting = ref(false)
// Computed
const isConnected = computed(() => clientId.value !== null)
const torchHolder = computed(() => clients.value.find(c => c.hasTorch))
// Actions
function setClientId(id: string) {
clientId.value = id
}
function setTorchState(holder: string | null) {
torchHolderId.value = holder
hasTorch.value = holder === clientId.value
}
function setClients(newClients: TorchClient[]) {
clients.value = newClients
// Update torch state based on clients
const holder = newClients.find(c => c.hasTorch)
torchHolderId.value = holder?.id || null
hasTorch.value = holder?.id === clientId.value
}
function setRequesting(value: boolean) {
isRequesting.value = value
}
function reset() {
clientId.value = null
hasTorch.value = false
torchHolderId.value = null
clients.value = []
isRequesting.value = false
}
return {
// State
clientId,
hasTorch,
torchHolderId,
clients,
isRequesting,
// Computed
isConnected,
torchHolder,
// Actions
setClientId,
setTorchState,
setClients,
setRequesting,
reset
}
})