CenterForDigitalHumanities / CenterForDigitalHumanities/TPEN-interfaces

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

Open
#451 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
2
Forks
3
PR merge metrics
No merged PRs in 30d

Description

## Problem

The `` 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`:
```javascript
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 && undefined` → `false`, 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](https://github.com/CenterForDigitalHumanities/TPEN-services) change.

### Reproduction

- Project `698378c3c19363cc0b368ef4`, page `698378c3c19363cc0b368ef6`
- Canvas 1 URI returns 404
- Visit the home page where `` renders — the card shows a placeholder SVG instead of the manuscript image

### Affected File

- `components/continue-working/index.js` — `getProjectThumbnail()` method (line ~173)

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.