@@ -2,8 +2,8 @@ import { useEffect, useState } from "react";
22import { useNavigate } from "react-router" ;
33import { apiRoute } from "./util" ;
44import { DebugSession , DebugSessionsPage as DebugSessionsPageType } from "./types" ;
5- import { Box , CopyToClipboard , Alert } from "@launchpad-ui/core" ;
6- import { Heading , Text , ProgressBar , Button } from "@launchpad-ui/components" ;
5+ import { Box , Alert } from "@launchpad-ui/core" ;
6+ import { Heading , Text , ProgressBar , Button , Link } from "@launchpad-ui/components" ;
77import { Icon } from "@launchpad-ui/icons" ;
88
99const DebugSessionsPage = ( ) => {
@@ -12,6 +12,7 @@ const DebugSessionsPage = () => {
1212 const [ loading , setLoading ] = useState < boolean > ( true ) ;
1313 const [ error , setError ] = useState < string | null > ( null ) ;
1414 const [ totalCount , setTotalCount ] = useState < number > ( 0 ) ;
15+ const [ deletingSession , setDeletingSession ] = useState < string | null > ( null ) ;
1516
1617 const fetchDebugSessions = async ( ) => {
1718 try {
@@ -51,6 +52,35 @@ const DebugSessionsPage = () => {
5152 navigate ( `/ui/debug-sessions/${ encodeURIComponent ( sessionKey ) } /events` ) ;
5253 } ;
5354
55+ const handleDeleteSession = async ( sessionKey : string ) => {
56+ if ( ! confirm ( `Are you sure you want to delete debug session "${ sessionKey } " and all its events? This action cannot be undone.` ) ) {
57+ return ;
58+ }
59+
60+ try {
61+ setDeletingSession ( sessionKey ) ;
62+ setError ( null ) ;
63+
64+ const response = await fetch ( apiRoute ( `/dev/debug-sessions/${ encodeURIComponent ( sessionKey ) } ` ) , {
65+ method : 'DELETE' ,
66+ } ) ;
67+
68+ if ( ! response . ok ) {
69+ if ( response . status === 404 ) {
70+ throw new Error ( 'Debug session not found' ) ;
71+ }
72+ throw new Error ( `Failed to delete debug session: ${ response . status } ${ response . statusText } ` ) ;
73+ }
74+
75+ // Refresh the sessions list after successful deletion
76+ await fetchDebugSessions ( ) ;
77+ } catch ( err ) {
78+ setError ( err instanceof Error ? err . message : "An unknown error occurred while deleting the session" ) ;
79+ } finally {
80+ setDeletingSession ( null ) ;
81+ }
82+ } ;
83+
5484 if ( loading ) {
5585 return (
5686 < Box padding = "2rem" width = "100%" >
@@ -118,27 +148,13 @@ const DebugSessionsPage = () => {
118148 < table style = { { width : "100%" , borderCollapse : "collapse" } } >
119149 < thead >
120150 < tr style = { { backgroundColor : "var(--lp-color-bg-ui-secondary)" } } >
121- < th style = { {
122- padding : "0.75rem" ,
123- textAlign : "left" ,
124- borderBottom : "1px solid var(--lp-color-border-ui-primary)" ,
125- fontWeight : 600
126- } } >
127- Session Key
128- < Text
129- color = "var(--lp-color-text-ui-secondary)"
130- style = { { fontSize : "0.75rem" , fontWeight : 400 , marginTop : "0.25rem" } }
131- >
132- (click to view events)
133- </ Text >
134- </ th >
135151 < th style = { {
136152 padding : "0.75rem" ,
137153 textAlign : "left" ,
138154 borderBottom : "1px solid var(--lp-color-border-ui-primary)" ,
139155 fontWeight : 600
140156 } } >
141- Created At
157+ Debug Session Started
142158 </ th >
143159 < th style = { {
144160 padding : "0.75rem" ,
@@ -155,7 +171,7 @@ const DebugSessionsPage = () => {
155171 fontWeight : 600 ,
156172 width : "100px"
157173 } } >
158- Copy Key
174+ Actions
159175 </ th >
160176 </ tr >
161177 </ thead >
@@ -167,52 +183,37 @@ const DebugSessionsPage = () => {
167183 borderBottom : index < debugSessions . length - 1 ? "1px solid var(--lp-color-border-ui-primary)" : "none"
168184 } }
169185 >
186+
170187 < td style = { { padding : "0.75rem" } } >
171- < button
172- onClick = { ( ) => handleSessionClick ( session . key ) }
173- style = { {
174- background : "none" ,
175- border : "none" ,
176- padding : 0 ,
177- cursor : "pointer" ,
178- textAlign : "left" ,
179- color : "var(--lp-color-text-link)" ,
180- textDecoration : "underline" ,
181- fontFamily : "monospace"
182- } }
183- title = "Click to view events for this session"
184- >
185- { session . key }
186- </ button >
187- </ td >
188- < td style = { { padding : "0.75rem" } } >
189- < Text >
188+ < Link href = { `/ui/debug-sessions/${ session . key } /events` } >
190189 { formatDate ( session . written_at ) }
191- </ Text >
190+ </ Link >
192191 </ td >
193192 < td style = { { padding : "0.75rem" , textAlign : "right" } } >
194193 < Text >
195194 { session . event_count . toLocaleString ( ) }
196195 </ Text >
197196 </ td >
198197 < td style = { { padding : "0.75rem" , textAlign : "center" } } >
199- < CopyToClipboard text = { session . key } >
200- < button
201- style = { {
202- background : "none" ,
203- border : "1px solid var(--lp-color-border-ui-primary)" ,
204- borderRadius : "4px" ,
205- padding : "0.25rem 0.5rem" ,
206- cursor : "pointer" ,
207- display : "flex" ,
208- alignItems : "center" ,
209- gap : "0.25rem"
210- } }
211- title = "Copy session key"
212- >
213- < Icon name = "link" size = "small" />
214- </ button >
215- </ CopyToClipboard >
198+ < button
199+ onClick = { ( ) => handleDeleteSession ( session . key ) }
200+ disabled = { deletingSession === session . key }
201+ style = { {
202+ background : "none" ,
203+ border : "1px solid var(--lp-color-border-destructive)" ,
204+ borderRadius : "4px" ,
205+ padding : "0.25rem 0.5rem" ,
206+ cursor : deletingSession === session . key ? "not-allowed" : "pointer" ,
207+ display : "flex" ,
208+ alignItems : "center" ,
209+ gap : "0.25rem" ,
210+ color : "var(--lp-color-text-destructive)" ,
211+ opacity : deletingSession === session . key ? 0.6 : 1
212+ } }
213+ title = { deletingSession === session . key ? "Deleting..." : "Delete session and all events" }
214+ >
215+ < Icon name = { "delete" } size = "small" />
216+ </ button >
216217 </ td >
217218 </ tr >
218219 ) ) }
0 commit comments