@leo000001/opencode-quota-sidebar 2.0.6 → 2.0.7
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/title.js +19 -3
- package/dist/title_apply.js +7 -0
- package/package.json +1 -1
package/dist/title.js
CHANGED
|
@@ -28,6 +28,20 @@ function isCoreDecoratedDetail(line) {
|
|
|
28
28
|
}
|
|
29
29
|
return false;
|
|
30
30
|
}
|
|
31
|
+
function isQuotaDecoratedDetail(line) {
|
|
32
|
+
if (!line)
|
|
33
|
+
return false;
|
|
34
|
+
if (/^(OpenAI|Copilot|Anthropic|Kimi|XYAI|Buzz|RC(?:-[^\s]+)?)\s*$/.test(line)) {
|
|
35
|
+
return true;
|
|
36
|
+
}
|
|
37
|
+
if (/^(?:(?:Daily\s+\$[\d.,]+\/\$[\d.,]+|\$[\d.,]+\/\$[\d.,]+)(?:\s+(?:Rst|Exp\+?)\s+[-:\d]+)?|(?:\d+[hdw]|Weekly|Monthly)\s+\d{1,3}%(?:\s+Rst\s+[-:\d]+)?|Balance\s+\$[\d.,]+|Remaining\s+\?|(?:error|unsupported|unavailable))$/.test(line)) {
|
|
38
|
+
return true;
|
|
39
|
+
}
|
|
40
|
+
if (/^(OpenAI|Copilot|Anthropic|Kimi|XYAI|Buzz|RC(?:-[^\s]+)?)(?:\s+(?:(?:Daily\s+\$[\d.,]+\/\$[\d.,]+|\$[\d.,]+\/\$[\d.,]+)(?:\s+(?:Rst|Exp\+?)\s+[-:\d]+)?|(?:\d+[hdw]|Weekly|Monthly)\s+\d{1,3}%(?:\s+Rst\s+[-:\d]+)?|(?:error|unsupported|unavailable)))$/.test(line)) {
|
|
41
|
+
return true;
|
|
42
|
+
}
|
|
43
|
+
return false;
|
|
44
|
+
}
|
|
31
45
|
function isSingleLineDecoratedPrefix(line) {
|
|
32
46
|
if (!line)
|
|
33
47
|
return false;
|
|
@@ -47,7 +61,9 @@ function isSingleLineDecoratedPrefix(line) {
|
|
|
47
61
|
return false;
|
|
48
62
|
}
|
|
49
63
|
function isSingleLineDetailPrefix(line) {
|
|
50
|
-
return isCoreDecoratedDetail(line) ||
|
|
64
|
+
return (isCoreDecoratedDetail(line) ||
|
|
65
|
+
isSingleLineDecoratedPrefix(line) ||
|
|
66
|
+
isQuotaDecoratedDetail(line));
|
|
51
67
|
}
|
|
52
68
|
function decoratedSingleLineBase(line) {
|
|
53
69
|
const parts = sanitizeTitleFragment(line)
|
|
@@ -72,7 +88,7 @@ export function normalizeBaseTitle(title) {
|
|
|
72
88
|
const lines = stripAnsi(safeTitle).split(/\r?\n/);
|
|
73
89
|
if (lines.length > 1) {
|
|
74
90
|
const detail = lines.slice(1).map((line) => sanitizeTitleFragment(line).trim());
|
|
75
|
-
if (detail.some((line) => isCoreDecoratedDetail(line))) {
|
|
91
|
+
if (detail.some((line) => isCoreDecoratedDetail(line) || isQuotaDecoratedDetail(line))) {
|
|
76
92
|
return sanitizeTitleFragment(firstLine) || 'Session';
|
|
77
93
|
}
|
|
78
94
|
}
|
|
@@ -122,5 +138,5 @@ export function looksDecorated(title) {
|
|
|
122
138
|
const detail = lines
|
|
123
139
|
.slice(1)
|
|
124
140
|
.map((line) => sanitizeTitleFragment(line).trim());
|
|
125
|
-
return detail.some((line) => isCoreDecoratedDetail(line));
|
|
141
|
+
return detail.some((line) => isCoreDecoratedDetail(line) || isQuotaDecoratedDetail(line));
|
|
126
142
|
}
|
package/dist/title_apply.js
CHANGED
|
@@ -33,6 +33,13 @@ export function createTitleApplicator(deps) {
|
|
|
33
33
|
if (canonicalizeTitle(currentTitle) !==
|
|
34
34
|
canonicalizeTitle(sessionState.lastAppliedTitle || '')) {
|
|
35
35
|
if (looksDecorated(currentTitle)) {
|
|
36
|
+
if (/\r?\n/.test(currentTitle)) {
|
|
37
|
+
const normalizedBase = normalizeBaseTitle(currentTitle);
|
|
38
|
+
if (sessionState.baseTitle !== normalizedBase) {
|
|
39
|
+
sessionState.baseTitle = normalizedBase;
|
|
40
|
+
stateMutated = true;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
36
43
|
// Ignore decorated echoes as base-title source.
|
|
37
44
|
// If we previously applied a decorated title, treat this as an
|
|
38
45
|
// equivalent echo (OpenCode may normalize whitespace) and keep
|