Skip to content

Preview Mode and Deeplinks ​

Problem Statement ​

preview=true is used to render deep links in web preview mode, but this flag could leak into regular navigation through preserved query params or persisted state.

When leaked, deeplinks such as tvcasthost://load?url=... are decoded to their HTTP target unexpectedly.

Expected Behavior ​

  • Preview mode is enabled only when the current URL explicitly contains ?preview=true.
  • If preview is not present in the URL, preview mode is considered false.
  • Internal navigation must not propagate preview between pages.
  • preview=true and uri starts with tvcasthost://load?url=: decode and open the HTTP target for browser preview.
  • Any other case: keep the deeplink URI as-is and open it with _system.

Implementation Notes ​

  • Query param propagation is handled in src/lib/navigation/menuActions.ts.
    • getPreservedQueryParams() excludes both id and preview.
  • Preview state calculation is handled in src/routes/+layout.ts.
    • The source of truth is the URL param.
    • Missing preview forces isPreview = false and synchronizes the preview store.

Validation ​

  • src/lib/navigation/menuActions.spec.ts
    • verifies decode in preview mode
    • verifies non-decode when preview=false
  • src/routes/layout.load.spec.ts
    • verifies preview=true is persisted when explicitly set
    • verifies missing preview forces false