Skip to content

Commit 65da3d1

Browse files
committed
fix: address critical review findings on upstream sync
1. apps/desktop/src/main.ts: remove duplicate GET_LOCAL_ENVIRONMENT_BOOTSTRAP_CHANNEL handler that shadowed the correct upstream handler with the fork's legacy { label, wsUrl } shape. The contract-compliant handler at line 1551-1563 now wins. 2. apps/desktop/src/main.ts: wire updateInstallInFlight into installDownloadedUpdate (set true on install start, cleared on error) and resolveUpdaterErrorContext so channel-switch guards and error-context reporting see the install-in-flight state. 3. apps/server/src/provider/providerStatusCache.ts: revert PROVIDER_CACHE_IDS to [codex, claudeAgent] (the set the registry actually caches). Fix ProviderRegistry.persistProvider to skip non-cached provider kinds without a non-null-assertion crash.
1 parent 9574396 commit 65da3d1

3 files changed

Lines changed: 15 additions & 22 deletions

File tree

apps/desktop/src/main.ts

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -642,6 +642,7 @@ let updaterConfigured = false;
642642
let updateState: DesktopUpdateState = initialUpdateState();
643643

644644
function resolveUpdaterErrorContext(): DesktopUpdateErrorContext {
645+
if (updateInstallInFlight) return "install";
645646
if (updateDownloadInFlight) return "download";
646647
if (updateCheckInFlight) return "check";
647648
return updateState.errorContext;
@@ -1219,13 +1220,15 @@ async function installDownloadedUpdate(): Promise<{ accepted: boolean; completed
12191220
}
12201221

12211222
isQuitting = true;
1223+
updateInstallInFlight = true;
12221224
clearUpdatePollTimer();
12231225
try {
12241226
await stopBackendAndWaitForExit();
12251227
autoUpdater.quitAndInstall();
12261228
return { accepted: true, completed: true };
12271229
} catch (error: unknown) {
12281230
const message = formatErrorMessage(error);
1231+
updateInstallInFlight = false;
12291232
isQuitting = false;
12301233
setUpdateState(reduceDesktopUpdateStateOnInstallFailure(updateState, message));
12311234
console.error(`[desktop-updater] Failed to install update: ${message}`);
@@ -1664,14 +1667,6 @@ function registerIpcHandlers(): void {
16641667
return nextState;
16651668
});
16661669

1667-
ipcMain.removeAllListeners(GET_LOCAL_ENVIRONMENT_BOOTSTRAP_CHANNEL);
1668-
ipcMain.on(GET_LOCAL_ENVIRONMENT_BOOTSTRAP_CHANNEL, (event) => {
1669-
event.returnValue = {
1670-
label: "Local environment",
1671-
wsUrl: backendWsUrl || null,
1672-
} as const;
1673-
});
1674-
16751670
ipcMain.removeHandler(PICK_FOLDER_CHANNEL);
16761671
ipcMain.handle(PICK_FOLDER_CHANNEL, async (_event, rawOptions: unknown) => {
16771672
const owner = BrowserWindow.getFocusedWindow() ?? mainWindow;

apps/server/src/provider/Layers/ProviderRegistry.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,16 +91,21 @@ export const ProviderRegistryLive = Layer.effect(
9191
);
9292
const providersRef = yield* Ref.make<ReadonlyArray<ServerProvider>>(cachedProviders);
9393

94-
const persistProvider = (provider: ServerProvider) =>
95-
writeProviderStatusCache({
96-
filePath: cachePathByProvider.get(provider.provider)!,
94+
const persistProvider = (provider: ServerProvider) => {
95+
const filePath = cachePathByProvider.get(
96+
provider.provider as (typeof PROVIDER_CACHE_IDS)[number],
97+
);
98+
if (!filePath) return Effect.void;
99+
return writeProviderStatusCache({
100+
filePath,
97101
provider,
98102
}).pipe(
99103
Effect.provideService(FileSystem.FileSystem, fileSystem),
100104
Effect.provideService(Path.Path, path),
101105
Effect.tapError(Effect.logError),
102106
Effect.ignore,
103107
);
108+
};
104109

105110
const upsertProviders = Effect.fn("upsertProviders")(function* (
106111
nextProviders: ReadonlyArray<ServerProvider>,

apps/server/src/provider/providerStatusCache.ts

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,23 +2,16 @@ import * as nodePath from "node:path";
22
import { type ServerProvider, ServerProvider as ServerProviderSchema } from "@t3tools/contracts";
33
import { Cause, Effect, FileSystem, Path, Schema } from "effect";
44

5-
export const PROVIDER_CACHE_IDS = [
6-
"codex",
7-
"claudeAgent",
8-
"copilot",
9-
"cursor",
10-
"opencode",
11-
"geminiCli",
12-
"amp",
13-
"kilo",
14-
] as const satisfies ReadonlyArray<ServerProvider["provider"]>;
5+
export const PROVIDER_CACHE_IDS = ["codex", "claudeAgent"] as const satisfies ReadonlyArray<
6+
ServerProvider["provider"]
7+
>;
158

169
const decodeProviderStatusCache = Schema.decodeUnknownEffect(
1710
Schema.fromJsonString(ServerProviderSchema),
1811
);
1912

2013
const providerOrderRank = (provider: ServerProvider["provider"]): number => {
21-
const rank = PROVIDER_CACHE_IDS.indexOf(provider);
14+
const rank = (PROVIDER_CACHE_IDS as ReadonlyArray<ServerProvider["provider"]>).indexOf(provider);
2215
return rank === -1 ? Number.MAX_SAFE_INTEGER : rank;
2316
};
2417

0 commit comments

Comments
 (0)