Skip to content

fix(desktop): use the typed DefaultsKey for onboardingStep in tests - #12035

Closed
aryanorastar wants to merge 1 commit into
BasedHardware:mainfrom
aryanorastar:fix/onboarding-test-typed-defaults-key
Closed

aryanorastar wants to merge 1 commit into
BasedHardware:mainfrom
aryanorastar:fix/onboarding-test-typed-defaults-key

Conversation

@aryanorastar

@aryanorastar aryanorastar commented Aug 22, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Desktop Swift Static & Test Contracts is red on main, and every open desktop PR inherits the failure through its merge ref. The cause is two raw UserDefaults key strings in a test file:

OnboardingPersistenceClearingTests.swift:60:22: error: omi_inline_userdefaults_key Violation: Use DefaultsKey.swift for typed UserDefaults keys
OnboardingPersistenceClearingTests.swift:66:34: error: omi_inline_userdefaults_key Violation: Use DefaultsKey.swift for typed UserDefaults keys

The custom rule's regex is (?<!removeValue\()forKey:\s*", and this file is not in .swiftlint-baseline.json, so both are new violations rather than baselined debt.

DefaultsKey.onboardingStep already exists with the raw value "onboardingStep", so this is behavior-identical by construction — the same string reaches UserDefaults either way. The lines immediately around these two already used DefaultsKey.hasCompletedOnboarding.rawValue; these two were simply missed.

