@@ -3,13 +3,15 @@ import { useExtensionState } from "../../context/ExtensionStateContext"
33import { vscode } from "../../utils/vscode"
44import { memo } from "react"
55import { formatLargeNumber } from "../../utils/format"
6+ import { useCopyToClipboard } from "../../utils/clipboard"
67
78type HistoryPreviewProps = {
89 showHistoryView : ( ) => void
910}
1011
1112const HistoryPreview = ( { showHistoryView } : HistoryPreviewProps ) => {
1213 const { taskHistory } = useExtensionState ( )
14+ const { showCopyFeedback, copyWithFeedback } = useCopyToClipboard ( )
1315 const handleHistorySelect = ( id : string ) => {
1416 vscode . postMessage ( { type : "showTaskWithId" , text : id } )
1517 }
@@ -31,8 +33,30 @@ const HistoryPreview = ({ showHistoryView }: HistoryPreviewProps) => {
3133
3234 return (
3335 < div style = { { flexShrink : 0 } } >
36+ { showCopyFeedback && < div className = "copy-modal" > Prompt Copied to Clipboard</ div > }
3437 < style >
3538 { `
39+ .copy-modal {
40+ position: fixed;
41+ top: 50%;
42+ left: 50%;
43+ transform: translate(-50%, -50%);
44+ background-color: var(--vscode-notifications-background);
45+ color: var(--vscode-notifications-foreground);
46+ padding: 12px 20px;
47+ border-radius: 4px;
48+ box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
49+ z-index: 1000;
50+ transition: opacity 0.2s ease-in-out;
51+ }
52+ .copy-button {
53+ opacity: 0;
54+ pointer-events: none;
55+ }
56+ .history-preview-item:hover .copy-button {
57+ opacity: 1;
58+ pointer-events: auto;
59+ }
3660 .history-preview-item {
3761 background-color: color-mix(in srgb, var(--vscode-toolbar-hoverBackground) 65%, transparent);
3862 border-radius: 4px;
@@ -79,8 +103,14 @@ const HistoryPreview = ({ showHistoryView }: HistoryPreviewProps) => {
79103 key = { item . id }
80104 className = "history-preview-item"
81105 onClick = { ( ) => handleHistorySelect ( item . id ) } >
82- < div style = { { padding : "12px" } } >
83- < div style = { { marginBottom : "8px" } } >
106+ < div style = { { padding : "12px" , position : "relative" } } >
107+ < div
108+ style = { {
109+ marginBottom : "8px" ,
110+ display : "flex" ,
111+ justifyContent : "space-between" ,
112+ alignItems : "center" ,
113+ } } >
84114 < span
85115 style = { {
86116 color : "var(--vscode-descriptionForeground)" ,
@@ -90,6 +120,14 @@ const HistoryPreview = ({ showHistoryView }: HistoryPreviewProps) => {
90120 } } >
91121 { formatDate ( item . ts ) }
92122 </ span >
123+ < button
124+ title = "Copy Prompt"
125+ aria-label = "Copy Prompt"
126+ className = "copy-button"
127+ data-appearance = "icon"
128+ onClick = { ( e ) => copyWithFeedback ( item . task , e ) } >
129+ < span className = "codicon codicon-copy" > </ span >
130+ </ button >
93131 </ div >
94132 < div
95133 style = { {
0 commit comments