GeezerVison is showing github.com — fix(desktop): refresh queued updates before install by SunkenInTime · Pull Request #6269 · pingdotgg/t3code
fix(desktop): refresh queued updates before install
#6269
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and
privacy statement . We’ll occasionally send you account related emails.
Already on GitHub?
Sign in
to your account
Uh oh!
There was an error while loading. Please reload this page.
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter
Filter by extension
.ts
(6)
All 1 file type selected
Viewed files
Conversations
Failed to load comments.
Loading
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Jump to file
Failed to load files.
Loading
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Hide whitespace
Diff view
Hide whitespace
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
Original file line number
Diff line number
Diff line change
Expand Up
@@ -337,6 +337,41 @@ describe("DesktopUpdates", () => {
).pipe(Effect.provide(Layer.merge(TestClock.layer(), harness.layer)));
});
it.effect("checks for newer releases after an update has been downloaded", () => {
const harness = makeHarness();
return Effect.scoped(
Effect.gen(function* () {
const updates = yield* DesktopUpdates.DesktopUpdates;
yield* updates.configure;
harness.emit("update-downloaded", { version: "1.2.4" });
yield* flushCallbacks;
const result = yield* updates.check("poll");
assert.isTrue(result.checked);
harness.emit("update-available", { version: "1.2.4" });
yield* flushCallbacks;
const unchangedState = yield* updates.getState;
assert.equal(unchangedState.status, "downloaded");
assert.equal(unchangedState.downloadedVersion, "1.2.4");
const nextResult = yield* updates.check("poll");
assert.isTrue(nextResult.checked);
harness.emit("update-available", { version: "1.2.5" });
yield* flushCallbacks;
const state = yield* updates.getState;
assert.equal(state.status, "available");
assert.equal(state.availableVersion, "1.2.5");
assert.isNull(state.downloadedVersion);
}),
).pipe(Effect.provide(Layer.merge(TestClock.layer(), harness.layer)));
});
it.effect("keeps raw updater event failures out of update state", () => {
const harness = makeHarness();
const cause = new Error(
Expand Down
Original file line number
Diff line number
Diff line change
Expand Up
@@ -353,7 +353,7 @@ export const make = Effect.gen(function* () {
if (yield* Ref.get(updateCheckInFlightRef)) return false;
const state = yield* Ref.get(updateStateRef);
if (state.status === "downloading" || state.status === "downloaded" ) {
if (state.status === "downloading") {
Comment thread
macroscopeapp[bot] marked this conversation as resolved.
Resolved
Uh oh!
There was an error while loading. Please reload this page.
Comment thread
cursor[bot] marked this conversation as resolved.
Resolved
Uh oh!
There was an error while loading. Please reload this page.
yield* logUpdaterInfo("skipping update check while update is active", {
reason,
status: state.status,
Expand Down
Original file line number
Diff line number
Diff line change
Expand Up
@@ -55,6 +55,54 @@ describe("updateMachine", () => {
expect(state.canRetry).toBe(true);
});
it("preserves an already-downloaded update while checking the feed", () => {
const downloadedState = {
...createInitialDesktopUpdateState("1.0.0", runtimeInfo, "latest"),
enabled: true,
status: "downloaded" as const,
availableVersion: "1.1.0",
downloadedVersion: "1.1.0",
releaseNotes: [{ version: "1.1.0", items: ["fix: queued update"] }],
downloadPercent: 100,
};
const checking = reduceDesktopUpdateStateOnCheckStart(
downloadedState,
"2026-03-04T00:00:00.000Z",
);
const failed = reduceDesktopUpdateStateOnCheckFailure(
checking,
"network unavailable",
"2026-03-04T00:00:01.000Z",
);
expect(checking.status).toBe("checking");
expect(checking.downloadedVersion).toBe("1.1.0");
expect(checking.releaseNotes).toEqual(downloadedState.releaseNotes);
expect(failed.status).toBe("downloaded");
expect(failed.downloadedVersion).toBe("1.1.0");
expect(failed.releaseNotes).toEqual(downloadedState.releaseNotes);
expect(failed.message).toBeNull();
});
it("keeps the installer when the feed still offers its version", () => {
const state = reduceDesktopUpdateStateOnUpdateAvailable(
{
...createInitialDesktopUpdateState("1.0.0", runtimeInfo, "latest"),
enabled: true,
status: "downloaded",
availableVersion: "1.1.0",
downloadedVersion: "1.1.0",
downloadPercent: 100,
},
"1.1.0",
"2026-03-04T00:00:00.000Z",
);
expect(state.status).toBe("downloaded");
expect(state.downloadedVersion).toBe("1.1.0");
expect(state.downloadPercent).toBe(100);
});
it("preserves available version on download failure for retry", () => {
const state = reduceDesktopUpdateStateOnDownloadFailure(
{
Expand Down
Original file line number
Diff line number
Diff line change
Expand Up
@@ -43,13 +43,14 @@ export function reduceDesktopUpdateStateOnCheckStart(
state: DesktopUpdateState,
checkedAt: string,
): DesktopUpdateState {
const hasDownloadedUpdate = state.downloadedVersion !== null;
return {
...state,
status: "checking",
checkedAt,
releaseNotes: [],
releaseNotes: hasDownloadedUpdate ? state.releaseNotes : [],
message: null,
downloadPercent: null,
downloadPercent: hasDownloadedUpdate ? 100 : null,
errorContext: null,
canRetry: false,
};
Expand All
@@ -60,6 +61,18 @@ export function reduceDesktopUpdateStateOnCheckFailure(
message: string,
checkedAt: string,
): DesktopUpdateState {
if (state.downloadedVersion !== null) {
return {
...state,
status: "downloaded",
message: null,
checkedAt,
downloadPercent: 100,
errorContext: null,
canRetry: true,
};
}
return {
...state,
status: "error",
Expand All
@@ -77,17 +90,18 @@ export function reduceDesktopUpdateStateOnUpdateAvailable(
checkedAt: string,
releaseNotes: ReadonlyArray<DesktopUpdateReleaseNote> = [],
): DesktopUpdateState {
const isDownloadedVersion = state.downloadedVersion === version;
return {
...state,
status: "available",
status: isDownloadedVersion ? "downloaded" : "available",
availableVersion: version,
downloadedVersion: null,
downloadedVersion: isDownloadedVersion ? version : null,
releaseNotes,
Comment thread
SunkenInTime marked this conversation as resolved.
Resolved
Uh oh!
There was an error while loading. Please reload this page.
downloadPercent: null,
downloadPercent: isDownloadedVersion ? 100 : null,
checkedAt,
message: null,
errorContext: null,
canRetry: false ,
canRetry: isDownloadedVersion ,
};
}
Expand Down
Original file line number
Diff line number
Diff line change
Expand Up
@@ -73,14 +73,25 @@ describe("desktop update button state", () => {
expect(getDesktopUpdateButtonTooltip(state)).toContain("Click to retry");
});
it("prefers install when a downloaded version already exists ", () => {
it("prefers a newly available release over a stale downloaded version", () => {
const state: DesktopUpdateState = {
...baseState,
status: "available",
availableVersion: "1.2.0",
downloadedVersion: "1.1.0",
};
expect(resolveDesktopUpdateButtonAction(state)).toBe("download");
});
it("hides the install action while checking for a newer release", () => {
const state: DesktopUpdateState = {
...baseState,
status: "checking",
availableVersion: "1.1.0",
downloadedVersion: "1.1.0",
downloadPercent: 100,
};
expect(resolveDesktopUpdateButtonAction(state)).toBe("install ");
expect(resolveDesktopUpdateButtonAction(state)).toBe("none ");
});
it("hides the button for non-actionable check errors", () => {
Expand Down
Expand Up
@@ -290,15 +301,15 @@ describe("canCheckForUpdate", () => {
);
});
it("returns false once an update has been downloaded", () => {
it("returns true once an update has been downloaded so newer releases can be found ", () => {
expect(
canCheckForUpdate({
...baseState,
status: "downloaded",
availableVersion: "1.1.0",
downloadedVersion: "1.1.0",
}),
).toBe(false );
).toBe(true );
});
it("returns true when idle", () => {
Expand Down
Original file line number
Diff line number
Diff line change
Expand Up
@@ -24,7 +24,10 @@ export function getDesktopUpdateReleaseUrl(version: string | null): string | nul
export function resolveDesktopUpdateButtonAction(
state: DesktopUpdateState,
): DesktopUpdateButtonAction {
if (state.downloadedVersion) {
if (
state.downloadedVersion &&
Comment thread
SunkenInTime marked this conversation as resolved.
Resolved
Uh oh!
There was an error while loading. Please reload this page.
(state.status === "downloaded" || state.errorContext === "install")
) {
return "install";
}
if (state.status === "available") {
Expand Down
Expand Up
@@ -125,9 +128,6 @@ export function shouldHighlightDesktopUpdateError(state: DesktopUpdateState | nu
export function canCheckForUpdate(state: DesktopUpdateState | null): boolean {
if (!state || !state.enabled) return false;
return (
state.status !== "checking" &&
state.status !== "downloading" &&
state.status !== "downloaded" &&
state.status !== "disabled"
state.status !== "checking" && state.status !== "downloading" && state.status !== "disabled"
);
}
Loading
Oops, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.