diff --git a/frontend/components/session/SessionContainer.vue b/frontend/components/session/SessionContainer.vue index 852c3b5..36496ce 100644 --- a/frontend/components/session/SessionContainer.vue +++ b/frontend/components/session/SessionContainer.vue @@ -41,7 +41,7 @@ function handleRdpClipboard(sessionId: string, text: string) {
diff --git a/frontend/components/terminal/TerminalTabs.vue b/frontend/components/terminal/TerminalTabs.vue index 63910eb..729ce86 100644 --- a/frontend/components/terminal/TerminalTabs.vue +++ b/frontend/components/terminal/TerminalTabs.vue @@ -8,7 +8,7 @@ const sessions = useSessionStore()
{ sessions.addSession({ + key: sessionId, id: sessionId, hostId, hostName: resolvedHostName || hostName, diff --git a/frontend/composables/useTerminal.ts b/frontend/composables/useTerminal.ts index 8ad3358..0bf025f 100644 --- a/frontend/composables/useTerminal.ts +++ b/frontend/composables/useTerminal.ts @@ -68,7 +68,7 @@ export function useTerminal() { switch (msg.type) { case 'connected': // Replace the pending placeholder with the real backend session - sessions.replaceSession(pendingSessionId, { id: msg.sessionId, hostId, hostName, protocol, color, active: true }) + sessions.replaceSession(pendingSessionId, { key: pendingSessionId, id: msg.sessionId, hostId, hostName, protocol, color, active: true }) // Send initial terminal size ws!.send(JSON.stringify({ type: 'resize', sessionId: msg.sessionId, cols: term.cols, rows: term.rows })) break diff --git a/frontend/pages/index.vue b/frontend/pages/index.vue index 70c2d6f..73a26bc 100644 --- a/frontend/pages/index.vue +++ b/frontend/pages/index.vue @@ -90,6 +90,7 @@ function connectHost(host: any) { } const pendingId = `pending-${Date.now()}` sessions.addSession({ + key: pendingId, id: pendingId, hostId: host.id, hostName: host.name, @@ -107,6 +108,7 @@ function handleQuickConnect(params: { hostname: string; port: number; username: : params.hostname sessions.addSession({ + key: sessionId, id: sessionId, hostId: null, hostName: displayName, diff --git a/frontend/stores/session.store.ts b/frontend/stores/session.store.ts index 34f1372..af9109e 100644 --- a/frontend/stores/session.store.ts +++ b/frontend/stores/session.store.ts @@ -1,7 +1,8 @@ import { defineStore } from 'pinia' interface Session { - id: string // uuid from backend + key: string // stable Vue key — never changes after creation + id: string // uuid from backend (starts as pending-XXX, replaced with real UUID) hostId: number hostName: string protocol: 'ssh' | 'rdp' @@ -32,6 +33,8 @@ export const useSessionStore = defineStore('sessions', { replaceSession(oldId: string, newSession: Session) { const idx = this.sessions.findIndex(s => s.id === oldId) if (idx !== -1) { + // Preserve the stable key so Vue doesn't remount the component + newSession.key = this.sessions[idx].key this.sessions[idx] = newSession } else { this.sessions.push(newSession)