retire a leftover ?cwd= from chat urls

nothing reads it and nothing writes it any more, but a refresh re-requests the
address bar verbatim, so one left over from before the path-based groups sits
there indefinitely looking like it means something. on a bare /chat it still
says which group you wanted, so upgrade it to /chat/g/<path> rather than
dropping it — an old bookmark keeps working. anywhere else the session decides
its own directory, so it is just removed. other params untouched.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
2026-08-07 00:27:41 +00:00
co-authored by Claude Opus 5
parent 942cc2b61d
commit 3e01de100e
@@ -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/<id> (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.