fix: pass container workspaces path as VITE_WORKING_DIR (#259)

This commit is contained in:
Hiep Le
2026-05-10 15:56:33 +07:00
committed by GitHub
parent 8017bb5e1b
commit 137fbae87f
3 changed files with 25 additions and 1 deletions
+11
View File
@@ -0,0 +1,11 @@
import { describe, expect, it } from "vitest";
import { CONTAINER_WORKSPACES_DIR } from "../../scripts/dev-docker.mjs";
describe("CONTAINER_WORKSPACES_DIR", () => {
it("points at the dockerized agent-server's in-container persistence dir so the working_dir the GUI sends is one the container can mkdir (regression guard for the host-path leak that caused 500 on POST /api/conversations)", () => {
expect(CONTAINER_WORKSPACES_DIR).toBe(
"/home/openhands/.openhands/agent-canvas/workspaces",
);
});
});
+11
View File
@@ -57,6 +57,15 @@ const CONTAINER_NAME = "agent-canvas-dev-agent-server";
// decryptable across docker / non-docker runs.
const DEFAULT_SECRET_KEY = "openhands-dev-secret-key-change-in-prod";
// Path inside the container where the agent-server stores per-conversation
// workspace directories. Mirrors dev-with-automation.mjs's host-side
// `${stateDir}/workspaces`, but rooted under the container's persistence
// dir (which is `~/.openhands` on the host, mounted in below). The frontend
// receives this via VITE_WORKING_DIR so the working_dir it sends to the
// agent-server is one the container can actually mkdir.
const CONTAINER_WORKSPACES_DIR =
"/home/openhands/.openhands/agent-canvas/workspaces";
/**
* Resolve the docker image to use based on environment.
*
@@ -197,6 +206,7 @@ if (isMainModule) {
bannerTitle: "Agent Canvas + Automation Development Stack (Docker)",
extraPrereqs: checkDockerPrereqs,
startAgentServer: startAgentServerDocker,
viteWorkingDir: CONTAINER_WORKSPACES_DIR,
}).catch((err) => {
logError(`Fatal error: ${err.message}`);
if (err.stack) {
@@ -209,6 +219,7 @@ if (isMainModule) {
export {
AGENT_SERVER_REPO,
CONTAINER_NAME,
CONTAINER_WORKSPACES_DIR,
DEFAULT_AGENT_SERVER_TAG,
checkDockerPrereqs,
resolveAgentServerImage,
+3 -1
View File
@@ -556,7 +556,7 @@ function startVite(config) {
// Point Vite at the ingress (so client-side fetches work)
VITE_BACKEND_HOST: `127.0.0.1:${config.ingressPort}`,
VITE_BACKEND_BASE_URL: `http://127.0.0.1:${config.ingressPort}`,
VITE_WORKING_DIR: join(config.stateDir, "workspaces"),
VITE_WORKING_DIR: config.viteWorkingDir ?? join(config.stateDir, "workspaces"),
VITE_FRONTEND_PORT: config.vitePort.toString(),
// Session API key for frontend to authenticate with agent-server
VITE_SESSION_API_KEY: config.sessionApiKey,
@@ -689,6 +689,7 @@ async function main(options = {}) {
bannerTitle = "Agent Canvas + Automation Development Stack",
startAgentServer: startAgentServerOverride,
extraPrereqs,
viteWorkingDir,
} = options;
const args = parseArgs();
@@ -704,6 +705,7 @@ async function main(options = {}) {
// Build config with dynamic port allocation
const config = await buildConfig(args);
if (viteWorkingDir) config.viteWorkingDir = viteWorkingDir;
ensureDirectories(config);
if (typeof extraPrereqs === "function") {
extraPrereqs(config);