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>
143 lines
4.3 KiB
TypeScript
143 lines
4.3 KiB
TypeScript
import { describe, expect, test } from "bun:test"
|
|
import path from "path"
|
|
import { Session } from "../../src/session"
|
|
import { Bus } from "../../src/bus"
|
|
import { Log } from "../../src/util/log"
|
|
import { Instance } from "../../src/project/instance"
|
|
import { MessageV2 } from "../../src/session/message-v2"
|
|
import { MessageID, PartID } from "../../src/session/schema"
|
|
|
|
const projectRoot = path.join(__dirname, "../..")
|
|
Log.init({ print: false })
|
|
|
|
describe("session.created event", () => {
|
|
test("should emit session.created event when session is created", async () => {
|
|
await Instance.provide({
|
|
directory: projectRoot,
|
|
fn: async () => {
|
|
let eventReceived = false
|
|
let receivedInfo: Session.Info | undefined
|
|
|
|
const unsub = Bus.subscribe(Session.Event.Created, (event) => {
|
|
eventReceived = true
|
|
receivedInfo = event.properties.info as Session.Info
|
|
})
|
|
|
|
const session = await Session.create({})
|
|
|
|
await new Promise((resolve) => setTimeout(resolve, 100))
|
|
|
|
unsub()
|
|
|
|
expect(eventReceived).toBe(true)
|
|
expect(receivedInfo).toBeDefined()
|
|
expect(receivedInfo?.id).toBe(session.id)
|
|
expect(receivedInfo?.projectID).toBe(session.projectID)
|
|
expect(receivedInfo?.directory).toBe(session.directory)
|
|
expect(receivedInfo?.title).toBe(session.title)
|
|
|
|
await Session.remove(session.id)
|
|
},
|
|
})
|
|
})
|
|
|
|
test("session.created event should be emitted before session.updated", async () => {
|
|
await Instance.provide({
|
|
directory: projectRoot,
|
|
fn: async () => {
|
|
const events: string[] = []
|
|
|
|
const unsubCreated = Bus.subscribe(Session.Event.Created, () => {
|
|
events.push("created")
|
|
})
|
|
|
|
const unsubUpdated = Bus.subscribe(Session.Event.Updated, () => {
|
|
events.push("updated")
|
|
})
|
|
|
|
const session = await Session.create({})
|
|
|
|
await new Promise((resolve) => setTimeout(resolve, 100))
|
|
|
|
unsubCreated()
|
|
unsubUpdated()
|
|
|
|
expect(events).toContain("created")
|
|
expect(events).toContain("updated")
|
|
expect(events.indexOf("created")).toBeLessThan(events.indexOf("updated"))
|
|
|
|
await Session.remove(session.id)
|
|
},
|
|
})
|
|
})
|
|
})
|
|
|
|
describe("step-finish token propagation via Bus event", () => {
|
|
test(
|
|
"non-zero tokens propagate through PartUpdated event",
|
|
async () => {
|
|
await Instance.provide({
|
|
directory: projectRoot,
|
|
fn: async () => {
|
|
const session = await Session.create({})
|
|
|
|
const messageID = MessageID.ascending()
|
|
await Session.updateMessage({
|
|
id: messageID,
|
|
sessionID: session.id,
|
|
role: "user",
|
|
time: { created: Date.now() },
|
|
agent: "user",
|
|
model: { providerID: "test", modelID: "test" },
|
|
tools: {},
|
|
mode: "",
|
|
} as unknown as MessageV2.Info)
|
|
|
|
let received: MessageV2.Part | undefined
|
|
const unsub = Bus.subscribe(MessageV2.Event.PartUpdated, (event) => {
|
|
received = event.properties.part
|
|
})
|
|
|
|
const tokens = {
|
|
total: 1500,
|
|
input: 500,
|
|
output: 800,
|
|
reasoning: 200,
|
|
cache: { read: 100, write: 50 },
|
|
}
|
|
|
|
const partInput = {
|
|
id: PartID.ascending(),
|
|
messageID,
|
|
sessionID: session.id,
|
|
type: "step-finish" as const,
|
|
reason: "stop",
|
|
cost: 0.005,
|
|
tokens,
|
|
}
|
|
|
|
await Session.updatePart(partInput)
|
|
|
|
await new Promise((resolve) => setTimeout(resolve, 100))
|
|
|
|
expect(received).toBeDefined()
|
|
expect(received!.type).toBe("step-finish")
|
|
const finish = received as MessageV2.StepFinishPart
|
|
expect(finish.tokens.input).toBe(500)
|
|
expect(finish.tokens.output).toBe(800)
|
|
expect(finish.tokens.reasoning).toBe(200)
|
|
expect(finish.tokens.total).toBe(1500)
|
|
expect(finish.tokens.cache.read).toBe(100)
|
|
expect(finish.tokens.cache.write).toBe(50)
|
|
expect(finish.cost).toBe(0.005)
|
|
expect(received).not.toBe(partInput)
|
|
|
|
unsub()
|
|
await Session.remove(session.id)
|
|
},
|
|
})
|
|
},
|
|
{ timeout: 30000 },
|
|
)
|
|
})
|