Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions packages/opencode/src/cli/cmd/run.ts
Original file line number Diff line number Diff line change
Expand Up @@ -277,8 +277,8 @@ export const RunCommand = cmd({
}
return { error }
})
if (!shareResult.error) {
UI.println(UI.Style.TEXT_INFO_BOLD + "~ https://opencode.ai/s/" + sessionID.slice(-8))
if (!shareResult.error && "data" in shareResult && shareResult.data?.share?.url) {
UI.println(UI.Style.TEXT_INFO_BOLD + "~ " + shareResult.data.share.url)
}
}

Expand Down Expand Up @@ -330,8 +330,8 @@ export const RunCommand = cmd({
}
return { error }
})
if (!shareResult.error) {
UI.println(UI.Style.TEXT_INFO_BOLD + "~ https://opencode.ai/s/" + sessionID.slice(-8))
if (!shareResult.error && "data" in shareResult && shareResult.data?.share?.url) {
UI.println(UI.Style.TEXT_INFO_BOLD + "~ " + shareResult.data.share.url)
}
}

Expand Down
11 changes: 7 additions & 4 deletions packages/opencode/src/cli/cmd/tui/routes/session/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -323,10 +323,13 @@ export function Session() {
keybind: "session_unshare",
disabled: !session()?.share?.url,
category: "Session",
onSelect: (dialog) => {
sdk.client.session.unshare({
sessionID: route.sessionID,
})
onSelect: async (dialog) => {
await sdk.client.session
.unshare({
sessionID: route.sessionID,
})
.then(() => toast.show({ message: "Session unshared successfully", variant: "success" }))
.catch(() => toast.show({ message: "Failed to unshare session", variant: "error" }))
dialog.clear()
},
},
Expand Down
16 changes: 3 additions & 13 deletions packages/opencode/src/session/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -234,22 +234,12 @@ export namespace Session {
})

export const unshare = fn(Identifier.schema("session"), async (id) => {
const cfg = await Config.get()
if (cfg.enterprise?.url) {
const { ShareNext } = await import("@/share/share-next")
await ShareNext.remove(id)
await update(id, (draft) => {
draft.share = undefined
})
}
const share = await getShare(id)
if (!share) return
await Storage.remove(["share", id])
// Use ShareNext to remove the share (same as share function uses ShareNext to create)
const { ShareNext } = await import("@/share/share-next")
await ShareNext.remove(id)
await update(id, (draft) => {
draft.share = undefined
})
const { Share } = await import("../share/share")
await Share.remove(id, share.secret)
})

export async function update(id: string, editor: (session: Info) => void) {
Expand Down
2 changes: 1 addition & 1 deletion packages/opencode/src/share/share-next.ts
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ export namespace ShareNext {
secret: share.secret,
}),
})
await Storage.remove(["session_share", share.id])
await Storage.remove(["session_share", sessionID])
}

async function fullSync(sessionID: string) {
Expand Down