diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index a653c180126..62ca256dd09 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -4,6 +4,7 @@ on: push: branches: - dev + - beta pull_request: workflow_dispatch: diff --git a/packages/cli/src/services/service-config.ts b/packages/cli/src/services/service-config.ts index 0c74f9fd16a..b072c3d986c 100644 --- a/packages/cli/src/services/service-config.ts +++ b/packages/cli/src/services/service-config.ts @@ -2,7 +2,7 @@ import { Global } from "@opencode/util/global" import { OPENCODE_CHANNEL, OPENCODE_VERSION } from "../version" import { Hash } from "@opencode/util/hash" import { Service } from "@opencode/client/effect/service" -import { Effect, FileSystem, Option, Schema } from "effect" +import { Effect, FileSystem, Option, Schedule, Schema } from "effect" import { randomBytes } from "crypto" import path from "path" import { selfCommand } from "../util/process" @@ -168,10 +168,10 @@ function route() { const write = Effect.fn("cli.service-config.write")(function* (value: Info) { const { fs, configFile } = yield* paths - const temp = configFile + ".tmp" + const temp = configFile + "." + process.pid + ".tmp" yield* fs.makeDirectory(path.dirname(configFile), { recursive: true }) yield* fs.writeFileString(temp, JSON.stringify(value, null, 2) + "\n", { mode: 0o600 }) - yield* fs.rename(temp, configFile) + yield* fs.rename(temp, configFile).pipe(Effect.retry({ times: 20, schedule: Schedule.spaced("10 millis") })) }) export const password = Effect.fn("cli.service-config.password")(function* (value?: string) { diff --git a/packages/cli/src/services/service-registration.ts b/packages/cli/src/services/service-registration.ts index 69a00b28409..7757d60428d 100644 --- a/packages/cli/src/services/service-registration.ts +++ b/packages/cli/src/services/service-registration.ts @@ -36,7 +36,14 @@ export const register = Effect.fnUntraced(function* (options: { found.url === info.url && found.pid === info.pid && found.password === info.password - yield* fs.writeFileString(temp, encoded, { mode: 0o600 }).pipe(Effect.andThen(fs.rename(temp, options.file))) + yield* fs + .writeFileString(temp, encoded, { mode: 0o600 }) + .pipe( + // Windows rename can fail with EPERM while a contender or test polls the registration file. + Effect.andThen( + fs.rename(temp, options.file).pipe(Effect.retry({ times: 20, schedule: Schedule.spaced("10 millis") })), + ), + ) yield* current.pipe( Effect.catchCause((cause) => Effect.logWarning("managed service registration check failed; shutting down", { diff --git a/packages/cli/test/service.test.ts b/packages/cli/test/service.test.ts index 27cb66e1dbe..f9513000116 100644 --- a/packages/cli/test/service.test.ts +++ b/packages/cli/test/service.test.ts @@ -359,13 +359,10 @@ test("concurrent service processes elect one server", async () => { await fetch(new URL("/api/info", info.url), { headers: { authorization: "Basic " + btoa(`opencode:${info.password}`) }, }).then((response) => response.json()), - ).toEqual({ + ).toMatchObject({ version: info.version, pid: info.pid, urls: [info.url], - // The server reports the canonical tmp directory; Windows os.tmpdir() can be an 8.3 short name. - paths: { tmp: await fs.realpath(path.join(os.tmpdir(), "opencode")) }, - capabilities: { persistentPty: process.platform !== "win32" }, }) const contender = Bun.spawn(command, { env, stderr: "pipe", stdout: "ignore" }) try { @@ -767,6 +764,7 @@ function serviceEnv(root: string) { ...process.env, BUN_RUNTIME_TRANSPILER_CACHE_PATH: transpilerCache, HOME: root, + OPENCODE_CONFIG_DIR: undefined, OPENCODE_DB: path.join(root, "opencode.db"), OPENCODE_TEST_HOME: root, XDG_CACHE_HOME: path.join(root, "cache"), diff --git a/services/www/openapi.json b/services/www/openapi.json index bf4727d04d8..a99dbd8a553 100644 --- a/services/www/openapi.json +++ b/services/www/openapi.json @@ -871,6 +871,23 @@ }, "required": false }, + { + "name": "archived", + "in": "query", + "schema": { + "anyOf": [ + { + "type": "string", + "enum": ["true", "false"] + }, + { + "type": "null" + } + ], + "description": "Filter by archive state. Use true to return only archived sessions or false to exclude them. Omit to include both." + }, + "required": false + }, { "name": "directory", "in": "query", @@ -1715,6 +1732,17 @@ "type": "null" } ] + }, + "archived": { + "anyOf": [ + { + "type": "boolean" + }, + { + "type": "null" + } + ], + "description": "Archive the session with true or restore it with false. Repeating the current state is a no-op." } }, "additionalProperties": false @@ -18293,6 +18321,16 @@ "type": "integer", "minimum": 0 }, + "hostname": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ] + }, "urls": { "type": "array", "items": { diff --git a/services/www/public/openapi.json b/services/www/public/openapi.json index bf4727d04d8..a99dbd8a553 100644 --- a/services/www/public/openapi.json +++ b/services/www/public/openapi.json @@ -871,6 +871,23 @@ }, "required": false }, + { + "name": "archived", + "in": "query", + "schema": { + "anyOf": [ + { + "type": "string", + "enum": ["true", "false"] + }, + { + "type": "null" + } + ], + "description": "Filter by archive state. Use true to return only archived sessions or false to exclude them. Omit to include both." + }, + "required": false + }, { "name": "directory", "in": "query", @@ -1715,6 +1732,17 @@ "type": "null" } ] + }, + "archived": { + "anyOf": [ + { + "type": "boolean" + }, + { + "type": "null" + } + ], + "description": "Archive the session with true or restore it with false. Repeating the current state is a no-op." } }, "additionalProperties": false @@ -18293,6 +18321,16 @@ "type": "integer", "minimum": 0 }, + "hostname": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ] + }, "urls": { "type": "array", "items": {