Skip to content

Commit 87721c5

Browse files
fix: an unbound attach row names no workspace explicitly
Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_011AhtJPr3nmT1Po92ZQk4VE
1 parent a8f283a commit 87721c5

2 files changed

Lines changed: 8 additions & 3 deletions

File tree

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,13 +51,14 @@ export function attachEvent(
5151
sessionID?: string,
5252
): Telemetry.Event {
5353
// The boundary's own workspace, named on the row rather than left to the process context; an
54-
// unbound or disabled outcome has none.
54+
// unbound or disabled outcome has none, and says so with an explicit undefined so the session's
55+
// entry is not stamped onto it either (the envelope drops an undefined value).
5556
const settledFor = outcome.kind !== "unbound" && outcome.kind !== "disabled" ? extra.workspaceId : undefined
5657
const base = {
5758
type: "workspace_engine_attach" as const,
5859
timestamp: Date.now(),
5960
session_id: sessionID ?? sessionId(),
60-
...(settledFor !== undefined && Number.isInteger(settledFor) && settledFor > 0 ? { workspace_id: settledFor } : {}),
61+
workspace_id: settledFor !== undefined && Number.isInteger(settledFor) && settledFor > 0 ? settledFor : undefined,
6162
}
6263
switch (outcome.kind) {
6364
case "attached":

‎packages/opencode/test/altimate/workspace/engine-telemetry.test.ts‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,11 @@ describe("workspace engine telemetry builders", () => {
8282
attachSignature({ kind: "attached", available: 2 }),
8383
)
8484
expect((attachEvent({ kind: "attached", available: 1 }, { workspaceId: 42 }) as any).workspace_id).toBe(42)
85-
expect("workspace_id" in (attachEvent({ kind: "unbound" }, { workspaceId: 42 }) as any)).toBe(false)
85+
// An unbound attach names no workspace, explicitly: the key is present and undefined, so the
86+
// session's entry cannot be stamped onto it.
87+
const unbound = attachEvent({ kind: "unbound" }, { workspaceId: 42 }) as any
88+
expect("workspace_id" in unbound).toBe(true)
89+
expect(unbound.workspace_id).toBeUndefined()
8690
})
8791

8892
test("the install prompt event carries the offer, the surface and node detection", () => {

0 commit comments

Comments
 (0)