feat(h5): show rotating loading tips during agent-run execution
Surface backend loading_tip SSE events in chat UI with shared tip pool and styles for long-running TKMind 智趣 tasks. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -1573,10 +1573,22 @@ type SubscribeOptions = {
|
||||
onBalance?: (update: BalanceUpdate) => void;
|
||||
};
|
||||
|
||||
export type AgentRunStreamEvent = {
|
||||
eventId?: string;
|
||||
eventType: string;
|
||||
data: unknown;
|
||||
createdAt?: string;
|
||||
};
|
||||
|
||||
type SubscribeAgentRunEventsOptions = {
|
||||
onRunEvent?: (event: AgentRunStreamEvent) => void;
|
||||
};
|
||||
|
||||
export function subscribeAgentRunEvents(
|
||||
runId: string,
|
||||
onRun: (run: AgentRun) => void,
|
||||
onError: (error: Error) => void,
|
||||
options: SubscribeAgentRunEventsOptions = {},
|
||||
): () => void {
|
||||
let closed = false;
|
||||
let activeController: AbortController | null = null;
|
||||
@@ -1634,6 +1646,20 @@ export function subscribeAgentRunEvents(
|
||||
const payload = JSON.parse(data) as { message?: string };
|
||||
throw new Error(payload.message || '后台任务失败');
|
||||
}
|
||||
if (eventName === 'run_event') {
|
||||
const payload = JSON.parse(data) as {
|
||||
eventId?: string;
|
||||
eventType?: string;
|
||||
data?: unknown;
|
||||
createdAt?: string;
|
||||
};
|
||||
options.onRunEvent?.({
|
||||
eventId: payload.eventId,
|
||||
eventType: String(payload.eventType ?? ''),
|
||||
data: payload.data,
|
||||
createdAt: payload.createdAt,
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (err) {
|
||||
|
||||
Reference in New Issue
Block a user