Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions desktop/agent-setup.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,17 @@ import { validateProjectId } from "./project-binding.mjs";

const GUIDE_NAME = "VIDEO_FS_AGENT_GUIDE.md";

/** Codex starts an MCP server with a short fixed list of environment variables.
* On Linux the launcher is the desktop app, which exits at startup when it
* cannot reach the session's display, so Codex has to pass these on as well. */
const CODEX_DISPLAY_ENV_VARS = [
"DISPLAY",
"WAYLAND_DISPLAY",
"XAUTHORITY",
"XDG_RUNTIME_DIR",
"XDG_SESSION_TYPE",
];

export function projectIdFromAppUrl(candidate, appUrl) {
let url;
try {
Expand Down Expand Up @@ -70,6 +81,9 @@ export async function setupAgentProject({ projectId: rawProjectId, state }) {
"[mcp_servers.video-fs]",
`command = ${tomlString(launcher.command)}`,
`args = ${tomlStringArray(launcher.args)}`,
...(process.platform === "linux"
? [`env_vars = ${tomlStringArray(CODEX_DISPLAY_ENV_VARS)}`]
: []),
"",
].join("\n");
const claudeHookConfig = hookConfig(claudeHookLauncher);
Expand Down
9 changes: 9 additions & 0 deletions desktop/agent-setup.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -337,6 +337,15 @@ test("both generated launchers bind exactly the opened project", async () => {
);
assert.match(codex, /args = \["--mcp", "--project-id", "bound-project"\]/);
assert.doesNotMatch(codex, /project-a|project-b/);
// Codex hands an MCP server none of the display variables unless they are
// named, and on Linux the launcher cannot start without them.
assert.equal(
codex.includes(
'env_vars = ["DISPLAY", "WAYLAND_DISPLAY", "XAUTHORITY", "XDG_RUNTIME_DIR", "XDG_SESSION_TYPE"]\n',
),
process.platform === "linux",
);
assert.equal(codex.includes("env_vars"), process.platform === "linux");

const claudeHooks = JSON.parse(
await readFile(
Expand Down