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} onModelChange={handleModelChange}
apiKeyUpdateTrigger={apiKeyUpdateTrigger} apiKeyUpdateTrigger={apiKeyUpdateTrigger}
mcpTools={mcpTools} mcpTools={mcpTools}
onMcpToolsUpdate={setMcpTools}
/> />
</div> </div>
</div> </div>

View file

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