Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 13 additions & 4 deletions studio/frontend/src/components/app-sidebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -249,10 +249,16 @@ export function AppSidebar() {

async function handleDeleteThread(item: Parameters<typeof deleteChatItem>[0]) {
await deleteChatItem(item, activeThreadId, (view) => {
navigate({
// Function-form search replaces (not merges) so the deleted
// thread / compare id can't survive in the URL. The recovery
// useEffect in chat-page only fires on hard reload, which is
// why the in-tab address bar stays stale otherwise.
setActiveThreadId(null);
void navigate({
to: "/chat",
search: { new: view.newThreadNonce },
search: () => ({ new: view.newThreadNonce }),
});
closeMobileIfOpen();
});
}

Expand Down Expand Up @@ -362,7 +368,7 @@ export function AppSidebar() {
closeMobileIfOpen();
void navigate({
to: "/chat",
search: { new: createNavigationNonce() },
search: () => ({ new: createNavigationNonce() }),
});
Comment on lines 369 to 372

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Using the functional form of search is a more idiomatic and robust way to reset the URL parameters in TanStack Router, as it explicitly defines the new search state rather than merging with the existing one.

Suggested change
void navigate({
to: "/chat",
search: { new: createNavigationNonce() },
search: { new: createNavigationNonce(), thread: undefined, compare: undefined },
});
void navigate({
to: "/chat",
search: () => ({ new: createNavigationNonce() }),
});

}}
className="flex items-center gap-[6px] select-none"
Expand Down Expand Up @@ -440,7 +446,10 @@ export function AppSidebar() {
onClick={() => {
if (chatDisabled) return;
setActiveThreadId(null);
navigate({ to: "/chat", search: { new: createNavigationNonce() } });
navigate({
to: "/chat",
search: () => ({ new: createNavigationNonce() }),
});
Comment on lines +449 to +452

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Using the functional form of search is a more idiomatic and robust way to reset the URL parameters in TanStack Router, as it explicitly defines the new search state rather than merging with the existing one.

Suggested change
navigate({
to: "/chat",
search: { new: createNavigationNonce(), thread: undefined, compare: undefined },
});
void navigate({
to: "/chat",
search: () => ({ new: createNavigationNonce() }),
});

closeMobileIfOpen();
}}
/>
Expand Down
Loading