fix: guard type assertion and use renderer for engine migration output
- commit
- 2efed6475e8775fd4f1ac1e234ed4672489231f7
- author
- brice · · 2026-03-18 06:30 UTC
- parent
- dbd974e
- signature
- GPG Verified
CD88F9E564E0102646FB6077A1A07C7C7C3E349D· arch-gpg Verified for the committer email
3 files · +16 -2
M cmd/dumber/main.go +4 -1
| @@ -515,7 +515,10 @@ func buildUIDependencies( | |||
| 515 | 515 | currentSessionID entity.SessionID, | |
| 516 | 516 | startupCrashReports []string, | |
| 517 | 517 | ) *ui.Dependencies { | |
| 518 | - | filterManager := engine.(*webkit.Engine).InternalFilterManager() | |
| 518 | + | var filterManager port.FilterManager | |
| 519 | + | if wkEngine, ok := engine.(*webkit.Engine); ok { | |
| 520 | + | filterManager = wkEngine.InternalFilterManager() | |
| 521 | + | } | |
| 519 | 522 | ||
| 520 | 523 | focusProvider := textinput.NewFocusProvider() | |
| 521 | 524 | ||
| @@ -515,7 +515,10 @@ func buildUIDependencies( | |||||
| 515 | currentSessionID entity.SessionID, | 515 | currentSessionID entity.SessionID, | ||
| 516 | startupCrashReports []string, | 516 | startupCrashReports []string, | ||
| 517 | ) *ui.Dependencies { | 517 | ) *ui.Dependencies { | ||
| 518 | - | filterManager := engine.(*webkit.Engine).InternalFilterManager() | 518 | + | var filterManager port.FilterManager |
| 519 | + | if wkEngine, ok := engine.(*webkit.Engine); ok { | |||
| 520 | + | filterManager = wkEngine.InternalFilterManager() | |||
| 521 | + | } | |||
| 519 | 522 | ||||
| 520 | focusProvider := textinput.NewFocusProvider() | 523 | focusProvider := textinput.NewFocusProvider() | ||
| 521 | 524 | ||||
M internal/cli/cmd/config.go +1 -1
| @@ -255,7 +255,7 @@ func runConfigMigrate(_ *cobra.Command, _ []string) error { | |||
| 255 | 255 | return nil | |
| 256 | 256 | } | |
| 257 | 257 | if engineMigrated { | |
| 258 | - | fmt.Printf(" Migrated legacy sections to [engine]/[engine.webkit]\n") | |
| 258 | + | fmt.Print(renderer.RenderEngineMigrationSuccess()) | |
| 259 | 259 | } | |
| 260 | 260 | ||
| 261 | 261 | // Detect changes (includes renames, additions, and removals) | |
| @@ -255,7 +255,7 @@ func runConfigMigrate(_ *cobra.Command, _ []string) error { | |||||
| 255 | return nil | 255 | return nil | ||
| 256 | } | 256 | } | ||
| 257 | if engineMigrated { | 257 | if engineMigrated { | ||
| 258 | - | fmt.Printf(" Migrated legacy sections to [engine]/[engine.webkit]\n") | 258 | + | fmt.Print(renderer.RenderEngineMigrationSuccess()) |
| 259 | } | 259 | } | ||
| 260 | 260 | ||||
| 261 | // Detect changes (includes renames, additions, and removals) | 261 | // Detect changes (includes renames, additions, and removals) | ||
M internal/cli/styles/config.go +11 -0
| @@ -247,6 +247,17 @@ func (r *ConfigRenderer) RenderNoConfigFile(path string) string { | |||
| 247 | 247 | ) | |
| 248 | 248 | } | |
| 249 | 249 | ||
| 250 | + | // RenderEngineMigrationSuccess renders the success message after migrating legacy | |
| 251 | + | // sections to [engine]/[engine.webkit]. | |
| 252 | + | func (r *ConfigRenderer) RenderEngineMigrationSuccess() string { | |
| 253 | + | iconStyle := lipgloss.NewStyle().Foreground(r.theme.Success) | |
| 254 | + | ||
| 255 | + | return fmt.Sprintf( | |
| 256 | + | " %s Migrated legacy sections to [engine]/[engine.webkit]\n", | |
| 257 | + | iconStyle.Render(IconCheck), | |
| 258 | + | ) | |
| 259 | + | } | |
| 260 | + | ||
| 250 | 261 | // RenderOpening renders a brief "opening config" message for `dumber config open`. | |
| 251 | 262 | func (r *ConfigRenderer) RenderOpening(path, editor string) string { | |
| 252 | 263 | iconStyle := r.theme.Subtle | |
| @@ -247,6 +247,17 @@ func (r *ConfigRenderer) RenderNoConfigFile(path string) string { | |||||
| 247 | ) | 247 | ) | ||
| 248 | } | 248 | } | ||
| 249 | 249 | ||||
| 250 | + | // RenderEngineMigrationSuccess renders the success message after migrating legacy | |||
| 251 | + | // sections to [engine]/[engine.webkit]. | |||
| 252 | + | func (r *ConfigRenderer) RenderEngineMigrationSuccess() string { | |||
| 253 | + | iconStyle := lipgloss.NewStyle().Foreground(r.theme.Success) | |||
| 254 | + | ||||
| 255 | + | return fmt.Sprintf( | |||
| 256 | + | " %s Migrated legacy sections to [engine]/[engine.webkit]\n", | |||
| 257 | + | iconStyle.Render(IconCheck), | |||
| 258 | + | ) | |||
| 259 | + | } | |||
| 260 | + | ||||
| 250 | // RenderOpening renders a brief "opening config" message for `dumber config open`. | 261 | // RenderOpening renders a brief "opening config" message for `dumber config open`. | ||
| 251 | func (r *ConfigRenderer) RenderOpening(path, editor string) string { | 262 | func (r *ConfigRenderer) RenderOpening(path, editor string) string { | ||
| 252 | iconStyle := r.theme.Subtle | 263 | iconStyle := r.theme.Subtle | ||