Markdown OKF-Schema Studio

Behaviour SwRS-MDOKFSTUDIO-TRUST-065

A page message is matched to the shown render or document by the gate of its type

When a page message reaches the host, the extension SHALL pass it only to the handler of its type after it matches the render or document the host holds by the gate of that type (render, comment, document, own-id or page-state), drop a message that fails the gate without an answer, and answer a write whose document is newer than the render with "The preview is out of date. Try again once it has refreshed." or a reopen hint.

Part of StRS-MDOKFSTUDIO-BLOCK-006, outside the paths drawn on its map.

Part of StRS-MDOKFSTUDIO-BLOCK-014, outside the paths drawn on its map.

Part of StRS-MDOKFSTUDIO-BLOCK-016, outside the paths drawn on its map.

Part of StRS-MDOKFSTUDIO-BLOCK-025, outside the paths drawn on its map.

Part of StRS-MDOKFSTUDIO-TOOLBAR-011, outside the paths drawn on its map.

Step 2 of path 1 in StRS-MDOKFSTUDIO-TRUST-009: from “The message is a registered one” to “The message reaches the handler of its type”.

Scenarios 6

The situations the tests check; open one to read it.

nominalCurrent render passes the render gate
Givena preview that holds revision 4, request 9 and a previewBlockMove message that names them
Whenthe message arrives
Thenits handler runs
boundaryThe five gates

Every page message type has one gate. A message with a registered type and a valid envelope (see SwRS-MDOKFSTUDIO-TRUST-052) is matched by it:

GateMessage typesPasses whenOtherwise
renderpreviewHistoryGo, previewViewPreferenceChanged, previewPaletteModeChanged, previewLabelRename, previewThreadReply, previewThreadDelete, previewBlockMove, previewBlocksCopy, previewBlocksCut, previewBlocksPaste, previewListTargets, previewListCitations, previewPickDocument, previewPickImage, previewPasteImage, previewPasteHtmlits document, revision and request identifiers equal those of the render the host holds, the preview is alive and has a rendered stagedropped with no change; a request that waits for an answer (see the scenario below) is answered with the out-of-date reason, previewHistoryGo, previewViewPreferenceChanged and previewPaletteModeChanged are not requests and get no answer
commentpreviewCommentCreate, previewCommentReply, previewCommentResolve, previewCommentDeleteits document and request identifiers equal those of the render the host holds, whatever its revision (comments live in a sidecar file and the quote is anchored again, so typed text is not lost to a race with typing)dropped, with no answer and no write
documentpreviewCopyText, previewPlantUmlInclude, previewShowProblems, previewWarningBannerClosedthe preview is alive and its documentId equals that of the document the preview shows, even one render behind; revision and request are not compareddropped without an answer
own-idpreviewEditClosed, previewEditFlushedthe preview is not disposed, whatever document, revision and request the message names (the waiting host matches the answer by the identifier it sent)dropped (disposed preview)
page-statepreviewReady, previewScroll, previewReveal, previewState, previewLink, previewLinkDiscover, previewThemeModeChanged, previewRefresh, previewAnchorModeChanged, previewEditModeChanged, previewEditOpen, previewEditSave, previewEditCancel, previewFrontmatterSave, previewCheckboxToggleit names the render the host holds, or it is one of the exceptions belowdropped without changing anything

The page-state exceptions are the ready reports (see SwRS-MDOKFSTUDIO-LIFE-071), the save or cancel of the block editor the host has open for exactly the render that message names (same editId, document, revision and request), and the stale save, cancel or frontmatter save of the second table.

