[PB Extension] Handle a missing lexicon without exposing full FW Lite - #2547
Conversation
When a project's stored lexicon code pointed at a lexicon that no longer
exists, "Browse lexicon" left FW Lite in its unrestricted view with the
project switcher enabled.
FW Lite only learned it was embedded in Paratext inside
`projectContext.setup()`, which runs after the project opens. A missing
lexicon makes `openCrdtProject`/`openFwDataProject` throw, so `setup()`
never ran and `inParatext` stayed false. The CSS-gated restrictions still
applied (`data-paratext` is on the DOM from first render), but the
switcher's `disabled={projectContext.inParatext}` did not, so the user
could navigate to `/project/<code>` and out of the embedded view.
- Set `inParatext` on the project context at construction, so the
restriction holds while the project loads and if it never loads.
- Ignore project selection in the sidebar while in Paratext.
- Notify the user when a stored lexicon no longer resolves, instead of
only logging before clearing it and reopening the selector.
- Validate the lexicon code in `displayEntry`, which bypassed the
existing check and handed a dead code straight to the browse URL.
- Return 404 rather than 500 for a missing project from the mini-lcm
routes, so clearing the user's lexicon choice is driven by a definitive
answer and not by a transient backend fault (#2487).
Fixes #2440
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
|
Important Review skippedAuto incremental reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (7)
📝 WalkthroughWalkthroughThe changes add explicit project route error statuses, separate Paratext mode from project setup, block project switching in Paratext, and improve recovery when a stored lexicon code is no longer valid. ChangesProject and lexicon selection handling
Estimated code review effort: 3 (Moderate) | ~20 minutes Possibly related PRs
Suggested reviewers: Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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. Comment |
|
The latest updates on your projects. Learn more about Argos notifications ↗︎
|
- Return 400 for the mini-lcm filter's other client-error paths (invalid
project type, blank project code), which still defaulted to 500, and
fix the garbled "Invalid project {type} type" message.
- Treat 400 as well as 404 as a definitive "this code can't resolve" in
the extension's validity check. A whitespace-only lexicon code reaches
the blank-code branch, so a 404-only check would have accepted it.
- Make `inParatext` one-way: dev throws and prod logs on an attempt to
turn it back off, mirroring how `projectCode` refuses re-assignment.
- Warn in dev when a project selection is ignored in Paratext, so an
unexpected reach past the disabled dropdown is visible rather than
silent.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
hahn-kev
left a comment
There was a problem hiding this comment.
looks good to me, Looking at how project-context is created I think I want to refactor it, but that's out of scope of this PR.
When a project's stored lexicon code points at a lexicon that no longer exists, "Browse lexicon" left FW Lite in its unrestricted view with the project switcher enabled, letting the user navigate out of the embedded experience.
FW Lite only learned it was embedded in Paratext inside
projectContext.setup(), which runs after the project opens. A missing lexicon makesopenCrdtProject/openFwDataProjectthrow, sosetup()never ran andinParatextstayedfalse. The CSS-gated restrictions still applied (data-paratextis on the DOM from first render), but the switcher'sdisabled={projectContext.inParatext}did not — that mismatch is the bug.inParatexton the project context at construction, so the restriction holds while the project is loading and if it never loads. This also covers the case whereresolveProjectTypefalls back toFwDatafor an unknown code and routes a Harmony project to the wrong view. The property is one-way: dev throws and prod logs on an attempt to turn it back off, mirroring howprojectCoderefuses re-assignment.displayEntry, which bypassed the existing check and handed a dead code straight to the browse URL.Test plan
Manual, with a Paratext project whose
lexicon.lexiconCodesetting names a lexicon that does not exist in FW Lite:lexicon.lexiconCodeis rejected by the project-settings validator.Automated:
svelte-checkclean, viewer unit tests pass (159), extension lint/build clean,FwLiteWebbuilds. Viewer browser tests were not run locally (Playwright chromium not installed); they don't touch this code, but CI covers them.Fixes #2440
Considered and rejected
Rendering a dedicated "lexicon not found" state in
DotnetProjectViewinstead of the current toast-plus-ViewErrorBoundarypath. It reads better, but it's a UX change beyond this bug, and the viewer's no-try/catch-around-async rule makes it more than a small diff. Worth a follow-up if the boundary message proves confusing.🤖 Generated with Claude Code