Verification

  • After the swap, the rule's regex no longer matches anywhere in the file (grep -P '(?<!removeValue\()forKey:\s*"' returns nothing).
  • The file is absent from .swiftlint-baseline.json (grep count 0), confirming these were flagged as new rather than pre-existing.
  • Diff is two lines, no behavior surface: DefaultsKey.onboardingStep.rawValue == "onboardingStep".

Verified with the pinned linter itself, through the repo's own lane:

$ scripts/pr-preflight --pr-body-file /tmp/pr-defaultskey.md
PR preflight passed: 19 checks in 48.38s.

desktop-swiftlint is one of those 19. To confirm the check was actually exercising this file rather than skipping it, I restored the two raw strings and re-ran:

<== FAIL desktop-swiftlint (0.50s)
Manifest checks failed: desktop-swiftlint

Then restored the fix and it passes again.

Product invariants affected

none

Failure-Class: none

Review in cubic

OnboardingPersistenceClearingTests reached for the raw string
"onboardingStep" in two places while the lines around it already used
DefaultsKey.hasCompletedOnboarding.rawValue. The custom SwiftLint rule
omi_inline_userdefaults_key flags exactly that shape, and this file is not
in .swiftlint-baseline.json, so both were new violations rather than
baselined debt:

  OnboardingPersistenceClearingTests.swift:60:22: error:
  omi_inline_userdefaults_key Violation: Use DefaultsKey.swift for typed
  UserDefaults keys

Desktop Swift Static & Test Contracts is red on main because of it, and
every open desktop PR inherits the failure through its merge ref, so the
whole desktop queue is blocked on a two-token change.

DefaultsKey.onboardingStep already exists with the raw value
"onboardingStep", so this is behavior-identical by construction -- the
same string reaches UserDefaults either way. After the swap the rule's
regex, (?<!removeValue\()forKey:\s*", no longer matches anywhere in the
file.
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@aryanorastar

aryanorastar commented Aug 22, 2026 •

Copy link
Copy Markdown
Collaborator Author

@Git-on-my-level this one is a two-line CI repair rather than a feature, so flagging it for a merge call ahead of my other PRs.

Desktop Swift Static & Test Contracts is red on main, and it blocks every desktop PR. The last completed run on main (08-21T20:25, the fix(desktop): keep onboarding account-scoped merge) failed on:

OnboardingPersistenceClearingTests.swift:60:22: error: omi_inline_userdefaults_key Violation: Use DefaultsKey.swift for typed UserDefaults keys
OnboardingPersistenceClearingTests.swift:66:34: error: omi_inline_userdefaults_key Violation: Use DefaultsKey.swift for typed UserDefaults keys

Both are still on main at 72a21e2a65. The file is absent from .swiftlint-baseline.json, so these are new violations rather than baselined debt — the rule's regex is (?<!removeValue\()forKey:\s*" and two raw "onboardingStep" strings slipped in while the lines immediately around them already used DefaultsKey.hasCompletedOnboarding.rawValue.

This is deterministic, not cosmetic. The desktop-swiftlint check runs swiftlint-wrapper.sh lint with no path arguments — it lints the whole tree against the baseline, so the manifest triggers decide only whether it runs, not what it covers. Any PR whose diff matches those triggers (desktop/macos/Desktop/Sources/**/*.swift, Tests/**/*.swift, the .swiftlint.yml/baseline) therefore inherits main's violations through its merge ref, regardless of its own content. Two confirmed so far: #12029, a Meet-detection fix that never touches OnboardingPersistenceClearingTests.swift, and #11452, whose only Swift file is a regenerated OmiApi.generated.swift client. Both failed on exactly these two lines.

To be precise about the blast radius: a desktop PR that changes no .swift file is unaffected — #11990 (manifest plus two Python files) went green on the same current main. So the rule is "touches a desktop Swift file", not "is a desktop PR". This PR is the exception among the former because it is the one that removes the violations.

The fix is behavior-identical by construction. DefaultsKey.onboardingStep already exists with the raw value "onboardingStep", so the same string reaches UserDefaults either way. Two lines, no production source touched.

Verified against the pinned linter, not by inspection. scripts/pr-preflight passes 19 checks on this head, desktop-swiftlint among them. To prove the check was actually exercising this file rather than skipping it, I restored the raw strings and re-ran:

<== FAIL desktop-swiftlint (0.50s)
Manifest checks failed: desktop-swiftlint

then restored the fix and it passes again. CI agrees: all four Swift jobs are green on this PR — Build & Tests, Release Compile, Static & Test Contracts, and Detect Changes.

One thing this is not: it is not blocking releases. I checked desktop_auto_release before writing this and it has succeeded hourly straight through the breakage (01:41, 00:22, 23:14, 22:14, 21:14 …).

Since it is someone else's merge that introduced it, I have no stake here beyond wanting the lane green; happy for anyone to take it over or land an equivalent fix. I am not bumping the rest of my queue with this.

Separately, and not a merge blocker: the same CI window keeps throwing unrelated Swift test failures, a different suite each run — RewindCaptureExclusionGenerationTests, SuggestedTasksStoreTests, KernelTurnRecordedProjectionTests, and ChatTranscriptGestureHarnessTests. Filing that separately with run links.

@Git-on-my-level

Copy link
Copy Markdown
Member

Thanks @aryanorastar — closing this one as superseded, with full credit for the diagnosis.

The root-cause analysis was exactly right: the two raw "onboardingStep" literals in desktop/macos/Desktop/Tests/OnboardingPersistenceClearingTests.swift — the defaults.set(18, forKey:) write and the XCTAssertNil(defaults.object(forKey:)) assertion in testCompletedOnboardingResetsWhenAuthenticatedOwnerChanges — were the only un-baselined omi_inline_userdefaults_key violations holding Desktop Swift Static & Test Contracts red on main. And the swap is behavior-identical, since DefaultsKey.onboardingStep already exists with rawValue "onboardingStep".

An equivalent fix landed on main directly in 822d373 ("fix(desktop): use the typed onboardingStep key in its test"), which also kept the deliberate wire-name literals in the key-list assertion. As of that commit, the file on main is byte-identical to this branch's version — same blob SHA c6781918 — so there is nothing left for this PR to merge, and the lane is green again.

The verification discipline here was excellent: proving the check actually covered this file by restoring the raw strings and re-running the pinned preflight, the blast-radius breakdown for #12029 and #11452, and confirming the release lane was unaffected. That write-up is what made the direct fix safe to land quickly. Appreciate the explicit "happy for anyone to land an equivalent fix" note — this close is exactly that, not a rejection.


by AI on behalf of David — if you need David’s attention urgently, please @Git-on-my-level and escalate with need human response.

@github-actions

Copy link
Copy Markdown
Contributor

Hey @aryanorastar 👋

Thank you so much for taking the time to contribute to Omi! We truly appreciate you putting in the effort to submit this pull request.

After careful review, we've decided not to merge this particular PR. Please don't take this personally — we genuinely try to merge as many contributions as possible, but sometimes we have to make tough calls based on:

  • Project standards — Ensuring consistency across the codebase
  • User needs — Making sure changes align with what our users need
  • Code best practices — Maintaining code quality and maintainability
  • Project direction — Keeping aligned with our product principles and locked invariants

Before your next PR, please skim:

  • PRODUCT.md — product north star
  • Product invariants — locked rules (shared chat, memory tiers, agent control plane, integrations, brand)

If this was declined for direction or taste, maintainers should cite an invariant ID or open a proposed one — ask if that citation is missing.

Your contribution is still valuable to us, and we'd love to see you contribute again in the future! If you'd like feedback on how to improve this PR or want to discuss alternative approaches, please don't hesitate to reach out.

Thank you for being part of the Omi community!

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

Labels

macOS superseded Superseded by a newer change on main

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants