Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Oct 28, 2025

Resolves #2080

Plan: Add PublishIn to Entry Editor ✅ COMPLETE

Understanding from exploration:

  • publishIn field already exists in IEntry interface as IPublication[]
  • getPublications() API method already exists in IMiniLcmJsInvokable
  • Need to add UI similar to semantic domains (multi-select)
  • Should only appear in FieldWorks (classic) view, NOT FieldWorks Lite
  • Should be the last field in EntryPrimitiveEditor (before senses)

Tasks:

  • Create publications service similar to parts-of-speech.svelte.ts
  • Add publishIn field to field-data.ts with help ID
  • Add publishIn field to view-data.ts (show only in FW_CLASSIC_VIEW)
  • Add PublishIn field to EntryEditorPrimitive.svelte using MultiSelect component
  • Add mock data for getPublications in InMemoryApiService
  • Update publications.ts to use WritingSystemService for consistent sorting and labels
  • Type check passed
  • Linter passed
  • Build passed

Recent Update (commit: Use WritingSystemService for publication sorting and labels)

Updated publications service to follow the parts-of-speech pattern:

  • Created PublicationService class with WritingSystemService integration
  • Publications are now sorted by their label (using pickBestAlternative)
  • Labels are computed once and reused for both display and sorting
  • Ensures consistent label values for sorting and display

💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

@coderabbitai
Copy link

coderabbitai bot commented Oct 28, 2025

Important

Review skipped

Auto incremental reviews are disabled on this repository.

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.

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

📝 Walkthrough

Walkthrough

This pull request introduces a new "publishIn" field to the entry editor system. It adds field configuration, a publications service layer, UI components for selecting publications via MultiSelect, mock API data, and translation entries across seven locales.

Changes

Cohort / File(s) Summary
Core publications service
frontend/viewer/src/lib/publications.ts, frontend/viewer/src/lib/in-memory-api-service.ts
New PublicationService class and usePublications hook created; service retrieves publications from project API, derives labeled/sorted current list, and provides getLabel() method. In-memory API implementation returns two mock publications.
Field and view configuration
frontend/viewer/src/lib/entry-editor/field-data.ts, frontend/viewer/src/lib/views/view-data.ts
Adds publishIn field to privateFieldData with helpId; extends allFields mapping with publishIn field (show: false, order: 8).
UI component
frontend/viewer/src/lib/entry-editor/object-editors/EntryEditorPrimitive.svelte
Imports publications service, initializes usePublications client, renders new Editor.Field.Root with MultiSelect for publishIn, sourcing options from publications.current with label and id selectors, respecting readonly state.
Localization
frontend/viewer/src/locales/{en,es,fr,id,ko,ms,sw}.po
Adds "Publish in" translation entries across all locales. English locale includes translated string; remaining locales (es, fr, id, ko, ms, sw) include placeholder entries with empty translations.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

  • publications.ts: Review new service architecture, resource handling, and label derivation logic with WritingSystemService integration
  • EntryEditorPrimitive.svelte: Verify MultiSelect binding, publications client initialization, and field visibility logic align with existing patterns
  • in-memory-api-service.ts: Confirm mock data structure matches IPublication interface expectations
  • Translation entries: Cross-check that msgid "Publish in" is consistently added across all locale files

Poem

