From cfd2ac14e57b057ecaa6ad9a56e54baeb19f388c Mon Sep 17 00:00:00 2001 From: QLHazyCoder <2825305047@qq.com> Date: Sat, 16 May 2026 17:41:27 +0800 Subject: [PATCH] fix: isolate FlowPilot release cache --- sidepanel/update-service.js | 4 +-- tests/update-service.test.js | 52 +++++++++++++++++++++++++++++++++++- 2 files changed, 53 insertions(+), 3 deletions(-) diff --git a/sidepanel/update-service.js b/sidepanel/update-service.js index 5ac3d1d..d3cf79f 100644 --- a/sidepanel/update-service.js +++ b/sidepanel/update-service.js @@ -3,8 +3,8 @@ const GITHUB_REPO = 'FlowPilot'; const RELEASES_PAGE_URL = `https://github.com/${GITHUB_OWNER}/${GITHUB_REPO}/releases`; const RELEASES_API_URL = `https://api.github.com/repos/${GITHUB_OWNER}/${GITHUB_REPO}/releases?per_page=10`; - const CACHE_KEY = 'multipage-release-snapshot-v1'; - const IGNORED_UPDATE_VERSION_KEY = 'multipage-ignored-release-version-v1'; + const CACHE_KEY = 'flowpilot-release-snapshot-v1'; + const IGNORED_UPDATE_VERSION_KEY = 'flowpilot-ignored-release-version-v1'; const CACHE_TTL_MS = 60 * 60 * 1000; const FETCH_TIMEOUT_MS = 8000; const MAX_RELEASES = 10; diff --git a/tests/update-service.test.js b/tests/update-service.test.js index b6f47f4..5fa898b 100644 --- a/tests/update-service.test.js +++ b/tests/update-service.test.js @@ -3,6 +3,8 @@ const assert = require('node:assert/strict'); const fs = require('node:fs'); const source = fs.readFileSync('sidepanel/update-service.js', 'utf8'); +const CACHE_KEY = 'flowpilot-release-snapshot-v1'; +const LEGACY_CACHE_KEY = 'multipage-release-snapshot-v1'; function createUpdateService(options = {}) { const manifest = options.manifest || { @@ -27,10 +29,16 @@ function createUpdateService(options = {}) { if (options.cachedSnapshot) { cache.set( - 'multipage-release-snapshot-v1', + CACHE_KEY, JSON.stringify(options.cachedSnapshot) ); } + if (options.legacyCachedSnapshot) { + cache.set( + LEGACY_CACHE_KEY, + JSON.stringify(options.legacyCachedSnapshot) + ); + } const fetchImpl = options.fetchImpl || (async () => ({ ok: true, @@ -202,6 +210,48 @@ test('getReleaseSnapshot reorders cached releases before choosing latest version ); }); +test('getReleaseSnapshot ignores legacy repository cache after FlowPilot rename', async () => { + const { api, getFetchCalls } = createUpdateService({ + legacyCachedSnapshot: { + fetchedAt: Date.now(), + releases: [ + { + version: '1.1', + displayVersion: 'Ultra1.1', + family: 'ultra', + title: '', + url: 'https://github.com/QLHazyCoder/codex-oauth-automation-extension/releases/tag/Ultra1.1', + publishedAt: '2026-04-19T00:00:00.000Z', + notes: [], + }, + ], + }, + fetchImpl: async () => ({ + ok: true, + async json() { + return [ + { + tag_name: 'FlowPilot1.1', + name: 'FlowPilot1.1', + html_url: 'https://github.com/QLHazyCoder/FlowPilot/releases/tag/FlowPilot1.1', + published_at: '2026-04-20T00:00:00.000Z', + body: '- current release', + draft: false, + prerelease: false, + }, + ]; + }, + }), + }); + + const snapshot = await api.getReleaseSnapshot(); + + assert.equal(getFetchCalls(), 1); + assert.equal(snapshot.logUrl, 'https://github.com/QLHazyCoder/FlowPilot/releases/tag/FlowPilot1.1'); + assert.equal(api.releasesPageUrl, 'https://github.com/QLHazyCoder/FlowPilot/releases'); + assert.equal(api.repositoryUrl, 'https://github.com/QLHazyCoder/FlowPilot'); +}); + test('getReleaseSnapshot suppresses an ignored latest update until a newer release appears', async () => { let releases = [ {