ghostscope-ui 0.1.5

Terminal user interface that streams GhostScope traces with async input handling.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
use super::App;
use crate::action::{Action, PanelType};
use anyhow::Result;
use tracing::debug;

impl App {
    pub(super) fn handle_action(&mut self, action: Action) -> Result<Vec<Action>> {
        debug!("Handling action: {:?}", action);
        let mut additional_actions = Vec::new();

        match action {
            Action::Quit => {
                self.state.should_quit = true;
            }
            Action::Resize(width, height) => {
                // Force refresh of all panel dimensions on terminal resize
                tracing::debug!("Terminal resized to {}x{}", width, height);
                // The render function will automatically pick up the new dimensions
                // and update panel sizes accordingly
            }
            Action::FocusNext => {
                let src_enabled = self.state.ui.config.show_source_panel;
                self.state.ui.focus.cycle_next(src_enabled);
            }
            Action::FocusPrevious => {
                let src_enabled = self.state.ui.config.show_source_panel;
                self.state.ui.focus.cycle_previous(src_enabled);
            }
            Action::FocusPanel(panel) => {
                if panel == crate::action::PanelType::Source
                    && !self.state.ui.config.show_source_panel
                {
                    // Ignore focusing hidden source panel; fallback to command panel
                    self.state
                        .ui
                        .focus
                        .set_panel(crate::action::PanelType::InteractiveCommand);
                } else {
                    self.state.ui.focus.set_panel(panel);
                }
            }
            Action::ToggleFullscreen => {
                self.state.ui.layout.toggle_fullscreen();
            }
            Action::SwitchLayout => {
                self.state.ui.layout.switch_mode();
            }
            Action::EnterWindowNavMode => {
                self.state.ui.focus.expecting_window_nav = true;
            }
            Action::ExitWindowNavMode => {
                self.state.ui.focus.expecting_window_nav = false;
            }
            Action::WindowNavMove(direction) => {
                let src_enabled = self.state.ui.config.show_source_panel;
                self.state.ui.focus.move_focus_in_direction(
                    direction,
                    self.state.ui.layout.mode,
                    src_enabled,
                );
            }
            Action::SetSourcePanelVisibility(show) => {
                let currently_shown = self.state.ui.config.show_source_panel;
                if show == currently_shown {
                    return Ok(Vec::new());
                }
                self.state.ui.config.show_source_panel = show;
                if show {
                    // If enabling, request source code immediately
                    if let Err(e) = self
                        .state
                        .event_registry
                        .command_sender
                        .send(crate::events::RuntimeCommand::RequestSourceCode)
                    {
                        tracing::warn!("Failed to send source request after enabling: {}", e);
                    }
                    // Inform user
                    let plain =
                        "✅ Source panel enabled. Use 'ui source off' to hide it.".to_string();
                    let styled = vec![
                        crate::components::command_panel::style_builder::StyledLineBuilder::new()
                            .styled(
                                plain.clone(),
                                crate::components::command_panel::style_builder::StylePresets::SUCCESS,
                            )
                            .build(),
                    ];
                    additional_actions.push(Action::AddResponseWithStyle {
                        content: plain,
                        styled_lines: Some(styled),
                        response_type: crate::action::ResponseType::Success,
                    });
                } else {
                    // If disabling and focus is Source or fullscreen Source, move focus away
                    if self.state.ui.focus.current_panel == crate::action::PanelType::Source {
                        self.state
                            .ui
                            .focus
                            .set_panel(crate::action::PanelType::InteractiveCommand);
                    }
                    if self.state.ui.layout.is_fullscreen
                        && matches!(
                            self.state.ui.focus.current_panel,
                            crate::action::PanelType::Source
                        )
                    {
                        self.state.ui.layout.is_fullscreen = false;
                    }
                    // Inform user
                    let plain = "✅ Source panel disabled. Panels: eBPF output + command. Use 'ui source on' to enable.".to_string();
                    let styled = vec![
                        crate::components::command_panel::style_builder::StyledLineBuilder::new()
                            .styled(
                                plain.clone(),
                                crate::components::command_panel::style_builder::StylePresets::SUCCESS,
                            )
                            .build(),
                    ];
                    additional_actions.push(Action::AddResponseWithStyle {
                        content: plain,
                        styled_lines: Some(styled),
                        response_type: crate::action::ResponseType::Success,
                    });
                }
            }
            Action::InsertChar(c) => {
                let actions = crate::components::command_panel::InputHandler::insert_char(
                    &mut self.state.command_panel,
                    c,
                );
                additional_actions.extend(actions);
            }
            Action::DeleteChar => {
                let actions = crate::components::command_panel::InputHandler::delete_char(
                    &mut self.state.command_panel,
                );
                additional_actions.extend(actions);
            }
            Action::MoveCursor(direction) => {
                let actions = crate::components::command_panel::InputHandler::move_cursor(
                    &mut self.state.command_panel,
                    direction,
                );
                additional_actions.extend(actions);
            }
            Action::SubmitCommand => {
                let actions = self
                    .state
                    .command_input_handler
                    .handle_submit(&mut self.state.command_panel);
                additional_actions.extend(actions);
                self.state.command_renderer.mark_pending_updates();

                // Realtime logging: write command to file if enabled
                if self.state.realtime_session_logger.enabled {
                    if let Some(command) = self
                        .state
                        .command_panel
                        .command_history
                        .last()
                        .map(|item| item.command.clone())
                    {
                        if let Err(e) = self.write_command_to_session_log(&command) {
                            tracing::error!("Failed to write command to session log: {}", e);
                        }
                    }
                }
            }
            Action::SubmitCommandWithText { command } => {
                // Handle command submission from history search mode
                // Add to history and process the command
                self.state.command_panel.add_command_to_history(&command);

                // Set the input text and submit it
                self.state.command_panel.input_text = command.clone();
                let actions = self
                    .state
                    .command_input_handler
                    .handle_submit(&mut self.state.command_panel);
                additional_actions.extend(actions);
                self.state.command_renderer.mark_pending_updates();

                // Realtime logging: write command to file if enabled
                if self.state.realtime_session_logger.enabled {
                    if let Err(e) = self.write_command_to_session_log(&command) {
                        tracing::error!("Failed to write command to session log: {}", e);
                    }
                }
            }
            Action::HistoryUp => {
                // Handled by input handler
            }
            Action::HistoryDown => {
                // Handled by input handler
            }
            Action::HistoryPrevious => {
                self.state.command_panel.history_previous();
                self.state.command_renderer.mark_pending_updates();
            }
            Action::HistoryNext => {
                self.state.command_panel.history_next();
                self.state.command_renderer.mark_pending_updates();
            }
            Action::EnterCommandMode => {
                self.state
                    .command_panel
                    .enter_command_mode(self.state.command_panel_width);
            }
            Action::ExitCommandMode => {
                self.state.command_panel.exit_command_mode();
            }
            Action::EnterInputMode => {
                self.state.command_panel.mode = crate::model::panel_state::InteractionMode::Input;
            }
            Action::CommandCursorUp => {
                self.state.command_panel.move_command_cursor_up();
                self.state.command_renderer.mark_pending_updates();
            }
            Action::CommandCursorDown => {
                self.state.command_panel.move_command_cursor_down();
                self.state.command_renderer.mark_pending_updates();
            }
            Action::CommandCursorLeft => {
                self.state.command_panel.move_command_cursor_left();
                self.state.command_renderer.mark_pending_updates();
            }
            Action::CommandCursorRight => {
                self.state.command_panel.move_command_cursor_right();
                self.state.command_renderer.mark_pending_updates();
            }
            Action::CommandHalfPageUp => {
                self.state.command_panel.move_command_half_page_up();
                self.state.command_renderer.mark_pending_updates();
            }
            Action::CommandHalfPageDown => {
                self.state.command_panel.move_command_half_page_down();
                self.state.command_renderer.mark_pending_updates();
            }
            Action::EnterScriptMode(command) => {
                let actions = crate::components::command_panel::ScriptEditor::enter_script_mode(
                    &mut self.state.command_panel,
                    &command,
                );
                additional_actions.extend(actions);
                self.state.command_renderer.mark_pending_updates();
            }
            Action::ExitScriptMode => {
                let actions = crate::components::command_panel::ScriptEditor::exit_script_mode(
                    &mut self.state.command_panel,
                );
                additional_actions.extend(actions);
                self.state.command_renderer.mark_pending_updates();
            }
            Action::SubmitScript => {
                let actions = crate::components::command_panel::ScriptEditor::submit_script(
                    &mut self.state.command_panel,
                );
                additional_actions.extend(actions);
                self.state.command_renderer.mark_pending_updates();
            }
            Action::CancelScript => {
                let actions = crate::components::command_panel::ScriptEditor::exit_script_mode(
                    &mut self.state.command_panel,
                );
                additional_actions.extend(actions);
                self.state.command_renderer.mark_pending_updates();
            }
            Action::AddResponseWithStyle {
                content,
                styled_lines,
                response_type,
            } => {
                // Realtime logging: write response to file if enabled (before moving content)
                if self.state.realtime_session_logger.enabled {
                    if let Err(e) = self.write_response_to_session_log(&content) {
                        tracing::error!("Failed to write response to session log: {}", e);
                    }
                }
                crate::components::command_panel::ResponseFormatter::add_response_with_style(
                    &mut self.state.command_panel,
                    content,
                    styled_lines,
                    response_type,
                );
                self.state.command_renderer.mark_pending_updates();
            }
            // Removed old AddWelcomeMessage - now using AddStyledWelcomeMessage
            Action::AddStyledWelcomeMessage {
                styled_lines,
                response_type,
            } => {
                // New direct styled approach - no complex mapping needed
                self.state
                    .command_panel
                    .add_styled_welcome_lines(styled_lines, response_type);
                self.state.command_renderer.mark_pending_updates();
            }
            Action::SendRuntimeCommand(cmd) => {
                // Send command to runtime via event_registry
                debug!("Sending runtime command: {:?}", cmd);
                if let Err(e) = self.state.event_registry.command_sender.send(cmd) {
                    tracing::error!("Failed to send runtime command: {}", e);
                    // Add error response to command panel
                    let plain = format!("✗ Failed to send command to runtime: {e}");
                    let styled = vec![
                        crate::components::command_panel::style_builder::StyledLineBuilder::new()
                            .styled(plain.clone(), crate::components::command_panel::style_builder::StylePresets::ERROR)
                            .build(),
                    ];
                    let error_action = Action::AddResponseWithStyle {
                        content: plain,
                        styled_lines: Some(styled),
                        response_type: crate::action::ResponseType::Error,
                    };
                    additional_actions.push(error_action);
                }
            }
            Action::HandleRuntimeStatus(status) => {
                // TODO: Handle runtime status updates
                debug!("Would handle runtime status: {:?}", status);
            }
            Action::DeletePreviousWord => match self.state.command_panel.mode {
                crate::model::panel_state::InteractionMode::ScriptEditor => {
                    let actions =
                        crate::components::command_panel::ScriptEditor::delete_previous_word(
                            &mut self.state.command_panel,
                        );
                    additional_actions.extend(actions);
                }
                _ => {
                    let actions =
                        crate::components::command_panel::InputHandler::delete_previous_word(
                            &mut self.state.command_panel,
                        );
                    additional_actions.extend(actions);
                }
            },
            Action::DeleteToEnd => {
                let actions = crate::components::command_panel::InputHandler::delete_to_end(
                    &mut self.state.command_panel,
                );
                additional_actions.extend(actions);
            }
            Action::DeleteToBeginning => {
                let actions = crate::components::command_panel::InputHandler::delete_to_beginning(
                    &mut self.state.command_panel,
                );
                additional_actions.extend(actions);
            }
            Action::InsertTab => {
                if self.state.command_panel.mode
                    == crate::model::panel_state::InteractionMode::ScriptEditor
                {
                    let actions = crate::components::command_panel::ScriptEditor::insert_tab(
                        &mut self.state.command_panel,
                    );
                    additional_actions.extend(actions);
                }
            }
            Action::InsertNewline => {
                if self.state.command_panel.mode
                    == crate::model::panel_state::InteractionMode::ScriptEditor
                {
                    let actions = crate::components::command_panel::ScriptEditor::insert_newline(
                        &mut self.state.command_panel,
                    );
                    additional_actions.extend(actions);
                }
            }
            // Source panel actions
            Action::NavigateSource(direction) => {
                let actions = match direction {
                    crate::action::SourceNavigation::Up => {
                        crate::components::source_panel::SourceNavigation::move_up(
                            &mut self.state.source_panel,
                        )
                    }
                    crate::action::SourceNavigation::Down => {
                        crate::components::source_panel::SourceNavigation::move_down(
                            &mut self.state.source_panel,
                        )
                    }
                    crate::action::SourceNavigation::Left => {
                        crate::components::source_panel::SourceNavigation::move_left(
                            &mut self.state.source_panel,
                        )
                    }
                    crate::action::SourceNavigation::Right => {
                        crate::components::source_panel::SourceNavigation::move_right(
                            &mut self.state.source_panel,
                        )
                    }
                    crate::action::SourceNavigation::PageUp => {
                        crate::components::source_panel::SourceNavigation::move_up_fast(
                            &mut self.state.source_panel,
                        )
                    }
                    crate::action::SourceNavigation::PageDown => {
                        crate::components::source_panel::SourceNavigation::move_down_fast(
                            &mut self.state.source_panel,
                        )
                    }
                    crate::action::SourceNavigation::HalfPageUp => {
                        crate::components::source_panel::SourceNavigation::move_half_page_up(
                            &mut self.state.source_panel,
                        )
                    }
                    crate::action::SourceNavigation::HalfPageDown => {
                        crate::components::source_panel::SourceNavigation::move_half_page_down(
                            &mut self.state.source_panel,
                        )
                    }
                    crate::action::SourceNavigation::GoToLine(line) => {
                        crate::components::source_panel::SourceNavigation::go_to_line(
                            &mut self.state.source_panel,
                            line,
                        )
                    }
                    crate::action::SourceNavigation::NextMatch => {
                        crate::components::source_panel::SourceSearch::next_match(
                            &mut self.state.source_panel,
                        )
                    }
                    crate::action::SourceNavigation::PrevMatch => {
                        crate::components::source_panel::SourceSearch::prev_match(
                            &mut self.state.source_panel,
                        )
                    }
                    crate::action::SourceNavigation::WordForward => {
                        crate::components::source_panel::SourceNavigation::move_word_forward(
                            &mut self.state.source_panel,
                        )
                    }
                    crate::action::SourceNavigation::WordBackward => {
                        crate::components::source_panel::SourceNavigation::move_word_backward(
                            &mut self.state.source_panel,
                        )
                    }
                    crate::action::SourceNavigation::LineStart => {
                        crate::components::source_panel::SourceNavigation::move_to_line_start(
                            &mut self.state.source_panel,
                        )
                    }
                    crate::action::SourceNavigation::LineEnd => {
                        crate::components::source_panel::SourceNavigation::move_to_line_end(
                            &mut self.state.source_panel,
                        )
                    }
                };
                additional_actions.extend(actions);
            }
            Action::LoadSource { path, line } => {
                let actions = crate::components::source_panel::SourceNavigation::load_source(
                    &mut self.state.source_panel,
                    path,
                    line,
                );
                additional_actions.extend(actions);
            }
            Action::EnterTextSearch => {
                let actions = crate::components::source_panel::SourceSearch::enter_search_mode(
                    &mut self.state.source_panel,
                );
                additional_actions.extend(actions);
            }
            Action::ExitTextSearch => {
                let actions = crate::components::source_panel::SourceSearch::exit_search_mode(
                    &mut self.state.source_panel,
                );
                additional_actions.extend(actions);
            }
            Action::EnterFileSearch => {
                let actions = crate::components::source_panel::SourceSearch::enter_file_search_mode(
                    &mut self.state.source_panel,
                );
                additional_actions.extend(actions);

                // Use file cache to populate source panel search
                if let Some(ref mut cache) = self.state.command_panel.file_completion_cache {
                    if !cache.is_empty() {
                        // Use existing file cache
                        tracing::debug!("Using cached file list for source panel search");
                        let files = cache.get_all_files().to_vec();
                        let actions =
                            crate::components::source_panel::SourceSearch::set_file_search_files(
                                &mut self.state.source_panel,
                                cache,
                                files,
                            );
                        additional_actions.extend(actions);
                    }
                } else {
                    // Fallback: request file information from runtime
                    tracing::debug!("No cached files available, requesting from runtime");
                    self.state.route_file_info_to_file_search = true;
                    if let Err(e) = self
                        .state
                        .event_registry
                        .command_sender
                        .send(crate::events::RuntimeCommand::InfoSource)
                    {
                        tracing::error!("Failed to send InfoSource command: {}", e);
                        // Clear routing flag if send failed
                        self.state.route_file_info_to_file_search = false;
                        let error_actions =
                            crate::components::source_panel::SourceSearch::set_file_search_error(
                                &mut self.state.source_panel,
                                "Failed to request file list".to_string(),
                            );
                        additional_actions.extend(error_actions);
                    }
                }
            }
            Action::ExitFileSearch => {
                let actions = crate::components::source_panel::SourceSearch::exit_file_search_mode(
                    &mut self.state.source_panel,
                );
                additional_actions.extend(actions);
            }
            Action::SourceSearchInput(ch) => {
                let actions = crate::components::source_panel::SourceSearch::push_search_char(
                    &mut self.state.source_panel,
                    ch,
                );
                additional_actions.extend(actions);
            }
            Action::SourceSearchBackspace => {
                let actions = crate::components::source_panel::SourceSearch::backspace_search(
                    &mut self.state.source_panel,
                );
                additional_actions.extend(actions);
            }
            Action::SourceSearchConfirm => {
                let actions = crate::components::source_panel::SourceSearch::confirm_search(
                    &mut self.state.source_panel,
                );
                additional_actions.extend(actions);
            }
            Action::SourceFileSearchInput(ch) => {
                if let Some(ref cache) = self.state.command_panel.file_completion_cache {
                    let actions =
                        crate::components::source_panel::SourceSearch::push_file_search_char(
                            &mut self.state.source_panel,
                            cache,
                            ch,
                        );
                    additional_actions.extend(actions);
                }
            }
            Action::SourceFileSearchBackspace => {
                if let Some(ref cache) = self.state.command_panel.file_completion_cache {
                    let actions =
                        crate::components::source_panel::SourceSearch::backspace_file_search(
                            &mut self.state.source_panel,
                            cache,
                        );
                    additional_actions.extend(actions);
                }
            }
            Action::SourceFileSearchConfirm => {
                if let Some(ref cache) = self.state.command_panel.file_completion_cache {
                    if let Some(selected_file) =
                        crate::components::source_panel::SourceSearch::confirm_file_search(
                            &mut self.state.source_panel,
                            cache,
                        )
                    {
                        // Load the selected file
                        additional_actions.push(Action::LoadSource {
                            path: selected_file,
                            line: None,
                        });
                    }
                }
            }
            Action::SourceNumberInput(ch) => {
                let actions =
                    crate::components::source_panel::SourceNavigation::handle_number_input(
                        &mut self.state.source_panel,
                        ch,
                    );
                additional_actions.extend(actions);
            }
            Action::SourceGoToLine => {
                let actions = crate::components::source_panel::SourceNavigation::handle_g_key(
                    &mut self.state.source_panel,
                );
                additional_actions.extend(actions);
            }
            Action::SourceGoToBottom => {
                let actions = crate::components::source_panel::SourceNavigation::handle_shift_g_key(
                    &mut self.state.source_panel,
                );
                additional_actions.extend(actions);
            }
            Action::SetTraceFromSourceLine => {
                // Get current file and line from source panel
                if let Some(file_path) = &self.state.source_panel.file_path {
                    let line_num = self.state.source_panel.cursor_line + 1; // Convert to 1-based

                    // Don't mark line as pending here - wait for trace response

                    // Build the trace command
                    let trace_command = format!("trace {file_path}:{line_num}");

                    // Focus command panel (keep fullscreen state if enabled)
                    self.state.ui.focus.current_panel = PanelType::InteractiveCommand;

                    // Add command to history (unified method)
                    self.state.command_panel.add_command_entry(&trace_command);

                    // Clear input
                    self.state.command_panel.input_text.clear();
                    self.state.command_panel.cursor_position = 0;

                    // Enter script mode directly
                    additional_actions.push(Action::EnterScriptMode(trace_command));
                }
            }
            Action::SaveEbpfOutput { filename } => {
                // Start realtime eBPF output logging
                let (content, response_type, style_preset) =
                    match self.start_realtime_output_logging(filename) {
                        Ok(file_path) => (
                            format!(
                                "✅ Realtime eBPF output logging started: {}",
                                file_path.display()
                            ),
                            crate::action::ResponseType::Success,
                            crate::components::command_panel::style_builder::StylePresets::SUCCESS,
                        ),
                        Err(e) => (
                            format!("✗ Failed to start output logging: {e}"),
                            crate::action::ResponseType::Error,
                            crate::components::command_panel::style_builder::StylePresets::ERROR,
                        ),
                    };

                // Directly add response to command history
                crate::components::command_panel::ResponseFormatter::add_simple_styled_response(
                    &mut self.state.command_panel,
                    content,
                    style_preset,
                    response_type,
                );
                self.state.command_renderer.mark_pending_updates();
            }
            Action::SaveCommandSession { filename } => {
                // Start realtime command session logging
                let (content, response_type, style_preset) =
                    match self.start_realtime_session_logging(filename) {
                        Ok(file_path) => (
                            format!(
                                "✅ Realtime session logging started: {}",
                                file_path.display()
                            ),
                            crate::action::ResponseType::Success,
                            crate::components::command_panel::style_builder::StylePresets::SUCCESS,
                        ),
                        Err(e) => (
                            format!("✗ Failed to start session logging: {e}"),
                            crate::action::ResponseType::Error,
                            crate::components::command_panel::style_builder::StylePresets::ERROR,
                        ),
                    };

                // Directly add response to command history
                crate::components::command_panel::ResponseFormatter::add_simple_styled_response(
                    &mut self.state.command_panel,
                    content,
                    style_preset,
                    response_type,
                );
                self.state.command_renderer.mark_pending_updates();
            }
            Action::StopSaveOutput => {
                // Stop realtime eBPF output logging
                let (content, response_type, style_preset) =
                    match self.state.realtime_output_logger.stop() {
                        Ok(()) => (
                            "✅ Realtime eBPF output logging stopped".to_string(),
                            crate::action::ResponseType::Success,
                            crate::components::command_panel::style_builder::StylePresets::SUCCESS,
                        ),
                        Err(e) => (
                            format!("✗ Failed to stop output logging: {e}"),
                            crate::action::ResponseType::Error,
                            crate::components::command_panel::style_builder::StylePresets::ERROR,
                        ),
                    };

                // Directly add response to command history
                crate::components::command_panel::ResponseFormatter::add_simple_styled_response(
                    &mut self.state.command_panel,
                    content,
                    style_preset,
                    response_type,
                );
                self.state.command_renderer.mark_pending_updates();
            }
            Action::StopSaveSession => {
                // Stop realtime command session logging
                let (content, response_type, style_preset) =
                    match self.state.realtime_session_logger.stop() {
                        Ok(()) => (
                            "✅ Realtime session logging stopped".to_string(),
                            crate::action::ResponseType::Success,
                            crate::components::command_panel::style_builder::StylePresets::SUCCESS,
                        ),
                        Err(e) => (
                            format!("✗ Failed to stop session logging: {e}"),
                            crate::action::ResponseType::Error,
                            crate::components::command_panel::style_builder::StylePresets::ERROR,
                        ),
                    };

                // Directly add response to command history
                crate::components::command_panel::ResponseFormatter::add_simple_styled_response(
                    &mut self.state.command_panel,
                    content,
                    style_preset,
                    response_type,
                );
                self.state.command_renderer.mark_pending_updates();
            }
            Action::NoOp => {
                // No operation - does nothing but prevents event fallback
            }
            _ => {
                debug!("Action not yet implemented: {:?}", action);
            }
        }

        Ok(additional_actions)
    }
}