Skip to content

Commit 290f43d

Browse files
sahrizviclaude
andcommitted
fix(workspace): bot-review round 5 — no browser-handoff for already-linked project, tighter workspace_id spelling
Two #1100-only cycle-5 findings: - **link.ts SET_UP_IN_BROWSER_SENTINEL** (CodeRabbit Major) — the browser handoff option was offered even when the project was already linked; ``runBrowserHandoff`` then created a fresh workspace and 409'd on ``bindExisting``, stranding the workspace. Gate the option on ``!existing`` alongside ``browserAvailable``. - **browser-handoff.ts workspace_id** (cubic P3) — ``Number()`` coerces ``"1e2"``, ``"0x2a"``, and ``" 42 "`` into finite integers, slipping past the ``isInteger`` guard. Require a plain decimal-digit spelling first. Test suite green (4072 pass across the altimate suite). Co-Authored-By: Claude Opus 4.7 <[email protected]> Claude-Session: https://claude.ai/code/session_016H42Vt4pt5dcD7opRqckeM
1 parent b1a0de8 commit 290f43d

2 files changed

Lines changed: 19 additions & 2 deletions

File tree

‎packages/opencode/src/altimate/workspace/browser-handoff.ts‎

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -256,9 +256,20 @@ async function startListener(pending: HandoffPending): Promise<{ server: Server;
256256
return
257257
}
258258

259-
const workspaceId = Number(workspaceIdRaw)
260259
// Integer-only: floats like ``42.5`` are rejected server-side but produce
261260
// a confusing failure the caller can't recover from. (m9 in the review.)
261+
// Also reject non-canonical spellings — ``Number()`` happily coerces
262+
// ``"1e2"``, ``"0x2a"``, and ``" 42 "`` into finite integers, so a
263+
// callback URL carrying those forms would slip past ``isInteger`` and
264+
// reach the bind payload. Requiring a plain decimal-digit string first
265+
// is the tight gate. (cubic cycle 4/5.)
266+
if (!/^[1-9][0-9]*$/.test(workspaceIdRaw)) {
267+
const msg = `Invalid workspace_id: ${workspaceIdRaw}`
268+
respond(400, htmlError(msg))
269+
pending.reject(markReason(new Error(msg), "error"))
270+
return
271+
}
272+
const workspaceId = Number(workspaceIdRaw)
262273
if (!Number.isInteger(workspaceId) || workspaceId <= 0) {
263274
const msg = `Invalid workspace_id: ${workspaceIdRaw}`
264275
respond(400, htmlError(msg))

‎packages/opencode/src/cli/cmd/link.ts‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,13 @@ export const LinkCommand = cmd({
115115
resolveWorkspaceWebUrl(creds.altimateUrl, creds.altimateInstanceName) !== null
116116

117117
const options: Array<{ value: string; label: string; hint?: string }> = [
118-
...(browserAvailable
118+
// Only offer browser handoff for UNLINKED projects (CodeRabbit cycle 5).
119+
// ``runBrowserHandoff`` creates a fresh workspace and calls
120+
// ``bindExisting``, which 409s when there's already an active binding —
121+
// leaving the browser-created workspace stranded and no rebind actually
122+
// happening. If the project is already linked, the caller wants a
123+
// rebind path (offered elsewhere in this menu), not create-and-bind.
124+
...(browserAvailable && !existing
119125
? [
120126
{
121127
value: SET_UP_IN_BROWSER_SENTINEL,

0 commit comments

Comments
 (0)