Add Switch, Btn, and Menu. Share Session and Run.term. Widget skill for agents; no plugin host.
95 lines
2.8 KiB
QML
95 lines
2.8 KiB
QML
import QtQuick
|
|
import ".."
|
|
import "../ui"
|
|
|
|
Chip {
|
|
id: root
|
|
color: Theme.magenta
|
|
text: ""
|
|
onClicked: button => {
|
|
if (button === Qt.RightButton)
|
|
Run.term("opencode2");
|
|
else {
|
|
AgentUsage.refresh();
|
|
panel.toggle(root);
|
|
}
|
|
}
|
|
|
|
PanelCard {
|
|
id: panel
|
|
paneWidth: 380
|
|
|
|
Heading {
|
|
title: AgentUsage.selected ? AgentUsage.selected.name : "Agents"
|
|
subtitle: AgentUsage.selected ? (AgentUsage.selected.tierLabel || "") : "No subscriptions"
|
|
}
|
|
|
|
Btn {
|
|
width: parent.width
|
|
text: "OpenCode"
|
|
kind: "primary"
|
|
onClicked: Run.term("opencode2")
|
|
}
|
|
|
|
Pills {
|
|
visible: AgentUsage.providers.length > 1
|
|
current: AgentUsage.selectedId
|
|
items: AgentUsage.providers.map(p => ({
|
|
id: p.id,
|
|
name: p.name
|
|
}))
|
|
onPicked: id => AgentUsage.selectedId = id
|
|
}
|
|
|
|
Section {
|
|
visible: AgentUsage.limits.length > 0
|
|
title: "LIMITS"
|
|
|
|
Repeater {
|
|
model: AgentUsage.limits
|
|
|
|
StatRow {
|
|
required property var modelData
|
|
label: modelData.title
|
|
value: Math.round((modelData.percent || 0) * 100) + "%"
|
|
ratio: modelData.percent || 0
|
|
detail: Fmt.wait(modelData.resetsAt, AgentUsage.nowMs)
|
|
}
|
|
}
|
|
}
|
|
|
|
Section {
|
|
visible: AgentUsage.days.length > 0
|
|
title: "TOKENS BY DAY"
|
|
|
|
Repeater {
|
|
model: AgentUsage.days
|
|
|
|
StatRow {
|
|
required property var modelData
|
|
readonly property bool isToday: modelData.date === Qt.formatDate(new Date(AgentUsage.nowMs), "yyyy-MM-dd")
|
|
readonly property real peak: Math.max(1, ...AgentUsage.days.map(d => Number(d.tokens || 0)))
|
|
label: isToday ? "Today" : ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"][new Date(modelData.date + "T00:00:00").getDay()]
|
|
value: Fmt.count(modelData.tokens || 0)
|
|
ratio: Number(modelData.tokens || 0) / peak
|
|
}
|
|
}
|
|
}
|
|
|
|
Section {
|
|
visible: AgentUsage.models.length > 0
|
|
title: "TOKENS BY MODEL"
|
|
|
|
Repeater {
|
|
model: AgentUsage.models
|
|
|
|
StatRow {
|
|
required property var modelData
|
|
label: modelData.name
|
|
value: Fmt.count(modelData.tokens)
|
|
ratio: modelData.tokens / Math.max(1, AgentUsage.models[0].tokens)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|