mirror of
https://github.com/chriswritescode-dev/opencode-manager.git
synced 2026-12-05 12:24:30 +01:00
fix sse frontend issue (#84)
This commit is contained in:
1 parent
020f4564f5
commit
d78bb120ed
2 files changed
+27
-9
No files matched your search
@@ -279,8 +279,12 @@ export const useSendPrompt = (opcodeUrl: string | null | undefined, directory?:
|
||||
contentParts,
|
||||
optimisticUserID,
|
||||
);
|
||||
|
||||
const messagesQueryKey = ["opencode", "messages", opcodeUrl, sessionID, directory];
|
||||
await queryClient.cancelQueries({ queryKey: messagesQueryKey });
|
||||
|
||||
queryClient.setQueryData<MessageListResponse>(
|
||||
["opencode", "messages", opcodeUrl, sessionID, directory],
|
||||
messagesQueryKey,
|
||||
(old) => [...(old || []), userMessage],
|
||||
);
|
||||
|
||||
@@ -348,7 +352,10 @@ export const useSendPrompt = (opcodeUrl: string | null | undefined, directory?:
|
||||
|
||||
queryClient.setQueryData<MessageListResponse>(
|
||||
["opencode", "messages", opcodeUrl, sessionID, directory],
|
||||
(old) => old?.filter((msg) => msg.info.id !== optimisticUserID) || [],
|
||||
(old) => {
|
||||
if (!old) return old;
|
||||
return old.filter((msg) => msg.info.id !== optimisticUserID);
|
||||
},
|
||||
);
|
||||
|
||||
queryClient.invalidateQueries({
|
||||
@@ -511,8 +518,12 @@ export const useSendShell = (opcodeUrl: string | null | undefined, directory?: s
|
||||
[{ type: "text" as const, content: command }],
|
||||
optimisticUserID,
|
||||
);
|
||||
|
||||
const messagesQueryKey = ["opencode", "messages", opcodeUrl, sessionID, directory];
|
||||
await queryClient.cancelQueries({ queryKey: messagesQueryKey });
|
||||
|
||||
queryClient.setQueryData<MessageListResponse>(
|
||||
["opencode", "messages", opcodeUrl, sessionID, directory],
|
||||
messagesQueryKey,
|
||||
(old) => [...(old || []), userMessage],
|
||||
);
|
||||
|
||||
@@ -528,7 +539,10 @@ export const useSendShell = (opcodeUrl: string | null | undefined, directory?: s
|
||||
setSessionStatus(sessionID, { type: "idle" });
|
||||
queryClient.setQueryData<MessageListResponse>(
|
||||
["opencode", "messages", opcodeUrl, sessionID, directory],
|
||||
(old) => old?.filter((msg) => !msg.info.id.startsWith("optimistic_")),
|
||||
(old) => {
|
||||
if (!old) return old;
|
||||
return old.filter((msg) => !msg.info.id.startsWith("optimistic_"));
|
||||
},
|
||||
);
|
||||
},
|
||||
onSuccess: (data, variables) => {
|
||||
@@ -537,7 +551,10 @@ export const useSendShell = (opcodeUrl: string | null | undefined, directory?: s
|
||||
|
||||
queryClient.setQueryData<MessageListResponse>(
|
||||
["opencode", "messages", opcodeUrl, sessionID, directory],
|
||||
(old) => old?.filter((msg) => msg.info.id !== optimisticUserID) || [],
|
||||
(old) => {
|
||||
if (!old) return old;
|
||||
return old.filter((msg) => msg.info.id !== optimisticUserID);
|
||||
},
|
||||
);
|
||||
|
||||
queryClient.invalidateQueries({
|
||||
|
||||
Reference in new issue
Block a user