diff --git a/src/workspaces/officerdev/src/hooks/useFileViewerPanels/useFileViewerPanels.tsx b/src/workspaces/officerdev/src/hooks/useFileViewerPanels/useFileViewerPanels.tsx index 0eddb4f0..2efab051 100644 --- a/src/workspaces/officerdev/src/hooks/useFileViewerPanels/useFileViewerPanels.tsx +++ b/src/workspaces/officerdev/src/hooks/useFileViewerPanels/useFileViewerPanels.tsx @@ -25,17 +25,35 @@ export const useFileViewerPanels = (): EphemeralPanels | null => { const [searchParams, setSearchParams] = useSearchParams(); const didClean = useRef(false); - // Clear stale ephemeral params on mount (page refresh) + /** + * On a fresh load, drop only what must not resume — which is autoplay, and nothing else. + * + * This used to delete EVERY ephemeral key on mount, under the heading "clear stale params". The effect + * of that was that `?view=` could never be linked to or survive a refresh: the page came up, the effect + * stripped the param, and you got a bare file browser with a URL that had quietly rewritten itself. + * Reported as "has never worked", and it never had — it arrived incidentally in 9acef6cf (2026-02-23) + * with the chat-about-a-file work, not as a decision about deep links. + * + * Nothing else needs clearing. `chatContext` fills the chat box via `defaultInput` and does NOT + * auto-send (`autoSend` defaults false), so restoring it costs a pre-filled input and no message. A + * `view` or `ephemeral` pointing at a file that has since gone shows the viewer's error, which now says + * what actually happened and offers a download. + * + * `ephemeral2Auto` is the exception and the reason this effect still exists: it starts audio playing. + * Reloading a page should not make sound come out of the machine. + */ useEffect(() => { if (didClean.current) return; didClean.current = true; - if (EPHEMERAL_KEYS.some((k) => searchParams.has(k))) { - setSearchParams((prev) => { + if (!searchParams.has('ephemeral2Auto')) return; + setSearchParams( + (prev) => { const next = new URLSearchParams(prev); - EPHEMERAL_KEYS.forEach((k) => next.delete(k)); + next.delete('ephemeral2Auto'); return next; - }); - } + }, + { replace: true }, + ); }, []); const viewPath = searchParams.get('view');