| 1 | /* Generated by tools/gen_ui.py from src/ui.html. Do not edit by hand. */ |
| 2 | #ifndef SX_SEQTHINK_UI_HTML_H |
| 3 | #define SX_SEQTHINK_UI_HTML_H |
| 4 | |
| 5 | static const char *UI_HTML = |
| 6 | "<!DOCTYPE html>\n" |
| 7 | "<html>\n" |
| 8 | "<head>\n" |
| 9 | "<meta charset=\"utf-8\">\n" |
| 10 | "<meta name=\"viewport\" content=\"width=device-width,initial-scale=1\">\n" |
| 11 | "<title>Thought Chains</title>\n" |
| 12 | "\001\n" |
| 13 | "<style>\n" |
| 14 | "*{box-sizing:border-box}\n" |
| 15 | "html,body{margin:0;padding:0}\n" |
| 16 | "body{background:var(--bg);color:var(--text);font-family:var(--font);font-size:14px;line-height:1.5}\n" |
| 17 | ".wrap{max-width:1180px;margin:0 auto;padding:14px}\n" |
| 18 | "header{display:flex;flex-wrap:wrap;align-items:center;gap:10px;margin-bottom:12px}\n" |
| 19 | "header h1{font-size:17px;margin:0;font-weight:700;letter-spacing:-.01em}\n" |
| 20 | ".chip{font-size:11px;color:var(--text-2);border:1px solid var(--line);border-radius:980px;padding:2px 10px;background:var(--bg-card)}\n" |
| 21 | ".chip b{color:var(--text);font-weight:600}\n" |
| 22 | ".spacer{flex:1}\n" |
| 23 | "button{background:var(--surface-2);color:var(--text);border:1px solid var(--line);border-radius:980px;padding:6px 14px;font:inherit;font-size:13px;font-weight:600;cursor:pointer}\n" |
| 24 | "button:hover{border-color:var(--line-2)}\n" |
| 25 | "button.danger{color:var(--red)}\n" |
| 26 | "button.primary{background:var(--blue);border-color:var(--blue);color:#fff}\n" |
| 27 | ".grid{display:grid;grid-template-columns:330px 1fr;gap:14px;align-items:start}\n" |
| 28 | ".card{background:var(--bg-card);border:1px solid var(--line);border-radius:14px;overflow:hidden}\n" |
| 29 | ".card h2{font-size:12px;text-transform:uppercase;letter-spacing:.08em;color:var(--text-2);margin:0;padding:10px 14px;border-bottom:1px solid var(--line);font-weight:600}\n" |
| 30 | "ul.chains{list-style:none;margin:0;padding:6px;max-height:70vh;overflow:auto}\n" |
| 31 | "ul.chains li{padding:9px 10px;border-radius:10px;cursor:pointer;border:1px solid transparent}\n" |
| 32 | "ul.chains li:hover{background:var(--surface-hover)}\n" |
| 33 | "ul.chains li.sel{background:var(--surface-2);border-color:var(--line-2)}\n" |
| 34 | ".cl-top{display:flex;align-items:baseline;gap:8px}\n" |
| 35 | ".cl-id{font-family:var(--mono);font-size:12px;color:var(--blue);font-weight:600;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}\n" |
| 36 | ".cl-when{font-size:11px;color:var(--text-2);margin-left:auto;white-space:nowrap}\n" |
| 37 | ".cl-last{font-size:12px;color:var(--text-2);margin-top:3px;display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical;overflow:hidden}\n" |
| 38 | ".cl-meta{display:flex;gap:6px;margin-top:6px;flex-wrap:wrap}\n" |
| 39 | ".pill{font-size:10px;font-weight:700;border-radius:980px;padding:1px 8px;border:1px solid var(--line);color:var(--text-2)}\n" |
| 40 | ".pill.b{color:var(--green);border-color:var(--green)}\n" |
| 41 | ".pill.t{color:var(--teal);border-color:var(--teal)}\n" |
| 42 | ".detail .empty{padding:36px 20px;text-align:center;color:var(--text-2)}\n" |
| 43 | ".detail .empty code{font-family:var(--mono);color:var(--text)}\n" |
| 44 | ".dhead{padding:12px 16px;border-bottom:1px solid var(--line);display:flex;flex-wrap:wrap;gap:10px;align-items:center}\n" |
| 45 | ".dhead .did{font-family:var(--mono);font-weight:700;color:var(--blue)}\n" |
| 46 | ".prog{flex:1;min-width:120px;max-width:280px;height:6px;border-radius:3px;background:var(--surface-2);overflow:hidden}\n" |
| 47 | ".prog i{display:block;height:100%;background:var(--blue);border-radius:3px}\n" |
| 48 | ".tl{list-style:none;margin:0;padding:14px 16px 18px 16px;position:relative}\n" |
| 49 | ".tl li{position:relative;padding:0 0 16px 30px}\n" |
| 50 | ".tl li::before{content:\"\";position:absolute;left:8px;top:18px;bottom:-2px;width:2px;background:var(--line)}\n" |
| 51 | ".tl li:last-child::before{display:none}\n" |
| 52 | ".tl .dot{position:absolute;left:2px;top:4px;width:14px;height:14px;border-radius:50%;border:3px solid var(--bg-card);background:var(--blue)}\n" |
| 53 | ".tl li.rev .dot{background:var(--orange)}\n" |
| 54 | ".tl li.br .dot{background:var(--green)}\n" |
| 55 | ".th-head{display:flex;flex-wrap:wrap;align-items:center;gap:8px;margin-bottom:4px}\n" |
| 56 | ".th-num{font-weight:700;font-size:13px}\n" |
| 57 | ".badge{font-size:10px;font-weight:700;text-transform:uppercase;letter-spacing:.05em;border-radius:980px;padding:1px 8px}\n" |
| 58 | ".badge.rev{color:var(--orange);border:1px solid var(--orange)}\n" |
| 59 | ".badge.br{color:var(--green);border:1px solid var(--green)}\n" |
| 60 | ".badge.fin{color:var(--purple);border:1px solid var(--purple)}\n" |
| 61 | ".th-more{font-size:11px;color:var(--text-2)}\n" |
| 62 | ".th-body{white-space:pre-wrap;word-wrap:break-word;font-size:13.5px;background:var(--surface-2);border:1px solid var(--line);border-radius:10px;padding:9px 12px;margin-top:2px}\n" |
| 63 | ".jsonwrap{margin-top:14px}\n" |
| 64 | ".jsonwrap pre{background:var(--code-bg);border:1px solid var(--line);border-radius:12px;padding:12px;font-family:var(--mono);font-size:11.5px;overflow:auto;max-height:340px;margin:8px 0 0}\n" |
| 65 | ".errbox{margin:12px 16px;padding:10px 12px;border:1px solid var(--red);border-radius:10px;color:var(--red);font-size:13px}\n" |
| 66 | "#backBtn{display:none}\n" |
| 67 | "@media (max-width:860px){\n" |
| 68 | " .grid{grid-template-columns:1fr}\n" |
| 69 | " body[data-view=detail] #listCard{display:none}\n" |
| 70 | " body:not([data-view=detail]) .tlwrap{display:none}\n" |
| 71 | " body:not([data-view=detail]) .dhead{display:none}\n" |
| 72 | " body[data-view=detail] #backBtn{display:inline-block}\n" |
| 73 | "}\n" |
| 74 | "</style>\n" |
| 75 | "</head>\n" |
| 76 | "<body>\n" |
| 77 | "<div class=\"wrap\">\n" |
| 78 | " <header>\n" |
| 79 | " <button id=\"backBtn\" type=\"button\">Back</button>\n" |
| 80 | " <h1>Thought Chains</h1>\n" |
| 81 | " <span class=\"chip\" id=\"chipChains\">chains <b>-</b></span>\n" |
| 82 | " <span class=\"chip\" id=\"chipThoughts\">thoughts <b>-</b></span>\n" |
| 83 | " <span class=\"chip\" id=\"chipState\">state <b>-</b></span>\n" |
| 84 | " <span class=\"spacer\"></span>\n" |
| 85 | " <button id=\"refreshBtn\" type=\"button\">Refresh</button>\n" |
| 86 | " <button id=\"clearBtn\" type=\"button\" class=\"danger\">Clear</button>\n" |
| 87 | " <button class=\"embed-hide\" id=\"themeToggle\" type=\"button\" title=\"Toggle appearance\">Theme</button>\n" |
| 88 | " </header>\n" |
| 89 | "\n" |
| 90 | " <div class=\"grid\">\n" |
| 91 | " <div class=\"card\" id=\"listCard\">\n" |
| 92 | " <h2>Chains</h2>\n" |
| 93 | " <ul class=\"chains\" id=\"chains\"></ul>\n" |
| 94 | " </div>\n" |
| 95 | "\n" |
| 96 | " <div class=\"card\">\n" |
| 97 | " <div class=\"dhead\" id=\"dhead\" style=\"display:none\">\n" |
| 98 | " <button id=\"backBtn2\" type=\"button\">Back</button>\n" |
| 99 | " <span class=\"did\" id=\"dId\"></span>\n" |
| 100 | " <span class=\"chip\" id=\"dCount\"></span>\n" |
| 101 | " <div class=\"prog\"><i id=\"dProg\" style=\"width:0%\"></i></div>\n" |
| 102 | " </div>\n" |
| 103 | " <div class=\"tlwrap\">\n" |
| 104 | " <div class=\"empty\" id=\"empty\">Loading...</div>\n" |
| 105 | " <ul class=\"tl\" id=\"tl\"></ul>\n" |
| 106 | " </div>\n" |
| 107 | " <div id=\"errbox\" class=\"errbox\" style=\"display:none\"></div>\n" |
| 108 | " <div class=\"jsonwrap\" style=\"padding:0 16px 14px\">\n" |
| 109 | " <button id=\"jsonBtn\" type=\"button\">Show JSON</button>\n" |
| 110 | " <pre id=\"json\" style=\"display:none\"></pre>\n" |
| 111 | " </div>\n" |
| 112 | " </div>\n" |
| 113 | " </div>\n" |
| 114 | "</div>\n" |
| 115 | "<script>\n" |
| 116 | "(function(){\n" |
| 117 | " var q=new URLSearchParams(location.search);\n" |
| 118 | " var HUB=q.get('plugin')||'';\n" |
| 119 | " var node=q.get('node')||'';\n" |
| 120 | " var sid=q.get('id')||'';\n" |
| 121 | " var pwd=q.get('pwd')||(node&&localStorage.getItem('bot_pwd_'+node))||localStorage.getItem('bot_active_pwd')||'';\n" |
| 122 | " var cur=null, lastJson='';\n" |
| 123 | "\n" |
| 124 | " function api(action,extra){\n" |
| 125 | " /* Hub-proxy route when served through /plugins?plugin=..., direct node\n" |
| 126 | " route when opened as /plugin_seqthink. Never call /plugins?plugin= on\n" |
| 127 | " the node itself: that is discovery and never dispatches. */\n" |
| 128 | " var u=(HUB?'/plugins?plugin='+encodeURIComponent(HUB)+'&action='+action\n" |
| 129 | " :'/plugin_seqthink?action='+action);\n" |
| 130 | " if(extra)u+='&'+extra;\n" |
| 131 | " if(node)u+='&node='+encodeURIComponent(node);\n" |
| 132 | " if(sid)u+='&id='+encodeURIComponent(sid);\n" |
| 133 | " if(pwd)u+='&pwd='+encodeURIComponent(pwd);\n" |
| 134 | " return fetch(u,{headers:pwd?{'X-Bot-Password':pwd}:{}}).then(function(r){return r.json();});\n" |
| 135 | " }\n" |
| 136 | " function esc(s){return String(s==null?'':s).replace(/[&<>\"]/g,function(c){\n" |
| 137 | " return {'&':'&','<':'<','>':'>','\"':'"'}[c];});}\n" |
| 138 | " function fmt(ts){if(!ts)return '-';try{return new Date(ts*1000).toLocaleString();}catch(e){return String(ts);}}\n" |
| 139 | " function showErr(m){var e=document.getElementById('errbox');e.textContent=m;e.style.display='block';}\n" |
| 140 | " function clearErr(){document.getElementById('errbox').style.display='none';}\n" |
| 141 | " function setJson(o){lastJson=JSON.stringify(o,null,2);var j=document.getElementById('json');j.textContent=lastJson;}\n" |
| 142 | "\n" |
| 143 | " function renderList(d){\n" |
| 144 | " var ul=document.getElementById('chains');\n" |
| 145 | " var cs=(d&&d.chains)||[];\n" |
| 146 | " document.getElementById('chipChains').innerHTML='chains <b>'+((d&&d.count!=null)?d.count:cs.length)+'</b>';\n" |
| 147 | " var tot=0;cs.forEach(function(c){tot+=c.thoughts||0;});\n" |
| 148 | " document.getElementById('chipThoughts').innerHTML='thoughts <b>'+tot+'</b>';\n" |
| 149 | " document.getElementById('chipState').innerHTML='state <b>'+esc((d&&d.state_dir_name)||'-')+'</b>';\n" |
| 150 | " ul.innerHTML='';\n" |
| 151 | " if(!cs.length){\n" |
| 152 | " if(!cur)document.getElementById('empty').innerHTML=\n" |
| 153 | " 'No thought chains recorded yet.<br>Call the <code>sequentialthinking</code> MCP tool '+\n" |
| 154 | " '(<code>plugin_seqthink --mcp</code>) and press Refresh.';\n" |
| 155 | " return;\n" |
| 156 | " }\n" |
| 157 | " cs.forEach(function(c){\n" |
| 158 | " var li=document.createElement('li');\n" |
| 159 | " if(c.id===cur)li.className='sel';\n" |
| 160 | " var badges='<span class=\"pill t\">thoughts '+esc(c.thoughts)+'</span>';\n" |
| 161 | " if(c.branches&&c.branches.length)badges+='<span class=\"pill b\">branches '+c.branches.length+'</span>';\n" |
| 162 | " if(c.truncated)badges+='<span class=\"pill\">capped</span>';\n" |
| 163 | " li.innerHTML='<div class=\"cl-top\"><span class=\"cl-id\">'+esc(c.id)+'</span>'+\n" |
| 164 | " '<span class=\"cl-when\">'+esc(fmt(c.updated_at))+'</span></div>'+\n" |
| 165 | " '<div class=\"cl-last\">'+esc(c.last_head||'')+'</div>'+\n" |
| 166 | " '<div class=\"cl-meta\">'+badges+'</div>';\n" |
| 167 | " li.onclick=function(){open(c.id);};\n" |
| 168 | " ul.appendChild(li);\n" |
| 169 | " });\n" |
| 170 | " }\n" |
| 171 | "\n" |
| 172 | " function renderDetail(d){\n" |
| 173 | " var tl=document.getElementById('tl');\n" |
| 174 | " var th=(d&&d.thoughts)||[];\n" |
| 175 | " document.getElementById('dhead').style.display=th.length?'flex':'none';\n" |
| 176 | " document.getElementById('dId').textContent=(d&&d.id)||'';\n" |
| 177 | " var last=th.length?th[th.length-1]:null;\n" |
| 178 | " var tt=last?(last.total_thoughts||0):0, tn=last?(last.thought_number||0):0;\n" |
| 179 | " document.getElementById('dCount').textContent=th.length+' thoughts';\n" |
| 180 | " document.getElementById('dProg').style.width=(tt>0?Math.min(100,Math.round(100*tn/tt)):0)+'%';\n" |
| 181 | " document.getElementById('empty').style.display=th.length?'none':'block';\n" |
| 182 | " if(!th.length&&!document.getElementById('empty').textContent.trim())\n" |
| 183 | " document.getElementById('empty').textContent='No thoughts in this chain.';\n" |
| 184 | " tl.innerHTML='';\n" |
| 185 | " th.forEach(function(t){\n" |
| 186 | " var li=document.createElement('li');\n" |
| 187 | " var cls=t.is_revision?'rev':(t.branch_from?'br':'');\n" |
| 188 | " if(cls)li.className=cls;\n" |
| 189 | " var badges='<span class=\"th-num\">#'+esc(t.thought_number)+' / '+esc(t.total_thoughts)+'</span>';\n" |
| 190 | " if(t.is_revision)badges+='<span class=\"badge rev\">revision'+(t.revises?' of #'+esc(t.revises):'')+'</span>';\n" |
| 191 | " if(t.branch_from)badges+='<span class=\"badge br\">branch from #'+esc(t.branch_from)+\n" |
| 192 | " (t.branch_id?' · '+esc(t.branch_id):'')+'</span>';\n" |
| 193 | " if(!t.next_needed)badges+='<span class=\"badge fin\">final</span>';\n" |
| 194 | " var more='';\n" |
| 195 | " if(t.needs_more)more=' <span class=\"th-more\">needs more thoughts</span>';\n" |
| 196 | " li.innerHTML='<span class=\"dot\"></span>'+\n" |
| 197 | " '<div class=\"th-head\">'+badges+more+'</div>'+\n" |
| 198 | " '<div class=\"th-body\">'+esc(t.thought)+'</div>';\n" |
| 199 | " tl.appendChild(li);\n" |
| 200 | " });\n" |
| 201 | " }\n" |
| 202 | "\n" |
| 203 | " function open(id){\n" |
| 204 | " cur=id;\n" |
| 205 | " document.body.setAttribute('data-view','detail');\n" |
| 206 | " clearErr();\n" |
| 207 | " api('chain','id='+encodeURIComponent(id)).then(function(d){\n" |
| 208 | " if(!d||d.ok===false){showErr((d&&d.error)||'chain failed');return;}\n" |
| 209 | " renderDetail(d);\n" |
| 210 | " setJson(d);\n" |
| 211 | " }).catch(function(e){showErr('chain: '+e);});\n" |
| 212 | " refreshList();\n" |
| 213 | " }\n" |
| 214 | " function back(){\n" |
| 215 | " cur=null;\n" |
| 216 | " document.body.removeAttribute('data-view');\n" |
| 217 | " document.getElementById('tl').innerHTML='';\n" |
| 218 | " document.getElementById('dhead').style.display='none';\n" |
| 219 | " refreshList();\n" |
| 220 | " }\n" |
| 221 | " function refreshList(){\n" |
| 222 | " api('chains').then(function(d){\n" |
| 223 | " if(!d||d.ok===false){showErr((d&&d.error)||'chains failed');return;}\n" |
| 224 | " renderList(d);\n" |
| 225 | " if(!cur)setJson(d);\n" |
| 226 | " }).catch(function(e){showErr('chains: '+e);});\n" |
| 227 | " }\n" |
| 228 | " document.getElementById('refreshBtn').onclick=function(){cur?open(cur):refreshList();};\n" |
| 229 | " document.getElementById('backBtn').onclick=back;\n" |
| 230 | " document.getElementById('backBtn2').onclick=back;\n" |
| 231 | " document.getElementById('jsonBtn').onclick=function(){\n" |
| 232 | " var j=document.getElementById('json');\n" |
| 233 | " var on=j.style.display!=='none';\n" |
| 234 | " j.style.display=on?'none':'block';\n" |
| 235 | " this.textContent=on?'Show JSON':'Hide JSON';\n" |
| 236 | " };\n" |
| 237 | " document.getElementById('clearBtn').onclick=function(){\n" |
| 238 | " if(!window.confirm('Delete all recorded thought chains? This cannot be undone.'))return;\n" |
| 239 | " api('clear','confirm=1').then(function(d){\n" |
| 240 | " if(!d||d.ok===false){showErr((d&&d.error)||'clear failed');return;}\n" |
| 241 | " cur=null;back();\n" |
| 242 | " }).catch(function(e){showErr('clear: '+e);});\n" |
| 243 | " };\n" |
| 244 | " document.getElementById('themeToggle').onclick=function(){\n" |
| 245 | " var t=document.documentElement.getAttribute('data-theme')==='dark'?'light':'dark';\n" |
| 246 | " window.sxApplyTheme(t);\n" |
| 247 | " };\n" |
| 248 | " refreshList();\n" |
| 249 | "})();\n" |
| 250 | "</script>\n" |
| 251 | "\002</body>\n" |
| 252 | "</html>\n" |
| 253 | ; |
| 254 | |
| 255 | #endif /* SX_SEQTHINK_UI_HTML_H */ |