fix: SFTP list not sent + RDP connect button does nothing

SFTP: Added console logging to diagnose, plus a watcher that sends
the pending list when sessionId becomes available (covers the race
where WS opens before sessionId is set).

RDP: connectHost() was returning early for non-SSH protocols.
Removed the guard and use host.protocol instead of hardcoded 'ssh'.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Vantz Stockwell 2026-03-14 02:04:33 -04:00
parent 46e2cb6e2f
commit 711ef73786
2 changed files with 20 additions and 6 deletions

View File

@ -1,4 +1,4 @@
import { ref, type Ref } from 'vue'
import { ref, watch, type Ref } from 'vue'
import { useAuthStore } from '~/stores/auth.store'
export function useSftp(sessionId: Ref<string | null>) {
@ -16,9 +16,17 @@ export function useSftp(sessionId: Ref<string | null>) {
ws = new WebSocket(wsUrl)
ws.onopen = () => {
console.log('[SFTP] WS open, sessionId=', sessionId.value, 'pendingList=', pendingList)
if (pendingList !== null) {
send({ type: 'list', path: pendingList })
// Send directly — don't rely on send() guard since we know WS is open
const path = pendingList
pendingList = null
if (sessionId.value) {
ws!.send(JSON.stringify({ type: 'list', path, sessionId: sessionId.value }))
} else {
console.warn('[SFTP] No sessionId available yet, cannot list')
pendingList = path // put it back
}
}
}
@ -72,6 +80,15 @@ export function useSftp(sessionId: Ref<string | null>) {
function chmod(path: string, mode: string) { send({ type: 'chmod', path, mode }) }
function download(path: string) { send({ type: 'download', path }) }
// If sessionId arrives after WS is already open, send any pending list
watch(sessionId, (newId) => {
if (newId && pendingList !== null && ws?.readyState === WebSocket.OPEN) {
const path = pendingList
pendingList = null
ws!.send(JSON.stringify({ type: 'list', path, sessionId: newId }))
}
})
function disconnect() {
ws?.close()
ws = null

View File

@ -85,16 +85,13 @@ function closeDetails() {
}
function connectHost(host: any) {
if (host.protocol !== 'ssh') {
return
}
const pendingId = `pending-${Date.now()}`
sessions.addSession({
key: pendingId,
id: pendingId,
hostId: host.id,
hostName: host.name,
protocol: 'ssh',
protocol: host.protocol,
color: host.color,
active: true,
})