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): show copilot chat source platform (#13175)

Abhimanyu Yadav732bf9e862a8
diff --git a/autogpt_platform/backend/backend/api/features/chat/routes.py b/autogpt_platform/backend/backend/api/features/chat/routes.py
index 471a459405..b8b196f341 100644
--- a/autogpt_platform/backend/backend/api/features/chat/routes.py
+++ b/autogpt_platform/backend/backend/api/features/chat/routes.py
@@ -324,6 +324,7 @@ class SessionSummaryResponse(BaseModel):
title: str | None = None
chat_status: str = "idle"
is_processing: bool
+ source_platform: str | None = None
class ListSessionsResponse(BaseModel):
@@ -416,6 +417,7 @@ async def list_sessions(
title=session.title,
chat_status=session.chat_status,
is_processing=session.session_id in processing_set,
+ source_platform=session.metadata.source_platform,
)
for session in sessions
],
diff --git a/autogpt_platform/backend/backend/api/features/chat/routes_test.py b/autogpt_platform/backend/backend/api/features/chat/routes_test.py
index 28c273e971..ed546db75c 100644
--- a/autogpt_platform/backend/backend/api/features/chat/routes_test.py
+++ b/autogpt_platform/backend/backend/api/features/chat/routes_test.py
@@ -1144,7 +1144,11 @@ def test_stream_chat_accepts_exactly_max_length_message(
# ─── list_sessions ────────────────────────────────────────────────────
-def _make_session_info(session_id: str = "sess-1", title: str | None = "Test"):
+def _make_session_info(
+ session_id: str = "sess-1",
+ title: str | None = "Test",
+ source_platform: str | None = None,
+):
"""Build a minimal ChatSessionInfo-like mock."""
from backend.copilot.model import ChatSessionInfo, ChatSessionMetadata
@@ -1155,7 +1159,7 @@ def _make_session_info(session_id: str = "sess-1", title: str | None = "Test"):
usage=[],
started_at=datetime.now(UTC),
updated_at=datetime.now(UTC),
- metadata=ChatSessionMetadata(),
+ metadata=ChatSessionMetadata(source_platform=source_platform),
)
@@ -1189,6 +1193,32 @@ def test_list_sessions_returns_sessions(mocker: pytest_mock.MockerFixture) -> No
assert data["sessions"][0]["is_processing"] is False
+def test_list_sessions_returns_source_platform(
+ mocker: pytest_mock.MockerFixture,
+) -> None:
+ session = _make_session_info("sess-discord", source_platform="discord")
+ mocker.patch(
+ "backend.api.features.chat.routes.get_user_sessions",
+ new_callable=AsyncMock,
+ return_value=([session], 1),
+ )
+ mock_redis = MagicMock()
+ mock_pipe = MagicMock()
+ mock_pipe.hget = MagicMock(return_value=None)
+ mock_pipe.execute = AsyncMock(return_value=["done"])
+ mock_redis.pipeline = MagicMock(return_value=mock_pipe)
+ mocker.patch(
+ "backend.api.features.chat.routes.get_redis_async",
+ new_callable=AsyncMock,
+ return_value=mock_redis,
+ )
+
+ response = client.get("/sessions")
+
+ assert response.status_code == 200
+ assert response.json()["sessions"][0]["source_platform"] == "discord"
+
+
def test_list_sessions_marks_running_as_processing(
mocker: pytest_mock.MockerFixture,
) -> None:
diff --git a/autogpt_platform/backend/backend/copilot/model.py b/autogpt_platform/backend/backend/copilot/model.py
index 04ce7226f3..038c13467a 100644
--- a/autogpt_platform/backend/backend/copilot/model.py
+++ b/autogpt_platform/backend/backend/copilot/model.py
@@ -70,6 +70,7 @@ class ChatSessionMetadata(BaseModel):
# this graph and reject calls targeting a different agent. Also used
# as a lookup key so refreshing the builder resumes the same chat.
builder_graph_id: str | None = None
+ source_platform: str | None = None
class ChatMessage(BaseModel):
@@ -257,6 +258,7 @@ class ChatSession(ChatSessionInfo):
*,
dry_run: bool,
builder_graph_id: str | None = None,
+ source_platform: str | None = None,
) -> Self:
return cls(
session_id=str(uuid.uuid4()),
@@ -270,6 +272,7 @@ class ChatSession(ChatSessionInfo):
metadata=ChatSessionMetadata(
dry_run=dry_run,
builder_graph_id=builder_graph_id,
+ source_platform=source_platform,
),
)
@@ -926,6 +929,7 @@ async def create_chat_session(
*,
dry_run: bool,
builder_graph_id: str | None = None,
+ source_platform: str | None = None,
) -> ChatSession:
"""Create a new chat session and persist it.
@@ -936,6 +940,7 @@ async def create_chat_session(
builder_graph_id: When set, locks the session to the given graph.
The builder panel uses this to bind a chat to the currently-
opened agent and to resume the same session on refresh.
+ source_platform: External chat platform that originated the session.
Raises:
DatabaseError: If the database write fails. We fail fast to ensure
@@ -946,6 +951,7 @@ async def create_chat_session(
user_id,
dry_run=dry_run,
builder_graph_id=builder_graph_id,
+ source_platform=source_platform,
)
# Create in database first - fail fast if this fails
diff --git a/autogpt_platform/backend/backend/platform_linking/chat.py b/autogpt_platform/backend/backend/platform_linking/chat.py
index 1d71029759..0b88cdbaf6 100644
--- a/autogpt_platform/backend/backend/platform_linking/chat.py
+++ b/autogpt_platform/backend/backend/platform_linking/chat.py
@@ -56,7 +56,11 @@ async def start_chat_turn(request: BotChatRequest) -> ChatTurnHandle:
if not session:
raise NotFoundError("Session not found.")
else:
- session = await create_chat_session(owner_user_id, dry_run=False)
+ session = await create_chat_session(
+ owner_user_id,
+ dry_run=False,
+ source_platform=request.platform.value.lower(),
+ )
session_id = session.session_id
# Persist the user message before enqueueing, mirroring the REST chat
diff --git a/autogpt_platform/backend/backend/platform_linking/chat_test.py b/autogpt_platform/backend/backend/platform_linking/chat_test.py
index ebc41ee6f8..067ff42fa9 100644
--- a/autogpt_platform/backend/backend/platform_linking/chat_test.py
+++ b/autogpt_platform/backend/backend/platform_linking/chat_test.py
@@ -74,6 +74,7 @@ class TestStartChatTurn:
db_mock = MagicMock()
db_mock.find_user_link_owner = AsyncMock(return_value="owner-1")
session = MagicMock(session_id="sess-new")
+ mock_create_chat_session = AsyncMock(return_value=session)
with (
patch(
@@ -82,7 +83,7 @@ class TestStartChatTurn:
),
patch(
"backend.platform_linking.chat.create_chat_session",
- new=AsyncMock(return_value=session),
+ new=mock_create_chat_session,
),
patch(
"backend.platform_linking.chat.append_and_save_message",
@@ -103,6 +104,9 @@ class TestStartChatTurn:
assert handle.user_id == "owner-1"
assert handle.turn_id
assert handle.subscribe_from == "0-0"
+ create_call = mock_create_chat_session.await_args
+ assert create_call is not None
+ assert create_call.kwargs["source_platform"] == "discord"
mock_stream_registry.create_session.assert_awaited_once()
mock_enqueue.assert_awaited_once()
diff --git a/autogpt_platform/frontend/public/integrations/teams.png b/autogpt_platform/frontend/public/integrations/teams.png
new file mode 100644
index 0000000000..9ad1e3d307
Binary files /dev/null and b/autogpt_platform/frontend/public/integrations/teams.png differ
diff --git a/autogpt_platform/frontend/public/integrations/whatsapp.png b/autogpt_platform/frontend/public/integrations/whatsapp.png
new file mode 100644
index 0000000000..084e0f5f1f
Binary files /dev/null and b/autogpt_platform/frontend/public/integrations/whatsapp.png differ
diff --git a/autogpt_platform/frontend/src/app/(platform)/copilot/components/ChatOriginIcon/ChatOriginIcon.tsx b/autogpt_platform/frontend/src/app/(platform)/copilot/components/ChatOriginIcon/ChatOriginIcon.tsx
new file mode 100644
index 0000000000..84c9330f33
--- /dev/null
+++ b/autogpt_platform/frontend/src/app/(platform)/copilot/components/ChatOriginIcon/ChatOriginIcon.tsx
@@ -0,0 +1,43 @@
+"use client";
+
+import Image from "next/image";
+import { useState } from "react";
+
+const PLATFORM_LOGOS: Record<string, { name: string; src: string }> = {
+ discord: { name: "Discord", src: "/integrations/discord.png" },
+ github: { name: "GitHub", src: "/integrations/github.png" },
+ linear: { name: "Linear", src: "/integrations/linear.png" },
+ slack: { name: "Slack", src: "/integrations/slack.png" },
+ teams: { name: "Teams", src: "/integrations/teams.png" },
+ telegram: { name: "Telegram", src: "/integrations/telegram.png" },
+ whatsapp: { name: "WhatsApp", src: "/integrations/whatsapp.png" },
+};
+
+interface Props {
+ sourcePlatform?: string | null;
+}
+
+export function ChatOriginIcon({ sourcePlatform }: Props) {
+ const platform = sourcePlatform?.trim().toLowerCase();
+ const logo = platform ? PLATFORM_LOGOS[platform] : undefined;
+ const [brokenSrc, setBrokenSrc] = useState<string | null>(null);
+
+ if (!logo || brokenSrc === logo.src) return null;
+
+ return (
+ <span
+ className="inline-flex size-4 shrink-0 items-center justify-center"
+ title={`From ${logo.name}`}
+ >
+ <Image
+ src={logo.src}
+ alt={logo.name}
+ width={16}
+ height={16}
+ loading="lazy"
+ className="size-4 object-contain"
+ onError={() => setBrokenSrc(logo.src)}
+ />
+ </span>
+ );
+}
diff --git a/autogpt_platform/frontend/src/app/(platform)/copilot/components/ChatSearchModal/ChatSearchResults.tsx b/autogpt_platform/frontend/src/app/(platform)/copilot/components/ChatSearchModal/ChatSearchResults.tsx
index 3e0e50d209..d64c65f06e 100644
--- a/autogpt_platform/frontend/src/app/(platform)/copilot/components/ChatSearchModal/ChatSearchResults.tsx
+++ b/autogpt_platform/frontend/src/app/(platform)/copilot/components/ChatSearchModal/ChatSearchResults.tsx
@@ -9,6 +9,7 @@ import {
import { AnimatePresence, motion, useReducedMotion } from "framer-motion";
import type { MutableRefObject } from "react";
import { shouldShowSessionProcessingIndicator } from "../../sessionActivity";
+import { ChatOriginIcon } from "../ChatOriginIcon/ChatOriginIcon";
import { getSessionTitle, highlightMatch, type SearchSession } from "./helpers";
const indicatorTransition = {
@@ -91,6 +92,7 @@ export function ChatSearchResults({
isHighlighted ? "text-zinc-900" : "text-zinc-500",
)}
/>
+ <ChatOriginIcon sourcePlatform={session.source_platform} />
<div className="min-w-0 flex-1">
<div
className={cn(
diff --git a/autogpt_platform/frontend/src/app/(platform)/copilot/components/ChatSearchModal/helpers.ts b/autogpt_platform/frontend/src/app/(platform)/copilot/components/ChatSearchModal/helpers.ts
index a6c042eec1..2ca12b0465 100644
--- a/autogpt_platform/frontend/src/app/(platform)/copilot/components/ChatSearchModal/helpers.ts
+++ b/autogpt_platform/frontend/src/app/(platform)/copilot/components/ChatSearchModal/helpers.ts
@@ -4,6 +4,7 @@ export interface SearchSession {
updated_at: string;
is_processing?: boolean;
chat_status?: string | null;
+ source_platform?: string | null;
}
export interface HighlightPart {
diff --git a/autogpt_platform/frontend/src/app/(platform)/copilot/components/ChatSessionBlock/ChatSessionBlock.stories.tsx b/autogpt_platform/frontend/src/app/(platform)/copilot/components/ChatSessionBlock/ChatSessionBlock.stories.tsx
new file mode 100644
index 0000000000..ab0e80830a
--- /dev/null
+++ b/autogpt_platform/frontend/src/app/(platform)/copilot/components/ChatSessionBlock/ChatSessionBlock.stories.tsx
@@ -0,0 +1,136 @@
+import type { ComponentProps } from "react";
+import type { Meta, StoryObj } from "@storybook/nextjs";
+import { ChatSessionBlock } from "./ChatSessionBlock";
+
+function daysAgo(days: number) {
+ const date = new Date();
+ date.setDate(date.getDate() - days);
+ return date.toISOString();
+}
+
+function renderSessionBlock(args: ComponentProps<typeof ChatSessionBlock>) {
+ return (
+ <button
+ type="button"
+ className={[
+ "w-full rounded-lg px-3 py-2.5 text-left transition-colors",
+ args.isActive ? "bg-zinc-100" : "bg-white hover:bg-zinc-50",
+ ].join(" ")}
+ >
+ <ChatSessionBlock {...args} />
+ </button>
+ );
+}
+
+const meta: Meta<typeof ChatSessionBlock> = {
+ title: "Copilot/ChatSessionBlock",
+ component: ChatSessionBlock,
+ tags: ["autodocs"],
+ parameters: {
+ layout: "centered",
+ docs: {
+ description: {
+ component:
+ "Copilot session row content used in the chat sidebar and mobile drawer, including external-platform origin logos.",
+ },
+ },
+ },
+ decorators: [
+ (Story) => (
+ <div className="w-80 rounded-lg border border-zinc-100 bg-zinc-50 p-3">
+ <Story />
+ </div>
+ ),
+ ],
+ render: renderSessionBlock,
+ args: {
+ title: "Review Discord support flow",
+ updatedAt: new Date().toISOString(),
+ sourcePlatform: "discord",
+ },
+};
+
+export default meta;
+type Story = StoryObj<typeof meta>;
+
+export const Discord: Story = {};
+
+export const SlackActive: Story = {
+ args: {
+ title: "Triage Slack escalation",
+ updatedAt: daysAgo(1),
+ sourcePlatform: "slack",
+ isActive: true,
+ },
+};
+
+export const TelegramQueued: Story = {
+ args: {
+ title: "Telegram onboarding message",
+ updatedAt: daysAgo(2),
+ sourcePlatform: "telegram",
+ chatStatus: "queued",
+ },
+};
+
+export const GitHubRunning: Story = {
+ args: {
+ title: "Investigate GitHub issue",
+ updatedAt: daysAgo(3),
+ sourcePlatform: "github",
+ chatStatus: "running",
+ },
+};
+
+export const LinearCompleted: Story = {
+ args: {
+ title: "Summarize Linear ticket",
+ updatedAt: daysAgo(4),
+ sourcePlatform: "linear",
+ showCompleted: true,
+ },
+};
+
+export const PlatformMatrix: Story = {
+ render: () => (
+ <div className="space-y-1">
+ {[
+ {
+ title: "Discord community report",
+ sourcePlatform: "discord",
+ updatedAt: new Date().toISOString(),
+ },
+ {
+ title: "Slack customer question",
+ sourcePlatform: "slack",
+ updatedAt: daysAgo(1),
+ isActive: true,
+ },
+ {
+ title: "Telegram lead follow-up",
+ sourcePlatform: "telegram",
+ updatedAt: daysAgo(2),
+ chatStatus: "queued",
+ },
+ {
+ title: "GitHub issue analysis",
+ sourcePlatform: "github",
+ updatedAt: daysAgo(3),
+ chatStatus: "running",
+ },
+ {
+ title: "Linear sprint update",
+ sourcePlatform: "linear",
+ updatedAt: daysAgo(4),
+ showCompleted: true,
+ },
+ {
+ title: "Native Copilot chat",
+ updatedAt: daysAgo(8),
+ },
+ ].map((session) => (
+ <div key={session.title}>{renderSessionBlock(session)}</div>
+ ))}
+ </div>
+ ),
+};
diff --git a/autogpt_platform/frontend/src/app/(platform)/copilot/components/ChatSessionBlock/ChatSessionBlock.tsx b/autogpt_platform/frontend/src/app/(platform)/copilot/components/ChatSessionBlock/ChatSessionBlock.tsx
new file mode 100644
index 0000000000..f9206658ab
--- /dev/null
+++ b/autogpt_platform/frontend/src/app/(platform)/copilot/components/ChatSessionBlock/ChatSessionBlock.tsx
@@ -0,0 +1,118 @@
+"use client";
+
+import { Text } from "@/components/atoms/Text/Text";
+import { cn } from "@/lib/utils";
+import {
+ CheckCircleIcon,
+ CircleNotchIcon,
+ HourglassIcon,
+} from "@phosphor-icons/react";
+import type { ReactNode } from "react";
+import { ChatOriginIcon } from "../ChatOriginIcon/ChatOriginIcon";
+
+interface Props {
+ title?: string | null;
+ titleContent?: ReactNode;
+ updatedAt: string;
+ sourcePlatform?: string | null;
+ isActive?: boolean;
+ chatStatus?: string | null;
+ showProcessing?: boolean;
+ showCompleted?: boolean;
+ className?: string;
+}
+
+function formatDate(dateString: string) {
+ const date = new Date(dateString);
+ const now = new Date();
+ const diffMs = now.getTime() - date.getTime();
+ const diffDays = Math.floor(diffMs / (1000 * 60 * 60 * 24));
+
+ if (diffDays === 0) return "Today";
+ if (diffDays === 1) return "Yesterday";
+ if (diffDays < 7) return `${diffDays} days ago`;
+
+ const day = date.getDate();
+ const ordinal =
+ day % 10 === 1 && day !== 11
+ ? "st"
+ : day % 10 === 2 && day !== 12
+ ? "nd"
+ : day % 10 === 3 && day !== 13
+ ? "rd"
+ : "th";
+ const month = date.toLocaleDateString("en-US", { month: "short" });
+ const year = date.getFullYear();
+
+ return `${day}${ordinal} ${month} ${year}`;
+}
+
+export function ChatSessionBlock({
+ title,
+ titleContent,
+ updatedAt,
+ sourcePlatform,
+ isActive = false,
+ chatStatus,
+ showProcessing = false,
+ showCompleted = false,
+ className,
+}: Props) {
+ const displayTitle = title || "Untitled chat";
+
+ return (
+ <div
+ className={cn("flex min-w-0 max-w-full items-center gap-2", className)}
+ >
+ <ChatOriginIcon sourcePlatform={sourcePlatform} />
+ <div className="min-w-0 flex-1">
+ <div className="flex min-w-0 items-center">
+ <Text
+ variant="body"
+ className={cn(
+ "min-w-0 flex-1 truncate font-normal",
+ isActive ? "text-zinc-600" : "text-zinc-800",
+ )}
+ >
+ {titleContent || displayTitle}
+ </Text>
+ </div>
+ <Text variant="small" className="text-neutral-400">
+ {formatDate(updatedAt)}
+ </Text>
+ </div>
+ {chatStatus === "running" ? (
+ <span
+ aria-label="Session running"
+ title="Running"
+ data-testid="session-status-running"
+ className="inline-flex h-4 w-4 shrink-0 items-center justify-center"
+ >
+ <span className="h-2 w-2 animate-pulse rounded-full bg-emerald-500" />
+ </span>
+ ) : null}
+ {chatStatus === "queued" ? (
+ <span
+ aria-label="Session queued"
+ title="Queued"
+ data-testid="session-status-queued"
+ className="inline-flex h-4 w-4 shrink-0 items-center justify-center text-purple-600"
+ >
+ <HourglassIcon className="h-3.5 w-3.5" weight="bold" />
+ </span>
+ ) : null}
+ {chatStatus !== "running" && showProcessing ? (
+ <CircleNotchIcon
+ className="h-4 w-4 shrink-0 animate-spin text-zinc-400"
+ weight="bold"
+ />
+ ) : null}
+ {showCompleted ? (
+ <CheckCircleIcon
+ className="h-4 w-4 shrink-0 text-green-500"
+ weight="fill"
+ />
+ ) : null}
+ </div>
+ );
+}
diff --git a/autogpt_platform/frontend/src/app/(platform)/copilot/components/ChatSidebar/ChatSidebar.tsx b/autogpt_platform/frontend/src/app/(platform)/copilot/components/ChatSidebar/ChatSidebar.tsx
index 744fb075c7..c1a038d04c 100644
--- a/autogpt_platform/frontend/src/app/(platform)/copilot/components/ChatSidebar/ChatSidebar.tsx
+++ b/autogpt_platform/frontend/src/app/(platform)/copilot/components/ChatSidebar/ChatSidebar.tsx
@@ -24,11 +24,9 @@ import {
import { cn } from "@/lib/utils";
import { Flag, useGetFlag } from "@/services/feature-flags/use-get-flag";
import {
- CheckCircle,
CircleNotch,
DotsThree,
DownloadSimpleIcon,
- HourglassIcon,
MagnifyingGlassIcon,
PencilSimpleIcon,
PlusCircleIcon,
@@ -47,6 +45,7 @@ import { useCopilotUIStore } from "../../store";
import { useSessionDeletion } from "../../useSessionDeletion";
import { SESSION_LIST_QUERY_KEY, useSessionList } from "../../useSessionList";
import { ChatSearchModal } from "../ChatSearchModal/ChatSearchModal";
+import { ChatSessionBlock } from "../ChatSessionBlock/ChatSessionBlock";
import { DeleteChatDialog } from "../DeleteChatDialog/DeleteChatDialog";
import { UsagePopover } from "../UsageLimits/UsagePopover/UsagePopover";
import { NotificationToggle } from "./components/NotificationToggle/NotificationToggle";
@@ -213,31 +212,6 @@ export function ChatSidebar() {
}
}
- function formatDate(dateString: string) {
- const date = new Date(dateString);
- const now = new Date();
- const diffMs = now.getTime() - date.getTime();
- const diffDays = Math.floor(diffMs / (1000 * 60 * 60 * 24));
-
- if (diffDays === 0) return "Today";
- if (diffDays === 1) return "Yesterday";
- if (diffDays < 7) return `${diffDays} days ago`;
-
- const day = date.getDate();
- const ordinal =
- day % 10 === 1 && day !== 11
- ? "st"
- : day % 10 === 2 && day !== 12
- ? "nd"
- : day % 10 === 3 && day !== 13
- ? "rd"
- : "th";
- const month = date.toLocaleDateString("en-US", { month: "short" });
- const year = date.getFullYear();
-
- return `${day}${ordinal} ${month} ${year}`;
- }
-
return (
<>
<Sidebar
@@ -397,59 +371,28 @@ export function ChatSidebar() {
: "pr-10",
)}
>
- <div className="flex min-w-0 max-w-full items-center gap-2">
- <div className="min-w-0 flex-1">
- <Text
- variant="body"
- className={cn(
- "truncate font-normal",
- session.id === sessionId
- ? "text-zinc-600"
- : "text-zinc-800",
- )}
- >
- <AnimatePresence mode="wait" initial={false}>
- <motion.span
- key={session.title || "untitled"}
- initial={{ opacity: 0, y: 4 }}
- animate={{ opacity: 1, y: 0 }}
- exit={{ opacity: 0, y: -4 }}
- transition={{ duration: 0.2 }}
- className="block truncate"
- >
- {session.title || "Untitled chat"}
- </motion.span>
- </AnimatePresence>
- </Text>
- <Text variant="small" className="text-neutral-400">
- {formatDate(session.updated_at)}
- </Text>
- </div>
- {session.chat_status === "running" && (
- <span
- aria-label="Session running"
- title="Running"
- data-testid="session-status-running"
- className="inline-flex h-4 w-4 shrink-0 items-center justify-center"
- >
- <span className="h-2 w-2 animate-pulse rounded-full bg-emerald-500" />
- </span>
- )}
- {session.chat_status === "queued" && (
- <span
- aria-label="Session queued"
- title="Queued"
- data-testid="session-status-queued"
- className="inline-flex h-4 w-4 shrink-0 items-center justify-center text-purple-600"
- >
- <HourglassIcon
- className="h-3.5 w-3.5"
- weight="bold"
- />
- </span>
- )}
- {session.chat_status !== "running" &&
- session.is_processing &&
+ <ChatSessionBlock
+ title={session.title}
+ titleContent={
+ <AnimatePresence mode="wait" initial={false}>
+ <motion.span
+ key={session.title || "untitled"}
+ initial={{ opacity: 0, y: 4 }}
+ animate={{ opacity: 1, y: 0 }}
+ exit={{ opacity: 0, y: -4 }}
+ transition={{ duration: 0.2 }}
+ className="block truncate"
+ >
+ {session.title || "Untitled chat"}
+ </motion.span>
+ </AnimatePresence>
+ }
+ updatedAt={session.updated_at}
+ sourcePlatform={session.source_platform}
+ isActive={session.id === sessionId}
+ chatStatus={session.chat_status}
+ showProcessing={
+ !!session.is_processing &&
shouldShowSessionProcessingIndicator({
sessionId: session.id,
currentSessionId: sessionId,
@@ -458,20 +401,13 @@ export function ChatSidebar() {
session.id,
),
needsReload: !!sessionNeedsReload[session.id],
- }) && (
- <CircleNotch
- className="h-4 w-4 shrink-0 animate-spin text-zinc-400"
- weight="bold"
- />
- )}
- {completedSessionIDs.has(session.id) &&
- session.id !== sessionId && (
- <CheckCircle
- className="h-4 w-4 shrink-0 text-green-500"
- weight="fill"
- />
- )}
- </div>
+ })
+ }
+ showCompleted={
+ completedSessionIDs.has(session.id) &&
+ session.id !== sessionId
+ }
+ />
</button>
)}
{exportingSessionIds.has(session.id) && (
diff --git a/autogpt_platform/frontend/src/app/(platform)/copilot/components/ChatSidebar/__tests__/ChatSidebar.test.tsx b/autogpt_platform/frontend/src/app/(platform)/copilot/components/ChatSidebar/__tests__/ChatSidebar.test.tsx
index a38f2f8db0..0b24b0e452 100644
--- a/autogpt_platform/frontend/src/app/(platform)/copilot/components/ChatSidebar/__tests__/ChatSidebar.test.tsx
+++ b/autogpt_platform/frontend/src/app/(platform)/copilot/components/ChatSidebar/__tests__/ChatSidebar.test.tsx
@@ -55,6 +55,7 @@ const sessions = [
id: "s1",
title: "Active chat",
is_processing: false,
+ source_platform: "discord",
created_at: "2025-01-01T00:00:00Z",
updated_at: "2025-01-01T00:00:00Z",
},
@@ -116,6 +117,12 @@ describe("ChatSidebar — delete flow", () => {
});
});
+ it("shows a platform logo for chats from an external platform", async () => {
+ renderSidebar();
+
+ expect(await screen.findByAltText("Discord")).toBeDefined();
+ });
+
it("clears the staged session when Cancel is clicked", async () => {
renderSidebar();
diff --git a/autogpt_platform/frontend/src/app/(platform)/copilot/components/MobileDrawer/MobileDrawer.tsx b/autogpt_platform/frontend/src/app/(platform)/copilot/components/MobileDrawer/MobileDrawer.tsx
index c554cd2c01..6ed858f663 100644
--- a/autogpt_platform/frontend/src/app/(platform)/copilot/components/MobileDrawer/MobileDrawer.tsx
+++ b/autogpt_platform/frontend/src/app/(platform)/copilot/components/MobileDrawer/MobileDrawer.tsx
@@ -1,5 +1,4 @@
import { Button } from "@/components/atoms/Button/Button";
-import { Text } from "@/components/atoms/Text/Text";
import { scrollbarStyles } from "@/components/styles/scrollbars";
import { Button as ShadcnButton } from "@/components/ui/button";
import { Input } from "@/components/ui/input";
@@ -8,8 +7,6 @@ import { useSupabase } from "@/lib/supabase/hooks/useSupabase";
import { cn } from "@/lib/utils";
import { Flag, useGetFlag } from "@/services/feature-flags/use-get-flag";
import {
- CheckCircle,
- CircleNotch,
MagnifyingGlass,
PlusIcon,
SpeakerHigh,
@@ -27,33 +24,9 @@ import { useSessionDeletion } from "../../useSessionDeletion";
import { useSessionList } from "../../useSessionList";
import { ChatSearchResults } from "../ChatSearchModal/ChatSearchResults";
import { useChatSearch } from "../ChatSearchModal/useChatSearch";
+import { ChatSessionBlock } from "../ChatSessionBlock/ChatSessionBlock";
import { DeleteChatDialog } from "../DeleteChatDialog/DeleteChatDialog";
-function formatDate(dateString: string) {
- const date = new Date(dateString);
- const now = new Date();
- const diffMs = now.getTime() - date.getTime();
- const diffDays = Math.floor(diffMs / (1000 * 60 * 60 * 24));
-
- if (diffDays === 0) return "Today";
- if (diffDays === 1) return "Yesterday";
- if (diffDays < 7) return `${diffDays} days ago`;
-
- const day = date.getDate();
- const ordinal =
- day % 10 === 1 && day !== 11
- ? "st"
- : day % 10 === 2 && day !== 12
- ? "nd"
- : day % 10 === 3 && day !== 13
- ? "rd"
- : "th";
- const month = date.toLocaleDateString("en-US", { month: "short" });
- const year = date.getFullYear();
-
- return `${day}${ordinal} ${month} ${year}`;
-}
-
export function MobileDrawer() {
const { isUserLoading, isLoggedIn } = useSupabase();
const searchInputRef = useRef<HTMLInputElement>(null);
@@ -265,46 +238,28 @@ export function MobileDrawer() {
: "hover:bg-zinc-50",
)}
>
- <div className="flex min-w-0 max-w-full flex-col overflow-hidden">
- <div className="flex min-w-0 max-w-full items-center gap-1.5">
- <Text
- variant="body"
- className={cn(
- "truncate font-normal",
- session.id === currentSessionId
- ? "text-zinc-600"
- : "text-zinc-800",
- )}
- >
- {session.title || "Untitled chat"}
- </Text>
- {session.is_processing &&
- shouldShowSessionProcessingIndicator({
- sessionId: session.id,
- currentSessionId,
- isProcessing: session.is_processing,
- hasCompletedIndicator: completedSessionIDs.has(
- session.id,
- ),
- needsReload: !!sessionNeedsReload[session.id],
- }) && (
- <CircleNotch
- className="h-4 w-4 shrink-0 animate-spin text-zinc-400"
- weight="bold"
- />
- )}
- {completedSessionIDs.has(session.id) &&
- session.id !== currentSessionId && (
- <CheckCircle
- className="h-4 w-4 shrink-0 text-green-500"
- weight="fill"
- />
- )}
- </div>
- <Text variant="small" className="text-neutral-400">
- {formatDate(session.updated_at)}
- </Text>
- </div>
+ <ChatSessionBlock
+ title={session.title}
+ updatedAt={session.updated_at}
+ sourcePlatform={session.source_platform}
+ isActive={session.id === currentSessionId}
+ showProcessing={
+ !!session.is_processing &&
+ shouldShowSessionProcessingIndicator({
+ sessionId: session.id,
+ currentSessionId,
+ isProcessing: session.is_processing,
+ hasCompletedIndicator: completedSessionIDs.has(
+ session.id,
+ ),
+ needsReload: !!sessionNeedsReload[session.id],
+ })
+ }
+ showCompleted={
+ completedSessionIDs.has(session.id) &&
+ session.id !== currentSessionId
+ }
+ />
</button>
))
)}
diff --git a/autogpt_platform/frontend/src/app/(platform)/copilot/components/MobileDrawer/__tests__/MobileDrawer.test.tsx b/autogpt_platform/frontend/src/app/(platform)/copilot/components/MobileDrawer/__tests__/MobileDrawer.test.tsx
index 1f289e3a12..14c883ecd7 100644
--- a/autogpt_platform/frontend/src/app/(platform)/copilot/components/MobileDrawer/__tests__/MobileDrawer.test.tsx
+++ b/autogpt_platform/frontend/src/app/(platform)/copilot/components/MobileDrawer/__tests__/MobileDrawer.test.tsx
@@ -33,6 +33,7 @@ const sessions = [
id: "s1",
title: "Budget notes",
is_processing: false,
+ source_platform: "slack",
created_at: "2025-01-01T00:00:00Z",
updated_at: "2025-01-01T00:00:00Z",
},
@@ -81,6 +82,7 @@ describe("MobileDrawer search", () => {
render(<MobileDrawer />);
expect(await screen.findByText("Budget notes")).toBeDefined();
+ expect(screen.getByAltText("Slack")).toBeDefined();
fireEvent.click(screen.getByRole("button", { name: /search chats/i }));
expect(
diff --git a/autogpt_platform/frontend/src/app/api/openapi.json b/autogpt_platform/frontend/src/app/api/openapi.json
index e324b6be73..265d5e3921 100644
--- a/autogpt_platform/frontend/src/app/api/openapi.json
+++ b/autogpt_platform/frontend/src/app/api/openapi.json
@@ -10879,6 +10879,10 @@
"builder_graph_id": {
"anyOf": [{ "type": "string" }, { "type": "null" }],
"title": "Builder Graph Id"
+ },
+ "source_platform": {
+ "anyOf": [{ "type": "string" }, { "type": "null" }],
+ "title": "Source Platform"
}
},
"type": "object",
@@ -16015,7 +16019,11 @@
"title": "Chat Status",
"default": "idle"
},
- "is_processing": { "type": "boolean", "title": "Is Processing" }
+ "is_processing": { "type": "boolean", "title": "Is Processing" },
+ "source_platform": {
+ "anyOf": [{ "type": "string" }, { "type": "null" }],
+ "title": "Source Platform"
+ }
},
"type": "object",
"required": ["id", "created_at", "updated_at", "is_processing"],