Reference Text: cache the plan's chapters when a project goes offline

Aperta
#790 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
54/100
Tipo di issue
Funzionalità
Chiarezza
Abbastanza chiara
Stato di attività
Attiva
Stack tecnologico
electron, react, typescript
Ambito
desktop

Direzione di ricerca

Read web/src/business/referenceText/referenceTextChapters.ts and trace the project download flow in ProjectDownload and ProjectDownloadAlert.tsx; the issue also points to CONTEXT.md and docs/adr/0014-reference-texts-in-project-defaults.md. Check how parseRef, defaultParams.referenceTexts, and the existing cancel check are used. Done means every chapter referenced by the project plan is available from disk when offline, including when audio is already present.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

enhancement

Follows #788. With #788, a desktop app saves a Reference Text chapter in offlineData/referencetext/{id}/{BOOK}/{chapter}.simple.json the first time a passage needs it, then reads it from disk. A team that goes offline before opening a passage's Internalize step gets fetchFailed for that passage. Rows can't be added or deleted while offline, so the chapters a project needs are known when it goes offline.

Goal: when a project is downloaded for offline work (the same flow that downloads its audio in ProjectDownload), also cache every Reference Text chapter the project plan references.

Decided

  • Prefetch only the chapters that the project's passages reference, for the Project Book. Use each passage's parseRef start and end chapters, for both the Primary and the Secondary Reference Text in defaultParams.referenceTexts.
  • Reuse getChapter / getChapters in web/src/business/referenceText/referenceTextChapters.ts. It already reads from disk first and writes after fetching, so any chapter already on disk is skipped.
  • Until this ships, and afterwards for anything not prefetched, a cache miss still tries the network even when the app thinks it is offline.

Proposed, to confirm when picked up

  • Expose a cacheReferenceTexts(project, …) from referenceTextChapters.ts. Call it in ProjectDownload's Import step after the zip is extracted and before moving to the next project. It honors the existing cancel check.
  • A failure doesn't stop the download. Log it with logError and show one snackbar warning. Lazy fetching fills the gap later when online.
  • Fetch at most 4 chapters at a time, to be polite to a free API. Desktop only.
  • New strings in the transcriptionTab XLIFF group (regenerate them through the localization pipeline):
    • downloadingReferenceTexts: "Downloading reference texts for {0}"
    • referenceTextsDownloadFailed: "Some reference text chapters could not be downloaded. They will download when you open the passage online."

Watch out

  • ProjectDownloadAlert decides which projects need a download only from missing media files (ProjectDownloadAlert.tsx, the path !== local.localname check). A project whose audio is already on disk never reaches ProjectDownload, so its Reference Texts would never be prefetched. The same is true when a project's Reference Texts change after it was downloaded. The needs-download check, or a separate pass, has to cover missing Reference Text chapters too.

Done when: after making a project available offline and going offline, every passage in the plan returns its Reference Text text from the disk cache.

See CONTEXT.md "Reference Text" and docs/adr/0014-reference-texts-in-project-defaults.md.

🤖 Generated with Claude Code

Lingua principale
TypeScript
Stelle
1
Fork
7
Merge medio
1g 12h
PR unite (30g)
64

Preparare l'ambiente

Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di sillsdev/apm

Tutte le issue di sillsdev/apm

Issue simili

Altre issue su TypeScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.