detached 8008fca

docs(refactoring): add TODO comments for high-complexity functions

Add TODO(#8) comments to document technical debt in 4 functions
that exceed cyclomatic complexity thresholds:

- splitNode (workspace_pane_ops.go) - complexity 65
- closePane (workspace_pane_ops.go) - complexity 31
- CloseStackedPane (stacked_panes.go) - complexity 49
- AttachKeyboardBridge (keyboard_bridge.go) - complexity 52

Issue #8 created to track future refactoring work.

Note: All critical error handling issues identified in PR review
were already fixed in earlier commits.
commit
8008fcad50fb523aff3304ccf7a93c290cccab76
author
bnema · · 2025-10-24 17:51 UTC
parent
f19dc07
signature
GPG Unverified2B82207D370127A0 The key is unknown
3 files · +8 -0
M internal/app/browser/stacked_panes.go +2 -0
@@ -714,6 +714,8 @@ func (spm *StackedPaneManager) createTitleBarWithTitle(title string, pageURL str
714714 return titleBox
715715 }
716716
717+// TODO(#8): Refactor this function to reduce cyclomatic complexity (49 -> <30)
718+//
717719 // CloseStackedPane handles closing a pane that is part of a stack.
718720 // The logic mirrors the regular close path: we rebuild the tree, update focus,
719721 // and let WorkspaceManager perform the actual cleanup/destroy work so that all
@@ -714,6 +714,8 @@ func (spm *StackedPaneManager) createTitleBarWithTitle(title string, pageURL str
714 return titleBox714 return titleBox
715 }715 }
716 716
717+// TODO(#8): Refactor this function to reduce cyclomatic complexity (49 -> <30)
718+//
717 // CloseStackedPane handles closing a pane that is part of a stack.719 // CloseStackedPane handles closing a pane that is part of a stack.
718 // The logic mirrors the regular close path: we rebuild the tree, update focus,720 // The logic mirrors the regular close path: we rebuild the tree, update focus,
719 // and let WorkspaceManager perform the actual cleanup/destroy work so that all721 // and let WorkspaceManager perform the actual cleanup/destroy work so that all
M internal/app/browser/workspace_pane_ops.go +4 -0
@@ -299,6 +299,8 @@ func (wm *WorkspaceManager) removeFromAppPanes(pane *BrowserPane) {
299299 // This eliminates widget reparenting of existing WebViews, which was causing rendering corruption.
300300 // See splitNode() for the unified implementation.
301301
302+// TODO(#8): Refactor this function to reduce cyclomatic complexity (65 -> <30)
303+//
302304 // splitNode splits a target pane into two panes in the specified direction
303305 // splitNode splits a target pane into two panes in the specified direction.
304306 // If existingPane is provided, it will be used instead of creating a new WebView.
@@ -922,6 +924,8 @@ func (wm *WorkspaceManager) setFocusToLeaf(node *paneNode) {
922924 }
923925 }
924926
927+// TODO(#8): Refactor this function to reduce cyclomatic complexity (31 -> <30)
928+//
925929 // closePane closes a specific pane and handles tree restructuring (simplified implementation)
926930 func (wm *WorkspaceManager) closePane(node *paneNode) (*paneNode, error) {
927931 ctx := wm.beginClose(node)
@@ -299,6 +299,8 @@ func (wm *WorkspaceManager) removeFromAppPanes(pane *BrowserPane) {
299 // This eliminates widget reparenting of existing WebViews, which was causing rendering corruption.299 // This eliminates widget reparenting of existing WebViews, which was causing rendering corruption.
300 // See splitNode() for the unified implementation.300 // See splitNode() for the unified implementation.
301 301
302+// TODO(#8): Refactor this function to reduce cyclomatic complexity (65 -> <30)
303+//
302 // splitNode splits a target pane into two panes in the specified direction304 // splitNode splits a target pane into two panes in the specified direction
303 // splitNode splits a target pane into two panes in the specified direction.305 // splitNode splits a target pane into two panes in the specified direction.
304 // If existingPane is provided, it will be used instead of creating a new WebView.306 // If existingPane is provided, it will be used instead of creating a new WebView.
@@ -922,6 +924,8 @@ func (wm *WorkspaceManager) setFocusToLeaf(node *paneNode) {
922 }924 }
923 }925 }
924 926
927+// TODO(#8): Refactor this function to reduce cyclomatic complexity (31 -> <30)
928+//
925 // closePane closes a specific pane and handles tree restructuring (simplified implementation)929 // closePane closes a specific pane and handles tree restructuring (simplified implementation)
926 func (wm *WorkspaceManager) closePane(node *paneNode) (*paneNode, error) {930 func (wm *WorkspaceManager) closePane(node *paneNode) (*paneNode, error) {
927 ctx := wm.beginClose(node)931 ctx := wm.beginClose(node)
M pkg/webkit/keyboard_bridge.go +2 -0
@@ -94,6 +94,8 @@ var shortcutActions = map[string]string{
9494 altmod + "+" + keyArrowUp: directionUp,
9595 }
9696
97+// TODO(#8): Refactor this function to reduce cyclomatic complexity (52 -> <30)
98+//
9799 // AttachKeyboardBridge attaches an EventControllerKey to bridge keyboard events to JavaScript
98100 // This is critical for allowing JavaScript KeyboardService to receive keyboard events
99101 // that would otherwise be consumed by GTK shortcuts
@@ -94,6 +94,8 @@ var shortcutActions = map[string]string{
94 altmod + "+" + keyArrowUp: directionUp,94 altmod + "+" + keyArrowUp: directionUp,
95 }95 }
96 96
97+// TODO(#8): Refactor this function to reduce cyclomatic complexity (52 -> <30)
98+//
97 // AttachKeyboardBridge attaches an EventControllerKey to bridge keyboard events to JavaScript99 // AttachKeyboardBridge attaches an EventControllerKey to bridge keyboard events to JavaScript
98 // This is critical for allowing JavaScript KeyboardService to receive keyboard events100 // This is critical for allowing JavaScript KeyboardService to receive keyboard events
99 // that would otherwise be consumed by GTK shortcuts101 // that would otherwise be consumed by GTK shortcuts

Keyboard shortcuts

Single-key shortcuts are on. ctrl k and esc work whatever this says.

ctrl k :
go to a section, branch, tag, file or repository
?
this list
j k
move the row cursor down / up
enter
open the row under the cursor; on Files, a directory opens or closes in place
↑ ↓ ← → home end
in the file tree (focus on a row): previous / next row, close / open a directory or go to its parent / first entry, first / last row. They never open a file
l h
on Files: open a directory or a file / close a directory or go up to its parent, then to the parent page. Elsewhere: into the side panel (on a merge request, its files) / back to the content; there j k move between its controls
g g G
first / last row
/
filter the list; on Files, find a file anywhere in the repository (esc clears, enter opens the best match)
b
switch branch or tag
g s g f g c g b g m g i g r g a
tabs: summary, files, commits, branches & tags, merge requests, issues, releases, actions (when available)
g h
home
w
wide mode: use the whole width of the screen, or not (remembered)
y
copy a permalink pinned to the commit
d u x
diff: split / unified / collapse or expand all
e E
diff: the whole file in view / every file, with the lines the hunks hide
n
merge request: next note in the diff
esc
close a dialog, leave a field

Branches 8

Tags 42

↑↓ moveenter openesc close