Skip to content

armgit / macro

Public Imported from GitHub
0

Macro is a unified workspace for teams: email, chat, docs, tasks, agents, calls, and CRM — @-linked together with shared AI memory.

feat(agents): unify chat and coding workspace (#6512)

Eric Hayes679c0a923792
diff --git a/apps/web/src/components/app/sidebar-next/list-nav.tsx b/apps/web/src/components/app/sidebar-next/list-nav.tsx
index f27ead0876..0e2d14f4e0 100644
--- a/apps/web/src/components/app/sidebar-next/list-nav.tsx
+++ b/apps/web/src/components/app/sidebar-next/list-nav.tsx
@@ -1,3 +1,4 @@
+import { parseAgentsRoute } from '@app/features/agents-view/core/route';
import { useAnalytics } from '@app/lib/analytics/analytics-context';
import { globalSplitManager } from '@app/signal/splitLayout';
import {
@@ -72,6 +73,12 @@ export const ListNav = (props: ListNavProps) => {
.includes(props.item.id);
}
const expected = content();
+ if (
+ props.item.id === 'agents' &&
+ activeContent.type === 'component' &&
+ parseAgentsRoute(activeContent.id)
+ )
+ return true;
return (
activeContent.type === expected.type && activeContent.id === expected.id
);
diff --git a/apps/web/src/components/app/split-layout/componentRegistry.tsx b/apps/web/src/components/app/split-layout/componentRegistry.tsx
index 6757ebd4b9..24401f6f3d 100644
--- a/apps/web/src/components/app/split-layout/componentRegistry.tsx
+++ b/apps/web/src/components/app/split-layout/componentRegistry.tsx
@@ -1,5 +1,6 @@
import { openEntityInSplit } from '@app/features/activity/open-entity-in-split';
import { useActivityFeedFlag } from '@app/features/activity/use-activity-feed-flag';
+import { parseAgentsRoute } from '@app/features/agents-view/core/route';
import { AgentsView } from '@app/features/agents-view/views/AgentsView';
import { ComposeAgentSession } from '@app/features/block-agent/component/ComposeAgentSession';
import type { EventEditorInitialValues } from '@app/features/calendar/components/composer/event-form-model';
@@ -38,6 +39,7 @@ import { useIsAuthenticated } from '@core/auth';
import { LoadingBlock } from '@core/component/LoadingBlock';
import {
DEV_MODE_ENV,
+ enableChatV3Agents,
enableCrm,
enableNewAppViews,
enableReminders,
@@ -200,6 +202,15 @@ export function resolveComponent(
): ResolvedComponent {
const registration = REGISTRY.get(name);
if (!registration) {
+ if (parseAgentsRoute(name)) {
+ const base = REGISTRY.get('agents');
+ if (base) {
+ return {
+ element: () => base.factory({ ...(params ?? {}), agentsRoute: name }),
+ initialMeta: base.initialMeta,
+ };
+ }
+ }
if (name.startsWith(REMINDER_VIEW_PREFIX)) {
const base = REGISTRY.get('reminder-view');
if (base) {
@@ -394,19 +405,43 @@ function LegacyAgentsView() {
);
}
-function RegisteredAgentsView() {
+function RegisteredAgentsView(params: ComponentParams) {
+ const route =
+ typeof params.agentsRoute === 'string'
+ ? parseAgentsRoute(params.agentsRoute)
+ : undefined;
usePageViewTracking('agents');
- const newAppViews = useNewAppViews({
- enabledLayout: () => (isTouchDevice() ? 'legacy' : 'composable'),
+ const panel = useSplitPanelOrThrow();
+ const agentsFlag = useFeatureFlag(enableChatV3Agents);
+
+ createRenderEffect(() => {
+ if (agentsFlag().loading) return;
+ panel.handle.updateMeta?.({
+ splitPanelLayout: agentsFlag().enabled ? 'composable' : 'legacy',
+ });
});
return (
- <Show when={newAppViews.ready()} fallback={<LoadingBlock />}>
+ <Show when={!agentsFlag().loading} fallback={<LoadingBlock />}>
<Show
- when={newAppViews.enabled() && !isTouchDevice()}
- fallback={<LegacyAgentsView />}
+ when={agentsFlag().enabled}
+ fallback={
+ route ? (
+ <RedirectSplit
+ to={{
+ type:
+ route.conversation.type === 'agent_session'
+ ? 'agent'
+ : 'chat',
+ id: route.conversation.id,
+ }}
+ />
+ ) : (
+ <LegacyAgentsView />
+ )
+ }
>
- <AgentsView />
+ <AgentsView initialRoute={route} />
</Show>
</Show>
);
diff --git a/apps/web/src/components/app/split-layout/layoutManager.ts b/apps/web/src/components/app/split-layout/layoutManager.ts
index e21406d45a..c4264970d0 100644
--- a/apps/web/src/components/app/split-layout/layoutManager.ts
+++ b/apps/web/src/components/app/split-layout/layoutManager.ts
@@ -1,4 +1,5 @@
import { LIST_VIEW_ID, type ListView } from '@app/constants/list-views';
+import { agentsRouteSegments } from '@app/features/agents-view/core/route';
import type {
BlockAlias,
BlockAliasContext,
@@ -114,6 +115,10 @@ function getAliasOrType(content: SplitContent): string {
* to keep the tab out of the URL.
*/
function contentUrlSegments(content: SplitContent): string[] {
+ if (content.type === 'component') {
+ const agentsRoute = agentsRouteSegments(content.id);
+ if (agentsRoute) return agentsRoute;
+ }
if (content.type === 'component' && content.id === 'settings') {
return ['settings', settingsTabToSlug(activeTabId())];
}
@@ -491,7 +496,7 @@ export type SplitHandle<TMeta extends ComponentMeta = ComponentMeta> = {
referredFrom?: ReferredFrom;
}) => void;
/**
- * Point this split at a new id for the same block *without* remounting it.
+ * Point this split at a new id for the same mounted surface without remounting it.
*
* `replace` tears the mount down and builds a new one, which is right when
* the user navigates somewhere else. This is the other case: the block is
@@ -500,12 +505,16 @@ export type SplitHandle<TMeta extends ComponentMeta = ComponentMeta> = {
* session id when the create resolves, with the composer the user is typing
* into left untouched.
*
- * Only the id moves — same block type, same mount, same history entry
+ * Components may also adopt a resolved route id, as the Agents workspace does.
+ * Only the id moves — same content type, same mount, same history entry
* (rewritten in place, so Back still goes where it did and the URL swaps
- * without a new entry). A no-op unless the split currently shows a block of
+ * without a new entry). A no-op unless the split currently shows content of
* `type`.
*/
- adoptContentId: (options: { type: BlockName; nextId: string }) => void;
+ adoptContentId: (options: {
+ type: BlockName | 'component';
+ nextId: string;
+ }) => void;
removeFromHistory: (predicate: (content: SplitContent) => boolean) => void;
toggleSpotlight: (force?: boolean) => void;
setDisplayName: (name: string) => void;
@@ -1031,7 +1040,11 @@ export function createSplitLayout(
* cause is `replace`, so the URL sync swaps the path in place instead of
* adding a back step to a placeholder the user can never return to.
*/
- function adoptContentId(id: SplitId, type: BlockName, nextId: string) {
+ function adoptContentId(
+ id: SplitId,
+ type: BlockName | 'component',
+ nextId: string
+ ) {
const i = splitIndexById(id);
if (i < 0) return;
@@ -1069,11 +1082,13 @@ export function createSplitLayout(
lastNavigationCause: 'replace',
});
});
- orchestrator.rekeyBlockInstance(
- resolveBlockAlias(type),
- current.id,
- nextId
- );
+ if (type !== 'component') {
+ orchestrator.rekeyBlockInstance(
+ resolveBlockAlias(type),
+ current.id,
+ nextId
+ );
+ }
});
}
diff --git a/apps/web/src/components/app/split-layout/layoutUtils.ts b/apps/web/src/components/app/split-layout/layoutUtils.ts
index af9184f6fd..f728dad0f5 100644
--- a/apps/web/src/components/app/split-layout/layoutUtils.ts
+++ b/apps/web/src/components/app/split-layout/layoutUtils.ts
@@ -1,4 +1,5 @@
import { isListViewID, LIST_VIEW_ID } from '@app/constants/list-views';
+import { agentsRouteFromSegments } from '@app/features/agents-view/core/route';
import { globalSplitManager } from '@app/signal/splitLayout';
import type { BlockAlias, BlockName } from '@core/block';
import { isBlockAlias, resolveBlockAlias } from '@core/constant/allBlocks';
@@ -25,8 +26,11 @@ export function decodePairs(segments: string[]): SplitContent[] {
const type = segments[i];
const id = segments[i + 1];
if (!type || !id) break;
+ const agentsRoute = agentsRouteFromSegments(type, id);
- if (type === 'settings') {
+ if (agentsRoute) {
+ pairs.push({ type: 'component', id: agentsRoute });
+ } else if (type === 'settings') {
// `settings/<tab>` is the URL form of the docked settings panel; it maps
// to the internal `component/settings` content. The active tab is read
// reactively from the URL by SettingsPanelComponentWrapper, so it isn't
diff --git a/apps/web/src/components/app/split-layout/tests/layoutUrlSync.test.ts b/apps/web/src/components/app/split-layout/tests/layoutUrlSync.test.ts
index c3710bf082..e4f22f8a3b 100644
--- a/apps/web/src/components/app/split-layout/tests/layoutUrlSync.test.ts
+++ b/apps/web/src/components/app/split-layout/tests/layoutUrlSync.test.ts
@@ -1,3 +1,4 @@
+import { agentsRouteId } from '@app/features/agents-view/core/route';
import type { BlockOrchestrator } from '@core/orchestrator';
import type { Navigator } from '@solidjs/router';
import { batch, createMemo, createRoot, createSignal } from 'solid-js';
@@ -108,6 +109,100 @@ async function flushUrlSync() {
}
describe('layout URL synchronization', () => {
+ it('navigates between Agents conversations and restores browser back/forward paths', async () => {
+ const chat = {
+ type: 'component' as const,
+ id: agentsRouteId({
+ mode: 'chat',
+ conversation: { type: 'agent_session', id: 'session-1' },
+ }),
+ };
+ const code = {
+ type: 'component' as const,
+ id: agentsRouteId({
+ mode: 'code',
+ conversation: { type: 'agent_session', id: 'session-2' },
+ }),
+ };
+ const harness = createHarness({
+ managerContent: [{ type: 'component', id: 'agents' }],
+ urlSegments: ['component', 'agents'],
+ });
+ await flushUrlSync();
+ const handle = harness.manager.getSplit(harness.manager.splits()[0].id)!;
+ handle.replace({ next: chat });
+ await flushUrlSync();
+ expect(harness.navigate).toHaveBeenLastCalledWith('/agents/session-1', {
+ replace: false,
+ });
+ harness.setUrl(['agents', 'session-1'], undefined);
+ await flushUrlSync();
+ handle.replace({ next: code });
+ await flushUrlSync();
+ expect(harness.navigate).toHaveBeenLastCalledWith('/coders/session-2', {
+ replace: false,
+ });
+ harness.setUrl(['coders', 'session-2'], undefined);
+ await flushUrlSync();
+ harness.setUrl(['agents', 'session-1'], undefined);
+ await flushUrlSync();
+ expect(harness.manager.splits()[0].content).toEqual(chat);
+ harness.setUrl(['coders', 'session-2'], undefined);
+ await flushUrlSync();
+ expect(harness.manager.splits()[0].content).toEqual(code);
+ harness.dispose();
+ });
+
+ it('replaces a pending workspace URL with the real session without remounting', async () => {
+ const pendingId = agentsRouteId({
+ mode: 'chat',
+ conversation: { type: 'agent_session', id: 'pending-1' },
+ });
+ const resolvedId = agentsRouteId({
+ mode: 'chat',
+ conversation: { type: 'agent_session', id: 'session-1' },
+ });
+ const harness = createHarness({
+ managerContent: [{ type: 'component', id: pendingId }],
+ urlSegments: ['agents', 'pending-1'],
+ });
+ await flushUrlSync();
+ const split = harness.manager.splits()[0];
+ const mount = split.mount;
+ const handle = harness.manager.getSplit(split.id)!;
+ const historyLength = handle.history().length;
+ handle.adoptContentId({ type: 'component', nextId: resolvedId });
+ await flushUrlSync();
+ expect(harness.navigate).toHaveBeenLastCalledWith('/agents/session-1', {
+ replace: true,
+ });
+ expect(harness.manager.splits()[0].mount).toBe(mount);
+ expect(handle.history()).toHaveLength(historyLength);
+ expect(handle.history().at(-1)?.id).toBe(resolvedId);
+ harness.dispose();
+ });
+
+ it('restores Agents deep links next to another split', async () => {
+ const harness = createHarness({
+ managerContent: [{ type: 'component', id: 'agents' }],
+ urlSegments: ['md', 'document-1', 'coders', 'session-2'],
+ });
+ await flushUrlSync();
+ expect(harness.manager.getUrlSegments()).toEqual([
+ 'md',
+ 'document-1',
+ 'coders',
+ 'session-2',
+ ]);
+ expect(harness.manager.splits()[1].content.id).toBe(
+ agentsRouteId({
+ mode: 'code',
+ conversation: { type: 'agent_session', id: 'session-2' },
+ })
+ );
+ harness.dispose();
+ });
+
it('coalesces preview engagement into one canonical manager-to-URL update', async () => {
const harness = createHarness({
managerContent: [{ type: 'component', id: 'inbox' }],
diff --git a/apps/web/src/features/agents-view/agents-view.css b/apps/web/src/features/agents-view/agents-view.css
new file mode 100644
index 0000000000..6fbc5de91f
--- /dev/null
+++ b/apps/web/src/features/agents-view/agents-view.css
@@ -0,0 +1,2392 @@
+/*
+ * Feature-specific Agents layouts, scoped to the workspace and its portals.
+ * Colors inherit the app theme. Composer and sidebar chrome use the shared
+ * UI components so changes to those surfaces carry through to this view.
+ */
+
+@layer components {
+ .agents-view,
+ .agents-view-portal {
+ --surface-0: var(--color-surface-0);
+ --surface-1: var(--color-surface-1);
+ --surface-2: var(--color-surface-2);
+ --surface-3: var(--color-surface-3);
+ --surface-4: var(--color-surface-4);
+ --ink: var(--color-ink);
+ --ink-muted: var(--color-ink-muted);
+ --ink-subtle: var(--color-ink-subtle);
+ --ink-disabled: var(--color-ink-disabled);
+ --ink-placeholder: var(--color-ink-placeholder);
+ --edge: var(--color-edge);
+ --edge-muted: var(--color-edge-muted);
+ --accent: var(--color-accent);
+ --accent-contrast: var(--color-accent-contrast);
+ --green: var(--color-green);
+ --amber: var(--color-amber);
+ --red: var(--color-red);
+ --blue: var(--color-blue);
+ --violet: var(--color-violet);
+ --cyan: var(--color-cyan);
+ --chat: var(--color-chat);
+ --page: var(--color-page);
+ --panel: var(--color-panel);
+ --menu: var(--color-menu);
+ --menu-glass: var(--color-menu-glass);
+ --hover: var(--color-hover);
+ --active: var(--color-active);
+ --selected: var(--color-selected);
+ --card-edge: color-mix(in oklch, var(--ink) 5%, transparent);
+ --hair: var(--app-border-width);
+ }
+
+ .agents-view {
+ display: flex;
+ flex-direction: column;
+ min-width: 0;
+ min-height: 0;
+ height: 100%;
+ background: var(--panel);
+ color: var(--ink);
+ font: 14px/1.45 var(--font-sans);
+ -webkit-font-smoothing: antialiased;
+ }
+
+ :where(.agents-view, .agents-view-portal) *,
+ :where(.agents-view, .agents-view-portal) *::before,
+ :where(.agents-view, .agents-view-portal) *::after {
+ box-sizing: border-box;
+ }
+
+ :where(.agents-view, .agents-view-portal) button:focus-visible,
+ :where(.agents-view, .agents-view-portal) textarea:focus-visible,
+ :where(.agents-view, .agents-view-portal) input:focus-visible {
+ outline: 1.5px solid var(--accent);
+ outline-offset: 1px;
+ }
+
+ :where(.agents-view, .agents-view-portal) svg {
+ display: block;
+ }
+
+ :where(.agents-view, .agents-view-portal) svg:not([fill]) {
+ fill: currentColor;
+ }
+
+ @media (prefers-reduced-motion: reduce) {
+ :where(.agents-view, .agents-view-portal) * {
+ transition: none !important;
+ animation: none !important;
+ }
+ }
+
+ :where(.agents-view, .agents-view-portal) .ph {
+ width: 16px;
+ height: 16px;
+ fill: currentColor;
+ flex-shrink: 0;
+ }
+
+ :where(.agents-view, .agents-view-portal) .mono {
+ font-family: var(--font-mono);
+ font-size: 11px;
+ letter-spacing: 0.01em;
+ font-variant-numeric: tabular-nums;
+ }
+
+ :where(.agents-view, .agents-view-portal) .num {
+ font-variant-numeric: tabular-nums;
+ }
+
+ :where(.agents-view, .agents-view-portal) .truncate {
+ white-space: nowrap;
+ overflow: hidden;
+ text-overflow: ellipsis;
+ min-width: 0;
+ }
+
+ :where(.agents-view, .agents-view-portal) .sr {
+ position: absolute;
+ width: 1px;
+ height: 1px;
+ overflow: hidden;
+ clip: rect(0 0 0 0);
+ white-space: nowrap;
+ }
+
+ /* ---------- ViewSidebar ---------- */
+ :where(.agents-view, .agents-view-portal) .aside {
+ display: flex;
+ flex-direction: column;
+ min-height: 0;
+ border-right: var(--hair) solid var(--edge-muted);
+ }
+
+ :where(.agents-view, .agents-view-portal) .ctl {
+ display: inline-flex;
+ gap: 2px;
+ }
+
+ :where(.agents-view, .agents-view-portal) .icon-btn {
+ width: 28px;
+ height: 28px;
+ border-radius: 8px;
+ display: grid;
+ place-items: center;
+ color: var(--ink-subtle);
+ }
+
+ :where(.agents-view, .agents-view-portal) .icon-btn .ph {
+ width: 14px;
+ height: 14px;
+ }
+
+ :where(.agents-view, .agents-view-portal) .icon-btn:hover {
+ background: var(--hover);
+ color: var(--ink);
+ }
+
+ :where(.agents-view, .agents-view-portal) .icon-btn[aria-pressed="true"] {
+ background: var(--active);
+ color: var(--ink);
+ }
+
+ :where(.agents-view, .agents-view-portal) .icon-btn:disabled {
+ color: var(--ink-placeholder);
+ }
+
+ :where(.agents-view, .agents-view-portal) .aside .content {
+ display: flex;
+ flex-direction: column;
+ gap: 24px;
+ padding: 16px 6px 20px;
+ min-height: 0;
+ flex: 1;
+ overflow: hidden;
+ }
+
+ :where(.agents-view, .agents-view-portal) .sec-head {
+ height: 28px;
+ display: flex;
+ align-items: center;
+ justify-content: space-between;
+ padding: 0 4px 0 12px;
+ font-size: 12px;
+ font-weight: 500;
+ color: var(--ink-subtle);
+ }
+
+ :where(.agents-view, .agents-view-portal) .sec-head h2 {
+ margin: 0;
+ font: inherit;
+ }
+
+ :where(.agents-view, .agents-view-portal) .recent {
+ display: flex;
+ flex-direction: column;
+ gap: 4px;
+ min-height: 0;
+ flex: 1;
+ }
+
+ :where(.agents-view, .agents-view-portal) .recent .list {
+ overflow: auto;
+ min-height: 0;
+ flex: 1;
+ display: flex;
+ flex-direction: column;
+ gap: 2px;
+ scrollbar-width: thin;
+ scrollbar-color: var(--surface-4) transparent;
+ -webkit-mask-image: linear-gradient(#000 calc(100% - 24px), transparent);
+ mask-image: linear-gradient(#000 calc(100% - 24px), transparent);
+ }
+
+ :where(.agents-view, .agents-view-portal) .search {
+ height: 36px;
+ display: flex;
+ align-items: center;
+ gap: 8px;
+ padding: 0 10px;
+ border-radius: 12px;
+ background: var(--surface-0);
+ border: var(--hair) solid var(--edge-muted);
+ color: var(--ink-placeholder);
+ flex-shrink: 0;
+ }
+
+ :where(.agents-view, .agents-view-portal) .search input {
+ flex: 1;
+ min-width: 0;
+ background: transparent;
+ border: 0;
+ outline: none;
+ color: var(--ink);
+ font: 14px var(--font-sans);
+ }
+
+ :where(.agents-view, .agents-view-portal) .search input::placeholder {
+ color: var(--ink-placeholder);
+ }
+
+ /* recent chat rows: left = PR state or status, title truncates, right = lines changed */
+ :where(.agents-view, .agents-view-portal) .row {
+ min-height: 32px;
+ display: grid;
+ grid-template-columns: 20px minmax(0, 1fr) auto;
+ column-gap: 8px;
+ align-items: center;
+ padding: 6px 10px;
+ border-radius: 12px;
+ font-size: 14px;
+ color: var(--ink-muted);
+ width: 100%;
+ text-align: left;
+ flex-shrink: 0;
+ }
+
+ :where(.agents-view, .agents-view-portal) .row:hover {
+ background: var(--hover);
+ color: var(--ink);
+ }
+
+ :where(.agents-view, .agents-view-portal) .row.active {
+ background: var(--active);
+ color: var(--ink);
+ }
+
+ :where(.agents-view, .agents-view-portal) .row .lead {
+ width: 20px;
+ height: 16px;
+ display: grid;
+ place-items: center;
+ position: relative;
+ }
+
+ :where(.agents-view, .agents-view-portal) .open {
+ color: var(--green);
+ }
+
+ /* Needs attention nests inside Active in Code mode */
+ :where(.agents-view, .agents-view-portal) .row .lead .spin {
+ width: 11px;
+ height: 11px;
+ border-radius: 50%;
+ border: 1.5px solid var(--surface-4);
+ border-top-color: var(--ink-subtle);
+ animation: spin 0.9s linear infinite;
+ }
+
+ /* Work mode: a stepped, square "cog" rather than a smooth ring */
+ :where(.agents-view, .agents-view-portal)[data-mode="work"] .spin {
+ border-radius: 2px;
+ border: 1.5px solid var(--surface-4);
+ border-top-color: var(--ink-subtle);
+ border-right-color: var(--ink-subtle);
+ animation: spin 1.2s steps(8) infinite;
+ }
+
+ :where(.agents-view, .agents-view-portal) .row .when {
+ color: var(--ink-placeholder);
+ font-size: 12px;
+ font-variant-numeric: tabular-nums;
+ white-space: nowrap;
+ }
+
+ :where(.agents-view, .agents-view-portal) .row .sub {
+ display: none;
+ }
+
+ @keyframes pulse {
+ 0%,
+ 100% {
+ opacity: 1;
+ }
+
+ 50% {
+ opacity: 0.35;
+ }
+ }
+
+ :where(.agents-view, .agents-view-portal) .row[data-kind="code"] {
+ padding: 6px 12px;
+ row-gap: 1px;
+ }
+
+ :where(.agents-view, .agents-view-portal) .row[data-kind="code"] .lead {
+ grid-row: 1 / 3;
+ align-self: start;
+ margin-top: 3px;
+ }
+
+ :where(.agents-view, .agents-view-portal) .row[data-kind="code"] .sub {
+ display: flex;
+ gap: 6px;
+ align-items: center;
+ grid-column: 2 / 4;
+ color: var(--ink-placeholder);
+ font-size: 12px;
+ white-space: nowrap;
+ overflow: hidden;
+ }
+
+ :where(.agents-view, .agents-view-portal) .row[data-kind="code"] .sub .when {
+ font-size: 11px;
+ }
+
+ :where(.agents-view, .agents-view-portal) .row[data-kind="code"] .sub .h {
+ color: var(--ink-disabled);
+ }
+
+ :where(.agents-view, .agents-view-portal) .group-h {
+ padding: 10px 12px 4px;
+ font-size: 11px;
+ font-weight: 500;
+ color: var(--ink-placeholder);
+ display: flex;
+ align-items: center;
+ gap: 6px;
+ }
+
+ :where(.agents-view, .agents-view-portal) .group-h .n {
+ color: var(--ink-disabled);
+ font-variant-numeric: tabular-nums;
+ }
+
+ :where(.agents-view, .agents-view-portal) .stdot.waiting::after {
+ display: none;
+ }
+
+ :where(.agents-view, .agents-view-portal) .stdot {
+ display: inline-flex;
+ align-items: center;
+ gap: 5px;
+ font-size: 11px;
+ color: var(--ink-subtle);
+ white-space: nowrap;
+ }
+
+ :where(.agents-view, .agents-view-portal) .stdot::before {
+ content: "";
+ width: 6px;
+ height: 6px;
+ border-radius: 50%;
+ background: var(--ink-disabled);
+ }
+
+ :where(.agents-view, .agents-view-portal) .stdot.running::before {
+ background: var(--green);
+ animation: pulse 1.6s ease-in-out infinite;
+ }
+
+ :where(.agents-view, .agents-view-portal) .stdot.waiting::before {
+ background: var(--amber);
+ }
+
+ :where(.agents-view, .agents-view-portal) .stdot.failed::before {
+ background: var(--red);
+ }
+
+ /* ---------- Main ---------- */
+ :where(.agents-view, .agents-view-portal) .main {
+ display: flex;
+ flex-direction: column;
+ min-width: 0;
+ min-height: 0;
+ overflow: hidden;
+ }
+
+ :where(.agents-view, .agents-view-portal) .topbar {
+ height: 48px;
+ flex-shrink: 0;
+ display: flex;
+ align-items: center;
+ justify-content: space-between;
+ gap: 12px;
+ padding: 0 24px;
+ }
+
+ :where(.agents-view, .agents-view-portal) .topbar h1 {
+ flex: 1;
+ min-width: 0;
+ }
+
+ :where(.agents-view, .agents-view-portal) .topbar h1 {
+ margin: 0;
+ font-size: 14px;
+ font-weight: 600;
+ letter-spacing: -0.03em;
+ }
+
+ :where(.agents-view, .agents-view-portal) .seg {
+ display: inline-flex;
+ padding: 2px;
+ gap: 2px;
+ border-radius: 999px;
+ background: var(--hover);
+ }
+
+ :where(.agents-view, .agents-view-portal) .seg button {
+ padding: 4px 10px;
+ border-radius: 999px;
+ font-size: 12.5px;
+ font-weight: 500;
+ color: var(--ink-subtle);
+ display: inline-flex;
+ align-items: center;
+ gap: 6px;
+ height: 28px;
+ }
+
+ :where(.agents-view, .agents-view-portal) .seg button:hover {
+ color: var(--ink);
+ }
+
+ :where(.agents-view, .agents-view-portal) .seg button[aria-pressed="true"] {
+ background: var(--active);
+ color: var(--ink);
+ }
+
+ :where(.agents-view, .agents-view-portal) .seg button kbd {
+ font: 10px var(--font-mono);
+ color: var(--ink-placeholder);
+ }
+
+ :where(.agents-view, .agents-view-portal) .seg .ph {
+ width: 12px;
+ height: 12px;
+ }
+
+ :where(.agents-view, .agents-view-portal) .seg.side {
+ display: grid;
+ grid-auto-flow: column;
+ grid-auto-columns: 1fr;
+ width: 100%;
+ padding: 3px;
+ border-radius: 999px;
+ }
+
+ :where(.agents-view, .agents-view-portal) .seg.side button {
+ justify-content: center;
+ height: 32px;
+ font-size: 14px;
+ border-radius: 999px;
+ gap: 6px;
+ padding: 4px 6px;
+ min-width: 0;
+ }
+
+ :where(.agents-view, .agents-view-portal) .aside > .seg.side {
+ margin: 16px 6px 0;
+ width: auto;
+ flex-shrink: 0;
+ }
+
+ :where(.agents-view, .agents-view-portal) .seg.side button .ph {
+ width: 14px;
+ height: 14px;
+ }
+
+ :where(.agents-view, .agents-view-portal) .aside .content {
+ gap: 20px;
+ padding-top: 14px;
+ }
+
+ :where(.agents-view, .agents-view-portal) .topbar .right {
+ display: flex;
+ align-items: center;
+ gap: 8px;
+ }
+
+ :where(.agents-view, .agents-view-portal) .body {
+ flex: 1;
+ min-height: 0;
+ overflow: auto;
+ display: flex;
+ flex-direction: column;
+ }
+
+ :where(.agents-view, .agents-view-portal) .page {
+ display: none;
+ flex: 1;
+ min-height: 0;
+ flex-direction: column;
+ }
+
+ :where(.agents-view, .agents-view-portal) .page[data-active] {
+ display: flex;
+ }
+
+ /* New Chat */
+ :where(.agents-view, .agents-view-portal) .newchat {
+ align-items: center;
+ justify-content: center;
+ padding: 24px 24px 64px;
+ gap: 20px;
+ }
+
+ :where(.agents-view, .agents-view-portal) .newchat .col {
+ width: 100%;
+ max-width: 768px;
+ display: flex;
+ flex-direction: column;
+ gap: 20px;
+ }
+
+ :where(.agents-view, .agents-view-portal) .greeting {
+ text-align: center;
+ margin-bottom: 12px;
+ }
+
+ :where(.agents-view, .agents-view-portal) .greeting h2 {
+ margin: 0;
+ font-size: 28px;
+ font-weight: 500;
+ letter-spacing: -0.03em;
+ line-height: 1.2;
+ text-wrap: balance;
+ }
+
+ :where(.agents-view, .agents-view-portal) .composer-drawer {
+ display: grid;
+ grid-template-rows: 0fr;
+ margin: 0 20px;
+ opacity: 0;
+ visibility: hidden;
+ transition: grid-template-rows 240ms ease, opacity 180ms ease, visibility 240ms;
+ }
+
+ :where(.agents-view, .agents-view-portal) .composer-drawer[data-open] {
+ grid-template-rows: 1fr;
+ opacity: 1;
+ visibility: visible;
+ }
+
+ :where(.agents-view, .agents-view-portal) .composer-drawer-inner {
+ min-height: 0;
+ }
+
+ :where(.agents-view, .agents-view-portal) .composer-drawer-content {
+ display: flex;
+ align-items: center;
+ padding: 6px 12px 10px;
+ border-radius: 0 0 20px 20px;
+ background: var(--surface-2);
+ border: var(--hair) solid var(--edge-muted);
+ border-top: 0;
+ transform: translateY(-12px);
+ transition: transform 240ms ease;
+ }
+
+ :where(.agents-view, .agents-view-portal) .composer-drawer[data-open] .composer-drawer-content {
+ transform: none;
+ }
+
+ @media (prefers-reduced-motion: reduce) {
+ :where(.agents-view, .agents-view-portal) .composer-drawer,
+ :where(.agents-view, .agents-view-portal) .composer-drawer-content {
+ transition: none;
+ }
+ }
+
+ :where(.agents-view, .agents-view-portal) .pill {
+ height: 36px;
+ display: inline-flex;
+ align-items: center;
+ gap: 8px;
+ padding: 0 10px 0 8px;
+ border-radius: 999px;
+ font-size: 14px;
+ color: var(--ink-muted);
+ max-width: min(260px, 60vw);
+ min-width: 0;
+ background: transparent;
+ }
+
+ :where(.agents-view, .agents-view-portal) .pill:hover {
+ background: var(--hover);
+ color: var(--ink);
+ }
+
+ :where(.agents-view, .agents-view-portal) .pill.empty {
+ background: transparent;
+ color: var(--ink-subtle);
+ }
+
+ :where(.agents-view, .agents-view-portal) .menu .opt .sysb {
+ font-size: 9px;
+ padding: 0 5px;
+ margin-left: auto;
+ }
+
+ :where(.agents-view, .agents-view-portal) .pill.empty:hover {
+ background: var(--hover);
+ }
+
+ :where(.agents-view, .agents-view-portal) .menu .opt .sub {
+ font-size: 11px;
+ color: var(--ink-placeholder);
+ white-space: nowrap;
+ }
+
+ :where(.agents-view, .agents-view-portal) .pill .lbl .k {
+ color: var(--ink-placeholder);
+ }
+
+ :where(.agents-view, .agents-view-portal) .pill .caret {
+ width: 14px;
+ height: 14px;
+ flex-shrink: 0;
+ }
+
+ :where(.agents-view, .agents-view-portal) .pill .av {
+ width: 18px;
+ height: 18px;
+ border-radius: 50%;
+ display: grid;
+ place-items: center;
+ color: var(--ink-muted);
+ background: var(--surface-1);
+ box-shadow: 0 0 0 0.5px var(--edge-muted);
+ }
+
+ :where(.agents-view, .agents-view-portal) .pill .av .ph {
+ width: 11px;
+ height: 11px;
+ }
+
+ :where(.agents-view, .agents-view-portal) .bar .grow {
+ flex: 1;
+ }
+
+ :where(.agents-view, .agents-view-portal) .logo {
+ width: 16px;
+ height: 16px;
+ flex-shrink: 0;
+ display: grid;
+ place-items: center;
+ }
+
+ :where(.agents-view, .agents-view-portal) .logo svg {
+ width: 16px;
+ height: 16px;
+ }
+
+ /* model menu */
+ :where(.agents-view, .agents-view-portal) .menu-anchor {
+ position: relative;
+ }
+
+ :where(.agents-view, .agents-view-portal) .menu {
+ position: absolute;
+ bottom: calc(100% + 6px);
+ left: 0;
+ width: 272px;
+ background: var(--menu);
+ border: var(--hair) solid var(--edge-muted);
+ border-radius: 16px;
+ box-shadow: var(--shadow-menu);
+ padding: 6px;
+ z-index: 20;
+ animation: menu-open 120ms cubic-bezier(0.16, 1, 0.3, 1);
+ }
+
+ @keyframes menu-open {
+ from {
+ opacity: 0;
+ transform: translateY(4px) scale(0.98);
+ }
+
+ to {
+ opacity: 1;
+ transform: none;
+ }
+ }
+
+ :where(.agents-view, .agents-view-portal) .menu .filter {
+ display: flex;
+ align-items: center;
+ gap: 8px;
+ padding: 0 8px;
+ height: 32px;
+ margin-bottom: 4px;
+ border-radius: 8px;
+ background: var(--surface-1);
+ border: var(--hair) solid var(--edge-muted);
+ color: var(--ink-placeholder);
+ }
+
+ :where(.agents-view, .agents-view-portal) .menu .filter input {
+ flex: 1;
+ background: transparent;
+ border: 0;
+ color: var(--ink);
+ font: 13px var(--font-sans);
+ outline: none;
+ min-width: 0;
+ }
+
+ :where(.agents-view, .agents-view-portal) .menu .grp {
+ display: flex;
+ align-items: center;
+ gap: 6px;
+ padding: 8px 8px 4px;
+ font-size: 11px;
+ color: var(--ink-placeholder);
+ }
+
+ :where(.agents-view, .agents-view-portal) .menu .grp .logo {
+ width: 12px;
+ height: 12px;
+ }
+
+ :where(.agents-view, .agents-view-portal) .menu .grp .logo svg {
+ width: 12px;
+ height: 12px;
+ }
+
+ :where(.agents-view, .agents-view-portal) .menu .grp .logo {
+ display: none;
+ }
+
+ :where(.agents-view, .agents-view-portal) .menu .opt {
+ display: flex;
+ align-items: center;
+ gap: 8px;
+ width: 100%;
+ height: 32px;
+ padding: 0 8px;
+ border-radius: 8px;
+ text-align: left;
+ font-size: 13.5px;
+ }
+
+ :where(.agents-view, .agents-view-portal) .menu .opt:hover {
+ background: var(--hover);
+ }
+
+ :where(.agents-view, .agents-view-portal) .menu .opt[aria-checked="true"] {
+ background: var(--active);
+ font-weight: 500;
+ }
+
+ :where(.agents-view, .agents-view-portal) .menu .opt .nm {
+ flex: 0 1 auto;
+ white-space: nowrap;
+ overflow: hidden;
+ text-overflow: ellipsis;
+ }
+
+ :where(.agents-view, .agents-view-portal) .menu .opt .hint {
+ font-size: 12px;
+ color: var(--ink-placeholder);
+ }
+
+ :where(.agents-view, .agents-view-portal) .menu .opt .tick {
+ color: var(--accent);
+ width: 14px;
+ height: 14px;
+ display: none;
+ }
+
+ :where(.agents-view, .agents-view-portal) .menu .opt[aria-checked="true"] .tick {
+ display: block;
+ }
+
+ :where(.agents-view, .agents-view-portal) .menu .opt .hint,
+ :where(.agents-view, .agents-view-portal) .menu .opt .id {
+ margin-left: auto;
+ }
+
+ :where(.agents-view, .agents-view-portal) .menu .opt .id {
+ display: none;
+ }
+
+ :where(.agents-view, .agents-view-portal)[data-mode="work"] .menu .opt .hint {
+ display: none;
+ }
+
+ :where(.agents-view, .agents-view-portal) .menu .foot {
+ margin-top: 4px;
+ padding: 8px 8px 4px;
+ border-top: var(--hair) solid var(--edge-muted);
+ font-size: 11px;
+ color: var(--ink-placeholder);
+ display: flex;
+ justify-content: space-between;
+ }
+
+ /* ---------- Settings-style pages (Agents) ---------- */
+ :where(.agents-view, .agents-view-portal) .settings {
+ overflow-y: auto;
+ }
+
+ :where(.agents-view, .agents-view-portal) .settings .wrap {
+ position: relative;
+ margin: 0 auto;
+ width: 100%;
+ max-width: 710px;
+ padding: 56px 40px 96px;
+ display: flex;
+ flex-direction: column;
+ }
+
+ :where(.agents-view, .agents-view-portal) .page-close {
+ position: absolute;
+ top: 18px;
+ right: 34px;
+ width: 30px;
+ height: 30px;
+ border-radius: 9px;
+ }
+
+ :where(.agents-view, .agents-view-portal) .page-close .ph {
+ width: 16px;
+ height: 16px;
+ }
+
+ :where(.agents-view, .agents-view-portal) .settings header.ph-head {
+ display: flex;
+ align-items: flex-start;
+ justify-content: space-between;
+ gap: 16px;
+ padding: 0 24px;
+ }
+
+ :where(.agents-view, .agents-view-portal) .settings h1.big {
+ margin: 0;
+ font-size: 24px;
+ line-height: 1.1;
+ font-weight: 600;
+ }
+
+ :where(.agents-view, .agents-view-portal) .settings .desc {
+ margin: 6px 0 0;
+ color: var(--ink-muted);
+ font-size: 14px;
+ }
+
+ :where(.agents-view, .agents-view-portal) .cta {
+ height: 32px;
+ display: inline-flex;
+ align-items: center;
+ gap: 6px;
+ padding: 0 12px;
+ border-radius: 999px;
+ background: var(--ink);
+ color: var(--panel);
+ font-size: 13px;
+ font-weight: 500;
+ white-space: nowrap;
+ flex-shrink: 0;
+ }
+
+ :where(.agents-view, .agents-view-portal) .cta .ph {
+ width: 14px;
+ height: 14px;
+ }
+
+ :where(.agents-view, .agents-view-portal) .cta:hover {
+ filter: brightness(1.04);
+ }
+
+ :where(.agents-view, .agents-view-portal) .cta:disabled {
+ opacity: 0.5;
+ filter: none;
+ }
+
+ :where(.agents-view, .agents-view-portal) .cta.sm {
+ height: 28px;
+ padding: 0 10px;
+ font-size: 12.5px;
+ border-radius: 999px;
+ }
+
+ :where(.agents-view, .agents-view-portal) .menu .foot {
+ align-items: center;
+ }
+
+ :where(.agents-view, .agents-view-portal) .menu .foot .cnt {
+ color: var(--ink-placeholder);
+ }
+
+ :where(.agents-view, .agents-view-portal) .settings .sections {
+ margin-top: 36px;
+ display: flex;
+ flex-direction: column;
+ gap: 40px;
+ }
+
+ :where(.agents-view, .agents-view-portal) .section {
+ display: flex;
+ flex-direction: column;
+ gap: 12px;
+ }
+
+ :where(.agents-view, .agents-view-portal) .section .sh {
+ padding: 0 24px;
+ }
+
+ :where(.agents-view, .agents-view-portal) .section .sh h2 {
+ margin: 0;
+ font-size: 14px;
+ font-weight: 600;
+ }
+
+ :where(.agents-view, .agents-view-portal) .section .sh p {
+ margin: 2px 0 0;
+ font-size: 14px;
+ color: var(--ink-muted);
+ }
+
+ :where(.agents-view, .agents-view-portal) .scard {
+ border-radius: 16px;
+ border: 1px solid var(--card-edge);
+ background: var(--hover);
+ overflow: hidden;
+ }
+
+ :where(.agents-view, .agents-view-portal) .scard > * + * {
+ border-top: var(--hair) solid var(--edge-muted);
+ }
+
+ :where(.agents-view, .agents-view-portal) .runtimes > #runtimeList > * + * {
+ border-top: var(--hair) solid var(--edge-muted);
+ }
+
+ :where(.agents-view, .agents-view-portal) .arow {
+ display: flex;
+ align-items: center;
+ gap: 16px;
+ padding: 16px 24px;
+ }
+
+ :where(.agents-view, .agents-view-portal) .arow .av {
+ width: 40px;
+ height: 40px;
+ border-radius: 50%;
+ display: grid;
+ place-items: center;
+ background: var(--surface-1);
+ color: var(--ink-muted);
+ box-shadow: 0 0 0 1px var(--edge-muted);
+ flex-shrink: 0;
+ }
+
+ :where(.agents-view, .agents-view-portal) .arow .av .ph {
+ width: 20px;
+ height: 20px;
+ }
+
+ :where(.agents-view, .agents-view-portal) .arow .info {
+ min-width: 0;
+ flex: 1;
+ }
+
+ :where(.agents-view, .agents-view-portal) .arow .line {
+ display: flex;
+ flex-wrap: wrap;
+ align-items: center;
+ gap: 4px 8px;
+ min-width: 0;
+ }
+
+ :where(.agents-view, .agents-view-portal) .arow .nm {
+ font-size: 14px;
+ font-weight: 500;
+ color: var(--ink);
+ }
+
+ :where(.agents-view, .agents-view-portal) .arow .tag {
+ font-size: 12px;
+ color: var(--ink-disabled);
+ }
+
+ :where(.agents-view, .agents-view-portal) .badge {
+ flex-shrink: 0;
+ border-radius: 999px;
+ border: var(--hair) solid var(--edge-muted);
+ padding: 2px 8px;
+ font-size: 10px;
+ font-weight: 500;
+ text-transform: uppercase;
+ color: var(--ink-disabled);
+ letter-spacing: 0.02em;
+ }
+
+ :where(.agents-view, .agents-view-portal) .arow .sub {
+ margin: 2px 0 0;
+ font-size: 12px;
+ color: var(--ink-disabled);
+ }
+
+ :where(.agents-view, .agents-view-portal) .arow .acts {
+ display: flex;
+ gap: 4px;
+ flex-shrink: 0;
+ }
+
+ :where(.agents-view, .agents-view-portal) .arow .acts .icon-btn.neg {
+ color: var(--red);
+ }
+
+ :where(.agents-view, .agents-view-portal) .badge.system {
+ color: var(--accent);
+ border-color: color-mix(in oklch, var(--accent) 35%, transparent);
+ background: color-mix(in oklch, var(--accent) 8%, transparent);
+ }
+
+ /* Page tabs: the agents page is split by kind, not by ownership. */
+ :where(.agents-view, .agents-view-portal) .tabs {
+ display: flex;
+ gap: 4px;
+ margin-top: 28px;
+ padding: 0 24px;
+ border-bottom: var(--hair) solid var(--edge);
+ }
+
+ :where(.agents-view, .agents-view-portal) .tabs button {
+ position: relative;
+ display: inline-flex;
+ align-items: center;
+ gap: 7px;
+ height: 36px;
+ padding: 0 10px;
+ border-radius: 8px 8px 0 0;
+ font-size: 13.5px;
+ font-weight: 500;
+ color: var(--ink-subtle);
+ }
+
+ :where(.agents-view, .agents-view-portal) .tabs button:hover {
+ color: var(--ink);
+ background: var(--hover);
+ }
+
+ :where(.agents-view, .agents-view-portal) .tabs button[aria-selected="true"] {
+ color: var(--ink);
+ }
+
+ :where(.agents-view, .agents-view-portal) .tabs button[aria-selected="true"]::after {
+ content: "";
+ position: absolute;
+ left: 8px;
+ right: 8px;
+ bottom: -0.5px;
+ height: 2px;
+ border-radius: 2px 2px 0 0;
+ background: var(--accent);
+ }
+
+ :where(.agents-view, .agents-view-portal) .tabs button .ph {
+ width: 14px;
+ height: 14px;
+ }
+
+ :where(.agents-view, .agents-view-portal) .tabs button .n {
+ font-size: 11px;
+ font-variant-numeric: tabular-nums;
+ color: var(--ink-placeholder);
+ background: var(--active);
+ border-radius: 999px;
+ padding: 1px 7px;
+ }
+
+ :where(.agents-view, .agents-view-portal) .tabs button[aria-selected="true"] .n {
+ color: var(--ink-subtle);
+ }
+
+ :where(.agents-view, .agents-view-portal) .settings .sections {
+ margin-top: 28px;
+ }
+
+ /* A coder wears its mark on its avatar, so the kind reads before the label does. --mark-ring matches whatever surface the avatar sits on. */
+ :where(.agents-view, .agents-view-portal) .avw {
+ position: relative;
+ display: inline-grid;
+ flex-shrink: 0;
+ }
+
+ :where(.agents-view, .agents-view-portal) .codemark {
+ position: absolute;
+ right: -3px;
+ bottom: -3px;
+ width: 16px;
+ height: 16px;
+ border-radius: 6px;
+ display: grid;
+ place-items: center;
+ background: var(--accent);
+ color: var(--accent-contrast);
+ box-shadow: 0 0 0 2px var(--mark-ring, var(--surface-2));
+ }
+
+ :where(.agents-view, .agents-view-portal) .codemark .ph {
+ width: 10px;
+ height: 10px;
+ }
+
+ :where(.agents-view, .agents-view-portal) .card {
+ --mark-ring: var(--surface-0);
+ }
+
+ :where(.agents-view, .agents-view-portal) .avrow .codemark {
+ width: 18px;
+ height: 18px;
+ right: -2px;
+ bottom: -2px;
+ }
+
+ :where(.agents-view, .agents-view-portal) .avrow .codemark .ph {
+ width: 11px;
+ height: 11px;
+ }
+
+ :where(.agents-view, .agents-view-portal) .badge.coder {
+ display: inline-flex;
+ align-items: center;
+ padding: 2px 5px;
+ color: var(--accent);
+ border-color: color-mix(in oklch, var(--accent) 35%, transparent);
+ background: color-mix(in oklch, var(--accent) 8%, transparent);
+ }
+
+ :where(.agents-view, .agents-view-portal) .badge.coder .ph {
+ width: 11px;
+ height: 11px;
+ }
+
+ :where(.agents-view, .agents-view-portal) .scard .empty-row {
+ margin: 0;
+ padding: 18px 24px;
+ font-size: 13px;
+ color: var(--ink-disabled);
+ }
+
+ /* ---------- sidebar: per-mode new button, routines view ---------- */
+ :where(.agents-view, .agents-view-portal) .top-actions {
+ display: flex;
+ flex-direction: column;
+ gap: 8px;
+ flex-shrink: 0;
+ }
+
+ /* ---------- slash menu: skills from the composer ---------- */
+ :where(.agents-view, .agents-view-portal) .composer-anchor {
+ display: block;
+ }
+
+ /* Bring your own agent */
+ :where(.agents-view, .agents-view-portal) .byoa {
+ border-radius: 12px;
+ border: 1px solid var(--card-edge);
+ background: var(--surface-2);
+ padding: 20px 24px;
+ }
+
+ :where(.agents-view, .agents-view-portal) .byoa.footer {
+ border-radius: 0;
+ border: 0;
+ border-top: var(--hair) solid var(--edge-muted);
+ background: color-mix(in oklch, var(--accent) 3%, var(--surface-2));
+ padding: 18px 24px;
+ display: grid;
+ grid-template-columns: 3fr 2fr;
+ gap: 20px;
+ align-items: start;
+ position: relative;
+ overflow: hidden;
+ }
+
+ :where(.agents-view, .agents-view-portal) .byoa::before {
+ content: "";
+ position: absolute;
+ inset: -40% -20% auto auto;
+ width: 320px;
+ height: 320px;
+ border-radius: 50%;
+ background: radial-gradient(closest-side, color-mix(in oklch, var(--accent) 12%, transparent), transparent);
+ pointer-events: none;
+ }
+
+ :where(.agents-view, .agents-view-portal) .byoa h2 {
+ margin: 0;
+ font-size: 16px;
+ font-weight: 600;
+ letter-spacing: -0.02em;
+ display: flex;
+ align-items: center;
+ gap: 8px;
+ }
+
+ :where(.agents-view, .agents-view-portal) .byoa h2 .ph {
+ width: 16px;
+ height: 16px;
+ color: var(--accent);
+ }
+
+ :where(.agents-view, .agents-view-portal) .byoa p {
+ margin: 6px 0 0;
+ font-size: 13px;
+ line-height: 1.5;
+ color: var(--ink-muted);
+ max-width: 52ch;
+ }
+
+ :where(.agents-view, .agents-view-portal) .byoa p code {
+ font: 12px var(--font-mono);
+ background: var(--surface-3);
+ padding: 1px 5px;
+ border-radius: 4px;
+ color: var(--ink);
+ }
+
+ :where(.agents-view, .agents-view-portal) .rot {
+ display: inline-grid;
+ vertical-align: baseline;
+ text-align: left;
+ position: relative;
+ color: var(--accent);
+ transition: width 380ms cubic-bezier(0.16, 1, 0.3, 1);
+ overflow: visible;
+ }
+
+ :where(.agents-view, .agents-view-portal) .rot .measure {
+ position: absolute;
+ visibility: hidden;
+ white-space: nowrap;
+ pointer-events: none;
+ }
+
+ :where(.agents-view, .agents-view-portal) .rot .w {
+ grid-area: 1 / 1;
+ white-space: nowrap;
+ transition: transform 380ms cubic-bezier(0.16, 1, 0.3, 1), opacity 300ms ease;
+ }
+
+ :where(.agents-view, .agents-view-portal) .rot .w.out {
+ transform: translateY(-70%);
+ opacity: 0;
+ }
+
+ :where(.agents-view, .agents-view-portal) .rot .w.in {
+ transform: translateY(70%);
+ opacity: 0;
+ }
+
+ :where(.agents-view, .agents-view-portal) .byoa .side {
+ display: flex;
+ flex-direction: column;
+ gap: 6px;
+ align-items: stretch;
+ min-width: 0;
+ position: relative;
+ justify-content: center;
+ }
+
+ :where(.agents-view, .agents-view-portal) .byoa .snippet {
+ display: flex;
+ align-items: center;
+ gap: 8px;
+ height: 32px;
+ padding: 0 6px 0 10px;
+ border-radius: 8px;
+ background: var(--surface-0);
+ border: var(--hair) solid var(--edge-muted);
+ font: 11.5px var(--font-mono);
+ color: var(--ink-subtle);
+ min-width: 0;
+ }
+
+ :where(.agents-view, .agents-view-portal) .byoa .snippet > span {
+ min-width: 0;
+ overflow: hidden;
+ text-overflow: ellipsis;
+ white-space: nowrap;
+ }
+
+ :where(.agents-view, .agents-view-portal) .byoa .snippet .icon-btn {
+ margin-left: auto;
+ width: 22px;
+ height: 22px;
+ flex-shrink: 0;
+ }
+
+ :where(.agents-view, .agents-view-portal) .runtimes {
+ display: flex;
+ flex-direction: column;
+ }
+
+ :where(.agents-view, .agents-view-portal) .rt {
+ display: grid;
+ grid-template-columns: 32px minmax(0, 1fr) auto auto;
+ gap: 14px;
+ align-items: center;
+ padding: 12px 24px;
+ }
+
+ :where(.agents-view, .agents-view-portal) .rt .ic {
+ width: 32px;
+ height: 32px;
+ border-radius: 8px;
+ display: grid;
+ place-items: center;
+ background: var(--surface-1);
+ color: var(--ink-muted);
+ box-shadow: 0 0 0 1px var(--edge-muted);
+ }
+
+ :where(.agents-view, .agents-view-portal) .rt .ic .ph {
+ width: 16px;
+ height: 16px;
+ }
+
+ :where(.agents-view, .agents-view-portal) .rt .nm {
+ font-size: 14px;
+ font-weight: 500;
+ color: var(--ink);
+ display: flex;
+ align-items: center;
+ gap: 8px;
+ }
+
+ :where(.agents-view, .agents-view-portal) .rt .sub {
+ font-size: 12px;
+ color: var(--ink-disabled);
+ margin-top: 1px;
+ }
+
+ :where(.agents-view, .agents-view-portal) .rt .conn {
+ display: inline-flex;
+ align-items: center;
+ gap: 6px;
+ font-size: 12px;
+ color: var(--ink-subtle);
+ white-space: nowrap;
+ }
+
+ :where(.agents-view, .agents-view-portal) .rt .conn::before {
+ content: "";
+ width: 6px;
+ height: 6px;
+ border-radius: 50%;
+ background: var(--green);
+ }
+
+ :where(.agents-view, .agents-view-portal) .rt .conn.off {
+ color: var(--ink-disabled);
+ }
+
+ :where(.agents-view, .agents-view-portal) .rt .conn.off::before {
+ background: var(--ink-disabled);
+ }
+
+ :where(.agents-view, .agents-view-portal) .rt .acts {
+ display: flex;
+ gap: 4px;
+ }
+
+ :where(.agents-view, .agents-view-portal) .paircode {
+ display: flex;
+ gap: 8px;
+ justify-content: center;
+ }
+
+ :where(.agents-view, .agents-view-portal) .paircode input {
+ width: 100%;
+ text-align: center;
+ font: 500 22px/1 var(--font-mono);
+ letter-spacing: 0.18em;
+ text-transform: uppercase;
+ height: 48px;
+ border-radius: 10px;
+ border: var(--hair) solid var(--edge-muted);
+ background: var(--surface-1);
+ color: var(--ink);
+ outline: none;
+ }
+
+ :where(.agents-view, .agents-view-portal) .paircode input:focus {
+ border-color: var(--accent);
+ }
+
+ /* ---------- Dialogs (Panel depth 2, rounded-xl) ---------- */
+ :where(.agents-view, .agents-view-portal) .overlay {
+ position: fixed;
+ inset: 0;
+ z-index: 100;
+ background: oklch(0 0 0 / 0.25);
+ display: grid;
+ place-items: center;
+ padding: 16px;
+ animation: dialog-overlay-open 120ms ease-out;
+ }
+
+ @keyframes dialog-overlay-open {
+ from {
+ opacity: 0;
+ }
+
+ to {
+ opacity: 1;
+ }
+ }
+
+ :where(.agents-view, .agents-view-portal) .dialog {
+ width: min(720px, calc(100vw - 16px));
+ max-height: 88vh;
+ display: flex;
+ flex-direction: column;
+ border-radius: 20px;
+ background: var(--menu);
+ color: var(--ink);
+ border: var(--hair) solid var(--edge-muted);
+ box-shadow: var(--shadow-menu);
+ overflow: hidden;
+ animation: dialog-content-open 160ms cubic-bezier(0.16, 1, 0.3, 1);
+ }
+
+ :where(.agents-view, .agents-view-portal) .dialog.narrow {
+ width: min(560px, calc(100vw - 16px));
+ }
+
+ @keyframes dialog-content-open {
+ from {
+ opacity: 0;
+ transform: translateY(6px) scale(0.985);
+ }
+
+ to {
+ opacity: 1;
+ transform: none;
+ }
+ }
+
+ :where(.agents-view, .agents-view-portal) .dialog .dh {
+ display: flex;
+ align-items: center;
+ justify-content: space-between;
+ padding: 0 12px 0 16px;
+ height: 44px;
+ border-bottom: var(--hair) solid var(--edge-muted);
+ flex-shrink: 0;
+ }
+
+ :where(.agents-view, .agents-view-portal) .dialog .dh .t {
+ font-size: 14px;
+ font-weight: 500;
+ display: flex;
+ align-items: center;
+ gap: 8px;
+ }
+
+ :where(.agents-view, .agents-view-portal) .dialog .dh .t .ph {
+ color: var(--ink-muted);
+ }
+
+ :where(.agents-view, .agents-view-portal) .dialog .dh .hr {
+ display: flex;
+ align-items: center;
+ gap: 10px;
+ }
+
+ :where(.agents-view, .agents-view-portal) .dialog .dh .hr .segc {
+ margin-right: 4px;
+ }
+
+ /* connector picker (settings/PipedreamAppPicker) */
+ :where(.agents-view, .agents-view-portal) .picker {
+ display: flex;
+ flex-direction: column;
+ gap: 10px;
+ }
+
+ :where(.agents-view, .agents-view-portal) .picker .results {
+ max-height: 180px;
+ overflow-y: auto;
+ border-radius: 10px;
+ border: var(--hair) solid var(--edge-muted);
+ background: var(--surface-1);
+ }
+
+ :where(.agents-view, .agents-view-portal) .picker .results > * + *,
+ :where(.agents-view, .agents-view-portal) .picker .picked > * + * {
+ border-top: var(--hair) solid var(--edge-muted);
+ }
+
+ :where(.agents-view, .agents-view-portal) .picker .crow {
+ display: flex;
+ align-items: center;
+ gap: 12px;
+ width: 100%;
+ padding: 8px 12px;
+ text-align: left;
+ }
+
+ :where(.agents-view, .agents-view-portal) .picker .crow:hover {
+ background: var(--hover);
+ }
+
+ :where(.agents-view, .agents-view-portal) .picker .crow .mk {
+ width: 16px;
+ height: 16px;
+ border-radius: 4px;
+ display: grid;
+ place-items: center;
+ font: 600 8.5px var(--font-mono);
+ color: var(--ink);
+ background: var(--surface-3);
+ flex-shrink: 0;
+ }
+
+ :where(.agents-view, .agents-view-portal) .picker .crow .nm {
+ display: block;
+ font-size: 13px;
+ color: var(--ink);
+ }
+
+ :where(.agents-view, .agents-view-portal) .picker .crow .ds {
+ display: block;
+ font-size: 11.5px;
+ color: var(--ink-muted);
+ }
+
+ :where(.agents-view, .agents-view-portal) .picker .crow .add {
+ margin-left: auto;
+ color: var(--ink-placeholder);
+ }
+
+ :where(.agents-view, .agents-view-portal) .picker .crow:hover .add {
+ color: var(--accent);
+ }
+
+ :where(.agents-view, .agents-view-portal) .picker .picked {
+ border-radius: 10px;
+ border: var(--hair) solid var(--edge-muted);
+ background: var(--surface-1);
+ }
+
+ :where(.agents-view, .agents-view-portal) .picker .picked .crow {
+ padding: 9px 12px;
+ }
+
+ :where(.agents-view, .agents-view-portal) .picker .picked .crow .mk {
+ width: 20px;
+ height: 20px;
+ font-size: 9.5px;
+ }
+
+ :where(.agents-view, .agents-view-portal) .picker .picked .crow .icon-btn {
+ margin-left: auto;
+ width: 24px;
+ height: 24px;
+ color: var(--ink-disabled);
+ }
+
+ :where(.agents-view, .agents-view-portal) .picker .none {
+ margin: 0;
+ font-size: 12px;
+ color: var(--ink-disabled);
+ }
+
+ /* routine dialog */
+ :where(.agents-view, .agents-view-portal) .dialog .db {
+ padding: 20px;
+ overflow-y: auto;
+ display: flex;
+ flex-direction: column;
+ gap: 24px;
+ }
+
+ :where(.agents-view, .agents-view-portal) .dialog.narrow .db {
+ padding: 12px;
+ gap: 12px;
+ }
+
+ :where(.agents-view, .agents-view-portal) .dialog .df {
+ display: flex;
+ align-items: center;
+ justify-content: space-between;
+ gap: 8px;
+ padding: 12px 20px;
+ border-top: var(--hair) solid var(--edge-muted);
+ flex-shrink: 0;
+ }
+
+ :where(.agents-view, .agents-view-portal) .dialog.narrow .df {
+ padding: 8px 12px;
+ justify-content: flex-end;
+ }
+
+ :where(.agents-view, .agents-view-portal) .field {
+ display: flex;
+ flex-direction: column;
+ gap: 6px;
+ min-width: 0;
+ }
+
+ :where(.agents-view, .agents-view-portal) .field > span {
+ font-size: 12px;
+ font-weight: 500;
+ color: var(--ink);
+ }
+
+ :where(.agents-view, .agents-view-portal) .sinput {
+ width: 100%;
+ border-radius: 8px;
+ border: var(--hair) solid var(--edge-muted);
+ background: var(--color-input);
+ color: var(--ink);
+ font: 14px var(--font-sans);
+ padding: 8px 12px;
+ outline: none;
+ }
+
+ :where(.agents-view, .agents-view-portal) .sinput:focus {
+ border-color: var(--accent);
+ }
+
+ :where(.agents-view, .agents-view-portal) textarea.sinput {
+ resize: vertical;
+ min-height: 120px;
+ font: 12px/20px var(--font-mono);
+ padding: 10px 12px;
+ }
+
+ :where(.agents-view, .agents-view-portal) select.sinput {
+ appearance: none;
+ background-image: linear-gradient(45deg, transparent 50%, var(--ink-disabled) 50%), linear-gradient(135deg, var(--ink-disabled) 50%, transparent 50%);
+ background-position: calc(100% - 16px) 55%, calc(100% - 11px) 55%;
+ background-size: 5px 5px;
+ background-repeat: no-repeat;
+ padding-right: 32px;
+ }
+
+ :where(.agents-view, .agents-view-portal) .grid2 {
+ display: grid;
+ grid-template-columns: 1fr 1fr;
+ gap: 12px;
+ }
+
+ :where(.agents-view, .agents-view-portal) .tagin {
+ display: flex;
+ align-items: center;
+ border-radius: 8px;
+ border: var(--hair) solid var(--edge-muted);
+ padding: 0 8px;
+ background: var(--color-input);
+ }
+
+ :where(.agents-view, .agents-view-portal) .tagin:focus-within {
+ border-color: var(--accent);
+ }
+
+ :where(.agents-view, .agents-view-portal) .tagin .at {
+ font-size: 14px;
+ color: var(--ink-disabled);
+ }
+
+ :where(.agents-view, .agents-view-portal) .tagin input {
+ min-width: 0;
+ flex: 1;
+ background: transparent;
+ border: 0;
+ padding: 8px 6px;
+ font: 14px var(--font-sans);
+ color: var(--ink);
+ outline: none;
+ }
+
+ :where(.agents-view, .agents-view-portal) .avrow {
+ display: flex;
+ align-items: center;
+ gap: 12px;
+ border-bottom: var(--hair) solid var(--edge-muted);
+ padding-bottom: 16px;
+ }
+
+ :where(.agents-view, .agents-view-portal) .avrow .bigav {
+ width: 48px;
+ height: 48px;
+ border-radius: 50%;
+ display: grid;
+ place-items: center;
+ background: var(--surface-1);
+ color: var(--accent);
+ box-shadow: 0 0 0 1px var(--edge-muted);
+ }
+
+ :where(.agents-view, .agents-view-portal) .avrow .bigav .ph {
+ width: 22px;
+ height: 22px;
+ }
+
+ :where(.agents-view, .agents-view-portal) .radio {
+ display: flex;
+ gap: 10px;
+ align-items: flex-start;
+ padding: 10px 12px;
+ border-radius: 10px;
+ border: var(--hair) solid var(--edge-muted);
+ background: var(--surface-1);
+ text-align: left;
+ width: 100%;
+ }
+
+ :where(.agents-view, .agents-view-portal) .radio[aria-checked="true"] {
+ border-color: color-mix(in oklch, var(--accent) 60%, var(--edge));
+ background: var(--selected);
+ }
+
+ :where(.agents-view, .agents-view-portal) .radio .rt {
+ font-size: 13px;
+ font-weight: 500;
+ }
+
+ :where(.agents-view, .agents-view-portal) .radio .rd {
+ font-size: 12px;
+ color: var(--ink-muted);
+ margin-top: 1px;
+ }
+
+ :where(.agents-view, .agents-view-portal) .kv {
+ display: grid;
+ grid-template-columns: auto 1fr;
+ gap: 6px 16px;
+ font-size: 12px;
+ color: var(--ink-muted);
+ padding: 12px 14px;
+ border-radius: 8px;
+ background: var(--surface-1);
+ border: var(--hair) solid var(--edge-muted);
+ }
+
+ :where(.agents-view, .agents-view-portal) .kv .k {
+ color: var(--ink-disabled);
+ }
+
+ :where(.agents-view, .agents-view-portal) .btn {
+ height: 32px;
+ display: inline-flex;
+ align-items: center;
+ gap: 6px;
+ padding: 0 12px;
+ border-radius: 999px;
+ font-size: 13px;
+ font-weight: 500;
+ color: var(--ink);
+ background: var(--active);
+ }
+
+ :where(.agents-view, .agents-view-portal) .btn:hover {
+ background: color-mix(in oklch, var(--ink) 9%, transparent);
+ }
+
+ :where(.agents-view, .agents-view-portal) .btn:disabled {
+ opacity: 0.45;
+ }
+
+ :where(.agents-view, .agents-view-portal) .btn:disabled:hover {
+ background: var(--active);
+ }
+
+ :where(.agents-view, .agents-view-portal) .btn.quiet {
+ background: transparent;
+ color: var(--ink-subtle);
+ }
+
+ :where(.agents-view, .agents-view-portal) .btn.quiet:hover {
+ background: var(--hover);
+ color: var(--ink);
+ }
+
+ :where(.agents-view, .agents-view-portal) .btn.outline {
+ background: transparent;
+ border: var(--hair) solid var(--edge);
+ }
+
+ :where(.agents-view, .agents-view-portal) .btn.outline:hover {
+ background: var(--hover);
+ }
+
+ :where(.agents-view, .agents-view-portal) .btn.danger {
+ background: transparent;
+ color: var(--red);
+ }
+
+ :where(.agents-view, .agents-view-portal) .btn.danger:hover {
+ background: color-mix(in oklch, var(--red) 12%, transparent);
+ }
+
+ :where(.agents-view, .agents-view-portal) .btn .ph {
+ width: 14px;
+ height: 14px;
+ }
+
+ /* two-column dialogs */
+ :where(.agents-view, .agents-view-portal) .dialog.wide {
+ width: min(920px, calc(100vw - 16px));
+ }
+
+ :where(.agents-view, .agents-view-portal) .dialog.xwide {
+ width: min(1080px, calc(100vw - 16px));
+ }
+
+ :where(.agents-view, .agents-view-portal) .cols {
+ display: grid;
+ grid-template-columns: 300px minmax(0, 1fr);
+ gap: 20px;
+ align-items: start;
+ }
+
+ :where(.agents-view, .agents-view-portal) .dialog.fixed {
+ height: min(860px, 92vh);
+ max-height: 92vh;
+ }
+
+ :where(.agents-view, .agents-view-portal) .dialog.fixed .db {
+ overflow: hidden;
+ flex: 1;
+ min-height: 0;
+ }
+
+ :where(.agents-view, .agents-view-portal) .cols.agent {
+ grid-template-columns: 400px minmax(0, 1fr);
+ align-items: stretch;
+ height: 100%;
+ min-height: 0;
+ }
+
+ :where(.agents-view, .agents-view-portal) .mdwrap textarea.always {
+ display: block;
+ font: 13.5px/1.6 var(--font-sans);
+ padding: 14px 18px;
+ }
+
+ :where(.agents-view, .agents-view-portal) .cols.agent .colL {
+ min-height: 0;
+ overflow-y: auto;
+ scrollbar-width: none;
+ padding-right: 2px;
+ gap: 12px;
+ }
+
+ :where(.agents-view, .agents-view-portal) .cols.agent .colL::-webkit-scrollbar {
+ display: none;
+ }
+
+ :where(.agents-view, .agents-view-portal) .cols.agent .colR {
+ display: flex;
+ min-height: 0;
+ }
+
+ :where(.agents-view, .agents-view-portal) .cols.agent .mdwrap {
+ height: auto;
+ flex: 1;
+ min-height: 0;
+ }
+
+ /* uniform pick lists (skills, agents, connectors) */
+ :where(.agents-view, .agents-view-portal) .plist {
+ border: var(--hair) solid var(--edge-muted);
+ border-radius: 10px;
+ background: var(--surface-1);
+ overflow: hidden;
+ }
+
+ :where(.agents-view, .agents-view-portal) .plist.scroll {
+ max-height: 180px;
+ overflow-y: auto;
+ scrollbar-width: thin;
+ scrollbar-color: var(--surface-4) transparent;
+ }
+
+ :where(.agents-view, .agents-view-portal) .plist > * + * {
+ border-top: var(--hair) solid var(--edge-muted);
+ }
+
+ /* scroll affordance: a soft fade at the bottom edge that lifts once you reach the end */
+ :where(.agents-view, .agents-view-portal) .prow {
+ display: grid;
+ grid-template-columns: 16px 16px minmax(0, 1fr) auto;
+ gap: 10px;
+ align-items: center;
+ width: 100%;
+ height: 36px;
+ padding: 0 10px;
+ text-align: left;
+ font-size: 13px;
+ color: var(--ink);
+ }
+
+ :where(.agents-view, .agents-view-portal) .prow:hover {
+ background: var(--hover);
+ }
+
+ :where(.agents-view, .agents-view-portal) .prow .cb.rd {
+ border-radius: 50%;
+ }
+
+ :where(.agents-view, .agents-view-portal) .prow[aria-checked="true"] .cb.rd {
+ background: transparent;
+ border-color: var(--accent);
+ box-shadow: inset 0 0 0 3px var(--surface-1), inset 0 0 0 8px var(--accent);
+ }
+
+ :where(.agents-view, .agents-view-portal) .prow[aria-checked="true"] .cb.rd .ph {
+ display: none;
+ }
+
+ :where(.agents-view, .agents-view-portal) .prow .cb {
+ width: 14px;
+ height: 14px;
+ border-radius: 4px;
+ border: 1.5px solid var(--ink-disabled);
+ display: grid;
+ place-items: center;
+ color: var(--accent-contrast);
+ }
+
+ :where(.agents-view, .agents-view-portal) .prow[aria-checked="true"] .cb {
+ background: var(--accent);
+ border-color: var(--accent);
+ }
+
+ :where(.agents-view, .agents-view-portal) .prow[aria-checked="true"] .cb .ph {
+ width: 10px;
+ height: 10px;
+ display: block;
+ }
+
+ :where(.agents-view, .agents-view-portal) .prow .cb .ph {
+ display: none;
+ }
+
+ :where(.agents-view, .agents-view-portal) .prow > .ph,
+ :where(.agents-view, .agents-view-portal) .prow .mk {
+ width: 16px;
+ height: 16px;
+ color: var(--ink-muted);
+ }
+
+ :where(.agents-view, .agents-view-portal) .prow .mk {
+ border-radius: 4px;
+ display: grid;
+ place-items: center;
+ font: 600 8.5px var(--font-mono);
+ color: var(--ink);
+ background: var(--surface-3);
+ }
+
+ :where(.agents-view, .agents-view-portal) .prow .meta {
+ font-size: 11.5px;
+ color: var(--ink-placeholder);
+ white-space: nowrap;
+ display: inline-flex;
+ align-items: center;
+ gap: 6px;
+ }
+
+ :where(.agents-view, .agents-view-portal) .prow .meta .on::before,
+ :where(.agents-view, .agents-view-portal) .prow .meta .off::before {
+ content: "";
+ display: inline-block;
+ width: 6px;
+ height: 6px;
+ border-radius: 50%;
+ margin-right: 5px;
+ background: var(--green);
+ vertical-align: middle;
+ }
+
+ :where(.agents-view, .agents-view-portal) .prow .meta .off::before {
+ background: var(--ink-disabled);
+ }
+
+ :where(.agents-view, .agents-view-portal) .plist .empty {
+ padding: 14px;
+ text-align: center;
+ font-size: 12.5px;
+ color: var(--ink-muted);
+ }
+
+ :where(.agents-view, .agents-view-portal) .csearch {
+ display: flex;
+ align-items: center;
+ gap: 8px;
+ height: 32px;
+ padding: 0 10px;
+ border-radius: 8px;
+ border: var(--hair) solid var(--edge-muted);
+ background: var(--surface-1);
+ color: var(--ink-placeholder);
+ }
+
+ :where(.agents-view, .agents-view-portal) .csearch input {
+ flex: 1;
+ min-width: 0;
+ background: transparent;
+ border: 0;
+ outline: none;
+ color: var(--ink);
+ font: 13px var(--font-sans);
+ }
+
+ :where(.agents-view, .agents-view-portal) .grp-row {
+ display: flex;
+ align-items: baseline;
+ justify-content: space-between;
+ }
+
+ :where(.agents-view, .agents-view-portal) .grp-row .cnt {
+ font-size: 11px;
+ color: var(--ink-disabled);
+ font-variant-numeric: tabular-nums;
+ }
+
+ :where(.agents-view, .agents-view-portal) .colL {
+ display: flex;
+ flex-direction: column;
+ gap: 16px;
+ min-width: 0;
+ }
+
+ :where(.agents-view, .agents-view-portal) .colR {
+ display: flex;
+ flex-direction: column;
+ gap: 10px;
+ min-width: 0;
+ }
+
+ :where(.agents-view, .agents-view-portal) .grp-h {
+ font-size: 11px;
+ font-weight: 500;
+ letter-spacing: 0.04em;
+ text-transform: uppercase;
+ color: var(--ink-placeholder);
+ margin: 0;
+ }
+
+ :where(.agents-view, .agents-view-portal) .divider {
+ height: var(--hair);
+ background: var(--edge-muted);
+ }
+
+ /* markdown surface (fixed height, scrolls) */
+ :where(.agents-view, .agents-view-portal) .mdwrap {
+ display: flex;
+ flex-direction: column;
+ border: var(--hair) solid var(--edge-muted);
+ border-radius: 12px;
+ background: var(--surface-1);
+ overflow: hidden;
+ height: 460px;
+ }
+
+ :where(.agents-view, .agents-view-portal) .mdwrap .mdbar {
+ display: flex;
+ align-items: center;
+ justify-content: space-between;
+ padding: 6px 8px 6px 12px;
+ border-bottom: var(--hair) solid var(--edge-muted);
+ flex-shrink: 0;
+ }
+
+ :where(.agents-view, .agents-view-portal) .mdwrap .mdbar .lbl {
+ font-size: 12px;
+ font-weight: 500;
+ color: var(--ink);
+ }
+
+ :where(.agents-view, .agents-view-portal) .mdwrap textarea {
+ flex: 1;
+ min-height: 0;
+ width: 100%;
+ resize: none;
+ border: 0;
+ outline: none;
+ background: transparent;
+ color: var(--ink);
+ padding: 14px 16px;
+ font: 12.5px/1.65 var(--font-mono);
+ }
+
+ /* compact settings rows */
+ :where(.agents-view, .agents-view-portal) .srow {
+ display: grid;
+ grid-template-columns: minmax(0, 1fr) auto;
+ align-items: center;
+ gap: 12px;
+ min-height: 32px;
+ }
+
+ :where(.agents-view, .agents-view-portal) .srow .lab {
+ font-size: 13px;
+ color: var(--ink);
+ }
+
+ :where(.agents-view, .agents-view-portal) .srow .lab small {
+ display: block;
+ font-size: 11.5px;
+ color: var(--ink-disabled);
+ margin-top: 1px;
+ }
+
+ :where(.agents-view, .agents-view-portal) .segc {
+ display: inline-flex;
+ padding: 2px;
+ gap: 2px;
+ border-radius: 999px;
+ background: var(--active);
+ }
+
+ :where(.agents-view, .agents-view-portal) .segc button {
+ padding: 3px 10px;
+ border-radius: 999px;
+ font-size: 12px;
+ font-weight: 500;
+ color: var(--ink-subtle);
+ height: 24px;
+ display: inline-flex;
+ align-items: center;
+ gap: 6px;
+ }
+
+ :where(.agents-view, .agents-view-portal) .segc button .ph {
+ width: 12px;
+ height: 12px;
+ }
+
+ :where(.agents-view, .agents-view-portal) .segc.lg button {
+ height: 28px;
+ padding: 4px 12px;
+ font-size: 12.5px;
+ }
+
+ :where(.agents-view, .agents-view-portal) .segc button[aria-pressed="true"] {
+ background: var(--surface-3);
+ color: var(--ink);
+ box-shadow: inset 0 0 0 0.5px var(--edge);
+ }
+
+ :where(.agents-view, .agents-view-portal) .sinput.sm {
+ padding: 6px 10px;
+ font-size: 13px;
+ width: auto;
+ min-width: 150px;
+ }
+
+ /* routine block page (block-automation/component/Automation.tsx) */
+ :where(.agents-view, .agents-view-portal) .switch {
+ display: inline-flex;
+ align-items: center;
+ gap: 8px;
+ height: 28px;
+ padding: 0 10px 0 6px;
+ border-radius: 8px;
+ border: var(--hair) solid var(--edge);
+ font-size: 12.5px;
+ font-weight: 500;
+ color: var(--ink-muted);
+ }
+
+ :where(.agents-view, .agents-view-portal) .switch:hover {
+ background: var(--hover);
+ }
+
+ :where(.agents-view, .agents-view-portal) .switch .trk {
+ width: 26px;
+ height: 16px;
+ border-radius: 999px;
+ background: var(--surface-4);
+ position: relative;
+ transition: background 160ms ease;
+ }
+
+ :where(.agents-view, .agents-view-portal) .switch .trk::after {
+ content: "";
+ position: absolute;
+ top: 2px;
+ left: 2px;
+ width: 12px;
+ height: 12px;
+ border-radius: 50%;
+ background: var(--ink);
+ transition: transform 160ms cubic-bezier(0.16, 1, 0.3, 1);
+ }
+
+ :where(.agents-view, .agents-view-portal) .switch[aria-checked="true"] .trk {
+ background: var(--green);
+ }
+
+ :where(.agents-view, .agents-view-portal) .switch[aria-checked="true"] .trk::after {
+ transform: translateX(10px);
+ background: oklch(0.15 0 0);
+ }
+
+ :where(.agents-view, .agents-view-portal) .switch[aria-checked="true"] {
+ color: var(--ink);
+ }
+
+ :where(.agents-view, .agents-view-portal) .bbar {
+ display: inline-flex;
+ align-items: center;
+ gap: 2px;
+ padding: 2px;
+ border-radius: 10px;
+ background: var(--active);
+ }
+
+ :where(.agents-view, .agents-view-portal) .bbar .icon-btn {
+ border-radius: 8px;
+ }
+
+ :where(.agents-view, .agents-view-portal) .bbar .sep {
+ width: var(--hair);
+ height: 16px;
+ background: var(--edge);
+ margin: 0 2px;
+ }
+
+ :where(.agents-view, .agents-view-portal):not([data-session]) .bbar .session-only {
+ display: none;
+ }
+
+ :where(.agents-view, .agents-view-portal) .btn.sm {
+ height: 28px;
+ padding: 0 10px;
+ font-size: 12.5px;
+ border-radius: 8px;
+ }
+
+ :where(.agents-view, .agents-view-portal) .menu.below {
+ bottom: auto;
+ top: calc(100% + 6px);
+ width: 200px;
+ }
+
+ /* ---------- Session pane ---------- */
+ :where(.agents-view, .agents-view-portal) .pane .meta {
+ display: none;
+ gap: 16px;
+ padding: 6px 16px;
+ border-bottom: var(--hair) solid var(--edge-muted);
+ color: var(--ink-placeholder);
+ flex-shrink: 0;
+ }
+
+ :where(.agents-view, .agents-view-portal)[data-mode="work"] .pane .meta {
+ display: flex;
+ }
+
+ :where(.agents-view, .agents-view-portal) .pane .meta .k {
+ color: var(--ink-disabled);
+ }
+
+ :where(.agents-view, .agents-view-portal) .pane .scroll {
+ flex: 1;
+ overflow: auto;
+ padding: 20px 16px;
+ }
+
+ @keyframes spin {
+ to {
+ transform: rotate(360deg);
+ }
+ }
+
+ :where(.agents-view, .agents-view-portal) .pane .dock {
+ padding: 0 16px 16px;
+ flex-shrink: 0;
+ }
+
+ :where(.agents-view, .agents-view-portal) .pane .dock .composer-anchor {
+ width: min(100%, 896px);
+ margin: 0 auto;
+ }
+
+ :where(.agents-view, .agents-view-portal) .pane .dock textarea {
+ min-height: 60px;
+ padding-top: 14px;
+ }
+
+ /* The session transcript keeps its own scroller. */
+ :where(.agents-view, .agents-view-portal) .pane .transcript-host {
+ flex: 1;
+ min-height: 0;
+ display: flex;
+ overflow: hidden;
+ }
+
+ :where(.agents-view, .agents-view-portal) .pane .dock .composer-anchor {
+ width: min(100%, 896px);
+ margin: 0 auto;
+ }
+
+ /* Dialogs render through a portal, above every app layer; menus above the page they anchor to. */
+ :where(.agents-view, .agents-view-portal) .overlay {
+ z-index: 1000;
+ }
+
+ :where(.agents-view, .agents-view-portal) .menu {
+ z-index: 60;
+ }
+
+ :where(.agents-view, .agents-view-portal) .menu.below {
+ left: auto;
+ right: 0;
+ }
+
+ :where(.agents-view, .agents-view-portal) .sinput.sm select {
+ width: 100%;
+ }
+
+ :where(.agents-view, .agents-view-portal) .icon-btn:disabled {
+ color: var(--ink-placeholder);
+ }
+
+ :where(.agents-view, .agents-view-portal) .cta:disabled {
+ opacity: 0.5;
+ filter: none;
+ }
+
+ :where(.agents-view, .agents-view-portal) a.link-btn {
+ text-decoration: none;
+ }
+
+ :where(.agents-view, .agents-view-portal) .picker .crow .ds {
+ color: var(--ink-muted);
+ }
+
+ :where(.agents-view, .agents-view-portal) .prow .mk img,
+ :where(.agents-view, .agents-view-portal) .picker .crow .mk img,
+ :where(.agents-view, .agents-view-portal) .picker .crow .mk svg {
+ width: 100%;
+ height: 100%;
+ border-radius: inherit;
+ }
+
+ :where(.agents-view, .agents-view-portal) .aside .content[hidden] {
+ display: none;
+ }
+
+ :where(.agents-view, .agents-view-portal) .list-note {
+ margin: 0;
+ padding: 8px 12px;
+ font-size: 13px;
+ color: var(--ink-placeholder);
+ }
+
+ :where(.agents-view, .agents-view-portal) .av img,
+ :where(.agents-view, .agents-view-portal) .bigav img {
+ width: 100%;
+ height: 100%;
+ object-fit: cover;
+ border-radius: inherit;
+ }
+
+ /* The view shell sizes the columns; each fills its slot. */
+ :where(.agents-view, .agents-view-portal) .aside,
+ :where(.agents-view, .agents-view-portal) .main {
+ height: 100%;
+ }
+}
diff --git a/apps/web/src/features/agents-view/components/AgentGlyph.tsx b/apps/web/src/features/agents-view/components/AgentGlyph.tsx
new file mode 100644
index 0000000000..3150620fdb
--- /dev/null
+++ b/apps/web/src/features/agents-view/components/AgentGlyph.tsx
@@ -0,0 +1,94 @@
+import { CURSOR_BOT_ID } from '@core/constant/cursorAgent';
+import { MACRO_AGENT_BOT_ID } from '@core/constant/macroAgent';
+import { MACRO_CODER_BOT_ID } from '@core/constant/macroCoder';
+import MacroLogo from '@icon/macro-logo.svg';
+import CursorIcon from '@icon/wide-cursor-ide.svg';
+import CodeIcon from '@phosphor/code.svg';
+import RobotIcon from '@phosphor/robot.svg';
+import { type JSX, Show } from 'solid-js';
+import { MACRO_PERSONA_ID } from '../core/roster';
+
+/** What an agent's avatar shows when it has no picture of its own. */
+export type GlyphAgent = {
+ id: string;
+ botId?: string;
+ name: string;
+ avatarUrl?: string;
+};
+
+const MACRO_IDS: ReadonlySet<string> = new Set([
+ MACRO_PERSONA_ID,
+ MACRO_AGENT_BOT_ID,
+ MACRO_CODER_BOT_ID,
+]);
+
+/** The mark for an agent: Macro's own logo, Cursor's, or a robot. */
+export function AgentIcon(props: {
+ agent: Pick<GlyphAgent, 'id' | 'botId'>;
+ class?: string;
+}) {
+ const id = () => props.agent.botId ?? props.agent.id;
+ return (
+ <Show
+ when={MACRO_IDS.has(id())}
+ fallback={
+ <Show
+ when={id() === CURSOR_BOT_ID}
+ fallback={<RobotIcon class={props.class ?? 'ph'} />}
+ >
+ <CursorIcon class={props.class ?? 'ph'} />
+ </Show>
+ }
+ >
+ <MacroLogo class={props.class ?? 'ph'} />
+ </Show>
+ );
+}
+
+/** The `</>` mark a coder wears on its avatar. */
+export function CodeMark(props: { hidden?: boolean }) {
+ return (
+ <span class="codemark" aria-hidden="true" hidden={props.hidden}>
+ <CodeIcon class="ph" />
+ </span>
+ );
+}
+
+/**
+ * Avatar with the coder mark. `cls` names the avatar shape the design uses
+ * where it sits: `av` in cards and rows, `bigav` in the editor.
+ */
+export function AgentAvatar(props: {
+ agent: GlyphAgent;
+ coder: boolean;
+ cls?: 'av' | 'bigav';
+ children?: JSX.Element;
+}) {
+ return (
+ <span class="avw">
+ <span class={props.cls ?? 'av'}>
+ <Show
+ when={props.agent.avatarUrl}
+ fallback={<AgentIcon agent={props.agent} />}
+ >
+ {(url) => (
+ <img
+ src={url()}
+ alt=""
+ style={{
+ width: '100%',
+ height: '100%',
+ 'object-fit': 'cover',
+ 'border-radius': 'inherit',
+ }}
+ />
+ )}
+ </Show>
+ </span>
+ <Show when={props.coder}>
+ <CodeMark />
+ </Show>
+ {props.children}
+ </span>
+ );
+}
diff --git a/apps/web/src/features/agents-view/components/AgentResourceList.tsx b/apps/web/src/features/agents-view/components/AgentResourceList.tsx
deleted file mode 100644
index fc7f9f6895..0000000000
--- a/apps/web/src/features/agents-view/components/AgentResourceList.tsx
+++ /dev/null
@@ -1,99 +0,0 @@
-import { runCreateAction } from '@app/features/command/Launcher';
-import {
- compileToAst,
- defineQueryFilters,
- queryStateFrom,
-} from '@app/features/next-soup/filters/filter-store';
-import { useSplitLayout } from '@components/app/split-layout/layout';
-import ClockIcon from '@phosphor/clock-clockwise.svg';
-import PlusIcon from '@phosphor/plus.svg';
-import SkillIcon from '@phosphor/sparkle.svg';
-import { useAutomationEntities } from '@queries/agent-schedule/entities';
-import { useSoupAstItemsQuery } from '@queries/soup/items';
-import { Button } from '@ui';
-import { For, Show } from 'solid-js';
-import { Dynamic } from 'solid-js/web';
-
-export function AgentResourceList(props: { page: 'routines' | 'skills' }) {
- const layout = useSplitLayout();
- const automations = useAutomationEntities();
- const skillsQuery = useSoupAstItemsQuery(
- () => ({
- params: { limit: 100, sort_method: 'updated_at' },
- body: compileToAst(
- queryStateFrom(defineQueryFilters({ include: { subType: ['skill'] } }))
- ),
- }),
- () => ({ enabled: props.page === 'skills' })
- );
- const items = () =>
- props.page === 'routines'
- ? automations()
- : skillsQuery.isLoading
- ? []
- : (skillsQuery.data?.entities ?? []);
- const loading = () => props.page === 'skills' && skillsQuery.isLoading;
- const error = () => props.page === 'skills' && Boolean(skillsQuery.error);
-
- return (
- <div class="flex h-full min-h-0 flex-col">
- <div class="flex h-12 shrink-0 items-center px-4">
- <Button
- variant="ghost"
- size="sm"
- class="h-8 gap-2 rounded-lg bg-ink/4 px-3"
- onClick={() =>
- runCreateAction(props.page === 'routines' ? 'automation' : 'skill')
- }
- >
- <PlusIcon class="size-3.5" />
- {props.page === 'routines' ? 'New routine' : 'New skill'}
- </Button>
- </div>
- <div class="min-h-0 flex-1 overflow-y-auto p-3">
- <For each={items()}>
- {(item) => (
- <Button
- variant="ghost"
- class="h-12 w-full justify-start gap-3 rounded-xl px-3 font-normal"
- onClick={(event) =>
- layout.openWithSplit(
- {
- type: props.page === 'routines' ? 'automation' : 'skill',
- id: item.id,
- },
- { preferNewSplit: event.shiftKey }
- )
- }
- >
- <Dynamic
- component={props.page === 'routines' ? ClockIcon : SkillIcon}
- class="size-4 text-ink-muted"
- />
- <span class="truncate">{item.name}</span>
- </Button>
- )}
- </For>
- <Show when={items().length === 0 && !error()}>
- <p class="px-3 py-6 text-sm text-ink-muted">
- {loading() ? 'Loading skills…' : `No ${props.page} yet`}
- </p>
- </Show>
- <Show when={error()}>
- <Button variant="ghost" onClick={() => void skillsQuery.refetch()}>
- Retry loading skills
- </Button>
- </Show>
- <Show when={props.page === 'skills' && skillsQuery.hasNextPage}>
- <Button
- variant="ghost"
- disabled={skillsQuery.isFetchingNextPage}
- onClick={() => void skillsQuery.fetchNextPage()}
- >
- {skillsQuery.isFetchingNextPage ? 'Loading…' : 'More skills'}
- </Button>
- </Show>
- </div>
- </div>
- );
-}
diff --git a/apps/web/src/features/agents-view/components/AgentSessionPane.tsx b/apps/web/src/features/agents-view/components/AgentSessionPane.tsx
index 12e2add197..e137aa144e 100644
--- a/apps/web/src/features/agents-view/components/AgentSessionPane.tsx
+++ b/apps/web/src/features/agents-view/components/AgentSessionPane.tsx
@@ -1,4 +1,3 @@
-import { ViewSidebarToggle } from '@app/components/view-shell/ViewShell';
import { AgentComposer } from '@app/features/block-agent/component/AgentComposer';
import { AgentPullRequestChip } from '@app/features/block-agent/component/AgentPullRequestChip';
import { Transcript } from '@app/features/block-agent/component/Transcript';
@@ -6,51 +5,273 @@ import {
AgentSessionProvider,
useAgentSession,
} from '@app/features/block-agent/context/AgentSessionContext';
+import { isDisconnected } from '@app/features/block-agent/context/create-session-status-controller';
import {
forgetPendingSession,
pendingSession,
} from '@app/features/block-agent/context/pending-session';
+import { makeCopyLinkAction } from '@app/features/next-soup/actions';
+import { useSplitLayout } from '@components/app/split-layout/layout';
import { LoadErrorPanel } from '@core/component/EntityLoadGate';
-import { onCleanup, Show } from 'solid-js';
+import { Permissions } from '@core/component/SharePermissions';
+import { toast } from '@core/component/Toast/Toast';
+import {
+ ShareDialogContext,
+ ShareModal,
+} from '@core/component/TopBar/ShareButton';
+import {
+ deleteAgentSession,
+ renameAgentSession,
+} from '@queries/agent-session/entity-mutations';
+import {
+ type FavoritesFilter,
+ useAddFavoriteMutation,
+ useFavoritesData,
+ useRemoveFavoriteMutation,
+} from '@queries/favorites/favorites';
+import { createSignal, onCleanup, Show, Suspense } from 'solid-js';
+import type { AgentsMode } from '../core/mode';
+import { repositoryLabel } from '../core/repository';
+import { type RosterAgent, runtimeLabel } from '../core/roster';
+import { ChatSessionInput } from './ChatComposer';
+import { SessionModelSelector } from './ModelSelector';
+import { modelLabel } from './model-label';
+import { ConfirmDialog, RenameDialog } from './SimpleDialogs';
+import { Topbar } from './Topbar';
+
+const FAVORITES_FILTER: FavoritesFilter = { entityType: ['agent_session'] };
+
+function SessionContent(props: {
+ mode: AgentsMode;
+ roster: RosterAgent[];
+ onDeleted: () => void;
+}) {
+ const {
+ blockedOnUser,
+ loadFailed,
+ loadRetryable,
+ metadata,
+ pending,
+ retryLoad,
+ session,
+ sessionId,
+ status,
+ working,
+ } = useAgentSession();
+ const { openWithSplit } = useSplitLayout();
+ const favorites = useFavoritesData(FAVORITES_FILTER);
+ const addFavorite = useAddFavoriteMutation();
+ const removeFavorite = useRemoveFavoriteMutation();
+ const [shareOpen, setShareOpen] = createSignal(false);
+ const [renaming, setRenaming] = createSignal(false);
+ const [deleting, setDeleting] = createSignal(false);
+ const [busy, setBusy] = createSignal(false);
+
+ const title = () => metadata()?.title ?? session()?.name ?? 'New chat';
+ const isFavorite = () => {
+ const id = sessionId();
+ return (
+ !!id &&
+ (favorites()?.favorites ?? []).some(
+ (favorite) => favorite.entityId === id
+ )
+ );
+ };
+ const agent = () =>
+ props.roster.find((candidate) => candidate.botId === session()?.botId);
+ const state = () => {
+ if (pending()) return { cls: 'running', label: 'Starting' };
+ if (isDisconnected(status()))
+ return { cls: 'failed', label: 'Disconnected' };
+ if (blockedOnUser()) return { cls: 'waiting', label: 'Needs input' };
+ if (working()) return { cls: 'running', label: 'Running' };
+ return { cls: 'done', label: 'Ready' };
+ };
-function AgentSessionContent() {
- const { loadFailed, loadRetryable, metadata, retryLoad, session } =
- useAgentSession();
+ const toggleFavorite = () => {
+ const id = sessionId();
+ if (!id) return;
+ const args = { entityId: id, entityType: 'agent_session' as const };
+ if (isFavorite()) removeFavorite.mutate(args);
+ else addFavorite.mutate(args);
+ };
+ const copyLink = () => {
+ const id = sessionId();
+ if (id)
+ void makeCopyLinkAction().executeByBlock(
+ id,
+ props.mode === 'code' ? 'coders' : 'agents'
+ );
+ };
+ const openInSplit = () => {
+ const id = sessionId();
+ if (id) openWithSplit({ type: 'agent', id }, { referredFrom: 'launcher' });
+ };
+ const rename = async (name: string) => {
+ const id = sessionId();
+ if (!id) return;
+ setBusy(true);
+ try {
+ await renameAgentSession(id, name);
+ setRenaming(false);
+ } catch {
+ toast.failure('Could not rename the session');
+ } finally {
+ setBusy(false);
+ }
+ };
+ const remove = async () => {
+ const id = sessionId();
+ if (!id) return;
+ setBusy(true);
+ try {
+ await deleteAgentSession(id);
+ setDeleting(false);
+ props.onDeleted();
+ } catch {
+ toast.failure('Could not delete the session');
+ } finally {
+ setBusy(false);
+ }
+ };
return (
- <>
- <header class="flex h-12 shrink-0 items-center justify-between gap-3 border-b border-edge px-4">
- <ViewSidebarToggle action="expand" />
- <h2 class="min-w-0 flex-1 truncate text-sm font-semibold text-ink">
- {metadata()?.title ?? session()?.name ?? 'New Chat'}
- </h2>
+ <ShareDialogContext.Provider
+ value={{
+ isOpen: shareOpen,
+ open: () => setShareOpen(true),
+ close: () => setShareOpen(false),
+ }}
+ >
+ <Topbar
+ title={title()}
+ session={{
+ favorite: isFavorite(),
+ onToggleFavorite: toggleFavorite,
+ onShare: () => setShareOpen(true),
+ onSidePanel: openInSplit,
+ onRename: () => setRenaming(true),
+ onCopyLink: copyLink,
+ onDelete: () => setDeleting(true),
+ }}
+ >
<Show when={session()?.pullRequestUrl}>
{(url) => <AgentPullRequestChip url={url()} />}
</Show>
- </header>
- <Show
- when={!loadFailed()}
- fallback={
- <LoadErrorPanel
- title="Unable to load this session"
- onRetry={loadRetryable() ? retryLoad : undefined}
- />
- }
- >
- <div class="flex min-h-0 flex-1 overflow-hidden">
- <Transcript />
- </div>
- <div class="mx-auto w-full max-w-4xl shrink-0 px-4 pb-4">
- <AgentComposer autofocus />
- </div>
+ </Topbar>
+ <div class="body">
+ <section class="page pane" data-active aria-label="Agent session">
+ <div class="meta mono">
+ <Show when={sessionId()}>
+ {(id) => (
+ <span>
+ <span class="k">session</span> {id()}
+ </span>
+ )}
+ </Show>
+ <Show when={agent()}>
+ {(current) => (
+ <span>
+ <span class="k">agent</span> @{current().handle}
+ </span>
+ )}
+ </Show>
+ <Show when={session()?.harness}>
+ {(harness) => (
+ <span>
+ <span class="k">harness</span>{' '}
+ {runtimeLabel(harness(), undefined, [])}
+ </span>
+ )}
+ </Show>
+ <Show when={metadata()?.model ?? session()?.model}>
+ {(model) => (
+ <span>
+ <span class="k">model</span> {modelLabel(model())}
+ </span>
+ )}
+ </Show>
+ <Show when={session()?.repoUrl}>
+ {(url) => (
+ <span>
+ <span class="k">repo</span> {repositoryLabel(url())}
+ </span>
+ )}
+ </Show>
+ <span class={`stdot ${state().cls}`}>{state().label}</span>
+ </div>
+ <Show
+ when={!loadFailed()}
+ fallback={
+ <LoadErrorPanel
+ title="Unable to load this session"
+ onRetry={loadRetryable() ? retryLoad : undefined}
+ />
+ }
+ >
+ <div class="transcript-host">
+ <Transcript />
+ </div>
+ <div class="dock">
+ <div class="composer-anchor">
+ <AgentComposer
+ autofocus
+ input={ChatSessionInput}
+ modelSelector={SessionModelSelector}
+ />
+ </div>
+ </div>
+ </Show>
+ </section>
+ </div>
+
+ <Show when={sessionId() && session()}>
+ {(_) => (
+ <Suspense>
+ <ShareModal
+ id={sessionId() ?? ''}
+ name={title()}
+ owner={session()?.ownerId ?? ''}
+ itemType="agent_session"
+ blockAlias="agent"
+ userPermissions={Permissions.OWNER}
+ isSharePermOpen={shareOpen()}
+ setIsSharePermOpen={setShareOpen}
+ />
+ </Suspense>
+ )}
+ </Show>
+ <Show when={renaming()}>
+ <RenameDialog
+ value={title()}
+ pending={busy()}
+ onRename={(name) => void rename(name)}
+ onClose={() => setRenaming(false)}
+ />
+ </Show>
+ <Show when={deleting()}>
+ <ConfirmDialog
+ title="Delete session?"
+ body="This removes the session and its transcript for everyone it was shared with. This cannot be undone."
+ confirmLabel="Delete session"
+ pendingLabel="Deleting…"
+ danger
+ pending={busy()}
+ onConfirm={() => void remove()}
+ onClose={() => setDeleting(false)}
+ />
</Show>
- </>
+ </ShareDialogContext.Provider>
);
}
+/** A conversation opened in the workspace: its title row, transcript, and composer. */
export function AgentSessionPane(props: {
id: string;
+ mode: AgentsMode;
+ roster: RosterAgent[];
onSessionId: (sessionId: string) => void;
+ onDeleted: () => void;
}) {
const pending = pendingSession(props.id);
onCleanup(() => {
@@ -61,7 +282,11 @@ export function AgentSessionPane(props: {
return (
<AgentSessionProvider blockId={props.id} onSessionId={props.onSessionId}>
- <AgentSessionContent />
+ <SessionContent
+ mode={props.mode}
+ roster={props.roster}
+ onDeleted={props.onDeleted}
+ />
</AgentSessionProvider>
);
}
diff --git a/apps/web/src/features/agents-view/components/AgentsSidebar.test.tsx b/apps/web/src/features/agents-view/components/AgentsSidebar.test.tsx
new file mode 100644
index 0000000000..69c8adc672
--- /dev/null
+++ b/apps/web/src/features/agents-view/components/AgentsSidebar.test.tsx
@@ -0,0 +1,83 @@
+import { fireEvent, render, screen } from '@solidjs/testing-library';
+import type { JSX } from 'solid-js';
+import { describe, expect, it, vi } from 'vitest';
+import {
+ type AgentConversationEntity,
+ groupConversations,
+} from '../core/recent-conversations';
+import { AgentsSidebar } from './AgentsSidebar';
+
+vi.mock('@app/components/view-shell', () => ({
+ useViewControlHotkeys: vi.fn(),
+ ViewSidebar: {
+ Header: (props: { children: JSX.Element }) => <div>{props.children}</div>,
+ Title: (props: { children: JSX.Element }) => <h1>{props.children}</h1>,
+ },
+}));
+vi.mock('@components/app/split-layout/layoutUtils', () => ({
+ useSplitPanelOrThrow: () => ({
+ splitHotkeyScope: 'test',
+ isPanelActive: () => true,
+ }),
+}));
+vi.mock('@components/app/split-panel', () => ({
+ SplitPanel: { CloseButton: () => null },
+}));
+vi.mock('@app/components/view-shell/SidebarCreateButton', () => ({
+ SidebarCreateButton: (props: { label: string; onCreate: () => void }) => (
+ <button onClick={props.onCreate}>{props.label}</button>
+ ),
+}));
+
+describe('mixed Agents sidebar', () => {
+ it('keeps Chat and Code together, marks each kind, and preserves split navigation', () => {
+ const conversations: AgentConversationEntity[] = [
+ {
+ type: 'agent_session',
+ id: 'code',
+ name: 'Fix build',
+ ownerId: 'me',
+ botId: 'cursor',
+ status: 'acp_ready',
+ },
+ { type: 'chat', id: 'chat', name: 'Plan launch', ownerId: 'me' },
+ ];
+ const open = vi.fn();
+ const create = vi.fn();
+ render(() => (
+ <AgentsSidebar
+ groups={groupConversations(conversations)}
+ modeForConversation={(conversation) =>
+ conversation.id === 'code' ? 'code' : 'chat'
+ }
+ activeConversationId="chat"
+ search=""
+ loading={false}
+ error={false}
+ hasNextPage={false}
+ loadingNextPage={false}
+ handleForBot={() => undefined}
+ onNewConversation={create}
+ onSearchChange={vi.fn()}
+ onOpenConversation={open}
+ onRetry={vi.fn()}
+ onLoadMore={vi.fn()}
+ />
+ ));
+ expect(screen.queryByRole('tablist')).toBeNull();
+ const code = screen.getByRole('button', { name: /Fix build/ });
+ const chat = screen.getByRole('button', { name: /Plan launch/ });
+ expect(code.getAttribute('data-kind')).toBe('code');
+ expect(chat.getAttribute('data-kind')).toBe('chat');
+ expect(chat.getAttribute('aria-current')).toBe('page');
+ fireEvent.click(code, { shiftKey: true });
+ expect(open).toHaveBeenCalledWith(
+ conversations[0],
+ expect.objectContaining({ shiftKey: true })
+ );
+ fireEvent.click(chat);
+ expect(open).toHaveBeenLastCalledWith(conversations[1], expect.anything());
+ fireEvent.click(screen.getByRole('button', { name: 'New conversation' }));
+ expect(create).toHaveBeenCalledOnce();
+ });
+});
diff --git a/apps/web/src/features/agents-view/components/AgentsSidebar.tsx b/apps/web/src/features/agents-view/components/AgentsSidebar.tsx
index eb9dafbc1d..4d8e7b22d5 100644
--- a/apps/web/src/features/agents-view/components/AgentsSidebar.tsx
+++ b/apps/web/src/features/agents-view/components/AgentsSidebar.tsx
@@ -1,278 +1,126 @@
-import { createListController } from '@app/components/list';
-import {
- CollapsibleSection,
- SearchBar,
- useViewControlHotkeys,
- ViewSidebar,
-} from '@app/components/view-shell';
-import { DOCS_BASE } from '@app/constants/docs-links';
-import { FavoriteContextMenu } from '@app/features/favorites/FavoriteContextMenu';
-import { FavoriteIcon } from '@app/features/favorites/FavoriteIcon';
-import {
- type EntityActionViewContext,
- toEntityActionListState,
-} from '@app/features/next-soup/actions';
-import { SoupEntityContextMenu } from '@app/features/soup';
-import { DEBUG_SETTING_KEYS, useDebugSetting } from '@app/lib/debugSettings';
-import { useFavoriteDisplayName } from '@app/util/favorites';
+import { useViewControlHotkeys, ViewSidebar } from '@app/components/view-shell';
+import { SidebarCreateButton } from '@app/components/view-shell/SidebarCreateButton';
import { useSplitPanelOrThrow } from '@components/app/split-layout/layoutUtils';
import { SplitPanel } from '@components/app/split-panel';
-import { ScrollIndicators } from '@core/component/VerticalScrollIndicators';
-import EmptyStateAiGraphic from '@design/empty-state-ai.svg';
-import EmptyStateNoSearchMatchGraphic from '@design/empty-state-no-search-match.svg';
-import { Entity, EntityRowIcon } from '@entity';
-import BookOpenIcon from '@phosphor/book-open.svg';
-import ClockIcon from '@phosphor/clock-clockwise.svg';
+import ChatIcon from '@phosphor/chat-circle.svg';
+import CodeIcon from '@phosphor/code.svg';
import MagnifyingGlassIcon from '@phosphor/magnifying-glass.svg';
-import PlugsIcon from '@phosphor/plugs.svg';
-import PlusIcon from '@phosphor/plus.svg';
-import SpinnerIcon from '@phosphor/spinner.svg';
-import {
- type FavoritesFilter,
- useFavoritesData,
-} from '@queries/favorites/favorites';
-import type { Favorite } from '@service-storage/generated/schemas/favorite';
import { Key } from '@solid-primitives/keyed';
-import { Button, cn, EmptyStatePanel, Scroll } from '@ui';
+import { createSignal, For, Show } from 'solid-js';
+import {
+ conversationState,
+ conversationStateLabel,
+} from '../core/conversation-state';
+import { compactAge } from '../core/format-age';
+import type { AgentsMode } from '../core/mode';
import {
- createEffect,
- createMemo,
- createSignal,
- For,
- onCleanup,
- Show,
-} from 'solid-js';
-import { Dynamic } from 'solid-js/web';
-import type { AgentsPage } from '../core/pages';
-import type {
- AgentConversationEntity,
- AgentConversationTarget,
+ type AgentConversationEntity,
+ type ConversationGroup,
+ conversationBotId,
+ conversationTimestamp,
} from '../core/recent-conversations';
-// Configurable agents ship after the sidebar, so the 'agents' and 'skills'
-// pages have no nav entries yet. When they do, add
-// `{ id: 'agents', label: 'Agents', icon: AgentIcon }` and
-// `{ id: 'skills', label: 'Skills', icon: SkillIcon }` back here, both icons
-// imported from `@phosphor/sparkle.svg`.
-const PAGES = [
- { id: 'new', label: 'New Chat', icon: PlusIcon },
- { id: 'routines', label: 'Routines', icon: ClockIcon },
- { id: 'connections', label: 'Connections', icon: PlugsIcon },
-] satisfies {
- id: AgentsPage;
- label: string;
- icon: typeof PlusIcon;
-}[];
-
-const AGENT_ACTION_VIEW_CONTEXT: EntityActionViewContext = {
- supportsMarkDone: false,
- senderBucket: undefined,
-};
-
-const AGENT_FAVORITES_FILTER = {
- entityType: ['agent_session', 'chat'],
-} satisfies FavoritesFilter;
-
-function FavoriteRow(props: {
- favorite: Favorite;
- onOpen: (favorite: Favorite, event: MouseEvent) => void;
-}) {
- const name = useFavoriteDisplayName(props.favorite);
-
- return (
- <FavoriteContextMenu favorite={props.favorite} triggerClass="block">
- <ViewSidebar.Item
- title={name()}
- onClick={(event) => props.onOpen(props.favorite, event)}
- >
- <ViewSidebar.Icon>
- <FavoriteIcon favorite={props.favorite} class="size-4" />
- </ViewSidebar.Icon>
- <span class="truncate">{name()}</span>
- </ViewSidebar.Item>
- </FavoriteContextMenu>
- );
-}
-
-function AgentFavorites(props: {
+export type AgentsSidebarProps = {
+ modeForConversation: (conversation: AgentConversationEntity) => AgentsMode;
+ activeConversationId: string | undefined;
+ search: string;
+ groups: ConversationGroup[];
+ loading: boolean;
+ error: boolean;
+ hasNextPage: boolean;
+ loadingNextPage: boolean;
+ /** The bot behind a session, as `@handle`, when the roster knows it. */
+ handleForBot: (botId: string | undefined) => string | undefined;
+ onNewConversation: () => void;
+ onSearchChange: (search: string) => void;
onOpenConversation: (
- conversation: AgentConversationTarget,
+ conversation: AgentConversationEntity,
event?: MouseEvent
) => void;
-}) {
- const favoritesData = useFavoritesData(AGENT_FAVORITES_FILTER);
- const [open, setOpen] = createSignal(true);
- const favorites = createMemo(() =>
- (favoritesData()?.favorites ?? []).toSorted(
- (left, right) => left.sortOrder - right.sortOrder
- )
- );
-
- const openFavorite = (favorite: Favorite, event: MouseEvent) => {
- if (
- favorite.entityType !== 'agent_session' &&
- favorite.entityType !== 'chat'
- ) {
- return;
- }
-
- props.onOpenConversation(
- {
- id: favorite.entityId,
- type: favorite.entityType,
- },
- event
- );
- };
-
- return (
- <Show when={favorites().length > 0}>
- <CollapsibleSection.Root open={open()} onOpenChange={setOpen}>
- <CollapsibleSection.Trigger class="text-xs">
- <span class="min-w-0 truncate">Favorites</span>
- <CollapsibleSection.Indicator />
- </CollapsibleSection.Trigger>
- <CollapsibleSection.Content>
- <ViewSidebar.Nav aria-label="Favorite agent chats">
- <For each={favorites()}>
- {(favorite) => (
- <FavoriteRow favorite={favorite} onOpen={openFavorite} />
- )}
- </For>
- </ViewSidebar.Nav>
- </CollapsibleSection.Content>
- </CollapsibleSection.Root>
- </Show>
- );
-}
+ onRetry: () => void;
+ onLoadMore: () => void;
+};
-function ConversationRow(props: {
+function Row(props: {
conversation: AgentConversationEntity;
+ mode: AgentsMode;
active: boolean;
+ handle: string | undefined;
onOpen: (event: MouseEvent) => void;
}) {
- const timestamp = () =>
- props.conversation.updatedAt ?? props.conversation.createdAt;
+ const title = () => props.conversation.name || 'Untitled chat';
+ const state = () =>
+ props.conversation.type === 'agent_session'
+ ? conversationState(props.conversation.status)
+ : undefined;
+ const age = () => compactAge(conversationTimestamp(props.conversation));
+ const stateLabel = () => {
+ const current = state();
+ return current ? conversationStateLabel(current) : undefined;
+ };
return (
- <ViewSidebar.Item
- active={props.active}
- class="group/recent-chat relative"
- title={props.conversation.name || 'Untitled chat'}
+ <button
+ type="button"
+ class={props.active ? 'row active' : 'row'}
+ title={title()}
+ data-kind={props.mode}
+ aria-current={props.active ? 'page' : undefined}
onClick={props.onOpen}
>
- <ViewSidebar.Icon>
- <EntityRowIcon entity={props.conversation} class="size-4" />
- </ViewSidebar.Icon>
- <span class="min-w-0 flex-1 truncate text-left group-hover/recent-chat:pr-12">
- {props.conversation.name || 'Untitled chat'}
+ <span class="lead">
+ <Show
+ when={state() === 'starting'}
+ fallback={
+ <Show
+ when={props.mode === 'code'}
+ fallback={<ChatIcon class="ph" />}
+ >
+ <CodeIcon class="ph" />
+ </Show>
+ }
+ >
+ <span class="spin" />
+ </Show>
</span>
- <Show when={timestamp()}>
- {(value) => (
- <span class="absolute right-3 top-1/2 -translate-y-1/2 text-xs font-light text-ink-extra-muted opacity-0 transition-opacity group-hover/recent-chat:opacity-100 touch:hidden">
- <Entity.Timestamp
- entity={props.conversation}
- overrideTimeStamp={value()}
- />
+ <span class="truncate">{title()}</span>
+ <Show
+ when={props.mode === 'code'}
+ fallback={<span class="when">{age()}</span>}
+ >
+ <span />
+ <span class="sub">
+ <Show when={props.handle}>
+ {(handle) => <span class="h">@{handle()}</span>}
+ </Show>
+ <Show when={props.handle && stateLabel()}>
+ <span>·</span>
+ </Show>
+ <Show when={stateLabel()}>{(label) => <span>{label()}</span>}</Show>
+ <span class="when" style={{ 'margin-left': 'auto' }}>
+ {age()}
</span>
- )}
+ </span>
</Show>
- </ViewSidebar.Item>
+ </button>
);
}
-function RecentChatsEmptyState(props: {
- search: string;
- onStartChat: () => void;
-}) {
- const search = () => props.search.trim();
-
- return (
- <EmptyStatePanel
- centered
- graphic={search() ? EmptyStateNoSearchMatchGraphic : EmptyStateAiGraphic}
- graphicClass="aspect-square h-auto w-[clamp(12rem,70%,18rem)] self-center"
- title={search() ? `No results for "${search()}"` : 'No recent chats'}
- description={
- search()
- ? 'Try a different search.'
- : 'Your latest agent conversations will appear here.'
- }
- descriptionClass="mt-1 text-balance"
- actionsClass="mt-5 flex-row @max-sm:flex-row"
- topSpacerClass="basis-0"
- titleClass={search() ? 'w-full break-words' : undefined}
- primaryAction={
- search()
- ? undefined
- : {
- label: 'Start a chat',
- icon: PlusIcon,
- onClick: props.onStartChat,
- }
- }
- documentationUrl={`${DOCS_BASE}/product/${search() ? 'search' : 'agents'}`}
- documentationIcon={BookOpenIcon}
- class="h-auto overflow-visible px-2 pt-4 @4xl:px-2"
- />
- );
-}
-
-export type AgentsSidebarProps = {
- page: AgentsPage;
- activeConversationId: string | undefined;
- search: string;
- conversations: AgentConversationEntity[];
- loading: boolean;
- error: boolean;
- hasNextPage: boolean;
- loadingNextPage: boolean;
- loadMoreError: boolean;
- onNavigate: (page: AgentsPage) => void;
- onSearchChange: (search: string) => void;
- onOpenConversation: (
- conversation: AgentConversationTarget,
- event?: MouseEvent
- ) => void;
- onRetry: () => void;
- onLoadMore: () => void;
-};
-
export function AgentsSidebar(props: AgentsSidebarProps) {
const panel = useSplitPanelOrThrow();
-
- const forceEmptyState = useDebugSetting(
- DEBUG_SETTING_KEYS.FORCE_EMPTY_STATES
- );
-
const [searchOpen, setSearchOpen] = createSignal(false);
- const [recentChatsOpen, setRecentChatsOpen] = createSignal(true);
-
- const [scrollRoot, setScrollRoot] = createSignal<HTMLElement>();
- const [loadMoreSentinel, setLoadMoreSentinel] =
- createSignal<HTMLDivElement>();
-
let searchInput: HTMLInputElement | undefined;
-
- const visibleConversations = () =>
- forceEmptyState() ? [] : props.conversations;
-
- const actionController = createListController({
- items: visibleConversations,
- getKey: (conversation) => conversation.id,
- isSelectable: () => false,
- });
-
- const actionList = toEntityActionListState({
- controller: actionController,
- getEntity: (conversation) => conversation,
- });
+ const total = () =>
+ props.groups.reduce((sum, group) => sum + group.conversations.length, 0);
const openSearch = () => {
- setRecentChatsOpen(true);
setSearchOpen(true);
queueMicrotask(() => searchInput?.focus());
};
+ const closeSearch = () => {
+ props.onSearchChange('');
+ setSearchOpen(false);
+ };
useViewControlHotkeys({
scopeId: panel.splitHotkeyScope,
@@ -286,41 +134,8 @@ export function AgentsSidebar(props: AgentsSidebarProps) {
},
});
- createEffect(() => {
- const root = scrollRoot();
- const sentinel = loadMoreSentinel();
- if (
- !root ||
- !sentinel ||
- forceEmptyState() ||
- !props.hasNextPage ||
- props.loadingNextPage ||
- props.loadMoreError
- ) {
- return;
- }
-
- const observer = new IntersectionObserver(
- (entries) => {
- if (!entries[0]?.isIntersecting) return;
- if (
- forceEmptyState() ||
- !props.hasNextPage ||
- props.loadingNextPage ||
- props.loadMoreError
- ) {
- return;
- }
- props.onLoadMore();
- },
- { root, rootMargin: '0px 0px 200px' }
- );
- observer.observe(sentinel);
- onCleanup(() => observer.disconnect());
- });
-
return (
- <ViewSidebar.Root aria-label="Agents navigation">
+ <aside class="aside" aria-label="Agents navigation">
<ViewSidebar.Header>
<div class="flex min-w-0 items-center gap-1">
<SplitPanel.CloseButton />
@@ -328,167 +143,111 @@ export function AgentsSidebar(props: AgentsSidebarProps) {
</div>
</ViewSidebar.Header>
- <ViewSidebar.Content class="flex flex-col gap-6 overflow-hidden pt-4">
- <ViewSidebar.Nav aria-label="Agent views">
- <For each={PAGES}>
- {(item) => (
- <ViewSidebar.Item
- active={props.page === item.id && !props.activeConversationId}
- onClick={() => props.onNavigate(item.id)}
- >
- <ViewSidebar.Icon>
- <Dynamic component={item.icon} class="size-4" />
- </ViewSidebar.Icon>
- <span class="truncate">{item.label}</span>
- </ViewSidebar.Item>
- )}
- </For>
- </ViewSidebar.Nav>
-
- <Show when={!forceEmptyState()}>
- <AgentFavorites onOpenConversation={props.onOpenConversation} />
- </Show>
+ <div class="content" data-view="agents">
+ <div class="top-actions">
+ <SidebarCreateButton
+ label="New conversation"
+ onCreate={props.onNewConversation}
+ />
+ </div>
- <CollapsibleSection.Root
- open={recentChatsOpen()}
- onOpenChange={setRecentChatsOpen}
- class={cn(
- 'flex min-h-0 flex-col gap-1',
- recentChatsOpen() ? 'flex-1' : 'shrink-0'
- )}
- >
- <div class="flex h-7 shrink-0 items-center gap-1 pr-1">
- <CollapsibleSection.Trigger class="h-7 min-w-0 flex-1 py-1 text-xs">
- <span class="min-w-0 truncate">Recent chats</span>
- <CollapsibleSection.Indicator />
- </CollapsibleSection.Trigger>
- <Button
- variant="ghost"
- size="icon-sm"
- label={
- searchOpen() ? 'Close agent chat search' : 'Search agent chats'
- }
+ <section class="recent">
+ <div class="sec-head">
+ <h2>Conversations</h2>
+ <button
+ type="button"
+ class="icon-btn"
aria-pressed={searchOpen()}
- class={cn(
- 'size-7 rounded-lg',
- searchOpen() && 'bg-active text-ink'
- )}
- onClick={() => {
- if (searchOpen()) {
- props.onSearchChange('');
- setSearchOpen(false);
- } else {
- openSearch();
- }
- }}
+ aria-label="Search conversations"
+ onClick={() => (searchOpen() ? closeSearch() : openSearch())}
>
- <MagnifyingGlassIcon class="size-3.5" />
- </Button>
+ <MagnifyingGlassIcon class="ph" />
+ </button>
</div>
- <CollapsibleSection.Content class="flex min-h-0 flex-1 flex-col gap-1">
- <Show when={searchOpen()}>
- <SearchBar
- label="Search agent chats"
- placeholder="Search chats"
- ref={(element) => {
- searchInput = element;
- }}
+ <Show when={searchOpen()}>
+ <div class="search">
+ <MagnifyingGlassIcon class="ph" />
+ <input
+ ref={searchInput}
+ placeholder="Search conversations"
+ aria-label="Search conversations"
value={props.search}
- onValueChange={props.onSearchChange}
- onEscape={() => {
- if (!props.search) setSearchOpen(false);
+ onInput={(event) =>
+ props.onSearchChange(event.currentTarget.value)
+ }
+ onKeyDown={(event) => {
+ if (event.key === 'Escape' && !props.search) closeSearch();
}}
- class="h-9 shrink-0 rounded-xl"
/>
- </Show>
- <div class="relative min-h-0 flex-1">
- <Scroll scrollRef={setScrollRoot}>
- <ViewSidebar.Nav aria-label="Recent agent chats">
- {/* Soup cache updates replace entity objects. Key rows by id so
- those updates preserve the list DOM and scroll position. */}
- <Key each={visibleConversations()} by="id">
+ </div>
+ </Show>
+ <nav
+ class="list"
+ aria-label="Recent conversations"
+ onScroll={(event) => {
+ const list = event.currentTarget;
+ if (!props.hasNextPage || props.loadingNextPage) return;
+ if (
+ list.scrollTop + list.clientHeight >=
+ list.scrollHeight - 200
+ ) {
+ props.onLoadMore();
+ }
+ }}
+ >
+ <For each={props.groups}>
+ {(group) => (
+ <>
+ <Show when={group.label}>
+ {(label) => (
+ <div class="group-h">
+ {label()}
+ <span class="n">{group.conversations.length}</span>
+ </div>
+ )}
+ </Show>
+ <Key each={group.conversations} by="id">
{(conversation) => (
- <SoupEntityContextMenu
- entity={conversation()}
- list={actionList}
- selectedEntities={() => []}
- viewContext={AGENT_ACTION_VIEW_CONTEXT}
- class="block w-full"
- onOpenChange={(open) => {
- if (!open) return;
- actionController.focus.set(conversation().id, {
- reason: 'pointer',
- force: true,
- });
- }}
- >
- <ConversationRow
- conversation={conversation()}
- active={
- props.activeConversationId === conversation().id
- }
- onOpen={(event) =>
- props.onOpenConversation(conversation(), event)
- }
- />
- </SoupEntityContextMenu>
+ <Row
+ conversation={conversation()}
+ mode={props.modeForConversation(conversation())}
+ active={
+ props.activeConversationId === conversation().id
+ }
+ handle={props.handleForBot(
+ conversationBotId(conversation())
+ )}
+ onOpen={(event) =>
+ props.onOpenConversation(conversation(), event)
+ }
+ />
)}
</Key>
- <Show when={!forceEmptyState() && props.loading}>
- <p class="px-3 py-2 text-xs text-ink-muted">
- Loading chats…
- </p>
- </Show>
- <Show when={!forceEmptyState() && props.error}>
- <Button variant="ghost" onClick={props.onRetry}>
- Retry loading chats
- </Button>
- </Show>
- <Show
- when={
- forceEmptyState() ||
- (!props.loading &&
- !props.error &&
- props.conversations.length === 0)
- }
- >
- <RecentChatsEmptyState
- search={forceEmptyState() ? '' : props.search}
- onStartChat={() => props.onNavigate('new')}
- />
- </Show>
- <Show when={!forceEmptyState() && props.hasNextPage}>
- <div
- ref={setLoadMoreSentinel}
- role={props.loadingNextPage ? 'status' : undefined}
- aria-label={
- props.loadingNextPage ? 'Loading more chats' : undefined
- }
- class="grid h-9 shrink-0 place-items-center text-ink-muted"
- >
- <Show when={props.loadMoreError}>
- <Button variant="ghost" onClick={props.onLoadMore}>
- Retry loading more chats
- </Button>
- </Show>
- <Show
- when={!props.loadMoreError && props.loadingNextPage}
- >
- <SpinnerIcon class="size-4 animate-spin" />
- </Show>
- </div>
- </Show>
- </ViewSidebar.Nav>
- </Scroll>
- <ScrollIndicators
- scrollRef={scrollRoot}
- appearance="gradient"
- gradientColor="panel"
- />
- </div>
- </CollapsibleSection.Content>
- </CollapsibleSection.Root>
- </ViewSidebar.Content>
- </ViewSidebar.Root>
+ </>
+ )}
+ </For>
+ <Show when={props.loading}>
+ <p class="list-note">Loading conversations…</p>
+ </Show>
+ <Show when={props.error}>
+ <button type="button" class="row" onClick={props.onRetry}>
+ <span class="lead" />
+ <span class="truncate">Retry loading</span>
+ </button>
+ </Show>
+ <Show when={!props.loading && !props.error && total() === 0}>
+ <p class="list-note">
+ {props.search.trim()
+ ? `No results for "${props.search.trim()}"`
+ : 'No conversations yet.'}
+ </p>
+ </Show>
+ <Show when={props.loadingNextPage}>
+ <p class="list-note">Loading more…</p>
+ </Show>
+ </nav>
+ </section>
+ </div>
+ </aside>
);
}
diff --git a/apps/web/src/features/agents-view/components/ArtifactDialog.tsx b/apps/web/src/features/agents-view/components/ArtifactDialog.tsx
new file mode 100644
index 0000000000..0b92de4b35
--- /dev/null
+++ b/apps/web/src/features/agents-view/components/ArtifactDialog.tsx
@@ -0,0 +1,64 @@
+import { type JSX, onCleanup, onMount } from 'solid-js';
+import { Portal } from 'solid-js/web';
+import { useDataMode } from '../context/data-mode';
+
+/**
+ * The design's dialog: a dimmed overlay and a raised panel, rendered through
+ * a portal that carries the view's tokens and mode. Escape, a click on the
+ * overlay, or any `data-close` control inside closes it; the first field
+ * takes focus.
+ */
+export function ArtifactDialog(props: {
+ /** Extra panel classes: `narrow`, `wide`, `xwide`, `fixed`. */
+ class?: string;
+ label: string;
+ onClose: () => void;
+ children: JSX.Element;
+}) {
+ const mode = useDataMode();
+ let panel: HTMLDivElement | undefined;
+
+ onMount(() => {
+ const onKeyDown = (event: KeyboardEvent) => {
+ if (event.key !== 'Escape') return;
+ event.stopPropagation();
+ props.onClose();
+ };
+ document.addEventListener('keydown', onKeyDown);
+ onCleanup(() => document.removeEventListener('keydown', onKeyDown));
+ queueMicrotask(() =>
+ panel
+ ?.querySelector<HTMLElement>(
+ 'input:not([type="file"]), textarea, select'
+ )
+ ?.focus()
+ );
+ });
+
+ return (
+ <Portal>
+ <div class="agents-view-portal" data-mode={mode()}>
+ <div
+ class="overlay"
+ onClick={(event) => {
+ if (event.target === event.currentTarget) props.onClose();
+ }}
+ >
+ <div
+ ref={panel}
+ class={props.class ? `dialog ${props.class}` : 'dialog'}
+ role="dialog"
+ aria-modal="true"
+ aria-label={props.label}
+ onClick={(event) => {
+ const target = event.target as HTMLElement;
+ if (target.closest('[data-close]')) props.onClose();
+ }}
+ >
+ {props.children}
+ </div>
+ </div>
+ </div>
+ </Portal>
+ );
+}
diff --git a/apps/web/src/features/agents-view/components/ChatComposer.test.tsx b/apps/web/src/features/agents-view/components/ChatComposer.test.tsx
new file mode 100644
index 0000000000..0d6c5a20af
--- /dev/null
+++ b/apps/web/src/features/agents-view/components/ChatComposer.test.tsx
@@ -0,0 +1,196 @@
+import { fireEvent, render, screen } from '@solidjs/testing-library';
+import { createSignal } from 'solid-js';
+import { beforeEach, describe, expect, it, vi } from 'vitest';
+import { ChatComposer, ChatSessionInput } from './ChatComposer';
+
+const editor = vi.hoisted(() => ({
+ clear: vi.fn(),
+ setMarkdown: vi.fn(),
+ enter: undefined as
+ | ((event: unknown, markdown: string) => boolean)
+ | undefined,
+ change: undefined as ((markdown: string) => void) | undefined,
+ text: '',
+}));
+
+vi.mock(
+ '@core/component/LexicalMarkdown/builder/MarkdownConfigBuilder',
+ () => ({
+ buildConfig: () => {
+ const builder = {
+ namespace: () => builder,
+ withMentions: () => builder,
+ withEmojis: () => builder,
+ withLinks: () => builder,
+ withHistory: () => builder,
+ withCode: () => builder,
+ withRestoreFocus: () => builder,
+ withSkills: () => builder,
+ withAgentCommands: () => builder,
+ onEnter: (callback: typeof editor.enter) => {
+ editor.enter = callback;
+ return builder;
+ },
+ onFocusLeave: () => builder,
+ onChange: (callback: typeof editor.change) => {
+ editor.change = callback;
+ return builder;
+ },
+ controls: {
+ clear: editor.clear,
+ setMarkdown: editor.setMarkdown,
+ focus: vi.fn(),
+ getMarkdown: () => editor.text,
+ },
+ lexical: {
+ update: vi.fn(),
+ dispatchCommand: vi.fn(),
+ getRootElement: () => null,
+ },
+ };
+ return builder;
+ },
+ })
+);
+
+vi.mock('@core/component/LexicalMarkdown/builder/MarkdownShell', () => ({
+ MarkdownShell: (props: { placeholder?: string }) => (
+ <div data-testid="editor">{props.placeholder}</div>
+ ),
+}));
+
+beforeEach(() => {
+ vi.clearAllMocks();
+ editor.text = '';
+ editor.enter = undefined;
+ editor.change = undefined;
+});
+
+function type(text: string) {
+ editor.text = text;
+ editor.change?.(text);
+}
+
+describe('Chat session input', () => {
+ it('shows only the model control and submits a trimmed follow-up', () => {
+ const send = vi.fn();
+ render(() => (
+ <ChatSessionInput modelControl={<button>Model</button>} onSend={send} />
+ ));
+ expect(
+ screen.getByRole('group', { name: 'Composer settings' }).textContent
+ ).toBe('Model');
+ type(' Follow up ');
+ fireEvent.click(screen.getByRole('button', { name: 'Send' }));
+ expect(send).toHaveBeenCalledWith('Follow up');
+ expect(editor.clear).toHaveBeenCalledOnce();
+ expect(
+ screen.getByRole('button', { name: 'Send' }).hasAttribute('disabled')
+ ).toBe(true);
+ });
+
+ it('keeps a draft intact while the session is pending', () => {
+ const send = vi.fn();
+ render(() => <ChatSessionInput disabled onSend={send} />);
+ type('Wait for the session');
+ editor.enter?.(undefined, editor.text);
+ expect(send).not.toHaveBeenCalled();
+ expect(editor.clear).not.toHaveBeenCalled();
+ });
+
+ it('stops an active turn, then sends a typed prompt to the queue', () => {
+ const send = vi.fn();
+ const stop = vi.fn();
+ render(() => <ChatSessionInput busy onSend={send} onStop={stop} />);
+ fireEvent.click(screen.getByRole('button', { name: 'Stop' }));
+ expect(stop).toHaveBeenCalledOnce();
+ type('Next request');
+ fireEvent.click(screen.getByRole('button', { name: 'Send' }));
+ expect(send).toHaveBeenCalledWith('Next request');
+ });
+
+ it('advances a queued prompt with Enter only when the draft is empty', () => {
+ const send = vi.fn();
+ const stop = vi.fn();
+ render(() => (
+ <ChatSessionInput busy hasQueuedMessages onSend={send} onStop={stop} />
+ ));
+ editor.enter?.(undefined, '');
+ expect(stop).toHaveBeenCalledOnce();
+ type('Another request');
+ editor.enter?.(undefined, editor.text);
+ expect(send).toHaveBeenCalledWith('Another request');
+ expect(stop).toHaveBeenCalledOnce();
+ });
+
+ it('registers and cleans up session focus and quote handlers', () => {
+ const focus = vi.fn();
+ const quote = vi.fn();
+ const { unmount } = render(() => (
+ <ChatSessionInput
+ onSend={vi.fn()}
+ registerFocus={focus}
+ registerQuoteInsert={quote}
+ />
+ ));
+ expect(focus).toHaveBeenCalledWith(expect.any(Function));
+ expect(quote).toHaveBeenCalledWith(expect.any(Function));
+ unmount();
+ expect(focus).toHaveBeenLastCalledWith(undefined);
+ expect(quote).toHaveBeenLastCalledWith(undefined);
+ });
+
+ it('retains the agent selector on the new-chat input', () => {
+ render(() => (
+ <ChatComposer
+ draft=""
+ onDraftChange={vi.fn()}
+ onSend={vi.fn()}
+ selector={<button>Agent</button>}
+ />
+ ));
+ expect(screen.getByRole('button', { name: 'Agent' })).toBeTruthy();
+ expect(screen.queryByRole('button', { name: 'Model' })).toBeNull();
+ });
+ it('reveals the repository drawer without remounting the editor', () => {
+ const [mode, setMode] = createSignal('chat');
+ const { container } = render(() => (
+ <ChatComposer
+ draft="Shared draft"
+ onDraftChange={vi.fn()}
+ selector={<button>Agent</button>}
+ drawer={<button>Repository</button>}
+ drawerOpen={mode() === 'code'}
+ onSend={vi.fn()}
+ />
+ ));
+ const input = screen.getByTestId('editor');
+ const drawer = container.querySelector('.composer-drawer');
+ expect((drawer as HTMLElement).inert).toBe(true);
+ expect(drawer?.getAttribute('aria-hidden')).toBe('true');
+ setMode('code');
+ expect(screen.getByTestId('editor')).toBe(input);
+ expect((drawer as HTMLElement).inert).toBe(false);
+ expect(drawer?.hasAttribute('data-open')).toBe(true);
+ setMode('chat');
+ expect((drawer as HTMLElement).inert).toBe(true);
+ const settings = screen.getByRole('group', { name: 'Composer settings' });
+ expect(settings.textContent).toBe('Agent');
+ });
+ it('lets controls inside the composer receive pointer focus', () => {
+ render(() => (
+ <ChatComposer
+ draft=""
+ onDraftChange={vi.fn()}
+ onSend={vi.fn()}
+ selector={<input aria-label="Filter models" />}
+ />
+ ));
+ const event = new MouseEvent('pointerdown', {
+ bubbles: true,
+ cancelable: true,
+ });
+ screen.getByRole('textbox', { name: 'Filter models' }).dispatchEvent(event);
+ expect(event.defaultPrevented).toBe(false);
+ });
+});
diff --git a/apps/web/src/features/agents-view/components/ChatComposer.tsx b/apps/web/src/features/agents-view/components/ChatComposer.tsx
new file mode 100644
index 0000000000..fffb1ad587
--- /dev/null
+++ b/apps/web/src/features/agents-view/components/ChatComposer.tsx
@@ -0,0 +1,206 @@
+import type { AgentInputProps } from '@app/features/block-agent/ui';
+import { buildConfig } from '@core/component/LexicalMarkdown/builder/MarkdownConfigBuilder';
+import { MarkdownShell } from '@core/component/LexicalMarkdown/builder/MarkdownShell';
+import { isTouchDevice } from '@core/mobile/isTouchDevice';
+import { useTouchOutsideToDismissKeyboard } from '@core/mobile/useTouchOutsideToDismissKeyboard';
+import { $insertReferencedPaste } from '@macro-inc/lexical-core';
+import { Button, ComposerSurface, SendButton } from '@ui';
+import { createSignal, type JSX, onCleanup, onMount, Show } from 'solid-js';
+import { createChatComposerTip } from '../primitives/chat-composer-tip';
+
+/** Shared input that starts on one line and grows with the draft. */
+export function ChatComposer(props: {
+ draft: string;
+ onDraftChange: (draft: string) => void;
+ blockedReason?: string;
+ selector: JSX.Element;
+ onSend: (prompt: string) => void;
+ session?: AgentInputProps;
+ drawer?: JSX.Element;
+ drawerOpen?: boolean;
+ placeholder?: string;
+}) {
+ const tip = createChatComposerTip(
+ () => props.draft.trim().length === 0,
+ !props.session
+ );
+ let container: HTMLDivElement | undefined;
+ useTouchOutsideToDismissKeyboard(() => container);
+ const disabled = () => !!props.blockedReason || props.session?.disabled;
+ const canSendNext = () =>
+ !props.draft.trim() &&
+ props.session?.busy &&
+ props.session.hasQueuedMessages &&
+ props.session.onStop &&
+ !disabled();
+ const editor = buildConfig('chat')
+ .namespace('agents-chat-composer')
+ .withMentions({ showOpenTabs: true, block: 'agent' })
+ .withEmojis()
+ .withLinks({ floatingMenu: true, autoLinkMatchMode: 'common-tlds' })
+ .withHistory({ timeGap: 400 })
+ .withCode()
+ .withRestoreFocus()
+ .onEnter((_event, markdown) => {
+ if (markdown.trim()) send(markdown);
+ else if (canSendNext()) props.session?.onStop?.();
+ return true;
+ })
+ .onFocusLeave({
+ onStart: (event) => {
+ if (!props.session?.onNavigateUp) return;
+ event.preventDefault();
+ props.session.onNavigateUp();
+ },
+ onEnd: () => {},
+ })
+ .onChange(props.onDraftChange);
+
+ if (props.session) {
+ editor.withAgentCommands({
+ commands: () => props.session?.commands?.() ?? [],
+ });
+ } else {
+ editor.withSkills();
+ }
+
+ onMount(() => {
+ props.session?.registerFocus?.(() => editor.controls.focus());
+ props.session?.registerQuoteInsert?.((text) => {
+ editor.lexical.update(() => $insertReferencedPaste(text), {
+ discrete: true,
+ });
+ editor.controls.focus();
+ });
+ onCleanup(() => {
+ props.session?.registerFocus?.(undefined);
+ props.session?.registerQuoteInsert?.(undefined);
+ });
+ });
+
+ const send = (markdown = editor.controls.getMarkdown()) => {
+ const prompt = markdown.trim();
+ if (!prompt || disabled()) return;
+ editor.controls.clear();
+ props.onDraftChange('');
+ props.onSend(prompt);
+ };
+
+ const focusEditor = (event: Event) => {
+ const target = event.target as HTMLElement | null;
+ if (
+ !target ||
+ target.closest('[data-composer-controls], button, input, select, a')
+ )
+ return;
+ if (editor.lexical.getRootElement()?.contains(target)) return;
+ event.preventDefault();
+ if (event.type === 'pointerdown') editor.controls.focus();
+ };
+
+ return (
+ <div ref={container} data-keep-keyboard class="min-w-0">
+ <ComposerSurface
+ as="div"
+ data-agent-composer="chat"
+ class="flex min-w-0 items-end gap-2 rounded-[32px] px-4 py-3"
+ onPointerDown={focusEditor}
+ onMouseDown={focusEditor}
+ >
+ <div class="max-h-60 min-w-0 flex-1 self-center overflow-y-auto px-1">
+ <MarkdownShell
+ class="h-auto min-h-6 text-base leading-6 [&_[data-markdown-editable]]:min-h-6 [&_[data-markdown-editable]]:outline-none [&_[data-markdown-editable]>.md-p]:my-0 [&_[data-markdown-placeholder]]:max-w-full [&_[data-markdown-placeholder]>p]:m-0 [&_[data-markdown-placeholder]>p]:truncate"
+ config={editor}
+ initialValue={props.draft}
+ placeholder={props.placeholder ?? tip()}
+ refFn={(element) =>
+ element.setAttribute('aria-label', 'Message the agent')
+ }
+ autofocus={!isTouchDevice() && (props.session?.autofocus ?? true)}
+ />
+ </div>
+ <div
+ data-composer-controls
+ class="flex min-w-0 max-w-[55%] shrink-0 items-center"
+ role="group"
+ aria-label="Composer settings"
+ >
+ <div class="ml-auto flex min-w-0 max-w-full items-center gap-2 [&_.menu]:right-0 [&_.menu]:left-auto [&_.menu-anchor]:min-w-0 [&_.pill]:max-w-full">
+ {props.selector}
+ <Show
+ when={
+ props.session?.busy &&
+ props.session.onStop &&
+ !props.draft.trim()
+ }
+ fallback={
+ <SendButton
+ appearance="composer"
+ aria-label="Send"
+ title={props.blockedReason}
+ disabled={!props.draft.trim() || disabled()}
+ onClick={() => send()}
+ />
+ }
+ >
+ <Show
+ when={canSendNext()}
+ fallback={
+ <Button
+ variant="strong"
+ size="icon-composer"
+ label="Stop"
+ disabled={disabled()}
+ onClick={() => props.session?.onStop?.()}
+ >
+ <div class="size-3.5 rounded-sm bg-current" />
+ </Button>
+ }
+ >
+ <SendButton
+ appearance="composer"
+ aria-label="Send next queued message"
+ tooltip="Send next queued message"
+ shortcut="Enter"
+ onClick={() => props.session?.onStop?.()}
+ />
+ </Show>
+ </Show>
+ </div>
+ </div>
+ </ComposerSurface>
+ <Show when={props.drawer}>
+ <div
+ class="composer-drawer"
+ data-open={props.drawerOpen ? '' : undefined}
+ aria-hidden={!props.drawerOpen}
+ inert={!props.drawerOpen}
+ >
+ <div class="composer-drawer-inner">
+ <div
+ class="composer-drawer-content"
+ role="group"
+ aria-label="Repository settings"
+ >
+ {props.drawer}
+ </div>
+ </div>
+ </div>
+ </Show>
+ </div>
+ );
+}
+
+/** Adapt the session's controls to the same input used for a new Chat. */
+export function ChatSessionInput(props: AgentInputProps) {
+ const [draft, setDraft] = createSignal('');
+ return (
+ <ChatComposer
+ draft={draft()}
+ onDraftChange={setDraft}
+ selector={props.modelControl}
+ onSend={props.onSend}
+ session={props}
+ />
+ );
+}
diff --git a/apps/web/src/features/agents-view/components/Menu.tsx b/apps/web/src/features/agents-view/components/Menu.tsx
new file mode 100644
index 0000000000..23bda2ff91
--- /dev/null
+++ b/apps/web/src/features/agents-view/components/Menu.tsx
@@ -0,0 +1,105 @@
+import CheckIcon from '@phosphor/check.svg';
+import {
+ type Accessor,
+ createSignal,
+ type JSX,
+ onCleanup,
+ onMount,
+ Show,
+} from 'solid-js';
+
+export type MenuHandle = {
+ open: Accessor<boolean>;
+ toggle: () => void;
+ close: () => void;
+};
+
+/**
+ * The design's anchored menu: a trigger and, while open, a panel positioned
+ * off the anchor by the stylesheet (above by default, `below` for toolbars).
+ * A pointer outside the anchor or Escape closes it.
+ */
+export function MenuAnchor(props: {
+ id?: string;
+ class?: string;
+ style?: JSX.CSSProperties;
+ menuLabel: string;
+ menuClass?: string;
+ role?: 'listbox' | 'menu';
+ trigger: (menu: MenuHandle) => JSX.Element;
+ children: (close: () => void) => JSX.Element;
+}) {
+ const [open, setOpen] = createSignal(false);
+ let anchor: HTMLDivElement | undefined;
+ const close = () => setOpen(false);
+ const toggle = () => setOpen((current) => !current);
+
+ onMount(() => {
+ const onPointerDown = (event: PointerEvent) => {
+ if (!open()) return;
+ if (anchor?.contains(event.target as Node)) return;
+ close();
+ };
+ const onKeyDown = (event: KeyboardEvent) => {
+ if (event.key === 'Escape' && open()) close();
+ };
+ document.addEventListener('pointerdown', onPointerDown, true);
+ document.addEventListener('keydown', onKeyDown);
+ onCleanup(() => {
+ document.removeEventListener('pointerdown', onPointerDown, true);
+ document.removeEventListener('keydown', onKeyDown);
+ });
+ });
+
+ return (
+ <div
+ ref={anchor}
+ id={props.id}
+ class={props.class ? `menu-anchor ${props.class}` : 'menu-anchor'}
+ style={props.style}
+ >
+ {props.trigger({ open, toggle, close })}
+ <Show when={open()}>
+ <div
+ class={props.menuClass ? `menu ${props.menuClass}` : 'menu'}
+ role={props.role ?? 'listbox'}
+ aria-label={props.menuLabel}
+ >
+ {props.children(close)}
+ </div>
+ </Show>
+ </div>
+ );
+}
+
+/** One row of a menu; the check mark shows on the chosen one. */
+export function MenuOption(props: {
+ checked?: boolean;
+ disabled?: boolean;
+ class?: string;
+ style?: JSX.CSSProperties;
+ onSelect: () => void;
+ children: JSX.Element;
+}) {
+ return (
+ <button
+ type="button"
+ class={props.class ? `opt ${props.class}` : 'opt'}
+ role="option"
+ aria-checked={props.checked ?? false}
+ aria-disabled={props.disabled || undefined}
+ style={props.style}
+ onClick={() => {
+ if (!props.disabled) props.onSelect();
+ }}
+ >
+ {props.children}
+ <CheckIcon class="ph tick" />
+ </button>
+ );
+}
+
+/** A group heading inside a menu. */
+export function MenuGroup(props: { children: JSX.Element }) {
+ return <div class="grp">{props.children}</div>;
+}
diff --git a/apps/web/src/features/agents-view/components/ModelSelector.test.tsx b/apps/web/src/features/agents-view/components/ModelSelector.test.tsx
new file mode 100644
index 0000000000..58bac1ad90
--- /dev/null
+++ b/apps/web/src/features/agents-view/components/ModelSelector.test.tsx
@@ -0,0 +1,197 @@
+import {
+ cleanup,
+ fireEvent,
+ render,
+ screen,
+ waitFor,
+} from '@solidjs/testing-library';
+import { Dropdown } from '@ui';
+import { createSignal } from 'solid-js';
+import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
+import { ModelSelector, SessionModelSelector } from './ModelSelector';
+
+const options = [
+ { id: 'gpt-5', name: 'GPT-5', description: null, group: null },
+ { id: 'claude-sonnet-4', name: 'Sonnet 4', description: null, group: null },
+];
+
+describe('shared model selector', () => {
+ let motionStyles: HTMLStyleElement;
+ beforeEach(() => {
+ // jsdom omits the CSS motion defaults required by Kobalte's presence tracking.
+ motionStyles = document.createElement('style');
+ motionStyles.textContent =
+ '[role="menu"] { animation-name: none; transition-duration: 0s; }';
+ document.head.append(motionStyles);
+ vi.stubGlobal('scrollTo', vi.fn());
+ });
+ afterEach(() => {
+ cleanup();
+ motionStyles.remove();
+ vi.unstubAllGlobals();
+ });
+ it('uses the shared pill and menu while switching a session model', async () => {
+ const select = vi.fn();
+ const [changingTo, setChangingTo] = createSignal<string>();
+ render(() => (
+ <SessionModelSelector
+ model="gpt-5"
+ options={options}
+ onSelect={select}
+ changingTo={changingTo()}
+ />
+ ));
+ const trigger = screen.getByRole('button', { name: 'Model' });
+ expect(trigger.classList.contains('pill')).toBe(true);
+ fireEvent.keyDown(trigger, { key: 'Enter' });
+ fireEvent.keyDown(screen.getByRole('menuitem', { name: /Sonnet 4/ }), {
+ key: 'Enter',
+ });
+ expect(select).toHaveBeenCalledWith('claude-sonnet-4');
+ await waitFor(() => expect(screen.queryByRole('menu')).toBeNull());
+ setChangingTo('claude-sonnet-4');
+ expect(trigger.textContent).toContain('Sonnet 4');
+ expect(trigger.hasAttribute('disabled')).toBe(true);
+ expect(trigger.getAttribute('aria-busy')).toBe('true');
+ });
+
+ it('preserves the new-chat default option in the same menu', () => {
+ render(() => (
+ <ModelSelector
+ model="gpt-5"
+ label="default (GPT-5)"
+ options={options.map(({ id, name }) => ({ id, name }))}
+ onSelect={vi.fn()}
+ >
+ <Dropdown.Group>
+ <Dropdown.Item>Agent default</Dropdown.Item>
+ </Dropdown.Group>
+ </ModelSelector>
+ ));
+ fireEvent.keyDown(screen.getByRole('button', { name: 'Model' }), {
+ key: 'Enter',
+ });
+ expect(
+ screen.getByRole('menuitem', { name: 'Agent default' })
+ ).toBeTruthy();
+ expect(screen.getByRole('menuitem', { name: /GPT-5/ })).toBeTruthy();
+ });
+ it('uses pretty session names while retaining model ids for selection', async () => {
+ const select = vi.fn();
+ const [changingTo, setChangingTo] = createSignal<string>();
+ const ids = [
+ 'anthropic/claude-sonnet-5',
+ 'anthropic/claude-opus-5',
+ 'anthropic/claude-haiku-4-5',
+ ];
+ render(() => (
+ <SessionModelSelector
+ model={ids[0]}
+ options={ids.map((id) => ({
+ id,
+ name: id,
+ description: null,
+ group: null,
+ }))}
+ changingTo={changingTo()}
+ onSelect={select}
+ />
+ ));
+ const trigger = screen.getByRole('button', { name: 'Model' });
+ expect(trigger.textContent).toBe('Sonnet 5');
+ expect(trigger.title).toBe('Sonnet 5');
+ fireEvent.keyDown(trigger, { key: 'Enter' });
+ expect(screen.getByRole('menuitem', { name: /^Haiku 4.5/ })).toBeTruthy();
+ expect(screen.queryByText(ids[0])).toBeNull();
+ fireEvent.keyDown(screen.getByRole('menuitem', { name: /^Opus 5/ }), {
+ key: 'Enter',
+ });
+ expect(select).toHaveBeenCalledWith(ids[1]);
+ await waitFor(() => expect(screen.queryByRole('menu')).toBeNull());
+ setChangingTo(ids[1]);
+ expect(trigger.textContent).toBe('Opus 5');
+ });
+ it('keeps the new-session default selectable before models are available', async () => {
+ const selectDefault = vi.fn();
+ render(() => (
+ <ModelSelector
+ label="Agent default"
+ options={[]}
+ emptyMessage="Start a session to choose models."
+ onSelect={vi.fn()}
+ >
+ <Dropdown.Group>
+ <Dropdown.Item closeOnSelect onSelect={selectDefault}>
+ Agent default
+ </Dropdown.Item>
+ </Dropdown.Group>
+ </ModelSelector>
+ ));
+ fireEvent.keyDown(screen.getByRole('button', { name: 'Model' }), {
+ key: 'Enter',
+ });
+ expect(screen.getByRole('status').textContent).toBe(
+ 'Start a session to choose models.'
+ );
+ fireEvent.keyDown(screen.getByRole('menuitem', { name: 'Agent default' }), {
+ key: 'Enter',
+ });
+ expect(selectDefault).toHaveBeenCalledOnce();
+ await waitFor(() => expect(screen.queryByRole('menu')).toBeNull());
+ });
+
+ it('shortlists a large catalog and searches every model with provider icons', async () => {
+ const select = vi.fn();
+ render(() => (
+ <ModelSelector
+ model="gpt-5-0"
+ label="GPT-5 variant 0"
+ options={Array.from({ length: 60 }, (_, index) => ({
+ id: `gpt-5-${index}`,
+ name: `GPT-5 variant ${index}`,
+ group: 'GPT',
+ }))}
+ onSelect={select}
+ />
+ ));
+ fireEvent.keyDown(screen.getByRole('button', { name: 'Model' }), {
+ key: 'Enter',
+ });
+ expect(screen.getAllByRole('menuitem').length).toBeLessThanOrEqual(6);
+ expect(screen.getByRole('menuitem', { name: /More models/ })).toBeTruthy();
+ fireEvent.input(screen.getByRole('textbox', { name: 'Search models' }), {
+ target: { value: 'variant 59' },
+ });
+ const model = screen.getByRole('menuitem', { name: /GPT-5 variant 59/ });
+ expect(model.querySelector('[data-ai-provider="openai"] svg')).toBeTruthy();
+ expect(screen.getAllByRole('menuitem')).toHaveLength(1);
+ fireEvent.keyDown(model, { key: 'Enter' });
+ expect(select).toHaveBeenCalledWith('gpt-5-59');
+ await waitFor(() => expect(screen.queryByRole('menu')).toBeNull());
+ });
+
+ it('keeps the session selector visible while its catalog arrives', async () => {
+ const [catalog, setCatalog] = createSignal<typeof options>([]);
+ const select = vi.fn();
+ render(() => (
+ <SessionModelSelector
+ model="gpt-5"
+ options={catalog()}
+ onSelect={select}
+ />
+ ));
+ const trigger = screen.getByRole('button', { name: 'Model' });
+ expect(trigger.textContent).toContain('gpt-5');
+ fireEvent.keyDown(trigger, { key: 'Enter' });
+ expect(screen.getByRole('status').textContent).toContain(
+ 'Waiting for the agent'
+ );
+ setCatalog(options);
+ expect(screen.queryByRole('status')).toBeNull();
+ fireEvent.keyDown(screen.getByRole('menuitem', { name: /Sonnet 4/ }), {
+ key: 'Enter',
+ });
+ expect(select).toHaveBeenCalledWith('claude-sonnet-4');
+ await waitFor(() => expect(screen.queryByRole('menu')).toBeNull());
+ });
+});
diff --git a/apps/web/src/features/agents-view/components/ModelSelector.tsx b/apps/web/src/features/agents-view/components/ModelSelector.tsx
new file mode 100644
index 0000000000..5516b00e46
--- /dev/null
+++ b/apps/web/src/features/agents-view/components/ModelSelector.tsx
@@ -0,0 +1,73 @@
+import type { AgentModelSelectorProps } from '@app/features/block-agent/ui/AgentModelSelector';
+import { ModelCatalogPicker } from '@core/component/AI/component/input/ModelCatalogPicker';
+import type { JSX } from 'solid-js';
+import { modelLabel } from './model-label';
+
+export type ModelChoice = {
+ id: string;
+ name: string;
+ description?: string;
+ group?: string;
+};
+
+/** The settings catalog with a compact trigger for new and running sessions. */
+export function ModelSelector(props: {
+ model?: string;
+ label: JSX.Element;
+ options: ModelChoice[];
+ disabled?: boolean;
+ pending?: boolean;
+ onSelect: (id: string) => void;
+ children?: JSX.Element;
+ emptyMessage?: string;
+}) {
+ return (
+ <ModelCatalogPicker
+ value={props.model ?? null}
+ options={props.options.map((option) => ({
+ id: option.id,
+ label: modelLabel(option.id, option.name),
+ description: option.description,
+ group: option.group,
+ }))}
+ triggerLabel={props.label}
+ placeholder={modelLabel(props.model)}
+ triggerClass="pill min-w-0 max-w-full gap-2 border-0 text-ink-muted"
+ ariaLabel="Model"
+ placement="top-end"
+ disabled={props.disabled}
+ pending={props.pending}
+ onSelect={props.onSelect}
+ emptyMessage={
+ props.emptyMessage ?? 'Waiting for the agent to report its models.'
+ }
+ >
+ {props.children}
+ </ModelCatalogPicker>
+ );
+}
+
+/** Use the session's advertised catalog and existing model-change action. */
+export function SessionModelSelector(props: AgentModelSelectorProps) {
+ const shown = () => props.changingTo ?? props.model ?? undefined;
+ return (
+ <ModelSelector
+ model={shown()}
+ label={modelLabel(
+ shown(),
+ props.options.find((option) => option.id === shown())?.name
+ )}
+ options={props.options.map((option) => ({
+ id: option.id,
+ name: option.name,
+ group: option.group ?? undefined,
+ description: option.description ?? undefined,
+ }))}
+ disabled={props.disabled}
+ pending={props.changingTo !== undefined}
+ onSelect={(id) => {
+ if (id !== props.model) props.onSelect(id);
+ }}
+ />
+ );
+}
diff --git a/apps/web/src/features/agents-view/components/Segmented.tsx b/apps/web/src/features/agents-view/components/Segmented.tsx
new file mode 100644
index 0000000000..814986fee7
--- /dev/null
+++ b/apps/web/src/features/agents-view/components/Segmented.tsx
@@ -0,0 +1,52 @@
+import LockIcon from '@phosphor/lock-simple.svg';
+import TeamIcon from '@phosphor/users-three.svg';
+import { For, Show } from 'solid-js';
+
+type SegmentIcon = 'lock' | 'team';
+
+export type SegmentOption<T extends string> = {
+ value: T;
+ label: string;
+ icon?: SegmentIcon;
+ disabled?: boolean;
+};
+
+/** The design's compact segmented control (`.segc`): one pressed segment. */
+export function Segmented<T extends string>(props: {
+ name: string;
+ value: T;
+ options: SegmentOption<T>[];
+ onChange: (value: T) => void;
+ large?: boolean;
+}) {
+ return (
+ <span
+ class={props.large ? 'segc lg' : 'segc'}
+ data-seg={props.name}
+ role="radiogroup"
+ aria-label={props.name}
+ >
+ <For each={props.options}>
+ {(option) => (
+ <button
+ type="button"
+ role="radio"
+ aria-checked={props.value === option.value}
+ aria-pressed={props.value === option.value}
+ disabled={option.disabled}
+ title={option.disabled ? 'Create or join a team first' : undefined}
+ onClick={() => props.onChange(option.value)}
+ >
+ <Show when={option.icon === 'lock'}>
+ <LockIcon class="ph" />
+ </Show>
+ <Show when={option.icon === 'team'}>
+ <TeamIcon class="ph" />
+ </Show>
+ {option.label}
+ </button>
+ )}
+ </For>
+ </span>
+ );
+}
diff --git a/apps/web/src/features/agents-view/components/SimpleDialogs.tsx b/apps/web/src/features/agents-view/components/SimpleDialogs.tsx
new file mode 100644
index 0000000000..0c77a1483b
--- /dev/null
+++ b/apps/web/src/features/agents-view/components/SimpleDialogs.tsx
@@ -0,0 +1,132 @@
+import TrashIcon from '@phosphor/trash.svg';
+import XIcon from '@phosphor/x.svg';
+import { createSignal, type JSX, Show } from 'solid-js';
+import { ArtifactDialog } from './ArtifactDialog';
+
+/** Rename a conversation or agent in place. */
+export function RenameDialog(props: {
+ title?: string;
+ value: string;
+ pending?: boolean;
+ onRename: (value: string) => void;
+ onClose: () => void;
+}) {
+ const [value, setValue] = createSignal(props.value);
+ const submit = () => {
+ const next = value().trim();
+ if (!next || props.pending) return;
+ props.onRename(next);
+ };
+
+ return (
+ <ArtifactDialog
+ class="narrow"
+ label={props.title ?? 'Rename'}
+ onClose={props.onClose}
+ >
+ <div class="dh" style={{ height: '40px', padding: '0 8px 0 12px' }}>
+ <span class="t" style={{ 'font-weight': 600 }}>
+ {props.title ?? 'Rename'}
+ </span>
+ <button type="button" class="icon-btn" aria-label="Close" data-close>
+ <XIcon class="ph" />
+ </button>
+ </div>
+ <div class="db">
+ <input
+ class="sinput"
+ aria-label="Name"
+ value={value()}
+ onInput={(event) => setValue(event.currentTarget.value)}
+ onKeyDown={(event) => {
+ if (event.key === 'Enter') {
+ event.preventDefault();
+ submit();
+ }
+ }}
+ onFocus={(event) => event.currentTarget.select()}
+ />
+ </div>
+ <div class="df">
+ <button type="button" class="btn outline" data-close>
+ Cancel
+ </button>
+ <button
+ type="button"
+ class="btn"
+ style={{
+ background: 'var(--accent)',
+ color: 'var(--accent-contrast)',
+ }}
+ disabled={props.pending || value().trim().length === 0}
+ onClick={submit}
+ >
+ {props.pending ? 'Renaming…' : 'Rename'}
+ </button>
+ </div>
+ </ArtifactDialog>
+ );
+}
+
+/** A yes/no question before something irreversible. */
+export function ConfirmDialog(props: {
+ title: string;
+ body: JSX.Element;
+ confirmLabel: string;
+ pendingLabel?: string;
+ pending?: boolean;
+ danger?: boolean;
+ onConfirm: () => void;
+ onClose: () => void;
+}) {
+ return (
+ <ArtifactDialog class="narrow" label={props.title} onClose={props.onClose}>
+ <div class="dh" style={{ height: '40px', padding: '0 8px 0 12px' }}>
+ <span class="t" style={{ 'font-weight': 600 }}>
+ {props.title}
+ </span>
+ <button type="button" class="icon-btn" aria-label="Close" data-close>
+ <XIcon class="ph" />
+ </button>
+ </div>
+ <div class="db">
+ <p
+ style={{
+ margin: 0,
+ 'font-size': '13.5px',
+ 'line-height': 1.5,
+ color: 'var(--ink-muted)',
+ }}
+ >
+ {props.body}
+ </p>
+ </div>
+ <div class="df">
+ <button type="button" class="btn outline" data-close>
+ Cancel
+ </button>
+ <button
+ type="button"
+ class={props.danger ? 'btn danger' : 'btn'}
+ style={
+ props.danger
+ ? undefined
+ : {
+ background: 'var(--accent)',
+ color: 'var(--accent-contrast)',
+ }
+ }
+ disabled={props.pending}
+ onClick={props.onConfirm}
+ >
+ <Show when={props.danger}>
+ <TrashIcon class="ph" />
+ </Show>
+ {props.pending
+ ? (props.pendingLabel ?? 'Working…')
+ : props.confirmLabel}
+ </button>
+ </div>
+ </ArtifactDialog>
+ );
+}
diff --git a/apps/web/src/features/agents-view/components/Topbar.tsx b/apps/web/src/features/agents-view/components/Topbar.tsx
new file mode 100644
index 0000000000..a1d5b49a88
--- /dev/null
+++ b/apps/web/src/features/agents-view/components/Topbar.tsx
@@ -0,0 +1,164 @@
+import { ViewSidebarToggle } from '@app/components/view-shell/ViewShell';
+import CopyIcon from '@phosphor/copy.svg';
+import DotsIcon from '@phosphor/dots-three.svg';
+import PencilIcon from '@phosphor/pencil-simple.svg';
+import ShareIcon from '@phosphor/share.svg';
+import SidebarIcon from '@phosphor/sidebar.svg';
+import SparkleIcon from '@phosphor/sparkle.svg';
+import TrashIcon from '@phosphor/trash.svg';
+import SparkleFillIcon from '@phosphor-fill/sparkle-fill.svg';
+import { type JSX, Show } from 'solid-js';
+import { MenuAnchor } from './Menu';
+
+/** What the toolbar can do to the open session. */
+export type SessionActions = {
+ favorite: boolean;
+ onToggleFavorite: () => void;
+ onShare: () => void;
+ onSidePanel: () => void;
+ onRename: () => void;
+ onCopyLink: () => void;
+ onDelete: () => void;
+};
+
+/**
+ * The main pane's title row. Session-only controls stay in the markup and the
+ * stylesheet hides them until the root carries `data-session`.
+ */
+export function Topbar(props: {
+ title: string;
+ session?: SessionActions;
+ children?: JSX.Element;
+}) {
+ return (
+ <div class="topbar">
+ <ViewSidebarToggle action="expand" />
+ <h1 class="truncate">{props.title}</h1>
+ <div class="right">
+ {props.children}
+ <div class="bbar" role="toolbar" aria-label="Session actions">
+ <button
+ type="button"
+ class="icon-btn session-only"
+ aria-label={
+ props.session?.favorite ? 'Remove from favorites' : 'Favorite'
+ }
+ title="Favorite"
+ aria-pressed={props.session?.favorite}
+ disabled={!props.session}
+ onClick={() => props.session?.onToggleFavorite()}
+ >
+ <Show
+ when={props.session?.favorite}
+ fallback={<SparkleIcon class="ph" />}
+ >
+ <SparkleFillIcon class="ph" style={{ color: 'var(--accent)' }} />
+ </Show>
+ </button>
+ <button
+ type="button"
+ class="icon-btn"
+ aria-label="Share"
+ title="Share"
+ disabled={!props.session}
+ onClick={() => props.session?.onShare()}
+ >
+ <ShareIcon class="ph" />
+ </button>
+ <button
+ type="button"
+ class="icon-btn"
+ aria-label="Side panel"
+ title="Side panel (])"
+ disabled={!props.session}
+ onClick={() => props.session?.onSidePanel()}
+ >
+ <SidebarIcon class="ph" />
+ </button>
+ <span class="sep session-only" />
+ <MenuAnchor
+ class="session-only"
+ menuLabel="Session actions"
+ menuClass="below"
+ role="menu"
+ style={{ width: '220px' }}
+ trigger={(menu) => (
+ <button
+ type="button"
+ class="icon-btn"
+ aria-label="More"
+ aria-haspopup="menu"
+ aria-expanded={menu.open()}
+ onClick={(event) => {
+ event.stopPropagation();
+ menu.toggle();
+ }}
+ >
+ <DotsIcon class="ph" />
+ </button>
+ )}
+ >
+ {(close) => (
+ <>
+ <button
+ type="button"
+ class="opt"
+ role="menuitem"
+ onClick={() => {
+ close();
+ props.session?.onRename();
+ }}
+ >
+ <PencilIcon class="ph" />
+ <span class="nm">Rename</span>
+ </button>
+ <button
+ type="button"
+ class="opt"
+ role="menuitem"
+ onClick={() => {
+ close();
+ props.session?.onCopyLink();
+ }}
+ >
+ <CopyIcon class="ph" />
+ <span class="nm">Copy link</span>
+ </button>
+ <button
+ type="button"
+ class="opt"
+ role="menuitem"
+ onClick={() => {
+ close();
+ props.session?.onToggleFavorite();
+ }}
+ >
+ <SparkleIcon class="ph" />
+ <span class="nm">
+ {props.session?.favorite
+ ? 'Remove from favorites'
+ : 'Add to favorites'}
+ </span>
+ </button>
+ <div class="grp" style={{ padding: '4px 0 0' }} />
+ <button
+ type="button"
+ class="opt"
+ role="menuitem"
+ style={{ color: 'var(--red)' }}
+ onClick={() => {
+ close();
+ props.session?.onDelete();
+ }}
+ >
+ <TrashIcon class="ph" />
+ <span class="nm">Delete session</span>
+ </button>
+ </>
+ )}
+ </MenuAnchor>
+ </div>
+ </div>
+ </div>
+ );
+}
diff --git a/apps/web/src/features/agents-view/components/model-label.ts b/apps/web/src/features/agents-view/components/model-label.ts
new file mode 100644
index 0000000000..66962e69e3
--- /dev/null
+++ b/apps/web/src/features/agents-view/components/model-label.ts
@@ -0,0 +1,16 @@
+import {
+ MODEL_PRETTYNAME,
+ type Model,
+} from '@core/component/AI/constant/model';
+
+/** Readable model names shared by the composer and running sessions. */
+export function modelLabel(id: string | undefined, name?: string) {
+ if (!id) return 'Model';
+ return (
+ MODEL_PRETTYNAME[id as Model] ??
+ MODEL_PRETTYNAME[`anthropic/${id}` as Model] ??
+ (name ?? id)
+ .replace(/^(anthropic|openai|google)\//, '')
+ .replace(/^Claude /, '')
+ );
+}
diff --git a/apps/web/src/features/agents-view/context/data-mode.ts b/apps/web/src/features/agents-view/context/data-mode.ts
new file mode 100644
index 0000000000..270c22c092
--- /dev/null
+++ b/apps/web/src/features/agents-view/context/data-mode.ts
@@ -0,0 +1,22 @@
+import { type Accessor, createContext, useContext } from 'solid-js';
+import type { AgentsMode } from '../core/mode';
+
+/**
+ * The design's `data-mode` vocabulary: `macro` is Chat, `work` is Code. The
+ * stylesheet keys its per-mode rules on it, and dialogs rendered through a
+ * portal read it here so they can carry the same attribute.
+ */
+export type DataMode = 'macro' | 'work';
+
+export function dataModeFor(mode: AgentsMode): DataMode {
+ return mode === 'code' ? 'work' : 'macro';
+}
+
+const defaultMode: Accessor<DataMode> = () => 'macro';
+const DataModeContext = createContext(defaultMode);
+
+export const DataModeProvider = DataModeContext.Provider;
+
+export function useDataMode(): Accessor<DataMode> {
+ return useContext(DataModeContext);
+}
diff --git a/apps/web/src/features/agents-view/core/agent-kind.test.ts b/apps/web/src/features/agents-view/core/agent-kind.test.ts
new file mode 100644
index 0000000000..4096eac7fc
--- /dev/null
+++ b/apps/web/src/features/agents-view/core/agent-kind.test.ts
@@ -0,0 +1,57 @@
+import { CURSOR_BOT_ID } from '@core/constant/cursorAgent';
+import { MACRO_AGENT_BOT_ID } from '@core/constant/macroAgent';
+import { MACRO_CODER_BOT_ID } from '@core/constant/macroCoder';
+import { describe, expect, it } from 'vitest';
+import {
+ agentKindNoun,
+ isCoderHarness,
+ kindForHarness,
+ kindForMode,
+ modeForKind,
+ systemBotKind,
+} from './agent-kind';
+
+describe('isCoderHarness', () => {
+ it('treats the in-process harnesses as chat', () => {
+ expect(isCoderHarness('in-memory')).toBe(false);
+ expect(isCoderHarness('macro-inmem')).toBe(false);
+ expect(isCoderHarness(undefined)).toBe(false);
+ expect(isCoderHarness('')).toBe(false);
+ });
+
+ it('treats every coding runtime as a coder', () => {
+ expect(isCoderHarness('cursor')).toBe(true);
+ expect(isCoderHarness('macrod')).toBe(true);
+ expect(isCoderHarness('sandbox')).toBe(true);
+ expect(kindForHarness('cursor')).toBe('coder');
+ expect(kindForHarness('in-memory')).toBe('agent');
+ });
+});
+
+describe('systemBotKind', () => {
+ it('knows the first-party bots in either id form', () => {
+ expect(systemBotKind(MACRO_AGENT_BOT_ID)).toBe('agent');
+ expect(systemBotKind(MACRO_CODER_BOT_ID)).toBe('coder');
+ expect(systemBotKind(`bot|${CURSOR_BOT_ID}`)).toBe('coder');
+ });
+
+ it('has no opinion about other bots', () => {
+ expect(
+ systemBotKind('11111111-1111-1111-1111-111111111111')
+ ).toBeUndefined();
+ expect(systemBotKind(undefined)).toBeUndefined();
+ });
+});
+
+describe('modes and kinds', () => {
+ it('round-trips', () => {
+ expect(modeForKind(kindForMode('code'))).toBe('code');
+ expect(modeForKind(kindForMode('chat'))).toBe('chat');
+ });
+
+ it('names the kind', () => {
+ expect(agentKindNoun('coder')).toBe('coding agent');
+ expect(agentKindNoun('coder', true)).toBe('coding agents');
+ expect(agentKindNoun('agent', true)).toBe('agents');
+ });
+});
diff --git a/apps/web/src/features/agents-view/core/agent-kind.ts b/apps/web/src/features/agents-view/core/agent-kind.ts
new file mode 100644
index 0000000000..4d52271400
--- /dev/null
+++ b/apps/web/src/features/agents-view/core/agent-kind.ts
@@ -0,0 +1,60 @@
+import { CURSOR_BOT_ID } from '@core/constant/cursorAgent';
+import { MACRO_AGENT_BOT_ID } from '@core/constant/macroAgent';
+import { MACRO_CODER_BOT_ID } from '@core/constant/macroCoder';
+import { MACRO_NEW_BOT_ID } from '@core/constant/macroNew';
+import type { AgentsMode } from './mode';
+
+/**
+ * What an agent is for. A coder writes code: it takes a repository and runs on
+ * a coding runtime (Cursor's cloud agents, or a macrod daemon on someone's
+ * machine). Every other agent chats from Macro's own in-memory harness.
+ *
+ * The kind is not stored on the agent — the harness decides it, because only a
+ * coding runtime can actually do coding work.
+ */
+export type AgentKind = 'agent' | 'coder';
+
+/** Harness slugs that run inside Macro's process, with no coding runtime. */
+const CHAT_HARNESSES: ReadonlySet<string> = new Set([
+ 'in-memory',
+ 'macro-inmem',
+]);
+
+export function isCoderHarness(harness: string | null | undefined): boolean {
+ if (!harness) return false;
+ return !CHAT_HARNESSES.has(harness);
+}
+
+export function kindForHarness(harness: string | null | undefined): AgentKind {
+ return isCoderHarness(harness) ? 'coder' : 'agent';
+}
+
+/** The first-party bots, whose kind is fixed by what mentioning them does. */
+const SYSTEM_BOT_KINDS: ReadonlyMap<string, AgentKind> = new Map([
+ [MACRO_AGENT_BOT_ID, 'agent'],
+ [MACRO_NEW_BOT_ID, 'agent'],
+ [MACRO_CODER_BOT_ID, 'coder'],
+ [CURSOR_BOT_ID, 'coder'],
+]);
+
+export function systemBotKind(
+ botId: string | null | undefined
+): AgentKind | undefined {
+ if (!botId) return undefined;
+ const bare = botId.startsWith('bot|') ? botId.slice('bot|'.length) : botId;
+ return SYSTEM_BOT_KINDS.get(bare);
+}
+
+export function modeForKind(kind: AgentKind): AgentsMode {
+ return kind === 'coder' ? 'code' : 'chat';
+}
+
+export function kindForMode(mode: AgentsMode): AgentKind {
+ return mode === 'code' ? 'coder' : 'agent';
+}
+
+/** Display nouns for headings and buttons. */
+export function agentKindNoun(kind: AgentKind, plural = false): string {
+ const noun = kind === 'coder' ? 'coding agent' : 'agent';
+ return plural ? `${noun}s` : noun;
+}
diff --git a/apps/web/src/features/agents-view/core/conversation-state.test.ts b/apps/web/src/features/agents-view/core/conversation-state.test.ts
new file mode 100644
index 0000000000..080933a3a8
--- /dev/null
+++ b/apps/web/src/features/agents-view/core/conversation-state.test.ts
@@ -0,0 +1,31 @@
+import { describe, expect, it } from 'vitest';
+import {
+ conversationState,
+ conversationStateLabel,
+} from './conversation-state';
+
+describe('conversationState', () => {
+ it('reads a session with no events yet as starting', () => {
+ expect(conversationState(undefined)).toBe('starting');
+ expect(conversationState('no_messages')).toBe('starting');
+ expect(conversationState('booting')).toBe('starting');
+ });
+
+ it('reads a reachable runtime as live, whatever it last said', () => {
+ expect(conversationState('acp_ready')).toBe('live');
+ expect(conversationState('ready')).toBe('live');
+ expect(conversationState('reload_required')).toBe('live');
+ expect(conversationState('worktree_ready')).toBe('live');
+ });
+
+ it('reads a dropped transport as ended', () => {
+ expect(conversationState('disconnected')).toBe('ended');
+ expect(conversationState('session/end')).toBe('ended');
+ });
+
+ it('labels each state', () => {
+ expect(conversationStateLabel('starting')).toBe('Starting');
+ expect(conversationStateLabel('live')).toBe('Ready');
+ expect(conversationStateLabel('ended')).toBe('Ended');
+ });
+});
diff --git a/apps/web/src/features/agents-view/core/conversation-state.ts b/apps/web/src/features/agents-view/core/conversation-state.ts
new file mode 100644
index 0000000000..b75a72bb0d
--- /dev/null
+++ b/apps/web/src/features/agents-view/core/conversation-state.ts
@@ -0,0 +1,36 @@
+/**
+ * What a session's last known runtime status means for a list row.
+ *
+ * Soup carries the wire name of the latest system event (`no_messages`
+ * before the first, `disconnected` when the transport dropped). That is
+ * coarse — it says whether a runtime is up, not whether a turn is running —
+ * so the list only distinguishes a session that is coming up, one whose
+ * runtime is alive, and one whose runtime has gone.
+ */
+export type ConversationState = 'starting' | 'live' | 'ended';
+
+const STARTING: ReadonlySet<string> = new Set(['no_messages', 'booting']);
+const ENDED: ReadonlySet<string> = new Set([
+ 'disconnected',
+ 'session/end',
+ 'closed',
+]);
+
+export function conversationState(
+ status: string | null | undefined
+): ConversationState {
+ if (!status || STARTING.has(status)) return 'starting';
+ if (ENDED.has(status)) return 'ended';
+ return 'live';
+}
+
+export function conversationStateLabel(state: ConversationState): string {
+ switch (state) {
+ case 'starting':
+ return 'Starting';
+ case 'live':
+ return 'Ready';
+ case 'ended':
+ return 'Ended';
+ }
+}
diff --git a/apps/web/src/features/agents-view/core/format-age.test.ts b/apps/web/src/features/agents-view/core/format-age.test.ts
new file mode 100644
index 0000000000..124c1b0cbc
--- /dev/null
+++ b/apps/web/src/features/agents-view/core/format-age.test.ts
@@ -0,0 +1,35 @@
+import { describe, expect, it } from 'vitest';
+import { compactAge, relativeAge } from './format-age';
+
+const NOW = Date.parse('2026-09-15T12:00:00Z');
+const ago = (ms: number) => NOW - ms;
+const MINUTE = 60_000;
+const HOUR = 60 * MINUTE;
+const DAY = 24 * HOUR;
+
+describe('compactAge', () => {
+ it('is empty for an unknown time', () => {
+ expect(compactAge(0, NOW)).toBe('');
+ });
+
+ it('steps through seconds, minutes, hours, and days', () => {
+ expect(compactAge(ago(20_000), NOW)).toBe('now');
+ expect(compactAge(ago(4 * MINUTE), NOW)).toBe('4m');
+ expect(compactAge(ago(3 * HOUR), NOW)).toBe('3h');
+ expect(compactAge(ago(2 * DAY), NOW)).toBe('2d');
+ });
+
+ it('falls back to a short date after a week', () => {
+ expect(compactAge(ago(10 * DAY), NOW)).toBe('Sep 5');
+ });
+});
+
+describe('relativeAge', () => {
+ it('spells the age out', () => {
+ expect(relativeAge(ago(5_000), NOW)).toBe('just now');
+ expect(relativeAge(ago(25 * MINUTE), NOW)).toBe('25 min ago');
+ expect(relativeAge(ago(2 * HOUR), NOW)).toBe('2 h ago');
+ expect(relativeAge(ago(12 * DAY), NOW)).toBe('12 d ago');
+ expect(relativeAge(ago(45 * DAY), NOW)).toBe('Aug 1');
+ });
+});
diff --git a/apps/web/src/features/agents-view/core/format-age.ts b/apps/web/src/features/agents-view/core/format-age.ts
new file mode 100644
index 0000000000..4a33a222bd
--- /dev/null
+++ b/apps/web/src/features/agents-view/core/format-age.ts
@@ -0,0 +1,36 @@
+/**
+ * How long ago something moved, at the width a list row can spare: `now`,
+ * `4m`, `3h`, `2d`, then a short date. Empty when the time is unknown.
+ */
+export function compactAge(timestamp: number, now = Date.now()): string {
+ if (!timestamp) return '';
+ const seconds = Math.max(0, Math.round((now - timestamp) / 1000));
+ if (seconds < 60) return 'now';
+ const minutes = Math.round(seconds / 60);
+ if (minutes < 60) return `${minutes}m`;
+ const hours = Math.round(minutes / 60);
+ if (hours < 24) return `${hours}h`;
+ const days = Math.round(hours / 24);
+ if (days < 7) return `${days}d`;
+ return new Date(timestamp).toLocaleDateString('en-US', {
+ month: 'short',
+ day: 'numeric',
+ });
+}
+
+/** The sentence form for card footers: `just now`, `4 min ago`, `3 h ago`, `2 d ago`. */
+export function relativeAge(timestamp: number, now = Date.now()): string {
+ if (!timestamp) return '';
+ const seconds = Math.max(0, Math.round((now - timestamp) / 1000));
+ if (seconds < 60) return 'just now';
+ const minutes = Math.round(seconds / 60);
+ if (minutes < 60) return `${minutes} min ago`;
+ const hours = Math.round(minutes / 60);
+ if (hours < 24) return `${hours} h ago`;
+ const days = Math.round(hours / 24);
+ if (days < 30) return `${days} d ago`;
+ return new Date(timestamp).toLocaleDateString('en-US', {
+ month: 'short',
+ day: 'numeric',
+ });
+}
diff --git a/apps/web/src/features/agents-view/core/links.ts b/apps/web/src/features/agents-view/core/links.ts
new file mode 100644
index 0000000000..6b010207e0
--- /dev/null
+++ b/apps/web/src/features/agents-view/core/links.ts
@@ -0,0 +1,11 @@
+/** Where the bring-your-own-agent (macrod) setup is documented. */
+export const BYOA_DOCS_URL = 'https://docs.macro.com/AI/bring-your-own';
+
+/** The coding agents macrod can bring to Macro, as the roster page names them. */
+export const BYOA_AGENTS = [
+ 'Claude Code',
+ 'Codex',
+ 'OpenCode',
+ 'Hermes',
+ 'OpenClaw',
+];
diff --git a/apps/web/src/features/agents-view/core/mode.ts b/apps/web/src/features/agents-view/core/mode.ts
new file mode 100644
index 0000000000..81d2ecb79c
--- /dev/null
+++ b/apps/web/src/features/agents-view/core/mode.ts
@@ -0,0 +1,2 @@
+/** Session kind used for routes and the agent workspace's presentation. */
+export type AgentsMode = 'chat' | 'code';
diff --git a/apps/web/src/features/agents-view/core/pages.ts b/apps/web/src/features/agents-view/core/pages.ts
index 4b705dfa30..8ff3ca2f7c 100644
--- a/apps/web/src/features/agents-view/core/pages.ts
+++ b/apps/web/src/features/agents-view/core/pages.ts
@@ -1,6 +1,6 @@
-export type AgentsPage =
- | 'new'
- | 'routines'
- | 'agents'
- | 'connections'
- | 'skills';
+/**
+ * The pages the Agents workspace can show in place of a conversation. Agents
+ * is the settings-style roster (agents, coders, runtimes); everything else the
+ * old page list offered lives in Settings or behind the composer's `/` menu.
+ */
+export type AgentsPage = 'new' | 'agents';
diff --git a/apps/web/src/features/agents-view/core/recent-conversations.test.ts b/apps/web/src/features/agents-view/core/recent-conversations.test.ts
new file mode 100644
index 0000000000..f7983e74a9
--- /dev/null
+++ b/apps/web/src/features/agents-view/core/recent-conversations.test.ts
@@ -0,0 +1,124 @@
+import type { AgentSessionEntity, ChatEntity } from '@entity';
+import { describe, expect, it } from 'vitest';
+import type { AgentKind } from './agent-kind';
+import {
+ type AgentConversationEntity,
+ botUsage,
+ conversationMode,
+ groupConversations,
+ selectRecentAgentConversations,
+} from './recent-conversations';
+
+const OWNER = 'macro|[email protected]';
+
+function session(
+ id: string,
+ overrides: Partial<AgentSessionEntity> = {}
+): AgentSessionEntity {
+ return {
+ type: 'agent_session',
+ id,
+ name: `Session ${id}`,
+ ownerId: OWNER,
+ botId: 'bot-chat',
+ status: 'acp_ready',
+ updatedAt: '2026-09-15T10:00:00Z',
+ ...overrides,
+ };
+}
+
+function chat(id: string, overrides: Partial<ChatEntity> = {}): ChatEntity {
+ return {
+ type: 'chat',
+ id,
+ name: `Chat ${id}`,
+ ownerId: OWNER,
+ updatedAt: '2026-09-15T09:00:00Z',
+ ...overrides,
+ };
+}
+
+const KINDS: Record<string, AgentKind> = {
+ 'bot-chat': 'agent',
+ 'bot-coder': 'coder',
+};
+const kindOf = (botId: string | undefined) =>
+ (botId && KINDS[botId]) || 'agent';
+
+describe('selectRecentAgentConversations', () => {
+ it('keeps only the owner’s conversations, newest first, matching the search', () => {
+ const mine = session('a', { updatedAt: '2026-09-15T08:00:00Z' });
+ const newer = chat('b', { updatedAt: '2026-09-15T11:00:00Z' });
+ const theirs = session('c', { ownerId: 'macro|[email protected]' });
+
+ expect(
+ selectRecentAgentConversations([mine, theirs, newer], OWNER, '')
+ ).toEqual([newer, mine]);
+ expect(
+ selectRecentAgentConversations([mine, newer], OWNER, 'chat b')
+ ).toEqual([newer]);
+ expect(selectRecentAgentConversations([mine], undefined, '')).toEqual([]);
+ });
+});
+
+describe('mixed conversation navigation', () => {
+ it('resolves each conversation mode independently of the new composer', () => {
+ expect(
+ conversationMode(session('code', { botId: 'bot-coder' }), kindOf)
+ ).toBe('code');
+ expect(conversationMode(session('agent'), kindOf)).toBe('chat');
+ expect(conversationMode(chat('plain'), kindOf)).toBe('chat');
+ expect(
+ conversationMode(session('unknown', { botId: 'unknown' }), kindOf)
+ ).toBe('chat');
+ });
+
+ it('prefers the bot on the row over the stored bot id', () => {
+ expect(
+ conversationMode(
+ session('x', {
+ botId: 'bot-chat',
+ bot: { id: 'bot-coder', name: 'Code agent' },
+ }),
+ kindOf
+ )
+ ).toBe('code');
+ });
+
+ it('keeps chat and coding sessions together in their original date order', () => {
+ const rows: AgentConversationEntity[] = [
+ session('code', { botId: 'bot-coder' }),
+ chat('chat'),
+ session('ended', { botId: 'bot-coder', status: 'disconnected' }),
+ session('agent'),
+ ];
+ expect(groupConversations(rows)).toEqual([
+ { id: 'recent', label: undefined, conversations: rows },
+ ]);
+ expect(groupConversations([])).toEqual([]);
+ });
+});
+
+describe('botUsage', () => {
+ it('counts sessions per bot and keeps the newest timestamp', () => {
+ const usage = botUsage([
+ session('a', { botId: 'bot-coder', updatedAt: '2026-09-15T10:00:00Z' }),
+ session('b', { botId: 'bot-coder', updatedAt: '2026-09-14T10:00:00Z' }),
+ session('c', {
+ botId: 'bot-chat',
+ updatedAt: null,
+ createdAt: '2026-09-01T00:00:00Z',
+ }),
+ chat('d'),
+ ]);
+ expect(usage.get('bot-coder')).toEqual({
+ sessions: 2,
+ lastUsedAt: Date.parse('2026-09-15T10:00:00Z'),
+ });
+ expect(usage.get('bot-chat')).toEqual({
+ sessions: 1,
+ lastUsedAt: Date.parse('2026-09-01T00:00:00Z'),
+ });
+ expect(usage.has('d')).toBe(false);
+ });
+});
diff --git a/apps/web/src/features/agents-view/core/recent-conversations.ts b/apps/web/src/features/agents-view/core/recent-conversations.ts
index 8daa3f27b0..ae57be41a1 100644
--- a/apps/web/src/features/agents-view/core/recent-conversations.ts
+++ b/apps/web/src/features/agents-view/core/recent-conversations.ts
@@ -1,6 +1,16 @@
import type { AgentSessionEntity, ChatEntity, EntityData } from '@entity';
+import { type AgentKind, modeForKind } from './agent-kind';
+import type { AgentsMode } from './mode';
export type AgentConversationEntity = AgentSessionEntity | ChatEntity;
+
+/** The persona a conversation runs, when the entity says. Chats have none. */
+export function conversationBotId(
+ conversation: AgentConversationEntity
+): string | undefined {
+ if (conversation.type !== 'agent_session') return undefined;
+ return conversation.bot?.id ?? conversation.botId;
+}
export type AgentConversationTarget = Pick<
AgentConversationEntity,
'id' | 'type'
@@ -12,7 +22,10 @@ function isAgentConversation(
return entity.type === 'agent_session' || entity.type === 'chat';
}
-function timestamp(entity: AgentConversationEntity): number {
+/** When a conversation last moved, as epoch millis; 0 when unknown. */
+export function conversationTimestamp(
+ entity: Pick<AgentConversationEntity, 'updatedAt' | 'createdAt'>
+): number {
const value = entity.updatedAt ?? entity.createdAt;
if (!value) return 0;
@@ -38,5 +51,66 @@ export function selectRecentAgentConversations(
!query ||
(entity.name || 'Untitled chat').toLocaleLowerCase().includes(query)
)
- .toSorted((left, right) => timestamp(right) - timestamp(left));
+ .toSorted(
+ (left, right) =>
+ conversationTimestamp(right) - conversationTimestamp(left)
+ );
+}
+
+/** Names the bot behind a session. Plain chats are always Macro's. */
+export type ConversationKindResolver = (botId: string | undefined) => AgentKind;
+
+/** Resolve navigation from the conversation itself, independent of composer mode. */
+export function conversationMode(
+ conversation: AgentConversationEntity,
+ kindOf: ConversationKindResolver
+): AgentsMode {
+ return conversation.type === 'chat'
+ ? 'chat'
+ : modeForKind(kindOf(conversationBotId(conversation)));
+}
+
+type ConversationGroupId = 'recent';
+
+export type ConversationGroup = {
+ id: ConversationGroupId;
+ /** Absent for a lone group that needs no heading. */
+ label: string | undefined;
+ conversations: AgentConversationEntity[];
+};
+
+/** One mixed list, retaining the query's newest-first order. */
+export function groupConversations(
+ conversations: readonly AgentConversationEntity[]
+): ConversationGroup[] {
+ return conversations.length
+ ? [{ id: 'recent', label: undefined, conversations: [...conversations] }]
+ : [];
+}
+
+export type BotUsage = {
+ /** Sessions in the loaded list that ran as this bot. */
+ sessions: number;
+ /** When the newest of them last moved, as epoch millis. */
+ lastUsedAt: number;
+};
+
+/** Per-bot usage from the loaded sessions, for the coder cards' footers. */
+export function botUsage(
+ conversations: readonly AgentConversationEntity[]
+): Map<string, BotUsage> {
+ const usage = new Map<string, BotUsage>();
+ for (const conversation of conversations) {
+ const botId = conversationBotId(conversation);
+ if (!botId) continue;
+ const current = usage.get(botId) ?? { sessions: 0, lastUsedAt: 0 };
+ usage.set(botId, {
+ sessions: current.sessions + 1,
+ lastUsedAt: Math.max(
+ current.lastUsedAt,
+ conversationTimestamp(conversation)
+ ),
+ });
+ }
+ return usage;
}
diff --git a/apps/web/src/features/agents-view/core/repository.test.ts b/apps/web/src/features/agents-view/core/repository.test.ts
new file mode 100644
index 0000000000..108ac621fe
--- /dev/null
+++ b/apps/web/src/features/agents-view/core/repository.test.ts
@@ -0,0 +1,53 @@
+import { describe, expect, it } from 'vitest';
+import {
+ parseRepositoryInput,
+ repositoryLabel,
+ repositoryShortName,
+} from './repository';
+
+describe('parseRepositoryInput', () => {
+ it('canonicalizes every way of naming a GitHub repository', () => {
+ const expected = 'https://github.com/macro-inc/macro';
+ expect(parseRepositoryInput('macro-inc/macro')).toBe(expected);
+ expect(parseRepositoryInput(' github.com/macro-inc/macro ')).toBe(expected);
+ expect(parseRepositoryInput('https://github.com/macro-inc/macro.git')).toBe(
+ expected
+ );
+ expect(parseRepositoryInput('https://github.com/macro-inc/macro/')).toBe(
+ expected
+ );
+ expect(
+ parseRepositoryInput('https://github.com/macro-inc/macro/pull/12')
+ ).toBe(expected);
+ expect(parseRepositoryInput('[email protected]:macro-inc/macro.git')).toBe(
+ expected
+ );
+ });
+
+ it('keeps other hosts as typed, minus the .git suffix', () => {
+ expect(parseRepositoryInput('https://gitlab.com/group/project.git')).toBe(
+ 'https://gitlab.com/group/project'
+ );
+ });
+
+ it('rejects text that is not a repository', () => {
+ expect(parseRepositoryInput('')).toBeUndefined();
+ expect(parseRepositoryInput('macro')).toBeUndefined();
+ expect(parseRepositoryInput('https://example.com')).toBeUndefined();
+ expect(parseRepositoryInput('not a repo')).toBeUndefined();
+ });
+});
+
+describe('repository names', () => {
+ it('shows owner/repo and the bare name', () => {
+ expect(repositoryLabel('https://github.com/macro-inc/macro')).toBe(
+ 'macro-inc/macro'
+ );
+ expect(repositoryShortName('https://github.com/macro-inc/macro')).toBe(
+ 'macro'
+ );
+ expect(repositoryLabel('https://gitlab.com/group/project.git')).toBe(
+ 'group/project'
+ );
+ });
+});
diff --git a/apps/web/src/features/agents-view/core/repository.ts b/apps/web/src/features/agents-view/core/repository.ts
new file mode 100644
index 0000000000..09c809da2b
--- /dev/null
+++ b/apps/web/src/features/agents-view/core/repository.ts
@@ -0,0 +1,51 @@
+/**
+ * Repositories a coder can be pointed at. Kept as canonical https URLs so the
+ * same repository typed three ways dedupes to one recent entry.
+ */
+
+const GITHUB_URL =
+ /^(?:https?:\/\/)?(?:www\.)?github\.com\/([\w.-]+)\/([\w.-]+?)(?:\.git)?(?:\/\S*|[#?]\S*)?$/i;
+const GITHUB_SSH = /^git@github\.com:([\w.-]+)\/([\w.-]+?)(?:\.git)?$/i;
+const SHORTHAND = /^([\w.-]+)\/([\w.-]+)$/;
+const ANY_HTTPS = /^https?:\/\/[^/\s]+\/\S+\/\S+$/i;
+
+/**
+ * Accepts `owner/repo`, `github.com/owner/repo`, a GitHub https or ssh URL, or
+ * a full https URL on another host. Returns the canonical URL, or undefined
+ * when the text does not name a repository.
+ */
+export function parseRepositoryInput(input: string): string | undefined {
+ const text = input.trim();
+ if (!text) return undefined;
+
+ const github = text.match(GITHUB_URL) ?? text.match(GITHUB_SSH);
+ if (github) return `https://github.com/${github[1]}/${github[2]}`;
+
+ const shorthand = text.match(SHORTHAND);
+ if (shorthand) {
+ return `https://github.com/${shorthand[1]}/${shorthand[2]}`;
+ }
+
+ if (ANY_HTTPS.test(text)) {
+ return text.replace(/\.git$/i, '').replace(/\/+$/, '');
+ }
+ return undefined;
+}
+
+/** `https://github.com/macro-inc/macro` → `macro-inc/macro`. */
+export function repositoryLabel(url: string): string {
+ const path = url
+ .replace(/\.git$/i, '')
+ .split('/')
+ .filter(Boolean);
+ const repo = path.at(-1);
+ const owner = path.at(-2);
+ return owner && repo && !owner.includes(':')
+ ? `${owner}/${repo}`
+ : (repo ?? url);
+}
+
+/** `https://github.com/macro-inc/macro` → `macro`; used where the owner is noise. */
+export function repositoryShortName(url: string): string {
+ return repositoryLabel(url).split('/').at(-1) ?? url;
+}
diff --git a/apps/web/src/features/agents-view/core/roster.test.ts b/apps/web/src/features/agents-view/core/roster.test.ts
new file mode 100644
index 0000000000..5a82528bed
--- /dev/null
+++ b/apps/web/src/features/agents-view/core/roster.test.ts
@@ -0,0 +1,141 @@
+import { CURSOR_BOT_ID } from '@core/constant/cursorAgent';
+import { MACRO_CODER_BOT_ID } from '@core/constant/macroCoder';
+import { describe, expect, it } from 'vitest';
+import {
+ buildAgentRoster,
+ kindForBot,
+ MACRO_PERSONA_ID,
+ type PersistedAgentLike,
+ type RosterInput,
+ rosterForComposer,
+} from './roster';
+
+function persisted(
+ overrides: Partial<PersistedAgentLike> & { harness: string }
+): PersistedAgentLike {
+ return {
+ bot: {
+ id: `bot-${overrides.harness}`,
+ name: 'Agent',
+ handle: 'agent',
+ owner: { type: 'user', user_id: 'macro|[email protected]' },
+ },
+ default_model: 'claude-sonnet-5',
+ ...overrides,
+ };
+}
+
+const EMPTY: RosterInput = {
+ agents: [],
+ runtimes: [],
+ cursorConnected: false,
+ cursorNeedsConnection: true,
+};
+
+describe('buildAgentRoster', () => {
+ it('leads with the first-party agents and coders', () => {
+ const roster = buildAgentRoster(EMPTY);
+ expect(roster.map((agent) => [agent.id, agent.kind])).toEqual([
+ [MACRO_PERSONA_ID, 'agent'],
+ [CURSOR_BOT_ID, 'coder'],
+ ]);
+ expect(roster[0]?.botId).toBeUndefined();
+ expect(roster.every((agent) => agent.share === 'system')).toBe(true);
+ });
+
+ it('offers to connect Cursor until it is connected', () => {
+ const cursor = buildAgentRoster(EMPTY).find((a) => a.id === CURSOR_BOT_ID);
+ expect(cursor?.unavailableReason).toBe('Connect Cursor to start it');
+ expect(cursor?.connectLabel).toBe('Connect Cursor');
+ expect(cursor?.runtime.connected).toBe(false);
+
+ const connected = buildAgentRoster({
+ ...EMPTY,
+ cursorConnected: true,
+ cursorNeedsConnection: false,
+ cursorDefaultModel: 'gpt-5',
+ }).find((a) => a.id === CURSOR_BOT_ID);
+ expect(connected?.unavailableReason).toBeUndefined();
+ expect(connected?.connectLabel).toBeUndefined();
+ expect(connected?.defaultModel).toBe('gpt-5');
+ });
+
+ it('classifies saved agents by harness and reads their runtime', () => {
+ const roster = buildAgentRoster({
+ ...EMPTY,
+ cursorConnected: true,
+ runtimes: [{ id: 'h1', name: 'wolf-laptop', connected: false }],
+ agents: [
+ persisted({ harness: 'in-memory' }),
+ persisted({
+ harness: 'cursor',
+ bot: {
+ id: 'bot-cursor',
+ name: 'Reviewer',
+ handle: 'reviewer',
+ owner: { type: 'team', team_id: 't1' },
+ },
+ }),
+ persisted({ harness: 'macrod', harness_id: 'h1' }),
+ persisted({ harness: 'macrod', harness_id: 'gone' }),
+ ],
+ });
+ const saved = roster.slice(2);
+ expect(saved.map((agent) => agent.kind)).toEqual([
+ 'agent',
+ 'coder',
+ 'coder',
+ 'coder',
+ ]);
+ expect(saved[0]?.runtime).toEqual({ label: 'Macro', connected: true });
+ expect(saved[0]?.unavailableReason).toBeUndefined();
+ expect(saved[1]?.share).toBe('team');
+ expect(saved[1]?.runtime).toEqual({ label: 'Cursor', connected: true });
+ expect(saved[2]?.runtime).toEqual({
+ label: 'wolf-laptop',
+ connected: false,
+ });
+ expect(saved[2]?.unavailableReason).toBe('Its runtime is disconnected');
+ expect(saved[3]?.runtime.label).toBe('Disconnected runtime');
+ });
+
+ it('cannot start a saved agent on a connected macrod runtime from here', () => {
+ const roster = buildAgentRoster({
+ ...EMPTY,
+ runtimes: [{ id: 'h1', name: 'wolf-laptop', connected: true }],
+ agents: [persisted({ harness: 'macrod', harness_id: 'h1' })],
+ });
+ expect(roster.at(-1)?.unavailableReason).toBe(
+ 'Runs on its own machine · start it from a channel mention'
+ );
+ });
+});
+
+describe('rosterForComposer and kindForBot', () => {
+ const roster = buildAgentRoster({
+ ...EMPTY,
+ agents: [
+ persisted({ harness: 'in-memory' }),
+ persisted({ harness: 'cursor' }),
+ persisted({ harness: 'macrod' }),
+ persisted({ harness: 'sandbox' }),
+ ],
+ });
+
+ it('combines supported chat and coding agents in one picker', () => {
+ expect(rosterForComposer(roster).map((a) => a.id)).toEqual([
+ MACRO_PERSONA_ID,
+ CURSOR_BOT_ID,
+ 'bot-in-memory',
+ 'bot-cursor',
+ ]);
+ });
+
+ it('resolves a session bot to its kind, defaulting to Chat', () => {
+ expect(kindForBot('bot-cursor', roster)).toBe('coder');
+ expect(kindForBot(`bot|${MACRO_CODER_BOT_ID}`, roster)).toBe('coder');
+ expect(kindForBot('bot-in-memory', roster)).toBe('agent');
+ expect(kindForBot('someone-elses-bot', roster)).toBe('agent');
+ expect(kindForBot(undefined, roster)).toBe('agent');
+ });
+});
diff --git a/apps/web/src/features/agents-view/core/roster.ts b/apps/web/src/features/agents-view/core/roster.ts
new file mode 100644
index 0000000000..f25105ca93
--- /dev/null
+++ b/apps/web/src/features/agents-view/core/roster.ts
@@ -0,0 +1,238 @@
+import {
+ CURSOR_BOT_HANDLE,
+ CURSOR_BOT_ID,
+ CURSOR_BOT_NAME,
+} from '@core/constant/cursorAgent';
+import {
+ MACRO_AGENT_HANDLE,
+ MACRO_AGENT_NAME,
+} from '@core/constant/macroAgent';
+import { type AgentKind, kindForHarness, systemBotKind } from './agent-kind';
+
+/**
+ * Macro's own chat agent: the deployment's managed default. Started without a
+ * `botId`, so the server picks the runtime it is configured to run it on.
+ */
+export const MACRO_PERSONA_ID = 'macro';
+
+/** The fields of a persisted agent the roster reads. Structural, so the wire
+ * type satisfies it without the core importing the client. */
+export type PersistedAgentLike = {
+ bot: {
+ id: string;
+ name: string;
+ handle: string;
+ description?: string | null;
+ avatar_url?: string | null;
+ created_by?: string | null;
+ owner?:
+ | { type: 'user'; user_id: string }
+ | { type: 'team'; team_id: string }
+ | null;
+ };
+ harness: string;
+ harness_id?: string | null;
+ default_model: string;
+};
+
+/** A registered macrod runtime, as far as the roster cares. */
+export type RuntimeLike = {
+ id: string;
+ name: string;
+ connected: boolean;
+};
+
+type RosterShare = 'system' | 'team' | 'private';
+
+/** One agent or coder as the composer, carousel, and roster page show it. */
+export type RosterAgent = {
+ /** Persona id: the bot id, or `MACRO_PERSONA_ID` for Macro's default. */
+ id: string;
+ /** Bot to start sessions for; absent for Macro's default persona. */
+ botId?: string;
+ kind: AgentKind;
+ name: string;
+ handle: string;
+ description?: string;
+ avatarUrl?: string;
+ harness: string;
+ harnessId?: string;
+ defaultModel?: string;
+ share: RosterShare;
+ /** Where it runs, as a person would say it, and whether that is reachable. */
+ runtime: { label: string; connected: boolean };
+ ownerId?: string;
+ /** Why it cannot be started from the composer right now, when it cannot. */
+ unavailableReason?: string;
+ /** An unavailable agent with a setup action stays clickable. */
+ connectLabel?: string;
+ /** The persisted record behind a user-made agent; absent for system ones. */
+ persisted?: PersistedAgentLike;
+};
+
+export type RosterInput = {
+ agents: readonly PersistedAgentLike[];
+ runtimes: readonly RuntimeLike[];
+ cursorConnected: boolean;
+ /** Cursor's status is known and it is not connected, so offer to connect. */
+ cursorNeedsConnection: boolean;
+ macroDefaultModel?: string;
+ cursorDefaultModel?: string;
+};
+
+/** The product name of a runtime, from the harness slug bots are stored with. */
+export function runtimeLabel(
+ harness: string,
+ harnessId: string | undefined,
+ runtimes: readonly RuntimeLike[]
+): string {
+ switch (harness) {
+ case 'in-memory':
+ case 'macro-inmem':
+ return 'Macro';
+ case 'cursor':
+ return 'Cursor';
+ case 'macrod':
+ return (
+ runtimes.find((runtime) => runtime.id === harnessId)?.name ??
+ 'Disconnected runtime'
+ );
+ default:
+ return harness;
+ }
+}
+
+function runtimeConnected(
+ harness: string,
+ harnessId: string | undefined,
+ input: Pick<RosterInput, 'runtimes' | 'cursorConnected'>
+): boolean {
+ switch (harness) {
+ case 'in-memory':
+ case 'macro-inmem':
+ return true;
+ case 'cursor':
+ return input.cursorConnected;
+ case 'macrod':
+ return (
+ input.runtimes.find((runtime) => runtime.id === harnessId)?.connected ??
+ false
+ );
+ default:
+ return false;
+ }
+}
+
+/**
+ * Supported runtimes for starting sessions from the composer. Paired runtimes
+ * remain in the roster for existing sessions, but start from channel mentions.
+ */
+function startableFromComposer(harness: string): boolean {
+ return (
+ harness === 'in-memory' || harness === 'macro-inmem' || harness === 'cursor'
+ );
+}
+
+function persistedAgent(
+ agent: PersistedAgentLike,
+ input: RosterInput
+): RosterAgent {
+ const harnessId = agent.harness_id ?? undefined;
+ const connected = runtimeConnected(agent.harness, harnessId, input);
+ const startable = startableFromComposer(agent.harness);
+ return {
+ id: agent.bot.id,
+ botId: agent.bot.id,
+ kind: kindForHarness(agent.harness),
+ name: agent.bot.name,
+ handle: agent.bot.handle,
+ description: agent.bot.description ?? undefined,
+ avatarUrl: agent.bot.avatar_url ?? undefined,
+ harness: agent.harness,
+ harnessId,
+ defaultModel: agent.default_model,
+ share: agent.bot.owner?.type === 'team' ? 'team' : 'private',
+ runtime: {
+ label: runtimeLabel(agent.harness, harnessId, input.runtimes),
+ connected,
+ },
+ ownerId:
+ agent.bot.owner?.type === 'user'
+ ? agent.bot.owner.user_id
+ : (agent.bot.created_by ?? undefined),
+ connectLabel:
+ agent.harness === 'cursor' && input.cursorNeedsConnection
+ ? 'Connect Cursor'
+ : undefined,
+ unavailableReason: startable
+ ? agent.harness === 'cursor' && !connected
+ ? 'Connect Cursor to start it'
+ : undefined
+ : connected
+ ? 'Runs on its own machine · start it from a channel mention'
+ : 'Its runtime is disconnected',
+ persisted: agent,
+ };
+}
+
+/**
+ * Everyone the composer can pick from: the first-party agents lead, then the
+ * saved ones the caller can start (their own, team-shared, and the ones they
+ * can `@` mention).
+ */
+export function buildAgentRoster(input: RosterInput): RosterAgent[] {
+ return [
+ {
+ id: MACRO_PERSONA_ID,
+ kind: 'agent',
+ name: MACRO_AGENT_NAME,
+ handle: MACRO_AGENT_HANDLE,
+ harness: 'in-memory',
+ defaultModel: input.macroDefaultModel,
+ share: 'system',
+ runtime: { label: 'Macro', connected: true },
+ },
+ {
+ id: CURSOR_BOT_ID,
+ botId: CURSOR_BOT_ID,
+ kind: 'coder',
+ name: CURSOR_BOT_NAME,
+ handle: CURSOR_BOT_HANDLE,
+ description: 'Cursor cloud agents, run with your Cursor account.',
+ harness: 'cursor',
+ defaultModel: input.cursorDefaultModel,
+ share: 'system',
+ runtime: { label: 'Cursor', connected: input.cursorConnected },
+ unavailableReason: input.cursorConnected
+ ? undefined
+ : 'Connect Cursor to start it',
+ connectLabel: input.cursorNeedsConnection ? 'Connect Cursor' : undefined,
+ },
+ ...input.agents.map((agent) => persistedAgent(agent, input)),
+ ];
+}
+
+/** Both chat and coding agents supported by the new-conversation composer. */
+export function rosterForComposer(
+ roster: readonly RosterAgent[]
+): RosterAgent[] {
+ return roster.filter((agent) => startableFromComposer(agent.harness));
+}
+
+/**
+ * The kind of the bot behind a session: fixed for first-party bots, read from
+ * the harness for saved agents, and Chat for anything the roster cannot see
+ * (a teammate's private agent, or one since deleted).
+ */
+export function kindForBot(
+ botId: string | null | undefined,
+ roster: readonly RosterAgent[]
+): AgentKind {
+ if (!botId) return 'agent';
+ const bare = botId.startsWith('bot|') ? botId.slice('bot|'.length) : botId;
+ return (
+ systemBotKind(bare) ??
+ roster.find((agent) => agent.botId === bare)?.kind ??
+ 'agent'
+ );
+}
diff --git a/apps/web/src/features/agents-view/core/route.test.ts b/apps/web/src/features/agents-view/core/route.test.ts
new file mode 100644
index 0000000000..bab2a6a200
--- /dev/null
+++ b/apps/web/src/features/agents-view/core/route.test.ts
@@ -0,0 +1,43 @@
+import { describe, expect, it } from 'vitest';
+import {
+ type AgentsRoute,
+ agentsRouteFromSegments,
+ agentsRouteId,
+ agentsRouteSegments,
+ parseAgentsRoute,
+} from './route';
+
+describe('Agents workspace routes', () => {
+ it.each<[AgentsRoute, string]>([
+ [
+ {
+ mode: 'chat',
+ conversation: { type: 'agent_session', id: 'session-1' },
+ },
+ 'agents',
+ ],
+ [
+ {
+ mode: 'code',
+ conversation: { type: 'agent_session', id: 'session-2' },
+ },
+ 'coders',
+ ],
+ [
+ { mode: 'chat', conversation: { type: 'chat', id: 'chat-1' } },
+ 'agent-chats',
+ ],
+ ])('round trips the selected conversation and mode: %j', (route, section) => {
+ const id = agentsRouteId(route);
+ expect(parseAgentsRoute(id)).toEqual(route);
+ expect(agentsRouteSegments(id)).toEqual([section, route.conversation.id]);
+ expect(agentsRouteFromSegments(section, route.conversation.id)).toBe(id);
+ });
+
+ it('does not claim unrelated routes or malformed component identities', () => {
+ expect(agentsRouteFromSegments('md', 'document-1')).toBeUndefined();
+ expect(parseAgentsRoute('agents')).toBeUndefined();
+ expect(parseAgentsRoute('agents-session~agents~')).toBeUndefined();
+ expect(parseAgentsRoute('agents-session~agents~id~extra')).toBeUndefined();
+ });
+});
diff --git a/apps/web/src/features/agents-view/core/route.ts b/apps/web/src/features/agents-view/core/route.ts
new file mode 100644
index 0000000000..693807d6a8
--- /dev/null
+++ b/apps/web/src/features/agents-view/core/route.ts
@@ -0,0 +1,48 @@
+import type { AgentsMode } from './mode';
+import type { AgentConversationTarget } from './recent-conversations';
+
+const PREFIX = 'agents-session~';
+
+export type AgentsRoute = {
+ mode: AgentsMode;
+ conversation: AgentConversationTarget;
+};
+
+/** Distinct component identities preserve each conversation in split history. */
+export function agentsRouteId(route: AgentsRoute): string {
+ const section =
+ route.conversation.type === 'chat'
+ ? 'agent-chats'
+ : route.mode === 'code'
+ ? 'coders'
+ : 'agents';
+ return `${PREFIX}${section}~${route.conversation.id}`;
+}
+
+export function parseAgentsRoute(id: string): AgentsRoute | undefined {
+ if (!id.startsWith(PREFIX)) return;
+ const [section, conversationId, extra] = id.slice(PREFIX.length).split('~');
+ if (!conversationId || extra !== undefined) return;
+ if (section !== 'agents' && section !== 'coders' && section !== 'agent-chats')
+ return;
+ return {
+ mode: section === 'coders' ? 'code' : 'chat',
+ conversation: {
+ type: section === 'agent-chats' ? 'chat' : 'agent_session',
+ id: conversationId,
+ },
+ };
+}
+
+export function agentsRouteSegments(id: string): string[] | undefined {
+ if (!parseAgentsRoute(id)) return;
+ return id.slice(PREFIX.length).split('~');
+}
+
+export function agentsRouteFromSegments(
+ section: string,
+ id: string
+): string | undefined {
+ const componentId = `${PREFIX}${section}~${id}`;
+ return parseAgentsRoute(componentId) ? componentId : undefined;
+}
diff --git a/apps/web/src/features/agents-view/primitives/chat-composer-tip.test.ts b/apps/web/src/features/agents-view/primitives/chat-composer-tip.test.ts
new file mode 100644
index 0000000000..4dd9ff7423
--- /dev/null
+++ b/apps/web/src/features/agents-view/primitives/chat-composer-tip.test.ts
@@ -0,0 +1,60 @@
+import { cleanup, renderHook } from '@solidjs/testing-library';
+import { createSignal } from 'solid-js';
+import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
+import { createChatComposerTip } from './chat-composer-tip';
+
+beforeEach(() => vi.useFakeTimers());
+afterEach(() => {
+ cleanup();
+ vi.useRealTimers();
+});
+
+describe('Chat composer tips', () => {
+ it('omits the agent-selection tip inside a session', () => {
+ const { result: tip } = renderHook(() =>
+ createChatComposerTip(() => true, false)
+ );
+ const first = tip();
+ vi.advanceTimersByTime(6000);
+ expect(tip()).toContain('skill');
+ vi.advanceTimersByTime(6000);
+ expect(tip()).toContain('@');
+ vi.advanceTimersByTime(6000);
+ expect(tip()).toBe(first);
+ });
+
+ it('cycles through connectors, skills, mentions and agents, then repeats', () => {
+ const { result: tip } = renderHook(() => createChatComposerTip(() => true));
+ const first = tip();
+ expect(first).toContain('Connections');
+ vi.advanceTimersByTime(6000);
+ expect(tip()).toContain('skill');
+ vi.advanceTimersByTime(6000);
+ expect(tip()).toContain('@');
+ vi.advanceTimersByTime(6000);
+ expect(tip()).toContain('agent');
+ vi.advanceTimersByTime(6000);
+ expect(tip()).toBe(first);
+ });
+
+ it('pauses while writing and resumes when the draft is cleared', () => {
+ const [empty, setEmpty] = createSignal(true);
+ const { result: tip } = renderHook(() => createChatComposerTip(empty));
+ const first = tip();
+ setEmpty(false);
+ vi.advanceTimersByTime(18000);
+ expect(tip()).toBe(first);
+ setEmpty(true);
+ vi.advanceTimersByTime(6000);
+ expect(tip()).toContain('skill');
+ });
+
+ it('stops its timer when the composer is removed', () => {
+ const { cleanup: dispose } = renderHook(() =>
+ createChatComposerTip(() => true)
+ );
+ expect(vi.getTimerCount()).toBe(1);
+ dispose();
+ expect(vi.getTimerCount()).toBe(0);
+ });
+});
diff --git a/apps/web/src/features/agents-view/primitives/chat-composer-tip.ts b/apps/web/src/features/agents-view/primitives/chat-composer-tip.ts
new file mode 100644
index 0000000000..aac42f96cf
--- /dev/null
+++ b/apps/web/src/features/agents-view/primitives/chat-composer-tip.ts
@@ -0,0 +1,26 @@
+import { type Accessor, createSignal, onCleanup, onMount } from 'solid-js';
+
+const TIPS = [
+ 'Connect your apps in Settings → Connections',
+ 'Type / to add a skill',
+ 'Type @ to mention docs, people, or channels',
+ 'Choose an agent to change who helps',
+];
+
+/** Cycle one hint at a time, pausing while the user has a draft. */
+export function createChatComposerTip(
+ empty: Accessor<boolean>,
+ canChooseAgent = true
+) {
+ const tips = canChooseAgent
+ ? TIPS
+ : [TIPS[0], 'Use @ to reference a skill document', TIPS[2]];
+ const [index, setIndex] = createSignal(0);
+ onMount(() => {
+ const interval = setInterval(() => {
+ if (empty()) setIndex((current) => (current + 1) % tips.length);
+ }, 6000);
+ onCleanup(() => clearInterval(interval));
+ });
+ return () => tips[index()];
+}
diff --git a/apps/web/src/features/agents-view/primitives/recent-repositories.ts b/apps/web/src/features/agents-view/primitives/recent-repositories.ts
new file mode 100644
index 0000000000..5bf0d31476
--- /dev/null
+++ b/apps/web/src/features/agents-view/primitives/recent-repositories.ts
@@ -0,0 +1,42 @@
+import { makePersistedState } from '@app/lib/persistence';
+import { createUserScopedStorage } from '@core/util/userScopedStorage';
+import { createSignal } from 'solid-js';
+
+const RECENT_REPOSITORY_LIMIT = 8;
+
+/**
+ * Repositories handed to coders from this composer, newest first and scoped
+ * to the signed-in user. There is no server-side list of a person's
+ * repositories yet, so the ones they have typed are the recents.
+ */
+export function createRecentRepositories(userId: string | undefined) {
+ const storage = createUserScopedStorage('agents-view-repositories-v1');
+ const [urls, setUrls] = makePersistedState(createSignal<string[]>([]), {
+ storages: {
+ restore: () => {
+ if (!userId) return;
+ const stored: unknown = JSON.parse(storage.read(userId) ?? '[]');
+ if (!Array.isArray(stored)) return;
+ return stored
+ .filter((url): url is string => typeof url === 'string')
+ .slice(0, RECENT_REPOSITORY_LIMIT);
+ },
+ write: (value) => {
+ if (userId) storage.write(userId, JSON.stringify(value));
+ },
+ },
+ });
+
+ return {
+ urls,
+ remember: (url: string) =>
+ setUrls((previous) =>
+ [url, ...previous.filter((value) => value !== url)].slice(
+ 0,
+ RECENT_REPOSITORY_LIMIT
+ )
+ ),
+ forget: (url: string) =>
+ setUrls((previous) => previous.filter((value) => value !== url)),
+ };
+}
diff --git a/apps/web/src/features/agents-view/queries/agent-roster-source.ts b/apps/web/src/features/agents-view/queries/agent-roster-source.ts
new file mode 100644
index 0000000000..5ab7da5a5c
--- /dev/null
+++ b/apps/web/src/features/agents-view/queries/agent-roster-source.ts
@@ -0,0 +1,64 @@
+import { useAgentsQuery } from '@queries/agents/agents';
+import { useAgentModelsQuery } from '@queries/agents/models';
+import { useCursorApiKeyStatusQuery } from '@queries/auth/cursor-api-key';
+import { useHarnessesQuery } from '@queries/harnesses/harnesses';
+import { type Accessor, createMemo } from 'solid-js';
+import { buildAgentRoster, type RosterAgent } from '../core/roster';
+
+export type AgentRosterSource = {
+ /** Every agent and coder the caller can see, first-party ones first. */
+ roster: Accessor<RosterAgent[]>;
+ /** The saved agents are still on their first load. */
+ loading: Accessor<boolean>;
+ /** The saved agents failed to load; the first-party ones are still listed. */
+ error: Accessor<boolean>;
+ cursorConnected: Accessor<boolean>;
+};
+
+/**
+ * Joins the saved agents, the registered macrod runtimes, and the Cursor
+ * connection into one roster. Model defaults for the first-party personas
+ * come from model discovery, so their pills can name what they will run on.
+ */
+export function createAgentRosterSource(): AgentRosterSource {
+ const agentsQuery = useAgentsQuery();
+ const harnessesQuery = useHarnessesQuery();
+ const cursorStatus = useCursorApiKeyStatusQuery();
+ const cursorConnected = () =>
+ cursorStatus.isSuccess ? cursorStatus.data.registered : false;
+ const cursorNeedsConnection = () =>
+ cursorStatus.isSuccess &&
+ !cursorStatus.isPlaceholderData &&
+ !cursorStatus.data.registered;
+ const macroDefaults = useAgentModelsQuery(() => ({ harness: 'in-memory' }));
+ const cursorDefaults = useAgentModelsQuery(
+ () => ({ harness: 'cursor' }),
+ cursorConnected
+ );
+
+ const agents = () => (agentsQuery.isSuccess ? agentsQuery.data : []);
+ const roster = createMemo(() =>
+ buildAgentRoster({
+ agents: agents(),
+ runtimes: harnessesQuery.isSuccess ? harnessesQuery.data : [],
+ cursorConnected: cursorConnected(),
+ cursorNeedsConnection: cursorNeedsConnection(),
+ macroDefaultModel: macroDefaults.isSuccess
+ ? (macroDefaults.data.currentModel ?? undefined)
+ : undefined,
+ cursorDefaultModel: cursorStatus.isSuccess
+ ? (cursorStatus.data.defaultModelId ??
+ (cursorDefaults.isSuccess
+ ? (cursorDefaults.data.currentModel ?? undefined)
+ : undefined))
+ : undefined,
+ })
+ );
+
+ return {
+ roster,
+ loading: () => agentsQuery.isPending,
+ error: () => agentsQuery.isError,
+ cursorConnected,
+ };
+}
diff --git a/apps/web/src/features/agents-view/queries/composer-models.test.ts b/apps/web/src/features/agents-view/queries/composer-models.test.ts
new file mode 100644
index 0000000000..d45bb59c19
--- /dev/null
+++ b/apps/web/src/features/agents-view/queries/composer-models.test.ts
@@ -0,0 +1,96 @@
+import { createRoot, createSignal } from 'solid-js';
+import { describe, expect, it, vi } from 'vitest';
+import type { RosterAgent } from '../core/roster';
+import { composerModelTarget, createComposerModels } from './composer-models';
+
+const discovery = vi.hoisted(() => ({
+ targets: undefined as (() => unknown) | undefined,
+ queries: [] as object[],
+}));
+
+vi.mock('@queries/agents/models', () => ({
+ useAgentModelsQueries: (targets: () => unknown) => {
+ discovery.targets = targets;
+ return discovery.queries;
+ },
+}));
+
+describe('composer model discovery', () => {
+ it('uses runtime identities rather than bot ids to discover models', () => {
+ expect(composerModelTarget({ harness: 'macro-inmem' })).toEqual({
+ harness: 'in-memory',
+ });
+ expect(composerModelTarget({ harness: 'cursor' })).toEqual({
+ harness: 'cursor',
+ });
+ expect(
+ composerModelTarget({ harness: 'macrod', harnessId: 'paired-runtime' })
+ ).toEqual({ harness: 'macrod', harnessId: 'paired-runtime' });
+ expect(composerModelTarget({ harness: 'macrod' })).toBeUndefined();
+ expect(composerModelTarget({ harness: 'sandbox' })).toBeUndefined();
+ });
+
+ it('switches discovery targets with the selected agent and skips disconnected runtimes', () => {
+ discovery.queries = [];
+ createRoot((dispose) => {
+ const [agent, setAgent] = createSignal<RosterAgent>({
+ id: 'bot-one',
+ name: 'One',
+ handle: 'one',
+ kind: 'coder',
+ share: 'private',
+ harness: 'cursor',
+ runtime: { label: 'Cursor', connected: true },
+ });
+ createComposerModels(agent);
+ expect(discovery.targets?.()).toEqual([{ harness: 'cursor' }]);
+ setAgent({ ...agent(), harness: 'macrod', harnessId: 'paired-runtime' });
+ expect(discovery.targets?.()).toEqual([
+ { harness: 'macrod', harnessId: 'paired-runtime' },
+ ]);
+ setAgent({ ...agent(), runtime: { label: 'Offline', connected: false } });
+ expect(discovery.targets?.()).toEqual([]);
+ dispose();
+ });
+ });
+
+ it('does not read pending resource data and exposes discovered choices when ready', () => {
+ createRoot((dispose) => {
+ const [ready, setReady] = createSignal(false);
+ const models = [{ id: 'runtime-model', name: 'Runtime model' }];
+ discovery.queries = [
+ {
+ get isSuccess() {
+ return ready();
+ },
+ get isPending() {
+ return !ready();
+ },
+ get data() {
+ if (!ready()) throw new Error('Pending resource must not be read');
+ return {
+ models,
+ currentModel: 'runtime-model',
+ status: 'available',
+ };
+ },
+ },
+ ];
+ const source = createComposerModels(() => ({
+ id: 'bot',
+ name: 'Agent',
+ handle: 'agent',
+ kind: 'coder',
+ share: 'private',
+ harness: 'cursor',
+ runtime: { label: 'Cursor', connected: true },
+ }));
+ expect(source.models()).toEqual([]);
+ expect(source.message()).toBe('Loading models…');
+ setReady(true);
+ expect(source.models()).toEqual(models);
+ expect(source.currentModel()).toBe('runtime-model');
+ dispose();
+ });
+ });
+});
diff --git a/apps/web/src/features/agents-view/queries/composer-models.ts b/apps/web/src/features/agents-view/queries/composer-models.ts
new file mode 100644
index 0000000000..dbd368b323
--- /dev/null
+++ b/apps/web/src/features/agents-view/queries/composer-models.ts
@@ -0,0 +1,46 @@
+import {
+ type AgentModelTarget,
+ useAgentModelsQueries,
+} from '@queries/agents/models';
+import type { Accessor } from 'solid-js';
+import type { RosterAgent } from '../core/roster';
+
+/** Map a roster entry to the same discovery target used by agent settings. */
+export function composerModelTarget(
+ agent: Pick<RosterAgent, 'harness' | 'harnessId'> | undefined
+): AgentModelTarget | undefined {
+ if (!agent) return;
+ if (agent.harness === 'in-memory' || agent.harness === 'macro-inmem') {
+ return { harness: 'in-memory' };
+ }
+ if (agent.harness === 'cursor') return { harness: 'cursor' };
+ if (agent.harness === 'macrod' && agent.harnessId) {
+ return { harness: 'macrod', harnessId: agent.harnessId };
+ }
+}
+
+/** Keep discovery scoped to the selected, connected runtime. */
+export function createComposerModels(agent: Accessor<RosterAgent | undefined>) {
+ const queries = useAgentModelsQueries(() => {
+ const selected = agent();
+ const target = composerModelTarget(selected);
+ return target && selected?.runtime.connected ? [target] : [];
+ });
+ // Status-gated reads keep a pending catalog from suspending the composer.
+ const data = () => (queries[0]?.isSuccess ? queries[0].data : undefined);
+ return {
+ models: () => data()?.models ?? [],
+ currentModel: () => data()?.currentModel ?? undefined,
+ message: () => {
+ if (!agent()?.runtime.connected)
+ return 'Connect the runtime to load models.';
+ if (queries[0]?.isError)
+ return 'Could not load models from this runtime.';
+ if (queries[0]?.isPending) return 'Loading models…';
+ if (data()?.status === 'unsupported' || !composerModelTarget(agent())) {
+ return 'This runtime does not provide model discovery.';
+ }
+ return 'This runtime returned no models.';
+ },
+ };
+}
diff --git a/apps/web/src/features/agents-view/queries/connected-runtimes.ts b/apps/web/src/features/agents-view/queries/connected-runtimes.ts
new file mode 100644
index 0000000000..0cccc269e2
--- /dev/null
+++ b/apps/web/src/features/agents-view/queries/connected-runtimes.ts
@@ -0,0 +1,61 @@
+import {
+ type AgentModelTarget,
+ buildAgentModelTargets,
+} from '@queries/agents/models';
+import type { Harness } from '@service-storage/client';
+
+/** A runtime an agent can be bound to, with the model-discovery target for it. */
+export type ConnectedRuntime = {
+ id: string;
+ name: string;
+ kind: 'builtin' | 'macrod';
+ target: AgentModelTarget;
+ connected: boolean;
+};
+
+/**
+ * Every runtime the editor can offer, in display order: Macro's harness,
+ * Cursor when the caller has connected it, then each paired macrod daemon.
+ */
+export function connectedRuntimes(
+ cursorConnected: boolean,
+ harnesses: readonly Harness[]
+): ConnectedRuntime[] {
+ // Claude Cloud remains in Settings; this workspace offers its existing runtimes.
+ return buildAgentModelTargets(cursorConnected, harnesses, false).map(
+ (target) => {
+ if (target.harness === 'in-memory') {
+ return {
+ id: 'in-memory',
+ name: 'Macro Harness',
+ kind: 'builtin',
+ target,
+ connected: true,
+ };
+ }
+ if (target.harness === 'cursor') {
+ return {
+ id: 'cursor',
+ name: 'Cursor',
+ kind: 'builtin',
+ target,
+ connected: true,
+ };
+ }
+ const harness = harnesses.find(
+ (candidate) => candidate.id === target.harnessId
+ );
+ return {
+ id: target.harnessId ?? '',
+ name: harness
+ ? harness.owner.type === 'team'
+ ? `${harness.name} · Team`
+ : harness.name
+ : 'macrod',
+ kind: 'macrod',
+ target,
+ connected: harness?.connected ?? false,
+ };
+ }
+ );
+}
diff --git a/apps/web/src/features/agents-view/views/AgentEditorDialog.tsx b/apps/web/src/features/agents-view/views/AgentEditorDialog.tsx
new file mode 100644
index 0000000000..aff81a7602
--- /dev/null
+++ b/apps/web/src/features/agents-view/views/AgentEditorDialog.tsx
@@ -0,0 +1,735 @@
+import { botAssignableChannelOptions } from '@app/features/channel/Bots/botChannelOptions';
+import {
+ addMcpServer,
+ catalogEntryToMcpServer,
+ removeMcpServer,
+} from '@app/features/settings/agentMcpServers';
+import { useChannelsContext } from '@core/context/channels';
+import { PipedreamConnectorIcon } from '@core/pipedream/ConnectorIcon';
+import { createPipedreamCatalogSearch } from '@core/pipedream/catalog';
+import { usePipedreamMcpFlag } from '@core/pipedream/flag';
+import MacroLogo from '@icon/macro-logo.svg';
+import CursorIcon from '@icon/wide-cursor-ide.svg';
+import CheckIcon from '@phosphor/check.svg';
+import MagnifyingGlassIcon from '@phosphor/magnifying-glass.svg';
+import PlugsIcon from '@phosphor/plugs.svg';
+import PlusIcon from '@phosphor/plus.svg';
+import TrashIcon from '@phosphor/trash.svg';
+import XIcon from '@phosphor/x.svg';
+import type {
+ AgentWithHarnessId,
+ CreateAgentParams,
+} from '@queries/agents/agents';
+import { useAgentModelsQueries } from '@queries/agents/models';
+import { usePipedreamConnectedSlugs } from '@queries/pipedream-connectors';
+import type { AgentMcpServer } from '@service-storage/generated/schemas/agentMcpServer';
+import type { AgentMcpServers } from '@service-storage/generated/schemas/agentMcpServers';
+import { createMemo, createSignal, For, Match, Show, Switch } from 'solid-js';
+import { AgentIcon, CodeMark } from '../components/AgentGlyph';
+import { ArtifactDialog } from '../components/ArtifactDialog';
+import { Segmented } from '../components/Segmented';
+import { type AgentKind, isCoderHarness } from '../core/agent-kind';
+import type { ConnectedRuntime } from '../queries/connected-runtimes';
+
+function slugTag(value: string): string {
+ return value
+ .toLowerCase()
+ .replace(/^@/, '')
+ .replace(/[^a-z0-9_-]+/g, '-')
+ .replace(/^-+|-+$/g, '');
+}
+
+/**
+ * Create or edit an agent: identity and settings on the left, instructions
+ * on the right. A coder is an agent bound to a coding runtime, so the Coder
+ * switch decides whether the Runtime list shows and what the save sends.
+ */
+export function AgentEditorDialog(props: {
+ agent?: AgentWithHarnessId;
+ initialKind: AgentKind;
+ runtimes: readonly ConnectedRuntime[];
+ currentTeamId?: string;
+ canShareWithTeam: boolean;
+ canMakePrivate: boolean;
+ pending: boolean;
+ onClose: () => void;
+ onSave: (agent: CreateAgentParams) => Promise<boolean>;
+ onDelete?: () => void;
+}) {
+ const isNew = () => props.agent === undefined;
+ const coderRuntimes = () =>
+ props.runtimes.filter((runtime) => runtime.id !== 'in-memory');
+ const [coder, setCoder] = createSignal(
+ props.agent
+ ? isCoderHarness(props.agent.harness)
+ : props.initialKind === 'coder'
+ );
+ const noun = () => (coder() ? 'coding agent' : 'agent');
+ const [name, setName] = createSignal(props.agent?.bot.name ?? '');
+ const [tag, setTag] = createSignal(props.agent?.bot.handle ?? '');
+ const [tagEdited, setTagEdited] = createSignal(props.agent !== undefined);
+ const [avatarUrl, setAvatarUrl] = createSignal<string | undefined>(
+ props.agent?.bot.avatar_url ?? undefined
+ );
+ const [instructions, setInstructions] = createSignal(
+ props.agent?.instructions ?? ''
+ );
+ const [harnessId, setHarnessId] = createSignal(
+ props.agent?.harness_id ??
+ props.agent?.harness ??
+ (coder() ? coderRuntimes()[0]?.id : 'in-memory') ??
+ ''
+ );
+ let avatarInput: HTMLInputElement | undefined;
+
+ // Model discovery per runtime, so switching runtimes swaps the catalog.
+ const modelQueries = useAgentModelsQueries(() =>
+ props.runtimes.map((runtime) => runtime.target)
+ );
+ const runtime = () =>
+ props.runtimes.find((candidate) => candidate.id === harnessId());
+ const modelQueryFor = (id: string) => {
+ const index = props.runtimes.findIndex((candidate) => candidate.id === id);
+ return index >= 0 ? modelQueries[index] : undefined;
+ };
+ const modelDataFor = (id: string) => {
+ const query = modelQueryFor(id);
+ return query?.isSuccess ? query.data : undefined;
+ };
+ const preferredModelId = (id: string) => {
+ const data = modelDataFor(id);
+ if (data?.status === 'unsupported') return 'default';
+ if (data?.status !== 'available') return '';
+ const current = data.currentModel;
+ if (
+ current &&
+ (data.models.length === 0 ||
+ data.models.some((model) => model.id === current))
+ ) {
+ return current;
+ }
+ return data.models[0]?.id ?? '';
+ };
+ const [defaultModelId, setDefaultModelId] = createSignal(
+ props.agent?.default_model ?? ''
+ );
+ const selectedDefaultModelId = () =>
+ defaultModelId() || preferredModelId(harnessId());
+ const modelOptions = () => {
+ const data = modelDataFor(harnessId());
+ if (data?.status !== 'available') return [];
+ const selected = selectedDefaultModelId();
+ const saved =
+ props.agent?.default_model === selected &&
+ (props.agent.harness_id ?? props.agent.harness) === harnessId();
+ if (!selected || data.models.some((model) => model.id === selected)) {
+ return data.models;
+ }
+ return [
+ ...data.models,
+ {
+ id: selected,
+ name: `${selected} (${saved ? 'saved, ' : ''}unavailable)`,
+ description: undefined,
+ group: undefined,
+ },
+ ];
+ };
+
+ const changeRuntime = (id: string) => {
+ setHarnessId(id);
+ setDefaultModelId(preferredModelId(id));
+ };
+ const setCoderMode = (on: boolean) => {
+ if (on && coderRuntimes().length === 0) return;
+ setCoder(on);
+ changeRuntime(on ? (coderRuntimes()[0]?.id ?? '') : 'in-memory');
+ };
+
+ const [channelMode, setChannelMode] = createSignal<'all' | 'selected'>(
+ props.agent?.channel_scope ?? 'all'
+ );
+ const [selectedChannelIds, setSelectedChannelIds] = createSignal<string[]>(
+ props.agent?.channel_ids ?? []
+ );
+ const channelsContext = useChannelsContext();
+ const channels = createMemo(() =>
+ botAssignableChannelOptions(channelsContext.channels())
+ );
+ const toggleChannel = (id: string) =>
+ setSelectedChannelIds((current) =>
+ current.includes(id)
+ ? current.filter((value) => value !== id)
+ : [...current, id]
+ );
+
+ const [share, setShare] = createSignal<'private' | 'team'>(
+ props.agent?.bot.owner?.type === 'team' ? 'team' : 'private'
+ );
+
+ const pipedreamMcp = usePipedreamMcpFlag();
+ const connections = usePipedreamConnectedSlugs();
+ const [mcp, setMcp] = createSignal<AgentMcpServers>(
+ props.agent?.mcp ?? { scope: 'owner_connections' }
+ );
+ const picked = (): AgentMcpServer[] => {
+ const current = mcp();
+ return current.scope === 'selected' ? current.servers : [];
+ };
+ // Picks survive a round trip through "All my MCPs", so comparing the two
+ // does not throw the list away.
+ let remembered: AgentMcpServer[] = picked();
+ const setMcpScope = (scope: AgentMcpServers['scope']) => {
+ if (scope === 'selected')
+ setMcp({ scope: 'selected', servers: remembered });
+ else {
+ remembered = picked();
+ setMcp({ scope: 'owner_connections' });
+ }
+ };
+ const setPicked = (servers: AgentMcpServer[]) => {
+ remembered = servers;
+ setMcp({ scope: 'selected', servers });
+ };
+ const pickedSlugs = createMemo<ReadonlySet<string>>(
+ () => new Set(picked().map((server) => server.app_slug))
+ );
+ const catalog = createPipedreamCatalogSearch(pickedSlugs);
+
+ const handleNameInput = (value: string) => {
+ setName(value);
+ if (!tagEdited()) setTag(slugTag(value));
+ };
+ const handleAvatar = (file: File | undefined) => {
+ if (!file) return;
+ const reader = new FileReader();
+ reader.addEventListener('load', () => {
+ if (typeof reader.result === 'string') setAvatarUrl(reader.result);
+ });
+ reader.readAsDataURL(file);
+ };
+
+ const canSave = () =>
+ !props.pending &&
+ name().trim().length > 0 &&
+ tag().trim().length > 0 &&
+ runtime() !== undefined &&
+ selectedDefaultModelId().length > 0 &&
+ (channelMode() === 'all' || selectedChannelIds().length > 0) &&
+ (mcp().scope === 'owner_connections' || picked().length > 0) &&
+ (share() === 'private' ? props.canMakePrivate : props.canShareWithTeam);
+
+ const submit = async () => {
+ const current = runtime();
+ if (!canSave() || !current) return;
+ const owner = props.agent?.bot.owner;
+ const saved = await props.onSave({
+ avatarUrl: avatarUrl(),
+ channelIds: channelMode() === 'all' ? [] : selectedChannelIds(),
+ channelScope: channelMode(),
+ defaultModel: selectedDefaultModelId(),
+ handle: slugTag(tag()),
+ // Paired macrod runtimes send the 'macrod' slug plus their uuid;
+ // built-ins send their own slug with no runtime id.
+ harness: current.kind === 'macrod' ? 'macrod' : current.id,
+ harnessId: current.kind === 'macrod' ? current.id : undefined,
+ name: name().trim(),
+ instructions: instructions().trim(),
+ mcp: mcp(),
+ teamId:
+ share() === 'team'
+ ? owner?.type === 'team'
+ ? owner.team_id
+ : props.currentTeamId
+ : undefined,
+ });
+ if (saved) props.onClose();
+ };
+
+ const glyphAgent = () => ({
+ id: props.agent?.bot.id ?? 'new',
+ name: name() || 'Agent',
+ });
+
+ return (
+ <ArtifactDialog
+ class="xwide fixed"
+ label={`${isNew() ? 'Create' : 'Edit'} ${noun()}`}
+ onClose={props.onClose}
+ >
+ <div class="dh">
+ <span class="t">
+ <AgentIcon agent={glyphAgent()} />
+ {isNew() ? 'Create' : 'Edit'} {noun()}
+ </span>
+ <span class="hr">
+ <Segmented
+ name="share"
+ value={share()}
+ options={[
+ {
+ value: 'private',
+ label: 'Private',
+ icon: 'lock',
+ disabled: !props.canMakePrivate,
+ },
+ {
+ value: 'team',
+ label: 'Team',
+ icon: 'team',
+ disabled: !props.canShareWithTeam,
+ },
+ ]}
+ onChange={setShare}
+ />
+ <button type="button" class="icon-btn" aria-label="Close" data-close>
+ <XIcon class="ph" />
+ </button>
+ </span>
+ </div>
+ <div class="db">
+ <div class="cols agent">
+ <div class="colL">
+ <div class="avrow" style={{ border: 0, padding: 0 }}>
+ <span class="avw">
+ <button
+ type="button"
+ class="bigav"
+ aria-label="Change avatar"
+ onClick={() => avatarInput?.click()}
+ >
+ <Show
+ when={avatarUrl()}
+ fallback={<AgentIcon agent={glyphAgent()} />}
+ >
+ {(url) => (
+ <img
+ src={url()}
+ alt=""
+ style={{
+ width: '100%',
+ height: '100%',
+ 'object-fit': 'cover',
+ 'border-radius': 'inherit',
+ }}
+ />
+ )}
+ </Show>
+ </button>
+ <CodeMark hidden={!coder()} />
+ </span>
+ <input
+ ref={avatarInput}
+ type="file"
+ accept="image/*"
+ hidden
+ onChange={(event) =>
+ handleAvatar(event.currentTarget.files?.[0])
+ }
+ />
+ <div style={{ 'min-width': 0, flex: 1 }}>
+ <input
+ class="sinput"
+ aria-label="Agent name"
+ placeholder="Agent name"
+ style={{ 'font-weight': 500 }}
+ value={name()}
+ onInput={(event) =>
+ handleNameInput(event.currentTarget.value)
+ }
+ />
+ <span class="tagin" style={{ 'margin-top': '6px' }}>
+ <span class="at">@</span>
+ <input
+ aria-label="@tag"
+ placeholder="tag"
+ value={tag()}
+ onInput={(event) => {
+ setTagEdited(true);
+ setTag(slugTag(event.currentTarget.value));
+ }}
+ />
+ </span>
+ </div>
+ </div>
+
+ <Show when={coder()}>
+ <div class="divider" />
+ <p class="grp-h">Runtime</p>
+ <div class="plist" role="radiogroup" aria-label="Runtime">
+ <For
+ each={coderRuntimes()}
+ fallback={
+ <p class="empty">
+ Connect Cursor or pair a runtime, then come back.
+ </p>
+ }
+ >
+ {(candidate) => (
+ <button
+ type="button"
+ class="prow"
+ role="radio"
+ aria-checked={harnessId() === candidate.id}
+ onClick={() => changeRuntime(candidate.id)}
+ >
+ <span class="cb rd" />
+ <Show
+ when={candidate.kind === 'macrod'}
+ fallback={
+ <Show
+ when={candidate.id === 'cursor'}
+ fallback={<MacroLogo class="ph" />}
+ >
+ <CursorIcon class="ph" />
+ </Show>
+ }
+ >
+ <PlugsIcon class="ph" />
+ </Show>
+ <span class="truncate">{candidate.name}</span>
+ <span class="meta">
+ <Show
+ when={candidate.kind === 'macrod'}
+ fallback={
+ candidate.id === 'cursor' ? 'cloud' : 'built in'
+ }
+ >
+ <span class={candidate.connected ? 'on' : 'off'}>
+ {candidate.connected ? 'Connected' : 'Disconnected'}
+ </span>
+ </Show>
+ </span>
+ </button>
+ )}
+ </For>
+ </div>
+ </Show>
+
+ <div class="srow">
+ <span class="lab">Default model</span>
+ <Show
+ when={modelQueryFor(harnessId())}
+ fallback={
+ <span class="sinput sm" style={{ color: 'var(--ink-muted)' }}>
+ Model discovery unavailable
+ </span>
+ }
+ >
+ {(query) => (
+ <Switch>
+ <Match when={query().isPending}>
+ <select
+ class="sinput sm"
+ aria-label="Default model"
+ disabled
+ >
+ <option>Loading models…</option>
+ </select>
+ </Match>
+ <Match when={query().isError}>
+ <span
+ style={{ 'font-size': '12px', color: 'var(--red)' }}
+ >
+ Could not load models.{' '}
+ <button
+ type="button"
+ class="link-btn"
+ onClick={() => void query().refetch()}
+ >
+ Retry
+ </button>
+ </span>
+ </Match>
+ <Match
+ when={modelDataFor(harnessId())?.status !== 'available'}
+ >
+ <span
+ class="sinput sm"
+ style={{ color: 'var(--ink-muted)' }}
+ >
+ Chosen by the runtime
+ </span>
+ </Match>
+ <Match when={true}>
+ <select
+ class="sinput sm"
+ aria-label="Default model"
+ value={selectedDefaultModelId()}
+ onChange={(event) =>
+ setDefaultModelId(event.currentTarget.value)
+ }
+ >
+ <For each={modelOptions()}>
+ {(model) => (
+ <option value={model.id}>{model.name}</option>
+ )}
+ </For>
+ </select>
+ </Match>
+ </Switch>
+ )}
+ </Show>
+ </div>
+
+ <Show when={pipedreamMcp()}>
+ <div class="divider" />
+ <div class="grp-row">
+ <p class="grp-h">Connections</p>
+ <Segmented
+ name="mcp"
+ value={mcp().scope}
+ options={[
+ { value: 'owner_connections', label: 'All my MCPs' },
+ { value: 'selected', label: 'Specific MCPs' },
+ ]}
+ onChange={setMcpScope}
+ />
+ </div>
+ <Show
+ when={mcp().scope === 'selected'}
+ fallback={
+ <p
+ style={{
+ margin: 0,
+ 'font-size': '12px',
+ color: 'var(--ink-disabled)',
+ }}
+ >
+ The agent can use every app the person running it has
+ connected.
+ </p>
+ }
+ >
+ <div class="picker">
+ <div class="csearch">
+ <MagnifyingGlassIcon class="ph" />
+ <input
+ placeholder="Search all connectors…"
+ aria-label="Search connectors"
+ value={catalog.searchInput()}
+ onInput={(event) =>
+ catalog.onSearchInput(event.currentTarget.value)
+ }
+ />
+ </div>
+ <Show when={catalog.searchInput().trim().length > 0}>
+ <div class="results" aria-label="Connector results">
+ <Show
+ when={
+ !catalog.query.isPending &&
+ catalog.entries().length === 0
+ }
+ >
+ <div class="empty">No connectors match.</div>
+ </Show>
+ <For each={catalog.entries()}>
+ {(entry) => (
+ <button
+ type="button"
+ class="crow"
+ onClick={() => {
+ setPicked(
+ addMcpServer(
+ picked(),
+ catalogEntryToMcpServer(entry)
+ )
+ );
+ catalog.onSearchInput('');
+ }}
+ >
+ <span class="mk">
+ <PipedreamConnectorIcon
+ appSlug={entry.app_slug}
+ class="size-4"
+ />
+ </span>
+ <span style={{ 'min-width': 0 }}>
+ <span class="nm truncate">
+ {entry.display_name}
+ </span>
+ <span class="ds truncate">
+ {entry.description}
+ </span>
+ </span>
+ <span class="add">
+ <PlusIcon class="ph" />
+ </span>
+ </button>
+ )}
+ </For>
+ </div>
+ </Show>
+ <div class="picked">
+ <For
+ each={picked()}
+ fallback={
+ <p class="none">
+ No apps picked yet. Search above to add one — you can
+ connect your account later.
+ </p>
+ }
+ >
+ {(server) => (
+ <div class="crow">
+ <span class="mk">
+ <PipedreamConnectorIcon
+ appSlug={server.app_slug}
+ class="size-5"
+ />
+ </span>
+ <span style={{ 'min-width': 0 }}>
+ <span class="nm truncate">
+ {server.server_name}
+ </span>
+ <span class="ds truncate">
+ {connections.ready()
+ ? connections.slugs().has(server.app_slug)
+ ? 'Connected'
+ : 'Not connected'
+ : ''}
+ </span>
+ </span>
+ <button
+ type="button"
+ class="icon-btn"
+ aria-label={`Remove ${server.server_name}`}
+ onClick={() =>
+ setPicked(
+ removeMcpServer(picked(), server.app_slug)
+ )
+ }
+ >
+ <XIcon class="ph" />
+ </button>
+ </div>
+ )}
+ </For>
+ </div>
+ </div>
+ </Show>
+ </Show>
+
+ <div class="divider" />
+ <div class="grp-row">
+ <p class="grp-h">Channels</p>
+ <Segmented
+ name="ch"
+ value={channelMode()}
+ options={[
+ { value: 'all', label: 'All channels' },
+ { value: 'selected', label: 'Specific' },
+ ]}
+ onChange={setChannelMode}
+ />
+ </div>
+ <Show when={channelMode() === 'selected'}>
+ <div class="plist scroll" aria-label="Channels">
+ <For
+ each={channels()}
+ fallback={<p class="empty">No channels to pick from.</p>}
+ >
+ {(channel) => (
+ <button
+ type="button"
+ class="prow"
+ role="checkbox"
+ aria-checked={selectedChannelIds().includes(channel.id)}
+ onClick={() => toggleChannel(channel.id)}
+ >
+ <span class="cb">
+ <CheckIcon class="ph" />
+ </span>
+ <span class="mk">#</span>
+ <span class="truncate">{channel.name}</span>
+ <span class="meta" />
+ </button>
+ )}
+ </For>
+ </div>
+ </Show>
+
+ <div class="divider" />
+ <div class="srow">
+ <span class="lab">
+ Coding agent
+ <small>
+ {coderRuntimes().length === 0
+ ? 'Connect Cursor or pair a runtime to make coding agents'
+ : 'Writes code: takes a repository, runs on a runtime, and appears under Coding agents'}
+ </small>
+ </span>
+ <button
+ type="button"
+ class="switch"
+ role="switch"
+ aria-checked={coder()}
+ aria-disabled={
+ coderRuntimes().length === 0 && !coder() ? true : undefined
+ }
+ style={
+ coderRuntimes().length === 0 && !coder()
+ ? { opacity: 0.7 }
+ : undefined
+ }
+ onClick={() => setCoderMode(!coder())}
+ >
+ <span class="trk" />
+ <span class="sw-l">{coder() ? 'On' : 'Off'}</span>
+ </button>
+ </div>
+ </div>
+
+ <div class="colR">
+ <div class="mdwrap">
+ <div class="mdbar">
+ <span class="lbl">Instructions</span>
+ </div>
+ <textarea
+ class="always"
+ aria-label="Instructions"
+ spellcheck={false}
+ placeholder="You are…"
+ value={instructions()}
+ onInput={(event) => setInstructions(event.currentTarget.value)}
+ />
+ </div>
+ </div>
+ </div>
+ </div>
+ <div class="df">
+ <Show when={!isNew() && props.onDelete} fallback={<span />}>
+ {(onDelete) => (
+ <button type="button" class="btn danger" onClick={onDelete()}>
+ <TrashIcon class="ph" />
+ Delete <span class="noun">{noun()}</span>
+ </button>
+ )}
+ </Show>
+ <div style={{ display: 'flex', gap: '8px' }}>
+ <button type="button" class="btn quiet" data-close>
+ Cancel
+ </button>
+ <button
+ type="button"
+ class="btn"
+ style={{
+ background: 'var(--accent)',
+ color: 'var(--accent-contrast)',
+ }}
+ disabled={!canSave()}
+ onClick={() => void submit()}
+ >
+ {props.pending
+ ? isNew()
+ ? 'Creating…'
+ : 'Saving…'
+ : isNew()
+ ? `Create ${noun()}`
+ : 'Save changes'}
+ </button>
+ </div>
+ </div>
+ </ArtifactDialog>
+ );
+}
diff --git a/apps/web/src/features/agents-view/views/AgentPicker.tsx b/apps/web/src/features/agents-view/views/AgentPicker.tsx
new file mode 100644
index 0000000000..0ce0d23030
--- /dev/null
+++ b/apps/web/src/features/agents-view/views/AgentPicker.tsx
@@ -0,0 +1,282 @@
+import { ModelCatalogMenu } from '@core/component/AI/component/input/ModelCatalogPicker';
+import {
+ modelProvider,
+ ProviderIcon,
+} from '@core/component/AI/component/ProviderIcon';
+import CaretDownIcon from '@phosphor/caret-down.svg';
+import CaretRightIcon from '@phosphor/caret-right.svg';
+import CheckIcon from '@phosphor/check.svg';
+import CodeIcon from '@phosphor/code.svg';
+import PlusIcon from '@phosphor/plus.svg';
+import SparkleIcon from '@phosphor/sparkle.svg';
+import { Dropdown } from '@ui';
+import { createSignal, For, Show } from 'solid-js';
+import { AgentIcon } from '../components/AgentGlyph';
+import { modelLabel } from '../components/model-label';
+import { MACRO_PERSONA_ID, type RosterAgent } from '../core/roster';
+import { createComposerModels } from '../queries/composer-models';
+
+/** Agent selection with a per-message model catalog in each submenu. */
+export function AgentPicker(props: {
+ agents: RosterAgent[];
+ selected?: RosterAgent;
+ modelOverride?: string;
+ loading: boolean;
+ onSelect: (agent: RosterAgent, model?: string) => void;
+ onConnect: (agent: RosterAgent) => void;
+ onCreate: () => void;
+}) {
+ const [open, setOpen] = createSignal(false);
+ const catalog = createComposerModels(() => props.selected);
+ const macro = () =>
+ props.agents.find((agent) => agent.id === MACRO_PERSONA_ID);
+ const macroCatalog = createComposerModels(macro);
+ const agents = () =>
+ props.agents.filter((agent) => agent.id !== MACRO_PERSONA_ID);
+ const rawModel = () => props.selected?.id === MACRO_PERSONA_ID;
+ const model = () =>
+ props.modelOverride ??
+ props.selected?.defaultModel ??
+ catalog.currentModel();
+ const label = () =>
+ modelLabel(
+ model(),
+ catalog.models().find((option) => option.id === model())?.name
+ );
+ const choose = (agent: RosterAgent, model?: string) => {
+ props.onSelect(agent, model);
+ setOpen(false);
+ };
+ return (
+ <Dropdown open={open()} onOpenChange={setOpen} placement="top-end">
+ <Dropdown.Trigger
+ variant="ghost"
+ aria-label="Agent"
+ title={
+ rawModel()
+ ? label()
+ : `${props.selected?.name ?? 'Choose agent'} · ${label()}`
+ }
+ class="pill min-w-0 max-w-full gap-2"
+ >
+ <Show
+ when={rawModel()}
+ fallback={
+ <Show when={props.selected}>
+ {(agent) => <AgentIcon agent={agent()} class="size-6 shrink-0" />}
+ </Show>
+ }
+ >
+ <ProviderIcon model={model()} class="size-6" />
+ </Show>
+ <span class="min-w-0 truncate text-left text-sm leading-5">
+ <Show
+ when={rawModel()}
+ fallback={
+ <>
+ {props.selected?.name ?? 'Choose agent'}
+ <span class="text-[13px] text-ink-muted"> · {label()}</span>
+ </>
+ }
+ >
+ {label()}
+ </Show>
+ </span>
+ <CaretDownIcon class="size-3 shrink-0" />
+ </Dropdown.Trigger>
+ <Dropdown.Content
+ class="w-80 max-w-[calc(100vw-1rem)] overflow-hidden"
+ onPointerDown={(event: PointerEvent) => event.stopPropagation()}
+ onMouseDown={(event: MouseEvent) => event.stopPropagation()}
+ >
+ <div class="flex min-h-0 max-h-[min(28rem,var(--kb-popper-content-available-height))] flex-col">
+ <div class="min-h-0 overflow-y-auto overscroll-contain">
+ <For each={['coder', 'agent'] as const}>
+ {(kind) => (
+ <Show when={agents().some((agent) => agent.kind === kind)}>
+ <Dropdown.Group>
+ <Dropdown.GroupLabel>
+ {kind === 'coder' ? 'Coding agents' : 'Agents'}
+ </Dropdown.GroupLabel>
+ <For each={agents().filter((agent) => agent.kind === kind)}>
+ {(agent) => (
+ <AgentPickerRow
+ agent={agent}
+ selected={agent.id === props.selected?.id}
+ modelOverride={
+ agent.id === props.selected?.id
+ ? props.modelOverride
+ : undefined
+ }
+ onSelect={(model) => choose(agent, model)}
+ onConnect={() => {
+ setOpen(false);
+ props.onConnect(agent);
+ }}
+ />
+ )}
+ </For>
+ </Dropdown.Group>
+ </Show>
+ )}
+ </For>
+ <Show when={macro()}>
+ {(agent) => (
+ <Dropdown.Group>
+ <Dropdown.GroupLabel>Models</Dropdown.GroupLabel>
+ <For each={macroCatalog.models()}>
+ {(option) => (
+ <Dropdown.Item
+ closeOnSelect
+ class="min-w-0 gap-2"
+ disabled={Boolean(agent().unavailableReason)}
+ textValue={modelLabel(option.id, option.name)}
+ title={modelLabel(option.id, option.name)}
+ onSelect={() => choose(agent(), option.id)}
+ >
+ <Show
+ when={modelProvider(option.id)}
+ fallback={<SparkleIcon class="size-5 shrink-0" />}
+ >
+ <ProviderIcon model={option.id} class="size-5" />
+ </Show>
+ <span class="min-w-0 flex-1 truncate">
+ {modelLabel(option.id, option.name)}
+ </span>
+ <Show
+ when={
+ props.selected?.id === agent().id &&
+ model() === option.id
+ }
+ >
+ <CheckIcon class="size-3.5 shrink-0 text-accent" />
+ </Show>
+ </Dropdown.Item>
+ )}
+ </For>
+ <Show when={macroCatalog.models().length === 0}>
+ <div role="status" class="px-3 py-2 text-xs text-ink-muted">
+ {macroCatalog.message()}
+ </div>
+ </Show>
+ </Dropdown.Group>
+ )}
+ </Show>
+ <Show when={props.loading}>
+ <div
+ role="status"
+ class="bg-menu px-3 py-2 text-xs text-ink-muted"
+ >
+ Loading agents…
+ </div>
+ </Show>
+ </div>
+ <Dropdown.Group class="shrink-0 border-t border-edge-muted">
+ <Dropdown.Item
+ closeOnSelect
+ onSelect={() => {
+ setOpen(false);
+ props.onCreate();
+ }}
+ >
+ <PlusIcon class="size-4" />
+ Create agent
+ </Dropdown.Item>
+ </Dropdown.Group>
+ </div>
+ </Dropdown.Content>
+ </Dropdown>
+ );
+}
+
+function AgentPickerRow(props: {
+ agent: RosterAgent;
+ selected: boolean;
+ modelOverride?: string;
+ onSelect: (model?: string) => void;
+ onConnect: () => void;
+}) {
+ const [open, setOpen] = createSignal(false);
+ const identity = () => (
+ <>
+ <AgentIcon agent={props.agent} class="size-5 shrink-0" />
+ <span class="min-w-0 flex-1 truncate">{props.agent.name}</span>
+ <Show when={props.agent.kind === 'coder'}>
+ <CodeIcon
+ class="size-3.5 shrink-0 text-ink-muted"
+ aria-label="Coding agent"
+ />
+ </Show>
+ <Show when={props.selected}>
+ <CheckIcon class="size-3.5 shrink-0 text-accent" />
+ </Show>
+ </>
+ );
+ return (
+ <div class="flex min-w-0 items-center gap-1">
+ <Show
+ when={!props.agent.unavailableReason}
+ fallback={
+ <Dropdown.Item
+ closeOnSelect
+ class="min-w-0 flex-1"
+ disabled={!props.agent.connectLabel}
+ onSelect={props.onConnect}
+ >
+ {identity()}
+ <span class="text-xs text-ink-muted">
+ {props.agent.connectLabel}
+ </span>
+ </Dropdown.Item>
+ }
+ >
+ <Dropdown.Sub open={open()} onOpenChange={setOpen}>
+ <Dropdown.SubTrigger
+ class="min-w-0 flex-1 gap-2"
+ textValue={props.agent.name}
+ onClick={() => props.onSelect()}
+ >
+ {identity()}
+ <CaretRightIcon class="size-3 shrink-0 text-ink-muted" />
+ </Dropdown.SubTrigger>
+ <Dropdown.SubContent
+ aria-label={`Models for ${props.agent.name}`}
+ class="w-72 max-w-[calc(100vw-1rem)] max-h-[min(28rem,var(--kb-popper-content-available-height))] overflow-y-auto overscroll-contain"
+ onPointerDown={(event: PointerEvent) => event.stopPropagation()}
+ onMouseDown={(event: MouseEvent) => event.stopPropagation()}
+ >
+ <Show when={open()}>
+ <AgentModels
+ agent={props.agent}
+ modelOverride={props.modelOverride}
+ onSelect={props.onSelect}
+ />
+ </Show>
+ </Dropdown.SubContent>
+ </Dropdown.Sub>
+ </Show>
+ </div>
+ );
+}
+
+function AgentModels(props: {
+ agent: RosterAgent;
+ modelOverride?: string;
+ onSelect: (model?: string) => void;
+}) {
+ const catalog = createComposerModels(() => props.agent);
+ const defaultModel = () => props.agent.defaultModel ?? catalog.currentModel();
+ return (
+ <ModelCatalogMenu
+ value={props.modelOverride ?? defaultModel() ?? null}
+ options={catalog.models().map((option) => ({
+ id: option.id,
+ label: modelLabel(option.id, option.name),
+ description: option.description ?? undefined,
+ group: option.group ?? undefined,
+ }))}
+ onSelect={props.onSelect}
+ emptyMessage={catalog.message()}
+ />
+ );
+}
diff --git a/apps/web/src/features/agents-view/views/AgentsView.tsx b/apps/web/src/features/agents-view/views/AgentsView.tsx
index 7ff7a67b31..8a068b358a 100644
--- a/apps/web/src/features/agents-view/views/AgentsView.tsx
+++ b/apps/web/src/features/agents-view/views/AgentsView.tsx
@@ -1,42 +1,72 @@
import { ViewShell } from '@app/components/view-shell';
-import { HomeChatInput } from '@app/features/home/home-chat-input';
+import { startPendingSession } from '@app/features/block-agent/context/pending-session';
import { QUERY_FILTERS_BASE } from '@app/features/next-soup/filters/query-filters';
-import { Agents } from '@app/features/settings/Agents';
-import { McpConnections } from '@app/features/settings/McpConnections';
import { useGlobalBlockOrchestrator } from '@components/app/GlobalAppState';
import { PreviewPanel } from '@components/app/PreviewPanel';
import { useSplitLayout } from '@components/app/split-layout/layout';
import { useSplitPanelOrThrow } from '@components/app/split-layout/layoutUtils';
import { SplitPanel } from '@components/app/split-panel';
-import { ChatInputProvider } from '@core/component/AI/context';
import { StaticMarkdownContext } from '@core/component/LexicalMarkdown/component/core/StaticMarkdown';
+import { toast } from '@core/component/Toast/Toast';
import { useUserId } from '@core/context/user';
import { ListEntityMetadataQueryProvider } from '@entity';
import SpinnerIcon from '@phosphor/spinner.svg';
+import {
+ type AgentWithHarnessId,
+ type CreateAgentParams,
+ useCreateAgentMutation,
+ useDeleteAgentMutation,
+ useUpdateAgentMutation,
+} from '@queries/agents/agents';
+import { useCursorApiKeyStatusQuery } from '@queries/auth/cursor-api-key';
+import {
+ useDeleteHarnessMutation,
+ useHarnessesQuery,
+} from '@queries/harnesses/harnesses';
import { useSoupItemsQuery } from '@queries/soup/items';
-import { createSignal, Match, onMount, Show, Suspense, Switch } from 'solid-js';
-import { AgentResourceList } from '../components/AgentResourceList';
+import { useCurrentTeamQuery } from '@queries/team/teams';
+import type { Harness } from '@service-storage/client';
+import {
+ createMemo,
+ createSignal,
+ Match,
+ onMount,
+ Show,
+ Suspense,
+ Switch,
+} from 'solid-js';
+import '../agents-view.css';
import { AgentSessionPane } from '../components/AgentSessionPane';
import { AgentsSidebar } from '../components/AgentsSidebar';
+import { ConfirmDialog } from '../components/SimpleDialogs';
+import { Topbar } from '../components/Topbar';
+import { DataModeProvider, dataModeFor } from '../context/data-mode';
+import { type AgentKind, modeForKind } from '../core/agent-kind';
+import type { AgentsMode } from '../core/mode';
import type { AgentsPage } from '../core/pages';
import {
+ type AgentConversationEntity,
type AgentConversationTarget,
+ conversationMode,
+ groupConversations,
selectRecentAgentConversations,
} from '../core/recent-conversations';
-
-const PAGE_TITLES: Record<AgentsPage, string> = {
- new: 'New Chat',
- routines: 'Routines',
- agents: 'Agents',
- connections: 'Connections',
- skills: 'Skills',
-};
+import { kindForBot } from '../core/roster';
+import { type AgentsRoute, agentsRouteId } from '../core/route';
+import { createAgentRosterSource } from '../queries/agent-roster-source';
+import { connectedRuntimes } from '../queries/connected-runtimes';
+import { AgentEditorDialog } from './AgentEditorDialog';
+import { NewChatPage, type StartConversation } from './NewChatPage';
+import { PairRuntimeDialog } from './PairRuntimeDialog';
+import { RosterPage } from './RosterPage';
type SelectedConversation = {
conversation: AgentConversationTarget;
activeConversationId: string;
};
+type EditorState = { agent?: AgentWithHarnessId; kind: AgentKind };
+
function LoadingComposer() {
return (
<div class="grid size-full place-items-center text-ink-muted">
@@ -48,16 +78,48 @@ function LoadingComposer() {
);
}
-function AgentsWorkspace() {
+function AgentsWorkspace(props: { initialRoute?: AgentsRoute }) {
const panel = useSplitPanelOrThrow();
const layout = useSplitLayout();
-
const orchestrator = useGlobalBlockOrchestrator();
const userId = useUserId();
-
+ const mode = (): AgentsMode => props.initialRoute?.mode ?? 'chat';
+ const dataMode = () => dataModeFor(mode());
const [page, setPage] = createSignal<AgentsPage>('new');
- const [selected, setSelected] = createSignal<SelectedConversation>();
+ const [rosterKind, setRosterKind] = createSignal<AgentKind>('agent');
+ const [selected, setSelected] = createSignal<
+ SelectedConversation | undefined
+ >(
+ props.initialRoute
+ ? {
+ conversation: props.initialRoute.conversation,
+ activeConversationId: props.initialRoute.conversation.id,
+ }
+ : undefined
+ );
const [search, setSearch] = createSignal('');
+ const [editor, setEditor] = createSignal<EditorState>();
+ const [deletingAgent, setDeletingAgent] = createSignal<AgentWithHarnessId>();
+ const [pairing, setPairing] = createSignal(false);
+ const [removingRuntime, setRemovingRuntime] = createSignal<Harness>();
+
+ const rosterSource = createAgentRosterSource();
+ const harnessesQuery = useHarnessesQuery();
+ const cursorStatus = useCursorApiKeyStatusQuery();
+ const currentTeamQuery = useCurrentTeamQuery();
+ const createAgent = useCreateAgentMutation();
+ const updateAgent = useUpdateAgentMutation();
+ const deleteAgent = useDeleteAgentMutation();
+ const deleteHarness = useDeleteHarnessMutation();
+ const cursorConnected = () =>
+ cursorStatus.isSuccess ? cursorStatus.data.registered : false;
+ const runtimes = () =>
+ connectedRuntimes(
+ cursorConnected(),
+ harnessesQuery.isSuccess ? harnessesQuery.data : []
+ );
+ const currentTeamId = () =>
+ currentTeamQuery.isSuccess ? currentTeamQuery.data?.team.id : undefined;
const query = useSoupItemsQuery(
() => {
@@ -76,176 +138,342 @@ function AgentsWorkspace() {
},
() => ({ enabled: Boolean(userId()) })
);
-
- const conversations = () =>
+ const conversations = createMemo(() =>
selectRecentAgentConversations(
query.isSuccess ? query.data : [],
userId(),
search()
+ )
+ );
+ const groups = createMemo(() => groupConversations(conversations()));
+ const modeForConversation = (conversation: AgentConversationEntity) =>
+ conversationMode(conversation, (botId) =>
+ kindForBot(botId, rosterSource.roster())
);
+ const handleForBot = (botId: string | undefined) =>
+ botId
+ ? rosterSource.roster().find((agent) => agent.botId === botId)?.handle
+ : undefined;
onMount(() => panel.handle.setDisplayName('Agents'));
- const navigate = (next: AgentsPage) => {
+ const showComposer = () => {
+ if (panel.handle.content().id !== 'agents') {
+ panel.handle.replace({ next: { type: 'component', id: 'agents' } });
+ return;
+ }
setSelected(undefined);
- setPage(next);
+ setPage('new');
+ };
+ const openRoster = (kind: AgentKind) => {
+ setSelected(undefined);
+ setRosterKind(kind);
+ setPage('agents');
};
-
const openConversation = (
conversation: AgentConversationTarget,
- event?: MouseEvent
+ event?: MouseEvent,
+ targetMode: AgentsMode = mode()
) => {
+ const next = {
+ type: 'component' as const,
+ id: agentsRouteId({ mode: targetMode, conversation }),
+ };
if (event?.shiftKey) {
- layout.openWithSplit(
- {
- type: conversation.type === 'agent_session' ? 'agent' : 'chat',
- id: conversation.id,
- },
- { preferNewSplit: true, referredFrom: 'agents' }
- );
+ layout.openWithSplit(next, {
+ preferNewSplit: true,
+ referredFrom: 'agents',
+ });
return;
}
-
- setPage('new');
- setSelected({
- conversation: { id: conversation.id, type: conversation.type },
- activeConversationId: conversation.id,
+ if (panel.handle.content().id === next.id) return;
+ panel.handle.replace({ next, referredFrom: 'agents' });
+ };
+ const startConversation = (start: StartConversation) => {
+ const id = startPendingSession({
+ botId: start.botId,
+ prompt: start.prompt,
+ modelOverride: start.modelOverride,
+ repoUrl: start.repoUrl,
});
+ openConversation(
+ { id, type: 'agent_session' },
+ undefined,
+ modeForKind(kindForBot(start.botId, rosterSource.roster()))
+ );
};
-
const adoptSessionId = (placeholderId: string, sessionId: string) => {
setSelected((current) => {
if (
current?.conversation.type !== 'agent_session' ||
- current.conversation.id !== placeholderId
+ current.conversation.id !== placeholderId ||
+ current.activeConversationId === sessionId ||
+ panel.handle.content().id !==
+ agentsRouteId({
+ mode: mode(),
+ conversation: current.conversation,
+ })
) {
return current;
}
+ panel.handle.adoptContentId({
+ type: 'component',
+ nextId: agentsRouteId({
+ mode: mode(),
+ conversation: { type: 'agent_session', id: sessionId },
+ }),
+ });
return { ...current, activeConversationId: sessionId };
});
};
+ const saveAgent = async (params: CreateAgentParams): Promise<boolean> => {
+ const current = editor();
+ try {
+ if (current?.agent) {
+ await updateAgent.mutateAsync({
+ ...params,
+ agentId: current.agent.bot.id,
+ ...(current.agent.bot.description
+ ? { description: current.agent.bot.description }
+ : {}),
+ });
+ toast.success('Agent updated');
+ } else {
+ await createAgent.mutateAsync(params);
+ toast.success('Agent created');
+ }
+ return true;
+ } catch {
+ toast.failure(
+ current?.agent ? 'Failed to update agent' : 'Failed to create agent'
+ );
+ return false;
+ }
+ };
+ const removeAgent = async () => {
+ const current = deletingAgent();
+ if (!current) return;
+ try {
+ await deleteAgent.mutateAsync({
+ agentId: current.bot.id,
+ channelIds: current.channel_ids,
+ });
+ setDeletingAgent(undefined);
+ setEditor(undefined);
+ toast.success('Agent deleted');
+ } catch {
+ toast.failure('Failed to delete agent');
+ }
+ };
+ const removeRuntime = async () => {
+ const current = removingRuntime();
+ if (!current) return;
+ try {
+ await deleteHarness.mutateAsync({ harnessId: current.id });
+ setRemovingRuntime(undefined);
+ toast.success('Runtime removed');
+ } catch {
+ toast.failure('Failed to remove runtime');
+ }
+ };
+
+ const pageTitle = () => {
+ if (page() === 'agents') return 'Agents';
+ return 'New conversation';
+ };
return (
<SplitPanel.Root>
<SplitPanel.Body>
- <ViewShell.Root
- asidePreferenceKey="agents"
- class="bg-panel"
- resizable
- aside={{
- width: 320,
- min: 224,
- max: 380,
- preserveDuringResize: false,
- }}
- breakpoints={{ collapsed: 0 }}
- layoutBreakpoint="collapsed"
- main={{ min: 280, preferredWidth: 640 }}
- >
- <ViewShell.Aside>
- <AgentsSidebar
- page={page()}
- activeConversationId={selected()?.activeConversationId}
- search={search()}
- conversations={conversations()}
- loading={query.isPending}
- error={query.isLoadingError}
- hasNextPage={Boolean(query.hasNextPage)}
- loadingNextPage={query.isFetchingNextPage}
- loadMoreError={query.isFetchNextPageError}
- onNavigate={navigate}
- onSearchChange={setSearch}
- onOpenConversation={openConversation}
- onRetry={() => void query.refetch()}
- onLoadMore={() => void query.fetchNextPage()}
- />
- </ViewShell.Aside>
+ <DataModeProvider value={dataMode}>
+ <div
+ class="agents-view"
+ data-mode={dataMode()}
+ data-session={selected() ? '1' : undefined}
+ >
+ <ViewShell.Root
+ asidePreferenceKey="agents"
+ resizable
+ aside={{
+ width: 280,
+ min: 224,
+ max: 380,
+ preserveDuringResize: false,
+ }}
+ breakpoints={{ collapsed: 0 }}
+ layoutBreakpoint="collapsed"
+ main={{ min: 280, preferredWidth: 640 }}
+ >
+ <ViewShell.Aside>
+ <AgentsSidebar
+ modeForConversation={modeForConversation}
+ activeConversationId={selected()?.activeConversationId}
+ search={search()}
+ groups={groups()}
+ loading={query.isPending}
+ error={query.isLoadingError}
+ hasNextPage={Boolean(query.hasNextPage)}
+ loadingNextPage={query.isFetchingNextPage}
+ handleForBot={handleForBot}
+ onNewConversation={showComposer}
+ onSearchChange={setSearch}
+ onOpenConversation={(conversation, event) =>
+ openConversation(
+ conversation,
+ event,
+ modeForConversation(conversation)
+ )
+ }
+ onRetry={() => void query.refetch()}
+ onLoadMore={() => void query.fetchNextPage()}
+ />
+ </ViewShell.Aside>
- <ViewShell.Main class="overflow-hidden">
- <Show
- when={selected()?.conversation}
- keyed
- fallback={
- <>
- <ViewShell.TopBar>
- <h1 class="min-w-0 truncate text-sm font-semibold tracking-[-0.03em] text-ink">
- {PAGE_TITLES[page()]}
- </h1>
- </ViewShell.TopBar>
- <div class="min-h-0 flex-1">
- <Suspense fallback={<LoadingComposer />}>
- <Switch>
- <Match when={page() === 'new'}>
- {/* The home composer, at home's width, so the box
- matches the chat that opens once you send. */}
- <div class="flex size-full items-center justify-center px-4 pb-16">
- <div class="w-full max-w-3xl">
- <ChatInputProvider>
- <HomeChatInput
- openChat={(id) =>
- openConversation({ id, type: 'chat' })
+ <ViewShell.Main class="overflow-hidden">
+ <main class="main">
+ <Show
+ when={selected()?.conversation}
+ keyed
+ fallback={
+ <>
+ <Topbar title={pageTitle()} />
+ <div class="body">
+ <Suspense fallback={<LoadingComposer />}>
+ <Switch>
+ <Match when={page() === 'agents'}>
+ <RosterPage
+ kind={rosterKind()}
+ onKindChange={setRosterKind}
+ onClose={showComposer}
+ onCreate={(kind) => setEditor({ kind })}
+ onEdit={(agent) =>
+ setEditor({
+ agent,
+ kind:
+ agent.harness === 'in-memory'
+ ? 'agent'
+ : 'coder',
+ })
}
+ onDelete={setDeletingAgent}
+ onPairRuntime={() => setPairing(true)}
+ onRemoveRuntime={setRemovingRuntime}
/>
- </ChatInputProvider>
- </div>
- </div>
- </Match>
- <Match when={page() === 'routines'}>
- <AgentResourceList page="routines" />
- </Match>
- <Match when={page() === 'agents'}>
- <Agents />
- </Match>
- <Match when={page() === 'connections'}>
- <McpConnections />
+ </Match>
+ <Match when={true}>
+ <NewChatPage
+ roster={rosterSource.roster()}
+ rosterLoading={rosterSource.loading()}
+ onStart={startConversation}
+ onOpenRoster={openRoster}
+ />
+ </Match>
+ </Switch>
+ </Suspense>
+ </div>
+ </>
+ }
+ >
+ {(conversation) => (
+ <Switch>
+ <Match when={conversation.type === 'agent_session'}>
+ <Suspense fallback={<LoadingComposer />}>
+ <AgentSessionPane
+ id={conversation.id}
+ mode={mode()}
+ roster={rosterSource.roster()}
+ onSessionId={(sessionId) =>
+ adoptSessionId(conversation.id, sessionId)
+ }
+ onDeleted={showComposer}
+ />
+ </Suspense>
</Match>
- <Match when={page() === 'skills'}>
- <AgentResourceList page="skills" />
+ <Match when={true}>
+ <Topbar title="Chat" />
+ <div class="body">
+ <Suspense fallback={<LoadingComposer />}>
+ <PreviewPanel
+ selectedEntity={conversation}
+ orchestrator={orchestrator}
+ splitPanelContext={panel}
+ />
+ </Suspense>
+ </div>
</Match>
</Switch>
- </Suspense>
- </div>
- </>
- }
- >
- {(conversation) => (
- <Switch>
- <Match when={conversation.type === 'agent_session'}>
- <Suspense>
- <AgentSessionPane
- id={conversation.id}
- onSessionId={(sessionId) =>
- adoptSessionId(conversation.id, sessionId)
- }
- />
- </Suspense>
- </Match>
- <Match when={true}>
- <Suspense>
- <PreviewPanel
- selectedEntity={conversation}
- orchestrator={orchestrator}
- splitPanelContext={panel}
- />
- </Suspense>
- </Match>
- </Switch>
- )}
- </Show>
- </ViewShell.Main>
- </ViewShell.Root>
+ )}
+ </Show>
+ </main>
+ </ViewShell.Main>
+ </ViewShell.Root>
+ </div>
+
+ <Show when={editor()} keyed>
+ {(state) => (
+ <AgentEditorDialog
+ agent={state.agent}
+ initialKind={state.kind}
+ runtimes={runtimes()}
+ currentTeamId={currentTeamId()}
+ canShareWithTeam={currentTeamId() !== undefined}
+ canMakePrivate={
+ state.agent?.bot.owner?.type !== 'team' ||
+ state.agent.bot.created_by === userId()
+ }
+ pending={createAgent.isPending || updateAgent.isPending}
+ onClose={() => setEditor(undefined)}
+ onSave={saveAgent}
+ onDelete={
+ state.agent ? () => setDeletingAgent(state.agent) : undefined
+ }
+ />
+ )}
+ </Show>
+ <Show when={deletingAgent()} keyed>
+ {(agent) => (
+ <ConfirmDialog
+ title={`Delete ${agent.bot.name}?`}
+ body="This removes the agent from every channel and permanently deletes its configuration. This action cannot be undone."
+ confirmLabel="Delete agent"
+ pendingLabel="Deleting…"
+ danger
+ pending={deleteAgent.isPending}
+ onConfirm={() => void removeAgent()}
+ onClose={() => setDeletingAgent(undefined)}
+ />
+ )}
+ </Show>
+ <Show when={pairing()}>
+ <PairRuntimeDialog onClose={() => setPairing(false)} />
+ </Show>
+ <Show when={removingRuntime()} keyed>
+ {(harness) => (
+ <ConfirmDialog
+ title={`Remove ${harness.name}?`}
+ body="Agents using this runtime will stop running until it is reconnected. macrod on that machine will need to pair again."
+ confirmLabel="Remove runtime"
+ pendingLabel="Removing…"
+ danger
+ pending={deleteHarness.isPending}
+ onConfirm={() => void removeRuntime()}
+ onClose={() => setRemovingRuntime(undefined)}
+ />
+ )}
+ </Show>
+ </DataModeProvider>
</SplitPanel.Body>
</SplitPanel.Root>
);
}
/** Dedicated Agents workspace used by the new app views layout. */
-export function AgentsView() {
+export function AgentsView(props: { initialRoute?: AgentsRoute }) {
return (
<ListEntityMetadataQueryProvider>
<StaticMarkdownContext>
<Suspense fallback={<LoadingComposer />}>
- <AgentsWorkspace />
+ <AgentsWorkspace initialRoute={props.initialRoute} />
</Suspense>
</StaticMarkdownContext>
</ListEntityMetadataQueryProvider>
diff --git a/apps/web/src/features/agents-view/views/NewChatPage.test.tsx b/apps/web/src/features/agents-view/views/NewChatPage.test.tsx
new file mode 100644
index 0000000000..6247faad82
--- /dev/null
+++ b/apps/web/src/features/agents-view/views/NewChatPage.test.tsx
@@ -0,0 +1,355 @@
+import { CURSOR_BOT_ID } from '@core/constant/cursorAgent';
+import { MACRO_CODER_BOT_ID } from '@core/constant/macroCoder';
+import {
+ cleanup,
+ fireEvent,
+ render,
+ screen,
+ waitFor,
+ within,
+} from '@solidjs/testing-library';
+import type { JSX } from 'solid-js';
+import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
+import { buildAgentRoster, type PersistedAgentLike } from '../core/roster';
+import { NewChatPage } from './NewChatPage';
+
+const mocks = vi.hoisted(() => ({
+ openSettings: vi.fn(),
+ recentIds: [] as string[],
+}));
+vi.mock('@core/context/user', () => ({ useUserId: () => () => 'user' }));
+vi.mock('@core/constant/SettingsState', () => ({
+ useSettingsState: () => ({ openSettings: mocks.openSettings }),
+}));
+vi.mock('@app/features/block-agent/context/recent-agent-selections', () => ({
+ createRecentAgentSelections: () => ({
+ ids: () => mocks.recentIds,
+ remember: vi.fn(),
+ }),
+}));
+vi.mock('../primitives/recent-repositories', () => ({
+ createRecentRepositories: () => ({ urls: () => [], remember: vi.fn() }),
+}));
+vi.mock('../components/AgentGlyph', () => ({ AgentIcon: () => <span /> }));
+
+vi.mock('@queries/agents/models', () => ({
+ useAgentModelsQueries: (targets: () => { harness: string }[]) => [
+ {
+ get isSuccess() {
+ return targets().length > 0;
+ },
+ get data() {
+ const harness = targets()[0]?.harness;
+ return {
+ status: 'available',
+ currentModel:
+ harness === 'cursor' ? 'cursor-default' : 'chat-default',
+ models:
+ harness === 'cursor'
+ ? [
+ { id: 'cursor-default', name: 'Cursor default' },
+ { id: 'gpt-5', name: 'GPT-5' },
+ ]
+ : [
+ { id: 'chat-default', name: 'Chat default' },
+ { id: 'claude-sonnet-4', name: 'Sonnet 4' },
+ {
+ id: 'anthropic/claude-sonnet-5',
+ name: 'anthropic/claude-sonnet-5',
+ },
+ ],
+ };
+ },
+ },
+ ],
+}));
+
+// Keep the real picker and send wiring; substitute only the Lexical editor.
+type ComposerProps = {
+ selector: JSX.Element;
+ drawer: JSX.Element;
+ drawerOpen: boolean;
+ draft: string;
+ onDraftChange: (draft: string) => void;
+ onSend: (prompt: string) => void;
+};
+vi.mock('../components/ChatComposer', () => ({
+ ChatComposer: (props: ComposerProps) => (
+ <>
+ {props.selector}
+ <div data-testid="drawer" hidden={!props.drawerOpen}>
+ {props.drawer}
+ </div>
+ <input
+ aria-label="Draft"
+ value={props.draft}
+ onInput={(event) => props.onDraftChange(event.currentTarget.value)}
+ />
+ <button onClick={() => props.onSend(props.draft || 'Prompt')}>
+ Send
+ </button>
+ </>
+ ),
+}));
+
+function page(connected = true, agents: PersistedAgentLike[] = []) {
+ const onStart = vi.fn();
+ render(() => (
+ <NewChatPage
+ roster={buildAgentRoster({
+ agents,
+ runtimes: [],
+ cursorConnected: connected,
+ cursorNeedsConnection: !connected,
+ macroDefaultModel: 'chat-default',
+ cursorDefaultModel: 'cursor-default',
+ })}
+ rosterLoading={false}
+ onStart={onStart}
+ onOpenRoster={vi.fn()}
+ />
+ ));
+ return onStart;
+}
+function openAgents() {
+ const trigger = screen.getByRole('button', { name: 'Agent' });
+ fireEvent.keyDown(trigger, { key: 'Enter' });
+ return trigger;
+}
+async function selectAgent(name: RegExp) {
+ const trigger = openAgents();
+ const item = screen.getByRole('menuitem', { name });
+ if (item.hasAttribute('aria-haspopup')) fireEvent.click(item);
+ else fireEvent.keyDown(item, { key: 'Enter' });
+ await waitFor(() =>
+ expect(trigger.getAttribute('aria-expanded')).toBe('false')
+ );
+}
+async function hoverAgent(name: string) {
+ openAgents();
+ const event = new MouseEvent('pointermove', { bubbles: true });
+ Object.defineProperty(event, 'pointerType', { value: 'mouse' });
+ screen
+ .getByRole('menuitem', { name: new RegExp(`^${name}`) })
+ .dispatchEvent(event);
+ const search = await screen.findByRole('textbox', { name: 'Search models' });
+ return within(search.closest('[role="menu"]') as HTMLElement);
+}
+
+describe('agent-led new conversation', () => {
+ let motionStyles: HTMLStyleElement;
+ beforeEach(() => {
+ mocks.recentIds = [MACRO_CODER_BOT_ID];
+ vi.clearAllMocks();
+ motionStyles = document.createElement('style');
+ motionStyles.textContent =
+ '[role="menu"] { animation-name: none; transition-duration: 0s; }';
+ document.head.append(motionStyles);
+ vi.stubGlobal('scrollTo', vi.fn());
+ });
+ afterEach(() => {
+ cleanup();
+ motionStyles.remove();
+ vi.unstubAllGlobals();
+ });
+ it('offers both kinds without a mode or model control and starts with the agent default', async () => {
+ const send = page();
+ expect(
+ screen.getByRole('heading', { name: 'What should we work on?' })
+ ).toBeTruthy();
+ expect(screen.queryByRole('button', { name: 'Model' })).toBeNull();
+ expect(
+ screen.queryByRole('button', { name: /^(Chat|Code) mode$/ })
+ ).toBeNull();
+ openAgents();
+ expect(screen.queryByRole('menuitem', { name: /Macro/ })).toBeNull();
+ expect(screen.getByRole('menuitem', { name: /Cursor/ })).toBeTruthy();
+ expect(screen.queryByText('Macro Coding Agent')).toBeNull();
+ fireEvent.keyDown(document, { key: 'Escape' });
+ await waitFor(() => expect(screen.queryByRole('menu')).toBeNull());
+ fireEvent.click(screen.getByRole('button', { name: 'Send' }));
+ expect(send).toHaveBeenCalledWith({
+ prompt: 'Prompt',
+ botId: undefined,
+ repoUrl: undefined,
+ });
+ });
+ it('selects a coding agent, keeps the draft, and only sends the repository to coding agents', async () => {
+ const send = page();
+ fireEvent.input(screen.getByRole('textbox', { name: 'Draft' }), {
+ target: { value: 'Shared draft' },
+ });
+ await selectAgent(/Cursor/);
+ expect(
+ screen.getByRole('heading', { name: 'What should we build?' })
+ ).toBeTruthy();
+ expect(screen.getByTestId('drawer').hasAttribute('hidden')).toBe(false);
+ fireEvent.click(screen.getByRole('button', { name: /Add repository/ }));
+ fireEvent.input(screen.getByRole('textbox', { name: 'Add repository' }), {
+ target: { value: 'macro-inc/macro' },
+ });
+ fireEvent.keyDown(screen.getByRole('textbox', { name: 'Add repository' }), {
+ key: 'Enter',
+ });
+ await selectAgent(/^Chat default$/);
+ expect(screen.getByTestId('drawer').hasAttribute('hidden')).toBe(true);
+ expect(
+ (screen.getByRole('textbox', { name: 'Draft' }) as HTMLInputElement).value
+ ).toBe('Shared draft');
+ fireEvent.click(screen.getByRole('button', { name: 'Send' }));
+ expect(send).toHaveBeenLastCalledWith({
+ prompt: 'Shared draft',
+ botId: undefined,
+ repoUrl: undefined,
+ modelOverride: 'chat-default',
+ });
+ await selectAgent(/Cursor/);
+ expect(
+ screen.getByRole('button', { name: /macro-inc\/macro/ })
+ ).toBeTruthy();
+ fireEvent.click(screen.getByRole('button', { name: 'Send' }));
+ expect(send).toHaveBeenLastCalledWith({
+ botId: CURSOR_BOT_ID,
+ prompt: 'Shared draft',
+ repoUrl: 'https://github.com/macro-inc/macro',
+ });
+ });
+ it('uses a saved agent without sending a per-session model override', async () => {
+ const send = page(true, [
+ {
+ bot: { id: 'saved-agent', name: 'Reviewer', handle: 'reviewer' },
+ harness: 'in-memory',
+ default_model: 'saved-default',
+ },
+ ]);
+ await selectAgent(/Reviewer/);
+ fireEvent.click(screen.getByRole('button', { name: 'Send' }));
+ expect(send).toHaveBeenCalledWith({
+ prompt: 'Prompt',
+ botId: 'saved-agent',
+ repoUrl: undefined,
+ });
+ expect(send.mock.calls[0][0]).not.toHaveProperty('modelOverride');
+ });
+ it('shows the model beside the agent and sends a hovered model choice only once', async () => {
+ const send = page();
+ expect(screen.getByRole('button', { name: 'Agent' }).textContent).toContain(
+ 'Chat default'
+ );
+ await hoverAgent('Cursor');
+ expect(screen.queryByText('Use agent default')).toBeNull();
+ expect(
+ screen
+ .getByRole('menuitem', { name: /Cursor default/ })
+ .querySelector('.text-accent')
+ ).toBeTruthy();
+ const model = screen.getByRole('menuitem', { name: /GPT-5/ });
+ expect(model.querySelector('.text-accent')).toBeNull();
+ expect(model.querySelector('[data-ai-provider="openai"] svg')).toBeTruthy();
+ fireEvent.keyDown(model, { key: 'Enter' });
+ await waitFor(() => expect(screen.queryByRole('menu')).toBeNull());
+ expect(screen.getByRole('button', { name: 'Agent' }).textContent).toContain(
+ 'GPT-5'
+ );
+ expect(screen.getByTestId('drawer').hasAttribute('hidden')).toBe(false);
+ openAgents();
+ fireEvent.keyDown(screen.getByRole('menuitem', { name: /^Cursor/ }), {
+ key: 'ArrowRight',
+ });
+ await screen.findByRole('textbox', { name: 'Search models' });
+ expect(
+ screen
+ .getByRole('menuitem', { name: /GPT-5/ })
+ .querySelector('.text-accent')
+ ).toBeTruthy();
+ expect(
+ screen
+ .getByRole('menuitem', { name: /Cursor default/ })
+ .querySelector('.text-accent')
+ ).toBeNull();
+ fireEvent.keyDown(document, { key: 'Escape' });
+ fireEvent.keyDown(document, { key: 'Escape' });
+ await waitFor(() => expect(screen.queryByRole('menu')).toBeNull());
+ fireEvent.click(screen.getByRole('button', { name: 'Send' }));
+ expect(send).toHaveBeenLastCalledWith({
+ prompt: 'Prompt',
+ botId: CURSOR_BOT_ID,
+ repoUrl: undefined,
+ modelOverride: 'gpt-5',
+ });
+ expect(screen.getByRole('button', { name: 'Agent' }).textContent).toContain(
+ 'Cursor default'
+ );
+ fireEvent.click(screen.getByRole('button', { name: 'Send' }));
+ expect(send.mock.calls[1][0]).not.toHaveProperty('modelOverride');
+ });
+ it('clears a temporary model choice when selecting another agent', async () => {
+ page();
+ openAgents();
+ fireEvent.keyDown(screen.getByRole('menuitem', { name: /Sonnet 4/ }), {
+ key: 'Enter',
+ });
+ await waitFor(() => expect(screen.queryByRole('menu')).toBeNull());
+ expect(screen.getByRole('button', { name: 'Agent' }).textContent).toContain(
+ 'Sonnet 4'
+ );
+ await selectAgent(/Cursor/);
+ expect(screen.getByRole('button', { name: 'Agent' }).textContent).toContain(
+ 'Cursor default'
+ );
+ });
+ it('groups by kind and selects direct models through Macro with readable names and icons', async () => {
+ const send = page();
+ await selectAgent(/Cursor/);
+ openAgents();
+ const coding = within(screen.getByRole('group', { name: 'Coding agents' }));
+ expect(screen.queryByRole('group', { name: 'Agents' })).toBeNull();
+ const models = within(screen.getByRole('group', { name: 'Models' }));
+ expect(coding.getByRole('menuitem', { name: /Cursor/ })).toBeTruthy();
+ expect(coding.queryByRole('menuitem', { name: /Macro/ })).toBeNull();
+ expect(screen.queryByRole('menuitem', { name: /Macro/ })).toBeNull();
+ expect(
+ models.queryByRole('menuitem', { name: /Cursor default|GPT-5/ })
+ ).toBeNull();
+ const sonnet = models.getByRole('menuitem', { name: 'Sonnet 5' });
+ expect(
+ sonnet.querySelector('[data-ai-provider="anthropic"] svg')
+ ).toBeTruthy();
+ expect(screen.queryByText('anthropic/claude-sonnet-5')).toBeNull();
+ fireEvent.keyDown(sonnet, { key: 'Enter' });
+ await waitFor(() => expect(screen.queryByRole('menu')).toBeNull());
+ expect(screen.getByRole('button', { name: 'Agent' }).textContent).toBe(
+ 'Sonnet 5'
+ );
+ const trigger = screen.getByRole('button', { name: 'Agent' });
+ expect(trigger.title).toBe('Sonnet 5');
+ expect(
+ trigger.querySelector('[data-ai-provider="anthropic"] svg')
+ ).toBeTruthy();
+ expect(screen.getByTestId('drawer').hasAttribute('hidden')).toBe(true);
+ fireEvent.click(screen.getByRole('button', { name: 'Send' }));
+ expect(send).toHaveBeenLastCalledWith({
+ prompt: 'Prompt',
+ botId: undefined,
+ repoUrl: undefined,
+ modelOverride: 'anthropic/claude-sonnet-5',
+ });
+ });
+ it('restores the most recently used supported agent', async () => {
+ mocks.recentIds = [CURSOR_BOT_ID];
+ page();
+ expect(screen.getByRole('button', { name: 'Agent' }).textContent).toContain(
+ 'Cursor'
+ );
+ expect(screen.getByTestId('drawer').hasAttribute('hidden')).toBe(false);
+ });
+ it('offers Cursor setup when disconnected without switching to an unavailable agent', async () => {
+ page(false);
+ await selectAgent(/Cursor/);
+ expect(mocks.openSettings).toHaveBeenCalledWith('Harness');
+ expect(screen.getByRole('button', { name: 'Agent' }).textContent).toContain(
+ 'Chat default'
+ );
+ expect(screen.getByTestId('drawer').hasAttribute('hidden')).toBe(true);
+ });
+});
diff --git a/apps/web/src/features/agents-view/views/NewChatPage.tsx b/apps/web/src/features/agents-view/views/NewChatPage.tsx
new file mode 100644
index 0000000000..90056fbcd9
--- /dev/null
+++ b/apps/web/src/features/agents-view/views/NewChatPage.tsx
@@ -0,0 +1,215 @@
+import { createRecentAgentSelections } from '@app/features/block-agent/context/recent-agent-selections';
+import { useSettingsState } from '@core/constant/SettingsState';
+import { useUserId } from '@core/context/user';
+import CaretDownIcon from '@phosphor/caret-down.svg';
+import GithubIcon from '@phosphor/github-logo.svg';
+import PlusIcon from '@phosphor/plus.svg';
+import XIcon from '@phosphor/x.svg';
+import { createMemo, createSignal, For, Show } from 'solid-js';
+import { ChatComposer } from '../components/ChatComposer';
+import { MenuAnchor, MenuGroup, MenuOption } from '../components/Menu';
+import type { AgentKind } from '../core/agent-kind';
+import { parseRepositoryInput, repositoryLabel } from '../core/repository';
+import {
+ MACRO_PERSONA_ID,
+ type RosterAgent,
+ rosterForComposer,
+} from '../core/roster';
+import { createRecentRepositories } from '../primitives/recent-repositories';
+import { AgentPicker } from './AgentPicker';
+
+/** What the composer hands the workspace to start a session with. */
+export type StartConversation = {
+ prompt: string;
+ /** Persisted or first-party bot to run; omitted for Macro's default. */
+ botId?: string;
+ repoUrl?: string;
+ modelOverride?: string;
+};
+
+/** One agent choice determines the session kind, default model, and repository context. */
+export function NewChatPage(props: {
+ roster: RosterAgent[];
+ rosterLoading: boolean;
+ onStart: (start: StartConversation) => void;
+ /** Opens the roster page on the given kind's tab. */
+ onOpenRoster: (kind: AgentKind) => void;
+}) {
+ const userId = useUserId();
+ const { openSettings } = useSettingsState();
+ const recentAgents = createRecentAgentSelections(userId());
+ const repositories = createRecentRepositories(userId());
+ const options = createMemo(() => rosterForComposer(props.roster));
+ const [agentId, setAgentId] = createSignal<string>();
+ const [modelOverride, setModelOverride] = createSignal<string>();
+ const [repoUrl, setRepoUrl] = createSignal<string | undefined>(
+ repositories.urls()[0]
+ );
+ const [draft, setDraft] = createSignal('');
+ const [repoInput, setRepoInput] = createSignal('');
+ const selected = createMemo(() => {
+ const wanted =
+ agentId() ??
+ recentAgents
+ .ids()
+ .find((id) =>
+ options().some((agent) => agent.id === id && !agent.unavailableReason)
+ ) ??
+ MACRO_PERSONA_ID;
+ return options().find((agent) => agent.id === wanted) ?? options()[0];
+ });
+ const coding = () => selected()?.kind === 'coder';
+ const blocked = () => {
+ const agent = selected();
+ return agent ? agent.unavailableReason : 'Choose an agent to start';
+ };
+
+ const connect = (agent: RosterAgent) => {
+ if (agent.harness === 'cursor') openSettings('Harness');
+ };
+
+ const send = (prompt: string) => {
+ const persona = selected();
+ if (!prompt.trim() || !persona || blocked()) return;
+ recentAgents.remember(persona.id);
+ const repo = coding() ? repoUrl() : undefined;
+ if (repo) repositories.remember(repo);
+ props.onStart({
+ prompt,
+ botId: persona.botId,
+ repoUrl: repo,
+ ...(modelOverride() ? { modelOverride: modelOverride() } : {}),
+ });
+ setModelOverride(undefined);
+ };
+
+ const addRepository = () => {
+ const url = parseRepositoryInput(repoInput());
+ if (!url) return;
+ repositories.remember(url);
+ setRepoUrl(url);
+ setRepoInput('');
+ };
+
+ const agentSelector = () => (
+ <AgentPicker
+ agents={options()}
+ selected={selected()}
+ modelOverride={modelOverride()}
+ loading={props.rosterLoading}
+ onSelect={(agent, model) => {
+ setAgentId(agent.id);
+ setModelOverride(model);
+ }}
+ onConnect={connect}
+ onCreate={() => props.onOpenRoster(coding() ? 'coder' : 'agent')}
+ />
+ );
+
+ const repositorySelector = () => (
+ <MenuAnchor
+ menuLabel="Repository"
+ trigger={(menu) => (
+ <button
+ type="button"
+ class={repoUrl() ? 'pill' : 'pill empty'}
+ aria-haspopup="listbox"
+ aria-expanded={menu.open()}
+ title="Repository (optional)"
+ onClick={(event) => {
+ event.stopPropagation();
+ menu.toggle();
+ }}
+ >
+ <span class="logo">
+ <GithubIcon class="ph" style={{ width: '16px', height: '16px' }} />
+ </span>
+ <span class="lbl truncate">
+ <Show when={repoUrl()} fallback="Add repository">
+ {(url) => (
+ <span class="mono" style={{ 'font-size': '12px' }}>
+ {repositoryLabel(url())}
+ </span>
+ )}
+ </Show>
+ </span>
+ <CaretDownIcon class="ph caret" />
+ </button>
+ )}
+ >
+ {(close) => (
+ <>
+ <div class="filter">
+ <PlusIcon class="ph" />
+ <input
+ placeholder="Add owner/repo or a URL"
+ aria-label="Add repository"
+ value={repoInput()}
+ onInput={(event) => setRepoInput(event.currentTarget.value)}
+ onKeyDown={(event) => {
+ if (event.key !== 'Enter') return;
+ event.preventDefault();
+ addRepository();
+ close();
+ }}
+ />
+ </div>
+ <MenuOption
+ checked={!repoUrl()}
+ onSelect={() => {
+ setRepoUrl(undefined);
+ close();
+ }}
+ >
+ <XIcon class="ph" />
+ <span class="nm">No repository</span>
+ <span class="sub">workspace only</span>
+ </MenuOption>
+ <Show when={repositories.urls().length > 0}>
+ <MenuGroup>Recent</MenuGroup>
+ <For each={repositories.urls()}>
+ {(url) => (
+ <MenuOption
+ checked={repoUrl() === url}
+ onSelect={() => {
+ setRepoUrl(url);
+ close();
+ }}
+ >
+ <GithubIcon class="ph" />
+ <span class="nm">{repositoryLabel(url)}</span>
+ </MenuOption>
+ )}
+ </For>
+ </Show>
+ <div class="foot">
+ <span>Optional · repository for this session</span>
+ <span>{repositories.urls().length} repos</span>
+ </div>
+ </>
+ )}
+ </MenuAnchor>
+ );
+
+ return (
+ <section class="page newchat" data-active aria-label="New conversation">
+ <div class="col">
+ <div class="greeting">
+ <h2>
+ {coding() ? 'What should we build?' : 'What should we work on?'}
+ </h2>
+ </div>
+ <ChatComposer
+ draft={draft()}
+ onDraftChange={setDraft}
+ blockedReason={blocked()}
+ selector={agentSelector()}
+ drawer={repositorySelector()}
+ drawerOpen={coding()}
+ placeholder={coding() ? 'Describe what you want to build' : undefined}
+ onSend={send}
+ />
+ </div>
+ </section>
+ );
+}
diff --git a/apps/web/src/features/agents-view/views/PairRuntimeDialog.tsx b/apps/web/src/features/agents-view/views/PairRuntimeDialog.tsx
new file mode 100644
index 0000000000..6083de65e9
--- /dev/null
+++ b/apps/web/src/features/agents-view/views/PairRuntimeDialog.tsx
@@ -0,0 +1,219 @@
+import { toast } from '@core/component/Toast/Toast';
+import { ThrownResultError } from '@core/util/result';
+import PlugsIcon from '@phosphor/plugs.svg';
+import XIcon from '@phosphor/x.svg';
+import {
+ useApproveHarnessPairingMutation,
+ useHarnessPairingQuery,
+} from '@queries/harnesses/harnesses';
+import { useCurrentTeamQuery } from '@queries/team/teams';
+import { createSignal, Show } from 'solid-js';
+import { ArtifactDialog } from '../components/ArtifactDialog';
+import { Segmented } from '../components/Segmented';
+
+const PAIRING_ERROR =
+ 'This pairing code is invalid, expired, or already claimed.';
+
+function failureMessage(error: unknown, fallback: string): string {
+ return (error instanceof ThrownResultError && error.message) || fallback;
+}
+
+/** `kx7m4qhd` → `KX7M-4QHD`, at most eight characters. */
+function formatCode(raw: string): string {
+ const chars = raw
+ .toUpperCase()
+ .replace(/[^A-Z0-9]/g, '')
+ .slice(0, 8);
+ return chars.length > 4 ? `${chars.slice(0, 4)}-${chars.slice(4)}` : chars;
+}
+
+function expiresIn(expiresAt: string): string {
+ const minutes = Math.max(
+ 0,
+ Math.round((new Date(expiresAt).getTime() - Date.now()) / 60_000)
+ );
+ return minutes === 1 ? 'in 1 minute' : `in ${minutes} minutes`;
+}
+
+/**
+ * Approves a macrod pairing request: the code the daemon printed, a name for
+ * the runtime, and who may run agents on it.
+ */
+export function PairRuntimeDialog(props: { onClose: () => void }) {
+ const [code, setCode] = createSignal('');
+ const [name, setName] = createSignal('');
+ const [nameEdited, setNameEdited] = createSignal(false);
+ const [share, setShare] = createSignal<'private' | 'team'>('private');
+ const [error, setError] = createSignal<string>();
+ const complete = () => code().length === 9;
+ const pairingQuery = useHarnessPairingQuery(() =>
+ complete() ? code() : undefined
+ );
+ const approve = useApproveHarnessPairingMutation();
+ const currentTeamQuery = useCurrentTeamQuery();
+ const teamId = () =>
+ currentTeamQuery.isSuccess ? currentTeamQuery.data?.team.id : undefined;
+ const pairing = () =>
+ pairingQuery.isSuccess ? pairingQuery.data : undefined;
+ const lookupError = () =>
+ complete() && pairingQuery.isError
+ ? failureMessage(pairingQuery.error, PAIRING_ERROR)
+ : undefined;
+ const requestedName = () => {
+ const details = pairing();
+ return details && !nameEdited() ? details.requested_name : name();
+ };
+ const canApprove = () =>
+ !!pairing() &&
+ requestedName().trim().length > 0 &&
+ !approve.isPending &&
+ (share() === 'private' || teamId() !== undefined);
+
+ const submit = async () => {
+ const details = pairing();
+ if (!details || !canApprove()) return;
+ setError(undefined);
+ try {
+ await approve.mutateAsync({
+ code: details.code,
+ name: requestedName().trim(),
+ teamId: share() === 'team' ? teamId() : undefined,
+ });
+ toast.success('Runtime paired');
+ props.onClose();
+ } catch (cause) {
+ setError(failureMessage(cause, PAIRING_ERROR));
+ }
+ };
+
+ return (
+ <ArtifactDialog
+ class="narrow"
+ label="Pair a runtime"
+ onClose={props.onClose}
+ >
+ <div class="dh">
+ <span class="t">
+ <PlugsIcon class="ph" />
+ Pair a runtime
+ </span>
+ <button type="button" class="icon-btn" aria-label="Close" data-close>
+ <XIcon class="ph" />
+ </button>
+ </div>
+ <div class="db" style={{ gap: '16px' }}>
+ <p
+ style={{
+ margin: 0,
+ 'font-size': '13.5px',
+ color: 'var(--ink-muted)',
+ 'line-height': 1.5,
+ }}
+ >
+ On the machine running your agent, start{' '}
+ <code
+ class="mono"
+ style={{
+ background: 'var(--surface-3)',
+ padding: '1px 5px',
+ 'border-radius': '4px',
+ color: 'var(--ink)',
+ }}
+ >
+ macrod
+ </code>{' '}
+ and press <code class="mono">p</code> to pair. It prints an
+ 8-character code that is valid for 15 minutes. Enter it here to
+ approve the pairing.
+ </p>
+ <div class="paircode">
+ <input
+ placeholder="XXXX-XXXX"
+ maxlength={9}
+ autocomplete="off"
+ spellcheck={false}
+ aria-label="Pairing code"
+ value={code()}
+ onInput={(event) => {
+ setError(undefined);
+ setCode(formatCode(event.currentTarget.value));
+ }}
+ />
+ </div>
+ <div class="grid2">
+ <label class="field">
+ <span>Name</span>
+ <input
+ class="sinput"
+ placeholder="e.g. wolf-laptop"
+ value={requestedName()}
+ onInput={(event) => {
+ setNameEdited(true);
+ setName(event.currentTarget.value);
+ }}
+ />
+ </label>
+ <div class="field">
+ <span>Share</span>
+ <Segmented
+ name="scope"
+ value={share()}
+ options={[
+ { value: 'private', label: 'Private', icon: 'lock' },
+ {
+ value: 'team',
+ label: 'Team',
+ icon: 'team',
+ disabled: teamId() === undefined,
+ },
+ ]}
+ onChange={setShare}
+ />
+ </div>
+ </div>
+ <div class="kv" style={{ 'grid-template-columns': 'auto 1fr' }}>
+ <span class="k">host</span>
+ <span class="mono">
+ {pairing()?.host ??
+ (complete()
+ ? pairingQuery.isPending
+ ? 'looking up code…'
+ : '—'
+ : 'waiting for code…')}
+ </span>
+ <span class="k">expires</span>
+ <span class="mono">
+ {pairing() ? expiresIn(pairing()!.expires_at) : '—'}
+ </span>
+ </div>
+ <Show when={error() ?? lookupError()}>
+ {(message) => (
+ <p style={{ margin: 0, 'font-size': '12px', color: 'var(--red)' }}>
+ {message()}
+ </p>
+ )}
+ </Show>
+ </div>
+ <div class="df">
+ <span />
+ <div style={{ display: 'flex', gap: '8px' }}>
+ <button type="button" class="btn quiet" data-close>
+ Cancel
+ </button>
+ <button
+ type="button"
+ class="btn"
+ disabled={!canApprove()}
+ style={{
+ background: 'var(--accent)',
+ color: 'var(--accent-contrast)',
+ }}
+ onClick={() => void submit()}
+ >
+ {approve.isPending ? 'Approving…' : 'Approve pairing'}
+ </button>
+ </div>
+ </div>
+ </ArtifactDialog>
+ );
+}
diff --git a/apps/web/src/features/agents-view/views/RosterPage.tsx b/apps/web/src/features/agents-view/views/RosterPage.tsx
new file mode 100644
index 0000000000..4058e5b293
--- /dev/null
+++ b/apps/web/src/features/agents-view/views/RosterPage.tsx
@@ -0,0 +1,609 @@
+import { botAssignableChannelOptions } from '@app/features/channel/Bots/botChannelOptions';
+import {
+ canDeleteBot,
+ canManageAgent,
+} from '@app/features/channel/Bots/botPermissions';
+import {
+ MODEL_PRETTYNAME,
+ type Model,
+} from '@core/component/AI/constant/model';
+import { toast } from '@core/component/Toast/Toast';
+import {
+ CURSOR_BOT_HANDLE,
+ CURSOR_BOT_ID,
+ CURSOR_BOT_NAME,
+} from '@core/constant/cursorAgent';
+import {
+ MACRO_AGENT_BOT_ID,
+ MACRO_AGENT_HANDLE,
+ MACRO_AGENT_NAME,
+} from '@core/constant/macroAgent';
+import { useSettingsState } from '@core/constant/SettingsState';
+import { useChannelsContext } from '@core/context/channels';
+import { useUserId } from '@core/context/user';
+import MacroLogo from '@icon/macro-logo.svg';
+import CursorIcon from '@icon/wide-cursor-ide.svg';
+import CodeIcon from '@phosphor/code.svg';
+import CopyIcon from '@phosphor/copy.svg';
+import GearIcon from '@phosphor/gear.svg';
+import PencilIcon from '@phosphor/pencil-simple.svg';
+import PlugsIcon from '@phosphor/plugs.svg';
+import PlusIcon from '@phosphor/plus.svg';
+import RobotIcon from '@phosphor/robot.svg';
+import TrashIcon from '@phosphor/trash.svg';
+import XIcon from '@phosphor/x.svg';
+import {
+ type AgentWithHarnessId,
+ useAgentsQuery,
+} from '@queries/agents/agents';
+import { useCursorApiKeyStatusQuery } from '@queries/auth/cursor-api-key';
+import { useHarnessesQuery } from '@queries/harnesses/harnesses';
+import { useCurrentTeamQuery, useIsTeamOwner } from '@queries/team/teams';
+import type { Harness } from '@service-storage/client';
+import {
+ createMemo,
+ createSignal,
+ For,
+ type JSX,
+ onCleanup,
+ onMount,
+ Show,
+} from 'solid-js';
+import { AgentAvatar } from '../components/AgentGlyph';
+import { type AgentKind, kindForHarness } from '../core/agent-kind';
+import { relativeAge } from '../core/format-age';
+import { BYOA_AGENTS, BYOA_DOCS_URL } from '../core/links';
+import { runtimeLabel } from '../core/roster';
+
+const KIND = {
+ agent: {
+ title: 'Agents',
+ desc: 'Create agents with their own identity, instructions, and skills.',
+ cta: 'Create agent',
+ empty: 'No agents here yet.',
+ },
+ coder: {
+ title: 'Coding agents',
+ desc: 'Agents that write code. They take a repository and run on a runtime you configure below.',
+ cta: 'Create coding agent',
+ empty: 'No coding agents here yet. Create one, or pair a runtime below.',
+ },
+} as const satisfies Record<AgentKind, Record<string, string>>;
+
+type Row = {
+ id: string;
+ name: string;
+ handle: string;
+ avatarUrl?: string;
+ kind: AgentKind;
+ share: 'system' | 'team' | 'private';
+ runtime: string;
+ model: string;
+ channels: string;
+ agent?: AgentWithHarnessId;
+ canEdit: boolean;
+ canDelete: boolean;
+};
+
+const MACRO_ROW: Row = {
+ id: MACRO_AGENT_BOT_ID,
+ name: MACRO_AGENT_NAME,
+ handle: MACRO_AGENT_HANDLE,
+ kind: 'agent',
+ share: 'system',
+ runtime: 'Macro Harness',
+ model: 'Default model',
+ channels: 'All channels',
+ canEdit: false,
+ canDelete: false,
+};
+
+function cursorRow(connected: boolean): Row {
+ return {
+ id: CURSOR_BOT_ID,
+ name: CURSOR_BOT_NAME,
+ handle: CURSOR_BOT_HANDLE,
+ kind: 'coder',
+ share: 'system',
+ runtime: connected ? 'Cursor' : 'Cursor · not connected',
+ model: 'Cursor default',
+ channels: 'All channels',
+ canEdit: false,
+ canDelete: false,
+ };
+}
+
+/**
+ * The settings-style roster inside the workspace: agents on one tab, coders
+ * and their runtimes on the other. Editing happens in dialogs the host opens.
+ */
+export function RosterPage(props: {
+ kind: AgentKind;
+ onKindChange: (kind: AgentKind) => void;
+ onClose: () => void;
+ onCreate: (kind: AgentKind) => void;
+ onEdit: (agent: AgentWithHarnessId) => void;
+ onDelete: (agent: AgentWithHarnessId) => void;
+ onPairRuntime: () => void;
+ onRemoveRuntime: (harness: Harness) => void;
+}) {
+ const { openSettings } = useSettingsState();
+ const userId = useUserId();
+ const agentsQuery = useAgentsQuery();
+ const harnessesQuery = useHarnessesQuery();
+ const cursorStatus = useCursorApiKeyStatusQuery();
+ const currentTeamQuery = useCurrentTeamQuery();
+ const isTeamOwner = useIsTeamOwner();
+ const channelsContext = useChannelsContext();
+ const cursorConnected = () =>
+ cursorStatus.isSuccess ? cursorStatus.data.registered : false;
+ const harnesses = () => (harnessesQuery.isSuccess ? harnessesQuery.data : []);
+ const teamId = () =>
+ currentTeamQuery.isSuccess ? currentTeamQuery.data?.team.id : undefined;
+ const channelOptions = createMemo(() =>
+ botAssignableChannelOptions(channelsContext.channels())
+ );
+
+ const rows = createMemo((): Row[] =>
+ (agentsQuery.isSuccess ? agentsQuery.data : []).map((agent) => {
+ const selected = channelOptions()
+ .filter((channel) => agent.channel_ids.includes(channel.id))
+ .map((channel) => `#${channel.name}`);
+ return {
+ id: agent.bot.id,
+ name: agent.bot.name,
+ handle: agent.bot.handle,
+ avatarUrl: agent.bot.avatar_url ?? undefined,
+ kind: kindForHarness(agent.harness),
+ share: agent.bot.owner?.type === 'team' ? 'team' : 'private',
+ runtime: runtimeLabel(
+ agent.harness,
+ agent.harness_id ?? undefined,
+ harnesses()
+ ),
+ model:
+ MODEL_PRETTYNAME[agent.default_model as Model] ?? agent.default_model,
+ channels:
+ agent.channel_scope === 'all'
+ ? 'All channels'
+ : selected.length > 0
+ ? selected.join(', ')
+ : `${agent.channel_ids.length} selected ${agent.channel_ids.length === 1 ? 'channel' : 'channels'}`,
+ agent,
+ canEdit: canManageAgent(agent.bot, userId(), teamId()),
+ canDelete: canDeleteBot(agent.bot, userId(), teamId(), isTeamOwner()),
+ };
+ })
+ );
+ const of = (kind: AgentKind, share: Row['share']) =>
+ rows().filter((row) => row.kind === kind && row.share === share);
+ const teamAgents = () => [MACRO_ROW, ...of('agent', 'team')];
+ const privateAgents = () => of('agent', 'private');
+ const teamCoders = () => [
+ cursorRow(cursorConnected()),
+ ...of('coder', 'team'),
+ ];
+ const privateCoders = () => of('coder', 'private');
+ const agentCount = () => teamAgents().length + privateAgents().length;
+ const coderCount = () => teamCoders().length + privateCoders().length;
+ const copy = () => KIND[props.kind];
+
+ onMount(() => {
+ const onKeyDown = (event: KeyboardEvent) => {
+ if (event.key !== 'Escape') return;
+ // An open dialog owns Escape.
+ if (document.querySelector('.agents-view-portal .overlay')) return;
+ props.onClose();
+ };
+ document.addEventListener('keydown', onKeyDown);
+ onCleanup(() => document.removeEventListener('keydown', onKeyDown));
+ });
+
+ const copyGuideLink = async () => {
+ try {
+ await navigator.clipboard.writeText(BYOA_DOCS_URL);
+ toast.success('Link copied to clipboard');
+ } catch {
+ toast.failure('Could not copy the link');
+ }
+ };
+
+ return (
+ <section class="page settings" data-active aria-label="Agents">
+ <div class="wrap">
+ <button
+ type="button"
+ class="icon-btn page-close"
+ aria-label="Close"
+ title="Close (esc)"
+ onClick={props.onClose}
+ >
+ <XIcon class="ph" />
+ </button>
+ <header class="ph-head">
+ <div>
+ <h1 class="big">{copy().title}</h1>
+ <p class="desc">{copy().desc}</p>
+ </div>
+ <button
+ type="button"
+ class="cta"
+ onClick={() => props.onCreate(props.kind)}
+ >
+ <PlusIcon class="ph" />
+ <span>{copy().cta}</span>
+ </button>
+ </header>
+ <div class="tabs" role="tablist" aria-label="Agent kind">
+ <button
+ type="button"
+ role="tab"
+ aria-selected={props.kind === 'agent'}
+ onClick={() => props.onKindChange('agent')}
+ >
+ <RobotIcon class="ph" />
+ Agents
+ <span class="n">{agentCount()}</span>
+ </button>
+ <button
+ type="button"
+ role="tab"
+ aria-selected={props.kind === 'coder'}
+ onClick={() => props.onKindChange('coder')}
+ >
+ <CodeIcon class="ph" />
+ Coding agents
+ <span class="n">{coderCount()}</span>
+ </button>
+ </div>
+
+ <Show when={props.kind === 'agent'}>
+ <div class="sections" data-kind="agents" role="tabpanel">
+ <Section
+ title="Team agents"
+ description="Agents shared with your team, including Macro."
+ >
+ <Rows
+ rows={teamAgents()}
+ empty={KIND.agent.empty}
+ loading={agentsQuery.isPending}
+ onEdit={props.onEdit}
+ onDelete={props.onDelete}
+ />
+ </Section>
+ <Section
+ title="Private agents"
+ description="Agents owned by you rather than your team."
+ >
+ <Rows
+ rows={privateAgents()}
+ empty={KIND.agent.empty}
+ loading={agentsQuery.isPending}
+ onEdit={props.onEdit}
+ onDelete={props.onDelete}
+ />
+ </Section>
+ </div>
+ </Show>
+
+ <Show when={props.kind === 'coder'}>
+ <div class="sections" data-kind="coders" role="tabpanel">
+ <Section
+ title="Team coding agents"
+ description="Coding agents shared with your team."
+ >
+ <Rows
+ rows={teamCoders()}
+ empty={KIND.coder.empty}
+ loading={agentsQuery.isPending}
+ onEdit={props.onEdit}
+ onDelete={props.onDelete}
+ />
+ </Section>
+ <Section
+ title="Private coding agents"
+ description="Coding agents owned by you rather than your team."
+ >
+ <Rows
+ rows={privateCoders()}
+ empty={KIND.coder.empty}
+ loading={agentsQuery.isPending}
+ onEdit={props.onEdit}
+ onDelete={props.onDelete}
+ />
+ </Section>
+ <Section
+ title="Runtimes"
+ description="Where coding agents run. Built-in runtimes are always available; paired runtimes come and go with your machine."
+ card={false}
+ >
+ <div class="scard runtimes">
+ <div id="runtimeList">
+ <RuntimeRow
+ icon={<MacroLogo class="ph" />}
+ name="Macro Harness"
+ badge="system"
+ sub="Built in · runs in Macro's cloud"
+ connected
+ status="Connected"
+ >
+ <button
+ type="button"
+ class="icon-btn"
+ aria-label="Configure Macro Harness"
+ onClick={() => openSettings('Harness')}
+ >
+ <GearIcon class="ph" />
+ </button>
+ </RuntimeRow>
+ <RuntimeRow
+ icon={<CursorIcon class="ph" />}
+ name="Cursor"
+ badge="system"
+ sub={
+ cursorConnected()
+ ? 'Cloud agents · connected with your Cursor API key'
+ : 'Cloud agents · connect with your Cursor API key'
+ }
+ connected={cursorConnected()}
+ status={cursorConnected() ? 'Connected' : 'Not connected'}
+ >
+ <button
+ type="button"
+ class="icon-btn"
+ aria-label="Configure Cursor"
+ onClick={() => openSettings('Harness')}
+ >
+ <GearIcon class="ph" />
+ </button>
+ </RuntimeRow>
+ <For each={harnesses()}>
+ {(harness) => (
+ <RuntimeRow
+ icon={<PlugsIcon class="ph" />}
+ name={harness.name}
+ badge={
+ harness.owner.type === 'team' ? 'team' : 'private'
+ }
+ sub={`macrod · paired ${relativeAge(Date.parse(harness.created_at))}`}
+ connected={harness.connected}
+ status={
+ harness.connected
+ ? 'Connected'
+ : harness.last_connected_at
+ ? `Disconnected · seen ${relativeAge(Date.parse(harness.last_connected_at))}`
+ : 'Disconnected · never seen'
+ }
+ >
+ <button
+ type="button"
+ class="icon-btn neg"
+ aria-label={`Remove ${harness.name}`}
+ style={{ color: 'var(--red)' }}
+ onClick={() => props.onRemoveRuntime(harness)}
+ >
+ <TrashIcon class="ph" />
+ </button>
+ </RuntimeRow>
+ )}
+ </For>
+ </div>
+ <div class="byoa footer">
+ <div>
+ <h2>
+ <PlugsIcon class="ph" />
+ <span>
+ Bring your <RotatingWord /> to Macro
+ </span>
+ </h2>
+ <p>
+ Run it on your own machine and give it a seat in Macro.
+ Pair once with <code>macrod</code>; after that it can be
+ @mentioned in channels and started from here like any
+ other agent. Works with any agent that speaks ACP.
+ </p>
+ </div>
+ <div class="side">
+ <button
+ type="button"
+ class="cta"
+ style={{ 'justify-content': 'center' }}
+ onClick={props.onPairRuntime}
+ >
+ <PlugsIcon class="ph" />
+ Pair a runtime
+ </button>
+ <div class="snippet">
+ <span title={BYOA_DOCS_URL}>{BYOA_DOCS_URL}</span>
+ <button
+ type="button"
+ class="icon-btn"
+ aria-label="Copy guide link"
+ onClick={() => void copyGuideLink()}
+ >
+ <CopyIcon class="ph" />
+ </button>
+ </div>
+ <a
+ class="link-btn"
+ style={{ 'justify-content': 'center' }}
+ href={BYOA_DOCS_URL}
+ target="_blank"
+ rel="noopener noreferrer"
+ >
+ Read the macrod guide
+ </a>
+ </div>
+ </div>
+ </div>
+ </Section>
+ </div>
+ </Show>
+ </div>
+ </section>
+ );
+}
+
+function Section(props: {
+ title: string;
+ description: string;
+ card?: boolean;
+ children: JSX.Element;
+}) {
+ return (
+ <div class="section">
+ <div class="sh">
+ <h2>{props.title}</h2>
+ <p>{props.description}</p>
+ </div>
+ <Show when={props.card !== false} fallback={props.children}>
+ <div class="scard">{props.children}</div>
+ </Show>
+ </div>
+ );
+}
+
+function Rows(props: {
+ rows: Row[];
+ empty: string;
+ loading: boolean;
+ onEdit: (agent: AgentWithHarnessId) => void;
+ onDelete: (agent: AgentWithHarnessId) => void;
+}) {
+ return (
+ <Show
+ when={props.rows.length > 0}
+ fallback={
+ <p class="empty-row">
+ {props.loading ? 'Loading agents…' : props.empty}
+ </p>
+ }
+ >
+ <For each={props.rows}>
+ {(row) => (
+ <div class="arow">
+ <AgentAvatar
+ agent={{
+ id: row.id,
+ botId: row.id,
+ name: row.name,
+ avatarUrl: row.avatarUrl,
+ }}
+ coder={row.kind === 'coder'}
+ />
+ <div class="info">
+ <div class="line">
+ <span class="nm truncate">{row.name}</span>
+ <span class="tag truncate">@{row.handle}</span>
+ <span class={row.share === 'system' ? 'badge system' : 'badge'}>
+ {row.share}
+ </span>
+ </div>
+ <p class="sub truncate">
+ {row.kind === 'coder' ? `${row.runtime} · ` : ''}
+ {row.model} · {row.channels}
+ </p>
+ </div>
+ <div class="acts">
+ <Show when={row.agent && row.canEdit}>
+ <button
+ type="button"
+ class="icon-btn"
+ aria-label={`Edit ${row.name}`}
+ onClick={() => row.agent && props.onEdit(row.agent)}
+ >
+ <PencilIcon class="ph" />
+ </button>
+ </Show>
+ <Show when={row.agent && row.canDelete}>
+ <button
+ type="button"
+ class="icon-btn neg"
+ aria-label={`Delete ${row.name}`}
+ onClick={() => row.agent && props.onDelete(row.agent)}
+ >
+ <TrashIcon class="ph" />
+ </button>
+ </Show>
+ </div>
+ </div>
+ )}
+ </For>
+ </Show>
+ );
+}
+
+function RuntimeRow(props: {
+ icon: JSX.Element;
+ name: string;
+ badge: 'system' | 'team' | 'private';
+ sub: string;
+ connected: boolean;
+ status: string;
+ children: JSX.Element;
+}) {
+ return (
+ <div class="rt">
+ <span class="ic">{props.icon}</span>
+ <div style={{ 'min-width': 0 }}>
+ <div class="nm">
+ <span class="truncate">{props.name}</span>
+ <span class={props.badge === 'system' ? 'badge system' : 'badge'}>
+ {props.badge}
+ </span>
+ </div>
+ <div class="sub truncate">{props.sub}</div>
+ </div>
+ <span class={props.connected ? 'conn' : 'conn off'}>{props.status}</span>
+ <div class="acts">{props.children}</div>
+ </div>
+ );
+}
+
+/**
+ * "Bring your <agent> to Macro": the name rolls through the supported CLIs,
+ * and the slot animates to each word's width so the sentence stays tight.
+ */
+function RotatingWord() {
+ const [index, setIndex] = createSignal(0);
+ const [phase, setPhase] = createSignal<'idle' | 'out' | 'in'>('idle');
+ let host: HTMLSpanElement | undefined;
+ let measure: HTMLSpanElement | undefined;
+
+ onMount(() => {
+ const fit = (word: string) => {
+ if (!host || !measure) return;
+ measure.textContent = word;
+ host.style.width = `${measure.offsetWidth}px`;
+ };
+ fit(BYOA_AGENTS[index()] ?? '');
+ void document.fonts?.ready.then(() => fit(BYOA_AGENTS[index()] ?? ''));
+ if (
+ typeof matchMedia === 'function' &&
+ matchMedia('(prefers-reduced-motion: reduce)').matches
+ ) {
+ return;
+ }
+ const timer = setInterval(() => {
+ if (!host?.offsetParent) return;
+ setPhase('out');
+ setTimeout(() => {
+ const next = (index() + 1) % BYOA_AGENTS.length;
+ setIndex(next);
+ fit(BYOA_AGENTS[next] ?? '');
+ setPhase('in');
+ requestAnimationFrame(() => setPhase('idle'));
+ }, 380);
+ }, 2200);
+ onCleanup(() => clearInterval(timer));
+ });
+
+ return (
+ <span class="rot" ref={host} aria-live="off">
+ <span class="measure" ref={measure} />
+ <span class={phase() === 'idle' ? 'w' : `w ${phase()}`}>
+ {BYOA_AGENTS[index()]}
+ </span>
+ </span>
+ );
+}
diff --git a/apps/web/src/features/block-agent/component/AgentComposer.tsx b/apps/web/src/features/block-agent/component/AgentComposer.tsx
index 1806f84f7c..d90ca429ed 100644
--- a/apps/web/src/features/block-agent/component/AgentComposer.tsx
+++ b/apps/web/src/features/block-agent/component/AgentComposer.tsx
@@ -6,15 +6,17 @@
import { useUserId } from '@core/context/user';
import { idToDisplayName } from '@core/user/util';
-import { Show } from 'solid-js';
+import { type Component, Show } from 'solid-js';
import { useAgentSession } from '../context/AgentSessionContext';
import {
AgentInput,
+ type AgentInputProps,
AgentModelSelector,
ComposerNotice,
type QueuedPromptItem,
QueuedPrompts,
} from '../ui';
+import type { AgentModelSelectorProps } from '../ui/AgentModelSelector';
export function AgentComposer(props: {
/**
@@ -22,7 +24,11 @@ export function AgentComposer(props: {
* split layout and j/k navigation — same contract as Chat and Channel.
*/
autofocus?: boolean;
+ input?: Component<AgentInputProps>;
+ modelSelector?: Component<AgentModelSelectorProps>;
}) {
+ const Input = props.input ?? AgentInput;
+ const ModelSelector = props.modelSelector ?? AgentModelSelector;
const {
blockedOnUser,
composer,
@@ -84,7 +90,7 @@ export function AgentComposer(props: {
}
/>
</Show>
- <AgentInput
+ <Input
placeholder="Message the agent, @mention anything"
autofocus={props.autofocus}
busy={composer.busy()}
@@ -108,7 +114,7 @@ export function AgentComposer(props: {
}}
registerQuoteInsert={registerQuoteInsert}
modelControl={
- <AgentModelSelector
+ <ModelSelector
model={metadata()?.model ?? null}
changingTo={composer.changingModel()}
options={metadata()?.supportedModels ?? []}
diff --git a/apps/web/src/features/block-agent/context/pending-session.ts b/apps/web/src/features/block-agent/context/pending-session.ts
index d2f5384f2b..1473c4cc8b 100644
--- a/apps/web/src/features/block-agent/context/pending-session.ts
+++ b/apps/web/src/features/block-agent/context/pending-session.ts
@@ -51,6 +51,11 @@ export type StartPendingSessionOptions = {
prompt?: string;
/** Optional model switch applied before the first prompt. */
modelOverride?: string;
+ /**
+ * Repository the session should work in. Informational for the runtime:
+ * having it cloned there is the runtime operator's job.
+ */
+ repoUrl?: string;
};
/**
@@ -68,6 +73,7 @@ export function startPendingSession(
void agentHarnessServiceClient
.create({
...(options.botId ? { botId: options.botId } : {}),
+ ...(options.repoUrl ? { repoUrl: options.repoUrl } : {}),
} satisfies CreateAgentSessionRequest)
.then(async (result) => {
if (result.isErr()) {
diff --git a/apps/web/src/lib/core/component/AI/component/input/ModelCatalogPicker.tsx b/apps/web/src/lib/core/component/AI/component/input/ModelCatalogPicker.tsx
index 1bbaa3de47..0c1b7279bf 100644
--- a/apps/web/src/lib/core/component/AI/component/input/ModelCatalogPicker.tsx
+++ b/apps/web/src/lib/core/component/AI/component/input/ModelCatalogPicker.tsx
@@ -1,27 +1,28 @@
import CaretDown from '@phosphor/caret-left.svg';
import CaretRight from '@phosphor/caret-right.svg';
import CheckIcon from '@phosphor/check.svg';
+import SparkleIcon from '@phosphor/sparkle.svg';
import { cn, Dropdown } from '@ui';
-import { createMemo, createSignal, For, Show } from 'solid-js';
+import { createMemo, createSignal, For, type JSX, Show } from 'solid-js';
+import { modelProvider, ProviderIcon } from '../ProviderIcon';
import {
buildModelCatalog,
type CatalogModelOption,
+ MAX_RECOMMENDED_MODELS,
matchesModelQuery,
modelFamilyHint,
moreModelFamilies,
} from './modelCatalog';
-/**
- * Scrolling lists (search hits, More models) cap at roughly eight `h-8` rows
- * plus a label, so the popover never grows with the size of the catalog.
- */
-const LIST_HEIGHT_CLASS = 'max-h-72 overflow-y-auto overscroll-contain';
-
type ModelCatalogPickerProps = {
value: string | null;
options: CatalogModelOption[];
onSelect: (id: string) => void;
disabled?: boolean;
+ pending?: boolean;
+ triggerLabel?: JSX.Element;
+ children?: JSX.Element;
+ emptyMessage?: string;
triggerClass?: string;
contentClass?: string;
placeholder?: string;
@@ -30,6 +31,17 @@ type ModelCatalogPickerProps = {
placement?: 'top-start' | 'top-end' | 'bottom-start' | 'bottom-end';
};
+function ModelIcon(props: { model?: string | null }) {
+ return (
+ <Show
+ when={modelProvider(props.model)}
+ fallback={<SparkleIcon class="size-4 shrink-0" />}
+ >
+ <ProviderIcon model={props.model} class="size-4" />
+ </Show>
+ );
+}
+
function ModelRow(props: {
option: CatalogModelOption;
selected: boolean;
@@ -39,10 +51,12 @@ function ModelRow(props: {
}) {
return (
<Dropdown.Item
+ closeOnSelect
class={cn('h-8 gap-2', props.selected && 'bg-ink/5 text-ink font-medium')}
- title={props.option.description ?? undefined}
+ title={props.option.description ?? props.option.label}
onSelect={props.onSelect}
>
+ <ModelIcon model={props.option.id} />
<span class="min-w-0 flex-1 truncate text-sm">{props.option.label}</span>
<Show when={props.hint}>
<span class="shrink-0 text-xs text-ink-extra-muted">{props.hint}</span>
@@ -70,29 +84,12 @@ function focusSearchAfterMenuOpen(input: () => HTMLInputElement | undefined) {
}
export function ModelCatalogPicker(props: ModelCatalogPickerProps) {
- const [query, setQuery] = createSignal('');
let searchRef: HTMLInputElement | undefined;
const selected = () =>
props.options.find((option) => option.id === props.value) ?? null;
const displayValue = () => selected()?.label ?? props.placeholder ?? 'Model';
- const normalizedQuery = () => query().trim().toLowerCase();
- const filtered = createMemo(() => {
- const currentQuery = normalizedQuery();
- if (!currentQuery) return [];
- return props.options.filter((option) =>
- matchesModelQuery(option, currentQuery)
- );
- });
- const catalog = createMemo(() =>
- buildModelCatalog(props.options, props.value ?? undefined)
- );
- const extraFamilies = createMemo(() => moreModelFamilies(catalog()));
- const extraCount = createMemo(() =>
- extraFamilies().reduce((count, family) => count + family.options.length, 0)
- );
-
return (
<Dropdown placement={props.placement ?? 'top-start'}>
<Dropdown.Trigger
@@ -103,14 +100,21 @@ export function ModelCatalogPicker(props: ModelCatalogPickerProps) {
props.triggerClass
)}
aria-label={props.ariaLabel}
- disabled={props.disabled}
+ aria-busy={props.pending || undefined}
+ title={displayValue()}
+ disabled={props.disabled || props.pending}
>
- <span class="truncate">{displayValue()}</span>
- <CaretDown class="size-3.5 rotate-[-90deg] opacity-70" />
+ <ModelIcon model={props.value} />
+ <span class="min-w-0 truncate">
+ {props.triggerLabel ?? displayValue()}
+ </span>
+ <CaretDown class="size-3.5 shrink-0 rotate-[-90deg] opacity-70" />
</Dropdown.Trigger>
<Dropdown.Content
+ onPointerDown={(event: PointerEvent) => event.stopPropagation()}
+ onMouseDown={(event: MouseEvent) => event.stopPropagation()}
class={cn(
- 'w-72 max-w-[min(24rem,calc(100vw-1rem))]',
+ 'w-72 max-w-[calc(100vw-1rem)] max-h-[min(28rem,var(--kb-popper-content-available-height))] overflow-y-auto overscroll-contain',
props.contentClass
)}
onOpenAutoFocus={(event) => {
@@ -118,110 +122,173 @@ export function ModelCatalogPicker(props: ModelCatalogPickerProps) {
focusSearchAfterMenuOpen(() => searchRef);
}}
>
- <div class="border-b border-edge-muted bg-menu p-1.5">
- <input
- ref={searchRef}
- aria-label={props.searchPlaceholder ?? 'Search models'}
- placeholder={props.searchPlaceholder ?? 'Search models'}
- value={query()}
- onInput={(event) => setQuery(event.currentTarget.value)}
- onMouseDown={(event) => event.stopPropagation()}
- onClick={(event) => event.stopPropagation()}
- onKeyDown={(event) => {
- if (event.key !== 'Escape') event.stopPropagation();
- }}
- onKeyUp={(event) => {
- if (event.key !== 'Escape') event.stopPropagation();
- }}
- class="w-full rounded-lg border border-edge-muted bg-transparent px-3 py-2 text-sm text-ink outline-none placeholder:text-ink-extra-muted focus:border-accent"
- />
- </div>
-
- <Show
- when={normalizedQuery().length > 0}
- fallback={
- <>
- <Show when={catalog().recommended.length > 0}>
- <Dropdown.Group>
- <Dropdown.GroupLabel>Recommended</Dropdown.GroupLabel>
- <For each={catalog().recommended}>
- {(option) => (
- <ModelRow
- option={option}
- hint={modelFamilyHint(option)}
- selected={option.id === props.value}
- onSelect={() => props.onSelect(option.id)}
- />
- )}
- </For>
- </Dropdown.Group>
- </Show>
-
- <Show when={extraCount() > 0}>
- <Dropdown.Separator class="h-px border-0 bg-edge-muted" />
- <Dropdown.Group>
- <Dropdown.Sub>
- <Dropdown.SubTrigger>
- <span class="truncate">More models</span>
- <span class="flex shrink-0 items-center gap-1 text-xs text-ink-extra-muted">
- {extraCount()}
- <CaretRight class="size-3" />
- </span>
- </Dropdown.SubTrigger>
- <Dropdown.SubContent class="w-72 max-w-[min(24rem,calc(100vw-1rem))]">
- <Dropdown.Group class={LIST_HEIGHT_CLASS}>
- <For each={extraFamilies()}>
- {(family) => (
- <>
- <Show when={family.label}>
- <Dropdown.GroupLabel>
- {family.label}
- </Dropdown.GroupLabel>
- </Show>
- <For each={family.options}>
- {(option) => (
- <ModelRow
- option={option}
- selected={option.id === props.value}
- onSelect={() => props.onSelect(option.id)}
- />
- )}
- </For>
- </>
- )}
- </For>
- </Dropdown.Group>
- </Dropdown.SubContent>
- </Dropdown.Sub>
- </Dropdown.Group>
- </Show>
- </>
- }
+ <ModelCatalogMenu
+ value={props.value}
+ options={props.options}
+ onSelect={props.onSelect}
+ emptyMessage={props.emptyMessage}
+ searchPlaceholder={props.searchPlaceholder}
+ searchRef={(element) => {
+ searchRef = element;
+ }}
>
- <Dropdown.Group class={LIST_HEIGHT_CLASS}>
- <Dropdown.GroupLabel>
- {filtered().length === 1
- ? '1 matching model'
- : `${filtered().length} matching models`}
- </Dropdown.GroupLabel>
- <For each={filtered()}>
- {(option) => (
- <ModelRow
- option={option}
- hint={modelFamilyHint(option)}
- selected={option.id === props.value}
- onSelect={() => props.onSelect(option.id)}
- />
- )}
- </For>
- <Show when={filtered().length === 0}>
- <div class="px-3 py-4 text-sm text-ink-muted">
- No models match that search.
- </div>
- </Show>
- </Dropdown.Group>
- </Show>
+ {props.children}
+ </ModelCatalogMenu>
</Dropdown.Content>
</Dropdown>
);
}
+
+/** Shared searchable catalog, usable inside a root menu or an agent submenu. */
+export function ModelCatalogMenu(
+ props: Pick<
+ ModelCatalogPickerProps,
+ | 'value'
+ | 'options'
+ | 'onSelect'
+ | 'emptyMessage'
+ | 'searchPlaceholder'
+ | 'children'
+ > & {
+ searchRef?: (element: HTMLInputElement) => void;
+ }
+) {
+ const [query, setQuery] = createSignal('');
+ const normalizedQuery = () => query().trim().toLowerCase();
+ const filtered = createMemo(() => {
+ const currentQuery = normalizedQuery();
+ if (!currentQuery) return [];
+ return props.options.filter((option) =>
+ matchesModelQuery(option, currentQuery)
+ );
+ });
+ const catalog = createMemo(() =>
+ props.options.length <= MAX_RECOMMENDED_MODELS
+ ? { recommended: props.options, families: [] }
+ : buildModelCatalog(props.options, props.value ?? undefined)
+ );
+ const extraFamilies = createMemo(() => moreModelFamilies(catalog()));
+ const extraCount = createMemo(() =>
+ extraFamilies().reduce((count, family) => count + family.options.length, 0)
+ );
+
+ return (
+ <>
+ <div class="border-b border-edge-muted bg-menu p-1.5">
+ <input
+ ref={props.searchRef}
+ aria-label={props.searchPlaceholder ?? 'Search models'}
+ placeholder={props.searchPlaceholder ?? 'Search models'}
+ value={query()}
+ onInput={(event) => setQuery(event.currentTarget.value)}
+ onMouseDown={(event: MouseEvent) => event.stopPropagation()}
+ onClick={(event) => event.stopPropagation()}
+ onKeyDown={(event) => {
+ if (event.key !== 'Escape') event.stopPropagation();
+ }}
+ onKeyUp={(event) => {
+ if (event.key !== 'Escape') event.stopPropagation();
+ }}
+ class="w-full rounded-lg border border-edge-muted bg-transparent px-3 py-2 text-sm text-ink outline-none placeholder:text-ink-extra-muted focus:border-accent"
+ />
+ </div>
+
+ {props.children}
+ <Show when={props.options.length === 0}>
+ <div class="bg-menu px-3 py-2 text-xs text-ink-muted" role="status">
+ {props.emptyMessage ?? 'No models available.'}
+ </div>
+ </Show>
+ <Show
+ when={normalizedQuery().length > 0}
+ fallback={
+ <>
+ <Show when={catalog().recommended.length > 0}>
+ <Dropdown.Group>
+ <Dropdown.GroupLabel>Recommended</Dropdown.GroupLabel>
+ <For each={catalog().recommended}>
+ {(option) => (
+ <ModelRow
+ option={option}
+ hint={modelFamilyHint(option)}
+ selected={option.id === props.value}
+ onSelect={() => props.onSelect(option.id)}
+ />
+ )}
+ </For>
+ </Dropdown.Group>
+ </Show>
+
+ <Show when={extraCount() > 0}>
+ <Dropdown.Separator class="h-px border-0 bg-edge-muted" />
+ <Dropdown.Group>
+ <Dropdown.Sub>
+ <Dropdown.SubTrigger>
+ <span class="truncate">More models</span>
+ <span class="flex shrink-0 items-center gap-1 text-xs text-ink-extra-muted">
+ {extraCount()}
+ <CaretRight class="size-3" />
+ </span>
+ </Dropdown.SubTrigger>
+ <Dropdown.SubContent
+ onPointerDown={(event: PointerEvent) =>
+ event.stopPropagation()
+ }
+ onMouseDown={(event: MouseEvent) => event.stopPropagation()}
+ class="w-72 max-w-[calc(100vw-1rem)] max-h-[var(--kb-popper-content-available-height)] overflow-y-auto overscroll-contain"
+ >
+ <Dropdown.Group class="max-h-72 overflow-y-auto overscroll-contain">
+ <For each={extraFamilies()}>
+ {(family) => (
+ <>
+ <Show when={family.label}>
+ <Dropdown.GroupLabel>
+ {family.label}
+ </Dropdown.GroupLabel>
+ </Show>
+ <For each={family.options}>
+ {(option) => (
+ <ModelRow
+ option={option}
+ selected={option.id === props.value}
+ onSelect={() => props.onSelect(option.id)}
+ />
+ )}
+ </For>
+ </>
+ )}
+ </For>
+ </Dropdown.Group>
+ </Dropdown.SubContent>
+ </Dropdown.Sub>
+ </Dropdown.Group>
+ </Show>
+ </>
+ }
+ >
+ <Dropdown.Group class="max-h-72 overflow-y-auto overscroll-contain">
+ <Dropdown.GroupLabel>
+ {filtered().length === 1
+ ? '1 matching model'
+ : `${filtered().length} matching models`}
+ </Dropdown.GroupLabel>
+ <For each={filtered()}>
+ {(option) => (
+ <ModelRow
+ option={option}
+ hint={modelFamilyHint(option)}
+ selected={option.id === props.value}
+ onSelect={() => props.onSelect(option.id)}
+ />
+ )}
+ </For>
+ <Show when={filtered().length === 0}>
+ <div class="px-3 py-4 text-sm text-ink-muted">
+ No models match that search.
+ </div>
+ </Show>
+ </Dropdown.Group>
+ </Show>
+ </>
+ );
+}
diff --git a/apps/web/src/lib/core/constant/macroCoder.ts b/apps/web/src/lib/core/constant/macroCoder.ts
index 1ded112a30..3e3c084ab2 100644
--- a/apps/web/src/lib/core/constant/macroCoder.ts
+++ b/apps/web/src/lib/core/constant/macroCoder.ts
@@ -1,25 +1,25 @@
/**
- * Identity for the first-party "Macro Coder" system bot. Mirrors
+ * Identity for the first-party "Macro Coding Agent" system bot. Mirrors
* `bot_id::MACRO_CODER_BOT_ID` on the backend. Deliberately a distinct bot
* from Macro (see `macroAgent.ts`): mentioning Macro answers in chat, while
- * mentioning Macro Coder opens a sandboxed coding-agent session.
+ * mentioning Macro Coding Agent opens a sandboxed coding-agent session.
*/
export const MACRO_CODER_BOT_ID = '00000000-0000-0000-0000-00000000a9e7';
/**
- * Canonical principal id for Macro Coder, matching the `bot|<uuid>` form used
+ * Canonical principal id for Macro Coding Agent, matching the `bot|<uuid>` form used
* for bot senders and participants everywhere else.
*/
export const MACRO_CODER_PRINCIPAL_ID = `bot|${MACRO_CODER_BOT_ID}`;
-/** Display name for Macro Coder. */
-export const MACRO_CODER_NAME = 'Macro Coder';
+/** Display name for Macro Coding Agent. */
+export const MACRO_CODER_NAME = 'Macro Coding Agent';
-/** Handle used to find Macro Coder in the mention typeahead (`@coder`). */
+/** Handle used to find Macro Coding Agent in the mention typeahead (`@coder`). */
export const MACRO_CODER_HANDLE = 'coder';
/**
- * Whether an id refers to the Macro Coder bot. Accepts both the bare UUID and
+ * Whether an id refers to the Macro Coding Agent bot. Accepts both the bare UUID and
* the `bot|<uuid>` participant/sender form.
*/
export function isMacroCoderId(id: string | undefined): boolean {
diff --git a/crates/chat/src/domain/models/model_access.rs b/crates/chat/src/domain/models/model_access.rs
index b1fe12ab5f..05552a586b 100644
--- a/crates/chat/src/domain/models/model_access.rs
+++ b/crates/chat/src/domain/models/model_access.rs
@@ -8,8 +8,6 @@ pub const CHAT_MODELS: &[&str] = &[
"anthropic/claude-sonnet-5",
"anthropic/claude-opus-5",
"anthropic/claude-haiku-4-5",
- "anthropic/claude-opus-4-7",
- "anthropic/claude-sonnet-4-6",
"openai/gpt-5.5",
"openai/gpt-5-mini",
];
diff --git a/docs/AGENT_GUIDE/ai-chat.md b/docs/AGENT_GUIDE/ai-chat.md
index 77ee9f681b..f70152df39 100644
--- a/docs/AGENT_GUIDE/ai-chat.md
+++ b/docs/AGENT_GUIDE/ai-chat.md
@@ -2,14 +2,78 @@
## Where chats live
-- List: `Go to Agents` → `/app/component/agents`. With new app views enabled
- on desktop, an Agents sidebar opens New Chat, Routines, configured Agents,
- Connections, and Skills, followed by favorite and recent conversations.
- Selecting a recent chat or agent session opens it inside the workspace;
- Shift-clicking one opens it in a new split instead.
- Touch devices and users outside the flag retain the Owned / Running / Shared /
- Automations / Skills list.
-- A chat is `/app/chat/<uuid>`. A doc-scoped chat is `/app/md/<doc>/chat/<chat>` (split view).
+- Open **Go to Agents** → `/app/component/agents`. With AI agents enabled
+ (`enable-chat-v3-agents`), the workspace uses one sidebar for Chat and Code.
+ **New conversation** opens the composer. **Conversations** is a mixed list
+ of chats and coding sessions, newest first, with one search across both.
+ Chat rows use a chat icon; coding rows use `</>` and show their agent and
+ runtime status. Changing the composer mode does not filter the sidebar.
+ Selecting a row opens its own mode; Shift-click opens it in a new split.
+- The starting page has a compact composer that starts at one line and grows
+ with longer prompts or Shift+Enter. **Agent** and **Send** sit inside the input on the right.
+ Direct model selections show only the model name and provider icon in the input.
+ Saved and coding agents show their identity beside the current model. There is
+ no Chat/Code switch or separate model button.
+- The agent dropdown combines Cursor and saved in-memory or Cursor
+ agents in **Coding agents** and **Agents** sections. A **Models** section lists
+ Macro’s available models with readable names (for example, **Sonnet 5**) and
+ provider icons aligned with the agent icons. The chat catalog offers Sonnet 5,
+ Opus 5, and Haiku 4.5; older Sonnet and Opus versions are not offered.
+ Selecting a model here selects
+ the default runtime and applies that model to the next send, retracting the repository drawer.
+ The built-in Macro agent is hidden from the agent sections; its models remain available.
+ Coding agents carry a `</>` badge. The most recently used supported,
+ available agent is selected initially; otherwise Macro is selected.
+ Hover an agent (or use the right arrow key) to open its model submenu, with
+ the searchable Settings catalog, provider icons, and scrollable **More models**.
+ Clicking an agent directly uses its default; choosing a submenu model selects
+ both the agent and that model. A checkmark identifies the selected model,
+ including when it is the agent’s configured default; there is no separate default row.
+ Disconnected Cursor offers **Connect Cursor**, opening Settings → Harness.
+ The built-in sandbox and paired macrod runtimes are not offered here.
+- Selecting an agent changes the heading: **What should we work on?** for chat
+ agents and **What should we build?** for coding agents. The draft stays intact
+ when changing agents. **Create agent** stays pinned at the bottom of the dropdown
+ while the agent and model lists scroll. It opens the roster on the selected kind's
+ tab, where either kind can be created.
+- Selecting a coding agent reveals a repository drawer directly under the input
+ with a short slide and fade; selecting a chat agent retracts it. Reduced-motion
+ preferences disable the animation. The hidden drawer is inert. **Repository**
+ offers **No repository**, recent repositories, or `owner/repo` / URL entry.
+ The chosen repository survives agent changes and is sent only to coding agents.
+- Sending starts a session with the chosen agent's configured default model;
+ a model selected from its submenu overrides that default for the next send
+ only. Sending or choosing another agent clears the override. This does not
+ update the saved agent; configure persistent defaults in the agent editor.
+ Within an existing session, the model picker remains available on the right.
+ Its trigger, model options, and session metadata use the same readable model names
+ as the new-conversation picker. The menu includes provider icons, search, a short
+ **Recommended** list, and a scrollable **More models** submenu shared with Settings.
+- Chat agents' empty input cycles tips about connectors, skills, mentions, and
+ agents; coding agents show **Describe what you want to build**. Type `@` for
+ mentions and `/` for skills.
+- Opening a conversation updates the URL based on that conversation's kind:
+ `/app/agents/<id>` for Chat sessions, `/app/coders/<id>` for Code sessions,
+ and `/app/agent-chats/<id>` for legacy chats. Reload and back/forward restore
+ its mode and conversation. Newly created sessions replace their temporary
+ URL with the real id without remounting the composer or adding a temporary
+ history step.
+- **Agents page** (inside the workspace; Settings → Agents is unchanged):
+ **Close** returns to the composer. **Agents / Coding agents** tabs split
+ the roster into Team and Private, with Edit / Delete actions. The coding
+ tab includes runtime setup. The create/edit dialog has sharing, name,
+ `@tag`, runtime, default model, connections, channels, and instructions.
+- **Session**: the header has the sidebar reopen control, a linked PR status chip,
+ favorite, Share, Side panel, and a More menu
+ (Rename, Copy link, Delete). A metadata strip lists the agent, runtime,
+ model, repository, and status. Chat and Code session inputs
+ use the same growing, initially single-line input with the model selector on
+ the right.
+ Existing sessions retain their agent and kind; use **New conversation** to
+ choose another. Stop, queued-message advancement, and quoting remain available.
+- Users outside the flag retain the Owned / Running / Shared / Automations /
+ Skills list. A standalone legacy chat is `/app/chat/<uuid>`; doc-scoped chat
+ is `/app/md/<doc>/chat/<chat>` (split view).
## Start a standalone chat
@@ -296,7 +360,6 @@ of an open turn. Earlier thoughts settle to **Thought** as soon as a tool or
answer follows, including during long Cursor turns. A trailing thought stays
outside the tool group so the live reasoning row stays visible. Do not wait
for every Thinking label to disappear — only the tail one is in flight.
-
### Sharing a session
Saved sessions have **Share** and **Copy Share Link** in the desktop header;
diff --git a/docs/AGENT_GUIDE/navigation.md b/docs/AGENT_GUIDE/navigation.md
index df51163e04..5d92947956 100644
--- a/docs/AGENT_GUIDE/navigation.md
+++ b/docs/AGENT_GUIDE/navigation.md
@@ -14,6 +14,9 @@
| `/app/component/documents` | Files (documents list) |
| `/app/component/tasks` | Tasks table |
| `/app/component/agents` | AI chats / agents list |
+| `/app/agents/<uuid>` | Chat agent session with the Agents sidebar |
+| `/app/coders/<uuid>` | Code session with the Agents sidebar |
+| `/app/agent-chats/<uuid>` | Legacy AI chat opened in the Agents workspace |
| `/app/component/calls` | Calls list |
| `/app/component/companies` | Customers (CRM; needs a team) |
| `/app/component/activity` | Activity heatmap + feed |
@@ -84,7 +87,9 @@ stay centered and the preview body fills the remaining height below the divider.
- Bottom: button named after the user's email — menu with `Command menu (Ctrl K)`,
`Settings (Ctrl ;)`, `Log out`.
-With the new app views enabled, the outer sidebar is an icon rail. Its tooltips
+With the new app views enabled, the outer sidebar is an icon rail. Start a new AI
+chat from the Agents workspace; the rail has no separate new-chat-in-a-new-split
+button. Its tooltips
use the standard 400 ms hover delay and 300 ms grace period between items. Home,
Email, and Chat show a small accent dot when the loaded data contains an unread
item. Home uses Signal; Email uses Important across all linked inboxes.
@@ -93,6 +98,12 @@ do not fetch additional pages to find every unread item. Opening a view alone do
not clear its dot — reading or completing the represented items does. The button's
accessible description is `Unread items` while its dot is active.
+The Agents sidebar mixes chat and coding sessions in one newest-first list.
+Its **New conversation** button opens the unified composer with one **Agent**
+selector on the right. Choosing a coding agent reveals the repository drawer;
+there is no Chat/Code switch. New sessions use the selected agent's default model
+and the URL for its kind. Opening an existing row restores its own kind and URL.
+
Home's inner rail starts with a full-width **New chat** plus button that returns
to Home's starting pane without creating a chat. Email and Tasks use the same
pill styling and top placement for **New email** and **New task**, replacing