diff --git a/src/apps/officer-web/Screens/Dashboard/ChatHistory/index.tsx b/src/apps/officer-web/Screens/Dashboard/ChatHistory/index.tsx index 44a726fd..4d583284 100644 --- a/src/apps/officer-web/Screens/Dashboard/ChatHistory/index.tsx +++ b/src/apps/officer-web/Screens/Dashboard/ChatHistory/index.tsx @@ -64,6 +64,22 @@ export const SessionListPage = ({ isNew }: SessionListPageProps) => { } }, [rawWorkspace.isLoaded, workspace.value, rawWorkspace.value]); + // Retire a legacy `?cwd=`. Nothing reads it any more and nothing writes it, but a refresh re-requests + // the address bar verbatim — so one left over from before the path-based groups sits there forever, + // looking like it means something. On a bare /chat it still says which group you wanted, so upgrade + // it to the path form rather than dropping it; anywhere else the session decides its own directory + // and the parameter is simply removed. Other params are left alone. + useEffect(() => { + const params = new URLSearchParams(window.location.search); + const legacyCwd = params.get('cwd'); + if (legacyCwd === null) return; + params.delete('cwd'); + const rest = params.toString(); + const canBeUpgraded = !sessionId && !isNew && !groupCwd && legacyCwd.startsWith('/'); + const path = canBeUpgraded ? chatListPath(legacyCwd) : window.location.pathname; + navigate(`${path}${rest ? `?${rest}` : ''}`, { replace: true }); + }, [sessionId, isNew, groupCwd, navigate]); + // Fresh /chat/ (deep-link or refresh): all we have is the id. Resolve the session by id — the // backend scans project groups — so the cwd picker lands on its real dir AND the chat resumes, exactly // as clicking it from the list would. Guarded so it never clobbers an already-loaded selection.