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>
192 lines
5.0 KiB
TypeScript
192 lines
5.0 KiB
TypeScript
import { describe, test, expect, beforeEach, afterEach, afterAll } from "bun:test"
|
|
import { tmpdir } from "../fixture/fixture"
|
|
import z from "zod"
|
|
import { Bus } from "../../src/bus"
|
|
import { Instance } from "../../src/project/instance"
|
|
import { SyncEvent } from "../../src/sync"
|
|
import { Database } from "../../src/storage/db"
|
|
import { EventTable } from "../../src/sync/event.sql"
|
|
import { Identifier } from "../../src/id/id"
|
|
import { Flag } from "../../src/flag/flag"
|
|
import { initProjectors } from "../../src/server/projectors"
|
|
|
|
const original = Flag.KILO_EXPERIMENTAL_WORKSPACES
|
|
|
|
beforeEach(() => {
|
|
Database.close()
|
|
|
|
// @ts-expect-error don't do this normally, but it works
|
|
Flag.KILO_EXPERIMENTAL_WORKSPACES = true
|
|
})
|
|
|
|
afterEach(() => {
|
|
// @ts-expect-error don't do this normally, but it works
|
|
Flag.KILO_EXPERIMENTAL_WORKSPACES = original
|
|
})
|
|
|
|
function withInstance(fn: () => void | Promise<void>) {
|
|
return async () => {
|
|
await using tmp = await tmpdir()
|
|
|
|
await Instance.provide({
|
|
directory: tmp.path,
|
|
fn: async () => {
|
|
await fn()
|
|
},
|
|
})
|
|
}
|
|
}
|
|
|
|
describe("SyncEvent", () => {
|
|
function setup() {
|
|
SyncEvent.reset()
|
|
|
|
const Created = SyncEvent.define({
|
|
type: "item.created",
|
|
version: 1,
|
|
aggregate: "id",
|
|
schema: z.object({ id: z.string(), name: z.string() }),
|
|
})
|
|
const Sent = SyncEvent.define({
|
|
type: "item.sent",
|
|
version: 1,
|
|
aggregate: "item_id",
|
|
schema: z.object({ item_id: z.string(), to: z.string() }),
|
|
})
|
|
|
|
SyncEvent.init({
|
|
projectors: [SyncEvent.project(Created, () => {}), SyncEvent.project(Sent, () => {})],
|
|
})
|
|
|
|
return { Created, Sent }
|
|
}
|
|
|
|
afterAll(() => {
|
|
SyncEvent.reset()
|
|
initProjectors()
|
|
})
|
|
|
|
describe("run", () => {
|
|
test(
|
|
"inserts event row",
|
|
withInstance(() => {
|
|
const { Created } = setup()
|
|
SyncEvent.run(Created, { id: "evt_1", name: "first" })
|
|
const rows = Database.use((db) => db.select().from(EventTable).all())
|
|
expect(rows).toHaveLength(1)
|
|
expect(rows[0].type).toBe("item.created.1")
|
|
expect(rows[0].aggregate_id).toBe("evt_1")
|
|
}),
|
|
)
|
|
|
|
test(
|
|
"increments seq per aggregate",
|
|
withInstance(() => {
|
|
const { Created } = setup()
|
|
SyncEvent.run(Created, { id: "evt_1", name: "first" })
|
|
SyncEvent.run(Created, { id: "evt_1", name: "second" })
|
|
const rows = Database.use((db) => db.select().from(EventTable).all())
|
|
expect(rows).toHaveLength(2)
|
|
expect(rows[1].seq).toBe(rows[0].seq + 1)
|
|
}),
|
|
)
|
|
|
|
test(
|
|
"uses custom aggregate field from agg()",
|
|
withInstance(() => {
|
|
const { Sent } = setup()
|
|
SyncEvent.run(Sent, { item_id: "evt_1", to: "james" })
|
|
const rows = Database.use((db) => db.select().from(EventTable).all())
|
|
expect(rows).toHaveLength(1)
|
|
expect(rows[0].aggregate_id).toBe("evt_1")
|
|
}),
|
|
)
|
|
|
|
test(
|
|
"emits events",
|
|
withInstance(async () => {
|
|
const { Created } = setup()
|
|
const events: Array<{
|
|
type: string
|
|
properties: { id: string; name: string }
|
|
}> = []
|
|
const received = new Promise<void>((resolve) => {
|
|
Bus.subscribeAll((event) => {
|
|
events.push(event)
|
|
resolve()
|
|
})
|
|
})
|
|
|
|
SyncEvent.run(Created, { id: "evt_1", name: "test" })
|
|
|
|
await received
|
|
expect(events).toHaveLength(1)
|
|
expect(events[0]).toEqual({
|
|
type: "item.created",
|
|
properties: {
|
|
id: "evt_1",
|
|
name: "test",
|
|
},
|
|
})
|
|
}),
|
|
)
|
|
})
|
|
|
|
describe("replay", () => {
|
|
test(
|
|
"inserts event from external payload",
|
|
withInstance(() => {
|
|
const id = Identifier.descending("message")
|
|
SyncEvent.replay({
|
|
id: "evt_1",
|
|
type: "item.created.1",
|
|
seq: 0,
|
|
aggregateID: id,
|
|
data: { id, name: "replayed" },
|
|
})
|
|
const rows = Database.use((db) => db.select().from(EventTable).all())
|
|
expect(rows).toHaveLength(1)
|
|
expect(rows[0].aggregate_id).toBe(id)
|
|
}),
|
|
)
|
|
|
|
test(
|
|
"throws on sequence mismatch",
|
|
withInstance(() => {
|
|
const id = Identifier.descending("message")
|
|
SyncEvent.replay({
|
|
id: "evt_1",
|
|
type: "item.created.1",
|
|
seq: 0,
|
|
aggregateID: id,
|
|
data: { id, name: "first" },
|
|
})
|
|
expect(() =>
|
|
SyncEvent.replay({
|
|
id: "evt_1",
|
|
type: "item.created.1",
|
|
seq: 5,
|
|
aggregateID: id,
|
|
data: { id, name: "bad" },
|
|
}),
|
|
).toThrow(/Sequence mismatch/)
|
|
}),
|
|
)
|
|
|
|
test(
|
|
"throws on unknown event type",
|
|
withInstance(() => {
|
|
expect(() =>
|
|
SyncEvent.replay({
|
|
id: "evt_1",
|
|
type: "unknown.event.1",
|
|
seq: 0,
|
|
aggregateID: "x",
|
|
data: {},
|
|
}),
|
|
).toThrow(/Unknown event type/)
|
|
}),
|
|
)
|
|
})
|
|
})
|