chore: format codebase

This commit is contained in:
yiling
2026-07-11 16:58:37 +08:00
parent 482df3315c
commit bd897b951a
5 changed files with 24 additions and 8 deletions
+5 -1
View File
@@ -150,7 +150,11 @@ export async function agentChat(task: WorkflowTask): Promise<void> {
referencedAssetDetailsList.push( referencedAssetDetailsList.push(
`- Name: ${referencedAsset.name} (ID: ${referencedAsset.id}, Type: ${referencedAsset.type}, Media Type: ${referencedAsset.mediaType || 'unknown'}, Project ID: ${referencedAsset.projectId || 'unknown'}, Path: ${path})`, `- Name: ${referencedAsset.name} (ID: ${referencedAsset.id}, Type: ${referencedAsset.type}, Media Type: ${referencedAsset.mediaType || 'unknown'}, Project ID: ${referencedAsset.projectId || 'unknown'}, Path: ${path})`,
) )
attachedAssets.push({ id: referencedAsset.id, name: referencedAsset.name, type: referencedAsset.type }) attachedAssets.push({
id: referencedAsset.id,
name: referencedAsset.name,
type: referencedAsset.type,
})
} }
} }
} }
+4 -1
View File
@@ -100,7 +100,10 @@ export function mapEntryToMessage(
entryRecord: Prisma.AgentSessionEntryGetPayload<Record<string, never>>, entryRecord: Prisma.AgentSessionEntryGetPayload<Record<string, never>>,
): ChatMessage | null { ): ChatMessage | null {
const entryObj = entryRecord.entry as unknown as SessionTreeEntry const entryObj = entryRecord.entry as unknown as SessionTreeEntry
if (entryObj.type === 'custom_message' && (entryObj as { customType?: string }).customType === 'context') { if (
entryObj.type === 'custom_message' &&
(entryObj as { customType?: string }).customType === 'context'
) {
return null return null
} }
const pathEntries = [{ ...entryObj, id: entryRecord.id }] const pathEntries = [{ ...entryObj, id: entryRecord.id }]
+11 -3
View File
@@ -90,12 +90,20 @@ export function ChatbotSidebar({ projectId, contextAssetId }: ChatbotSidebarProp
} }
const renderMessage = (msg: ChatMessage) => { const renderMessage = (msg: ChatMessage) => {
if (msg.role === 'custom' && (msg as { customType?: string }).customType === 'context_display_info') { if (
const details = msg.details as { assets?: Array<{ id: string; name: string; type: string }> } | undefined msg.role === 'custom' &&
(msg as { customType?: string }).customType === 'context_display_info'
) {
const details = msg.details as
| { assets?: Array<{ id: string; name: string; type: string }> }
| undefined
const assets = details?.assets || [] const assets = details?.assets || []
if (assets.length === 0) return null if (assets.length === 0) return null
return ( return (
<div key={msg.id} className="text-xs text-muted-foreground bg-muted/40 p-2.5 rounded-lg border border-border/50 space-y-1 my-1"> <div
key={msg.id}
className="text-xs text-muted-foreground bg-muted/40 p-2.5 rounded-lg border border-border/50 space-y-1 my-1"
>
<div className="font-semibold">{m.assets_added_to_context()}</div> <div className="font-semibold">{m.assets_added_to_context()}</div>
<ul className="list-disc list-inside space-y-0.5"> <ul className="list-disc list-inside space-y-0.5">
{assets.map((asset) => ( {assets.map((asset) => (
+3 -1
View File
@@ -106,7 +106,9 @@ describe('useChatbotStore', () => {
const stateWithOptimistic = useChatbotStore.getState() const stateWithOptimistic = useChatbotStore.getState()
expect(stateWithOptimistic.messages).toHaveLength(1) expect(stateWithOptimistic.messages).toHaveLength(1)
expect(stateWithOptimistic.messages[0].id).toContain('temp-') expect(stateWithOptimistic.messages[0].id).toContain('temp-')
expect((stateWithOptimistic.messages[0] as { content: unknown }).content).toEqual([{ type: 'text', text: 'hello' }]) expect((stateWithOptimistic.messages[0] as { content: unknown }).content).toEqual([
{ type: 'text', text: 'hello' },
])
expect(stateWithOptimistic.isStreaming).toBe(true) expect(stateWithOptimistic.isStreaming).toBe(true)
await sendPromise await sendPromise
+1 -2
View File
@@ -199,8 +199,7 @@ export const useChatbotStore = create<ChatbotState>((set) => ({
const isExisting = s.messages.some((m) => m.id === entry.id) const isExisting = s.messages.some((m) => m.id === entry.id)
// Replace temp/optimistic message when the real user message streams back // Replace temp/optimistic message when the real user message streams back
const filtered = s.messages.filter( const filtered = s.messages.filter(
(m) => (m) => !(entry.role === 'user' && !isExisting && m.id.startsWith('temp-')),
!(entry.role === 'user' && !isExisting && m.id.startsWith('temp-')),
) )
// Prevent duplicates by ID // Prevent duplicates by ID