Skip to content

Commit 42f6b4a

Browse files
Address code review: extract disabled logic, document tool role in docs
Agent-Logs-Url: https://github.com/objectstack-ai/objectui/sessions/40e1c13a-9cc3-482e-9ab3-f43e05a917c3 Co-authored-by: xuyushun441-sys <255036401+xuyushun441-sys@users.noreply.github.com>
1 parent 661c01f commit 42f6b4a

2 files changed

Lines changed: 27 additions & 3 deletions

File tree

content/docs/plugins/plugin-chatbot.mdx

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -300,6 +300,27 @@ System messages appear centered with muted styling:
300300
}
301301
```
302302

303+
### Tool Messages (AI Mode)
304+
305+
Tool messages represent results from tool invocations during AI streaming. They are generated automatically by the vercel/ai SDK when the backend performs tool calls (e.g., fetching weather, querying a database). Tool messages are not displayed directly — their results are embedded in the assistant message's `toolInvocations` array:
306+
307+
```tsx
308+
{
309+
id: '4',
310+
role: 'assistant',
311+
content: 'The weather in SF is 68°F.',
312+
toolInvocations: [
313+
{
314+
toolCallId: 'tc-1',
315+
toolName: 'getWeather',
316+
args: { city: 'San Francisco' },
317+
result: { temp: 68, condition: 'Sunny' },
318+
state: 'result',
319+
}
320+
]
321+
}
322+
```
323+
303324
## Examples
304325

305326
### Simple AI Chat

packages/plugin-chatbot/src/ChatbotEnhanced.tsx

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,9 @@ const ChatbotEnhanced = React.forwardRef<HTMLDivElement, ChatbotEnhancedProps>(
167167
}
168168
}
169169

170+
const isInputDisabled = disabled || isLoading
171+
const isSendDisabled = isInputDisabled || (!inputValue.trim() && selectedFiles.length === 0)
172+
170173
const handleKeyDown = (e: React.KeyboardEvent<HTMLInputElement>) => {
171174
if (e.key === "Enter" && !e.shiftKey) {
172175
e.preventDefault()
@@ -386,7 +389,7 @@ const ChatbotEnhanced = React.forwardRef<HTMLDivElement, ChatbotEnhancedProps>(
386389
variant="ghost"
387390
size="icon"
388391
onClick={() => fileInputRef.current?.click()}
389-
disabled={disabled || isLoading}
392+
disabled={isInputDisabled}
390393
aria-label="Attach file"
391394
>
392395
<Paperclip className="h-4 w-4" />
@@ -400,13 +403,13 @@ const ChatbotEnhanced = React.forwardRef<HTMLDivElement, ChatbotEnhancedProps>(
400403
onChange={(e) => setInputValue(e.target.value)}
401404
onKeyDown={handleKeyDown}
402405
placeholder={placeholder}
403-
disabled={disabled || isLoading}
406+
disabled={isInputDisabled}
404407
className="flex-1"
405408
/>
406409

407410
<Button
408411
onClick={handleSend}
409-
disabled={disabled || isLoading || (!inputValue.trim() && selectedFiles.length === 0)}
412+
disabled={isSendDisabled}
410413
size="icon"
411414
aria-label="Send message"
412415
>

0 commit comments

Comments
 (0)