Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions src/renderer/src/pages/ChatPage/hooks/refactored/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
// リファクタリングされたフックのエクスポート

export { useMessages } from './useMessages'
export { useRequestControl } from './useRequestControl'
export { useChatUIState } from './useChatUIState'
export { useSessionManager } from './useSessionManager'
export { useToolExecution } from './useToolExecution'
export { useStreamChat } from './useStreamChat'
export { useAgentChatRefactored } from './useAgentChatRefactored'

// 型定義のエクスポート
export type { UseMessagesProps, UseMessagesReturn } from './useMessages'
export type { UseRequestControlReturn } from './useRequestControl'
export type { UseChatUIStateReturn } from './useChatUIState'
export type { UseSessionManagerProps, UseSessionManagerReturn } from './useSessionManager'
export type { UseToolExecutionProps, UseToolExecutionReturn } from './useToolExecution'
export type { UseStreamChatProps, UseStreamChatReturn } from './useStreamChat'

export type {
ChatUIState,
SessionInfo,
ToolExecutionState,
MessageOperations,
StreamingState,
UseAgentChatReturn
} from './types'
59 changes: 59 additions & 0 deletions src/renderer/src/pages/ChatPage/hooks/refactored/types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
// 共通の型定義ファイル

import { IdentifiableMessage } from '@/types/chat/message'
import { ToolName } from '@/types/tools'

// UI状態の型
export interface ChatUIState {
loading: boolean
reasoning: boolean
executingTool: ToolName | null
latestReasoningText: string
}

// セッション管理の型
export interface SessionInfo {
currentSessionId: string | undefined
enableHistory: boolean
}

// ツール実行の型
export interface ToolExecutionState {
isExecuting: boolean
currentTool: ToolName | null
}

// メッセージ管理の型
export interface MessageOperations {
addMessage: (message: IdentifiableMessage) => Promise<void>
persistMessage: (message: IdentifiableMessage) => Promise<IdentifiableMessage>
clearMessages: () => void
}

// ストリーミングの型
export interface StreamingState {
isStreaming: boolean
abortController: AbortController | null
}

// リファクタリング後のフックの戻り値の型
export interface UseAgentChatReturn {
// メッセージ関連
messages: IdentifiableMessage[]
setMessages: React.Dispatch<React.SetStateAction<IdentifiableMessage[]>>

// UI状態
loading: boolean
reasoning: boolean
executingTool: ToolName | null
latestReasoningText: string

// セッション管理
currentSessionId: string | undefined
setCurrentSessionId: (sessionId: string) => void
clearChat: () => Promise<void>

// メイン機能
handleSubmit: (userInput: string, attachedImages?: any[]) => Promise<any>
stopGeneration: () => void
}
Loading
Loading