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 empty mobile pairing payload errors (#3372)

Julius Marminged87ec967bf5e
diff --git a/apps/mobile/src/features/connection/pairing.test.ts b/apps/mobile/src/features/connection/pairing.test.ts
index 028c46c1c..18b6c71a2 100644
--- a/apps/mobile/src/features/connection/pairing.test.ts
+++ b/apps/mobile/src/features/connection/pairing.test.ts
@@ -1,6 +1,10 @@
import { describe, expect, it } from "vite-plus/test";
-import { extractPairingUrlFromQrPayload, parsePairingUrl } from "./pairing";
+import {
+ extractPairingUrlFromQrPayload,
+ PairingQrPayloadEmptyError,
+ parsePairingUrl,
+} from "./pairing";
describe("extractPairingUrlFromQrPayload", () => {
it("trims raw pairing urls from qr payloads", () => {
@@ -18,7 +22,8 @@ describe("extractPairingUrlFromQrPayload", () => {
});
it("rejects empty qr payloads", () => {
- expect(() => extractPairingUrlFromQrPayload(" ")).toThrow(
+ expect(() => extractPairingUrlFromQrPayload(" ")).toThrowError(PairingQrPayloadEmptyError);
+ expect(() => extractPairingUrlFromQrPayload(" ")).toThrowError(
"Scanned QR code did not contain a pairing URL.",
);
});
diff --git a/apps/mobile/src/features/connection/pairing.ts b/apps/mobile/src/features/connection/pairing.ts
index f7362900b..910efa7f2 100644
--- a/apps/mobile/src/features/connection/pairing.ts
+++ b/apps/mobile/src/features/connection/pairing.ts
@@ -1,7 +1,17 @@
import { readHostedPairingRequest } from "@t3tools/shared/remote";
+import * as Schema from "effect/Schema";
const MOBILE_PAIRING_URL_PARAM = "pairingUrl";
+export class PairingQrPayloadEmptyError extends Schema.TaggedErrorClass<PairingQrPayloadEmptyError>()(
+ "PairingQrPayloadEmptyError",
+ {},
+) {
+ override get message(): string {
+ return "Scanned QR code did not contain a pairing URL.";
+ }
+}
+
export function buildPairingUrl(host: string, code: string): string {
const h = host.trim();
const c = code.trim();
@@ -48,7 +58,7 @@ export function parsePairingUrl(url: string): { host: string; code: string } {
export function extractPairingUrlFromQrPayload(payload: string): string {
const trimmed = payload.trim();
if (!trimmed) {
- throw new Error("Scanned QR code did not contain a pairing URL.");
+ throw new PairingQrPayloadEmptyError({});
}
try {