detached 5017596

refactor(omnibox): trim resize debug overhead

Remove temporary widget-state logging from the omnibox resize path and simplify the result-container state helper. Also sanitize spawned session environments so layer-shell preload does not leak into restored browser windows.
commit
5017596a3ae05f413ec9bde63081b47d4a966f5e
author
brice · · 2026-04-06 18:19 UTC
parent
ee4a1fb
signature
GPG VerifiedCD88F9E564E0102646FB6077A1A07C7C7C3E349D · arch-gpg Verified for the committer email
3 files · +18 -93
M internal/infrastructure/desktop/adapter.go +4 -4
@@ -479,9 +479,9 @@ func (s *SessionSpawner) SpawnWithSession(sessionID entity.SessionID) error {
479479 cmd := exec.Command(execPath, "browse")
480480
481481 // Inherit environment and add restore session ID
482- cmd.Env = append(os.Environ(), RestoreSessionEnvVar+"="+string(sessionID))
482+ cmd.Env = append(sanitizedChildEnv(os.Environ()), RestoreSessionEnvVar+"="+string(sessionID))
483483
484- // Detach from current process group so the new process survives
484+ // Detach from current process group so the new process survives.
485485 cmd.Stdin = nil
486486 cmd.Stdout = nil
487487 cmd.Stderr = nil
@@ -490,10 +490,10 @@ func (s *SessionSpawner) SpawnWithSession(sessionID entity.SessionID) error {
490490 return fmt.Errorf("spawn session: %w", err)
491491 }
492492
493- // Capture PID before releasing
493+ // Capture PID before releasing.
494494 pid := cmd.Process.Pid
495495
496- // Release the process so it continues running after we close
496+ // Release the process so it continues running after we close.
497497 if err := cmd.Process.Release(); err != nil {
498498 log.Warn().Err(err).Msg("failed to release spawned process (non-fatal)")
499499 }
@@ -479,9 +479,9 @@ func (s *SessionSpawner) SpawnWithSession(sessionID entity.SessionID) error {
479 cmd := exec.Command(execPath, "browse")479 cmd := exec.Command(execPath, "browse")
480 480
481 // Inherit environment and add restore session ID481 // Inherit environment and add restore session ID
482- cmd.Env = append(os.Environ(), RestoreSessionEnvVar+"="+string(sessionID))482+ cmd.Env = append(sanitizedChildEnv(os.Environ()), RestoreSessionEnvVar+"="+string(sessionID))
483 483
484- // Detach from current process group so the new process survives484+ // Detach from current process group so the new process survives.
485 cmd.Stdin = nil485 cmd.Stdin = nil
486 cmd.Stdout = nil486 cmd.Stdout = nil
487 cmd.Stderr = nil487 cmd.Stderr = nil
@@ -490,10 +490,10 @@ func (s *SessionSpawner) SpawnWithSession(sessionID entity.SessionID) error {
490 return fmt.Errorf("spawn session: %w", err)490 return fmt.Errorf("spawn session: %w", err)
491 }491 }
492 492
493- // Capture PID before releasing493+ // Capture PID before releasing.
494 pid := cmd.Process.Pid494 pid := cmd.Process.Pid
495 495
496- // Release the process so it continues running after we close496+ // Release the process so it continues running after we close.
497 if err := cmd.Process.Release(); err != nil {497 if err := cmd.Process.Release(); err != nil {
498 log.Warn().Err(err).Msg("failed to release spawned process (non-fatal)")498 log.Warn().Err(err).Msg("failed to release spawned process (non-fatal)")
499 }499 }
M internal/ui/component/omnibox.go +4 -76
@@ -322,85 +322,25 @@ func (o *Omnibox) estimateRowHeight() int {
322322 return ScaleValue(DefaultRowHeights.Standard, o.uiScale)
323323 }
324324
325-func resultsContainerState(rowCount int) (visible bool, expand bool, listVisible bool, emptyBackdrop bool) {
326- return rowCount > 0, rowCount > 0, rowCount > 0, false
325+func resultsContainerState(rowCount int) (visible bool, expand bool, listVisible bool) {
326+ return rowCount > 0, rowCount > 0, rowCount > 0
327327 }
328328
329329 func (o *Omnibox) setResultsContainerState(rowCount int) {
330330 if o.scrolledWin == nil {
331331 return
332332 }
333- visible, expand, listVisible, emptyBackdrop := resultsContainerState(rowCount)
333+ visible, expand, listVisible := resultsContainerState(rowCount)
334334 o.scrolledWin.SetVisible(visible)
335335 o.scrolledWin.SetVexpand(expand)
336336 if o.listBox != nil {
337337 o.listBox.SetVisible(listVisible)
338338 }
339- if o.mainBox != nil && !emptyBackdrop {
339+ if o.mainBox != nil {
340340 o.mainBox.RemoveCssClass("omnibox-empty")
341341 }
342342 }
343343
344-func logOmniboxWidgetState(ctx context.Context, overlay layout.OverlayWidget, outerBox, mainBox *gtk.Box, scrolledWin *gtk.ScrolledWindow, listBox *gtk.ListBox) {
345- log := logging.FromContext(ctx)
346- var overlayWidth, overlayHeight int
347- if overlay != nil {
348- overlayWidth = overlay.GetAllocatedWidth()
349- overlayHeight = overlay.GetAllocatedHeight()
350- }
351-
352- var outerVisible bool
353- var outerWidth, outerHeight int
354- if outerBox != nil {
355- outerVisible = outerBox.GetVisible()
356- outerWidth = outerBox.GetAllocatedWidth()
357- outerHeight = outerBox.GetAllocatedHeight()
358- }
359-
360- var mainVisible bool
361- var mainWidth, mainHeight int
362- if mainBox != nil {
363- mainVisible = mainBox.GetVisible()
364- mainWidth = mainBox.GetAllocatedWidth()
365- mainHeight = mainBox.GetAllocatedHeight()
366- }
367-
368- var scrolledVisible, scrolledExpand bool
369- var scrolledWidth, scrolledHeight int
370- if scrolledWin != nil {
371- scrolledVisible = scrolledWin.GetVisible()
372- scrolledExpand = scrolledWin.GetVexpand()
373- scrolledWidth = scrolledWin.GetAllocatedWidth()
374- scrolledHeight = scrolledWin.GetAllocatedHeight()
375- }
376-
377- var listVisible bool
378- var listWidth, listHeight int
379- if listBox != nil {
380- listVisible = listBox.GetVisible()
381- listWidth = listBox.GetAllocatedWidth()
382- listHeight = listBox.GetAllocatedHeight()
383- }
384-
385- log.Debug().
386- Int("overlayWidth", overlayWidth).
387- Int("overlayHeight", overlayHeight).
388- Bool("outerVisible", outerVisible).
389- Int("outerWidth", outerWidth).
390- Int("outerHeight", outerHeight).
391- Bool("mainVisible", mainVisible).
392- Int("mainWidth", mainWidth).
393- Int("mainHeight", mainHeight).
394- Bool("scrolledVisible", scrolledVisible).
395- Bool("scrolledExpand", scrolledExpand).
396- Int("scrolledWidth", scrolledWidth).
397- Int("scrolledHeight", scrolledHeight).
398- Bool("listVisible", listVisible).
399- Int("listWidth", listWidth).
400- Int("listHeight", listHeight).
401- Msg("omnibox widget state")
402-}
403-
404344 // effectiveMaxRows returns the max visible rows adapted to the current parent pane height.
405345 // Must be called on the GTK main thread.
406346 func (o *Omnibox) effectiveMaxRows() int {
@@ -474,14 +414,8 @@ func (o *Omnibox) measureAndResize(width, rowCount int) {
474414 if parent := o.parentOverlay; parent != nil {
475415 if widget := parent.GtkWidget(); widget != nil {
476416 widget.QueueResize()
477- if parentWidget := widget.GetParent(); parentWidget != nil {
478- parentWidget.QueueResize()
479- }
480417 }
481418 }
482- if o.listBox != nil {
483- o.listBox.QueueResize()
484- }
485419 if o.scrolledWin != nil {
486420 o.scrolledWin.QueueResize()
487421 }
@@ -494,12 +428,6 @@ func (o *Omnibox) measureAndResize(width, rowCount int) {
494428 Int("rows", rowCount).
495429 Bool("measured", o.measuredHeights.valid).
496430 Msg("omnibox resized")
497-
498- var cb glib.SourceFunc = func(uintptr) bool {
499- logOmniboxWidgetState(o.ctx, o.parentOverlay, o.outerBox, o.mainBox, o.scrolledWin, o.listBox)
500- return false
501- }
502- glib.IdleAdd(&cb, 0)
503431 }
504432
505433 // createWidgets builds the GTK widget hierarchy.
@@ -322,85 +322,25 @@ func (o *Omnibox) estimateRowHeight() int {
322 return ScaleValue(DefaultRowHeights.Standard, o.uiScale)322 return ScaleValue(DefaultRowHeights.Standard, o.uiScale)
323 }323 }
324 324
325-func resultsContainerState(rowCount int) (visible bool, expand bool, listVisible bool, emptyBackdrop bool) {325+func resultsContainerState(rowCount int) (visible bool, expand bool, listVisible bool) {
326- return rowCount > 0, rowCount > 0, rowCount > 0, false326+ return rowCount > 0, rowCount > 0, rowCount > 0
327 }327 }
328 328
329 func (o *Omnibox) setResultsContainerState(rowCount int) {329 func (o *Omnibox) setResultsContainerState(rowCount int) {
330 if o.scrolledWin == nil {330 if o.scrolledWin == nil {
331 return331 return
332 }332 }
333- visible, expand, listVisible, emptyBackdrop := resultsContainerState(rowCount)333+ visible, expand, listVisible := resultsContainerState(rowCount)
334 o.scrolledWin.SetVisible(visible)334 o.scrolledWin.SetVisible(visible)
335 o.scrolledWin.SetVexpand(expand)335 o.scrolledWin.SetVexpand(expand)
336 if o.listBox != nil {336 if o.listBox != nil {
337 o.listBox.SetVisible(listVisible)337 o.listBox.SetVisible(listVisible)
338 }338 }
339- if o.mainBox != nil && !emptyBackdrop {339+ if o.mainBox != nil {
340 o.mainBox.RemoveCssClass("omnibox-empty")340 o.mainBox.RemoveCssClass("omnibox-empty")
341 }341 }
342 }342 }
343 343
344-func logOmniboxWidgetState(ctx context.Context, overlay layout.OverlayWidget, outerBox, mainBox *gtk.Box, scrolledWin *gtk.ScrolledWindow, listBox *gtk.ListBox) {
345- log := logging.FromContext(ctx)
346- var overlayWidth, overlayHeight int
347- if overlay != nil {
348- overlayWidth = overlay.GetAllocatedWidth()
349- overlayHeight = overlay.GetAllocatedHeight()
350- }
351-
352- var outerVisible bool
353- var outerWidth, outerHeight int
354- if outerBox != nil {
355- outerVisible = outerBox.GetVisible()
356- outerWidth = outerBox.GetAllocatedWidth()
357- outerHeight = outerBox.GetAllocatedHeight()
358- }
359-
360- var mainVisible bool
361- var mainWidth, mainHeight int
362- if mainBox != nil {
363- mainVisible = mainBox.GetVisible()
364- mainWidth = mainBox.GetAllocatedWidth()
365- mainHeight = mainBox.GetAllocatedHeight()
366- }
367-
368- var scrolledVisible, scrolledExpand bool
369- var scrolledWidth, scrolledHeight int
370- if scrolledWin != nil {
371- scrolledVisible = scrolledWin.GetVisible()
372- scrolledExpand = scrolledWin.GetVexpand()
373- scrolledWidth = scrolledWin.GetAllocatedWidth()
374- scrolledHeight = scrolledWin.GetAllocatedHeight()
375- }
376-
377- var listVisible bool
378- var listWidth, listHeight int
379- if listBox != nil {
380- listVisible = listBox.GetVisible()
381- listWidth = listBox.GetAllocatedWidth()
382- listHeight = listBox.GetAllocatedHeight()
383- }
384-
385- log.Debug().
386- Int("overlayWidth", overlayWidth).
387- Int("overlayHeight", overlayHeight).
388- Bool("outerVisible", outerVisible).
389- Int("outerWidth", outerWidth).
390- Int("outerHeight", outerHeight).
391- Bool("mainVisible", mainVisible).
392- Int("mainWidth", mainWidth).
393- Int("mainHeight", mainHeight).
394- Bool("scrolledVisible", scrolledVisible).
395- Bool("scrolledExpand", scrolledExpand).
396- Int("scrolledWidth", scrolledWidth).
397- Int("scrolledHeight", scrolledHeight).
398- Bool("listVisible", listVisible).
399- Int("listWidth", listWidth).
400- Int("listHeight", listHeight).
401- Msg("omnibox widget state")
402-}
403-
404 // effectiveMaxRows returns the max visible rows adapted to the current parent pane height.344 // effectiveMaxRows returns the max visible rows adapted to the current parent pane height.
405 // Must be called on the GTK main thread.345 // Must be called on the GTK main thread.
406 func (o *Omnibox) effectiveMaxRows() int {346 func (o *Omnibox) effectiveMaxRows() int {
@@ -474,14 +414,8 @@ func (o *Omnibox) measureAndResize(width, rowCount int) {
474 if parent := o.parentOverlay; parent != nil {414 if parent := o.parentOverlay; parent != nil {
475 if widget := parent.GtkWidget(); widget != nil {415 if widget := parent.GtkWidget(); widget != nil {
476 widget.QueueResize()416 widget.QueueResize()
477- if parentWidget := widget.GetParent(); parentWidget != nil {
478- parentWidget.QueueResize()
479- }
480 }417 }
481 }418 }
482- if o.listBox != nil {
483- o.listBox.QueueResize()
484- }
485 if o.scrolledWin != nil {419 if o.scrolledWin != nil {
486 o.scrolledWin.QueueResize()420 o.scrolledWin.QueueResize()
487 }421 }
@@ -494,12 +428,6 @@ func (o *Omnibox) measureAndResize(width, rowCount int) {
494 Int("rows", rowCount).428 Int("rows", rowCount).
495 Bool("measured", o.measuredHeights.valid).429 Bool("measured", o.measuredHeights.valid).
496 Msg("omnibox resized")430 Msg("omnibox resized")
497-
498- var cb glib.SourceFunc = func(uintptr) bool {
499- logOmniboxWidgetState(o.ctx, o.parentOverlay, o.outerBox, o.mainBox, o.scrolledWin, o.listBox)
500- return false
501- }
502- glib.IdleAdd(&cb, 0)
503 }431 }
504 432
505 // createWidgets builds the GTK widget hierarchy.433 // createWidgets builds the GTK widget hierarchy.
M internal/ui/component/omnibox_navigation_state_test.go +10 -13
@@ -89,32 +89,29 @@ func TestEffectiveSearchQuery(t *testing.T) {
8989
9090 func TestResultsContainerState(t *testing.T) {
9191 tests := []struct {
92- name string
93- rowCount int
94- wantVisible bool
95- wantExpand bool
96- wantListVisible bool
97- wantEmptyBackdrop bool
92+ name string
93+ rowCount int
94+ wantVisible bool
95+ wantExpand bool
96+ wantListVisible bool
9897 }{
99- {name: "no rows stays hidden without empty backdrop", rowCount: 0, wantVisible: false, wantExpand: false, wantListVisible: false, wantEmptyBackdrop: false},
100- {name: "rows show and expand", rowCount: 3, wantVisible: true, wantExpand: true, wantListVisible: true, wantEmptyBackdrop: false},
98+ {name: "no rows stays hidden", rowCount: 0, wantVisible: false, wantExpand: false, wantListVisible: false},
99+ {name: "rows show and expand", rowCount: 3, wantVisible: true, wantExpand: true, wantListVisible: true},
101100 }
102101
103102 for _, tt := range tests {
104103 t.Run(tt.name, func(t *testing.T) {
105- gotVisible, gotExpand, gotListVisible, gotEmptyBackdrop := resultsContainerState(tt.rowCount)
106- if gotVisible != tt.wantVisible || gotExpand != tt.wantExpand || gotListVisible != tt.wantListVisible || gotEmptyBackdrop != tt.wantEmptyBackdrop {
104+ gotVisible, gotExpand, gotListVisible := resultsContainerState(tt.rowCount)
105+ if gotVisible != tt.wantVisible || gotExpand != tt.wantExpand || gotListVisible != tt.wantListVisible {
107106 t.Fatalf(
108- "resultsContainerState(%d) = (%v, %v, %v, %v), want (%v, %v, %v, %v)",
107+ "resultsContainerState(%d) = (%v, %v, %v), want (%v, %v, %v)",
109108 tt.rowCount,
110109 gotVisible,
111110 gotExpand,
112111 gotListVisible,
113- gotEmptyBackdrop,
114112 tt.wantVisible,
115113 tt.wantExpand,
116114 tt.wantListVisible,
117- tt.wantEmptyBackdrop,
118115 )
119116 }
120117 })
@@ -89,32 +89,29 @@ func TestEffectiveSearchQuery(t *testing.T) {
89 89
90 func TestResultsContainerState(t *testing.T) {90 func TestResultsContainerState(t *testing.T) {
91 tests := []struct {91 tests := []struct {
92- name string92+ name string
93- rowCount int93+ rowCount int
94- wantVisible bool94+ wantVisible bool
95- wantExpand bool95+ wantExpand bool
96- wantListVisible bool96+ wantListVisible bool
97- wantEmptyBackdrop bool
98 }{97 }{
99- {name: "no rows stays hidden without empty backdrop", rowCount: 0, wantVisible: false, wantExpand: false, wantListVisible: false, wantEmptyBackdrop: false},98+ {name: "no rows stays hidden", rowCount: 0, wantVisible: false, wantExpand: false, wantListVisible: false},
100- {name: "rows show and expand", rowCount: 3, wantVisible: true, wantExpand: true, wantListVisible: true, wantEmptyBackdrop: false},99+ {name: "rows show and expand", rowCount: 3, wantVisible: true, wantExpand: true, wantListVisible: true},
101 }100 }
102 101
103 for _, tt := range tests {102 for _, tt := range tests {
104 t.Run(tt.name, func(t *testing.T) {103 t.Run(tt.name, func(t *testing.T) {
105- gotVisible, gotExpand, gotListVisible, gotEmptyBackdrop := resultsContainerState(tt.rowCount)104+ gotVisible, gotExpand, gotListVisible := resultsContainerState(tt.rowCount)
106- if gotVisible != tt.wantVisible || gotExpand != tt.wantExpand || gotListVisible != tt.wantListVisible || gotEmptyBackdrop != tt.wantEmptyBackdrop {105+ if gotVisible != tt.wantVisible || gotExpand != tt.wantExpand || gotListVisible != tt.wantListVisible {
107 t.Fatalf(106 t.Fatalf(
108- "resultsContainerState(%d) = (%v, %v, %v, %v), want (%v, %v, %v, %v)",107+ "resultsContainerState(%d) = (%v, %v, %v), want (%v, %v, %v)",
109 tt.rowCount,108 tt.rowCount,
110 gotVisible,109 gotVisible,
111 gotExpand,110 gotExpand,
112 gotListVisible,111 gotListVisible,
113- gotEmptyBackdrop,
114 tt.wantVisible,112 tt.wantVisible,
115 tt.wantExpand,113 tt.wantExpand,
116 tt.wantListVisible,114 tt.wantListVisible,
117- tt.wantEmptyBackdrop,
118 )115 )
119 }116 }
120 })117 })

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