fix(tui): keep /share available to copy existing link (#12532)

This commit is contained in:
Kit Langton
2026-02-11 08:58:24 -05:00
committed by GitHub
parent 352a54c698
commit 7a463cd193

View File

@@ -314,26 +314,31 @@ export function Session() {
const command = useCommandDialog() const command = useCommandDialog()
command.register(() => [ command.register(() => [
{ {
title: "Share session", title: session()?.share?.url ? "Copy share link" : "Share session",
value: "session.share", value: "session.share",
suggested: route.type === "session", suggested: route.type === "session",
keybind: "session_share", keybind: "session_share",
category: "Session", category: "Session",
enabled: sync.data.config.share !== "disabled" && !session()?.share?.url, enabled: sync.data.config.share !== "disabled",
slash: { slash: {
name: "share", name: "share",
}, },
onSelect: async (dialog) => { onSelect: async (dialog) => {
const copy = (url: string) =>
Clipboard.copy(url)
.then(() => toast.show({ message: "Share URL copied to clipboard!", variant: "success" }))
.catch(() => toast.show({ message: "Failed to copy URL to clipboard", variant: "error" }))
const url = session()?.share?.url
if (url) {
await copy(url)
dialog.clear()
return
}
await sdk.client.session await sdk.client.session
.share({ .share({
sessionID: route.sessionID, sessionID: route.sessionID,
}) })
.then((res) => .then((res) => copy(res.data!.share!.url))
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" })) .catch(() => toast.show({ message: "Failed to share session", variant: "error" }))
dialog.clear() dialog.clear()
}, },