Skip to content

Commit

Permalink
chore: onagentselect
Browse files Browse the repository at this point in the history
  • Loading branch information
CristiCanizales committed Mar 1, 2025
1 parent 932cc61 commit acc9a79
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 1 deletion.
14 changes: 13 additions & 1 deletion agent-chat/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,21 @@ const App: React.FC = () => {
}
};

const handleAgentSelect = (agent: string) => {
console.log('Selected Agent:', agent);
if (vscode) {
vscode.postMessage({ command: 'selectAgent', agent });
}
};

return (
<div className="app-container">
<Navbar currentAgent={currentAgent} setCurrentAgent={setCurrentAgent} onEndSession={handleEndSession} />
<Navbar
currentAgent={currentAgent}
setCurrentAgent={setCurrentAgent}
onAgentSelect={handleAgentSelect}
onEndSession={handleEndSession}
/>
<MainContainer className="chat-container">
<ChatContainer className="chat-container">
<MessageList
Expand Down
3 changes: 3 additions & 0 deletions agent-chat/src/components/Navbar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,12 @@ import { useState } from 'react';
const Navbar = ({
currentAgent,
setCurrentAgent,
onAgentSelect,
onEndSession
}: {
currentAgent: string;
setCurrentAgent: (agent: string) => void;
onAgentSelect: (agent: string) => void;
onEndSession: () => void;
}) => {
const [anchorEl, setAnchorEl] = useState<null | HTMLElement>(null);
Expand All @@ -24,6 +26,7 @@ const Navbar = ({

const handleSelectAgent = (agent: string) => {
setCurrentAgent(agent);
onAgentSelect(agent);
handleMenuClose();
};

Expand Down
3 changes: 3 additions & 0 deletions src/views/agentChatViewProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,9 @@ export class AgentChatViewProvider implements vscode.WebviewViewProvider {
this.agentPreview = undefined;

webviewView.webview.postMessage({ command: 'sessionEnded' });
} else if (message.command === 'selectAgent') {
console.log('Agent selected:', message.agent);
// TODO: logic to get bot id from agent name
}
} catch (error) {
console.error('Error:', error);
Expand Down

0 comments on commit acc9a79

Please sign in to comment.