detached d0951c4

test(history): clean up sidebar test contexts

commit
d0951c471a10c0b1cf7d7d12d7058c14c4df4bf3
author
brice · · 2026-06-13 07:22 UTC
parent
5caec5d
signature
GPG VerifiedCD88F9E564E0102646FB6077A1A07C7C7C3E349D · arch-gpg Verified for the committer email
4 files · +29 -35
M internal/ui/browser_window_test.go +14 -14
@@ -911,7 +911,7 @@ func TestRestoreSession_ActiveWindowIndexSyncsState(t *testing.T) {
911911 // that the default OnNavigate callback targets the owning browser window's
912912 // active pane and keeps the sidebar visible.
913913 func TestHistorySidebarConfig_OnNavigateNavigatesActivePaneAndKeepsSidebar(t *testing.T) {
914- ctx := context.Background()
914+ ctx := t.Context()
915915
916916 // Build two browser windows with independent tabs and panes.
917917 tab1 := entity.NewTab(entity.TabID("tab-1"), entity.WorkspaceID("ws-1"), entity.NewPane(entity.PaneID("pane-1")))
@@ -973,7 +973,7 @@ func TestHistorySidebarConfig_OnNavigateNavigatesActivePaneAndKeepsSidebar(t *te
973973 // that the OnNavigateKeepOpen callback (Ctrl+Enter) navigates the owning window's
974974 // active pane and keeps the sidebar visible.
975975 func TestHistorySidebarConfig_OnNavigateKeepOpenNavigatesWithoutClosing(t *testing.T) {
976- ctx := context.Background()
976+ ctx := t.Context()
977977
978978 tab := entity.NewTab(entity.TabID("tab-1"), entity.WorkspaceID("ws-1"), entity.NewPane(entity.PaneID("pane-1")))
979979 bwTabs := entity.NewTabList()
@@ -1011,7 +1011,7 @@ func TestHistorySidebarConfig_OnNavigateKeepOpenNavigatesWithoutClosing(t *testi
10111011 // correct owning window's active pane. This tests the stale-focus scenario
10121012 // where a different window is globally focused.
10131013 func TestHistorySidebar_OwnershipOnMultiWindowNavigation(t *testing.T) {
1014- ctx := context.Background()
1014+ ctx := t.Context()
10151015
10161016 // Two windows, each with their own tab and pane.
10171017 tab1 := entity.NewTab(entity.TabID("tab-1"), entity.WorkspaceID("ws-1"), entity.NewPane(entity.PaneID("pane-1")))
@@ -1225,7 +1225,7 @@ func TestApp_HistorySidebarToggleHandler_NilFocusedWindowIsNoOp(t *testing.T) {
12251225 // TestHistorySidebarConfig_OnCloseHidesSidebar verifies that the OnClose
12261226 // callback hides the sidebar for the owning browser window.
12271227 func TestHistorySidebarConfig_OnCloseHidesSidebar(t *testing.T) {
1228- ctx := context.Background()
1228+ ctx := t.Context()
12291229 tab := entity.NewTab(entity.TabID("tab-1"), entity.WorkspaceID("ws-1"), entity.NewPane(entity.PaneID("pane-1")))
12301230 bwTabs := entity.NewTabList()
12311231 bwTabs.Add(tab)
@@ -1261,7 +1261,7 @@ func TestHistorySidebarConfig_OnCloseHidesSidebar(t *testing.T) {
12611261 // dispatches ActionToggleHistorySystemView, asserting the focused browser
12621262 // window's sidebar visibility toggles.
12631263 func TestApp_HistorySidebar_ToggleThroughKeyboardDispatcher(t *testing.T) {
1264- ctx := context.Background()
1264+ ctx := t.Context()
12651265
12661266 focusedBW := &browserWindow{
12671267 id: "focused",
@@ -1309,7 +1309,7 @@ func TestApp_HistorySidebar_ToggleThroughKeyboardDispatcher(t *testing.T) {
13091309 // TestApp_HistorySidebar_ToggleThroughDispatcher_UnavailableReturnsError verifies that
13101310 // when the focused window has no history sidebar, Ctrl+H returns a clean error.
13111311 func TestApp_HistorySidebar_ToggleThroughDispatcher_UnavailableReturnsError(t *testing.T) {
1312- ctx := context.Background()
1312+ ctx := t.Context()
13131313
13141314 bw := &browserWindow{
13151315 id: "no-sidebar",
@@ -1342,7 +1342,7 @@ func TestApp_HistorySidebar_ToggleThroughDispatcher_UnavailableReturnsError(t *t
13421342 // TestApp_HistorySidebar_ToggleThroughDispatcher_NilFocusedReturnsError verifies
13431343 // that the toggle handler returns a clean error when there is no focused window.
13441344 func TestApp_HistorySidebar_ToggleThroughDispatcher_NilFocusedReturnsError(t *testing.T) {
1345- ctx := context.Background()
1345+ ctx := t.Context()
13461346
13471347 app := &App{
13481348 browserWindows: make(map[string]*browserWindow),
@@ -1373,7 +1373,7 @@ func TestApp_HistorySidebar_ToggleThroughDispatcher_NilFocusedReturnsError(t *te
13731373 // callback from buildHistorySidebarConfig navigates the owning browser window's
13741374 // active pane to the given URL.
13751375 func TestApp_HistorySidebarConfig_NavigateCallbackNavigates(t *testing.T) {
1376- ctx := context.Background()
1376+ ctx := t.Context()
13771377
13781378 paneID := entity.PaneID("pane-1")
13791379 tab := entity.NewTab(entity.TabID("tab-1"), entity.WorkspaceID("ws-1"), entity.NewPane(paneID))
@@ -1421,7 +1421,7 @@ func TestApp_HistorySidebarConfig_NavigateCallbackNavigates(t *testing.T) {
14211421 }
14221422
14231423 func TestApp_NavigateHistorySidebarSelection_KeepsSidebarVisible(t *testing.T) {
1424- ctx := context.Background()
1424+ ctx := t.Context()
14251425
14261426 paneID := entity.PaneID("pane-1")
14271427 tab := entity.NewTab(entity.TabID("tab-1"), entity.WorkspaceID("ws-1"), entity.NewPane(paneID))
@@ -1464,7 +1464,7 @@ func TestApp_NavigateHistorySidebarSelection_KeepsSidebarVisible(t *testing.T) {
14641464 // OnNavigate targets the callback's owning window, not the globally focused
14651465 // window, when they differ.
14661466 func TestApp_HistorySidebarConfig_NavigateCallbackOwnership(t *testing.T) {
1467- ctx := context.Background()
1467+ ctx := t.Context()
14681468
14691469 tab1 := entity.NewTab(entity.TabID("tab-1"), entity.WorkspaceID("ws-1"), entity.NewPane(entity.PaneID("pane-1")))
14701470 tab2 := entity.NewTab(entity.TabID("tab-2"), entity.WorkspaceID("ws-2"), entity.NewPane(entity.PaneID("pane-2")))
@@ -1519,7 +1519,7 @@ func TestApp_HistorySidebarConfig_NavigateCallbackOwnership(t *testing.T) {
15191519 // TestApp_HistorySidebarConfig_KeepOpenCallback verifies that
15201520 // OnNavigateKeepOpen navigates the owning window without hiding the sidebar.
15211521 func TestApp_HistorySidebarConfig_KeepOpenCallback(t *testing.T) {
1522- ctx := context.Background()
1522+ ctx := t.Context()
15231523
15241524 paneID := entity.PaneID("pane-1")
15251525 tab := entity.NewTab(entity.TabID("tab-1"), entity.WorkspaceID("ws-1"), entity.NewPane(paneID))
@@ -1569,7 +1569,7 @@ func TestApp_HistorySidebarConfig_KeepOpenCallback(t *testing.T) {
15691569 // OnOpenInNewPane activates the owning browser window and creates a split
15701570 // with the target URL.
15711571 func TestApp_HistorySidebarConfig_OpenInNewPaneCallback(t *testing.T) {
1572- ctx := context.Background()
1572+ ctx := t.Context()
15731573
15741574 paneID := entity.PaneID("pane-1")
15751575 tab := entity.NewTab(entity.TabID("tab-1"), entity.WorkspaceID("ws-1"), entity.NewPane(paneID))
@@ -1627,7 +1627,7 @@ func TestApp_HistorySidebarConfig_OpenInNewPaneCallback(t *testing.T) {
16271627 // TestApp_HistorySidebarConfig_CloseCallback verifies that OnClose hides the
16281628 // sidebar for the owning browser window and restores focus to the active pane.
16291629 func TestApp_HistorySidebarConfig_CloseCallback(t *testing.T) {
1630- ctx := context.Background()
1630+ ctx := t.Context()
16311631
16321632 paneID := entity.PaneID("pane-1")
16331633 tab := entity.NewTab(entity.TabID("tab-1"), entity.WorkspaceID("ws-1"), entity.NewPane(paneID))
@@ -1674,7 +1674,7 @@ func TestApp_HistorySidebarConfig_CloseCallback(t *testing.T) {
16741674 // OnClose (hideAndRestoreFocusForBrowserWindow) is safe when the browser
16751675 // window has no sidebar or is nil.
16761676 func TestApp_HistorySidebarConfig_CloseWithNoSidebarIsSafe(t *testing.T) {
1677- ctx := context.Background()
1677+ ctx := t.Context()
16781678
16791679 bw := &browserWindow{
16801680 id: "no-sidebar",
@@ -911,7 +911,7 @@ func TestRestoreSession_ActiveWindowIndexSyncsState(t *testing.T) {
911 // that the default OnNavigate callback targets the owning browser window's911 // that the default OnNavigate callback targets the owning browser window's
912 // active pane and keeps the sidebar visible.912 // active pane and keeps the sidebar visible.
913 func TestHistorySidebarConfig_OnNavigateNavigatesActivePaneAndKeepsSidebar(t *testing.T) {913 func TestHistorySidebarConfig_OnNavigateNavigatesActivePaneAndKeepsSidebar(t *testing.T) {
914- ctx := context.Background()914+ ctx := t.Context()
915 915
916 // Build two browser windows with independent tabs and panes.916 // Build two browser windows with independent tabs and panes.
917 tab1 := entity.NewTab(entity.TabID("tab-1"), entity.WorkspaceID("ws-1"), entity.NewPane(entity.PaneID("pane-1")))917 tab1 := entity.NewTab(entity.TabID("tab-1"), entity.WorkspaceID("ws-1"), entity.NewPane(entity.PaneID("pane-1")))
@@ -973,7 +973,7 @@ func TestHistorySidebarConfig_OnNavigateNavigatesActivePaneAndKeepsSidebar(t *te
973 // that the OnNavigateKeepOpen callback (Ctrl+Enter) navigates the owning window's973 // that the OnNavigateKeepOpen callback (Ctrl+Enter) navigates the owning window's
974 // active pane and keeps the sidebar visible.974 // active pane and keeps the sidebar visible.
975 func TestHistorySidebarConfig_OnNavigateKeepOpenNavigatesWithoutClosing(t *testing.T) {975 func TestHistorySidebarConfig_OnNavigateKeepOpenNavigatesWithoutClosing(t *testing.T) {
976- ctx := context.Background()976+ ctx := t.Context()
977 977
978 tab := entity.NewTab(entity.TabID("tab-1"), entity.WorkspaceID("ws-1"), entity.NewPane(entity.PaneID("pane-1")))978 tab := entity.NewTab(entity.TabID("tab-1"), entity.WorkspaceID("ws-1"), entity.NewPane(entity.PaneID("pane-1")))
979 bwTabs := entity.NewTabList()979 bwTabs := entity.NewTabList()
@@ -1011,7 +1011,7 @@ func TestHistorySidebarConfig_OnNavigateKeepOpenNavigatesWithoutClosing(t *testi
1011 // correct owning window's active pane. This tests the stale-focus scenario1011 // correct owning window's active pane. This tests the stale-focus scenario
1012 // where a different window is globally focused.1012 // where a different window is globally focused.
1013 func TestHistorySidebar_OwnershipOnMultiWindowNavigation(t *testing.T) {1013 func TestHistorySidebar_OwnershipOnMultiWindowNavigation(t *testing.T) {
1014- ctx := context.Background()1014+ ctx := t.Context()
1015 1015
1016 // Two windows, each with their own tab and pane.1016 // Two windows, each with their own tab and pane.
1017 tab1 := entity.NewTab(entity.TabID("tab-1"), entity.WorkspaceID("ws-1"), entity.NewPane(entity.PaneID("pane-1")))1017 tab1 := entity.NewTab(entity.TabID("tab-1"), entity.WorkspaceID("ws-1"), entity.NewPane(entity.PaneID("pane-1")))
@@ -1225,7 +1225,7 @@ func TestApp_HistorySidebarToggleHandler_NilFocusedWindowIsNoOp(t *testing.T) {
1225 // TestHistorySidebarConfig_OnCloseHidesSidebar verifies that the OnClose1225 // TestHistorySidebarConfig_OnCloseHidesSidebar verifies that the OnClose
1226 // callback hides the sidebar for the owning browser window.1226 // callback hides the sidebar for the owning browser window.
1227 func TestHistorySidebarConfig_OnCloseHidesSidebar(t *testing.T) {1227 func TestHistorySidebarConfig_OnCloseHidesSidebar(t *testing.T) {
1228- ctx := context.Background()1228+ ctx := t.Context()
1229 tab := entity.NewTab(entity.TabID("tab-1"), entity.WorkspaceID("ws-1"), entity.NewPane(entity.PaneID("pane-1")))1229 tab := entity.NewTab(entity.TabID("tab-1"), entity.WorkspaceID("ws-1"), entity.NewPane(entity.PaneID("pane-1")))
1230 bwTabs := entity.NewTabList()1230 bwTabs := entity.NewTabList()
1231 bwTabs.Add(tab)1231 bwTabs.Add(tab)
@@ -1261,7 +1261,7 @@ func TestHistorySidebarConfig_OnCloseHidesSidebar(t *testing.T) {
1261 // dispatches ActionToggleHistorySystemView, asserting the focused browser1261 // dispatches ActionToggleHistorySystemView, asserting the focused browser
1262 // window's sidebar visibility toggles.1262 // window's sidebar visibility toggles.
1263 func TestApp_HistorySidebar_ToggleThroughKeyboardDispatcher(t *testing.T) {1263 func TestApp_HistorySidebar_ToggleThroughKeyboardDispatcher(t *testing.T) {
1264- ctx := context.Background()1264+ ctx := t.Context()
1265 1265
1266 focusedBW := &browserWindow{1266 focusedBW := &browserWindow{
1267 id: "focused",1267 id: "focused",
@@ -1309,7 +1309,7 @@ func TestApp_HistorySidebar_ToggleThroughKeyboardDispatcher(t *testing.T) {
1309 // TestApp_HistorySidebar_ToggleThroughDispatcher_UnavailableReturnsError verifies that1309 // TestApp_HistorySidebar_ToggleThroughDispatcher_UnavailableReturnsError verifies that
1310 // when the focused window has no history sidebar, Ctrl+H returns a clean error.1310 // when the focused window has no history sidebar, Ctrl+H returns a clean error.
1311 func TestApp_HistorySidebar_ToggleThroughDispatcher_UnavailableReturnsError(t *testing.T) {1311 func TestApp_HistorySidebar_ToggleThroughDispatcher_UnavailableReturnsError(t *testing.T) {
1312- ctx := context.Background()1312+ ctx := t.Context()
1313 1313
1314 bw := &browserWindow{1314 bw := &browserWindow{
1315 id: "no-sidebar",1315 id: "no-sidebar",
@@ -1342,7 +1342,7 @@ func TestApp_HistorySidebar_ToggleThroughDispatcher_UnavailableReturnsError(t *t
1342 // TestApp_HistorySidebar_ToggleThroughDispatcher_NilFocusedReturnsError verifies1342 // TestApp_HistorySidebar_ToggleThroughDispatcher_NilFocusedReturnsError verifies
1343 // that the toggle handler returns a clean error when there is no focused window.1343 // that the toggle handler returns a clean error when there is no focused window.
1344 func TestApp_HistorySidebar_ToggleThroughDispatcher_NilFocusedReturnsError(t *testing.T) {1344 func TestApp_HistorySidebar_ToggleThroughDispatcher_NilFocusedReturnsError(t *testing.T) {
1345- ctx := context.Background()1345+ ctx := t.Context()
1346 1346
1347 app := &App{1347 app := &App{
1348 browserWindows: make(map[string]*browserWindow),1348 browserWindows: make(map[string]*browserWindow),
@@ -1373,7 +1373,7 @@ func TestApp_HistorySidebar_ToggleThroughDispatcher_NilFocusedReturnsError(t *te
1373 // callback from buildHistorySidebarConfig navigates the owning browser window's1373 // callback from buildHistorySidebarConfig navigates the owning browser window's
1374 // active pane to the given URL.1374 // active pane to the given URL.
1375 func TestApp_HistorySidebarConfig_NavigateCallbackNavigates(t *testing.T) {1375 func TestApp_HistorySidebarConfig_NavigateCallbackNavigates(t *testing.T) {
1376- ctx := context.Background()1376+ ctx := t.Context()
1377 1377
1378 paneID := entity.PaneID("pane-1")1378 paneID := entity.PaneID("pane-1")
1379 tab := entity.NewTab(entity.TabID("tab-1"), entity.WorkspaceID("ws-1"), entity.NewPane(paneID))1379 tab := entity.NewTab(entity.TabID("tab-1"), entity.WorkspaceID("ws-1"), entity.NewPane(paneID))
@@ -1421,7 +1421,7 @@ func TestApp_HistorySidebarConfig_NavigateCallbackNavigates(t *testing.T) {
1421 }1421 }
1422 1422
1423 func TestApp_NavigateHistorySidebarSelection_KeepsSidebarVisible(t *testing.T) {1423 func TestApp_NavigateHistorySidebarSelection_KeepsSidebarVisible(t *testing.T) {
1424- ctx := context.Background()1424+ ctx := t.Context()
1425 1425
1426 paneID := entity.PaneID("pane-1")1426 paneID := entity.PaneID("pane-1")
1427 tab := entity.NewTab(entity.TabID("tab-1"), entity.WorkspaceID("ws-1"), entity.NewPane(paneID))1427 tab := entity.NewTab(entity.TabID("tab-1"), entity.WorkspaceID("ws-1"), entity.NewPane(paneID))
@@ -1464,7 +1464,7 @@ func TestApp_NavigateHistorySidebarSelection_KeepsSidebarVisible(t *testing.T) {
1464 // OnNavigate targets the callback's owning window, not the globally focused1464 // OnNavigate targets the callback's owning window, not the globally focused
1465 // window, when they differ.1465 // window, when they differ.
1466 func TestApp_HistorySidebarConfig_NavigateCallbackOwnership(t *testing.T) {1466 func TestApp_HistorySidebarConfig_NavigateCallbackOwnership(t *testing.T) {
1467- ctx := context.Background()1467+ ctx := t.Context()
1468 1468
1469 tab1 := entity.NewTab(entity.TabID("tab-1"), entity.WorkspaceID("ws-1"), entity.NewPane(entity.PaneID("pane-1")))1469 tab1 := entity.NewTab(entity.TabID("tab-1"), entity.WorkspaceID("ws-1"), entity.NewPane(entity.PaneID("pane-1")))
1470 tab2 := entity.NewTab(entity.TabID("tab-2"), entity.WorkspaceID("ws-2"), entity.NewPane(entity.PaneID("pane-2")))1470 tab2 := entity.NewTab(entity.TabID("tab-2"), entity.WorkspaceID("ws-2"), entity.NewPane(entity.PaneID("pane-2")))
@@ -1519,7 +1519,7 @@ func TestApp_HistorySidebarConfig_NavigateCallbackOwnership(t *testing.T) {
1519 // TestApp_HistorySidebarConfig_KeepOpenCallback verifies that1519 // TestApp_HistorySidebarConfig_KeepOpenCallback verifies that
1520 // OnNavigateKeepOpen navigates the owning window without hiding the sidebar.1520 // OnNavigateKeepOpen navigates the owning window without hiding the sidebar.
1521 func TestApp_HistorySidebarConfig_KeepOpenCallback(t *testing.T) {1521 func TestApp_HistorySidebarConfig_KeepOpenCallback(t *testing.T) {
1522- ctx := context.Background()1522+ ctx := t.Context()
1523 1523
1524 paneID := entity.PaneID("pane-1")1524 paneID := entity.PaneID("pane-1")
1525 tab := entity.NewTab(entity.TabID("tab-1"), entity.WorkspaceID("ws-1"), entity.NewPane(paneID))1525 tab := entity.NewTab(entity.TabID("tab-1"), entity.WorkspaceID("ws-1"), entity.NewPane(paneID))
@@ -1569,7 +1569,7 @@ func TestApp_HistorySidebarConfig_KeepOpenCallback(t *testing.T) {
1569 // OnOpenInNewPane activates the owning browser window and creates a split1569 // OnOpenInNewPane activates the owning browser window and creates a split
1570 // with the target URL.1570 // with the target URL.
1571 func TestApp_HistorySidebarConfig_OpenInNewPaneCallback(t *testing.T) {1571 func TestApp_HistorySidebarConfig_OpenInNewPaneCallback(t *testing.T) {
1572- ctx := context.Background()1572+ ctx := t.Context()
1573 1573
1574 paneID := entity.PaneID("pane-1")1574 paneID := entity.PaneID("pane-1")
1575 tab := entity.NewTab(entity.TabID("tab-1"), entity.WorkspaceID("ws-1"), entity.NewPane(paneID))1575 tab := entity.NewTab(entity.TabID("tab-1"), entity.WorkspaceID("ws-1"), entity.NewPane(paneID))
@@ -1627,7 +1627,7 @@ func TestApp_HistorySidebarConfig_OpenInNewPaneCallback(t *testing.T) {
1627 // TestApp_HistorySidebarConfig_CloseCallback verifies that OnClose hides the1627 // TestApp_HistorySidebarConfig_CloseCallback verifies that OnClose hides the
1628 // sidebar for the owning browser window and restores focus to the active pane.1628 // sidebar for the owning browser window and restores focus to the active pane.
1629 func TestApp_HistorySidebarConfig_CloseCallback(t *testing.T) {1629 func TestApp_HistorySidebarConfig_CloseCallback(t *testing.T) {
1630- ctx := context.Background()1630+ ctx := t.Context()
1631 1631
1632 paneID := entity.PaneID("pane-1")1632 paneID := entity.PaneID("pane-1")
1633 tab := entity.NewTab(entity.TabID("tab-1"), entity.WorkspaceID("ws-1"), entity.NewPane(paneID))1633 tab := entity.NewTab(entity.TabID("tab-1"), entity.WorkspaceID("ws-1"), entity.NewPane(paneID))
@@ -1674,7 +1674,7 @@ func TestApp_HistorySidebarConfig_CloseCallback(t *testing.T) {
1674 // OnClose (hideAndRestoreFocusForBrowserWindow) is safe when the browser1674 // OnClose (hideAndRestoreFocusForBrowserWindow) is safe when the browser
1675 // window has no sidebar or is nil.1675 // window has no sidebar or is nil.
1676 func TestApp_HistorySidebarConfig_CloseWithNoSidebarIsSafe(t *testing.T) {1676 func TestApp_HistorySidebarConfig_CloseWithNoSidebarIsSafe(t *testing.T) {
1677- ctx := context.Background()1677+ ctx := t.Context()
1678 1678
1679 bw := &browserWindow{1679 bw := &browserWindow{
1680 id: "no-sidebar",1680 id: "no-sidebar",
M internal/ui/component/history_model_test.go +10 -16
@@ -417,8 +417,7 @@ func TestKeyboardNavModel_EntryCount(t *testing.T) {
417417 // =============================================================================
418418
419419 func TestTransitionSearchState_EmptyQuery(t *testing.T) {
420- initial := searchStateSnapshot{}
421- next := transitionSearchState(initial, "", 0)
420+ next := transitionSearchState("", 0)
422421 assert.Equal(t, "", next.Query)
423422 assert.False(t, next.HasSearchDone)
424423 assert.False(t, next.HasResults)
@@ -426,8 +425,7 @@ func TestTransitionSearchState_EmptyQuery(t *testing.T) {
426425 }
427426
428427 func TestTransitionSearchState_NewQuery(t *testing.T) {
429- initial := searchStateSnapshot{}
430- next := transitionSearchState(initial, "example", 5)
428+ next := transitionSearchState("example", 5)
431429 assert.Equal(t, "example", next.Query)
432430 assert.True(t, next.HasSearchDone)
433431 assert.True(t, next.HasResults)
@@ -435,8 +433,7 @@ func TestTransitionSearchState_NewQuery(t *testing.T) {
435433 }
436434
437435 func TestTransitionSearchState_QueryWithNoResults(t *testing.T) {
438- initial := searchStateSnapshot{}
439- next := transitionSearchState(initial, "nonexistent", 0)
436+ next := transitionSearchState("nonexistent", 0)
440437 assert.Equal(t, "nonexistent", next.Query)
441438 assert.True(t, next.HasSearchDone)
442439 assert.False(t, next.HasResults)
@@ -444,8 +441,7 @@ func TestTransitionSearchState_QueryWithNoResults(t *testing.T) {
444441 }
445442
446443 func TestTransitionSearchState_QueryToQuery(t *testing.T) {
447- initial := searchStateSnapshot{Query: "old", HasSearchDone: true, HasResults: true, ResultCount: 3}
448- next := transitionSearchState(initial, "new", 7)
444+ next := transitionSearchState("new", 7)
449445 assert.Equal(t, "new", next.Query)
450446 assert.True(t, next.HasSearchDone)
451447 assert.True(t, next.HasResults)
@@ -453,8 +449,7 @@ func TestTransitionSearchState_QueryToQuery(t *testing.T) {
453449 }
454450
455451 func TestTransitionSearchState_QueryToEmpty(t *testing.T) {
456- initial := searchStateSnapshot{Query: "old", HasSearchDone: true, HasResults: true, ResultCount: 3}
457- next := transitionSearchState(initial, "", 0)
452+ next := transitionSearchState("", 0)
458453 assert.Equal(t, "", next.Query)
459454 assert.False(t, next.HasSearchDone)
460455 assert.False(t, next.HasResults)
@@ -610,15 +605,14 @@ func TestKeyboardNavModel_EntryCountWithEmptyGroups(t *testing.T) {
610605 // where a later result arrives after the gen has moved on.
611606 func TestTransitionSearchState_SequentialSearches(t *testing.T) {
612607 // Search 1: "foo" -> 5 results
613- s1 := searchStateSnapshot{}
614- next1 := transitionSearchState(s1, "foo", 5)
608+ next1 := transitionSearchState("foo", 5)
615609 assert.Equal(t, "foo", next1.Query)
616610 assert.True(t, next1.HasSearchDone)
617611 assert.True(t, next1.HasResults)
618612 assert.Equal(t, 5, next1.ResultCount)
619613
620614 // Search 2: "foobar" -> 3 results (supersedes search 1)
621- next2 := transitionSearchState(next1, "foobar", 3)
615+ next2 := transitionSearchState("foobar", 3)
622616 assert.Equal(t, "foobar", next2.Query)
623617 assert.True(t, next2.HasSearchDone)
624618 assert.True(t, next2.HasResults)
@@ -631,21 +625,21 @@ func TestTransitionSearchState_SearchThenClearThenReSearch(t *testing.T) {
631625 s := searchStateSnapshot{}
632626
633627 // Search "term" -> 2 results
634- s = transitionSearchState(s, "term", 2)
628+ s = transitionSearchState("term", 2)
635629 assert.Equal(t, "term", s.Query)
636630 assert.True(t, s.HasSearchDone)
637631 assert.True(t, s.HasResults)
638632 assert.Equal(t, 2, s.ResultCount)
639633
640634 // Clear: query becomes ""
641- s = transitionSearchState(s, "", 0)
635+ s = transitionSearchState("", 0)
642636 assert.Equal(t, "", s.Query)
643637 assert.False(t, s.HasSearchDone)
644638 assert.False(t, s.HasResults)
645639 assert.Equal(t, 0, s.ResultCount)
646640
647641 // Re-search: new term
648- s = transitionSearchState(s, "other", 7)
642+ s = transitionSearchState("other", 7)
649643 assert.Equal(t, "other", s.Query)
650644 assert.True(t, s.HasSearchDone)
651645 assert.True(t, s.HasResults)
@@ -417,8 +417,7 @@ func TestKeyboardNavModel_EntryCount(t *testing.T) {
417 // =============================================================================417 // =============================================================================
418 418
419 func TestTransitionSearchState_EmptyQuery(t *testing.T) {419 func TestTransitionSearchState_EmptyQuery(t *testing.T) {
420- initial := searchStateSnapshot{}420+ next := transitionSearchState("", 0)
421- next := transitionSearchState(initial, "", 0)
422 assert.Equal(t, "", next.Query)421 assert.Equal(t, "", next.Query)
423 assert.False(t, next.HasSearchDone)422 assert.False(t, next.HasSearchDone)
424 assert.False(t, next.HasResults)423 assert.False(t, next.HasResults)
@@ -426,8 +425,7 @@ func TestTransitionSearchState_EmptyQuery(t *testing.T) {
426 }425 }
427 426
428 func TestTransitionSearchState_NewQuery(t *testing.T) {427 func TestTransitionSearchState_NewQuery(t *testing.T) {
429- initial := searchStateSnapshot{}428+ next := transitionSearchState("example", 5)
430- next := transitionSearchState(initial, "example", 5)
431 assert.Equal(t, "example", next.Query)429 assert.Equal(t, "example", next.Query)
432 assert.True(t, next.HasSearchDone)430 assert.True(t, next.HasSearchDone)
433 assert.True(t, next.HasResults)431 assert.True(t, next.HasResults)
@@ -435,8 +433,7 @@ func TestTransitionSearchState_NewQuery(t *testing.T) {
435 }433 }
436 434
437 func TestTransitionSearchState_QueryWithNoResults(t *testing.T) {435 func TestTransitionSearchState_QueryWithNoResults(t *testing.T) {
438- initial := searchStateSnapshot{}436+ next := transitionSearchState("nonexistent", 0)
439- next := transitionSearchState(initial, "nonexistent", 0)
440 assert.Equal(t, "nonexistent", next.Query)437 assert.Equal(t, "nonexistent", next.Query)
441 assert.True(t, next.HasSearchDone)438 assert.True(t, next.HasSearchDone)
442 assert.False(t, next.HasResults)439 assert.False(t, next.HasResults)
@@ -444,8 +441,7 @@ func TestTransitionSearchState_QueryWithNoResults(t *testing.T) {
444 }441 }
445 442
446 func TestTransitionSearchState_QueryToQuery(t *testing.T) {443 func TestTransitionSearchState_QueryToQuery(t *testing.T) {
447- initial := searchStateSnapshot{Query: "old", HasSearchDone: true, HasResults: true, ResultCount: 3}444+ next := transitionSearchState("new", 7)
448- next := transitionSearchState(initial, "new", 7)
449 assert.Equal(t, "new", next.Query)445 assert.Equal(t, "new", next.Query)
450 assert.True(t, next.HasSearchDone)446 assert.True(t, next.HasSearchDone)
451 assert.True(t, next.HasResults)447 assert.True(t, next.HasResults)
@@ -453,8 +449,7 @@ func TestTransitionSearchState_QueryToQuery(t *testing.T) {
453 }449 }
454 450
455 func TestTransitionSearchState_QueryToEmpty(t *testing.T) {451 func TestTransitionSearchState_QueryToEmpty(t *testing.T) {
456- initial := searchStateSnapshot{Query: "old", HasSearchDone: true, HasResults: true, ResultCount: 3}452+ next := transitionSearchState("", 0)
457- next := transitionSearchState(initial, "", 0)
458 assert.Equal(t, "", next.Query)453 assert.Equal(t, "", next.Query)
459 assert.False(t, next.HasSearchDone)454 assert.False(t, next.HasSearchDone)
460 assert.False(t, next.HasResults)455 assert.False(t, next.HasResults)
@@ -610,15 +605,14 @@ func TestKeyboardNavModel_EntryCountWithEmptyGroups(t *testing.T) {
610 // where a later result arrives after the gen has moved on.605 // where a later result arrives after the gen has moved on.
611 func TestTransitionSearchState_SequentialSearches(t *testing.T) {606 func TestTransitionSearchState_SequentialSearches(t *testing.T) {
612 // Search 1: "foo" -> 5 results607 // Search 1: "foo" -> 5 results
613- s1 := searchStateSnapshot{}608+ next1 := transitionSearchState("foo", 5)
614- next1 := transitionSearchState(s1, "foo", 5)
615 assert.Equal(t, "foo", next1.Query)609 assert.Equal(t, "foo", next1.Query)
616 assert.True(t, next1.HasSearchDone)610 assert.True(t, next1.HasSearchDone)
617 assert.True(t, next1.HasResults)611 assert.True(t, next1.HasResults)
618 assert.Equal(t, 5, next1.ResultCount)612 assert.Equal(t, 5, next1.ResultCount)
619 613
620 // Search 2: "foobar" -> 3 results (supersedes search 1)614 // Search 2: "foobar" -> 3 results (supersedes search 1)
621- next2 := transitionSearchState(next1, "foobar", 3)615+ next2 := transitionSearchState("foobar", 3)
622 assert.Equal(t, "foobar", next2.Query)616 assert.Equal(t, "foobar", next2.Query)
623 assert.True(t, next2.HasSearchDone)617 assert.True(t, next2.HasSearchDone)
624 assert.True(t, next2.HasResults)618 assert.True(t, next2.HasResults)
@@ -631,21 +625,21 @@ func TestTransitionSearchState_SearchThenClearThenReSearch(t *testing.T) {
631 s := searchStateSnapshot{}625 s := searchStateSnapshot{}
632 626
633 // Search "term" -> 2 results627 // Search "term" -> 2 results
634- s = transitionSearchState(s, "term", 2)628+ s = transitionSearchState("term", 2)
635 assert.Equal(t, "term", s.Query)629 assert.Equal(t, "term", s.Query)
636 assert.True(t, s.HasSearchDone)630 assert.True(t, s.HasSearchDone)
637 assert.True(t, s.HasResults)631 assert.True(t, s.HasResults)
638 assert.Equal(t, 2, s.ResultCount)632 assert.Equal(t, 2, s.ResultCount)
639 633
640 // Clear: query becomes ""634 // Clear: query becomes ""
641- s = transitionSearchState(s, "", 0)635+ s = transitionSearchState("", 0)
642 assert.Equal(t, "", s.Query)636 assert.Equal(t, "", s.Query)
643 assert.False(t, s.HasSearchDone)637 assert.False(t, s.HasSearchDone)
644 assert.False(t, s.HasResults)638 assert.False(t, s.HasResults)
645 assert.Equal(t, 0, s.ResultCount)639 assert.Equal(t, 0, s.ResultCount)
646 640
647 // Re-search: new term641 // Re-search: new term
648- s = transitionSearchState(s, "other", 7)642+ s = transitionSearchState("other", 7)
649 assert.Equal(t, "other", s.Query)643 assert.Equal(t, "other", s.Query)
650 assert.True(t, s.HasSearchDone)644 assert.True(t, s.HasSearchDone)
651 assert.True(t, s.HasResults)645 assert.True(t, s.HasResults)
M internal/ui/component/history_sidebar_search_test.go +4 -4
@@ -164,7 +164,7 @@ func TestApplySearchResults_StaleGenerationDropsResultsAfterSearch(t *testing.T)
164164 }
165165
166166 hs := newTestSidebarSearchHarness()
167- hs.ctx = context.Background()
167+ hs.ctx = t.Context()
168168 hs.historyUC = history
169169 hs.searchGen = 1
170170 hs.idleScheduler = func(cb glib.SourceFunc) {
@@ -212,7 +212,7 @@ func TestApplySearchResults_CurrentGenerationAppliedAfterSearch(t *testing.T) {
212212 }
213213
214214 hs := newTestSidebarSearchHarness()
215- hs.ctx = context.Background()
215+ hs.ctx = t.Context()
216216 hs.historyUC = history
217217 hs.searchGen = 1
218218 hs.idleScheduler = func(cb glib.SourceFunc) {
@@ -260,7 +260,7 @@ func TestHistorySidebar_ReloadPreservesQuery(t *testing.T) {
260260 hs := newTestSidebarSearchHarness()
261261 hs.currentQuery = "preserved"
262262 hs.historyUC = history
263- hs.ctx = context.Background()
263+ hs.ctx = t.Context()
264264
265265 hs.mu.Lock()
266266 oldGen := hs.searchGen
@@ -314,7 +314,7 @@ func TestFetchPage_StaleGenerationDoesNotMutateLoadingState(t *testing.T) {
314314 }
315315
316316 hs := newTestSidebarSearchHarness()
317- hs.ctx = context.Background()
317+ hs.ctx = t.Context()
318318 hs.historyUC = history
319319
320320 // Simulate: gen 1 started, then gen 2 started (e.g. by Reload/Show).
@@ -164,7 +164,7 @@ func TestApplySearchResults_StaleGenerationDropsResultsAfterSearch(t *testing.T)
164 }164 }
165 165
166 hs := newTestSidebarSearchHarness()166 hs := newTestSidebarSearchHarness()
167- hs.ctx = context.Background()167+ hs.ctx = t.Context()
168 hs.historyUC = history168 hs.historyUC = history
169 hs.searchGen = 1169 hs.searchGen = 1
170 hs.idleScheduler = func(cb glib.SourceFunc) {170 hs.idleScheduler = func(cb glib.SourceFunc) {
@@ -212,7 +212,7 @@ func TestApplySearchResults_CurrentGenerationAppliedAfterSearch(t *testing.T) {
212 }212 }
213 213
214 hs := newTestSidebarSearchHarness()214 hs := newTestSidebarSearchHarness()
215- hs.ctx = context.Background()215+ hs.ctx = t.Context()
216 hs.historyUC = history216 hs.historyUC = history
217 hs.searchGen = 1217 hs.searchGen = 1
218 hs.idleScheduler = func(cb glib.SourceFunc) {218 hs.idleScheduler = func(cb glib.SourceFunc) {
@@ -260,7 +260,7 @@ func TestHistorySidebar_ReloadPreservesQuery(t *testing.T) {
260 hs := newTestSidebarSearchHarness()260 hs := newTestSidebarSearchHarness()
261 hs.currentQuery = "preserved"261 hs.currentQuery = "preserved"
262 hs.historyUC = history262 hs.historyUC = history
263- hs.ctx = context.Background()263+ hs.ctx = t.Context()
264 264
265 hs.mu.Lock()265 hs.mu.Lock()
266 oldGen := hs.searchGen266 oldGen := hs.searchGen
@@ -314,7 +314,7 @@ func TestFetchPage_StaleGenerationDoesNotMutateLoadingState(t *testing.T) {
314 }314 }
315 315
316 hs := newTestSidebarSearchHarness()316 hs := newTestSidebarSearchHarness()
317- hs.ctx = context.Background()317+ hs.ctx = t.Context()
318 hs.historyUC = history318 hs.historyUC = history
319 319
320 // Simulate: gen 1 started, then gen 2 started (e.g. by Reload/Show).320 // Simulate: gen 1 started, then gen 2 started (e.g. by Reload/Show).
M internal/ui/component/history_test_helpers_test.go +1 -1
@@ -10,7 +10,7 @@ type searchStateSnapshot struct {
1010 }
1111
1212 // transitionSearchState models a search state transition for tests without GTK.
13-func transitionSearchState(_ searchStateSnapshot, newQuery string, resultCount int) searchStateSnapshot {
13+func transitionSearchState(newQuery string, resultCount int) searchStateSnapshot {
1414 return searchStateSnapshot{
1515 Query: newQuery,
1616 HasSearchDone: newQuery != "",
@@ -10,7 +10,7 @@ type searchStateSnapshot struct {
10 }10 }
11 11
12 // transitionSearchState models a search state transition for tests without GTK.12 // transitionSearchState models a search state transition for tests without GTK.
13-func transitionSearchState(_ searchStateSnapshot, newQuery string, resultCount int) searchStateSnapshot {13+func transitionSearchState(newQuery string, resultCount int) searchStateSnapshot {
14 return searchStateSnapshot{14 return searchStateSnapshot{
15 Query: newQuery,15 Query: newQuery,
16 HasSearchDone: newQuery != "",16 HasSearchDone: newQuery != "",

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