π OpenHands: AI-Driven Development
feat(frontend): Display LLM model on conversation cards and header (#13616)
Jathin Sreenivas0731e8c68a8f
diff --git a/frontend/__tests__/components/features/conversation-panel/conversation-card.test.tsx b/frontend/__tests__/components/features/conversation-panel/conversation-card.test.tsxindex d069280b00..f690ce7e64 100644--- a/frontend/__tests__/components/features/conversation-panel/conversation-card.test.tsx+++ b/frontend/__tests__/components/features/conversation-panel/conversation-card.test.tsx@@ -434,6 +434,46 @@ describe("ConversationCard", () => {expect(screen.queryByTestId("ellipsis-button")).not.toBeInTheDocument();});+ it("should render the llm model when provided", () => {+ renderWithProviders(+ <ConversationCard+ onDelete={onDelete}+ onChangeTitle={onChangeTitle}+ title="Conversation 1"+ selectedRepository={null}+ lastUpdatedAt="2021-10-01T12:00:00Z"+ llmModel="anthropic/claude-sonnet-4-20250514"+ />,+ );++ const model = screen.getByTestId("conversation-card-llm-model");+ expect(model).toBeInTheDocument();+ expect(model).toHaveTextContent("anthropic/claude-sonnet-4-20250514");+ expect(model).toHaveAttribute("title", "anthropic/claude-sonnet-4-20250514");+ expect(model.querySelector("svg")).toBeInTheDocument();++ // Verify truncation structure: text is wrapped in a span with truncate class+ const textSpan = model.querySelector("span.truncate");+ expect(textSpan).toBeInTheDocument();+ expect(textSpan).toHaveTextContent("anthropic/claude-sonnet-4-20250514");+ });++ it("should not render the llm model when not provided", () => {+ renderWithProviders(+ <ConversationCard+ onDelete={onDelete}+ onChangeTitle={onChangeTitle}+ title="Conversation 1"+ selectedRepository={null}+ lastUpdatedAt="2021-10-01T12:00:00Z"+ />,+ );++ expect(+ screen.queryByTestId("conversation-card-llm-model"),+ ).not.toBeInTheDocument();+ });+const statusTable: [ConversationStatus, boolean][] = [["RUNNING", true],["STARTING", true],diff --git a/frontend/__tests__/components/features/conversation/conversation-name.test.tsx b/frontend/__tests__/components/features/conversation/conversation-name.test.tsxindex 3152fde699..7a24e4647d 100644--- a/frontend/__tests__/components/features/conversation/conversation-name.test.tsx+++ b/frontend/__tests__/components/features/conversation/conversation-name.test.tsx@@ -296,6 +296,46 @@ describe("ConversationName", () => {).not.toBeInTheDocument();});+ it("should render the llm model when available", () => {+ useActiveConversationMock.mockReturnValue({+ data: {+ conversation_id: "test-conversation-id",+ title: "Test Conversation",+ status: "RUNNING",+ llm_model: "openai/gpt-4o",+ } as Conversation,+ });++ renderConversationNameWithRouter();++ const model = screen.getByTestId("conversation-name-llm-model");+ expect(model).toBeInTheDocument();+ expect(model).toHaveTextContent("openai/gpt-4o");+ expect(model).toHaveAttribute("title", "openai/gpt-4o");+ expect(model.querySelector("svg")).toBeInTheDocument();++ // Verify truncation structure: text is wrapped in a span with truncate class+ const textSpan = model.querySelector("span.truncate");+ expect(textSpan).toBeInTheDocument();+ expect(textSpan).toHaveTextContent("openai/gpt-4o");+ });++ it("should not render the llm model when not available", () => {+ useActiveConversationMock.mockReturnValue({+ data: {+ conversation_id: "test-conversation-id",+ title: "Test Conversation",+ status: "RUNNING",+ },+ });++ renderConversationNameWithRouter();++ expect(+ screen.queryByTestId("conversation-name-llm-model"),+ ).not.toBeInTheDocument();+ });+it("should focus input when entering edit mode", async () => {const user = userEvent.setup();renderConversationNameWithRouter();diff --git a/frontend/__tests__/components/features/home/recent-conversation.test.tsx b/frontend/__tests__/components/features/home/recent-conversation.test.tsxnew file mode 100644index 0000000000..00915b02e5--- /dev/null+++ b/frontend/__tests__/components/features/home/recent-conversation.test.tsx@@ -0,0 +1,77 @@+import { screen } from "@testing-library/react";+import { describe, it, expect, vi } from "vitest";+import { renderWithProviders } from "test-utils";+import { BrowserRouter } from "react-router";+import { RecentConversation } from "#/components/features/home/recent-conversations/recent-conversation";+import type { Conversation } from "#/api/open-hands.types";++vi.mock("react-i18next", async () => {+ const actual = await vi.importActual("react-i18next");+ return {+ ...actual,+ useTranslation: () => ({+ t: (key: string) => {+ const translations: Record<string, string> = {+ CONVERSATION$AGO: "ago",+ COMMON$NO_REPOSITORY: "No repository",+ };+ return translations[key] || key;+ },+ i18n: {+ changeLanguage: () => new Promise(() => {}),+ },+ }),+ };+});++const baseConversation: Conversation = {+ conversation_id: "test-id",+ title: "Test Conversation",+ status: "RUNNING",+ last_updated_at: "2021-10-01T12:00:00Z",+ created_at: "2021-10-01T12:00:00Z",+ selected_repository: null,+ selected_branch: null,+ git_provider: null,+ runtime_status: null,+ url: null,+ session_api_key: null,+};++const renderRecentConversation = (conversation: Conversation) =>+ renderWithProviders(+ <BrowserRouter>+ <RecentConversation conversation={conversation} />+ </BrowserRouter>,+ );++describe("RecentConversation - llm_model", () => {+ it("should render the llm model when provided", () => {+ renderRecentConversation({+ ...baseConversation,+ llm_model: "anthropic/claude-sonnet-4-20250514",+ });++ const model = screen.getByTestId("recent-conversation-llm-model");+ expect(model).toBeInTheDocument();+ expect(model).toHaveTextContent("anthropic/claude-sonnet-4-20250514");+ expect(model).toHaveAttribute(+ "title",+ "anthropic/claude-sonnet-4-20250514",+ );+ expect(model.querySelector("svg")).toBeInTheDocument();++ // Verify truncation structure: text is wrapped in a span with truncate class+ const textSpan = model.querySelector("span.truncate");+ expect(textSpan).toBeInTheDocument();+ expect(textSpan).toHaveTextContent("anthropic/claude-sonnet-4-20250514");+ });++ it("should not render the llm model when not provided", () => {+ renderRecentConversation(baseConversation);++ expect(+ screen.queryByTestId("recent-conversation-llm-model"),+ ).not.toBeInTheDocument();+ });+});diff --git a/frontend/src/api/open-hands.types.ts b/frontend/src/api/open-hands.types.tsindex 532937f98a..dabcefbe1c 100644--- a/frontend/src/api/open-hands.types.ts+++ b/frontend/src/api/open-hands.types.ts@@ -80,6 +80,7 @@ export interface Conversation {sub_conversation_ids?: string[];public?: boolean;sandbox_id?: string | null;+ llm_model?: string | null;}export interface ResultSet<T> {diff --git a/frontend/src/components/features/conversation-panel/conversation-card/conversation-card-footer.tsx b/frontend/src/components/features/conversation-panel/conversation-card/conversation-card-footer.tsxindex f44a2f8141..2432751c15 100644--- a/frontend/src/components/features/conversation-panel/conversation-card/conversation-card-footer.tsx+++ b/frontend/src/components/features/conversation-panel/conversation-card/conversation-card-footer.tsx@@ -6,12 +6,14 @@ import { RepositorySelection } from "#/api/open-hands.types";import { ConversationRepoLink } from "./conversation-repo-link";import { NoRepository } from "./no-repository";import { ConversationStatus } from "#/types/conversation-status";+import CircuitIcon from "#/icons/u-circuit.svg?react";interface ConversationCardFooterProps {selectedRepository: RepositorySelection | null;lastUpdatedAt: string; // ISO 8601createdAt?: string; // ISO 8601conversationStatus?: ConversationStatus;+ llmModel?: string | null;}export function ConversationCardFooter({@@ -19,6 +21,7 @@ export function ConversationCardFooter({lastUpdatedAt,createdAt,conversationStatus,+ llmModel,}: ConversationCardFooterProps) {const { t } = useTranslation();@@ -36,13 +39,25 @@ export function ConversationCardFooter({) : (<NoRepository />)}- {(createdAt ?? lastUpdatedAt) && (- <p className="text-xs text-[#A3A3A3] flex-1 text-right">- <time>- {`${formatTimeDelta(lastUpdatedAt ?? createdAt)} ${t(I18nKey.CONVERSATION$AGO)}`}- </time>- </p>- )}+ <div className="flex items-center gap-2 flex-1 justify-end">+ {llmModel && (+ <span+ className="text-xs text-[#A3A3A3] max-w-[120px] flex items-center gap-1 overflow-hidden"+ title={llmModel}+ data-testid="conversation-card-llm-model"+ >+ <CircuitIcon width={12} height={12} className="shrink-0" />+ <span className="truncate">{llmModel}</span>+ </span>+ )}+ {(createdAt ?? lastUpdatedAt) && (+ <p className="text-xs text-[#A3A3A3] text-right">+ <time>+ {`${formatTimeDelta(lastUpdatedAt ?? createdAt)} ${t(I18nKey.CONVERSATION$AGO)}`}+ </time>+ </p>+ )}+ </div></div>);}diff --git a/frontend/src/components/features/conversation-panel/conversation-card/conversation-card.tsx b/frontend/src/components/features/conversation-panel/conversation-card/conversation-card.tsxindex 22fa91f3ac..acc3e89d1c 100644--- a/frontend/src/components/features/conversation-panel/conversation-card/conversation-card.tsx+++ b/frontend/src/components/features/conversation-panel/conversation-card/conversation-card.tsx@@ -25,6 +25,7 @@ interface ConversationCardProps {conversationVersion?: "V0" | "V1";contextMenuOpen?: boolean;onContextMenuToggle?: (isOpen: boolean) => void;+ llmModel?: string | null;}export function ConversationCard({@@ -44,6 +45,7 @@ export function ConversationCard({conversationVersion,contextMenuOpen = false,onContextMenuToggle,+ llmModel,}: ConversationCardProps) {const posthog = usePostHog();const [titleMode, setTitleMode] = React.useState<"view" | "edit">("view");@@ -161,6 +163,7 @@ export function ConversationCard({lastUpdatedAt={lastUpdatedAt}createdAt={createdAt}conversationStatus={conversationStatus}+ llmModel={llmModel}/></div>);diff --git a/frontend/src/components/features/conversation-panel/conversation-panel.tsx b/frontend/src/components/features/conversation-panel/conversation-panel.tsxindex a69c5d4e3d..36705a2b0d 100644--- a/frontend/src/components/features/conversation-panel/conversation-panel.tsx+++ b/frontend/src/components/features/conversation-panel/conversation-panel.tsx@@ -211,6 +211,7 @@ export function ConversationPanel({ onClose }: ConversationPanelProps) {onContextMenuToggle={(isOpen) =>setOpenContextMenuId(isOpen ? project.conversation_id : null)}+ llmModel={project.llm_model}/></NavLink>))}diff --git a/frontend/src/components/features/conversation/conversation-name.tsx b/frontend/src/components/features/conversation/conversation-name.tsxindex c2549a6e90..b520057aed 100644--- a/frontend/src/components/features/conversation/conversation-name.tsx+++ b/frontend/src/components/features/conversation/conversation-name.tsx@@ -15,6 +15,7 @@ import { ConfirmDeleteModal } from "../conversation-panel/confirm-delete-modal";import { ConfirmStopModal } from "../conversation-panel/confirm-stop-modal";import { MetricsModal } from "./metrics-modal/metrics-modal";import { ConversationVersionBadge } from "../conversation-panel/conversation-card/conversation-version-badge";+import CircuitIcon from "#/icons/u-circuit.svg?react";export function ConversationName() {const { t } = useTranslation();@@ -169,6 +170,17 @@ export function ConversationName() {/>)}+ {titleMode !== "edit" && conversation.llm_model && (+ <span+ className="text-xs text-[#A3A3A3] max-w-[150px] flex items-center gap-1 overflow-hidden"+ title={conversation.llm_model}+ data-testid="conversation-name-llm-model"+ >+ <CircuitIcon width={12} height={12} className="shrink-0" />+ <span className="truncate">{conversation.llm_model}</span>+ </span>+ )}+{titleMode !== "edit" && (<div className="relative flex items-center"><EllipsisButton fill="#B1B9D3" onClick={handleEllipsisClick} />diff --git a/frontend/src/components/features/home/recent-conversations/recent-conversation.tsx b/frontend/src/components/features/home/recent-conversations/recent-conversation.tsxindex 4e0068aac4..ff8115d908 100644--- a/frontend/src/components/features/home/recent-conversations/recent-conversation.tsx+++ b/frontend/src/components/features/home/recent-conversations/recent-conversation.tsx@@ -8,6 +8,7 @@ import { formatTimeDelta } from "#/utils/format-time-delta";import { I18nKey } from "#/i18n/declaration";import { ConversationStatusIndicator } from "./conversation-status-indicator";import RepoForkedIcon from "#/icons/repo-forked.svg?react";+import CircuitIcon from "#/icons/u-circuit.svg?react";interface RecentConversationProps {conversation: Conversation;@@ -64,14 +65,26 @@ export function RecentConversation({ conversation }: RecentConversationProps) {</div>) : null}</div>- {(conversation.created_at || conversation.last_updated_at) && (- <span>- {formatTimeDelta(- conversation.created_at || conversation.last_updated_at,- )}{" "}- {t(I18nKey.CONVERSATION$AGO)}- </span>- )}+ <div className="flex items-center gap-2">+ {conversation.llm_model && (+ <span+ className="max-w-[120px] flex items-center gap-1 overflow-hidden"+ title={conversation.llm_model}+ data-testid="recent-conversation-llm-model"+ >+ <CircuitIcon width={12} height={12} className="shrink-0" />+ <span className="truncate">{conversation.llm_model}</span>+ </span>+ )}+ {(conversation.created_at || conversation.last_updated_at) && (+ <span>+ {formatTimeDelta(+ conversation.created_at || conversation.last_updated_at,+ )}{" "}+ {t(I18nKey.CONVERSATION$AGO)}+ </span>+ )}+ </div></div></Link>);diff --git a/openhands/server/data_models/conversation_info.py b/openhands/server/data_models/conversation_info.pyindex db5d91eff2..c16e682598 100644--- a/openhands/server/data_models/conversation_info.py+++ b/openhands/server/data_models/conversation_info.py@@ -39,3 +39,4 @@ class ConversationInfo:sub_conversation_ids: list[str] = field(default_factory=list)public: bool | None = Nonesandbox_id: str | None = None+ llm_model: str | None = Nonediff --git a/openhands/server/routes/manage_conversations.py b/openhands/server/routes/manage_conversations.pyindex 5789e9784c..19b87884aa 100644--- a/openhands/server/routes/manage_conversations.py+++ b/openhands/server/routes/manage_conversations.py@@ -1594,4 +1594,5 @@ def _to_conversation_info(app_conversation: AppConversation) -> ConversationInfo],public=app_conversation.public,sandbox_id=app_conversation.sandbox_id,+ llm_model=app_conversation.llm_model,)