fix(preview): name hidden, disabled, and ambiguous click failures #7301
Closedgb1095(GitHub profile, opens in a new tab)wants to merge 8 commits into
main fromrefs/pull/7301/headopened View on GitHubgithub-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:trusted
github-actions[bot](GitHub profile, opens in a new tab) added labelssize:L
- apps/web/src/components/preview/previewAutomationErrors.ts lines 153 to 162OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -136,0 +142,21 @@142+ tabId: Schema.NullOr(PreviewTabId),143+ cause: Schema.Defect(),144+};145+146+const readTargetLookupKind = (147+ cause: unknown,148+): "missing" | "hidden" | "disabled" | "ambiguous" | null => {149+ if (typeof cause !== "object" || cause === null || !("_tag" in cause)) return null;150+ if (cause._tag === "PreviewAutomationTargetHiddenError") return "hidden";151+ if (cause._tag === "PreviewAutomationTargetDisabledError") return "disabled";152+ if (cause._tag === "PreviewAutomationTargetAmbiguousError") return "ambiguous";153+ if (cause._tag !== "PreviewAutomationTargetNotFoundError") return null;154+ if (155+ "failureKind" in cause &&156+ (cause.failureKind === "hidden" ||157+ cause.failureKind === "disabled" ||158+ cause.failureKind === "ambiguous")159+ ) {160+ return cause.failureKind;161+ }162+ return "missing";
- apps/desktop/src/preview/Manager.ts lines 3690 to 3711OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -3659,0 +3691,21 @@3691+ "PreviewAutomationTargetLookupError",3692+ (3693+ error,3694+ ): Effect.Effect<3695+ DesktopPreviewAutomationClickResult,3696+ PreviewAutomationTargetLookupError3697+ > => {3698+ if (error.failureKind === "ambiguous") {3699+ if (error.matchCount === undefined) return Effect.fail(error);3700+ return Effect.succeed<DesktopPreviewAutomationClickResult>({3701+ _tag: "NotSent",3702+ reason: "target-ambiguous",3703+ matchCount: error.matchCount,3704+ });3705+ }3706+ return Effect.succeed<DesktopPreviewAutomationClickResult>({3707+ _tag: "NotSent",3708+ reason: `target-${error.failureKind}`,3709+ });3710+ },3711+ ),
- apps/desktop/src/preview/Manager.ts lines 3569 to 3572OutdatedResolvedby t3dotgg(GitHub profile, opens in a new tab)@@ -3545,9 +3554,19 @@3554+ matchCount: number;3555+ }35453556 >(35463557 tabId,35473558 send,35483559 `(() => {35493560 try {35503561 const injected = globalThis.__t3PlaywrightInjected;35513562 const parsed = injected.parseSelector(${locatorJson});3552- const element = injected.querySelector(parsed, document, true);3553- if (!element) return { notFound: true };3563+ let element;3564+ try {3565+ element = injected.querySelector(parsed, document, true);3566+ } catch (error) {3567+ const message = String(error);3568+ if (message.toLowerCase().includes("strict mode")) {3569+ const matches = injected.querySelectorAll3570+ ? injected.querySelectorAll(parsed, document)3571+ : [];3572+ return { notFound: true, failureKind: "ambiguous", matchCount: matches.length || 2 };
- apps/web/src/components/preview/previewAutomationErrors.ts line 198OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -136,0 +178,21 @@178+ ...context,179+ failureKind: "missing",180+ });181+ case "target-hidden":182+ throw new PreviewAutomationTargetLookupHostError({183+ ...context,184+ failureKind: "hidden",185+ });186+ case "target-disabled":187+ throw new PreviewAutomationTargetLookupHostError({188+ ...context,189+ failureKind: "disabled",190+ });191+ case "target-ambiguous":192+ throw new PreviewAutomationTargetLookupHostError({193+ ...context,194+ failureKind: "ambiguous",195+ matchCount: result.matchCount,196+ });197+ default:198+ return result;
macroscopeapp[bot](GitHub profile, opens in a new tab) approved these changes
juliusmarminge added labelsmacroscope-review
- @@ -800,3 +800,16 @@800800 }801801 }802802803+export const PreviewAutomationTargetLookupFailureKind = Schema.Literals([804+ "missing",805+ "hidden",806+ "disabled",807+ "ambiguous",808+]);809+export type PreviewAutomationTargetLookupFailureKind =810+ typeof PreviewAutomationTargetLookupFailureKind.Type;811+812+export class PreviewAutomationTargetLookupError extends Schema.TaggedErrorClass<PreviewAutomationTargetLookupError>()(813+ "PreviewAutomationTargetLookupError",814+ {815+ ...PreviewAutomationRequestErrorFields,
maria-rcks closed this
maria-rcks reopened this
maria-rcks closed this
Sign in to join this conversation.
Important
Review skipped#
Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the
.coderabbit.yamlfile in this repository. To trigger a single review, invoke the@coderabbitai reviewcommand.⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID:
438ef4e0-9982-4cbd-8b1f-40df040e76d7You can disable this status message by setting the
reviews.review_statustofalsein the CodeRabbit configuration file.Use the checkbox below for a quick retry:
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
❤️ Share