@@ -36,7 +36,6 @@ import type { TaskTool } from "@/tool/task"
3636import { useKeyboard , useTerminalDimensions , type BoxProps , type JSX } from "@opentui/solid"
3737import { useSDK } from "@tui/context/sdk"
3838import { useCommandDialog } from "@tui/component/dialog-command"
39- import { Clipboard } from "@tui/util/clipboard"
4039import { Shimmer } from "@tui/ui/shimmer"
4140import { useKeybind } from "@tui/context/keybind"
4241import { Header } from "./header"
@@ -49,8 +48,9 @@ import { DialogConfirm } from "@tui/ui/dialog-confirm"
4948import { DialogTimeline } from "./dialog-timeline"
5049import { Sidebar } from "./sidebar"
5150import { LANGUAGE_EXTENSIONS } from "@/lsp/language"
52-
5351import parsers from "../../../../../../parsers-config.json"
52+ import { Clipboard } from "../../util/clipboard"
53+ import { Toast , useToast } from "../../ui/toast"
5454
5555addDefaultParsers ( parsers . parsers )
5656
@@ -84,6 +84,8 @@ export function Session() {
8484
8585 createEffect ( ( ) => sync . session . sync ( route . sessionID ) )
8686
87+ const toast = useToast ( )
88+
8789 const sdk = useSDK ( )
8890
8991 let scroll : ScrollBoxRenderable
@@ -175,13 +177,18 @@ export function Session() {
175177 disabled : ! ! session ( ) ?. share ?. url ,
176178 category : "Session" ,
177179 onSelect : async ( dialog ) => {
178- const result = await sdk . client . session . share ( {
179- path : {
180- id : route . sessionID ,
181- } ,
182- } )
183- if ( result . data ?. share ?. url ) {
184- await Clipboard . copy ( result . data . share . url )
180+ try {
181+ const response = await sdk . client . session . share ( {
182+ path : {
183+ id : route . sessionID ,
184+ } ,
185+ } )
186+ Clipboard . copy ( response . data ! . share ! . url ) . catch ( ( ) =>
187+ toast . show ( { message : "Failed to copy URL to clipboard" , type : "error" , duration : 3000 } )
188+ )
189+ toast . show ( { message : "Share URL copied to clipboard!" , type : "success" , duration : 3000 } )
190+ } catch {
191+ toast . show ( { message : "Failed to share session" , type : "error" , duration : 3000 } )
185192 }
186193 dialog . clear ( )
187194 } ,
0 commit comments