feat(agents): input/output token split display per active session row#448
feat(agents): input/output token split display per active session row#448
Conversation
|
Bosun CI signal: Bosun-created PR currently has failing checks.
|
There was a problem hiding this comment.
Pull request overview
Adds input/output token split visibility across the UI by extending session payloads and analytics trend data, then rendering new token split stats and a token-split trend chart in Telemetry plus a per-session-row token pill in Agents.
Changes:
- Extend session insights normalization to recognize
inputTokens/outputTokens/totalTokensshapes and meta wrappers (meta.tokenUsage, etc.). - Add split token totals + token-split trend series to usage analytics and expose split token fields in session list payloads (API + TUI bridge).
- Render token split totals and a “Token Split Trend” chart in Telemetry; render an “In/Out” token split pill per active session row in Agents.
Reviewed changes
Copilot reviewed 11 out of 11 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| ui/tabs/telemetry.js | Adds token split lifetime stats and a token split trend panel. |
| site/ui/tabs/telemetry.js | Mirrors Telemetry token split UI additions for the site build. |
| ui/tabs/agents.js | Adds token split helper/renderer and displays it per active session row. |
| site/ui/tabs/agents.js | Adds the render call for token split in the mirrored Agents tab. |
| ui/styles/components.css | Adds styles for the token split pill. |
| tests/ui-server.test.mjs | Adds coverage ensuring session list payload includes split token fields; extends analytics expectations for split token trends. |
| lib/session-insights.mjs | Expands token usage normalization to accept camelCase token keys and meta wrappers. |
| site/lib/session-insights.mjs | Mirrors session insight normalization changes for the site build. |
| infra/tui-bridge.mjs | Normalizes session token fields in TUI session updates/events and aligns tokenCount with totalTokens. |
| infra/session-tracker.mjs | Includes split token fields in /api/sessions list entries from session insights. |
| server/ui-server.mjs | Adds daily and total input/output token aggregation to usage analytics trend payloads. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| <span class="fleet-slot-token-split" aria-label=${`Input ${usage.inputTokens} Output ${usage.outputTokens}`}> | ||
| <span class="fleet-slot-token-segment"><strong>In</strong> ${formatCompactCount(usage.inputTokens)}</span> | ||
| <span class="fleet-slot-token-divider">/</span> | ||
| <span class="fleet-slot-token-segment"><strong>Out</strong> ${formatCompactCount(usage.outputTokens)}</span> |
There was a problem hiding this comment.
formatCompactCount is used here but isn’t defined or imported in this module, which will throw at runtime when the token split is rendered. Import it (e.g., from ../modules/session-insights.js) or switch to an already-in-scope formatter.
| ${s.taskId ? ` · ${s.taskId}` : ""} | ||
| ${s.branch ? ` · ${s.branch}` : ""} | ||
| </div> | ||
| ${renderFleetEntryTokenSplit({ session: s })} |
There was a problem hiding this comment.
This adds a call to renderFleetEntryTokenSplit, but site/ui/tabs/agents.js doesn’t define/import that helper (nor the related token-usage helpers). Since site/ui/* is a mirrored build, this will crash when rendering the Agents tab; port the helper(s) and required imports into the site copy as well.
| .fleet-slot-token-split { | ||
| display: inline-flex; | ||
| align-items: center; | ||
| gap: 4px; | ||
| max-width: 100%; | ||
| padding: 2px 6px; | ||
| border: 1px solid var(--border); | ||
| border-radius: 999px; | ||
| background: var(--surface-1); | ||
| color: var(--text-secondary); | ||
| font-size: 10px; | ||
| line-height: 1.2; | ||
| white-space: nowrap; | ||
| } |
There was a problem hiding this comment.
These new styles support the token split pill, but the repository keeps ui/ and site/ui/ in sync for the shipped UI. Please mirror the same CSS into site/ui/styles/components.css (currently missing .fleet-slot-token-split etc.) so the site build renders consistently.
…oken-split-display-per
…oken-split-display-per
|
Bosun PR classification: Bosun-created.
|
Co-authored-by: bosun-ve[bot] <262908237+bosun-ve[bot]@users.noreply.github.com>
Co-authored-by: bosun-ve[bot] <262908237+bosun-ve[bot]@users.noreply.github.com>
Task-ID: e69d4710-8981-44c2-b6d8-641e638bfe4f\n\nAutomated PR for task e69d4710-8981-44c2-b6d8-641e638bfe4f\n\n---\n\nBosun-Origin: created