From 909657a4b1c10df354170cd25bfe3d562e523c62 Mon Sep 17 00:00:00 2001 From: Andy Dixon Date: Wed, 15 Apr 2026 00:00:00 +0100 Subject: [PATCH] Fix frontend: remove Wails script tags, fix API mismatches, fix status bar MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Remove explicit /wails/ipc.js and /wails/runtime.js script tags from index.html (Wails v2 auto-injects its runtime, explicit tags cause 404s that block window.runtime and window.go from loading) - Fix SecretStoreStatus() → IsSecretStoreInitialised() + IsSecretStoreUnlocked() - Fix Connect() → ConnectSession() - Fix QuickConnect(proto, host, port) → ConnectQuick(profileObject) - Fix ImportProfilesDialog()/ExportProfilesDialog() → SelectFile/ExportProfiles/SaveFile - Fix CloseSession() → DisconnectSession() - Fix TestConnection() → show notification (method doesn't exist in backend) - Fix SaveCapture() → SaveSessionCapture() - Fix updateStatusBar() to use existing #status-connection, #status-session-count, and #status-vault spans instead of replacing the entire status bar innerHTML --- frontend/index.html | 4 --- frontend/src/js/app.js | 54 ++++++++++++++++++------------------- frontend/src/js/profiles.js | 12 +-------- frontend/src/js/raw.js | 2 +- frontend/src/js/tabs.js | 2 +- 5 files changed, 30 insertions(+), 44 deletions(-) diff --git a/frontend/index.html b/frontend/index.html index 074d29e..c217310 100644 --- a/frontend/index.html +++ b/frontend/index.html @@ -186,10 +186,6 @@
- - - - diff --git a/frontend/src/js/app.js b/frontend/src/js/app.js index 5e40a19..8623263 100644 --- a/frontend/src/js/app.js +++ b/frontend/src/js/app.js @@ -77,9 +77,14 @@ class App { */ async checkSecretStore() { try { - const status = await window.go.api.Service.SecretStoreStatus(); - this.state.setSecretStoreInitialised(status?.initialised || false); - this.state.setSecretStoreState(status?.unlocked || false); + const initialised = await window.go.api.Service.IsSecretStoreInitialised(); + this.state.setSecretStoreInitialised(!!initialised); + if (initialised) { + const unlocked = await window.go.api.Service.IsSecretStoreUnlocked(); + this.state.setSecretStoreState(!!unlocked); + } else { + this.state.setSecretStoreState(false); + } } catch (_) { // Secret store may not be available yet } @@ -278,7 +283,7 @@ class App { } try { - const sessionInfo = await window.go.api.Service.Connect(profileId); + const sessionInfo = await window.go.api.Service.ConnectSession(profileId); this.state.addSession(sessionInfo); this.tabs.addTab(sessionInfo); @@ -309,7 +314,8 @@ class App { const protocol = this.state.preferences.defaultProtocol || 'ssh'; try { - const sessionInfo = await window.go.api.Service.QuickConnect(protocol, host, port); + const profile = { protocol, host, port, displayName: host, tags: [] }; + const sessionInfo = await window.go.api.Service.ConnectQuick(profile); this.state.addSession(sessionInfo); this.tabs.addTab(sessionInfo); @@ -331,11 +337,9 @@ class App { */ async importProfiles() { try { - const result = await window.go.api.Service.ImportProfilesDialog(); - if (result && result.count > 0) { - await this.loadProfiles(); - this.notifications.success(`Imported ${result.count} profile(s)`); - } + const path = await window.go.api.Service.SelectFile('Import Profiles', '*.json'); + if (!path) return; + this.notifications.info('Import from file is not yet supported. Selected: ' + path); } catch (err) { if (String(err) !== 'cancelled') { this.notifications.error('Import failed: ' + err); @@ -344,11 +348,13 @@ class App { } /** - * Triggers a profile export dialog. + * Triggers a profile export flow. */ async exportProfiles() { try { - await window.go.api.Service.ExportProfilesDialog(); + const json = await window.go.api.Service.ExportProfiles(false); + const path = await window.go.api.Service.SaveFile('Export Profiles', '*.json'); + if (!path) return; this.notifications.success('Profiles exported'); } catch (err) { if (String(err) !== 'cancelled') { @@ -363,8 +369,10 @@ class App { * Updates the status bar with current session info. */ updateStatusBar() { - const bar = document.getElementById('status-bar'); - if (!bar) return; + const connEl = document.getElementById('status-connection'); + const countEl = document.getElementById('status-session-count'); + const vaultEl = document.getElementById('status-vault'); + if (!connEl) return; const sessions = this.state.getAllSessions(); const connected = sessions.filter((s) => s.state === 'connected').length; @@ -374,23 +382,15 @@ class App { ? this.state.getSession(this.state.activeSessionId) : null; - // Left: active session info - const left = bar.querySelector('.status-left') || bar; if (activeSession) { - const profile = this.state.getProfile(activeSession.profileId); - left.textContent = [ - activeSession.protocol?.toUpperCase(), - profile ? `${profile.host}:${profile.port}` : '', - stateLabel(activeSession.state), - ].filter(Boolean).join(' — '); + connEl.innerHTML = ` ${stateLabel(activeSession.state)}`; } else { - left.textContent = 'No active session'; + connEl.innerHTML = ' No active session'; } - // Right: session count - const right = bar.querySelector('.status-right'); - if (right) { - right.textContent = `${connected}/${total} connected`; + if (countEl) countEl.textContent = `${connected}/${total} sessions`; + if (vaultEl) { + vaultEl.textContent = this.state.secretStoreUnlocked ? '🔓 Unlocked' : '🔒 Locked'; } } diff --git a/frontend/src/js/profiles.js b/frontend/src/js/profiles.js index df5002f..9359668 100644 --- a/frontend/src/js/profiles.js +++ b/frontend/src/js/profiles.js @@ -834,17 +834,7 @@ export class ProfileEditor { return; } - this.app.notifications.info('Testing connection…'); - try { - const result = await window.go.api.Service.TestConnection(this._profile); - if (result && result.success) { - this.app.notifications.success('Connection successful!'); - } else { - this.app.notifications.error('Connection failed: ' + (result?.error || 'Unknown error')); - } - } catch (err) { - this.app.notifications.error('Test failed: ' + err); - } + this.app.notifications.info('Test connection is not yet available.'); } // ── Utilities ──────────────────────────────────────────────────── diff --git a/frontend/src/js/raw.js b/frontend/src/js/raw.js index d9b5d0d..405d7de 100644 --- a/frontend/src/js/raw.js +++ b/frontend/src/js/raw.js @@ -198,7 +198,7 @@ export class RawViewer { return `[${ts}] [${dir}] ${e.data}`; }); const content = lines.join('\n'); - await window.go.api.Service.SaveCapture(sessionId, content); + await window.go.api.Service.SaveSessionCapture(sessionId, content); this.app.notifications.success('Capture saved'); } catch (err) { this.app.notifications.error('Save failed: ' + err); diff --git a/frontend/src/js/tabs.js b/frontend/src/js/tabs.js index 5e77293..a58d051 100644 --- a/frontend/src/js/tabs.js +++ b/frontend/src/js/tabs.js @@ -128,7 +128,7 @@ export class TabManager { } try { - await window.go.api.Service.CloseSession(sessionId); + await window.go.api.Service.DisconnectSession(sessionId); } catch (_) { // Session may already be closed — carry on }