fix: address review follow-ups for omnibox, webkit, updater, and config
- commit
- 162a4b977c1fad6499dd8801127b3352879cfba3
- author
- brice · · 2026-02-07 08:31 UTC
- parent
- 83a2b1b
- signature
- GPG Verified
CD88F9E564E0102646FB6077A1A07C7C7C3E349D· arch-gpg Verified for the committer email
4 files · +15 -2
M internal/infrastructure/config/loader.go +2 -0
| @@ -274,6 +274,8 @@ func normalizePerformanceProfile(config *Config) { | |||
| 274 | 274 | config.Performance.Profile = ProfileMax | |
| 275 | 275 | case string(ProfileCustom): | |
| 276 | 276 | config.Performance.Profile = ProfileCustom | |
| 277 | + | default: | |
| 278 | + | config.Performance.Profile = ProfileDefault | |
| 277 | 279 | } | |
| 278 | 280 | } | |
| 279 | 281 | ||
| @@ -274,6 +274,8 @@ func normalizePerformanceProfile(config *Config) { | |||||
| 274 | config.Performance.Profile = ProfileMax | 274 | config.Performance.Profile = ProfileMax | ||
| 275 | case string(ProfileCustom): | 275 | case string(ProfileCustom): | ||
| 276 | config.Performance.Profile = ProfileCustom | 276 | config.Performance.Profile = ProfileCustom | ||
| 277 | + | default: | |||
| 278 | + | config.Performance.Profile = ProfileDefault | |||
| 277 | } | 279 | } | ||
| 278 | } | 280 | } | ||
| 279 | 281 | ||||
M internal/infrastructure/updater/github.go +4 -0
| @@ -311,6 +311,10 @@ func retryDelayForAttempt(attempt int, randInt63 func(n int64) int64) time.Durat | |||
| 311 | 311 | return delay | |
| 312 | 312 | } | |
| 313 | 313 | ||
| 314 | + | // doRequestWithRetryHelper retries the same request instance across attempts. | |
| 315 | + | // It assumes req.Body is non-consumable (for example http.NoBody); it does not clone | |
| 316 | + | // the request or rewind req.Body. Callers needing retries with a real body must provide | |
| 317 | + | // a fresh cloned request per attempt or use a rewindable body implementation. | |
| 314 | 318 | func doRequestWithRetryHelper( | |
| 315 | 319 | ctx context.Context, | |
| 316 | 320 | client *http.Client, | |
| @@ -311,6 +311,10 @@ func retryDelayForAttempt(attempt int, randInt63 func(n int64) int64) time.Durat | |||||
| 311 | return delay | 311 | return delay | ||
| 312 | } | 312 | } | ||
| 313 | 313 | ||||
| 314 | + | // doRequestWithRetryHelper retries the same request instance across attempts. | |||
| 315 | + | // It assumes req.Body is non-consumable (for example http.NoBody); it does not clone | |||
| 316 | + | // the request or rewind req.Body. Callers needing retries with a real body must provide | |||
| 317 | + | // a fresh cloned request per attempt or use a rewindable body implementation. | |||
| 314 | func doRequestWithRetryHelper( | 318 | func doRequestWithRetryHelper( | ||
| 315 | ctx context.Context, | 319 | ctx context.Context, | ||
| 316 | client *http.Client, | 320 | client *http.Client, | ||
M internal/infrastructure/webkit/webview.go +2 -1
| @@ -1486,8 +1486,9 @@ func shouldTerminateWebProcess(policy string, isRelated, navigationActive bool) | |||
| 1486 | 1486 | } | |
| 1487 | 1487 | ||
| 1488 | 1488 | func classifyRunJSEvaluateError(err error) (nonFatal bool, signature string) { | |
| 1489 | + | // Defensive guard: callers should only pass non-nil errors, but tolerate nil safely. | |
| 1489 | 1490 | if err == nil { | |
| 1490 | - | return false, "evaluate_error" | |
| 1491 | + | return true, "" | |
| 1491 | 1492 | } | |
| 1492 | 1493 | msg := strings.ToLower(strings.TrimSpace(err.Error())) | |
| 1493 | 1494 | signature = "evaluate_error:" + normalizeRunJSErrorSignature(msg) | |
| @@ -1486,8 +1486,9 @@ func shouldTerminateWebProcess(policy string, isRelated, navigationActive bool) | |||||
| 1486 | } | 1486 | } | ||
| 1487 | 1487 | ||||
| 1488 | func classifyRunJSEvaluateError(err error) (nonFatal bool, signature string) { | 1488 | func classifyRunJSEvaluateError(err error) (nonFatal bool, signature string) { | ||
| 1489 | + | // Defensive guard: callers should only pass non-nil errors, but tolerate nil safely. | |||
| 1489 | if err == nil { | 1490 | if err == nil { | ||
| 1490 | - | return false, "evaluate_error" | 1491 | + | return true, "" |
| 1491 | } | 1492 | } | ||
| 1492 | msg := strings.ToLower(strings.TrimSpace(err.Error())) | 1493 | msg := strings.ToLower(strings.TrimSpace(err.Error())) | ||
| 1493 | signature = "evaluate_error:" + normalizeRunJSErrorSignature(msg) | 1494 | signature = "evaluate_error:" + normalizeRunJSErrorSignature(msg) | ||
M internal/ui/component/omnibox.go +7 -1
| @@ -876,6 +876,7 @@ func (o *Omnibox) setGhostText(originalInput, suffix, fullText string) { | |||
| 876 | 876 | o.ghostSuffix = suffix | |
| 877 | 877 | o.ghostFullText = fullText | |
| 878 | 878 | o.hasGhostText = true | |
| 879 | + | capturedToken := o.ghostToken | |
| 879 | 880 | o.mu.Unlock() | |
| 880 | 881 | ||
| 881 | 882 | var cb glib.SourceFunc = func(uintptr) bool { | |
| @@ -885,10 +886,14 @@ func (o *Omnibox) setGhostText(originalInput, suffix, fullText string) { | |||
| 885 | 886 | ||
| 886 | 887 | o.mu.RLock() | |
| 887 | 888 | currentInput := o.realInput | |
| 889 | + | currentToken := o.ghostToken | |
| 888 | 890 | o.mu.RUnlock() | |
| 889 | 891 | if currentInput != originalInput { | |
| 890 | 892 | return false | |
| 891 | 893 | } | |
| 894 | + | if capturedToken != currentToken { | |
| 895 | + | return false | |
| 896 | + | } | |
| 892 | 897 | o.mu.Lock() | |
| 893 | 898 | o.isAcceptingGhost = true | |
| 894 | 899 | o.mu.Unlock() | |
| @@ -1962,6 +1967,7 @@ func (o *Omnibox) toggleFavorite() { | |||
| 1962 | 1967 | log.Debug().Msg("remove favorite: invalid ID") | |
| 1963 | 1968 | return | |
| 1964 | 1969 | } | |
| 1970 | + | entryText := o.entry.GetText() | |
| 1965 | 1971 | ||
| 1966 | 1972 | go func() { | |
| 1967 | 1973 | ctx := o.ctx | |
| @@ -1989,7 +1995,7 @@ func (o *Omnibox) toggleFavorite() { | |||
| 1989 | 1995 | o.mu.RLock() | |
| 1990 | 1996 | currentToken := o.searchToken | |
| 1991 | 1997 | o.mu.RUnlock() | |
| 1992 | - | o.loadFavorites(o.entry.GetText(), currentToken) | |
| 1998 | + | o.loadFavorites(entryText, currentToken) | |
| 1993 | 1999 | if o.onToast != nil { | |
| 1994 | 2000 | cb := glib.SourceFunc(func(_ uintptr) bool { | |
| 1995 | 2001 | o.onToast(ctx, "Favorite removed", ToastSuccess) | |
| @@ -876,6 +876,7 @@ func (o *Omnibox) setGhostText(originalInput, suffix, fullText string) { | |||||
| 876 | o.ghostSuffix = suffix | 876 | o.ghostSuffix = suffix | ||
| 877 | o.ghostFullText = fullText | 877 | o.ghostFullText = fullText | ||
| 878 | o.hasGhostText = true | 878 | o.hasGhostText = true | ||
| 879 | + | capturedToken := o.ghostToken | |||
| 879 | o.mu.Unlock() | 880 | o.mu.Unlock() | ||
| 880 | 881 | ||||
| 881 | var cb glib.SourceFunc = func(uintptr) bool { | 882 | var cb glib.SourceFunc = func(uintptr) bool { | ||
| @@ -885,10 +886,14 @@ func (o *Omnibox) setGhostText(originalInput, suffix, fullText string) { | |||||
| 885 | 886 | ||||
| 886 | o.mu.RLock() | 887 | o.mu.RLock() | ||
| 887 | currentInput := o.realInput | 888 | currentInput := o.realInput | ||
| 889 | + | currentToken := o.ghostToken | |||
| 888 | o.mu.RUnlock() | 890 | o.mu.RUnlock() | ||
| 889 | if currentInput != originalInput { | 891 | if currentInput != originalInput { | ||
| 890 | return false | 892 | return false | ||
| 891 | } | 893 | } | ||
| 894 | + | if capturedToken != currentToken { | |||
| 895 | + | return false | |||
| 896 | + | } | |||
| 892 | o.mu.Lock() | 897 | o.mu.Lock() | ||
| 893 | o.isAcceptingGhost = true | 898 | o.isAcceptingGhost = true | ||
| 894 | o.mu.Unlock() | 899 | o.mu.Unlock() | ||
| @@ -1962,6 +1967,7 @@ func (o *Omnibox) toggleFavorite() { | |||||
| 1962 | log.Debug().Msg("remove favorite: invalid ID") | 1967 | log.Debug().Msg("remove favorite: invalid ID") | ||
| 1963 | return | 1968 | return | ||
| 1964 | } | 1969 | } | ||
| 1970 | + | entryText := o.entry.GetText() | |||
| 1965 | 1971 | ||||
| 1966 | go func() { | 1972 | go func() { | ||
| 1967 | ctx := o.ctx | 1973 | ctx := o.ctx | ||
| @@ -1989,7 +1995,7 @@ func (o *Omnibox) toggleFavorite() { | |||||
| 1989 | o.mu.RLock() | 1995 | o.mu.RLock() | ||
| 1990 | currentToken := o.searchToken | 1996 | currentToken := o.searchToken | ||
| 1991 | o.mu.RUnlock() | 1997 | o.mu.RUnlock() | ||
| 1992 | - | o.loadFavorites(o.entry.GetText(), currentToken) | 1998 | + | o.loadFavorites(entryText, currentToken) |
| 1993 | if o.onToast != nil { | 1999 | if o.onToast != nil { | ||
| 1994 | cb := glib.SourceFunc(func(_ uintptr) bool { | 2000 | cb := glib.SourceFunc(func(_ uintptr) bool { | ||
| 1995 | o.onToast(ctx, "Favorite removed", ToastSuccess) | 2001 | o.onToast(ctx, "Favorite removed", ToastSuccess) | ||