Fix MCP tools count update in plug icon indicator

- Add onMcpToolsUpdate prop to ConversationThread interface
- Pass setMcpTools function from ChatApp down to ConversationThread
- Connect McpServerModal onToolsUpdate to parent state update
- Now plug icon will correctly show '1 (N)' when N tools are available
- Fixes issue where tool count remained at 0 despite successful connection
This commit is contained in:
Glen Maddern 2025-06-23 16:11:42 +10:00
commit 812fdf92e3
2 changed files with 4 additions and 3 deletions

View file

@ -143,6 +143,7 @@ const ChatApp: React.FC<ChatAppProps> = () => {
onModelChange={handleModelChange}
apiKeyUpdateTrigger={apiKeyUpdateTrigger}
mcpTools={mcpTools}
onMcpToolsUpdate={setMcpTools}
/>
</div>
</div>

View file

@ -27,6 +27,7 @@ interface ConversationThreadProps {
onModelChange: (model: Model) => void
apiKeyUpdateTrigger: number
mcpTools: Tool[]
onMcpToolsUpdate: (tools: Tool[]) => void
}
const ConversationThread: React.FC<ConversationThreadProps> = ({
@ -40,6 +41,7 @@ const ConversationThread: React.FC<ConversationThreadProps> = ({
onModelChange,
apiKeyUpdateTrigger,
mcpTools,
onMcpToolsUpdate,
}) => {
const [input, setInput] = useState<string>('')
const [apiKeyModal, setApiKeyModal] = useState<{ isOpen: boolean; model: Model | null }>({
@ -269,9 +271,7 @@ const ConversationThread: React.FC<ConversationThreadProps> = ({
<McpServerModal
isOpen={mcpServerModal}
onClose={() => setMcpServerModal(false)}
onToolsUpdate={(tools) => {
// This will be handled by the existing MCP tools logic in ChatApp
}}
onToolsUpdate={onMcpToolsUpdate}
/>
</div>
)