tui: add text selection and copy functionality to messages

This commit is contained in:
Dax Raad 2025-10-31 14:28:56 -04:00
parent ee112f780e
commit 2361352374
2 changed files with 12 additions and 3 deletions

View file

@ -260,6 +260,7 @@ function App() {
renderer.writeOut(finalOsc52)
await Clipboard.copy(text)
renderer.clearSelection()
toast.show({ message: "Copied to clipboard", variant: "info" })
}
}}
>

View file

@ -40,7 +40,13 @@ import type { EditTool } from "@/tool/edit"
import type { PatchTool } from "@/tool/patch"
import type { WebFetchTool } from "@/tool/webfetch"
import type { TaskTool } from "@/tool/task"
import { useKeyboard, useTerminalDimensions, type BoxProps, type JSX } from "@opentui/solid"
import {
useKeyboard,
useRenderer,
useTerminalDimensions,
type BoxProps,
type JSX,
} from "@opentui/solid"
import { useSDK } from "@tui/context/sdk"
import { useCommandDialog } from "@tui/component/dialog-command"
import { Shimmer } from "@tui/ui/shimmer"
@ -398,6 +404,7 @@ export function Session() {
})
const dialog = useDialog()
const renderer = useRenderer()
return (
<context.Provider
@ -510,11 +517,12 @@ export function Session() {
<Match when={message.role === "user"}>
<UserMessage
index={index()}
onMouseUp={() =>
onMouseUp={() => {
if (renderer.getSelection()?.getSelectedText()) return
dialog.replace(() => (
<DialogMessage messageID={message.id} sessionID={route.sessionID} />
))
}
}}
message={message as UserMessage}
parts={sync.data.part[message.id] ?? []}
pending={pending()}