mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-05 10:53:59 +00:00
Merge branch 'main' into upstream/terrain-partial-heights
Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
commit
692e99729c
29 files changed
+1123
-39
No files matched your search
@@ -71,6 +71,7 @@ export function createApplicationRequestServices({
|
||||
// Discovery is bounded; failed, malformed or timed-out probes are forgotten and not
|
||||
// retried for a short backoff, during which queries go to the server as
|
||||
// they would against an older server without the probe.
|
||||
let summaryCapability = null;
|
||||
let boundaryCapability = null;
|
||||
let boundaryProbeRetryAt = 0;
|
||||
function boundariesConfigured() {
|
||||
@@ -188,6 +189,23 @@ export function createApplicationRequestServices({
|
||||
},
|
||||
},
|
||||
summary: {
|
||||
// The capability probe, asked once per page: true or false from a
|
||||
// server that answers it, null (unknown) from one that does not.
|
||||
configured() {
|
||||
summaryCapability ??= request(`${urls.summary}/status`, {
|
||||
signal: AbortSignal.timeout(3000),
|
||||
}).then(
|
||||
(response) =>
|
||||
response.ok && typeof response.data?.configured === 'boolean'
|
||||
? response.data.configured
|
||||
: null,
|
||||
(error) => {
|
||||
if (lifetime?.aborted) throw error;
|
||||
return null;
|
||||
},
|
||||
);
|
||||
return summaryCapability;
|
||||
},
|
||||
async summarize(context, { signal } = {}) {
|
||||
return request(urls.summary, {
|
||||
method: 'POST',
|
||||
|
||||
@@ -111,3 +111,24 @@ test('a failed terrain request carries the real heights the server had', async (
|
||||
return true;
|
||||
});
|
||||
});
|
||||
|
||||
test('the summary capability probe is asked once and unknown when unanswered', async () => {
|
||||
for (const [answer, expected] of [
|
||||
[() => Response.json({ configured: false }), false],
|
||||
[() => Response.json({ configured: true }), true],
|
||||
[() => new Response('missing', { status: 404 }), null],
|
||||
[() => Response.json({ configured: 'yes' }), null],
|
||||
[() => { throw new TypeError('offline'); }, null],
|
||||
]) {
|
||||
const seen = [];
|
||||
const services = createApplicationRequestServices({
|
||||
fetchImpl: async (url, init) => {
|
||||
seen.push(`${init.method || 'GET'} ${url}`);
|
||||
return answer();
|
||||
},
|
||||
});
|
||||
assert.equal(await services.summary.configured(), expected);
|
||||
assert.equal(await services.summary.configured(), expected);
|
||||
assert.deepEqual(seen, ['GET /api/openai/hud-summary/status']);
|
||||
}
|
||||
});
|
||||
Reference in new issue
Block a user