Skip to content

AI Agents & MCPs & AI Workflow Automation • (~400 MCP servers for AI agents) • AI Automation / AI Agent with MCPs • AI Workflows & AI Agents • MCPs for AI Agents

feat(agents): the runs and configure panels open and close smoothly, with buttons that stay in place (#16035)

Hazem Adel0749c55d8a62
diff --git a/bun.lock b/bun.lock
index 27156051794..565e438c6c2 100644
--- a/bun.lock
+++ b/bun.lock
@@ -1,5 +1,6 @@
{
"lockfileVersion": 1,
+ "configVersion": 0,
"workspaces": {
"": {
"name": "activepieces",
@@ -151,7 +152,7 @@
},
"packages/core/piece-types": {
"name": "@activepieces/core-piece-types",
- "version": "0.12.0",
+ "version": "0.12.1",
"dependencies": {
"@activepieces/core-utils": "workspace:*",
"tslib": "2.6.2",
@@ -164,7 +165,7 @@
},
"packages/core/shared": {
"name": "@activepieces/shared",
- "version": "0.187.0",
+ "version": "0.188.0",
"dependencies": {
"@activepieces/core-execution": "workspace:*",
"@activepieces/core-formula": "workspace:*",
@@ -4675,7 +4676,7 @@
},
"packages/pieces/community/jina-ai": {
"name": "@activepieces/piece-jina-ai",
- "version": "0.1.7",
+ "version": "0.2.0",
"dependencies": {
"@activepieces/core-piece-types": "workspace:*",
"@activepieces/core-utils": "workspace:*",
@@ -5476,7 +5477,7 @@
},
"packages/pieces/community/maileroo": {
"name": "@activepieces/piece-maileroo",
- "version": "0.2.5",
+ "version": "0.3.0",
"dependencies": {
"@activepieces/core-piece-types": "workspace:*",
"@activepieces/core-utils": "workspace:*",
diff --git a/packages/web/src/app/routes/agents/id/configure-panel/index.tsx b/packages/web/src/app/routes/agents/id/configure-panel/index.tsx
index 51d8a209e6a..46f9e2e9a46 100644
--- a/packages/web/src/app/routes/agents/id/configure-panel/index.tsx
+++ b/packages/web/src/app/routes/agents/id/configure-panel/index.tsx
@@ -14,7 +14,13 @@ import {
import { zodResolver } from '@hookform/resolvers/zod';
import { t } from 'i18next';
import { ChevronRight, Trash2, X } from 'lucide-react';
-import { useEffect, useRef, useState } from 'react';
+import {
+ forwardRef,
+ useEffect,
+ useImperativeHandle,
+ useRef,
+ useState,
+} from 'react';
import { useForm } from 'react-hook-form';
import { useNavigate } from 'react-router-dom';
import { toast } from 'sonner';
@@ -481,13 +487,10 @@ const ScrollFade = ({
);
};
-const AgentConfigurePanel = ({
- agent,
- onExit,
-}: {
- agent: Agent;
- onExit: () => void;
-}) => {
+const AgentConfigurePanel = forwardRef<
+ AgentConfigurePanelHandle,
+ { agent: Agent; onExit: () => void }
+>(({ agent, onExit }, ref) => {
const form = useForm<ConfigureAgentInput, unknown, ConfigureAgentValues>({
resolver: zodResolver(ConfigureAgentSchema),
defaultValues: formValuesOf(agent),
@@ -590,6 +593,7 @@ const AgentConfigurePanel = ({
};
const requestExit = () => (unsavedTyping ? setExitRequested(true) : onExit());
+ useImperativeHandle(ref, () => ({ requestExit }));
return (
<Form {...form}>
@@ -710,6 +714,8 @@ const AgentConfigurePanel = ({
</form>
</Form>
);
-};
+});
+AgentConfigurePanel.displayName = 'AgentConfigurePanel';
export { AgentConfigurePanel };
+export type AgentConfigurePanelHandle = { requestExit: () => void };
diff --git a/packages/web/src/app/routes/agents/id/index.tsx b/packages/web/src/app/routes/agents/id/index.tsx
index fadf27231b1..d4a53946d2f 100644
--- a/packages/web/src/app/routes/agents/id/index.tsx
+++ b/packages/web/src/app/routes/agents/id/index.tsx
@@ -2,7 +2,7 @@ import { isNil, unique } from '@activepieces/core-utils';
import { Agent, AgentToolType } from '@activepieces/shared';
import { t } from 'i18next';
import { ChevronLeft, History, SearchX, Settings2 } from 'lucide-react';
-import { useState } from 'react';
+import { useEffect, useRef, useState, useSyncExternalStore } from 'react';
import {
useLocation,
useNavigate,
@@ -27,7 +27,10 @@ import { authenticationSession } from '@/lib/authentication-session';
import { cn } from '@/lib/utils';
import { AgentChatView } from './agent-chat-view';
-import { AgentConfigurePanel } from './configure-panel';
+import {
+ AgentConfigurePanel,
+ AgentConfigurePanelHandle,
+} from './configure-panel';
import { AgentRuns } from './runs';
const pieceDisplayName = (pieceName: string): string =>
@@ -52,11 +55,13 @@ const buildCapabilityNote = (agent: Agent): string => {
});
};
-type OpenPanel = 'conversations' | 'configure' | 'none';
+type RightPanel = 'runs' | 'configure';
const CONVERSATION_QUERY_PARAM = 'conversation';
const RUNS_TAB = 'runs';
const CHAT_TAB = 'chat';
+const WIDE_ENOUGH_QUERY = '(min-width: 1280px)';
+const SLIDE_MS = 200;
const SLIDING_ASIDE =
'shrink-0 overflow-hidden border-border transition-[width] duration-200 ease-out';
@@ -82,8 +87,15 @@ const AgentEditorContent = () => {
const { pathname, state: locationState } = useLocation();
const [backTo] = useState(() => backDestination(locationState));
const agentsAvailable = useAgentsAvailable();
- const [openPanel, setOpenPanel] = useState<OpenPanel>();
- const [configureMounted, setConfigureMounted] = useState(false);
+ const [conversationsOpen, setConversationsOpen] = useState(true);
+ const [expandedBesidePanel, setExpandedBesidePanel] = useState(false);
+ const roomForBoth = useSyncExternalStore(
+ subscribeToWindowWidth,
+ roomForConversationsBesidePanel,
+ );
+ const [configureChosen, setConfigureChosen] = useState<boolean>();
+ const configureRef = useRef<AgentConfigurePanelHandle>(null);
+ const [renderedPanel, setRenderedPanel] = useState<RightPanel | null>(null);
const [searchParams, setSearchParams] = useSearchParams();
const conversationId =
searchParams.get(CONVERSATION_QUERY_PARAM) ?? undefined;
@@ -140,27 +152,48 @@ const AgentEditorContent = () => {
});
const needsModel = agent !== undefined && needsAModel(agent);
- const panel: OpenPanel =
- openPanel ?? (needsModel && !runsOpen ? 'configure' : 'conversations');
- const configureOpen = panel === 'configure';
- const conversationsOpen = panel === 'conversations';
+ const configureOpen = configureChosen ?? (needsModel && !runsOpen);
const runsVisible = runsOpen && !configureOpen;
const toggleRuns = () => showTab(runsVisible ? CHAT_TAB : RUNS_TAB);
- const openConfigure = () => {
- setOpenPanel('configure');
+ const toggleConfigure = () => {
+ if (configureOpen) {
+ configureRef.current?.requestExit();
+ return;
+ }
+ setConfigureChosen(true);
if (runsOpen) {
showTab(CHAT_TAB);
}
};
+ const activePanel: RightPanel | null = configureOpen
+ ? 'configure'
+ : runsVisible
+ ? 'runs'
+ : null;
if (runsOpen !== runsWereOpen) {
setRunsWereOpen(runsOpen);
if (runsOpen && configureOpen) {
- setOpenPanel('conversations');
+ setConfigureChosen(false);
}
}
- if (configureOpen && !configureMounted) {
- setConfigureMounted(true);
+ if (activePanel !== null && activePanel !== renderedPanel) {
+ setRenderedPanel(activePanel);
+ }
+ if (renderedPanel === null && expandedBesidePanel) {
+ setExpandedBesidePanel(false);
}
+ const panelCrowdsConversations = renderedPanel !== null && !roomForBoth;
+ const conversationsShown =
+ conversationsOpen && (!panelCrowdsConversations || expandedBesidePanel);
+
+ const panelIsSlidingOut = activePanel === null && renderedPanel !== null;
+ useEffect(() => {
+ if (!panelIsSlidingOut) {
+ return;
+ }
+ const timer = setTimeout(() => setRenderedPanel(null), SLIDE_MS);
+ return () => clearTimeout(timer);
+ }, [panelIsSlidingOut]);
if (isLoading) {
return <AgentEditorSkeleton />;
@@ -192,104 +225,112 @@ const AgentEditorContent = () => {
}
return (
- <div className="flex h-full w-full">
- <div className="flex min-w-0 grow flex-col">
- <div className="flex h-[60px] shrink-0 items-center gap-3 border-b border-border px-5">
- <button
- type="button"
- aria-label={t('Back')}
- onClick={() => navigate(backTo)}
- className="flex size-7 shrink-0 items-center justify-center rounded-lg text-muted-foreground transition-colors hover:bg-accent hover:text-foreground"
- >
- <ChevronLeft size={16} />
- </button>
- <AgentMark size="sm" icon={agent.icon} color={agent.color} />
- <div className="flex min-w-0 grow basis-0 flex-col gap-px">
- <span className="truncate text-base font-semibold leading-5 tracking-[-0.01em]">
- {agent.displayName}
- </span>
- <span className="truncate text-xs leading-4 text-muted-foreground">
- {agent.description ?? t('No description yet')}
- </span>
- </div>
+ <div className="flex h-full w-full flex-col">
+ <div className="flex h-[60px] shrink-0 items-center gap-3 border-b border-border px-5">
+ <button
+ type="button"
+ aria-label={t('Back')}
+ onClick={() => navigate(backTo)}
+ className="flex size-7 shrink-0 items-center justify-center rounded-lg text-muted-foreground transition-colors hover:bg-accent hover:text-foreground"
+ >
+ <ChevronLeft size={16} />
+ </button>
+ <AgentMark size="sm" icon={agent.icon} color={agent.color} />
+ <div className="flex min-w-0 grow basis-0 flex-col gap-px">
+ <span className="truncate text-base font-semibold leading-5 tracking-[-0.01em]">
+ {agent.displayName}
+ </span>
+ <span className="truncate text-xs leading-4 text-muted-foreground">
+ {agent.description ?? t('No description yet')}
+ </span>
+ </div>
+ <div className="flex shrink-0 items-center gap-1">
<Button
type="button"
- variant="outline"
- className="h-[34px] shrink-0 gap-2 rounded-lg px-[13px]"
+ variant="ghost"
+ className="gap-2 px-2"
aria-pressed={runsVisible}
onClick={toggleRuns}
>
- <History size={15} />
+ <History className="size-4" />
{t('Runs')}
</Button>
- {!configureOpen && (
- <div className="flex min-w-0 shrink items-center gap-2">
- <Button
- type="button"
- variant="outline"
- className="h-[34px] shrink-0 gap-2 rounded-lg px-[13px] animate-in fade-in duration-200"
- onClick={openConfigure}
- >
- <Settings2 size={15} />
- {t('Configure')}
- </Button>
- </div>
- )}
+ <Button
+ type="button"
+ variant="ghost"
+ className="gap-2 px-2"
+ aria-pressed={configureOpen}
+ onClick={toggleConfigure}
+ >
+ <Settings2 className="size-4" />
+ {t('Configure')}
+ </Button>
</div>
- <div className="flex min-h-0 grow">
+ </div>
+ <div className="flex min-h-0 grow">
+ <div className="flex min-w-0 grow">
<AgentChatView
agent={agent}
- conversationsOpen={conversationsOpen}
+ conversationsOpen={conversationsShown}
openedConversationId={openedConversationId ?? conversationId}
chatSessionKey={chatSessionKey}
footerNote={buildCapabilityNote(agent)}
onSelectConversation={openConversation}
onNewConversation={startNewConversation}
- onCollapseConversations={() => setOpenPanel('none')}
- onExpandConversations={() => setOpenPanel('conversations')}
+ onCollapseConversations={() => {
+ setExpandedBesidePanel(false);
+ setConversationsOpen(false);
+ }}
+ onExpandConversations={() => {
+ setExpandedBesidePanel(panelCrowdsConversations);
+ setConversationsOpen(true);
+ }}
onConversationCreated={writeConversationParam}
/>
</div>
- </div>
- <aside
- className={cn(
- SLIDING_ASIDE,
- 'border-l',
- runsVisible ? 'w-[400px]' : 'w-0',
- )}
- >
- <div className="flex h-full w-[400px] flex-col">
- {runsVisible && (
- <AgentRuns agentId={agent.id} onClose={() => showTab(CHAT_TAB)} />
+ <aside
+ className={cn(
+ SLIDING_ASIDE,
+ 'border-l',
+ activePanel !== null ? 'w-[452px]' : 'w-0',
)}
- </div>
- </aside>
- <aside
- onTransitionEnd={(event) => {
- if (event.propertyName === 'width' && !configureOpen) {
- setConfigureMounted(false);
- }
- }}
- className={cn(
- SLIDING_ASIDE,
- 'border-l',
- configureOpen ? 'w-[452px]' : 'w-0',
- )}
- >
- <div className="flex h-full w-[452px] flex-col">
- {configureMounted && (
- <AgentConfigurePanel
- key={agent.id}
- agent={agent}
- onExit={() => setOpenPanel('none')}
- />
+ >
+ {renderedPanel !== null && (
+ <div
+ key={renderedPanel}
+ className="flex h-full w-[452px] flex-col animate-in fade-in duration-150"
+ >
+ {renderedPanel === 'runs' ? (
+ <AgentRuns
+ agentId={agent.id}
+ onClose={() => showTab(CHAT_TAB)}
+ />
+ ) : (
+ <AgentConfigurePanel
+ key={agent.id}
+ ref={configureRef}
+ agent={agent}
+ onExit={() => setConfigureChosen(false)}
+ />
+ )}
+ </div>
)}
- </div>
- </aside>
+ </aside>
+ </div>
</div>
);
};
+function roomForConversationsBesidePanel(): boolean {
+ return window.matchMedia(WIDE_ENOUGH_QUERY).matches;
+}
+
+function subscribeToWindowWidth(onChange: () => void): () => void {
+ const query = window.matchMedia(WIDE_ENOUGH_QUERY);
+ query.addEventListener('change', onChange);
+ return () => query.removeEventListener('change', onChange);
+}
+
function backDestination(state: unknown): string {
if (
typeof state === 'object' &&
diff --git a/packages/web/test/app/routes/agents/id/side-panel.test.tsx b/packages/web/test/app/routes/agents/id/side-panel.test.tsx
new file mode 100644
index 00000000000..ecd816535b9
--- /dev/null
+++ b/packages/web/test/app/routes/agents/id/side-panel.test.tsx
@@ -0,0 +1,217 @@
+// @vitest-environment jsdom
+import {
+ act,
+ cleanup,
+ fireEvent,
+ render,
+ screen,
+ waitFor,
+} from '@testing-library/react';
+import { forwardRef, useImperativeHandle } from 'react';
+import { MemoryRouter, Route, Routes } from 'react-router-dom';
+import {
+ afterEach,
+ beforeEach,
+ describe,
+ expect,
+ it,
+ vi,
+} from 'vitest';
+
+vi.mock('i18next', () => ({ t: (key: string) => key }));
+vi.mock('@/app/components/locked-feature-guard', () => ({
+ LockedFeatureGuard: ({ children }: { children: React.ReactNode }) => (
+ <>{children}</>
+ ),
+}));
+vi.mock('@/features/agents', () => ({ useAgentsAvailable: () => true }));
+vi.mock('@/features/agents/agent-mark', () => ({ AgentMark: () => null }));
+vi.mock('@/lib/authentication-session', () => ({
+ authenticationSession: { appendProjectRoutePrefix: (path: string) => path },
+}));
+vi.mock('@/features/agents/hooks/agents-hooks', () => ({
+ agentsQueries: {
+ useAgent: () => ({
+ isLoading: false,
+ isError: false,
+ data: {
+ id: 'agent_1',
+ displayName: 'Travel Desk',
+ description: null,
+ published: { provider: 'openai', modelName: 'gpt-5', tools: [] },
+ draft: { provider: 'openai', modelName: 'gpt-5', tools: [] },
+ },
+ }),
+ },
+}));
+vi.mock('@/app/routes/agents/id/agent-chat-view', () => ({
+ AgentChatView: ({
+ conversationsOpen,
+ onCollapseConversations,
+ }: {
+ conversationsOpen: boolean;
+ onCollapseConversations: () => void;
+ }) => (
+ <div data-testid="chat" data-conversations={String(conversationsOpen)}>
+ <button type="button" onClick={onCollapseConversations}>
+ collapse-list
+ </button>
+ </div>
+ ),
+}));
+vi.mock('@/app/routes/agents/id/runs', () => ({
+ AgentRuns: () => <div data-testid="runs-panel" />,
+}));
+vi.mock('@/app/routes/agents/id/configure-panel', () => ({
+ AgentConfigurePanel: forwardRef<
+ { requestExit: () => void },
+ { onExit: () => void }
+ >(({ onExit }, ref) => {
+ useImperativeHandle(ref, () => ({ requestExit: onExit }));
+ return <div data-testid="configure-panel" />;
+ }),
+}));
+
+import { AgentEditorPage } from '@/app/routes/agents/id';
+
+const mediaLists = new Set<FakeMediaQueryList>();
+let windowIsWide = true;
+
+beforeEach(() => {
+ setWindowWide(true);
+});
+afterEach(cleanup);
+
+describe('agent side panel', () => {
+ it('keeps the runs panel content while it slides closed, then removes it', async () => {
+ renderPage({ path: '/agents/agent_1' });
+ click('Runs');
+ expect(await screen.findByTestId('runs-panel')).toBeTruthy();
+
+ click('Runs');
+ await waitFor(() => expect(sidePanel().className).toContain('w-0'));
+ expect(screen.getByTestId('runs-panel')).toBeTruthy();
+
+ await waitFor(() => expect(screen.queryByTestId('runs-panel')).toBeNull());
+ });
+
+ it('swaps runs for configure without resizing the panel', async () => {
+ renderPage({ path: '/agents/agent_1/runs' });
+ expect(await screen.findByTestId('runs-panel')).toBeTruthy();
+
+ click('Configure');
+ expect(screen.getByTestId('configure-panel')).toBeTruthy();
+ expect(screen.queryByTestId('runs-panel')).toBeNull();
+ expect(sidePanel().className).toContain('w-[452px]');
+ });
+
+ it('folds the conversations list when a panel opens on a narrow screen', async () => {
+ setWindowWide(false);
+ renderPage({ path: '/agents/agent_1' });
+ expect(conversationsShown()).toBe('true');
+
+ click('Runs');
+ await waitFor(() => expect(conversationsShown()).toBe('false'));
+
+ click('Runs');
+ await waitFor(() => expect(sidePanel().className).toContain('w-0'));
+ expect(conversationsShown()).toBe('false');
+ await waitFor(() => expect(conversationsShown()).toBe('true'));
+ });
+
+ it('folds the list when the window narrows while a panel is open', async () => {
+ renderPage({ path: '/agents/agent_1' });
+ click('Runs');
+ await screen.findByTestId('runs-panel');
+ expect(conversationsShown()).toBe('true');
+
+ act(() => setWindowWide(false));
+ expect(conversationsShown()).toBe('false');
+ });
+
+ it('leaves a list the user collapsed collapsed after the panel closes', async () => {
+ setWindowWide(false);
+ renderPage({ path: '/agents/agent_1' });
+ click('collapse-list');
+ expect(conversationsShown()).toBe('false');
+
+ click('Runs');
+ await screen.findByTestId('runs-panel');
+ click('Runs');
+ await waitFor(() => expect(sidePanel().className).toContain('w-0'));
+ await waitFor(() =>
+ expect(screen.queryByTestId('runs-panel')).toBeNull(),
+ );
+ expect(conversationsShown()).toBe('false');
+ });
+
+ it('keeps the conversations list beside a panel on a wide screen', () => {
+ renderPage({ path: '/agents/agent_1' });
+ click('Configure');
+ expect(conversationsShown()).toBe('true');
+ });
+
+ it('closes configure from its header button through the panel exit', () => {
+ renderPage({ path: '/agents/agent_1' });
+ click('Configure');
+ expect(sidePanel().className).toContain('w-[452px]');
+
+ click('Configure');
+ expect(sidePanel().className).toContain('w-0');
+ });
+});
+
+function renderPage({ path }: { path: string }) {
+ return render(
+ <MemoryRouter initialEntries={[path]}>
+ <Routes>
+ <Route path="/agents/:agentId" element={<AgentEditorPage />} />
+ <Route path="/agents/:agentId/runs" element={<AgentEditorPage />} />
+ </Routes>
+ </MemoryRouter>,
+ );
+}
+
+function setWindowWide(wide: boolean) {
+ windowIsWide = wide;
+ window.matchMedia = (query: string) => {
+ const list = new FakeMediaQueryList(query);
+ mediaLists.add(list);
+ return list;
+ };
+ mediaLists.forEach((list) => list.dispatchEvent(new Event('change')));
+}
+
+function conversationsShown(): string | null {
+ return screen.getByTestId('chat').getAttribute('data-conversations');
+}
+
+function click(name: string) {
+ fireEvent.click(screen.getByRole('button', { name }));
+}
+
+function sidePanel(): HTMLElement {
+ const panel = document.querySelector('aside');
+ if (panel === null) throw new Error('side panel not rendered');
+ return panel;
+}
+
+
+
+class FakeMediaQueryList extends EventTarget implements MediaQueryList {
+ readonly media: string;
+ onchange = null;
+ constructor(media: string) {
+ super();
+ this.media = media;
+ }
+ get matches(): boolean {
+ return windowIsWide;
+ }
+ addListener(): void {
+ return undefined;
+ }
+ removeListener(): void {
+ return undefined;
+ }
+}