mirror of
https://github.com/aljazceru/opencode.git
synced 2025-12-24 03:04:21 +01:00
fix: tui: add toast for /share url copy (#3686)
This commit is contained in:
@@ -62,7 +62,8 @@ import { DialogTimeline } from "./dialog-timeline"
|
||||
import { Sidebar } from "./sidebar"
|
||||
import { LANGUAGE_EXTENSIONS } from "@/lsp/language"
|
||||
import parsers from "../../../../../../parsers-config.ts"
|
||||
import { Toast } from "../../ui/toast"
|
||||
import { Clipboard } from "../../util/clipboard"
|
||||
import { Toast, useToast } from "../../ui/toast"
|
||||
import { DialogSessionRename } from "../../component/dialog-session-rename"
|
||||
|
||||
addDefaultParsers(parsers.parsers)
|
||||
@@ -100,6 +101,8 @@ export function Session() {
|
||||
|
||||
createEffect(() => sync.session.sync(route.sessionID))
|
||||
|
||||
const toast = useToast()
|
||||
|
||||
const sdk = useSDK()
|
||||
|
||||
let scroll: ScrollBoxRenderable
|
||||
@@ -196,12 +199,21 @@ export function Session() {
|
||||
keybind: "session_share",
|
||||
disabled: !!session()?.share?.url,
|
||||
category: "Session",
|
||||
onSelect: (dialog) => {
|
||||
sdk.client.session.share({
|
||||
onSelect: async (dialog) => {
|
||||
await sdk.client.session.share({
|
||||
path: {
|
||||
id: route.sessionID,
|
||||
},
|
||||
})
|
||||
.then((res) =>
|
||||
Clipboard.copy(res.data!.share!.url).catch(() =>
|
||||
toast.show({ message: "Failed to copy URL to clipboard", variant: "error" })
|
||||
)
|
||||
)
|
||||
.then(() =>
|
||||
toast.show({ message: "Share URL copied to clipboard!", variant: "success" })
|
||||
)
|
||||
.catch(() => toast.show({ message: "Failed to share session", variant: "error" }))
|
||||
dialog.clear()
|
||||
},
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user