fix issues (#136)

* fix: prevent delete button click when card is not swiped open

* refactor: improve CreateRepoInput type safety

* security: require AUTH_SECRET and use secure random generation

* fix: SSH key path validation, async passphrase stripping, and port handling

* fix: use correct console methods for logger levels

* Add error handling to DB update functions and improve migration logging

* Add error handling for session lookup in auth middleware

* Add structured git error handling with user-friendly messages

- Parse git errors with specific error codes (AUTH_FAILED, REPO_NOT_FOUND,
  PUSH_REJECTED, MERGE_CONFLICT, etc.) and appropriate HTTP status codes
- Return structured error responses with summary and detail from backend
- Add GitErrorBanner component for better error display in UI
- Add optional onError callback to useGit hook for external error handling

* Make IPC server initialization/disposal async and fix SSH host key handler

* add try-catch error handling in frontend lib utilities

* remove unresolved promise handlers in speech synthesizer callbacks

* Extract error types to shared package

* Import GitErrorCode from shared package

* Refactor API layer to use shared FetchError and fetchWrapper

* Update prompt parser and source control components

* Extract MCP server list to separate component with improved badge menu UX

* merge useSettingsDialogUrl into useSettingsDialog and extract getRepoDisplayName utility

* add separate loading state for passkey sign in

* refactor hooks: use fetchWrapper, improve error handling, add proper types

* replace browser confirm() with DeleteDialog component in settings

* fix: add missing variables parameter in React Query onError callbacks

* Refactor message parts to use separate Zustand store

* Update QuestionPrompt styling for light/dark mode
This commit is contained in:
Chris Scott authored and GitHub committed 2026-02-15 19:48:03 -05:00
1 parent 7f7d106c28
commit 5de419ee28
75 files changed
+1990 -1367

No files matched your search

+35 -28
View File
@@ -1,8 +1,9 @@
import { useMutation, useQueryClient } from '@tanstack/react-query'
import { createOpenCodeClient } from '@/api/opencode'
import { showToast } from '@/lib/toast'
import type { MessageWithParts, MessageListResponse } from '@/api/types'
import type { Message, Part } from '@/api/types'
import { useSessionStatus } from '@/stores/sessionStatusStore'
import { useMessageParts } from '@/stores/messagePartsStore'
interface UseRemoveMessageOptions {
opcodeUrl: string | null
@@ -10,10 +11,15 @@ interface UseRemoveMessageOptions {
directory?: string
}
interface RemoveMessageContext {
previousMessages?: Message[]
}
export function useRemoveMessage({ opcodeUrl, sessionId, directory }: UseRemoveMessageOptions) {
const queryClient = useQueryClient()
const clearMessage = useMessageParts((state) => state.clearMessage)
return useMutation({
return useMutation<unknown, Error, { messageID: string; partID?: string }, RemoveMessageContext>({
mutationFn: async ({ messageID, partID }: { messageID: string, partID?: string }) => {
if (!opcodeUrl) throw new Error('OpenCode URL not available')
@@ -25,25 +31,25 @@ export function useRemoveMessage({ opcodeUrl, sessionId, directory }: UseRemoveM
await queryClient.cancelQueries({ queryKey })
const previousMessages = queryClient.getQueryData<MessageListResponse>(queryKey)
const previousMessages = queryClient.getQueryData<Message[]>(queryKey)
if (previousMessages) {
const messageIndex = previousMessages.findIndex(m => m.info.id === messageID)
const messageIndex = previousMessages.findIndex(m => m.id === messageID)
if (messageIndex !== -1) {
const newMessages = previousMessages.slice(0, messageIndex)
queryClient.setQueryData(queryKey, newMessages)
}
}
clearMessage(messageID)
return { previousMessages }
},
onError: (error, _, context) => {
console.error('Failed to remove message:', error)
if (context?.previousMessages) {
onError: (_error, _variables, _context: RemoveMessageContext | undefined) => {
if (_context?.previousMessages) {
queryClient.setQueryData(
['opencode', 'messages', opcodeUrl, sessionId, directory],
context.previousMessages
_context.previousMessages
)
}
@@ -70,6 +76,7 @@ export function useRefreshMessage({ opcodeUrl, sessionId, directory }: UseRefres
const queryClient = useQueryClient()
const removeMessage = useRemoveMessage({ opcodeUrl, sessionId, directory })
const setSessionStatus = useSessionStatus((state) => state.setStatus)
const setParts = useMessageParts((state) => state.setParts)
return useMutation({
mutationFn: async ({
@@ -92,26 +99,26 @@ export function useRefreshMessage({ opcodeUrl, sessionId, directory }: UseRefres
const client = createOpenCodeClient(opcodeUrl, directory)
const optimisticUserID = `optimistic_user_${Date.now()}_${Math.random()}`
const userMessage = {
info: {
id: optimisticUserID,
role: 'user' as const,
sessionID: sessionId,
time: { created: Date.now() }
},
parts: [{
id: `${optimisticUserID}_part_0`,
type: 'text' as const,
text: userMessageContent,
messageID: optimisticUserID,
sessionID: sessionId
}]
} as MessageWithParts
const userMessageInfo = {
id: optimisticUserID,
role: 'user' as const,
sessionID: sessionId,
time: { created: Date.now() }
} as Message
queryClient.setQueryData<MessageListResponse>(
const userMessageParts = [{
id: `${optimisticUserID}_part_0`,
type: 'text' as const,
text: userMessageContent,
messageID: optimisticUserID,
sessionID: sessionId
}] as Part[]
queryClient.setQueryData<Message[]>(
['opencode', 'messages', opcodeUrl, sessionId, directory],
(old) => [...(old || []), userMessage]
(old) => [...(old || []), userMessageInfo]
)
setParts(optimisticUserID, userMessageParts)
interface SendPromptRequest {
parts: Array<{ type: 'text'; text: string }>
@@ -149,11 +156,11 @@ export function useRefreshMessage({ opcodeUrl, sessionId, directory }: UseRefres
onError: (_, variables) => {
void variables
setSessionStatus(sessionId, { type: 'idle' })
queryClient.setQueryData<MessageListResponse>(
queryClient.setQueryData<Message[]>(
['opencode', 'messages', opcodeUrl, sessionId, directory],
(old) => {
const messages = old || []
const optimisticIndex = messages.findIndex((m) => m.info.id.startsWith('optimistic_user_'))
const optimisticIndex = messages.findIndex((m) => m.id.startsWith('optimistic_user_'))
if (optimisticIndex !== -1) {
return messages.slice(0, optimisticIndex)
}