Skip to content

Commit c75d7b9

Browse files
fix(ui): fix home button not working until stream ends (#4145)
Co-authored-by: Theodore Li <theo@sim.ai>
1 parent c71ae49 commit c75d7b9

File tree

1 file changed

+3
-28
lines changed
  • apps/sim/app/workspace/[workspaceId]/home/hooks

1 file changed

+3
-28
lines changed

apps/sim/app/workspace/[workspaceId]/home/hooks/use-chat.ts

Lines changed: 3 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -963,8 +963,6 @@ export function useChat(
963963
const recoveringClientWorkflowToolIdsRef = useRef<Set<string>>(new Set())
964964
const executionStream = useExecutionStream()
965965
const isHomePage = pathname.endsWith('/home')
966-
const wasHomePageRef = useRef(isHomePage)
967-
const pendingHomeResetRef = useRef(false)
968966

969967
const setTransportIdle = useCallback(() => {
970968
sendingRef.current = false
@@ -1219,33 +1217,10 @@ export function useChat(
12191217
])
12201218

12211219
useEffect(() => {
1222-
const wasHomePage = wasHomePageRef.current
1223-
wasHomePageRef.current = isHomePage
1224-
1225-
if (!isHomePage) {
1226-
pendingHomeResetRef.current = false
1227-
return
1228-
}
1229-
if (workflowIdRef.current || !chatIdRef.current) return
1230-
1231-
const shouldHandleHomeReset = pendingHomeResetRef.current || !wasHomePage
1232-
if (!shouldHandleHomeReset) return
1233-
1234-
const hasActiveTransport =
1235-
isSending ||
1236-
sendingRef.current ||
1237-
isReconnecting ||
1238-
abortControllerRef.current !== null ||
1239-
streamReaderRef.current !== null
1240-
1241-
if (hasActiveTransport) {
1242-
pendingHomeResetRef.current = true
1243-
return
1244-
}
1245-
1246-
pendingHomeResetRef.current = false
1220+
if (workflowIdRef.current) return
1221+
if (!isHomePage || !chatIdRef.current) return
12471222
resetHomeChatState()
1248-
}, [isHomePage, isReconnecting, isSending, resetHomeChatState])
1223+
}, [isHomePage, resetHomeChatState])
12491224

12501225
useEffect(() => {
12511226
if (!chatHistory) return

0 commit comments

Comments
 (0)