codex-copilot-dx 1.3.25 → 1.3.27
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/README.md +2 -2
- package/bin/cli.mjs +2 -2
- package/docs/ARCHITECTURE.md +6 -0
- package/docs/REFERENCE.md +24 -3
- package/package.json +1 -1
- package/src/antigravity-chat-bridge.mjs +2 -1
- package/src/antigravity-handler.mjs +67 -13
- package/src/antigravity-runtime.mjs +7 -2
- package/src/antigravity-usage.mjs +86 -0
- package/src/cli-command-spec.mjs +9 -4
- package/src/cli-management.mjs +25 -5
- package/src/client-versions.mjs +17 -13
- package/src/dashboard/console.js +1 -1
- package/src/dashboard/context.js +8 -4
- package/src/dashboard/flow.js +12 -11
- package/src/dashboard/gemini.js +20 -5
- package/src/dashboard/index.html +10 -9
- package/src/dashboard/language.js +31 -9
- package/src/dashboard/status.js +11 -2
- package/src/dashboard/ui.js +18 -7
- package/src/dashboard/usage.js +35 -19
- package/src/dashboard-api.mjs +19 -6
- package/src/stream-performance.mjs +5 -1
- package/src/terminal-state.mjs +8 -0
- package/src/usage-analysis.mjs +19 -8
- package/src/usage-analytics.mjs +9 -7
- package/src/usage-query.mjs +36 -0
- package/src/usage-store.mjs +4 -3
- package/src/usage.mjs +7 -3
package/src/dashboard/console.js
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
let accountsPending = false;
|
|
10
10
|
const accountReasons = new Set(["m365_account_ambiguous", "m365_account_unavailable", "m365_account_conflict", "m365_interaction_required", "m365_llm_permission_unavailable", "m365_account_busy", "m365_account_selection_stale"]);
|
|
11
11
|
function renderClientVersions(value) {
|
|
12
|
-
for (const client of ["codex", "claude"]) {
|
|
12
|
+
for (const client of ["codex", "claude", "antigravity"]) {
|
|
13
13
|
const node = el(`client-version-${client}`);if (!node) continue;
|
|
14
14
|
const rows = Array.isArray(value?.[client]) ? value[client] : [];
|
|
15
15
|
if (!rows.length) { node.removeAttribute("data-i18n");node.textContent = "—";node.title = "";continue; }
|
package/src/dashboard/context.js
CHANGED
|
@@ -20,11 +20,9 @@
|
|
|
20
20
|
if (!points.some(point => valid(point.input_tokens))) { label(host, "context_no_input");return; }
|
|
21
21
|
if (!entry.identified) { label(host, "context_unassigned");return; }
|
|
22
22
|
const width = host.clientWidth;if (!width) return;
|
|
23
|
-
const height = 210,
|
|
23
|
+
const height = 210, right = 12, top = 25, bottom = 35;
|
|
24
24
|
const measured = Math.max(...points.map(point => valid(point.input_tokens) ? point.input_tokens : 0), 1);
|
|
25
25
|
const maximum = Math.max(measured, latest(entry).context_window_tokens || 0);
|
|
26
|
-
const x = index => left + (width - left - right) * index / Math.max(1, points.length - 1);
|
|
27
|
-
const y = value => top + (height - top - bottom) * (1 - value / maximum);
|
|
28
26
|
const svg = document.createElementNS(ns, "svg");svg.setAttribute("viewBox", `0 0 ${width} ${height}`);
|
|
29
27
|
svg.setAttribute("role", "img");svg.setAttribute("aria-label", language.format("context_history"));host.append(svg);
|
|
30
28
|
const shape = (tag, attributes, text) => {
|
|
@@ -32,10 +30,16 @@
|
|
|
32
30
|
for (const [key, value] of Object.entries(attributes)) node.setAttribute(key, value);
|
|
33
31
|
if (text !== undefined) node.textContent = text;svg.append(node);return node;
|
|
34
32
|
};
|
|
33
|
+
const ticks = [0, maximum / 2, maximum].map(value => Math.round(value).toLocaleString());
|
|
34
|
+
const measures = ticks.map(text => shape("text", { visibility: "hidden" }, text));
|
|
35
|
+
const left = Math.max(64, Math.ceil(Math.max(...measures.map(node => node.getComputedTextLength()))) + 16);
|
|
36
|
+
measures.forEach(node => node.remove());
|
|
37
|
+
const x = index => left + (width - left - right) * index / Math.max(1, points.length - 1);
|
|
38
|
+
const y = value => top + (height - top - bottom) * (1 - value / maximum);
|
|
35
39
|
for (let index = 0; index <= 2; index++) {
|
|
36
40
|
const value = maximum * index / 2, py = y(value);
|
|
37
41
|
shape("line", { x1: left, x2: width - right, y1: py, y2: py, class: "context-grid" });
|
|
38
|
-
shape("text", { x: left - 8, y: py + 4, "text-anchor": "end" },
|
|
42
|
+
shape("text", { x: left - 8, y: py + 4, "text-anchor": "end" }, ticks[index]);
|
|
39
43
|
}
|
|
40
44
|
shape("text", { x: left, y: 12 }, "tokens");
|
|
41
45
|
let path = "", continuing = false;
|
package/src/dashboard/flow.js
CHANGED
|
@@ -16,16 +16,18 @@
|
|
|
16
16
|
const visible = () => document.visibilityState === "visible" && !root.closest("[hidden]");
|
|
17
17
|
const integer = value => Number.isSafeInteger(value) && value >= 0;
|
|
18
18
|
const appName = id => format(`flow_app_${id}`);
|
|
19
|
-
const
|
|
20
|
-
const
|
|
19
|
+
const awaitingMetadata = row => !row.terminal_outcome && row.upstream_attempts === 0 && ["received", "admission", "body", "history", "images", "serialization"].includes(row.phase);
|
|
20
|
+
const sourceName = (id, pending = false) => id === "github" ? "GitHub Copilot" : id === "m365" ? "Microsoft 365" : id === "google" ? "Google" : globalThis.ccdxConnectionNames?.[id] || format(pending ? "flow_source_pending" : "flow_source_unknown");
|
|
21
|
+
const modelName = (id, pending = false) => !id || id === "other" ? format(pending ? "flow_model_pending" : "flow_model_unknown") : id;
|
|
21
22
|
const modelKey = row => JSON.stringify([row.provider, row.model]);
|
|
22
23
|
const related = row => !selected || (selected.type === "apps" ? row.application === selected.id : modelKey(row) === selected.id);
|
|
23
24
|
const responding = row => row.first_output_ms !== null && !row.terminal_outcome;
|
|
24
25
|
function status(row) {
|
|
25
26
|
if (row.terminal_outcome) return "flow_finishing";
|
|
26
27
|
if (responding(row)) return "flow_responding";
|
|
28
|
+
if (row.phase === "admission") return "flow_queued";
|
|
27
29
|
if (row.upstream_attempts > 1) return "flow_retrying";
|
|
28
|
-
return row.upstream_attempts ? "flow_waiting" : "flow_preparing";
|
|
30
|
+
return row.upstream_attempts ? "flow_waiting" : row.phase === "received" ? "flow_preparing" : "flow_input";
|
|
29
31
|
}
|
|
30
32
|
function entry(tag, className) { const node = document.createElement(tag);if (className) node.className = className;return node; }
|
|
31
33
|
function svg(tag, values) { const node = document.createElementNS(ns, tag);for (const [key, value] of Object.entries(values)) node.setAttribute(key, value);return node; }
|
|
@@ -41,8 +43,8 @@
|
|
|
41
43
|
const map = new Map();
|
|
42
44
|
for (const row of rows) {
|
|
43
45
|
const id = type === "apps" ? row.application : modelKey(row);
|
|
44
|
-
if (!map.has(id)) map.set(id, { id, provider: row.provider, model: row.model, rows: [] });
|
|
45
|
-
map.get(id).rows.push(row);
|
|
46
|
+
if (!map.has(id)) map.set(id, { id, provider: row.provider, model: row.model, rows: [], pending: true });
|
|
47
|
+
map.get(id).rows.push(row);map.get(id).pending &&= awaitingMetadata(row);
|
|
46
48
|
}
|
|
47
49
|
const order = ["codex_app", "codex_cli", "codex", "claude_code", "claude_app", "claude", "gemini_app", "api"];
|
|
48
50
|
return [...map.values()].sort((a, b) => type === "apps" ? order.indexOf(a.id) - order.indexOf(b.id) : a.id.localeCompare(b.id));
|
|
@@ -65,16 +67,15 @@
|
|
|
65
67
|
cache.set(group.id, node);resize.observe(node);positions = null;
|
|
66
68
|
}
|
|
67
69
|
const [button, count, note] = node.children;
|
|
68
|
-
const title = type === "apps" ? appName(group.id) : modelName(group.model);
|
|
70
|
+
const title = type === "apps" ? appName(group.id) : modelName(group.model, group.pending);
|
|
69
71
|
if (button.textContent !== title) { button.textContent = title;positions = null; }
|
|
70
72
|
button.setAttribute("aria-pressed", String(selected?.type === type && selected.id === group.id));
|
|
71
73
|
count.hidden = fresh && omitted === 0 && group.rows.length < 2;
|
|
72
74
|
if (fresh && (group.rows.length || total === 0)) label(count, omitted ? "flow_count_lower" : "flow_count", { count: group.rows.length.toLocaleString() });
|
|
73
75
|
else count.textContent = "—";
|
|
74
|
-
if (type === "models" && node.children[3].textContent !== sourceName(group.provider)) { node.children[3].textContent = sourceName(group.provider);positions = null; }
|
|
76
|
+
if (type === "models" && node.children[3].textContent !== sourceName(group.provider, group.pending)) { node.children[3].textContent = sourceName(group.provider, group.pending);positions = null; }
|
|
75
77
|
const output = group.rows.filter(responding).length;
|
|
76
|
-
const
|
|
77
|
-
: group.rows.every(row => row.upstream_attempts > 1) ? "flow_retrying" : "flow_waiting";
|
|
78
|
+
const phases = new Set(group.rows.map(status)), phase = phases.size === 1 ? [...phases][0] : "flow_processing";
|
|
78
79
|
label(note, !fresh || total && !group.rows.length ? "flow_last_observed" : !group.rows.length ? "flow_idle" : output ? group.rows.length === 1 ? "flow_responding" : "flow_group_response" : phase, { count: output });
|
|
79
80
|
node.dataset.related = String(!selected || group.rows.some(related));fragments.push(node);
|
|
80
81
|
}
|
|
@@ -91,7 +92,7 @@
|
|
|
91
92
|
const id = row.request_id || JSON.stringify([row.application, row.provider, row.model, index]);wanted.add(id);
|
|
92
93
|
let tr = detailRows.get(id);
|
|
93
94
|
if (!tr) { tr = entry("tr");for (let i = 0; i < 6; i++) tr.append(entry("td"));detailRows.set(id, tr); }
|
|
94
|
-
const values = [appName(row.application), sourceName(row.provider), modelName(row.model), format(fresh ? status(row) : "flow_last_observed"), `${((row.elapsed_ms + Math.max(0, Date.now() - sampledAt)) / 1000).toFixed(1)} s`, row.upstream_attempts.toLocaleString()];
|
|
95
|
+
const values = [appName(row.application), sourceName(row.provider, awaitingMetadata(row)), modelName(row.model, awaitingMetadata(row)), format(fresh ? status(row) : "flow_last_observed"), `${((row.elapsed_ms + Math.max(0, Date.now() - sampledAt)) / 1000).toFixed(1)} s`, row.upstream_attempts.toLocaleString()];
|
|
95
96
|
if (row.previous_request) values[3] += " · " + format("flow_previous_result", { reason: row.previous_request.stop_reason || row.previous_request.outcome || "—", seconds: (row.previous_request.elapsed_ms / 1000).toFixed(1) });
|
|
96
97
|
tr.title = row.session_id ? format("flow_session_previous", { session: row.session_id, reason: row.previous_request?.stop_reason || row.previous_request?.outcome || "—", seconds: row.previous_request ? (row.previous_request.elapsed_ms / 1000).toFixed(1) : "—" }) : format("flow_session_unknown");
|
|
97
98
|
values.forEach((value, i) => { if (tr.children[i].textContent !== value) tr.children[i].textContent = value; });
|
|
@@ -107,7 +108,7 @@
|
|
|
107
108
|
root.dataset.paused = "false";
|
|
108
109
|
const apps = group("apps"), allModels = group("models");
|
|
109
110
|
if (fresh && rows.length) { lastApps = apps;lastModels = allModels; }
|
|
110
|
-
if (fresh && !rows.length) { for (const groups of [lastApps, lastModels]) for (const group of groups) group.rows = []; }
|
|
111
|
+
if (fresh && !rows.length) { lastModels = lastModels.filter(group => !(group.pending && (!group.model || group.model === "other")));for (const groups of [lastApps, lastModels]) for (const group of groups) group.rows = []; }
|
|
111
112
|
const shownApps = apps.length ? apps : lastApps, models = allModels.length ? allModels : lastModels;
|
|
112
113
|
if (selected && !rows.some(related)) selected = null;
|
|
113
114
|
const signature = JSON.stringify([fresh, total, omitted, selected, expanded, rows.map(row => [row.request_id, row.application, row.provider, row.model, row.phase, row.upstream_attempts, row.first_output_ms !== null, row.terminal_outcome])]);
|
package/src/dashboard/gemini.js
CHANGED
|
@@ -7,6 +7,16 @@
|
|
|
7
7
|
const selected=()=>state?.models.filter(model=>model.selected!==false).map(model=>model.id)||[];
|
|
8
8
|
const dirty=()=>draft!==null&&JSON.stringify([...draft].sort())!==JSON.stringify(selected().sort());
|
|
9
9
|
const count=value=>!value?'—':value>=1000000?`${Number((value/1000000).toFixed(2))}M`:value>=1000?`${Number((value/1000).toFixed(1))}K`:String(value);
|
|
10
|
+
const groupedModels=()=>{
|
|
11
|
+
if(Array.isArray(state.model_groups))return state.model_groups;
|
|
12
|
+
const groups=new Map();
|
|
13
|
+
for(const variant of state.models){
|
|
14
|
+
const name=variant.name.split(' · Copilot')[0],id=variant.model||name;
|
|
15
|
+
if(!groups.has(id))groups.set(id,{id,name,context_window:variant.context_window,efforts:[]});
|
|
16
|
+
groups.get(id).efforts.push({id:variant.id,effort:variant.effort,selected:variant.selected});
|
|
17
|
+
}
|
|
18
|
+
return [...groups.values()];
|
|
19
|
+
};
|
|
10
20
|
function render(){
|
|
11
21
|
for(const id of controls)el(id).disabled=busy||!state;
|
|
12
22
|
if(!state)return;
|
|
@@ -22,12 +32,17 @@
|
|
|
22
32
|
el('gemini-reopen').hidden=!hint;if(hint)words('gemini-reopen',hint);
|
|
23
33
|
el('gemini-open').disabled=busy||state.app.status!=='stopped';
|
|
24
34
|
const list=el('gemini-models'),focus=list.contains(document.activeElement)?document.activeElement.value:null;list.replaceChildren();
|
|
25
|
-
for(const model of
|
|
35
|
+
for(const model of groupedModels()){
|
|
36
|
+
const chosen=new Set(draft||selected()),ids=model.efforts.map(item=>item.id);
|
|
26
37
|
const row=document.createElement('tr'),name=document.createElement('td'),label=document.createElement('label'),input=document.createElement('input');
|
|
27
|
-
input.type='checkbox';input.value=model.id;input.checked=(
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
38
|
+
input.type='checkbox';input.value=model.id;input.checked=ids.some(id=>chosen.has(id));input.disabled=busy;input.setAttribute('aria-label',model.name);
|
|
39
|
+
const update=(values,checked)=>{const next=new Set(draft||selected());for(const id of values)if(checked)next.add(id);else next.delete(id);draft=[...next];notice=null;clear('gemini-note');render()};
|
|
40
|
+
input.addEventListener('change',()=>{const saved=ids.filter(id=>selected().includes(id));update(input.checked&&saved.length?saved:ids,input.checked)});
|
|
41
|
+
label.append(input,document.createTextNode(model.name));name.append(label);row.append(name);
|
|
42
|
+
for(const [key,value]of [['source','GitHub Copilot'],['cap_context',count(model.context_window)]]){const cell=document.createElement('td');cell.textContent=value;cell.dataset.label=language.format(key);row.append(cell)}
|
|
43
|
+
const efforts=document.createElement('td');efforts.dataset.label=language.format('cap_reasoning');
|
|
44
|
+
efforts.textContent=model.efforts.map(item=>item.effort).join(' / ');
|
|
45
|
+
row.append(efforts);list.append(row);
|
|
31
46
|
}
|
|
32
47
|
if(!state.models.length){const row=document.createElement('tr'),cell=document.createElement('td');cell.colSpan=4;language.set(cell,'gemini_no_models');row.append(cell);list.append(row)}
|
|
33
48
|
if(focus)[...list.querySelectorAll('input')].find(input=>input.value===focus)?.focus();
|
package/src/dashboard/index.html
CHANGED
|
@@ -165,7 +165,7 @@
|
|
|
165
165
|
<div data-view="gemini" hidden>
|
|
166
166
|
<section class="connection-access"><div class="connection-row"><label for="gemini-enabled" data-i18n="gemini_access_title">Copilot access</label><label class="switch-hit"><input id="gemini-enabled" type="checkbox" role="switch" data-i18n-label="gemini_access_title" aria-label="Copilot access" disabled></label></div></section>
|
|
167
167
|
<section class="panel dashboard-section">
|
|
168
|
-
<div class="panel-heading"><h2 data-i18n="
|
|
168
|
+
<div class="panel-heading"><h2 data-i18n="cap_visible_model">Available models</h2><span id="gemini-draft-state" role="status">—</span></div>
|
|
169
169
|
<form id="gemini-model-form">
|
|
170
170
|
<div class="table-wrap"><table class="binding-table"><thead><tr><th data-i18n="model">Model</th><th data-i18n="source">Source</th><th data-i18n="cap_context">Context</th><th data-i18n="cap_reasoning">Reasoning</th></tr></thead><tbody id="gemini-models"></tbody></table></div>
|
|
171
171
|
<div class="section-actions"><button id="gemini-save" type="submit" data-i18n="api_save" disabled>Save</button><button id="gemini-cancel" type="button" data-i18n="cap_discard_changes" disabled>Discard changes</button></div>
|
|
@@ -289,6 +289,7 @@
|
|
|
289
289
|
<p class="hint" data-i18n="tools_local_scope">Local checks do not contact external services.</p>
|
|
290
290
|
<p>Codex App: <strong id="client-version-codex">—</strong></p>
|
|
291
291
|
<p>Claude App: <strong id="client-version-claude">—</strong></p>
|
|
292
|
+
<p>Antigravity: <strong id="client-version-antigravity">—</strong></p>
|
|
292
293
|
<p class="hint" data-i18n="client_versions_scope">Installed versions only; running App adoption and compatibility are separate.</p>
|
|
293
294
|
<div class="section-actions"><button id="check-local" type="button" data-i18n="tools_check_local">Check this computer</button></div>
|
|
294
295
|
<p id="checks-note" class="table-note" role="status" aria-live="polite" data-i18n="tools_checks_empty">Run a check to see the results.</p>
|
|
@@ -316,29 +317,29 @@
|
|
|
316
317
|
<div data-view="usage" hidden>
|
|
317
318
|
<div class="context-tabs" role="tablist" aria-label="Usage view" data-i18n-label="context_tabs"><button type="button" id="usage-tokens-tab" role="tab" aria-selected="true" aria-controls="usage-tokens-pane" data-i18n="context_tokens">Tokens</button><button type="button" id="usage-context-tab" role="tab" aria-selected="false" aria-controls="usage-context-pane" data-i18n="context_title">Context</button></div>
|
|
318
319
|
<div id="usage-tokens-pane" role="tabpanel" aria-labelledby="usage-tokens-tab">
|
|
319
|
-
<div class="section-actions usage-source-controls"><label><span data-i18n="source_entire_page">Source / entire page</span><select id="usage-provider"><option value="" data-i18n="all_providers">All providers</option></select></label
|
|
320
|
+
<div class="section-actions usage-source-controls"><label><span data-i18n="source_entire_page">Source / entire page</span><select id="usage-provider"><option value="" data-i18n="all_providers">All providers</option></select></label>
|
|
321
|
+
<label><span data-i18n="usage_model_page">Model / entire page</span><select id="analytics-model"><option value="" data-i18n="all_models">All models</option></select></label>
|
|
322
|
+
<label><span data-i18n="usage_range_page">Time / entire page</span><select id="analytics-range"><option value="all" selected data-i18n="usage_all_history">All retained history</option><option value="7" data-i18n="7_days">Last 7 days</option><option value="30" data-i18n="30_days">Last 30 days</option><option value="90" data-i18n="90_days">Last 90 days</option><option value="365" data-i18n="usage_365_days">Last 365 days</option></select></label>
|
|
323
|
+
<button id="refresh-usage" type="button" data-i18n="refresh_usage">Refresh usage</button></div>
|
|
320
324
|
|
|
321
325
|
<details id="usage-analytics" class="panel dashboard-section analytics-section">
|
|
322
326
|
<summary data-i18n="usage_analytics">USAGE TRENDS</summary>
|
|
323
|
-
<div class="analytics-controls">
|
|
324
|
-
<label><span data-i18n="model_both_charts">Model / both charts</span> <select id="analytics-model"><option value="" data-i18n="all_models">All models</option></select></label>
|
|
325
|
-
</div>
|
|
326
327
|
<p id="analytics-note" class="table-note" role="status" data-i18n="open_to_read_retained_usage_history">Loading usage trends…</p>
|
|
327
328
|
<p id="analytics-updated" class="refresh-time"></p>
|
|
328
|
-
<div class="chart-heading"><h3 data-i18n="daily_tokens">
|
|
329
|
+
<div class="chart-heading"><h3 data-i18n="daily_tokens">USAGE BY DATE</h3><div class="analytics-controls">
|
|
329
330
|
<label><span data-i18n="chart_view">Chart view</span> <select id="analytics-view"><option value="bars" selected data-i18n="bar_chart">Bar chart</option><option value="line" data-i18n="line_chart">Line chart</option></select></label></div></div>
|
|
330
331
|
<div id="daily-bars" class="daily-bars" aria-label="Daily usage in Token" data-i18n-label="daily_token_usage"></div>
|
|
331
332
|
<div class="daily-axis"><span id="daily-from"></span><span id="daily-to"></span></div>
|
|
332
333
|
<div class="chart-legend"><span class="legend-input" data-i18n="input_36ecb">Input usage</span><span class="legend-output" data-i18n="output_b2439">Output usage</span></div>
|
|
333
|
-
<div class="chart-heading"><h3 data-i18n="
|
|
334
|
+
<div class="chart-heading"><h3 data-i18n="usage_activity_range">ACTIVITY</h3><div class="analytics-controls"><label><span data-i18n="calendar_measure">Calendar measure</span> <select id="analytics-metric"><option value="requests" data-i18n="recorded_usage">Usage records</option><option value="tokens" data-i18n="tokens">Usage (Token)</option></select></label></div></div><p id="activity-scale" class="hint">—</p>
|
|
334
335
|
<div class="calendar-scroll"><div class="calendar-grid"><div id="calendar-months" class="calendar-months" aria-hidden="true"></div><div id="activity-calendar" class="activity-calendar" aria-label="Daily recorded activity over 365 days" data-i18n-label="daily_recorded_request_activity"></div></div></div>
|
|
335
336
|
<p id="analytics-selection" class="hint" role="status" data-i18n="select_a_day_to_inspect_its_model_totals_no_history_is_distinct_">Select a day for its usage. No records does not mean zero requests.</p>
|
|
336
337
|
</details>
|
|
337
338
|
<details class="panel dashboard-section" id="model-usage" open>
|
|
338
339
|
<summary class="panel-heading"><h2 data-i18n="usage_totals">USAGE TOTALS</h2><span id="usage-state" data-i18n="reading_log">COUNTING</span></summary>
|
|
339
|
-
<div class="section-actions"><button id="clear-usage-day" type="button" hidden data-i18n="
|
|
340
|
+
<div class="section-actions"><button id="clear-usage-day" type="button" hidden data-i18n="usage_clear_date">Clear date</button></div>
|
|
340
341
|
<p id="usage-note" class="table-note" data-i18n="aggregating_local_usage_metadata">Counting local usage…</p>
|
|
341
|
-
<div class="table-wrap"><table class="usage-table"><thead><tr><th scope="col" data-i18n="model">MODEL</th><th scope="col" data-i18n="
|
|
342
|
+
<div class="table-wrap"><table class="usage-table"><thead><tr><th scope="col" data-i18n="model">MODEL</th><th scope="col" data-i18n="usage_records">RECORDS</th><th scope="col" data-i18n="input">INPUT USAGE</th><th scope="col" data-i18n="cache_read">REUSED INPUT</th><th scope="col" data-i18n="cache_write">CACHE WRITE</th><th scope="col" data-i18n="output">OUTPUT USAGE</th><th scope="col" data-i18n="total">TOTAL</th><th scope="col" data-i18n="cache_hit">REUSE RATE</th></tr></thead><tbody id="usage-body"><tr><td colspan="8" data-i18n="loading">Loading…</td></tr></tbody></table></div>
|
|
342
343
|
<p class="hint" data-i18n="cache_hit_recorded_cached_input_tokens_incomplete_history_unavai">Unit: Token. Reused input is part of input. Rate uses records with valid input and cache-read counts.
|
|
343
344
|
~ Partial coverage. — No valid input basis.</p>
|
|
344
345
|
|
|
@@ -492,7 +492,7 @@
|
|
|
492
492
|
"flow_active_count": ["Active requests · {count}", "进行中 · {count}"],
|
|
493
493
|
"flow_last_count": ["Last observed · {count}", "上次记录 · {count}"],
|
|
494
494
|
"flow_related_count": ["{count} related requests", "{count} 个相关请求"],
|
|
495
|
-
"flow_group_scope": ["{apps} apps · {models}
|
|
495
|
+
"flow_group_scope": ["{apps} apps · {models} model groups", "{apps} 个应用 · {models} 个模型分组"],
|
|
496
496
|
"flow_omitted": ["Showing {count} requests; {omitted} more have no detail", "显示 {count} 个请求,另有 {omitted} 个暂无详情"],
|
|
497
497
|
"flow_more_models": ["Show {count} more models", "显示其余 {count} 个模型"],
|
|
498
498
|
"flow_fewer_models": ["Show fewer models", "收起模型"],
|
|
@@ -503,11 +503,33 @@
|
|
|
503
503
|
"flow_app_gemini_app": ["Antigravity", "Antigravity"],
|
|
504
504
|
"flow_app_claude": ["Claude (app unspecified)", "Claude(未区分应用)"],
|
|
505
505
|
"flow_app_api": ["Unidentified app", "未识别应用"],
|
|
506
|
+
"flow_source_pending": ["Source pending", "来源待确认"],
|
|
507
|
+
"flow_model_pending": ["Model pending", "模型待确认"],
|
|
506
508
|
"flow_source_unknown": ["Source unknown", "来源未知"],
|
|
507
509
|
"flow_model_unknown": ["Model not identified", "未识别模型"],
|
|
508
510
|
"flow_responding": ["Responding", "响应中"],
|
|
509
511
|
"flow_group_response": ["{count} responding", "{count} 个响应中"],
|
|
510
|
-
"flow_waiting": ["Waiting
|
|
512
|
+
"flow_waiting": ["Waiting upstream", "等待上游"],
|
|
513
|
+
"flow_queued": ["Queued", "排队中"],
|
|
514
|
+
"flow_input": ["Processing input", "处理输入"],
|
|
515
|
+
"flow_processing": ["Processing", "处理中"],
|
|
516
|
+
"request_usage_state": ["Usage received", "用量接收状态"],
|
|
517
|
+
"request_usage_reported": ["Reported", "已收到"],
|
|
518
|
+
"request_usage_partial": ["Some counts unavailable", "部分计数未提供"],
|
|
519
|
+
"request_usage_missing": ["No valid usage received", "未收到有效用量"],
|
|
520
|
+
"request_usage_unavailable": ["Metadata could not be read", "元数据无法读取"],
|
|
521
|
+
"usage_model_page": ["Model / entire page", "模型/整页"],
|
|
522
|
+
"usage_range_page": ["Time / entire page", "时间/整页"],
|
|
523
|
+
"usage_all_history": ["All retained history", "全部已保留历史"],
|
|
524
|
+
"usage_365_days": ["Last 365 days", "最近 365 天"],
|
|
525
|
+
"usage_clear_date": ["Clear date", "清除日期"],
|
|
526
|
+
"usage_records": ["RECORDS", "用量记录"],
|
|
527
|
+
"recorded_usage": ["Usage records", "用量记录"],
|
|
528
|
+
"usage_earlier": ["Earlier records", "更早记录"],
|
|
529
|
+
"usage_earlier_before": ["Records before {date}", "{date} 之前的记录"],
|
|
530
|
+
"usage_empty_selection": ["No recorded usage matches these filters. No records does not mean zero requests.", "当前筛选没有已记录用量。没有记录不代表没有请求。"],
|
|
531
|
+
"usage_activity_range": ["ACTIVITY", "用量活动"],
|
|
532
|
+
"usage_cache_coverage": ["Cache counts available: {known} records; unavailable: {unknown}.", "缓存计数已知 {known} 条,未知 {unknown} 条。"],
|
|
511
533
|
"flow_preparing": ["Preparing", "准备中"],
|
|
512
534
|
"flow_retrying": ["Retrying", "正在重试"],
|
|
513
535
|
"flow_finishing": ["Finishing delivery", "正在完成交付"],
|
|
@@ -992,13 +1014,13 @@
|
|
|
992
1014
|
"calls_b73a5": ["Requests", "请求次数"],
|
|
993
1015
|
"tokens": ["Usage (Token)", "处理用量"],
|
|
994
1016
|
"open_to_read_retained_usage_history": ["Loading usage trends…", "读取用量趋势中…"],
|
|
995
|
-
"daily_tokens": ["
|
|
1017
|
+
"daily_tokens": ["USAGE BY DATE", "按日期用量"],
|
|
996
1018
|
"input_output_cache_included_in_input": ["INPUT + OUTPUT / REUSED INPUT IS PART OF INPUT", "输入与输出合计。\n复用部分已计入输入。"],
|
|
997
|
-
"daily_token_usage": ["
|
|
1019
|
+
"daily_token_usage": ["Input and output usage by date", "按日期记录的输入与输出用量"],
|
|
998
1020
|
"input_36ecb": ["Input usage", "输入用量"],
|
|
999
1021
|
"output_b2439": ["Output usage", "输出用量"],
|
|
1000
1022
|
"request_activity_365_days": ["ACTIVITY · LAST 365 DAYS", "活跃日历"],
|
|
1001
|
-
"daily_recorded_request_activity": ["
|
|
1023
|
+
"daily_recorded_request_activity": ["Recorded usage by date", "按日期记录的用量"],
|
|
1002
1024
|
"select_a_day_to_inspect_its_model_totals_no_history_is_distinct_": ["Select a day for usage. Blank means no records.", "点击日期查看当天用量。空白表示无记录。"],
|
|
1003
1025
|
"recent_failures": ["Recent issues", "异常记录"],
|
|
1004
1026
|
"recent_response_failures": ["RECENT ISSUES", "异常记录"],
|
|
@@ -1087,17 +1109,17 @@
|
|
|
1087
1109
|
"records_records_shown_of_models_models_shown_day": ["Records: {records} · models: {shown} of {models}{day}", "记录:{records}条\n模型:展示{shown}个,共{models}个{day}"],
|
|
1088
1110
|
"zone_model": [" / {zone} / {model}", " / {zone} / {model}"],
|
|
1089
1111
|
"no_retained_history": ["no records", "没有记录"],
|
|
1090
|
-
"calls_recorded_calls_input_input_output_output_cached_cached_inc": ["{calls}
|
|
1112
|
+
"calls_recorded_calls_input_input_output_output_cached_cached_inc": ["{calls} usage records\nInput: {input} / output: {output}\nReused input: {cached} Token\nReused input is part of input.{partial}", "用量记录:{calls}\n输入:{input}/输出:{output}\n复用输入:{cached} Token\n复用部分已计入输入。{partial}"],
|
|
1091
1113
|
"partial_token_counts": ["\nIncomplete usage records.", "\n用量记录不完整。"],
|
|
1092
1114
|
"date_description": ["{date} / {description}", "{date} / {description}"],
|
|
1093
|
-
"metric_peak_peak": ["
|
|
1115
|
+
"metric_peak_peak": ["{metric} · Peak {peak}", "{metric} · 峰值 {peak}"],
|
|
1094
1116
|
"input_output": ["TOTAL USAGE (Token)", "总用量"],
|
|
1095
1117
|
"recorded_calls": ["RECORDED REQUESTS", "请求次数"],
|
|
1096
1118
|
"zone_from_to_retained_history_starts_first_oldest_day_may_be_par": ["Zone: {zone}\nRange: {from}–{to}\nFirst record: {first}\nThe first day may be partial.{excluded}{limit}", "时区:{zone}\n记录范围:{from}—{to}\n最早记录:{first}\n最早一天可能记录不全。{excluded}{limit}"],
|
|
1097
1119
|
"count_records_with_invalid_future_timestamps_excluded": ["\nSkipped {count} records with invalid or future dates.", "\n已跳过{count}条时间异常记录。"],
|
|
1098
1120
|
"model_filters_limited_to_100_all_model_totals_include_the_remain": ["\nFilters show up to 100 models. Totals include the rest.", "\n只列出前100个模型。\n总计包含其余模型。"],
|
|
1099
|
-
"selected_date_model_totals_in_the_usage_table_above_all_history_": ["Selected: {date} / {model}\
|
|
1100
|
-
"select_a_day_for_model_totals_calls_are_usage_records_not_messag": ["Select a day for usage.\nCounts are
|
|
1121
|
+
"selected_date_model_totals_in_the_usage_table_above_all_history_": ["Selected: {date} / {model}\nClear date restores the time filter.", "已选:{date}/{model}\n清除日期后恢复时间筛选。"],
|
|
1122
|
+
"select_a_day_for_model_totals_calls_are_usage_records_not_messag": ["Select a day for usage.\nCounts are usage records, not messages or time.\nHatched: no retained history. Blank: zero recorded usage.", "点击日期查看当天用量。\n计数为用量记录,不代表消息或时长。\n斜线格:没有保留记录。\n空白格:用量记录为零。"],
|
|
1101
1123
|
"log_unavailable": ["READ FAILED", "读取失败"],
|
|
1102
1124
|
"no_usage_summary_available": ["Cannot read usage records.", "无法读取用量记录。"],
|
|
1103
1125
|
"analytics_unavailable_refresh_usage_to_retry": ["Trends unavailable. Refresh Model usage to retry.", "统计失败,请刷新用量。"],
|
package/src/dashboard/status.js
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
let issueGroups = { issues: [], capability: [], connection: [] }, issueRequests = [];
|
|
10
10
|
element("failure-kind")?.addEventListener?.("change", () => renderFailures(issueGroups[element("failure-kind").value] || [], element("failure-kind").value === "issues" ? issueRequests : []));
|
|
11
11
|
let contextSignature;
|
|
12
|
-
const sourceNames = new Map([["github", "GitHub Copilot"], ["m365", "Microsoft 365"]]);
|
|
12
|
+
const sourceNames = new Map([["github", "GitHub Copilot"], ["m365", "Microsoft 365"], ["google", "Google"]]);
|
|
13
13
|
|
|
14
14
|
const sourceLabel = id => globalThis.ccdxConnectionNames?.[id] || sourceNames.get(id) || id;
|
|
15
15
|
function renderProviders(data) {
|
|
@@ -75,7 +75,14 @@
|
|
|
75
75
|
}
|
|
76
76
|
if (data.gemini || globalThis.ccdxGeminiStatus) {
|
|
77
77
|
const gemini=data.gemini || globalThis.ccdxGeminiStatus;
|
|
78
|
-
|
|
78
|
+
const setup=gemini.enabled&&gemini.source_enabled!==false?"configured":gemini.configured?"access_paused":"not_configured";
|
|
79
|
+
const service=gemini.configured===true?"running":gemini.configured===false?"unavailable":"unknown";
|
|
80
|
+
const row=tableRow(["Antigravity",gemini.enabled&&gemini.source_enabled!==false?"Google + GitHub Copilot":"Google",setup,service,"—"],{labels:[2,3]});
|
|
81
|
+
if(globalThis.ccdxIcons){
|
|
82
|
+
globalThis.ccdxIcons.set(row.children[2],setup,globalThis.ccdxIcons.kind(setup==="access_paused"?"paused":setup));
|
|
83
|
+
globalThis.ccdxIcons.set(row.children[3],service,globalThis.ccdxIcons.kind(service));
|
|
84
|
+
}
|
|
85
|
+
clients.append(row);
|
|
79
86
|
}
|
|
80
87
|
if (element("claude-client-state")) element("claude-client-state").hidden = Boolean(claudeClients?.children.length);
|
|
81
88
|
text("source-summary", "count_providers", { count: providers.length });
|
|
@@ -398,6 +405,8 @@
|
|
|
398
405
|
["wire_mib", finite(context.payload_bytes) ? `${(Number(context.payload_bytes) / 1048576).toFixed(2)} MiB` : "—"],
|
|
399
406
|
["images", number(context.images)], ["model_window", number(context.context_window_tokens)], ["input_window", ratio],
|
|
400
407
|
["output_requested", number(context.max_output_tokens_requested)], ["output_sent", number(context.max_output_tokens_sent)], ["output_used", number(context.output_tokens)], ["stop_reason", request.stop_reason || "—"],
|
|
408
|
+
...(context.requested_model && context.requested_model !== request.model ? [["requested_model", context.requested_model]] : []),
|
|
409
|
+
...(["reported", "partial", "missing", "unavailable"].includes(context.usage_state) ? [["request_usage_state", globalThis.ccdxLanguage?.format("request_usage_" + context.usage_state) || context.usage_state]] : []),
|
|
401
410
|
...(context.client_tool_errors_received > 0 ? [["client_tool_errors_received", number(context.client_tool_errors_received)]] : [])]) {
|
|
402
411
|
const term = document.createElement("dt"), detail = document.createElement("dd");localize(term, key);detail.textContent = value;fields.append(term, detail);
|
|
403
412
|
}
|
package/src/dashboard/ui.js
CHANGED
|
@@ -17,6 +17,7 @@ const number = (value) => finite(value) ? Math.max(0, Math.round(Number(value)))
|
|
|
17
17
|
const mib = (value) => finite(value) ? `${(Number(value) / 1048576).toFixed(1)} MiB` : "—";
|
|
18
18
|
const time = (value, options) => globalThis.ccdxTime?.format(value, options) ?? (value ? new Date(value).toLocaleTimeString() : "—");
|
|
19
19
|
const viewHelpers = { time, element, phrase, localize, text, finite, number, mib, tableRow, emptyTable, document, navigator: globalThis.navigator, modelLabel: usageModelLabel,
|
|
20
|
+
usageChanged: () => { dashboardRefresh.invalidate("usage");return dashboardRefresh.refresh("usage", { force: true }); },
|
|
20
21
|
motionAllowed: () => !reducedMotion.matches && document.visibilityState === "visible" && element("usage-analytics").open && !element("usage-analytics").closest("[hidden]") };
|
|
21
22
|
const { render, renderActivity, renderProviders, renderFailures, renderContext } = globalThis.ccdxViewBoundary.create("client-features", () => globalThis.ccdxDashboardStatus.create(viewHelpers), ["render", "renderActivity", "renderProviders", "renderFailures", "renderContext"]);
|
|
22
23
|
const usageView = globalThis.ccdxViewBoundary.create("usage-analytics", () => globalThis.ccdxDashboardUsage.create(viewHelpers), ["applyUsage", "renderUsageState", "renderAnalytics", "renderUsageTable", "selectUsageDay", "usageValues", "setChartVisible", "revealChart", "stopMotion", "refreshModelLabels"]);
|
|
@@ -80,8 +81,8 @@ let selectedProvider = "";
|
|
|
80
81
|
function usageModelLabel(value) {
|
|
81
82
|
if (typeof value !== "string") return value;
|
|
82
83
|
const at = value.indexOf(" / "), id = value.slice(0, at);
|
|
83
|
-
if (at < 0
|
|
84
|
-
const name = providerEntries.find(provider => provider.id === id)?.name;
|
|
84
|
+
if (at < 0) return value;
|
|
85
|
+
const name = providerEntries.find(provider => provider.id === id)?.name || ({ github: "GitHub Copilot", m365: "Microsoft 365", google: "Google" })[id];
|
|
85
86
|
return name ? name + value.slice(at) : value;
|
|
86
87
|
}
|
|
87
88
|
const modelSnapshots = new Map();
|
|
@@ -91,7 +92,7 @@ try { selectedProvider = localStorage.getItem("ccdx.dashboard.modelProvider") ||
|
|
|
91
92
|
function syncUsageProviders() {
|
|
92
93
|
const selector = element("usage-provider"), selected = selector.value;
|
|
93
94
|
const entries = new Map(providerEntries.map(provider => [provider.id, provider.name]));
|
|
94
|
-
for (const id of Object.keys(usageProviders)) if (usageProviders[id] > 0 && !entries.has(id)) entries.set(id, id);
|
|
95
|
+
for (const id of Object.keys(usageProviders)) if (usageProviders[id] > 0 && !entries.has(id)) entries.set(id, ({ google: "Google", github: "GitHub Copilot", m365: "Microsoft 365" })[id] || id);
|
|
95
96
|
const signature = JSON.stringify([...entries]);
|
|
96
97
|
if (selector.dataset.providers === signature) return;
|
|
97
98
|
selector.dataset.providers = signature;
|
|
@@ -390,12 +391,17 @@ const dashboardRefresh = globalThis.ccdxRefresh.createController({
|
|
|
390
391
|
variant: () => {
|
|
391
392
|
const mode = (element("usage-analytics").open || Boolean(usageView.selectedDate)) ? "analytics" : "summary";
|
|
392
393
|
const provider = element("usage-provider")?.value || "";
|
|
393
|
-
return mode
|
|
394
|
+
return JSON.stringify({ mode, provider, model: element("analytics-model").value || "", days: element("analytics-range").value || "all", date: usageView.selectedDate });
|
|
394
395
|
},
|
|
395
396
|
load: async ({ variant, signal }) => {
|
|
396
|
-
const
|
|
397
|
+
const { mode, provider, model, days, date } = JSON.parse(variant), query = new URLSearchParams();
|
|
397
398
|
if (mode === "analytics") { query.set("analytics", "1");query.set("time_zone", Intl.DateTimeFormat().resolvedOptions().timeZone); }
|
|
398
399
|
if (provider) query.set("provider", provider);
|
|
400
|
+
if (model) query.set("model", model);
|
|
401
|
+
if (date?.startsWith("<")) query.set("to", new Date(Date.parse(date.slice(1)) - 86400000).toISOString().slice(0, 10));
|
|
402
|
+
else if (date) { query.set("from", date);query.set("to", date); }
|
|
403
|
+
else if (days !== "all") query.set("days", days);
|
|
404
|
+
if (date || days !== "all") query.set("time_zone", Intl.DateTimeFormat().resolvedOptions().timeZone);
|
|
399
405
|
const data = await readDashboard(`/_ccdx/ui/usage${query.size ? `?${query}` : ""}`, { signal, source: "local_usage_log" });
|
|
400
406
|
if (!data.total || !Array.isArray(data.rows) || (mode === "analytics" && (!Array.isArray(data.analytics?.days) || !data.analytics.days.length))) throw new Error("Invalid usage snapshot");
|
|
401
407
|
return data;
|
|
@@ -495,12 +501,17 @@ element("usage-analytics").addEventListener("toggle", () => {
|
|
|
495
501
|
if (element("usage-analytics").open) usageView.revealChart();else usageView.stopMotion();
|
|
496
502
|
if (element("usage-analytics").open) dashboardRefresh.refresh("usage");
|
|
497
503
|
});
|
|
498
|
-
for (const id of ["analytics-
|
|
504
|
+
for (const id of ["analytics-metric", "analytics-view"]) element(id).addEventListener("change", () => {
|
|
499
505
|
renderAnalytics();
|
|
500
506
|
if (usageView.data && usageView.selectedDate) renderUsageTable();
|
|
501
507
|
});
|
|
508
|
+
for (const id of ["analytics-model", "analytics-range"]) element(id).addEventListener("change", () => {
|
|
509
|
+
if (id === "analytics-range" && usageView.selectedDate) { const range = element(id).value;selectUsageDay("", { refresh: false });element(id).value = range; }
|
|
510
|
+
renderAnalytics();if (usageView.data && !usageView.data.filters) renderUsageTable();
|
|
511
|
+
dashboardRefresh.invalidate("usage");void dashboardRefresh.refresh("usage", { force: true });
|
|
512
|
+
});
|
|
502
513
|
element("clear-usage-day").addEventListener("click", () => selectUsageDay(""));
|
|
503
|
-
element("usage-provider")?.addEventListener("change", () => { dashboardRefresh.invalidate("usage");dashboardRefresh.refresh("usage", { force: true }); });
|
|
514
|
+
element("usage-provider")?.addEventListener("change", () => { selectUsageDay("", { refresh: false });element("analytics-model").value = "";dashboardRefresh.invalidate("usage");dashboardRefresh.refresh("usage", { force: true }); });
|
|
504
515
|
element("refresh-models").addEventListener("click", loadModels);
|
|
505
516
|
element("refresh-usage").addEventListener("click", loadUsage);
|
|
506
517
|
for (const link of document.querySelectorAll("[data-source-link]")) link.addEventListener("click", () => {
|
package/src/dashboard/usage.js
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
}).join(" ");
|
|
8
8
|
}
|
|
9
9
|
|
|
10
|
-
function create({ time, element, phrase, localize, text, finite, number, mib, tableRow, emptyTable, document, navigator, modelLabel = value => value, motionAllowed = () => false }) {
|
|
10
|
+
function create({ time, element, phrase, localize, text, finite, number, mib, tableRow, emptyTable, document, navigator, modelLabel = value => value, usageChanged = () => {}, motionAllowed = () => false }) {
|
|
11
11
|
function usageValues(row) {
|
|
12
12
|
const rate = Number.isFinite(row.cache_hit_rate) && row.cache_hit_rate >= 0 && row.cache_hit_rate <= 1
|
|
13
13
|
? `${row.cache_hit_rate_partial ? "~" : ""}${(row.cache_hit_rate * 100).toFixed(1)}%` : "—";
|
|
@@ -17,6 +17,7 @@
|
|
|
17
17
|
let usageData = null;
|
|
18
18
|
let analyticsSignature, calendarSignature;
|
|
19
19
|
let selectedUsageDate = "";
|
|
20
|
+
let previousRange = "all";
|
|
20
21
|
let dailySignature, dailySelection, chartVisible = false, motionPending = false;
|
|
21
22
|
let motionTargets = [];
|
|
22
23
|
const animations = new Set();
|
|
@@ -103,18 +104,20 @@
|
|
|
103
104
|
}
|
|
104
105
|
|
|
105
106
|
function renderUsageTable() {
|
|
106
|
-
const day = selectedUsageDate && usageData.analytics?.days.find((entry) => entry.date === selectedUsageDate);
|
|
107
|
+
const day = !usageData.filters && selectedUsageDate && usageData.analytics?.days.find((entry) => entry.date === selectedUsageDate);
|
|
107
108
|
const model = element("analytics-model").value;
|
|
108
109
|
const total = day ? { ...analyticsPoint(day, model), model: "TOTAL" } : usageData.total;
|
|
109
110
|
const rows = day ? day.models.filter((row) => !model || row.model === model).sort((a, b) => b.total_tokens - a.total_tokens || a.model.localeCompare(b.model)) : usageData.rows;
|
|
110
111
|
const body = element("usage-body");
|
|
111
112
|
body.replaceChildren();
|
|
112
113
|
if (total.requests > 0) {
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
114
|
+
for (const [index, row] of [total, ...rows].entries()) {
|
|
115
|
+
const entry = tableRow(usageValues(row), { total: index === 0 });
|
|
116
|
+
localize(entry.children[7], "usage_cache_coverage", { known: number(row.cache_hit_known_requests), unknown: number(row.cache_hit_unknown_requests) }, "title");body.append(entry);
|
|
117
|
+
}
|
|
118
|
+
} else { emptyTable("usage-body", 8, usageData.filters ? "usage_empty_selection" : "no_usage_records"); }
|
|
119
|
+
element("clear-usage-day").hidden = !selectedUsageDate;
|
|
120
|
+
renderUsageState();
|
|
118
121
|
text("usage-note", "records_records_shown_of_models_models_shown_day", {
|
|
119
122
|
records: number(total.requests), shown: number(rows.length), models: number(day ? rows.length : usageData.model_count),
|
|
120
123
|
day: day ? phrase("zone_model", { zone: usageData.analytics.time_zone, model: model ? modelLabel(model) : phrase("all_models") }) : "",
|
|
@@ -122,17 +125,29 @@
|
|
|
122
125
|
}
|
|
123
126
|
|
|
124
127
|
function renderUsageState() {
|
|
125
|
-
text("usage-state",
|
|
128
|
+
if (selectedUsageDate.startsWith("<")) text("usage-state", "usage_earlier_before", { date: selectedUsageDate.slice(1) });
|
|
129
|
+
else text("usage-state", selectedUsageDate || "local_log");
|
|
126
130
|
}
|
|
127
131
|
|
|
128
132
|
function analyticsPoint(day, model) {
|
|
133
|
+
if (usageData?.filters) return day;
|
|
129
134
|
return model ? day.models.find((row) => row.model === model) || { requests: 0, input_tokens: 0, output_tokens: 0 } : day;
|
|
130
135
|
}
|
|
131
136
|
|
|
132
|
-
function selectUsageDay(date) {
|
|
137
|
+
function selectUsageDay(date, { refresh = true } = {}) {
|
|
138
|
+
const select = element("analytics-range");
|
|
139
|
+
const hadDate = Boolean(selectedUsageDate);
|
|
140
|
+
if (date && !selectedUsageDate) previousRange = select.value;
|
|
133
141
|
selectedUsageDate = date;
|
|
142
|
+
for (const option of [...select.children]) if (option.value === "date") option.remove();
|
|
143
|
+
if (date) {
|
|
144
|
+
const option = document.createElement("option");option.value = "date";
|
|
145
|
+
if (date.startsWith("<")) localize(option, "usage_earlier_before", { date: date.slice(1) });else option.textContent = date;
|
|
146
|
+
select.append(option);select.value = "date";
|
|
147
|
+
} else if (hadDate) select.value = previousRange;
|
|
134
148
|
renderUsageTable();
|
|
135
149
|
renderAnalytics();
|
|
150
|
+
if (refresh) usageChanged();
|
|
136
151
|
}
|
|
137
152
|
|
|
138
153
|
function dayButton(day, point) {
|
|
@@ -142,10 +157,10 @@
|
|
|
142
157
|
button.setAttribute("aria-pressed", String(day.date === selectedUsageDate));
|
|
143
158
|
const description = !day.available ? phrase("no_retained_history")
|
|
144
159
|
: phrase("calls_recorded_calls_input_input_output_output_cached_cached_inc", {
|
|
145
|
-
|
|
160
|
+
calls: number(point.requests), input: number(point.input_tokens), output: number(point.output_tokens), cached: number(point.cache_read_tokens), partial: point.tokens_partial ? phrase("partial_token_counts") : "",
|
|
146
161
|
});
|
|
147
|
-
for (const attribute of ["title", "aria-label"]) localize(button, "date_description", { date: day.date, description }, attribute);
|
|
148
|
-
button.addEventListener("click", () => selectUsageDay(day.date));
|
|
162
|
+
for (const attribute of ["title", "aria-label"]) localize(button, "date_description", { date: day.date === "earlier" ? phrase("usage_earlier_before", { date: day.before }) : day.date, description }, attribute);
|
|
163
|
+
button.addEventListener("click", () => selectUsageDay(day.date === "earlier" ? "<" + day.before : day.date));
|
|
149
164
|
return button;
|
|
150
165
|
}
|
|
151
166
|
|
|
@@ -158,13 +173,14 @@
|
|
|
158
173
|
if (signature === analyticsSignature) return;
|
|
159
174
|
analyticsSignature = signature;
|
|
160
175
|
const days = analytics.days;
|
|
161
|
-
const
|
|
176
|
+
const range = element("analytics-range").value === "date" ? previousRange : element("analytics-range").value;
|
|
177
|
+
const daily = usageData.filters ? [...(analytics.earlier ? [analytics.earlier] : []), ...days] : range === "all" ? days : days.slice(-Number(range));
|
|
162
178
|
const maximum = Math.max(1, ...daily.map((day) => {
|
|
163
179
|
const point = analyticsPoint(day, model);
|
|
164
180
|
return point.input_tokens + point.output_tokens;
|
|
165
181
|
}));
|
|
166
182
|
renderDaily(daily, model, maximum);
|
|
167
|
-
text("daily-from", daily[0].date);
|
|
183
|
+
text("daily-from", daily[0].date === "earlier" ? "usage_earlier" : daily[0].date);
|
|
168
184
|
text("daily-to", analytics.to);
|
|
169
185
|
if (commonSignature === calendarSignature) return;
|
|
170
186
|
calendarSignature = commonSignature;
|
|
@@ -174,7 +190,7 @@
|
|
|
174
190
|
return metric === "tokens" ? point.input_tokens + point.output_tokens : point.requests;
|
|
175
191
|
};
|
|
176
192
|
const peak = Math.max(1, ...days.map(value));
|
|
177
|
-
text("activity-scale", "metric_peak_peak", { metric: phrase(metric === "tokens" ? "input_output" : "
|
|
193
|
+
text("activity-scale", "metric_peak_peak", { metric: phrase(metric === "tokens" ? "input_output" : "recorded_usage"), peak: number(peak === 1 && days.every((day) => value(day) === 0) ? 0 : peak) });
|
|
178
194
|
const calendar = element("activity-calendar");
|
|
179
195
|
calendar.replaceChildren();
|
|
180
196
|
const offset = (new Date(`${days[0].date}T00:00:00Z`).getUTCDay() + 6) % 7;
|
|
@@ -205,7 +221,7 @@
|
|
|
205
221
|
calendar.append(button);
|
|
206
222
|
}
|
|
207
223
|
text("analytics-note", "zone_from_to_retained_history_starts_first_oldest_day_may_be_par", {
|
|
208
|
-
zone: analytics.time_zone, from: daily[0].date, to: analytics.to, first: analytics.first_date || phrase("unknown"),
|
|
224
|
+
zone: analytics.time_zone, from: analytics.earlier ? analytics.first_date : daily[0].date, to: analytics.to, first: analytics.first_date || phrase("unknown"),
|
|
209
225
|
excluded: analytics.undated_records ? phrase("count_records_with_invalid_future_timestamps_excluded", { count: number(analytics.undated_records) }) : "",
|
|
210
226
|
limit: analytics.models_truncated ? phrase("model_filters_limited_to_100_all_model_totals_include_the_remain") : "",
|
|
211
227
|
});
|
|
@@ -216,7 +232,7 @@
|
|
|
216
232
|
const select = element("analytics-model");
|
|
217
233
|
const previous = select.value;
|
|
218
234
|
select.replaceChildren();
|
|
219
|
-
for (const model of [...new Set(["", ...usageData.analytics
|
|
235
|
+
for (const model of [...new Set(["", ...(usageData.available_models || usageData.analytics?.models || []), ...(previous ? [previous] : [])])]) {
|
|
220
236
|
const option = document.createElement("option");
|
|
221
237
|
option.value = model;
|
|
222
238
|
if (model) option.textContent = modelLabel(model);
|
|
@@ -228,10 +244,10 @@
|
|
|
228
244
|
|
|
229
245
|
function applyUsage(data, { changed }) {
|
|
230
246
|
const sameProvider = (data.provider || "all") === (usageData?.provider || "all");
|
|
231
|
-
if (!sameProvider
|
|
247
|
+
if (!sameProvider && selectedUsageDate) selectUsageDay("", { refresh: false });
|
|
232
248
|
usageData = { ...data, ...(!data.analytics && sameProvider && usageData?.analytics ? { analytics: usageData.analytics } : {}) };
|
|
233
249
|
if (changed) {
|
|
234
|
-
if (data.analytics) updateAnalyticsModels();
|
|
250
|
+
if (data.available_models || data.analytics) updateAnalyticsModels();
|
|
235
251
|
renderUsageTable();
|
|
236
252
|
if (data.analytics) renderAnalytics();
|
|
237
253
|
}
|