Appearance
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
previewis not present in the URL, preview mode is consideredfalse. - Internal navigation must not propagate
previewbetween pages.
Deeplink Behavior Matrix ​
preview=trueanduristarts withtvcasthost://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 bothidandpreview.
- Preview state calculation is handled in
src/routes/+layout.ts.- The source of truth is the URL param.
- Missing
previewforcesisPreview = falseand synchronizes thepreviewstore.
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=trueis persisted when explicitly set - verifies missing
previewforcesfalse
- verifies