Free Motion Capture for Everyone πβ¨
TypeScript
fix mac onedir vs onefile stuff
jonmatthis182dc8088da1
diff --git a/.github/workflows/build-installers-pyinstaller.yml b/.github/workflows/build-installers-pyinstaller.ymlindex d9820596..447aaa68 100644--- a/.github/workflows/build-installers-pyinstaller.yml+++ b/.github/workflows/build-installers-pyinstaller.yml@@ -274,7 +274,7 @@ jobs:codesign --force --options runtime --sign "Developer ID Application" \--timestamp \"./freemocap-ui/freemocap_server/${{ matrix.server-binary }}"- codesign --verify --deep --verbose "./freemocap-ui/freemocap_server"+ codesign --verify --verbose "./freemocap-ui/freemocap_server/${{ matrix.server-binary }}"echo "Server binary signed and verified successfully"# ββ Upload server-only artifact ββ- name: Upload server binary artifactdiff --git a/freemocap-ui/src/store/slices/cameras/cameras-reconcile.test.ts b/freemocap-ui/src/store/slices/cameras/cameras-reconcile.test.tsnew file mode 100644index 00000000..f0ea4d25--- /dev/null+++ b/freemocap-ui/src/store/slices/cameras/cameras-reconcile.test.ts@@ -0,0 +1,87 @@+// One-off test (no unit-test framework in this project β run via esbuild+node).+// Reproduces the duplicate-camera_index collision seen in the backend log:+// ValueError: Camera indexes must be unique ... {'be07': 0, 'fa5a': 1, '583d': 1}+//+// Run:+// node_modules/.bin/esbuild src/store/slices/cameras/cameras-reconcile.test.ts \+// --bundle --platform=node --format=esm --outfile=.tmp-reconcile-test.mjs \+// && node .tmp-reconcile-test.mjs++import {Camera, createDefaultCameraConfig, reconcileDetectedCameras} from './cameras-types';++// Tiny framework-free assert so this file type-checks under the app's+// (browser) tsconfig and still runs under node via esbuild.+function assertEqual<T>(actual: T, expected: T, message: string): void {+ if (actual !== expected) {+ throw new Error(`${message} (expected ${String(expected)}, got ${String(actual)})`);+ }+}++function makeCamera(id: string, index: number, name: string, tune?: {exposure?: number}): Camera {+ const desiredConfig = {+ ...createDefaultCameraConfig(id, index, name),+ ...(tune?.exposure !== undefined ? {exposure: tune.exposure} : {}),+ };+ return {+ id,+ index,+ name,+ actualConfig: createDefaultCameraConfig(id, index, name),+ desiredConfig,+ hasConfigMismatch: false,+ connectionStatus: 'available',+ selected: true,+ realtimeEnabled: true,+ deviceInfo: {},+ metrics: undefined,+ };+}++// State BEFORE the new camera was plugged in: fa5a is at OS index 1, and the+// user tuned its exposure to -5 (so we can prove settings survive the merge).+const previousCameras: Camera[] = [+ makeCamera('be07', 0, 'USB Camera'),+ makeCamera('fa5a', 1, 'USB Camera', {exposure: -5}),+];++// Fresh detection AFTER plugging in 583d: Windows renumbered the ports, so the+// same physical camera fa5a (stable id) now enumerates at index 2, and the new+// camera 583d took over index 1. Every detected camera carries its FRESH index.+const detectedCameras: Camera[] = [+ makeCamera('be07', 0, 'USB Camera'),+ makeCamera('fa5a', 2, 'USB Camera'),+ makeCamera('583d', 1, 'USB Camera'),+];++const merged = reconcileDetectedCameras(previousCameras, detectedCameras);++// What actually gets sent to the backend is desiredConfig (see selectSelectedCameraConfigs).+const indexesById = Object.fromEntries(+ merged.map(c => [c.id, c.desiredConfig.camera_index]),+);+console.log('resulting desiredConfig.camera_index by id:', JSON.stringify(indexesById));++// 1) The volatile index must be refreshed from detection, not carried over stale.+const fa5a = merged.find(c => c.id === 'fa5a')!;+assertEqual(+ fa5a.desiredConfig.camera_index,+ 2,+ 'fa5a.desiredConfig.camera_index should refresh to the detected index (stale index carried over)',+);++// 2) The whole point: no two cameras may claim the same index (backend rejects it).+const indexes = merged.map(c => c.desiredConfig.camera_index);+assertEqual(+ new Set(indexes).size,+ indexes.length,+ `camera_index values must be unique across configs, got ${JSON.stringify(indexesById)}`,+);++// 3) The merge must NOT clobber user-tuned settings while refreshing identity.+assertEqual(+ fa5a.desiredConfig.exposure,+ -5,+ "fa5a's tuned exposure (-5) must survive the merge",+);++console.log('PASS: reconcileDetectedCameras refreshes volatile index and keeps tuned settings');