tui: report clipboard copy delivery status

This commit is contained in:
Simon Klee 2026-07-07 08:14:31 +02:00
parent a749a73ad4
commit e4416a1d8d
No known key found for this signature in database
GPG key ID: B91696044D47BEA3
2 changed files with 24 additions and 7 deletions

View file

@ -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(() => ({

View file

@ -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) {