fix: show and dismiss teacher introductions as one group
This commit is contained in:
1 parent
a77ddbd681
commit
7458c37fb0
12 files changed
+290
-148
No files matched your search
@@ -12,7 +12,7 @@ export function Layout() {
|
||||
const [bubble, setBubble] = useState<HTMLDivElement | null>(null);
|
||||
const [draft, setDraft] = useState('');
|
||||
const [sent, setSent] = useState(false);
|
||||
const [dismissed, setDismissed] = useState<string[]>([]);
|
||||
const [dismissed, setDismissed] = useState(false);
|
||||
const agents = ['架构工程师-陈宗琦', '产品工程师-Alice'].map((name, index) => ({
|
||||
teacher_id: String(index), version: 1, is_default: index === 0,
|
||||
definition: { config_id: String(index), name, avatar_id: 'avatar-06',
|
||||
@@ -22,9 +22,8 @@ export function Layout() {
|
||||
agents, selectedAgent: agents[0], definition: agents[0].definition, enabled: true,
|
||||
unreadAgentIds: [], invitation: null, welcome: null, loading: false, error: null, checking: false,
|
||||
refreshing: false, refreshStatus: 'idle', refresh: async () => {}, reloadCatalog: async () => {}, dismiss: () => {},
|
||||
welcomes: new URLSearchParams(location.search).has('teachers') ? agents.flatMap((agent, index) => dismissed.includes(agent.teacher_id)
|
||||
? [] : [{ agentId: agent.teacher_id, definition: agent.definition, text: agent.definition.description, tone: index }]) : [],
|
||||
dismissWelcome: (id: string) => setDismissed(values => [...values, id]),
|
||||
welcomes: new URLSearchParams(location.search).has('teachers') && !dismissed ? agents.map((agent, index) => ({ agentId: agent.teacher_id, definition: agent.definition, text: agent.definition.description, tone: index })) : [],
|
||||
dismissWelcomes: () => setDismissed(true),
|
||||
} as ComponentProps<typeof TeacherCompanion>['companion'];
|
||||
return <div className="flex h-screen">
|
||||
{new URLSearchParams(location.search).has('sidebar') && <aside data-testid="project-sidebar" className="shrink-0 border-r p-4 text-sm" style={{ width: 210, background: '#f1f6fc' }}>我的项目</aside>}
|
||||
|
||||
@@ -19,7 +19,7 @@ export function Layout() {
|
||||
const [refreshStatus, setRefreshStatus] = useState<'idle' | 'success' | 'error'>('idle');
|
||||
const [selected, setSelected] = useState(0);
|
||||
const welcomeMode = new URLSearchParams(location.search).has('welcomes');
|
||||
const [dismissed, setDismissed] = useState<string[]>([]);
|
||||
const [dismissed, setDismissed] = useState(false);
|
||||
const agents = Array.from({ length: count }, (_, index) => ({
|
||||
teacher_id: `agent-${index}`, version: index + 1, is_default: index === 0,
|
||||
definition: { config_id: `agent-${index}`, name: `智能体${index + 1}`, avatar_id: 'avatar-06',
|
||||
@@ -31,8 +31,8 @@ export function Layout() {
|
||||
definition: agents[selected]?.definition ?? { name: '编程老师', avatar_id: 'avatar-06' },
|
||||
invitation: !welcomeMode && visible ? { response: long ? '你刚才说想做一个宠物游戏。我们一起想想,什么样的小动作,会让你愿意一直陪它玩下去?可以先挑一个最想试的想法。' : '有什么编程问题想一起讨论?' } : null,
|
||||
welcome: null, enabled: true, loading: false, checking: false, error: null,
|
||||
welcomes: welcomeMode && !open ? agents.flatMap((agent, index) => dismissed.includes(agent.teacher_id) ? [] : [{ agentId: agent.teacher_id, definition: agent.definition, text: agent.definition.description, tone: index % 3 }]) : [],
|
||||
dismissWelcome: (id: string) => setDismissed(ids => [...new Set([...ids, id])]),
|
||||
welcomes: welcomeMode && !open && !dismissed ? agents.map((agent, index) => ({ agentId: agent.teacher_id, definition: agent.definition, text: agent.definition.description, tone: index % 3 })) : [],
|
||||
dismissWelcomes: () => setDismissed(true),
|
||||
refreshing, refreshStatus,
|
||||
refresh: async () => {
|
||||
setRefreshing(true);
|
||||
|
||||
Reference in new issue
Block a user