@devries-cameron20 / t3code Mirror · read-only / commits / d87ec967bf
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 empty mobile pairing payload errors (#3372)

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

Julius Marminge committed Jun 20, 2026 at 10:56 UTC d87ec967bf5ef884486479e887e74307276d3e74
2 files changed +18 -3
apps/mobile/src/features/connection/pairing.test.ts
+7 -2
@@ -1,6 +1,10 @@
1 import { describe, expect, it } from "vite-plus/test";
2
3 -import { extractPairingUrlFromQrPayload, parsePairingUrl } from "./pairing";
3 +import {
4 + extractPairingUrlFromQrPayload,
5 + PairingQrPayloadEmptyError,
6 + parsePairingUrl,
7 +} from "./pairing";
8
9 describe("extractPairingUrlFromQrPayload", () => {
10 it("trims raw pairing urls from qr payloads", () => {
@@ -18,7 +22,8 @@ describe("extractPairingUrlFromQrPayload", () => {
22 });
23
24 it("rejects empty qr payloads", () => {
21 - expect(() => extractPairingUrlFromQrPayload(" ")).toThrow(
25 + expect(() => extractPairingUrlFromQrPayload(" ")).toThrowError(PairingQrPayloadEmptyError);
26 + expect(() => extractPairingUrlFromQrPayload(" ")).toThrowError(
27 "Scanned QR code did not contain a pairing URL.",
28 );
29 });
apps/mobile/src/features/connection/pairing.ts
+11 -1
@@ -1,7 +1,17 @@
1 import { readHostedPairingRequest } from "@t3tools/shared/remote";
2 +import * as Schema from "effect/Schema";
3
4 const MOBILE_PAIRING_URL_PARAM = "pairingUrl";
5
6 +export class PairingQrPayloadEmptyError extends Schema.TaggedErrorClass<PairingQrPayloadEmptyError>()(
7 + "PairingQrPayloadEmptyError",
8 + {},
9 +) {
10 + override get message(): string {
11 + return "Scanned QR code did not contain a pairing URL.";
12 + }
13 +}
14 +
15 export function buildPairingUrl(host: string, code: string): string {
16 const h = host.trim();
17 const c = code.trim();
@@ -48,7 +58,7 @@ export function parsePairingUrl(url: string): { host: string; code: string } {
58 export function extractPairingUrlFromQrPayload(payload: string): string {
59 const trimmed = payload.trim();
60 if (!trimmed) {
51 - throw new Error("Scanned QR code did not contain a pairing URL.");
61 + throw new PairingQrPayloadEmptyError({});
62 }
63
64 try {