refactor: Unify sync server and combine torch with connection UI

- Consolidate git and torch WebSocket servers on port 4105
- Create separate handlers for git and torch in handlers/ directory
- Combine TorchButton with connection status into single pill button
- Remove StatusBar (now redundant with TorchButton)
- Remove auto-assign torch on register/disconnect
- Remove auto-connect to MCP on page load
- Connection only happens when user explicitly requests torch
This commit is contained in:
2026-02-14 17:13:32 -06:00
parent c98f3e2b99
commit 0f73bd60bf
13 changed files with 519 additions and 434 deletions

View File

@@ -1,5 +1,5 @@
import { useTorchStore } from '../stores/torch'
import { getWebMCP, autoConnect } from './webmcp'
import { autoConnect, disconnectWebMCP } from './webmcp'
import { endpoints } from '../config/endpoints'
let torchWs: WebSocket | null = null
@@ -71,9 +71,9 @@ async function handleMessage(data: any) {
torchStore.setClientId(data.id)
console.log(`[Torch] Registered as ${data.id}, hasTorch: ${data.hasTorch}`)
// Just update state, don't auto-connect - user must request torch explicitly
if (data.hasTorch) {
torchStore.setTorchState(data.id)
await connectToMCP()
}
break
}
@@ -147,17 +147,6 @@ export async function releaseTorch(): Promise<boolean> {
* Connect to MCP (when we have the torch)
*/
async function connectToMCP(): Promise<void> {
const webmcp = getWebMCP()
if (!webmcp) {
console.error('[Torch] WebMCP not initialized')
return
}
if (webmcp.isConnected) {
console.log('[Torch] Already connected to MCP')
return
}
console.log('[Torch] Connecting to MCP...')
const success = await autoConnect()
if (success) {
@@ -171,13 +160,8 @@ async function connectToMCP(): Promise<void> {
* Disconnect from MCP (when we lose the torch)
*/
function disconnectFromMCP(): void {
const webmcp = getWebMCP()
if (!webmcp) return
if (webmcp.isConnected && typeof webmcp.disconnect === 'function') {
console.log('[Torch] Disconnecting from MCP...')
webmcp.disconnect()
}
console.log('[Torch] Disconnecting from MCP...')
disconnectWebMCP()
}
/**