tokmon 0.12.4 → 0.12.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.js +34 -55
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -642,13 +642,15 @@ function App({ interval: cliInterval }) {
|
|
|
642
642
|
});
|
|
643
643
|
}, []);
|
|
644
644
|
const billingMs = cfg.billingInterval * 6e4;
|
|
645
|
-
const
|
|
646
|
-
const
|
|
645
|
+
const configReady = config2 !== null;
|
|
646
|
+
const accountsKey = cfg.accounts.map((a) => `${a.id}:${a.homeDir}`).join("|");
|
|
647
|
+
const dataSlotsRef = useRef([]);
|
|
648
|
+
dataSlotsRef.current = cfg.accounts.length > 0 ? slots.slice(1) : slots;
|
|
647
649
|
useEffect(() => {
|
|
648
|
-
if (!
|
|
650
|
+
if (!configReady) return;
|
|
649
651
|
let active = true;
|
|
650
652
|
const load = async () => {
|
|
651
|
-
await Promise.all(
|
|
653
|
+
await Promise.all(dataSlotsRef.current.map(async (slot) => {
|
|
652
654
|
try {
|
|
653
655
|
const dashboard = await fetchDashboard(tz, slot.homeDir);
|
|
654
656
|
if (!active) return;
|
|
@@ -673,12 +675,12 @@ function App({ interval: cliInterval }) {
|
|
|
673
675
|
active = false;
|
|
674
676
|
clearInterval(id);
|
|
675
677
|
};
|
|
676
|
-
}, [interval2, tz,
|
|
678
|
+
}, [interval2, tz, configReady, accountsKey]);
|
|
677
679
|
useEffect(() => {
|
|
678
|
-
if (!
|
|
680
|
+
if (!configReady) return;
|
|
679
681
|
let active = true;
|
|
680
682
|
const load = async () => {
|
|
681
|
-
await Promise.all(
|
|
683
|
+
await Promise.all(dataSlotsRef.current.map(async (slot) => {
|
|
682
684
|
try {
|
|
683
685
|
const billing = await fetchBilling(slot.homeDir);
|
|
684
686
|
if (!active) return;
|
|
@@ -698,7 +700,7 @@ function App({ interval: cliInterval }) {
|
|
|
698
700
|
active = false;
|
|
699
701
|
clearInterval(id);
|
|
700
702
|
};
|
|
701
|
-
}, [billingMs,
|
|
703
|
+
}, [billingMs, configReady, accountsKey]);
|
|
702
704
|
useEffect(() => {
|
|
703
705
|
tableLoadedOnce.current = false;
|
|
704
706
|
setTable(null);
|
|
@@ -1155,14 +1157,13 @@ function App({ interval: cliInterval }) {
|
|
|
1155
1157
|
activeAccountId: cfg.activeAccountId
|
|
1156
1158
|
}
|
|
1157
1159
|
) : /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
1158
|
-
/* @__PURE__ */ jsxs(Box, { marginTop: 1, children: [
|
|
1160
|
+
/* @__PURE__ */ jsxs(Box, { marginTop: 1, marginBottom: 1, children: [
|
|
1159
1161
|
/* @__PURE__ */ jsx(TabBar, { tabs: TABS, active: tab, onSelect: (i) => {
|
|
1160
1162
|
setTab(i);
|
|
1161
1163
|
resetView();
|
|
1162
1164
|
} }),
|
|
1163
1165
|
/* @__PURE__ */ jsx(Text, { dimColor: true, children: " Tab/\u2190\u2192" })
|
|
1164
1166
|
] }),
|
|
1165
|
-
/* @__PURE__ */ jsx(Box, { height: 1 }),
|
|
1166
1167
|
tab === 0 && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
1167
1168
|
/* @__PURE__ */ jsx(
|
|
1168
1169
|
DashboardView,
|
|
@@ -1172,9 +1173,9 @@ function App({ interval: cliInterval }) {
|
|
|
1172
1173
|
compact: visibleSlots.length > 1
|
|
1173
1174
|
}
|
|
1174
1175
|
),
|
|
1175
|
-
slots.length > 1 && /* @__PURE__ */ jsxs(Box, { marginTop: 1,
|
|
1176
|
-
/* @__PURE__ */ jsx(Text, {
|
|
1177
|
-
/* @__PURE__ */ jsx(
|
|
1176
|
+
slots.length > 1 && /* @__PURE__ */ jsxs(Box, { marginTop: 1, children: [
|
|
1177
|
+
/* @__PURE__ */ jsx(Text, { dimColor: true, children: "focus " }),
|
|
1178
|
+
/* @__PURE__ */ jsx(
|
|
1178
1179
|
AccountStrip,
|
|
1179
1180
|
{
|
|
1180
1181
|
slots,
|
|
@@ -1185,7 +1186,7 @@ function App({ interval: cliInterval }) {
|
|
|
1185
1186
|
resetView();
|
|
1186
1187
|
}
|
|
1187
1188
|
}
|
|
1188
|
-
)
|
|
1189
|
+
)
|
|
1189
1190
|
] })
|
|
1190
1191
|
] }),
|
|
1191
1192
|
tab === 1 && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
@@ -1239,12 +1240,13 @@ function AccountStrip({ slots, activeIdx, onSelect }) {
|
|
|
1239
1240
|
return /* @__PURE__ */ jsx(Box, { flexWrap: "wrap", children: slots.map((s, i) => {
|
|
1240
1241
|
const active = i === activeIdx;
|
|
1241
1242
|
const dot = s.id === null ? "\u2726" : "\u25CF";
|
|
1243
|
+
const label = truncateName(s.name, 16);
|
|
1242
1244
|
return /* @__PURE__ */ jsxs(ClickableBox, { onClick: () => onSelect(i), marginRight: 2, children: [
|
|
1243
1245
|
/* @__PURE__ */ jsx(Text, { dimColor: !active, children: i }),
|
|
1244
1246
|
/* @__PURE__ */ jsx(Text, { children: " " }),
|
|
1245
1247
|
/* @__PURE__ */ jsx(Text, { color: s.color, bold: active, dimColor: !active, children: dot }),
|
|
1246
1248
|
/* @__PURE__ */ jsx(Text, { children: " " }),
|
|
1247
|
-
active ? /* @__PURE__ */ jsx(Text, { bold: true, color: s.color, children:
|
|
1249
|
+
active ? /* @__PURE__ */ jsx(Text, { bold: true, color: s.color, children: label }) : /* @__PURE__ */ jsx(Text, { dimColor: true, children: label })
|
|
1248
1250
|
] }, s.id ?? "__all__");
|
|
1249
1251
|
}) });
|
|
1250
1252
|
}
|
|
@@ -1389,9 +1391,11 @@ function SettingsView({
|
|
|
1389
1391
|
isActive ? "\u25CF" : "\u25CB",
|
|
1390
1392
|
" "
|
|
1391
1393
|
] }),
|
|
1392
|
-
/* @__PURE__ */ jsx(
|
|
1393
|
-
/* @__PURE__ */
|
|
1394
|
-
|
|
1394
|
+
/* @__PURE__ */ jsx(Text, { bold: true, children: truncateName(acc.name, 24) }),
|
|
1395
|
+
/* @__PURE__ */ jsxs(Text, { dimColor: true, children: [
|
|
1396
|
+
" ",
|
|
1397
|
+
truncateName(acc.homeDir, 28)
|
|
1398
|
+
] })
|
|
1395
1399
|
] }, acc.id);
|
|
1396
1400
|
}),
|
|
1397
1401
|
/* @__PURE__ */ jsxs(Box, { children: [
|
|
@@ -1600,35 +1604,18 @@ function DashboardView({ slots, stats, compact: _compact }) {
|
|
|
1600
1604
|
borderTop: false,
|
|
1601
1605
|
borderBottom: false,
|
|
1602
1606
|
children: [
|
|
1603
|
-
/* @__PURE__ */
|
|
1604
|
-
/* @__PURE__ */ jsx(Text, { bold: true, children: "Claude" }),
|
|
1605
|
-
isMulti && /* @__PURE__ */ jsxs(Text, { dimColor: true, children: [
|
|
1606
|
-
" all accounts (",
|
|
1607
|
-
items.length,
|
|
1608
|
-
")"
|
|
1609
|
-
] }),
|
|
1610
|
-
!isMulti && items[0].slot.id && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
1611
|
-
/* @__PURE__ */ jsx(Text, { dimColor: true, children: " " }),
|
|
1612
|
-
/* @__PURE__ */ jsx(Text, { color: items[0].slot.color, children: "\u25CF " }),
|
|
1613
|
-
/* @__PURE__ */ jsx(Text, { dimColor: true, children: items[0].slot.name })
|
|
1614
|
-
] })
|
|
1615
|
-
] }),
|
|
1616
|
-
/* @__PURE__ */ jsx(Box, { height: 1 }),
|
|
1607
|
+
/* @__PURE__ */ jsx(Text, { bold: true, children: "Claude" }),
|
|
1617
1608
|
/* @__PURE__ */ jsx(SummaryRow, { label: "Today", summary: agg.today }),
|
|
1618
1609
|
/* @__PURE__ */ jsx(SummaryRow, { label: "This Week", summary: agg.week }),
|
|
1619
1610
|
/* @__PURE__ */ jsx(SummaryRow, { label: "This Month", summary: agg.month }),
|
|
1620
|
-
agg.burnRate > 0 && /* @__PURE__ */ jsxs(
|
|
1621
|
-
/* @__PURE__ */ jsx(Box, {
|
|
1622
|
-
/* @__PURE__ */
|
|
1623
|
-
|
|
1624
|
-
/* @__PURE__ */ jsx(Box, { width: 12, justifyContent: "flex-end", children: /* @__PURE__ */ jsx(Text, { color: "red", children: currency(agg.burnRate) }) }),
|
|
1625
|
-
/* @__PURE__ */ jsx(Text, { dimColor: true, children: "/hr" })
|
|
1626
|
-
] })
|
|
1611
|
+
agg.burnRate > 0 && /* @__PURE__ */ jsxs(Box, { children: [
|
|
1612
|
+
/* @__PURE__ */ jsx(Box, { width: 14, children: /* @__PURE__ */ jsx(Text, { dimColor: true, children: "Burn rate" }) }),
|
|
1613
|
+
/* @__PURE__ */ jsx(Box, { width: 12, justifyContent: "flex-end", children: /* @__PURE__ */ jsx(Text, { color: "red", children: currency(agg.burnRate) }) }),
|
|
1614
|
+
/* @__PURE__ */ jsx(Text, { dimColor: true, children: "/hr" })
|
|
1627
1615
|
] })
|
|
1628
1616
|
]
|
|
1629
1617
|
}
|
|
1630
1618
|
),
|
|
1631
|
-
/* @__PURE__ */ jsx(Box, { height: 1 }),
|
|
1632
1619
|
/* @__PURE__ */ jsx(RateLimitsCard, { items })
|
|
1633
1620
|
] });
|
|
1634
1621
|
}
|
|
@@ -1676,17 +1663,16 @@ function RateLimitsCard({ items }) {
|
|
|
1676
1663
|
borderBottom: false,
|
|
1677
1664
|
children: [
|
|
1678
1665
|
/* @__PURE__ */ jsx(Text, { bold: true, children: "Rate Limits" }),
|
|
1679
|
-
/* @__PURE__ */ jsx(Box, { height: 1 }),
|
|
1680
1666
|
!anyData ? anyError ? /* @__PURE__ */ jsx(Box, { flexDirection: "column", children: items.map(({ slot, s }) => s.billing?.error && /* @__PURE__ */ jsxs(Box, { children: [
|
|
1681
1667
|
/* @__PURE__ */ jsx(Text, { color: slot.color, children: "\u25CF " }),
|
|
1682
1668
|
/* @__PURE__ */ jsx(Box, { width: 22, children: /* @__PURE__ */ jsx(Text, { dimColor: true, children: truncateName(slot.name, 20) }) }),
|
|
1683
1669
|
/* @__PURE__ */ jsx(Text, { color: "red", children: s.billing.error })
|
|
1684
1670
|
] }, slot.id ?? "__default__")) }) : /* @__PURE__ */ jsx(Text, { dimColor: true, children: "Fetching..." }) : /* @__PURE__ */ jsxs(Box, { flexDirection: "column", children: [
|
|
1685
|
-
/* @__PURE__ */ jsx(MetricBlock, { label: "
|
|
1686
|
-
/* @__PURE__ */ jsx(MetricBlock, { label: "
|
|
1687
|
-
/* @__PURE__ */ jsx(MetricBlock, { label: "Sonnet",
|
|
1688
|
-
items.some((i) => i.s.billing?.extraUsage) && /* @__PURE__ */ jsxs(Box, { flexDirection: "column",
|
|
1689
|
-
/* @__PURE__ */ jsx(Text, { bold: true, dimColor: true, children: "Extra
|
|
1671
|
+
/* @__PURE__ */ jsx(MetricBlock, { label: "5h", pick: (b) => b?.session, items, showResets: true }),
|
|
1672
|
+
/* @__PURE__ */ jsx(MetricBlock, { label: "Week", pick: (b) => b?.weekly, items, showResets: true }),
|
|
1673
|
+
/* @__PURE__ */ jsx(MetricBlock, { label: "Sonnet", pick: (b) => b?.sonnet, items }),
|
|
1674
|
+
items.some((i) => i.s.billing?.extraUsage) && /* @__PURE__ */ jsxs(Box, { flexDirection: "column", children: [
|
|
1675
|
+
/* @__PURE__ */ jsx(Text, { bold: true, dimColor: true, children: "Extra" }),
|
|
1690
1676
|
items.map(({ slot, s }) => {
|
|
1691
1677
|
const e = s.billing?.extraUsage;
|
|
1692
1678
|
if (!e) return null;
|
|
@@ -1713,7 +1699,6 @@ function RateLimitsCard({ items }) {
|
|
|
1713
1699
|
}
|
|
1714
1700
|
function MetricBlock({
|
|
1715
1701
|
label,
|
|
1716
|
-
sublabel,
|
|
1717
1702
|
pick,
|
|
1718
1703
|
items,
|
|
1719
1704
|
showResets
|
|
@@ -1724,14 +1709,8 @@ function MetricBlock({
|
|
|
1724
1709
|
error: i.s.billing?.error ?? null
|
|
1725
1710
|
}));
|
|
1726
1711
|
if (rows.every((r) => r.lim === null && !r.error)) return null;
|
|
1727
|
-
return /* @__PURE__ */ jsxs(Box, { flexDirection: "column",
|
|
1728
|
-
/* @__PURE__ */
|
|
1729
|
-
/* @__PURE__ */ jsx(Text, { bold: true, children: label }),
|
|
1730
|
-
/* @__PURE__ */ jsxs(Text, { dimColor: true, children: [
|
|
1731
|
-
" ",
|
|
1732
|
-
sublabel
|
|
1733
|
-
] })
|
|
1734
|
-
] }),
|
|
1712
|
+
return /* @__PURE__ */ jsxs(Box, { flexDirection: "column", children: [
|
|
1713
|
+
/* @__PURE__ */ jsx(Text, { bold: true, children: label }),
|
|
1735
1714
|
rows.map(({ slot, lim, error }) => {
|
|
1736
1715
|
if (lim) {
|
|
1737
1716
|
return /* @__PURE__ */ jsx(
|