refactor: use backend chat sessions

This commit is contained in:
2026-06-04 15:02:27 +08:00
parent 20ca410e0a
commit e60e1f6453
9 changed files with 91 additions and 178 deletions
+12 -12
View File
@@ -60,7 +60,7 @@ export const GlobalChatbox: React.FC<Props> = ({ open, onClose }) => {
const {
messages,
chatSessions,
activeStorageSessionId,
activeSessionId,
branchGroups,
branchTransition,
isHydrating,
@@ -129,33 +129,33 @@ export const GlobalChatbox: React.FC<Props> = ({ open, onClose }) => {
}, []);
const handleSelectSession = useCallback(
(storageSessionId: string) => {
(sessionId: string) => {
composerRef.current?.clear();
void switchSession(storageSessionId);
void switchSession(sessionId);
},
[switchSession],
);
const handleDeleteSession = useCallback(
(storageSessionId: string) => {
void removeSession(storageSessionId);
(sessionId: string) => {
void removeSession(sessionId);
},
[removeSession],
);
const handleRenameSession = useCallback(
(storageSessionId: string, title: string) => {
void renameSession(storageSessionId, title);
(sessionId: string, title: string) => {
void renameSession(sessionId, title);
},
[renameSession],
);
const handleRenameActiveSession = useCallback(
(title: string) => {
if (!activeStorageSessionId) return;
void renameSession(activeStorageSessionId, title);
if (!activeSessionId) return;
void renameSession(activeSessionId, title);
},
[activeStorageSessionId, renameSession],
[activeSessionId, renameSession],
);
const handleMouseDown = useCallback((event: React.MouseEvent) => {
@@ -255,7 +255,7 @@ export const GlobalChatbox: React.FC<Props> = ({ open, onClose }) => {
<AgentHeader
sessionTitle={sessionTitle}
canRenameSessionTitle={Boolean(activeStorageSessionId)}
canRenameSessionTitle={Boolean(activeSessionId)}
isHydrating={isHydrating}
isStreaming={isStreaming}
isHistoryOpen={isHistoryOpen}
@@ -294,7 +294,7 @@ export const GlobalChatbox: React.FC<Props> = ({ open, onClose }) => {
>
<AgentHistoryPanel
sessions={chatSessions}
activeSessionId={activeStorageSessionId}
activeSessionId={activeSessionId}
isHydrating={isHydrating}
onNewSession={() => {
handleNewConversation();