mirror of
https://github.com/shumaiOne/shumai.git
synced 2026-11-26 19:04:23 +00:00
chore: format codebase
This commit is contained in:
@@ -90,12 +90,20 @@ export function ChatbotSidebar({ projectId, contextAssetId }: ChatbotSidebarProp
|
||||
}
|
||||
|
||||
const renderMessage = (msg: ChatMessage) => {
|
||||
if (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
|
||||
if (
|
||||
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 || []
|
||||
if (assets.length === 0) return null
|
||||
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>
|
||||
<ul className="list-disc list-inside space-y-0.5">
|
||||
{assets.map((asset) => (
|
||||
|
||||
@@ -106,7 +106,9 @@ describe('useChatbotStore', () => {
|
||||
const stateWithOptimistic = useChatbotStore.getState()
|
||||
expect(stateWithOptimistic.messages).toHaveLength(1)
|
||||
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)
|
||||
|
||||
await sendPromise
|
||||
|
||||
@@ -199,8 +199,7 @@ export const useChatbotStore = create<ChatbotState>((set) => ({
|
||||
const isExisting = s.messages.some((m) => m.id === entry.id)
|
||||
// Replace temp/optimistic message when the real user message streams back
|
||||
const filtered = s.messages.filter(
|
||||
(m) =>
|
||||
!(entry.role === 'user' && !isExisting && m.id.startsWith('temp-')),
|
||||
(m) => !(entry.role === 'user' && !isExisting && m.id.startsWith('temp-')),
|
||||
)
|
||||
|
||||
// Prevent duplicates by ID
|
||||
|
||||
Reference in New Issue
Block a user