fix: isolate FlowPilot release cache

This commit is contained in:
QLHazyCoder
2026-05-16 17:41:27 +08:00
parent 6216a26956
commit cfd2ac14e5
2 changed files with 53 additions and 3 deletions
+2 -2
View File
@@ -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;
+51 -1
View File
@@ -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 = [
{