Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Dec 16, 2025

Pages with no line annotations displayed blank instead of showing the canvas image. updateTranscriptionImages() returned early when thisLine was undefined, preventing canvas setup.

Changes

  • Handle empty pages: When this.#page.items?.[0] is undefined, extract canvasID from page target via setCanvasAndSelector(null, this.#page) and render full canvas
  • Default region: Display top 10% of canvas height (120px fallback) matching existing behavior for pages with lines
  • User guidance modal: Added dismissible alert that appears when a page has no line annotations, providing:
    • Clear message about missing line annotations
    • Link to annotation interface (/interfaces/annotator) with properly encoded project and page IDs
    • "Got it" button to dismiss the alert
// Handle pages with no lines - still load the canvas
if (!thisLine) {
  const { canvasID } = this.setCanvasAndSelector(null, this.#page)
  if (!canvasID) return
  const canvas = this.#canvas = await vault.get(canvasID, 'canvas')
  const regionValue = `0,0,${canvas?.width ?? 'full'},${(canvas?.height && canvas?.height / 10) ?? 120}`
  topImage.canvas = canvasID
  bottomImage.canvas = canvas
  topImage.setAttribute('region', regionValue)
  // Show alert to inform user about missing lines
  this.showNoLinesAlert()
  return
}

Security

  • URL parameters are properly encoded using encodeURIComponent() to prevent injection vulnerabilities
  • DOM elements created programmatically (no innerHTML) for secure content rendering
  • Styles added via <style> element instead of inline styles
Original prompt

This section details on the original issue you should resolve

<issue_title>Loading Temp Pages in Transcribe Interface</issue_title>
<issue_description>I thought we previously had something special for this. It loads, but it is blank


Image

I attempted to change lines to get the image to load, but it didn't do anything and caused console errors, probably because this project has never been given a line. </issue_description>

<agent_instructions>review the code for possible mishandling when pages load that have no lines or pages. The default behavior should prevent this, as the project should only be able to exist with at least one layer and page, though it might not have lines on it.</agent_instructions>

Comments on the Issue (you are @copilot in this section)


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Handle pages without lines in updateTranscriptionImages by still loading and displaying the canvas even when there are no line annotations. Shows the full page image instead of returning early.

Co-authored-by: cubap <1119165+cubap@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix loading of temp pages in transcribe interface Fix blank canvas on pages without line annotations Dec 16, 2025
Copilot AI requested a review from cubap December 16, 2025 22:47
Copy link
Member

@cubap cubap left a comment

Choose a reason for hiding this comment

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

also include a dismissible modal that the page has no lines with a line to the annotation interface to define lines manually.

Copilot AI and others added 2 commits December 16, 2025 22:57
Shows an alert when a page has no line annotations with a link to the annotation interface where users can manually define lines. The alert is dismissible by clicking the "Got it" button.

Co-authored-by: cubap <1119165+cubap@users.noreply.github.com>
- Encode URL parameters to prevent injection vulnerabilities
- Replace innerHTML with DOM element creation for better security
- Add CSS via style element instead of inline styles
- Add fallback for potential future public API on AlertContainer

Co-authored-by: cubap <1119165+cubap@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Dec 16, 2025

also include a dismissible modal that the page has no lines with a line to the annotation interface to define lines manually.

Added in commit 65fa6e2. The modal appears when a page has no lines with a link to /interfaces/annotator?projectId=X&pageId=Y and can be dismissed by clicking "Got it". URL parameters are properly encoded for security.

Copilot AI changed the title Fix blank canvas on pages without line annotations Fix blank canvas on pages without line annotations and add user guidance Dec 16, 2025
Copilot AI requested a review from cubap December 16, 2025 23:01
@cubap cubap marked this pull request as ready for review December 17, 2025 18:31
@github-actions
Copy link
Contributor

github-actions bot commented Dec 17, 2025

@cubap
Copy link
Member

cubap commented Dec 17, 2025

This illustrates some issues in annotator that I believe are being handled elsewhere. The pageID is read correctly, but the fetch it fires is /interfaces/annotator/{pageID} instead of to the API.

@cubap cubap merged commit ce34d5b into main Dec 17, 2025
2 checks passed
@cubap cubap deleted the copilot/fix-temp-pages-loading branch December 17, 2025 18:52
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.

Loading Temp Pages in Transcribe Interface

2 participants