For the release status of each capability, see Capabilities and progress.An extension draws its interface with The status band:
The status band is the strip above the message box, inside its border and above the user’s draft. All plugins share one band, and each draws a line or two in it.Keep the Panels:
A panel is a tab in the conversation’s side panel on the right, next to tabs such as Files and Browser. A plugin opens each of its panels itself and tells them apart by The backdrop:
Coming soonThe backdrop is a layer behind the conversation and below every panel in the main window. While a plugin theme is active, it replaces the user’s wallpaper and gradient. It shows only when the conversation has a plugin theme. A theme is set with Rules:The host draws every element with its own components, so props accept only the token names below, and the host picks the pixels and styles. Colors are token names too, and a few props also accept a hex color; see colors. Children that are Rules for
Once a drawing updates, the host can find the control in the new drawing that matches a press, keystroke or submit made on the old one only through This example only registers the panel’s drawing. To show it, you also need to call Drawing functions should only read. Read Other rules:This module keeps no state, so it doesn’t need A few things to note:A few things to note:
ui.render on three sites: the status band, panels and the backdrop. This page covers the rules for each site, how several plugins draw on the same site, the elements and their props, callbacks for buttons and inputs, when a drawing runs again, and the design rules that keep it looking right.To look up a single prop or limit, go straight to the extensions reference. If the type files in
.minimax-plugin/types/ disagree with this page, the type files are correct.Three sites
A site is a place where an extension can draw. You name the site in the matcher ofui.render, and the host decides which elements that site accepts. An extension can draw on three sites:- Status band: the strip above the message box, inside its border. All plugins share one band, and each draws a line or two in it. Its site name in code is
above-prompt. - Panel: a tab in the conversation’s side panel on the right, next to tabs such as Files and Browser. Its site name in code is
pane. - Backdrop: the backdrop behind the conversation, a layer behind the conversation and below every panel in the main window. It replaces the wallpaper while a plugin theme is active. Its site name in code is
backdrop.
Rules that apply to all three sites:
- Each plugin can register only one
ui.renderper site. Forpane, that means one perid, plus at most one without anid. A duplicate registration reportsEXTENSION_DUPLICATE_ENTRY. siteandidmust be string literals.- All three sites are drawn through the same render chain, with exactly the same rules. Coming soon Once the status band is drawn in two steps,
above-promptdraws only your plugin’s own row, and the render chain runs onabove-prompt-listinstead. See status band row arrangement.
The status band: above-prompt
The status band is the strip above the message box, inside its border and above the user’s draft. All plugins share one band, and each draws a line or two in it.- There’s one band per conversation. Each plugin is one layer, and the layers stack in render chain order.
eis always{ site: 'above-prompt' }. - The status band can use
<Box>,<Text>,<Button>,<Tag>,<Spinner>, plus<Progress>,<Link>and<Svg>Coming soon. Any other element is replaced by a placeholder, and tests reportTREE_INVALID. Put forms and long text in a panel, and put a button that opens the panel in the status band. - Its height is capped at about 12 lines of body text, always cut at a whole line. When there’s little content, the band takes only its own height. Past the cap it scrolls inside, with the scrollbar hidden.
- Its width follows the message box. Content that’s too wide is cut off, so keep labels short. When a row may not fit on one line, use
<Box wrap>so it wraps. - A close button at the end of the row. Coming soon
<Button key="dismiss" role="dismiss" label="Close" onPress={…} />draws as a compact×button at the end of the row, withlabelas the name screen readers read.onPressruns as usual: changectx.statein it, and the next drawing leaves the row out. - Focus stays in the message box. When the user presses a button in the band, focus and the caret stay in the message box.
- It’s separate from the draft. The band’s content isn’t part of the draft, and
ctx.prompt.read()reads only what the user wrote. - Limits on element count, nesting depth and text length apply to the whole band (see tree size limits).
Arrange rows across plugins: above-prompt-list
Coming soonThe status band will be drawn in two steps:above-promptdraws your plugin’s own row. Each plugin’sabove-promptruns on its own, without affecting the others. Returnundefinedto draw no row.next()is empty here, so existing code that keepsawait next()still works. A row that fails validation, or that would push the stacked band past its limits, is dropped on its own, and the other plugins’ rows still show.above-prompt-listarranges the drawn rows. Itseis{ site: 'above-prompt-list', props: { rows } }, wheree.props.rowsisreadonly { plugin: string; tree: RenderTree }[]in render chain order. Filter or reorder them, then pass those rows unchanged tonext({ ...e, props: { ...e.props, rows } }). When no plugin arranges them, the rows stack vertically in order.
above-prompt-list goes through the render chain with the same rules as the other sites, so its drawing must use next too. The rows you pass to next must be the rows you received: changing a row’s content, making up a row, or passing the same row twice reports EXTENSION_ROWS_INVALID, and this list layer is skipped.In the example below, a plugin expands a view inside its own above-prompt row from a / command and keeps the open flag in state as open. While the expanded view is open, the band keeps only this plugin’s row:mine.length > 0 check. When your row wasn’t drawn, or a plugin earlier in the chain already filtered it out, mine is empty. Then return next() instead of passing an empty list on.Panels: pane
A panel is a tab in the conversation’s side panel on the right, next to tabs such as Files and Browser. A plugin opens each of its panels itself and tells them apart by id.Registering the drawing and opening the tab are two separate steps:idis the name you give the panel: a non-empty string of up to 200 characters.titleis the text shown on the tab.- Calling
ctx.ui.openagain with anidthat’s already open only updates the title. It doesn’t add a second tab, so opening the same panel twice is safe. - You can call
ctx.ui.closefrom any callback. - When the arguments are invalid, both
openandclosereject withARGUMENT_INVALID.
Focus
focus: true switches to the tab and expands the side panel. In three cases focus has no effect and the tab is only added:- a dialog is open;
- the user is typing in the message box;
- the window is in the background.
session.start with a fixed id and without focus.When the user closes the tab
When the user clicks close on the tab, yourui.close hook runs:e is { sessionId, id }, with no turnId or agentId. Only the plugin that opened the tab receives it. Calling ctx.ui.close yourself doesn’t trigger it. You can leave id out of the matcher, and then the hook runs when any of your panels is closed.Panel lifecycle
- A tab belongs to the plugin that opened it. That plugin opens and closes it, and a close by the user notifies only that plugin. While the plugin isn’t running (for example, when it’s paused), the tab shows a paused placeholder.
- Each plugin can open at most 16 panels in a conversation. Opening a 17th rejects with
ARGUMENT_INVALID. - The runtime remembers which tabs are open in a conversation. A window catches up on its next subscribe or snapshot (opening the conversation, coming back to it, reloading or reconnecting): it adds missing tabs without switching to them and drops tabs that were closed in the meantime. When the user closes a tab in one window, other windows don’t close it right away. They catch up on their next sync.
- While the extension reloads, the tab shows a paused placeholder, and it draws again once the extension is back. Withdrawing an extension removes all of its tabs.
- After the runtime restarts, reopen tabs in
session.start. A restart clears the tabs, andsession.startruns again. A panel that should be there from the start must be reopened insession.startwith a fixedidand withoutfocus.
What a panel can hold
- All 13 elements. The page fills the panel and scrolls when there’s a lot of content.
- The panel is drawn only while its tab is the selected one. While another tab is selected the panel isn’t kept: when the user comes back it’s drawn again from state, so
Inputtext that wasn’t stored in state is gone. A<Link>that opens in the in-app browser selects the browser tab, so it leaves the panel the same way. - When no layer draws anything, the tab shows an empty state.
The backdrop: backdrop
Coming soonThe backdrop is a layer behind the conversation and below every panel in the main window. While a plugin theme is active, it replaces the user’s wallpaper and gradient. It shows only when the conversation has a plugin theme. A theme is set with ctx.theme.set({ backdrop: { scene } }); see Set a theme. When there’s no plugin theme, or after the theme is cleared or the plugin that set it is withdrawn, the user’s own wallpaper comes back.-
There’s one backdrop per conversation. Each plugin is one layer, and the layers are ordered by the render chain.
eis{ site: 'backdrop', props }, ande.propsis the conversation’s current theme: -
Each layer draws only its own scene and passes the rest to
next(). While the conversation has a plugin theme, every plugin’s backdrop layer runs, no matter who set the theme. No plugin owns the backdrop, so first check thate.props.pluginisctx.plugin.id, then checke.props.scene. If it isn’t yours,return next(), or you’ll cover another plugin’s theme. A plugin can have several scenes and picks which one to draw frome.props.scene. -
The backdrop can use
<Box>,<Text>and<Svg>. Draw the picture with<Svg>. The backdrop sits below everything the user works with and receives no mouse events, so put only the picture and caption text in it. -
The reading surface (
glass). While the backdrop shows, the window puts a reading surface under the reply rows so the conversation doesn’t sit directly on the picture. By default it uses the panel color (derived fromsurface-1when the theme’scolorssets it, otherwise fromsurface-0), at that color’s own opacity, plus an 8 px blur on desktop. To change it, usebackdrop.glassinctx.theme.set: write{ blur?, tint?, opacity? }, and fields you leave out keep their defaults. Withfalse, no reading surface is drawn and the reply rows sit directly on the picture, so readability is up to you. Text colors are corrected against the theme’s own surface colors, not againsttint, a loweropacityor the picture. -
Draw a still version for reduced motion. When reduced motion is on in system settings, the host draws a still version of the same SVG: it removes SMIL elements and
<mpath>, everyanimation*andtransition*declaration, and@keyframesblocks. So put the resting look in the base styles, not only in keyframes. Write animation in the SVG, and don’t redraw frame by frame withctx.clock. - No placeholder when every layer is paused. It behaves as if there were no theme: no layer is drawn, the wallpaper stays as it is, and the paused placeholder with “Retry” doesn’t show. On the backdrop, keeping the wallpaper is better than covering it with a notice.
- The backdrop redraws when the theme changes.
The render chain
No plugin owns a site by itself. Every plugin whose matcher hits the site is one layer, and the layers are ordered:- Plugins previewed in the current conversation come first, then the other plugins in load order.
- Earlier layers are on the outside.
next. await next() returns what all the layers after yours drew, and the last layer’s next() draws nothing. Your job is to put that result in your own tree, usually as the last child of a column Box:hooks/register.tsx
- Leaving out
nexthides every plugin after yours. When a drawing function never referencesnext, validation reports anEXTENSION_SHADOWINGwarning. It doesn’t block preview, but it’s almost always a mistake. return next()means you add nothing and pass the later layers through unchanged. Use it when you have nothing to show right now.- A drawing can call
nextonly once. A second call reportsEXTENSION_NEXT_TWICE. - A layer that throws is skipped. If it throws before
next(), that layer is skipped and the other layers draw as usual. If it throws afternext(), what the later layers drew is kept. - A layer that keeps failing is paused. A layer that fails repeatedly is paused in the current conversation and skipped, and the other layers draw as usual. The paused placeholder with “Retry” shows only when every layer on a site is paused. The backdrop is an exception; see the backdrop.
- A button you wrap still belongs to its plugin. If you put a button that a later plugin drew inside your own
<Box>, pressing it still runs that plugin’s callback. Only the elements you create are yours. - The host fixes
eand the site’s properties. Each layer draws on the site or panel the host gives it.
{ site: 'pane', id: 'board' } is a layer of the board panel (the id is just a string, not tied to a plugin), and { site: 'pane' } without an id is a layer of every panel. The page drawn by the plugin that opened the panel is only one layer too, so the page also needs await next(). To add a section to another plugin’s panel, match its id and keep await next() as well. e.id is always the panel’s id.The backdrop uses the same chain too, but each layer draws only the picture the conversation’s theme names and otherwise does return next(). See the backdrop.Elements
Import elements from@minimax/mcode-plugin-extension/ui and write them as JSX:undefined, null or a boolean aren’t drawn, so you can show or hide an element with {cond ? <Tag label="…" /> : undefined}.Every element can take a
key (a string or a number, up to 256 characters). See rules for key.Tokens
Some values are valid but don’t draw as their names suggest. See Never use.
Colors
Coming soontone and background on <Text>, background on <Box>, and tone on <Progress> accept either a tone token or a hex color: #rgb, #rgba, #rrggbb or #rrggbbaa. Tone tokens follow the light and dark themes. Hex colors are drawn as written in both. Other color props accept only tone tokens: hover.background on <Box>, tone on <Button>, and tone on <Tag>.Use hex colors only for data. See design rules.Box
A layout container. It only arranges its children and takes no callbacks.Text
A string placed directly in a
<Box> is drawn as a <Text> with default styles.Markdown
For panels.Links in the Markdown (inline links, reference links and bare addresses) are clickable when the address follows the
<Link> address rules, and clicking them works the same as clicking a <Link>. Other links show as plain text.Code
For panels. The panel is narrow, so keep lines short, or usewrap to wrap long lines.Tag
Button
Input
For panels. A text field, single-line by default and multi-line whenrows is 2 or more.When neither
onInput nor onSubmit is set, the field shows as disabled.How Enter works:- Single-line field: Enter submits.
- Multi-line field with
onSubmit: Enter,Cmd+EnterandCtrl+Entersubmit, andShift+Enteradds a line break. - Multi-line field without
onSubmit: Enter adds a line break. - If a redraw changes
rowsfrom more than 1 to 1 while the user is typing, line breaks in the draft are removed. Going from 1 line to several keeps the text and the focus.
Select
For panels.Switch
For panels.Spinner
Progress
Coming soonShows how far a task has got. Draws a progress bar when you know how far along it is, and a spinner when you don’t.- Progress bar: when
valueis a finite number andmaxis a finite number greater than 0, it draws a bar and a number. The number isvalueText, or a whole percentage when there’s novalueText. It shows 0% or 100% only at the exact ends (below 0 shows 0%, abovemaxshows 100%), and every value in between shows as 1% to 99%. - Spinner: without
value, it draws a task in progress: a spinner andlabel, plusvalueTextwhen set. It also draws this way whenvalueormaxisNaNor infinite, or whenmaxis 0 or less. A missingmaxcounts as 1, but an invalid one doesn’t. - In the status band it takes one line. In a panel,
labeland the number share a line, with the bar below. A number that’s too long is cut with an ellipsis.
Link
Coming soonOpens a web address.- The text shown is, in order: the children’s text,
label, then the address itself. - Address rules: the link is clickable when
hrefis anhttps:address orhttp://localhost(any port), with no username or password. Any other address shows as plain text, with no error and no diagnostic. - A click works like clicking a link in the conversation and follows the user’s link-opening setting (the in-app browser by default, or the system browser if they changed it). Cmd-click or Ctrl-click opens it in the system browser.
Svg
Coming soonAn SVG picture. The backdrop, the status band and panels all accept<Svg>, but the backdrop displays and checks it differently from the other two. See how it’s displayed and rules for the markup.<Svg> takes only these four props and no children, and source and the sizes must stay within the ranges above. Otherwise the host rejects the whole tree, not just this picture, and tests report TREE_INVALID and name the prop. The tree’s 200 KB limit counts the SVG markup too, so a tree can hold at most one picture near the size limit.How it’s displayed
- It’s displayed as an image (an
<img>with adata:address). It’s a separate document that runs no scripts, loads nothing and can’t touch the page. So ids, classes and<style>rules in the SVG apply only inside it, and it can’t read the page’s CSS custom properties. - It can animate.
<style>can hold CSS animations, transitions and@keyframes, and you can use SMIL:<animate>,<animateTransform>,<animateMotion>,<set>. - It follows the app’s colors.
currentColoris the host’s primary text color, andprefers-color-scheme,light-dark()and system colors follow the app’s light or dark mode. If you don’t set them yourself, the host adds acolorattribute to the root element and putscolor-schemeat the start of the root element’sstyle. - On the backdrop, it fills its box and is cropped. Give the root element
xmlns="http://www.w3.org/2000/svg",viewBoxandpreserveAspectRatio(usexMidYMid sliceto fill), and set its size towidth="100%" height="100%"or leave it out. The image fills its own box and the overflow is cropped (object-fit: cover). It redraws when the window is resized, but animations don’t restart.@media (max-width: …)in the SVG checks the box’s displayed size. A root element withoutviewBoxdraws at its own size and is cropped the same way. When reduced motion is on in system settings, the backdrop draws a still version; see the backdrop. - In the status band and panels, it takes its own size. On
above-prompt,above-prompt-listandpane,<Svg>doesn’t fill the window. It shows at the picture’s natural size in its own<img>, and withoutwidthits width fits the content (fit-content). So setwidthandheighton<Svg>or on the SVG’s root<svg>rather than relying onviewBoxalone, especially inside a horizontal<Box direction="row">. Animations here aren’t removed for reduced motion. - An image the browser can’t load hides only itself.
Rules for the markup
The checks below apply only on the backdrop. In the status band and panels (above-prompt, above-prompt-list, pane), only the <Svg> props (see the prop table above; breaking them rejects the whole tree, recorded by the window as invalid-svg and reported by tests as TREE_INVALID) and the tree’s 200 KB limit are checked. So standard SVG elements all work there, and you can embed data: bitmaps, such as <image href="data:image/webp;base64,…">.On the backdrop, source goes through two checks that use the same rules, so a picture that passes test also draws in the window.- The runtime checks the text the hook returns, and so does
test. If any part breaks a rule, the whole picture is rejected withEXTENSION_SVG_REFUSED, and the message names the category and the exact content, such asSvg refused: script-vector (foreignObject)orSvg refused: element (a).testreports it in the site’sdiagnostics. After a preview, once the site has drawn once, it shows inruntime.diagnosticsofinspect. The other layers draw as usual, just without yours. A rejection isn’t a failure: no number of repeats pauses your hook, and once you fixsource, the next drawing shows it. - The window checks again against an allowlist before drawing. If the picture fails, it shows as a placeholder (“Part of an extension can’t be displayed”), with the reason
unsafe-svg.runtime.sitesininspectlists, per site, what the window couldn’t draw, with the reason and details. Entries are in time order with the newest last, and they stay after you fix the problem, so compare an entry’srenderSeqwith the site’s latest drawing.
- Use only standard drawing elements. The root is one
<svg>in the SVG namespace. Pick elements from these lists. Names are case-sensitive:- Shapes and text:
circle,ellipse,line,path,polygon,polyline,rect,text,textPath,tspan - Structure:
svg,g,defs,symbol,use,title,desc,style - Paint effects:
linearGradient,radialGradient,stop,pattern,mask,clipPath,marker,filter - Filters:
feBlend,feColorMatrix,feComponentTransfer,feComposite,feConvolveMatrix,feDisplacementMap,feDropShadow,feFlood,feFuncA,feFuncB,feFuncG,feFuncR,feGaussianBlur,feMerge,feMergeNode,feMorphology,feOffset,feTurbulence - Animation:
animate,animateMotion,animateTransform,set,mpath
- Shapes and text:
- Reference only elements in the picture itself. Write
href(orxlink:href) only as#id, andurl()only asurl(#id). - Draw everything in the picture. Use fonts installed on the system for text. Don’t write
data:addresses or base64 content, don’t use@import,@font-face,image-set(),cross-fade(),src()or<?xml-stylesheet, and don’t include bitmaps (image,feImage) or HTML (foreignObject). - Draw, don’t script. No
<script>, and no attribute names that start withon(such asonload). - Use only SVG and XLink attributes. Declare only these two namespaces. From XLink, use only
xlink:href.xml:spaceandxml:langare allowed. - Use common CSS functions and rules. Color, math, transform, gradient, filter and easing functions are all fine. The allowed at-rules are
@keyframes(or@-webkit-keyframes),@media(includingprefers-reduced-motion),@supports,@container,@layer,@scope,@property,@starting-style,@counter-style,@page,@position-try,@view-transitionand@charset. Other functions, such asattr(), aren’t allowed. - Animations don’t change
hreforstyle. The runtime check refuses an animation ofhref(EXTENSION_SVG_REFUSED), and the window check refuses an animation ofstyle, so the whole drawing shows as a placeholder. An animation ofmedia, an animation of the root element’s ownwidthorheight, and<metadata>are only removed by the window; the rest of the drawing still shows. - Hide nothing. No backslashes in
<style>or in tags. Use only the character references&,<,>,"and'. No control characters and no unpaired surrogates. No DOCTYPE, entity declarations, CDATA or<?…?>(a UTF-8 XML declaration at the start of the file is fine, which is what drawing tools export).<style>holds only CSS, with no elements or XML comments, and has a closing tag. Quote every attribute value, and keep<and>out of values. - Write well-formed XML. Every tag is closed and paired, every prefix is declared,
&is written&,<in text is written<, and each attribute appears only once. - Keep it small. At most 5000 nodes (elements and text, plus the elements each
<use>clones). A<use>doesn’t point to another<use>or to an element that contains a<use>. Amarkerholds at most 16 elements (counting what<use>clones inside it), and amarkerdoesn’t contain anothermarker. The host doesn’t watch how fast the picture plays, so these limits are what keep its cost down. - Comments are checked too. Ordinary XML comments between tags (without
<or--) and closed CSS comments are fine, buthrefordata:in a comment or in<text>is rejected the same way.
Tree size limits
The whole tree returned by one drawing has these limits:Buttons and inputs
Only hooks receivectx, written as (ctx, e) or (ctx, e, next). Element callbacks receive only their own value. When you need ctx, use the one from the enclosing hook:- Each callback runs as its own Invocation. The callback uses the
ctxfrom the drawing, but the identity and permissions of the call come from the press, not from the drawing. That’s why a callback can writectx.state, callctx.mcp.call, show a toast or fill text into the message box. - Use the
ctxfrom the enclosing hook in a callback. A callback that declares its ownctxparameter, such asonPress={(ctx) => …}, doesn’t getctxand fails at runtime. - Callbacks share the 10-second execution budget with hooks, and the same rule that pauses after 3 failures in a row. See events.
hooks/register.tsx
Rules for key
Once a drawing updates, the host can find the control in the new drawing that matches a press, keystroke or submit made on the old one only through key. It matches on element type, callback prop name (such as onPress or onSubmit), and key chain. The key chain is made of the control’s own key and the key of each ancestor, and an ancestor without a key is represented by its position in its parent. The event is delivered only when exactly one control matches.- A control with no
keyon itself or any ancestor never matches. A press that arrives after a redraw is ignored (EXTENSION_HANDLE_STALE), even if the control looks unchanged. The same goes for a control that has disappeared. - Give every list row a
key, using a stable id rather than the index. Once a row has akey, the buttons inside it don’t need one. - Give a
keyto every control that causes a redraw:<Input>,<Select>,<Switch>, and any<Button>whose callback triggers a redraw. Then the next keystroke, submit or press still reaches it. - Sibling keys must be unique.
- Change the
keywhen the meaning changes. A keyed control keeps its identity even when its label changes. For example, if “Delete” becomes “Confirm delete” or “Start” becomes “Stop” under the samekey, a late second click on the old button runs the new meaning. Use a differentkeyfor each meaning.
key, each row uses the to-do’s id as its key, and “Delete” and “Confirm delete” use different keys.hooks/state.ts
hooks/register.tsx
ctx.ui.open({ id: 'todo', title: 'To-dos' }) somewhere, such as from a button in the status band.Redrawing
The host keeps the last drawing result and reuses it for ordinary repaints. Your drawing function runs again only in these cases:- when the status band, the tab or the backdrop is shown;
- when a
ctx.statekey read during the drawing changes (for example,ctx.state.setin anonPress); - after you call
ctx.ui.invalidate(); - when the conversation’s theme changes (backdrop only).
ctx.store. After you write to ctx.store, call ctx.ui.invalidate() yourself if the drawing should reflect the change. Do the same when an observe hook learns something new (for example, when session.measure reports that usage changed).ctx.state in them (and await reads of ctx.store), but don’t write:- A
ctx.state.setorctx.state.updatein the body of a drawing function that validation can detect reportsEXTENSION_RENDER_SIDE_EFFECTand blocks preview. - Writing
ctx.statewhile a drawing runs reportsSTATE_WRITE_IN_RENDERat runtime.
Design rules
The host draws every element with its own components and picks the pixels. Colors are token names too, except for a few hex colors used for data. Even so, a drawing can still look wrong: some values draw the same as another one, some draw nothing visible, and a crowded status band pushes the message box down. The items below are rules, not suggestions.Never use
These values and patterns pass validation, but the host doesn’t draw them the way you’d expect.Tokens
- Text size:
basefor body text in a panel.smfor secondary information and for all text in the status band.xsonly for metadata such as a time or a count.lgonly for a panel page title. - Weight:
semiboldfor a page title,mediumfor a group title or a name to emphasize, anddefaultfor everything else. - Text tone:
primaryfor content,secondaryfor descriptions and hints,tertiaryonly for placeholder or unavailable text, andaccentfor something the user can act on.danger,successandwarningmean a state, never decoration. - Show state with a
<Tag>:successfor done or passing,accentfor running,warningfor needs attention,dangerfor failed. Don’t color a<Text>to show a state. A<Tag>withouttoneis a neutral label (a branch, a count, a category). <Spinner>appears only while work is really in progress. When the work ends, replace it with a<Tag>or remove it. Don’t leave a spinner in a resting status band.<Progress>is for when you know how far along the work is: setvalueandmax, and usevalueText(such as"412 / 900") in place of the percentage when it helps. Withoutvalue, it’s a spinner with text. As with<Spinner>, replace it with a<Tag>or remove it when the work ends.- Hex colors are only for data: a label’s own color, one series in a chart, one bar per category. They look the same in the light and dark themes, so pick colors that read well in both. States still use
<Tag>, and every other color uses a token. - Links: use
<Link>for a standalone address (such as “Open PR” in a row). Write links inside a sentence as<Markdown>links, because<Text>holds only strings. An address that breaks the address rules shows as plain text, so usehttps:addresses. <Svg>on the backdrop is a picture, not content: one scene, a few paths, no bitmaps. Backdrop markup is checked against the markup rules, so use only shapes, gradients, filters,<text>and<style>. A rejected picture doesn’t show: when the runtime rejects it, the layer is simply missing, and when the window rejects it, a placeholder shows. Backdrop animation is removed for reduced motion, so the picture has to look good still, too. In the status band and panels,<Svg>checks only its props, so standard SVG elements and embeddeddata:bitmaps work. It takes its own size there, so setwidthandheight.- Radius:
mdfor a card or a group,smfor a small row or a small tag,fullfor a pill. - Buttons:
secondary(the default) for ordinary actions.primaryfor the one main action of a panel page.dangerfor a destructive action.<Button variant="plain" icon="…">for light or repeated actions. Coming soonrole="dismiss"for the trailing×button that closes a status band row or an expanded view inside it, by changingctx.statein itsonPress, with alabelfor screen readers. Aplainbutton always needs anicon, or it reads as plain text.
Status band budget
The status band sits inside the message box, above the user’s draft, and every plugin shares it. Each plugin should keep its layer as small as it can.- One line is the norm, and two lines per plugin is the maximum. Put anything more in a panel, and add a button in the status band that opens it.
- A
<Progress>takes a line of its own, and that line counts toward the two. - Shape of a line: name or state text, then
<Tag>s, then buttons, all in one<Box direction="row" wrap gap="2" align="center">. - Use only the
smtext size. The plugin or topic name can useweight="medium". Other text usestone="secondary". - Give a
<Link>size="sm"too. Without it, the link draws at the body text size. - Three buttons at most: at most one
secondarybutton for the main action, and the others<Button variant="plain" icon="…">. Buttons in the status band use onlysecondaryandplain. Filledprimary,accentordangerbuttons draw more attention than the message box. - A short list has three items at most, each with a stable
key. The two-line budget comes first: three separate rows don’t fit, so either show fewer items or move the list to a panel. - Put
{await next()}as the last child so the plugins after yours still draw.
Panel skeleton
Open an on-demand panel from a user action, usually a button in the status band. For a panel that should be there from the start, callctx.ui.open({ id, title }) in session.start with a fixed id and without focus. The tab appears without stealing attention, and opening the same id again doesn’t add another tab.A panel page has a fixed skeleton:- Title:
<Text size="lg" weight="semibold">. - One line of description, optional:
<Text size="sm" tone="secondary">. - Groups, with
gap="4"between them. A group is<Box direction="column" border radius="md" padding="4" gap="3">and starts with a group title,<Text size="sm" weight="medium">. {await next()}last.
- List rows:
<Box direction="row" align="center" justify="between" padding="2" radius="sm" hover={{ background: 'secondary' }}>, with text on the left and a<Tag>or aplainbutton on the right. Rows that can get long use<Text truncate>, ormaxLinesto show a preview of a few lines. Numbers that line up in a column usetabular. - At most one
primarybutton per page. Destructive actions usedanger. Everything else usessecondaryorplain. - Forms: an
<Input>has alabel, and usesrowsfor text longer than one line (withonSubmit, Enter submits, so say in theplaceholderthatShift+Enteradds a line break). A<Switch>has alabelandonChange. Put one<Select>per row, with alabelthat says what it chooses. - Code: keep lines short, or write
<Code wrap>. The panel is narrow, and long lines that don’t wrap need sideways scrolling to read.
Loading, empty and error states
A panel that depends on data implements loading, empty and error states, and draws only the one that matches the current state. When the data is ready, show the content. Don’t put all three states next to it.Checklist before publishing
- Nothing from “Never use”.
- Status band: two lines at most, three buttons at most, only
smtext, buttons onlysecondaryorplain. - Every state is shown with a
<Tag>, and no<Spinner>or progress bar is left after the work ends. - Hex colors are used only for data (label colors, chart series), never to show a state.
- Every
plainbutton has anicon. - Panel: a title, groups, and the loading, empty and error states.
- Every drawing function includes
await next()(orreturn next()).
Icons
Pick a<Button>’s icon from the names below. A name that isn’t on the list draws no icon. You can also get these names from the Icon object (such as Icon.refresh) and the ICON_NAMES array exported by @minimax/mcode-plugin-extension/ui.Pick the icon that names the action:
refresh for sync, external-link for opening something outside, kanban for a board.Example: a context usage status band
This example shows the conversation’s context usage in the status band and adds a “Compacting soon” tag above 80%. It usessession.measure to redraw when usage changes and ctx.session.usage() to read the number. Before the first measurement, it returns next() and adds nothing.hooks/register.tsx
hooks/state.ts.Example: a release checklist with a progress bar and a link
Coming soonThis example tracks a four-step release checklist in the status band. While it’s unfinished, the first line is a progress bar, and the second line has a “Complete a step” button and a link to the release notes. When it’s done, the progress bar becomes a “Done” tag. The whole plugin takes two lines at most.hooks/state.ts
hooks/register.tsx
Example: a board panel with loading, empty and error states
This example puts an “Open board” button in the status band. Pressing it opens theboard panel and switches to it. The panel calls the plugin’s bundled notes MCP server to sync data, and draws one of four states: loading, empty, error or ready.This example calls
ctx.mcp.call('notes', 'sync', …), so the plugin package must bundle an MCP server named notes and declare it in mcpServers in the manifest. See Call MCP. The call goes through the permission rules. When it needs confirmation, the card’s allow option, “Only this chat”, allows only this one call, and the next call asks again. Whatever the user answers, no permission rule is saved.hooks/state.ts
hooks/register.tsx
syncis defined inside the drawing function, but it’s used only as a button’sonPressand runs on the press. Its writes toctx.statedon’t count as writes during a drawing.- The panel’s
focus: trueis in a button callback, so a user action triggers it. To have the panel there from the start, addawait ctx.ui.open({ id: 'board', title: 'Board' })tosession.start, withoutfocus. - Both drawing functions end with
await next(), so other plugins can still add content to the status band and to this panel.
Example: a night sky backdrop
Coming soonThis example sets a theme namednight when the conversation starts, and the backdrop layer draws a night sky: a gradient sky, three twinkling stars and a moon. The stars’ resting look (opacity: 0.8) is in the base styles, so the picture still looks right when reduced motion removes the animation.hooks/register.tsx
- The SVG references only its own gradient (
url(#sky)) and has no external content, so it passes the markup rules. - The whole backdrop is hidden from screen readers, so there’s no
alt. - A conversation has only one theme. If another plugin calls
ctx.theme.setlater, its theme replaces this one. Thene.props.pluginis no longer your plugin, and the backdrop layer takesreturn next(). For the theme’s other fields (colors, andblur,dimandglassinbackdrop), see Set a theme. - This module keeps no state, so it doesn’t need
hooks/state.ts.
Next steps
Events (hooks)
How to write
ui.render and observe events, when they fire, and how errors are handled.Extension API
Save state, call MCP, open panels, fill text into the message box and set a theme.
Test and troubleshoot
Test the status band and panels with
mount, find and press.Diagnostic codes
What diagnostics such as
EXTENSION_SHADOWING and TREE_INVALID mean and how to fix them.