1- import { VSCodeButton } from "@vscode/webview-ui-toolkit/react"
2- import { useExtensionState } from "../../context/ExtensionStateContext"
3- import { vscode } from "../../utils/vscode"
41import { memo } from "react"
5- import { formatLargeNumber } from "../../utils/format"
6- import { useCopyToClipboard } from "../../utils/clipboard"
2+
3+ import { vscode } from "@/utils/vscode"
4+ import { formatLargeNumber , formatDate } from "@/utils/format"
5+ import { Button } from "@/components/ui"
6+
7+ import { useExtensionState } from "../../context/ExtensionStateContext"
8+ import { CopyButton } from "./CopyButton"
79
810type HistoryPreviewProps = {
911 showHistoryView : ( ) => void
1012}
1113
1214const HistoryPreview = ( { showHistoryView } : HistoryPreviewProps ) => {
1315 const { taskHistory } = useExtensionState ( )
14- const { showCopyFeedback , copyWithFeedback } = useCopyToClipboard ( )
16+
1517 const handleHistorySelect = ( id : string ) => {
1618 vscode . postMessage ( { type : "showTaskWithId" , text : id } )
1719 }
1820
19- const formatDate = ( timestamp : number ) => {
20- const date = new Date ( timestamp )
21- return date
22- ?. toLocaleString ( "en-US" , {
23- month : "long" ,
24- day : "numeric" ,
25- hour : "numeric" ,
26- minute : "2-digit" ,
27- hour12 : true ,
28- } )
29- . replace ( ", " , " " )
30- . replace ( " at" , "," )
31- . toUpperCase ( )
32- }
33-
3421 return (
3522 < div style = { { flexShrink : 0 } } >
36- { showCopyFeedback && < div className = "copy-modal" > Prompt Copied to Clipboard</ div > }
3723 < style >
3824 { `
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- }
6025 .history-preview-item {
6126 background-color: color-mix(in srgb, var(--vscode-toolbar-hoverBackground) 65%, transparent);
6227 border-radius: 4px;
@@ -73,28 +38,17 @@ const HistoryPreview = ({ showHistoryView }: HistoryPreviewProps) => {
7338 }
7439 ` }
7540 </ style >
76-
7741 < div
7842 style = { {
7943 color : "var(--vscode-descriptionForeground)" ,
8044 margin : "10px 20px 10px 20px" ,
8145 display : "flex" ,
8246 alignItems : "center" ,
8347 } } >
84- < span
85- className = "codicon codicon-comment-discussion"
86- style = { { marginRight : "4px" , transform : "scale(0.9)" } } > </ span >
87- < span
88- style = { {
89- fontWeight : 500 ,
90- fontSize : "0.85em" ,
91- textTransform : "uppercase" ,
92- } } >
93- Recent Tasks
94- </ span >
48+ < span className = "codicon codicon-comment-discussion scale-90 mr-1" />
49+ < span className = "font-medium text-xs uppercase" > Recent Tasks</ span >
9550 </ div >
96-
97- < div style = { { padding : "0px 20px 0 20px" } } >
51+ < div className = "px-5" >
9852 { taskHistory
9953 . filter ( ( item ) => item . ts && item . task )
10054 . slice ( 0 , 3 )
@@ -103,48 +57,25 @@ const HistoryPreview = ({ showHistoryView }: HistoryPreviewProps) => {
10357 key = { item . id }
10458 className = "history-preview-item"
10559 onClick = { ( ) => handleHistorySelect ( item . id ) } >
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- } } >
114- < span
115- style = { {
116- color : "var(--vscode-descriptionForeground)" ,
117- fontWeight : 500 ,
118- fontSize : "0.85em" ,
119- textTransform : "uppercase" ,
120- } } >
60+ < div className = "flex flex-col gap-2 p-3 pt-1" >
61+ < div className = "flex justify-between items-center" >
62+ < span className = "text-xs font-medium text-vscode-descriptionForeground uppercase" >
12163 { formatDate ( item . ts ) }
12264 </ 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 >
65+ < CopyButton itemTask = { item . task } />
13166 </ div >
13267 < div
68+ className = "text-vscode-descriptionForeground overflow-hidden whitespace-pre-wrap"
13369 style = { {
134- fontSize : "var(--vscode-font-size)" ,
135- color : "var(--vscode-descriptionForeground)" ,
136- marginBottom : "8px" ,
13770 display : "-webkit-box" ,
13871 WebkitLineClamp : 3 ,
13972 WebkitBoxOrient : "vertical" ,
140- overflow : "hidden" ,
141- whiteSpace : "pre-wrap" ,
14273 wordBreak : "break-word" ,
14374 overflowWrap : "anywhere" ,
14475 } } >
14576 { item . task }
14677 </ div >
147- < div style = { { fontSize : "0.85em" , color : "var(-- vscode-descriptionForeground)" } } >
78+ < div className = "text-xs text- vscode-descriptionForeground" >
14879 < span >
14980 Tokens: ↑{ formatLargeNumber ( item . tokensIn || 0 ) } ↓
15081 { formatLargeNumber ( item . tokensOut || 0 ) }
@@ -168,21 +99,14 @@ const HistoryPreview = ({ showHistoryView }: HistoryPreviewProps) => {
16899 </ div >
169100 </ div >
170101 ) ) }
171- < div style = { { display : "flex" , alignItems : "center" , justifyContent : "center" } } >
172- < VSCodeButton
173- appearance = "icon"
102+ < div className = "flex justify-center" >
103+ < Button
104+ variant = "ghost"
105+ size = "sm"
174106 onClick = { ( ) => showHistoryView ( ) }
175- style = { {
176- opacity : 0.9 ,
177- } } >
178- < div
179- style = { {
180- fontSize : "var(--vscode-font-size)" ,
181- color : "var(--vscode-descriptionForeground)" ,
182- } } >
183- View all history
184- </ div >
185- </ VSCodeButton >
107+ className = "font-normal text-vscode-descriptionForeground" >
108+ View all history
109+ </ Button >
186110 </ div >
187111 </ div >
188112 </ div >
0 commit comments