Skip to content

ADE-61: Avoid building APNs bridge service on every getAdeActionDomainServices call#437

Merged
arul28 merged 1 commit into
mainfrom
ade-61-avoid-building-apns-bridge-service-on-every-getadeactiondomainservices-call
May 30, 2026
Merged

ADE-61: Avoid building APNs bridge service on every getAdeActionDomainServices call#437
arul28 merged 1 commit into
mainfrom
ade-61-avoid-building-apns-bridge-service-on-every-getadeactiondomainservices-call

Conversation

@arul28
Copy link
Copy Markdown
Owner

@arul28 arul28 commented May 30, 2026

Fixes ADE-61

Summary

Describe the change.

What Changed

Key files and behaviors.

Validation

How you tested.

Risks

Anything to watch.

Linked Linear issues

ADE   Open in ADE  ·  ade-61-avoid-building-apns-bridge-service-on-every-getadeactiondomainservices-call branch  ·  PR #437

Greptile Summary

This PR avoids rebuilding the APNs bridge service on every getAdeActionDomainServices call by introducing a WeakMap-based cache keyed by AdeRuntime and converting notifications_apns from an eagerly-computed value to a lazy getter.

  • A module-level WeakMap<AdeRuntime, CachedApnsBridgeDomainService> stores the bridge instance and the three dependency references (projectConfigService, apnsService, apnsKeyStore) used to detect staleness; the cache is invalidated when any of those references change.
  • notifications_apns is now a getter in the returned object so APNs dependencies are not read at all when an unrelated domain is accessed, and three new tests cover the lazy initialisation, cache reuse, and cache invalidation paths.

Confidence Score: 5/5

Safe to merge — the change is a targeted performance optimisation with no behavioural regressions.

The WeakMap cache is keyed on the runtime object and invalidated whenever any of the three tracked dependency references change. The lazy getter correctly defers APNs dependency access, and the toService wrapper in the getter handles any falsy return from createApnsBridgeService. The getDeviceRegistryService closure captures runtime directly so it stays current even when syncService is replaced without a cache miss. All three critical paths (lazy skip, cache hit, cache invalidation) are covered by the new tests.

No files require special attention.

Important Files Changed

Filename Overview
apps/desktop/src/main/services/adeActions/registry.ts Introduces WeakMap cache and lazy getter for notifications_apns; logic is correct and cache invalidation covers all tracked dependencies.
apps/desktop/src/main/services/adeActions/registry.test.ts Adds three focused tests covering lazy evaluation, cache reuse across calls, and invalidation on dependency change; all cases look correct.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A["getAdeActionDomainServices(runtime)"] --> B["Return object with getter\nnotifications_apns"]
    B --> C{"Caller accesses\nnotifications_apns?"}
    C -- No --> D["APNs deps never read\n(lazy evaluation)"]
    C -- Yes --> E["getApnsBridgeDomainService(runtime)"]
    E --> F{"WeakMap cache hit?\n(runtime key exists)"}
    F -- No --> G["createApnsBridgeService(...)"]
    G --> H["Store in WeakMap\n{projectConfigService, apnsService,\napnsKeyStore, service}"]
    H --> I["Return service"]
    F -- Yes --> J{"Dependency refs equal?\n(projectConfigService ===\napnsService === apnsKeyStore)"}
    J -- Yes --> K["Return cached service"]
    J -- No --> G
    I --> L["toService(service)\nOpaqueService | null"]
    K --> L
Loading

Reviews (5): Last reviewed commit: "fix: memoize APNs ADE action bridge" | Re-trigger Greptile

@vercel
Copy link
Copy Markdown

vercel Bot commented May 30, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
ade Error Error May 31, 2026 7:08am

@linear-code
Copy link
Copy Markdown

linear-code Bot commented May 30, 2026

ADE-61

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 30, 2026

Warning

Review limit reached

@arul28, we couldn't start this review because you've reached your PR review rate limit.

More reviews will be available in 26 minutes and 39 seconds. Learn how PR review limits work.

Your organization has run out of usage credits. Purchase more in the billing tab.

⌛ How to resolve this issue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available.

Please see our Fair Usage Limits Policy for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 3b3c819c-c17a-4e14-b941-b9985348e14e

📥 Commits

Reviewing files that changed from the base of the PR and between 8dc8834 and c01f36f.

📒 Files selected for processing (2)
  • apps/desktop/src/main/services/adeActions/registry.test.ts
  • apps/desktop/src/main/services/adeActions/registry.ts
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch ade-61-avoid-building-apns-bridge-service-on-every-getadeactiondomainservices-call

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 and usage tips.

@capy-ai
Copy link
Copy Markdown

capy-ai Bot commented May 30, 2026

Capy auto-review is paused for this organization because the monthly auto-review limit has been reached. Increase the limit or turn it off in billing settings to resume automatic reviews.

@arul28
Copy link
Copy Markdown
Owner Author

arul28 commented May 30, 2026

@copilot review but do not make fixes

Comment thread apps/desktop/src/main/services/adeActions/registry.ts
@arul28
Copy link
Copy Markdown
Owner Author

arul28 commented May 30, 2026

@copilot review but do not make fixes

@arul28 arul28 force-pushed the ade-61-avoid-building-apns-bridge-service-on-every-getadeactiondomainservices-call branch from afb25f1 to 95ce639 Compare May 30, 2026 07:04
@arul28
Copy link
Copy Markdown
Owner Author

arul28 commented May 30, 2026

@copilot review but do not make fixes

@arul28 arul28 force-pushed the ade-61-avoid-building-apns-bridge-service-on-every-getadeactiondomainservices-call branch from 95ce639 to a970aa2 Compare May 30, 2026 07:19
@arul28
Copy link
Copy Markdown
Owner Author

arul28 commented May 30, 2026

@copilot review but do not make fixes

@arul28 arul28 force-pushed the ade-61-avoid-building-apns-bridge-service-on-every-getadeactiondomainservices-call branch from a970aa2 to c01f36f Compare May 30, 2026 07:45
@arul28
Copy link
Copy Markdown
Owner Author

arul28 commented May 30, 2026

@copilot review but do not make fixes

@arul28 arul28 merged commit ac6a438 into main May 30, 2026
28 of 29 checks passed
@arul28 arul28 deleted the ade-61-avoid-building-apns-bridge-service-on-every-getadeactiondomainservices-call branch May 30, 2026 08:08
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