Something went wrong. Try again.
A KDE Plasma panel widget showing how much Claude Max quota is left, at a glance.
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201.pragma library
// Labels are built here, from the semantic `kind` the daemon sends. The state// file deliberately carries no interface strings: the language belongs to the// session, and the daemon has none.function windowLabel(win, i18n) { if (!win) { return "" } switch (win.kind) { case "session": return i18n("Session (5h)") case "weekly_all": return i18n("This week (all models)") case "weekly_scoped": // The model name comes from the server and is not a closed set: // render it as it arrives, untranslated. return win.model ? i18n("This week — %1", win.model) : i18n("This week (scoped)") default: // An unknown kind is shown anyway: the endpoint is undocumented and // adds them without notice. Raw beats absent. return win.kind || i18n("Unknown limit") }}
// The server already classifies severity, so dipstick invents no thresholds.// The exact vocabulary is undocumented: "normal" is the only observed value,// so anything that is not "normal" is treated as deserving attention rather// than being ignored.function severityRank(severity) { switch ((severity || "").toLowerCase()) { case "": case "normal": return 0 case "warning": case "warn": case "elevated": return 1 default: return 2 }}
// Countdown to the reset. Returns "" when we do not know when that is.function untilReset(isoString, now, i18n) { if (!isoString) { return "" } var target = new Date(isoString).getTime() if (isNaN(target)) { return "" } var mins = Math.round((target - now) / 60000) if (mins <= 0) { return i18n("resetting now") } if (mins < 60) { return i18n("resets in %1m", mins) } var hours = Math.floor(mins / 60) if (hours < 24) { var rest = mins % 60 return rest === 0 ? i18n("resets in %1h", hours) : i18n("resets in %1h %2m", hours, rest) } return i18n("resets in %1d %2h", Math.floor(hours / 24), hours % 24)}
// The window the panel shows, named in one word: the popup's headline// already says it is the nearest limit, so "week" is enough.function shortWindowLabel(win, i18n) { if (!win) { return "" } switch (win.kind) { case "session": return i18n("session") case "weekly_all": case "weekly_scoped": return i18n("week") default: return win.kind || "" }}
// The countdown without the verb, for where the reset is already implied:// "in 3d 6h". Returns "" when we do not know when that is.function untilResetShort(isoString, now, i18n) { if (!isoString) { return "" } var target = new Date(isoString).getTime() if (isNaN(target)) { return "" } var mins = Math.round((target - now) / 60000) if (mins <= 0) { return i18nc("a quota window resetting at this moment", "now") } if (mins < 60) { return i18n("in %1m", mins) } var hours = Math.floor(mins / 60) if (hours < 24) { var rest = mins % 60 return rest === 0 ? i18n("in %1h", hours) : i18n("in %1h %2m", hours, rest) } return i18n("in %1d %2h", Math.floor(hours / 24), hours % 24)}
// Local token counts are huge numbers with no limit to compare them against:// abbreviate them, because the exact figure helps nobody.function humanTokens(n) { // A missing field is not a zero: it means the daemon is a version that // does not write it. Showing "0" would hide the mismatch by making it look // like real data. if (n === undefined || n === null) { return "\u2014" } if (typeof n !== "number" || n <= 0) { return "0" } if (n >= 1e9) { // "B" for billions, not "G": these are tokens, and the giga prefix // reads as a unit of bytes. return (n / 1e9).toFixed(1) + "B" } if (n >= 1e6) { return (n / 1e6).toFixed(1) + "M" } if (n >= 1e3) { return Math.round(n / 1e3) + "k" } return String(n)}
// How long since any work happened. Returns "" when we do not know.function sinceActivity(isoString, now, i18n) { if (!isoString) { return "" } var then = new Date(isoString).getTime() if (isNaN(then)) { return "" } var mins = Math.round((now - then) / 60000) if (mins < 2) { return i18n("active just now") } if (mins < 60) { return i18n("last active %1m ago", mins) } var hours = Math.round(mins / 60) if (hours < 24) { return i18n("last active %1h ago", hours) } return i18n("last active %1d ago", Math.round(hours / 24))}
// "claude-opus-5" -> "Opus 5", "claude-haiku-4-5-20251001" -> "Haiku 4.5".// The names come from the transcripts and are not a closed set: prettify what// is recognisable and let the rest through, rather than mapping against a// table that goes stale.function modelName(id) { if (!id) { return "" } var parts = (id.indexOf("claude-") === 0 ? id.substring(7) : id).split("-") // The trailing release date adds nothing: "Haiku 4.5" is enough. if (parts.length > 1 && /^\d{8}$/.test(parts[parts.length - 1])) { parts.pop() } var name = parts.shift() || "" if (name.length > 0 && name[0] >= "a" && name[0] <= "z") { name = name[0].toUpperCase() + name.substring(1) } // Version digits are hyphen-separated in the id but read as a single // number: "4-5" is 4.5. var version = parts.filter(function(p) { return p.length > 0 }) if (version.length === 0) { return name } return name + " " + (version.every(function(p) { return /^\d+$/.test(p) }) ? version.join(".") : version.join(" "))}
// "2026-07-29" -> "29 Jul", in the user's locale format.function shortDate(iso) { if (!iso) { return "" } var d = new Date(iso + "T00:00:00") if (isNaN(d.getTime())) { return iso } return d.toLocaleDateString(Qt.locale(), "d MMM")}