mirror of
https://github.com/chriswritescode-dev/opencode-manager.git
synced 2026-12-06 04:44:21 +01:00
refactor: derive session active state from messages instead of status store (#264)
* refactor: derive session active state from messages instead of status store * refactor: remove duplicate session.updated handler from EventContext
This commit is contained in:
1 parent
30c34e867e
commit
468e2f5dfb
5 files changed
+13
-60
No files matched your search
@@ -3,7 +3,6 @@ import { createOpenCodeClient } from '@/api/opencode'
|
||||
import { showToast } from '@/lib/toast'
|
||||
import { messagesQueryKey } from '@/lib/queryInvalidation'
|
||||
import type { Message, Part, MessageWithParts } from '@/api/types'
|
||||
import { useSessionStatus } from '@/stores/sessionStatusStore'
|
||||
|
||||
interface UseRemoveMessageOptions {
|
||||
opcodeUrl: string | null
|
||||
@@ -72,7 +71,6 @@ interface UseRefreshMessageOptions {
|
||||
export function useRefreshMessage({ opcodeUrl, sessionId, directory }: UseRefreshMessageOptions) {
|
||||
const queryClient = useQueryClient()
|
||||
const removeMessage = useRemoveMessage({ opcodeUrl, sessionId, directory })
|
||||
const setSessionStatus = useSessionStatus((state) => state.setStatus)
|
||||
|
||||
return useMutation({
|
||||
mutationFn: async ({
|
||||
@@ -88,8 +86,6 @@ export function useRefreshMessage({ opcodeUrl, sessionId, directory }: UseRefres
|
||||
}) => {
|
||||
if (!opcodeUrl) throw new Error('OpenCode URL not available')
|
||||
|
||||
setSessionStatus(sessionId, { type: 'busy' })
|
||||
|
||||
await removeMessage.mutateAsync({ messageID: assistantMessageID })
|
||||
|
||||
const client = createOpenCodeClient(opcodeUrl, directory)
|
||||
@@ -155,7 +151,6 @@ export function useRefreshMessage({ opcodeUrl, sessionId, directory }: UseRefres
|
||||
},
|
||||
onError: (_, variables) => {
|
||||
void variables
|
||||
setSessionStatus(sessionId, { type: 'idle' })
|
||||
queryClient.setQueryData<MessageWithParts[]>(
|
||||
messagesQueryKey(opcodeUrl, sessionId, directory),
|
||||
(old) => {
|
||||
|
||||
Reference in new issue
Block a user