Skip to content
Merged
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
8 changes: 7 additions & 1 deletion src/api/reports.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,14 @@ export const reportsApi = {

download: (id: string) => apiClient.get(`/reports/${id}/download`, { responseType: 'blob' }),

// BE→AI 서비스 호출이 여러 도구 체인(문헌 검색 등)을 거치며 30초 이상 걸릴 수 있어
// 공용 15초 타임아웃 대신 BE의 AI 서비스 타임아웃(60초)에 맞춘 값을 사용한다.
sendChatMessage: (reportId: string, message: string) =>
apiClient.post<ChatMessageResponse>(`/reports/${reportId}/chat/messages`, { message }),
apiClient.post<ChatMessageResponse>(
`/reports/${reportId}/chat/messages`,
{ message },
{ timeout: 65_000 },
),

applyPatch: (patchId: string) =>
apiClient.post<PatchApplyResponse>(`/reports/patch-proposals/${patchId}/apply`),
Expand Down
11 changes: 9 additions & 2 deletions src/components/common/ReportChatPanel.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { useState, useRef, useEffect } from 'react'
import axios from 'axios'
import { reportsApi, type Report, type PatchProposal } from '@/api/reports'
import { Icon } from '@/components/common/Icon'
import { useToast } from '@/hooks/useToast'
Expand Down Expand Up @@ -53,8 +54,14 @@ export function ReportChatPanel({ report, onPatchApplied }: Props) {
patch: data.patch_proposal ?? undefined,
},
])
} catch {
showToast({ title: '메시지 전송에 실패했습니다', kind: 'error' })
} catch (error) {
const isTimeout = axios.isAxiosError(error) && error.code === 'ECONNABORTED'
showToast({
title: isTimeout
? 'AI 응답이 지연되고 있습니다. 잠시 후 새로고침해 확인해주세요'
: '메시지 전송에 실패했습니다',
kind: 'error',
})
setMessages((prev) => prev.slice(0, -1))
setInput(trimmed)
} finally {
Expand Down
Loading