Skip to content

Commit 4f79ad3

Browse files
sahrizviclaude
andcommitted
fix(workspace): bot-review round 6 — isBrowserHandoffAvailable guard, gate on preCheckOk, keep err diagnostic
Three #1100-only cycle-6 findings: - **``isBrowserHandoffAvailable`` guarded** (CR Major) — line 63 wrapped ``isConfigured()`` with ``.catch(() => false)`` but ``getCredentials()`` on line 64 was unguarded. That call can throw on corrupt credentials JSON, Zod schema drift, or an unresolved ``${env:...}`` reference; an unhandled rejection there would take the TUI down. Wrap the whole body in try/catch and fail closed (treat as "handoff unavailable"). - **``link.ts`` browser option also gated on ``preCheckOk``** (Kilo suggestion) — was ``browserAvailable && !existing``. When the pre-check itself failed (network / 5xx), ``existing`` stays null while the project MAY be linked server-side. Offering the browser flow then reproduces the "workspace created + 409 on bindExisting" strand. Add ``&& preCheckOk``. - **``void err`` no-op replaced with log** (Kilo suggestion) — the previous ``catch (err) { ... void err }`` discarded the diagnostic. Log-warn so a regression in ``showLinkedConfirmation`` doesn't vanish silently. Test suite: green (4072 pass, 0 fail). Co-Authored-By: Claude Opus 4.7 <[email protected]> Claude-Session: https://claude.ai/code/session_016H42Vt4pt5dcD7opRqckeM
1 parent b265740 commit 4f79ad3

2 files changed

Lines changed: 22 additions & 5 deletions

File tree

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

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,13 @@ export const LinkCommand = cmd({
121121
// leaving the browser-created workspace stranded and no rebind actually
122122
// happening. If the project is already linked, the caller wants a
123123
// rebind path (offered elsewhere in this menu), not create-and-bind.
124-
...(browserAvailable && !existing
124+
//
125+
// Also gate on ``preCheckOk`` (Kilo cycle 6): when the pre-check itself
126+
// failed (network / 5xx), ``existing`` stays null but the project MAY
127+
// be linked server-side. Offering the browser flow then would run the
128+
// same 409 → stranded-workspace path. Better to hide the option until
129+
// the caller can confirm the binding state.
130+
...(browserAvailable && !existing && preCheckOk
125131
? [
126132
{
127133
value: SET_UP_IN_BROWSER_SENTINEL,

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

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,17 @@ const log = Log.create({ service: "altimate-workspace" })
6060
* flow and the on-demand `altimate-code link` picker can hide the option
6161
* consistently when the deployment isn't supported. */
6262
async function isBrowserHandoffAvailable(): Promise<boolean> {
63-
if (!(await AltimateApi.isConfigured().catch(() => false))) return false
64-
const creds = await AltimateApi.getCredentials()
65-
return resolveWorkspaceWebUrl(creds.altimateUrl, creds.altimateInstanceName) !== null
63+
// Both credential calls can throw (corrupt JSON, schema drift, unresolved
64+
// ``${env:...}`` reference). Callers use this in the sync arm of dialog
65+
// rendering, so an unhandled rejection would take the TUI down. Fail
66+
// closed — treat any credential error as "handoff unavailable". (CR cycle 6.)
67+
try {
68+
if (!(await AltimateApi.isConfigured().catch(() => false))) return false
69+
const creds = await AltimateApi.getCredentials()
70+
return resolveWorkspaceWebUrl(creds.altimateUrl, creds.altimateInstanceName) !== null
71+
} catch {
72+
return false
73+
}
6674
}
6775

6876
// ─────────────────────────────────────────────────────────────────────────────
@@ -525,11 +533,14 @@ async function createAndBindInline(
525533
})
526534
await showLinkedConfirmation(api, "Created", res.datamate.id, res.datamate.name)
527535
} catch (err) {
536+
// Log the failure so a regression in ``showLinkedConfirmation`` doesn't
537+
// vanish silently, then fall back to a plain toast. Previously ``void err``
538+
// discarded the diagnostic — Kilo cycle 6 called it out.
539+
log.warn("workspace post-create confirmation failed", { err: String(err) })
528540
api.ui.toast({
529541
variant: "info",
530542
message: `Workspace "${res.datamate.name}" created and linked.`,
531543
})
532-
void err
533544
}
534545
}
535546

0 commit comments

Comments
 (0)