mirror of
https://github.com/OpenHands/OpenHands.git
synced 2026-10-07 17:08:34 +08:00
fix: pass container workspaces path as VITE_WORKING_DIR (#259)
This commit is contained in:
@@ -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,
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user