Skip to content

Conversation

@myieye
Copy link
Collaborator

@myieye myieye commented Feb 10, 2026

Due to refactoring, the entry row loading skeletons now tend to get destroyed faster. And strangely enough even though they're skeletons, they trigger loading parts-of-speech from the back end. They're the first component to load parts of speech, which means the loading effect (inside the runed resource) is scoped to their lifecycle (this is a bad pattern that I hadn't noticed before. I wasted lots of time looking for a clean way to redesign stuff, but failed to find anything really elegant). Because they started getting destroyed sooner, they were getting destroyed before the parts of speech were even loaded, which meant that the parts of speech never got loaded for any component that needed them 🙀.

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

coderabbitai bot commented Feb 10, 2026

📝 Walkthrough

Walkthrough

This PR refactors the resource initialization logic in the project context by replacing a throttling-based mechanism with a queuing system that defers resource initialization until the API is available. The change introduces a queue for managing pending resource callbacks and generates unique identifiers for tracking resources.

Changes

Cohort / File(s) Summary
Project Context Refactoring
frontend/viewer/src/project/project-context.svelte.ts
Replaced throttling-based initial load logic with a queuing mechanism that defers resource initialization until the API is set up; removed watchOnce import, added randomId import, introduced #queuedResources state queue, and implemented callback-based initialization on API availability.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Suggested reviewers

  • rmunn

Poem

🐰 wiggles whiskers thoughtfully
Queue the resources, don't rush ahead,
Wait for the API to wake from bed,
Then spring them forth with hoppy pride! 🌟

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title 'Ensure api-resources are always loaded' directly aligns with the main objective of fixing a resource loading issue where API resources were being destroyed before completion.
Description check ✅ Passed The description explains the root cause (skeleton components destroyed sooner due to refactoring) and the impact (parts-of-speech loading was scoped to skeleton lifecycle), which is directly related to the changeset's solution of deferring resource initialization until the API is available.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix-parts-of-speech-never-loader

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
Copy link
Contributor

github-actions bot commented Feb 10, 2026

UI unit Tests

  1 files  ±0   50 suites  ±0   23s ⏱️ -2s
138 tests ±0  138 ✅ ±0  0 💤 ±0  0 ❌ ±0 
203 runs  ±0  203 ✅ ±0  0 💤 ±0  0 ❌ ±0 

Results for commit 4be66dd. ± Comparison against base commit a096927.

♻️ This comment has been updated with latest results.

@argos-ci
Copy link

argos-ci bot commented Feb 10, 2026

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

Build Status Details Updated (UTC)
default (Inspect) ✅ No changes detected - Feb 10, 2026, 1:23 PM

@github-actions
Copy link
Contributor

C# Unit Tests

146 tests  ±0   146 ✅ ±0   19s ⏱️ ±0s
 22 suites ±0     0 💤 ±0 
  1 files   ±0     0 ❌ ±0 

Results for commit 4be66dd. ± Comparison against base commit a096927.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

🤖 Fix all issues with AI agents
In `@frontend/viewer/src/project/project-context.svelte.ts`:
- Around line 119-122: The queued resource factories in setup()
(this.#queuedResources → factory(args.api)) get invoked twice because Svelte's
reactive resource source callback also calls factory(api); fix by ensuring only
one path runs: when you flush queued factories in setup(), mark those resources
as initialized (e.g., move their keys into a this.#initializedResources set or
delete them from this.#queuedResources) so the reactive resource source callback
can check that marker and early-return if the resource was already initialized;
alternatively, skip the flush and rely solely on the reactive path—apply the
change around the flush code that calls factory(args.api) and in the resource
source callback (the function that later calls factory(api)) to consult the same
marker before invoking factory.
- Around line 154-158: The queued factory promise can reject and currently
causes an unhandled rejection; update the callback stored in
this.#queuedResources[resourceId] (the function using
factory(api).then(res.mutate)) to handle errors by adding a .catch handler on
the Promise returned by factory(api) and surface the error (e.g., call a
resource error handler or log it) so failures don't become unhandled
rejections—ensure the callback uses factory(api).then(res.mutate).catch(err => {
/* handle or log err and notify resource */ }).
- Around line 120-121: The forEach callback currently uses the concise arrow
form which implicitly returns a value (Object.values(...).forEach(factory =>
factory(args.api));); update the callback to a block-bodied arrow that calls the
factory without returning anything—i.e., locate the Object.values<(api:
IMiniLcmJsInvokable) => void>(this.#queuedResources).forEach(...) line and
change the callback to use braces so it becomes factory => { factory(args.api);
} to satisfy the lint rule.

@myieye myieye merged commit 1d20393 into develop Feb 10, 2026
39 checks passed
@myieye myieye deleted the fix-parts-of-speech-never-loader branch February 10, 2026 14:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

💻 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