Skip to content

Commit 20a9ec3

Browse files
committed
fix: Implement /share copy to clipboard (anomalyco#3372)
1 parent 2cae9d1 commit 20a9ec3

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
@@ -48,8 +48,9 @@ import { DialogConfirm } from "@tui/ui/dialog-confirm"
4848
import { DialogTimeline } from "./dialog-timeline"
4949
import { Sidebar } from "./sidebar"
5050
import { LANGUAGE_EXTENSIONS } from "@/lsp/language"
51-
5251
import parsers from "../../../../../../parsers-config.json"
52+
import { Clipboard } from "../../util/clipboard"
53+
import { Toast, useToast } from "../../ui/toast"
5354

5455
addDefaultParsers(parsers.parsers)
5556

@@ -83,6 +84,8 @@ export function Session() {
8384

8485
createEffect(() => sync.session.sync(route.sessionID))
8586

87+
const toast = useToast()
88+
8689
const sdk = useSDK()
8790

8891
let scroll: ScrollBoxRenderable
@@ -173,12 +176,20 @@ export function Session() {
173176
keybind: "session_share",
174177
disabled: !!session()?.share?.url,
175178
category: "Session",
176-
onSelect: (dialog) => {
177-
sdk.client.session.share({
178-
path: {
179-
id: route.sessionID,
180-
},
181-
})
179+
onSelect: async (dialog) => {
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 })
192+
}
182193
dialog.clear()
183194
},
184195
},

0 commit comments

Comments
 (0)