fix(webui): add spring feedback at the history boundary (#6322)
* fix(webui): add spring feedback at the history boundary Refs NAN-287. * fix(webui): refine history boundary states and retry feedback * fix(webui): share history loading states with subagents
This commit is contained in:
1 parent
a1bca7dc50
commit
816c9221a0
27 files changed
+910
-209
No files matched your search
@@ -14,7 +14,8 @@ export function useSubagentThread({ token, sessionKey, task, historyEnabled }: {
|
||||
}) {
|
||||
const pageVisible = usePageVisibility();
|
||||
const [thread, setThread] = useState<WebuiThreadPersistedPayload | null>(null);
|
||||
const [failed, setFailed] = useState(false);
|
||||
const [loading, setLoading] = useState(historyEnabled);
|
||||
const [error, setError] = useState<string | null>(null);
|
||||
const refreshRef = useRef<(() => void) | null>(null);
|
||||
const taskId = task.task_id;
|
||||
|
||||
@@ -27,12 +28,15 @@ export function useSubagentThread({ token, sessionKey, task, historyEnabled }: {
|
||||
const refresh = async () => {
|
||||
if (refreshing) { pending = true; return; }
|
||||
refreshing = true;
|
||||
setLoading(true);
|
||||
setError(null);
|
||||
try {
|
||||
const payload = await fetchSubagentThread(token, sessionKey, taskId, controller.signal);
|
||||
if (!cancelled) { setThread(payload); setFailed(false); }
|
||||
} catch {
|
||||
if (!cancelled) setFailed(true);
|
||||
if (!cancelled) setThread(payload);
|
||||
} catch (reason) {
|
||||
if (!cancelled) setError(reason instanceof Error ? reason.message : String(reason));
|
||||
} finally {
|
||||
if (!cancelled) setLoading(false);
|
||||
refreshing = false;
|
||||
if (pending && !cancelled) { pending = false; void refresh(); }
|
||||
}
|
||||
@@ -56,5 +60,5 @@ export function useSubagentThread({ token, sessionKey, task, historyEnabled }: {
|
||||
}, [historyEnabled, taskId, task.task_description, task.created_at, task.completed_at, task.result, thread]);
|
||||
|
||||
const retry = useCallback(() => refreshRef.current?.(), []);
|
||||
return { messages, failed, loading: historyEnabled && thread === null, activeTurnId: thread?.active_turn_id, retry };
|
||||
return { messages, loading, error, activeTurnId: thread?.active_turn_id, retry };
|
||||
}
|
||||
Reference in new issue
Block a user