@@ -17,6 +17,7 @@ import {
1717import { PanelProvider } from '@/views/panel/backend/panel-provider'
1818import { get_checkpoint_path } from './utils'
1919import { WebsitesProvider } from '@/context/providers/websites-provider'
20+ import { dictionary } from '@shared/constants/dictionary'
2021
2122dayjs . extend ( relativeTime )
2223
@@ -84,6 +85,11 @@ export const checkpoints_command = (params: {
8485 tooltip : 'Delete all checkpoints'
8586 }
8687
88+ const copy_button : vscode . QuickInputButton = {
89+ iconPath : new vscode . ThemeIcon ( 'copy' ) ,
90+ tooltip : 'Copy checkpoints as logs'
91+ }
92+
8793 let notification_count = 0
8894 let checkpoints : Checkpoint [ ] = [ ]
8995 let temp_checkpoint_is_valid = false
@@ -103,7 +109,7 @@ export const checkpoints_command = (params: {
103109 const visible_checkpoints = checkpoints . filter ( ( c ) => ! c . is_temporary )
104110
105111 if ( visible_checkpoints . length > 0 ) {
106- quick_pick . buttons = [ clear_all_button ]
112+ quick_pick . buttons = [ copy_button , clear_all_button ]
107113 } else {
108114 quick_pick . buttons = [ ]
109115 }
@@ -260,6 +266,53 @@ export const checkpoints_command = (params: {
260266 } )
261267
262268 quick_pick . onDidTriggerButton ( async ( button ) => {
269+ if ( button === copy_button ) {
270+ const visible_checkpoints = checkpoints
271+ . filter ( ( c ) => ! c . is_temporary )
272+ . sort ( ( a , b ) => b . timestamp - a . timestamp )
273+
274+ if ( visible_checkpoints . length == 0 ) {
275+ return
276+ }
277+
278+ const longest_title_length = Math . max (
279+ ...visible_checkpoints . map ( ( c ) => c . title . length )
280+ )
281+
282+ const time_zone = Intl . DateTimeFormat ( ) . resolvedOptions ( ) . timeZone
283+
284+ const log_lines : string [ ] = [ ]
285+ let last_full_hour : string | null = null
286+
287+ for ( const c of visible_checkpoints ) {
288+ const date_obj = dayjs ( c . timestamp )
289+ const current_full_hour = date_obj . format ( 'YYYY-MM-DD HH' )
290+
291+ if (
292+ last_full_hour !== null &&
293+ last_full_hour !== current_full_hour
294+ ) {
295+ log_lines . push ( '' )
296+ }
297+
298+ const date = date_obj . format ( 'YYYY-MM-DD HH:mm' )
299+ const padded_title = c . title . padEnd ( longest_title_length , ' ' )
300+ log_lines . push (
301+ `[${ date } ${ time_zone } ] | ${ padded_title } | ${
302+ c . description ? c . description : ''
303+ } `
304+ )
305+ last_full_hour = current_full_hour
306+ }
307+
308+ const log_string = log_lines . join ( '\n' )
309+ await vscode . env . clipboard . writeText ( log_string )
310+ vscode . window . showInformationMessage (
311+ dictionary . information_message . CHECKPOINTS_COPIED_TO_CLIPBOARD
312+ )
313+ return
314+ }
315+
263316 if ( button === clear_all_button ) {
264317 quick_pick . hide ( )
265318 const confirmation = await vscode . window . showWarningMessage (
0 commit comments