@devries-cameron20 / t3code Mirror · read-only / commits / 36f4e07e03
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 21, 23:30 UTC

fix(server): preview automation reports ambiguous selectors instead of calling them invalid (#34205)

Julius Marminge committed Nov 11, 2026 at 03:39 UTC 36f4e07e037083cff4eb6e497fbae37e542f29a8
2 files changed +36 -4
apps/server/src/preview/ServerBrowser.test.ts
+35 -1
@@ -219,7 +219,7 @@ function makeContext(onClose?: (context: BrowserContext) => void, initialUrl = "
219 interactiveElements: [],
220 })),
221 ariaSnapshot: vi.fn(async () => '- button "delete" [ref=e1]'),
222 - locator: vi.fn(() => {
222 + locator: vi.fn((): unknown => {
223 throw new Error("Unexpected locator action");
224 }),
225 isClosed: () => closed,
@@ -994,6 +994,40 @@ it.live(
994 ).pipe(Effect.provide(layer)),
995 );
996
997 +it.live(
998 + "reports a valid CSS selector that matches several elements as ambiguous, not invalid",
999 + () =>
1000 + Effect.scoped(
1001 + Effect.gen(function* () {
1002 + const { broker, tabId } = yield* ready;
1003 + const strict = new Error(
1004 + "locator.scrollIntoViewIfNeeded: Error: strict mode violation: locator('button[aria-label=\\'Permissions: Full access\\']') resolved to 2 elements:",
1005 + );
1006 + contexts[0]!.page.locator.mockImplementation(
1007 + () =>
1008 + new Proxy(
1009 + {},
1010 + {
1011 + get: () => async () => {
1012 + throw strict;
1013 + },
1014 + },
1015 + ),
1016 + );
1017 + const failure = yield* broker
1018 + .invoke<void>({
1019 + scope,
1020 + tabId,
1021 + operation: "click",
1022 + input: { selector: "button[aria-label='Permissions: Full access']", timeoutMs: 1_000 },
1023 + })
1024 + .pipe(Effect.flip);
1025 + expect(failure.message).not.toMatch(/invalid selector/);
1026 + expect(failure.message).toMatch(/2 elements/);
1027 + }),
1028 + ).pipe(Effect.provide(layer)),
1029 +);
1030 +
1031 it.live("reports a pending dialog without evaluating the page and resolves it explicitly", () =>
1032 Effect.scoped(
1033 Effect.gen(function* () {
apps/server/src/preview/ServerBrowserPage.ts
+1 -3
@@ -64,9 +64,7 @@ export const toOperationError = (
64 detail: timeoutMs === undefined ? undefined : { timeoutMs },
65 });
66 }
67 - if (
68 - /while parsing selector|Unknown engine|Unexpected token|strict mode violation/i.test(message)
69 - ) {
67 + if (/while parsing selector|Unknown engine|Unexpected token/i.test(message)) {
68 return new ServerBrowserOperationError({
69 tag: "PreviewAutomationInvalidSelectorError",
70 message: firstLine,