triflux 2.0.0 → 2.0.1
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/hud/hud-qos-status.mjs +14 -8
- package/package.json +1 -1
package/hud/hud-qos-status.mjs
CHANGED
|
@@ -655,19 +655,25 @@ function formatResetRemaining(isoOrUnix) {
|
|
|
655
655
|
const d = typeof isoOrUnix === "string" ? new Date(isoOrUnix) : new Date(isoOrUnix * 1000);
|
|
656
656
|
if (isNaN(d.getTime())) return "";
|
|
657
657
|
const diffMs = d.getTime() - Date.now();
|
|
658
|
-
if (diffMs <= 0) return "
|
|
658
|
+
if (diffMs <= 0) return "00h00m";
|
|
659
659
|
const totalMinutes = Math.floor(diffMs / 60000);
|
|
660
660
|
const totalHours = Math.floor(totalMinutes / 60);
|
|
661
661
|
const minutes = totalMinutes % 60;
|
|
662
662
|
return `${String(totalHours).padStart(2, "0")}h${String(minutes).padStart(2, "0")}m`;
|
|
663
663
|
}
|
|
664
664
|
|
|
665
|
+
function isResetPast(isoOrUnix) {
|
|
666
|
+
if (!isoOrUnix) return false;
|
|
667
|
+
const d = typeof isoOrUnix === "string" ? new Date(isoOrUnix) : new Date(isoOrUnix * 1000);
|
|
668
|
+
return !isNaN(d.getTime()) && d.getTime() <= Date.now();
|
|
669
|
+
}
|
|
670
|
+
|
|
665
671
|
function formatResetRemainingDayHour(isoOrUnix) {
|
|
666
672
|
if (!isoOrUnix) return "";
|
|
667
673
|
const d = typeof isoOrUnix === "string" ? new Date(isoOrUnix) : new Date(isoOrUnix * 1000);
|
|
668
674
|
if (isNaN(d.getTime())) return "";
|
|
669
675
|
const diffMs = d.getTime() - Date.now();
|
|
670
|
-
if (diffMs <= 0) return "
|
|
676
|
+
if (diffMs <= 0) return "0d00h";
|
|
671
677
|
const totalMinutes = Math.floor(diffMs / 60000);
|
|
672
678
|
const days = Math.floor(totalMinutes / (60 * 24));
|
|
673
679
|
const hours = Math.floor((totalMinutes % (60 * 24)) / 60);
|
|
@@ -1159,8 +1165,8 @@ function getProviderRow(provider, marker, markerColor, qosProfile, accountsConfi
|
|
|
1159
1165
|
if (realQuota?.type === "codex") {
|
|
1160
1166
|
const main = realQuota.buckets.codex || realQuota.buckets[Object.keys(realQuota.buckets)[0]];
|
|
1161
1167
|
if (main) {
|
|
1162
|
-
const fiveP = clampPercent(main.primary?.used_percent ?? 0);
|
|
1163
|
-
const weekP = clampPercent(main.secondary?.used_percent ?? 0);
|
|
1168
|
+
const fiveP = isResetPast(main.primary?.resets_at) ? 0 : clampPercent(main.primary?.used_percent ?? 0);
|
|
1169
|
+
const weekP = isResetPast(main.secondary?.resets_at) ? 0 : clampPercent(main.secondary?.used_percent ?? 0);
|
|
1164
1170
|
if (cols < 40) {
|
|
1165
1171
|
return { prefix: minPrefix, left: `${colorByPercent(fiveP, `${fiveP}%`)}${dim("/")}${colorByPercent(weekP, `${weekP}%`)}${svCompact}`, right: "" };
|
|
1166
1172
|
}
|
|
@@ -1185,8 +1191,8 @@ function getProviderRow(provider, marker, markerColor, qosProfile, accountsConfi
|
|
|
1185
1191
|
if (realQuota?.type === "codex") {
|
|
1186
1192
|
const main = realQuota.buckets.codex || realQuota.buckets[Object.keys(realQuota.buckets)[0]];
|
|
1187
1193
|
if (main) {
|
|
1188
|
-
const fiveP = clampPercent(main.primary?.used_percent ?? 0);
|
|
1189
|
-
const weekP = clampPercent(main.secondary?.used_percent ?? 0);
|
|
1194
|
+
const fiveP = isResetPast(main.primary?.resets_at) ? 0 : clampPercent(main.primary?.used_percent ?? 0);
|
|
1195
|
+
const weekP = isResetPast(main.secondary?.resets_at) ? 0 : clampPercent(main.secondary?.used_percent ?? 0);
|
|
1190
1196
|
quotaSection = `${dim("5h:")}${colorByPercent(fiveP, `${fiveP}%`)} ` +
|
|
1191
1197
|
`${dim("1w:")}${colorByPercent(weekP, `${weekP}%`)}`;
|
|
1192
1198
|
}
|
|
@@ -1211,8 +1217,8 @@ function getProviderRow(provider, marker, markerColor, qosProfile, accountsConfi
|
|
|
1211
1217
|
if (realQuota?.type === "codex") {
|
|
1212
1218
|
const main = realQuota.buckets.codex || realQuota.buckets[Object.keys(realQuota.buckets)[0]];
|
|
1213
1219
|
if (main) {
|
|
1214
|
-
const fiveP = clampPercent(main.primary?.used_percent ?? 0);
|
|
1215
|
-
const weekP = clampPercent(main.secondary?.used_percent ?? 0);
|
|
1220
|
+
const fiveP = isResetPast(main.primary?.resets_at) ? 0 : clampPercent(main.primary?.used_percent ?? 0);
|
|
1221
|
+
const weekP = isResetPast(main.secondary?.resets_at) ? 0 : clampPercent(main.secondary?.used_percent ?? 0);
|
|
1216
1222
|
const fiveReset = formatResetRemaining(main.primary?.resets_at) || "n/a";
|
|
1217
1223
|
const weekReset = formatResetRemainingDayHour(main.secondary?.resets_at) || "n/a";
|
|
1218
1224
|
quotaSection = `${dim("5h:")}${colorByPercent(fiveP, formatPercentCell(fiveP))} ` +
|