Skip to content

Commit ead39c6

Browse files
fix: no node probe on the offer's dispatch path; no writer is no copy
The bus offer carries the offer's fields only, so publishing no longer awaits `node --version` ahead of the turn boundary; the printed-offer row has no node fields. `confirmedCopy` returns false without a writer, whatever the clipboard holds. Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_011AhtJPr3nmT1Po92ZQk4VE
1 parent 2d21add commit ead39c6

4 files changed

Lines changed: 18 additions & 22 deletions

File tree

‎packages/opencode/src/altimate/workspace/engine-offer.ts‎

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -273,20 +273,17 @@ export async function installEngine(): Promise<InstallResult> {
273273
return { ok: false, error: detail || `npm exited with code ${run.code ?? "unknown"}` }
274274
}
275275

276-
/** What the bus carries with the offer command: the offer's telemetry fields plus the server's
277-
* node major (the install happens where the server runs), so the surface that prints the offer in
278-
* another process (an attached run) reports `shown` with them. */
279-
export type OfferDetail = Pick<EngineOffer, "reason" | "workspaceId" | "declared" | "found"> & {
280-
nodeMajor: number | null
281-
}
276+
/** What the bus carries with the offer command: the offer's telemetry fields, so the surface that
277+
* prints the offer in another process (an attached run) reports `shown` with them. No node probe
278+
* rides along: it would sit on the dispatch path, ahead of the turn boundary. */
279+
export type OfferDetail = Pick<EngineOffer, "reason" | "workspaceId" | "declared" | "found">
282280

