Skip to content

Commit 1d47fa6

Browse files
authored
Add copy prompt to history (#56)
1 parent da31a23 commit 1d47fa6

File tree

3 files changed

+415
-28
lines changed

3 files changed

+415
-28
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"displayName": "Roo Cline",
44
"description": "A fork of Cline, an autonomous coding agent, with some added experimental configuration and automation features.",
55
"publisher": "RooVeterinaryInc",
6-
"version": "2.1.15",
6+
"version": "2.1.16",
77
"icon": "assets/icons/rocket.png",
88
"galleryBanner": {
99
"color": "#617A91",

webview-ui/src/components/history/HistoryView.tsx

Lines changed: 52 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ const HistoryView = ({ onDone }: HistoryViewProps) => {
1717
const [searchQuery, setSearchQuery] = useState("")
1818
const [sortOption, setSortOption] = useState<SortOption>("newest")
1919
const [lastNonRelevantSort, setLastNonRelevantSort] = useState<SortOption | null>("newest")
20+
const [showCopyModal, setShowCopyModal] = useState(false)
2021

2122
useEffect(() => {
2223
if (searchQuery && sortOption !== "mostRelevant" && !lastNonRelevantSort) {
@@ -36,6 +37,17 @@ const HistoryView = ({ onDone }: HistoryViewProps) => {
3637
vscode.postMessage({ type: "deleteTaskWithId", text: id })
3738
}
3839

40+
const handleCopyTask = async (e: React.MouseEvent, task: string) => {
41+
e.stopPropagation()
42+
try {
43+
await navigator.clipboard.writeText(task)
44+
setShowCopyModal(true)
45+
setTimeout(() => setShowCopyModal(false), 2000)
46+
} catch (error) {
47+
console.error('Failed to copy to clipboard:', error)
48+
}
49+
}
50+
3951
const formatDate = (timestamp: number) => {
4052
const date = new Date(timestamp)
4153
return date
@@ -103,21 +115,40 @@ const HistoryView = ({ onDone }: HistoryViewProps) => {
103115
.history-item:hover {
104116
background-color: var(--vscode-list-hoverBackground);
105117
}
106-
.delete-button, .export-button {
118+
.delete-button, .export-button, .copy-button {
107119
opacity: 0;
108120
pointer-events: none;
109121
}
110122
.history-item:hover .delete-button,
111-
.history-item:hover .export-button {
123+
.history-item:hover .export-button,
124+
.history-item:hover .copy-button {
112125
opacity: 1;
113126
pointer-events: auto;
114127
}
115128
.history-item-highlight {
116129
background-color: var(--vscode-editor-findMatchHighlightBackground);
117130
color: inherit;
118131
}
132+
.copy-modal {
133+
position: fixed;
134+
top: 50%;
135+
left: 50%;
136+
transform: translate(-50%, -50%);
137+
background-color: var(--vscode-notifications-background);
138+
color: var(--vscode-notifications-foreground);
139+
padding: 12px 20px;
140+
border-radius: 4px;
141+
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
142+
z-index: 1000;
143+
transition: opacity 0.2s ease-in-out;
144+
}
119145
`}
120146
</style>
147+
{showCopyModal && (
148+
<div className="copy-modal">
149+
Prompt Copied to Clipboard
150+
</div>
151+
)}
121152
<div
122153
style={{
123154
position: "fixed",
@@ -190,22 +221,6 @@ const HistoryView = ({ onDone }: HistoryViewProps) => {
190221
</div>
191222
</div>
192223
<div style={{ flexGrow: 1, overflowY: "auto", margin: 0 }}>
193-
{/* {presentableTasks.length === 0 && (
194-
<div
195-
style={{
196-
197-
alignItems: "center",
198-
fontStyle: "italic",
199-
color: "var(--vscode-descriptionForeground)",
200-
textAlign: "center",
201-
padding: "0px 10px",
202-
}}>
203-
<span
204-
className="codicon codicon-robot"
205-
style={{ fontSize: "60px", marginBottom: "10px" }}></span>
206-
<div>Start a task to see it here</div>
207-
</div>
208-
)} */}
209224
<Virtuoso
210225
style={{
211226
flexGrow: 1,
@@ -247,15 +262,25 @@ const HistoryView = ({ onDone }: HistoryViewProps) => {
247262
}}>
248263
{formatDate(item.ts)}
249264
</span>
250-
<VSCodeButton
251-
appearance="icon"
252-
onClick={(e) => {
253-
e.stopPropagation()
254-
handleDeleteHistoryItem(item.id)
255-
}}
256-
className="delete-button">
257-
<span className="codicon codicon-trash"></span>
258-
</VSCodeButton>
265+
<div style={{ display: "flex", gap: "4px" }}>
266+
<VSCodeButton
267+
appearance="icon"
268+
title="Copy Prompt"
269+
className="copy-button"
270+
onClick={(e) => handleCopyTask(e, item.task)}>
271+
<span className="codicon codicon-copy"></span>
272+
</VSCodeButton>
273+
<VSCodeButton
274+
appearance="icon"
275+
title="Delete Task"
276+
onClick={(e) => {
277+
e.stopPropagation()
278+
handleDeleteHistoryItem(item.id)
279+
}}
280+
className="delete-button">
281+
<span className="codicon codicon-trash"></span>
282+
</VSCodeButton>
283+
</div>
259284
</div>
260285
<div
261286
style={{

0 commit comments

Comments
 (0)