| index efe7034..af269ef 100644 | ||
| --- a/Makefile | ||
| +++ b/Makefile | ||
| @@ -1,4 +1,4 @@ | ||
| 1 | -# plugin_docker — ScorpioX Bot open-source container dashboard plugin | |
| 1 | +# plugin_docker — SCORPIOX BOT open-source container dashboard plugin | |
| 2 | 2 | # Targets: |
| 3 | 3 | # make native build -> ./plugin_docker |
| 4 | 4 | # make musl static musl x86_64 -> ./plugin_docker (fully static) |
| index 1189304..b735618 100644 | ||
| --- a/README.md | ||
| +++ b/README.md | ||
| @@ -1,6 +1,6 @@ | ||
| 1 | -# plugin_docker — ScorpioX Bot open-source container dashboard plugin | |
| 1 | +# plugin_docker — SCORPIOX BOT open-source container dashboard plugin | |
| 2 | 2 | |
| 3 | -A clean-room, MIT-licensed [ScorpioX Bot](https://bot.scorpiox.net) dynamic plugin that shows | |
| 3 | +A clean-room, MIT-licensed [SCORPIOX BOT](https://bot.scorpiox.net) dynamic plugin that shows | |
| 4 | 4 | the containers running on **your own node**, their live CPU and memory use, their last 100 |
| 5 | 5 | log lines, and lets you safely start, stop and restart them. |
| 6 | 6 | |
| @@ -88,7 +88,7 @@ cp plugin_docker ~/.scorpiox/plugins/ | ||
| 88 | 88 | |
| 89 | 89 | ### Let your agent do it |
| 90 | 90 | |
| 91 | -Paste this into ScorpioX Bot Chat: | |
| 91 | +Paste this into SCORPIOX BOT Chat: | |
| 92 | 92 | |
| 93 | 93 | > Clone `https://plugingit.scorpiox.net/scorpiox-bot-plugin-docker.git`, audit |
| 94 | 94 | > `src/plugin_docker.c` for safety, customize it for my machine, compile it natively, verify |
| @@ -100,7 +100,7 @@ The whole plugin is one readable C file, so an audit is a five-minute job, not a | ||
| 100 | 100 | |
| 101 | 101 | ## The three-mode contract |
| 102 | 102 | |
| 103 | -Every ScorpioX Bot node plugin is one executable that switches on how it is invoked. | |
| 103 | +Every SCORPIOX BOT node plugin is one executable that switches on how it is invoked. | |
| 104 | 104 | |
| 105 | 105 | ### 1. Metadata |
| 106 | 106 |
| index 0ef9a2d..46ae2e6 100755 | ||
| --- a/release-dist.sh | ||
| +++ b/release-dist.sh | ||
| @@ -28,7 +28,7 @@ set -euo pipefail | ||
| 28 | 28 | |
| 29 | 29 | SLUG="docker" |
| 30 | 30 | ID="plugin_docker" |
| 31 | -VERSION="1.1.1" | |
| 31 | +VERSION="1.1.2" | |
| 32 | 32 | DIST_BASE_URL="https://dist.scorpiox.net/bot-plugins" |
| 33 | 33 | |
| 34 | 34 | ROOT="$(cd "$(dirname "$0")" && pwd)" |
| 1 | 1 | new file mode 100644 |
| index 0000000..0dd243b | ||
| --- /dev/null | ||
| +++ b/src/bot_theme_plugin.h | ||
| @@ -0,0 +1,129 @@ | ||
| 1 | +/* | |
| 2 | + * bot_theme_plugin.h -- SCORPIOX BOT theme tokens for node plugins. | |
| 3 | + * | |
| 4 | + * A trimmed copy of scorpiox-bot-web/bot_theme.h (the bot's single source of | |
| 5 | + * truth for its dual theme). A plugin runs inside the bot (Hub modal, Session | |
| 6 | + * Card modal, Chat floating window) or in its own tab, and in every case it | |
| 7 | + * must look like part of the bot: same tokens, same dark/light pair, same | |
| 8 | + * localStorage key, same prepaint order. | |
| 9 | + * | |
| 10 | + * Three rules, and nothing else: | |
| 11 | + * | |
| 12 | + * 1. Colours come from these tokens only. No plugin-private palette. | |
| 13 | + * 2. The theme is decided BEFORE first paint, in this order: | |
| 14 | + * ?theme=light|dark -> localStorage.bot_theme -> prefers-color-scheme | |
| 15 | + * so a plugin opened from the bot paints in the bot's theme from frame 0. | |
| 16 | + * 3. When the bot's theme changes it posts {type:'sx-theme',theme:'...'} into | |
| 17 | + * this window; the plugin follows without a reload. The plugin asks once | |
| 18 | + * with {type:'sx-theme-request'} at startup, which covers the case where | |
| 19 | + * it was already open when the bot changed theme. | |
| 20 | + * | |
| 21 | + * The bottom of :root carries aliases for the names older plugin CSS already | |
| 22 | + * uses (--surface, --surface2, --muted, --accent, --accent2, --danger, --warn, | |
| 23 | + * --ok), so adopting the bot palette is a swap, not a redesign. Because they | |
| 24 | + * are var() references, one definition covers both themes. | |
| 25 | + * | |
| 26 | + * MIT License. Copyright (c) 2026 SCORPIOX INC. | |
| 27 | + */ | |
| 28 | +#ifndef SX_BOT_THEME_PLUGIN_H | |
| 29 | +#define SX_BOT_THEME_PLUGIN_H | |
| 30 | + | |
| 31 | +/* Dark is the default; light is applied by html[data-theme=light] (chosen by | |
| 32 | + * ?theme= or the bot) or by prefers-color-scheme when nothing chose. */ | |
| 33 | +#define SX_BOT_THEME_TOKENS \ | |
| 34 | +":root{color-scheme:dark;" \ | |
| 35 | + "--bg:#000000;--bg-2:#08080a;--bg-card:#1c1c1e;" \ | |
| 36 | + "--surface-2:rgba(255,255,255,.06);--surface-hover:rgba(255,255,255,.05);" \ | |
| 37 | + "--line:rgba(255,255,255,.08);--line-2:rgba(255,255,255,.16);--border:rgba(255,255,255,.08);" \ | |
| 38 | + "--text:#f5f5f7;--text-2:#86868b;--dim:#86868b;" \ | |
| 39 | + "--blue:#0a84ff;--green:#30d158;--orange:#ff9f0a;--red:#ff453a;--gray:#8e8e93;" \ | |
| 40 | + "--indigo:#5e5ce6;--teal:#64d2ff;--purple:#bf5af2;--yellow:#ffd60a;" \ | |
| 41 | + "--input-bg:rgba(255,255,255,.04);--modal-bg:#1c1c1e;--menu-bg:#1c1c1e;--code-bg:rgba(255,255,255,.06);" \ | |
| 42 | + "--mono:'SF Mono',ui-monospace,Menlo,Consolas,'DejaVu Sans Mono',monospace;" \ | |
| 43 | + "--font:-apple-system,BlinkMacSystemFont,'SF Pro Display','SF Pro Text','Inter','Segoe UI',Roboto,Helvetica,Arial,sans-serif;" \ | |
| 44 | + "--shadow:0 1px 2px rgba(0,0,0,.35);" \ | |
| 45 | + "--shadow-lg:0 30px 80px rgba(0,0,0,.65),0 0 0 1px rgba(255,255,255,.04);" \ | |
| 46 | + "--ease:cubic-bezier(.16,1,.3,1);" \ | |
| 47 | + "--surface:var(--bg-card);--surface2:var(--surface-2);--muted:var(--text-2);" \ | |
| 48 | + "--accent:var(--blue);--accent2:var(--green);--accent-dim:#0071e3;" \ | |
| 49 | + "--danger:var(--red);--err:var(--red);--warn:var(--orange);--ok:var(--green);" \ | |
| 50 | +"}" \ | |
| 51 | +"@media (prefers-color-scheme:light){html:not([data-theme=dark]){" \ | |
| 52 | + "--bg:#f5f5f7;--bg-2:#ffffff;--bg-card:#ffffff;" \ | |
| 53 | + "--surface-2:rgba(0,0,0,.04);--surface-hover:#ffffff;" \ | |
| 54 | + "--line:rgba(0,0,0,.06);--line-2:rgba(0,0,0,.12);--border:rgba(0,0,0,.06);" \ | |
| 55 | + "--text:#1d1d1f;--text-2:#6e6e73;--dim:#6e6e73;" \ | |
| 56 | + "--blue:#007aff;--green:#34c759;--orange:#ff9500;--red:#ff3b30;--gray:#8e8e93;" \ | |
| 57 | + "--indigo:#5856d6;--teal:#32ade6;--purple:#af52de;--yellow:#b8860b;" \ | |
| 58 | + "--accent-dim:#0066d6;" \ | |
| 59 | + "--input-bg:#f5f5f7;--modal-bg:#ffffff;--menu-bg:#ffffff;--code-bg:rgba(0,0,0,.05);" \ | |
| 60 | + "--shadow:0 2px 10px rgba(0,0,0,.03);" \ | |
| 61 | + "--shadow-lg:0 30px 80px rgba(0,0,0,.18),0 0 0 1px rgba(0,0,0,.04);" \ | |
| 62 | + "color-scheme:light}}" \ | |
| 63 | +"html[data-theme=light]{" \ | |
| 64 | + "--bg:#f5f5f7;--bg-2:#ffffff;--bg-card:#ffffff;" \ | |
| 65 | + "--surface-2:rgba(0,0,0,.04);--surface-hover:#ffffff;" \ | |
| 66 | + "--line:rgba(0,0,0,.06);--line-2:rgba(0,0,0,.12);--border:rgba(0,0,0,.06);" \ | |
| 67 | + "--text:#1d1d1f;--text-2:#6e6e73;--dim:#6e6e73;" \ | |
| 68 | + "--blue:#007aff;--green:#34c759;--orange:#ff9500;--red:#ff3b30;--gray:#8e8e93;" \ | |
| 69 | + "--indigo:#5856d6;--teal:#32ade6;--purple:#af52de;--yellow:#b8860b;" \ | |
| 70 | + "--accent-dim:#0066d6;" \ | |
| 71 | + "--input-bg:#f5f5f7;--modal-bg:#ffffff;--menu-bg:#ffffff;--code-bg:rgba(0,0,0,.05);" \ | |
| 72 | + "--shadow:0 2px 10px rgba(0,0,0,.03);" \ | |
| 73 | + "--shadow-lg:0 30px 80px rgba(0,0,0,.18),0 0 0 1px rgba(0,0,0,.04);" \ | |
| 74 | + "color-scheme:light}" \ | |
| 75 | +"html{color-scheme:dark}html[data-theme=dark]{color-scheme:dark}" \ | |
| 76 | +"*{box-sizing:border-box}" \ | |
| 77 | +"body{margin:0;background:var(--bg);color:var(--text);font-family:var(--font);" \ | |
| 78 | + "-webkit-font-smoothing:antialiased}" \ | |
| 79 | +"button{font-family:inherit;letter-spacing:inherit}" \ | |
| 80 | +"button:active{transform:scale(.98)}" \ | |
| 81 | +"select option{background:var(--menu-bg);color:var(--text)}" \ | |
| 82 | +"a{color:var(--blue);text-decoration:none;font-weight:600}" \ | |
| 83 | +"/* Embed mode (?embed=1): the host owns the title and the theme, so the plugin" \ | |
| 84 | +" * hides its own back link and its own toggle. */" \ | |
| 85 | +"html.embedded .embed-hide,html.embedded #themeToggle{display:none!important}" \ | |
| 86 | +"@media(prefers-reduced-motion:reduce){*{animation:none!important;transition:none!important}}" | |
| 87 | + | |
| 88 | +/* Pre-paint: decide the theme before the first frame. Must be the first thing | |
| 89 | + * in <head> so there is no flash of the wrong theme. Also flags embed mode as | |
| 90 | + * html.embedded so the embed rules apply before first paint. */ | |
| 91 | +#define SX_BOT_THEME_PREPAINT \ | |
| 92 | +"<script>(function(){var t='';" \ | |
| 93 | +"try{var m=/[?&]theme=(light|dark)/.exec(location.search);if(m)t=m[1];}catch(e){}" \ | |
| 94 | +"if(!t){try{var s=localStorage.getItem('bot_theme');if(s==='light'||s==='dark')t=s;}catch(e){}}" \ | |
| 95 | +"if(!t){try{t=(window.matchMedia&&window.matchMedia('(prefers-color-scheme: light)').matches)?'light':'dark';}catch(e){t='dark';}}" \ | |
| 96 | +"document.documentElement.setAttribute('data-theme',t);" \ | |
| 97 | +"try{if(/[?&]embed=(1|true)(&|$)/.test(location.search))document.documentElement.classList.add('embedded');}catch(e){}" \ | |
| 98 | +"try{localStorage.setItem('bot_theme',t);}catch(e){}" \ | |
| 99 | +"})();</script>\n" | |
| 100 | + | |
| 101 | +/* Handoff: follow the bot. The host posts {type:'sx-theme',theme}; we ask once | |
| 102 | + * at startup in case it changed while this page was already open. Fires the | |
| 103 | + * same 'bot-theme' CustomEvent the bot pages use, so canvas surfaces can | |
| 104 | + * re-skin themselves from one listener. */ | |
| 105 | +#define SX_BOT_THEME_HANDOFF \ | |
| 106 | +"<script>(function(){" \ | |
| 107 | +"function apply(t){if(t!=='light'&&t!=='dark')return;" \ | |
| 108 | +"if(document.documentElement.getAttribute('data-theme')===t)return;" \ | |
| 109 | +"document.documentElement.setAttribute('data-theme',t);" \ | |
| 110 | +"try{localStorage.setItem('bot_theme',t);}catch(e){}" \ | |
| 111 | +"try{window.dispatchEvent(new CustomEvent('bot-theme',{detail:t}));}catch(e){}}" \ | |
| 112 | +"window.sxApplyTheme=apply;" \ | |
| 113 | +"window.sxTheme=function(){var t=document.documentElement.getAttribute('data-theme');return (t==='light'||t==='dark')?t:'dark';};" \ | |
| 114 | +"window.addEventListener('message',function(e){var d=e&&e.data;if(d&&d.type==='sx-theme')apply(d.theme);});" \ | |
| 115 | +"try{if(window.parent&&window.parent!==window)window.parent.postMessage({type:'sx-theme-request'},'*');}catch(e){}" \ | |
| 116 | +"})();</script>\n" | |
| 117 | + | |
| 118 | +/* Standalone toggle (hidden in embed mode by the CSS above). Only useful when | |
| 119 | + * the plugin is opened in its own tab; inside the bot the host owns the theme. | |
| 120 | + * Give it class 'icon-btn'-free styling from the page, or use the helper JS. */ | |
| 121 | +#define SX_BOT_THEME_TOGGLE_BTN \ | |
| 122 | +"<button class='embed-hide' id='themeToggle' type='button' title='Toggle appearance'>Theme</button>" | |
| 123 | + | |
| 124 | +#define SX_BOT_THEME_TOGGLE_JS \ | |
| 125 | +"<script>(function(){var b=document.getElementById('themeToggle');if(!b)return;" \ | |
| 126 | +"b.onclick=function(){window.sxApplyTheme(window.sxTheme()==='dark'?'light':'dark');};" \ | |
| 127 | +"})();</script>\n" | |
| 128 | + | |
| 129 | +#endif /* SX_BOT_THEME_PLUGIN_H */ |
| index 85d6b58..3243baf 100644 | ||
| --- a/src/plugin_docker.c | ||
| +++ b/src/plugin_docker.c | ||
| @@ -1,5 +1,5 @@ | ||
| 1 | 1 | /* |
| 2 | - * plugin_docker — ScorpioX Bot open-source container dashboard plugin | |
| 2 | + * plugin_docker — SCORPIOX BOT open-source container dashboard plugin | |
| 3 | 3 | * |
| 4 | 4 | * A single clean-room C99 binary that serves THREE modes: |
| 5 | 5 | * 1. --meta / SX_PLUGIN_META=1 -> JSON metadata for discovery |
| @@ -50,9 +50,11 @@ | ||
| 50 | 50 | # define SX_PATH_SEP ':' |
| 51 | 51 | #endif |
| 52 | 52 | |
| 53 | +#include "bot_theme_plugin.h" | |
| 54 | + | |
| 53 | 55 | #define PLUGIN_SLUG "docker" |
| 54 | 56 | #define PLUGIN_ID "plugin_docker" |
| 55 | -#define PLUGIN_VER "1.1.1" | |
| 57 | +#define PLUGIN_VER "1.1.2" | |
| 56 | 58 | |
| 57 | 59 | #define MAX_CONTAINERS 256 |
| 58 | 60 | #define LOG_TAIL 100 |
| @@ -736,16 +738,10 @@ static int mode_html(int embed) | ||
| 736 | 738 | |
| 737 | 739 | fputs("<!DOCTYPE html>\n<html lang='en'><head><meta charset='utf-8'>" |
| 738 | 740 | "<meta name='viewport' content='width=device-width,initial-scale=1'>" |
| 739 | - "<title>docker</title><style>", stdout); | |
| 741 | + "<title>docker</title>", stdout); | |
| 740 | 742 | |
| 743 | + fputs(SX_BOT_THEME_PREPAINT "<style>" SX_BOT_THEME_TOKENS, stdout); | |
| 741 | 744 | fputs( |
| 742 | -":root{color-scheme:dark light;" | |
| 743 | - "--bg:#0d0d10;--surface:#16161a;--surface2:#1e1e24;--text:#f5f5f7;" | |
| 744 | - "--muted:#8e8e96;--line:rgba(255,255,255,.11);--accent:#0a84ff;" | |
| 745 | - "--accent2:#30d158;--warn:#ffd60a;--danger:#ff453a;" | |
| 746 | - "--mono:ui-monospace,SFMono-Regular,Menlo,monospace}" | |
| 747 | -"html[data-theme=light]{--bg:#f4f4f7;--surface:#ffffff;--surface2:#f0f0f4;" | |
| 748 | - "--text:#1c1c1e;--muted:#6b6b73;--line:rgba(0,0,0,.10)}" | |
| 749 | 745 | "*{box-sizing:border-box}" |
| 750 | 746 | "body{margin:0;padding:16px;background:var(--bg);color:var(--text);" |
| 751 | 747 | "font-family:-apple-system,BlinkMacSystemFont,'Segoe UI',sans-serif;" |
| @@ -808,7 +804,7 @@ static int mode_html(int embed) | ||
| 808 | 804 | "td{padding:8px 4px}th{padding:6px 4px}" |
| 809 | 805 | "td:nth-child(2){white-space:nowrap;font-weight:600}" |
| 810 | 806 | ".acts{gap:4px}button.sm{padding:4px 8px;font-size:11px}}" |
| 811 | -"</style></head><body><div class='wrap'>", stdout); | |
| 807 | +"</style></head>" SX_BOT_THEME_HANDOFF "<body><div class='wrap'>", stdout); | |
| 812 | 808 | |
| 813 | 809 | if (!embed) |
| 814 | 810 | fputs("<div class='top'><a href='/' style='color:var(--accent);text-decoration:none;" |
| @@ -818,7 +814,7 @@ static int mode_html(int embed) | ||
| 818 | 814 | "<span class='pill'>" PLUGIN_VER "</span>" |
| 819 | 815 | "<span class='pill' id='badge'>connecting</span>" |
| 820 | 816 | "<span class='spacer'></span>" |
| 821 | - "<button class='ghost' id='themeBtn' type='button'>Theme</button>" | |
| 817 | + "<button class='ghost embed-hide' id='themeBtn' type='button'>Theme</button>" | |
| 822 | 818 | "<button class='ghost' id='reloadBtn' type='button'>Refresh</button></div>", stdout); |
| 823 | 819 | |
| 824 | 820 | /* KPIs */ |
| index ebf7055..fc3e341 100755 | ||
| --- a/tests/run.sh | ||
| +++ b/tests/run.sh | ||
| @@ -95,7 +95,7 @@ DESC=$(printf '%s' "$META" | sed 's/.*"desc":"\([^"]*\)".*/\1/') | ||
| 95 | 95 | [ ${#DESC} -le 15 ] && pass "desc length ${#DESC} <= 15 chars" || fail "desc too long (${#DESC})" |
| 96 | 96 | NAME=$(printf '%s' "$META" | sed 's/.*"name":"\([^"]*\)".*/\1/') |
| 97 | 97 | [ "$(printf '%s' "$NAME" | wc -w | tr -d ' ')" -le 1 ] && pass "name is a single word" || fail "name has spaces" |
| 98 | -check "--version prints version" '1.1.1' "$("$BIN" --version)" | |
| 98 | +check "--version prints version" '1.1.2' "$("$BIN" --version)" | |
| 99 | 99 | check "--help is available" 'usage:' "$("$BIN" --help)" |
| 100 | 100 | |
| 101 | 101 | # ---------------------------------------------------------------- list mode |
| @@ -129,7 +129,7 @@ check_not "list header has no Content-Length" 'Content-Length' "$LIST" | ||
| 129 | 129 | check "list ok:true" '"ok":true' "$LBODY" |
| 130 | 130 | check "list plugin id" '"plugin":"plugin_docker"' "$LBODY" |
| 131 | 131 | check "list slug docker" '"slug":"docker"' "$LBODY" |
| 132 | -check "list version" '"version":"1.1.1"' "$LBODY" | |
| 132 | +check "list version" '"version":"1.1.2"' "$LBODY" | |
| 133 | 133 | check "list runtime available" '"available":true' "$LBODY" |
| 134 | 134 | check "list daemon available" '"daemon_available":true' "$LBODY" |
| 135 | 135 | check "list count 3" '"count":3' "$LBODY" |
| @@ -259,6 +259,24 @@ check "html log viewer card" "logCard" "$HTML" | ||
| 259 | 259 | check "html uses /plugins?plugin= route" "/plugins?plugin=" "$HTML" |
| 260 | 260 | check "html uses POST for control" "method:'POST'" "$HTML" |
| 261 | 261 | check "html has theme switch" "bot_theme" "$HTML" |
| 262 | + | |
| 263 | +# ---- theme handoff (bot_theme_plugin.h) ---- | |
| 264 | +# the bot owns the theme: ?theme= before first paint, sx-theme after it | |
| 265 | +check "html reads ?theme= before paint" 'theme=(light|dark)' "$HTML" | |
| 266 | +check "html listens for sx-theme" "d.type==='sx-theme'" "$HTML" | |
| 267 | +check "html asks the host for the theme" "sx-theme-request" "$HTML" | |
| 268 | +check "html uses bot token --bg-card" "--bg-card" "$HTML" | |
| 269 | +check "html uses bot token --surface-2" "--surface-2" "$HTML" | |
| 270 | +check "html uses bot token --text-2" "--text-2" "$HTML" | |
| 271 | +check "html hides its toggle when embedded" "embed-hide" "$HTML" | |
| 272 | +check_not "html no retired brand casing" 'Scorpio'"X Bot" "$HTML" | |
| 273 | +check_not "html no private palette 0d0d10" '0d0d10' "$HTML" | |
| 274 | +check_not "html no private palette 16161a" '16161a' "$HTML" | |
| 275 | +check_not "html no private palette f4f4f7" 'f4f4f7' "$HTML" | |
| 276 | +THEMEQ=$(QUERY_STRING='theme=light' "$BIN") | |
| 277 | +check "?theme=light still renders the UI" 'prefers-color-scheme' "$THEMEQ" | |
| 278 | +# ---- end theme handoff ---- | |
| 279 | + | |
| 262 | 280 | check "html closes document" '</html>' "$HTML" |
| 263 | 281 | EMB=$(QUERY_STRING='embed=1' "$BIN") |
| 264 | 282 | check_not "embed=1 strips the back-link" 'Back to Bot' "$EMB" |
| 265 | 283 |
| index efe7034..af269ef 100644 | index efe7034..af269ef 100644 | ||
| --- a/Makefile | --- a/Makefile | ||
| +++ b/Makefile | +++ b/Makefile | ||
| @@ -1,4 +1,4 @@ | @@ -1,4 +1,4 @@ | ||
| 1 | -# plugin_docker — ScorpioX Bot open-source container dashboard plugin | 1 | +# plugin_docker — SCORPIOX BOT open-source container dashboard plugin |
| 2 | # Targets: | 2 | # Targets: |
| 3 | # make native build -> ./plugin_docker | 3 | # make native build -> ./plugin_docker |
| 4 | # make musl static musl x86_64 -> ./plugin_docker (fully static) | 4 | # make musl static musl x86_64 -> ./plugin_docker (fully static) |
| index 1189304..b735618 100644 | index 1189304..b735618 100644 | ||
| --- a/README.md | --- a/README.md | ||
| +++ b/README.md | +++ b/README.md | ||
| @@ -1,6 +1,6 @@ | @@ -1,6 +1,6 @@ | ||
| 1 | -# plugin_docker — ScorpioX Bot open-source container dashboard plugin | 1 | +# plugin_docker — SCORPIOX BOT open-source container dashboard plugin |
| 2 | 2 | ||
| 3 | -A clean-room, MIT-licensed [ScorpioX Bot](https://bot.scorpiox.net) dynamic plugin that shows | 3 | +A clean-room, MIT-licensed [SCORPIOX BOT](https://bot.scorpiox.net) dynamic plugin that shows |
| 4 | the containers running on **your own node**, their live CPU and memory use, their last 100 | 4 | the containers running on **your own node**, their live CPU and memory use, their last 100 |
| 5 | log lines, and lets you safely start, stop and restart them. | 5 | log lines, and lets you safely start, stop and restart them. |
| 6 | 6 | ||
| @@ -88,7 +88,7 @@ cp plugin_docker ~/.scorpiox/plugins/ | @@ -88,7 +88,7 @@ cp plugin_docker ~/.scorpiox/plugins/ | ||
| 88 | 88 | ||
| 89 | ### Let your agent do it | 89 | ### Let your agent do it |
| 90 | 90 | ||
| 91 | -Paste this into ScorpioX Bot Chat: | 91 | +Paste this into SCORPIOX BOT Chat: |
| 92 | 92 | ||
| 93 | > Clone `https://plugingit.scorpiox.net/scorpiox-bot-plugin-docker.git`, audit | 93 | > Clone `https://plugingit.scorpiox.net/scorpiox-bot-plugin-docker.git`, audit |
| 94 | > `src/plugin_docker.c` for safety, customize it for my machine, compile it natively, verify | 94 | > `src/plugin_docker.c` for safety, customize it for my machine, compile it natively, verify |
| @@ -100,7 +100,7 @@ The whole plugin is one readable C file, so an audit is a five-minute job, not a | @@ -100,7 +100,7 @@ The whole plugin is one readable C file, so an audit is a five-minute job, not a | ||
| 100 | 100 | ||
| 101 | ## The three-mode contract | 101 | ## The three-mode contract |
| 102 | 102 | ||
| 103 | -Every ScorpioX Bot node plugin is one executable that switches on how it is invoked. | 103 | +Every SCORPIOX BOT node plugin is one executable that switches on how it is invoked. |
| 104 | 104 | ||
| 105 | ### 1. Metadata | 105 | ### 1. Metadata |
| 106 | 106 |
| index 0ef9a2d..46ae2e6 100755 | index 0ef9a2d..46ae2e6 100755 | ||
| --- a/release-dist.sh | --- a/release-dist.sh | ||
| +++ b/release-dist.sh | +++ b/release-dist.sh | ||
| @@ -28,7 +28,7 @@ set -euo pipefail | @@ -28,7 +28,7 @@ set -euo pipefail | ||
| 28 | 28 | ||
| 29 | SLUG="docker" | 29 | SLUG="docker" |
| 30 | ID="plugin_docker" | 30 | ID="plugin_docker" |
| 31 | -VERSION="1.1.1" | 31 | +VERSION="1.1.2" |
| 32 | DIST_BASE_URL="https://dist.scorpiox.net/bot-plugins" | 32 | DIST_BASE_URL="https://dist.scorpiox.net/bot-plugins" |
| 33 | 33 | ||
| 34 | ROOT="$(cd "$(dirname "$0")" && pwd)" | 34 | ROOT="$(cd "$(dirname "$0")" && pwd)" |
| 1 | new file mode 100644 | 1 | new file mode 100644 |
| index 0000000..0dd243b | index 0000000..0dd243b | ||
| --- /dev/null | --- /dev/null | ||
| +++ b/src/bot_theme_plugin.h | +++ b/src/bot_theme_plugin.h | ||
| @@ -0,0 +1,129 @@ | @@ -0,0 +1,129 @@ | ||
| 1 | +/* | ||
| 2 | + * bot_theme_plugin.h -- SCORPIOX BOT theme tokens for node plugins. | ||
| 3 | + * | ||
| 4 | + * A trimmed copy of scorpiox-bot-web/bot_theme.h (the bot's single source of | ||
| 5 | + * truth for its dual theme). A plugin runs inside the bot (Hub modal, Session | ||
| 6 | + * Card modal, Chat floating window) or in its own tab, and in every case it | ||
| 7 | + * must look like part of the bot: same tokens, same dark/light pair, same | ||
| 8 | + * localStorage key, same prepaint order. | ||
| 9 | + * | ||
| 10 | + * Three rules, and nothing else: | ||
| 11 | + * | ||
| 12 | + * 1. Colours come from these tokens only. No plugin-private palette. | ||
| 13 | + * 2. The theme is decided BEFORE first paint, in this order: | ||
| 14 | + * ?theme=light|dark -> localStorage.bot_theme -> prefers-color-scheme | ||
| 15 | + * so a plugin opened from the bot paints in the bot's theme from frame 0. | ||
| 16 | + * 3. When the bot's theme changes it posts {type:'sx-theme',theme:'...'} into | ||
| 17 | + * this window; the plugin follows without a reload. The plugin asks once | ||
| 18 | + * with {type:'sx-theme-request'} at startup, which covers the case where | ||
| 19 | + * it was already open when the bot changed theme. | ||
| 20 | + * | ||
| 21 | + * The bottom of :root carries aliases for the names older plugin CSS already | ||
| 22 | + * uses (--surface, --surface2, --muted, --accent, --accent2, --danger, --warn, | ||
| 23 | + * --ok), so adopting the bot palette is a swap, not a redesign. Because they | ||
| 24 | + * are var() references, one definition covers both themes. | ||
| 25 | + * | ||
| 26 | + * MIT License. Copyright (c) 2026 SCORPIOX INC. | ||
| 27 | + */ | ||
| 28 | +#ifndef SX_BOT_THEME_PLUGIN_H | ||
| 29 | +#define SX_BOT_THEME_PLUGIN_H | ||
| 30 | + | ||
| 31 | +/* Dark is the default; light is applied by html[data-theme=light] (chosen by | ||
| 32 | + * ?theme= or the bot) or by prefers-color-scheme when nothing chose. */ | ||
| 33 | +#define SX_BOT_THEME_TOKENS \ | ||
| 34 | +":root{color-scheme:dark;" \ | ||
| 35 | + "--bg:#000000;--bg-2:#08080a;--bg-card:#1c1c1e;" \ | ||
| 36 | + "--surface-2:rgba(255,255,255,.06);--surface-hover:rgba(255,255,255,.05);" \ | ||
| 37 | + "--line:rgba(255,255,255,.08);--line-2:rgba(255,255,255,.16);--border:rgba(255,255,255,.08);" \ | ||
| 38 | + "--text:#f5f5f7;--text-2:#86868b;--dim:#86868b;" \ | ||
| 39 | + "--blue:#0a84ff;--green:#30d158;--orange:#ff9f0a;--red:#ff453a;--gray:#8e8e93;" \ | ||
| 40 | + "--indigo:#5e5ce6;--teal:#64d2ff;--purple:#bf5af2;--yellow:#ffd60a;" \ | ||
| 41 | + "--input-bg:rgba(255,255,255,.04);--modal-bg:#1c1c1e;--menu-bg:#1c1c1e;--code-bg:rgba(255,255,255,.06);" \ | ||
| 42 | + "--mono:'SF Mono',ui-monospace,Menlo,Consolas,'DejaVu Sans Mono',monospace;" \ | ||
| 43 | + "--font:-apple-system,BlinkMacSystemFont,'SF Pro Display','SF Pro Text','Inter','Segoe UI',Roboto,Helvetica,Arial,sans-serif;" \ | ||
| 44 | + "--shadow:0 1px 2px rgba(0,0,0,.35);" \ | ||
| 45 | + "--shadow-lg:0 30px 80px rgba(0,0,0,.65),0 0 0 1px rgba(255,255,255,.04);" \ | ||
| 46 | + "--ease:cubic-bezier(.16,1,.3,1);" \ | ||
| 47 | + "--surface:var(--bg-card);--surface2:var(--surface-2);--muted:var(--text-2);" \ | ||
| 48 | + "--accent:var(--blue);--accent2:var(--green);--accent-dim:#0071e3;" \ | ||
| 49 | + "--danger:var(--red);--err:var(--red);--warn:var(--orange);--ok:var(--green);" \ | ||
| 50 | +"}" \ | ||
| 51 | +"@media (prefers-color-scheme:light){html:not([data-theme=dark]){" \ | ||
| 52 | + "--bg:#f5f5f7;--bg-2:#ffffff;--bg-card:#ffffff;" \ | ||
| 53 | + "--surface-2:rgba(0,0,0,.04);--surface-hover:#ffffff;" \ | ||
| 54 | + "--line:rgba(0,0,0,.06);--line-2:rgba(0,0,0,.12);--border:rgba(0,0,0,.06);" \ | ||
| 55 | + "--text:#1d1d1f;--text-2:#6e6e73;--dim:#6e6e73;" \ | ||
| 56 | + "--blue:#007aff;--green:#34c759;--orange:#ff9500;--red:#ff3b30;--gray:#8e8e93;" \ | ||
| 57 | + "--indigo:#5856d6;--teal:#32ade6;--purple:#af52de;--yellow:#b8860b;" \ | ||
| 58 | + "--accent-dim:#0066d6;" \ | ||
| 59 | + "--input-bg:#f5f5f7;--modal-bg:#ffffff;--menu-bg:#ffffff;--code-bg:rgba(0,0,0,.05);" \ | ||
| 60 | + "--shadow:0 2px 10px rgba(0,0,0,.03);" \ | ||
| 61 | + "--shadow-lg:0 30px 80px rgba(0,0,0,.18),0 0 0 1px rgba(0,0,0,.04);" \ | ||
| 62 | + "color-scheme:light}}" \ | ||
| 63 | +"html[data-theme=light]{" \ | ||
| 64 | + "--bg:#f5f5f7;--bg-2:#ffffff;--bg-card:#ffffff;" \ | ||
| 65 | + "--surface-2:rgba(0,0,0,.04);--surface-hover:#ffffff;" \ | ||
| 66 | + "--line:rgba(0,0,0,.06);--line-2:rgba(0,0,0,.12);--border:rgba(0,0,0,.06);" \ | ||
| 67 | + "--text:#1d1d1f;--text-2:#6e6e73;--dim:#6e6e73;" \ | ||
| 68 | + "--blue:#007aff;--green:#34c759;--orange:#ff9500;--red:#ff3b30;--gray:#8e8e93;" \ | ||
| 69 | + "--indigo:#5856d6;--teal:#32ade6;--purple:#af52de;--yellow:#b8860b;" \ | ||
| 70 | + "--accent-dim:#0066d6;" \ | ||
| 71 | + "--input-bg:#f5f5f7;--modal-bg:#ffffff;--menu-bg:#ffffff;--code-bg:rgba(0,0,0,.05);" \ | ||
| 72 | + "--shadow:0 2px 10px rgba(0,0,0,.03);" \ | ||
| 73 | + "--shadow-lg:0 30px 80px rgba(0,0,0,.18),0 0 0 1px rgba(0,0,0,.04);" \ | ||
| 74 | + "color-scheme:light}" \ | ||
| 75 | +"html{color-scheme:dark}html[data-theme=dark]{color-scheme:dark}" \ | ||
| 76 | +"*{box-sizing:border-box}" \ | ||
| 77 | +"body{margin:0;background:var(--bg);color:var(--text);font-family:var(--font);" \ | ||
| 78 | + "-webkit-font-smoothing:antialiased}" \ | ||
| 79 | +"button{font-family:inherit;letter-spacing:inherit}" \ | ||
| 80 | +"button:active{transform:scale(.98)}" \ | ||
| 81 | +"select option{background:var(--menu-bg);color:var(--text)}" \ | ||
| 82 | +"a{color:var(--blue);text-decoration:none;font-weight:600}" \ | ||
| 83 | +"/* Embed mode (?embed=1): the host owns the title and the theme, so the plugin" \ | ||
| 84 | +" * hides its own back link and its own toggle. */" \ | ||
| 85 | +"html.embedded .embed-hide,html.embedded #themeToggle{display:none!important}" \ | ||
| 86 | +"@media(prefers-reduced-motion:reduce){*{animation:none!important;transition:none!important}}" | ||
| 87 | + | ||
| 88 | +/* Pre-paint: decide the theme before the first frame. Must be the first thing | ||
| 89 | + * in <head> so there is no flash of the wrong theme. Also flags embed mode as | ||
| 90 | + * html.embedded so the embed rules apply before first paint. */ | ||
| 91 | +#define SX_BOT_THEME_PREPAINT \ | ||
| 92 | +"<script>(function(){var t='';" \ | ||
| 93 | +"try{var m=/[?&]theme=(light|dark)/.exec(location.search);if(m)t=m[1];}catch(e){}" \ | ||
| 94 | +"if(!t){try{var s=localStorage.getItem('bot_theme');if(s==='light'||s==='dark')t=s;}catch(e){}}" \ | ||
| 95 | +"if(!t){try{t=(window.matchMedia&&window.matchMedia('(prefers-color-scheme: light)').matches)?'light':'dark';}catch(e){t='dark';}}" \ | ||
| 96 | +"document.documentElement.setAttribute('data-theme',t);" \ | ||
| 97 | +"try{if(/[?&]embed=(1|true)(&|$)/.test(location.search))document.documentElement.classList.add('embedded');}catch(e){}" \ | ||
| 98 | +"try{localStorage.setItem('bot_theme',t);}catch(e){}" \ | ||
| 99 | +"})();</script>\n" | ||
| 100 | + | ||
| 101 | +/* Handoff: follow the bot. The host posts {type:'sx-theme',theme}; we ask once | ||
| 102 | + * at startup in case it changed while this page was already open. Fires the | ||
| 103 | + * same 'bot-theme' CustomEvent the bot pages use, so canvas surfaces can | ||
| 104 | + * re-skin themselves from one listener. */ | ||
| 105 | +#define SX_BOT_THEME_HANDOFF \ | ||
| 106 | +"<script>(function(){" \ | ||
| 107 | +"function apply(t){if(t!=='light'&&t!=='dark')return;" \ | ||
| 108 | +"if(document.documentElement.getAttribute('data-theme')===t)return;" \ | ||
| 109 | +"document.documentElement.setAttribute('data-theme',t);" \ | ||
| 110 | +"try{localStorage.setItem('bot_theme',t);}catch(e){}" \ | ||
| 111 | +"try{window.dispatchEvent(new CustomEvent('bot-theme',{detail:t}));}catch(e){}}" \ | ||
| 112 | +"window.sxApplyTheme=apply;" \ | ||
| 113 | +"window.sxTheme=function(){var t=document.documentElement.getAttribute('data-theme');return (t==='light'||t==='dark')?t:'dark';};" \ | ||
| 114 | +"window.addEventListener('message',function(e){var d=e&&e.data;if(d&&d.type==='sx-theme')apply(d.theme);});" \ | ||
| 115 | +"try{if(window.parent&&window.parent!==window)window.parent.postMessage({type:'sx-theme-request'},'*');}catch(e){}" \ | ||
| 116 | +"})();</script>\n" | ||
| 117 | + | ||
| 118 | +/* Standalone toggle (hidden in embed mode by the CSS above). Only useful when | ||
| 119 | + * the plugin is opened in its own tab; inside the bot the host owns the theme. | ||
| 120 | + * Give it class 'icon-btn'-free styling from the page, or use the helper JS. */ | ||
| 121 | +#define SX_BOT_THEME_TOGGLE_BTN \ | ||
| 122 | +"<button class='embed-hide' id='themeToggle' type='button' title='Toggle appearance'>Theme</button>" | ||
| 123 | + | ||
| 124 | +#define SX_BOT_THEME_TOGGLE_JS \ | ||
| 125 | +"<script>(function(){var b=document.getElementById('themeToggle');if(!b)return;" \ | ||
| 126 | +"b.onclick=function(){window.sxApplyTheme(window.sxTheme()==='dark'?'light':'dark');};" \ | ||
| 127 | +"})();</script>\n" | ||
| 128 | + | ||
| 129 | +#endif /* SX_BOT_THEME_PLUGIN_H */ |
| index 85d6b58..3243baf 100644 | index 85d6b58..3243baf 100644 | ||
| --- a/src/plugin_docker.c | --- a/src/plugin_docker.c | ||
| +++ b/src/plugin_docker.c | +++ b/src/plugin_docker.c | ||
| @@ -1,5 +1,5 @@ | @@ -1,5 +1,5 @@ | ||
| 1 | /* | 1 | /* |
| 2 | - * plugin_docker — ScorpioX Bot open-source container dashboard plugin | 2 | + * plugin_docker — SCORPIOX BOT open-source container dashboard plugin |
| 3 | * | 3 | * |
| 4 | * A single clean-room C99 binary that serves THREE modes: | 4 | * A single clean-room C99 binary that serves THREE modes: |
| 5 | * 1. --meta / SX_PLUGIN_META=1 -> JSON metadata for discovery | 5 | * 1. --meta / SX_PLUGIN_META=1 -> JSON metadata for discovery |
| @@ -50,9 +50,11 @@ | @@ -50,9 +50,11 @@ | ||
| 50 | # define SX_PATH_SEP ':' | 50 | # define SX_PATH_SEP ':' |
| 51 | #endif | 51 | #endif |
| 52 | 52 | ||
| 53 | +#include "bot_theme_plugin.h" | ||
| 54 | + | ||
| 53 | #define PLUGIN_SLUG "docker" | 55 | #define PLUGIN_SLUG "docker" |
| 54 | #define PLUGIN_ID "plugin_docker" | 56 | #define PLUGIN_ID "plugin_docker" |
| 55 | -#define PLUGIN_VER "1.1.1" | 57 | +#define PLUGIN_VER "1.1.2" |
| 56 | 58 | ||
| 57 | #define MAX_CONTAINERS 256 | 59 | #define MAX_CONTAINERS 256 |
| 58 | #define LOG_TAIL 100 | 60 | #define LOG_TAIL 100 |
| @@ -736,16 +738,10 @@ static int mode_html(int embed) | @@ -736,16 +738,10 @@ static int mode_html(int embed) | ||
| 736 | 738 | ||
| 737 | fputs("<!DOCTYPE html>\n<html lang='en'><head><meta charset='utf-8'>" | 739 | fputs("<!DOCTYPE html>\n<html lang='en'><head><meta charset='utf-8'>" |
| 738 | "<meta name='viewport' content='width=device-width,initial-scale=1'>" | 740 | "<meta name='viewport' content='width=device-width,initial-scale=1'>" |
| 739 | - "<title>docker</title><style>", stdout); | 741 | + "<title>docker</title>", stdout); |
| 740 | 742 | ||
| 743 | + fputs(SX_BOT_THEME_PREPAINT "<style>" SX_BOT_THEME_TOKENS, stdout); | ||
| 741 | fputs( | 744 | fputs( |
| 742 | -":root{color-scheme:dark light;" | ||
| 743 | - "--bg:#0d0d10;--surface:#16161a;--surface2:#1e1e24;--text:#f5f5f7;" | ||
| 744 | - "--muted:#8e8e96;--line:rgba(255,255,255,.11);--accent:#0a84ff;" | ||
| 745 | - "--accent2:#30d158;--warn:#ffd60a;--danger:#ff453a;" | ||
| 746 | - "--mono:ui-monospace,SFMono-Regular,Menlo,monospace}" | ||
| 747 | -"html[data-theme=light]{--bg:#f4f4f7;--surface:#ffffff;--surface2:#f0f0f4;" | ||
| 748 | - "--text:#1c1c1e;--muted:#6b6b73;--line:rgba(0,0,0,.10)}" | ||
| 749 | "*{box-sizing:border-box}" | 745 | "*{box-sizing:border-box}" |
| 750 | "body{margin:0;padding:16px;background:var(--bg);color:var(--text);" | 746 | "body{margin:0;padding:16px;background:var(--bg);color:var(--text);" |
| 751 | "font-family:-apple-system,BlinkMacSystemFont,'Segoe UI',sans-serif;" | 747 | "font-family:-apple-system,BlinkMacSystemFont,'Segoe UI',sans-serif;" |
| @@ -808,7 +804,7 @@ static int mode_html(int embed) | @@ -808,7 +804,7 @@ static int mode_html(int embed) | ||
| 808 | "td{padding:8px 4px}th{padding:6px 4px}" | 804 | "td{padding:8px 4px}th{padding:6px 4px}" |
| 809 | "td:nth-child(2){white-space:nowrap;font-weight:600}" | 805 | "td:nth-child(2){white-space:nowrap;font-weight:600}" |
| 810 | ".acts{gap:4px}button.sm{padding:4px 8px;font-size:11px}}" | 806 | ".acts{gap:4px}button.sm{padding:4px 8px;font-size:11px}}" |
| 811 | -"</style></head><body><div class='wrap'>", stdout); | 807 | +"</style></head>" SX_BOT_THEME_HANDOFF "<body><div class='wrap'>", stdout); |
| 812 | 808 | ||
| 813 | if (!embed) | 809 | if (!embed) |
| 814 | fputs("<div class='top'><a href='/' style='color:var(--accent);text-decoration:none;" | 810 | fputs("<div class='top'><a href='/' style='color:var(--accent);text-decoration:none;" |
| @@ -818,7 +814,7 @@ static int mode_html(int embed) | @@ -818,7 +814,7 @@ static int mode_html(int embed) | ||
| 818 | "<span class='pill'>" PLUGIN_VER "</span>" | 814 | "<span class='pill'>" PLUGIN_VER "</span>" |
| 819 | "<span class='pill' id='badge'>connecting</span>" | 815 | "<span class='pill' id='badge'>connecting</span>" |
| 820 | "<span class='spacer'></span>" | 816 | "<span class='spacer'></span>" |
| 821 | - "<button class='ghost' id='themeBtn' type='button'>Theme</button>" | 817 | + "<button class='ghost embed-hide' id='themeBtn' type='button'>Theme</button>" |
| 822 | "<button class='ghost' id='reloadBtn' type='button'>Refresh</button></div>", stdout); | 818 | "<button class='ghost' id='reloadBtn' type='button'>Refresh</button></div>", stdout); |
| 823 | 819 | ||
| 824 | /* KPIs */ | 820 | /* KPIs */ |
| index ebf7055..fc3e341 100755 | index ebf7055..fc3e341 100755 | ||
| --- a/tests/run.sh | --- a/tests/run.sh | ||
| +++ b/tests/run.sh | +++ b/tests/run.sh | ||
| @@ -95,7 +95,7 @@ DESC=$(printf '%s' "$META" | sed 's/.*"desc":"\([^"]*\)".*/\1/') | @@ -95,7 +95,7 @@ DESC=$(printf '%s' "$META" | sed 's/.*"desc":"\([^"]*\)".*/\1/') | ||
| 95 | [ ${#DESC} -le 15 ] && pass "desc length ${#DESC} <= 15 chars" || fail "desc too long (${#DESC})" | 95 | [ ${#DESC} -le 15 ] && pass "desc length ${#DESC} <= 15 chars" || fail "desc too long (${#DESC})" |
| 96 | NAME=$(printf '%s' "$META" | sed 's/.*"name":"\([^"]*\)".*/\1/') | 96 | NAME=$(printf '%s' "$META" | sed 's/.*"name":"\([^"]*\)".*/\1/') |
| 97 | [ "$(printf '%s' "$NAME" | wc -w | tr -d ' ')" -le 1 ] && pass "name is a single word" || fail "name has spaces" | 97 | [ "$(printf '%s' "$NAME" | wc -w | tr -d ' ')" -le 1 ] && pass "name is a single word" || fail "name has spaces" |
| 98 | -check "--version prints version" '1.1.1' "$("$BIN" --version)" | 98 | +check "--version prints version" '1.1.2' "$("$BIN" --version)" |
| 99 | check "--help is available" 'usage:' "$("$BIN" --help)" | 99 | check "--help is available" 'usage:' "$("$BIN" --help)" |
| 100 | 100 | ||
| 101 | # ---------------------------------------------------------------- list mode | 101 | # ---------------------------------------------------------------- list mode |
| @@ -129,7 +129,7 @@ check_not "list header has no Content-Length" 'Content-Length' "$LIST" | @@ -129,7 +129,7 @@ check_not "list header has no Content-Length" 'Content-Length' "$LIST" | ||
| 129 | check "list ok:true" '"ok":true' "$LBODY" | 129 | check "list ok:true" '"ok":true' "$LBODY" |
| 130 | check "list plugin id" '"plugin":"plugin_docker"' "$LBODY" | 130 | check "list plugin id" '"plugin":"plugin_docker"' "$LBODY" |
| 131 | check "list slug docker" '"slug":"docker"' "$LBODY" | 131 | check "list slug docker" '"slug":"docker"' "$LBODY" |
| 132 | -check "list version" '"version":"1.1.1"' "$LBODY" | 132 | +check "list version" '"version":"1.1.2"' "$LBODY" |
| 133 | check "list runtime available" '"available":true' "$LBODY" | 133 | check "list runtime available" '"available":true' "$LBODY" |
| 134 | check "list daemon available" '"daemon_available":true' "$LBODY" | 134 | check "list daemon available" '"daemon_available":true' "$LBODY" |
| 135 | check "list count 3" '"count":3' "$LBODY" | 135 | check "list count 3" '"count":3' "$LBODY" |
| @@ -259,6 +259,24 @@ check "html log viewer card" "logCard" "$HTML" | @@ -259,6 +259,24 @@ check "html log viewer card" "logCard" "$HTML" | ||
| 259 | check "html uses /plugins?plugin= route" "/plugins?plugin=" "$HTML" | 259 | check "html uses /plugins?plugin= route" "/plugins?plugin=" "$HTML" |
| 260 | check "html uses POST for control" "method:'POST'" "$HTML" | 260 | check "html uses POST for control" "method:'POST'" "$HTML" |
| 261 | check "html has theme switch" "bot_theme" "$HTML" | 261 | check "html has theme switch" "bot_theme" "$HTML" |
| 262 | + | ||
| 263 | +# ---- theme handoff (bot_theme_plugin.h) ---- | ||
| 264 | +# the bot owns the theme: ?theme= before first paint, sx-theme after it | ||
| 265 | +check "html reads ?theme= before paint" 'theme=(light|dark)' "$HTML" | ||
| 266 | +check "html listens for sx-theme" "d.type==='sx-theme'" "$HTML" | ||
| 267 | +check "html asks the host for the theme" "sx-theme-request" "$HTML" | ||
| 268 | +check "html uses bot token --bg-card" "--bg-card" "$HTML" | ||
| 269 | +check "html uses bot token --surface-2" "--surface-2" "$HTML" | ||
| 270 | +check "html uses bot token --text-2" "--text-2" "$HTML" | ||
| 271 | +check "html hides its toggle when embedded" "embed-hide" "$HTML" | ||
| 272 | +check_not "html no retired brand casing" 'Scorpio'"X Bot" "$HTML" | ||
| 273 | +check_not "html no private palette 0d0d10" '0d0d10' "$HTML" | ||
| 274 | +check_not "html no private palette 16161a" '16161a' "$HTML" | ||
| 275 | +check_not "html no private palette f4f4f7" 'f4f4f7' "$HTML" | ||
| 276 | +THEMEQ=$(QUERY_STRING='theme=light' "$BIN") | ||
| 277 | +check "?theme=light still renders the UI" 'prefers-color-scheme' "$THEMEQ" | ||
| 278 | +# ---- end theme handoff ---- | ||
| 279 | + | ||
| 262 | check "html closes document" '</html>' "$HTML" | 280 | check "html closes document" '</html>' "$HTML" |
| 263 | EMB=$(QUERY_STRING='embed=1' "$BIN") | 281 | EMB=$(QUERY_STRING='embed=1' "$BIN") |
| 264 | check_not "embed=1 strips the back-link" 'Back to Bot' "$EMB" | 282 | check_not "embed=1 strips the back-link" 'Back to Bot' "$EMB" |
| 265 | 283 |