refactor: remove dead assistant_chat system, consolidate image helpers

The old /assistant/chats/* CRUD endpoints and assistant_chat_service
chat functions were unused — the frontend exclusively uses
/ai-sessions/{id}/chat (unified_chat_service) for all chat operations.

Removed:
- Chat CRUD endpoints (create, list, get, send, delete, conclude)
- assistant_chat_service: create_chat, send_message,
  generate_conclusion_summary, CONCLUSION_SYSTEM_PROMPT
- Frontend: assistantChatApi chat methods, dead types
  (AssistantChat, AssistantChatMessage, ConcludeChatRequest, etc.)

Kept:
- /assistant/retention endpoints (used by ChatRetentionSettingsPage)
- Shared AI infrastructure (_call_ai, _call_anthropic_cached,
  ASSISTANT_SYSTEM_PROMPT, _auto_title) — imported by unified_chat_service

Moved:
- fetch_upload_images + resize_image_for_vision → storage_service.py
  (shared location, not tied to dead endpoint)

Also added "Image Analysis" section to system prompt so Claude knows
to describe attached screenshots.

-650 lines of dead code removed.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
chihlasm
2026-03-24 05:28:06 +00:00
parent 36ca830481
commit 8e7f13d2f8
8 changed files with 141 additions and 791 deletions

View File

@@ -1,52 +1,13 @@
import apiClient from './client'
import type {
AssistantChat,
ChatListItem,
ChatMessageResponse,
RetentionSettings,
ConcludeChatRequest,
ConcludeChatResponse,
} from '@/types/assistant-chat'
import type { RetentionSettings } from '@/types/assistant-chat'
/**
* Chat retention settings API.
*
* Note: Chat CRUD methods were removed — the frontend uses aiSessionsApi
* for all chat operations. Only retention settings remain on the /assistant prefix.
*/
export const assistantChatApi = {
async createChat(): Promise<AssistantChat> {
const response = await apiClient.post<AssistantChat>('/assistant/chats', {})
return response.data
},
async listChats(page = 1, size = 20): Promise<ChatListItem[]> {
const response = await apiClient.get<ChatListItem[]>('/assistant/chats', {
params: { page, size },
})
return response.data
},
async getChat(chatId: string): Promise<AssistantChat> {
const response = await apiClient.get<AssistantChat>(`/assistant/chats/${chatId}`)
return response.data
},
async sendMessage(chatId: string, message: string): Promise<ChatMessageResponse> {
const response = await apiClient.post<ChatMessageResponse>(
`/assistant/chats/${chatId}/messages`,
{ message }
)
return response.data
},
async updateChat(chatId: string, data: { title?: string; pinned?: boolean }): Promise<AssistantChat> {
const response = await apiClient.patch<AssistantChat>(`/assistant/chats/${chatId}`, data)
return response.data
},
async deleteChat(chatId: string): Promise<void> {
await apiClient.delete(`/assistant/chats/${chatId}`)
},
async bulkDeleteChats(olderThanDays: number): Promise<void> {
await apiClient.delete('/assistant/chats', { params: { older_than_days: olderThanDays } })
},
async getRetentionSettings(): Promise<RetentionSettings> {
const response = await apiClient.get<RetentionSettings>('/assistant/retention')
return response.data
@@ -56,14 +17,6 @@ export const assistantChatApi = {
const response = await apiClient.patch<RetentionSettings>('/assistant/retention', data)
return response.data
},
async concludeChat(chatId: string, data: ConcludeChatRequest): Promise<ConcludeChatResponse> {
const response = await apiClient.post<ConcludeChatResponse>(
`/assistant/chats/${chatId}/conclude`,
data
)
return response.data
},
}
export default assistantChatApi

View File

@@ -1,20 +1,3 @@
import type { SuggestedFlow } from './copilot'
export interface AssistantChat {
id: string
title: string
messages: AssistantChatMessage[]
message_count: number
pinned: boolean
created_at: string
updated_at: string
}
export interface AssistantChatMessage {
role: 'user' | 'assistant'
content: string
}
export interface ChatListItem {
id: string
title: string
@@ -24,27 +7,9 @@ export interface ChatListItem {
updated_at: string
}
export interface ChatMessageResponse {
content: string
suggested_flows: SuggestedFlow[]
}
export interface RetentionSettings {
chat_retention_days: number | null
chat_retention_max_count: number | null
}
export type ConclusionOutcome = 'resolved' | 'escalated' | 'paused'
export interface ConcludeChatRequest {
outcome: ConclusionOutcome
notes?: string
}
export interface ConcludeChatResponse {
summary: string
outcome: ConclusionOutcome
concluded_at: string
}
export type { SuggestedFlow }

View File

@@ -11,7 +11,7 @@ export type { Account, Subscription, PlanLimits, SubscriptionDetails, AccountInv
export * from './admin'
export * from './analytics'
export * from './copilot'
export type { AssistantChat, AssistantChatMessage, ChatListItem, ChatMessageResponse, RetentionSettings } from './assistant-chat'
export type { ChatListItem, RetentionSettings, ConclusionOutcome } from './assistant-chat'
export * from './ai-session'
export * from './flow-proposal'
export * from './flowpilot-analytics'