Skip to content

Commit 1e54c55

Browse files
t3dotggclaude
andcommitted
fix(desktop): a stale update pointer keeps the API fallback, and previews skip npm
Council round 1: - The updater still scans the API when the feed has no nightly and the pointer offers nothing newer than the installed build. - Preview runs no longer publish the npm launcher, which cannot download a draft's files. - The feed job compares the first nightly in releases.atom, respects PAUSE_NIGHTLY, repairs the pointer when the feed is unreadable, and does not rewrite the pointer on a GitHub error. Co-Authored-By: Claude Fable 5.2 <[email protected]>
1 parent bea81ed commit 1e54c55

7 files changed

Lines changed: 148 additions & 84 deletions

File tree

‎.github/scripts/check-nightly-release.cjs‎

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -121,26 +121,32 @@ async function resolveLatestNightlyCommit({ github, context, core }) {
121121
return { tag, sha: commit.sha, version };
122122
}
123123

124-
// The two places a nightly install looks for an update: releases.atom, which holds the 10 newest
125-
// git tags of any kind, and the `update-feed` pointer. Reports what each names beside the newest
126-
// published nightly, so the caller can repair the pointer and fail when the feed hides the nightly.
124+
// The two places a nightly install looks for an update: the `update-feed` pointer, and
125+
// releases.atom, which holds the 10 newest git tags of any kind. Older installs take the first
126+
// nightly in the feed. Reports what each names beside the newest published nightly.
127127
async function readNightlyUpdateFeed({ github, context, fetch = globalThis.fetch }) {
128128
const latest = await findLatestNightly({ github, context });
129129
if (!latest) return {};
130130

131131
const base = `https://github.com/${context.repo.owner}/${context.repo.repo}`;
132-
const feed = await fetch(`${base}/releases.atom`);
133-
if (!feed.ok) throw new Error(`releases.atom answered HTTP ${feed.status}.`);
134-
const feedTags = Array.from(
135-
(await feed.text()).matchAll(/href="[^"]*\/releases\/tag\/([^"]+)"/g),
136-
(match) => decodeURIComponent(match[1]),
137-
);
138-
139-
// A missing or unreadable pointer is a stale one; the caller rewrites it.
132+
// Only a missing or malformed pointer is stale. Rewriting deletes the old file first, so a
133+
// GitHub outage must not look like one.
140134
const pointer = await fetch(`${base}/releases/download/update-feed/nightly.json`);
141-
const pointerTag = pointer.ok ? (await pointer.json().catch(() => ({}))).tag_name : undefined;
142-
143-
return { tag: latest.tagName, feedTags, pointerTag };
135+
if (!pointer.ok && pointer.status !== 404) {
136+
throw new Error(`The update-feed pointer answered HTTP ${pointer.status}.`);
137+
}
138+
const pointerTag = pointer.ok ? (await pointer.json().catch(() => null))?.tag_name : undefined;
139+
140+
// An unreadable feed leaves `feedNightly` unset, so the pointer is still repaired.
141+
const feed = await fetch(`${base}/releases.atom`).catch(() => undefined);
142+
const feedTags = feed?.ok
143+
? Array.from((await feed.text()).matchAll(/href="[^"]*\/releases\/tag\/([^"]+)"/g), (match) =>
144+
decodeURIComponent(match[1]),
145+
)
146+
: undefined;
147+
const feedNightly = feedTags?.find((tag) => /^v\d+\.\d+\.\d+-nightly\./.test(tag));
148+
149+
return { tag: latest.tagName, pointerTag, feedNightly, feedTags };
144150
}
145151

146152
module.exports = {

‎.github/scripts/check-nightly-release.test.cjs‎

Lines changed: 35 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -243,36 +243,53 @@ const { readNightlyUpdateFeed } = require("./check-nightly-release.cjs");
243243
// GitHub percent-encodes tag names in the feed, and any tag in the repository takes a slot.
244244
const atomEntry = (tag) =>
245245
`<entry><link rel="alternate" type="text/html" href="https://github.com/example/app/releases/tag/${encodeURIComponent(tag)}"/></entry>`;
246+
const atomFeed = (tags) => new Response(`<feed>${tags.map(atomEntry).join("")}</feed>`);
247+
const NEWEST = "v1.0.1-nightly.20260905.123";
248+
const OLDER = "v1.0.1-nightly.20260905.100";
246249

247-
function updateFeedFixture({ feedTags, pointer }) {
250+
function updateFeedFixture({ feed, pointer }) {
248251
const { options } = fixture({
249252
releases: [nightly(1), nightly(0, { tagName: "v1.0.2-preview.1" })],
250253
});
251254
options.fetch = async (url) =>
252255
url === "https://github.com/example/app/releases.atom"
253-
? new Response(`<feed>${feedTags.map(atomEntry).join("")}</feed>`)
256+
? feed
254257
: url === "https://github.com/example/app/releases/download/update-feed/nightly.json"
255258
? pointer
256259
: assert.fail(`unexpected fetch ${url}`);
257260
return options;
258261
}
259262

260-
test("update feed check reports a nightly crowded out of the feed and a missing pointer", async () => {
261-
const feedTags = ["v1.0.2-preview.1", "mobile-android-build/2.3.0/abc"];
262-
assert.deepEqual(
263-
await readNightlyUpdateFeed(
264-
updateFeedFixture({ feedTags, pointer: new Response("Not Found", { status: 404 }) }),
265-
),
266-
{ tag: "v1.0.1-nightly.20260905.123", feedTags, pointerTag: undefined },
267-
);
268-
});
263+
const missing = () => new Response("Not Found", { status: 404 });
264+
for (const [name, { feed, pointer }, expected] of [
265+
[
266+
"a nightly crowded out of the feed and a missing pointer",
267+
{ feed: atomFeed(["v1.0.2-preview.1", "mobile-android-build/2.3.0/abc"]), pointer: missing() },
268+
{ pointerTag: undefined, feedNightly: undefined },
269+
],
270+
[
271+
"the first nightly in the feed, which is the one older installs take",
272+
{ feed: atomFeed(["update-feed", OLDER, NEWEST]), pointer: Response.json({ tag_name: OLDER }) },
273+
{ pointerTag: OLDER, feedNightly: OLDER },
274+
],
275+
[
276+
"a malformed pointer as stale and an unreadable feed as naming nothing",
277+
{ feed: new Response("", { status: 503 }), pointer: Response.json(null) },
278+
{ pointerTag: undefined, feedNightly: undefined },
279+
],
280+
]) {
281+
test(`update feed check reports ${name}`, async () => {
282+
const { tag, pointerTag, feedNightly } = await readNightlyUpdateFeed(
283+
updateFeedFixture({ feed, pointer }),
284+
);
285+
assert.deepEqual({ tag, pointerTag, feedNightly }, { tag: NEWEST, ...expected });
286+
});
287+
}
269288

270-
test("update feed check reads the tag the pointer names", async () => {
271-
const feedTags = ["v1.0.1-nightly.20260905.123"];
272-
const pointer = Response.json({ tag_name: "v1.0.1-nightly.20260905.100" });
273-
assert.deepEqual(await readNightlyUpdateFeed(updateFeedFixture({ feedTags, pointer })), {
274-
tag: "v1.0.1-nightly.20260905.123",
275-
feedTags,
276-
pointerTag: "v1.0.1-nightly.20260905.100",
289+
test("update feed check does not call a pointer stale when GitHub fails to serve it", async () => {
290+
const options = updateFeedFixture({
291+
feed: atomFeed([NEWEST]),
292+
pointer: new Response("", { status: 503 }),
277293
});
294+
await assert.rejects(readNightlyUpdateFeed(options), /pointer answered HTTP 503/);
278295
});

‎.github/workflows/release.yml‎

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -169,8 +169,8 @@ jobs:
169169
# commit end users must never receive. Never scheduled.
170170
# Same versioning as nightly under its own prerelease identifier.
171171
# A preview release stays a draft (see "Publish prerelease"), its
172-
# desktop builds carry no update feed, and no updater manifest is
173-
# attached, so neither stable nor nightly installs can be offered one.
172+
# desktop builds carry no update feed, no updater manifest is
173+
# attached, and npm gets nothing, so no install can be offered one.
174174
nightly_date="$(date -u -d "$NIGHTLY_DATE" +%Y%m%d)"
175175
176176
node scripts/resolve-nightly-release.ts \
@@ -1053,7 +1053,7 @@ jobs:
10531053
update_feed:
10541054
name: Check the update feed
10551055
needs: [preflight, release]
1056-
if: ${{ !cancelled() && github.repository == 'pingdotgg/t3code' && (github.event_name == 'schedule' || needs.preflight.outputs.release_channel == 'nightly') }}
1056+
if: ${{ !cancelled() && github.repository == 'pingdotgg/t3code' && ((github.event_name == 'schedule' && vars.PAUSE_NIGHTLY != 'true') || needs.preflight.outputs.release_channel == 'nightly') }}
10571057
runs-on: blacksmith-2vcpu-ubuntu-2404
10581058
timeout-minutes: 5
10591059
permissions:
@@ -1071,12 +1071,12 @@ jobs:
10711071
retries: 3
10721072
script: |
10731073
const { readNightlyUpdateFeed } = require('./.github/scripts/check-nightly-release.cjs');
1074-
const { tag, feedTags, pointerTag } = await readNightlyUpdateFeed({ github, context });
1074+
const { tag, pointerTag, feedNightly, feedTags } = await readNightlyUpdateFeed({ github, context });
10751075
if (!tag) return;
1076-
core.info(`Newest nightly: ${tag}. Pointer: ${pointerTag}. Feed: ${feedTags.join(', ')}.`);
1076+
core.info(`Newest nightly: ${tag}. Pointer: ${pointerTag}. Feed: ${feedTags?.join(', ')}.`);
10771077
core.setOutput('tag', tag);
10781078
core.setOutput('pointer_stale', pointerTag !== tag);
1079-
core.setOutput('in_feed', feedTags.includes(tag));
1079+
core.setOutput('feed_names_it', feedNightly === tag);
10801080
10811081
- name: Point the update feed at the newest nightly
10821082
if: steps.feed.outputs.pointer_stale == 'true'
@@ -1092,21 +1092,21 @@ jobs:
10921092
gh release upload update-feed nightly.json --clobber
10931093
10941094
- name: Fail when the feed hides the newest nightly
1095-
if: steps.feed.outputs.in_feed == 'false'
1095+
if: steps.feed.outputs.feed_names_it == 'false'
10961096
env:
10971097
RELEASE_TAG: ${{ steps.feed.outputs.tag }}
10981098
run: |
1099-
echo "::error::releases.atom does not list $RELEASE_TAG. Nightly installs older than 0.1.10-nightly.20261112.4603 cannot update. See docs/operations/release.md#update-feed."
1099+
echo "::error::releases.atom could not be read, or its first nightly is not $RELEASE_TAG. Nightly installs older than 0.1.10-nightly.20261112.4603 cannot reach it. A preview from a branch not rebased onto main is the usual cause. See docs/operations/release.md#update-feed."
11001100
exit 1
11011101
11021102
# The `t3` npm package is a launcher that downloads this version's CLI
11031103
# archive from the GitHub Release, so it publishes only once that release
1104-
# exists. Preview publishes too, under the `preview` dist-tag, which
1105-
# nothing resolves unless asked for by name.
1104+
# exists. A preview release stays a draft, whose files are not public, so
1105+
# a preview never publishes the launcher.
11061106
publish_cli:
11071107
name: Publish CLI to npm
11081108
needs: [preflight, build_bundle, release]
1109-
if: ${{ !failure() && !cancelled() && needs.preflight.result == 'success' && needs.release.result == 'success' }}
1109+
if: ${{ !failure() && !cancelled() && needs.preflight.result == 'success' && needs.release.result == 'success' && needs.preflight.outputs.release_channel != 'preview' }}
11101110
runs-on: ubuntu-24.04 # blacksmith-8vcpu-ubuntu-2404
11111111
timeout-minutes: 15
11121112
permissions:

‎apps/desktop/src/updates/githubUpdateFeed.test.ts‎

Lines changed: 30 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,16 @@ const atomFeed = (tags: ReadonlyArray<string>) =>
2121
)
2222
.join("")}</feed>`;
2323

24-
/** The tag a nightly install is offered when GitHub serves this feed and this `update-feed` pointer. */
25-
const offeredRelease = async (feedTags: ReadonlyArray<string>, pointerTag: string | undefined) => {
24+
/**
25+
* The release a nightly install on 4580 is offered when GitHub serves this feed, this `update-feed`
26+
* pointer, and this newest nightly from the REST API scan.
27+
*/
28+
const offeredRelease = async (
29+
feedTags: ReadonlyArray<string>,
30+
pointerTag: string | undefined,
31+
listedTag?: string,
32+
) => {
33+
let apiScans = 0;
2634
const request = async ({ path = "" }: { readonly path?: string | null }) => {
2735
if (path === `${REPO}/releases.atom`) return atomFeed(feedTags);
2836
if (path === `${REPO}/releases/download/update-feed/nightly.json`) {
@@ -31,8 +39,8 @@ const offeredRelease = async (feedTags: ReadonlyArray<string>, pointerTag: strin
3139
}
3240
const manifest = /\/releases\/download\/v([^/]+)\/nightly\.yml$/.exec(path ?? "");
3341
if (manifest) return `version: ${manifest[1]}\npath: T3-Code.exe\nsha512: abc\n`;
34-
// The API scan, the last resort, finds nothing.
35-
return "[]";
42+
apiScans += 1;
43+
return JSON.stringify(listedTag ? [{ tag_name: listedTag, body: "API notes" }] : []);
3644
};
3745
const provider = new GitHubProvider(
3846
{ provider: "github", owner: "pingdotgg", repo: "t3code" },
@@ -41,7 +49,7 @@ const offeredRelease = async (feedTags: ReadonlyArray<string>, pointerTag: strin
4149
allowPrerelease: true,
4250
channel: "nightly",
4351
currentVersion: semver.parse("0.1.10-nightly.20261112.4580"),
44-
fullChangelog: false,
52+
fullChangelog: true,
4553
} as ProviderArgs[1],
4654
{
4755
isUseMultipleRangeRequest: false,
@@ -50,7 +58,7 @@ const offeredRelease = async (feedTags: ReadonlyArray<string>, pointerTag: strin
5058
} as ProviderArgs[2],
5159
);
5260
const { tag, releaseNotes } = await provider.getLatestVersion();
53-
return { tag, releaseNotes };
61+
return { tag, releaseNotes, apiScans };
5462
};
5563

5664
// What filled releases.atom on 2026-11-12: ten tags, none of them a nightly.
@@ -61,17 +69,27 @@ describe("GitHubProvider nightly lookup", () => {
6169
expect(await offeredRelease(crowdedFeed, nightly(4606))).toEqual({
6270
tag: nightly(4606),
6371
releaseNotes: "pointer notes",
72+
apiScans: 0,
73+
});
74+
});
75+
76+
it("still scans the API when the feed has no nightly and the pointer offers nothing new", async () => {
77+
expect(await offeredRelease(crowdedFeed, nightly(4580), nightly(4606))).toEqual({
78+
tag: nightly(4606),
79+
releaseNotes: "API notes",
80+
apiScans: 1,
6481
});
6582
});
6683

6784
it.each([
68-
["the feed is newer than the pointer", [nightly(4606)], nightly(4603)],
69-
["there is no pointer", [nightly(4606)], undefined],
70-
["the pointer names another channel", [nightly(4606)], "v0.1.10-preview.20261112.4700"],
71-
])("keeps the feed's nightly when %s", async (_case, feedTags, pointerTag) => {
72-
expect(await offeredRelease(feedTags, pointerTag)).toEqual({
85+
["the feed is newer than the pointer", nightly(4603)],
86+
["there is no pointer", undefined],
87+
["the pointer names another channel", "v0.1.10-preview.20261112.4700"],
88+
])("keeps the feed's nightly when %s", async (_case, pointerTag) => {
89+
expect(await offeredRelease([nightly(4606)], pointerTag)).toEqual({
7390
tag: nightly(4606),
74-
releaseNotes: `${nightly(4606)} feed notes`,
91+
releaseNotes: [{ version: nightly(4606).slice(1), note: `${nightly(4606)} feed notes` }],
92+
apiScans: 0,
7593
});
7694
});
7795
});

0 commit comments

Comments
 (0)