Browse Source

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

Kit Langton 2 weeks ago
parent
commit
7a463cd193
1 changed files with 13 additions and 8 deletions
  1. 13 8
      packages/opencode/src/cli/cmd/tui/routes/session/index.tsx

+ 13 - 8
packages/opencode/src/cli/cmd/tui/routes/session/index.tsx

@@ -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) =>
-            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" }))
+          .then((res) => copy(res.data!.share!.url))
           .catch(() => toast.show({ message: "Failed to share session", variant: "error" }))
           .catch(() => toast.show({ message: "Failed to share session", variant: "error" }))
         dialog.clear()
         dialog.clear()
       },
       },