← Back to Pull requests

Escape store links from in-app browsers #4274

Open
pepeladeira opened this pull request with 728 lines diff across 5 files
View on GitHub
pepeladeira pepeladeira commented on Aug 04, 2026 15:37 UTC
Author

<!-- This is an auto-generated comment: release notes by coderabbit.ai -->

Summary by CodeRabbit

New Features
Added an in-app browser escape experience for Instagram, Facebook, and TikTok.
Users can open links in an external browser or copy destination URLs.
Added localized messaging in eight languages, app store guidance, branded styling, badges, and deep-link support.
Bug Fixes
Improved redirect handling across iOS, Android, and location-based destinations.
Added clear success messaging and a selectable fallback URL when copying fails.
Invalid or unsupported links now continue safely without unnecessary external-browser redirects.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->

Diff: 728 lines (+706 / -22) across 5 files Reviewer: pepeladeira Review duration: 109287m
All Vouch review confidence checks passed
Residual risk 0.12 = Change Risk (0.74) × (1 − Review Confidence (0.84)). Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.74 · 728 lines diff across 5 files
0.74
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.96 · 5 substantive comment(s)
0.96
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 50%
83%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size diff_size
0.394
Self Review self_review
0.140
Ai Authored ai_authored
0.050
Real PR Conversation Timeline
18 items
vercel[bot] vercel[bot] commented on Aug 04, 2026 15:38 UTC
Bot

[vc]: #sqa9eKJgh5IXu5UBgB9p3hZJ0LZ2jftHlAbhPoxmuPQ=:eyJpc01vbm9yZXBvIjp0cnVlLCJ0eXBlIjoiZ2l0aHViIiwicHJvamVjdHMiOlt7Im5hbWUiOiJkdWIiLCJwcm9qZWN0SWQiOiJwcmpfYkx6SmdUUFdoQXlMSjZLS0dhWWVtQ3gxdlpWVSIsInYwIjpmYWxzZSwiaW5zcGVjdG9yVXJsIjoiaHR0cHM6Ly92ZXJjZWwuY29tL2R1YmluYy9kdWIvR0VWaWpEZ0trRnhMZ3V3ektlbVo2bmlhR1BEbSIsInByZXZpZXdVcmwiOiJkdWItZ2l0LWVzY2FwZS1zdG9yZS1saW5rcy1pbi1hcHAtYnJvd3NlcnMtZHViaW5jLnZlcmNlbC5hcHAiLCJuZXh0Q29tbWl0U3RhdHVzIjoiREVQTE9ZRUQiLCJyb290RGlyZWN0b3J5IjoiYXBwcy93ZWIifV0sInJlcXVlc3RSZXZpZXdVcmwiOiJodHRwczovL3ZlcmNlbC5jb20vdmVyY2VsLWFnZW50L3JlcXVlc3QtcmV2aWV3P293bmVyPWR1YmluYyZyZXBvPWR1YiZwcj00Mjc0In0=
The latest updates on your projects. Learn more about Vercel for GitHub.

| Project | Deployment | Actions | Updated (UTC) |
| :--- | :----- | :------ | :------ |
| <a href="https://vercel.com/dubinc/dub"><sup><img src="https://vercel.com/api/www/avatar?projectId=prj_bLzJgTPWhAyLJ6KKGaYemCx1vZVU&teamId=team_y0zuoaL8RHti4hQoucTdqRSG&s=32" width="16" height="16" align="middle" alt="" /></sup></a> dub | !Ready Ready | Preview | Aug 4, 2026 8:05pm |

<a href="https://vercel.com/vercel-agent/request-review?owner=dubinc&repo=dub&pr=4274" rel="noreferrer"><picture><source media="(prefers-color-scheme: dark)" srcset="https://agents-vade-review.vercel.sh/request-review-dark.svg"><source media="(prefers-color-scheme: light)" srcset="https://agents-vade-review.vercel.sh/request-review-light.svg"><img src="https://agents-vade-review.vercel.sh/request-review-light.svg" alt="Request Review"></picture></a>

coderabbitai[bot] coderabbitai[bot] commented on Aug 04, 2026 15:38 UTC
Bot

<!-- This is an auto-generated comment: summarize by coderabbit.ai -->
<!-- review_stack_entry_start -->