283-
export function encodeOfferDetail(offer: EngineOffer, nodeMajor: number | null): string {
281+
export function encodeOfferDetail(offer: EngineOffer): string {
284282
const detail: OfferDetail = {
285283
reason: offer.reason,
286284
workspaceId: offer.workspaceId,
287285
declared: offer.declared,
288286
found: offer.found,
289-
nodeMajor,
290287
}
291288
return JSON.stringify(detail)
292289
}
@@ -300,11 +297,10 @@ export function decodeOfferDetail(raw: unknown): OfferDetail | undefined {
300297
const workspaceId = typeof v.workspaceId === "string" ? v.workspaceId : undefined
301298
const declared = typeof v.declared === "number" ? v.declared : v.declared === undefined ? undefined : NaN
302299
const found = typeof v.found === "string" ? v.found : v.found === undefined ? undefined : ""
303-
const nodeMajor = v.nodeMajor === null ? null : typeof v.nodeMajor === "number" ? v.nodeMajor : undefined
304-
if (!reason || workspaceId === undefined || Number.isNaN(declared) || found === "" || nodeMajor === undefined) {
300+
if (!reason || workspaceId === undefined || Number.isNaN(declared) || found === "") {
305301
return undefined
306302
}
307-
return { reason, workspaceId, declared, found, nodeMajor }
303+
return { reason, workspaceId, declared, found }
308304
} catch {
309305
return undefined
310306
}
@@ -316,7 +312,7 @@ export function decodeOfferDetail(raw: unknown): OfferDetail | undefined {
316312
export function trackPrintedOffer(raw: unknown, sessionID: string): boolean {
317313
const detail = decodeOfferDetail(raw)
318314
if (!detail) return false
319-
trackInstallPrompt("shown", detail, { surface: "bus", nodeMajor: detail.nodeMajor }, sessionID)
315+
trackInstallPrompt("shown", detail, { surface: "bus" }, sessionID)
320316
return true
321317
}
322318

@@ -326,7 +322,7 @@ export function trackPrintedOffer(raw: unknown, sessionID: string): boolean {
326322
* ride along so that run reports `shown` from them (the TUI dialog re-derives
327323
* the offer and reports its own). */
328324
async function publishOffer(offer: EngineOffer, sessionID: string): Promise<boolean> {
329-
const detail = encodeOfferDetail(offer, await nodeMajor().catch(() => null))
325+
const detail = encodeOfferDetail(offer)
330326
if (syncInternals.publishOffer) return syncInternals.publishOffer(sessionID, detail)
331327
try {
332328
await AppRuntime.runPromise(

‎packages/opencode/src/plugin/tui/altimate/workspace.tsx‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1990,8 +1990,10 @@ function EngineInstallOfferDialog(props: EngineOfferProps) {
19901990
* (Caught by E2E: the toast said "Copied:" while the clipboard was untouched.) An unreadable or
19911991
* unwritable clipboard is the same unconfirmed outcome. */
19921992
export async function confirmedCopy(clipboard: Pick<ClipboardService, "write" | "read">, text: string) {
1993+
// No writer means nothing was copied, whatever the clipboard happens to hold.
1994+
if (!clipboard.write) return false
19931995
try {
1994-
await clipboard.write?.(text)
1996+
await clipboard.write(text)
19951997
const back = await clipboard.read?.()
19961998
return back?.data.trim() === text
19971999
} catch {

‎packages/opencode/test/altimate/plugin/workspace.test.ts‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1283,5 +1283,7 @@ describe("confirmedCopy", () => {
12831283
),
12841284
).toBe(false)
12851285
expect(await confirmedCopy({ write: async () => {}, read: undefined }, cmd)).toBe(false)
1286+
// No writer: the clipboard holding the command already is not a copy.
1287+
expect(await confirmedCopy({ write: undefined, read: async () => ({ data: cmd, mime: "text/plain" }) }, cmd)).toBe(false)
12861288
})
12871289
})

‎packages/opencode/test/altimate/workspace/engine-install-offer.test.ts‎

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -176,14 +176,12 @@ describe("offer routing — engine missing", () => {
176176
})
177177
test("the published offer carries its fields, and the surface that prints them reports shown", async () => {
178178
const h = install({})
179-
syncInternals.nodeMajor = async () => 22
180179
await beforeTurn("s1")
181180
expect(decodeOfferDetail(h.publishedDetail[0])).toEqual({
182181
reason: "engine-missing",
183182
workspaceId: "42",
184183
declared: 2,
185184
found: undefined,
186-
nodeMajor: 22,
187185
})
188186
const rows: Record<string, unknown>[] = []
189187
const spy = spyOn(Telemetry, "track").mockImplementation((e) => {
@@ -194,10 +192,8 @@ describe("offer routing — engine missing", () => {
194192
expect(trackPrintedOffer(h.publishedDetail[0], "s1")).toBe(true)
195193
expect(trackPrintedOffer(undefined, "s1")).toBe(false)
196194
expect(trackPrintedOffer("not json", "s1")).toBe(false)
197-
expect(trackPrintedOffer(JSON.stringify({ reason: "other", workspaceId: "42", nodeMajor: null }), "s1")).toBe(
198-
false,
199-
)
200-
expect(trackPrintedOffer(JSON.stringify({ reason: "engine-missing", workspaceId: "42" }), "s1")).toBe(false)
195+
expect(trackPrintedOffer(JSON.stringify({ reason: "other", workspaceId: "42" }), "s1")).toBe(false)
196+
expect(trackPrintedOffer(JSON.stringify({ reason: "engine-missing", declared: "2" }), "s1")).toBe(false)
201197
} finally {
202198
spy.mockRestore()
203199
}
@@ -210,10 +206,10 @@ describe("offer routing — engine missing", () => {
210206
workspace_id: 42,
211207
reason: "engine-missing",
212208
declared: 2,
213-
node_detected: true,
214-
node_major: 22,
215209
}),
216210
])
211+
// No node fields: the probe stays off the dispatch path, so the event carries none.
212+
expect("node_detected" in rows[0]!).toBe(false)
217213
})
218214
test("falls back to the toast only when the bus is unavailable", async () => {
219215
const h = install({ bus: false })

0 commit comments

Comments
 (0)