Skip to content

PT-2602: Main toolbar scroll group follows the active tab#2489

Closed
lyonsil wants to merge 1 commit into
mainfrom
pt-2602-toolbar-follows-active-tab
Closed

PT-2602: Main toolbar scroll group follows the active tab#2489
lyonsil wants to merge 1 commit into
mainfrom
pt-2602-toolbar-follows-active-tab

Conversation

@lyonsil

@lyonsil lyonsil commented Jul 2, 2026

Copy link
Copy Markdown
Member

Summary

The main application toolbar's scroll group and Book/Chapter/Verse (BCV) control now follow the active (focused) scripture tab. Focus a tab synced to scroll group C and the toolbar switches to group C and shows that tab's reference — matching PT9's behavior. Previously the toolbar's scroll group was a standalone localStorage value with no awareness of the active tab.

Jira: PT-2602

Stacked on #2478 (please review that first)

This is based on pt-4036-versification-aware-sync (#2478), not main, because it depends on that PR's versification-aware useScrollGroupScrRef. This PR therefore targets pt-4036-versification-aware-sync as its base so its diff shows only the PT-2602 changes. Once #2478 merges, this branch will be rebased onto main and retargeted.

The toolbar passes the active tab's projectId to #2478's versification-aware hook, so the toolbar BCV shows the identical reference the active tab shows, even across versification divergence points (Psalm headings, 3 John, etc.).

Changes

  • New toolbar-internal hook src/renderer/components/use-active-tab-scroll-group.hook.ts — reads window focus (the platform.windowServiceDataProvider Focus type) and the focused WebView's saved definition to expose the last active scripture tab's { webViewId, scrollGroupId, projectId }, ignoring transient 'other'/non-webview focus (keep-last). Not exported through any shared barrel.
  • Toolbar wiring src/renderer/components/platform-bible-toolbar.tsx — a follow-effect (keyed on the active tab's identity) adopts the active tab's numbered scroll group; a small effectiveProjectId derivation (attached → the active tab's project; otherwise the driven group's own source project) replaces the currentProject?.id argument PT-4036/PT-4037: versification-aware synchronized scrolling #2478 introduced.
  • Design spec + implementation plan under docs/superpowers/.

Key design decisions (full rationale + PT9 source analysis in the spec)

  • Non-destructive top selector (intentional divergence from PT9): changing the top-bar scroll-group selector re-points what the toolbar drives; it does not re-group the active editor. PT10 already has a per-tab selector for that, so making the top one a second mutator would be redundant. The toolbar performs no write-back to any WebView definition.
  • Keep-last: when the active tab has no numbered scroll group (non-scripture WebView, or an independent "no scroll group" ref), the toolbar keeps its last group.
  • Override "move the verse, nothing else": navigating a group from the toolbar while overridden preserves that group's versification source.

AI Involvement

AI-assisted. The human developer (Matt Lyons) directed and reviewed every design decision. Workflow: collaborative brainstorming (including verifying the actual PT9 behavior against the Paratext 9 source), a written design spec, an implementation plan, then subagent-driven TDD implementation with an independent code review after each task and a whole-branch review before opening this PR. All code was human-reviewed. (Session link to be added.)

Testing

  • Unit tests pass — 25 tests (9 hook + 16 toolbar), including a falsifiable regression test guarding the synchronous definition derivation (no stale webViewId/group pairing on a tab switch).
  • npm run typecheck / npm run lint clean for the changed files.
  • Manual/visual verification — not yet run (why this is a draft): confirm in power mode that the toolbar BCV matches the active tab's displayed ref across a versification divergence point with two different-versification projects in one scroll group; plus a simple-mode display sanity check.

Risk Level

Low — additive, renderer-only, display-follow behavior; no new services or cross-process contracts; backward compatible (the platform-bible-toolbar.scrollGroupId localStorage key is retained); no write-back to WebView definitions.


This change is Reviewable

Base automatically changed from pt-4036-versification-aware-sync to main July 6, 2026 17:11
Building on #2478's versification-aware sync, the main toolbar adopts the
active scripture tab's numbered scroll group and renders its BCV in that
tab's versification (via the #2478 projectId), keeping the last group when
the active tab has none.

Adds a toolbar-internal useActiveTabScrollGroup hook that exposes the last
active scripture tab's scroll group + project from window focus and the
WebView definition (ignoring transient non-webview focus), deriving the
active-tab definition synchronously so webViewId and its definition update
in the same render. Includes the design spec and implementation plan.

Treats a project-bound tab with no persisted scrollGroupScrRef as the
default scroll group 0 (a freshly-opened reader/editor persists none until
the user changes its group), so the toolbar recognizes it as attached and
adopts its project for versification framing instead of falling back to the
group's stored source. Non-project tabs and detached (object) refs stay
unattached, so the toolbar keeps its last group.

Also stops the scroll-group service from reprocessing its own
platform.verseRef mirror echoes. Every group-0 verse change is mirrored out
to that setting; when a toolbar navigation and the editor's scroll-settle
write raced, a stale setting echo arrived after the stored ref had moved on
and — carrying no source frame — cleared the known versification source, so
followers stopped converting and both panels showed the same raw reference.
The subscription now recognizes and skips the values it just mirrored,
breaking the feedback loop; genuine external verseRef writers still flow
through.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01V8KSmVvarWfKxtutZhpRyA
@lyonsil lyonsil force-pushed the pt-2602-toolbar-follows-active-tab branch from 4b40d4d to 023790d Compare July 7, 2026 00:05
@lyonsil

lyonsil commented Jul 13, 2026

Copy link
Copy Markdown
Member Author

Done as part of #2519

@lyonsil lyonsil closed this Jul 13, 2026
@lyonsil lyonsil deleted the pt-2602-toolbar-follows-active-tab branch July 13, 2026 15:26
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.

1 participant