Skip to content

Show stale free translations in place (#374) - #378

Open
alex-rawlings-yyc wants to merge 15 commits into
mainfrom
feat/374-stale-free-translations
Open

alex-rawlings-yyc wants to merge 15 commits into
mainfrom
feat/374-stale-free-translations

Conversation

@alex-rawlings-yyc

@alex-rawlings-yyc alex-rawlings-yyc commented Sep 28, 2026 •

Copy link
Copy Markdown
Contributor

Closes #374. Part of #349.

A segment shows its stale free translations for review in its own box. A lone stale translation with text in the active language, standing in for an approved one, fills the input in stale styling, with Keep (re-approve it for the text as it now reads) and Discard; editing it and committing approves the result, its other languages included, while clearing it drops only that language's text and leaves the translation stale. Any other stale translations — several, one beside an approved translation, or one with no text in the active language — are listed under the input instead, with Keep offered only while the segment has no approval.

A translation whose segment vanished, such as a merged-away verse or a removed split, shows in the segment now covering where it began. This includes the reader's own boundary edits, which re-anchoring stales. A vanished heading's translation shows on its verse's heading of the same marker, else at the start of its verse. A translation of a verse the book no longer holds shows nowhere.

Re-anchoring follows a heading's translation to the heading of the same marker in its verse that reads exactly its old text, when adding or removing an earlier heading has shifted its id; where none or several do, it stays and goes stale.

The segment height estimate charges stale review rows, including the lines a long stale translation wraps onto. Checked in the running app.


This change is Reviewable

Summary by CodeRabbit

  • New Features
    • Review free translations that no longer match the text, with options to keep or discard them.
    • When no approved translation exists, continue editing a stale translation to adopt it. Missing translations in the active language are clearly labeled.
  • Bug Fixes
    • Translations for headings stay associated with the matching heading when headings are added or removed.

@alex-rawlings-yyc alex-rawlings-yyc self-assigned this Sep 28, 2026
@coderabbitai

coderabbitai Bot commented Sep 28, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

Important

  • 🔍 Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Advanced

Run ID: ccc31b39-e7cc-43db-b1fa-5d0961bc6b78

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Advanced

Run ID: 1b86f74d-75dc-4274-bd0c-30893c30b8e5

📥 Commits

Reviewing files that changed from the base of the PR and between 2ce1434 and 7185bc4.

📒 Files selected for processing (18)
  • contributions/localizedStrings.json
  • src/__tests__/components/AnalysisStore.test.tsx
  • src/__tests__/components/Interlinearizer.test.tsx
  • src/__tests__/components/SegmentFreeTranslationInput.test.tsx
  • src/__tests__/components/SegmentView.test.tsx
  • src/__tests__/store/analysisSlice.test.ts
  • src/__tests__/test-helpers.ts
  • src/__tests__/utils/reanchor-analysis.test.ts
  • src/__tests__/utils/segment-heights.test.ts
  • src/__tests__/utils/stale-free-translations.test.ts
  • src/components/AnalysisStore.tsx
  • src/components/SegmentFreeTranslationInput.tsx
  • src/components/SegmentListView.tsx
  • src/components/SegmentView.tsx
  • src/store/analysisSlice.ts
  • src/utils/reanchor-analysis.ts
  • src/utils/segment-heights.ts
  • src/utils/stale-free-translations.ts

Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.


📝 Walkthrough

Walkthrough

The change adds stale free-translation selection, placement, and review controls. Users can keep, edit, or discard stale translations. Height prediction accounts for review rows, and heading translations can follow uniquely matching re-keyed headings.

Changes

Stale Free Translation Review

Layer / File(s) Summary
Stale translation state and store access
src/store/analysisSlice.ts, src/components/AnalysisStore.tsx, src/__tests__/store/analysisSlice.test.ts, src/__tests__/components/AnalysisStore.test.tsx
The store adds actions and selectors to adopt, keep, and discard stale translations, and to identify approved translations. AnalysisStore exposes hooks for these operations and lookups. Tests cover the resulting state and selector behavior.
Stale translation placement and heading re-anchoring
src/utils/stale-free-translations.ts, src/utils/reanchor-analysis.ts, src/__tests__/utils/stale-free-translations.test.ts, src/__tests__/utils/reanchor-analysis.test.ts, src/__tests__/test-helpers.ts
Utilities place stale translations on covering segments and match re-keyed headings by stored baseline text. Tests cover placement cases, heading changes, and duplicate heading IDs.
Stale translation review controls
src/components/SegmentFreeTranslationInput.tsx, src/components/SegmentListView.tsx, src/components/SegmentView.tsx, contributions/localizedStrings.json, src/__tests__/components/SegmentFreeTranslationInput.test.tsx, src/__tests__/components/SegmentView.test.tsx
Segments display stale translations with Keep and Discard controls, use eligible stale text to initialize the input, and pass keep or discard actions to the store. Localized strings label the review controls and missing-language text.
Stale review height prediction
src/utils/segment-heights.ts, src/components/SegmentListView.tsx, src/__tests__/utils/segment-heights.test.ts, src/__tests__/components/Interlinearizer.test.tsx
Height prediction includes stale review text and controls, including wrapped text and off-screen segments. Tests cover review-row layouts and trailing spacer height.

Priority: ⬇️ Low

Estimated code review effort: 3 (Moderate) | ~25 minutes

Change: Feature

Sequence Diagram(s)

sequenceDiagram
  participant SegmentListView
  participant SegmentFreeTranslationInput
  participant AnalysisStore
  participant analysisSlice
  SegmentListView->>SegmentFreeTranslationInput: Pass stale translations for a segment
  SegmentFreeTranslationInput->>AnalysisStore: Request keep or discard
  AnalysisStore->>analysisSlice: Dispatch stale translation action
Loading

Suggested reviewers: imnasnainaec, jasonleenaylor

Merge Risk: ⚪ Minimal · up to 7185b

The change shows stale free translations in place with keep and discard controls. No merge-blocking risk was identified in the supplied evidence.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Linked Issues check ✅ Passed The PR implements the coding requirements in #374. SegmentFreeTranslationInput displays stale translations, initializes typing from an eligible stale value, and provides Keep and Discard controls. `…
Out of Scope Changes check ✅ Passed The changes stay within #374. Placement filtering, heading re-anchoring, height estimates, localized strings, and related tests support stale-translation display and review. The reviewed changes do no…
Docstring Coverage ✅ Passed Docstring coverage is 92.50% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 40 functions across 17 files. (1 skipped: 1…
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: showing stale free translations in their corresponding segment locations.
✨ Finishing Touches
📝 Generate docstrings
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR

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.

@alex-rawlings-yyc
alex-rawlings-yyc force-pushed the feat/374-stale-free-translations branch from 1b6635b to b8ad4a2 Compare September 29, 2026 17:34
@alex-rawlings-yyc
alex-rawlings-yyc force-pushed the feat/374-stale-free-translations branch from 6b67cdf to 1d520b4 Compare September 29, 2026 20:55
@alex-rawlings-yyc
alex-rawlings-yyc marked this pull request as ready for review September 29, 2026 22:16

@myieye myieye left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTC 😉

Heavily relied on AI for this review 🤖

⛏️ Is any of this worth an entry in user-questions.md?

Screenshots would definitely be nice for this sort of UI change 🙂. A few small things inline and one question, none blocking.

@myieye reviewed 18 files and all commit messages, and made 3 comments.
Reviewable status: all files reviewed, 2 unresolved discussions (waiting on alex-rawlings-yyc and jasonleenaylor).


src/components/AnalysisStore.tsx line 1059 at r1 (raw file):

  return useSelector((state: AnalysisRootState) =>
    selectSegmentHasApprovedTranslation(state.analysis, segmentId),

Suggestion: this runs an unmemoized .some() over every link, once per mounted input, on every store change. useSegmentsWithApprovedTranslation below already reads a memoized set; this could just read .has(segmentId) off that instead.


src/utils/stale-free-translations.ts line 104 at r1 (raw file):

    const { verse, offset } = positionOf(translation.segmentId);
    const places = placesByVerse.get(verse) ?? vanishedHeadingPlaces(verse, placesByVerse);
    if (!places) return [];

A translation whose verse the book no longer holds is kept in storage but can't be seen or discarded anywhere. Is that something we are at all worried about?

@alex-rawlings-yyc alex-rawlings-yyc left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

No user-questions.md entry: there's no one outside the team to put these to yet. Screenshots are below.

@alex-rawlings-yyc made 3 comments.
Reviewable status: all files reviewed, 2 unresolved discussions (waiting on jasonleenaylor and myieye).


src/components/AnalysisStore.tsx line 1059 at r1 (raw file):

Previously, myieye (Tim Haasdyk) wrote…

Suggestion: this runs an unmemoized .some() over every link, once per mounted input, on every store change. useSegmentsWithApprovedTranslation below already reads a memoized set; this could just read .has(segmentId) off that instead.

Done: the hook reads .has(segmentId) off the memoized set, and selectSegmentHasApprovedTranslation is gone.


src/utils/stale-free-translations.ts line 104 at r1 (raw file):

Previously, myieye (Tim Haasdyk) wrote…

A translation whose verse the book no longer holds is kept in storage but can't be seen or discarded anywhere. Is that something we are at all worried about?

Yes, but later: #349 left a wholly deleted verse's translation unreachable on purpose, for #143 (orphaned analyses) to pick up.

@alex-rawlings-yyc

Copy link
Copy Markdown
Contributor Author
02-full 378-lone 378-stacked

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.

Show stale free translations in place

2 participants