Skip to content

continue-working: canvas fallback fails because lightweight project lacks manifest URL #451

@thehabes

Description

@thehabes

Problem

The <tpen-continue-working> component fails to load thumbnail images when a canvas URI returns 404. The vault's getWithFallback() mechanism is designed to handle this by prefetching the manifest and finding the canvas data embedded within it, but the fallback never triggers.

Root Cause

In components/continue-working/index.js:182:

canvas = await vault.getWithFallback(canvasId, 'canvas', project.manifest)

The project object here comes from TPEN.userProjects, populated by GET /my/projects. This endpoint returns lightweight project summaries that do not include the manifest property. So project.manifest is undefined.

Inside getWithFallback(), the condition !result && manifestUrls evaluates to !null && undefinedfalse, and the manifest prefetch fallback is skipped entirely. The canvas 404 is treated as a final failure and falls through to a placeholder SVG.

Every other component in the codebase avoids this by using TPEN.activeProject?.manifest, which is a fully-fetched project (from GET /project/:id) that includes the manifest array.

Expected Behavior

When a canvas URI returns 404, the vault should fall back to the project's manifest(s), find the embedded canvas data, and extract the thumbnail image.

Suggested Approaches

  1. Raw fetch for manifest URL — In getProjectThumbnail(), make a targeted fetch() to GET /project/:id and extract just the .manifest array. Important: do not use Project.getById() since that dispatches tpen-project-loaded and would overwrite TPEN.activeProject, which is incorrect for the home page context. Only 1–3 extra fetches needed (one per card), and they can run in parallel with the existing annotation page fetches.

  2. Static helper on Project — Add something like Project.getManifest(id) that fetches the project and returns only the manifest field without side effects. Keeps it reusable for other lightweight contexts.

  3. Include manifest in /my/projects response — If the TPEN services API included the manifest array in the lightweight project summaries, no extra fetch would be needed. This is the cheapest client-side solution but requires a services change.

Reproduction

  • Project 698378c3c19363cc0b368ef4, page 698378c3c19363cc0b368ef6
  • Canvas 1 URI returns 404
  • Visit the home page where <tpen-continue-working> renders — the card shows a placeholder SVG instead of the manuscript image

Affected File

  • components/continue-working/index.jsgetProjectThumbnail() method (line ~173)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions