mirror of
https://github.com/anomalyco/opencode.git
synced 2026-08-07 02:03:22 +00:00
tui: report clipboard copy delivery status
This commit is contained in:
parent
a749a73ad4
commit
e4416a1d8d
2 changed files with 24 additions and 7 deletions
|
|
@ -9,6 +9,7 @@ import { useClipboard } from "../context/clipboard"
|
|||
import { useToast } from "../ui/toast"
|
||||
import { useBindings } from "../keymap"
|
||||
import { describeOS, describeTerminal } from "../util/system"
|
||||
import { formatClipboardWriteNotification } from "../clipboard"
|
||||
|
||||
export function DialogDebug() {
|
||||
const { theme } = useTheme()
|
||||
|
|
@ -37,13 +38,22 @@ export function DialogDebug() {
|
|||
const text = entries()
|
||||
.map((entry) => `${entry.label}: ${entry.value}`)
|
||||
.join("\n")
|
||||
setCopied(false)
|
||||
void clipboard
|
||||
.write?.(text)
|
||||
.then(() => {
|
||||
setCopied(true)
|
||||
toast.show({ message: "Debug info copied to clipboard", variant: "info" })
|
||||
.write(text)
|
||||
.then((outcome) => {
|
||||
setCopied(outcome.delivery === "confirmed")
|
||||
toast.show(
|
||||
formatClipboardWriteNotification(outcome, {
|
||||
message: "Debug info copied to clipboard",
|
||||
variant: "info",
|
||||
}),
|
||||
)
|
||||
})
|
||||
.catch((error) => {
|
||||
setCopied(false)
|
||||
toast.error(error)
|
||||
})
|
||||
.catch(toast.error)
|
||||
}
|
||||
|
||||
useBindings(() => ({
|
||||
|
|
|
|||
|
|
@ -469,8 +469,15 @@ export function Session() {
|
|||
run: async () => {
|
||||
const copy = (url: string) =>
|
||||
clipboard
|
||||
.write?.(url)
|
||||
.then(() => toast.show({ message: "Share URL copied to clipboard!", variant: "success" }))
|
||||
.write(url)
|
||||
.then((outcome) =>
|
||||
toast.show(
|
||||
formatClipboardWriteNotification(outcome, {
|
||||
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) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue