From 0306cbaccd4efd1bae966279417da42e19d3a827 Mon Sep 17 00:00:00 2001 From: ospab Date: Sun, 17 May 2026 18:32:55 +0300 Subject: [PATCH] fix: resolve GUI buttons by safe tauri invoke, add validation toasts, build and bundle ostp-tun-helper in CI/CD pipeline --- .github/workflows/release.yml | 7 +++++++ ostp-gui/src-tauri/src/lib.rs | 26 ++++++++++++++++++++++++++ ostp-gui/src/index.html | 2 +- ostp-gui/src/main.js | 10 +++++++++- ostp-wiki | 1 + 5 files changed, 44 insertions(+), 2 deletions(-) create mode 160000 ostp-wiki diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index df359fd..3f2cd17 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -258,6 +258,10 @@ jobs: - name: Install Tauri CLI run: cargo install tauri-cli --version "^2" + - name: Build Tun Helper + run: | + cargo build --release --target ${{ matrix.target }} -p ostp-tun-helper + - name: Build Tauri application shell: pwsh run: | @@ -275,6 +279,9 @@ jobs: $exePath = Get-ChildItem -Path "ostp-gui/src-tauri/target/${{ matrix.target }}/release" -Filter "ostp-gui.exe" | Select-Object -First 1 Copy-Item $exePath.FullName -Destination "$dist/ostp-gui.exe" + # 1.5 Copy the Tun Helper executable + Copy-Item "target/${{ matrix.target }}/release/ostp-tun-helper.exe" -Destination "$dist/ostp-tun-helper.exe" + # 2. Download tun2socks Invoke-WebRequest -Uri "https://github.com/xjasonlyu/tun2socks/releases/download/v2.6.0/tun2socks-${{ matrix.tun2socks_arch }}.zip" -OutFile "tun2socks.zip" Expand-Archive -Path "tun2socks.zip" -DestinationPath "tun_temp" -Force diff --git a/ostp-gui/src-tauri/src/lib.rs b/ostp-gui/src-tauri/src/lib.rs index 4b9bf0e..fd3da47 100644 --- a/ostp-gui/src-tauri/src/lib.rs +++ b/ostp-gui/src-tauri/src/lib.rs @@ -413,10 +413,36 @@ struct HelperPipeState { fn find_helper_exe() -> Option { if let Ok(exe) = std::env::current_exe() { if let Some(dir) = exe.parent() { + // 1. Release/Production adjacent let candidate = dir.join("ostp-tun-helper.exe"); if candidate.exists() { return Some(candidate); } + + // 2. Tauri target directory fallback + // e.g. from ostp-gui/src-tauri/target/debug/deps/ + let mut parent = dir; + while let Some(p) = parent.parent() { + if p.file_name().map(|n| n == "target").unwrap_or(false) { + let deb = p.join("debug").join("ostp-tun-helper.exe"); + if deb.exists() { return Some(deb); } + let rel = p.join("release").join("ostp-tun-helper.exe"); + if rel.exists() { return Some(rel); } + } + parent = p; + } } } + // 3. Current working directory target fallback + let cwd = std::env::current_dir().unwrap_or_default(); + let candidates = [ + cwd.join("ostp-tun-helper.exe"), + cwd.join("target").join("debug").join("ostp-tun-helper.exe"), + cwd.join("target").join("release").join("ostp-tun-helper.exe"), + cwd.join("..").join("target").join("debug").join("ostp-tun-helper.exe"), + cwd.join("..").join("target").join("release").join("ostp-tun-helper.exe"), + ]; + for path in &candidates { + if path.exists() { return Some(path.clone()); } + } None } diff --git a/ostp-gui/src/index.html b/ostp-gui/src/index.html index d1810d6..a6b438b 100644 --- a/ostp-gui/src/index.html +++ b/ostp-gui/src/index.html @@ -5,7 +5,7 @@ OSTP Client - +
diff --git a/ostp-gui/src/main.js b/ostp-gui/src/main.js index ac3331d..407695c 100644 --- a/ostp-gui/src/main.js +++ b/ostp-gui/src/main.js @@ -1,6 +1,12 @@ import { t, toggleLang, applyTranslations, getLang } from './i18n.js'; -const { invoke } = window.__TAURI__.core; +let invoke = () => { + console.warn('Tauri invoke is not available in this environment.'); + return Promise.resolve(null); +}; +if (window.__TAURI__ && window.__TAURI__.core) { + invoke = window.__TAURI__.core.invoke; +} // State management let appState = 'disconnected'; @@ -240,9 +246,11 @@ async function handleSaveConfig() { // Validation if (!rawConfigObj.server) { + showToast(t('err_server_req') || 'Server address is required'); return; } if (!rawConfigObj.access_key) { + showToast(t('err_key_req') || 'Access key is required'); return; } diff --git a/ostp-wiki b/ostp-wiki new file mode 160000 index 0000000..b5ab15b --- /dev/null +++ b/ostp-wiki @@ -0,0 +1 @@ +Subproject commit b5ab15bb8f63467df3393861c69142435e3cec65