Skip to content

[PB Extension] Create FW project#2394

Draft
imnasnainaec wants to merge 7 commits into
developfrom
pb-extension/create-project-api
Draft

[PB Extension] Create FW project#2394
imnasnainaec wants to merge 7 commits into
developfrom
pb-extension/create-project-api

Conversation

@imnasnainaec

@imnasnainaec imnasnainaec commented Jun 30, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Adds FwLiteApi.createProject(name, code, vernacularWs, analysisWs?) to the Platform.Bible extension's HTTP client, wrapping the POST /api/project/create endpoint added in Wire up template-based project creation via JSON snapshot import #2281.
  • Fixes a latent bug in fetchUrl: it previously called response.json() unconditionally, which throws a SyntaxError on empty-body responses (HTTP 200 with no content). The fix reads the body as text first and only parses JSON when the body is non-empty. This also silently affected deleteEntry.
  • Adds a Create new lexicon flow to the SelectLexicon WebView: a form with name, auto-derived code, and vernacular language tag (pre-filled from the Paratext project's language but editable), plus an optional analysis language tag. On success the new lexicon is auto-selected and the dialog shows the standard "Lexicon selection saved" confirmation.

Changes

  • platform.bible-extension/src/utils/fw-lite-api.ts
    • fetchUrl: results.json()results.text() + conditional JSON.parse
    • FwLiteApi.createProject: new public method using URLSearchParams for the create endpoint
  • platform.bible-extension/src/main.ts — registers lexicon.createLexicon command
  • platform.bible-extension/src/types/lexicon.d.ts'lexicon.createLexicon' command handler type
  • platform.bible-extension/src/types/localized-string-keys.ts + contributions/localizedStrings.json — 8 new %lexicon_createLexicon_*% strings
  • platform.bible-extension/src/components/create-lexicon.tsx — new form component
  • platform.bible-extension/src/components/lexicon-combo-box.tsx — optional onCreateNew prop adds the "Create new lexicon" button
  • platform.bible-extension/src/utils/project-manager.ts — passes the project's vernacular language tag when opening the SelectLexicon WebView
  • platform.bible-extension/src/web-views/select-lexicon.web-view.tsx — wires up the create flow with auto-selection on success

Implemented by Claude Sonnet 4.6 via Claude Code.

Devin review: https://app.devin.ai/review/sillsdev/languageforge-lexbox/pull/2394

Closes #2061

@coderabbitai

coderabbitai Bot commented Jun 30, 2026

Copy link
Copy Markdown

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: c7bf2a74-50aa-4c72-84b8-3987468d0fe1

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
  • Commit unit tests in branch pb-extension/create-project-api

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.

@imnasnainaec imnasnainaec self-assigned this Jun 30, 2026
@imnasnainaec imnasnainaec changed the title Add FwLiteApi.createProject (closes #2061) [PB Extension] Create FW project Jun 30, 2026

@myieye myieye left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Generally looks fine to me. 👍


function isValidLangTag(tag: string): boolean {
try {
return Intl.getCanonicalLocales(tag).length === 1;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

What's the === 1 about? I'd expect >= 1.

Comment thread platform.bible-extension/src/components/create-lexicon.tsx
async getProjects(): Promise<IProjectModel[]> {
return (await this.fetchPath('localProjects')) as IProjectModel[];
const projects = (await this.fetchPath('localProjects')) as IProjectModel[];
projects.forEach((p) => FwLiteApi.projectTypeByCode.set(p.code, p.crdt ? 'Harmony' : 'FwData'));

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

If I'm not mistaken, these projects are sometimes flagged as both crdt and fwdata.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Correct, and if the project has both flags, don't we want to default to Harmony interaction?

imnasnainaec and others added 6 commits July 2, 2026 16:52
`fetchUrl` now reads the response as text before conditionally parsing
JSON, so endpoints that return an empty 200 (like DELETE entry and the
new project/create route) no longer throw a SyntaxError.

`FwLiteApi.createProject` wraps `POST /api/project/create`, which was
added in #2281 to resolve #1920. Closes #2061.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Adds an end-to-end flow for creating a new FW Lite CRDT project from
within the SelectLexicon dialog:
- New `lexicon.createLexicon` PAPI command wrapping FwLiteApi.createProject
- New CreateLexicon form component (name, auto-derived code, vernacular
  WS pre-filled from the Paratext project language, optional analysis WS)
- "Create new lexicon" button in LexiconComboBox opens the form
- On successful creation the new lexicon is auto-selected and the dialog
  shows the standard "Lexicon selection saved" confirmation

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…key order

- fw-lite-api: add static projectTypeByCode cache (shared across FwLiteApi
  instances including EntryService) so CRDT projects created via createProject
  route through mini-lcm/Harmony/... instead of mini-lcm/FwData/...
  getProjects() populates the cache; createProject() seeds 'Harmony' immediately
  so the writingSystems call in selectLexicon succeeds without a re-fetch
- fw-lite-api: include response body text in error messages so backend
  validation failures (duplicate code, invalid lang tag, etc.) reach the logger
- create-lexicon: validate vernacular and analysis language tags with
  Intl.getCanonicalLocales() before enabling the submit button
- localized-string-keys / localizedStrings.json: restore alphabetical ordering

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- deriveCode now replaces invalid characters with '-' instead of removing
  them, matching the backend SanitizeProjectCode behavior
- WebView onCreated catches selectLexicon failure: logs the error, refreshes
  the lexicon list, and falls back to the combo box so the user can manually
  select the project that was created on disk

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
The Svelte frontend routes FwData projects via /paratext/fwdata/{code}
and CRDT/Harmony projects via /paratext/project/{code}. The standalone
getBrowseUrl always used 'fwdata', producing a broken URL for any
Harmony lexicon.

Move getBrowseUrl into FwLiteApi as a method so it can consult the
projectTypeByCode cache and emit 'project' vs 'fwdata' accordingly.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Hints the default analysis writing system on the Create new lexicon form,
per review feedback.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@imnasnainaec imnasnainaec force-pushed the pb-extension/create-project-api branch from 26cae9e to 77b6250 Compare July 2, 2026 20:52
Display the backend error message (e.g. duplicate code, invalid language
tag) instead of only logging it, per review feedback. Also drop the now-
pointless useCallback around handleSubmit.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Create a new project via the MiniLCM API

2 participants