feat(sidebar): add resize debug logging#95
Conversation
📝 WalkthroughWalkthroughAdds an optional file-based resize debug logging capability to the sidebar resize hooks. A new ChangesResize Debug Logging via SidebarLoggerPort
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@internal/app/router.go`:
- Around line 461-469: The sidebarWithLogger function returns early when logger
is nil, preventing WithSidebarLogger(nil) from being called on mutable
SidebarLoggerPort implementations. This leaves previously attached loggers
active when debug is disabled. Move the nil logger check to after the type
assertion for ports.SidebarLoggerPort, so that WithSidebarLogger is always
invoked with the provided logger value (including nil) on implementations that
support it, ensuring previous logger state is properly cleared.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: ASSERTIVE
Plan: Pro
Run ID: becff809-290d-49f2-b006-d606f90b2110
📒 Files selected for processing (23)
.mockery.yamlinternal/adapters/tmuxcli/client.gointernal/adapters/tmuxcli/sidebar_rebalance.gointernal/adapters/tmuxcli/sidebar_rebalance_test.gointernal/app/router.gointernal/app/sidebar_layout_test.gointernal/ports/mocks/mock_daemon_launcher_port.gointernal/ports/mocks/mock_file_watcher_port.gointernal/ports/mocks/mock_filesystem_port.gointernal/ports/mocks/mock_git_port.gointernal/ports/mocks/mock_ipc_client_port.gointernal/ports/mocks/mock_ipc_handler.gointernal/ports/mocks/mock_ipc_server_port.gointernal/ports/mocks/mock_locker_port.gointernal/ports/mocks/mock_logger_port.gointernal/ports/mocks/mock_process_port.gointernal/ports/mocks/mock_query_port.gointernal/ports/mocks/mock_release_checker_port.gointernal/ports/mocks/mock_sidebar_logger_port.gointernal/ports/mocks/mock_sidebar_refresher_port.gointernal/ports/mocks/mock_state_store_port.gointernal/ports/mocks/mock_system_color_scheme_port.gointernal/ports/multiplexer.go
| func sidebarWithLogger(sidebar ports.SidebarPort, logger ports.LoggerPort) ports.SidebarPort { | ||
| if logger == nil { | ||
| return sidebar | ||
| } | ||
| width := strings.TrimSpace(widthOutput) | ||
| if width == "" { | ||
| width = "30" | ||
| withLogger, ok := sidebar.(ports.SidebarLoggerPort) | ||
| if !ok { | ||
| return sidebar | ||
| } | ||
| return withLogger.WithSidebarLogger(logger) |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
Clear logger state even when debug is disabled.
Line 462 short-circuits on logger == nil, so WithSidebarLogger(nil) is never called. For mutable SidebarLoggerPort implementations, this can leave a previously attached logger active after debug is turned off.
💡 Suggested fix
func sidebarWithLogger(sidebar ports.SidebarPort, logger ports.LoggerPort) ports.SidebarPort {
- if logger == nil {
- return sidebar
- }
withLogger, ok := sidebar.(ports.SidebarLoggerPort)
if !ok {
return sidebar
}
- return withLogger.WithSidebarLogger(logger)
+ logged := withLogger.WithSidebarLogger(logger)
+ if logged == nil {
+ return sidebar
+ }
+ return logged
}📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| func sidebarWithLogger(sidebar ports.SidebarPort, logger ports.LoggerPort) ports.SidebarPort { | |
| if logger == nil { | |
| return sidebar | |
| } | |
| width := strings.TrimSpace(widthOutput) | |
| if width == "" { | |
| width = "30" | |
| withLogger, ok := sidebar.(ports.SidebarLoggerPort) | |
| if !ok { | |
| return sidebar | |
| } | |
| return withLogger.WithSidebarLogger(logger) | |
| func sidebarWithLogger(sidebar ports.SidebarPort, logger ports.LoggerPort) ports.SidebarPort { | |
| withLogger, ok := sidebar.(ports.SidebarLoggerPort) | |
| if !ok { | |
| return sidebar | |
| } | |
| logged := withLogger.WithSidebarLogger(logger) | |
| if logged == nil { | |
| return sidebar | |
| } | |
| return logged | |
| } |
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@internal/app/router.go` around lines 461 - 469, The sidebarWithLogger
function returns early when logger is nil, preventing WithSidebarLogger(nil)
from being called on mutable SidebarLoggerPort implementations. This leaves
previously attached loggers active when debug is disabled. Move the nil logger
check to after the type assertion for ports.SidebarLoggerPort, so that
WithSidebarLogger is always invoked with the provided logger value (including
nil) on implementations that support it, ensuring previous logger state is
properly cleared.
Summary
Verification
Runtime check
Summary by CodeRabbit
Release Notes
New Features
Tests
Chores