Skip to content

πŸ™Œ OpenHands: AI-Driven Development

fix(acp): show model picker on cloud home screen; hide Code/Plan for ACP (#1296)

simonrosenbergfe94fedd0020
diff --git a/__tests__/components/features/chat/components/chat-input-model.test.tsx b/__tests__/components/features/chat/components/chat-input-model.test.tsx
index 11cb0830c4..18a1ce278e 100644
--- a/__tests__/components/features/chat/components/chat-input-model.test.tsx
+++ b/__tests__/components/features/chat/components/chat-input-model.test.tsx
@@ -303,7 +303,7 @@ describe("ChatInputModel", () => {
});
});
- it("does not offer selectable rows on a cloud backend (display + Settings link only)", () => {
+ it("offers selectable rows on a cloud backend for ACP conversations (mid-conversation model switching is supported)", () => {
useActiveBackendMock.mockReturnValue({ backend: { kind: "cloud" } });
useActiveConversationMock.mockReturnValue({
data: {
@@ -318,10 +318,16 @@ describe("ChatInputModel", () => {
fireEvent.click(screen.getByTestId("chat-input-llm-model"));
- // No selectable model rows; the popover keeps the display value + Settings.
+ // Cloud ACP conversations support mid-conversation model switching,
+ // so selectable model rows are shown.
+ const selectedRow = screen.getByTestId(
+ "chat-input-acp-model-option-claude-sonnet-4-6",
+ );
+ expect(selectedRow).toBeInTheDocument();
+ expect(selectedRow).toHaveTextContent("Claude Sonnet 4.6");
expect(
- screen.queryByTestId("chat-input-acp-model-option-claude-sonnet-4-6"),
- ).not.toBeInTheDocument();
+ screen.getByTestId("chat-input-acp-model-option-claude-opus-4-7"),
+ ).toBeInTheDocument();
const popover = screen.getByTestId("chat-input-llm-model-popover");
expect(popover).toHaveTextContent("Claude Sonnet 4.6");
expect(screen.getByRole("link")).toHaveAttribute("href", "/settings/agent");
diff --git a/__tests__/hooks/use-chat-input-model-state.test.tsx b/__tests__/hooks/use-chat-input-model-state.test.tsx
index fdd016e953..a762a6f578 100644
--- a/__tests__/hooks/use-chat-input-model-state.test.tsx
+++ b/__tests__/hooks/use-chat-input-model-state.test.tsx
@@ -182,7 +182,7 @@ describe("useChatInputModelState", () => {
expect(result.current.currentModelId).toBe(provider?.default_model);
});
- it("showAcpPicker tri-condition: cloud backend suppresses the picker even with a model list", () => {
+ it("showAcpPicker: cloud backend shows the picker when a model list is present (cloud ACP supports mid-conversation switching)", () => {
useActiveBackendMock.mockReturnValue({ backend: { kind: "cloud" } });
useActiveConversationMock.mockReturnValue({
data: {
@@ -199,8 +199,9 @@ describe("useChatInputModelState", () => {
const { result } = renderHook(() => useChatInputModelState());
expect(result.current.availableAcpModels.length).toBeGreaterThan(0);
- // ACP + model list present, but cloud backend β†’ display-only.
- expect(result.current.showAcpPicker).toBe(false);
+ // ACP + model list present β†’ picker is enabled on all backends
+ // (cloud ACP conversations support mid-conversation model switching).
+ expect(result.current.showAcpPicker).toBe(true);
});
it("showAcpPicker tri-condition: an unknown ACP provider has no model list β†’ no picker", () => {
diff --git a/src/api/conversation-service/agent-server-conversation-service.api.ts b/src/api/conversation-service/agent-server-conversation-service.api.ts
index bb2f57b1cc..6d0c263310 100644
--- a/src/api/conversation-service/agent-server-conversation-service.api.ts
+++ b/src/api/conversation-service/agent-server-conversation-service.api.ts
@@ -727,10 +727,15 @@ class AgentServerConversationService {
conversationId: string,
model: string,
): Promise<void> {
- if (getActiveBackend().backend.kind === "cloud") {
- throw new Error(
- "ACP model switching is only supported for local agent-server backends.",
- );
+ const { backend } = getActiveBackend();
+ if (backend.kind === "cloud") {
+ await callCloudProxy({
+ backend,
+ method: "POST",
+ path: `/api/v1/app-conversations/${conversationId}/switch_acp_model`,
+ body: { model },
+ });
+ return;
}
await new ConversationClient(getAgentServerClientOptions()).switchAcpModel(
diff --git a/src/components/features/chat/components/chat-input-actions.tsx b/src/components/features/chat/components/chat-input-actions.tsx
index c1d9d0ec15..50392f603d 100644
--- a/src/components/features/chat/components/chat-input-actions.tsx
+++ b/src/components/features/chat/components/chat-input-actions.tsx
@@ -59,7 +59,9 @@ export function ChatInputActions({
const { backend } = useActiveBackend();
const isCloud = backend.kind === "cloud";
const modelState = useChatInputModelState();
- const showChangeAgentButton = isCloud;
+ // Code/Plan mode switching is a cloud OpenHands feature β€” it doesn't apply
+ // to ACP conversations (which have no "plan" mode), so hide it when ACP.
+ const showChangeAgentButton = isCloud && !modelState.isAcpContext;
const webSocketStatus = useUnifiedWebSocketStatus();
const { curAgentState } = useAgentState();
const { conversationMode, setConversationMode } = useConversationStore();
diff --git a/src/hooks/use-chat-input-model-state.ts b/src/hooks/use-chat-input-model-state.ts
index dfe33180e0..7dc9688221 100644
--- a/src/hooks/use-chat-input-model-state.ts
+++ b/src/hooks/use-chat-input-model-state.ts
@@ -1,4 +1,3 @@
-import { useActiveBackend } from "#/contexts/active-backend-context";
import { useActiveConversation } from "#/hooks/query/use-active-conversation";
import { useSettings } from "#/hooks/query/use-settings";
import { useAcpModelContext } from "#/hooks/use-acp-model-context";
@@ -25,7 +24,6 @@ export interface ChatInputModelState {
export function useChatInputModelState(): ChatInputModelState {
const { data: conversation } = useActiveConversation();
const { data: settings } = useSettings();
- const { backend } = useActiveBackend();
const { conversationId } = useOptionalConversationId();
const {
isActiveAcpConversation,
@@ -44,15 +42,25 @@ export function useChatInputModelState(): ChatInputModelState {
: null;
const acpProvider = isAcpContext ? getAcpProvider(acpServerKey) : undefined;
+ const acpConfiguredModel =
+ typeof settings?.agent_settings?.acp_model === "string"
+ ? settings.agent_settings.acp_model
+ : null;
+
let currentModelId: string | null = null;
if (isActiveAcpConversation) {
- currentModelId = conversation?.llm_model ?? null;
+ // Cloud ACP conversations store llm_model=null (the model lives in the
+ // running ACP subprocess, not in the conversation row). Fall back to the
+ // settings-configured model or provider default so the chip stays visible.
+ currentModelId =
+ conversation?.llm_model ??
+ resolveEffectiveAcpModel({
+ configured: acpConfiguredModel,
+ providerDefault: getAcpPreferredDefaultModel(acpServerKey),
+ });
} else if (isHomeAcp) {
currentModelId = resolveEffectiveAcpModel({
- configured:
- typeof settings?.agent_settings?.acp_model === "string"
- ? settings.agent_settings.acp_model
- : null,
+ configured: acpConfiguredModel,
// Preferred default (Vertex-safe for Gemini) β€” must match what the
// start request would substitute for an unconfigured model.
providerDefault: getAcpPreferredDefaultModel(acpServerKey),
@@ -66,8 +74,7 @@ export function useChatInputModelState(): ChatInputModelState {
? (labelForAcpModel(acpServerKey, currentModelId) ?? currentModelId)
: currentModelId;
const availableAcpModels = acpProvider?.available_models ?? [];
- const showAcpPicker =
- isAcpContext && backend.kind !== "cloud" && availableAcpModels.length > 0;
+ const showAcpPicker = isAcpContext && availableAcpModels.length > 0;
const switchConversationId = isActiveAcpConversation
? (conversationId ?? null)
: null;