studio/frontend: clear stale thread/compare search after sidebar navigation
The sidebar's "delete active chat", "New Chat", and Unsloth-home-logo
all call `navigate({to: "/chat", search: {new: nonce}})`. TanStack
Router merges search params by default, so passing only `{new}` leaves
the prior `thread=<id>` (or `compare=<id>`) in the URL. The recovery
useEffect in chat-page.tsx only fires when `search.thread` changes,
which it doesn't here, so the in-tab address bar stays stale until a
hard reload kicks in.
Visible impact: deleting the currently-open chat correctly removes the
row from the sidebar, but the URL still references the deleted id.
A copied share link is broken; opening a new tab to the same URL
trips the "Chat not found" recovery toast.
Fix: pass `thread: undefined, compare: undefined` alongside `new` so
the merged search ends up as just `{new: nonce}`. This is the
documented TanStack Router idiom for removing keys.
Probe + repro: scripts/r6_sidebar_delete_chat_probe.py and
scripts/r6_repro_active_delete_url.py.
This commit is contained in:
parent
6c52697ad0
commit
b4ec1b9ab5
1 changed files with 11 additions and 3 deletions
|
|
@ -249,9 +249,14 @@ export function AppSidebar() {
|
|||
|
||||
async function handleDeleteThread(item: Parameters<typeof deleteChatItem>[0]) {
|
||||
await deleteChatItem(item, activeThreadId, (view) => {
|
||||
// Clear `thread`/`compare` explicitly: TanStack Router merges
|
||||
// search params by default, so passing only `{new}` leaves the
|
||||
// deleted thread id in the URL. The recovery useEffect in
|
||||
// chat-page only fires on hard reload, which means the in-tab
|
||||
// address bar stays stale until then.
|
||||
navigate({
|
||||
to: "/chat",
|
||||
search: { new: view.newThreadNonce },
|
||||
search: { new: view.newThreadNonce, thread: undefined, compare: undefined },
|
||||
});
|
||||
});
|
||||
}
|
||||
|
|
@ -362,7 +367,7 @@ export function AppSidebar() {
|
|||
closeMobileIfOpen();
|
||||
void navigate({
|
||||
to: "/chat",
|
||||
search: { new: createNavigationNonce() },
|
||||
search: { new: createNavigationNonce(), thread: undefined, compare: undefined },
|
||||
});
|
||||
}}
|
||||
className="flex items-center gap-[6px] select-none"
|
||||
|
|
@ -440,7 +445,10 @@ export function AppSidebar() {
|
|||
onClick={() => {
|
||||
if (chatDisabled) return;
|
||||
setActiveThreadId(null);
|
||||
navigate({ to: "/chat", search: { new: createNavigationNonce() } });
|
||||
navigate({
|
||||
to: "/chat",
|
||||
search: { new: createNavigationNonce(), thread: undefined, compare: undefined },
|
||||
});
|
||||
closeMobileIfOpen();
|
||||
}}
|
||||
/>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue