Markdown OKF-Schema Studio

Behaviour SwRS-MDOKFSTUDIO-TRUST-090

Every page request is answered once by its id and result type, or ends with a readable error

When the page sends a request to the host, the extension SHALL answer it once with the matching result or end it with a readable error after its timeout.

Part of StRS-MDOKFSTUDIO-TRUST-009, outside the paths drawn on its map.

Part of StRS-MDOKFSTUDIO-PALETTE-013, outside the paths drawn on its map.

Scenarios 10

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

nominalThe answer is matched by edit id and result type
Givena pending previewListTargets request with the edit id host-1, a fresh edit id of 1 to 100 characters
Whenthe host answers previewListTargetsResult with the edit id host-1
Thenthe request is answered once, and a second answer with the same edit id is ignored

Example: a previewPlantUmlInclude request with the edit id plantuml-1 in flight, and an ok answer with that edit id, delivers the file id and the text to the PlantUML bundle

refusalAn answer that does not match is ignored
Giventhe same pending request
Whenan answer arrives with another edit id, or of another result type such as previewListCitationsResult with host-1
Thenit is ignored and the request stays pending until its own answer or its timeout

Example: with plantuml-1 in flight, an answer for plantuml-99 is ignored, and so is a second answer for plantuml-1 after the first one was delivered

nominalThe host answers with the type followed by Result and the identity of the request
Givena list, pick, paste, thread or include request of the table below
Whenthe host handles it
Thenit posts the request type followed by Result, repeating the document id, the revision, the request id and the edit id of the request
a success carries ok true with the payload of the table, and a refusal or a failure carries ok false and a reason
refusalA refused request is still answered
Givena previewPickImage request refused by the host, or a previewListTargets request for a preview that is out of date
Whenthe host answers
ThenpreviewPickImageResult carries ok false, the reason and the identity of the request, and the page shows the reason
boundaryTimeouts and the readable error
RequestTimeoutEnd without an answer
previewListTargets, previewListCitations, previewCopyText6 secondsok false and the reason The editor did not answer. Try again., shown in the popover
previewThreadReply, previewThreadDelete6 seconds (default)ok false and the reason The editor did not answer. Try again., shown in the status line of the thread
previewPasteHtml10 seconds (set by the block editor)ok false and the reason The editor did not answer. Try again.
previewPasteImage30 seconds (set by the block editor)ok false and the reason The editor did not answer. Try again.
previewPlantUmlInclude10 seconds (set by the PlantUML bridge)the bundle receives ok false and the reason The editor did not answer. Try again.
previewPickDocument, previewPickImage10 minutes (a request marked as a dialog)ok false and the reason The editor did not answer. Try again.

A request answered before its timeout produces no timeout result. A request that names an older render is answered at once by the host, so none of the timeouts above applies to it.

A request that ended on its timeout is forgotten, so an answer that arrives later is ignored.

While a dialog request is pending, the block editor does not treat the focus loss as leaving; this holds also until its timeout.

