Skip to content

Commit 509b64d

Browse files
hkaltaiclaude
andcommitted
fix: an attach failure after a shared rewrite says who has the new credential, and --share help names both effects
Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent a74b173 commit 509b64d

3 files changed

Lines changed: 6 additions & 3 deletions

File tree

‎packages/opencode/src/altimate/integrations/core.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1108,7 +1108,7 @@ async function syncReal(
11081108
}
11091109
const reportWorkspace = (w: NonNullable<UpsertResult["workspace"]>, sharedConnection = false): SyncOutcome => {
11101110
// A shared connection that was rewritten stays reported as shared even when the attach after it fails.
1111-
if ("error" in w) return { id, result: "failed", reason: ATTACH_FAILED_PREFIX + w.error, steps, ...(sharedConnection ? { shared: true as const } : {}) }
1111+
if ("error" in w) return { id, result: "failed", reason: ATTACH_FAILED_PREFIX + w.error + (sharedConnection ? ` ${SHARED_REWRITE_NOTE}` : ""), steps, ...(sharedConnection ? { shared: true as const } : {}) }
11121112
if ("attached" in w) step(`${w.kept ? `Kept the workspace's existing connection in ${workspaceLabel(w.attached, w.workspaceId)}` : `Attached to ${workspaceLabel(w.attached, w.workspaceId)}`}${w.shared ? SHARED_AUDIENCE : ""}`)
11131113
else {
11141114
steps.push({ label: NOT_LINKED_LABEL, ok: false })

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ const UNSAFE = /[\u0000-\u001f\u007f-\u009f\u061c\u200e\u200f\u202a-\u202e\u2066
2323
export const clean = (value: unknown) => String(value ?? "").replace(ANSI, "").replace(UNSAFE, " ").replace(/ {2,}/g, " ").trim()
2424
const json = (value: unknown) => console.log(JSON.stringify(value, null, 2))
2525
const jsonOption = { describe: "print machine-readable JSON", type: "boolean", default: false } as const
26-
const shareOption = { describe: "attach to a linked workspace that is not private, letting its members use this connection", type: "boolean", default: false } as const
26+
const shareOption = { describe: "allow sharing: attach to a linked workspace that is not private (its members can use the connection), and update a connection that is already shared (the people it is shared with get the new credential)", type: "boolean", default: false } as const
2727

2828
const STATE_VIEW: Record<ProviderStatus["state"], { icon: string; color: string; label: string }> = {
2929
connected: { icon: "●", color: S.TEXT_SUCCESS, label: "connected" },

‎packages/opencode/test/altimate/integrations.test.ts‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -486,6 +486,7 @@ describe("workspace connections", () => {
486486
try {
487487
const failed = await core.syncProvider("github", undefined, 0, false, true)
488488
expect([failed.result, failed.shared]).toEqual(["failed", true])
489+
expect(failed.reason).toContain(core.SHARED_REWRITE_NOTE)
489490
} finally {
490491
;(AltimateApi.isConfigured as any).mockRestore()
491492
}
@@ -2792,14 +2793,16 @@ describe("the CLI passes --share through and reports shared", () => {
27922793
const log = spyOn(console, "log").mockImplementation((t?: unknown) => void logs.push(String(t)))
27932794
const connect = spyOn(creds, "connectCredentials").mockResolvedValue({ provider: "github", status: "connected", sync: "synced", account: null, expiresAt: null, message: null, shared: true } as any)
27942795
const sync = spyOn(core, "syncProvider").mockResolvedValue({ id: "github", result: "synced", steps: [], shared: true })
2796+
const info = spyOn(core, "liveWorkspaceInfo").mockResolvedValue({} as any)
27952797
try {
27962798
await (ConnectCommand.handler as any)({ provider: "github", share: true, json: true })
27972799
expect(connect.mock.calls[0][0].share).toBe(true)
27982800
expect(JSON.parse(logs.join("\n")).shared).toBe(true)
27992801
await (SyncCommand.handler as any)({ provider: "github", share: true, json: true })
28002802
expect(sync.mock.calls[0][4]).toBe(true)
2803+
expect(JSON.parse(logs[logs.length - 1]).results[0].shared).toBe(true)
28012804
} finally {
2802-
for (const sp of [log, connect, sync]) sp.mockRestore()
2805+
for (const sp of [log, connect, sync, info]) sp.mockRestore()
28032806
process.exitCode = 0
28042807
}
28052808
})

0 commit comments

Comments
 (0)