From b889b5403d4c9db0be24a91f8980246948161a7b Mon Sep 17 00:00:00 2001 From: Jeremie Fraeys Date: Wed, 18 Feb 2026 14:45:44 -0500 Subject: [PATCH] docs: clean up verbose comments in TUI main.go --- cmd/tui/main.go | 29 +++-------------------------- 1 file changed, 3 insertions(+), 26 deletions(-) diff --git a/cmd/tui/main.go b/cmd/tui/main.go index 1bf901a..b6fb2ad 100644 --- a/cmd/tui/main.go +++ b/cmd/tui/main.go @@ -149,22 +149,8 @@ func main() { } }() - // Initialize logger - // Note: In original code, logger was created inside initialModel. - // Here we create it and pass it to controller. - // We use slog.LevelError as default from original code. - // But original code imported "log/slog". - // We use internal/logging package. - // Check logging package signature. - // Original: logger := logging.NewLogger(slog.LevelError, false) - // We need to import "log/slog" in main if we use slog constants. - // Or use logging package constants if available. - // Let's check logging package. - // Assuming logging.NewLogger takes (slog.Level, bool). - // I'll import "log/slog". - - // Wait, I need to import "log/slog" - logger := logging.NewLogger(-4, false) // -4 is slog.LevelError value. Or I can import log/slog. + // Initialize logger with error level and no debug output + logger := logging.NewLogger(-4, false) // -4 = slog.LevelError // Initialize State and Controller var effectiveAPIKey string @@ -182,32 +168,23 @@ func main() { controller: ctrl, } - // Run TUI app + // Run TUI program with graceful shutdown on SIGINT/SIGTERM p := tea.NewProgram(appModel, tea.WithAltScreen(), tea.WithMouseAllMotion()) - // Ensure we restore the terminal even if panic or error occurs - // Note: p.Run() usually handles this, but explicit cleanup is safer - // if we want to ensure the alt screen is exited. - // We can't defer p.ReleaseTerminal() here because p is created here. - // But we can defer a function that calls it. - // Set up signal handling for graceful shutdown sigChan := make(chan os.Signal, 1) signal.Notify(sigChan, syscall.SIGINT, syscall.SIGTERM) - // Run program and handle signals go func() { <-sigChan p.Quit() }() if _, err := p.Run(); err != nil { - // Attempt to restore terminal before logging error _ = p.ReleaseTerminal() log.Printf("Error running TUI: %v", err) return } - // Explicitly restore terminal after program exits _ = p.ReleaseTerminal() }