Skip to content

fix(cli): po loader push performance, multi-entry sections, pseudo mode crash#2064

Merged
AndreyHirsa merged 1 commit intomainfrom
fix/po-loader-push-and-pseudo-mode
Apr 2, 2026
Merged

fix(cli): po loader push performance, multi-entry sections, pseudo mode crash#2064
AndreyHirsa merged 1 commit intomainfrom
fix/po-loader-push-and-pseudo-mode

Conversation

@AndreyHirsa
Copy link
Copy Markdown
Contributor

@AndreyHirsa AndreyHirsa commented Apr 2, 2026

Summary

Fix PO loader push crashing on large files, missing entries in multi-entry sections, and pseudo mode crash due to missing validateSettings.

Changes

  • Fixed push parsing the entire target file for every section
  • Fixed push only translating the first entry when multiple entries share a section without blank lines between them
  • Added missing validateSettings to pseudo localizer so --pseudo mode no longer crashes

Testing

Business logic tests added:

  • Multi-entry section push translates all entries
  • All 18 PO loader tests pass locally

Visuals

N/A - no UI changes

Checklist

  • Changeset added (if version bump needed)
  • Tests cover business logic (not just happy path)
  • No breaking changes (or documented below)

Summary by CodeRabbit

  • Bug Fixes
    • Improved PO loader push performance
    • Fixed multi-entry section handling in PO files
    • Resolved crash in pseudo mode

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Apr 2, 2026

📝 Walkthrough

Walkthrough

This PR delivers a patch release for lingo.dev that addresses PO loader push performance, fixes multi-entry section handling, and resolves a pseudo mode crash. Changes include optimizations to the push operation, a new test case validating multi-entry translations, and an addition to the pseudo localizer's interface.

Changes

Cohort / File(s) Summary
Release & Changelog
.changeset/light-shrimps-hear.md
New changeset entry documenting patch release with fixes for PO loader push performance, multi-entry section handling, and pseudo mode crash.
PO Loader Tests
packages/cli/src/cli/loaders/po/index.spec.ts
Added test case verifying push() correctly translates multiple msgid/msgstr pairs in a contiguous PO section without blank line separators.
PO Loader Implementation
packages/cli/src/cli/loaders/po/index.ts
Refactored push logic: lazy-initialized currentSections, improved section matching fallback, changed merge behavior to handle multiple entries, and introduced resolveTargetHeaders() helper for conditional header extraction.
Pseudo Localizer
packages/cli/src/cli/localizer/pseudo.ts
Added validateSettings async method to pseudo localizer interface, resolving to { valid: true }.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~22 minutes

Possibly related PRs

Suggested reviewers

  • cherkanovart
  • ohmoses

Poem

🐰 With whiskers and optimized code,
We polish the PO loader's mode,
Multi-entries now blend with grace,
Pseudo crashes vanish without trace!

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 16.67% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately summarizes the three main fixes in the changeset: PO loader push performance, multi-entry sections handling, and pseudo mode crash.
Description check ✅ Passed The description includes all required sections: summary, changes, testing, visuals, and checklist. All key changes are documented with business logic tests added and confirmed to pass.

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

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/po-loader-push-and-pseudo-mode

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

Copy link
Copy Markdown
Contributor

@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.

🧹 Nitpick comments (1)
packages/cli/src/cli/loaders/po/index.ts (1)

66-86: Verify the section-matching logic for header-only sections.

Inside the if (!msgid) block, msgid is undefined. Line 83 compares csMsgid === msgid, which effectively checks csMsgid === undefined. This appears intentional for matching header-only sections, but the logic could be clearer.

Consider adding a comment to clarify the intent:

               const csMsgid = Object.keys(csEntries).find(
                 (key) => csEntries[key].msgid,
               );
+              // Match sections that both lack a real msgid (header-only sections)
               return csMsgid === msgid;
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/cli/src/cli/loaders/po/index.ts` around lines 66 - 86, The matching
branch using if (!msgid) currently compares csMsgid === msgid (i.e., ===
undefined) to detect header-only sections; update the block around
currentSections/currentSection to make the intent explicit by either changing
the comparison to check for absence of csMsgid (e.g., csMsgid == null) or adding
a clear inline comment explaining that csMsgid === undefined is intentionally
used to match header-only PO sections, referencing msgid, csPo, csContextKey,
csEntries and csMsgid so future readers understand this special-case logic.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@packages/cli/src/cli/loaders/po/index.ts`:
- Around line 66-86: The matching branch using if (!msgid) currently compares
csMsgid === msgid (i.e., === undefined) to detect header-only sections; update
the block around currentSections/currentSection to make the intent explicit by
either changing the comparison to check for absence of csMsgid (e.g., csMsgid ==
null) or adding a clear inline comment explaining that csMsgid === undefined is
intentionally used to match header-only PO sections, referencing msgid, csPo,
csContextKey, csEntries and csMsgid so future readers understand this
special-case logic.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: a7f9564e-aba7-42b0-bb91-345613734c81

📥 Commits

Reviewing files that changed from the base of the PR and between e490347 and 0b6247b.

📒 Files selected for processing (4)
  • .changeset/light-shrimps-hear.md
  • packages/cli/src/cli/loaders/po/index.spec.ts
  • packages/cli/src/cli/loaders/po/index.ts
  • packages/cli/src/cli/localizer/pseudo.ts

@AndreyHirsa AndreyHirsa merged commit 3140f2a into main Apr 2, 2026
10 checks passed
@AndreyHirsa AndreyHirsa deleted the fix/po-loader-push-and-pseudo-mode branch April 2, 2026 14:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants