Skip to content

AutoGPT is the vision of accessible AI for everyone, to use and to build on. Our mission is to provide the tools, so that you can focus on what matters.

feat(platform): expert proposal cards outside the tool chain with approve flow and taglines (#14273)

Abhimanyu Yadav24628eeca3ce
diff --git a/autogpt_platform/backend/backend/api/features/experts/experts_db.py b/autogpt_platform/backend/backend/api/features/experts/experts_db.py
index 3641ef9d31..2d197fbbab 100644
--- a/autogpt_platform/backend/backend/api/features/experts/experts_db.py
+++ b/autogpt_platform/backend/backend/api/features/experts/experts_db.py
@@ -753,6 +753,7 @@ async def create_raised_expert(
*,
avatar_url: str | None = None,
color: str | None = None,
+ tagline: str | None = None,
about: str | None = None,
boundaries: str | None = None,
weekly_budget: int | None = None,
@@ -773,6 +774,7 @@ async def create_raised_expert(
voice_preferences,
avatar_url=avatar_url,
color=color,
+ tagline=tagline,
about=about,
boundaries=boundaries,
weekly_budget=weekly_budget,
@@ -798,6 +800,7 @@ async def _create_raised_expert_row(
*,
avatar_url: str | None,
color: str | None,
+ tagline: str | None = None,
about: str | None,
boundaries: str | None = None,
weekly_budget: int | None = None,
@@ -822,6 +825,7 @@ async def _create_raised_expert_row(
"avatarUrl": avatar_url,
"color": color or "",
"role": role or "",
+ "tagline": tagline,
"identity": about or _raised_identity(name),
"voicePreferences": voice_preferences or "",
"boundaries": boundaries or "",
diff --git a/autogpt_platform/backend/backend/api/features/experts/experts_db_test.py b/autogpt_platform/backend/backend/api/features/experts/experts_db_test.py
index 7f872e5d84..0adf08ad7b 100644
--- a/autogpt_platform/backend/backend/api/features/experts/experts_db_test.py
+++ b/autogpt_platform/backend/backend/api/features/experts/experts_db_test.py
@@ -411,14 +411,17 @@ async def test_raise_expert_persists_avatar_and_color(server: SpinTestServer):
voice_preferences=None,
avatar_url="https://storage.googleapis.com/bucket/nova.png",
color="sky-300",
+ tagline="Finds your leads and their decision-makers.",
)
assert raised.expert.avatar_url == "https://storage.googleapis.com/bucket/nova.png"
assert raised.expert.color == "sky-300"
+ assert raised.expert.tagline == "Finds your leads and their decision-makers."
reloaded = await experts_db.get_expert(owner.id, raised.expert.id)
assert reloaded is not None
assert reloaded.avatar_url == "https://storage.googleapis.com/bucket/nova.png"
assert reloaded.color == "sky-300"
+ assert reloaded.tagline == "Finds your leads and their decision-makers."
@pytest.mark.asyncio(loop_scope="session")
diff --git a/autogpt_platform/backend/backend/api/features/experts/models.py b/autogpt_platform/backend/backend/api/features/experts/models.py
index 7cfa2300d6..1d41061389 100644
--- a/autogpt_platform/backend/backend/api/features/experts/models.py
+++ b/autogpt_platform/backend/backend/api/features/experts/models.py
@@ -22,6 +22,7 @@ EXTERNAL_ACTION_APPROVAL_RULE = "External actions require approval."
PROTECTED_SOUL_RULES = (AI_DISCLOSURE_RULE, EXTERNAL_ACTION_APPROVAL_RULE)
EXPERT_NAME_MAX_LENGTH = 100
+EXPERT_TAGLINE_MAX_LENGTH = 160
EXPERT_IDENTITY_MAX_LENGTH = 10_000
_EXPERT_SOUL_TEXT_MAX_LENGTH = 4_000
EXPERT_COLOR_MAX_LENGTH = 32
diff --git a/autogpt_platform/backend/backend/copilot/tools/confirm_expert_change.py b/autogpt_platform/backend/backend/copilot/tools/confirm_expert_change.py
index 3f11727015..0dcf79e2d1 100644
--- a/autogpt_platform/backend/backend/copilot/tools/confirm_expert_change.py
+++ b/autogpt_platform/backend/backend/copilot/tools/confirm_expert_change.py
@@ -23,6 +23,7 @@ _PROPOSAL_FIELDS = (
"template_id",
"name",
"role",
+ "tagline",
"about",
"boundaries",
"voice_preferences",
diff --git a/autogpt_platform/backend/backend/copilot/tools/expert_change_test.py b/autogpt_platform/backend/backend/copilot/tools/expert_change_test.py
index b9a1421125..fff39065de 100644
--- a/autogpt_platform/backend/backend/copilot/tools/expert_change_test.py
+++ b/autogpt_platform/backend/backend/copilot/tools/expert_change_test.py
@@ -46,6 +46,7 @@ _CONFIRM_MODULE = "backend.copilot.tools.confirm_expert_change"
_CHARTER = {
"name": "Otto",
"role": "Inbox triage",
+ "tagline": "Sorts your morning inbox and drafts the routine replies.",
"color": "violet-300",
"about": "You group the morning inbox and draft routine replies.",
"boundaries": "You never send a reply yourself.",
@@ -74,6 +75,7 @@ def _template(template_id: str = "tpl-scout"):
id=template_id,
name="Scout",
role="Market research",
+ tagline="Tracks your competitors and reports what changed.",
identity="You track competitors.",
boundaries="You never contact anyone outside the team.",
voice_preferences="Short and factual.",
@@ -87,6 +89,11 @@ def _created(name: str = "Scout", expert_id: str = "exp-1"):
id=expert_id,
name=name,
role="Market research",
+ tagline="Tracks your competitors and reports what changed.",
+ identity="You track competitors.",
+ boundaries="You never contact anyone outside the team.",
+ voice_preferences="Short and factual.",
+ weekly_budget=None,
avatar_url=None,
color="sky-300",
)
@@ -98,6 +105,7 @@ def _hired_otto():
id="exp-2",
name="Otto",
role="Inbox triage",
+ tagline="Sorts your morning inbox.",
identity="You group the morning inbox.",
boundaries="You never send a reply yourself.",
voice_preferences="Plain sentences.",
@@ -216,11 +224,27 @@ class TestPreviewNeverWrites:
resp = await _raise(make_session(_USER), **_CHARTER)
assert isinstance(resp, ExpertChangeProposedResponse)
assert resp.applied is False
+ assert resp.preview.tagline == _CHARTER["tagline"]
assert resp.preview.about == _CHARTER["about"]
assert resp.preview.boundaries == _CHARTER["boundaries"]
assert resp.preview.color == _CHARTER["color"]
db.create_raised_expert.assert_not_called()
+ @pytest.mark.asyncio(loop_scope="session")
+ async def test_hire_preview_carries_the_template_tagline(self):
+ with _env():
+ resp = await _hire(make_session(_USER), template_id="tpl-scout")
+ assert isinstance(resp, ExpertChangeProposedResponse)
+ assert resp.preview.tagline == _template().tagline
+
+ @pytest.mark.asyncio(loop_scope="session")
+ async def test_raise_without_tagline_is_refused(self):
+ with _env() as db:
+ resp = await _raise(make_session(_USER), **{**_CHARTER, "tagline": " "})
+ assert isinstance(resp, ErrorResponse)
+ assert "tagline" in resp.message
+ db.create_raised_expert.assert_not_called()
+
@pytest.mark.asyncio(loop_scope="session")
async def test_hire_renames_the_template(self):
with _env():
@@ -509,12 +533,16 @@ class TestConfirm:
assert isinstance(resp, ExpertChangeAppliedResponse)
assert resp.kind == "raise"
assert resp.expert.name == "Otto"
+ assert resp.expert.tagline == _created().tagline
+ assert resp.expert.about == _created().identity
+ assert resp.expert.boundaries == _created().boundaries
db.create_raised_expert.assert_awaited_once_with(
_USER,
_CHARTER["name"],
_CHARTER["role"],
None,
color=_CHARTER["color"],
+ tagline=_CHARTER["tagline"],
about=_CHARTER["about"],
boundaries=_CHARTER["boundaries"],
weekly_budget=2000,
diff --git a/autogpt_platform/backend/backend/copilot/tools/expert_proposal.py b/autogpt_platform/backend/backend/copilot/tools/expert_proposal.py
index bca9968b2d..e1a447175f 100644
--- a/autogpt_platform/backend/backend/copilot/tools/expert_proposal.py
+++ b/autogpt_platform/backend/backend/copilot/tools/expert_proposal.py
@@ -381,6 +381,7 @@ async def _apply_raise(
preview.role or None,
preview.voice_preferences or None,
color=preview.color or None,
+ tagline=preview.tagline or None,
about=preview.about or None,
boundaries=preview.boundaries or None,
weekly_budget=preview.weekly_budget,
@@ -549,6 +550,11 @@ def _summary(expert: Expert) -> ExpertSummary:
id=expert.id,
name=expert.name,
role=expert.role,
+ tagline=expert.tagline,
+ about=expert.identity,
+ boundaries=expert.boundaries,
+ voice_preferences=expert.voice_preferences,
+ weekly_budget=expert.weekly_budget,
avatar_url=expert.avatar_url,
color=expert.color,
)
diff --git a/autogpt_platform/backend/backend/copilot/tools/hire_expert.py b/autogpt_platform/backend/backend/copilot/tools/hire_expert.py
index 888405b2f4..a7fd2303e6 100644
--- a/autogpt_platform/backend/backend/copilot/tools/hire_expert.py
+++ b/autogpt_platform/backend/backend/copilot/tools/hire_expert.py
@@ -53,9 +53,11 @@ class HireExpertTool(BaseTool):
return (
"Propose hiring a ready-made expert from the roster. Never "
"writes: returns who would join plus a one-time confirmation_id. "
- "Show the user who they'd hire and, only after they approve, "
- "call confirm_expert_change with that id. Use raise_expert when "
- "no template fits."
+ "The user sees who would join on a card with Approve and Decline "
+ "buttons, so do not describe them in text — one short line at "
+ "most, then wait. Only after they approve, call "
+ "confirm_expert_change with that id. Use raise_expert when no "
+ "template fits."
)
@property
@@ -118,6 +120,7 @@ class HireExpertTool(BaseTool):
kind="hire",
name=params.name or template.name,
role=template.role,
+ tagline=template.tagline or "",
about=template.identity,
boundaries=template.boundaries,
voice_preferences=template.voice_preferences,
@@ -138,8 +141,9 @@ class HireExpertTool(BaseTool):
)
return ExpertChangeProposedResponse(
message=(
- "Nothing hired yet. Show the user who would join, what they "
- "own, and that the hire draws on the shared weekly budget. "
+ "Nothing hired yet. The user is looking at this expert on a "
+ "card with Approve and Decline buttons — do not describe "
+ "them in text. Reply with one short line at most and wait. "
"Only after they explicitly approve, call "
"confirm_expert_change with this confirmation_id."
),
diff --git a/autogpt_platform/backend/backend/copilot/tools/models.py b/autogpt_platform/backend/backend/copilot/tools/models.py
index cbdcf67cd3..11aedfec78 100644
--- a/autogpt_platform/backend/backend/copilot/tools/models.py
+++ b/autogpt_platform/backend/backend/copilot/tools/models.py
@@ -558,6 +558,7 @@ class ExpertChangePreview(BaseModel):
kind: ExpertChangeKind
name: str
role: str = ""
+ tagline: str = ""
about: str = ""
boundaries: str = ""
voice_preferences: str = ""
@@ -568,11 +569,17 @@ class ExpertChangePreview(BaseModel):
class ExpertSummary(BaseModel):
- """Identity of an expert created by ``confirm_expert_change``."""
+ """The expert ``confirm_expert_change`` created — same charter fields as
+ the preview, so the card can show the whole thing after the fact."""
id: str
name: str
role: str
+ tagline: str | None = None
+ about: str = ""
+ boundaries: str = ""
+ voice_preferences: str = ""
+ weekly_budget: int | None = None
avatar_url: str | None = None
color: str = ""
diff --git a/autogpt_platform/backend/backend/copilot/tools/raise_expert.py b/autogpt_platform/backend/backend/copilot/tools/raise_expert.py
index 60fd1ec799..d45792245e 100644
--- a/autogpt_platform/backend/backend/copilot/tools/raise_expert.py
+++ b/autogpt_platform/backend/backend/copilot/tools/raise_expert.py
@@ -16,6 +16,7 @@ from pydantic import BaseModel, Field, ValidationError
from backend.api.features.experts.models import (
EXPERT_COLOR_MAX_LENGTH,
EXPERT_NAME_MAX_LENGTH,
+ EXPERT_TAGLINE_MAX_LENGTH,
WEEKLY_BUDGET_MAX_CREDITS,
Expert,
ExpertSoulFieldsPatch,
@@ -69,6 +70,7 @@ class _RaiseParams(BaseModel):
name: str = Field(min_length=1, max_length=EXPERT_NAME_MAX_LENGTH)
role: str = Field(default="", max_length=EXPERT_NAME_MAX_LENGTH)
+ tagline: str = Field(min_length=1, max_length=EXPERT_TAGLINE_MAX_LENGTH)
color: str = Field(default="", max_length=EXPERT_COLOR_MAX_LENGTH)
weekly_budget: int | None = Field(default=None, ge=0, le=WEEKLY_BUDGET_MAX_CREDITS)
@@ -89,13 +91,15 @@ class RaiseExpertTool(BaseTool):
return (
"Propose a brand-new expert when no roster template fits. Give "
"them a personal first name (the role field carries the job "
- "title) and an accent color, then write their charter: what they "
- "own, what good looks like, and where they stop (always fill "
- "boundaries — an expert without them oversteps). Never writes: "
- "returns the proposed expert plus a one-time confirmation_id. "
- "Read the FULL charter back — name, role, color, what they own, "
- "where they stop, voice, weekly budget — and only after the user "
- "approves, call confirm_expert_change with that id."
+ "title), a one-line tagline and an accent color, then write "
+ "their charter: what they own, what good looks like, and where "
+ "they stop (always fill boundaries — an expert without them "
+ "oversteps). This tool never writes; it returns the proposed "
+ "expert plus a one-time confirmation_id. "
+ "The user sees the whole charter on a card with Approve and "
+ "Decline buttons, so never repeat it in text — one short line "
+ "at most, then wait. Only after the user approves, call "
+ "confirm_expert_change with that id."
)
@property
@@ -115,6 +119,15 @@ class RaiseExpertTool(BaseTool):
"type": "string",
"description": "Short title for what they own.",
},
+ "tagline": {
+ "type": "string",
+ "description": (
+ "One line, third person, what they do for the user "
+ "— e.g. 'Finds your leads and their decision-makers.' "
+ "Under 120 characters. This is what the user reads "
+ "on their card; the charter is for the expert."
+ ),
+ },
"color": {
"type": "string",
"enum": COLOR_TOKENS,
@@ -146,7 +159,7 @@ class RaiseExpertTool(BaseTool):
"description": "Weekly credit cap (100 = $1); omit for default.",
},
},
- "required": ["name", "about", "boundaries"],
+ "required": ["name", "tagline", "about", "boundaries"],
}
async def _execute(
@@ -156,6 +169,7 @@ class RaiseExpertTool(BaseTool):
*,
name: str = "",
role: str = "",
+ tagline: str = "",
color: str = "",
about: str = "",
boundaries: str = "",
@@ -185,6 +199,7 @@ class RaiseExpertTool(BaseTool):
# entries that ``escape_prompt_xml_tags`` cannot neutralise.
name=" ".join(name.split()),
role=" ".join(role.split()),
+ tagline=" ".join(tagline.split()),
color=color,
weekly_budget=weekly_budget,
)
@@ -235,6 +250,7 @@ class RaiseExpertTool(BaseTool):
kind="raise",
name=params.name,
role=params.role,
+ tagline=params.tagline,
color=params.color,
about=soul.identity or "",
boundaries=soul.boundaries,
@@ -254,11 +270,11 @@ class RaiseExpertTool(BaseTool):
)
return ExpertChangeProposedResponse(
message=(
- "Nothing created yet. Read the full charter back to the "
- "user — name, role, color, what this expert owns, where "
- "they stop, voice and weekly budget — and only after they "
- "explicitly approve, call confirm_expert_change with this "
- "confirmation_id."
+ "Nothing created yet. The user is looking at this charter on "
+ "a card with Approve and Decline buttons — do not repeat any "
+ "of it in text. Reply with one short line at most and wait. "
+ "Only after they explicitly approve, call "
+ "confirm_expert_change with this confirmation_id."
),
session_id=session_id,
preview=preview,
diff --git a/autogpt_platform/backend/backend/copilot/tools/update_expert.py b/autogpt_platform/backend/backend/copilot/tools/update_expert.py
index bbbfcc561a..cff5a9f26b 100644
--- a/autogpt_platform/backend/backend/copilot/tools/update_expert.py
+++ b/autogpt_platform/backend/backend/copilot/tools/update_expert.py
@@ -166,6 +166,7 @@ class UpdateExpertTool(BaseTool):
kind="update",
name=merged.name,
role=expert.role,
+ tagline=expert.tagline or "",
about=merged.identity,
boundaries=merged.boundaries,
voice_preferences=merged.voice_preferences,
diff --git a/autogpt_platform/frontend/src/app/(platform)/copilot/components/ArtifactPanel/__tests__/helpers.test.ts b/autogpt_platform/frontend/src/app/(platform)/copilot/components/ArtifactPanel/__tests__/helpers.test.ts
index 66004bc953..4349b79a46 100644
--- a/autogpt_platform/frontend/src/app/(platform)/copilot/components/ArtifactPanel/__tests__/helpers.test.ts
+++ b/autogpt_platform/frontend/src/app/(platform)/copilot/components/ArtifactPanel/__tests__/helpers.test.ts
@@ -1,5 +1,44 @@
import { describe, expect, it } from "vitest";
-import { classifyArtifact } from "../helpers";
+import { classifyArtifact, classifyArtifactRef } from "../helpers";
+
+describe("classifyArtifactRef", () => {
+ it("classifies an expert ref without touching the file tables", () => {
+ const c = classifyArtifactRef({
+ id: "expert:call-1",
+ title: "Otto",
+ mimeType: null,
+ sourceUrl: "",
+ origin: "agent",
+ expert: {
+ id: null,
+ kind: "raise",
+ name: "Otto",
+ role: null,
+ color: null,
+ tagline: null,
+ about: null,
+ boundaries: null,
+ voicePreferences: null,
+ weeklyBudget: null,
+ avatarUrl: null,
+ applied: false,
+ },
+ });
+ expect(c.type).toBe("expert");
+ expect(c.hasSourceToggle).toBe(false);
+ });
+
+ it("falls through to the file classifier otherwise", () => {
+ const c = classifyArtifactRef({
+ id: "f",
+ title: "report.pdf",
+ mimeType: null,
+ sourceUrl: "/x",
+ origin: "agent",
+ });
+ expect(c.type).toBe("pdf");
+ });
+});
describe("classifyArtifact", () => {
it("routes PDF by extension", () => {
diff --git a/autogpt_platform/frontend/src/app/(platform)/copilot/components/ArtifactPanel/components/ArtifactContent.tsx b/autogpt_platform/frontend/src/app/(platform)/copilot/components/ArtifactPanel/components/ArtifactContent.tsx
index 7a65188b86..329d308f91 100644
--- a/autogpt_platform/frontend/src/app/(platform)/copilot/components/ArtifactPanel/components/ArtifactContent.tsx
+++ b/autogpt_platform/frontend/src/app/(platform)/copilot/components/ArtifactPanel/components/ArtifactContent.tsx
@@ -9,6 +9,7 @@ import type { ArtifactClassification } from "../helpers";
import { ArtifactErrorBoundary } from "./ArtifactErrorBoundary";
import { ArtifactReactPreview } from "./ArtifactReactPreview";
import { ArtifactSkeleton } from "./ArtifactSkeleton";
+import { ExpertArtifactContent } from "./ExpertArtifactContent";
import {
FRAGMENT_LINK_INTERCEPTOR_SCRIPT,
TAILWIND_CDN_URL,
@@ -309,6 +310,9 @@ function ArtifactRenderer({
}
export function ArtifactContent(props: Props) {
+ if (props.artifact.expert) {
+ return <ExpertArtifactContent expert={props.artifact.expert} />;
+ }
return (
<Suspense fallback={<ArtifactSkeleton />}>
<ArtifactContentLoader {...props} />
diff --git a/autogpt_platform/frontend/src/app/(platform)/copilot/components/ArtifactPanel/components/ArtifactPanelHeader.tsx b/autogpt_platform/frontend/src/app/(platform)/copilot/components/ArtifactPanel/components/ArtifactPanelHeader.tsx
index 090360b8af..154f3f5094 100644
--- a/autogpt_platform/frontend/src/app/(platform)/copilot/components/ArtifactPanel/components/ArtifactPanelHeader.tsx
+++ b/autogpt_platform/frontend/src/app/(platform)/copilot/components/ArtifactPanel/components/ArtifactPanelHeader.tsx
@@ -78,6 +78,9 @@ export function ArtifactPanelHeader({
onSourceToggle,
hasExternalClose = false,
}: Props) {
+ // An expert is not a workspace file: nothing to download, and "All files"
+ // would strand the user in the wrong tab.
+ const isFile = !artifact.expert;
// Height matches the chat thread header (36px avatar + py-2 + border) so
// the two top bars share one seam across the panel split.
return (
@@ -119,12 +122,16 @@ export function ArtifactPanelHeader({
<Icon icon={Copy01Icon} size={16} />
</HeaderButton>
)}
- <HeaderButton onClick={onDownload} title="Download">
- <Icon icon={Download01Icon} size={16} />
- </HeaderButton>
- <HeaderButton onClick={onOpenFiles} title="All files">
- <Icon icon={Folder01Icon} size={16} />
- </HeaderButton>
+ {isFile && (
+ <HeaderButton onClick={onDownload} title="Download">
+ <Icon icon={Download01Icon} size={16} />
+ </HeaderButton>
+ )}
+ {isFile && (
+ <HeaderButton onClick={onOpenFiles} title="All files">
+ <Icon icon={Folder01Icon} size={16} />
+ </HeaderButton>
+ )}
{!hasExternalClose && (
<HeaderButton onClick={onClose} title="Close">
<Icon icon={Cancel01Icon} size={16} />
diff --git a/autogpt_platform/frontend/src/app/(platform)/copilot/components/ArtifactPanel/components/ExpertArtifactContent.tsx b/autogpt_platform/frontend/src/app/(platform)/copilot/components/ArtifactPanel/components/ExpertArtifactContent.tsx
new file mode 100644
index 0000000000..b33fefbf7d
--- /dev/null
+++ b/autogpt_platform/frontend/src/app/(platform)/copilot/components/ArtifactPanel/components/ExpertArtifactContent.tsx
@@ -0,0 +1,131 @@
+"use client";
+
+import { useGetExpert } from "@/app/api/__generated__/endpoints/experts/experts";
+import { okData } from "@/app/api/helpers";
+import { swatchClassFor } from "@/app/(platform)/raise/components/ColorStep/helpers";
+import { ExpertAvatar } from "@/components/molecules/ExpertAvatar/ExpertAvatar";
+import { cn } from "@/lib/utils";
+import type { ExpertArtifact } from "../../../store";
+
+interface Props {
+ expert: ExpertArtifact;
+}
+
+interface SectionProps {
+ title: string;
+ text: string;
+}
+
+// Same section labels as the team page's soul editor (SoulDrawer), so the
+// charter reads the same here as where it gets edited.
+const LABEL =
+ "mb-1.5 text-xs font-medium uppercase tracking-[0.12em] text-zinc-700";
+
+function Section({ title, text }: SectionProps) {
+ return (
+ <section>
+ <div className={LABEL}>{title}</div>
+ <p className="whitespace-pre-line text-sm leading-relaxed text-zinc-600">
+ {text}
+ </p>
+ </section>
+ );
+}
+
+const KIND_LABELS: Record<NonNullable<ExpertArtifact["kind"]>, string> = {
+ hire: "Hired from the roster",
+ raise: "Raised from a charter",
+ update: "Charter update",
+};
+
+/** Messages saved before the applied response carried the charter only
+ * hold the summary — for those, the expert record itself fills the gaps. */
+function useCharterFallback(artifact: ExpertArtifact): ExpertArtifact {
+ const missing = !!artifact.id && !artifact.about && !artifact.boundaries;
+ const query = useGetExpert(artifact.id ?? "", {
+ query: { select: (res) => okData(res) ?? null, enabled: missing },
+ });
+ const record = missing ? query.data : null;
+ if (!record) return artifact;
+ return {
+ ...artifact,
+ role: artifact.role ?? record.role,
+ tagline: artifact.tagline ?? record.tagline ?? null,
+ about: record.identity || null,
+ boundaries: record.boundaries || null,
+ voicePreferences:
+ artifact.voicePreferences ?? (record.voice_preferences || null),
+ weeklyBudget: artifact.weeklyBudget ?? record.weekly_budget ?? null,
+ avatarUrl: artifact.avatarUrl ?? record.avatar_url ?? null,
+ color: artifact.color ?? (record.color || null),
+ };
+}
+
+/** The whole charter of a proposed or newly created expert — the card in
+ * the chat shows one line, this is everything the model wrote for them. */
+export function ExpertArtifactContent({ expert: artifact }: Props) {
+ const expert = useCharterFallback(artifact);
+ const status = expert.applied
+ ? "On the team"
+ : "Proposed — nothing created yet";
+
+ return (
+ <div className="flex flex-1 flex-col gap-6 overflow-y-auto p-5">
+ <div className="flex items-center gap-3">
+ <ExpertAvatar
+ name={expert.name}
+ avatarUrl={expert.avatarUrl}
+ size={48}
+ />
+ <div className="min-w-0">
+ <p className="truncate text-base font-semibold text-zinc-900">
+ {expert.name}
+ </p>
+ {expert.role && (
+ <p className="truncate text-sm text-zinc-500">{expert.role}</p>
+ )}
+ </div>
+ </div>
+ {expert.tagline && (
+ <p className="text-sm leading-relaxed text-zinc-700">
+ {expert.tagline}
+ </p>
+ )}
+ <Section title="Status" text={status} />
+ {expert.kind && <Section title="Kind" text={KIND_LABELS[expert.kind]} />}
+ {expert.about && (
+ <Section title="Identity and personality" text={expert.about} />
+ )}
+ {expert.voicePreferences && (
+ <Section title="Voice" text={expert.voicePreferences} />
+ )}
+ {expert.boundaries && (
+ <Section title="Boundaries" text={expert.boundaries} />
+ )}
+ <Section
+ title="Weekly budget"
+ text={
+ expert.weeklyBudget === null
+ ? "Default"
+ : `${expert.weeklyBudget} credits`
+ }
+ />
+ {expert.color && swatchClassFor(expert.color) && (
+ <section>
+ <div className={LABEL}>Accent</div>
+ <div className="flex items-center gap-2 text-sm text-zinc-600">
+ <span
+ aria-hidden="true"
+ className={cn(
+ "size-4 rounded-full",
+ swatchClassFor(expert.color),
+ )}
+ />
+ {expert.color}
+ </div>
+ </section>
+ )}
+ {expert.id && <Section title="Expert ID" text={expert.id} />}
+ </div>
+ );
+}
diff --git a/autogpt_platform/frontend/src/app/(platform)/copilot/components/ArtifactPanel/components/__tests__/ExpertArtifactContent.test.tsx b/autogpt_platform/frontend/src/app/(platform)/copilot/components/ArtifactPanel/components/__tests__/ExpertArtifactContent.test.tsx
new file mode 100644
index 0000000000..707f67efb3
--- /dev/null
+++ b/autogpt_platform/frontend/src/app/(platform)/copilot/components/ArtifactPanel/components/__tests__/ExpertArtifactContent.test.tsx
@@ -0,0 +1,108 @@
+import { render, screen } from "@/tests/integrations/test-utils";
+import { describe, expect, it, vi } from "vitest";
+import type { ExpertArtifact } from "../../../../store";
+import { ExpertArtifactContent } from "../ExpertArtifactContent";
+
+const fetched = {
+ enabled: false,
+ record: {
+ identity: "You ship the frontend.",
+ boundaries: "You never touch the backend.",
+ voice_preferences: "Crisp.",
+ weekly_budget: 500,
+ role: "Frontend Engineer",
+ tagline: null,
+ avatar_url: null,
+ color: "",
+ },
+};
+vi.mock("@/app/api/__generated__/endpoints/experts/experts", () => ({
+ useGetExpert: (
+ _id: string,
+ options: { query: { enabled: boolean; select: (r: unknown) => unknown } },
+ ) => {
+ fetched.enabled = options.query.enabled;
+ return {
+ data: options.query.enabled
+ ? options.query.select({ status: 200, data: fetched.record })
+ : undefined,
+ };
+ },
+}));
+
+function expert(overrides: Partial<ExpertArtifact> = {}): ExpertArtifact {
+ return {
+ id: null,
+ kind: "raise",
+ name: "Otto",
+ role: "Inbox triage",
+ color: "violet-300",
+ tagline: "Sorts your morning inbox.",
+ about: "You group the morning inbox.",
+ boundaries: "You never send a reply yourself.",
+ voicePreferences: "Plain sentences.",
+ weeklyBudget: 2000,
+ avatarUrl: null,
+ applied: false,
+ ...overrides,
+ };
+}
+
+describe("ExpertArtifactContent", () => {
+ it("lays out every detail the proposal carries", () => {
+ render(<ExpertArtifactContent expert={expert()} />);
+
+ expect(screen.getByText("Otto")).toBeDefined();
+ expect(screen.getByText("Inbox triage")).toBeDefined();
+ expect(screen.getByText("Sorts your morning inbox.")).toBeDefined();
+ expect(screen.getByText(/nothing created yet/i)).toBeDefined();
+ expect(screen.getByText("Raised from a charter")).toBeDefined();
+ expect(screen.getByText("You group the morning inbox.")).toBeDefined();
+ expect(screen.getByText("You never send a reply yourself.")).toBeDefined();
+ expect(screen.getByText("Plain sentences.")).toBeDefined();
+ expect(screen.getByText("2000 credits")).toBeDefined();
+ expect(screen.getByText("violet-300")).toBeDefined();
+ expect(screen.queryByRole("link")).toBeNull();
+ });
+
+ it("reads a default budget and the team status once applied", () => {
+ render(
+ <ExpertArtifactContent
+ expert={expert({ id: "exp-1", applied: true, weeklyBudget: null })}
+ />,
+ );
+
+ expect(screen.getByText("On the team")).toBeDefined();
+ expect(screen.getByText("Default")).toBeDefined();
+ expect(screen.getByText("exp-1")).toBeDefined();
+ expect(screen.queryByRole("link")).toBeNull();
+ });
+
+ it("fills a saved applied card's missing charter from the expert record", () => {
+ render(
+ <ExpertArtifactContent
+ expert={expert({
+ id: "exp-1",
+ applied: true,
+ about: null,
+ boundaries: null,
+ voicePreferences: null,
+ weeklyBudget: null,
+ })}
+ />,
+ );
+
+ expect(fetched.enabled).toBe(true);
+ expect(screen.getByText("You ship the frontend.")).toBeDefined();
+ expect(screen.getByText("You never touch the backend.")).toBeDefined();
+ expect(screen.getByText("Crisp.")).toBeDefined();
+ expect(screen.getByText("500 credits")).toBeDefined();
+ });
+
+ it("does not fetch when the charter is already there", () => {
+ render(<ExpertArtifactContent expert={expert({ id: "exp-1" })} />);
+
+ expect(fetched.enabled).toBe(false);
+ expect(screen.getByText("You group the morning inbox.")).toBeDefined();
+ });
+});
diff --git a/autogpt_platform/frontend/src/app/(platform)/copilot/components/ArtifactPanel/helpers.ts b/autogpt_platform/frontend/src/app/(platform)/copilot/components/ArtifactPanel/helpers.ts
index eb636f2a26..796d950459 100644
--- a/autogpt_platform/frontend/src/app/(platform)/copilot/components/ArtifactPanel/helpers.ts
+++ b/autogpt_platform/frontend/src/app/(platform)/copilot/components/ArtifactPanel/helpers.ts
@@ -5,9 +5,11 @@ import {
HtmlFile01Icon,
Image01Icon,
TableIcon,
+ UserIcon,
Video01Icon,
} from "@hugeicons/core-free-icons";
import type { IconSvgElement } from "@hugeicons/react";
+import type { ArtifactRef } from "../../store";
export interface ArtifactClassification {
type:
@@ -21,7 +23,8 @@ export interface ArtifactClassification {
| "video"
| "pdf"
| "text"
- | "download-only";
+ | "download-only"
+ | "expert";
icon: IconSvgElement;
label: string;
openable: boolean;
@@ -265,6 +268,20 @@ const NATIVELY_RENDERED = new Set<ArtifactClassification["type"]>([
"pdf",
]);
+const EXPERT_CLASSIFICATION: ArtifactClassification = {
+ type: "expert",
+ icon: UserIcon,
+ label: "Expert",
+ openable: true,
+ hasSourceToggle: false,
+};
+
+/** An expert ref is not a file — it skips the MIME/extension tables. */
+export function classifyArtifactRef(ref: ArtifactRef): ArtifactClassification {
+ if (ref.expert) return EXPERT_CLASSIFICATION;
+ return classifyArtifact(ref.mimeType, ref.title, ref.sizeBytes);
+}
+
export function classifyArtifact(
mimeType: string | null,
filename?: string,
diff --git a/autogpt_platform/frontend/src/app/(platform)/copilot/components/ArtifactPanel/useArtifactPanel.ts b/autogpt_platform/frontend/src/app/(platform)/copilot/components/ArtifactPanel/useArtifactPanel.ts
index de87913797..caea6951a4 100644
--- a/autogpt_platform/frontend/src/app/(platform)/copilot/components/ArtifactPanel/useArtifactPanel.ts
+++ b/autogpt_platform/frontend/src/app/(platform)/copilot/components/ArtifactPanel/useArtifactPanel.ts
@@ -5,7 +5,7 @@ import { useEffect, useState } from "react";
import { useCopilotUIStore } from "../../store";
import { getCachedArtifactContent } from "./components/useArtifactContent";
import { downloadArtifact } from "./downloadArtifact";
-import { classifyArtifact } from "./helpers";
+import { classifyArtifactRef } from "./helpers";
export function useArtifactPanel() {
const artifactPanel = useCopilotUIStore((s) => s.artifactPanel);
@@ -22,11 +22,7 @@ export function useArtifactPanel() {
const { activeArtifact } = artifactPanel;
const classification = activeArtifact
- ? classifyArtifact(
- activeArtifact.mimeType,
- activeArtifact.title,
- activeArtifact.sizeBytes,
- )
+ ? classifyArtifactRef(activeArtifact)
: null;
// Reset source view when switching artifacts
@@ -43,7 +39,8 @@ export function useArtifactPanel() {
classification.type !== "image" &&
classification.type !== "video" &&
classification.type !== "download-only" &&
- classification.type !== "pdf";
+ classification.type !== "pdf" &&
+ classification.type !== "expert";
function handleCopy() {
if (!activeArtifact || !canCopy) return;
diff --git a/autogpt_platform/frontend/src/app/(platform)/copilot/components/ChatMessagesContainer/components/ChainMessageParts.tsx b/autogpt_platform/frontend/src/app/(platform)/copilot/components/ChatMessagesContainer/components/ChainMessageParts.tsx
index 7500d9a665..4fdc1b4e1f 100644
--- a/autogpt_platform/frontend/src/app/(platform)/copilot/components/ChatMessagesContainer/components/ChainMessageParts.tsx
+++ b/autogpt_platform/frontend/src/app/(platform)/copilot/components/ChatMessagesContainer/components/ChainMessageParts.tsx
@@ -1,4 +1,6 @@
import { isChainableToolPart, type MessagePart } from "../helpers";
+import type { ToolUIPart } from "ai";
+import { ExpertChangeGroup } from "../../ToolChain/ExpertCards";
import { buildChainSegments } from "../../ToolChain/helpers";
import { ToolChain } from "../../ToolChain/ToolChain";
import type {
@@ -50,6 +52,16 @@ export function ChainMessageParts({
/>
);
}
+ if (segment.kind === "experts") {
+ return (
+ <ExpertChangeGroup
+ key={`${messageID}-experts-${segment.index}`}
+ parts={segment.parts as ToolUIPart[]}
+ isCurrentlyStreaming={isCurrentlyStreaming}
+ readOnly={readOnly}
+ />
+ );
+ }
return (
<MessagePartRenderer
key={`${messageID}-${segment.index}`}
diff --git a/autogpt_platform/frontend/src/app/(platform)/copilot/components/ChatMessagesContainer/components/__tests__/ChainMessageParts.test.tsx b/autogpt_platform/frontend/src/app/(platform)/copilot/components/ChatMessagesContainer/components/__tests__/ChainMessageParts.test.tsx
index 94aa58c0dc..bb495b9422 100644
--- a/autogpt_platform/frontend/src/app/(platform)/copilot/components/ChatMessagesContainer/components/__tests__/ChainMessageParts.test.tsx
+++ b/autogpt_platform/frontend/src/app/(platform)/copilot/components/ChatMessagesContainer/components/__tests__/ChainMessageParts.test.tsx
@@ -13,6 +13,12 @@ vi.mock("../MessagePartRenderer", () => ({
MessagePartRenderer: () => <div data-testid="message-part" />,
}));
+vi.mock("../../../ToolChain/ExpertCards", () => ({
+ ExpertChangeGroup: ({ parts }: { parts: unknown[] }) => (
+ <div data-testid="expert-group" data-count={parts.length} />
+ ),
+}));
+
describe("ChainMessageParts", () => {
afterEach(cleanup);
@@ -40,4 +46,42 @@ describe("ChainMessageParts", () => {
expect(screen.getByTestId("tool-chain").dataset.streaming).toBe("true");
expect(screen.getByTestId("message-part")).toBeDefined();
});
+
+ it("renders expert approvals as one group outside the chain", () => {
+ const parts = [
+ {
+ type: "tool-web_search",
+ state: "output-available",
+ toolCallId: "search",
+ input: {},
+ output: {},
+ },
+ {
+ type: "tool-raise_expert",
+ state: "output-available",
+ toolCallId: "raise-1",
+ input: {},
+ output: { type: "expert_change_proposed" },
+ },
+ {
+ type: "tool-raise_expert",
+ state: "output-available",
+ toolCallId: "raise-2",
+ input: {},
+ output: { type: "expert_change_proposed" },
+ },
+ ] as MessagePart[];
+
+ render(
+ <ChainMessageParts
+ parts={parts}
+ messageID="message"
+ isCurrentlyStreaming={false}
+ />,
+ );
+
+ expect(screen.getAllByTestId("tool-chain").length).toBe(1);
+ expect(screen.getByTestId("expert-group").dataset.count).toBe("2");
+ expect(screen.queryByTestId("message-part")).toBeNull();
+ });
});
diff --git a/autogpt_platform/frontend/src/app/(platform)/copilot/components/ChatMessagesContainer/helpers.ts b/autogpt_platform/frontend/src/app/(platform)/copilot/components/ChatMessagesContainer/helpers.ts
index 8b5703985d..8845fbb2c8 100644
--- a/autogpt_platform/frontend/src/app/(platform)/copilot/components/ChatMessagesContainer/helpers.ts
+++ b/autogpt_platform/frontend/src/app/(platform)/copilot/components/ChatMessagesContainer/helpers.ts
@@ -8,7 +8,7 @@ import {
type CompactionPhase,
type CompactionStats,
} from "../CompactionCard/helpers";
-import { COMPACTION_PART_TYPE } from "../ToolChain/helpers";
+import { COMPACTION_PART_TYPE, isExpertChangePart } from "../ToolChain/helpers";
export type MessagePart = UIMessage<
unknown,
@@ -19,8 +19,12 @@ export type MessagePart = UIMessage<
// Every assistant tool renders inside the ToolChain. ToolResult supplies a
// compact result view for known backend tools and a structured fallback for
// SDK or future tools, so no tool ever renders as a bare top-level part.
+// Compaction and expert changes are the exceptions: each owns a card that
+// must stay on screen, so they render as parts of their own.
export function isChainableToolPart(part: MessagePart): boolean {
- if (part.type === COMPACTION_PART_TYPE) return false;
+ if (part.type === COMPACTION_PART_TYPE || isExpertChangePart(part)) {
+ return false;
+ }
return part.type === "reasoning" || part.type.startsWith("tool-");
}
diff --git a/autogpt_platform/frontend/src/app/(platform)/copilot/components/ToolChain/ChainRowView.tsx b/autogpt_platform/frontend/src/app/(platform)/copilot/components/ToolChain/ChainRowView.tsx
index 2e5a0929c8..21d3bdcb63 100644
--- a/autogpt_platform/frontend/src/app/(platform)/copilot/components/ToolChain/ChainRowView.tsx
+++ b/autogpt_platform/frontend/src/app/(platform)/copilot/components/ToolChain/ChainRowView.tsx
@@ -6,7 +6,6 @@ import { Icon } from "@/components/atoms/Icon/Icon";
import { cn } from "@/lib/utils";
import { useCopilotUIStore } from "../../store";
import { ACCORDION_PANEL, accordionState, PANEL_REVEAL } from "./accordion";
-import { EXPERT_CHANGE_TOOLS } from "./ExpertCards";
import type { ChainRow } from "./helpers";
import { ProviderIcon, RowIcon } from "./RowIcon";
import { useSubSessionEffectiveStatus } from "./SubSessionLive";
@@ -120,22 +119,10 @@ export function ChainRowView({ row, isLast }: Props) {
);
const liveReasoning =
isReasoning && row.state === "running" && !!row.reasoningText;
- // An expert being hired/raised has no output until it lands — the skeleton
- // card stands in for it, so the row has something to show while running.
- const pendingExpertChange =
- !!row.tool &&
- EXPERT_CHANGE_TOOLS.has(row.tool) &&
- row.output === undefined &&
- row.state === "running";
const hasContent = isReasoning
? !!row.reasoningText
: !row.supersededSubSession &&
- ((row.output !== undefined && row.output !== "") ||
- liveSubSession ||
- pendingExpertChange);
- useEffect(() => {
- if (pendingExpertChange) setOpen(true);
- }, [pendingExpertChange]);
+ ((row.output !== undefined && row.output !== "") || liveSubSession);
const showContent = liveReasoning || (open && hasContent);
const rowText = (
<SwapText
@@ -204,7 +191,7 @@ export function ChainRowView({ row, isLast }: Props) {
<div className={ACCORDION_PANEL + " " + accordionState(showContent)}>
<div
aria-hidden={!showContent}
- inert={!showContent ? ("" as unknown as boolean) : undefined}
+ inert={!showContent || undefined}
className="min-h-0 overflow-hidden"
>
<div
diff --git a/autogpt_platform/frontend/src/app/(platform)/copilot/components/ToolChain/ExpertCards.tsx b/autogpt_platform/frontend/src/app/(platform)/copilot/components/ToolChain/ExpertCards.tsx
index 75a68a7b71..c0f12298f6 100644
--- a/autogpt_platform/frontend/src/app/(platform)/copilot/components/ToolChain/ExpertCards.tsx
+++ b/autogpt_platform/frontend/src/app/(platform)/copilot/components/ToolChain/ExpertCards.tsx
@@ -1,176 +1,550 @@
"use client";
import {
- ArrowDown01Icon,
- BubbleChatIcon,
- CheckmarkCircle02Icon,
- PencilIcon,
+ ArrowLeft01Icon,
+ ArrowRight01Icon,
+ InformationCircleIcon,
+ PencilEdit02Icon,
+ SentIcon,
+ UndoIcon,
+ Tick02Icon,
+ UserAdd01Icon,
} from "@hugeicons/core-free-icons";
-import Link from "next/link";
-import { useId, useState } from "react";
+import type { IconSvgElement } from "@hugeicons/react";
+import type { ToolUIPart } from "ai";
+import { type ReactNode, useState } from "react";
+import { Button } from "@/components/atoms/Button/Button";
import { Icon } from "@/components/atoms/Icon/Icon";
import { Skeleton } from "@/components/atoms/Skeleton/Skeleton";
import { ExpertAvatar } from "@/components/molecules/ExpertAvatar/ExpertAvatar";
import { cn } from "@/lib/utils";
-import { CARD } from "./ResultCards";
+import { Flag, useGetFlag } from "@/services/feature-flags/use-get-flag";
+import { GenericTool } from "../../tools/GenericTool/GenericTool";
+import { type ArtifactRef, useCopilotUIStore } from "../../store";
import { asObject, str } from "./resultHelpers";
-import { useCardResize } from "./useCardResize";
-
-export const EXPERT_CHANGE_TOOLS = new Set([
- "hire_expert",
- "raise_expert",
- "update_expert",
- "confirm_expert_change",
-]);
interface Props {
output: Record<string, unknown>;
+ /** Stable key for the panel's history — the tool call that produced
+ * the card. Without one, Show more expands inline instead. */
+ artifactId?: string;
+ /** Pager controls when several experts share one card slot. */
+ pager?: ReactNode;
+ /** The decision already taken on this proposal, if any. */
+ decision?: Decision | null;
+ /** Offered while the proposal is still open; absent once applied, on a
+ * read-only transcript, or when the output carries no confirmation. */
+ onDecide?: (decision: Decision) => void;
+ /** Takes the decision back so Approve/Decline can be chosen again. */
+ onUndo?: () => void;
+ /** Footer control the group adds once every proposal is decided. */
+ action?: ReactNode;
+ /** Which way the pager just moved — the identity block slides in from
+ * that side while the shell (Details, pager, decision) stays put. */
+ stepDirection?: StepDirection;
}
-const APPLIED_LABELS: Record<string, string> = {
- hire: "Hired",
- raise: "Raised",
- update: "Updated",
-};
-
-function failedWorkflows(output: Record<string, unknown>): string[] {
- const value = output.failed_workflows;
- if (!Array.isArray(value)) return [];
- return value.filter(
- (entry): entry is string => typeof entry === "string" && !!entry.trim(),
- );
+export type StepDirection = "forward" | "back";
+
+export type Decision = "approved" | "declined";
+
+// Same shell as the chain's action card (connect / inputs / questions) so
+// every "your turn" card in the thread reads as one family.
+const SHELL =
+ "w-full overflow-hidden rounded-3xl border border-zinc-100 bg-white";
+const HEADER = "flex items-center gap-2.5 border-b border-zinc-100 px-4 py-3";
+const FOOTER =
+ "flex items-center justify-between gap-2 border-t border-zinc-100 px-4 py-3";
+
+type ExpertKind = "hire" | "raise" | "update";
+
+function kindOf(output: Record<string, unknown>): ExpertKind | null {
+ const preview = asObject(output.preview);
+ const kind = str(output, "kind") ?? (preview ? str(preview, "kind") : null);
+ return kind === "hire" || kind === "raise" || kind === "update" ? kind : null;
+}
+
+function headerFor(
+ kind: ExpertKind | null,
+ applied: boolean,
+): { icon: IconSvgElement; title: string } {
+ const icon = kind === "update" ? PencilEdit02Icon : UserAdd01Icon;
+ if (applied) {
+ return {
+ icon,
+ title:
+ kind === "hire"
+ ? "Expert hired"
+ : kind === "update"
+ ? "Expert updated"
+ : "Expert raised",
+ };
+ }
+ return {
+ icon,
+ title:
+ kind === "hire"
+ ? "Hire an expert"
+ : kind === "update"
+ ? "Update an expert"
+ : "Raise an expert",
+ };
+}
+
+interface Proposal {
+ toolCallId: string;
+ kind: ExpertKind | null;
+ name: string;
+ confirmationId: string;
+}
+
+/** A hire/raise preview the user can still say yes or no to. */
+function proposalOf(part: ToolUIPart): Proposal | null {
+ const output = asObject(part.output);
+ if (!output || output.applied === true) return null;
+ const confirmationId = str(output, "confirmation_id");
+ const preview = asObject(output.preview);
+ if (!confirmationId || !preview) return null;
+ return {
+ toolCallId: part.toolCallId,
+ kind: kindOf(output),
+ name: str(preview, "name") ?? "this expert",
+ confirmationId,
+ };
+}
+
+function decisionLine(proposal: Proposal, decision: Decision): string {
+ const verb =
+ proposal.kind === "hire"
+ ? "hire"
+ : proposal.kind === "update"
+ ? "update"
+ : "create";
+ return decision === "approved"
+ ? `Approved: ${verb} ${proposal.name} (confirmation_id: ${proposal.confirmationId}).`
+ : `Not approved: do not ${verb} ${proposal.name}, discard that proposal (confirmation_id: ${proposal.confirmationId}).`;
}
-/** An expert inside the chain — either a hire/raise preview awaiting the
- * user's OK (given in chat, nothing created yet) or the teammate
- * ``confirm_expert_change`` actually created. Once they exist, the card
- * offers the two things the user does next: adjust them or talk to them. */
-export function ExpertChangeCard({ output }: Props) {
- const [expanded, setExpanded] = useState(false);
- const detailsID = useId();
- const { contentRef, height } = useCardResize(expanded);
- const applied = output.applied === true;
+function toExpertArtifact(
+ expert: Record<string, unknown>,
+ output: Record<string, unknown>,
+ artifactId: string,
+): ArtifactRef {
+ const name = str(expert, "name") ?? "New expert";
+ return {
+ id: `expert:${artifactId}`,
+ title: name,
+ mimeType: null,
+ sourceUrl: "",
+ origin: "agent",
+ expert: {
+ id: str(expert, "id") ?? null,
+ kind: kindOf(output),
+ name,
+ role: str(expert, "role") ?? null,
+ color: str(expert, "color") ?? null,
+ tagline: str(expert, "tagline") ?? null,
+ about: str(expert, "about") ?? null,
+ boundaries: str(expert, "boundaries") ?? null,
+ voicePreferences: str(expert, "voice_preferences") ?? null,
+ weeklyBudget:
+ typeof expert.weekly_budget === "number" ? expert.weekly_budget : null,
+ avatarUrl: str(expert, "avatar_url") ?? null,
+ applied: output.applied === true,
+ },
+ };
+}
+
+/** An expert change as its own message part — either a hire/raise preview
+ * awaiting the user's OK (given in chat, nothing created yet) or the
+ * teammate ``confirm_expert_change`` actually created. Both read the same:
+ * who this is, in one glance. The tagline is written for the user; the
+ * charter (identity, boundaries) is written for the expert and stays
+ * under Show more, which opens the full charter in the side panel — or,
+ * where the panel is not available, unfolds it inline. Experts raised
+ * before taglines existed fall back to the charter as their one line. */
+export function ExpertChangeCard({
+ output,
+ artifactId,
+ pager,
+ decision = null,
+ onDecide,
+ onUndo,
+ action,
+ stepDirection,
+}: Props) {
+ const [showCharter, setShowCharter] = useState(false);
+ const openArtifact = useCopilotUIStore((s) => s.openArtifact);
+ const panelAvailable = useGetFlag(Flag.ARTIFACTS) && !!artifactId;
const expert = asObject(output.expert) ?? asObject(output.preview);
if (!expert) return null;
- const id = str(expert, "id");
+ function handleShowMore() {
+ if (panelAvailable && expert && artifactId) {
+ openArtifact(toExpertArtifact(expert, output, artifactId));
+ return;
+ }
+ setShowCharter(!showCharter);
+ }
+
const name = str(expert, "name") ?? "New expert";
const role = str(expert, "role");
+ const tagline = str(expert, "tagline");
const about = str(expert, "about");
const boundaries = str(expert, "boundaries");
- const budget =
- typeof expert.weekly_budget === "number" ? expert.weekly_budget : null;
- const appliedLabel = APPLIED_LABELS[str(output, "kind") ?? ""] ?? "Done";
- const failed = applied ? failedWorkflows(output) : [];
- const clampable = !!about || !!boundaries;
- const clamp = expanded ? undefined : "line-clamp-2";
+ const summary = tagline ?? about;
+ // The panel always has the full charter to show; inline, the button only
+ // earns its place when the one-line summary leaves something out.
+ const hasCharter = (!!tagline && !!about) || !!boundaries;
+ const showDetails = panelAvailable || hasCharter;
+ const showFooter = !!pager || !!onDecide || !!decision || !!action;
+ const header = headerFor(kindOf(output), output.applied === true);
return (
- <div className={cn(CARD, "w-full rounded-3xl p-2.5")}>
- <div className="flex items-center gap-2.5">
- <ExpertAvatar
- name={name}
- avatarUrl={str(expert, "avatar_url")}
- size={28}
- />
- <p className="min-w-0 flex-1 truncate text-[13px] font-medium text-zinc-800">
- {name}
- {role && (
- <span className="ml-1.5 font-normal text-zinc-400">{role}</span>
- )}
- </p>
- {applied ? (
- <span className="inline-flex shrink-0 items-center gap-1 rounded-md bg-emerald-50 px-1.5 py-0.5 text-[10px] font-semibold text-emerald-700">
- <Icon icon={CheckmarkCircle02Icon} size={11} />
- {appliedLabel}
- </span>
- ) : (
- <span className="shrink-0 rounded-md bg-amber-50 px-1.5 py-0.5 text-[10px] font-semibold text-amber-700">
- Needs your OK
- </span>
- )}
- {clampable && (
- <button
- type="button"
- onClick={() => setExpanded(!expanded)}
- aria-expanded={expanded}
- aria-controls={detailsID}
- aria-label={expanded ? "Show less" : "Show more"}
- className="group/expand -mr-0.5 flex size-6 shrink-0 items-center justify-center rounded-full transition-colors hover:bg-zinc-100"
- >
- <Icon
- icon={ArrowDown01Icon}
- size={12}
- className={cn(
- "text-zinc-300 transition-transform duration-300 ease-out-quint group-hover/expand:text-zinc-500",
- expanded && "rotate-180",
- )}
- />
- </button>
- )}
+ <div className={SHELL}>
+ <div className={HEADER}>
+ <Icon icon={header.icon} size={18} className="text-zinc-400" />
+ <span className="min-w-0 flex-1 truncate text-sm font-medium text-zinc-900">
+ {header.title}
+ </span>
</div>
- <div
- id={detailsID}
- className="overflow-hidden transition-[height] duration-300 ease-out-quint motion-reduce:transition-none"
- style={{ height }}
- >
- <div ref={contentRef} className="flex flex-col gap-1 pt-1.5">
- {about && (
- <p className={cn("pl-9 text-sm text-zinc-500", clamp)}>{about}</p>
- )}
- {boundaries && (
- <p className={cn("pl-9 text-sm text-zinc-400", clamp)}>
- Stops at: {boundaries}
- </p>
+ <div className="px-4 py-3">
+ <div
+ key={artifactId ?? name}
+ className={cn(
+ "flex items-center gap-2.5",
+ stepDirection &&
+ "duration-300 animate-in fade-in fill-mode-both motion-reduce:animate-none",
+ stepDirection === "forward" && "slide-in-from-right-4",
+ stepDirection === "back" && "slide-in-from-left-4",
)}
- {budget !== null && (
- <p className="pl-9 text-sm text-zinc-600">
- Weekly budget: {budget} credits
+ >
+ <ExpertAvatar
+ name={name}
+ avatarUrl={str(expert, "avatar_url")}
+ size={32}
+ />
+ <div className="min-w-0 flex-1">
+ <p className="truncate text-[13px] font-medium text-zinc-800">
+ {name}
</p>
- )}
- {failed.length > 0 && (
- <p className="pl-9 text-[11px] text-amber-700">
- Couldn&apos;t set up: {failed.join(", ")}. Everything else is
- ready — add {failed.length > 1 ? "them" : "it"} from the
- expert&apos;s page.
- </p>
- )}
- {applied && id && (
- <div className="mt-1.5 flex items-center gap-1.5 pl-9">
- <Link
- href={`/team/${id}`}
- className="inline-flex h-7 items-center gap-1.5 rounded-full border border-zinc-200 px-3 text-xs font-medium text-zinc-600 transition-colors hover:bg-zinc-50 hover:text-zinc-900"
- >
- <Icon icon={PencilIcon} size={13} />
- Edit
- </Link>
- <Link
- href={`/copilot?expertId=${id}`}
- className="inline-flex h-7 items-center gap-1.5 rounded-full bg-zinc-900 px-3 text-xs font-medium text-white transition-colors hover:bg-zinc-700"
- >
- <Icon icon={BubbleChatIcon} size={13} />
- Chat
- </Link>
- </div>
+ {role && <p className="truncate text-xs text-zinc-400">{role}</p>}
+ </div>
+ {showDetails && (
+ <Button
+ variant="secondary"
+ size="small"
+ aria-expanded={panelAvailable ? undefined : showCharter}
+ onClick={handleShowMore}
+ leftIcon={<Icon icon={InformationCircleIcon} size={16} />}
+ className="h-8 !min-w-0 shrink-0 px-3"
+ >
+ {showCharter ? "Hide details" : "Details"}
+ </Button>
)}
</div>
+ {summary && (
+ <p
+ key={`${artifactId ?? name}-summary`}
+ className={cn(
+ "pl-[42px] pt-2 text-sm text-zinc-500",
+ stepDirection &&
+ "delay-75 duration-300 animate-in fade-in fill-mode-both motion-reduce:animate-none",
+ stepDirection === "forward" && "slide-in-from-right-4",
+ stepDirection === "back" && "slide-in-from-left-4",
+ )}
+ >
+ {summary}
+ </p>
+ )}
+ {hasCharter && !panelAvailable && showCharter && (
+ <div className="flex flex-col gap-1 pl-[42px] pt-1.5">
+ {tagline && about && (
+ <p className="text-sm text-zinc-500">{about}</p>
+ )}
+ {boundaries && (
+ <p className="text-sm text-zinc-400">Stops at: {boundaries}</p>
+ )}
+ </div>
+ )}
</div>
+ {showFooter && (
+ <div className={FOOTER}>
+ <div className="min-w-0">{pager}</div>
+ <div className="flex shrink-0 items-center gap-1.5">
+ {decision && onUndo && (
+ <Button
+ variant="secondary"
+ size="small"
+ onClick={onUndo}
+ leftIcon={<Icon icon={UndoIcon} size={14} />}
+ className="h-8 !min-w-0 px-3"
+ >
+ {decision === "approved" ? "Unapprove" : "Undo decline"}
+ </Button>
+ )}
+ {!decision && onDecide && (
+ <>
+ <Button
+ variant="ghost"
+ size="small"
+ onClick={() => onDecide("declined")}
+ className="h-8 !min-w-0 px-3"
+ >
+ Decline
+ </Button>
+ <Button
+ variant="primary"
+ size="small"
+ onClick={() => onDecide("approved")}
+ className="h-8 !min-w-0 px-3"
+ >
+ Approve
+ </Button>
+ </>
+ )}
+ {action}
+ </div>
+ </div>
+ )}
</div>
);
}
export function ExpertChangeCardSkeleton() {
return (
- <div className={cn(CARD, "w-full rounded-3xl p-2.5")}>
- <div className="flex items-center gap-2.5">
- <Skeleton className="size-7 shrink-0 rounded-full" />
- <Skeleton className="h-3.5 w-40" />
- <Skeleton className="ml-auto h-4 w-20 rounded-md" />
+ <div className={SHELL}>
+ <div className={HEADER}>
+ <Icon icon={UserAdd01Icon} size={18} className="text-zinc-400" />
+ <span className="text-sm font-medium text-zinc-900">
+ Raise an expert
+ </span>
</div>
- <div className="flex flex-col gap-1.5 pl-9 pt-2.5">
- <Skeleton className="h-3 w-full" />
- <Skeleton className="h-3 w-4/5" />
+ <div className="px-4 py-3">
+ <div className="flex items-center gap-2.5">
+ <Skeleton className="size-8 shrink-0 rounded-full" />
+ <div className="flex min-w-0 flex-1 flex-col gap-1.5">
+ <Skeleton className="h-3.5 w-28" />
+ <Skeleton className="h-3 w-20" />
+ </div>
+ </div>
+ <div className="flex flex-col gap-1.5 pl-[42px] pt-2.5">
+ <Skeleton className="h-3 w-full" />
+ <Skeleton className="h-3 w-4/5" />
+ </div>
</div>
</div>
);
}
+
+interface PartProps {
+ part: ToolUIPart;
+ isCurrentlyStreaming?: boolean;
+ pager?: ReactNode;
+ decision?: Decision | null;
+ onDecide?: (decision: Decision) => void;
+ onUndo?: () => void;
+ action?: ReactNode;
+ stepDirection?: StepDirection;
+}
+
+/** The expert is still being written while the row has no output — hold
+ * the card's shape so the real one swaps in without the message jumping.
+ * A row still empty once the stream is over never landed, so it renders
+ * nothing rather than a skeleton that never resolves. */
+export function ExpertChangePart({
+ part,
+ isCurrentlyStreaming,
+ pager,
+ decision,
+ onDecide,
+ onUndo,
+ action,
+ stepDirection,
+}: PartProps) {
+ if (part.state === "output-error") return <GenericTool part={part} />;
+ const output = asObject(part.output);
+ if (output) {
+ return (
+ <ExpertChangeCard
+ output={output}
+ artifactId={part.toolCallId}
+ pager={pager}
+ decision={decision}
+ onDecide={onDecide}
+ onUndo={onUndo}
+ action={action}
+ stepDirection={stepDirection}
+ />
+ );
+ }
+ return isCurrentlyStreaming ? <ExpertChangeCardSkeleton /> : null;
+}
+
+function isVisibleExpertPart(
+ part: ToolUIPart,
+ isCurrentlyStreaming: boolean,
+): boolean {
+ return (
+ part.state === "output-error" ||
+ !!asObject(part.output) ||
+ isCurrentlyStreaming
+ );
+}
+
+interface GroupProps {
+ parts: ToolUIPart[];
+ isCurrentlyStreaming?: boolean;
+ /** Share viewer / transcript: the decisions were the owner's to make. */
+ readOnly?: boolean;
+}
+
+/** One hire/raise per call, so a new team lands as several cards in a
+ * row. They page like the clarifying questions do, one expert at a time:
+ * each Approve/Decline moves to the next, and once every proposal has an
+ * answer a single send drafts all of them into the composer — the user
+ * still reads and sends the message themselves. */
+export function ExpertChangeGroup({
+ parts,
+ isCurrentlyStreaming = false,
+ readOnly = false,
+}: GroupProps) {
+ const [step, setStep] = useState(0);
+ const [direction, setDirection] = useState<StepDirection | undefined>();
+ const [decisions, setDecisions] = useState<Record<string, Decision>>({});
+ const [drafted, setDrafted] = useState(false);
+ const setInitialPrompt = useCopilotUIStore((s) => s.setInitialPrompt);
+ const visible = parts.filter((part) =>
+ isVisibleExpertPart(part, isCurrentlyStreaming),
+ );
+ if (visible.length === 0) return null;
+
+ const current = Math.min(step, visible.length - 1);
+ const part = visible[current];
+ const isLast = current === visible.length - 1;
+ const proposals = visible
+ .map(proposalOf)
+ .filter((proposal): proposal is Proposal => proposal !== null);
+ const allDecided =
+ proposals.length > 0 &&
+ proposals.every((proposal) => decisions[proposal.toolCallId]);
+ const currentProposal = readOnly ? null : proposalOf(part);
+
+ function goTo(next: number) {
+ setDirection(next > current ? "forward" : "back");
+ setStep(next);
+ }
+
+ function decide(decision: Decision) {
+ if (!currentProposal) return;
+ setDecisions({ ...decisions, [currentProposal.toolCallId]: decision });
+ if (!isLast) goTo(current + 1);
+ }
+
+ function undo() {
+ if (!currentProposal) return;
+ const { [currentProposal.toolCallId]: _, ...rest } = decisions;
+ setDecisions(rest);
+ // The draft in the composer no longer matches — offer the send again
+ // once every proposal has an answer.
+ setDrafted(false);
+ }
+
+ function draft() {
+ setInitialPrompt(
+ proposals
+ .map((proposal) =>
+ decisionLine(proposal, decisions[proposal.toolCallId]),
+ )
+ .join("\n"),
+ );
+ setDrafted(true);
+ }
+
+ const pager = visible.length > 1 && (
+ <div className="flex items-center gap-2">
+ <button
+ type="button"
+ aria-label="Previous expert"
+ disabled={current === 0}
+ onClick={() => goTo(current - 1)}
+ className="flex size-6 items-center justify-center rounded-lg text-zinc-400 transition-colors enabled:hover:bg-zinc-100 enabled:hover:text-zinc-600 disabled:opacity-35"
+ >
+ <Icon icon={ArrowLeft01Icon} size={14} />
+ </button>
+ <span className="flex items-center gap-1.5">
+ {visible.map(({ toolCallId }, i) => (
+ <button
+ key={toolCallId}
+ type="button"
+ aria-label={`Go to expert ${i + 1}`}
+ aria-current={i === current ? "step" : undefined}
+ data-decision={decisions[toolCallId]}
+ onClick={() => goTo(i)}
+ className={cn(
+ "rounded-full transition-all duration-300",
+ i === current ? "size-2.5 border-2" : "size-2 border",
+ decisions[toolCallId] === "approved"
+ ? "border-emerald-500 bg-emerald-500"
+ : decisions[toolCallId] === "declined"
+ ? "border-red-400 bg-red-400"
+ : i === current
+ ? "border-zinc-800"
+ : "border-zinc-300",
+ )}
+ />
+ ))}
+ </span>
+ <button
+ type="button"
+ aria-label="Next expert"
+ disabled={isLast}
+ onClick={() => goTo(current + 1)}
+ className="flex size-6 items-center justify-center rounded-lg text-zinc-400 transition-colors enabled:hover:bg-zinc-100 enabled:hover:text-zinc-600 disabled:opacity-35"
+ >
+ <Icon icon={ArrowRight01Icon} size={14} />
+ </button>
+ <span className="text-xs text-zinc-400">
+ {current + 1} of {visible.length}
+ </span>
+ </div>
+ );
+
+ const action =
+ !readOnly &&
+ allDecided &&
+ (drafted ? (
+ <span className="flex items-center gap-1 text-xs text-zinc-400">
+ <Icon icon={Tick02Icon} size={14} />
+ Added to message
+ </span>
+ ) : (
+ <Button
+ variant="primary"
+ size="icon"
+ aria-label="Add decisions to message"
+ onClick={draft}
+ className="size-8 p-0"
+ >
+ <Icon icon={SentIcon} size={15} />
+ </Button>
+ ));
+
+ // The shell (Details, pager, decision buttons) is the same from one
+ // expert to the next, so it stays mounted; only the identity block
+ // inside the card slides — see ExpertChangeCard.
+ return (
+ <div className="my-2">
+ <ExpertChangePart
+ part={part}
+ isCurrentlyStreaming={isCurrentlyStreaming}
+ pager={pager || undefined}
+ decision={decisions[part.toolCallId] ?? null}
+ onDecide={currentProposal ? decide : undefined}
+ onUndo={currentProposal ? undo : undefined}
+ action={action || undefined}
+ stepDirection={direction}
+ />
+ </div>
+ );
+}
diff --git a/autogpt_platform/frontend/src/app/(platform)/copilot/components/ToolChain/ToolChain.tsx b/autogpt_platform/frontend/src/app/(platform)/copilot/components/ToolChain/ToolChain.tsx
index ed6e620650..daf4fdf243 100644
--- a/autogpt_platform/frontend/src/app/(platform)/copilot/components/ToolChain/ToolChain.tsx
+++ b/autogpt_platform/frontend/src/app/(platform)/copilot/components/ToolChain/ToolChain.tsx
@@ -225,7 +225,7 @@ export function ToolChain({ parts, isStreaming, readOnly = false }: Props) {
<div
id={panelId}
aria-hidden={!panelOpen}
- inert={!panelOpen ? ("" as unknown as boolean) : undefined}
+ inert={!panelOpen || undefined}
className="min-h-0 overflow-hidden"
>
<div
diff --git a/autogpt_platform/frontend/src/app/(platform)/copilot/components/ToolChain/ToolResult.tsx b/autogpt_platform/frontend/src/app/(platform)/copilot/components/ToolChain/ToolResult.tsx
index af7a1e1eb4..f40db3b8b8 100644
--- a/autogpt_platform/frontend/src/app/(platform)/copilot/components/ToolChain/ToolResult.tsx
+++ b/autogpt_platform/frontend/src/app/(platform)/copilot/components/ToolChain/ToolResult.tsx
@@ -14,7 +14,6 @@ import {
} from "./AgentCards";
import { BlockListCard, BlockOutputCard } from "./BlockCards";
import { ExecutionCard } from "./ExecutionCard";
-import { ExpertChangeCard, ExpertChangeCardSkeleton } from "./ExpertCards";
import { FileDiff } from "./FileDiff";
import { isDiffText } from "./fileDiffHelpers";
import type { ChainRow } from "./helpers";
@@ -277,14 +276,6 @@ function toolCard(row: ChainRow, output: Record<string, unknown> | null) {
<SubSessionPendingCard input={row.input} minimal={delegated} />
) : null;
}
- case "hire_expert":
- case "raise_expert":
- case "update_expert":
- case "confirm_expert_change":
- if (output) return <ExpertChangeCard output={output} />;
- // The expert is still being written — hold the card's shape so the
- // real one swaps in without the row jumping.
- return row.state === "running" ? <ExpertChangeCardSkeleton /> : null;
case "find_agent":
case "find_library_agent": {
const agents = output && asItems(output.agents);
diff --git a/autogpt_platform/frontend/src/app/(platform)/copilot/components/ToolChain/__tests__/ExpertCards.test.tsx b/autogpt_platform/frontend/src/app/(platform)/copilot/components/ToolChain/__tests__/ExpertCards.test.tsx
index c70e30d89f..2bb0ef4960 100644
--- a/autogpt_platform/frontend/src/app/(platform)/copilot/components/ToolChain/__tests__/ExpertCards.test.tsx
+++ b/autogpt_platform/frontend/src/app/(platform)/copilot/components/ToolChain/__tests__/ExpertCards.test.tsx
@@ -1,8 +1,26 @@
-import { render, screen } from "@/tests/integrations/test-utils";
-import { describe, expect, it } from "vitest";
+import { cleanup, render, screen } from "@/tests/integrations/test-utils";
+import userEvent from "@testing-library/user-event";
+import type { ToolUIPart } from "ai";
+import { afterEach, describe, expect, it, vi } from "vitest";
+import { useCopilotUIStore } from "../../../store";
+import {
+ ExpertChangeCard,
+ ExpertChangeGroup,
+ ExpertChangePart,
+} from "../ExpertCards";
import type { ChainRow } from "../helpers";
import { ToolResult } from "../ToolResult";
+vi.mock("../../../tools/GenericTool/GenericTool", () => ({
+ GenericTool: () => <div data-testid="generic-tool" />,
+}));
+
+const artifactsFlag = { enabled: false };
+vi.mock("@/services/feature-flags/use-get-flag", () => ({
+ Flag: { ARTIFACTS: "artifacts" },
+ useGetFlag: () => artifactsFlag.enabled,
+}));
+
function row(tool: string, output: unknown): ChainRow {
return {
key: tool,
@@ -15,10 +33,16 @@ function row(tool: string, output: unknown): ChainRow {
}
describe("expert change cards", () => {
- it("shows the proposed charter and that nothing happened yet", () => {
+ afterEach(() => {
+ artifactsFlag.enabled = false;
+ useCopilotUIStore.getState().resetArtifactPanel();
+ useCopilotUIStore.getState().setInitialPrompt(null);
+ });
+
+ it("shows who the proposed expert is and nothing else", () => {
render(
- <ToolResult
- row={row("raise_expert", {
+ <ExpertChangeCard
+ output={{
type: "expert_change_proposed",
message: "Nothing created yet.",
applied: false,
@@ -27,91 +51,188 @@ describe("expert change cards", () => {
kind: "raise",
name: "Otto",
role: "Inbox triage",
+ tagline: "Sorts your morning inbox.",
about: "You group the morning inbox.",
boundaries: "You never send a reply yourself.",
weekly_budget: 2000,
},
- })}
+ }}
/>,
);
+ expect(screen.getByText("Raise an expert")).toBeDefined();
expect(screen.getByText("Otto")).toBeDefined();
expect(screen.getByText("Inbox triage")).toBeDefined();
- expect(screen.getByText("Needs your OK")).toBeDefined();
- expect(
- screen.getByText("Stops at: You never send a reply yourself."),
- ).toBeDefined();
- expect(screen.getByText("Weekly budget: 2000 credits")).toBeDefined();
- expect(screen.queryByRole("link", { name: /Edit/ })).toBeNull();
- expect(screen.queryByRole("link", { name: /Chat/ })).toBeNull();
+ expect(screen.getByText("Sorts your morning inbox.")).toBeDefined();
+ // The card is an introduction, not a charter — no status, budget or limits.
+ expect(screen.queryByText("You group the morning inbox.")).toBeNull();
+ expect(screen.queryByText("Needs your OK")).toBeNull();
+ expect(screen.queryByText(/Stops at:/)).toBeNull();
+ expect(screen.queryByText(/Weekly budget/)).toBeNull();
});
- it("offers Edit and Chat once the expert exists", () => {
+ it("opens the full charter in the side panel from Show more", async () => {
+ artifactsFlag.enabled = true;
+ const user = userEvent.setup();
render(
- <ToolResult
- row={row("confirm_expert_change", {
- type: "expert_change_applied",
- message: "Otto is on the team.",
- applied: true,
- kind: "raise",
- expert: {
- id: "exp-otto",
+ <ExpertChangeCard
+ artifactId="call-raise"
+ output={{
+ type: "expert_change_proposed",
+ applied: false,
+ preview: {
+ kind: "raise",
name: "Otto",
role: "Inbox triage",
- avatar_url: null,
- color: "violet",
+ tagline: "Sorts your morning inbox.",
+ about: "You group the morning inbox.",
+ boundaries: "You never send a reply yourself.",
+ weekly_budget: 2000,
},
- })}
+ }}
/>,
);
- expect(screen.getByText("Otto")).toBeDefined();
- expect(screen.queryByText("Needs your OK")).toBeNull();
- // The applied state must be readable, not colour-and-glyph only.
- expect(screen.getByText("Raised")).toBeDefined();
- expect(
- screen.getByRole("link", { name: /Edit/ }).getAttribute("href"),
- ).toBe("/team/exp-otto");
- expect(
- screen.getByRole("link", { name: /Chat/ }).getAttribute("href"),
- ).toBe("/copilot?expertId=exp-otto");
+ await user.click(screen.getByRole("button", { name: "Details" }));
+
+ const { activeArtifact, isOpen } =
+ useCopilotUIStore.getState().artifactPanel;
+ expect(isOpen).toBe(true);
+ expect(activeArtifact?.id).toBe("expert:call-raise");
+ expect(activeArtifact?.expert).toMatchObject({
+ kind: "raise",
+ name: "Otto",
+ role: "Inbox triage",
+ about: "You group the morning inbox.",
+ boundaries: "You never send a reply yourself.",
+ weeklyBudget: 2000,
+ applied: false,
+ });
+ expect(screen.queryByText("You group the morning inbox.")).toBeNull();
});
- it("names the workflows that failed to install on a partial hire", () => {
+ it("keeps the charter under Show more when the panel is unavailable", async () => {
+ const user = userEvent.setup();
render(
- <ToolResult
- row={row("confirm_expert_change", {
- type: "expert_change_applied",
- message: "Otto is on the team.",
- applied: true,
- kind: "hire",
- expert: { id: "exp-otto", name: "Otto", role: "Inbox triage" },
- failed_workflows: ["Inbox sweep", "Weekly digest"],
- })}
+ <ExpertChangeCard
+ output={{
+ type: "expert_change_proposed",
+ applied: false,
+ preview: {
+ kind: "raise",
+ name: "Otto",
+ tagline: "Sorts your morning inbox.",
+ about: "You group the morning inbox.",
+ boundaries: "You never send a reply yourself.",
+ },
+ }}
/>,
);
- expect(screen.getByText("Hired")).toBeDefined();
+ await user.click(screen.getByRole("button", { name: "Details" }));
+
+ expect(screen.getByText("You group the morning inbox.")).toBeDefined();
expect(
- screen.getByText(/Couldn't set up: Inbox sweep, Weekly digest/),
+ screen.getByText("Stops at: You never send a reply yourself."),
).toBeDefined();
});
- it("stays quiet when every workflow installed", () => {
+ it("falls back to the charter when an expert has no tagline", () => {
render(
- <ToolResult
- row={row("confirm_expert_change", {
+ <ExpertChangeCard
+ output={{
+ type: "expert_change_proposed",
+ applied: false,
+ preview: { kind: "raise", name: "Otto", about: "You triage." },
+ }}
+ />,
+ );
+
+ expect(screen.getByText("You triage.")).toBeDefined();
+ expect(screen.queryByRole("button", { name: "Details" })).toBeNull();
+ });
+
+ it("always offers Details when the panel is available", () => {
+ artifactsFlag.enabled = true;
+ render(
+ <ExpertChangeCard
+ artifactId="call-1"
+ output={{
+ type: "expert_change_proposed",
+ applied: false,
+ preview: { kind: "raise", name: "Otto", about: "You triage." },
+ }}
+ />,
+ );
+
+ expect(screen.getByRole("button", { name: "Details" })).toBeDefined();
+ });
+
+ it("hides Details when the tagline is the whole card", () => {
+ render(
+ <ExpertChangeCard
+ output={{
+ type: "expert_change_proposed",
+ applied: false,
+ preview: {
+ kind: "raise",
+ name: "Otto",
+ tagline: "Sorts your morning inbox.",
+ voice_preferences: "Short sentences.",
+ weekly_budget: 2000,
+ },
+ }}
+ />,
+ );
+
+ expect(screen.queryByRole("button", { name: "Details" })).toBeNull();
+ });
+
+ it("still offers Details without a tagline when there is more to read", () => {
+ render(
+ <ExpertChangeCard
+ output={{
+ type: "expert_change_proposed",
+ applied: false,
+ preview: {
+ kind: "raise",
+ name: "Otto",
+ about: "You triage.",
+ boundaries: "You never reply.",
+ },
+ }}
+ />,
+ );
+
+ expect(screen.getByRole("button", { name: "Details" })).toBeDefined();
+ });
+
+ it("reads the same once the expert exists", () => {
+ render(
+ <ExpertChangeCard
+ output={{
type: "expert_change_applied",
message: "Otto is on the team.",
applied: true,
- kind: "hire",
- expert: { id: "exp-otto", name: "Otto", role: "Inbox triage" },
- failed_workflows: [],
- })}
+ kind: "raise",
+ expert: {
+ id: "exp-otto",
+ name: "Otto",
+ role: "Inbox triage",
+ avatar_url: null,
+ color: "violet",
+ },
+ failed_workflows: ["Inbox sweep"],
+ }}
/>,
);
+ expect(screen.getByText("Expert raised")).toBeDefined();
+ expect(screen.getByText("Otto")).toBeDefined();
+ expect(screen.getByText("Inbox triage")).toBeDefined();
+ expect(screen.queryByText("Raised")).toBeNull();
expect(screen.queryByText(/Couldn't set up/)).toBeNull();
+ expect(screen.queryByRole("link")).toBeNull();
});
it("renders a handoff as the receiving teammate's sub-session", () => {
@@ -138,3 +259,269 @@ describe("expert change cards", () => {
);
});
});
+
+function expertPart(
+ state: string,
+ output?: unknown,
+ id = "call-raise",
+): ToolUIPart {
+ return {
+ type: "tool-raise_expert",
+ state,
+ toolCallId: id,
+ input: {},
+ output,
+ } as ToolUIPart;
+}
+
+function proposal(name: string, id: string): ToolUIPart {
+ return expertPart(
+ "output-available",
+ {
+ type: "expert_change_proposed",
+ applied: false,
+ confirmation_id: `c-${id}`,
+ preview: { kind: "raise", name, role: "Engineer" },
+ },
+ id,
+ );
+}
+
+describe("ExpertChangePart", () => {
+ it("renders the proposal card once the output lands", () => {
+ render(
+ <ExpertChangePart
+ part={proposal("Otto", "a")}
+ isCurrentlyStreaming={false}
+ />,
+ );
+
+ expect(screen.getByText("Otto")).toBeDefined();
+ expect(screen.getByText("Engineer")).toBeDefined();
+ });
+
+ it("holds the card's shape while the expert is still being written", () => {
+ const { container } = render(
+ <ExpertChangePart
+ part={expertPart("input-available")}
+ isCurrentlyStreaming
+ />,
+ );
+
+ expect(container.querySelectorAll(".animate-pulse").length).toBe(5);
+ });
+
+ it("renders nothing for an empty row once the stream is over", () => {
+ const { container } = render(
+ <ExpertChangePart
+ part={expertPart("input-available")}
+ isCurrentlyStreaming={false}
+ />,
+ );
+
+ expect(container.firstChild).toBeNull();
+ });
+
+ it("falls back to the generic tool row when the call errored", () => {
+ render(
+ <ExpertChangePart
+ part={
+ { ...expertPart("output-error"), errorText: "boom" } as ToolUIPart
+ }
+ isCurrentlyStreaming={false}
+ />,
+ );
+
+ expect(screen.getByTestId("generic-tool")).toBeDefined();
+ });
+});
+
+describe("ExpertChangeGroup", () => {
+ it("shows a single expert without a pager", () => {
+ render(<ExpertChangeGroup parts={[proposal("Fiona", "a")]} />);
+
+ expect(screen.getByText("Fiona")).toBeDefined();
+ expect(screen.queryByRole("button", { name: "Next expert" })).toBeNull();
+ });
+
+ it("pages through two or more experts one at a time", async () => {
+ const user = userEvent.setup();
+ render(
+ <ExpertChangeGroup
+ parts={[
+ proposal("Fiona", "a"),
+ proposal("Bhaskar", "b"),
+ proposal("Otto", "c"),
+ ]}
+ />,
+ );
+
+ expect(screen.getByText("Fiona")).toBeDefined();
+ expect(screen.queryByText("Bhaskar")).toBeNull();
+ expect(screen.getByText("1 of 3")).toBeDefined();
+ expect(
+ screen.getByRole("button", { name: "Previous expert" }),
+ ).toHaveProperty("disabled", true);
+
+ await user.click(screen.getByRole("button", { name: "Next expert" }));
+ expect(screen.getByText("Bhaskar")).toBeDefined();
+ expect(screen.getByText("2 of 3")).toBeDefined();
+
+ await user.click(screen.getByRole("button", { name: "Go to expert 3" }));
+ expect(screen.getByText("Otto")).toBeDefined();
+ expect(screen.getByRole("button", { name: "Next expert" })).toHaveProperty(
+ "disabled",
+ true,
+ );
+
+ await user.click(screen.getByRole("button", { name: "Previous expert" }));
+ expect(screen.getByText("Bhaskar")).toBeDefined();
+ });
+
+ it("leaves empty rows out of the pager once the stream is over", () => {
+ const { container } = render(
+ <ExpertChangeGroup
+ parts={[expertPart("input-available"), expertPart("input-available")]}
+ isCurrentlyStreaming={false}
+ />,
+ );
+
+ expect(container.firstChild).toBeNull();
+ });
+});
+
+describe("expert approval", () => {
+ function prompt(): string | null {
+ return useCopilotUIStore.getState().initialPrompt;
+ }
+
+ it("moves to the next expert on each decision, then drafts all of them", async () => {
+ const user = userEvent.setup();
+ render(
+ <ExpertChangeGroup
+ parts={[proposal("Fiona", "a"), proposal("Bhaskar", "b")]}
+ />,
+ );
+
+ expect(screen.getByText("Fiona")).toBeDefined();
+ expect(
+ screen.queryByRole("button", { name: "Add decisions to message" }),
+ ).toBeNull();
+
+ await user.click(screen.getByRole("button", { name: "Approve" }));
+ expect(screen.getByText("Bhaskar")).toBeDefined();
+ expect(screen.getByText("2 of 2")).toBeDefined();
+ expect(
+ screen.getByRole("button", { name: "Go to expert 1" }).className,
+ ).toContain("emerald");
+
+ await user.click(screen.getByRole("button", { name: "Decline" }));
+ expect(screen.getByRole("button", { name: "Undo decline" })).toBeDefined();
+ expect(
+ screen.getByRole("button", { name: "Go to expert 2" }).className,
+ ).toContain("red");
+ expect(screen.queryByRole("button", { name: "Approve" })).toBeNull();
+
+ await user.click(
+ screen.getByRole("button", { name: "Add decisions to message" }),
+ );
+ expect(prompt()).toContain("Approved: create Fiona");
+ expect(prompt()).toContain("c-a");
+ expect(prompt()).toContain("Not approved: do not create Bhaskar");
+ expect(prompt()).toContain("c-b");
+ expect(screen.getByText("Added to message")).toBeDefined();
+ });
+
+ it("remembers a decision when paging back", async () => {
+ const user = userEvent.setup();
+ render(
+ <ExpertChangeGroup
+ parts={[proposal("Fiona", "a"), proposal("Bhaskar", "b")]}
+ />,
+ );
+
+ await user.click(screen.getByRole("button", { name: "Approve" }));
+ await user.click(screen.getByRole("button", { name: "Previous expert" }));
+
+ expect(screen.getByText("Fiona")).toBeDefined();
+ expect(screen.queryByRole("button", { name: "Approve" })).toBeNull();
+
+ await user.click(screen.getByRole("button", { name: "Unapprove" }));
+ expect(screen.getByRole("button", { name: "Approve" })).toBeDefined();
+ expect(
+ screen.getByRole("button", { name: "Go to expert 1" }).className,
+ ).not.toContain("emerald");
+ });
+
+ it("drafts a single expert straight after its decision", async () => {
+ const user = userEvent.setup();
+ render(<ExpertChangeGroup parts={[proposal("Otto", "a")]} />);
+
+ await user.click(screen.getByRole("button", { name: "Approve" }));
+ await user.click(
+ screen.getByRole("button", { name: "Add decisions to message" }),
+ );
+
+ expect(prompt()).toBe("Approved: create Otto (confirmation_id: c-a).");
+ });
+
+ it("drafts the verb the proposal actually asks for", async () => {
+ const user = userEvent.setup();
+ render(
+ <ExpertChangeGroup
+ parts={[
+ expertPart(
+ "output-available",
+ {
+ type: "expert_change_proposed",
+ applied: false,
+ confirmation_id: "c-u",
+ preview: { kind: "update", name: "Otto", role: "Engineer" },
+ },
+ "u",
+ ),
+ ]}
+ />,
+ );
+
+ await user.click(screen.getByRole("button", { name: "Approve" }));
+ await user.click(
+ screen.getByRole("button", { name: "Add decisions to message" }),
+ );
+
+ expect(prompt()).toBe("Approved: update Otto (confirmation_id: c-u).");
+ });
+
+ it("offers no decision once applied or on a read-only transcript", () => {
+ render(
+ <ExpertChangeGroup
+ parts={[
+ expertPart("output-available", {
+ type: "expert_change_applied",
+ applied: true,
+ kind: "raise",
+ expert: { id: "exp-1", name: "Otto", role: "Inbox triage" },
+ }),
+ ]}
+ />,
+ );
+ expect(screen.queryByRole("button", { name: "Approve" })).toBeNull();
+ cleanup();
+
+ render(<ExpertChangeGroup parts={[proposal("Otto", "a")]} readOnly />);
+ expect(screen.queryByRole("button", { name: "Approve" })).toBeNull();
+ });
+
+ it("keeps the pager inside the card, beside the decision", () => {
+ render(
+ <ExpertChangeGroup
+ parts={[proposal("Fiona", "a"), proposal("Bhaskar", "b")]}
+ />,
+ );
+
+ const card = screen.getByText("Fiona").closest(".rounded-3xl");
+ expect(card).not.toBeNull();
+ expect(card?.textContent).toContain("1 of 2");
+ expect(card?.textContent).toContain("Approve");
+ });
+});
diff --git a/autogpt_platform/frontend/src/app/(platform)/copilot/components/ToolChain/__tests__/ToolChain.test.tsx b/autogpt_platform/frontend/src/app/(platform)/copilot/components/ToolChain/__tests__/ToolChain.test.tsx
index 85b047258c..9286b07ac2 100644
--- a/autogpt_platform/frontend/src/app/(platform)/copilot/components/ToolChain/__tests__/ToolChain.test.tsx
+++ b/autogpt_platform/frontend/src/app/(platform)/copilot/components/ToolChain/__tests__/ToolChain.test.tsx
@@ -295,72 +295,6 @@ describe("ToolChain", () => {
expect(screen.getByText("Send Email")).toBeDefined();
});
- it("keeps the expert approval card on screen for a hire preview", () => {
- render(
- <ToolChain
- parts={[
- toolPart("web_search", "output-available", {
- input: { query: "researchers" },
- output: { results: [] },
- }),
- toolPart("hire_expert", "output-available", {
- output: {
- type: "expert_change_proposed",
- applied: false,
- confirmation_id: "conf-1",
- preview: {
- kind: "hire",
- name: "Otto",
- role: "Inbox triage",
- boundaries: "You never send a reply yourself.",
- weekly_budget: 2000,
- },
- },
- }),
- ]}
- isStreaming={false}
- />,
- );
-
- const header = getChainHeader(/approve the new expert/i);
- expect(getPanel(header)?.getAttribute("aria-hidden")).toBe("false");
-
- expect(screen.getByText("Otto")).toBeDefined();
- expect(screen.getByText("Inbox triage")).toBeDefined();
- expect(screen.getByText("Needs your OK")).toBeDefined();
- expect(
- screen.getByText("Stops at: You never send a reply yourself."),
- ).toBeDefined();
- expect(screen.getByText("Weekly budget: 2000 credits")).toBeDefined();
- });
-
- it("lets the user collapse an expert approval card", async () => {
- const user = userEvent.setup();
- render(
- <ToolChain
- parts={[
- toolPart("hire_expert", "output-available", {
- output: {
- type: "expert_change_proposed",
- applied: false,
- confirmation_id: "conf-1",
- preview: { kind: "hire", name: "Otto", role: "Inbox triage" },
- },
- }),
- ]}
- isStreaming={false}
- />,
- );
-
- const header = getChainHeader(/approve the new expert/i);
- expect(getPanel(header)?.getAttribute("aria-hidden")).toBe("false");
-
- await user.click(header);
- await user.click(header);
-
- expect(getPanel(header)?.getAttribute("aria-hidden")).toBe("true");
- });
-
// A live row mounts before its output exists, so "needs you" is only known
// on a later render — the reveal has to react to it, not read it once.
it("reveals an action row when its output arrives mid-stream", () => {
@@ -385,17 +319,6 @@ describe("ToolChain", () => {
).toBe("true");
});
- it("holds a card's shape while an expert is still being written", () => {
- const { container } = render(
- <ToolChain
- parts={[toolPart("hire_expert", "input-available")]}
- isStreaming={true}
- />,
- );
-
- expect(container.querySelectorAll(".animate-pulse").length).toBe(5);
- });
-
it("drafts answered questions into the chat input and dismisses on send", async () => {
const user = userEvent.setup();
const pending: PendingQuestions = {
diff --git a/autogpt_platform/frontend/src/app/(platform)/copilot/components/ToolChain/__tests__/helpers.test.ts b/autogpt_platform/frontend/src/app/(platform)/copilot/components/ToolChain/__tests__/helpers.test.ts
index 13ee0917b1..a4ce7595f2 100644
--- a/autogpt_platform/frontend/src/app/(platform)/copilot/components/ToolChain/__tests__/helpers.test.ts
+++ b/autogpt_platform/frontend/src/app/(platform)/copilot/components/ToolChain/__tests__/helpers.test.ts
@@ -99,6 +99,39 @@ describe("buildChainSegments", () => {
])("routes legacy %s cards through ToolChain", (toolName) => {
expect(isChainableToolPart(toolPart(toolName))).toBe(true);
});
+
+ it("splits the chain around an expert approval", () => {
+ const parts = [
+ toolPart("web_search"),
+ toolPart("raise_expert", {}, { type: "expert_change_proposed" }),
+ toolPart("web_fetch"),
+ ];
+
+ expect(buildChainSegments(parts, isChainableToolPart)).toEqual([
+ { kind: "chain", parts: [parts[0]], index: 0 },
+ { kind: "experts", parts: [parts[1]], index: 1 },
+ { kind: "chain", parts: [parts[2]], index: 2 },
+ ]);
+ });
+
+ it("groups back-to-back expert changes into one segment", () => {
+ const raise = (id: string): MessagePart =>
+ ({ ...toolPart("raise_expert"), toolCallId: id }) as MessagePart;
+ const parts = [
+ raise("a"),
+ { type: "step-start" } as MessagePart,
+ raise("b"),
+ toolPart("confirm_expert_change"),
+ textPart("All three are ready for your OK."),
+ raise("c"),
+ ];
+
+ expect(buildChainSegments(parts, isChainableToolPart)).toEqual([
+ { kind: "experts", parts: [parts[0], parts[2], parts[3]], index: 0 },
+ { kind: "part", part: parts[4], index: 4 },
+ { kind: "experts", parts: [parts[5]], index: 5 },
+ ]);
+ });
});
describe("toChainRow", () => {
@@ -144,6 +177,21 @@ describe("toChainRow", () => {
expect(settled).toMatchObject({ text: "Thought", state: "done" });
});
+ it("drops a settled reasoning part that has no text", () => {
+ expect(
+ toChainRow(
+ { type: "reasoning", text: "", state: "done" } as MessagePart,
+ 0,
+ ),
+ ).toBeNull();
+ expect(
+ toChainRow(
+ { type: "reasoning", text: "", state: "streaming" } as MessagePart,
+ 0,
+ ),
+ ).toMatchObject({ text: "Thinking…" });
+ });
+
it("marks failed tool calls with their error detail", () => {
const row = toChainRow(
{
@@ -239,19 +287,6 @@ describe("isLiftedSetupRow", () => {
expect(lifted && isLiftedSetupRow(lifted)).toBe(true);
expect(notLifted && isLiftedSetupRow(notLifted)).toBe(false);
});
-
- it("does not lift an expert approval, whose card never registers", () => {
- const row = toChainRow(
- toolPart(
- "hire_expert",
- {},
- { type: "expert_change_proposed", preview: { name: "Otto" } },
- ),
- 0,
- );
-
- expect(row && isLiftedSetupRow(row)).toBe(false);
- });
});
describe("isChainPart", () => {
@@ -262,6 +297,16 @@ describe("isChainPart", () => {
expect(isChainPart(toolPart("web_search"))).toBe(true);
expect(isChainPart(textPart("Hello"))).toBe(false);
});
+
+ it.each([
+ "hire_expert",
+ "raise_expert",
+ "update_expert",
+ "confirm_expert_change",
+ ])("keeps %s out of the chain so its card stands on its own", (toolName) => {
+ expect(isChainPart(toolPart(toolName))).toBe(false);
+ expect(isChainableToolPart(toolPart(toolName))).toBe(false);
+ });
});
describe("toChainRow provider icons", () => {
diff --git a/autogpt_platform/frontend/src/app/(platform)/copilot/components/ToolChain/helpers.ts b/autogpt_platform/frontend/src/app/(platform)/copilot/components/ToolChain/helpers.ts
index 43199d033a..abf972c1a7 100644
--- a/autogpt_platform/frontend/src/app/(platform)/copilot/components/ToolChain/helpers.ts
+++ b/autogpt_platform/frontend/src/app/(platform)/copilot/components/ToolChain/helpers.ts
@@ -83,7 +83,6 @@ const ACTION_RESPONSE_TYPES = new Set([
"need_login",
"trigger_config_required",
"suggested_goal",
- "expert_change_proposed",
]);
function actionLabel(output: unknown): string | null {
@@ -109,7 +108,6 @@ function actionLabel(output: unknown): string | null {
: "Review this action";
}
if (data.type === "suggested_goal") return "Review the suggested goal";
- if (data.type === "expert_change_proposed") return "Approve the new expert";
return typeof data.message === "string" && data.message.trim()
? data.message.trim()
: "Action required";
@@ -142,8 +140,27 @@ function getProviderIconSrc(tool: ToolUIPart): string | undefined {
// it into a chain would bury both behind a collapsed "summarized context".
export const COMPACTION_PART_TYPE = "tool-context_compaction";
+// Hiring, raising or updating an expert is the user's call, not a step the
+// model worked through — the card renders as its own message part so the
+// approval never sits inside a chain that collapses on top of it.
+export const EXPERT_CHANGE_TOOLS = new Set([
+ "hire_expert",
+ "raise_expert",
+ "update_expert",
+ "confirm_expert_change",
+]);
+
+export function isExpertChangePart(part: MessagePart): boolean {
+ return (
+ part.type.startsWith("tool-") &&
+ EXPERT_CHANGE_TOOLS.has(part.type.slice("tool-".length))
+ );
+}
+
export function isChainPart(part: MessagePart): boolean {
- if (part.type === COMPACTION_PART_TYPE) return false;
+ if (part.type === COMPACTION_PART_TYPE || isExpertChangePart(part)) {
+ return false;
+ }
return part.type === "reasoning" || part.type.startsWith("tool-");
}
@@ -172,6 +189,11 @@ export function toChainRow(part: MessagePart, index: number): ChainRow | null {
}
if (part.type === "reasoning") {
const isStreaming = "state" in part && part.state === "streaming";
+ // A settled reasoning part with nothing in it is a "Thought it through"
+ // row over an empty panel — the model never actually wrote any.
+ const hasText =
+ "text" in part && typeof part.text === "string" && !!part.text.trim();
+ if (!isStreaming && !hasText) return null;
return {
key: `reasoning-${index}`,
category: "reasoning",
@@ -309,6 +331,9 @@ export function getChainHeading(
export type ChainSegment =
| { kind: "chain"; parts: MessagePart[]; index: number }
+ // Back-to-back expert changes (one per hire/raise call) render as one
+ // group so a whole new team pages instead of stacking down the message.
+ | { kind: "experts"; parts: MessagePart[]; index: number }
| { kind: "part"; part: MessagePart; index: number };
export function buildChainSegments(
@@ -331,6 +356,13 @@ export function buildChainSegments(
parts.forEach((part, index) => {
if (part.type === "step-start") return;
+ if (isExpertChangePart(part)) {
+ chain = null;
+ const last = segments[segments.length - 1];
+ if (last?.kind === "experts") last.parts.push(part);
+ else segments.push({ kind: "experts", parts: [part], index });
+ return;
+ }
if (isChainable(part)) {
if (!chain) {
chain = { kind: "chain", parts: [], index };
diff --git a/autogpt_platform/frontend/src/app/(platform)/copilot/components/ToolChain/useCardResize.ts b/autogpt_platform/frontend/src/app/(platform)/copilot/components/ToolChain/useCardResize.ts
deleted file mode 100644
index 0a37968361..0000000000
--- a/autogpt_platform/frontend/src/app/(platform)/copilot/components/ToolChain/useCardResize.ts
+++ /dev/null
@@ -1,26 +0,0 @@
-"use client";
-
-import { useLayoutEffect, useRef, useState } from "react";
-
-/** Measures the card body so its clipping wrapper can tween between the
- * collapsed and expanded heights — `height: auto` is not interpolable, so
- * the transition needs a real pixel value on both sides of the change. */
-export function useCardResize(expanded: boolean) {
- const contentRef = useRef<HTMLDivElement>(null);
- const [height, setHeight] = useState<number>();
-
- useLayoutEffect(() => {
- const el = contentRef.current;
- if (!el) return;
- function measure() {
- if (el) setHeight(el.getBoundingClientRect().height);
- }
- measure();
- // Text reflow (window resize, font swap) changes the clamped height too.
- const observer = new ResizeObserver(measure);
- observer.observe(el);
- return () => observer.disconnect();
- }, [expanded]);
-
- return { contentRef, height };
-}
diff --git a/autogpt_platform/frontend/src/app/(platform)/copilot/store.ts b/autogpt_platform/frontend/src/app/(platform)/copilot/store.ts
index 3f9fb49527..205b93c4b4 100644
--- a/autogpt_platform/frontend/src/app/(platform)/copilot/store.ts
+++ b/autogpt_platform/frontend/src/app/(platform)/copilot/store.ts
@@ -16,6 +16,24 @@ export interface DeleteTarget {
* or from `FileUIPart` attachments; see `getMessageArtifacts` in
* `ChatMessagesContainer/helpers.ts`.
*/
+/** The expert an ``ExpertChangeCard`` opens in the panel — a hire/raise
+ * preview or the teammate it became. Not a file: no fetch, copy or
+ * download; the panel renders the charter straight from this. */
+export interface ExpertArtifact {
+ id: string | null;
+ kind: "hire" | "raise" | "update" | null;
+ name: string;
+ role: string | null;
+ color: string | null;
+ tagline: string | null;
+ about: string | null;
+ boundaries: string | null;
+ voicePreferences: string | null;
+ weeklyBudget: number | null;
+ avatarUrl: string | null;
+ applied: boolean;
+}
+
export interface ArtifactRef {
/** Workspace file ID (matches the backend `WorkspaceFile.id`). */
id: string;
@@ -36,6 +54,8 @@ export interface ArtifactRef {
origin: "agent" | "user-upload";
/** Size in bytes if known — used by `classifyArtifact` for size gating. */
sizeBytes?: number;
+ /** Set when the ref is an expert rather than a workspace file. */
+ expert?: ExpertArtifact;
}
interface ArtifactPanelState {