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
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
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
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
boundaryTimeouts and the readable error
| Request | Timeout | End without an answer |
|---|---|---|
| previewListTargets, previewListCitations, previewCopyText | 6 seconds | ok false and the reason The editor did not answer. Try again., shown in the popover |
| previewThreadReply, previewThreadDelete | 6 seconds (default) | ok false and the reason The editor did not answer. Try again., shown in the status line of the thread |
| previewPasteHtml | 10 seconds (set by the block editor) | ok false and the reason The editor did not answer. Try again. |
| previewPasteImage | 30 seconds (set by the block editor) | ok false and the reason The editor did not answer. Try again. |
| previewPlantUmlInclude | 10 seconds (set by the PlantUML bridge) | the bundle receives ok false and the reason The editor did not answer. Try again. |
| previewPickDocument, previewPickImage | 10 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
| Request | Result message | Success payload | Refusals and failures, as the reason text of ok false |
|---|---|---|---|
| previewCopyText | previewCopyTextResult | ok true | Too large to copy. (text over 1 000 000 characters); Could not copy. (the clipboard write failed) |
| previewListTargets | previewListTargetsResult | ok true, items, truncated | The preview is out of date. Try again once it has refreshed. (no refusal for restricted reads: the label list reads only the document) |
| previewListCitations | previewListCitationsResult | ok true, items, truncated | the 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 |
| previewPickDocument | previewPickDocumentResult | ok true and path relative to the document, or ok true and cancelled true when the dialog is closed | The 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 |
| previewPickImage | previewPickImageResult | ok true and path relative to the document, or ok true and cancelled true | The 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 |
| previewPasteImage | previewPasteImageResult | ok true and fileName | Save 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 |
| previewPasteHtml | previewPasteHtmlResult | ok true and markdown | the message of the conversion error |
| previewPlantUmlInclude | previewPlantUmlIncludeResult | ok true, the real path of the file as id, and text | ok 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 |
| previewThreadReply | previewThreadReplyResult | ok true | Save 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 |
| previewThreadDelete | previewThreadDeleteResult | ok true | the 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
| Request | Result message | Content | Page timeout |
|---|---|---|---|
| previewCommentCreate | previewCommentResult | ok, kind create, reason when ok is false | 15 seconds: No answer from the editor. Your text is kept: try Save again. |
| previewCommentReply | previewCommentResult | ok, kind reply, the thread id, reason when ok is false | 15 seconds: No answer from the editor. Your text is kept: try Reply again. |
| previewCommentResolve, previewCommentDelete | previewCommentResult | ok, kind, the thread id, reason when ok is false | 15 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
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
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
the page clears the pending request at once and shows the reason, without waiting for its own timeout
Implemented in 10
- src/core/protocol/pageToHost.ts
- src/page/features/hostHandlers.ts
- src/page/modules/editPalettePopovers.ts
- src/page/modules/hostRequests.ts
- src/page/modules/pasteHtml.ts
- src/page/modules/pasteImage.ts
- src/session/features/comments.ts
- src/session/features/hostRequests.ts
- src/session/features/plantUml.ts
- src/session/features/sourceEdits.ts
Tested by 14
- test/core/protocol/pageToHost.test.tsunit
- test/integration/commentWrite.test.tsintegration
- test/integration/imagePaste.test.tsintegration
- test/integration/imagePicker.test.tsintegration
- test/integration/inlineThread.test.tsintegration
- test/integration/mystPickers.test.tsintegration
- test/page/modules/commentCompose.test.tsunit
- test/page/modules/commentThreads.test.tsunit
- test/page/modules/editPalette.test.tsunit
- test/page/modules/hostRequests.test.tsunit
- test/page/modules/paletteReq.requirements.test.tsunit
- test/page/modules/plantumlFileRequests.test.tsunit
- test/page/runtimePaletteActions.test.tsunit
- test/session/diagReq.plantuml.requirements.test.tsunit