From bd48533b03aba73d5eca76717d2c35e1785d4e1b Mon Sep 17 00:00:00 2001 From: Aditya <205600203+Rohilalala@users.noreply.github.com> Date: Fri, 16 Oct 2026 05:43:24 +0530 Subject: [PATCH 1/7] fix(director): land on the requested shot A shot action seeks to the target shot's startProgress, which sceneTimingForShot computes as start / total. sceneSeekState multiplied that back into seconds and compared it with each shot's end, but (start / total) * total can round one ulp below start. The comparison then put the seek at the very end of the previous shot. With five equal 3.9 s shots, "go to" shots 2, 3 and 5 landed on shots 1, 2 and 4. Compare the requested progress against each shot's end / total instead, the same division the caller used, so a shot's own start always selects that shot. Exact boundaries still select the next shot, and anything below a start still selects the previous one. --- CHANGELOG.md | 4 ++++ docs/CURRENT-STATE.md | 2 ++ src/director/timeline.js | 16 +++++++++++---- src/director/timeline.test.mjs | 36 ++++++++++++++++++++++++++++++++++ 4 files changed, 54 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index dd76d7a250..da78668160 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Changelog +- Director shot actions land on the requested shot. A seek to a shot's start + could round a hair below it and select the end of the previous shot for some + shot counts and durations. + - Add Barcelona's bike share to the GBFS registry: Bicing (543 stations, the city's PBSC system) and AMBici (237 e-bike stations across the metropolitan area, run by nextbike). Both are keyless GBFS 2.3 feeds listed in diff --git a/docs/CURRENT-STATE.md b/docs/CURRENT-STATE.md index 4c06dd3cb2..29f82501d6 100644 --- a/docs/CURRENT-STATE.md +++ b/docs/CURRENT-STATE.md @@ -427,6 +427,8 @@ reference. Legacy projects retain their ordinary flights, content and edits. Seeking between ordinary camera poses uses the shortest longitude arc across the dateline while preserving both authored endpoint longitudes, and turns heading and roll the short way for any authored angles. +A seek to a shot's start, as a shot action makes, selects that shot rather than +the end of the previous one. See [camera directions](DIRECTOR-CAMERA.md). Realtime voice composes separate connection, response/tool, Radio handoff, input diff --git a/src/director/timeline.js b/src/director/timeline.js index f7cffcece8..5bcb42db6b 100644 --- a/src/director/timeline.js +++ b/src/director/timeline.js @@ -72,19 +72,27 @@ export function sceneSeekState(scene, progress, durationForShot, holdForShot) { let shotIndex = scene.shots.length - 1; for (let index = 0; index < scene.shots.length; index += 1) { const endElapsedSec = startElapsedSec + durations[index]; - if (targetSec < endElapsedSec || index === scene.shots.length - 1) { + // Compare in progress units: a shot's startProgress (start / total) + // times total can round below its start and select the previous shot. + if ( + normalized < endElapsedSec / totalSec || + index === scene.shots.length - 1 + ) { shotIndex = index; break; } startElapsedSec = endElapsedSec; } + // Keep the elapsed time inside the selected shot, so it agrees with + // shotIndex when targetSec rounded below the shot's start. + const elapsedSec = Math.max(targetSec, startElapsedSec); const shot = scene.shots[shotIndex]; const flightDurationSec = shot.durationSec || DEFAULT_SHOT_DURATION_SEC; const holdDurationSec = holdForShot(scene, shot); const shotDurationSec = Math.max(0.001, flightDurationSec + holdDurationSec); const shotElapsedSec = Math.max( 0, - Math.min(shotDurationSec, targetSec - startElapsedSec), + Math.min(shotDurationSec, elapsedSec - startElapsedSec), ); const cameraProgress = clamp01( shotElapsedSec / Math.max(0.001, flightDurationSec), @@ -99,8 +107,8 @@ export function sceneSeekState(scene, progress, durationForShot, holdForShot) { ); const move = resolveCameraMove(scene, shot); return { - sceneProgress: totalSec > 0 ? targetSec / totalSec : 0, - sceneElapsedSec: targetSec, + sceneProgress: totalSec > 0 ? elapsedSec / totalSec : 0, + sceneElapsedSec: elapsedSec, sceneDurationSec: totalSec, shotIndex, shot, diff --git a/src/director/timeline.test.mjs b/src/director/timeline.test.mjs index 1950eeef06..69a370c981 100644 --- a/src/director/timeline.test.mjs +++ b/src/director/timeline.test.mjs @@ -49,3 +49,39 @@ test('camera seeking preserves cubic easing and shortest-angle orientation', () ); assert.deepEqual(cameraAtProgress(null, camera(20, 350), 0), camera(20, 350)); }); + +test('seeking to a shot start lands in that shot for every shot count and duration', () => { + const misses = []; + for (let count = 2; count <= 12; count += 1) { + for (let flightTenths = 1; flightTenths <= 100; flightTenths += 1) { + for (let holdTenths = 0; holdTenths <= 50; holdTenths += 1) { + const shots = Array.from({ length: count }, (_, index) => ({ + id: `s${index}`, + // Every third shot is longer, so boundaries are not all equal steps. + durationSec: flightTenths / 10 + (index % 3 === 2 ? 1.7 : 0), + holdSec: holdTenths / 10, + camera: camera(20, 0), + })); + const mixed = { shots }; + for (const [index, shot] of shots.entries()) { + const { startProgress, startElapsedSec } = sceneTimingForShot( + mixed, + shot, + duration, + ); + const seek = sceneSeekState(mixed, startProgress, duration, hold); + // One or two ulps earlier still belongs to the previous shot. + const before = startProgress * (1 - Number.EPSILON); + const previous = sceneSeekState(mixed, before, duration, hold); + if ( + seek.shotIndex !== index || + seek.sceneElapsedSec < startElapsedSec || + previous.shotIndex !== Math.max(0, index - 1) + ) + misses.push(`${count}x${flightTenths}/${holdTenths}#${index}`); + } + } + } + } + assert.deepEqual(misses.slice(0, 5), []); +}); From a316e12323d2b862a92cc00fec2c6620710badea Mon Sep 17 00:00:00 2001 From: Aditya <205600203+Rohilalala@users.noreply.github.com> Date: Tue, 13 Oct 2026 14:15:45 +0530 Subject: [PATCH 2/7] fix(overpass): read failure phrases from the remark, not element tags overpassLooksRuntimeError and overpassLooksRateLimited searched the whole 200 body, element tags included. A result containing a place named "Timed Out Escape Rooms" (or any tag with "runtime error", "out of memory", "too many requests" or "rate_limited") was refused as an upstream failure, and the endpoint was put on cooldown for every other query. Parse the body once. A data reply (one with an elements array) reports failure in its remark, so the phrase checks run on the remark. Any other body, an error page or JSON without elements, is matched whole as before. --- CHANGELOG.md | 5 +++++ docs/CURRENT-STATE.md | 2 +- server/providers/overpass/transport.js | 22 ++++++++++++++++++---- src/overpassProxy.test.mjs | 26 ++++++++++++++++++++++++++ 4 files changed, 50 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index dd76d7a250..c2b02f0b06 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,10 @@ # Changelog +- Overpass data whose element tags contain a failure phrase ("timed out", + "runtime error", "too many requests" and similar, e.g. a place named "Timed + Out Escape Rooms") is returned as data instead of being refused and putting + the endpoint on cooldown; upstream failures are read from the remark. + - Add Barcelona's bike share to the GBFS registry: Bicing (543 stations, the city's PBSC system) and AMBici (237 e-bike stations across the metropolitan area, run by nextbike). Both are keyless GBFS 2.3 feeds listed in diff --git a/docs/CURRENT-STATE.md b/docs/CURRENT-STATE.md index 4c06dd3cb2..3424560ebc 100644 --- a/docs/CURRENT-STATE.md +++ b/docs/CURRENT-STATE.md @@ -525,7 +525,7 @@ are protected from fallback writes. Version 6 is the export format, with zero pitch, low camera heights, scope and detection edits preserved. See [the document contract](SCENE-DOCUMENT.md); see [Director](DIRECTOR.md) for camera, pack, action and sharing support. -Search framing and annotations request semantic map features from an explicit source. The Overpass adapter owns bounded queries, member/tag decoding and request deadlines; callers retain candidate ranking, outline caching, deferred retries and scene placement. Empty, unavailable, transient and throttled outcomes remain distinct. Traffic sources return road records and installation sources return mapped records with freshness/saturation metadata, so their layers no longer decode upstream elements. ALPR already normalizes its records in the source. Traffic uses OpenFreeMap roads with optional matched TomTom congestion; ALPR uses an hourly OpenStreetMap extract. Keyless installations use military-area tiles. Detailed feature queries require operator-configured Overpass. +Search framing and annotations request semantic map features from an explicit source. The Overpass adapter owns bounded queries, member/tag decoding and request deadlines; callers retain candidate ranking, outline caching, deferred retries and scene placement. Empty, unavailable, transient and throttled outcomes remain distinct; a data reply is refused only for its `remark`, never for text in element tags. Traffic sources return road records and installation sources return mapped records with freshness/saturation metadata, so their layers no longer decode upstream elements. ALPR already normalizes its records in the source. Traffic uses OpenFreeMap roads with optional matched TomTom congestion; ALPR uses an hourly OpenStreetMap extract. Keyless installations use military-area tiles. Detailed feature queries require operator-configured Overpass. Nepal media preloads survive repeated camera-flight updates, but Stop, event disable and replacement remove abandoned frames and revoke pending Facebook sessions. Fallback evidence-card clicks respect the shared drawing-tool pointer lease. diff --git a/server/providers/overpass/transport.js b/server/providers/overpass/transport.js index 38c31bb085..e3776e291f 100644 --- a/server/providers/overpass/transport.js +++ b/server/providers/overpass/transport.js @@ -14,7 +14,7 @@ import { simplifyOverpassPayloadBody } from './geometry.js'; * Checks for known rate-limit phrases in the body text regardless of * HTTP status code, since some mirrors return 200 with an error payload. * - * @param {string} bodyText - Upstream response body. + * @param {string} bodyText - The remark of a data reply, or a non-data body. * @returns {boolean} True if the body looks rate-limited. */ function overpassLooksRateLimited(bodyText) { @@ -41,6 +41,14 @@ function overpassLooksRuntimeError(bodyText) { ); } +function parseJson(text) { + try { + return JSON.parse(text); + } catch { + return undefined; + } +} + /** * True only for an upstream response that is actually Overpass data. * @@ -151,15 +159,22 @@ async function fetchOverpassPayload( signal: controller.signal, }); const responseBody = await readBody(upstream, maxResponseBytes); + const parsed = parseJson(responseBody); + // An Overpass data reply reports failure in its remark; its element + // tags are data and can contain any phrase. Any other body (an error + // page, or JSON without elements) is matched whole. + const failureText = Array.isArray(parsed?.elements) + ? String(parsed.remark || '') + : responseBody; const rateLimited = upstream.status === 429 || upstream.status === 406 || - overpassLooksRateLimited(responseBody); + overpassLooksRateLimited(failureText); if ( rateLimited || upstream.status < 200 || upstream.status >= 300 || - overpassLooksRuntimeError(responseBody) + overpassLooksRuntimeError(failureText) ) { const failures = (previous?.failures || 0) + 1; const delay = retryDelay( @@ -178,7 +193,6 @@ async function fetchOverpassPayload( failure = refusal(status, delay); continue; } - const parsed = JSON.parse(responseBody); if (!Array.isArray(parsed?.elements) || parsed.remark) throw new Error('Malformed Overpass response'); cooldowns.delete(endpoint); diff --git a/src/overpassProxy.test.mjs b/src/overpassProxy.test.mjs index ed4539fda7..788846db7e 100644 --- a/src/overpassProxy.test.mjs +++ b/src/overpassProxy.test.mjs @@ -126,6 +126,32 @@ test('production reader rejects oversized, malformed and runtime-failure bodies' } }); +test('element data that mentions a failure phrase is data, and sets no cooldown', async () => { + const names = ['Timed Out Escape Rooms', 'Runtime Error Bar', 'Out of Memory Lane', 'Too Many Requests Cafe', 'rate_limited']; + for (const [i, name] of names.entries()) { + const body = JSON.stringify({ elements: [{ type: 'node', id: 1, lat: 1, lon: 2, tags: { name } }] }); + let count = 0; + const options = { endpoints: [`https://phrase-${i}.example/`], fetchImpl: async () => { + count++; return new Response(body); + } }; + const payload = await fetchOverpassPayload('first', 1024, options); + assert.equal(payload.status, 200, name); + assert.ok(overpassPayloadIsData(payload), name); + assert.ok(payload.body.includes(name), name); + await fetchOverpassPayload('different', 1024, options); + assert.equal(count, 2, name); + } + const remark = JSON.stringify({ elements: [], remark: 'runtime error: rate_limited' }); + const limited = await fetchOverpassPayload('x', 1024, { endpoints: ['https://remark.example/'], + fetchImpl: async () => new Response(remark, { headers: { 'Retry-After': '90' } }) }); + assert.equal(limited.status, 429); + assert.equal(limited.retryAfterMs, 90_000); + const error = await fetchOverpassPayload('x', 1024, { endpoints: ['https://error.example/'], + fetchImpl: async () => new Response('{"error":"rate_limited"}', { headers: { 'Retry-After': '120' } }) }); + assert.equal(error.status, 429); + assert.equal(error.retryAfterMs, 120_000); +}); + function proxyHandler() { const plugin = createViteConfig({ mode: 'test' }).plugins.find(p => p.name === 'overpass-proxy'); const routes = new Map(); From aa7943a07bfbce6fae9fd8325712e09346583f48 Mon Sep 17 00:00:00 2001 From: Sameh Khamis Date: Fri, 16 Oct 2026 14:16:34 -0700 Subject: [PATCH 3/7] Move the changelog entry into changelog.d Main now takes release notes as one fragment per pull request (#787). --- CHANGELOG.md | 5 ----- changelog.d/1097-overpass-remark-failure-phrases.md | 5 +++++ 2 files changed, 5 insertions(+), 5 deletions(-) create mode 100644 changelog.d/1097-overpass-remark-failure-phrases.md diff --git a/CHANGELOG.md b/CHANGELOG.md index 873522b98c..8ee00d8392 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,10 +1,5 @@ # Changelog -- Overpass data whose element tags contain a failure phrase ("timed out", - "runtime error", "too many requests" and similar, e.g. a place named "Timed - Out Escape Rooms") is returned as data instead of being refused and putting - the endpoint on cooldown; upstream failures are read from the remark. - - Local FM seek finds stations after wrapping around 87.5–108 MHz, covers both band edges, skips the starting station and rejects spectra from an earlier tune (Aditya, @Rohilalala, #1174). diff --git a/changelog.d/1097-overpass-remark-failure-phrases.md b/changelog.d/1097-overpass-remark-failure-phrases.md new file mode 100644 index 0000000000..4543710dad --- /dev/null +++ b/changelog.d/1097-overpass-remark-failure-phrases.md @@ -0,0 +1,5 @@ +- Overpass data whose element tags contain a failure phrase ("timed out", + "runtime error", "too many requests" and similar, e.g. a place named "Timed + Out Escape Rooms") is returned as data instead of being refused and putting + the endpoint on cooldown; upstream failures are read from the remark (Aditya, + @Rohilalala, #1097). From 41be10f320aa7668e7b9a1dc31e66418e4ae7a08 Mon Sep 17 00:00:00 2001 From: Sameh Khamis Date: Fri, 16 Oct 2026 14:16:36 -0700 Subject: [PATCH 4/7] Move the changelog entry into changelog.d Main now takes release notes as one fragment per pull request (#787). --- CHANGELOG.md | 4 ---- changelog.d/1171-director-goto-shot.md | 3 +++ 2 files changed, 3 insertions(+), 4 deletions(-) create mode 100644 changelog.d/1171-director-goto-shot.md diff --git a/CHANGELOG.md b/CHANGELOG.md index 24fb0df5c3..8ee00d8392 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,9 +1,5 @@ # Changelog -- Director shot actions land on the requested shot. A seek to a shot's start - could round a hair below it and select the end of the previous shot for some - shot counts and durations. - - Local FM seek finds stations after wrapping around 87.5–108 MHz, covers both band edges, skips the starting station and rejects spectra from an earlier tune (Aditya, @Rohilalala, #1174). diff --git a/changelog.d/1171-director-goto-shot.md b/changelog.d/1171-director-goto-shot.md new file mode 100644 index 0000000000..4c08351efa --- /dev/null +++ b/changelog.d/1171-director-goto-shot.md @@ -0,0 +1,3 @@ +- Director shot actions land on the requested shot. A seek to a shot's start + could round a hair below it and select the end of the previous shot for some + shot counts and durations (Aditya, @Rohilalala, #1171). From fa8e3e989ff2c28e13c883c8570ea994e645b6ae Mon Sep 17 00:00:00 2001 From: Rudy Mizrahi Celekli <47457359+rudycelekli@users.noreply.github.com> Date: Fri, 16 Oct 2026 17:53:50 -0400 Subject: [PATCH 5/7] fix(tools): exclude unknown altitude from requested aircraft bands (#1115) aircraft_in_area compared a nullable altitude, so a contact with neither barometric nor geometric altitude matched max_altitude_m as though it were at zero. Require a reported finite altitude only when a band is requested; unfiltered queries keep the contact. --- .../1115-aircraft-altitude-band-unknown.md | 2 + docs/CURRENT-STATE.md | 3 + src/tools/queries/aviation.js | 2 + src/tools/queries/aviation.test.mjs | 59 +++++++++++++++++++ 4 files changed, 66 insertions(+) create mode 100644 changelog.d/1115-aircraft-altitude-band-unknown.md diff --git a/changelog.d/1115-aircraft-altitude-band-unknown.md b/changelog.d/1115-aircraft-altitude-band-unknown.md new file mode 100644 index 0000000000..a6b69472d8 --- /dev/null +++ b/changelog.d/1115-aircraft-altitude-band-unknown.md @@ -0,0 +1,2 @@ +- Exclude aircraft without a reported altitude from requested altitude bands; + unfiltered aircraft queries still retain them (rudycelekli, #1115). diff --git a/docs/CURRENT-STATE.md b/docs/CURRENT-STATE.md index df92c0d507..1bdca76707 100644 --- a/docs/CURRENT-STATE.md +++ b/docs/CURRENT-STATE.md @@ -100,6 +100,9 @@ shared `area` argument (place name, bounding box, or point and radius) and cap lists at 25 rows by default. Voice offers the same queries next to its app actions: the session lists them, and the browser runs them through the same catalog, loaded on first use. See [tools and the MCP server](TOOLS.md). +Aircraft altitude-band queries require a reported barometric or geometric altitude +for each match, so a grounded contact that reports none is left out of a band too. +Queries without an altitude band retain unknown-altitude contacts. Catalog calls check their cancellation signal immediately before executing a tool. Already-cancelled queries do not start; cancellation after execution starts diff --git a/src/tools/queries/aviation.js b/src/tools/queries/aviation.js index 0b8b54b79d..235f542e15 100644 --- a/src/tools/queries/aviation.js +++ b/src/tools/queries/aviation.js @@ -111,6 +111,8 @@ export const aircraftInArea = defineTool({ (record) => areaContains(area, { lat: record.latitude, lon: record.longitude }) && !(args.airborne_only && record.onGround) && + ((args.min_altitude_m == null && args.max_altitude_m == null) || + Number.isFinite(altitude(record))) && (args.min_altitude_m == null || altitude(record) >= args.min_altitude_m) && (args.max_altitude_m == null || diff --git a/src/tools/queries/aviation.test.mjs b/src/tools/queries/aviation.test.mjs index 20ec833aa3..d0e979ed65 100644 --- a/src/tools/queries/aviation.test.mjs +++ b/src/tools/queries/aviation.test.mjs @@ -388,3 +388,62 @@ test('the real OpenSky source marks an hour-old snapshot stale for searches', as assert.deepEqual(result.data.stale_feeds, ['civil']); assert.match(result.summary, /may be stale\.$/); }); + +test('altitude bands require a reported altitude from normalized OpenSky records', async () => { + const { normalizeOpenSkyAircraft } = + await import('../../sources/live/aircraft.js'); + const state = (id, baro, geometric) => + normalizeOpenSkyAircraft([ + id, + 'TEST', + 'Test', + 1767225600, + 1767225600, + 0, + 0, + baro, + false, + 10, + 90, + 0, + [], + geometric, + ]); + const records = [ + state('abc001', null, null), + state('abc002', 0, null), + state('abc003', null, 50), + state('abc004', 500, null), + ]; + const catalog = composeCatalog({ + tools: coreTools, + services: { + aircraft: { getSnapshot: async () => ({ records }) }, + }, + }); + const area = { bbox: [-1, -1, 1, 1] }; + assert.equal( + (await catalog.call('aircraft_in_area', { area })).data.total, + 4, + 'unfiltered answers retain unknown altitude', + ); + for (const band of [ + { max_altitude_m: 100 }, + { min_altitude_m: -500, max_altitude_m: 100 }, + ]) { + const result = await catalog.call('aircraft_in_area', { area, ...band }); + assert.deepEqual( + result.data.rows.map((row) => row.id), + ['abc002', 'abc003'], + ); + assert.deepEqual( + result.data.rows.map((row) => row.altitude_m), + [0, 50], + ); + } + const minimum = await catalog.call('aircraft_in_area', { + area, + min_altitude_m: -500, + }); + assert.equal(minimum.data.total, 3); +}); From 3c3ea269a946a18adc14f3553e2cd57c242130bd Mon Sep 17 00:00:00 2001 From: quanticsoul4772 <71096528+quanticsoul4772@users.noreply.github.com> Date: Fri, 16 Oct 2026 15:28:39 -0700 Subject: [PATCH 6/7] fix(setup): stop Node's DEP0190 warning when npm runs on Windows (#1057) Windows runs npm.cmd through a shell, and passing an argument array with `shell: true` is deprecated in Node 24 (DEP0190). Every `npm run doctor` and every Pinokio install on Windows printed the warning. npmProcessSpec now takes the npm arguments and, on Windows, joins them into the command string; the arguments are fixed subcommands (`--version`, `ci`). Unix behavior is unchanged. --- changelog.d/1057-windows-npm-dep0190.md | 4 ++++ scripts/pinokio-install.mjs | 4 ++-- scripts/setup-doctor.mjs | 17 +++++++++++------ src/setupDoctor.test.mjs | 18 ++++++++++++++---- 4 files changed, 31 insertions(+), 12 deletions(-) create mode 100644 changelog.d/1057-windows-npm-dep0190.md diff --git a/changelog.d/1057-windows-npm-dep0190.md b/changelog.d/1057-windows-npm-dep0190.md new file mode 100644 index 0000000000..1e8e1da559 --- /dev/null +++ b/changelog.d/1057-windows-npm-dep0190.md @@ -0,0 +1,4 @@ +- On Windows, `npm run doctor` and the Pinokio install no longer print Node's + DEP0190 warning ("Passing args to a child process with shell option true can + lead to security vulnerabilities"): npm.cmd's fixed subcommand is now part of + the shell command string instead of an argument array (quanticsoul4772, #1057). diff --git a/scripts/pinokio-install.mjs b/scripts/pinokio-install.mjs index 01a26ccce8..4e52bf3afb 100644 --- a/scripts/pinokio-install.mjs +++ b/scripts/pinokio-install.mjs @@ -24,8 +24,8 @@ export function runChecked(command, args, { shell = false } = {}) { export function installPinokioDependencies() { applyPinokioEnvironment(); rmSync(READY_FILE, { force: true }); - const npm = npmProcessSpec(); - runChecked(npm.command, ['ci'], { shell: npm.shell }); + const npm = npmProcessSpec(['ci']); + runChecked(npm.command, npm.args, { shell: npm.shell }); // Pinokio starts Vite directly and loads only its ENVIRONMENT file plus the // normal dotenv ladder. Unlike dev-fresh.sh, it does not import macOS diff --git a/scripts/setup-doctor.mjs b/scripts/setup-doctor.mjs index 49c6722c29..01e0480917 100644 --- a/scripts/setup-doctor.mjs +++ b/scripts/setup-doctor.mjs @@ -76,10 +76,15 @@ export function hasRequiredDependencies(rootDir = ROOT) { } } -/** Return the npm command and spawn mode required by the target platform. */ -export function npmProcessSpec(platform = process.platform) { - const windows = platform === 'win32'; - return { command: windows ? 'npm.cmd' : 'npm', shell: windows }; +/** + * Return the npm command, arguments and spawn mode for the target platform. + * Windows must run npm.cmd through a shell, and Node 24 deprecates passing an + * argument array with `shell: true` (DEP0190), so there the arguments, which + * are fixed npm subcommands, join the command string. + */ +export function npmProcessSpec(args, platform = process.platform) { + if (platform !== 'win32') return { command: 'npm', args, shell: false }; + return { command: ['npm.cmd', ...args].join(' '), args: [], shell: true }; } /** Read one key from Vite's dotenv file ladder without depending on Vite. */ @@ -190,8 +195,8 @@ export function buildCapabilitySummary( export function inspectSetup({ includeKeychain = true, authoritativeEnvironment = false, rootDir = ROOT } = {}) { const node = classifyNodeVersion(); - const npm = npmProcessSpec(); - const npmResult = spawnSync(npm.command, ['--version'], { + const npm = npmProcessSpec(['--version']); + const npmResult = spawnSync(npm.command, npm.args, { encoding: 'utf8', shell: npm.shell, }); diff --git a/src/setupDoctor.test.mjs b/src/setupDoctor.test.mjs index 71c6e44af6..26d695ba19 100644 --- a/src/setupDoctor.test.mjs +++ b/src/setupDoctor.test.mjs @@ -69,12 +69,22 @@ test('placeholder values are never counted as configured credentials', () => { }); test('doctor selects a Windows-safe npm process without changing Unix behavior', () => { - assert.deepEqual(npmProcessSpec('win32'), { - command: 'npm.cmd', + // Windows passes no argument array with shell: true (Node DEP0190). + assert.deepEqual(npmProcessSpec(['ci'], 'win32'), { + command: 'npm.cmd ci', + args: [], shell: true, }); - assert.deepEqual(npmProcessSpec('darwin'), { command: 'npm', shell: false }); - assert.deepEqual(npmProcessSpec('linux'), { command: 'npm', shell: false }); + assert.deepEqual(npmProcessSpec(['--version'], 'darwin'), { + command: 'npm', + args: ['--version'], + shell: false, + }); + assert.deepEqual(npmProcessSpec(['ci'], 'linux'), { + command: 'npm', + args: ['ci'], + shell: false, + }); }); test('doctor recognizes every OpenSky OAuth keychain alias used by dev-fresh', () => { From fb1088984178fe29ea4d3b53035d2393cb37d695 Mon Sep 17 00:00:00 2001 From: Rudy Mizrahi Celekli <47457359+rudycelekli@users.noreply.github.com> Date: Fri, 16 Oct 2026 18:34:26 -0400 Subject: [PATCH 7/7] fix(street-level): release superseded and unmounted Google viewer work (#1117) A superseded open wait cleared the shared cancelShown slot that belonged to the newer wait, leaving its auth listener and timer alive after close; open() now settles the previous wait first. A lookup whose viewer unmounted while the Street View service loaded still sent a billed getPanorama; describe() now rechecks the lookup after acquisition. --- changelog.d/1117-google-viewer-lifecycle.md | 3 + docs/CURRENT-STATE.md | 5 +- .../streetLevel/providers/google/viewer.js | 3 + .../providers/google/viewer.test.mjs | 66 +++++++++++++++++++ 4 files changed, 76 insertions(+), 1 deletion(-) create mode 100644 changelog.d/1117-google-viewer-lifecycle.md diff --git a/changelog.d/1117-google-viewer-lifecycle.md b/changelog.d/1117-google-viewer-lifecycle.md new file mode 100644 index 0000000000..66d73d4a22 --- /dev/null +++ b/changelog.d/1117-google-viewer-lifecycle.md @@ -0,0 +1,3 @@ +- Release superseded Google Street View open waits and suppress metadata + requests whose viewer was unmounted while the service loaded (rudycelekli, + #1117). diff --git a/docs/CURRENT-STATE.md b/docs/CURRENT-STATE.md index f1c04711e5..f425d6ebe4 100644 --- a/docs/CURRENT-STATE.md +++ b/docs/CURRENT-STATE.md @@ -3465,7 +3465,10 @@ controls (the address goes in the caption); a pose goes out at once and again when the panorama's month, photographer and address arrive (one successful lookup per panorama per session, seeded by the nearest lookup; a details lookup that fails or takes over ten seconds waits five seconds -before a view event can retry, and an unmount drops lookups in flight). A key +before a view event can retry, and an unmount drops lookups in flight). Opening +another panorama settles the previous open before registering its wait; closing +then releases the current wait immediately. A details lookup released while its +service loads makes no panorama request after that service becomes available. A key Google refuses (`gm_authFailure`: the API not enabled, a referrer it does not allow, billing off) reads KEY REJECTED and fails a pending open at once; a lookup or open Google never answers fails after 10 or 20 s. In CI diff --git a/src/layers/streetLevel/providers/google/viewer.js b/src/layers/streetLevel/providers/google/viewer.js index 422f52c0c4..25e0b08fe0 100644 --- a/src/layers/streetLevel/providers/google/viewer.js +++ b/src/layers/streetLevel/providers/google/viewer.js @@ -97,6 +97,8 @@ export function createGoogleViewer({ loader, getService, render } = {}) { service ||= getService ? await getService() : new (await ensureLibrary()).StreetViewService(); + if (!current()) + throw new Error('Street View details lookup was released'); return service.getPanorama({ pano: panoId }); })().then(resolve, reject); }); @@ -236,6 +238,7 @@ export function createGoogleViewer({ loader, getService, render } = {}) { const panoId = String(imageId); if (!host) throw new Error('Street View is not mounted'); if (loader.authFailed()) throw new Error(KEY_REJECTED_MESSAGE); + cancelShown?.(); pendingOpen = panoId; const instance = await ensurePanorama(host); if (pendingOpen !== panoId) return; diff --git a/src/layers/streetLevel/providers/google/viewer.test.mjs b/src/layers/streetLevel/providers/google/viewer.test.mjs index a3d746a343..e1d4a187ca 100644 --- a/src/layers/streetLevel/providers/google/viewer.test.mjs +++ b/src/layers/streetLevel/providers/google/viewer.test.mjs @@ -403,3 +403,69 @@ test('a remount looks up again a panorama whose lookup hung', async () => { await settle(); assert.equal(poses.length, count); }); + +test('superseded panorama waits cannot steal the current close cleanup', async (t) => { + t.mock.timers.enable({ apis: ['setTimeout'] }); + const { OPEN_TIMEOUT_MS } = await import('./policy.js'); + const flush = async () => { + for (let i = 0; i < 10; i++) await Promise.resolve(); + }; + const { fake, loader, viewer, host } = setup(); + await viewer.mount(host); + const [panorama] = fake.built; + panorama.setPano = (id) => { + panorama.pano = id; + }; + const first = viewer.open('pano-a'); + await flush(); + const second = viewer.open('pano-b'); + await flush(); + panorama.fire('position_changed'); // new panorama has not reached OK + await flush(); + viewer.close(); + const remaining = loader.listenerCount(); + t.mock.timers.tick(OPEN_TIMEOUT_MS); + await Promise.allSettled([first, second]); + assert.equal( + remaining, + 0, + 'close disposes every pending open without waiting 20 seconds', + ); + assert.equal(panorama.visible, false); +}); + +test('unmount during details-service acquisition makes no later billed lookup', async () => { + const fake = fakeStreetViewLibrary({ panoramas: PANORAMAS }); + const loader = fakeMapsLoader(fake.library); + const { createGoogleProvider } = await import('./index.js'); + let release; + const acquiring = new Promise((resolve) => { + release = resolve; + }); + const importLibrary = loader.importLibrary.bind(loader); + let imports = 0; + loader.importLibrary = async (name) => { + if (++imports > 1) await acquiring; + return importLibrary(name); + }; + const provider = createGoogleProvider({ + getApiKey: () => 'fixture-key', + loader, + }); + const instance = provider.create({ + notify() {}, + actions: { reportError() {} }, + }); + const viewer = instance.viewer; + await viewer.mount(fakeHost()); + await viewer.open('pano-a'); + viewer.unmount(); + release(); + for (let i = 0; i < 10; i++) await Promise.resolve(); + assert.equal( + fake.lookups.length, + 0, + 'teardown invalidates the request before calling getPanorama', + ); + instance.destroy(); +});