Skip to content

Introduce lazy API resource activation (lazyApiResource + LazyResource)#2201

Draft
myieye wants to merge 1 commit intodevelopfrom
codex/implement-lazy-loading-for-parts-of-speech
Draft

Introduce lazy API resource activation (lazyApiResource + LazyResource)#2201
myieye wants to merge 1 commit intodevelopfrom
codex/implement-lazy-loading-for-parts-of-speech

Conversation

@myieye
Copy link
Collaborator

@myieye myieye commented Mar 10, 2026

Motivation

  • Prevent automatic API calls before a resource is actually needed so throttling/cancellation or component teardown cannot swallow the initial fetch.
  • Allow registering project-scoped services (e.g. parts-of-speech) without forcing an immediate remote load.

Description

  • Added LazyResource class in project/lazy-resource.ts which wraps a runed ResourceReturn and only activates the underlying resource on first current read or refetch call.
  • Added lazyApiResource to ProjectContext in project/project-context.svelte.ts which composes a runed resource with an activation gate (LazyActivation) and returns a LazyResource that triggers the API factory on demand; apiResource now defaults to lazy when API is not yet available.
  • Reworked parts-of-speech.svelte.ts to use lazyApiResource so parts-of-speech are not fetched until needed.
  • Updated ShadcnProjectView.svelte to register the parts-of-speech service in project scope without forcing load.
  • Added a small LazyApiResourceHarness.svelte test helper used by tests.
  • Added unit/browser tests: lazy-resource.test.ts and lazy-api-resource.browser.test.ts that verify activation semantics and lazy fetch behavior.

Testing

  • Ran vitest unit tests including lazy-resource.test.ts, which passed.
  • Ran the browser-oriented test lazy-api-resource.browser.test.ts (via the test harness), which passed and confirmed the API factory is not called on initialization and that data is loaded after the first current read.

Codex Task

@coderabbitai
Copy link

coderabbitai bot commented Mar 10, 2026

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 4295d15a-0ec0-4c52-9d76-6dbf65f56614

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch codex/implement-lazy-loading-for-parts-of-speech

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.

@github-actions github-actions bot added the 💻 FW Lite issues related to the fw lite application, not miniLcm or crdt related label Mar 10, 2026
@github-actions
Copy link
Contributor

github-actions bot commented Mar 10, 2026

UI unit Tests

 1 files  ±  0   3 suites   - 51   0s ⏱️ -25s
10 tests  - 130  10 ✅  - 130  0 💤 ±0  0 ❌ ±0 
10 runs   - 197  10 ✅  - 197  0 💤 ±0  0 ❌ ±0 

Results for commit f82c026. ± Comparison against base commit 3f62d45.

This pull request removes 140 and adds 10 tests. Note that renamed tests count towards both.
src/lib/components/stomp/stomp-guard.svelte.test.ts ‑ StompGuard > accepts parent values when not dirty
src/lib/components/stomp/stomp-guard.svelte.test.ts ‑ StompGuard > does NOT guard against stomping deep changes, because StompGuard can't detect them
src/lib/components/stomp/stomp-guard.svelte.test.ts ‑ StompGuard > ignores parent values when dirty
src/lib/components/stomp/stomp-guard.svelte.test.ts ‑ StompGuard > initializes with the parent value
src/lib/components/stomp/stomp-guard.svelte.test.ts ‑ StompGuard > keeps subscribers up to date when it becomes dirty
src/lib/components/stomp/stomp-guard.svelte.test.ts ‑ StompGuard > pushs changes to parent
src/lib/components/stomp/stomp-guard.svelte.test.ts ‑ StompGuard > reverts new parent values when ignored
src/lib/components/stomp/stomp-guard.svelte.test.ts ‑ StompGuard > starts accepting parent changes again after a flush
src/lib/components/ui/format/format-duration.test.ts ‑ formatDuration > formats durations
src/lib/components/ui/format/format-duration.test.ts ‑ formatDuration > formats durations with smallest unit
…
src/index.test.ts ‑ password hashing > can hash a pw using sha1
src/lib/i18n/i18n.test.ts ‑ buildRegionalLocaleRegex > should find all regional locales for available locales
src/lib/i18n/i18n.test.ts ‑ pickBestLocale > should return en by default
src/lib/i18n/i18n.test.ts ‑ pickBestLocale > should return en if no user locale is provided and acceptLanguageHeader does not have any supported locales
src/lib/i18n/i18n.test.ts ‑ pickBestLocale > should return regional locale from acceptLanguageHeader if it has a higher quality rating than the regionless locale
src/lib/i18n/i18n.test.ts ‑ pickBestLocale > should return supported locale from acceptLanguageHeader with highest quality rating if no user locale is provided
src/lib/i18n/i18n.test.ts ‑ pickBestLocale > should return user locale if acceptLanguageHeader does not provide a regional/more specific locale
src/lib/i18n/i18n.test.ts ‑ pickBestLocale > should return user locale if acceptLanguageHeader does not provide a regional/more specific locale with a higher quality rating
src/lib/i18n/i18n.test.ts ‑ pickBestLocale > should return user locale if acceptLanguageHeader is not provided
src/lib/user.test.ts ‑ jwtToUser > should convert a jwt token to a LexAuthUser

♻️ This comment has been updated with latest results.

@argos-ci
Copy link

argos-ci bot commented Mar 10, 2026

The latest updates on your projects. Learn more about Argos notifications ↗︎

Build Status Details Updated (UTC)
default (Inspect) ✅ No changes detected - Mar 10, 2026, 2:35 PM

@github-actions
Copy link
Contributor

C# Unit Tests

162 tests  ±0   162 ✅ ±0   19s ⏱️ -1s
 23 suites ±0     0 💤 ±0 
  1 files   ±0     0 ❌ ±0 

Results for commit f82c026. ± Comparison against base commit 3f62d45.

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

Labels

codex 💻 FW Lite issues related to the fw lite application, not miniLcm or crdt related

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant