Repository navigation
feat(abctl): Identity banner + token columns + plugin state helpers - #374
Merged
Merged
Conversation
Three cohesive additions to the session-observability layer:
1. abctl IDENTITY banner on the events pane. Caller identity (subject /
client / scopes) now shows once at session level instead of repeating
on every event row. Scopes are truncated to 3 entries with "+N more"
so long scope lists don't overflow the banner. Banner only renders
when inbound identity is present, and its height is subtracted from
the events table height only when actually shown.
2. TOKENS column on the sessions and events panes. Server-side: add
TotalTokens to SessionSummary, aggregated in ListSessions via a new
sumTokens helper that walks inference response events. Client-side:
sessions pane prefers the server total (authoritative, covers the full
backlog) and falls back to a client-side sum over cached events when
the server returned zero (older server compat). Events pane shows the
per-call total only on inference response rows. Both use a shared
formatCount helper in util.go for thousands separators.
3. pipeline.GetState[T] / pipeline.SetState[T] generic helpers for
plugin-private per-request state. Lets a new plugin stash typed data
on pctx.Extensions.Custom keyed by its Name() without extending the
core Extensions struct for every new plugin. Named typed slots (MCP,
A2A, Inference, ...) stay reserved for telemetry-worthy extensions
that flow onto the wire API; GetState/SetState covers everything
that's internal to a single plugin. Test file covers round-trip,
mutation visibility, wrong-type degradation, missing key, and
multi-plugin isolation.
Other cleanups:
- Drop "identity" from per-event detail render (banner supersedes it);
yank still writes the full wire JSON.
- Use a struct key {subject,clientID} for identity dedup instead of
"|"-concatenation.
- Add unit tests for sumTokens and ListSessions.TotalTokens.
Assisted-By: Claude (Anthropic AI) <noreply@anthropic.com>
Signed-off-by: Hai Huang <huang195@gmail.com>
formatCount(-100) .. formatCount(-999) produced "-,100" .. "-,999"
because the leading '-' was counted as a digit in the triplet math
(len("-abc") % 3 == 1 ⇒ wrote s[:1] = "-", then the loop added a
separator + "abc"). Same band-shape break hit 6-digit and 9-digit
negatives. Token counts are non-negative so there was no runtime
impact, but the helper was documented as handling negatives and will
be reused. Strip the sign up front, group the digits, and re-apply.
Added tui/util_test.go with a table covering the previously-broken
3/6-digit negatives and the paths that already worked, locking in the
contract.
Also widen the sessions-pane TOKENS column from 8 to 10: "1,234,567"
is 9 chars, so any session crossing 1M tokens (plausible for multi-
turn agentic runs) would truncate under width 8. The events-pane
TOKENS column stays at 8 — per-call totals rarely exceed 6 digits.
Assisted-By: Claude (Anthropic AI) <noreply@anthropic.com>
Signed-off-by: Hai Huang <huang195@gmail.com>
pdettori
approved these changes
May 6, 2026
pdettori
left a comment
Member
There was a problem hiding this comment.
Clean, well-structured PR. Three cohesive additions to the session-observability layer:
- Identity banner — proper struct-key dedup, height accounting guards minimum table size
- Token columns —
sumTokenscorrectly filters to inference response-phase events; sessions pane falls back to client-side sum for older-server compat GetState[T]/SetState[T]— nil-safe, type-safe generics with lazy map init; good separation between telemetry-worthy named slots and plugin-internal state
All CI green. Both commits DCO signed-off. Unit tests cover edge cases (negative formatCount, wrong-type degradation, multi-plugin isolation).
Assisted-By: Claude Code
3 of 9 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Three cohesive additions to the session-observability layer on top of the merged
abctlTUI (#372).1. IDENTITY banner on the events pane
Caller identity (
subject/client/scopes) now shows once at the session level instead of repeating on every event row. Scopes truncated to 3 entries with+N moreso long scope lists don't overflow. Banner only renders when inbound identity is present; table height accounts for it only when it renders.2.
TOKENScolumn on sessions + events panesTotalTokensfield onSessionSummary, aggregated inListSessionsviasumTokens().TotalTokensonly on inference response rows.formatCounthelper for thousands-separator display (1,203).3.
pipeline.GetState[T]/pipeline.SetState[T]— plugin-private per-request stateLets new plugins stash typed state on
pctx.Extensions.Customkeyed by plugin name, without extending the coreExtensionsstruct for every new plugin. Named typed slots (MCP, A2A, Inference, …) stay reserved for telemetry-worthy extensions that flow onto the wire API;GetState/SetStatecovers everything internal to a single plugin.Also
identityfrom per-event detail render (banner supersedes it); yank still writes the full wire JSON.{subject, clientID}for identity dedup instead of"|"-concatenation.sumTokens,ListSessions.TotalTokens,SetState/GetStateround-trip, mutation visibility, wrong-type degradation, missing key, multi-plugin isolation.Test plan
go test ./...inauthlibandcmd/abctl— all green.TOKENScolumn on sessions pane populates immediately (no drill-through needed).yankstill writes the full unfiltered event JSON to/tmp/abctl-event-*.json.Assisted-By: Claude (Anthropic AI) noreply@anthropic.com