From 9677a3bd788a1d314cb048cdac38ab7d0ecdc5ce Mon Sep 17 00:00:00 2001 From: AngusBell97 <124716116+AngusBell97@users.noreply.github.com> Date: Sun, 13 Sep 2026 21:40:03 -0500 Subject: [PATCH] Harden Galaxy version picker --- .../assets/mobile/js/components/GalaxySelect.js | 2 +- .../assets/mobile/js/components/VersionHistoryPicker.js | 2 +- .../system/the_galaxy/tests/test_branch_selector.mjs | 8 ++++++++ .../the_galaxy/tests/test_version_history_picker.mjs | 7 +++++++ starpilot/system/the_galaxy/version_install.py | 1 - 5 files changed, 17 insertions(+), 3 deletions(-) diff --git a/starpilot/system/the_galaxy/assets/mobile/js/components/GalaxySelect.js b/starpilot/system/the_galaxy/assets/mobile/js/components/GalaxySelect.js index 18e74c9ada..1775e00461 100644 --- a/starpilot/system/the_galaxy/assets/mobile/js/components/GalaxySelect.js +++ b/starpilot/system/the_galaxy/assets/mobile/js/components/GalaxySelect.js @@ -36,7 +36,7 @@ export const GalaxySelect = { if (this.disabled && this.open) this.close() }, async show(event) { - if (this.disabled) return + if (this.disabled || this.open) return this.sync() this.open = true await this.$nextTick() diff --git a/starpilot/system/the_galaxy/assets/mobile/js/components/VersionHistoryPicker.js b/starpilot/system/the_galaxy/assets/mobile/js/components/VersionHistoryPicker.js index 1022356d39..aa16aa404a 100644 --- a/starpilot/system/the_galaxy/assets/mobile/js/components/VersionHistoryPicker.js +++ b/starpilot/system/the_galaxy/assets/mobile/js/components/VersionHistoryPicker.js @@ -73,7 +73,7 @@ export const VersionHistoryPicker = { this.expanded = expanded }, async show() { - if (this.disabled) return + if (this.disabled || this.open) return const selectedDay = this.groups.find(group => group.commits.some(commit => commit.sha === this.value)) if (selectedDay) this.expanded[selectedDay.key] = true this.open = true diff --git a/starpilot/system/the_galaxy/tests/test_branch_selector.mjs b/starpilot/system/the_galaxy/tests/test_branch_selector.mjs index a42108b522..28644b6406 100644 --- a/starpilot/system/the_galaxy/tests/test_branch_selector.mjs +++ b/starpilot/system/the_galaxy/tests/test_branch_selector.mjs @@ -168,6 +168,14 @@ test('GalaxySelect reads optional option descriptions without adding them to col assert.equal(instance.label, 'Dom') }) +test('GalaxySelect ignores a second open request while its menu is open', async () => { + const context = vm.createContext({document: {getElementById() {}}}) + vm.runInContext(fs.readFileSync(js + 'components/GalaxySelect.js', 'utf8').replace('export const GalaxySelect =', 'globalThis.component ='), context) + const instance = {...context.component.data(), open: true, disabled: false, sync() { throw new Error('menu reopened') }} + await context.component.methods.show.call(instance) + assert.equal(instance.open, true) +}) + test('unavailable branch and navigation values cannot become install targets', async () => { const {instance, calls, confirmations} = fixture() for (const branch of ['other:', '', 'deleted-branch']) instance.selectTargetBranch(branch) diff --git a/starpilot/system/the_galaxy/tests/test_version_history_picker.mjs b/starpilot/system/the_galaxy/tests/test_version_history_picker.mjs index 433931fe5b..afd080b0e4 100644 --- a/starpilot/system/the_galaxy/tests/test_version_history_picker.mjs +++ b/starpilot/system/the_galaxy/tests/test_version_history_picker.mjs @@ -41,6 +41,13 @@ test('newly appended days stay collapsed while the current day keeps its state', assert.equal(instance.expanded['2026-09-10'], true) assert.equal(instance.expanded['2026-09-09'], false) }) + +test('history picker ignores a second open request while its dialog is open', async () => { + const instance = {disabled: false, open: true} + await context.picker.methods.show.call(instance) + assert.equal(instance.open, true) +}) + test('selection emits only an available exact SHA and disabled selection emits nothing', () => { assert.ok(context.picker) const calls = [] diff --git a/starpilot/system/the_galaxy/version_install.py b/starpilot/system/the_galaxy/version_install.py index f7d3b73c0b..a77b81fd61 100644 --- a/starpilot/system/the_galaxy/version_install.py +++ b/starpilot/system/the_galaxy/version_install.py @@ -9,7 +9,6 @@ import inspect from contextlib import contextmanager from contextvars import ContextVar from datetime import datetime, timezone -import hashlib import json import os from pathlib import Path