@devries-cameron20 / t3code Mirror · read-only / commits / 477845733d
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

Mirrored from https://github.com/Camo67/t3code.git

Synced Nov 21, 23:30 UTC

fix(web): track switch dialog no longer offers a switch that moves nothing (#27484)

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>

Julius Marminge committed Nov 11, 2026 at 11:56 UTC 477845733dbb223f68dcf822ea0fe9fe2310a2a3
3 files changed +108 -6
apps/web/src/components/settings/UpdateTrackSwitchDialog.tsx
+18 -5
@@ -18,7 +18,11 @@ import {
18 type ChannelSwitchRelease,
19 } from "../sidebar/updateEverything.logic";
20 import { isHostedByThisApp, useUpdateEverything } from "../sidebar/useUpdateEverything";
21 -import { localUpdaterStaysPut, prepareLocalTrackSwitch } from "./updateTrackSwitch.logic";
21 +import {
22 + localUpdaterStaysPut,
23 + nothingToMove,
24 + prepareLocalTrackSwitch,
25 +} from "./updateTrackSwitch.logic";
26 import {
27 AlertDialog,
28 AlertDialogClose,
@@ -82,6 +86,15 @@ function SwitchPlan({
86 const [checking, setChecking] = useState(false);
87 const everything = useUpdateEverything(switchesLocal ? release.version : null, release);
88 const label = channelSwitchLabel(release.channel);
89 + const idle = nothingToMove({
90 + label,
91 + channel: release.channel,
92 + savedChannel: updateState?.channel ?? null,
93 + switchesLocal,
94 + crossesLocal,
95 + rows: everything.rows,
96 + hasTargets: everything.hasUpdates,
97 + });
98 // This app's reinstall restarts every server it hosts, so each of their databases must allow it.
99 const localBlocked = localSwitchBlockReason(
100 APP_VERSION,
@@ -157,9 +170,7 @@ function SwitchPlan({
170 providerCount={0}
171 rows={everything.rows}
172 notes={[
160 - ...(everything.rows.length === 0 && !crossesLocal
161 - ? [`Every connected machine is already on ${label}. This only saves the track.`]
162 - : []),
173 + ...(idle.note === null ? [] : [idle.note]),
174 ...(crossesLocal && updatesOff
175 ? ["This app's updates are off here, so reinstall it yourself to switch."]
176 : []),
@@ -171,7 +182,9 @@ function SwitchPlan({
182 confirmLabel={checking ? "Checking…" : `Switch to ${label}`}
183 busy={checking}
184 disabledReason={
174 - !switchesLocal || localBlocked === null ? null : `This app cannot switch: ${localBlocked}.`
185 + switchesLocal && localBlocked !== null
186 + ? `This app cannot switch: ${localBlocked}.`
187 + : idle.disabledReason
188 }
189 onConfirm={() => void run()}
190 />
apps/web/src/components/settings/updateTrackSwitch.logic.test.ts
+66 -1
@@ -1,7 +1,11 @@
1 import type { DesktopUpdateChannel, DesktopUpdateState } from "@t3tools/contracts";
2 import { describe, expect, it } from "vite-plus/test";
3
4 -import { localUpdaterStaysPut, prepareLocalTrackSwitch } from "./updateTrackSwitch.logic";
4 +import {
5 + localUpdaterStaysPut,
6 + nothingToMove,
7 + prepareLocalTrackSwitch,
8 +} from "./updateTrackSwitch.logic";
9
10 const STABLE = "0.1.3";
11
@@ -75,6 +79,67 @@ describe("prepareLocalTrackSwitch", () => {
79 });
80 });
81
82 +describe("nothingToMove", () => {
83 + const skippedRemote = {
84 + skipped: "its server predates database checks; update it on Nightly first",
85 + };
86 + const stableSwitch = {
87 + label: "Stable",
88 + channel: "latest" as const,
89 + savedChannel: "latest" as const,
90 + switchesLocal: false,
91 + crossesLocal: false,
92 + rows: [skippedRemote],
93 + hasTargets: false,
94 + };
95 +
96 + it("disables a switch that would neither move a machine nor save a track", () => {
97 + expect(nothingToMove(stableSwitch)).toEqual({
98 + note: null,
99 + disabledReason: "No machine can switch to Stable now.",
100 + });
101 + });
102 +
103 + it("says a switch only saves the track when no machine moves", () => {
104 + const onlySaves = { note: "No machine can switch to Stable now. This only saves the track." };
105 + expect(nothingToMove({ ...stableSwitch, savedChannel: "nightly" })).toEqual({
106 + ...onlySaves,
107 + disabledReason: null,
108 + });
109 + // Before the desktop reports its saved track, confirming may still need to save it.
110 + expect(nothingToMove({ ...stableSwitch, savedChannel: null })).toEqual({
111 + ...onlySaves,
112 + disabledReason: null,
113 + });
114 + // A desktop host already on the track still gets its saved track changed.
115 + expect(nothingToMove({ ...stableSwitch, hasTargets: true })).toEqual({
116 + ...onlySaves,
117 + disabledReason: null,
118 + });
119 + // With its updater off, this app stays on the other track.
120 + expect(
121 + nothingToMove({ ...stableSwitch, rows: [], crossesLocal: true, savedChannel: "nightly" }),
122 + ).toEqual({
123 + ...onlySaves,
124 + disabledReason: null,
125 + });
126 + expect(nothingToMove({ ...stableSwitch, rows: [], savedChannel: "nightly" })).toEqual({
127 + note: "Every connected machine is already on Stable. This only saves the track.",
128 + disabledReason: null,
129 + });
130 + });
131 +
132 + it("stays out of a switch that moves a machine", () => {
133 + const none = { note: null, disabledReason: null };
134 + expect(nothingToMove({ ...stableSwitch, switchesLocal: true, crossesLocal: true })).toEqual(
135 + none,
136 + );
137 + expect(nothingToMove({ ...stableSwitch, rows: [skippedRemote, { skipped: null }] })).toEqual(
138 + none,
139 + );
140 + });
141 +});
142 +
143 describe("localUpdaterStaysPut", () => {
144 it("moves an app whose updater is off only because its policy rules out nightly", () => {
145 const blocked = { enabled: false, channelBlockedByPolicy: true as const };
apps/web/src/components/settings/updateTrackSwitch.logic.ts
+24
@@ -49,6 +49,30 @@ export async function prepareLocalTrackSwitch(
49 };
50 }
51
52 +/** When no machine moves, confirming only saves the track; when that track is already saved too,
53 + * confirming would do nothing. Track-only hosts are not rows but still get a request. */
54 +export function nothingToMove(input: {
55 + readonly label: string;
56 + readonly channel: DesktopUpdateChannel;
57 + // Null until the desktop reports it; an unknown track may still need saving.
58 + readonly savedChannel: DesktopUpdateChannel | null;
59 + readonly switchesLocal: boolean;
60 + readonly crossesLocal: boolean;
61 + readonly rows: ReadonlyArray<{ readonly skipped: string | null }>;
62 + readonly hasTargets: boolean;
63 +}): { readonly note: string | null; readonly disabledReason: string | null } {
64 + if (input.switchesLocal || input.rows.some((row) => row.skipped === null)) {
65 + return { note: null, disabledReason: null };
66 + }
67 + const reason =
68 + input.rows.length === 0 && !input.crossesLocal
69 + ? `Every connected machine is already on ${input.label}.`
70 + : `No machine can switch to ${input.label} now.`;
71 + return !input.hasTargets && input.savedChannel === input.channel
72 + ? { note: null, disabledReason: reason }
73 + : { note: `${reason} This only saves the track.`, disabledReason: null };
74 +}
75 +
76 /**
77 * Whether this app stays put while connected machines move: its updater is off, as for a .deb
78 * install or without a feed. Off only because a policy rules out its nightly channel, it moves.