feat(chat): add manual refresh for delivered agents

This commit is contained in:
鲨鱼辣椒 committed 2026-09-28 13:06:38 +08:00
1 parent 862477f9d4
commit 2b1943dd0f
13 files changed
+517 -59

No files matched your search

+11 -1
View File
@@ -1,4 +1,4 @@
import { ArrowUpRight, Loader2, X } from 'lucide-react';
import { ArrowUpRight, Loader2, RefreshCw, X } from 'lucide-react';
import { useState, type Ref } from 'react';
import { Provider as TooltipProvider } from '@radix-ui/react-tooltip';
import { TeacherAvatar } from './TeacherAvatar';
@@ -28,6 +28,9 @@ export function TeacherCompanion({ companion, open, onOpen, onToggle, bubbleRef,
const status = loading ? '正在连接智能体…'
: checking ? '智能体在看看你最近的进展…'
: error || (!enabled ? '智能体暂未开放,仍可查看以往讨论' : open ? '我们慢慢聊,想到什么都可以说' : '点我聊聊,想到什么都可以说');
const refreshMessage = companion.refreshing ? '正在刷新…'
: companion.refreshStatus === 'error' ? '刷新失败,请重试'
: companion.refreshStatus === 'success' ? '已更新' : '';
return (
<TooltipProvider delayDuration={180} skipDelayDuration={100}>
<section className="teacher-companion no-drag" aria-label="智能体陪伴" data-testid="teacher-companion">
@@ -50,6 +53,13 @@ export function TeacherCompanion({ companion, open, onOpen, onToggle, bubbleRef,
{checking && <Loader2 className="h-3 w-3 shrink-0 animate-spin text-muted-foreground motion-reduce:animate-none" aria-label="智能体正在思考" />}
</button></TeacherIntroduction>}
</nav>
<button type="button" className="consultation-agents-refresh" aria-label="刷新智能体"
title={refreshMessage || '刷新智能体'} disabled={loading || companion.refreshing} aria-busy={companion.refreshing}
onMouseDown={(event) => event.preventDefault()} onClick={() => { setIntroductionId(null); void companion.refresh(); }}>
<RefreshCw className={`h-3.5 w-3.5 shrink-0 ${companion.refreshing ? 'animate-spin motion-reduce:animate-none' : ''}`} aria-hidden="true" />
<span>{companion.refreshing ? '刷新中' : companion.refreshStatus === 'error' ? '刷新失败' : companion.refreshStatus === 'success' ? '已更新' : '刷新'}</span>
</button>
<span className="sr-only" role="status" aria-live="polite">{refreshMessage}</span>
{(invitation || welcome) && <div ref={bubbleRef} className="teacher-companion-presence" data-testid="teacher-presence">
<div className="teacher-companion-bubble" data-testid="teacher-invitation" data-bubble-kind={invitation ? 'check-in' : 'welcome'}>
<div className="teacher-companion-bubble-heading">