@devries-cameron20 / t3code Mirror · read-only / commits / 8112aff7c2
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 24, 22:45 UTC

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

Co-authored-by: codex <codex@users.noreply.github.com>

Julius Marminge committed Jun 20, 2026 at 11:05 UTC 8112aff7c2dc8a82447920e6fde232565149d32c
2 files changed +55 -4
apps/web/src/cloud/relayClientInstallDialog.test.ts
+25
@@ -4,6 +4,7 @@ import {
4 completeRelayClientInstallDialogClose,
5 finishRelayClientInstall,
6 readRelayClientInstallDialogState,
7 + RelayClientInstallConfirmationConflictError,
8 reportRelayClientInstallProgress,
9 requestRelayClientInstallConfirmation,
10 resetRelayClientInstallDialogForTests,
@@ -67,4 +68,28 @@ describe("relay client install dialog coordinator", () => {
68 completeRelayClientInstallDialogClose();
69 expect(readRelayClientInstallDialogState()).toEqual({ status: "idle" });
70 });
71 +
72 + it("rejects concurrent confirmation with the active install state", async () => {
73 + const confirmation = requestRelayClientInstallConfirmation("2026.5.2");
74 + respondToRelayClientInstallConfirmation(true);
75 + await expect(confirmation).resolves.toBe(true);
76 + reportRelayClientInstallProgress({ type: "progress", stage: "downloading" });
77 +
78 + const error = await requestRelayClientInstallConfirmation("2026.6.0").then(
79 + () => undefined,
80 + (cause: unknown) => cause,
81 + );
82 +
83 + expect(error).toBeInstanceOf(RelayClientInstallConfirmationConflictError);
84 + expect(error).toMatchObject({
85 + requestedVersion: "2026.6.0",
86 + activeVersion: "2026.5.2",
87 + activeDialogStatus: "installing",
88 + activeInstallStage: "downloading",
89 + });
90 + expect(error).not.toHaveProperty("cause");
91 + expect((error as Error).message).toBe(
92 + "Cannot confirm relay client installation 2026.6.0; installation 2026.5.2 has dialog status installing.",
93 + );
94 + });
95 });
apps/web/src/cloud/relayClientInstallDialog.ts
+30 -4
@@ -1,7 +1,23 @@
1 -import type {
2 - RelayClientInstallProgressEvent,
3 - RelayClientInstallProgressStage,
1 +import {
2 + RelayClientInstallProgressStageSchema,
3 + type RelayClientInstallProgressEvent,
4 + type RelayClientInstallProgressStage,
5 } from "@t3tools/contracts";
6 +import * as Schema from "effect/Schema";
7 +
8 +export class RelayClientInstallConfirmationConflictError extends Schema.TaggedErrorClass<RelayClientInstallConfirmationConflictError>()(
9 + "RelayClientInstallConfirmationConflictError",
10 + {
11 + requestedVersion: Schema.String,
12 + activeVersion: Schema.String,
13 + activeDialogStatus: Schema.Literals(["confirming", "installing", "closing"]),
14 + activeInstallStage: Schema.optional(RelayClientInstallProgressStageSchema),
15 + },
16 +) {
17 + override get message(): string {
18 + return `Cannot confirm relay client installation ${this.requestedVersion}; installation ${this.activeVersion} has dialog status ${this.activeDialogStatus}.`;
19 + }
20 +}
21
22 export type RelayClientInstallDialogState =
23 | { readonly status: "idle" }
@@ -47,7 +63,17 @@ export function subscribeRelayClientInstallDialog(listener: () => void): () => v
63
64 export function requestRelayClientInstallConfirmation(version: string): Promise<boolean> {
65 if (state.status !== "idle") {
50 - return Promise.reject(new Error("A relay client installation is already in progress."));
66 + const activeInstall = state.status === "closing" ? state.view : state;
67 + return Promise.reject(
68 + new RelayClientInstallConfirmationConflictError({
69 + requestedVersion: version,
70 + activeVersion: activeInstall.version,
71 + activeDialogStatus: state.status,
72 + ...(activeInstall.status === "installing"
73 + ? { activeInstallStage: activeInstall.stage }
74 + : {}),
75 + }),
76 + );
77 }
78
79 publish({ status: "confirming", version });