Skip to content

Commit 725c20d

Browse files
sshirokovclaude
andcommitted
fix(assistant): guard against stuck loading state and fix useCallback deps
- Add else branch in refreshAssistants to set loading:false on null response, preventing a stuck loading state if getAssistants() returns falsy. - Add refreshAssistants to useCallback deps array with eslint-disable, addressing the exhaustive-deps lint warning (zustand functions are stable). Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
1 parent 18e37d8 commit 725c20d

2 files changed

Lines changed: 4 additions & 6 deletions

File tree

web-app/src/hooks/useAssistant.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -222,10 +222,9 @@ export const useAssistant = create<AssistantState>((set, get) => ({
222222
try {
223223
const assistants = await getServiceHub().assistants().getAssistants()
224224
if (assistants) {
225-
set({
226-
assistants,
227-
loading: false
228-
})
225+
set({ assistants, loading: false })
226+
} else {
227+
set({ loading: false })
229228
}
230229
} catch (error) {
231230
toast.error('Failed to refresh assistants', {

web-app/src/routes/settings/assistant.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ function AssistantContent() {
3737
deleteAssistant,
3838
defaultAssistantId,
3939
setDefaultAssistant,
40-
refreshAssistants
4140
} = useAssistant()
4241
const [open, setOpen] = useState(false)
4342
const [editingKey, setEditingKey] = useState<string | null>(null)
@@ -71,7 +70,7 @@ function AssistantContent() {
7170
const handleEditClick = useCallback((assistantId: string) => {
7271
// Before opening the edit dialog, refresh the assistants to get the latest data
7372
const requestId = ++refreshRequestRef.current
74-
refreshAssistants()
73+
useAssistant.getState().refreshAssistants()
7574
.then(() => {
7675
if (refreshRequestRef.current !== requestId) return
7776
setEditingKey(assistantId)

0 commit comments

Comments
 (0)