detached dd1fd2b

refactor(omnibox): keep favorites tags-safe

commit
dd1fd2b30585ba725ab7cb1514118fc3e637cba4
author
brice · · 2026-06-28 07:41 UTC
parent
45b8a06
signature
GPG VerifiedCD88F9E564E0102646FB6077A1A07C7C7C3E349D · arch-gpg Verified for the committer email
2 files · +44 -9
M internal/ui/component/omnibox.go +14 -9
@@ -1753,20 +1753,25 @@ func (o *Omnibox) loadFavorites(query string, token uint64) {
17531753 return
17541754 }
17551755
1756- favorites := make([]Favorite, 0, len(results))
1757- for i, r := range results {
1758- favorites = append(favorites, Favorite{
1759- ID: int64(r.ID),
1760- URL: r.URL,
1761- Title: r.Title,
1762- Position: i,
1763- })
1764- }
1756+ favorites := favoriteResultsForOmnibox(results)
17651757
17661758 o.idleAddUpdateFavorites(favorites, query, token)
17671759 }()
17681760 }
17691761
1762+func favoriteResultsForOmnibox(results []*entity.Favorite) []Favorite {
1763+ favorites := make([]Favorite, 0, len(results))
1764+ for i, r := range results {
1765+ favorites = append(favorites, Favorite{
1766+ ID: int64(r.ID),
1767+ URL: r.URL,
1768+ Title: r.Title,
1769+ Position: i,
1770+ })
1771+ }
1772+ return favorites
1773+}
1774+
17701775 func (o *Omnibox) loadBangSuggestions(query string, token uint64) {
17711776 if o.shortcutsUC == nil {
17721777 return
@@ -1753,20 +1753,25 @@ func (o *Omnibox) loadFavorites(query string, token uint64) {
1753 return1753 return
1754 }1754 }
1755 1755
1756- favorites := make([]Favorite, 0, len(results))1756+ favorites := favoriteResultsForOmnibox(results)
1757- for i, r := range results {
1758- favorites = append(favorites, Favorite{
1759- ID: int64(r.ID),
1760- URL: r.URL,
1761- Title: r.Title,
1762- Position: i,
1763- })
1764- }
1765 1757
1766 o.idleAddUpdateFavorites(favorites, query, token)1758 o.idleAddUpdateFavorites(favorites, query, token)
1767 }()1759 }()
1768 }1760 }
1769 1761
1762+func favoriteResultsForOmnibox(results []*entity.Favorite) []Favorite {
1763+ favorites := make([]Favorite, 0, len(results))
1764+ for i, r := range results {
1765+ favorites = append(favorites, Favorite{
1766+ ID: int64(r.ID),
1767+ URL: r.URL,
1768+ Title: r.Title,
1769+ Position: i,
1770+ })
1771+ }
1772+ return favorites
1773+}
1774+
1770 func (o *Omnibox) loadBangSuggestions(query string, token uint64) {1775 func (o *Omnibox) loadBangSuggestions(query string, token uint64) {
1771 if o.shortcutsUC == nil {1776 if o.shortcutsUC == nil {
1772 return1777 return
A internal/ui/component/omnibox_favorite_search_test.go +30 -0
@@ -0,0 +1,30 @@
1+package component
2+
3+import (
4+ "testing"
5+
6+ "github.com/bnema/dumber/internal/domain/entity"
7+ "github.com/stretchr/testify/assert"
8+)
9+
10+func TestOmniboxFavoriteSearchResultsAllowTagsPresent(t *testing.T) {
11+ results := []*entity.Favorite{
12+ {
13+ ID: 1,
14+ URL: "https://example.com/docs",
15+ Title: "Docs",
16+ Tags: []entity.Tag{{ID: 7, Name: "Go"}},
17+ },
18+ }
19+
20+ favorites := favoriteResultsForOmnibox(results)
21+
22+ assert.Equal(t, []Favorite{
23+ {
24+ ID: 1,
25+ URL: "https://example.com/docs",
26+ Title: "Docs",
27+ Position: 0,
28+ },
29+ }, favorites)
30+}
@@ -0,0 +1,30 @@
1+package component
2+
3+import (
4+ "testing"
5+
6+ "github.com/bnema/dumber/internal/domain/entity"
7+ "github.com/stretchr/testify/assert"
8+)
9+
10+func TestOmniboxFavoriteSearchResultsAllowTagsPresent(t *testing.T) {
11+ results := []*entity.Favorite{
12+ {
13+ ID: 1,
14+ URL: "https://example.com/docs",
15+ Title: "Docs",
16+ Tags: []entity.Tag{{ID: 7, Name: "Go"}},
17+ },
18+ }
19+
20+ favorites := favoriteResultsForOmnibox(results)
21+
22+ assert.Equal(t, []Favorite{
23+ {
24+ ID: 1,
25+ URL: "https://example.com/docs",
26+ Title: "Docs",
27+ Position: 0,
28+ },
29+ }, favorites)
30+}

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