opencode-statboard 2.10.32 → 2.10.34

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "opencode-statboard",
3
- "version": "2.10.32",
3
+ "version": "2.10.34",
4
4
  "description": "Real-time dashboard for opencode token usage and cost statistics",
5
5
  "main": "server.js",
6
6
  "bin": {
package/public/index.html CHANGED
@@ -6,97 +6,99 @@
6
6
  <title>opencode Dashboard</title>
7
7
  <style>
8
8
  :root {
9
- --bg: #0d1117; --panel: #161b22; --border: #30363d; --text: #e6edf3; --muted: #8b949e;
10
- --in: #58a6ff; --out: #3fb950; --cache: #d29922; --cost: #f778ba; --tool: #a371f7;
11
- --warn: #e3b341; --dim: #6e7681;
9
+ --bg: #0a0c10; --panel: #12151c; --border: #1e2230; --text: #e8eaed; --muted: #9aa0a6;
10
+ --in: #4a9eff; --out: #34a853; --cache: #f9ab00; --cost: #ff6b9d; --tool: #a78bfa;
11
+ --warn: #fdd663; --dim: #5f6368;
12
12
  }
13
13
  * { box-sizing: border-box; margin: 0; padding: 0; }
14
- body { background: var(--bg); color: var(--text); font-family: "Segoe UI", "Microsoft JhengHei", sans-serif; padding: 24px; max-width: 1560px; margin: 0 auto; }
15
- header { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 10px; margin-bottom: 8px; }
16
- h1 { font-size: 20px; font-weight: 600; }
17
- h1 .dot { color: #3fb950; }
18
- .status { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 13px; flex-wrap: wrap; }
19
- .pill { padding: 4px 12px; border-radius: 999px; font-size: 12px; border: 1px solid var(--border); cursor: pointer; user-select: none; white-space: nowrap; }
20
- .pill.ok { color: #3fb950; border-color: #238636; background: rgba(63,185,80,.08); }
21
- .pill.err { color: #f85149; border-color: #da3633; background: rgba(248,81,73,.08); }
22
- .pill.lang { color: var(--text); border-color: var(--border); background: rgba(139,148,158,.08); }
23
- .pill.lang:hover { background: rgba(139,148,158,.18); }
24
- .pill.backup { color: var(--cache); border-color: var(--cache); background: rgba(210,153,34,.08); }
25
- .pill.backup:hover { background: rgba(210,153,34,.18); }
14
+ body { background: var(--bg); color: var(--text); font-family: "Inter", "SF Pro Display", -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft JhengHei", sans-serif; padding: 32px 24px; max-width: 1440px; margin: 0 auto; line-height: 1.5; }
15
+ header { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 12px; margin-bottom: 24px; }
16
+ h1 { font-size: 22px; font-weight: 600; letter-spacing: -0.3px; }
17
+ h1 .dot { color: #34a853; }
18
+ .status { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 13px; flex-wrap: wrap; }
19
+ .pill { padding: 6px 14px; border-radius: 8px; font-size: 12px; border: 1px solid var(--border); cursor: pointer; user-select: none; white-space: nowrap; transition: all 0.15s; }
20
+ .pill.ok { color: #34a853; border-color: #1e8e3e; background: rgba(52,168,83,.1); }
21
+ .pill.err { color: #f85149; border-color: #da3633; background: rgba(248,81,73,.1); }
22
+ .pill.lang { color: var(--text); border-color: var(--border); background: rgba(154,160,166,.08); }
23
+ .pill.lang:hover { background: rgba(154,160,166,.15); }
24
+ .pill.backup { color: var(--cache); border-color: var(--cache); background: rgba(249,171,0,.08); }
25
+ .pill.backup:hover { background: rgba(249,171,0,.15); }
26
26
  .pill.backup.busy { opacity: .6; pointer-events: none; }
27
- .version { font-size: 11px; color: var(--muted); background: var(--panel); border: 1px solid var(--border); padding: 2px 8px; border-radius: 4px; }
27
+ .version { font-size: 11px; color: var(--muted); background: var(--panel); border: 1px solid var(--border); padding: 3px 9px; border-radius: 6px; }
28
28
 
29
29
  /* ---- caveat line ---- */
30
- .caveat { font-size: 11px; color: var(--dim); line-height: 1.6; margin-bottom: 14px; letter-spacing: .1px; }
30
+ .caveat { font-size: 11px; color: var(--dim); line-height: 1.7; margin-bottom: 20px; letter-spacing: .2px; }
31
31
 
32
32
  /* ---- single global scope bar ---- */
33
- .scopebar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; background: var(--panel); border: 1px solid var(--border); border-radius: 10px; padding: 12px 16px; margin-bottom: 18px; position: sticky; top: 0; z-index: 20; box-shadow: 0 6px 20px rgba(0,0,0,.35); }
34
- .scopebar .sb-label { font-size: 11px; text-transform: uppercase; letter-spacing: .6px; color: var(--muted); font-weight: 600; }
35
- .range-btns { display: flex; gap: 4px; flex-wrap: wrap; }
36
- .range-btns .pill.active { color: var(--text); border-color: #58a6ff; background: rgba(88,166,255,.12); font-weight: 600; }
33
+ .scopebar { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; background: var(--panel); border: 1px solid var(--border); border-radius: 12px; padding: 14px 20px; margin-bottom: 24px; position: sticky; top: 0; z-index: 20; backdrop-filter: blur(12px); box-shadow: 0 4px 24px rgba(0,0,0,.4); }
34
+ .scopebar .sb-label { font-size: 11px; text-transform: uppercase; letter-spacing: .8px; color: var(--muted); font-weight: 600; }
35
+ .range-btns { display: flex; gap: 6px; flex-wrap: wrap; }
36
+ .range-btns .pill.active { color: var(--text); border-color: #4a9eff; background: rgba(74,158,255,.15); font-weight: 600; }
37
37
  .range-btns .pill:not(.active) { color: var(--muted); border-color: var(--border); background: transparent; }
38
- .range-btns .pill:not(.active):hover { background: rgba(139,148,158,.08); }
39
- .scopebar .sb-now { font-size: 12px; color: var(--text); margin-left: auto; font-weight: 600; }
38
+ .range-btns .pill:not(.active):hover { background: rgba(154,160,166,.1); }
39
+ .scopebar .sb-now { font-size: 13px; color: var(--text); margin-left: auto; font-weight: 600; }
40
40
 
41
- h2 { font-size: 13px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .5px; margin-bottom: 14px; }
41
+ h2 { font-size: 14px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .6px; margin-bottom: 16px; }
42
42
 
43
43
  /* ---- headline cards: the dominant tier ---- */
44
- .cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 14px; }
45
- .card { background: var(--bg); border: 1px solid var(--border); border-radius: 8px; padding: 16px; }
46
- .card.hero { border-color: #2d3748; box-shadow: inset 0 1px 0 rgba(255,255,255,.03); }
47
- .card .v { font-size: 26px; font-weight: 700; margin-top: 4px; line-height: 1.15; letter-spacing: -.5px; }
48
- .card.hero .v { font-size: 34px; }
49
- .card .l { font-size: 12px; color: var(--muted); }
50
- .card .subs { display: flex; flex-wrap: wrap; gap: 4px 12px; margin-top: 8px; font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
44
+ .cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 16px; }
45
+ .card { background: var(--panel); border: 1px solid var(--border); border-radius: 12px; padding: 20px; transition: border-color 0.2s; }
46
+ .card:hover { border-color: #2a2f3a; }
47
+ .card.hero { border-color: #252a35; box-shadow: 0 2px 12px rgba(0,0,0,.3); }
48
+ .card .v { font-size: 28px; font-weight: 700; margin-top: 6px; line-height: 1.2; letter-spacing: -0.5px; }
49
+ .card.hero .v { font-size: 36px; }
50
+ .card .l { font-size: 13px; color: var(--muted); font-weight: 500; }
51
+ .card .subs { display: flex; flex-wrap: wrap; gap: 6px 14px; margin-top: 10px; font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
51
52
  .card .subs b { color: var(--text); font-weight: 600; }
52
53
  .subs .k-in { color: var(--in); } .subs .k-out { color: var(--out); }
53
54
  .subs .k-incl { flex-basis: 100%; font-variant-numeric: tabular-nums; }
54
55
  .subs .k-reasoning { color: var(--tool); } .subs .k-cache { color: var(--cache); }
55
56
  .subs .warn { color: var(--warn); cursor: pointer; border-bottom: 1px dashed var(--warn); }
56
- .subs .warn:hover { color: #f0c674; }
57
- .foot-note { display: flex; flex-wrap: wrap; gap: 6px 16px; align-items: center; margin-top: 14px; font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
57
+ .subs .warn:hover { color: #fdd663; }
58
+ .foot-note { display: flex; flex-wrap: wrap; gap: 8px 20px; align-items: center; margin-top: 16px; font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
58
59
 
59
60
  /* ---- breakdown / pricing tables ---- */
60
61
  .scrollx { overflow-x: auto; }
61
62
  .scrollx table { min-width: 1080px; }
62
63
  td.clip { max-width: 300px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
63
- .track { background: #21262d; border-radius: 4px; height: 12px; overflow: hidden; }
64
- .track.share { min-width: 90px; height: 10px; }
64
+ .track { background: #1a1f2a; border-radius: 6px; height: 14px; overflow: hidden; }
65
+ .track .fill { height: 100%; border-radius: 6px; transition: width 0.3s ease; }
66
+ .track.share { min-width: 90px; height: 12px; }
65
67
  /* horizontal bar list (tools). The container must NOT be a .bar-row — each
66
68
  child is a grid item, so a grid container here collapses all rows into
67
69
  one column and renders as a single giant bar. */
68
70
  .bar-list { display: block; }
69
- .bar-row { display: grid; grid-template-columns: 170px 1fr 150px; align-items: center; gap: 12px; padding: 5px 0; font-size: 13px; }
71
+ .bar-row { display: grid; grid-template-columns: 180px 1fr 160px; align-items: center; gap: 16px; padding: 6px 0; font-size: 13px; }
70
72
  .bar-row .name { color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
71
73
  .bar-row .val { text-align: right; font-variant-numeric: tabular-nums; }
72
74
  .stack { display: flex; height: 100%; }
73
75
  .stack > div { height: 100%; }
74
76
  table { width: 100%; border-collapse: collapse; font-size: 13px; }
75
- th, td { padding: 8px 10px; text-align: right; border-bottom: 1px solid var(--border); font-variant-numeric: tabular-nums; white-space: nowrap; }
77
+ th, td { padding: 10px 12px; text-align: right; border-bottom: 1px solid var(--border); font-variant-numeric: tabular-nums; white-space: nowrap; }
76
78
  th:first-child, td:first-child { text-align: left; }
77
79
  th { color: var(--muted); font-weight: 500; font-size: 12px; }
78
- tbody tr:hover td { background: rgba(139,148,158,.06); }
79
- td.bd-name { max-width: 320px; overflow: hidden; text-overflow: ellipsis; }
80
+ tbody tr:hover td { background: rgba(154,160,166,.06); }
81
+ td.bd-name { max-width: 340px; overflow: hidden; text-overflow: ellipsis; }
80
82
  td.na { color: var(--dim); }
81
83
 
82
84
  .rep-hint { color: var(--muted); font-size: 12px; font-weight: 400; }
83
- .rep-pre { font-family: monospace; font-size: 12.5px; line-height: 1.6; white-space: pre; overflow-x: auto; color: var(--text); margin: 0; }
85
+ .rep-pre { font-family: "SF Mono", Monaco, "Cascadia Code", monospace; font-size: 12.5px; line-height: 1.7; white-space: pre; overflow-x: auto; color: var(--text); margin: 0; }
84
86
 
85
87
  /* ---- trend ---- */
86
- .chart { position: relative; display: flex; align-items: flex-end; gap: 2px; height: 200px; padding-top: 10px; }
87
- .chart .col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 4px; height: 100%; justify-content: flex-end; min-width: 0; }
88
- .chart .bars { display: flex; gap: 2px; align-items: flex-end; justify-content: center; height: 170px; width: 100%; }
89
- .trend-x { display: flex; height: 16px; margin-top: 4px; }
90
- .trend-x span { flex: 1; text-align: center; font-size: 10px; color: var(--muted); line-height: 16px; overflow: hidden; text-overflow: clip; white-space: nowrap; }
91
- .trend-wrap { display: flex; gap: 24px; flex-wrap: wrap; }
92
- .trend-wrap > div { flex: 1; min-width: 300px; }
93
- .trend-wrap #costSection { min-width: 240px; }
94
- .heatmap-wrap { display: flex; flex-direction: column; gap: 8px; }
95
- .heatmap-months { display: flex; gap: 2px; padding-left: 28px; font-size: 11px; color: var(--muted); }
88
+ .chart { position: relative; display: flex; align-items: flex-end; gap: 3px; height: 220px; padding-top: 12px; }
89
+ .chart .col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 5px; height: 100%; justify-content: flex-end; min-width: 0; }
90
+ .chart .bars { display: flex; gap: 3px; align-items: flex-end; justify-content: center; height: 190px; width: 100%; }
91
+ .trend-x { display: flex; height: 18px; margin-top: 6px; }
92
+ .trend-x span { flex: 1; text-align: center; font-size: 10px; color: var(--muted); line-height: 18px; overflow: hidden; text-overflow: clip; white-space: nowrap; }
93
+ .trend-wrap { display: flex; gap: 28px; flex-wrap: wrap; }
94
+ .trend-wrap > div { flex: 1; min-width: 320px; }
95
+ .trend-wrap #costSection { min-width: 260px; }
96
+ .heatmap-wrap { display: flex; flex-direction: column; gap: 10px; }
97
+ .heatmap-months { display: flex; gap: 3px; padding-left: 32px; font-size: 11px; color: var(--muted); }
96
98
  .heatmap-months span { flex: 1; text-align: left; overflow: visible; white-space: nowrap; }
97
- .heatmap-grid { display: flex; gap: 2px; }
98
- .heatmap-grid .hm-week { display: flex; flex-direction: column; gap: 2px; }
99
- .hm-cell { width: 14px; height: 14px; border-radius: 2px; background: var(--card2); border: 1px solid var(--border); box-sizing: border-box; }
99
+ .heatmap-grid { display: flex; gap: 3px; }
100
+ .heatmap-grid .hm-week { display: flex; flex-direction: column; gap: 3px; }
101
+ .hm-cell { width: 15px; height: 15px; border-radius: 3px; background: var(--card2); border: 1px solid var(--border); box-sizing: border-box; }
100
102
  /* Heatmap color scale: 10 levels from cool to hot */
101
103
  .hm-cell.hm-0 { background: var(--card2); }
102
104
  .hm-cell.hm-1 { background: #0d47a1; } /* Deep blue */
@@ -121,46 +123,47 @@
121
123
  .hm-cell.hm-19 { background: #d84315; }
122
124
  .hm-cell.hm-20 { background: #c62828; }
123
125
  .hm-cell.hm-21 { background: #b71c1c; }
124
- .heatmap-legend { display: flex; gap: 4px; align-items: center; font-size: 11px; color: var(--muted); flex-wrap: wrap; }
125
- .heatmap-legend .hm-cell { width: 12px; height: 12px; }
126
- .legend { display: flex; gap: 16px; font-size: 12px; color: var(--muted); margin-bottom: 12px; flex-wrap: wrap; }
127
- .legend span { display: flex; align-items: center; gap: 6px; }
128
- .sw { width: 12px; height: 12px; border-radius: 3px; display: inline-block; }
126
+ .heatmap-legend { display: flex; gap: 5px; align-items: center; font-size: 11px; color: var(--muted); flex-wrap: wrap; }
127
+ .heatmap-legend .hm-cell { width: 13px; height: 13px; }
128
+ .legend { display: flex; gap: 18px; font-size: 12px; color: var(--muted); margin-bottom: 14px; flex-wrap: wrap; }
129
+ .legend span { display: flex; align-items: center; gap: 7px; }
130
+ .sw { width: 13px; height: 13px; border-radius: 3px; display: inline-block; }
129
131
 
130
- .error-banner { display: none; background: rgba(248,81,73,.1); border: 1px solid #da3633; color: #f85149; padding: 10px 14px; border-radius: 8px; margin-bottom: 16px; font-size: 13px; }
132
+ .error-banner { display: none; background: rgba(248,81,73,.1); border: 1px solid #da3633; color: #f85149; padding: 12px 16px; border-radius: 10px; margin-bottom: 20px; font-size: 13px; }
131
133
  .error-banner.show { display: block; }
132
134
 
133
135
  /* ---- collapsible sections: primary vs secondary tier ---- */
134
- details.tool-section { background: var(--panel); border: 1px solid var(--border); border-radius: 10px; padding: 18px; margin-bottom: 18px; }
135
- details.tool-section summary { cursor: pointer; list-style: none; display: flex; align-items: center; gap: 8px; justify-content: space-between; }
136
+ details.tool-section { background: var(--panel); border: 1px solid var(--border); border-radius: 12px; padding: 20px; margin-bottom: 20px; transition: border-color 0.2s; }
137
+ details.tool-section:hover { border-color: #2a2f3a; }
138
+ details.tool-section summary { cursor: pointer; list-style: none; display: flex; align-items: center; gap: 10px; justify-content: space-between; }
136
139
  details.tool-section summary::-webkit-details-marker { display: none; }
137
- details.tool-section summary::before { content: '\25B8'; font-size: 12px; color: var(--muted); transition: transform .2s; flex: none; }
140
+ details.tool-section summary::before { content: '\25B8'; font-size: 13px; color: var(--muted); transition: transform 0.2s; flex: none; }
138
141
  details.tool-section[open] summary::before { transform: rotate(90deg); }
139
142
  details.tool-section summary h2 { margin: 0; }
140
- details.tool-section.secondary { background: transparent; padding: 12px 18px; }
141
- details.tool-section.secondary[open] { padding: 18px; }
142
- details.tool-section.secondary summary h2 { font-size: 11px; }
143
- .scope-tag { font-size: 11px; color: var(--muted); border: 1px solid var(--border); border-radius: 999px; padding: 2px 10px; font-weight: 500; white-space: nowrap; flex: none; margin-left: 12px; font-variant-numeric: tabular-nums; }
143
+ details.tool-section.secondary { background: transparent; padding: 14px 20px; }
144
+ details.tool-section.secondary[open] { padding: 20px; }
145
+ details.tool-section.secondary summary h2 { font-size: 12px; }
146
+ .scope-tag { font-size: 11px; color: var(--muted); border: 1px solid var(--border); border-radius: 8px; padding: 3px 11px; font-weight: 500; white-space: nowrap; flex: none; margin-left: 14px; font-variant-numeric: tabular-nums; }
144
147
 
145
- .subtabs { display: flex; gap: 4px; margin: 0 0 14px 20px; }
148
+ .subtabs { display: flex; gap: 6px; margin: 0 0 16px 24px; }
146
149
  .subtabs .pill { color: var(--muted); background: transparent; }
147
- .subtabs .pill.active { color: var(--text); border-color: #58a6ff; background: rgba(88,166,255,.12); font-weight: 600; }
148
-
149
- .badge { display: inline-block; font-size: 11px; padding: 1px 8px; border-radius: 999px; border: 1px solid var(--border); color: var(--muted); white-space: nowrap; }
150
- .badge.exact { color: #3fb950; border-color: rgba(63,185,80,.4); }
151
- .badge.sibling { color: #58a6ff; border-color: rgba(88,166,255,.4); }
152
- .badge.proxy { color: #d29922; border-color: rgba(210,153,34,.4); }
153
- .badge.openrouter { color: #a371f7; border-color: rgba(163,113,247,.4); }
154
- .badge.partial { color: #f778ba; border-color: rgba(247,120,186,.4); }
150
+ .subtabs .pill.active { color: var(--text); border-color: #4a9eff; background: rgba(74,158,255,.15); font-weight: 600; }
151
+
152
+ .badge { display: inline-block; font-size: 11px; padding: 2px 9px; border-radius: 8px; border: 1px solid var(--border); color: var(--muted); white-space: nowrap; }
153
+ .badge.exact { color: #34a853; border-color: rgba(52,168,83,.4); }
154
+ .badge.sibling { color: #4a9eff; border-color: rgba(74,158,255,.4); }
155
+ .badge.proxy { color: #f9ab00; border-color: rgba(249,171,0,.4); }
156
+ .badge.openrouter { color: #a78bfa; border-color: rgba(167,139,250,.4); }
157
+ .badge.partial { color: #ff6b9d; border-color: rgba(255,107,157,.4); }
155
158
  .badge.unpriced { color: #f85149; border-color: rgba(248,81,73,.4); }
156
- .empty { color: var(--muted); font-size: 13px; padding: 12px 0; }
159
+ .empty { color: var(--muted); font-size: 13px; padding: 14px 0; }
157
160
 
158
- .trend-bar { position: absolute; bottom: 0; border-radius: 2px 2px 0 0; transition: height .4s ease; }
161
+ .trend-bar { position: absolute; bottom: 0; border-radius: 3px 3px 0 0; transition: height .4s ease; }
159
162
  .trend-bar-cache { left: 0; right: 0; opacity: .2; }
160
163
  .trend-bar-input { left: 25%; width: 22%; z-index: 1; }
161
164
  .trend-bar-output { left: 53%; width: 22%; z-index: 1; }
162
165
  .trend-bar-reasoning { left: 76%; width: 22%; z-index: 1; }
163
- @media (max-width: 640px) { body { padding: 14px; } .card.hero .v { font-size: 26px; } }
166
+ @media (max-width: 640px) { body { padding: 16px; } .card.hero .v { font-size: 28px; } }
164
167
  </style>
165
168
  </head>
166
169
  <body>
@@ -421,6 +424,8 @@ const STRINGS = {
421
424
  statsFail: 'Failed to read opencode stats', connFail: 'Connection failed', reportFail: 'Failed to read usage report',
422
425
  langBtn: '繁中',
423
426
  backup: 'Backup DB', backingUp: 'Backing up…', backupFail: 'Backup failed',
427
+ unlimited: 'unlimited', freeRpd: 'free RPD', left: 'left', budgetValue: 'budget', freeTier: '[free tier]',
428
+ remaining: 'remaining', used: 'used', quotaReset: 'reset 00:00 UTC = 08:00 TW', cached: 'cached 5 min',
424
429
  },
425
430
  'zh-TW': {
426
431
  title: 'opencode 用量儀表板',
@@ -470,6 +475,8 @@ const STRINGS = {
470
475
  statsFail: 'opencode stats 讀取失敗', connFail: '連線失敗', reportFail: '用量報告讀取失敗',
471
476
  langBtn: 'EN',
472
477
  backup: '備份 DB', backingUp: '備份中…', backupFail: '備份失敗',
478
+ unlimited: '無限制', freeRpd: '免費 RPD', left: '剩', budgetValue: '預算剩', freeTier: '[免費層]',
479
+ remaining: '剩餘', used: '已用', quotaReset: '重置 00:00 UTC = 08:00 台灣', cached: '快取 5 分鐘',
473
480
  }
474
481
  };
475
482
 
@@ -759,20 +766,30 @@ function renderQuota(q) {
759
766
  const free = a.freeModelDaily || {};
760
767
  const rem = a.remainingUsd != null ? fmtUsd(a.remainingUsd) : '—';
761
768
  const used = fmtUsd(a.usedUsd || 0);
762
- const lim = a.limitUsd != null ? fmtUsd(a.limitUsd) : 'unlimited';
769
+ const lim = a.limitUsd != null ? fmtUsd(a.limitUsd) : t('unlimited');
763
770
  const pct = (a.limitUsd && a.limitUsd > 0) ? Math.round(((a.usedUsd || 0) / a.limitUsd) * 100) : null;
771
+ const freePct = (free.limit && free.limit > 0) ? Math.round((free.used / free.limit) * 100) : 0;
764
772
  const freeLine = free.limit != null
765
- ? 'free RPD ' + fmt(free.used) + '/' + fmt(free.limit) + ' (left ' + fmt(free.remaining) + ')'
773
+ ? '<div style="margin-top:4px">' + t('freeRpd') + ' ' + fmt(free.used) + '/' + fmt(free.limit) + ' (' + t('left') + ' ' + fmt(free.remaining) + ')</div>'
774
+ + '<div class="track" style="margin-top:2px"><div class="fill" style="width:' + freePct + '%;background:' + (freePct > 80 ? 'var(--out)' : 'var(--in)') + '"></div></div>'
766
775
  : '';
767
- const bud = a.budgetRemaining != null ? 'budget left ' + fmtUsd(a.budgetRemaining) + (a.budgetResetInterval ? ' (resets ' + a.budgetResetInterval + ')' : '') : '';
768
- return '<div style="margin-bottom:6px"><b>' + esc(a.label) + '</b>'
769
- + ' remaining ' + rem + ' / ' + lim + (pct != null ? ' (' + pct + '% used)' : '')
770
- + ' used ' + used + (a.isFreeTier ? ' [free tier]' : '')
771
- + (freeLine ? '<br>&nbsp;&nbsp;' + freeLine : '')
772
- + (bud ? '<br>&nbsp;&nbsp;' + bud : '')
776
+ const bud = a.budgetRemaining != null ? '<div style="margin-top:4px;color:var(--muted)">' + t('budgetValue') + ' ' + fmtUsd(a.budgetRemaining) + '</div>' : '';
777
+ const barColor = pct != null && pct > 80 ? 'var(--out)' : pct != null && pct > 50 ? 'var(--cache)' : 'var(--in)';
778
+ return '<div style="margin-bottom:12px;padding:12px;background:var(--bg);border:1px solid var(--border);border-radius:8px">'
779
+ + '<div style="display:flex;justify-content:space-between;align-items:center;margin-bottom:6px">'
780
+ + '<b style="color:var(--text)">' + esc(a.label) + '</b>'
781
+ + '<span style="font-size:11px;color:var(--muted)">' + (a.isFreeTier ? t('freeTier') : '') + '</span>'
782
+ + '</div>'
783
+ + '<div style="display:flex;justify-content:space-between;font-size:12px;margin-bottom:4px">'
784
+ + '<span>' + t('remaining') + ' <b>' + rem + '</b> / ' + lim + '</span>'
785
+ + '<span style="color:var(--muted)">' + t('used') + ' ' + used + '</span>'
786
+ + '</div>'
787
+ + (pct != null ? '<div class="track"><div class="fill" style="width:' + pct + '%;background:' + barColor + '"></div></div>' : '')
788
+ + freeLine
789
+ + bud
773
790
  + '</div>';
774
791
  }).join('');
775
- body.innerHTML = rows + '<div style="color:var(--muted);font-size:10px;margin-top:4px">reset 00:00 UTC = 08:00 TW · cached 5 min</div>';
792
+ body.innerHTML = rows + '<div style="color:var(--muted);font-size:10px;margin-top:8px;text-align:center">' + t('quotaReset') + ' · ' + t('cached') + '</div>';
776
793
  }
777
794
  async function loadQuota() {
778
795
  try { const r = await fetch('/api/openrouter-quota?_=' + Date.now(), { cache: 'no-store' }); const j = await r.json(); renderQuota(j); } catch (e) { $('quota-body').textContent = 'load failed: ' + e.message; }
@@ -1057,6 +1074,7 @@ async function poll() {
1057
1074
  lastUpdatedText = t('lastUpdated') + ' ' + time + ' (' + t('dataAgo') + ' ' + ago + 's)';
1058
1075
  $('updated').textContent = lastUpdatedText;
1059
1076
  refreshCurrentReport(); // auto-refresh report panels
1077
+ loadQuota(); // keep quota/RPD fresh on a 24/7 dashboard (server caches 5 min, so this is cheap)
1060
1078
  return j;
1061
1079
  } catch (e) {
1062
1080
  $('updated').textContent = t('connFail') + ': ' + e.message;
package/server.js CHANGED
@@ -1576,12 +1576,15 @@ async function fetchOpenRouterQuota() {
1576
1576
  const j = await r.json();
1577
1577
  const d = j.data || {};
1578
1578
  const eb = d.effective_budget || {};
1579
+ // free_model_daily_requests is account-level (shared across all keys of the same account).
1580
+ // Only show RPD for the free tier key; paid keys don't have their own RPD.
1581
+ const isFree = !!d.is_free_tier;
1579
1582
  accounts.push({
1580
1583
  label, limitUsd: d.limit != null ? d.limit : null, usedUsd: d.usage || 0,
1581
1584
  remainingUsd: d.limit_remaining != null ? d.limit_remaining : null,
1582
1585
  dailyUsed: d.usage_daily || 0, weeklyUsed: d.usage_weekly || 0, monthlyUsed: d.usage_monthly || 0,
1583
- isFreeTier: !!d.is_free_tier, expiresAt: d.expires_at || null,
1584
- freeModelDaily: d.free_model_daily_requests || null,
1586
+ isFreeTier: isFree, expiresAt: d.expires_at || null,
1587
+ freeModelDaily: isFree ? (d.free_model_daily_requests || null) : null,
1585
1588
  budgetScope: eb.scope || null, budgetLimit: eb.limit_usd != null ? eb.limit_usd : null,
1586
1589
  budgetSpend: eb.spend_usd != null ? eb.spend_usd : null,
1587
1590
  budgetRemaining: eb.remaining_usd != null ? eb.remaining_usd : null,