Demo: fix the @Entry closure warning for showAPIConfiguration
Los mantenedores suelen responder en 2 días
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 3/5
- Tiempo estimado
- 1-2 días
- Aptitud para principiantes
- 70/100
Línea de trabajo
Start by reading Demo/DemoChat/Sources/UI/Environment/APIConfiguration.swift, then inspect how Demo/App/DemoApp.swift sets showAPIConfiguration and how Demo/DemoChat/Sources/UI/Misc/MiscView.swift uses it. Build Demo to check the warning; done when it is gone and the API Configuration button still opens the screen.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
Building Demo reports this warning:
Demo/DemoChat/Sources/UI/Environment/APIConfiguration.swift:13:45: warning: Storing a closure in '@Entry var showAPIConfiguration' may invalidate dependents on every update because closures may not be comparable. (from macro 'Entry ')
Context
EnvironmentValues.showAPIConfiguration is a () -> Void that opens the API Configuration screen.
DemoAppsets it with.environment(\.showAPIConfiguration, { isShowingAPIConfigModal = true })in itsbody(Demo/App/DemoApp.swift).MiscViewreads it for its API Configuration button (Demo/DemoChat/Sources/UI/Misc/MiscView.swift).
SwiftUI can't compare closures, so it can't tell that the value is unchanged. A new closure is created each time DemoApp.body runs, so every run counts as a change and re-evaluates the views that read the value, here MiscView. The cost is small in this app. The warning is only in the Demo build; it doesn't reach users of the package.
The same warning was reported for dateProviderValue and idProviderValue. Nothing ever set those, so they were removed.
Options
- Store a type with a stable identity instead of a bare closure, e.g. a
final classthat holds the action, so the environment value compares by identity. A plain struct wrapper would only silence the warning. - Stop using the environment for this: pass the action to
MiscViewthrough the views in between, or give it a binding toisShowingAPIConfigModal.
Done when the Demo build no longer reports the warning and the API Configuration button still opens the screen.
- Lenguaje dominante
- Swift
- Estrellas
- 2.9k
- Forks
- 519
- Merge medio
- 1 d 17 h
- PR fusionados (30 d)
- 10
Preparar el entorno
- Sin Dockerfile ni archivo de Docker Compose
- Tiene una plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de MacPaw/OpenAI
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
Los mantenedores suelen responder en 2 días
-
Enable batch promptsAbierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
MacPaw/OpenAI#73 · 1 comentario · 1 reacción ·
Los mantenedores suelen responder en 2 días
-
bug
Dificultad 3/5 1-2 días Aptitud para principiantes 35/100
Los mantenedores suelen responder en 2 días
-
Dificultad 4/5 3-5 días Aptitud para principiantes 45/100
Los mantenedores suelen responder en 2 días
-
Wiz-remediation
Dificultad 5/5 Más de una semana Aptitud para principiantes 1/100
Los mantenedores suelen responder en 2 días
Todos los issues de MacPaw/OpenAI
Issues similares
-
area: agents area: layout S3: minor
Dificultad 2/5 1-3 horas Aptitud para principiantes 62/100
manaflow-ai/cmux#34277 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
priority: medium
Dificultad 2/5 1-3 horas Aptitud para principiantes 79/100
thunderbird/thunderbird-ios#599 ·
Los mantenedores suelen responder en 1 día
-
bug core p3
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
RunanywhereAI/runanywhere-sdks#1258 ·
Los mantenedores suelen responder en 1 día
-
bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 62/100
altic-dev/FluidVoice#1284 ·
Los mantenedores suelen responder en 1 día
-
enhancement
Dificultad 2/5 1-3 horas Aptitud para principiantes 62/100
Los mantenedores suelen responder en 1 día