Skip to content

Commit a36d186

Browse files
committed
fix: conversations总结添加旋转动画并等待完成后刷新
Co-Authored-By: Rayner Zeng <1361209507@qq.com>
1 parent cf45cc9 commit a36d186

1 file changed

Lines changed: 19 additions & 2 deletions

File tree

server/src/cli/ui/views/ConversationsView.tsx

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React, { useCallback, useMemo, useState } from 'react';
1+
import React, { useCallback, useEffect, useMemo, useState } from 'react';
22
import { InteractiveList, type ColumnDef } from '../components/InteractiveList.js';
33
import { usePagination } from '../hooks/usePagination.js';
44
import { getLocale } from '../locale/index.js';
@@ -29,6 +29,14 @@ interface ConversationsViewProps {
2929
export function ConversationsView({ client, source, status, search, onSelect, onSearch, onQuit }: ConversationsViewProps) {
3030
const t = getLocale();
3131
const [summarizing, setSummarizing] = useState<string | null>(null);
32+
const [spinFrame, setSpinFrame] = useState(0);
33+
const spinChars = ['⠋', '⠙', '⠹', '⠸', '⠼', '⠴', '⠦', '⠧', '⠇', '⠏'];
34+
35+
useEffect(() => {
36+
if (!summarizing) return;
37+
const timer = setInterval(() => setSpinFrame(prev => (prev + 1) % spinChars.length), 80);
38+
return () => clearInterval(timer);
39+
}, [summarizing]);
3240

3341
const fetchPage = useCallback(async (offset: number, limit: number) => {
3442
const data = await client.getConversations({ source, status, search, offset, limit });
@@ -58,6 +66,15 @@ export function ConversationsView({ client, source, status, search, onSelect, on
5866
setSummarizing(item.id);
5967
try {
6068
await client.summarize(item.id);
69+
// Poll until status changes (summarization is async via queue)
70+
for (let i = 0; i < 30; i++) {
71+
await new Promise(r => setTimeout(r, 2000));
72+
const data = await client.getConversations({ search: item.id, limit: 1 });
73+
const updated = data.items.find(c => c.id === item.id);
74+
if (updated && updated.status !== 'imported') {
75+
break;
76+
}
77+
}
6178
reload();
6279
} catch { /* ignore */ }
6380
finally { setSummarizing(null); }
@@ -82,7 +99,7 @@ export function ConversationsView({ client, source, status, search, onSelect, on
8299
extraHints={extraHints}
83100
title={t.conversationsTitle}
84101
renderPreview={(item) => {
85-
if (summarizing === item.id) return `...`;
102+
if (summarizing === item.id) return `${spinChars[spinFrame]} ${t.hints.summarize.split(':')[1]}...`;
86103
if (item.status === 'summarized') return `${item.source} | ${item.project_name} | ${item.message_count} msgs`;
87104
return `${t.notSummarized}${t.pressSToSummarize}`;
88105
}}

0 commit comments

Comments
 (0)