7ea50aac14
* tweak: use theme tokens for debug bar surface * chore: update nix node_modules hashes * feat(tui): add heap snapshot functionality for TUI and server (#19028) * ci * change model for changelog * release: v1.3.2 * fix(opencode): skip typechecking generated models snapshot (#19018) * Revert "fix(app): more startup efficiency (#18985)" This reverts commit98b3340cee. * Revert "fix(app): startup efficiency (#18854)" This reverts commit546748a461. * effectify Worktree service (#18679) * fix: increase operations-per-run to 1000 and pin stale action to v10.2.0 The stale-issues workflow was hitting the default 30 operations limit, preventing it from processing all 2900+ issues/PRs. Increased to 1000 to handle the full backlog. Also pinned to exact v10.2.0 for reproducibility. * Add close-issues script and GitHub Action - Create script/github/close-issues.ts to close stale issues after 60 days - Add GitHub Action workflow to run daily at 2 AM - Remove old stale-issues workflow to avoid conflicts * Fix close-issues workflow permissions - Add contents: read permission for checkout - Use github.token instead of secrets.GITHUB_TOKEN * Process issues sequentially to avoid rate limits * Change issue close reason from not_planned to completed * fix(opencode): avoid snapshotting files over 2MB (#19043) * fix: provide merge context to beta conflict resolver (#19055) * tweak: only spawn lsp servers for files in current instance (or cwd if instance is global) (#19058) * fix: beta resolver typecheck + build smoke check (#19060) * fix: unblock beta conflict recovery (#19068) * electron: add createDirectory to open directory picker (#19071) * electron: remove file extension from electron-store wrapper (#19082) * app: pre-warm project globalSync state when navigate project via keybind (#19088) * fix(app): move message navigation off cmd+arrow (#18728) * Reapply "fix(app): startup efficiency (#18854)" This reverts commita379eb3867. * Reapply "fix(app): more startup efficiency (#18985)" This reverts commitcbe1337f24. * fix(app): hash inline script for csp * Revert "fix(app): startup efficiency" * Reapply "fix(app): startup efficiency" This reverts commit898456a25c. * fix(app): opencode web server url * chore(app): markdown playground in storyboard * chore(app): markdown playground in storyboard * feat(core): initial implementation of syncing (#17814) * chore: generate * chore: bump modelcontextprotocol/sdk to 1.27.1 (#19064) * chore: storybook tweaks * feat: restore git-backed review modes with effectful git service (#18900) * chore: generate * chore: update nix node_modules hashes * chore: cleanup * chore: remove dead code for todoread tool (#19128) * chore: storybook tweaks * fix(opencode): classify ZlibError from Bun fetch as retryable instead of unknown (#19104) Co-authored-by: Aiden Cline <63023139+rekram1-node@users.noreply.github.com> * fix(task): respect agent permission config for todowrite tool (#19125) * fix(app): agent normalization (#19169) * fix: Windows e2e stability (CrossSpawnSpawner, snapshot isolation, session race guards) (#19163) * fix+refactor(mcp): lifecycle tests, cancelPending fix, Effect migration (#19042) * effectify Bus service: migrate to Effect PubSub + InstanceState (#18579) * file: use Effect.cached for scan deduplication (#19164) * ignore: update disavowed list (#19184) * skill: use Effect.cached for load deduplication (#19165) * chore: generate * fix: bump gitlab-ai-provider to 5.3.3 for DWS tool approval support (#19185) * test: restore 5 workers on Windows e2e (#19188) * fix(opencode): image paste on Windows Terminal 1.25+ with kitty keyboard (#17674) * chore: update nix node_modules hashes * wip: zen * wip: zen * go: do not respect disabled zen models * fix: ensure enterprise url is set properly during auth flow (#19212) * revert: roll back git-backed review modes (#19295) * chore: generate * tui: bypass local SSE event streaming in worker (#19183) * feat: embed WebUI in binary with proxy flags (#19299) Co-authored-by: BlankParticle <blankparticle@gmail.com> * release: v1.3.3 * refactor: kilo compat for v1.3.3 * fix: Typecheck issues * fix(build): normalize backslashes in web UI bundle import paths Replace backslashes with forward slashes in embedded web UI file import paths to ensure correct module resolution on Windows. * fix: Add mcp reconnect error handling * chore(script): use forward slashes in web UI bundle export keys Ensure embedded file map keys use POSIX-style paths so lookups are consistent across platforms. * chore: regenerate source links --------- Co-authored-by: Jay V <air@live.ca> Co-authored-by: opencode-agent[bot] <opencode-agent[bot]@users.noreply.github.com> Co-authored-by: Dax <mail@thdxr.com> Co-authored-by: Dax Raad <d@ironbay.co> Co-authored-by: opencode <opencode@sst.dev> Co-authored-by: Kit Langton <kit.langton@gmail.com> Co-authored-by: Adam <2363879+adamdotdevin@users.noreply.github.com> Co-authored-by: Luke Parker <10430890+Hona@users.noreply.github.com> Co-authored-by: Aiden Cline <63023139+rekram1-node@users.noreply.github.com> Co-authored-by: Brendan Allan <brendonovich@outlook.com> Co-authored-by: Shoubhit Dash <shoubhit2005@gmail.com> Co-authored-by: James Long <longster@gmail.com> Co-authored-by: André Cruz <acruz@cloudflare.com> Co-authored-by: Ariane Emory <97994360+ariane-emory@users.noreply.github.com> Co-authored-by: Vladimir Glafirov <vglafirov@gitlab.com> Co-authored-by: Frank <frank@anoma.ly> Co-authored-by: BlankParticle <blankparticle@gmail.com> Co-authored-by: Imanol Maiztegui <imanol.mzd@gmail.com>
174 lines
6.0 KiB
TypeScript
174 lines
6.0 KiB
TypeScript
import { $ } from "bun"
|
|
import { afterEach, describe, expect, test } from "bun:test"
|
|
|
|
const wintest = process.platform !== "win32" ? test : test.skip
|
|
import fs from "fs/promises"
|
|
import path from "path"
|
|
import { Instance } from "../../src/project/instance"
|
|
import { Worktree } from "../../src/worktree"
|
|
import { tmpdir } from "../fixture/fixture"
|
|
|
|
function withInstance(directory: string, fn: () => Promise<any>) {
|
|
return Instance.provide({ directory, fn })
|
|
}
|
|
|
|
function normalize(input: string) {
|
|
return input.replace(/\\/g, "/").toLowerCase()
|
|
}
|
|
|
|
async function waitReady() {
|
|
const { GlobalBus } = await import("../../src/bus/global")
|
|
|
|
return await new Promise<{ name: string; branch: string }>((resolve, reject) => {
|
|
const timer = setTimeout(() => {
|
|
GlobalBus.off("event", on)
|
|
reject(new Error("timed out waiting for worktree.ready"))
|
|
}, 10_000)
|
|
|
|
function on(evt: { directory?: string; payload: { type: string; properties: { name: string; branch: string } } }) {
|
|
if (evt.payload.type !== Worktree.Event.Ready.type) return
|
|
clearTimeout(timer)
|
|
GlobalBus.off("event", on)
|
|
resolve(evt.payload.properties)
|
|
}
|
|
|
|
GlobalBus.on("event", on)
|
|
})
|
|
}
|
|
|
|
describe("Worktree", () => {
|
|
afterEach(() => Instance.disposeAll())
|
|
|
|
describe("makeWorktreeInfo", () => {
|
|
test("returns info with name, branch, and directory", async () => {
|
|
await using tmp = await tmpdir({ git: true })
|
|
|
|
const info = await withInstance(tmp.path, () => Worktree.makeWorktreeInfo())
|
|
|
|
expect(info.name).toBeDefined()
|
|
expect(typeof info.name).toBe("string")
|
|
expect(info.branch).toBe(`opencode/${info.name}`)
|
|
expect(info.directory).toContain(info.name)
|
|
})
|
|
|
|
test("uses provided name as base", async () => {
|
|
await using tmp = await tmpdir({ git: true })
|
|
|
|
const info = await withInstance(tmp.path, () => Worktree.makeWorktreeInfo("my-feature"))
|
|
|
|
expect(info.name).toBe("my-feature")
|
|
expect(info.branch).toBe("opencode/my-feature")
|
|
})
|
|
|
|
test("slugifies the provided name", async () => {
|
|
await using tmp = await tmpdir({ git: true })
|
|
|
|
const info = await withInstance(tmp.path, () => Worktree.makeWorktreeInfo("My Feature Branch!"))
|
|
|
|
expect(info.name).toBe("my-feature-branch")
|
|
})
|
|
|
|
test("throws NotGitError for non-git directories", async () => {
|
|
await using tmp = await tmpdir()
|
|
|
|
await expect(withInstance(tmp.path, () => Worktree.makeWorktreeInfo())).rejects.toThrow("WorktreeNotGitError")
|
|
})
|
|
})
|
|
|
|
describe("create + remove lifecycle", () => {
|
|
test("create returns worktree info and remove cleans up", async () => {
|
|
await using tmp = await tmpdir({ git: true })
|
|
|
|
const info = await withInstance(tmp.path, () => Worktree.create())
|
|
|
|
expect(info.name).toBeDefined()
|
|
expect(info.branch).toStartWith("opencode/")
|
|
expect(info.directory).toBeDefined()
|
|
|
|
// Wait for bootstrap to complete
|
|
await Bun.sleep(1000)
|
|
|
|
const ok = await withInstance(tmp.path, () => Worktree.remove({ directory: info.directory }))
|
|
expect(ok).toBe(true)
|
|
})
|
|
|
|
test("create returns after setup and fires Event.Ready after bootstrap", async () => {
|
|
await using tmp = await tmpdir({ git: true })
|
|
const ready = waitReady()
|
|
|
|
const info = await withInstance(tmp.path, () => Worktree.create())
|
|
|
|
// create returns before bootstrap completes, but the worktree already exists
|
|
expect(info.name).toBeDefined()
|
|
expect(info.branch).toStartWith("opencode/")
|
|
|
|
const text = await $`git worktree list --porcelain`.cwd(tmp.path).quiet().text()
|
|
const dir = await fs.realpath(info.directory).catch(() => info.directory)
|
|
expect(normalize(text)).toContain(normalize(dir))
|
|
|
|
// Event.Ready fires after bootstrap finishes in the background
|
|
const props = await ready
|
|
expect(props.name).toBe(info.name)
|
|
expect(props.branch).toBe(info.branch)
|
|
|
|
// Cleanup
|
|
await withInstance(info.directory, () => Instance.dispose())
|
|
await Bun.sleep(100)
|
|
await withInstance(tmp.path, () => Worktree.remove({ directory: info.directory }))
|
|
})
|
|
|
|
test("create with custom name", async () => {
|
|
await using tmp = await tmpdir({ git: true })
|
|
const ready = waitReady()
|
|
|
|
const info = await withInstance(tmp.path, () => Worktree.create({ name: "test-workspace" }))
|
|
|
|
expect(info.name).toBe("test-workspace")
|
|
expect(info.branch).toBe("opencode/test-workspace")
|
|
|
|
// Cleanup
|
|
await ready
|
|
await withInstance(info.directory, () => Instance.dispose())
|
|
await Bun.sleep(100)
|
|
await withInstance(tmp.path, () => Worktree.remove({ directory: info.directory }))
|
|
})
|
|
})
|
|
|
|
describe("createFromInfo", () => {
|
|
wintest("creates and bootstraps git worktree", async () => {
|
|
await using tmp = await tmpdir({ git: true })
|
|
|
|
const info = await withInstance(tmp.path, () => Worktree.makeWorktreeInfo("from-info-test"))
|
|
await withInstance(tmp.path, () => Worktree.createFromInfo(info))
|
|
|
|
// Worktree should exist in git (normalize slashes for Windows)
|
|
const list = await $`git worktree list --porcelain`.cwd(tmp.path).quiet().text()
|
|
const normalizedList = list.replace(/\\/g, "/")
|
|
const normalizedDir = info.directory.replace(/\\/g, "/")
|
|
expect(normalizedList).toContain(normalizedDir)
|
|
|
|
// Cleanup
|
|
await withInstance(tmp.path, () => Worktree.remove({ directory: info.directory }))
|
|
})
|
|
})
|
|
|
|
describe("remove edge cases", () => {
|
|
test("remove non-existent directory succeeds silently", async () => {
|
|
await using tmp = await tmpdir({ git: true })
|
|
|
|
const ok = await withInstance(tmp.path, () =>
|
|
Worktree.remove({ directory: path.join(tmp.path, "does-not-exist") }),
|
|
)
|
|
expect(ok).toBe(true)
|
|
})
|
|
|
|
test("throws NotGitError for non-git directories", async () => {
|
|
await using tmp = await tmpdir()
|
|
|
|
await expect(withInstance(tmp.path, () => Worktree.remove({ directory: "/tmp/fake" }))).rejects.toThrow(
|
|
"WorktreeNotGitError",
|
|
)
|
|
})
|
|
})
|
|
})
|