Skip to content

Refine segment view#98

Merged
alex-rawlings-yyc merged 24 commits into
mainfrom
refine-segment-view
Jun 12, 2026
Merged

Refine segment view#98
alex-rawlings-yyc merged 24 commits into
mainfrom
refine-segment-view

Conversation

@alex-rawlings-yyc

@alex-rawlings-yyc alex-rawlings-yyc commented Jun 5, 2026

Copy link
Copy Markdown
Contributor

This change is Reviewable

Summary by CodeRabbit

  • New Features

    • Added a "Chapter Label in Verse" project setting and view toggle to display verse labels as "chapter:verse".
  • Improvements

    • Smoother cross‑book fade/recenter transitions and more stable visuals during navigation.
    • Improved scrolling, focus, and snap behavior across navigation jumps and view modes; segment list supports optional inline chapter labeling.
    • Click/focus handling refined to avoid unwanted auto-scrolling when interacting with phrase and gloss inputs.

@alex-rawlings-yyc alex-rawlings-yyc self-assigned this Jun 5, 2026
@coderabbitai

coderabbitai Bot commented Jun 5, 2026

Copy link
Copy Markdown

Review Change Stack

Note

Reviews paused

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • ✅ Review completed - (🔄 Check again to review again)
📝 Walkthrough

Walkthrough

Refactors navigation to a provider with cross-book fade, implements scroll-window + recenter/snap lifecycle, centralizes phrase-strip hooks, adds a chapter-label-in-verse setting with UI and wiring, and expands tests and test infrastructure.

Changes

Interlinearizer Navigation & Windowing Refactor

Layer / File(s) Summary
Navigation Context Foundation
src/components/InterlinearNavContext.tsx
Exports verse-0 normalization and verse-key utils, InterlinearNav interface, and InterlinearNavProvider managing live/normalized refs, internal-nav marks, and cross-book fade lifecycle with reportSettled/cancelFade.
Windowing & Recenter Infrastructure
src/hooks/useRecenterSnap.ts, src/hooks/useSegmentWindow.ts, src/components/recenter-fade.ts, src/components/SegmentListView.tsx
Adds useRecenterSnap for snap/settle lifecycle, useSegmentWindow for scroll-anchored windowing with sentinel-driven growth and resize compensation, shared recenter constants, and SegmentListView rendering windowed segments.
Phrase Strip Setup & View Refactoring
src/hooks/usePhraseStripSetup.ts, src/hooks/useLatestRef.ts, src/components/ContinuousView.tsx, src/components/SegmentView.tsx
Centralizes edit-token, arc-split, candidate-phrase-id, and strip-context hooks; adds useLatestRef; refactors ContinuousView/SegmentView to use hook-based wiring, tokenDocOrder, and fade-gated focus resolution.
Component Architecture Refactoring
src/components/Interlinearizer.tsx, src/components/InterlinearizerLoader.tsx, src/hooks/useInterlinearizerBookData.ts
Interlinearizer/Loader now use useInterlinearNav() instead of prop-based scrRef setters; focus derives from active segment; useInterlinearizerBookData returns full unfiltered book and stabilizes duplicate USJ results.
Chapter Label in Verse Feature
contributions/localizedStrings.json, contributions/projectSettings.json, src/components/controls/ViewOptionsDropdown.tsx, src/types/interlinearizer.d.ts, src/main.ts
Adds interlinearizer.chapterLabelInVerse project setting, localization, validator, ViewOptionsDropdown toggle, types, and passes setting into SegmentView to show chapter:verse inline label when enabled.
Test Infrastructure & Framework
jest.setup.intersection-observer.js, jest.config.ts
Adds an IntersectionObserver stub for Jest with instance registry and triggerIntersection; jest config loads the new setup file.
Test Coverage
src/__tests__/*
Extensive tests added/updated for InterlinearNavContext, useSegmentWindow, Interlinearizer/Loader/ContinuousView/SegmentView/ViewOptionsDropdown hooks and components, including cross-book fade, recenter timing, sentinel/window behaviors, and chapter-label toggle.
Configuration & Supporting Changes
cspell.json, src/main.ts
Added spell-check words (recentering/resnap/etc.); registered boolean validator for interlinearizer.chapterLabelInVerse and included registration in activation disposables.

Sequence Diagram

sequenceDiagram
  participant WebView as Host WebView
  participant Loader as InterlinearizerLoader
  participant Nav as InterlinearNavProvider
  participant Inter as Interlinearizer
  participant Window as useSegmentWindow
  participant Recenter as useRecenterSnap

  WebView->>Loader: useWebViewScrollGroupScrRef()
  Loader->>Nav: wrap subtree with provider
  Nav->>Inter: useInterlinearNav() => rawScrRef/scrRef/navigate()
  Inter->>Window: useSegmentWindow(scrRef, consumeInternalNav)
  alt External cross-book navigation
    Inter->>Nav: navigate(ref, 'external')
    Nav->>Inter: fadePhase='out'
    Inter->>Recenter: markRecenterStarted()
    Recenter->>Window: snapActiveToTop()
    Window->>Inter: rebuild windowSegments
    Recenter->>Inter: beginRecenterSettle() -> onSettled
    Nav->>Inter: fadePhase='in' then 'idle' after RECENTER_FADE_MS
  else Internal same-book navigation
    Inter->>Nav: navigate(ref, 'internal')
    Window->>Inter: update display refs immediately (no fade)
  end
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

Possibly related PRs

Suggested labels

🟥High, up next

Suggested reviewers

  • imnasnainaec
  • jasonleenaylor

Poem

🐇 A rabbit hopped through lines of code,
Wrapped fades and windows on the road,
Chapters stitched into a verse,
Tests to guard where things could worse,
A tiny toggle — neat and spry,
Hooray — the UI learns to sigh!

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 inconclusive)

Check name Status Explanation Resolution
Title check ❓ Inconclusive The title "Refine segment view" is vague and generic, using a non-descriptive term that doesn't clearly convey the scope of changes. Replace with a more specific title that highlights the main change, such as "Add chapter label in verse option and refactor navigation context" or "Implement InterlinearNav context and SegmentListView for navigation/fade coordination".
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Docstring Coverage ✅ Passed Docstring coverage is 94.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

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

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch refine-segment-view

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 and usage tips.

@alex-rawlings-yyc alex-rawlings-yyc linked an issue Jun 5, 2026 that may be closed by this pull request
@alex-rawlings-yyc alex-rawlings-yyc force-pushed the refine-segment-view branch 4 times, most recently from a18e2c8 to c78343e Compare June 10, 2026 16:44
@alex-rawlings-yyc alex-rawlings-yyc marked this pull request as ready for review June 11, 2026 16:11
coderabbitai[bot]

This comment was marked as outdated.

coderabbitai[bot]

This comment was marked as outdated.

@alex-rawlings-yyc

This comment was marked as outdated.

@coderabbitai

This comment was marked as outdated.

imnasnainaec and others added 2 commits June 12, 2026 14:17
…rse-0 dead code (#103)

Co-authored-by: Claude Fable 5 <noreply@anthropic.com>

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

@imnasnainaec partially reviewed 12 files.
Reviewable status: 12 of 38 files reviewed, all discussions resolved (waiting on alex-rawlings-yyc).

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

@alex-rawlings-yyc reviewed 38 files and all commit messages.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on alex-rawlings-yyc).

@alex-rawlings-yyc alex-rawlings-yyc merged commit b9dec18 into main Jun 12, 2026
11 checks passed
@alex-rawlings-yyc alex-rawlings-yyc deleted the refine-segment-view branch June 12, 2026 19:08
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.

Refine segment view

2 participants