Skip to content

Broaden TPEN_CONTEXT.siblings to span all layers, not just the active one #566

Description

@thehabes

Surfaced during testing of the 5-2-tools-align cut (PR #564). The TPEN_CONTEXT.canvases array sent to tool iframes only includes pages from the single layer that contains the active page. For a project with multiple layers (e.g. "Layer 1 Page 1" + "Layer 2 Page 1"), only the active layer's pages reach the tool — Compare-Pages' dropdown is correspondingly limited.

This is a pre-existing gap, not introduced by #564. The legacy CANVASES payload (now removed) used the same single-layer .find(layer)?.pages?.flatMap(...) shape (see 1196c28:components/simple-transcription/index.js lines 1070-1072), so #getActiveLayerCanvases was a faithful 1:1 port — but the constraint pre-dates the contract cleanup and is worth lifting.

Required change

Broaden #getActiveLayerCanvases (in components/simple-transcription/index.js) to flatten across all layers, not just the active one. Likely shape:

#getProjectCanvases() {
  return TPEN.activeProject?.layers
    ?.flatMap(l => l.pages ?? [])
    .map(p => ({ id: p.target, label: p.label })) ?? []
}

Consider renaming to #getProjectCanvases since "active layer" no longer describes the result. Update the JSDoc on #buildTPENContext to clarify the list spans all layers.

Companion repo

Compare-Pages (CenterForDigitalHumanities/Compare-Pages) consumes canvases directly without filtering, so no code change is needed there once this lands. Its PR CenterForDigitalHumanities/Compare-Pages#3 will start showing the cross-layer list automatically.

Verification

On a multi-layer project, open /transcribe, attach Compare-Pages, and confirm the dropdown lists every page across every layer.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions