import { defineStore } from 'pinia' interface Session { id: string // uuid from backend hostId: number hostName: string protocol: 'ssh' | 'rdp' color: string | null active: boolean } export const useSessionStore = defineStore('sessions', { state: () => ({ sessions: [] as Session[], activeSessionId: null as string | null, }), getters: { activeSession: (state) => state.sessions.find(s => s.id === state.activeSessionId), hasSessions: (state) => state.sessions.length > 0, }, actions: { addSession(session: Session) { this.sessions.push(session) this.activeSessionId = session.id }, removeSession(id: string) { this.sessions = this.sessions.filter(s => s.id !== id) if (this.activeSessionId === id) { this.activeSessionId = this.sessions.length ? this.sessions[this.sessions.length - 1].id : null } }, setActive(id: string) { this.activeSessionId = id }, }, })