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,8 +1,46 @@
<script setup lang="ts">
import { computed } from 'vue'
import { useTorchStore } from '../stores/torch'
import { useCanvasStore } from '../stores/canvas'
import { requestTorch, releaseTorch } from '../services/torch'
const torchStore = useTorchStore()
const canvasStore = useCanvasStore()
// Combined state
const hasTorch = computed(() => torchStore.hasTorch)
const isConnected = computed(() => canvasStore.isConnected)
const isReconnecting = computed(() => canvasStore.isReconnecting)
// Visual states:
// - No torch: gray, "Sin control"
// - Has torch, reconnecting: orange pulse, "Conectando..."
// - Has torch, not connected: orange, "Conectando..."
// - Has torch, connected: green glow, "Conectado"
const buttonState = computed(() => {
if (!hasTorch.value) return 'no-torch'
if (isReconnecting.value) return 'reconnecting'
if (isConnected.value) return 'connected'
return 'has-torch'
})
const statusText = computed(() => {
if (!hasTorch.value) return 'Sin control'
if (isReconnecting.value) return 'Conectando...'
if (isConnected.value) return 'Conectado'
return 'Conectando...'
})
const tooltipText = computed(() => {
if (!hasTorch.value) {
return torchStore.torchHolderId
? 'Otro browser tiene el control - click para solicitar'
: 'Click para solicitar control MCP'
}
if (isReconnecting.value) return 'Reconectando al MCP...'
if (isConnected.value) return 'Conectado al MCP - click para liberar control'
return 'Tiene control, conectando al MCP...'
})
async function handleClick() {
if (torchStore.hasTorch) {
@@ -16,20 +54,12 @@ async function handleClick() {
<template>
<button
class="torch-btn"
:class="{
'has-torch': torchStore.hasTorch,
'torch-held': torchStore.torchHolderId && !torchStore.hasTorch,
'requesting': torchStore.isRequesting
}"
:class="[buttonState, { requesting: torchStore.isRequesting }]"
@click="handleClick"
:title="torchStore.hasTorch ? 'You have the torch - click to release' : torchStore.torchHolderId ? 'Torch held by another client - click to request' : 'Click to request the torch'"
:title="tooltipText"
>
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
<!-- Torch/flame icon -->
<path d="M12 2c1 3 2.5 3.5 3.5 4.5A5 5 0 0 1 17 10a5 5 0 0 1-5 5 5 5 0 0 1-5-5 5 5 0 0 1 1.5-3.5C9.5 5.5 11 5 12 2z"/>
<path d="M12 15v7"/>
<path d="M10 22h4"/>
</svg>
<span class="status-dot"></span>
<span class="status-text">{{ statusText }}</span>
<span v-if="torchStore.isRequesting" class="requesting-indicator"></span>
</button>
</template>
@@ -38,45 +68,86 @@ async function handleClick() {
.torch-btn {
display: flex;
align-items: center;
justify-content: center;
padding: 6px 10px;
background: var(--bg-secondary);
border: 1px solid var(--border-color);
border-radius: 6px;
color: var(--text-secondary);
gap: 0.5rem;
padding: 0.375rem 0.75rem;
border-radius: 9999px;
font-size: 0.75rem;
font-weight: 500;
border: none;
cursor: pointer;
transition: all 0.2s ease;
transition: all 0.3s ease;
position: relative;
}
.torch-btn:hover {
background: var(--bg-tertiary);
color: var(--text-primary);
.status-dot {
width: 8px;
height: 8px;
border-radius: 50%;
transition: all 0.3s ease;
}
/* Has the torch - golden glow */
.status-text {
transition: all 0.3s ease;
}
/* No torch - gray/red, dimmed */
.torch-btn.no-torch {
background: rgba(239, 68, 68, 0.1);
color: #ef4444;
}
.torch-btn.no-torch .status-dot {
background: #ef4444;
}
.torch-btn.no-torch:hover {
background: rgba(245, 158, 11, 0.15);
color: #f59e0b;
}
.torch-btn.no-torch:hover .status-dot {
background: #f59e0b;
box-shadow: 0 0 8px #f59e0b;
}
/* Has torch but connecting - orange pulse */
.torch-btn.has-torch {
background: linear-gradient(135deg, #ff9500 0%, #ff6b00 100%);
border-color: #ff9500;
color: white;
box-shadow: 0 0 12px rgba(255, 149, 0, 0.5);
animation: torch-glow 2s ease-in-out infinite;
background: rgba(245, 158, 11, 0.15);
color: #f59e0b;
animation: status-pulse 2s ease-in-out infinite;
}
.torch-btn.has-torch:hover {
background: linear-gradient(135deg, #ffaa33 0%, #ff8533 100%);
.torch-btn.has-torch .status-dot {
background: #f59e0b;
box-shadow: 0 0 8px #f59e0b;
animation: dot-pulse 1.5s ease-in-out infinite;
}
/* Torch held by another */
.torch-btn.torch-held {
background: var(--bg-secondary);
border-color: #ff9500;
color: #ff9500;
opacity: 0.7;
/* Reconnecting - orange with faster pulse */
.torch-btn.reconnecting {
background: rgba(245, 158, 11, 0.15);
color: #f59e0b;
animation: status-pulse 1s ease-in-out infinite;
}
.torch-btn.torch-held:hover {
opacity: 1;
.torch-btn.reconnecting .status-dot {
background: #f59e0b;
animation: dot-pulse 0.8s ease-in-out infinite;
}
/* Connected - green glow */
.torch-btn.connected {
background: rgba(34, 197, 94, 0.1);
color: #22c55e;
}
.torch-btn.connected .status-dot {
background: #22c55e;
box-shadow: 0 0 8px #22c55e;
}
.torch-btn.connected:hover {
background: rgba(34, 197, 94, 0.2);
}
/* Requesting state */
@@ -90,27 +161,39 @@ async function handleClick() {
right: -2px;
width: 8px;
height: 8px;
background: var(--accent-color);
background: #6366f1;
border-radius: 50%;
animation: pulse 1s ease-in-out infinite;
animation: request-pulse 1s ease-in-out infinite;
}
@keyframes torch-glow {
/* Animations */
@keyframes status-pulse {
0%, 100% {
box-shadow: 0 0 12px rgba(255, 149, 0, 0.5);
opacity: 1;
}
50% {
box-shadow: 0 0 20px rgba(255, 149, 0, 0.8);
opacity: 0.7;
}
}
@keyframes pulse {
@keyframes dot-pulse {
0%, 100% {
transform: scale(1);
opacity: 1;
}
50% {
transform: scale(1.2);
transform: scale(1.3);
opacity: 0.8;
}
}
@keyframes request-pulse {
0%, 100% {
transform: scale(1);
opacity: 1;
}
50% {
transform: scale(1.3);
opacity: 0.7;
}
}