fix: keep Alta bearer out of proxy command lines

This commit is contained in:
2026-08-19 22:26:47 +00:00
parent 582fc46914
commit 808698dc46
15 changed files with 207 additions and 101 deletions
+22 -10
View File
@@ -7,6 +7,7 @@ const statusIndicator = document.getElementById('statusIndicator');
const deviceSearch = document.getElementById('deviceSearch');
const disconnectBtn = document.getElementById('disconnectBtn');
const selectedDeviceId = document.getElementById('selectedDeviceId');
const altaUsername = document.getElementById('altaUsername');
const startProxyBtn = document.getElementById('startProxyBtn');
const stopProxyBtn = document.getElementById('stopProxyBtn');
const checkUpdateBtn = document.getElementById('checkUpdateBtn');
@@ -54,7 +55,8 @@ function renderConnectionState(state) {
function updateProxyButtons() {
const id = selectedDevice && (selectedDevice.guid || selectedDevice.id);
const active = id ? activeDeviceIds().has(id.toLowerCase()) : false;
startProxyBtn.disabled = !connection.connected || !id || active;
const hasUsername = altaUsername.value.trim().length > 0;
startProxyBtn.disabled = !connection.connected || !id || !hasUsername || active;
stopProxyBtn.disabled = !id || !active;
}
@@ -204,14 +206,21 @@ async function loadDevices() {
}
}
const rendererController = window.AptRendererController.createRendererController({
disconnect: () => window.electronAPI.disconnect(),
renderConnectionState,
clearDisconnectedState: () => {
allDevices = [];
allSites = {};
collapsedSites.clear();
altaUsername.value = '';
clearDeviceList();
},
showConnectionStatus: (message, type) => showStatus(connectionStatus, message, type),
});
async function handleDisconnect() {
const state = await window.electronAPI.disconnect();
renderConnectionState(state);
allDevices = [];
allSites = {};
collapsedSites.clear();
clearDeviceList();
showStatus(connectionStatus, 'Disconnected from Alta.', 'info');
await rendererController.disconnect();
}
async function handleStartProxy() {
@@ -219,7 +228,7 @@ async function handleStartProxy() {
if (!id) return;
startProxyBtn.disabled = true;
showStatus(connectionStatus, `Starting proxy for ${selectedDevice.name || 'selected device'}...`, 'info');
const result = await window.electronAPI.launchProxy(id);
const result = await window.electronAPI.launchProxy(id, altaUsername.value);
if (result.success) {
connection = await window.electronAPI.getConnectionState();
renderConnectionState(connection);
@@ -284,8 +293,10 @@ async function initialize() {
renderPairingStatus(await window.electronAPI.getPairingStatus());
if (connection.connected) await loadDevices();
window.electronAPI.onConnectionStateChanged(async (state) => {
const wasConnected = connection.connected;
const previousOrigin = connection.origin;
renderConnectionState(state);
if (state.connected) {
if (state.connected && (!wasConnected || state.origin !== previousOrigin)) {
allDevices = [];
allSites = {};
clearDeviceList();
@@ -300,6 +311,7 @@ disconnectBtn.addEventListener('click', handleDisconnect);
startProxyBtn.addEventListener('click', handleStartProxy);
stopProxyBtn.addEventListener('click', handleStopProxy);
deviceSearch.addEventListener('input', filterDevices);
altaUsername.addEventListener('input', updateProxyButtons);
checkUpdateBtn.addEventListener('click', () => checkForUpdates(true));
openReleasesBtn.addEventListener('click', () => window.electronAPI.openFixedReleasesPage());
dismissUpdateBtn.addEventListener('click', () => { updateNotice.style.display = 'none'; });