Skip to content

Commit 9b0eb86

Browse files
committed
Improve update error handling and user feedback
1 parent b57aa2e commit 9b0eb86

File tree

3 files changed

+75
-14
lines changed

3 files changed

+75
-14
lines changed

.github/workflows/publish.yml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,23 @@ jobs:
254254
Write-Host "Files in bundle directory after signing:"
255255
Get-ChildItem -Path $bundleDir -Filter *.exe | ForEach-Object { Write-Host " - $($_.Name)" }
256256
257+
- name: Re-sign Windows installer for Tauri updater
258+
if: ${{ runner.os == 'Windows' }}
259+
shell: bash
260+
working-directory: apps/desktop
261+
run: |
262+
BUNDLE_DIR="../../target/${{ matrix.settings.target }}/release/bundle/nsis"
263+
for exe in "$BUNDLE_DIR"/*.exe; do
264+
echo "Re-signing $(basename "$exe") for Tauri updater..."
265+
rm -f "${exe}.sig"
266+
pnpm tauri signer sign -k "$TAURI_SIGNING_PRIVATE_KEY" -p "$TAURI_SIGNING_PRIVATE_KEY_PASSWORD" "$exe"
267+
done
268+
echo "Signature files after re-signing:"
269+
ls -la "$BUNDLE_DIR"/*.sig
270+
env:
271+
TAURI_SIGNING_PRIVATE_KEY: ${{ secrets.TAURI_SIGNING_PRIVATE_KEY }}
272+
TAURI_SIGNING_PRIVATE_KEY_PASSWORD: ${{ secrets.TAURI_SIGNING_PRIVATE_KEY_PASSWORD }}
273+
257274
- name: Upload assets
258275
uses: crabnebula-dev/cloud-release@v0
259276
with:

apps/desktop/src/routes/(window-chrome)/new-main/index.tsx

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -358,13 +358,31 @@ function createUpdateCheck() {
358358

359359
await new Promise((res) => setTimeout(res, 1000));
360360

361-
const update = await updater.check();
361+
let update: updater.Update | undefined;
362+
try {
363+
const result = await updater.check();
364+
if (result) update = result;
365+
} catch (e) {
366+
console.error("Failed to check for updates:", e);
367+
await dialog.message(
368+
"Unable to check for updates. Please download the latest version manually from cap.so/download. Your data will not be lost.\n\nIf this issue persists, please contact support.",
369+
{ title: "Update Error", kind: "error" },
370+
);
371+
return;
372+
}
373+
362374
if (!update) return;
363375

364-
const shouldUpdate = await dialog.confirm(
365-
`Version ${update.version} of Cap is available, would you like to install it?`,
366-
{ title: "Update Cap", okLabel: "Update", cancelLabel: "Ignore" },
367-
);
376+
let shouldUpdate: boolean | undefined;
377+
try {
378+
shouldUpdate = await dialog.confirm(
379+
`Version ${update.version} of Cap is available, would you like to install it?`,
380+
{ title: "Update Cap", okLabel: "Update", cancelLabel: "Ignore" },
381+
);
382+
} catch (e) {
383+
console.error("Failed to show update dialog:", e);
384+
return;
385+
}
368386

369387
if (!shouldUpdate) return;
370388
navigate("/update");

apps/desktop/src/routes/(window-chrome)/update.tsx

Lines changed: 35 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,25 +2,46 @@ import { Button } from "@cap/ui-solid";
22
import { useNavigate } from "@solidjs/router";
33
import { getCurrentWindow, UserAttentionType } from "@tauri-apps/api/window";
44
import { relaunch } from "@tauri-apps/plugin-process";
5-
import { check } from "@tauri-apps/plugin-updater";
6-
import { createResource, Match, Show, Switch } from "solid-js";
5+
import { check, type Update } from "@tauri-apps/plugin-updater";
6+
import { createResource, createSignal, Match, Show, Switch } from "solid-js";
77

88
export default function () {
99
const navigate = useNavigate();
10+
const [updateError, setUpdateError] = createSignal<string | null>(null);
1011

1112
const [update] = createResource(async () => {
12-
const update = await check();
13-
if (!update) return;
14-
15-
return update;
13+
try {
14+
const update = await check();
15+
if (!update) return;
16+
return update;
17+
} catch (e) {
18+
console.error("Failed to check for updates:", e);
19+
setUpdateError("Unable to check for updates.");
20+
return;
21+
}
1622
});
1723

1824
return (
1925
<div class="flex flex-col justify-center flex-1 items-center gap-[3rem] p-[1rem] text-[0.875rem] font-[400] h-full">
26+
<Show when={updateError()}>
27+
<div class="flex flex-col gap-4 items-center text-center max-w-md">
28+
<p class="text-[--text-primary]">{updateError()}</p>
29+
<p class="text-[--text-tertiary]">
30+
Please download the latest version manually from cap.so/download.
31+
Your data will not be lost.
32+
</p>
33+
<p class="text-[--text-tertiary] text-xs">
34+
If this issue persists, please contact support.
35+
</p>
36+
<Button onClick={() => navigate("/")}>Go Back</Button>
37+
</div>
38+
</Show>
2039
<Show
21-
when={update()}
40+
when={!updateError() && update()}
2241
fallback={
23-
<span class="text-[--text-tertiary]">No update available</span>
42+
!updateError() && (
43+
<span class="text-[--text-tertiary]">No update available</span>
44+
)
2445
}
2546
keyed
2647
>
@@ -61,7 +82,12 @@ export default function () {
6182
UserAttentionType.Informational,
6283
);
6384
})
64-
.catch(() => navigate("/"));
85+
.catch((e) => {
86+
console.error("Failed to download/install update:", e);
87+
setUpdateError(
88+
"Failed to download or install the update.",
89+
);
90+
});
6591
}),
6692
);
6793

0 commit comments

Comments
 (0)