refusalOlder render is answered, foreign render is dropped
InputOutcome
previewBlockMove naming revision 3 while the host holds revision 4answered with previewBlockMoveResult ok false and "The preview is out of date. Try again once it has refreshed."; nothing changes
previewBlockMove, previewBlocksCopy, previewBlocksCut or previewBlocksPaste naming an earlier request idanswered with ok false and the out-of-date reason (previewBlocksResult carries the operation); nothing changes
previewThreadReply, previewThreadDelete, previewListTargets, previewListCitations, previewPickDocument, previewPickImage, previewPasteImage or previewPasteHtml naming an older renderanswered with its Result message, ok false and the out-of-date reason; no file is read and no dialog is opened, and the page clears its pending request
previewEditOpen or previewCheckboxToggle naming an older render of a previewanswered with the out-of-date reason (the block editor error, the checkbox error); for the open, the frame of the block editor shows the reason and can be left (see SwRS-MDOKFSTUDIO-BLOCK-216)
a request of the render gate naming another document, or of a disposed previewdropped without an answer
previewCopyText of a page whose document version or render request is no longer currenthandled: the text is written to the clipboard and the page is answered, because a copy edits nothing
previewCopyText naming another documentdropped, the clipboard is not written
previewLink with another document identity, revision or request than the host renderignored: nothing opens and nothing is recorded
previewLink after the preview was disposedignored: nothing happens
message of a disposed preview, or of a preview without a rendered stagedropped
previewCommentReply naming another requestdropped, nothing is written
previewCommentCreate naming another document iddropped, nothing is written
previewScroll naming request 8 while the host holds request 9dropped, the text editor does not scroll
previewLabelRename for a stale render revisionanswered with ok false and The label is no longer on that line. Refresh the preview.; nothing is written
previewPlantUmlInclude, previewShowProblems or previewWarningBannerClosed naming another documentdropped without an answer
previewEditFlushed or previewEditClosed on a disposed previewdropped
nominalGates that accept an older revision
InputOutcome
previewCommentCreate naming revision 3 of the same render while the host holds revision 4the handler runs and the thread is written and answered ok
previewWarningBannerClosed for the shown document from a preview one render behindthe handler runs
previewPlantUmlInclude addressed to the current document from a page one render behindthe include is answered
previewEditFlushed or previewEditClosed naming an older render, on a live previewthe handler runs and the waiting host continues
previewEditSave of the block editor opened on revision 3 after the document moved to revision 4, same editIdaccepted
previewListTargets, previewListCitations, previewPickDocument or previewPickImage naming render 3 while the block editor the host holds is open on render 3 and its own saves moved the document to revision 4the request is answered as for a current preview (the preview refreshes only when the editor closes)
refusalStale write answered out of date or with a reopen hint

A message that passes its gate but writes for a document newer than the render is answered with a reason and changes nothing. The page-state gate answers a stale save or cancel of a live preview instead of dropping it:

RequestStale caseAnswer
previewBlockMovethe document was edited after the last renderok false, "The preview is out of date. Try again once it has refreshed."; a render of the current text plans the move
previewBlocksCopy, previewBlocksCut, previewBlocksPastethe document changed since the renderok false, "The preview is out of date. Try again once it has refreshed."; a render of the current text plans the copy
previewLabelRenamethe document was edited after rendering"The preview is out of date. Try again once it has refreshed." and nothing changes
previewListTargetsthe document is no longer the one of the render, or was edited after it with no block editor open on that renderok false, "The preview is out of date. Try again once it has refreshed."; an unedited document answers the labels
previewListCitationsthe document is no longer the one of the render, or was edited after it with no block editor open on that renderok false, "The preview is out of date. Try again once it has refreshed." and no file is read; an unedited document answers the keys
previewPickImagethe preview is out of date (no block editor open on that render), or the document is an untitled document that is not a saved Markdown file"The preview is out of date, or the document is not a file." and the dialog is not opened
previewPickDocumentthe preview is out of date (no block editor open on that render), or the document is not a saved Markdown file"The preview is out of date, or the document is not a file." and the dialog is not opened
previewThreadReply, previewThreadDeletethe request names another revision of the document than the host holds"The preview is out of date. Try again once it has refreshed." and nothing changes; a request naming the current revision is handled
previewEditSave, previewEditCancel (block editor)the editor was opened on an older page than the host holds"The preview changed while this block was being edited. Copy your text, then reopen the block."
previewFrontmatterSavethe editor was opened on an older render (render 1 while the host shows render 2 of the same document)"The preview changed while this field was being edited. Reopen the field." and the document is unchanged
refusalNo stale answer where none is owed
InputOutcome
stale previewFrontmatterSave naming another documentno answer is sent
stale save of a disposed previewno stale answer is sent
stale previewScroll or any other page-state message that is not a save, cancel or frontmatter savedropped without an answer

Implemented in 5

Tested by 12

Known limits (1)

Replaces

SwRS-MDOKFSTUDIO-CODE-027Drop a copy request from a stale page superseded superseded by SwRS-MDOKFSTUDIO-TRUST-065 Markdown file
SwRS-MDOKFSTUDIO-DIAG-051Include requests are handled for the current document superseded superseded by SwRS-MDOKFSTUDIO-TRUST-065 Markdown file
SwRS-MDOKFSTUDIO-FMEDIT-052A save from an older render is refused with a reopen hint superseded superseded by SwRS-MDOKFSTUDIO-TRUST-065 Markdown file
SwRS-MDOKFSTUDIO-MYST-044The host refuses a rename for an out-of-date preview superseded superseded by SwRS-MDOKFSTUDIO-TRUST-065 Markdown file