🐰 A new field hops into the fray,
Publications now have their say!
MultiSelect blooms with data so fine,
Services and services align,
Locales wait (their turn's on the way)! 🌾

Pre-merge checks and finishing touches

✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The pull request title 'Add PublishIn field to entry editor' is directly related to the main change in the changeset. The PR adds a new publishIn field to the entry editor UI with supporting infrastructure across multiple files, including the field definitions, UI components, and service implementations. The title clearly and concisely summarizes this primary change from the developer's perspective.
Description check ✅ Passed The pull request description is well-detailed and directly related to the changeset. It outlines the plan for adding the PublishIn field, documents the exploration and understanding of existing interfaces, lists all the implementation tasks with checkmarks indicating completion, and provides context about the WritingSystemService integration in a recent commit. The description accurately reflects what was implemented across all modified files.

Note

Free review on us!

CodeRabbit is offering free reviews until Fri Nov 07 2025 to showcase some of the refinements we've made.

Comment @coderabbitai help to get the list of available commands and usage tips.

Copilot AI changed the title [WIP] Add PublishIn support to entry editor UI Add PublishIn field to entry editor Oct 28, 2025
Copilot AI requested a review from myieye October 28, 2025 17:00
Copilot finished work on behalf of myieye October 28, 2025 17:00
@github-actions github-actions bot added the 💻 FW Lite issues related to the fw lite application, not miniLcm or crdt related label Oct 29, 2025
@github-actions
Copy link

github-actions bot commented Oct 29, 2025

UI unit Tests

  1 files  ±0   45 suites  ±0   19s ⏱️ -9s
111 tests ±0  111 ✅ ±0  0 💤 ±0  0 ❌ ±0 
160 runs  ±0  160 ✅ ±0  0 💤 ±0  0 ❌ ±0 

Results for commit 78e8292. ± Comparison against base commit e7033b0.

♻️ This comment has been updated with latest results.

Copy link
Collaborator

@myieye myieye left a comment

Choose a reason for hiding this comment

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

@copilot The sorting of publications should use the same value as the labels (which you are correctly selecting). Take a look at parts-of-speech or semantic-domains.

@github-actions
Copy link

github-actions bot commented Oct 29, 2025

C# Unit Tests

130 tests  ±0   130 ✅ ±0   20s ⏱️ +2s
 20 suites ±0     0 💤 ±0 
  1 files   ±0     0 ❌ ±0 

Results for commit 78e8292. ± Comparison against base commit e7033b0.

♻️ This comment has been updated with latest results.

@argos-ci
Copy link

argos-ci bot commented Oct 29, 2025

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

Build Status Details Updated (UTC)
default (Inspect) ✅ No changes detected - Nov 6, 2025, 3:54 PM

Copy link
Contributor Author

Copilot AI commented Oct 29, 2025

@copilot The sorting of publications should use the same value as the labels (which you are correctly selecting). Take a look at parts-of-speech or semantic-domains.

Fixed in commit 3524539. The publications service now follows the parts-of-speech pattern - using WritingSystemService to compute labels and sort by those labels (via pickBestAlternative). This ensures publications are sorted using the same value displayed to the user.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • fonts.googleapis.com
    • Triggering command: node /home/REDACTED/work/languageforge-lexbox/languageforge-lexbox/frontend/viewer/node_modules/.bin/../vite/bin/vite.js build (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Copilot finished work on behalf of myieye October 29, 2025 16:40
Copilot AI requested a review from myieye October 29, 2025 16:40
@myieye myieye marked this pull request as ready for review November 3, 2025 14:22
@myieye
Copy link
Collaborator

myieye commented Nov 3, 2025

@coderabbitai full review

@coderabbitai
Copy link

coderabbitai bot commented Nov 3, 2025

✅ Actions performed

Full review triggered.

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: 0

🧹 Nitpick comments (7)
frontend/viewer/src/lib/in-memory-api-service.ts (1)

368-371: Stub looks good; drop redundant field and minor identity tweak optional

Returning concrete publications unblocks UI. You can remove deletedAt: undefined (redundant if optional). Optionally hoist the list to a file/class constant to avoid a new array identity on each call.

-    return Promise.resolve([
-      {id: '1', name: {en: 'Main Dictionary'}, deletedAt: undefined},
-      {id: '2', name: {en: 'School Dictionary'}, deletedAt: undefined},
-    ]);
+    return Promise.resolve([
+      {id: '1', name: {en: 'Main Dictionary'}},
+      {id: '2', name: {en: 'School Dictionary'}},
+    ]);

(Optional outside this hunk)

// At top-level in this file:
const MOCK_PUBLICATIONS: IPublication[] = [
  {id: '1', name: {en: 'Main Dictionary'}},
  {id: '2', name: {en: 'School Dictionary'}},
];

// And in getPublications():
return Promise.resolve(MOCK_PUBLICATIONS);
frontend/viewer/src/locales/es.po (1)

937-940: Provide an initial Spanish translation for this new key

Suggest “Publicar en” to match UI context.

 msgid "Publish in"
-msgstr ""
+msgstr "Publicar en"
frontend/viewer/src/locales/id.po (1)

937-940: Add Indonesian translation

Suggest “Terbitkan di”.

 msgid "Publish in"
-msgstr ""
+msgstr "Terbitkan di"
frontend/viewer/src/locales/ko.po (1)

937-940: Add Korean translation

Suggest “게시 대상”.

 msgid "Publish in"
-msgstr ""
+msgstr "게시 대상"
frontend/viewer/src/locales/fr.po (1)

937-940: Add French translation

Suggest “Publier dans”.

 msgid "Publish in"
-msgstr ""
+msgstr "Publier dans"
frontend/viewer/src/locales/sw.po (1)

937-940: Add Swahili translation

Suggest “Chapisha katika”.

 msgid "Publish in"
-msgstr ""
+msgstr "Chapisha katika"
frontend/viewer/src/lib/entry-editor/object-editors/EntryEditorPrimitive.svelte (1)

128-140: Consider using pre-computed labels for efficiency.

The implementation is functionally correct and follows the established MultiSelect pattern. However, publications.current already includes computed labels (see LabeledPublication type in publications.ts, line 6), so the labelSelector is recomputing labels unnecessarily.

Apply this diff to use the pre-computed labels:

       <MultiSelect
           onchange={() => onFieldChanged('publishIn')}
           bind:values={entry.publishIn}
           options={publications.current}
-          labelSelector={(pub) => publications.getLabel(pub)}
+          labelSelector={(pub) => pub.label}
           idSelector="id"
           sortValuesBy="selectionOrder"
           {readonly} />

This eliminates redundant label computation and ensures consistent labels by using the values computed during sorting in publications.current.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between e7033b0 and 3524539.

📒 Files selected for processing (12)
  • frontend/viewer/src/lib/entry-editor/field-data.ts (1 hunks)
  • frontend/viewer/src/lib/entry-editor/object-editors/EntryEditorPrimitive.svelte (3 hunks)
  • frontend/viewer/src/lib/in-memory-api-service.ts (1 hunks)
  • frontend/viewer/src/lib/publications.ts (1 hunks)
  • frontend/viewer/src/lib/views/view-data.ts (1 hunks)
  • frontend/viewer/src/locales/en.po (1 hunks)
  • frontend/viewer/src/locales/es.po (1 hunks)
  • frontend/viewer/src/locales/fr.po (1 hunks)
  • frontend/viewer/src/locales/id.po (1 hunks)
  • frontend/viewer/src/locales/ko.po (1 hunks)
  • frontend/viewer/src/locales/ms.po (1 hunks)
  • frontend/viewer/src/locales/sw.po (1 hunks)
🧰 Additional context used
🧠 Learnings (2)
📚 Learning: 2025-06-02T14:27:02.745Z
Learnt from: myieye
Repo: sillsdev/languageforge-lexbox PR: 1720
File: frontend/viewer/src/locales/es.json:1786-1790
Timestamp: 2025-06-02T14:27:02.745Z
Learning: Spanish locale file (frontend/viewer/src/locales/es.json) contains generated code that may have null line numbers in origin entries due to limitations in the code generation process.

Applied to files:

  • frontend/viewer/src/locales/es.po
📚 Learning: 2025-07-30T04:53:41.702Z
Learnt from: rmunn
Repo: sillsdev/languageforge-lexbox PR: 1844
File: frontend/viewer/src/lib/entry-editor/ItemListItem.svelte:26-37
Timestamp: 2025-07-30T04:53:41.702Z
Learning: In frontend/viewer/src/lib/entry-editor/ItemListItem.svelte, the TODO comments for unused props `index` and `actions` are intentional reminders for future work to be completed in a separate PR, not issues to be resolved immediately. These represent planned functionality that will be implemented later.

Applied to files:

  • frontend/viewer/src/lib/entry-editor/object-editors/EntryEditorPrimitive.svelte
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (7)
  • GitHub Check: Build UI / publish-ui
  • GitHub Check: Build API / publish-api
  • GitHub Check: Build FW Lite and run tests
  • GitHub Check: frontend
  • GitHub Check: check-and-lint
  • GitHub Check: frontend-component-unit-tests
  • GitHub Check: Analyze (csharp)
🔇 Additional comments (7)
frontend/viewer/src/lib/entry-editor/field-data.ts (1)

18-18: Add looks correct; please verify help link path

Help ID path format matches neighbors, but the segment Publication_Settings_flds differs from typical Entry_level_fields/Sense_level_fields. Confirm it resolves to the intended doc.

frontend/viewer/src/locales/en.po (1)

932-935: LGTM

English translation present and consistent.

frontend/viewer/src/lib/views/view-data.ts (1)

19-19: LGTM! Field configuration aligns with requirements.

The publishIn field is correctly configured with show: false and order: 8, ensuring it's hidden in FieldWorks Lite but visible in FieldWorks Classic (via the [defaultDef]: {show: true} spread on line 47). The order places it as the last entry field before senses, as specified in the PR objectives.

frontend/viewer/src/locales/ms.po (1)

937-939: LGTM! Translation key properly added.

The new "Publish in" translation entry follows the standard localization pattern. The empty msgstr is expected and will be populated by translators in a future update.

frontend/viewer/src/lib/entry-editor/object-editors/EntryEditorPrimitive.svelte (1)

12-12: LGTM! Service initialization follows established patterns.

The import and initialization of the publications service is consistent with the complexFormTypes service pattern used elsewhere in this component.

Also applies to: 36-36

frontend/viewer/src/lib/publications.ts (2)

1-15: LGTM! Hook implementation follows established service patterns.

The usePublications hook correctly implements the singleton pattern using Symbol.for and getOrAdd, consistent with other service initializations in the codebase. The type definition for LabeledPublication appropriately extends IPublication with a computed label.


17-39: LGTM! Service structure is clean and efficient.

The PublicationService correctly:

  • Fetches publications using the project context's API resource
  • Computes labels once within the reactive $derived.by block and reuses them for sorting
  • Uses localeCompare for internationalization-friendly sorting
  • Provides a refetch method for data refresh

The implementation aligns with the PR description's goal of computing labels once and reusing them for consistency.

Copilot AI and others added 8 commits November 3, 2025 16:07
Co-authored-by: myieye <12587509+myieye@users.noreply.github.com>
Co-authored-by: myieye <12587509+myieye@users.noreply.github.com>
Co-authored-by: myieye <12587509+myieye@users.noreply.github.com>
@myieye myieye force-pushed the copilot/add-publishin-to-entry-editor branch from 3524539 to 2320e2e Compare November 3, 2025 15:08
@myieye myieye mentioned this pull request Nov 4, 2025
@myieye myieye merged commit 9f6ff7f into develop Nov 7, 2025
27 checks passed
@myieye myieye deleted the copilot/add-publishin-to-entry-editor branch November 7, 2025 08:22
@myieye myieye linked an issue Nov 28, 2025 that may be closed by this pull request
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.

Add PublishIn to entry editor

3 participants