fix(web): offer Update client when the app is behind the server #5254
Closedmatheustimbo(GitHub profile, opens in a new tab)wants to merge 7 commits into
main fromrefs/pull/5254/headopened View on GitHubgithub-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:unvouched
github-actions[bot](GitHub profile, opens in a new tab) added labelssize:L
- apps/web/src/components/ClientUpdateAction.tsx line 164OutdatedResolvedby cursor[bot](GitHub profile, opens in a new tab)@@ -0,0 +144,21 @@144+ }145+ if (!shouldToastDesktopUpdateActionResult(downloadResult)) return;146+ const actionError = getDesktopUpdateActionError(downloadResult);147+ if (!actionError) return;148+ toastManager.add(149+ stackedThreadToast({150+ type: "error",151+ title: "Could not download update",152+ description: actionError,153+ }),154+ );155+ });156+ }157+ if (nextAction === "none" && result.state.status === "up-to-date") {158+ toastManager.add({159+ type: "info",160+ title: "No newer desktop update found",161+ description:162+ "This build may not have a published update yet. Install a newer T3 Code desktop build to match the server.",163+ });164+ }apps/web/src/components/ClientUpdateAction.tsx line 220Resolvedby cursor[bot](GitHub profile, opens in a new tab)@@ -0,0 +13,21 @@13+import { Button } from "./ui/button";14+import { Spinner } from "./ui/spinner";15+import { stackedThreadToast, toastManager } from "./ui/toast";16+17+/**18+ * Call-to-action when this client is behind the connected server. On desktop,19+ * drives the Electron updater (check → download → install). Elsewhere, only20+ * guidance text is shown — there is no server-install path for this case.21+ */22+export function ClientUpdateAction({ label = "Update client" }: { readonly label?: string }) {23+ const updateState = useDesktopUpdateState();24+25+ const action = updateState ? resolveDesktopUpdateButtonAction(updateState) : "none";26+ const checking = updateState?.status === "checking";27+ const downloading = updateState?.status === "downloading";28+ const buttonDisabled =29+ checking ||30+ downloading ||31+ (action === "none"32+ ? !canCheckForUpdate(updateState)33+ : isDesktopUpdateButtonDisabled(updateState));
- apps/web/src/components/ClientUpdateAction.tsx line 90OutdatedResolvedby matheustimbo(GitHub profile, opens in a new tab)@@ -0,0 +70,21 @@70+ const buttonDisabled =71+ checking ||72+ downloading ||73+ (action === "none"74+ ? !canCheckForUpdate(updateState)75+ : isDesktopUpdateButtonDisabled(updateState));76+77+ const buttonLabel =78+ action === "install"79+ ? "Restart to update"80+ : action === "download"81+ ? label82+ : downloading83+ ? typeof updateState?.downloadPercent === "number"84+ ? `Downloading (${Math.floor(updateState.downloadPercent)}%)`85+ : "Downloading…"86+ : checking87+ ? "Checking…"88+ : label;89+90+ useEffect(() => {
- apps/web/src/components/ClientUpdateAction.tsx line 128OutdatedResolvedby matheustimbo(GitHub profile, opens in a new tab)@@ -0,0 +108,21 @@108+ return;109+ }110+ if (updateState.status === "up-to-date") {111+ toastManager.add({112+ type: "info",113+ title: "No newer desktop update found",114+ description:115+ "This build may not have a published update yet. Install a newer T3 Code desktop build to match the server.",116+ });117+ return;118+ }119+ if (updateState.status === "error") {120+ toastManager.add(121+ stackedThreadToast({122+ type: "error",123+ title: "Could not check for updates",124+ description: updateState.message ?? "Update check failed.",125+ }),126+ );127+ }128+ }, [awaitingCheckResult, updateState]);
- apps/web/src/components/ClientUpdateAction.tsx line 230OutdatedResolvedby matheustimbo(GitHub profile, opens in a new tab)@@ -0,0 +210,21 @@210+ title: "Could not install update",211+ description: actionError,212+ }),213+ );214+ })215+ .catch((error: unknown) => {216+ toastManager.add(217+ stackedThreadToast({218+ type: "error",219+ title: "Could not install update",220+ description: error instanceof Error ? error.message : "An unexpected error occurred.",221+ }),222+ );223+ });224+ return;225+ }226+227+ setLocalCheckPending(true);228+ void checkThenDownloadDesktopUpdate(updateState?.checkedAt ?? null).finally(() => {229+ setLocalCheckPending(false);230+ });
- apps/web/src/components/ClientUpdateAction.tsx line 180OutdatedResolvedby matheustimbo(GitHub profile, opens in a new tab)@@ -0,0 +160,21 @@160+ }161+}162+163+/**164+ * Call-to-action when this client is behind the connected server. On desktop,165+ * drives the Electron updater (check → download → install). Elsewhere, only166+ * guidance text is shown — there is no server-install path for this case.167+ */168+export function ClientUpdateAction({ label = "Update client" }: { readonly label?: string }) {169+ const updateState = useDesktopUpdateState();170+ const [localCheckPending, setLocalCheckPending] = useState(clientUpdateCheckInFlight);171+172+ useEffect(() => {173+ if (!clientUpdateCheckInFlight) {174+ return;175+ }176+ setLocalCheckPending(true);177+ void waitForClientUpdateCheckIdle().then(() => {178+ setLocalCheckPending(false);179+ });180+ }, []);
- apps/web/src/components/ClientUpdateAction.tsx lines 139 to 165Resolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -0,0 +128,21 @@128+ */129+async function checkThenDownloadDesktopUpdate(130+ baselineCheckedAt: string | null,131+): Promise<"owned" | "skipped"> {132+ const bridge = window.desktopBridge;133+ if (!bridge || typeof bridge.checkForUpdate !== "function") return "skipped";134+ if (clientUpdateCheckInFlight) return "skipped";135+136+ setClientUpdateCheckInFlight(true);137+ try {138+ const result = await bridge.checkForUpdate();139+ if (!result.checked) {140+ toastManager.add(141+ stackedThreadToast({142+ type: "error",143+ title: "Could not check for updates",144+ description: result.state.message ?? "Automatic updates are not available in this build.",145+ }),146+ );147+ return "owned";148+ }
t3dotgg(GitHub profile, opens in a new tab) closed this
Sign in to join this conversation.




Important
Review skipped#
Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the
.coderabbit.yamlfile in this repository. To trigger a single review, invoke the@coderabbitai reviewcommand.⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID:
effe6349-1df4-430b-86c6-7105db87b2e9You can disable this status message by setting the
reviews.review_statustofalsein the CodeRabbit configuration file.Use the checkbox below for a quick retry:
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
❤️ Share