Skip to content

Commit b3cf963

Browse files
anandgupta42claude
andcommitted
fix(workspace): refuse link without readable credentials; no Unlink under a pin
Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
1 parent 010b87c commit b3cf963

2 files changed

Lines changed: 25 additions & 4 deletions

File tree

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

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -364,7 +364,13 @@ async function runBrowserHandoff(
364364
directory: string,
365365
): Promise<void> {
366366
// The account this bind acts as; the seed refuses (account-changed) if it switches mid-way.
367-
const linkAccount = (await accountDigest()) ?? undefined
367+
// Unreadable credentials cannot link anyway, and must not leave the bind unguarded.
368+
const linkAccount = await accountDigest()
369+
if (linkAccount === null) {
370+
prompts.log.error("Could not read your Altimate credentials, so nothing was linked. Check /connect and try again.")
371+
process.exitCode = 1
372+
return
373+
}
368374
const spin = prompts.spinner()
369375
spin.start("Waiting for browser approval (up to 15 min)...")
370376
const result: HandoffResult = await openWorkspaceBrowserHandoff({ identifier, projectName })
@@ -495,7 +501,13 @@ export async function createThenBindOrRebind(
495501
existing: ProjectBindingLookup | null,
496502
): Promise<void> {
497503
// The account this bind acts as; the seed refuses (account-changed) if it switches mid-way.
498-
const linkAccount = (await accountDigest()) ?? undefined
504+
// Unreadable credentials cannot link anyway, and must not leave the bind unguarded.
505+
const linkAccount = await accountDigest()
506+
if (linkAccount === null) {
507+
prompts.log.error("Could not read your Altimate credentials, so nothing was linked. Check /connect and try again.")
508+
process.exitCode = 1
509+
return
510+
}
499511
const spin = prompts.spinner()
500512
spin.start(`Creating workspace "${name}"...`)
501513
// Discriminated on how the workspace was made, because the two creates return
@@ -667,7 +679,13 @@ async function bindOrRebind(
667679
directory: string,
668680
): Promise<void> {
669681
// The account this bind acts as; the seed refuses (account-changed) if it switches mid-way.
670-
const linkAccount = (await accountDigest()) ?? undefined
682+
// Unreadable credentials cannot link anyway, and must not leave the bind unguarded.
683+
const linkAccount = await accountDigest()
684+
if (linkAccount === null) {
685+
prompts.log.error("Could not read your Altimate credentials, so nothing was linked. Check /connect and try again.")
686+
process.exitCode = 1
687+
return
688+
}
671689
const isRebind = existing !== null
672690
const spin = prompts.spinner()
673691
spin.start(isRebind ? `Re-linking to workspace...` : `Linking to workspace...`)

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1955,7 +1955,10 @@ async function runWorkspaceManage(api: TuiPluginApi, directory: string): Promise
19551955
...(pinned
19561956
? []
19571957
: [{ title: "Switch workspace", value: "link", description: "Link this project to a different workspace." }]),
1958-
{ title: "Unlink", value: "unlink", description: "Detach this project from the workspace." },
1958+
// Unlink edits the project's own binding, which a pinned session does not use.
1959+
...(pinned
1960+
? []
1961+
: [{ title: "Unlink", value: "unlink", description: "Detach this project from the workspace." }]),
19591962
{ title: "Done", value: "done", description: "Close this menu." },
19601963
]
19611964
: [

0 commit comments

Comments
 (0)