Skip to content

Fix release build: break up type-checker-stalling ?? chains#11

Open
ehs208 wants to merge 1 commit into
NewTurn2017:mainfrom
ehs208:fix/inbox-notification-typecheck
Open

Fix release build: break up type-checker-stalling ?? chains#11
ehs208 wants to merge 1 commit into
NewTurn2017:mainfrom
ehs208:fix/inbox-notification-typecheck

Conversation

@ehs208

@ehs208 ehs208 commented Jul 10, 2026

Copy link
Copy Markdown

Problem

swift build -c release (used by scripts/install-launchd.sh) fails to compile:

Sources/SharedKit/InboxNotification.swift:25:13: error: the compiler is unable to
type-check this expression in reasonable time; try breaking up the expression into
distinct sub-expressions

This blocks the launchd install entirely — the script never gets past the build step.

Cause

The body value is assembled from a long ?? chain mixing stringValue(for:) and nestedStringValue(...). Since ?? is an overloaded operator, a chain that long forces the Swift type-checker to explore too many overload combinations and time out. (Swift 6.0.3, arm64 macOS.)

Fix

Add a small firstStringValue(forAny:) helper on the payload dictionary that returns the first non-empty string among a list of keys, and use it to collapse the long ?? chains for workspaceId, title, body, surfaceId, id, subtitle, and threadId.

Key ordering (first match wins) is preserved, so behavior is unchanged — this is purely a readability + compile-time fix.

Verification

  • swift build -c releaseBuild complete!
  • swift test --filter SharedKitTests → all 37 tests pass (incl. InboxNotificationTests)
  • scripts/install-launchd.sh now runs to completion; agent reaches state = running and listens on 0.0.0.0:4399

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Bug Fixes
    • Improved inbox notification data extraction across supported payload formats.
    • Preserved existing fallback behavior when notification fields are missing or empty.
    • Increased consistency for workspace, title, body, surface, identifier, subtitle, and thread information.

`swift build -c release` failed to compile InboxNotification.swift:

  error: the compiler is unable to type-check this expression in
  reasonable time; try breaking up the expression into distinct
  sub-expressions

The `body` value was built from a long `??` chain mixing
`stringValue(for:)` and `nestedStringValue(...)`. Because `??` is an
overloaded operator, a chain that long makes the Swift type-checker
explore too many overload combinations and time out.

Introduce a `firstStringValue(forAny:)` helper that returns the first
non-empty string among a list of keys, and use it to collapse the long
`??` chains for workspaceId, title, body, surfaceId, id, subtitle, and
threadId. Key ordering (first match wins) is preserved, so behavior is
unchanged. Release build and all 37 SharedKitTests pass.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
@coderabbitai

coderabbitai Bot commented Jul 10, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 2eb72614-6f1e-4600-aa99-c321045ad091

📥 Commits

Reviewing files that changed from the base of the PR and between 9f805eb and ca3d9de.

📒 Files selected for processing (1)
  • Sources/SharedKit/InboxNotification.swift

📝 Walkthrough

Walkthrough

InboxNotification.record(from:now:) now uses a shared helper to select the first non-empty string from ordered payload keys, covering notification identifiers, content, workspace, surface, subtitle, and thread fields.

Changes

Inbox notification fallback extraction

Layer / File(s) Summary
Non-empty string fallback helper
Sources/SharedKit/InboxNotification.swift
Adds a private dictionary helper that returns the first non-empty string for an ordered list of keys.
Notification field extraction
Sources/SharedKit/InboxNotification.swift
Replaces repeated fallback chains with the helper for notification metadata and preserves the existing workspace default behavior.

Estimated code review effort: 2 (Simple) | ~10 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main change: splitting long ?? chains to fix a Swift release-build type-checker issue.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant