refactor(engine): expand typed settings payload
- commit
- 15efbc77c911a2bee009b30370e0649a434d506d
- author
- brice · · 2026-06-23 13:21 UTC
- committer
- brice · · 2026-06-23 20:01 UTC
- parent
- 237f69b
- signature
- GPG Verified
CD88F9E564E0102646FB6077A1A07C7C7C3E349D· arch-gpg Verified for the committer email
2 files · +56 -7
M internal/application/port/engine.go +26 -7
| @@ -142,22 +142,41 @@ type Engine interface { | |||
| 142 | 142 | SetHandlerContext(ctx context.Context) | |
| 143 | 143 | } | |
| 144 | 144 | ||
| 145 | + | // EngineHardwareDecodingMode controls engine-facing video hardware acceleration. | |
| 146 | + | type EngineHardwareDecodingMode string | |
| 147 | + | ||
| 148 | + | const ( | |
| 149 | + | EngineHardwareDecodingAuto EngineHardwareDecodingMode = "auto" | |
| 150 | + | EngineHardwareDecodingForce EngineHardwareDecodingMode = "force" | |
| 151 | + | EngineHardwareDecodingDisable EngineHardwareDecodingMode = "disable" | |
| 152 | + | ) | |
| 153 | + | ||
| 154 | + | // EngineWebContentSettingsPayload is the engine-facing runtime view of web | |
| 155 | + | // content settings that can be applied to newly-created or existing webviews. | |
| 156 | + | type EngineWebContentSettingsPayload struct { | |
| 157 | + | SansFont string | |
| 158 | + | SerifFont string | |
| 159 | + | MonospaceFont string | |
| 160 | + | DefaultFontSize int | |
| 161 | + | EnableDevTools bool | |
| 162 | + | CaptureConsole bool | |
| 163 | + | DrawCompositingIndicators bool | |
| 164 | + | HardwareDecoding EngineHardwareDecodingMode | |
| 165 | + | } | |
| 166 | + | ||
| 145 | 167 | // EngineSettingsPayload is the engine-facing boundary view of runtime config. | |
| 146 | 168 | // Add fields here only when an engine needs to react to them at runtime. | |
| 147 | 169 | type EngineSettingsPayload struct { | |
| 148 | 170 | DefaultUIScale float64 | |
| 171 | + | WebContent EngineWebContentSettingsPayload | |
| 149 | 172 | } | |
| 150 | 173 | ||
| 151 | 174 | // EngineSettingsUpdate carries a runtime config change to the engine. | |
| 152 | - | // | |
| 153 | - | // Settings exposes the typed boundary payload that engine adapters should prefer. | |
| 154 | - | // Raw remains for legacy adapters that still consume implementation-specific | |
| 155 | - | // config until their settings managers are narrowed to boundary fields. | |
| 156 | 175 | type EngineSettingsUpdate struct { | |
| 157 | 176 | Settings EngineSettingsPayload | |
| 158 | - | // Raw holds the implementation-specific config for legacy adapters. | |
| 159 | - | // WebKit engine currently expects *infrastructure/config.Config. | |
| 160 | - | Raw any //nolint:iface // intentional legacy bridge; prefer Settings for new code | |
| 177 | + | // Raw remains only until the UI runtime config provider migration removes | |
| 178 | + | // the last concrete-config caller. Adapter implementations must ignore it. | |
| 179 | + | Raw any //nolint:iface // temporary legacy bridge; removed in Phase 4 | |
| 161 | 180 | } | |
| 162 | 181 | ||
| 163 | 182 | // WebUIMessageHandler handles a decoded message payload from the JS bridge. | |
| @@ -142,22 +142,41 @@ type Engine interface { | |||||
| 142 | SetHandlerContext(ctx context.Context) | 142 | SetHandlerContext(ctx context.Context) | ||
| 143 | } | 143 | } | ||
| 144 | 144 | ||||
| 145 | + | // EngineHardwareDecodingMode controls engine-facing video hardware acceleration. | |||
| 146 | + | type EngineHardwareDecodingMode string | |||
| 147 | + | ||||
| 148 | + | const ( | |||
| 149 | + | EngineHardwareDecodingAuto EngineHardwareDecodingMode = "auto" | |||
| 150 | + | EngineHardwareDecodingForce EngineHardwareDecodingMode = "force" | |||
| 151 | + | EngineHardwareDecodingDisable EngineHardwareDecodingMode = "disable" | |||
| 152 | + | ) | |||
| 153 | + | ||||
| 154 | + | // EngineWebContentSettingsPayload is the engine-facing runtime view of web | |||
| 155 | + | // content settings that can be applied to newly-created or existing webviews. | |||
| 156 | + | type EngineWebContentSettingsPayload struct { | |||
| 157 | + | SansFont string | |||
| 158 | + | SerifFont string | |||
| 159 | + | MonospaceFont string | |||
| 160 | + | DefaultFontSize int | |||
| 161 | + | EnableDevTools bool | |||
| 162 | + | CaptureConsole bool | |||
| 163 | + | DrawCompositingIndicators bool | |||
| 164 | + | HardwareDecoding EngineHardwareDecodingMode | |||
| 165 | + | } | |||
| 166 | + | ||||
| 145 | // EngineSettingsPayload is the engine-facing boundary view of runtime config. | 167 | // EngineSettingsPayload is the engine-facing boundary view of runtime config. | ||
| 146 | // Add fields here only when an engine needs to react to them at runtime. | 168 | // Add fields here only when an engine needs to react to them at runtime. | ||
| 147 | type EngineSettingsPayload struct { | 169 | type EngineSettingsPayload struct { | ||
| 148 | DefaultUIScale float64 | 170 | DefaultUIScale float64 | ||
| 171 | + | WebContent EngineWebContentSettingsPayload | |||
| 149 | } | 172 | } | ||
| 150 | 173 | ||||
| 151 | // EngineSettingsUpdate carries a runtime config change to the engine. | 174 | // EngineSettingsUpdate carries a runtime config change to the engine. | ||
| 152 | - | // | |||
| 153 | - | // Settings exposes the typed boundary payload that engine adapters should prefer. | |||
| 154 | - | // Raw remains for legacy adapters that still consume implementation-specific | |||
| 155 | - | // config until their settings managers are narrowed to boundary fields. | |||
| 156 | type EngineSettingsUpdate struct { | 175 | type EngineSettingsUpdate struct { | ||
| 157 | Settings EngineSettingsPayload | 176 | Settings EngineSettingsPayload | ||
| 158 | - | // Raw holds the implementation-specific config for legacy adapters. | 177 | + | // Raw remains only until the UI runtime config provider migration removes |
| 159 | - | // WebKit engine currently expects *infrastructure/config.Config. | 178 | + | // the last concrete-config caller. Adapter implementations must ignore it. |
| 160 | - | Raw any //nolint:iface // intentional legacy bridge; prefer Settings for new code | 179 | + | Raw any //nolint:iface // temporary legacy bridge; removed in Phase 4 |
| 161 | } | 180 | } | ||
| 162 | 181 | ||||
| 163 | // WebUIMessageHandler handles a decoded message payload from the JS bridge. | 182 | // WebUIMessageHandler handles a decoded message payload from the JS bridge. | ||
A internal/application/port/engine_settings_test.go +30 -0
| @@ -0,0 +1,30 @@ | |||
| 1 | + | package port | |
| 2 | + | ||
| 3 | + | import ( | |
| 4 | + | "reflect" | |
| 5 | + | "testing" | |
| 6 | + | ) | |
| 7 | + | ||
| 8 | + | func TestEngineSettingsPayloadContainsRuntimeWebContentFields(t *testing.T) { | |
| 9 | + | payloadType := reflect.TypeOf(EngineSettingsPayload{}) | |
| 10 | + | for _, field := range []string{"DefaultUIScale", "WebContent"} { | |
| 11 | + | if _, ok := payloadType.FieldByName(field); !ok { | |
| 12 | + | t.Fatalf("EngineSettingsPayload missing %s", field) | |
| 13 | + | } | |
| 14 | + | } | |
| 15 | + | webContentType := reflect.TypeOf(EngineWebContentSettingsPayload{}) | |
| 16 | + | for _, field := range []string{ | |
| 17 | + | "SansFont", | |
| 18 | + | "SerifFont", | |
| 19 | + | "MonospaceFont", | |
| 20 | + | "DefaultFontSize", | |
| 21 | + | "EnableDevTools", | |
| 22 | + | "CaptureConsole", | |
| 23 | + | "DrawCompositingIndicators", | |
| 24 | + | "HardwareDecoding", | |
| 25 | + | } { | |
| 26 | + | if _, ok := webContentType.FieldByName(field); !ok { | |
| 27 | + | t.Fatalf("EngineWebContentSettingsPayload missing %s", field) | |
| 28 | + | } | |
| 29 | + | } | |
| 30 | + | } | |
| @@ -0,0 +1,30 @@ | |||||
| 1 | + | package port | |||
| 2 | + | ||||
| 3 | + | import ( | |||
| 4 | + | "reflect" | |||
| 5 | + | "testing" | |||
| 6 | + | ) | |||
| 7 | + | ||||
| 8 | + | func TestEngineSettingsPayloadContainsRuntimeWebContentFields(t *testing.T) { | |||
| 9 | + | payloadType := reflect.TypeOf(EngineSettingsPayload{}) | |||
| 10 | + | for _, field := range []string{"DefaultUIScale", "WebContent"} { | |||
| 11 | + | if _, ok := payloadType.FieldByName(field); !ok { | |||
| 12 | + | t.Fatalf("EngineSettingsPayload missing %s", field) | |||
| 13 | + | } | |||
| 14 | + | } | |||
| 15 | + | webContentType := reflect.TypeOf(EngineWebContentSettingsPayload{}) | |||
| 16 | + | for _, field := range []string{ | |||
| 17 | + | "SansFont", | |||
| 18 | + | "SerifFont", | |||
| 19 | + | "MonospaceFont", | |||
| 20 | + | "DefaultFontSize", | |||
| 21 | + | "EnableDevTools", | |||
| 22 | + | "CaptureConsole", | |||
| 23 | + | "DrawCompositingIndicators", | |||
| 24 | + | "HardwareDecoding", | |||
| 25 | + | } { | |||
| 26 | + | if _, ok := webContentType.FieldByName(field); !ok { | |||
| 27 | + | t.Fatalf("EngineWebContentSettingsPayload missing %s", field) | |||
| 28 | + | } | |||
| 29 | + | } | |||
| 30 | + | } | |||