fix: derive canvas root from workspace dir when not explicitly configured
When canvasHost.root is not set, use <workspace>/canvas instead of hardcoded ~/clawd/canvas, so the canvas directory respects the agents.defaults.workspace setting.
This commit is contained in:
parent
4583f88626
commit
bfc4e5fe1d
@ -36,7 +36,7 @@ export type DiscoveryConfig = {
|
|||||||
|
|
||||||
export type CanvasHostConfig = {
|
export type CanvasHostConfig = {
|
||||||
enabled?: boolean;
|
enabled?: boolean;
|
||||||
/** Directory to serve (default: ~/clawd/canvas). */
|
/** Directory to serve (default: <workspace>/canvas, e.g. ~/clawd/canvas). */
|
||||||
root?: string;
|
root?: string;
|
||||||
/** HTTP port to listen on (default: 18793). */
|
/** HTTP port to listen on (default: 18793). */
|
||||||
port?: number;
|
port?: number;
|
||||||
|
|||||||
@ -1,4 +1,5 @@
|
|||||||
import type { Server as HttpServer } from "node:http";
|
import type { Server as HttpServer } from "node:http";
|
||||||
|
import path from "node:path";
|
||||||
import { WebSocketServer } from "ws";
|
import { WebSocketServer } from "ws";
|
||||||
import { CANVAS_HOST_PATH } from "../canvas-host/a2ui.js";
|
import { CANVAS_HOST_PATH } from "../canvas-host/a2ui.js";
|
||||||
import { type CanvasHostHandler, createCanvasHostHandler } from "../canvas-host/server.js";
|
import { type CanvasHostHandler, createCanvasHostHandler } from "../canvas-host/server.js";
|
||||||
@ -37,6 +38,7 @@ export async function createGatewayRuntimeState(params: {
|
|||||||
deps: CliDeps;
|
deps: CliDeps;
|
||||||
canvasRuntime: RuntimeEnv;
|
canvasRuntime: RuntimeEnv;
|
||||||
canvasHostEnabled: boolean;
|
canvasHostEnabled: boolean;
|
||||||
|
defaultWorkspaceDir: string;
|
||||||
allowCanvasHostInTests?: boolean;
|
allowCanvasHostInTests?: boolean;
|
||||||
logCanvas: { info: (msg: string) => void; warn: (msg: string) => void };
|
logCanvas: { info: (msg: string) => void; warn: (msg: string) => void };
|
||||||
log: { info: (msg: string) => void; warn: (msg: string) => void };
|
log: { info: (msg: string) => void; warn: (msg: string) => void };
|
||||||
@ -75,7 +77,7 @@ export async function createGatewayRuntimeState(params: {
|
|||||||
try {
|
try {
|
||||||
const handler = await createCanvasHostHandler({
|
const handler = await createCanvasHostHandler({
|
||||||
runtime: params.canvasRuntime,
|
runtime: params.canvasRuntime,
|
||||||
rootDir: params.cfg.canvasHost?.root,
|
rootDir: params.cfg.canvasHost?.root ?? path.join(params.defaultWorkspaceDir, "canvas"),
|
||||||
basePath: CANVAS_HOST_PATH,
|
basePath: CANVAS_HOST_PATH,
|
||||||
allowInTests: params.allowCanvasHostInTests,
|
allowInTests: params.allowCanvasHostInTests,
|
||||||
liveReload: params.cfg.canvasHost?.liveReload,
|
liveReload: params.cfg.canvasHost?.liveReload,
|
||||||
|
|||||||
@ -301,6 +301,7 @@ export async function startGatewayServer(
|
|||||||
deps,
|
deps,
|
||||||
canvasRuntime,
|
canvasRuntime,
|
||||||
canvasHostEnabled,
|
canvasHostEnabled,
|
||||||
|
defaultWorkspaceDir,
|
||||||
allowCanvasHostInTests: opts.allowCanvasHostInTests,
|
allowCanvasHostInTests: opts.allowCanvasHostInTests,
|
||||||
logCanvas,
|
logCanvas,
|
||||||
log,
|
log,
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user