Demo: fix the @Entry closure warning for showAPIConfiguration
维护者通常 2 天内回复
还没有人认领这个 Issue。
评估
调研方向
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.
由索引模型根据 Issue 内容生成。
描述
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.
- 主要语言
- Swift
- 星标
- 2.9k
- 派生
- 519
- 平均合并
- 3 天 12 小时
- 30 天内合并 PR
- 11
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
MacPaw/OpenAI 的其他 Issue
-
难度 2/5 1-3 小时 新手友好度 76/100
维护者通常 2 天内回复
-
难度 2/5 1-3 小时 新手友好度 68/100
MacPaw/OpenAI#73 · 1 条评论 · 1 个 reaction ·
维护者通常 2 天内回复
-
难度 3/5 1-2 天 新手友好度 55/100
维护者通常 2 天内回复
-
Demo release check 2026-10-27: failures, skips and notes可能已有人在做 关联的 PR 仍在进行中或已合并。 未关闭bug
难度 3/5 1-2 天 新手友好度 35/100
维护者通常 2 天内回复
-
难度 4/5 3-5 天 新手友好度 45/100
维护者通常 2 天内回复
相似的 Issue
-
feat: 앱 정보에 개인정보처리방침과 고객지원 연결可能已有人在做 @xrpjwk8 今天认领。 未关闭
难度 2/5 1-3 小时 新手友好度 62/100
DeveloperAcademy-POSTECH/2026-C6-A13-Hear-I-am#120 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 76/100
swiftlang/swift-java#955 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 78/100
michaelnisi/hanstholm#246 · 1 条评论 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 68/100
deepsealabs/libdc-swift#110 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 65/100
jaywcjlove/quick-rss#448 ·