Skip to content

feat: render sync server messages as rich text#4560

Open
timarnoldev wants to merge 1 commit intoankitects:mainfrom
timarnoldev:feat/rich-text-sync-message
Open

feat: render sync server messages as rich text#4560
timarnoldev wants to merge 1 commit intoankitects:mainfrom
timarnoldev:feat/rich-text-sync-message

Conversation

@timarnoldev
Copy link

@timarnoldev timarnoldev commented Feb 13, 2026

Summary

  • Pass type="rich" to showText() when displaying the sync server message, enabling HTML rendering via QTextBrowser.setHtml()
  • Plain-text messages continue to render identically — setHtml() handles plain strings the same as setPlainText()
  • Allows self-hosted sync servers to send formatted post-sync messages (e.g. styled statistics, notices with links, tables)

Context

The /sync/meta response includes a msg field that is displayed to the user after sync. The display widget is already a QTextBrowser (which supports Qt rich text/HTML), but showText() is called with the default type="text", routing through setPlainText().

The showText helper already has full HTML support — it just needs type="rich":

# qt/aqt/utils.py
text = QTextBrowser()
text.setOpenExternalLinks(True)
if type == "text":
    text.setPlainText(txt)    # current path
else:
    text.setHtml(txt)         # proposed path

Security: QTextBrowser does not execute JavaScript — only static HTML/CSS. The sync server is explicitly configured and trusted by the user.

The sync message from the server is displayed using QTextBrowser, which
natively supports HTML rendering. By passing type="rich" to showText(),
server operators can send formatted messages (tables, bold, links, etc.)
while plain-text messages continue to render identically.
@timarnoldev timarnoldev force-pushed the feat/rich-text-sync-message branch from e4645ab to e151564 Compare February 13, 2026 12:08
@abdnh
Copy link
Collaborator

abdnh commented Feb 16, 2026

We'll need to confirm if this won't cause issues with messages returned by AnkiWeb.

@timarnoldev
Copy link
Author

@abdnh Are there public tests available? Since AnkiWeb is proprietary I can't review every possible case. Is there a list of messages coming from AnkiWeb available?

@abdnh
Copy link
Collaborator

abdnh commented Feb 16, 2026

It's not publicly available. We're still in the process of transitioning management and private access to AnkiHub. I'll check and get back to this.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants