Skip to content

Commit e95f748

Browse files
committed
Preserve hash on initial resource activation
1 parent eab6aed commit e95f748

File tree

1 file changed

+6
-1
lines changed
  • apps/sim/app/workspace/[workspaceId]/home

1 file changed

+6
-1
lines changed

apps/sim/app/workspace/[workspaceId]/home/home.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,7 @@ export function Home({ chatId }: HomeProps = {}) {
171171
const [editingInputValue, setEditingInputValue] = useState('')
172172
const [prevChatId, setPrevChatId] = useState(chatId)
173173
const clearEditingValue = useCallback(() => setEditingInputValue(''), [])
174+
const previousActiveResourceIdRef = useRef<string | null>(null)
174175

175176
// Clear editing value when navigating to a different chat (guarded render-phase update)
176177
if (chatId !== prevChatId) {
@@ -190,12 +191,16 @@ export function Home({ chatId }: HomeProps = {}) {
190191

191192
useEffect(() => {
192193
const url = new URL(window.location.href)
194+
const previousActiveResourceId = previousActiveResourceIdRef.current
193195
if (activeResourceId) {
194196
url.searchParams.set('resource', activeResourceId)
195197
} else {
196198
url.searchParams.delete('resource')
197199
}
198-
url.hash = ''
200+
if (previousActiveResourceId !== null && previousActiveResourceId !== activeResourceId) {
201+
url.hash = ''
202+
}
203+
previousActiveResourceIdRef.current = activeResourceId ?? null
199204
window.history.replaceState(null, '', url.toString())
200205
}, [activeResourceId])
201206

0 commit comments

Comments
 (0)