π OpenHands: AI-Driven Development
Fix live direct-backend conversation flows
openhands1b93bcc3f240
diff --git a/AGENTS.md b/AGENTS.mdindex 74d8237b19..a57487852e 100644--- a/AGENTS.md+++ b/AGENTS.md@@ -21,4 +21,9 @@- runtime git panels: `/api/git/changes`, `/api/git/diff`- Useful regression tests for mock mode live in `__tests__/api/option-service.test.ts`, `__tests__/api/mock-conversation-handlers.test.ts`, and `__tests__/api/mock-settings-handlers.test.ts`.- Browser-verified mock-mode tour artifact was generated at `artifacts/frontend-tour.gif`.+- Live `agent_server` compatibility quirks discovered during browser verification:+ - `GET /api/conversations` expects repeated `ids` params (`?ids=a&ids=b`), not Axios's default bracket form (`ids[]=a`), so the shared Axios client needs a custom params serializer.+ - Runtime git panels should prefer the conversation's reported `workspace.working_dir` when present; falling back to `/workspace/project` can produce 500s like `Not a git repository` for direct local workspaces such as `/workspace/project/agent-server-gui`.+ - Live settings currently load with the `SDK settings schema unavailable.` placeholder when the backend does not expose `/api/settings/agent-schema` and `/api/settings/conversation-schema`; this is expected for the current local backend.+diff --git a/__tests__/api/mock-conversation-handlers.test.ts b/__tests__/api/mock-conversation-handlers.test.tsindex 9c8ad6e1f8..0439ac4f98 100644--- a/__tests__/api/mock-conversation-handlers.test.ts+++ b/__tests__/api/mock-conversation-handlers.test.ts@@ -11,6 +11,7 @@ describe("mock conversation handlers", () => {expect(conversation?.id).toBe("1");expect(conversation?.title).toBe("My New Project");expect(conversation?.conversation_url).toContain("/api/conversations/1");+ expect(conversation?.workspace?.working_dir).toBe("/workspace/project");});it("returns adapted conversation pages for search", async () => {diff --git a/__tests__/api/open-hands-axios.test.ts b/__tests__/api/open-hands-axios.test.tsnew file mode 100644index 0000000000..da0dce52c2--- /dev/null+++ b/__tests__/api/open-hands-axios.test.ts@@ -0,0 +1,20 @@+import { describe, expect, it } from "vitest";+import { openHands } from "#/api/open-hands-axios";++describe("openHands axios client", () => {+ it("serializes array query params without bracket suffixes", () => {+ const uri = openHands.getUri({+ url: "/api/conversations",+ params: {+ ids: ["conversation-1", "conversation-2"],+ limit: 10,+ },+ });++ expect(uri).toContain("/api/conversations?");+ expect(uri).toContain("ids=conversation-1");+ expect(uri).toContain("ids=conversation-2");+ expect(uri).toContain("limit=10");+ expect(uri).not.toContain("ids%5B%5D=");+ });+});diff --git a/__tests__/utils/get-git-path.test.ts b/__tests__/utils/get-git-path.test.tsindex a1f3512862..2410ec6db4 100644--- a/__tests__/utils/get-git-path.test.ts+++ b/__tests__/utils/get-git-path.test.ts@@ -96,4 +96,23 @@ describe("getGitPath", () => {);});});++ describe("with a backend-provided workspace path", () => {+ it("prefers the explicit workspace path over derived git paths", () => {+ expect(+ getGitPath(+ conversationId,+ "OpenHands/software-agent-sdk",+ true,+ "/workspace/project/agent-server-gui",+ ),+ ).toBe("/workspace/project/agent-server-gui");+ });++ it("ignores blank workspace paths and falls back to heuristics", () => {+ expect(getGitPath(conversationId, "OpenHands/software-agent-sdk", true, " ")).toBe(+ `/workspace/project/${conversationId}/software-agent-sdk`,+ );+ });+ });});diff --git a/artifacts/frontend-tour.gif b/artifacts/frontend-tour.gifindex 2ae6f5f910..9526c50531 100644Binary files a/artifacts/frontend-tour.gif and b/artifacts/frontend-tour.gif differdiff --git a/src/api/agent-server-adapter.ts b/src/api/agent-server-adapter.tsindex b16cefd7cf..886ecb025d 100644--- a/src/api/agent-server-adapter.ts+++ b/src/api/agent-server-adapter.ts@@ -112,6 +112,9 @@ export function toV1AppConversation(V1ExecutionStatus.IDLE,conversation_url: toConversationUrl(info.id),session_api_key: getAgentServerSessionApiKey(),+ workspace: {+ working_dir: info.workspace?.working_dir ?? getAgentServerWorkingDir(),+ },public: false,sub_conversation_ids: [],};diff --git a/src/api/conversation-service/v1-conversation-service.types.ts b/src/api/conversation-service/v1-conversation-service.types.tsindex 184d624d0c..7d8b007507 100644--- a/src/api/conversation-service/v1-conversation-service.types.ts+++ b/src/api/conversation-service/v1-conversation-service.types.ts@@ -100,6 +100,10 @@ export interface V1AppConversationStartTaskPage {next_page_id: string | null;}+export interface V1ConversationWorkspace {+ working_dir: string | null;+}+export interface V1AppConversation {id: string;created_by_user_id: string | null;@@ -118,6 +122,7 @@ export interface V1AppConversation {execution_status: V1ExecutionStatus | null;conversation_url: string | null;session_api_key: string | null;+ workspace?: V1ConversationWorkspace | null;public?: boolean;sub_conversation_ids: string[];}diff --git a/src/api/open-hands-axios.ts b/src/api/open-hands-axios.tsindex f2b89d0fc5..67d2208f1e 100644--- a/src/api/open-hands-axios.ts+++ b/src/api/open-hands-axios.ts@@ -1,8 +1,36 @@import axios, { AxiosError, AxiosResponse, InternalAxiosRequestConfig } from "axios";import { getAgentServerBaseUrl, getAgentServerHeaders } from "./agent-server-config";+function serializeParams(params: Record<string, unknown> | URLSearchParams): string {+ if (params instanceof URLSearchParams) {+ return params.toString();+ }++ const searchParams = new URLSearchParams();++ Object.entries(params).forEach(([key, value]) => {+ if (value === undefined || value === null) {+ return;+ }++ if (Array.isArray(value)) {+ value.forEach((item) => {+ if (item !== undefined && item !== null) {+ searchParams.append(key, String(item));+ }+ });+ return;+ }++ searchParams.append(key, String(value));+ });++ return searchParams.toString();+}+export const openHands = axios.create({baseURL: getAgentServerBaseUrl(),+ paramsSerializer: { serialize: serializeParams },});openHands.interceptors.request.use((config: InternalAxiosRequestConfig) => {diff --git a/src/hooks/query/use-unified-get-git-changes.ts b/src/hooks/query/use-unified-get-git-changes.tsindex 610fc7fc15..9acfe81b00 100644--- a/src/hooks/query/use-unified-get-git-changes.ts+++ b/src/hooks/query/use-unified-get-git-changes.ts@@ -24,16 +24,22 @@ export const useUnifiedGetGitChanges = () => {const conversationUrl = conversation?.conversation_url;const sessionApiKey = conversation?.session_api_key;const selectedRepository = conversation?.selected_repository;+ const workingDir = conversation?.workspace?.working_dir?.trim();// Sandbox grouping is enabled when strategy is not NO_GROUPINGconst useSandboxGrouping =settings?.sandbox_grouping_strategy !== "NO_GROUPING" &&settings?.sandbox_grouping_strategy !== undefined;- // Calculate git path based on selected repository and sandbox grouping strategyconst gitPath = React.useMemo(- () => getGitPath(conversationId, selectedRepository, useSandboxGrouping),- [conversationId, selectedRepository, useSandboxGrouping],+ () =>+ getGitPath(+ conversationId,+ selectedRepository,+ useSandboxGrouping,+ workingDir,+ ),+ [conversationId, selectedRepository, useSandboxGrouping, workingDir],);const result = useQuery({diff --git a/src/hooks/query/use-unified-git-diff.ts b/src/hooks/query/use-unified-git-diff.tsindex 7517997c08..cd35b191fe 100644--- a/src/hooks/query/use-unified-git-diff.ts+++ b/src/hooks/query/use-unified-git-diff.ts@@ -26,22 +26,28 @@ export const useUnifiedGitDiff = (config: UseUnifiedGitDiffConfig) => {const conversationUrl = conversation?.conversation_url;const sessionApiKey = conversation?.session_api_key;const selectedRepository = conversation?.selected_repository;+ const workingDir = conversation?.workspace?.working_dir?.trim();// Sandbox grouping is enabled when strategy is not NO_GROUPINGconst useSandboxGrouping =settings?.sandbox_grouping_strategy !== "NO_GROUPING" &&settings?.sandbox_grouping_strategy !== undefined;- // For V1, we need to convert the relative file path to an absolute path- // The diff endpoint expects: /workspace/project/RepoName/relative/pathconst absoluteFilePath = React.useMemo(() => {const gitPath = getGitPath(conversationId,selectedRepository,useSandboxGrouping,+ workingDir,);return `${gitPath}/${config.filePath}`;- }, [conversationId, selectedRepository, useSandboxGrouping, config.filePath]);+ }, [+ conversationId,+ selectedRepository,+ useSandboxGrouping,+ config.filePath,+ workingDir,+ ]);return useQuery({queryKey: [diff --git a/src/utils/get-git-path.ts b/src/utils/get-git-path.tsindex e55b0bb989..21876b1d64 100644--- a/src/utils/get-git-path.ts+++ b/src/utils/get-git-path.ts@@ -1,23 +1,26 @@/**- * Get the git repository path for a conversation+ * Get the git repository path for a conversation.*- * When sandbox grouping is enabled (strategy != NO_GROUPING), each conversation- * gets its own subdirectory: /workspace/project/{conversationId}[/{repoName}]+ * If the backend provides an explicit workspace path for the conversation,+ * prefer that over frontend heuristics.+ *+ * Otherwise, when sandbox grouping is enabled (strategy != NO_GROUPING), each+ * conversation gets its own subdirectory: /workspace/project/{conversationId}[/{repoName}]** When sandbox grouping is disabled (NO_GROUPING), the path is simply:* /workspace/project[/{repoName}]- *- * @param conversationId The conversation ID- * @param selectedRepository The selected repository (e.g., "OpenHands/OpenHands", "owner/repo", or "group/subgroup/repo")- * @param useSandboxGrouping Whether sandbox grouping is enabled (strategy != NO_GROUPING)- * @returns The git path to use*/export function getGitPath(conversationId: string,selectedRepository: string | null | undefined,useSandboxGrouping: boolean = false,+ workingDir?: string | null,): string {- // Base path depends on sandbox grouping strategy+ const normalizedWorkingDir = workingDir?.trim();+ if (normalizedWorkingDir) {+ return normalizedWorkingDir;+ }+const basePath = useSandboxGrouping? `/workspace/project/${conversationId}`: "/workspace/project";@@ -26,8 +29,6 @@ export function getGitPath(return basePath;}- // Extract the repository name from the path- // The folder name is always the last part (handles both "owner/repo" and "group/subgroup/repo" formats)const parts = selectedRepository.split("/");const repoName = parts[parts.length - 1];