feat(workspace): add cleanup generation tracking and debug infrastructure to core types
- commit
- e182a2ceeeea8d7b178409aad7481f47b48fdd9a
- author
- Brice · · 2025-09-30 05:15 UTC
- parent
- 197375c
- signature
- unsigned
2 files · +19 -0
M internal/app/browser/workspace_manager.go +15 -0
| @@ -65,6 +65,13 @@ type WorkspaceManager struct { | |||
| 65 | 65 | geometryValidator *GeometryValidator | |
| 66 | 66 | stackLifecycleManager *StackLifecycleManager | |
| 67 | 67 | stateTombstoneManager *StateTombstoneManager | |
| 68 | + | ||
| 69 | + | // Debug instrumentation helpers | |
| 70 | + | debugPaneClose bool | |
| 71 | + | diagnostics *WorkspaceDiagnostics | |
| 72 | + | ||
| 73 | + | // Enhanced pane close refactoring fields | |
| 74 | + | cleanupCounter uint | |
| 68 | 75 | } | |
| 69 | 76 | ||
| 70 | 77 | // Workspace navigation shortcuts are now handled globally by WindowShortcutHandler | |
| @@ -148,13 +155,21 @@ func NewWorkspaceManager(app *BrowserApp, rootPane *BrowserPane) *WorkspaceManag | |||
| 148 | 155 | false, // CSS debug removed | |
| 149 | 156 | app.config.Debug.EnableFocusMetrics, | |
| 150 | 157 | ) | |
| 158 | + | ||
| 159 | + | manager.debugPaneClose = app.config.Debug.EnablePaneCloseDebug | |
| 151 | 160 | } | |
| 152 | 161 | ||
| 162 | + | manager.diagnostics = NewWorkspaceDiagnostics(manager.debugPaneClose) | |
| 163 | + | ||
| 153 | 164 | // Initialize focus state machine after all setup is complete | |
| 154 | 165 | if err := manager.focusStateMachine.Initialize(); err != nil { | |
| 155 | 166 | log.Printf("[workspace] Failed to initialize focus state machine: %v", err) | |
| 156 | 167 | } | |
| 157 | 168 | ||
| 169 | + | if manager.debugPaneClose { | |
| 170 | + | manager.dumpTreeState("workspace_init") | |
| 171 | + | } | |
| 172 | + | ||
| 158 | 173 | return manager | |
| 159 | 174 | } | |
| 160 | 175 | ||
| @@ -65,6 +65,13 @@ type WorkspaceManager struct { | |||||
| 65 | geometryValidator *GeometryValidator | 65 | geometryValidator *GeometryValidator | ||
| 66 | stackLifecycleManager *StackLifecycleManager | 66 | stackLifecycleManager *StackLifecycleManager | ||
| 67 | stateTombstoneManager *StateTombstoneManager | 67 | stateTombstoneManager *StateTombstoneManager | ||
| 68 | + | ||||
| 69 | + | // Debug instrumentation helpers | |||
| 70 | + | debugPaneClose bool | |||
| 71 | + | diagnostics *WorkspaceDiagnostics | |||
| 72 | + | ||||
| 73 | + | // Enhanced pane close refactoring fields | |||
| 74 | + | cleanupCounter uint | |||
| 68 | } | 75 | } | ||
| 69 | 76 | ||||
| 70 | // Workspace navigation shortcuts are now handled globally by WindowShortcutHandler | 77 | // Workspace navigation shortcuts are now handled globally by WindowShortcutHandler | ||
| @@ -148,13 +155,21 @@ func NewWorkspaceManager(app *BrowserApp, rootPane *BrowserPane) *WorkspaceManag | |||||
| 148 | false, // CSS debug removed | 155 | false, // CSS debug removed | ||
| 149 | app.config.Debug.EnableFocusMetrics, | 156 | app.config.Debug.EnableFocusMetrics, | ||
| 150 | ) | 157 | ) | ||
| 158 | + | ||||
| 159 | + | manager.debugPaneClose = app.config.Debug.EnablePaneCloseDebug | |||
| 151 | } | 160 | } | ||
| 152 | 161 | ||||
| 162 | + | manager.diagnostics = NewWorkspaceDiagnostics(manager.debugPaneClose) | |||
| 163 | + | ||||
| 153 | // Initialize focus state machine after all setup is complete | 164 | // Initialize focus state machine after all setup is complete | ||
| 154 | if err := manager.focusStateMachine.Initialize(); err != nil { | 165 | if err := manager.focusStateMachine.Initialize(); err != nil { | ||
| 155 | log.Printf("[workspace] Failed to initialize focus state machine: %v", err) | 166 | log.Printf("[workspace] Failed to initialize focus state machine: %v", err) | ||
| 156 | } | 167 | } | ||
| 157 | 168 | ||||
| 169 | + | if manager.debugPaneClose { | |||
| 170 | + | manager.dumpTreeState("workspace_init") | |||
| 171 | + | } | |||
| 172 | + | ||||
| 158 | return manager | 173 | return manager | ||
| 159 | } | 174 | } | ||
| 160 | 175 | ||||
M internal/app/browser/workspace_types.go +4 -0
| @@ -37,6 +37,10 @@ type paneNode struct { | |||
| 37 | 37 | activeStackIndex int // Index of currently visible pane in stack | |
| 38 | 38 | titleBar *SafeWidget // GtkBox for title bar (when collapsed) | |
| 39 | 39 | stackWrapper *SafeWidget // Internal GtkBox containing the actual stacked widgets (titles + webviews) | |
| 40 | + | ||
| 41 | + | // Enhanced pane close refactoring fields | |
| 42 | + | widgetValid bool // Guard flagged before GTK destruction | |
| 43 | + | cleanupGeneration uint // Helps assert that asynchronous callbacks skip stale nodes | |
| 40 | 44 | } | |
| 41 | 45 | ||
| 42 | 46 | // Workspace CSS class constants | |
| @@ -37,6 +37,10 @@ type paneNode struct { | |||||
| 37 | activeStackIndex int // Index of currently visible pane in stack | 37 | activeStackIndex int // Index of currently visible pane in stack | ||
| 38 | titleBar *SafeWidget // GtkBox for title bar (when collapsed) | 38 | titleBar *SafeWidget // GtkBox for title bar (when collapsed) | ||
| 39 | stackWrapper *SafeWidget // Internal GtkBox containing the actual stacked widgets (titles + webviews) | 39 | stackWrapper *SafeWidget // Internal GtkBox containing the actual stacked widgets (titles + webviews) | ||
| 40 | + | ||||
| 41 | + | // Enhanced pane close refactoring fields | |||
| 42 | + | widgetValid bool // Guard flagged before GTK destruction | |||
| 43 | + | cleanupGeneration uint // Helps assert that asynchronous callbacks skip stale nodes | |||
| 40 | } | 44 | } | ||
| 41 | 45 | ||||
| 42 | // Workspace CSS class constants | 46 | // Workspace CSS class constants | ||