Skip to content

Account Token Activity: aggregate wide ranges without hiding gaps #57

Description

@thrr87

Parent: #46

Blocked by: #56
Parent user stories covered: 23, 26, 37–38, 56

Outcome

Wide Account Token Activity ranges remain readable and responsive by merging only adjacent compatible display intervals. Aggregation preserves exact totals and every real gap or Account Counter Break. Zooming recomputes the display from source intervals and reveals finer facts. Zero, missing, future, and selection semantics remain distinct for keyboard and assistive-technology users.

This issue is presentation-only over the finished source interval model. It must not mutate history or selected-range totals.

Existing code to start from

Measure the current chart before adding complex machinery. Use the smallest deterministic aggregation rule that keeps the existing UI responsive. No new dependency is justified.

Aggregation contract

  • Source intervals and exact selected-range total never change.
  • Only adjacent display-compatible intervals may merge.
  • A merged mark's token value is the exact sum of its members and its span is their outer start/end.
  • Never merge across missing time, future time, Account Counter Break, account partition, allowance-window boundary, lifetime/daily source-method boundary, or any other incompatibility already exposed by the source model.
  • Recompute display marks when visible range or zoom changes.
  • Zooming in must reveal finer source intervals when the available width permits.
  • Do not synthesize values inside a real gap.
  • Selected detail must either identify the exact source interval or truthfully identify an aggregated display interval and expose its combined total/span. Do not pretend an aggregate is one raw reading interval.

Accessibility contract

  • Observed zero is announced as an observed zero-token interval.
  • Missing time is announced/described as missing observations, not zero.
  • Future Current-window space is described as future/no observation, not missing historical data.
  • Positive interval details include token total, start, end, and source.
  • Keyboard users can reach visible interval marks and previous/next controls in chronological order.
  • Visual distinctions cannot rely on color alone.

Acceptance criteria

  • Aggregated and unaggregated source intervals have identical total tokens.
  • Every source break/gap remains a break/gap after aggregation.
  • Reversing input order does not change display output.
  • Zoom-in increases or preserves interval detail and never fills gaps.
  • Zoom-out may reduce mark count without changing source snapshots.
  • Selection details remain truthful for aggregated marks.
  • Zero, missing, future, and positive intervals have distinct reader-visible and accessibility descriptions.
  • Visual zero markers and empty spaces remain distinguishable without color alone.
  • Existing Current-window future emptiness remains intact.
  • No persistence or token math changes.

Required tests

Create deterministic interval fixtures with adjacent compatible intervals, gaps, counter breaks, source-method changes, zeros, and future space. Compare totals and break positions before/after aggregation and across two zoom levels. Add keyboard order and accessibility-label assertions.

One focused view test must cover: Current-window so far, observed zero, missing space, future space, interval selection, and a specific unavailable reason.

Run:

swift test --filter AnalyticsWorkspaceTests

swift test --filter UsageIntelligenceEngineTests

If a performance check is needed, keep it deterministic and local to the aggregation function; do not add a benchmark framework.

Documentation

Update only chart aggregation, zoom, and accessibility semantics.

Out of scope

  • Rewriting source history.
  • Predicting tokens inside intervals.
  • New charting dependencies.
  • General redesign of other analytics graphs.
  • Performance work without a failing test or measured problem.

Shared delivery contract

  • Implement only on the shared analytics-fixes branch and reuse all earlier completed commits.
  • Keep this issue as one isolated commit whose message references the issue number.
  • Do not create another branch or pull request. Do not merge, tag, publish, or release.
  • Do not close the issue manually.
  • Preserve unrelated changes and avoid refactors outside this scope.
  • Add no dependency, persistence format, feature flag, protocol, or speculative abstraction.
  • Run the focused checks before committing; full-suite and integrated UI verification happen after all child issues.
  • Scan touched UI text for debug/TODO/internal implementation leaks.

Handoff evidence

Report commit hash, files, commands/results, each criterion pass/fail, and remaining risk.

Metadata

Metadata

Assignees

No one assigned

    Labels

    ready-for-agentReady for implementation by an agent

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions