Skip to content
Merged
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ All notable changes to **omp-web** (`@kahme247/ompweb`) are documented in this f
- **Copied uploads start retention at the send time on Windows too.** When a hard link cannot be used or its timestamp cannot be changed, the host writes a fresh exclusive copy instead of inheriting an old staging timestamp. Failed copies remain retryable without replacing unrelated files.
- **Windows servers can manage pools of Unix workers.** Pool configuration and clone paths use the worker's path rules, not the web server's OS. Creation journals retain their synced-file, atomic-rename commit on Windows without requiring unsupported directory fsync.
- **Session HTML export supports Windows OMP launchers.** Export uses the same `.cmd` and `.bat` handling as RPC sessions and version checks.
- **Git status and pool preparation work under Windows short paths.** A workspace opened through an 8.3 short name (such as `C:\Users\RUNNER~1`) or with backslashes no longer loses its Git changes, and pooled preparation no longer rejects its own clone as "not an independent repository". Repository roots are located relative to the workspace instead of comparing Git's spelling of the path with the caller's.
- **Newly sent uploads survive an overlapping retention sweep.** The host refreshes the staged file's timestamp before making its hard link visible, for attachments and Files-panel uploads alike, so cleanup cannot mistake a just-sent file for an expired one. A Files-panel overwrite of an expired file can no longer be deleted by a sweep that inspected the file it replaced.
- **Windows upload cleanup respects each daemon's retention policy.** Shared temporary roots now keep each daemon's attachments in its own subfolder, so a seven-day policy cannot delete another daemon's “Never” uploads, even with copied session UUIDs. Existing flat fallback files remain readable and are left untouched because their owner is unknown.
- **Credential copies and config `.env` files stay private without blocking independent uploads.** The file viewer and upload preflight/overwrite deny editor swaps and backups such as `.agent.db.swp`, `agent.db~`, `.models.yml.swp` and `models.yml-backup` only directly in omp's actual agent directories (including profiles). `.env` and `.env.*` are also denied at genuine default/profile config roots and agent directories, including their symlinked real targets. Same-named session uploads, workspace files and package assets remain readable and replaceable.
Expand Down
5 changes: 3 additions & 2 deletions lib/agent-tools.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import test from "node:test";
import { execFileSync } from "node:child_process";
import { existsSync, mkdtempSync, readFileSync, realpathSync, rmSync, writeFileSync } from "node:fs";
import { tmpdir } from "node:os";
import { basename, dirname, join } from "node:path";
import { join, posix } from "node:path";
import { randomUUID } from "node:crypto";
import { fileURLToPath } from "node:url";

