Skip to content

Commit 730f968

Browse files
committed
centralize table definions
1 parent e1b27db commit 730f968

3 files changed

Lines changed: 14 additions & 180 deletions

File tree

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "copilot-token-tracker",
33
"displayName": "Copilot Token Tracker",
44
"description": "Shows daily and monthly (estimated) GitHub Copilot token usage stats in VS Code status bar",
5-
"version": "0.0.8",
5+
"version": "0.0.9",
66
"publisher": "RobBos",
77
"engines": {
88
"vscode": "^1.108.0"

src/webview/details/main.ts

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -219,8 +219,8 @@ function buildMetricsSection(
219219
{ label: 'Tokens', icon: '🟣', color: '#c37bff', today: formatNumber(stats.today.tokens), month: formatNumber(stats.month.tokens), projected: formatNumber(projections.projectedTokens) },
220220
{ label: 'Est. Cost (USD)', icon: '🪙', color: '#ffd166', today: formatCost(stats.today.estimatedCost), month: formatCost(stats.month.estimatedCost), projected: formatCost(projections.projectedCost) },
221221
{ label: 'Sessions', icon: '📅', color: '#66aaff', today: formatNumber(stats.today.sessions), month: formatNumber(stats.month.sessions), projected: formatNumber(projections.projectedSessions) },
222-
{ label: 'Avg Interactions', icon: '💬', color: '#8ce0ff', today: formatNumber(stats.today.avgInteractionsPerSession), month: formatNumber(stats.month.avgInteractionsPerSession), projected: '—' },
223-
{ label: 'Avg Tokens', icon: '🔢', color: '#7ce38b', today: formatNumber(stats.today.avgTokensPerSession), month: formatNumber(stats.month.avgTokensPerSession), projected: '—' },
222+
{ label: 'Avg Interactions/session', icon: '💬', color: '#8ce0ff', today: formatNumber(stats.today.avgInteractionsPerSession), month: formatNumber(stats.month.avgInteractionsPerSession), projected: '—' },
223+
{ label: 'Avg Tokens/session', icon: '🔢', color: '#7ce38b', today: formatNumber(stats.today.avgTokensPerSession), month: formatNumber(stats.month.avgTokensPerSession), projected: '—' },
224224
{ label: 'Est. CO₂ (g)', icon: '🌱', color: '#7fe36f', today: `${formatFixed(stats.today.co2, 2)} g`, month: `${formatFixed(stats.month.co2, 2)} g`, projected: `${formatFixed(projections.projectedCo2, 2)} g` },
225225
{ label: 'Est. Water (L)', icon: '💧', color: '#6fc3ff', today: `${formatFixed(stats.today.waterUsage, 3)} L`, month: `${formatFixed(stats.month.waterUsage, 3)} L`, projected: `${formatFixed(projections.projectedWater, 3)} L` },
226226
{ label: 'Tree Equivalent (yr)', icon: '🌳', color: '#9de67f', today: stats.today.treesEquivalent.toFixed(6), month: stats.month.treesEquivalent.toFixed(6), projected: projections.projectedTrees.toFixed(4) }
@@ -286,7 +286,8 @@ function buildEditorUsageSection(stats: DetailedStats): HTMLElement | null {
286286
const headers = [
287287
{ icon: '📝', text: 'Editor' },
288288
{ icon: '📅', text: 'Today' },
289-
{ icon: '📈', text: 'This Month' }
289+
{ icon: '📈', text: 'This Month' },
290+
{ icon: '🌍', text: 'Projected Year' }
290291
];
291292
headers.forEach((h, idx) => {
292293
const th = document.createElement('th');
@@ -307,6 +308,8 @@ function buildEditorUsageSection(stats: DetailedStats): HTMLElement | null {
307308
const monthUsage = stats.month.editorUsage[editor] || { tokens: 0, sessions: 0 };
308309
const todayPercent = todayTotal > 0 ? (todayUsage.tokens / todayTotal) * 100 : 0;
309310
const monthPercent = monthTotal > 0 ? (monthUsage.tokens / monthTotal) * 100 : 0;
311+
const projectedTokens = Math.round(calculateProjection(monthUsage.tokens));
312+
const projectedSessions = Math.round(calculateProjection(monthUsage.sessions));
310313

311314
const tr = document.createElement('tr');
312315
const labelTd = document.createElement('td');
@@ -327,7 +330,13 @@ function buildEditorUsageSection(stats: DetailedStats): HTMLElement | null {
327330
const monthSub = el('div', 'muted', `${formatPercent(monthPercent)} · ${monthUsage.sessions} sessions`);
328331
monthTd.append(monthSub);
329332

330-
tr.append(labelTd, todayTd, monthTd);
333+
const projTd = document.createElement('td');
334+
projTd.className = 'value-right align-right';
335+
projTd.textContent = formatNumber(projectedTokens);
336+
const projSub = el('div', 'muted', `${projectedSessions} sessions`);
337+
projTd.append(projSub);
338+
339+
tr.append(labelTd, todayTd, monthTd, projTd);
331340
tbody.append(tr);
332341
});
333342

src/webviewTemplates.ts

Lines changed: 0 additions & 175 deletions
This file was deleted.

0 commit comments

Comments
 (0)