Skip to content

A reactive notebook for Python — run reproducible experiments, query with SQL, execute as a script, deploy as an app, and version with git. Stored as pure Python. All in a modern, AI-native editor.

merge Agents and chat into 1 sidebar panel (#7332)

Shahmir Varqhaf82b9e55bf5a
diff --git a/frontend/src/components/chat/acp/agent-panel.tsx b/frontend/src/components/chat/acp/agent-panel.tsx
index 009afcf590..ceffc8649c 100644
--- a/frontend/src/components/chat/acp/agent-panel.tsx
+++ b/frontend/src/components/chat/acp/agent-panel.tsx
@@ -94,9 +94,7 @@ interface AgentTitleProps {
}
const AgentTitle = memo<AgentTitleProps>(({ currentAgentId }) => (
- <span className="text-sm font-medium">
- {currentAgentId ? capitalize(currentAgentId) : "Agents"}
- </span>
+ <span className="text-sm font-medium">{capitalize(currentAgentId)}</span>
));
AgentTitle.displayName = "AgentTitle";
@@ -134,7 +132,7 @@ const HeaderInfo = memo<HeaderInfoProps>(
({ currentAgentId, connectionStatus, shouldShowConnectionControl }) => (
<div className="flex items-center gap-2">
<BotMessageSquareIcon className="h-4 w-4 text-muted-foreground" />
- <AgentTitle currentAgentId={currentAgentId} />
+ {currentAgentId && <AgentTitle currentAgentId={currentAgentId} />}
{shouldShowConnectionControl && (
<ConnectionStatus status={connectionStatus} />
)}
diff --git a/frontend/src/components/editor/chrome/types.ts b/frontend/src/components/editor/chrome/types.ts
index 8f602cf104..088f63a938 100644
--- a/frontend/src/components/editor/chrome/types.ts
+++ b/frontend/src/components/editor/chrome/types.ts
@@ -2,14 +2,13 @@
import {
ActivityIcon,
- BotMessageSquareIcon,
+ BotIcon,
BoxIcon,
DatabaseIcon,
DatabaseZapIcon,
FileTextIcon,
FolderTreeIcon,
FunctionSquareIcon,
- HatGlassesIcon,
KeyRoundIcon,
type LucideIcon,
NetworkIcon,
@@ -34,8 +33,7 @@ export type PanelType =
| "snippets"
| "datasources"
| "scratchpad"
- | "chat"
- | "agents"
+ | "ai"
| "cache"
| "secrets"
| "logs";
@@ -91,25 +89,15 @@ export const PANELS: PanelDescriptor[] = [
tooltip: "Manage packages",
position: "sidebar",
},
- // 2. "Add cells" panels.
+ // 2. "AI" panel.
//
- // We start with chat because it's the easiest
- // way to add new cells to the editor.
+ // The AI panel holds both agents and in-editor chat.
{
- type: "chat",
- Icon: BotMessageSquareIcon,
- tooltip: "Chat with AI",
+ type: "ai",
+ Icon: BotIcon,
+ tooltip: "Chat & Agents",
position: "sidebar",
},
- {
- // TODO(akshayka): Consider merging with chat panel
- // before release.
- type: "agents",
- Icon: HatGlassesIcon,
- tooltip: "Agents",
- position: "sidebar",
- hidden: !getFeatureFlag("external_agents"),
- },
// Scratchpad is the only way users can
// code without DAG restrictions, so it is
// privileged.
diff --git a/frontend/src/components/editor/chrome/wrapper/app-chrome.tsx b/frontend/src/components/editor/chrome/wrapper/app-chrome.tsx
index c54bd44285..eeded15d3f 100644
--- a/frontend/src/components/editor/chrome/wrapper/app-chrome.tsx
+++ b/frontend/src/components/editor/chrome/wrapper/app-chrome.tsx
@@ -12,7 +12,9 @@ import "./app-chrome.css";
import { TooltipProvider } from "@radix-ui/react-tooltip";
import { XIcon } from "lucide-react";
import { Button } from "@/components/ui/button";
+import { Tabs, TabsList, TabsTrigger } from "@/components/ui/tabs";
import { LazyMount } from "@/components/utils/lazy-mount";
+import { getFeatureFlag } from "@/core/config/feature-flag";
import { IfCapability } from "@/core/config/if-capability";
import { cn } from "@/utils/cn";
import { ErrorBoundary } from "../../boundary/ErrorBoundary";
@@ -21,6 +23,7 @@ import { useChromeActions, useChromeState } from "../state";
import { Minimap } from "./minimap";
import { PanelsWrapper } from "./panels";
import { PendingAICells } from "./pending-ai-cells";
+import { useAiPanelTab } from "./useAiPanel";
import { handleDragging } from "./utils";
const LazyTerminal = React.lazy(() => import("@/components/terminal/terminal"));
@@ -58,6 +61,7 @@ export const AppChrome: React.FC<PropsWithChildren> = ({ children }) => {
const { setIsSidebarOpen, setIsTerminalOpen } = useChromeActions();
const sidebarRef = React.useRef<ImperativePanelHandle>(null);
const terminalRef = React.useRef<ImperativePanelHandle>(null);
+ const { aiPanelTab, setAiPanelTab } = useAiPanelTab();
// sync sidebar
useEffect(() => {
@@ -135,13 +139,48 @@ export const AppChrome: React.FC<PropsWithChildren> = ({ children }) => {
/>
);
+ const agentsEnabled = getFeatureFlag("external_agents");
+
+ const renderAiPanel = () => {
+ if (agentsEnabled && aiPanelTab === "agents") {
+ return <LazyAgentPanel />;
+ }
+ return <LazyChatPanel />;
+ };
+
const helpPaneBody = (
<ErrorBoundary>
<div className="flex flex-col h-full flex-1 overflow-hidden mr-[-4px]">
<div className="p-3 border-b flex justify-between items-center">
- <div className="text-sm text-(--slate-11) uppercase tracking-wide font-semibold flex-1">
- {selectedPanel}
- </div>
+ {selectedPanel === "ai" && agentsEnabled ? (
+ <Tabs
+ value={aiPanelTab}
+ onValueChange={(value) => {
+ if (value === "chat" || value === "agents") {
+ setAiPanelTab(value);
+ }
+ }}
+ >
+ <TabsList>
+ <TabsTrigger
+ value="chat"
+ className="py-0.5 text-xs uppercase tracking-wide font-bold"
+ >
+ Chat
+ </TabsTrigger>
+ <TabsTrigger
+ value="agents"
+ className="py-0.5 text-xs uppercase tracking-wide font-bold"
+ >
+ Agents
+ </TabsTrigger>
+ </TabsList>
+ </Tabs>
+ ) : (
+ <span className="text-sm text-(--slate-11) uppercase tracking-wide font-semibold flex-1">
+ {selectedPanel}
+ </span>
+ )}
<Button
data-testid="close-helper-pane"
className="m-0"
@@ -164,8 +203,7 @@ export const AppChrome: React.FC<PropsWithChildren> = ({ children }) => {
{selectedPanel === "documentation" && <LazyDocumentationPanel />}
{selectedPanel === "snippets" && <LazySnippetsPanel />}
{selectedPanel === "scratchpad" && <LazyScratchpadPanel />}
- {selectedPanel === "chat" && <LazyChatPanel />}
- {selectedPanel === "agents" && <LazyAgentPanel />}
+ {selectedPanel === "ai" && renderAiPanel()}
{selectedPanel === "logs" && <LazyLogsPanel />}
{selectedPanel === "tracing" && <LazyTracingPanel />}
{selectedPanel === "secrets" && <LazySecretsPanel />}
diff --git a/frontend/src/components/editor/chrome/wrapper/useAiPanel.ts b/frontend/src/components/editor/chrome/wrapper/useAiPanel.ts
new file mode 100644
index 0000000000..702c415f15
--- /dev/null
+++ b/frontend/src/components/editor/chrome/wrapper/useAiPanel.ts
@@ -0,0 +1,18 @@
+/* Copyright 2024 Marimo. All rights reserved. */
+
+import { useAtom } from "jotai";
+import { atomWithStorage } from "jotai/utils";
+import { jotaiJsonStorage } from "@/utils/storage/jotai";
+
+const AI_PANEL_TAB_KEY = "marimo:chrome:ai-panel-tab";
+
+const aiPanelTabAtom = atomWithStorage<"chat" | "agents">(
+ AI_PANEL_TAB_KEY,
+ "chat",
+ jotaiJsonStorage,
+);
+
+export function useAiPanelTab() {
+ const [aiPanelTab, setAiPanelTab] = useAtom(aiPanelTabAtom);
+ return { aiPanelTab, setAiPanelTab };
+}