Skip to content

Show bot cards and applets on the phone - #53

Merged
TheAnimatrix merged 6 commits into
mainfrom
feat/bot-cards-applets
Dec 1, 2026
Merged

TheAnimatrix merged 6 commits into
mainfrom
feat/bot-cards-applets

Conversation

@TheAnimatrix

Copy link
Copy Markdown
Collaborator

Bot cards and applets now show on the phone instead of placeholders.

Cards

A bot's show_card cards, and the ones Mousse adds, are drawn natively from their data with new UI-library parts (ShowCards.kt, ShowCards.swift) on the design tokens, matching desktop's BotCards.tsx:

  • facts (label over value; only code, bold and link words styled, as desktop's CardValue)
  • checklist (done, in progress, to do, skipped marks)
  • progress (label, "done of total", bar, note)
  • picture set (the gallery's pictures on its card, not repeated among the message's files)
  • automation, watcher, offer and sandbox cards: their title and lines, with where to act on them ("… on your computer")

A revised card comes back as the same message, so it replaces the old one. A card of a kind the phone doesn't know still shows the "open it on your computer" placeholder.

Applets

Shown the way desktop hosts them (shared/appletDocument.ts), with the page built in the shared core:

  • one document with the applet's HTML, CSS and JS, under desktop's strict CSP (nothing loads; only the two nonce'd scripts run)
  • desktop's host styles and theme variables (--bg-primary, --accent, …) from the phone's own light or dark colours, text size and Reduce Motion; a theme change reaches a running page without reloading it
  • window.mousseApplet: data, state, saveState, resize, reportError, requestConversationInput, icon, iconNames, appearance. Reports go through the web view's bridge, and the core checks each one (size limits, clamped heights).
  • height comes from the content (the root element's box, never the frame's), so a progress bar can't collapse to a line or grow without end. Up to 480 pt inline, with a Full screen button.
  • locked down: Android WebView with network, file, content, storage, windows, location and zoom off, every request refused and navigation blocked. iOS WKWebView with a non-persistent store, a content rule list that blocks network and file loads, only the first about:blank load allowed, no new windows, and reports taken only from the main frame.
  • read over the paired connection's single call path: bots.applets.get / bots.applets.state.get / bots.applets.state.save for bot chats, and routed.applets.get / routed.applets.state.get / routed.applets.state.save for threads. Bot sources are read in pages and checked against their SHA-256. A source is kept in the bounded media cache by revision, so an applet still opens while its computer is away (shown as the phone's copy, with saves held). A save goes out once, 0.8 s after the page settles. A thread save carries a request ID.
  • an applet the phone can't read shows "Open it on your computer" with the reason.
  • in threads, a reply's applets come from presentationParts, and their mousse-applet fences are cut from its words.

Tests

  • Core: card parsing for every kind and its limits, a card left out, gallery pictures, applet references from bot messages and thread replies, fence cutting, page joining, the page builder (CSP, nonce, no frame-sized root, theme) and page reports. Each has a must-fail case.
  • The demo's new bot chat (Ledger) has every card kind, a progress applet whose height comes from its content, a chart applet and one the phone can't read. A core test reads it through the same parsers.

@TheAnimatrix
TheAnimatrix force-pushed the feat/bot-cards-applets branch 2 times, most recently from 0fcc4bd to b1b349f Compare December 1, 2026 06:07
@TheAnimatrix
TheAnimatrix changed the base branch from fix/mobile-attachments to main December 1, 2026 06:07
@TheAnimatrix
TheAnimatrix force-pushed the feat/bot-cards-applets branch from 8dee8ab to 8a79b7b Compare December 1, 2026 07:44
@TheAnimatrix
TheAnimatrix marked this pull request as ready for review December 1, 2026 07:44
@TheAnimatrix
TheAnimatrix force-pushed the feat/bot-cards-applets branch from 8a79b7b to b2f853d Compare December 1, 2026 07:53
@TheAnimatrix

Copy link
Copy Markdown
Collaborator Author

Screens from the demo walk (Android emulator, Ledger bot chat).

Cards More cards
Progress, checklist, facts and picture set cards Automation, watcher, offer and sandbox cards
Applets inline Full screen
Progress applet sized to its content, chart applet, and the fallback for one the phone can't read Progress applet full screen

Dark: the progress applet, and how a page's own error is shown (this run had a bug in the demo chart, since fixed in 10f871a):

Dark theme progress applet and an applet's error

@TheAnimatrix
TheAnimatrix force-pushed the feat/bot-cards-applets branch from 10f871a to eb32932 Compare December 1, 2026 08:15
@TheAnimatrix
TheAnimatrix merged commit 9d3fb6f into main Dec 1, 2026
3 checks passed
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.

1 participant