Skip to content

Commit 1e87d06

Browse files
committed
fix: Implement /share copy to clipboard (anomalyco#3372)
1 parent 041353f commit 1e87d06

1 file changed

Lines changed: 18 additions & 7 deletions

File tree

  • packages/opencode/src/cli/cmd/tui/routes/session

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

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,8 @@ import { DialogTimeline } from "./dialog-timeline"
6262
import { Sidebar } from "./sidebar"
6363
import { LANGUAGE_EXTENSIONS } from "@/lsp/language"
6464
import parsers from "../../../../../../parsers-config.ts"
65-
import { Toast } from "../../ui/toast"
65+
import { Clipboard } from "../../util/clipboard"
66+
import { Toast, useToast } from "../../ui/toast"
6667
import { DialogSessionRename } from "../../component/dialog-session-rename"
6768

6869
addDefaultParsers(parsers.parsers)
@@ -100,6 +101,8 @@ export function Session() {
100101

101102
createEffect(() => sync.session.sync(route.sessionID))
102103

104+
const toast = useToast()
105+
103106
const sdk = useSDK()
104107

105108
let scroll: ScrollBoxRenderable
@@ -196,12 +199,20 @@ export function Session() {
196199
keybind: "session_share",
197200
disabled: !!session()?.share?.url,
198201
category: "Session",
199-
onSelect: (dialog) => {
200-
sdk.client.session.share({
201-
path: {
202-
id: route.sessionID,
203-
},
204-
})
202+
onSelect: async (dialog) => {
203+
try {
204+
const response = await sdk.client.session.share({
205+
path: {
206+
id: route.sessionID,
207+
},
208+
})
209+
Clipboard.copy(response.data!.share!.url).catch(() =>
210+
toast.show({ message: "Failed to copy URL to clipboard", variant: "error", duration: 3000 })
211+
)
212+
toast.show({ message: "Share URL copied to clipboard!", variant: "success", duration: 3000 })
213+
} catch {
214+
toast.show({ message: "Failed to share session", variant: "error", duration: 3000 })
215+
}
205216
dialog.clear()
206217
},
207218
},

0 commit comments

Comments
 (0)