boundaryEach request type, its result and its refusals
RequestResult messageSuccess payloadRefusals and failures, as the reason text of ok false
previewCopyTextpreviewCopyTextResultok trueToo large to copy. (text over 1 000 000 characters); Could not copy. (the clipboard write failed)
previewListTargetspreviewListTargetsResultok true, items, truncatedThe preview is out of date. Try again once it has refreshed. (no refusal for restricted reads: the label list reads only the document)
previewListCitationspreviewListCitationsResultok true, items, truncatedthe citation reason of SwRS-MDOKFSTUDIO-TRUST-005 (restricted reads); The preview is out of date. Try again once it has refreshed.; the message of the scan error
previewPickDocumentpreviewPickDocumentResultok true and path relative to the document, or ok true and cancelled true when the dialog is closedThe preview is out of date, or the document is not a file.; That file name cannot be written in a {doc} link.; the message of the dialog error
previewPickImagepreviewPickImageResultok true and path relative to the document, or ok true and cancelled trueThe preview is out of date, or the document is not a file.; Pick a png, jpeg, gif, webp or svg image.; The image must be inside a workspace folder.; The image must be inside the folder of the document. (a standalone file); That image cannot be referenced from this document (another drive, or an unusual name).; the message of the dialog error
previewPasteImagepreviewPasteImageResultok true and fileNameSave the document before pasting an image.; Pasting an image needs a Markdown file.; The image must be saved inside a workspace folder.; That clipboard image type is not supported.; The image is larger than 10 MB.; The clipboard data is not a png, jpeg, gif or webp image.; Too many pasted images next to this document.; the message of the write error
previewPasteHtmlpreviewPasteHtmlResultok true and markdownthe message of the conversion error
previewPlantUmlIncludepreviewPlantUmlIncludeResultok true, the real path of the file as id, and textok false and a reason, for a file outside the allowed folders; a malformed or incomplete answer reaches the bundle as the reason that the file could not be read
previewThreadReplypreviewThreadReplyResultok trueSave or cancel the open Markdown edit before changing a thread.; The preview is out of date. Try again once it has refreshed.; The document changed meanwhile. Try again.; VS Code could not apply the change.; the refusal of the thread lines
previewThreadDeletepreviewThreadDeleteResultok truethe same reasons as previewThreadReply, except The document changed meanwhile. Try again.

The page shows the reason of a refusal where the request came from: the popover for a list, the status line of the block editor for a picker, the status line of the thread (or The change was not saved. when there is no reason).

The page matches these results by the edit id only, because the edit itself can move the document revision. The host-to-page rule of these result types is the own-id addressing, see SwRS-MDOKFSTUDIO-TRUST-059.

The writes among them are handled in every preview, trust included; only the citation list is refused for restricted reads, see SwRS-MDOKFSTUDIO-TRUST-005.

boundaryThe comment actions are answered by a result without an edit id
RequestResult messageContentPage timeout
previewCommentCreatepreviewCommentResultok, kind create, reason when ok is false15 seconds: No answer from the editor. Your text is kept: try Save again.
previewCommentReplypreviewCommentResultok, kind reply, the thread id, reason when ok is false15 seconds: No answer from the editor. Your text is kept: try Reply again.
previewCommentResolve, previewCommentDeletepreviewCommentResultok, kind, the thread id, reason when ok is false15 seconds: No answer from the editor. Nothing changed here: try again.

The host answers each handled comment message with exactly one previewCommentResult, also after an unexpected error (then ok false with the message of the error), and the page keeps the typed text until ok is true.

A previewCommentResult is addressed to the shown render and has no edit id; the page gives it to the compose box (kind create) or to the thread that waits.

A late previewCommentResult after the 15 seconds still counts for the compose box that waits (Save stays awaiting).

refusalClosing the editor forgets the pending requests
Givena pending list request and its timeout
Whenthe block editor is torn down, and the answer arrives later or the timeout would have elapsed
Thennothing is inserted, nothing is shown and no failure result is produced
the PlantUML include requests are not cancelled by this, because the bridge keeps its own pending table
refusalAnswers for another or a closed editor are ignored
Givenan answer for a pasted image or a rich text paste whose edit id is not pending, or whose editor is closed or replaced, or a list answer for a popover that is closed or replaced
Whenit arrives
Thenit is ignored: nothing is shown and nothing is inserted
an answer that arrives for the editor still open is used (the entries are shown, the Markdown is inserted)
refusalA request of an older render is answered
Givena list, picker, paste or thread request that names an older render than the host holds
Whenthe host receives it
Thenit answers with ok false and "The preview is out of date. Try again once it has refreshed."
the page clears the pending request at once and shows the reason, without waiting for its own timeout

Implemented in 10

Tested by 14

Replaces

SwRS-MDOKFSTUDIO-DIAG-047Include answers are matched by their edit id superseded superseded by SwRS-MDOKFSTUDIO-TRUST-090 Markdown file
SwRS-MDOKFSTUDIO-DIAG-052The host answers an include request with the same edit id superseded superseded by SwRS-MDOKFSTUDIO-TRUST-090 Markdown file