Repository navigation
Fix explicit-self capture breaking clean macOS builds of main - #8331
Conversation
The NSImage drawing handler is escaping, so referencing the enclosing view's color without an explicit capture fails to compile; capture the color by value. Unbreaks clean Debug builds of current main carried into this branch. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Sources/Sidebar/AppKitList/Cells/SidebarWorkspaceRowSlotViews.swift does not compile on a clean checkout: the NSImage drawing closure references the view's color property without explicit self, which Swift rejects in an escaping closure. macOS builds of main have been broken since the change landed (PR CI is disabled this week, so nothing caught it). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
📝 WalkthroughWalkthroughThe closed-state pull request icon rendering closure now explicitly captures the ChangesSidebar icon rendering
Estimated code review effort: 1 (Trivial) | ~2 minutes Possibly related issues
Possibly related PRs
🚥 Pre-merge checks | ✅ 25✅ Passed checks (25 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
| let tinted = NSImage(size: image.size, flipped: false) { [color] drawRect in | ||
| image.draw(in: drawRect, from: .zero, operation: .sourceOver, fraction: 1) | ||
| color.set() | ||
| self.color.set() |
There was a problem hiding this comment.
The capture list
[color] captures the property value by copy but then self.color.set() ignores that copy entirely and reads the property through self — so [color] is dead code and self is still captured strongly. The fix resolves the compiler error, but the capture list should either be removed (keep self.color.set()) or actually be used (drop the self. so the closure uses the copied value and avoids capturing self at all).
| let tinted = NSImage(size: image.size, flipped: false) { [color] drawRect in | |
| image.draw(in: drawRect, from: .zero, operation: .sourceOver, fraction: 1) | |
| color.set() | |
| self.color.set() | |
| let tinted = NSImage(size: image.size, flipped: false) { [color] drawRect in | |
| image.draw(in: drawRect, from: .zero, operation: .sourceOver, fraction: 1) | |
| color.set() |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@Sources/Sidebar/AppKitList/Cells/SidebarWorkspaceRowSlotViews.swift`:
- Around line 99-101: Update the NSImage drawing handler in the tinted image
construction to use the captured color snapshot via color.set() instead of
accessing self.color. Keep the existing image drawing behavior unchanged.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Pro
Run ID: 7dc13c5f-9130-4a48-910c-dae0655fd40e
📒 Files selected for processing (1)
Sources/Sidebar/AppKitList/Cells/SidebarWorkspaceRowSlotViews.swift
Sources/Sidebar/AppKitList/Cells/SidebarWorkspaceRowSlotViews.swift:101referencescolorinside theNSImage(size:flipped:)drawing closure without explicitself, which Swift rejects (escaping closure capture semantics). Clean checkouts of main fail to build the macOS app withreference to property 'color' in closure requires explicit use of 'self'; unnoticed because PR CI is off during the advisory experiment (second clean-build breakage this week after the unpushed bonsplit pointer, manaflow-ai/bonsplit#188).One line:
self.color.set(). Verified by compiling the tagged dev app from a checkout that previously failed.🤖 Generated with Claude Code
Need help on this PR? Tag
/codesmithwith what you need. Autofix is disabled.Summary by cubic
Fixes the macOS build by capturing the tint
[color]in the escapingNSImage(size:flipped:)drawing closure inSidebarWorkspaceRowSlotViews. This meets Swift capture rules, restores clean builds of main, and ensures pull request icons render with the correct tint.Written for commit d291005. Summary will update on new commits.
Summary by CodeRabbit