![Review Change Stack](https://app.coderabbit.ai/change-stack/dubinc/dub/pull/4274?utm_source=github_walkthrough&utm_medium=github&utm_campaign=change_stack)

<!-- review_stack_entry_end -->
<!-- This is an auto-generated comment: review paused by coderabbit.ai -->

[!NOTE]

## Reviews paused

> It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

> Use the following commands to manage reviews:

- @coderabbitai resume to resume automatic reviews.

- @coderabbitai review to trigger a single review.

> Use the checkboxes below for quick actions:

- [ ] <!-- {"checkboxId": "7f6cc2e2-2e4e-497a-8c31-c9e4573e93d1"} --> ▶️ Resume reviews

- [ ] <!-- {"checkboxId": "e9bb8d72-00e8-4f67-9cb2-caf3b22574fe"} --> 🔍 Trigger review

<!-- end of auto-generated comment: review paused by coderabbit.ai -->
<!-- walkthrough_start -->

<details>
<summary>📝 Walkthrough</summary>

Walkthrough

Adds an in-app browser escape flow for Instagram, Facebook, and TikTok browser contexts. The middleware creates encoded escape URLs, and the escape page renders localized messaging, branding, destination details, and browser or copy actions.

Changes

In-app browser escape

|Layer / File(s)|Summary|
|---|---|
|Detect and route in-app browsers <br> apps/web/lib/middleware/utils/detect-in-app-browser.ts, apps/web/lib/middleware/link.ts|The middleware detects supported in-app browsers for store destinations. It resolves the destination, records the click, and rewrites the request to an encoded escape URL.|
|Render localized escape page <br> apps/web/app/in-app-browser/[url]/page.tsx, apps/web/app/in-app-browser/[url]/translations.ts|The escape page decodes and validates request data, resolves optional link configuration, selects localized content, and renders branding and store messaging.|
|Provide browser and copy actions <br> apps/web/app/in-app-browser/[url]/action-button.tsx|The client component opens external-browser schemes, handles intent:// fallbacks, copies the destination URL, and displays a selectable URL fallback when copying fails.|

Estimated code review effort: 4 (Complex) | ~45 minutes

Sequence Diagram(s)

sequenceDiagram
  participant Request
  participant LinkMiddleware
  participant EscapePage
  participant Prisma
  participant ActionButton

  Request->>LinkMiddleware: request store destination
  LinkMiddleware->>LinkMiddleware: detect supported in-app browser
  LinkMiddleware-->>Request: rewrite to encoded escape URL
  Request->>EscapePage: load escape URL
  EscapePage->>Prisma: resolve optional link configuration
  Prisma-->>EscapePage: return configuration or destination fallback
  EscapePage->>ActionButton: provide destination and copy URLs
  ActionButton-->>Request: open external browser or copy URL

Possibly related PRs

  • dubinc/dub#3836: Modifies shared middleware redirect handling and destination selection.

  • dubinc/dub#3946: Modifies related deep-view branding, configuration, and button styling.

  • dubinc/dub#3997: Adds related intent:// fallback behavior with visibility detection.
  • Suggested reviewers: devkiran, steven-tey

    </details>

    <!-- walkthrough_end -->
    <!-- pre_merge_checks_walkthrough_start -->

    <details>
    <summary>🚥 Pre-merge checks | ✅ 4 | ❌ 1</summary>

    ❌ Failed checks (1 warning)

    | Check name | Status | Explanation | Resolution |
    | :----------------: | :--------- | :----------------------------------------------------------------------------------- | :--------------------------------------------------------------------------------- |
    | Docstring Coverage | ⚠️ Warning | Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. | Write docstrings for the functions missing them to satisfy the coverage threshold. |

    <details>
    <summary>✅ Passed checks (4 passed)</summary>

    | Check name | Status | Explanation |
    | :------------------------: | :------- | :---------------------------------------------------------------------------------------------------- |
    | Description Check | ✅ Passed | Check skipped - CodeRabbit’s high-level summary is enabled. |
    | Title check | ✅ Passed | The title clearly and concisely describes the main change: escaping store links from in-app browsers. |
    | Linked Issues check | ✅ Passed | Check skipped because no linked issues were found for this pull request. |
    | Out of Scope Changes check | ✅ Passed | Check skipped because no linked issues were found for this pull request. |

    </details>

    </details>

    <!-- pre_merge_checks_walkthrough_end -->
    <!-- finishing_touch_checkbox_start -->

    <details>
    <summary>✨ Finishing Touches 💡 1</summary>

    <!-- finishing_touch_suggestion:docstrings -->
    <details>
    <summary>📝 Generate docstrings 💡</summary>

  • <!-- {"checkboxId": "7962f53c-55bc-4827-bfbf-6a18da830691"} --> Create stacked PR

  • <!-- {"checkboxId": "3e1879ae-f29b-4d0d-8e06-d12b7ba33d98"} --> Commit on current branch
  • </details>
    <details>
    <summary>🧪 Generate unit tests (beta)</summary>

  • <!-- {"checkboxId": "f47ac10b-58cc-4372-a567-0e02b2c3d479", "radioGroupId": "utg-output-choice-group-unknown_comment_id"} --> Create PR with unit tests

  • <!-- {"checkboxId": "6ba7b810-9dad-11d1-80b4-00c04fd430c8", "radioGroupId": "utg-output-choice-group-unknown_comment_id"} --> Commit unit tests in branch escape-store-links-in-app-browsers
  • </details>

    </details>

    <!-- finishing_touch_checkbox_end -->
    <!-- tips_start -->

    ---

    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.

    <details>
    <summary>❤️ Share</summary>

  • X

  • Mastodon

  • Reddit

  • LinkedIn
  • </details>

    <sub>Comment @coderabbitai help to get the list of available commands.</sub>

    <!-- tips_end -->

    coderabbitai[bot] coderabbitai[bot] commented on code on Aug 04, 2026 15:43 UTC
    Code Review
    apps/web/app/in-app-browser/[url]/action-button.tsx:1
    @@ -0,0 +1,56 @@
    +"use client";
    +
    +import { DeepViewData } from "@/lib/zod/schemas/deep-links";
    +import { Button, useCopyToClipboard } from "@dub/ui";
    +
    +export function InAppBrowserActionButton({
    +  label,
    +  copyLabel,
    +  copiedLabel,
    +  copyUrl,
    +  destinationUrl,
    +  extBrowserScheme,
    +  buttonStyle,
    +}: {
    +  label: string;
    +  copyLabel: string;
    +  copiedLabel: string;
    +  copyUrl: string;
    +  destinationUrl: string;
    +  extBrowserScheme: string | null;
    +  buttonStyle?: DeepViewData["buttonStyle"];
    +}) {
    +  const [copied, copyToClipboard] = useCopyToClipboard();
    +
    +  const handleOpen = () => {
    +    if (extBrowserScheme) {
    +      window.location.href = extBrowserScheme;
    +      return;
    +    }
    +
    +    window.location.href = destinationUrl;
    +  };
    +
    +  return (
    +    <div className="flex flex-col gap-3">
    +      <Button
    +        text={label}
    +        className="h-12 w-full font-medium text-white"
    +        onClick={handleOpen}
    +        {...(buttonStyle && {
    +          style: {
    +            backgroundColor: buttonStyle.backgroundColor,
    +            borderRadius: buttonStyle.borderRadius,
    +            borderColor: buttonStyle.borderColor,
    +          },
    +        })}

    _📐 Maintainability & Code Quality_ | _🟡 Minor_ | _⚡ Quick win_

    A custom backgroundColor can make the label unreadable.

    Line 38 hardcodes text-white. Lines 40-46 let buttonStyle.backgroundColor override the background. A workspace that configures a light background gets white text on a light surface, and the label fails contrast.

    Derive the text color from the configured background, or let buttonStyle supply a color value as well.

    <details>
    <summary>🤖 Prompt for AI Agents</summary>

    Verify each finding against current code. Fix only still-valid issues, skip the
    rest with a brief reason, keep changes minimal, and validate.
    
    In `@apps/web/app/in-app-browser/`[url]/action-button.tsx around lines 38 - 46,
    Update the button styling in the action-button component so its text color
    remains readable when buttonStyle.backgroundColor is customized. Derive the
    label color from the configured background or apply a buttonStyle.color
    override, while preserving the existing white-text fallback when no custom
    styling is provided.
    

    </details>

    <!-- fingerprinting:phantom:medusa:komodo -->

    <!-- cr-indicator-types:potential_issue -->

    <!-- cr-comment:v1:f62ed603d2f21a38ee0eda1b -->

    <!-- This is an auto-generated reply by CodeRabbit -->

    ✅ Addressed in commit 2aaf29b

    <!-- This is an auto-generated comment by CodeRabbit -->

    coderabbitai[bot] coderabbitai[bot] commented on code on Aug 04, 2026 15:43 UTC
    Code Review
    apps/web/app/in-app-browser/[url]/action-button.tsx:1
    @@ -0,0 +1,56 @@
    +"use client";
    +
    +import { DeepViewData } from "@/lib/zod/schemas/deep-links";
    +import { Button, useCopyToClipboard } from "@dub/ui";
    +
    +export function InAppBrowserActionButton({
    +  label,
    +  copyLabel,
    +  copiedLabel,
    +  copyUrl,
    +  destinationUrl,
    +  extBrowserScheme,
    +  buttonStyle,
    +}: {
    +  label: string;
    +  copyLabel: string;
    +  copiedLabel: string;
    +  copyUrl: string;
    +  destinationUrl: string;
    +  extBrowserScheme: string | null;
    +  buttonStyle?: DeepViewData["buttonStyle"];
    +}) {
    +  const [copied, copyToClipboard] = useCopyToClipboard();
    +
    +  const handleOpen = () => {
    +    if (extBrowserScheme) {
    +      window.location.href = extBrowserScheme;
    +      return;
    +    }
    +
    +    window.location.href = destinationUrl;
    +  };
    +
    +  return (
    +    <div className="flex flex-col gap-3">
    +      <Button
    +        text={label}
    +        className="h-12 w-full font-medium text-white"
    +        onClick={handleOpen}
    +        {...(buttonStyle && {
    +          style: {
    +            backgroundColor: buttonStyle.backgroundColor,
    +            borderRadius: buttonStyle.borderRadius,
    +            borderColor: buttonStyle.borderColor,
    +          },
    +        })}
    +      />
    +      <Button
    +        text={copied ? copiedLabel : copyLabel}
    +        variant="secondary"
    +        className="h-12 w-full font-medium"
    +        onClick={() => copyToClipboard(copyUrl)}
    +      />

    _🩺 Stability & Availability_ | _🟡 Minor_ | _⚡ Quick win_

    The copy action fails silently when the Clipboard API is unavailable.

    useCopyToClipboard catches the failure, logs it with console.error, and leaves copied as false (see packages/ui/src/hooks/use-copy-to-clipboard.tsx). The label then never changes, and the user gets no signal.

    Some in-app webviews block navigator.clipboard or run outside a secure context. For a TikTok source this button is the only working path, because getExtBrowserScheme returns null for "tiktok".

    Pass throwOnError and show an error state, or render the URL as selectable text so the user can copy it manually.

    <details>
    <summary>🤖 Prompt for AI Agents</summary>

    Verify each finding against current code. Fix only still-valid issues, skip the
    rest with a brief reason, keep changes minimal, and validate.
    
    In `@apps/web/app/in-app-browser/`[url]/action-button.tsx around lines 48 - 53,
    The copy button in the action-button component fails silently when the Clipboard
    API is unavailable, leaving the user with no feedback. Update the onClick
    handler for the Button to pass throwOnError to copyToClipboard (or configure
    useCopyToClipboard with throwOnError), then add error state tracking alongside
    the existing copied state to capture and display failures. When an error occurs,
    show an error message or visual indicator to the user so they know the clipboard
    action failed, or alternatively render the copyUrl as selectable text below the
    button so users can manually select and copy the URL when the Clipboard API is
    unavailable.
    

    </details>

    <!-- fingerprinting:phantom:medusa:komodo -->

    <!-- cr-indicator-types:potential_issue -->

    <!-- cr-comment:v1:3971a6583560e930ea4cb7b9 -->

    <!-- This is an auto-generated comment by CodeRabbit -->

    ✅ Addressed in commits cbc78e2 to cde30e5

    coderabbitai[bot] coderabbitai[bot] commented on code on Aug 04, 2026 15:43 UTC
    Code Review
    apps/web/app/in-app-browser/[url]/page.tsx:1
    @@ -0,0 +1,253 @@
    +import {
    +  decodeLinkIfCaseSensitive,
    +  encodeKeyIfCaseSensitive,
    +} from "@/lib/api/links/case-sensitivity";
    +import { isGooglePlayStoreUrl } from "@/lib/middleware/utils/is-google-play-store-url";
    +import type { InAppBrowserSource } from "@/lib/middleware/utils/detect-in-app-browser";
    +import { prisma } from "@/lib/prisma";
    +import { parseDeepViewData } from "@/lib/zod/schemas/deep-links";
    +import { Grid, Wordmark } from "@dub/ui";
    +import {
    +  AndroidLogo,
    +  ArrowRight,
    +  Copy,
    +  IOSAppStore,
    +  MobilePhone,
    +} from "@dub/ui/icons";
    +import { cn, constructMetadata } from "@dub/utils";
    +import { headers } from "next/headers";
    +import Link from "next/link";
    +import { userAgent } from "next/server";
    +import { BrandLogoBadge } from "../../app.dub.co/(deeplink)/deeplink/[domain]/[[...key]]/brand-logo-badge";
    +import { InAppBrowserActionButton } from "./action-button";
    +import { getLanguage, getTranslations } from "./translations";
    +
    +export const revalidate = false;
    +
    +export function generateStaticParams() {
    +  return [];
    +}
    +
    +export const metadata = constructMetadata({
    +  title: "Open link",
    +  noIndex: true,
    +});
    +
    +const VALID_SOURCES = new Set<InAppBrowserSource>([
    +  "instagram",
    +  "facebook",
    +  "tiktok",
    +]);
    +
    +function getDestinationUrl(param: string): string {
    +  if (/^https?%3A/i.test(param)) {
    +    try {
    +      return decodeURIComponent(param);
    +    } catch {
    +      return param;
    +    }
    +  }
    +
    +  return param;
    +}
    +
    +function getExtBrowserScheme(
    +  source: InAppBrowserSource,
    +  destinationUrl: string,
    +): string | null {
    +  const encoded = encodeURIComponent(destinationUrl);
    +  if (source === "instagram") {
    +    return `instagram://extbrowser/?url=${encoded}`;
    +  }
    +  if (source === "facebook") {
    +    return `fb://extbrowser/?url=${encoded}`;
    +  }
    +  return null;
    +}

    _🎯 Functional Correctness_ | _🟡 Minor_ | _⚡ Quick win_

    TikTok gets no escape path.

    getExtBrowserScheme returns null for "tiktok". InAppBrowserActionButton then assigns window.location.href = destinationUrl in action-button.tsx Line 31. That navigation stays inside the TikTok webview, which is the condition this page exists to escape.

    The button label still reads "Open in App Store", so the primary action does not do what it states. The copy-link button remains as a fallback.

    Either hide the primary button when extBrowserScheme is null, or change the label and instructions for that case to direct the user to the webview menu.

    <details>
    <summary>🤖 Prompt for AI Agents</summary>

    Verify each finding against current code. Fix only still-valid issues, skip the
    rest with a brief reason, keep changes minimal, and validate.
    
    In `@apps/web/app/in-app-browser/`[url]/page.tsx around lines 54 - 66, The TikTok
    path in getExtBrowserScheme currently returns null, causing
    InAppBrowserActionButton to navigate within the embedded webview while still
    displaying the “Open in App Store” action. Update the related action-button
    behavior so the primary action is hidden when extBrowserScheme is null, while
    preserving the copy-link fallback.
    

    </details>

    <!-- fingerprinting:phantom:medusa:komodo -->

    <!-- cr-indicator-types:potential_issue -->

    <!-- cr-comment:v1:5f9ffb9620bc9323cd2f789c -->

    <!-- This is an auto-generated comment by CodeRabbit -->

    ✅ Addressed in commits cbc78e2 to cde30e5

    coderabbitai[bot] coderabbitai[bot] commented on code on Aug 04, 2026 15:43 UTC
    Code Review
    apps/web/app/in-app-browser/[url]/page.tsx:1
    @@ -0,0 +1,253 @@
    +import {
    +  decodeLinkIfCaseSensitive,
    +  encodeKeyIfCaseSensitive,
    +} from "@/lib/api/links/case-sensitivity";
    +import { isGooglePlayStoreUrl } from "@/lib/middleware/utils/is-google-play-store-url";
    +import type { InAppBrowserSource } from "@/lib/middleware/utils/detect-in-app-browser";
    +import { prisma } from "@/lib/prisma";
    +import { parseDeepViewData } from "@/lib/zod/schemas/deep-links";
    +import { Grid, Wordmark } from "@dub/ui";
    +import {
    +  AndroidLogo,
    +  ArrowRight,
    +  Copy,
    +  IOSAppStore,
    +  MobilePhone,
    +} from "@dub/ui/icons";
    +import { cn, constructMetadata } from "@dub/utils";
    +import { headers } from "next/headers";
    +import Link from "next/link";
    +import { userAgent } from "next/server";
    +import { BrandLogoBadge } from "../../app.dub.co/(deeplink)/deeplink/[domain]/[[...key]]/brand-logo-badge";
    +import { InAppBrowserActionButton } from "./action-button";
    +import { getLanguage, getTranslations } from "./translations";
    +
    +export const revalidate = false;
    +
    +export function generateStaticParams() {
    +  return [];
    +}
    +
    +export const metadata = constructMetadata({
    +  title: "Open link",
    +  noIndex: true,
    +});
    +
    +const VALID_SOURCES = new Set<InAppBrowserSource>([
    +  "instagram",
    +  "facebook",
    +  "tiktok",
    +]);
    +
    +function getDestinationUrl(param: string): string {
    +  if (/^https?%3A/i.test(param)) {
    +    try {
    +      return decodeURIComponent(param);
    +    } catch {
    +      return param;
    +    }
    +  }
    +
    +  return param;
    +}
    +
    +function getExtBrowserScheme(
    +  source: InAppBrowserSource,
    +  destinationUrl: string,
    +): string | null {
    +  const encoded = encodeURIComponent(destinationUrl);
    +  if (source === "instagram") {
    +    return `instagram://extbrowser/?url=${encoded}`;
    +  }
    +  if (source === "facebook") {
    +    return `fb://extbrowser/?url=${encoded}`;
    +  }
    +  return null;
    +}
    +
    +export default async function InAppBrowserEscapePage(props: {
    +  params: Promise<{ url: string }>;
    +  searchParams: Promise<{ source?: string; domain?: string; key?: string }>;
    +}) {
    +  const params = await props.params;
    +  const searchParams = await props.searchParams;
    +
    +  const destinationUrl = getDestinationUrl(params.url);
    +  const rawSource = searchParams.source;
    +  const source: InAppBrowserSource = VALID_SOURCES.has(
    +    rawSource as InAppBrowserSource,
    +  )
    +    ? (rawSource as InAppBrowserSource)
    +    : "instagram";
    +
    +  const headersList = await headers();
    +  const acceptLanguage = headersList.get("accept-language");
    +  const language = getLanguage(acceptLanguage);
    +  const t = getTranslations(language);
    +
    +  const ua = userAgent({ headers: headersList });
    +  const platform: "ios" | "android" =
    +    ua.os?.name === "Android" ? "android" : "ios";
    +
    +  const domain = searchParams.domain;
    +  const key = searchParams.key
    +    ? decodeURIComponent(searchParams.key)
    +    : undefined;

    _🩺 Stability & Availability_ | _🟠 Major_ | _⚡ Quick win_

    Remove the second decode of key; it can throw and crash the page.

    The middleware sets key with escapeUrl.searchParams.set("key", key). Next.js decodes searchParams values before it passes them to the page. decodeURIComponent at Line 94 therefore decodes a second time.

    Two consequences follow. A key that contains a literal % makes decodeURIComponent throw URIError, and the unhandled error turns the escape page into a 500. A key that contains %25 silently resolves to %, so the findUnique lookup at Line 107 misses.

    <details>
    <summary>🐛 Proposed fix to use the already-decoded value</summary>

       const domain = searchParams.domain;
    -  const key = searchParams.key
    -    ? decodeURIComponent(searchParams.key)
    -    : undefined;
    +  const key = searchParams.key;
    

    </details>

    <details>
    <summary>🤖 Prompt for AI Agents</summary>

    Verify each finding against current code. Fix only still-valid issues, skip the
    rest with a brief reason, keep changes minimal, and validate.
    
    In `@apps/web/app/in-app-browser/`[url]/page.tsx around lines 93 - 95, Remove the
    decodeURIComponent call from the key assignment in the page component, using
    searchParams.key directly when present and preserving undefined when absent.
    Keep the existing key lookup flow unchanged so literal percent characters are
    handled safely and the original decoded value reaches findUnique.
    

    </details>

    <!-- fingerprinting:phantom:medusa:komodo -->

    <!-- cr-indicator-types:potential_issue -->

    <!-- cr-comment:v1:855e0b5e972232bf41dfeb52 -->

    <!-- This is an auto-generated comment by CodeRabbit -->

    ✅ Addressed in commits cbc78e2 to cde30e5

    coderabbitai[bot] coderabbitai[bot] commented on code on Aug 04, 2026 15:43 UTC
    Code Review
    apps/web/app/in-app-browser/[url]/translations.ts:1
    @@ -0,0 +1,85 @@
    +export const translations = {
    +  en: {
    +    poweredBy: "Powered by",
    +    description: "Click below to continue to {storeName}.",
    +    openInStore: "Open in {storeName}",
    +    copyLink: "Copy link",
    +    copied: "Copied",
    +  },
    +  zh: {
    +    poweredBy: "由",
    +    description: "点击下方继续前往{storeName}。",
    +    openInStore: "在{storeName}中打开",
    +    copyLink: "复制链接",
    +    copied: "已复制",
    +  },
    +  es: {
    +    poweredBy: "Desarrollado por",
    +    description: "Haz clic abajo para continuar a {storeName}.",
    +    openInStore: "Abrir en {storeName}",
    +    copyLink: "Copiar enlace",
    +    copied: "Copiado",
    +  },
    +  fr: {
    +    poweredBy: "Propulsé par",
    +    description: "Cliquez ci-dessous pour continuer vers le {storeName}.",
    +    openInStore: "Ouvrir dans le {storeName}",

    _📐 Maintainability & Code Quality_ | _🟡 Minor_ | _⚡ Quick win_

    Interpolated store names produce ungrammatical strings in some locales.

    storeName resolves to "Google Play" or "App Store" in page.tsx Line 136. The surrounding articles are fixed per locale, so they only fit one of the two values.

  • fr Line 25 and Line 26: "le App Store" is incorrect; French elides to "l'App Store". "le Google Play" is also wrong.

  • pt Line 39 and Line 40: "na Google Play" uses a feminine article that does not fit "App Store".

  • de Line 46 and Line 47: "zum Google Play" adds an article that German does not use for that name.
  • Remove the articles from the templates, or store per-locale phrasing for each store name.

    Also applies to: 39-40, 46-47

    <details>
    <summary>🤖 Prompt for AI Agents</summary>

    Verify each finding against current code. Fix only still-valid issues, skip the
    rest with a brief reason, keep changes minimal, and validate.
    
    In `@apps/web/app/in-app-browser/`[url]/translations.ts around lines 25 - 26,
    Update the localized description and openInStore templates in the French,
    Portuguese, and German translation entries to avoid fixed articles that conflict
    with either storeName value. Remove or replace the surrounding article phrasing
    while preserving the {storeName} interpolation and the intended meaning for both
    Google Play and App Store.
    

    </details>

    <!-- fingerprinting:phantom:medusa:komodo -->

    <!-- cr-indicator-types:potential_issue -->

    <!-- cr-comment:v1:d11032ed639c1f0c7702ea4d -->

    <!-- This is an auto-generated comment by CodeRabbit -->

    ✅ Addressed in commits cbc78e2 to cde30e5

    coderabbitai[bot] coderabbitai[bot] commented on code on Aug 04, 2026 15:43 UTC
    Code Review
    apps/web/lib/middleware/link.ts:1
    @@ -405,14 +409,68 @@ export async function LinkMiddleware(req: NextRequest, ev: NextFetchEvent) {
           ),
           cookieData,
         );
    +  }
     
    -    // redirect to iOS link if it is specified and the user is on an iOS device
    -  } else if (ios && ua.os?.name === "iOS") {
    -    const finalUrl = getFinalUrl(ios, {
    -      req,
    -      ...(shouldCacheClickId && { clickId }),
    -      ...(isPartnerLink && { via: key }),
    -    });
    +  const finalUrlOptions = {
    +    req,
    +    ...(shouldCacheClickId && { clickId }),
    +    ...(isPartnerLink && { via: key }),
    +  };
    +
    +  let destinationForEscape = url;
    +  if (ios && ua.os?.name === "iOS") {
    +    destinationForEscape = ios;
    +  } else if (android && ua.os?.name === "Android") {
    +    destinationForEscape = android;
    +  } else if (geoTargeting && country && country in geoTargeting) {
    +    destinationForEscape = geoTargeting[country];
    +  }
    +
    +  const escapeFinalUrl = getFinalUrl(destinationForEscape, finalUrlOptions);
    +  const inAppBrowserSource = shouldEscapeInAppBrowser({
    +    userAgentString: ua.ua,
    +    destinationUrl: escapeFinalUrl,
    +  });

    _📐 Maintainability & Code Quality_ | _🟠 Major_ | _🏗️ Heavy lift_

    Reuse one destination resolution instead of duplicating the precedence rules.

    Lines 420-427 repeat the iOS, Android, and geo precedence that the branches at Line 472, Line 536, and Line 599 already implement. Two copies of the same rules can drift.

    Line 429 also calls getFinalUrl on every request that reaches this point. The selected branch then calls getFinalUrl again with the same inputs, so the work is done twice on the redirect hot path.

    Resolve the destination once, compute finalUrl once, and reuse both values in the branches below.

    <details>
    <summary>🤖 Prompt for AI Agents</summary>

    Verify each finding against current code. Fix only still-valid issues, skip the
    rest with a brief reason, keep changes minimal, and validate.
    
    In `@apps/web/lib/middleware/link.ts` around lines 420 - 433, Consolidate
    destination selection and final URL computation in the surrounding link
    middleware: reuse the existing precedence logic from the branches at Lines 472,
    536, and 599 instead of maintaining the duplicate destinationForEscape chain.
    Compute getFinalUrl once for the resolved destination, then pass the shared
    destination and final URL through those branches so each request avoids repeated
    resolution and URL generation.
    

    </details>

    <!-- fingerprinting:phantom:medusa:komodo -->

    <!-- cr-indicator-types:refactor_suggestion -->

    <!-- cr-comment:v1:9ad1078e07d43f45de9af0df -->

    <!-- This is an auto-generated comment by CodeRabbit -->

    ✅ Addressed in commit 2aaf29b

    coderabbitai[bot] coderabbitai[bot] commented on code on Aug 04, 2026 15:43 UTC
    Code Review
    apps/web/lib/middleware/link.ts:1
    @@ -405,14 +409,68 @@ export async function LinkMiddleware(req: NextRequest, ev: NextFetchEvent) {
           ),
           cookieData,
         );
    +  }
     
    -    // redirect to iOS link if it is specified and the user is on an iOS device
    -  } else if (ios && ua.os?.name === "iOS") {
    -    const finalUrl = getFinalUrl(ios, {
    -      req,
    -      ...(shouldCacheClickId && { clickId }),
    -      ...(isPartnerLink && { via: key }),
    -    });
    +  const finalUrlOptions = {
    +    req,
    +    ...(shouldCacheClickId && { clickId }),
    +    ...(isPartnerLink && { via: key }),
    +  };
    +
    +  let destinationForEscape = url;
    +  if (ios && ua.os?.name === "iOS") {
    +    destinationForEscape = ios;
    +  } else if (android && ua.os?.name === "Android") {
    +    destinationForEscape = android;
    +  } else if (geoTargeting && country && country in geoTargeting) {
    +    destinationForEscape = geoTargeting[country];
    +  }
    +
    +  const escapeFinalUrl = getFinalUrl(destinationForEscape, finalUrlOptions);
    +  const inAppBrowserSource = shouldEscapeInAppBrowser({
    +    userAgentString: ua.ua,
    +    destinationUrl: escapeFinalUrl,
    +  });
    +
    +  if (inAppBrowserSource) {
    +    ev.waitUntil(
    +      recordClick({
    +        req,
    +        clickId,
    +        workspaceId,
    +        linkId,
    +        domain,
    +        key,
    +        url: escapeFinalUrl,
    +        programId: cachedLink.programId,
    +        partnerId: cachedLink.partnerId,
    +        shouldCacheClickId,
    +      }),
    +    );
    +
    +    return createResponseWithCookies(
    +      NextResponse.rewrite(
    +        getInAppBrowserEscapeUrl({
    +          reqUrl: req.url,
    +          destinationUrl: escapeFinalUrl,
    +          source: inAppBrowserSource,
    +          domain,
    +          key,
    +        }),
    +        {
    +          headers: {
    +            ...DUB_HEADERS,
    +            ...(!shouldIndex && { "X-Robots-Tag": "googlebot: noindex" }),
    +          },
    +        },
    +      ),
    +      cookieData,
    +    );
    +  }

    _🗄️ Data Integrity & Integration_ | _🟠 Major_ | _⚡ Quick win_

    <details>
    <summary>🧩 Analysis chain</summary>

    🏁 Script executed:

    #!/bin/bash
    # Description: Trace cacheDeepLinkClickData producers and consumers.
    set -euo pipefail
    
    fd -t f 'cache-deep-link-click-data*' || true
    rg -n -C6 'cacheDeepLinkClickData|deepLinkClickCache|deferred deep link' --type=ts --type=tsx
    

    Repository: dubinc/dub

    Length of output: 180

    ---

    🏁 Script executed:

    #!/bin/bash
    set -euo pipefail
    
    printf 'Tracked files matching cache-deep-link-click-data:\n'
    git ls-files | grep -i 'cache-deep-link-click-data' || true
    
    printf '\nCache/write and consumer references:\n'
    rg -n -C6 'cacheDeepLinkClickData|deepLinkClickCache|deferred deep link' -e '\.(ts|tsx)$' | head -n 240
    
    printf '\nCandidate middleware outline:\n'
    ast-grep outline apps/web/lib/middleware/link.ts 2>/dev/null || true
    
    printf '\nRelevant middleware sections:\n'
    sed -n '360,580p' apps/web/lib/middleware/link.ts
    

    Repository: dubinc/dub

    Length of output: 430

    ---

    🏁 Script executed:

    #!/bin/bash
    set -euo pipefail
    
    printf 'Trackable TypeScript files (non-error filtered):\n'
    git ls-files | grep -P '\.(ts|tsx)$' | head -n 50
    
    printf '\nLocate cacheDeepLinkClickData references:\n'
    git ls-files -z | xargs -0 rg -n -C6 'cacheDeepLinkClickData|deepLinkClickCache|deferred deep link' || true
    
    printf '\nRelevant middleware sections:\n'
    sed -n '360,580p' apps/web/lib/middleware/link
    
    printf '\nFind deep link interstitial references:\n'
    git ls-files -z | xargs -0 rg -n -C4 '/deeplink|deeplink|deferred|skip_deeplink_preview' || true
    

    Repository: dubinc/dub

    Length of output: 3623

    ---

    🏁 Script executed:

    #!/bin/bash
    set -euo pipefail
    
    printf 'Find cacheDeepLinkClickData references:\n'
    git ls-files -z | xargs -0 rg -n -C8 'cacheDeepLinkClickData|deepLinkClickCache|deferred deep link' || true
    
    printf '\nInspect middleware link around escape/iOS/Android branches:\n'
    sed -n '360,580p' apps/web/lib/middleware/link.ts
    
    printf '\nFind deeplink interstitial references (focused):\n'
    rg -n -C5 '/deeplink|deeplink|skip_deeplink_preview|cacheDeepLinkClickData|deepLinkClickCache' .
    

    Repository: dubinc/dub

    Length of output: 38108

    ---

    </details>

    Preserve store-link deep-link click caching in the escape branch.

    The iOS and Android branches cache deep link click data when the destination is an App Store or Play Store URL and skip_deeplink_preview is absent. The in-app browser escape branch runs first and returns early, then bypasses those branches, so store clicks in supported in-app browsers never populate deepLinkClickCache and cannot support deferred deep linking.

    Call cacheDeepLinkClickData in the escape path before returning; use the main destination URL so later tracking can read the original application URL.

    <details>
    <summary>🤖 Prompt for AI Agents</summary>

    Verify each finding against current code. Fix only still-valid issues, skip the
    rest with a brief reason, keep changes minimal, and validate.
    
    In `@apps/web/lib/middleware/link.ts` around lines 435 - 469, Update the
    inAppBrowserSource escape branch before its early return to call
    cacheDeepLinkClickData for eligible App Store or Play Store destinations when
    skip_deeplink_preview is absent. Pass the main destination URL rather than
    escapeFinalUrl so deferred deep-link tracking can recover the original
    application URL.
    

    </details>

    <!-- fingerprinting:phantom:medusa:komodo -->

    <!-- cr-indicator-types:potential_issue -->

    <!-- cr-comment:v1:a4dfd2f30e014ed28df95922 -->

    <!-- This is an auto-generated comment by CodeRabbit -->

    ✅ Addressed in commits cbc78e2 to cde30e5

    coderabbitai[bot] coderabbitai[bot] commented on Aug 04, 2026 15:43 UTC
    Reviewer

    Actionable comments posted: 7

    <details>
    <summary>🧹 Nitpick comments (2)</summary><blockquote>

    <details>
    <summary>apps/web/app/in-app-browser/[url]/page.tsx (2)</summary><blockquote>

    36-40: _🎯 Functional Correctness_ | _🔵 Trivial_ | _⚡ Quick win_

    Falling back to "instagram" for an unknown source is misleading.

    Line 81 coerces any unrecognized source value to "instagram". The page then emits an instagram://extbrowser/ scheme and auto-navigates to it at Line 151. On a device without Instagram installed, that navigation fails and the user sees nothing happen.

    Treat an unknown source as "no scheme available" instead, so the page renders the copy-link fallback.

    <details>
    <summary>♻️ Proposed change to the source fallback</summary>

    -  const source: InAppBrowserSource = VALID_SOURCES.has(
    -    rawSource as InAppBrowserSource,
    -  )
    -    ? (rawSource as InAppBrowserSource)
    -    : "instagram";
    +  const source: InAppBrowserSource | null = VALID_SOURCES.has(
    +    rawSource as InAppBrowserSource,
    +  )
    +    ? (rawSource as InAppBrowserSource)
    +    : null;
    

    getExtBrowserScheme then needs to accept null and return null for it.
    </details>

    Also applies to: 77-81

    <details>
    <summary>🤖 Prompt for AI Agents</summary>

    Verify each finding against current code. Fix only still-valid issues, skip the
    rest with a brief reason, keep changes minimal, and validate.
    
    In `@apps/web/app/in-app-browser/`[url]/page.tsx around lines 36 - 40, The source
    fallback logic (around the VALID_SOURCES reference) currently coerces
    unrecognized source values to "instagram", which triggers a misleading
    instagram:// scheme navigation that fails if the app isn't installed. Instead of
    defaulting unknown sources to a valid scheme, treat them as null to represent
    "no scheme available". Update the getExtBrowserScheme function to accept null as
    input and return null for it, so the page falls back to rendering the copy-link
    UI for unrecognized sources rather than attempting a failed navigation.
    

    </details>

    <!-- cr-comment:v1:289ce65153e6c5a31be328ec -->

    ---

    105-130: _🚀 Performance & Scalability_ | _🔵 Trivial_ | _⚡ Quick win_

    Remove the duplicate Prisma lookup from the escape page.

    The in-app browser rewrite only passes domain and key through search params, so apps/web/app/in-app-browser/[url]/page.tsx resolves shortLink and shortDomain.deepviewData again. Move those fields into the rewrite state, or avoid re-fetching when they are already available.

    <details>
    <summary>🤖 Prompt for AI Agents</summary>

    Verify each finding against current code. Fix only still-valid issues, skip the
    rest with a brief reason, keep changes minimal, and validate.
    
    In `@apps/web/app/in-app-browser/`[url]/page.tsx around lines 105 - 130, The
    Prisma findUnique query around the domain_key lookup is redundantly fetching
    shortLink and shortDomain.deepviewData even though the rewrite already passes
    domain and key through search params. Either include shortLink and deepviewData
    in the rewrite state to make them available without re-fetching, or
    conditionally skip the findUnique query if those fields are already present.
    Preserve the decodeLinkIfCaseSensitive logic for decoding the resolved link
    data.
    

    </details>

    <!-- cr-comment:v1:82d4afc616019539bd68a738 -->

    </blockquote></details>

    </blockquote></details>

    <details>
    <summary>🤖 Prompt for all review comments with AI agents</summary>

    Verify each finding against current code. Fix only still-valid issues, skip the
    rest with a brief reason, keep changes minimal, and validate.
    
    Inline comments:
    In `@apps/web/app/in-app-browser/`[url]/action-button.tsx:
    - Around line 38-46: Update the button styling in the action-button component so
    its text color remains readable when buttonStyle.backgroundColor is customized.
    Derive the label color from the configured background or apply a
    buttonStyle.color override, while preserving the existing white-text fallback
    when no custom styling is provided.
    - Around line 48-53: The copy button in the action-button component fails
    silently when the Clipboard API is unavailable, leaving the user with no
    feedback. Update the onClick handler for the Button to pass throwOnError to
    copyToClipboard (or configure useCopyToClipboard with throwOnError), then add
    error state tracking alongside the existing copied state to capture and display
    failures. When an error occurs, show an error message or visual indicator to the
    user so they know the clipboard action failed, or alternatively render the
    copyUrl as selectable text below the button so users can manually select and
    copy the URL when the Clipboard API is unavailable.
    
    In `@apps/web/app/in-app-browser/`[url]/page.tsx:
    - Around line 54-66: The TikTok path in getExtBrowserScheme currently returns
    null, causing InAppBrowserActionButton to navigate within the embedded webview
    while still displaying the “Open in App Store” action. Update the related
    action-button behavior so the primary action is hidden when extBrowserScheme is
    null, while preserving the copy-link fallback.
    - Around line 93-95: Remove the decodeURIComponent call from the key assignment
    in the page component, using searchParams.key directly when present and
    preserving undefined when absent. Keep the existing key lookup flow unchanged so
    literal percent characters are handled safely and the original decoded value
    reaches findUnique.
    
    In `@apps/web/app/in-app-browser/`[url]/translations.ts:
    - Around line 25-26: Update the localized description and openInStore templates
    in the French, Portuguese, and German translation entries to avoid fixed
    articles that conflict with either storeName value. Remove or replace the
    surrounding article phrasing while preserving the {storeName} interpolation and
    the intended meaning for both Google Play and App Store.
    
    In `@apps/web/lib/middleware/link.ts`:
    - Around line 420-433: Consolidate destination selection and final URL
    computation in the surrounding link middleware: reuse the existing precedence
    logic from the branches at Lines 472, 536, and 599 instead of maintaining the
    duplicate destinationForEscape chain. Compute getFinalUrl once for the resolved
    destination, then pass the shared destination and final URL through those
    branches so each request avoids repeated resolution and URL generation.
    - Around line 435-469: Update the inAppBrowserSource escape branch before its
    early return to call cacheDeepLinkClickData for eligible App Store or Play Store
    destinations when skip_deeplink_preview is absent. Pass the main destination URL
    rather than escapeFinalUrl so deferred deep-link tracking can recover the
    original application URL.
    
    ---
    
    Nitpick comments:
    In `@apps/web/app/in-app-browser/`[url]/page.tsx:
    - Around line 36-40: The source fallback logic (around the VALID_SOURCES
    reference) currently coerces unrecognized source values to "instagram", which
    triggers a misleading instagram:// scheme navigation that fails if the app isn't
    installed. Instead of defaulting unknown sources to a valid scheme, treat them
    as null to represent "no scheme available". Update the getExtBrowserScheme
    function to accept null as input and return null for it, so the page falls back
    to rendering the copy-link UI for unrecognized sources rather than attempting a
    failed navigation.
    - Around line 105-130: The Prisma findUnique query around the domain_key lookup
    is redundantly fetching shortLink and shortDomain.deepviewData even though the
    rewrite already passes domain and key through search params. Either include
    shortLink and deepviewData in the rewrite state to make them available without
    re-fetching, or conditionally skip the findUnique query if those fields are
    already present. Preserve the decodeLinkIfCaseSensitive logic for decoding the
    resolved link data.
    

    </details>

    <details>
    <summary>🪄 Autofix</summary>

    Fix all unresolved CodeRabbit comments on this PR:

  • <!-- {"checkboxId": "4b0d0e0a-96d7-4f10-b296-3a18ea78f0b9"} --> Push a commit to this branch (recommended)

  • <!-- {"checkboxId": "ff5b1114-7d8c-49e6-8ac1-43f82af23a33"} --> Create a new PR with the fixes
  • </details>

    ---

    <details>
    <summary>ℹ️ Review info</summary>

    <details>
    <summary>⚙️ Run configuration</summary>

    Configuration used: defaults

    Review profile: CHILL

    Plan: Pro Plus

    Run ID: 9bcbdeeb-5283-41aa-82c4-475fee916995

    </details>

    <details>
    <summary>📥 Commits</summary>

    Reviewing files that changed from the base of the PR and between 73c58094a6dd326e4ae7db7ecd3830f7a9d6584a and 5d7026684a4581a3c309e9b6a86507838c2b83db.

    </details>

    <details>
    <summary>📒 Files selected for processing (5)</summary>

    apps/web/app/in-app-browser/[url]/action-button.tsx
    apps/web/app/in-app-browser/[url]/page.tsx
    apps/web/app/in-app-browser/[url]/translations.ts
    apps/web/lib/middleware/link.ts

  • apps/web/lib/middleware/utils/detect-in-app-browser.ts
  • </details>

    </details>

    <!-- This is an auto-generated comment by CodeRabbit for review status -->

    pepeladeira pepeladeira commented on code on Aug 04, 2026 17:57 UTC
    Code Review
    apps/web/app/in-app-browser/[url]/action-button.tsx:1
    @@ -0,0 +1,56 @@
    +"use client";
    +
    +import { DeepViewData } from "@/lib/zod/schemas/deep-links";
    +import { Button, useCopyToClipboard } from "@dub/ui";
    +
    +export function InAppBrowserActionButton({
    +  label,
    +  copyLabel,
    +  copiedLabel,
    +  copyUrl,
    +  destinationUrl,
    +  extBrowserScheme,
    +  buttonStyle,
    +}: {
    +  label: string;
    +  copyLabel: string;
    +  copiedLabel: string;
    +  copyUrl: string;
    +  destinationUrl: string;
    +  extBrowserScheme: string | null;
    +  buttonStyle?: DeepViewData["buttonStyle"];
    +}) {
    +  const [copied, copyToClipboard] = useCopyToClipboard();
    +
    +  const handleOpen = () => {
    +    if (extBrowserScheme) {
    +      window.location.href = extBrowserScheme;
    +      return;
    +    }
    +
    +    window.location.href = destinationUrl;
    +  };
    +
    +  return (
    +    <div className="flex flex-col gap-3">
    +      <Button
    +        text={label}
    +        className="h-12 w-full font-medium text-white"
    +        onClick={handleOpen}
    +        {...(buttonStyle && {
    +          style: {
    +            backgroundColor: buttonStyle.backgroundColor,
    +            borderRadius: buttonStyle.borderRadius,
    +            borderColor: buttonStyle.borderColor,
    +          },
    +        })}

    Pre-existing Deep View pattern; out of scope for this change

    coderabbitai[bot] coderabbitai[bot] commented on code on Aug 04, 2026 17:57 UTC
    Code Review
    apps/web/app/in-app-browser/[url]/action-button.tsx:1
    @@ -0,0 +1,56 @@
    +"use client";
    +
    +import { DeepViewData } from "@/lib/zod/schemas/deep-links";
    +import { Button, useCopyToClipboard } from "@dub/ui";
    +
    +export function InAppBrowserActionButton({
    +  label,
    +  copyLabel,
    +  copiedLabel,
    +  copyUrl,
    +  destinationUrl,
    +  extBrowserScheme,
    +  buttonStyle,
    +}: {
    +  label: string;
    +  copyLabel: string;
    +  copiedLabel: string;
    +  copyUrl: string;
    +  destinationUrl: string;
    +  extBrowserScheme: string | null;
    +  buttonStyle?: DeepViewData["buttonStyle"];
    +}) {
    +  const [copied, copyToClipboard] = useCopyToClipboard();
    +
    +  const handleOpen = () => {
    +    if (extBrowserScheme) {
    +      window.location.href = extBrowserScheme;
    +      return;
    +    }
    +
    +    window.location.href = destinationUrl;
    +  };
    +
    +  return (
    +    <div className="flex flex-col gap-3">
    +      <Button
    +        text={label}
    +        className="h-12 w-full font-medium text-white"
    +        onClick={handleOpen}
    +        {...(buttonStyle && {
    +          style: {
    +            backgroundColor: buttonStyle.backgroundColor,
    +            borderRadius: buttonStyle.borderRadius,
    +            borderColor: buttonStyle.borderColor,
    +          },
    +        })}

    @pepeladeira, acknowledged. This PR follows the existing Deep View styling pattern, so this change is out of scope.

    Would you like me to create a GitHub follow-up issue for configurable button text contrast?

    <sub>You are interacting with an AI system.</sub>

    <!-- This is an auto-generated reply by CodeRabbit -->

    coderabbitai[bot] coderabbitai[bot] commented on Aug 04, 2026 18:51 UTC
    Reviewer

    <details>
    <summary>🧹 Nitpick comments (1)</summary><blockquote>

    <details>
    <summary>apps/web/app/in-app-browser/[url]/page.tsx (1)</summary><blockquote>

    26-30: _📐 Maintainability & Code Quality_ | _🔵 Trivial_ | _💤 Low value_

    Remove the unused static rendering config, or document why it stays.

    InAppBrowserEscapePage reads request data with headers() before getLanguage() and userAgent(). That makes the route dynamic, so revalidate = false and generateStaticParams() do not affect rendering. Keep the config if a specific reason applies; otherwise remove it to avoid a future headers() removal accidentally enabling stale static cache.

    <details>
    <summary>🤖 Prompt for AI Agents</summary>

    Verify each finding against current code. Fix only still-valid issues, skip the
    rest with a brief reason, keep changes minimal, and validate.
    
    In `@apps/web/app/in-app-browser/`[url]/page.tsx around lines 26 - 30, Remove the
    unused revalidate export and generateStaticParams function near
    InAppBrowserEscapePage, since headers() makes this route dynamic; only retain
    them if you add documentation explaining a specific intentional purpose.
    

    </details>

    <!-- cr-comment:v1:c49ef14d4a4f634ff068188f -->

    </blockquote></details>

    </blockquote></details>

    <details>
    <summary>🤖 Prompt for all review comments with AI agents</summary>

    Verify each finding against current code. Fix only still-valid issues, skip the
    rest with a brief reason, keep changes minimal, and validate.
    
    Nitpick comments:
    In `@apps/web/app/in-app-browser/`[url]/page.tsx:
    - Around line 26-30: Remove the unused revalidate export and
    generateStaticParams function near InAppBrowserEscapePage, since headers() makes
    this route dynamic; only retain them if you add documentation explaining a
    specific intentional purpose.
    

    </details>

    ---

    <details>
    <summary>ℹ️ Review info</summary>

    <details>
    <summary>⚙️ Run configuration</summary>

    Configuration used: defaults

    Review profile: CHILL

    Plan: Pro Plus

    Run ID: 4cf66a69-b8c2-4ab2-ba63-e40ed7c77596

    </details>

    <details>
    <summary>📥 Commits</summary>

    Reviewing files that changed from the base of the PR and between cde30e5c35ed10ff8a84b33274f6b385aae162bb and 2aaf29bca29198b2aaa6ace3d602887dba02d299.

    </details>

    <details>
    <summary>📒 Files selected for processing (3)</summary>

    apps/web/app/in-app-browser/[url]/action-button.tsx
    apps/web/app/in-app-browser/[url]/page.tsx
    apps/web/lib/middleware/link.ts

    </details>

    <details>
    <summary>🚧 Files skipped from review as they are similar to previous changes (1)</summary>

    apps/web/app/in-app-browser/[url]/action-button.tsx

    </details>

    </details>

    <!-- This is an auto-generated comment by CodeRabbit for review status -->

    pepeladeira pepeladeira commented on Aug 04, 2026 18:51 UTC
    Author

    @coderabbitai full review. any breaking changes?

    coderabbitai[bot] coderabbitai[bot] commented on Aug 04, 2026 18:52 UTC
    Bot

    <!-- This is an auto-generated reply by CodeRabbit -->
    <!-- CodeRabbit review command invocation: 832f7515-563b-43bb-b18b-8992d6d470f9 -->
    <details>
    <summary>🧩 Analysis chain</summary>

    🏁 Script executed:

    #!/bin/bash
    set -euo pipefail
    
    git diff --stat HEAD^ HEAD
    git diff --find-renames -- \
      'apps/web/lib/middleware/link.ts' \
      'apps/web/lib/middleware/utils/detect-in-app-browser.ts' \
      'apps/web/app/in-app-browser/[url]/action-button.tsx' \
      'apps/web/app/in-app-browser/[url]/page.tsx' \
      'apps/web/app/in-app-browser/[url]/translations.ts'
    
    printf '\n--- Relevant symbols and references ---\n'
    ast-grep outline apps/web/lib/middleware/link.ts --items all
    ast-grep outline apps/web/lib/middleware/utils/detect-in-app-browser.ts --items all
    ast-grep outline 'apps/web/app/in-app-browser/[url]/page.tsx' --items all
    rg -n -C 3 '\b(shouldEscapeInAppBrowser|getInAppBrowserEscapeUrl|InAppBrowserEscapePage|InAppBrowserActionButton)\b' apps/web
    
    printf '\n--- Related test files ---\n'
    fd -t f . apps/web | rg -i '(in-app-browser|detect-in-app-browser|middleware.*link|link.*middleware).*(test|spec)|\.(test|spec)\.[^.]+$' || true
    

    Length of output: 14052

    ---

    🏁 Script executed:

    #!/bin/bash
    set -euo pipefail
    
    printf '%s\n' '--- PR commits and changed paths ---'
    git log --oneline HEAD^..HEAD
    git diff --name-status HEAD^ HEAD
    
    printf '%s\n' '--- Current LinkMiddleware redirect section ---'
    sed -n '300,510p' apps/web/lib/middleware/link.ts
    printf '%s\n' '--- Parent LinkMiddleware redirect section ---'
    git show HEAD^:apps/web/lib/middleware/link.ts | sed -n '300,510p'
    
    printf '%s\n' '--- In-app browser helpers ---'
    cat -n apps/web/lib/middleware/utils/detect-in-app-browser.ts
    printf '%s\n' '--- URL/store helpers ---'
    cat -n apps/web/lib/middleware/utils/is-ios-app-store-url.ts
    cat -n apps/web/lib/middleware/utils/is-google-play-store-url.ts
    cat -n apps/web/lib/middleware/utils/get-final-url.ts
    
    printf '%s\n' '--- Escape page and action component ---'
    sed -n '1,340p' 'apps/web/app/in-app-browser/[url]/page.tsx'
    sed -n '1,220p' 'apps/web/app/in-app-browser/[url]/action-button.tsx'
    
    printf '%s\n' '--- Effective diff with context ---'
    git diff --find-renames -U80 HEAD^ HEAD -- \
      'apps/web/lib/middleware/link.ts' \
      'apps/web/app/in-app-browser/[url]/page.tsx' \
      'apps/web/app/in-app-browser/[url]/action-button.tsx'
    

    Length of output: 57039

    ---

    🏁 Script executed:

    #!/bin/bash
    set -euo pipefail
    
    base="$(git merge-base HEAD main)"
    printf 'Merge base: %s\n' "$base"
    printf '%s\n' '--- Complete PR changed paths ---'
    git diff --name-status "$base" HEAD
    printf '%s\n' '--- Complete PR diff summary ---'
    git diff --stat "$base" HEAD
    
    printf '%s\n' '--- Complete PR diff: in-app-browser and middleware ---'
    git diff -U50 "$base" HEAD -- \
      'apps/web/lib/middleware/link.ts' \
      'apps/web/lib/middleware/utils/detect-in-app-browser.ts' \
      'apps/web/app/in-app-browser/[url]/page.tsx' \
      'apps/web/app/in-app-browser/[url]/action-button.tsx' \
      'apps/web/app/in-app-browser/[url]/translations.ts'
    
    printf '%s\n' '--- Middleware and route configuration references ---'
    rg -n -C 4 'LinkMiddleware|matcher|in-app-browser|/deeplink/' \
      apps/web/middleware.ts apps/web/next.config.* apps/web 2>/dev/null || true
    
    printf '%s\n' '--- Target branch versions, when files exist ---'
    for f in \
      'apps/web/lib/middleware/utils/detect-in-app-browser.ts' \
      'apps/web/app/in-app-browser/[url]/page.tsx' \
      'apps/web/app/in-app-browser/[url]/action-button.tsx' \
      'apps/web/app/in-app-browser/[url]/translations.ts'
    do
      if git cat-file -e "$base:$f" 2>/dev/null; then
        printf '\n--- %s at merge base ---\n' "$f"
        git show "$base:$f" | sed -n '1,360p'
      fi
    done
    
    printf '%s\n' '--- URL construction edge cases ---'
    python3 - <<'PY'
    from urllib.parse import quote
    for u in [
        "https://play.google.com/store/apps/details?id=com.example#reviews",
        "https://apps.apple.com/us/app/example/id123?pt=1#privacy",
        "https://play.google.com:8443/store/apps/details?id=com.example",
    ]:
        print(u)
        print("encoded path:", quote(u, safe=""))
    PY
    

    Length of output: 45658

    ---

    🏁 Script executed:

    #!/bin/bash
    set -euo pipefail
    
    printf '%s\n' '--- Middleware dispatch and application-route exclusions ---'
    sed -n '1,115p' apps/web/middleware.ts
    sed -n '1,95p' apps/web/lib/middleware/app.ts
    
    printf '%s\n' '--- Domain and request parsing behavior ---'
    rg -n -C 3 '\bAPP_DOMAIN\b|function isDubDomain|const isDubDomain|export.*isDubDomain' \
      packages apps/web 2>/dev/null || true
    cat -n apps/web/lib/middleware/utils/parse.ts
    
    printf '%s\n' '--- Existing test conventions for middleware utilities ---'
    fd -t f -e ts -e tsx apps/web | rg '(test|spec)\.(ts|tsx)$' | head -80
    rg -n -C 2 'NextRequest|NextFetchEvent|LinkMiddleware|userAgent\(' \
      apps/web/tests apps/web/lib --glob '*.{test,spec}.ts' 2>/dev/null || true
    
    printf '%s\n' '--- Package scripts and test tooling declarations ---'
    for f in package.json apps/web/package.json; do
      if [ -f "$f" ]; then
        printf '\n--- %s ---\n' "$f"
        sed -n '1,220p' "$f"
      fi
    done
    

    Length of output: 64519

    ---

    </details>

    @pepeladeira I completed the full review.

    I found no breaking public API or redirect-contract change.

    The PR intentionally changes behavior for Instagram, Facebook, and TikTok in-app browsers when the selected destination is an App Store or Google Play URL. These requests now render the escape page instead of continuing through the normal store-link flow.

    For all other requests, the existing destination priority remains unchanged:

    1. iOS destination on iOS.
    2. Android destination on Android.
    3. Geo-targeted destination.
    4. Default destination.

    The implementation preserves click recording, cookies, tracking parameters, and deferred deep-link caching before it enters the escape flow.

    I did not identify a blocking code defect. The main release risk is device-specific behavior for the Instagram, Facebook, and Android intent:// external-browser schemes. Validate those paths on physical iOS and Android devices before release. Focused automated coverage for user-agent detection and escape URL construction would also reduce regression risk.

    <details>
    <summary>✅ Action performed</summary>

    Full review finished.

    </details>

    coderabbitai[bot] coderabbitai[bot] commented on code on Aug 04, 2026 18:57 UTC
    Code Review
    apps/web/app/in-app-browser/[url]/translations.ts:1
    @@ -0,0 +1,108 @@
    +export const translations = {
    +  en: {
    +    poweredBy: "Powered by",
    +    description: "Click below to continue to {storeName}.",
    +    manualEscapeDescription:
    +      "Copy the link, then open it in your browser to continue to {storeName}.",
    +    openInStore: "Open in {storeName}",
    +    copyLink: "Copy link",
    +    copied: "Copied",
    +    copyFailed: "Couldn't copy — select the link below",
    +  },
    +  zh: {
    +    poweredBy: "由",
    +    description: "点击下方继续前往{storeName}。",
    +    manualEscapeDescription: "请复制链接,然后在浏览器中打开以继续前往{storeName}。",
    +    openInStore: "在{storeName}中打开",
    +    copyLink: "复制链接",
    +    copied: "已复制",
    +    copyFailed: "无法复制 — 请选择下方链接",
    +  },
    +  es: {
    +    poweredBy: "Desarrollado por",
    +    description: "Haz clic abajo para continuar a {storeName}.",
    +    manualEscapeDescription:
    +      "Copia el enlace y ábrelo en tu navegador para continuar a {storeName}.",
    +    openInStore: "Abrir en {storeName}",
    +    copyLink: "Copiar enlace",
    +    copied: "Copiado",
    +    copyFailed: "No se pudo copiar — selecciona el enlace abajo",
    +  },
    +  fr: {
    +    poweredBy: "Propulsé par",
    +    description: "Cliquez ci-dessous pour continuer vers {storeName}.",
    +    manualEscapeDescription:
    +      "Copiez le lien, puis ouvrez-le dans votre navigateur pour continuer vers {storeName}.",
    +    openInStore: "Ouvrir dans {storeName}",
    +    copyLink: "Copier le lien",
    +    copied: "Copié",
    +    copyFailed: "Impossible de copier — sélectionnez le lien ci-dessous",
    +  },
    +  it: {
    +    poweredBy: "Offerto da",
    +    description: "Clicca qui sotto per continuare su {storeName}.",
    +    manualEscapeDescription:
    +      "Copia il link e aprilo nel browser per continuare su {storeName}.",
    +    openInStore: "Apri in {storeName}",
    +    copyLink: "Copia link",
    +    copied: "Copiato",
    +    copyFailed: "Impossibile copiare — seleziona il link qui sotto",
    +  },
    +  pt: {
    +    poweredBy: "Desenvolvido por",
    +    description: "Clique abaixo para continuar em {storeName}.",
    +    manualEscapeDescription:
    +      "Copie o link e abra no navegador para continuar em {storeName}.",
    +    openInStore: "Abrir em {storeName}",
    +    copyLink: "Copiar link",
    +    copied: "Copiado",
    +    copyFailed: "Não foi possível copiar — selecione o link abaixo",
    +  },
    +  de: {
    +    poweredBy: "Bereitgestellt von",
    +    description: "Klicke unten, um zu {storeName} zu gelangen.",
    +    manualEscapeDescription:
    +      "Kopiere den Link und öffne ihn im Browser, um zu {storeName} zu gelangen.",
    +    openInStore: "In {storeName} öffnen",
    +    copyLink: "Link kopieren",
    +    copied: "Kopiert",
    +    copyFailed: "Kopieren fehlgeschlagen — Link unten auswählen",
    +  },
    +  tr: {
    +    poweredBy: "tarafından desteklenmektedir",
    +    poweredByOrder: "inverted",
    +    description: "{storeName} için aşağıya tıklayın.",
    +    manualEscapeDescription:
    +      "Bağlantıyı kopyalayıp tarayıcınızda açarak {storeName} ile devam edin.",
    +    openInStore: "{storeName} içinde aç",
    +    copyLink: "Bağlantıyı kopyala",
    +    copied: "Kopyalandı",
    +    copyFailed: "Kopyalanamadı — aşağıdaki bağlantıyı seçin",
    +  },
    +} as const;
    +
    +export type Language = keyof typeof translations;
    +
    +export function getLanguage(acceptLanguage?: string | null): Language {
    +  if (!acceptLanguage) return "en";
    +
    +  const languages = acceptLanguage
    +    .toLowerCase()
    +    .split(",")
    +    .map((lang) => {
    +      const [code] = lang.trim().split(";");
    +      return code.split("-")[0];
    +    });
    +
    +  for (const lang of languages) {
    +    if (lang in translations) {
    +      return lang as Language;
    +    }
    +  }
    +
    +  return "en";
    +}

    _🩺 Stability & Availability_ | _🟡 Minor_ | _⚡ Quick win_

    Replace the in check with an own-property check.

    in also matches inherited Object.prototype keys. A request with Accept-Language: constructor makes getLanguage return "constructor", and getTranslations then returns Object. On the escape page, t.description is undefined, so .replace("{storeName}", storeName) at page.tsx Line 183 throws and the page returns a 500.

    Use Object.prototype.hasOwnProperty.call or a Set of valid codes.

    <details>
    <summary>🐛 Proposed fix</summary>

       for (const lang of languages) {
    -    if (lang in translations) {
    +    if (Object.prototype.hasOwnProperty.call(translations, lang)) {
           return lang as Language;
         }
       }
    

    </details>

    <!-- suggestion_start -->

    <details>
    <summary>📝 Committable suggestion</summary>

    ‼️ IMPORTANT

    Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

    export function getLanguage(acceptLanguage?: string | null): Language {
      if (!acceptLanguage) return "en";
    
      const languages = acceptLanguage
        .toLowerCase()
        .split(",")
        .map((lang) => {
          const [code] = lang.trim().split(";");
          return code.split("-")[0];
        });
    
      for (const lang of languages) {
        if (Object.prototype.hasOwnProperty.call(translations, lang)) {
          return lang as Language;
        }
      }
    
      return "en";
    }
    

    </details>

    <!-- suggestion_end -->

    <details>
    <summary>🤖 Prompt for AI Agents</summary>

    Verify each finding against current code. Fix only still-valid issues, skip the
    rest with a brief reason, keep changes minimal, and validate.
    
    In `@apps/web/app/in-app-browser/`[url]/translations.ts around lines 86 - 104,
    Update the language validation in getLanguage to accept only translation codes
    that are own properties of translations, using
    Object.prototype.hasOwnProperty.call or an equivalent valid-code Set. Preserve
    the existing fallback to "en" and return behavior for supported language codes.
    

    </details>

    <!-- fingerprinting:phantom:medusa:komodo -->

    <!-- cr-indicator-types:potential_issue -->

    <!-- cr-comment:v1:ccb5c97ad980fed463770a60 -->

    <!-- This is an auto-generated comment by CodeRabbit -->

    ✅ Addressed in commit 5c3701b

    coderabbitai[bot] coderabbitai[bot] commented on Aug 04, 2026 18:57 UTC
    Reviewer

    Actionable comments posted: 1

    <details>
    <summary>🤖 Prompt for all review comments with AI agents</summary>

    Verify each finding against current code. Fix only still-valid issues, skip the
    rest with a brief reason, keep changes minimal, and validate.
    
    Inline comments:
    In `@apps/web/app/in-app-browser/`[url]/translations.ts:
    - Around line 86-104: Update the language validation in getLanguage to accept
    only translation codes that are own properties of translations, using
    Object.prototype.hasOwnProperty.call or an equivalent valid-code Set. Preserve
    the existing fallback to "en" and return behavior for supported language codes.
    

    </details>

    <details>
    <summary>🪄 Autofix</summary>

    Fix all unresolved CodeRabbit comments on this PR:

  • <!-- {"checkboxId": "4b0d0e0a-96d7-4f10-b296-3a18ea78f0b9"} --> Push a commit to this branch (recommended)

  • <!-- {"checkboxId": "ff5b1114-7d8c-49e6-8ac1-43f82af23a33"} --> Create a new PR with the fixes
  • </details>

    ---

    <details>
    <summary>ℹ️ Review info</summary>

    <details>
    <summary>⚙️ Run configuration</summary>

    Configuration used: defaults

    Review profile: CHILL

    Plan: Pro Plus

    Run ID: 512a4df5-220b-4b9f-be5a-91057bbbdaac

    </details>

    <details>
    <summary>📥 Commits</summary>

    Reviewing files that changed from the base of the PR and between cbc78e2c93d4e6ec3218d3b9b919807839570646 and 2aaf29bca29198b2aaa6ace3d602887dba02d299.

    </details>

    <details>
    <summary>📒 Files selected for processing (5)</summary>

    apps/web/app/in-app-browser/[url]/action-button.tsx
    apps/web/app/in-app-browser/[url]/page.tsx
    apps/web/app/in-app-browser/[url]/translations.ts
    apps/web/lib/middleware/link.ts

  • apps/web/lib/middleware/utils/detect-in-app-browser.ts
  • </details>

    </details>

    <!-- This is an auto-generated comment by CodeRabbit for review status -->

    Reviewers
    Assignees
    pepeladeira pepeladeira
    Labels
    risk: low confidence: 84.0% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 74.3% (HIGH) · Higher = larger blast radius
    74.3%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 84.0% · Lower = rushed or shallow review
    84.0%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 11.9% · Safe to merge
    11.9%
    Repository