Skip to content

content_type="semi-markdown" exists in the client but not in StreamingContentType #2396

Description

@schloerke

Problem

The client accepts a content_type value that the Python API does not expose: "semi-markdown".

Client — shiny/www/py-shiny/markdown-stream/markdown-stream.js handles four values, dispatching semi-markdown to a different marked renderer than markdown:

if (e === "markdown") { ... renderer: uo ... }
else if (e === "semi-markdown") { ... renderer: po ... }   // distinct renderer
else if (e === "html") { ... }
else if (e === "text") { return t; }
else throw new Error(`Unknown content type: ${e}`);

Python — shinychat/_markdown_stream.py L20:

StreamingContentType = Literal[
    "markdown",
    "html",
    "text",
]

Nothing under shiny/ui/ mentions semi-markdown.

Consequence

Passing content_type="semi-markdown" works at runtime (Literal is not enforced) but fails type checking, and is undiscoverable from the Python side. The po renderer appears to be the HTML-escaping variant, which is a genuinely useful mode for streaming untrusted LLM output — so this is a real capability that is currently reachable only by accident.

Suggested resolution

Pick one:

  1. Expose it — add "semi-markdown" to StreamingContentType and document what it does differently from "markdown" (escaping behavior). Preferred if the escaping mode is intentional.
  2. Remove it — drop the branch from the JS if it is a vestigial port from R Shiny.

Either way the two sides should agree.

Context: the docs site briefly documented "semi-markdown" as a valid value and removed it after discovering it was absent from the Python signature (posit-dev/py-shiny-site#418). Verified against shiny 1.7.1.dev6.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions