Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

import { useState, useCallback, useEffect, type Ref } from 'react';
import { useState, useCallback, useEffect, useRef, type Ref } from 'react';
import Box from '@mui/material/Box';
import LinearProgress from '@mui/material/LinearProgress';
import Alert from '@mui/material/Alert';
Expand Down Expand Up @@ -97,6 +97,8 @@ export function ChatView({
const [currentAgent, setCurrentAgent] = useState<string | undefined>();
const [showMarketplace, setShowMarketplace] = useState(true);
const [marketplaceRefreshKey, setMarketplaceRefreshKey] = useState(0);
const [switchToMyAgents, setSwitchToMyAgents] = useState(0);
const justCreatedRef = useRef(false);

// Agent creation state (all dialogs live in the front door)
const [intentDialogOpen, setIntentDialogOpen] = useState(false);
Expand Down Expand Up @@ -201,6 +203,10 @@ export function ChatView({
const handleWizardBack = useCallback(() => {
setWizardOpen(false);
setWizardDeployMethod(undefined);
if (justCreatedRef.current) {
justCreatedRef.current = false;
return;
}
setIntentDialogOpen(true);
}, []);

Expand Down Expand Up @@ -236,12 +242,14 @@ export function ChatView({
}, []);

const handleAgentCreated = useCallback(() => {
justCreatedRef.current = true;
setWizardOpen(false);
setWizardDeployMethod(undefined);
setCreateSuccess(
'Agent created successfully! It will appear in your agents list.',
);
setMarketplaceRefreshKey(k => k + 1);
setSwitchToMyAgents(k => k + 1);
}, []);

// --- Tool Creation Flow ---
Expand Down Expand Up @@ -322,6 +330,7 @@ export function ChatView({
onOpenCommandCenter={handleSwitchToAdmin}
onOpenGuidedTour={handleOpenGuidedTour}
refreshKey={marketplaceRefreshKey}
switchToMyAgentsKey={switchToMyAgents}
/>
</Box>
)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ interface MarketplacePageProps {
onOpenCommandCenter?: () => void;
onOpenGuidedTour?: () => void;
refreshKey?: number;
/** When this key changes, automatically switch to the My Agents tab */
switchToMyAgentsKey?: number;
}

/**
Expand All @@ -66,6 +68,7 @@ export function MarketplacePage({
onOpenCommandCenter,
onOpenGuidedTour,
refreshKey,
switchToMyAgentsKey,
}: MarketplacePageProps) {
const theme = useTheme();
const isDark = theme.palette.mode === 'dark';
Expand Down Expand Up @@ -120,6 +123,12 @@ export function MarketplacePage({
};
}, [api, refreshKey]);

useEffect(() => {
if (switchToMyAgentsKey && switchToMyAgentsKey > 0) {
setActiveTab('my-agents');
}
}, [switchToMyAgentsKey]);

const frameworks = useMemo(() => {
const set = new Set<string>();
agents.forEach(a => {
Expand Down
Loading