Skip to content

Commit c02e6ec

Browse files
neriousyvirajchoudharyNie Yinanmatt8sstussysenik
authored
fix: fix a batch of Windows tooling and test harness issues (#66806)
Co-authored-by: Viraj Choudhary <70713801+virajchoudhary@users.noreply.github.com> Co-authored-by: Nie Yinan <noah17@yeah.net> Co-authored-by: Matthew Em. Spotnitz <mespotnitz@gmail.com> Co-authored-by: stussysenik <35629779+stussysenik@users.noreply.github.com>
1 parent f2a9ebb commit c02e6ec

9 files changed

Lines changed: 107 additions & 63 deletions

File tree

‎packages/app/package.json‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@
2121
"build": "vite build",
2222
"serve": "vite preview",
2323
"test": "bun run test:unit && bun run test:browser",
24-
"test:unit": "bun test --conditions=solid --only-failures --isolate --preload ../ui/test/solid-jsx.ts --preload ./happydom.ts ./src",
24+
"test:unit": "bun test --conditions=browser --only-failures --isolate --preload ../ui/test/solid-jsx.ts --preload ./happydom.ts ./src",
2525
"test:browser": "bun test --conditions=browser --isolate --preload ../ui/test/solid-jsx.ts --preload ./happydom.ts ./test-browser",
26-
"test:unit:watch": "bun test --conditions=solid --watch --isolate --preload ../ui/test/solid-jsx.ts --preload ./happydom.ts ./src",
26+
"test:unit:watch": "bun test --conditions=browser --watch --isolate --preload ../ui/test/solid-jsx.ts --preload ./happydom.ts ./src",
2727
"test:e2e": "playwright test",
2828
"test:e2e:built": "PLAYWRIGHT_BUILD=1 playwright test",
2929
"test:e2e:local": "playwright test",

‎packages/app/src/composer/editor/actions.test.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { describe, expect, test } from "bun:test"
2-
import { createStore } from "solid-js/store"
2+
import { createStore, unwrap } from "solid-js/store"
33
import { Skill } from "@opencode/schema/skill"
44
import type { ComposerPersistedState } from "../types"
55
import { createComposerEditorActions } from "./actions"
@@ -123,7 +123,7 @@ describe("Composer store", () => {
123123
},
124124
{ start: 0, end: 0 },
125125
)
126-
expect(prompt.state.prompt).toMatchObject([
126+
expect(unwrap(prompt.state.prompt)).toMatchObject([
127127
{ type: "skill", id: "show-me", content: "@show-me", start: 0, end: 8 },
128128
{ type: "text", content: " ", start: 8, end: 9 },
129129
{ type: "file", path: "one", content: "@one", start: 9, end: 13 },

‎packages/app/src/composer/submit.test.ts‎

Lines changed: 69 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -314,54 +314,66 @@ describe("Composer submission", () => {
314314
gate.resolve()
315315
await submitted
316316
await sent.promise
317-
expect(calls.filter((call) => call === "gate" || call === "admit" || call === "send")).toEqual(["gate", "admit", "send"])
317+
expect(calls.filter((call) => call === "gate" || call === "admit" || call === "send")).toEqual([
318+
"gate",
319+
"admit",
320+
"send",
321+
])
318322
expect(composer.submission.state()).toEqual({ type: "idle", attempt: 1 })
319323
})
320324

321325
test.each([
322326
{ name: "a prompt", prompt: "Hello", left: "Hello" },
323327
{ name: "a prompt, with a draft typed since", prompt: "Hello", edit: "next", left: "Hello\n\nnext" },
324328
{ name: "a server command", prompt: "/review now", left: "/review now" },
325-
])("Stop while $name waits on the gate cancels that send: nothing reaches the server and its text comes back", async (row) => {
326-
const calls: string[] = []
327-
const timeline: string[] = []
328-
const statuses: ("idle" | "running")[] = []
329-
const gate = Promise.withResolvers<void>()
330-
331-
const target = session({
332-
calls,
333-
statuses,
334-
handoff: { set: () => timeline.push("set"), hold() {}, settle: () => timeline.push("settle"), clear: () => timeline.push("clear") },
335-
command: async () => void calls.push("command"),
336-
})
337-
338-
const composer = gated(target, () => gate.promise, { prompt: row.prompt, calls })
339-
const submitted = composer.submission.submit(new Event("submit"))
340-
await flush()
341-
expect(composer.submission.state().type).toBe("sending")
342-
expect(text(composer.state)).toBe("")
343-
344-
if (row.edit) composer.state.set(typed(row.edit), row.edit.length)
345-
await composer.submission.stop()
346-
await submitted
347-
await flush()
329+
])(
330+
"Stop while $name waits on the gate cancels that send: nothing reaches the server and its text comes back",
331+
async (row) => {
332+
const calls: string[] = []
333+
const timeline: string[] = []
334+
const statuses: ("idle" | "running")[] = []
335+
const gate = Promise.withResolvers<void>()
348336

349-
// Neither the request nor an interrupt: the Session was never told of this send.
350-
expect(calls.filter((call) => call === "send" || call === "command" || call === "interrupt")).toEqual([])
351-
expect(text(composer.state)).toBe(row.left)
352-
expect(composer.failures).toEqual([])
353-
expect(composer.submission.state()).toEqual({ type: "idle", attempt: 1 })
354-
// A prompt that showed in the Session is taken out of it again, and the Session is not left looking busy.
355-
expect(timeline).toEqual(row.prompt.startsWith("/") ? [] : ["set", "clear"])
356-
expect(statuses.at(-1) ?? "idle").toBe("idle")
357-
expect(composer.history).toEqual([`add:${row.prompt}`, `remove:${row.prompt}`])
337+
const target = session({
338+
calls,
339+
statuses,
340+
handoff: {
341+
set: () => timeline.push("set"),
342+
hold() {},
343+
settle: () => timeline.push("settle"),
344+
clear: () => timeline.push("clear"),
345+
},
346+
command: async () => void calls.push("command"),
347+
})
358348

359-
// What the send waited for is ready later: the result belongs to a send that no longer exists.
360-
gate.resolve()
361-
await flush()
362-
expect(calls.filter((call) => call === "send" || call === "command")).toEqual([])
363-
expect(composer.submission.state()).toEqual({ type: "idle", attempt: 1 })
364-
})
349+
const composer = gated(target, () => gate.promise, { prompt: row.prompt, calls })
350+
const submitted = composer.submission.submit(new Event("submit"))
351+
await flush()
352+
expect(composer.submission.state().type).toBe("sending")
353+
expect(text(composer.state)).toBe("")
354+
355+
if (row.edit) composer.state.set(typed(row.edit), row.edit.length)
356+
await composer.submission.stop()
357+
await submitted
358+
await flush()
359+
360+
// Neither the request nor an interrupt: the Session was never told of this send.
361+
expect(calls.filter((call) => call === "send" || call === "command" || call === "interrupt")).toEqual([])
362+
expect(text(composer.state)).toBe(row.left)
363+
expect(composer.failures).toEqual([])
364+
expect(composer.submission.state()).toEqual({ type: "idle", attempt: 1 })
365+
// A prompt that showed in the Session is taken out of it again, and the Session is not left looking busy.
366+
expect(timeline).toEqual(row.prompt.startsWith("/") ? [] : ["set", "clear"])
367+
expect(statuses.at(-1) ?? "idle").toBe("idle")
368+
expect(composer.history).toEqual([`add:${row.prompt}`, `remove:${row.prompt}`])
369+
370+
// What the send waited for is ready later: the result belongs to a send that no longer exists.
371+
gate.resolve()
372+
await flush()
373+
expect(calls.filter((call) => call === "send" || call === "command")).toEqual([])
374+
expect(composer.submission.state()).toEqual({ type: "idle", attempt: 1 })
375+
},
376+
)
365377

366378
test.each([
367379
{
@@ -405,7 +417,12 @@ describe("Composer submission", () => {
405417

406418
await flush()
407419
expect(composer.state.context.items()).toEqual([])
408-
composer.state.context.add({ type: "file", path: "src/later.ts", comment: "Added while it waited", commentID: "later" })
420+
composer.state.context.add({
421+
type: "file",
422+
path: "src/later.ts",
423+
comment: "Added while it waited",
424+
commentID: "later",
425+
})
409426
await composer.submission.stop()
410427
await submitted
411428
await flush()
@@ -526,8 +543,7 @@ describe("Composer submission", () => {
526543
const ref = { key: `server\n${target.id}`, id: target.id } as SessionRef
527544
const never = { plugin: "browser", value: { ready: () => new Promise<void>(() => undefined) } }
528545

529-
const ready = () =>
530-
how === "times out" ? settlePromptGates([never], () => true, ref) : gate.promise
546+
const ready = () => (how === "times out" ? settlePromptGates([never], () => true, ref) : gate.promise)
531547

532548
const sends = [
533549
gated(target, ready, { prompt: "Hello" }),
@@ -557,9 +573,7 @@ describe("Composer submission", () => {
557573
const accepted = Promise.withResolvers<void>()
558574
const state = createMemoryComposerState({ prompt: "Hello" }).capture()
559575

560-
await submitInput(active(state, session({ calls, accept: () => accepted.resolve() }))).submit(
561-
new Event("submit"),
562-
)
576+
await submitInput(active(state, session({ calls, accept: () => accepted.resolve() }))).submit(new Event("submit"))
563577
await accepted.promise
564578

565579
expect(calls.filter((call) => call === "accept-send")).toHaveLength(1)
@@ -657,9 +671,7 @@ describe("Composer submission", () => {
657671
expect(await submission.submitComment("quote:c=selected", "Compare @src/api.ts with @here")).toBe(true)
658672
expect(calls[0]).toBe("keep-preview")
659673
expect(requests).toHaveLength(1)
660-
expect(requests[0]?.text).toBe(
661-
"> Selected passage\n\nCompare @src/api.ts with @here",
662-
)
674+
expect(requests[0]?.text).toBe("> Selected passage\n\nCompare @src/api.ts with @here")
663675
expect(requests[0]).toMatchObject({
664676
delivery,
665677
files: [{ uri: "file:///C:/repo/src/api.ts", name: "api.ts" }],
@@ -759,7 +771,7 @@ describe("Composer submission", () => {
759771
expect(await pending).toBe(false)
760772
expect(errors).toHaveLength(1)
761773
expect(state.current()).toEqual([{ type: "text", content: "Keep this draft", start: 0, end: 15 }])
762-
expect(state.context.items()).toMatchObject([
774+
expect(JSON.parse(JSON.stringify(state.context.items()))).toMatchObject([
763775
{ key: "quote:c=selected", text: "Selected passage", comment: "Latest comment" },
764776
])
765777
expect(calls.filter((call) => call === "send")).toHaveLength(2)
@@ -1310,7 +1322,7 @@ describe("Composer submission", () => {
13101322
expect(statuses).toEqual(["running", "idle", "running", "idle"])
13111323
expect(state.current()).toEqual(prompt)
13121324
// In the order it was sent, so the resend's request matches the first.
1313-
expect(state.context.items()).toMatchObject([
1325+
expect(JSON.parse(JSON.stringify(state.context.items()))).toMatchObject([
13141326
{ type: "file", path: "notes.md", description: "the failing version" },
13151327
note,
13161328
])
@@ -1350,8 +1362,10 @@ describe("Composer submission", () => {
13501362
).submit(new Event("submit"))
13511363
await failed.promise
13521364

1353-
expect(promoted.current()).toMatchObject([{ type: "text", content: "first prompt" }])
1354-
expect(promoted.context.items()).toMatchObject([{ type: "file", path: "src/app.ts", comment: "Keep this comment" }])
1365+
expect(JSON.parse(JSON.stringify(promoted.current()))).toMatchObject([{ type: "text", content: "first prompt" }])
1366+
expect(JSON.parse(JSON.stringify(promoted.context.items()))).toMatchObject([
1367+
{ type: "file", path: "src/app.ts", comment: "Keep this comment" },
1368+
])
13551369
expect(promoted.mode.current()).toBe("shell")
13561370
})
13571371

@@ -1392,7 +1406,9 @@ describe("Composer submission", () => {
13921406
await failed.promise
13931407

13941408
expect(text(promoted)).toBe("first prompt\n\nfollow-up")
1395-
expect(promoted.context.items()).toMatchObject([{ key, type: "quote", text: "quoted passage" }])
1409+
expect(JSON.parse(JSON.stringify(promoted.context.items()))).toMatchObject([
1410+
{ key, type: "quote", text: "quoted passage" },
1411+
])
13961412
expect(promoted.quoteSource.state.sources[key]).toEqual(source)
13971413
// A recovered follow-up changes the payload, so it is not a retry of the failed admission.
13981414
expect(promoted.retry.current()).toBeUndefined()

‎packages/app/src/custom-elements.d.ts‎

Lines changed: 0 additions & 1 deletion
This file was deleted.
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
/// <reference path="../../ui/src/custom-elements.d.ts" />
2+
export {}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import { expect, test } from "bun:test"
2+
import { createMemo, createRoot, createSignal } from "solid-js"
3+
4+
test("unit conditions resolve the reactive client build of solid-js", () => {
5+
expect(import.meta.resolve("solid-js")).toContain("/dist/solid.js")
6+
7+
createRoot((dispose) => {
8+
const [n, setN] = createSignal(1)
9+
const double = createMemo(() => n() * 2)
10+
11+
expect(double()).toBe(2)
12+
setN(2)
13+
expect(double()).toBe(4)
14+
dispose()
15+
})
16+
})

‎packages/core/test/config/config.test.ts‎

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -106,14 +106,18 @@ describe("Config", () => {
106106
fs.mkdir(project, { recursive: true }),
107107
fs.mkdir(path.join(home, ".claude"), { recursive: true }),
108108
fs.mkdir(path.join(home, ".agents"), { recursive: true }),
109+
fs.mkdir(path.join(tmp.path, ".agents"), { recursive: true }),
109110
]),
110111
).pipe(
111112
Effect.andThen(
112113
Effect.gen(function* () {
113-
// The fixture is real: with global enabled the walk finds both.
114+
// Discovery also sees ancestors above the fixture, which may have host config.
114115
const config = yield* Config.Service
115116
const compatibility = yield* config.compatibility!()
116-
expect([...compatibility.claude, ...compatibility.agents]).toHaveLength(2)
117+
expect(
118+
[...compatibility.claude, ...compatibility.agents].filter((directory) => inFixture(home, directory)),
119+
).toHaveLength(2)
120+
expect(compatibility.agents).toContain(AbsolutePath.make(path.join(tmp.path, ".agents")))
117121
}).pipe(Effect.provide(testLayer(project, global))),
118122
),
119123
Effect.andThen(
@@ -122,7 +126,11 @@ describe("Config", () => {
122126
// project walk enabled.
123127
Effect.gen(function* () {
124128
const config = yield* Config.Service
125-
expect(yield* config.compatibility!()).toEqual({ claude: [], agents: [] })
129+
const compatibility = yield* config.compatibility!()
130+
expect(
131+
[...compatibility.claude, ...compatibility.agents].filter((directory) => inFixture(home, directory)),
132+
).toEqual([])
133+
expect(compatibility.agents).toContain(AbsolutePath.make(path.join(tmp.path, ".agents")))
126134
const watcher = yield* Watcher.Test
127135
expect(
128136
(yield* watcher.subscriptions()).filter((watch) => watch.type === "entries" && watch.path === home),

‎packages/core/test/preload.ts‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ import path from "path"
44

55
process.env.OPENCODE_DB = ":memory:"
66
process.env.NPM_CONFIG_AUDIT = "false"
7+
// Git Bash exports SHELL=/usr/bin/bash. Windows tests expect the platform default shell, PowerShell.
8+
if (process.platform === "win32") delete process.env.SHELL
79

810
// Direct `bun test` invocations bypass `packages/core/script/test.ts`.
911
// Isolate home and XDG roots before any module reads them.

‎script/check-greys.ts‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,8 @@ const entries = (
6868
await Promise.all(
6969
files.map(async (file) => {
7070
const source = await Bun.file(path.join(repo(), file)).text()
71-
const exception = EXCEPTIONS.find(([re]) => re.test(file))?.[1]
71+
const normalizedFile = file.replaceAll(path.sep, "/")
72+
const exception = EXCEPTIONS.find(([re]) => re.test(normalizedFile))?.[1]
7273
const allowed = allowedRanges(source)
7374
return declarations(source).flatMap((decl) =>
7475
neutrals(decl.value).map((hex) => ({

‎script/upgrade-opentui.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ const skip = new Set([".git", ".opencode", ".turbo", "dist", "node_modules"])
3939
const keys = ["@opentui/core", "@opentui/keymap", "@opentui/solid"] as const
4040

4141
const files = (await Array.fromAsync(new Bun.Glob("**/package.json").scan({ cwd: root }))).filter(
42-
(file) => !file.split("/").some((part) => skip.has(part)),
42+
(file) => !file.split(/[\\/]/).some((part) => skip.has(part)),
4343
)
4444

4545
const setVersion = (cur: string) => {

0 commit comments

Comments
 (0)