Skip to content

Commit 5192fe3

Browse files
committed
fix(org): keep a Home chat's query when switching to Search
1 parent 42f006e commit 5192fe3

2 files changed

Lines changed: 6 additions & 4 deletions

File tree

‎apps/sim/platform/app/(shell)/home/_components/home-conversation/home-conversation.tsx‎

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,11 @@ export function HomeConversation({ requestMode }: HomeConversationProps) {
3636
modes: [...SEARCH_MODES],
3737
changeMode: (mode) => {
3838
if (mode !== 'search') return
39-
const { pathname } = window.location
40-
const chatPath = pathname.startsWith(`${routes.search}/chat/`) ? pathname : routes.search
41-
router.push(`${chatPath}?mode=search`)
39+
const current = new URL(window.location.href)
40+
const onChat = current.pathname.startsWith(`${routes.search}/chat/`)
41+
const params = new URLSearchParams(onChat ? current.search : '')
42+
params.set('mode', 'search')
43+
router.push(`${onChat ? current.pathname : routes.search}?${params}`)
4244
},
4345
newLabel: 'New chat',
4446
canStartNew: true,

‎apps/sim/scripts/test-org-redesign-e2e.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1361,7 +1361,7 @@ async function homeChecks() {
13611361
await composer(page).fill('Say hello again from Home')
13621362
await composer(page).press('Enter')
13631363
await expect(page).toHaveURL(/\/search\/chat\/[^/?]+/, { timeout: 30_000 })
1364-
await page.getByRole('button', { name: 'New chat' }).click()
1364+
await page.getByRole('button', { name: 'New chat', exact: true }).click()
13651365
await expect(page).toHaveURL(/\/home$/)
13661366
await expect(composer(page)).toHaveValue('')
13671367
})

0 commit comments

Comments
 (0)