Skip to content

[3j] Re-anchor every linked book in the host #449

Open

Description

@imnasnainaec

Part of Phase 3 (#426) of the data layer plan.

Reanchor pass in the host over every book the draft links into, through the session's queue, as 2e's read delivers each one and again whenever BookService gets new text for one, sending that book's onAnalysisChanged after the pass; not an undo step, since an undo or redo re-anchors what it restores to the current text, as main does; links into a book the text lacks go stale, as reanchorDraftToMissingBook does.

Done when: its result matches the WebView passes on the #407 datasets, which hold no drift, on the drift cases in reanchor-analysis.test.ts and on the missing-book cases in reanchor-draft.test.ts, undo and redo restore content re-anchored to the current text, and a mid-session Scripture edit re-anchors the open book before its refetch.

Depends on: 2e (#439), 3b (#441).

From the plan

Risks

Risk Effect Mitigation
Whole-record inverses restore stale fields Undo restores an old tokenRef after a reanchor pass or a Scripture edit An undo or redo re-anchors what it restores to the current text, as on main; a whole-scope change clears the history

Activity

  1. imnasnainaec commented on Oct 19, 2026

    @imnasnainaec
    ContributorAuthor

    2d emits onAnalysisChanged as soon as the open book's text changes. 3j needs to hold it until its pass finishes. It also relies on 2e's watches to hear about edits to linked books that aren't open.

  2. imnasnainaec commented on Oct 20, 2026

    @imnasnainaec
    ContributorAuthor

    The 2e read (#474) discards each tokenized Book once its forms are filed, and announces a book's arrival to no one.

    3j needs a per-book arrival hook from readTextBook, or must tokenize again.

    Edits to read books come through bookService.onBookTextChanged. main.ts emits onAnalysisChanged straight from it. 3j's pass goes between the two.

    A book whose read fails doesn't arrive, so its links aren't re-anchored until it does. Every read book keeps a live subscription, and every Scripture save in the project makes each subscription fetch its book again, so a failed book is read again, and arrives, on the next save. A project without a USJ_Book provider fails getTextReadStatus instead. If a failed book must arrive without a save, add a retry, and have the hook deliver a retried book like any other.

  3. self-assigned this
    on Oct 22, 2026
  4. alex-rawlings-yyc commented on Oct 23, 2026

    @alex-rawlings-yyc
    Contributor

    From #486: only opening a session clears the undo history. Host New and Open don't exist yet; for this issue's mitigation to hold, whatever builds them must clear the history or arrive as openSession.

  5. 9 remaining items

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions