Skip to content

Commit 7df61a7

Browse files
authored
fix: tui: add toast for /share url copy (#3686)
1 parent 4f23110 commit 7df61a7

File tree

1 file changed

+15
-3
lines changed
  • packages/opencode/src/cli/cmd/tui/routes/session

1 file changed

+15
-3
lines changed

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

Lines changed: 15 additions & 3 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,21 @@ export function Session() {
196199
keybind: "session_share",
197200
disabled: !!session()?.share?.url,
198201
category: "Session",
199-
onSelect: (dialog) => {
200-
sdk.client.session.share({
202+
onSelect: async (dialog) => {
203+
await sdk.client.session.share({
201204
path: {
202205
id: route.sessionID,
203206
},
204207
})
208+
.then((res) =>
209+
Clipboard.copy(res.data!.share!.url).catch(() =>
210+
toast.show({ message: "Failed to copy URL to clipboard", variant: "error" })
211+
)
212+
)
213+
.then(() =>
214+
toast.show({ message: "Share URL copied to clipboard!", variant: "success" })
215+
)
216+
.catch(() => toast.show({ message: "Failed to share session", variant: "error" }))
205217
dialog.clear()
206218
},
207219
},

0 commit comments

Comments
 (0)