fix(coding): isolate async conversation actions
This commit is contained in:
@@ -335,12 +335,21 @@ export function CodingChatPanel({
|
||||
]);
|
||||
|
||||
const handleForkConversation = useCallback(async (sourceEntryId?: string) => {
|
||||
if (!activeProject || !targetConversationId) return;
|
||||
const forked = await forkCodingConversation(targetConversationId, sourceEntryId);
|
||||
if (!activeProject || !selectedAgent || !targetConversationId) return;
|
||||
const sourceProjectId = activeProject.id;
|
||||
const sourceAgentId = selectedAgent.id;
|
||||
const sourceConversationId = targetConversationId;
|
||||
const forked = await forkCodingConversation(sourceConversationId, sourceEntryId);
|
||||
upsertConversation(forked);
|
||||
primeConversation(createLocalConversationSnapshot(activeProject.id, forked));
|
||||
await selectConversation(forked.id);
|
||||
}, [activeProject, primeConversation, selectConversation, targetConversationId, upsertConversation]);
|
||||
primeConversation(createLocalConversationSnapshot(sourceProjectId, forked));
|
||||
const workspace = codingWorkspaceStore.getState();
|
||||
const selectedId = codingConversationStore.getState().selectedConversationId;
|
||||
if (workspace.activeProjectId === sourceProjectId
|
||||
&& workspace.selectedAgentId === sourceAgentId
|
||||
&& selectedId === sourceConversationId) {
|
||||
await selectConversation(forked.id);
|
||||
}
|
||||
}, [activeProject, primeConversation, selectConversation, selectedAgent, targetConversationId, upsertConversation]);
|
||||
|
||||
const handleAddFiles = useCallback((files: File[]) => {
|
||||
if (!draftKey
|
||||
@@ -615,6 +624,7 @@ export function CodingChatPanel({
|
||||
|
||||
<div className="flex min-w-0 flex-1 flex-col">
|
||||
<CodingConversationHeader
|
||||
key={`header:${targetConversationId ?? 'none'}`}
|
||||
conversation={selectedConversation}
|
||||
snapshot={snapshot}
|
||||
connectionState={connectionState}
|
||||
@@ -623,8 +633,11 @@ export function CodingChatPanel({
|
||||
}}
|
||||
onArchive={async () => {
|
||||
if (!targetConversationId) return;
|
||||
await patchConversation(targetConversationId, { archived: true });
|
||||
clearConversationSelection();
|
||||
const sourceConversationId = targetConversationId;
|
||||
await patchConversation(sourceConversationId, { archived: true });
|
||||
if (codingConversationStore.getState().selectedConversationId === sourceConversationId) {
|
||||
clearConversationSelection();
|
||||
}
|
||||
}}
|
||||
onToggleUnread={async () => {
|
||||
if (!targetConversationId || !selectedConversation) return;
|
||||
@@ -683,6 +696,7 @@ export function CodingChatPanel({
|
||||
|
||||
{targetConversationId && (
|
||||
<CodingInteractionPanel
|
||||
key={`interaction:${targetConversationId}`}
|
||||
conversationId={targetConversationId}
|
||||
interactions={snapshot?.pendingInteractions ?? []}
|
||||
onSettled={() => loadConversationSnapshot(targetConversationId, true).then(() => undefined)}
|
||||
@@ -730,6 +744,7 @@ export function CodingChatPanel({
|
||||
onRemoveAttachment={handleRemoveAttachment}
|
||||
/>
|
||||
<CodingWorkspaceInspector
|
||||
key={`inspector:${targetConversationId ?? 'none'}`}
|
||||
open={inspectorOpen}
|
||||
onOpenChange={setInspectorOpen}
|
||||
conversationId={targetConversationId}
|
||||
|
||||
Reference in New Issue
Block a user