Skip to content

armgit / Cap

Public Imported from GitHub
0

Open source Loom alternative. Beautiful, shareable screen recordings.

Improve update error handling and user feedback

Richie McIlroy9b0eb8615e6a
diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml
index c73854a6a..01c54ffd2 100644
--- a/.github/workflows/publish.yml
+++ b/.github/workflows/publish.yml
@@ -254,6 +254,23 @@ jobs:
Write-Host "Files in bundle directory after signing:"
Get-ChildItem -Path $bundleDir -Filter *.exe | ForEach-Object { Write-Host " - $($_.Name)" }
+ - name: Re-sign Windows installer for Tauri updater
+ if: ${{ runner.os == 'Windows' }}
+ shell: bash
+ working-directory: apps/desktop
+ run: |
+ BUNDLE_DIR="../../target/${{ matrix.settings.target }}/release/bundle/nsis"
+ for exe in "$BUNDLE_DIR"/*.exe; do
+ echo "Re-signing $(basename "$exe") for Tauri updater..."
+ rm -f "${exe}.sig"
+ pnpm tauri signer sign -k "$TAURI_SIGNING_PRIVATE_KEY" -p "$TAURI_SIGNING_PRIVATE_KEY_PASSWORD" "$exe"
+ done
+ echo "Signature files after re-signing:"
+ ls -la "$BUNDLE_DIR"/*.sig
+ env:
+ TAURI_SIGNING_PRIVATE_KEY: ${{ secrets.TAURI_SIGNING_PRIVATE_KEY }}
+ TAURI_SIGNING_PRIVATE_KEY_PASSWORD: ${{ secrets.TAURI_SIGNING_PRIVATE_KEY_PASSWORD }}
+
- name: Upload assets
uses: crabnebula-dev/cloud-release@v0
with:
diff --git a/apps/desktop/src/routes/(window-chrome)/new-main/index.tsx b/apps/desktop/src/routes/(window-chrome)/new-main/index.tsx
index 33b782298..532ee1b18 100644
--- a/apps/desktop/src/routes/(window-chrome)/new-main/index.tsx
+++ b/apps/desktop/src/routes/(window-chrome)/new-main/index.tsx
@@ -358,13 +358,31 @@ function createUpdateCheck() {
await new Promise((res) => setTimeout(res, 1000));
- const update = await updater.check();
+ let update: updater.Update | undefined;
+ try {
+ const result = await updater.check();
+ if (result) update = result;
+ } catch (e) {
+ console.error("Failed to check for updates:", e);
+ await dialog.message(
+ "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.",
+ { title: "Update Error", kind: "error" },
+ );
+ return;
+ }
+
if (!update) return;
- const shouldUpdate = await dialog.confirm(
- `Version ${update.version} of Cap is available, would you like to install it?`,
- { title: "Update Cap", okLabel: "Update", cancelLabel: "Ignore" },
- );
+ let shouldUpdate: boolean | undefined;
+ try {
+ shouldUpdate = await dialog.confirm(
+ `Version ${update.version} of Cap is available, would you like to install it?`,
+ { title: "Update Cap", okLabel: "Update", cancelLabel: "Ignore" },
+ );
+ } catch (e) {
+ console.error("Failed to show update dialog:", e);
+ return;
+ }
if (!shouldUpdate) return;
navigate("/update");
diff --git a/apps/desktop/src/routes/(window-chrome)/update.tsx b/apps/desktop/src/routes/(window-chrome)/update.tsx
index 2dddd8a40..41cee01e5 100644
--- a/apps/desktop/src/routes/(window-chrome)/update.tsx
+++ b/apps/desktop/src/routes/(window-chrome)/update.tsx
@@ -2,25 +2,46 @@ import { Button } from "@cap/ui-solid";
import { useNavigate } from "@solidjs/router";
import { getCurrentWindow, UserAttentionType } from "@tauri-apps/api/window";
import { relaunch } from "@tauri-apps/plugin-process";
-import { check } from "@tauri-apps/plugin-updater";
-import { createResource, Match, Show, Switch } from "solid-js";
+import { check, type Update } from "@tauri-apps/plugin-updater";
+import { createResource, createSignal, Match, Show, Switch } from "solid-js";
export default function () {
const navigate = useNavigate();
+ const [updateError, setUpdateError] = createSignal<string | null>(null);
const [update] = createResource(async () => {
- const update = await check();
- if (!update) return;
-
- return update;
+ try {
+ const update = await check();
+ if (!update) return;
+ return update;
+ } catch (e) {
+ console.error("Failed to check for updates:", e);
+ setUpdateError("Unable to check for updates.");
+ return;
+ }
});
return (
<div class="flex flex-col justify-center flex-1 items-center gap-[3rem] p-[1rem] text-[0.875rem] font-[400] h-full">
+ <Show when={updateError()}>
+ <div class="flex flex-col gap-4 items-center text-center max-w-md">
+ <p class="text-[--text-primary]">{updateError()}</p>
+ <p class="text-[--text-tertiary]">
+ Please download the latest version manually from cap.so/download.
+ Your data will not be lost.
+ </p>
+ <p class="text-[--text-tertiary] text-xs">
+ If this issue persists, please contact support.
+ </p>
+ <Button onClick={() => navigate("/")}>Go Back</Button>
+ </div>
+ </Show>
<Show
- when={update()}
+ when={!updateError() && update()}
fallback={
- <span class="text-[--text-tertiary]">No update available</span>
+ !updateError() && (
+ <span class="text-[--text-tertiary]">No update available</span>
+ )
}
keyed
>
@@ -61,7 +82,12 @@ export default function () {
UserAttentionType.Informational,
);
})
- .catch(() => navigate("/"));
+ .catch((e) => {
+ console.error("Failed to download/install update:", e);
+ setUpdateError(
+ "Failed to download or install the update.",
+ );
+ });
}),
);