Skip to content

Open-source Grok Bot alternative for named AI teammates. Local-first desktop, web, and mobile clients with per-bot tools, instructions, and memory. Independent fork of T3 Code.

[codex] Structure relay install confirmation conflicts (#3365)

Julius Marminge8112aff7c2dc
diff --git a/apps/web/src/cloud/relayClientInstallDialog.test.ts b/apps/web/src/cloud/relayClientInstallDialog.test.ts
index 8f2a25bc3..7bd8d4967 100644
--- a/apps/web/src/cloud/relayClientInstallDialog.test.ts
+++ b/apps/web/src/cloud/relayClientInstallDialog.test.ts
@@ -4,6 +4,7 @@ import {
completeRelayClientInstallDialogClose,
finishRelayClientInstall,
readRelayClientInstallDialogState,
+ RelayClientInstallConfirmationConflictError,
reportRelayClientInstallProgress,
requestRelayClientInstallConfirmation,
resetRelayClientInstallDialogForTests,
@@ -67,4 +68,28 @@ describe("relay client install dialog coordinator", () => {
completeRelayClientInstallDialogClose();
expect(readRelayClientInstallDialogState()).toEqual({ status: "idle" });
});
+
+ it("rejects concurrent confirmation with the active install state", async () => {
+ const confirmation = requestRelayClientInstallConfirmation("2026.5.2");
+ respondToRelayClientInstallConfirmation(true);
+ await expect(confirmation).resolves.toBe(true);
+ reportRelayClientInstallProgress({ type: "progress", stage: "downloading" });
+
+ const error = await requestRelayClientInstallConfirmation("2026.6.0").then(
+ () => undefined,
+ (cause: unknown) => cause,
+ );
+
+ expect(error).toBeInstanceOf(RelayClientInstallConfirmationConflictError);
+ expect(error).toMatchObject({
+ requestedVersion: "2026.6.0",
+ activeVersion: "2026.5.2",
+ activeDialogStatus: "installing",
+ activeInstallStage: "downloading",
+ });
+ expect(error).not.toHaveProperty("cause");
+ expect((error as Error).message).toBe(
+ "Cannot confirm relay client installation 2026.6.0; installation 2026.5.2 has dialog status installing.",
+ );
+ });
});
diff --git a/apps/web/src/cloud/relayClientInstallDialog.ts b/apps/web/src/cloud/relayClientInstallDialog.ts
index 908890ad1..b1b0c6607 100644
--- a/apps/web/src/cloud/relayClientInstallDialog.ts
+++ b/apps/web/src/cloud/relayClientInstallDialog.ts
@@ -1,7 +1,23 @@
-import type {
- RelayClientInstallProgressEvent,
- RelayClientInstallProgressStage,
+import {
+ RelayClientInstallProgressStageSchema,
+ type RelayClientInstallProgressEvent,
+ type RelayClientInstallProgressStage,
} from "@t3tools/contracts";
+import * as Schema from "effect/Schema";
+
+export class RelayClientInstallConfirmationConflictError extends Schema.TaggedErrorClass<RelayClientInstallConfirmationConflictError>()(
+ "RelayClientInstallConfirmationConflictError",
+ {
+ requestedVersion: Schema.String,
+ activeVersion: Schema.String,
+ activeDialogStatus: Schema.Literals(["confirming", "installing", "closing"]),
+ activeInstallStage: Schema.optional(RelayClientInstallProgressStageSchema),
+ },
+) {
+ override get message(): string {
+ return `Cannot confirm relay client installation ${this.requestedVersion}; installation ${this.activeVersion} has dialog status ${this.activeDialogStatus}.`;
+ }
+}
export type RelayClientInstallDialogState =
| { readonly status: "idle" }
@@ -47,7 +63,17 @@ export function subscribeRelayClientInstallDialog(listener: () => void): () => v
export function requestRelayClientInstallConfirmation(version: string): Promise<boolean> {
if (state.status !== "idle") {
- return Promise.reject(new Error("A relay client installation is already in progress."));
+ const activeInstall = state.status === "closing" ? state.view : state;
+ return Promise.reject(
+ new RelayClientInstallConfirmationConflictError({
+ requestedVersion: version,
+ activeVersion: activeInstall.version,
+ activeDialogStatus: state.status,
+ ...(activeInstall.status === "installing"
+ ? { activeInstallStage: activeInstall.stage }
+ : {}),
+ }),
+ );
}
publish({ status: "confirming", version });