mirror of
https://github.com/sst/opencode.git
synced 2025-12-23 10:11:41 +00:00
tui: add text selection and copy functionality to messages
This commit is contained in:
parent
ee112f780e
commit
2361352374
2 changed files with 12 additions and 3 deletions
|
|
@ -260,6 +260,7 @@ function App() {
|
|||
renderer.writeOut(finalOsc52)
|
||||
await Clipboard.copy(text)
|
||||
renderer.clearSelection()
|
||||
toast.show({ message: "Copied to clipboard", variant: "info" })
|
||||
}
|
||||
}}
|
||||
>
|
||||
|
|
|
|||
|
|
@ -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()}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue