Skip to content
This repository was archived by the owner on Apr 1, 2026. It is now read-only.

Commit 54569b5

Browse files
fix(session): fix unshare command not clearing share state (anomalyco#5523)
1 parent 6a09861 commit 54569b5

4 files changed

Lines changed: 15 additions & 22 deletions

File tree

packages/opencode/src/cli/cmd/run.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -277,8 +277,8 @@ export const RunCommand = cmd({
277277
}
278278
return { error }
279279
})
280-
if (!shareResult.error) {
281-
UI.println(UI.Style.TEXT_INFO_BOLD + "~ https://opencode.ai/s/" + sessionID.slice(-8))
280+
if (!shareResult.error && "data" in shareResult && shareResult.data?.share?.url) {
281+
UI.println(UI.Style.TEXT_INFO_BOLD + "~ " + shareResult.data.share.url)
282282
}
283283
}
284284

@@ -330,8 +330,8 @@ export const RunCommand = cmd({
330330
}
331331
return { error }
332332
})
333-
if (!shareResult.error) {
334-
UI.println(UI.Style.TEXT_INFO_BOLD + "~ https://opencode.ai/s/" + sessionID.slice(-8))
333+
if (!shareResult.error && "data" in shareResult && shareResult.data?.share?.url) {
334+
UI.println(UI.Style.TEXT_INFO_BOLD + "~ " + shareResult.data.share.url)
335335
}
336336
}
337337

packages/opencode/src/cli/cmd/tui/routes/session/index.tsx

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -323,10 +323,13 @@ export function Session() {
323323
keybind: "session_unshare",
324324
disabled: !session()?.share?.url,
325325
category: "Session",
326-
onSelect: (dialog) => {
327-
sdk.client.session.unshare({
328-
sessionID: route.sessionID,
329-
})
326+
onSelect: async (dialog) => {
327+
await sdk.client.session
328+
.unshare({
329+
sessionID: route.sessionID,
330+
})
331+
.then(() => toast.show({ message: "Session unshared successfully", variant: "success" }))
332+
.catch(() => toast.show({ message: "Failed to unshare session", variant: "error" }))
330333
dialog.clear()
331334
},
332335
},

packages/opencode/src/session/index.ts

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -234,22 +234,12 @@ export namespace Session {
234234
})
235235

236236
export const unshare = fn(Identifier.schema("session"), async (id) => {
237-
const cfg = await Config.get()
238-
if (cfg.enterprise?.url) {
239-
const { ShareNext } = await import("@/share/share-next")
240-
await ShareNext.remove(id)
241-
await update(id, (draft) => {
242-
draft.share = undefined
243-
})
244-
}
245-
const share = await getShare(id)
246-
if (!share) return
247-
await Storage.remove(["share", id])
237+
// Use ShareNext to remove the share (same as share function uses ShareNext to create)
238+
const { ShareNext } = await import("@/share/share-next")
239+
await ShareNext.remove(id)
248240
await update(id, (draft) => {
249241
draft.share = undefined
250242
})
251-
const { Share } = await import("../share/share")
252-
await Share.remove(id, share.secret)
253243
})
254244

255245
export async function update(id: string, editor: (session: Info) => void) {

packages/opencode/src/share/share-next.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ export namespace ShareNext {
157157
secret: share.secret,
158158
}),
159159
})
160-
await Storage.remove(["session_share", share.id])
160+
await Storage.remove(["session_share", sessionID])
161161
}
162162

163163
async function fullSync(sessionID: string) {

0 commit comments

Comments
 (0)