Expand Down Expand Up @@ -434,7 +434,8 @@ async function placementFixture(t, { workerAllows = true, fallback = false, hold
invalidateSessionLists: () => null,
preparePoolProject: ({ input }) => {
preparations.push({ hostId: link.id, ...input });
return { ok: true, value: { cwd: join(dirname(input.cloneRoot), `.${basename(input.cloneRoot)}_worktrees`, "session", input.creationId), projectRoot: input.cloneRoot, baseCommit: "a".repeat(40) } };
// A simulated POSIX worker: its paths follow POSIX rules whatever OS runs this test.
return { ok: true, value: { cwd: posix.join(posix.dirname(input.cloneRoot), `.${posix.basename(input.cloneRoot)}_worktrees`, "session", input.creationId), projectRoot: input.cloneRoot, baseCommit: "a".repeat(40) } };
},
addProject: () => ({ ok: true, value: {} }),
updateProject: () => ({ ok: true, value: { projects: [], newRoots: [] } }),
Expand Down
3 changes: 2 additions & 1 deletion lib/git-changes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,10 @@ async function git(cwd: string, args: string[], maxBuffer = GIT_STATUS_MAX_BUFFE
return (await pending).stdout;
}

/** The toplevel in `cwd`'s own spelling: Git's --show-toplevel can differ in separators, 8.3 names and symlinks. */
async function findRepositoryRoot(cwd: string): Promise<string | null> {
try {
return (await git(cwd, ["rev-parse", "--show-toplevel"])).trim() || null;
return path.resolve(cwd, (await git(cwd, ["rev-parse", "--show-cdup"])).trim());
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Resolved
} catch {
return null;
}
Expand Down
3 changes: 2 additions & 1 deletion lib/hosts/files-owner.integration.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,8 @@ async function startDaemon(machine, token) {
await until(() => hub.getHost(machine.hostId)?.status() === "online", `${machine.name} daemon to link`, 20000);
}
async function stopDaemon(machine) {
if (!machine.process || machine.process.exitCode !== null) return;
// Windows kill() terminates without a handler: exitCode stays null and signalCode is set.
if (!machine.process || machine.process.exitCode !== null || machine.process.signalCode !== null) return;
const exited = new Promise((resolve) => machine.process.once("exit", resolve));
machine.process.kill("SIGTERM");
await exited;
Expand Down
30 changes: 21 additions & 9 deletions lib/hosts/pool-starts.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,20 @@ import assert from "node:assert/strict";
import { execFileSync, spawn } from "node:child_process";
import { existsSync, mkdirSync, mkdtempSync, readFileSync, realpathSync, rmSync, writeFileSync } from "node:fs";
import { tmpdir } from "node:os";
import { basename, dirname, join } from "node:path";
import { join, posix, sep } from "node:path";
import { fileURLToPath } from "node:url";
import test from "node:test";

// Windows cannot spawn a shebang script: run it through a .cmd launcher (which wrapWindowsScript routes via cmd.exe).
function writeFakeOmp(file, source) {
if (process.platform !== "win32") {
writeFileSync(file, `#!${process.execPath}\n${source}`, { mode: 0o700 });
return;
}
writeFileSync(`${file}.cjs`, source);
writeFileSync(file, `@"${process.execPath.replaceAll("%", "%%")}" "${file.replaceAll("%", "%%")}.cjs" %*\r\n`);
}

const root = fileURLToPath(new URL("../../", import.meta.url));
const scratch = realpathSync(mkdtempSync(join(tmpdir(), "omp-pool-starts-")));
const previousAgentDir = process.env.PI_CODING_AGENT_DIR;
Expand All @@ -21,7 +31,8 @@ const sample = (overrides = {}) => ({ effectiveCpus: 4, load1: 0, busyFraction:
const intent = { type: "prompt", message: "first prompt", provider: "test", modelId: "model-a", thinkingLevel: "high", toolNames: ["read"], advisor: false };
const records = () => JSON.stringify(JSON.parse(readFileSync(journalPath, "utf8")));
const input = (fixture, suffix, overrides = {}) => ({ creationId: `${fixture.id}-${suffix}`, poolId: fixture.id, projectId: "project", intent, ...overrides });
const preparedFor = (request) => ({ cwd: join(dirname(request.cloneRoot), `.${basename(request.cloneRoot)}_worktrees`, "session", request.creationId), projectRoot: request.cloneRoot, baseCommit: "a".repeat(40) });
// Simulated POSIX workers: their paths follow POSIX rules whatever OS runs this test.
const preparedFor = (request) => ({ cwd: posix.join(posix.dirname(request.cloneRoot), `.${posix.basename(request.cloneRoot)}_worktrees`, "session", request.creationId), projectRoot: request.cloneRoot, baseCommit: "a".repeat(40) });

async function fixture(t, { members = 1, memory = 3 * GiB, prepare } = {}) {
const id = `pool-${++serial}`;
Expand Down Expand Up @@ -285,16 +296,17 @@ async function durableDaemonFixture(t, hold) {
git(source, "push", "origin", "HEAD:refs/heads/main");
git(dir, "--git-dir", remote, "symbolic-ref", "HEAD", "refs/heads/main");
const ssh = join(dir, "ssh");
writeFileSync(ssh, `#!/bin/sh\nexec git-upload-pack '${remote.replaceAll("'", "'\\''")}'\n`, { mode: 0o700 });
gitEnv.GIT_SSH_COMMAND = ssh;
// Git runs GIT_SSH_COMMAND through sh; forward slashes keep Windows paths intact there.
const quotePath = (path) => `'${path.replaceAll("\\", "/").replaceAll("'", "'\\''")}'`;
writeFileSync(ssh, `#!/bin/sh\nexec git-upload-pack ${quotePath(remote)}\n`, { mode: 0o700 });
Object.assign(gitEnv, { GIT_SSH_COMMAND: `sh ${quotePath(ssh)}`, GIT_SSH_VARIANT: "simple" });
const logFile = join(dir, "omp.jsonl");
const killsFile = join(dir, "kills.jsonl");
const eventsFile = join(dir, "events.jsonl");
const holdFile = join(dir, hold);
writeFileSync(holdFile, "");
const fakeOmp = join(dir, "fake-omp");
writeFileSync(fakeOmp, `#!${process.execPath}
if (process.argv.includes("--version")) { console.log("14.0.0-fake"); process.exit(0); }
const fakeOmp = join(dir, process.platform === "win32" ? "fake-omp.cmd" : "fake-omp");
writeFakeOmp(fakeOmp, `if (process.argv.includes("--version")) { console.log("14.0.0-fake"); process.exit(0); }
if (process.argv.includes("update")) { console.log("Current version: 14.0.0-fake"); process.exit(0); }
const fs = require("node:fs"), path = require("node:path");
const id = require("node:crypto").randomUUID();
Expand Down Expand Up @@ -327,7 +339,7 @@ require("node:readline").createInterface({input:process.stdin}).on("line", (line
reply({});
});
process.stdin.on("end",()=>process.exit(0));
`, { mode: 0o700 });
`);
const mainScript = `
import {appendFileSync,existsSync,readFileSync,rmSync,writeFileSync} from "node:fs";
const hub=await import("./lib/hosts/hub.ts");
Expand Down Expand Up @@ -355,7 +367,7 @@ const wrap=(ws)=>{let value=wrapped.get(ws);if(!value){value={data:ws.data,send(
if(message.type==="kill")appendFileSync(${JSON.stringify(killsFile)},JSON.stringify(message)+"\\n");
const launch=message.type==="req"?(message.op==="open"?message.args.launch:message.op==="spawn"?message.args:null):null;
if(launch?.creationId&&existsSync(${JSON.stringify(join(dir, "remove-cwd"))})){
if(!launch.cwd.startsWith(${JSON.stringify(`${projectsRoot}/`)}))throw new Error("fixture refused deleting outside its projects root");
if(!launch.cwd.startsWith(${JSON.stringify(projectsRoot + sep)}))throw new Error("fixture refused deleting outside its projects root");
rmSync(launch.cwd,{recursive:true,force:true});
writeFileSync(${JSON.stringify(join(dir, "cwd-removed"))},"");
}
Expand Down
Loading
Loading