Align with TPEN messaging contract — accept TPEN_CONTEXT, emit NAVIGATE_TO_LINE#14
Merged
Conversation
Drop the legacy MANIFEST_CANVAS_* and line-nav alias soup (SELECT_ANNOTATION / NAVIGATE_TO_LINE inbound / CURRENT_LINE_INDEX / RETURN_LINE_ID) and accept only the canonical pair: TPEN_CONTEXT for boot (canvas/manifest/annotationPage URIs + currentLineId) and UPDATE_CURRENT_LINE for line deltas. Outbound RETURN_LINE_ID renamed to NAVIGATE_TO_LINE — the canonical tool→parent line-selection name.
This was referenced May 8, 2026
Merged
loadPage is async and already highlights the active line via its 4th argument once annotations have rendered (viewer.js:90-95). Calling highlightAnnotation synchronously right after kicked off a no-op against an empty DOM and was redundant with loadPage's own behavior. Pass currentLineId through loadPage and drop the duplicate call.
cubap
approved these changes
May 8, 2026
| this.pageViewer.uiManager?.highlightAnnotation?.(lineRef) | ||
| #handleLineNavigation(currentLineId) { | ||
| if (!currentLineId) return | ||
| this.pageViewer.uiManager?.highlightAnnotation?.(currentLineId) |
Member
There was a problem hiding this comment.
We control the pageViewer so these optional checks all look a bit odd.
Member
Author
There was a problem hiding this comment.
Dropped both ?. chains in 008bd4f. Agreed — uiManager is unconditionally assigned in viewer.js:23 and highlightAnnotation is always a method on UIManager, so the optionals were just hiding regressions.
| // Standard navigation message - extract line ID and navigate | ||
| this.#handleLineNavigation(event.data) | ||
| case "UPDATE_CURRENT_LINE": | ||
| this.#handleLineNavigation(event.data.currentLineId) |
Member
There was a problem hiding this comment.
This will fail silently if event.data is malformed or currentLineId is somehow falsey.
Member
Author
There was a problem hiding this comment.
Added a console.warn for UPDATE_CURRENT_LINE messages missing the currentLineId field in 008bd4f. A null/empty value still flows through (treated as the parent's 'no active line' signal); only true contract violations now surface.
…ATE_CURRENT_LINE `uiManager` is unconditionally assigned in viewer.js; `highlightAnnotation` is unconditionally a method on UIManager. The optional chains in this file were treating internals like untrusted data and would silently swallow a regression. Drop them. Also surface a malformed UPDATE_CURRENT_LINE message (no `currentLineId` field at all) with a console.warn instead of silently no-oping. A null value still flows through as the parent's "no active line" signal. Addresses cubap's review on PR #14. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Align Page-Viewer with the canonical TPEN messaging contract. Replace the alias-soup switch (
MANIFEST_CANVAS_*,CANVAS_*,SELECT_ANNOTATION,CURRENT_LINE_INDEX,RETURN_LINE_ID) with the two messages we actually use:TPEN_CONTEXT(boot) andUPDATE_CURRENT_LINE(line-nav delta). Outbound, replaceRETURN_LINE_IDwithNAVIGATE_TO_LINE. The full contract is defined in CenterForDigitalHumanities/TPEN-interfaces#564.Changes
message-handler.jshandleMessageswitch reduced to two cases:TPEN_CONTEXT,UPDATE_CURRENT_LINE. Unknown types now silently ignored (was aconsole.warn).#handleTPENContextcallsloadPage(canvas, manifest, annotationPage, currentLineId)— the existing 4-arg signature highlights the matching overlay box internally once annotations render.ff25235): removed the redundanthighlightAnnotation(currentLineId)follow-up.loadPageis async and the sync follow-up hit an empty DOM, so the highlight wasn't reliably applied on boot.#handleLineNavigationsimplified to a single param (the new contract carriescurrentLineId, no alias hunting).ui-manager.jsRETURN_LINE_ID→NAVIGATE_TO_LINE; fieldlineid→lineId. Dropped the redundantlineIndexfield — the parent matches by id.Coordinated cut
Hard cut, all PRs must merge together. Full contract and other PRs:
Test plan
Developer-validated locally on 2026-05-08 against CenterForDigitalHumanities/TPEN-interfaces#564 + CenterForDigitalHumanities/TPEN-services#519 on
:4000/:3012:jekyll s), add Page-Viewer to a project's tools. Open/transcribe.ff25235confirmed.UPDATE_CURRENT_LINE).NAVIGATE_TO_LINE { lineId }).TPEN_CONTEXTper iframe load, one inboundUPDATE_CURRENT_LINEper parent-side line nav, one outboundNAVIGATE_TO_LINEper click. No legacy aliases observed.