diff options
| author | Danilo M. <danix@danix.xyz> | 2026-11-10 19:53:32 +0100 |
|---|---|---|
| committer | Danilo M. <danix@danix.xyz> | 2026-11-10 19:53:32 +0100 |
| commit | c75b6f1ff69d944bb07b9395880a63620a0a8a00 (patch) | |
| tree | 85275188ebfbaf7863f0089b4644e089cd977604 /static/modules/llm.js | |
| parent | d0c5ae2bf4a8a0ab1ddec409e007e7aef0dfc3e3 (diff) | |
| download | deck-it-c75b6f1ff69d944bb07b9395880a63620a0a8a00.tar.gz deck-it-c75b6f1ff69d944bb07b9395880a63620a0a8a00.zip | |
feat(dashboard): one fixed screen for the tablet
The Dashboard tab drops the draggable card grid for a fixed layout: a
top band of system, Claude and tablet chips with trend and fill
backgrounds, music and spending always on, a row of one to three busy
modules (printer, build VM, OBS) that scroll long lines, and the
action icons in Hyprland's rotating border. The stats, tablet and llm
panels and the vendored Gridstack go.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Diffstat (limited to 'static/modules/llm.js')
| -rw-r--r-- | static/modules/llm.js | 125 |
1 files changed, 0 insertions, 125 deletions
diff --git a/static/modules/llm.js b/static/modules/llm.js deleted file mode 100644 index 1bbbcce..0000000 --- a/static/modules/llm.js +++ /dev/null @@ -1,125 +0,0 @@ -// deck-it - llm panel -// Copyright (C) 2026 Danilo M. <danix@danix.xyz> -// -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License version 2 as -// published by the Free Software Foundation. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License along -// with this program; if not, write to the Free Software Foundation, Inc., -// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - -import { offline } from "../offline.js"; - -const num = (v) => (v == null ? null : Number(v)); -const money = (v) => (num(v) == null ? "—" : `$${num(v).toFixed(2)}`); -const tokens = (n) => { - if (n == null) return "—"; - if (n >= 1e9) return `${(n / 1e9).toFixed(1)}B`; - if (n >= 1e6) return `${(n / 1e6).toFixed(1)}M`; - if (n >= 1e3) return `${(n / 1e3).toFixed(1)}k`; - return String(n); -}; - -const CLAUDE_ICON = '<span class="brand claude"></span>'; -const OPENCODE_ICON = '<span class="brand opencode"></span>'; -const AGENT_ICON = '<i class="nf brand-nf">\uf086</i>'; - -function section(icon, title, model) { - const sec = document.createElement("section"); - sec.className = "llm-sec"; - const head = document.createElement("header"); - head.className = "llm-head"; - head.innerHTML = `${icon}<h3></h3><span class="model"></span>`; - head.querySelector("h3").textContent = title; - head.querySelector(".model").textContent = model || "—"; - sec.append(head); - return sec; -} - -function gauge(label, value) { - const d = document.createElement("div"); - d.className = "gauge"; - const l = document.createElement("span"); - l.className = "glabel"; - l.textContent = label; - const v = document.createElement("span"); - v.className = "gvalue num"; - v.textContent = value == null ? "—" : `${Math.round(value)}%`; - const bar = document.createElement("div"); - bar.className = "gbar"; - const fill = document.createElement("i"); - fill.style.width = `${Math.max(0, Math.min(100, value || 0))}%`; - bar.append(fill); - d.append(l, v, bar); - return d; -} - -function stat(label, value, sub) { - const d = document.createElement("div"); - d.className = "lbig"; - const l = document.createElement("span"); - l.className = "mlabel"; - l.textContent = label; - const v = document.createElement("span"); - v.className = "mvalue num"; - v.textContent = value; - const s = document.createElement("span"); - s.className = "msub"; - s.textContent = sub || ""; - d.append(l, v, s); - return d; -} - -export default { - title: "LLM usage", - interval: 5, - - mount(el) { - el.innerHTML = `<div class="llm"></div>`; - }, - - update(state, el) { - const box = el.querySelector(".llm"); - if (state.offline) { - offline(box, { - icon: "/logos/claude.svg", - title: "Usage dashboard is off", - detail: "Start llm-cost-dashboard and Claude, opencode and assistant usage appear here.", - }); - return; - } - box.textContent = ""; - const c = state.claude ?? {}; - const o = state.opencode ?? {}; - - const claude = section(CLAUDE_ICON, "Claude Code", c.model); - const gauges = document.createElement("div"); - gauges.className = "gauges"; - gauges.append( - gauge("Context", c.context_pct), - gauge("5h", c.five_hour_pct), - gauge("7d", c.seven_day_pct), - ); - claude.append(gauges); - box.append(claude); - - for (const [icon, title, p] of [[OPENCODE_ICON, "opencode", o], - [AGENT_ICON, "Local Agent", state.assistant ?? {}]]) { - const sec = section(icon, title, p.model); - const pair = document.createElement("div"); - pair.className = "lpair"; - pair.append( - stat("session", money(p.session_cost), `${tokens(p.session_tokens)} · ${p.session_calls ?? 0} calls`), - stat("total", money(p.cost), `${tokens(p.tokens)} · ${p.calls ?? 0} calls`), - ); - sec.append(pair); - box.append(sec); - } - }, -}; |
