@@ -23,6 +23,7 @@ struct QueryEditorView: View {
2323 @State private var isExecuting = false
2424 @State private var executionTime : TimeInterval ?
2525 @State private var executeTask : Task < Void , Never > ?
26+ @State private var executionStartTime : Date ?
2627 @Binding var queryHistory : [ QueryHistoryItem ]
2728 let connectionId : UUID
2829 let historyStorage : QueryHistoryStorage
@@ -31,6 +32,7 @@ struct QueryEditorView: View {
3132 @State private var showWriteConfirmation = false
3233 @State private var showWriteBlockedAlert = false
3334 @State private var pendingWriteQuery = " "
35+ @State private var showClearConfirmation = false
3436 @State private var showShareSheet = false
3537 @State private var shareText = " "
3638 @State private var hapticSuccess = false
@@ -63,6 +65,20 @@ struct QueryEditorView: View {
6365 ActivityViewController ( items: [ shareText] )
6466 }
6567 . sheet ( isPresented: $showHistory) { historySheet }
68+ . confirmationDialog (
69+ String ( localized: " Clear Query " ) ,
70+ isPresented: $showClearConfirmation,
71+ titleVisibility: . visible
72+ ) {
73+ Button ( String ( localized: " Clear " ) , role: . destructive) {
74+ query = " "
75+ result = nil
76+ appError = nil
77+ executionTime = nil
78+ }
79+ } message: {
80+ Text ( " Query text and results will be cleared. " )
81+ }
6682 }
6783
6884 // MARK: - Editor
@@ -72,9 +88,16 @@ struct QueryEditorView: View {
7288 SQLHighlightTextView ( text: $query)
7389 . frame ( minHeight: 80 , maxHeight: result != nil || appError != nil ? 120 : 250 )
7490
75- if executionTime != nil || result != nil {
91+ if isExecuting || executionTime != nil || result != nil {
7692 HStack {
77- if let time = executionTime {
93+ if isExecuting, let startTime = executionStartTime {
94+ TimelineView ( . periodic( from: startTime, by: 0.1 ) ) { context in
95+ let elapsed = context. date. timeIntervalSince ( startTime)
96+ Label ( String ( format: " %.1fs " , elapsed) , systemImage: " clock " )
97+ . font ( . caption2)
98+ . foregroundStyle ( . secondary)
99+ }
100+ } else if let time = executionTime {
78101 Label ( String ( format: " %.1fms " , time * 1000 ) , systemImage: " clock " )
79102 . font ( . caption2)
80103 . foregroundStyle ( . secondary)
@@ -290,10 +313,7 @@ struct QueryEditorView: View {
290313 Divider ( )
291314
292315 Button ( role: . destructive) {
293- query = " "
294- result = nil
295- appError = nil
296- executionTime = nil
316+ showClearConfirmation = true
297317 } label: {
298318 Label ( " Clear " , systemImage: " trash " )
299319 }
@@ -398,7 +418,11 @@ struct QueryEditorView: View {
398418
399419 UIApplication . shared. sendAction ( #selector( UIResponder . resignFirstResponder) , to: nil , from: nil , for: nil )
400420 isExecuting = true
401- defer { isExecuting = false }
421+ executionStartTime = Date ( )
422+ defer {
423+ isExecuting = false
424+ executionStartTime = nil
425+ }
402426 appError = nil
403427 result = nil
404428
0 commit comments