Skip to content

feat(telemetry): pick the Telemetry panel's time window - #16031

Merged
iamwhatever merged 1 commit into
kirodotdev:mainfrom
Pearcekieser:feat/telemetry-time-range
Oct 12, 2026
Merged

iamwhatever merged 1 commit into
kirodotdev:mainfrom
Pearcekieser:feat/telemetry-time-range

Conversation

@Pearcekieser

@Pearcekieser Pearcekieser commented Oct 1, 2026 •

Copy link
Copy Markdown
Contributor

Problem / Motivation

Goal: Let the reader of Developer > Telemetry pick the time span the panel reports on, from 24 hours to 90 days or any custom pair of dates.

Every card on the panel used a window fixed in code. Spend showed 7 days; context occupancy and the OTEL cards (health strip, latency, startup) showed 14. There was no way to ask what last month cost, or to look at one bad week in September.

Why it matters

Spend questions are rarely "the last 7 days". People ask about a sprint, a month, or the week a model switched. Today they read shard files by hand to answer that. The two fixed windows also put a 7-day spend total beside a 14-day turn count with no shared span; one pick now gives every card the same span.

Not a goal

  • Changing any card's default window. With no pick, every card shows what it shows on main.
  • Changing retention. The per-turn usage shards are never pruned; metric shards keep following telemetry.retention_days.
  • The per-session context trace route (/api/telemetry/context-trace). It serves the Context breakdown pages, not this panel, and keeps its 14-day lookback.
  • The Sessions table's spend column. It keeps main's fixed 7-day window (see the design note below).
  • Group by folder. That is a separate PR.

What changed (motivation → approach → change)

Piece Behaviour
Period control One control above the panel: Default, 24h, 7d, 14d, 30d, 90d, or Custom with start and end date pickers. The choice and the custom dates persist in localStorage. With nothing stored the control sits on Default. Its segments are sized to their labels, so the control is one row at desktop and 390px widths and wraps only when the row does not fit (German at 320px). Until a new pick's figures arrive, the old ones stay up and a "Loading telemetry…" line shows under the control. That line has its own fixed-height row that is always rendered (only its text comes and goes), so the cards do not move when a pick starts or finishes loading.
Default Sends no window parameters, so each card keeps main's window: spend 7 days, context and OTEL cards 14. Each card titles itself with its own window ("Last 7d" on spend, "Last 14d" on the health strip). The first pick applies to every card.
GET /api/telemetry/startup Takes days=N (rolling, ends now) or since/until in epoch seconds. The panel sends local midnights, so the browser's timezone decides what a day is. A named window drives every block. With no parameters the answer is main's: OTEL and context over 14 days, spend over 7, flagged window_default: true with cost_window_days.
GET /api/usage/turns Reads the same parameters and echoes the clamped days (no start/end echo; nothing reads one). A session row's turn drill-down is fetched over the bounds the panel payload reports it measured, not over the request, so it lists the turns that row summed. On Default it reads the spend week.
Clamping Never refuses. A rolling days is at least 1 day and at most 90 (MAX_WINDOW_DAYS); a fixed start is clamped to 90 days back, the end to now. Inverted ranges are swapped and an empty one becomes the day before its end. The custom picker offers start days back to 89 days before today, so a picked range holds at most 90 whole dates, all inside the clamp. When a DST fall-back adds an hour to that span, the earliest day moves up one so its midnight stays inside the gateway's now - 90 x 24h floor. Emptying one date input resets only that date (start to a week before the end, end to today).
Reporting The payload echoes window_days, window_start, window_end and window_rolling. Card titles are built from those, so a clamped pick shows what was actually measured. When the window starts before telemetry.retention_days, a line under the control says so ("Turn, latency and startup figures cover only the last 14d; older metrics are deleted", naming the setting through SettingRef), and the health, latency and startup cards title themselves with the span the kept shards cover. The "OTEL sections · period:" footer names that same capped span, not the pick.

In src/kiro_crew/dashboard/handlers/usage.py, resolve_window is the one place that turns query parameters into a [start, end) window. cost_breakdown, context_occupancy, slot_turn_usage and the metric-shard aggregator take an optional until, so rows after the end of a past range are dropped too. Before, every reader only cut at the start. For a named window the metric reader in handlers/telemetry.py also filters each data point by its own time_unix_nano, because shard files cover a whole UTC day. That filter compares integers: the window's bounds are converted once to whole epoch nanoseconds (exact, through Fraction), and each point's timestamp is read with the exact integer reader, because a 2026 epoch in nanoseconds (~1.79e18) is past float's 2**53 range, where neighbouring floats are 256 ns apart. A point with no timestamp counts only when its shard's whole day is inside the window. On Default it counts every point of the picked shards, as main does. Spend still compares against the equal-length period right before the window, whichever way the window is anchored.

Design note: the Sessions table and the Spend card agree only on Default. On main, SPEND_WINDOW_DAYS was the one window both sums used, so they could not report different totals for one session. The Sessions table still gets its spend from slot_spend(), which the session-memory sampler calls with no arguments, so it always sums the last 7 days ending now. The Spend card's per-conversation rows come from cost_breakdown over the picked window. With 30d picked, a session's row on the Spend card counts 30 days of turns and its Sessions-table cell counts 7; with a past custom range the two can share no turns at all. Moving the Sessions table onto the panel's pick would need the pick on the server (the table is polled from a different page), so it stays out of this PR. The comment on SPEND_WINDOW_DAYS states the same narrowing.

Caches key on the window. A rolling window keys on its length, so the 5s poll keeps hitting the cache while "now" moves. A fixed range's end rounds up to the minute for the same reason. In website/src/pages/TelemetryPanel.tsx the query key carries the range too (preset and date math lives in pages/telemetryRange.ts, the client in website/src/api/client/telemetry.ts passes the range through), so a cached week is never served as a month.

website/src/components/SegmentedControl.tsx no longer gives each segment button its own z-index. Each button was a stacking context, so the moving highlight painted over the label of every segment it passed (picking 90d from 7d blanked "30d"). The radio group is now isolate and the labels sit above the highlight in one context. This touches every SegmentedControl; the one inline DOM golden that renders it is updated. The control also gains wrap="hug": the group wraps but keeps each segment at its content width and is no wider than its segments. The existing wrap (stretch to fill each row, used by the tag manager's policy picker) is unchanged.

The spec in docs/system-specs/modules/metrics.md and the feature-map row describe the new parameters. New strings are translated in all 12 catalogs under website/src/i18n/locales (en-XA regenerated), with translator notes in website/src/i18n/en.context.json. Existing strings keep main's wording. The new strings say "period" to match the control's label: range_label, the empty-panel line no_telemetry_in_window and the footer window_footer. telemetry.retention_days is added to the SettingRef schema fixture (website/src/test/fixtures/settingref-schema.json) so the retention line's setting reference resolves; the key already exists in the backend schema.

Backwards compatibility

Compatible. Both endpoints answer a request with no parameters exactly as main does, and the panel opens on Default, so no card's visible window changes until the reader picks one. days on /api/usage/turns is still accepted; its ceiling rises from 7 to 90. This widens the endpoint for every caller, not only the panel: any client of /api/usage/turns, apps included, can now read up to 90 days of turns and can pass a fixed since/until range. /api/telemetry/startup gains the fields window_start, window_end, window_rolling, window_default, cost_window_days and metrics_retention_days. The 90-day ceiling lives in one constant per side (MAX_WINDOW_DAYS in the gateway, MAX_RANGE_DAYS in the panel) and is not sent in the payload.

Tests

  • test/metrics/test_telemetry_time_window.py (new; every test runs on one pinned instant shared by the test and the handlers' time/datetime reads): resolve_window clamping for every out-of-range case including the one-day floor, both ends of a fixed range on each reader, the equal-length prior period, cache keys that differ per window, per-point filtering of metric shards (including points 1 ns before, at and after each bound of a 2026 range), the route handing one window to every block, a request with no window keeping main's 7-day spend and 14-day OTEL and context windows, and that request counting every point of the in-window shards (as main does) while an explicit days=14 drops the points past the window's start.
  • test/test_telemetry_handlers_cov80.py, test/metrics/test_usage_turns.py and two shard-stub fixtures follow the new signatures; the days clamp test keeps its 1 <= floor.
  • website/src/test/TelemetryPanel.timeRange.test.tsx (new; Date is pinned to one local instant for the panel and the expectations): the panel opens on Default with no window requested and per-card titles, a pick refetches with the right query and persists, custom ranges go out as epoch bounds and title the cards with their dates, the custom picker's earliest day keeps the range to 90 dates, clearing one date keeps the other, the control stays on screen when a window is empty, the loading line carries text only while a new pick is in flight and its row is the same element, with the same full-row fixed-height classes, before, during and after the load, and the retention line (with the setting reference kept clear of the brackets around it, the "cover only the last 14d; older metrics are deleted" wording and the day count said once), the capped card titles and the capped footer appear only when the window starts before the retention cut.
  • website/src/test/telemetryRange.test.ts (new): Default, preset and custom query building, the earliest custom day (including a New York DST fall-back night), the measured-window query, inclusive end dates, invalid dates.
  • TelemetryPanel.turnsDrilldown.test.tsx: the drill-down passes the measured window, keeps the shown window while a new pick loads, and reads the spend week on Default.
  • SegmentedControl.indicatorLayout.test.tsx: no segment button carries a z-index and the group is isolated.
  • SegmentedControl.wrapHug.test.tsx (new): wrap="hug" sizes segments to content and does not stretch the group; wrap still stretches. The panel test also checks the period control uses the content-sized form.

Manual verification

Earlier I rendered the built dist against payloads this machine's own stores produced through the new handler (7d, 30d, and 15 to 21 Sep): 453,214 credits for 30d against 227,585 for 7d. The screenshots below were captured on the current head: an isolated gateway from kiro_crew.testing.harness.spawn_feature_gateway (fixture minimal) serving this branch's built dist, with /api/telemetry/startup answered by fixture payloads so each state (retention cut, empty window, in-flight pick) can be shown on demand. During the in-flight captures the script read the top of the first card before the click, while the response was held, and after it landed: 182.6px at all three points at 1280px, and 267.8px at all three at 390px, so the loading line no longer moves the cards.

Screenshots / video

Default, as the panel opens. Spend says "Last 7d" and the health strip "Last 14d", as on main:

Telemetry panel on Default

Custom range, 12 to 18 Sep. Every card title names the dates:

Telemetry panel, custom range

30d on an install with telemetry.retention_days = 14. The line under the control says the OTEL figures stop at 14 days:

Telemetry panel, 30d window with the retention line

A 24h pick with nothing recorded keeps the control on screen:

Telemetry panel, empty 24h window

In-flight pick, 390px, German at 320px, full height with footer

90d clicked from 30d with its response held: the highlight sits on 90d, every other label stays readable, the figures are still 30d's and the loading line is shown:

Telemetry panel while a 90d pick loads

The same at 390px:

Telemetry panel at 390px while a 90d pick loads

Default at 390px:

Telemetry panel on Default at 390px

Telemetry panel in German at 320px, control wrapped to two rows

7d, full height, footer naming the period:

Telemetry panel full height, footer naming the period

Telemetry off, Startup under the retention cap, Context on a custom range

Telemetry off with no usage data, 30d picked. The period control stays above the "Telemetry is off" notice:

Telemetry off notice with the period control on 30d

Telemetry off with local usage data, 30d picked. Credits and Context window title themselves "Last 30d" and the off banner sits below them:

Telemetry off with Spend and Context cards on 30d

The Startup tab with 30d picked and telemetry.retention_days = 14. The Session startup card and the footer say "Last 14d":

Startup tab on 30d capped to 14 days

The Context tab on a custom range, 12 to 18 Sep. The card title names the dates:

Context tab on a custom range

Related Issues

no linked issue: requested directly by the repo owner's team, no tracking issue filed.

Checklist

  • At most two commits (one is the norm), with a Conventional Commits title (feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)
  • Existing tests pass and new tests added for new functionality
  • Self-review completed; code follows project style guidelines
  • Documentation updated (if applicable)
  • No secrets, credentials, or internal references in the diff

@Pearcekieser
Pearcekieser requested a review from a team October 1, 2026 23:15
@Pearcekieser
Pearcekieser requested a review from a team as a code owner October 1, 2026 23:15
@Pearcekieser

Copy link
Copy Markdown
Contributor Author

Intent: Let the Telemetry panel reader choose the span every card reports on (24h to 90d presets or a custom date range), with each card labelled by the window the gateway actually measured.
Not a goal: changing shard retention, the per-session context-trace route, or adding new groupings.

@github-actions github-actions Bot added readiness: checking Automated validation is still running fork Pull request from a fork (external contributor) labels Oct 1, 2026
@github-actions

github-actions Bot commented Oct 2, 2026 •

Copy link
Copy Markdown
Contributor

Design Review (Opus 5.5, fork) — 🟡 CONCERNS

Design-level review of 2e3cdbe3789a8f059214219e0543647e42f5d8e1 via the fork AI-review pipeline — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS/CONCERNS are advisory.

Design-Verdict: CONCERNS

Default and the 14d pick both say "Last 14d" but can show different numbers, because Default counts whole shards and a pick filters each point.

Watch

  • Two meanings for one label. The patch sends Default through whole_shards=defaulted (no per-point cut) and a named window through span_ns (per-point time_unix_nano filtering). The cause is that Default counts every point in the oldest UTC-day shard, while a pick drops points older than 14×24h and untimed points from boundary days. The effect is that a user switching from Default to 14d sees the health, latency and startup totals drop with no visible change in the window. The PR's own test pins this: the same shard totals 111.0 on Default and 1.0 on ?days=14. Either label Default's span differently (for example "since , whole days"), or make the 14d pick read shards the same way as Default.
    Clears when: a Default card and the same card under a 14d pick either show the same total for the same data, or carry different titles that say why they differ.
  • Compatibility list may be cut off. The description is cut off inside ## Backwards compatibility ("Compati…"), so I can't fully check the take-away list. The patch drops the i18n keys days, d, window_last and no_telemetry_recorded_yet_in_the_last, and _COST_WINDOW_DAYS. Their only readers, in TelemetryPanel.tsx and the cov80 test, are changed in this patch. It also widens the app-facing /api/usage/turns from a 7-day to a 90-day ceiling and adds since/until to it, which apps reach through permissions.api.
    Clears when: the Backwards compatibility section fits under the description limit and names the app callers of /api/usage/turns, with why they still work under the wider ceiling.

[DESIGN-REVIEWED] 2e3cdbe

Description read

[DESCRIPTION-READ] 36a4c6a993e074f6bea9b71652be86039cccca5ac1d728f53ea63a6a7526955a

That sha256 names everything this verdict read: the PR description, plus the 1 evidence file(s) the workflow collected from it and handed this review. It covers that evidence because the media strip replaces every attachment URL with the same placeholder, so an edit swapping one attachment for another would leave the description's captured text identical while what this review judged changed. Recompute it with .github/scripts/pr-description-capture.sh over the same inputs; if it differs, the description or that evidence changed after this verdict was formed and any finding drawn from either is unproven.

@github-actions

github-actions Bot commented Oct 2, 2026 •

Copy link
Copy Markdown
Contributor

UX Review (Opus 5.5, fork) — 🟡 CONCERNS

UX-level review of 2e3cdbe3789a8f059214219e0543647e42f5d8e1 via the fork AI-review pipeline — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS/CONCERNS are advisory.

UX-Verdict: CONCERNS

"Default" doesn't say which span it covers: on the same screen it shows a 7-day spend card next to a 14-day health strip and footer.

Watch

  • "Default" is not a period anyone can read. The new segment range_default: "Default" sits beside "24h…90d", and choosing it gives each card a different span. In attachment-01, Credits says "Last 7d" while Throughput and the footer say "Last 14d". So the most common state, and the one a new user lands on, mixes two spans under one label, which is the confusion the PR says it removes. This hits every visit with nothing stored, and it misleads rather than failing outright. Smallest fix: name the mix in the label or a tooltip, e.g. "Default (7d spend · 14d other)". Or, without changing any card's data, add a one-line note under the control.
  • The retention line's punctuation breaks around the chip. In attachment-03 and attachment-12 the copy renders as "…older metrics are deleted ( ⟩_ telemetry.retention_days )." The mx-1 wrapper leaves loose brackets around a bordered chip. This shows on every pick wider than the retention setting. It's a cosmetic issue only. Fix: drop the brackets from otel_retention_cap and use "…are deleted after ." or similar.
  • Not seen by a first-time reader. The attachments show every new control and state: presets, Custom with date inputs, the loading line, the retention line, the empty period, telemetry off, and the German wrap at 320px. But this lane has no blind read, so nobody new to the product has checked whether "Period", "Default" and "OTEL sections · period:" make sense.

[UX-REVIEWED] 2e3cdbe

Description read

[DESCRIPTION-READ] 4e29ea4c9a58e27dac29db7511b1d987e08efb92fe009405dad1044312cc9b42

That sha256 names everything this verdict read: the PR description, plus the 16 evidence file(s) the workflow collected from it and handed this review. It covers that evidence because the media strip replaces every attachment URL with the same placeholder, so an edit swapping one attachment for another would leave the description's captured text identical while what this review judged changed. Recompute it with .github/scripts/pr-description-capture.sh over the same inputs; if it differs, the description or that evidence changed after this verdict was formed and any finding drawn from either is unproven.

@github-actions

github-actions Bot commented Oct 2, 2026 •

Copy link
Copy Markdown
Contributor

First Principles Review (Opus 5.5, fork) — ✅ PASS

Premise-level review of 2e3cdbe3789a8f059214219e0543647e42f5d8e1 via the fork AI-review pipeline — why this exists and whether the shipped surface is the smallest honest version. Updated in place on each push. A BLOCK verdict blocks PR readiness; PASS/CONCERNS are advisory.

First-Principles-Verdict: PASS

Check before merge: /api/usage/turns is an app-granted API, and its ceiling for app callers rises from 7 to 90 days (SPEND_WINDOW_DAYS → MAX_WINDOW_DAYS).

What this change ships

Inventory (10 items) — 10 justified

Intent: let a Telemetry panel reader choose the time span every card reports on (24h–90d or custom dates). ADDITION.

  1. A Period control above the panel (Default, 24h, 7d, 14d, 30d, 90d, Custom), remembered in localStorage — justified
  2. Custom start/end date pickers, limited to the 90-day clamp — justified
  3. /api/telemetry/startup accepts days or since/until and echoes the window it actually used — justified
  4. /api/usage/turns takes the same window and allows up to 90 days, for apps too — justified
  5. Default sends no window, so every card keeps main's 7d/14d — justified
  6. Metric points are now filtered by their own timestamp, and readers cut at the window's end — justified
  7. A notice under the control when the pick starts before telemetry.retention_days, and OTEL card titles name only the span they cover — justified
  8. Old figures stay up during a new pick, with a fixed-height "Loading" row — justified
  9. All SegmentedControls: the moving highlight no longer paints over other segments' labels; adds wrap="hug" — justified
  10. Empty-panel and footer strings reworded to "period" — justified

[FIRST-PRINCIPLES-REVIEWED] 2e3cdbe

Description read

[DESCRIPTION-READ] 55240f0f5238e99c354b61176dbbb68fc8890ce2b61a9bf02331eef67addd5d8

That sha256 names the PR description this verdict read. Recompute it with .github/scripts/pr-description-capture.sh; if it differs, the description changed after this verdict was formed and any finding drawn from the description is unproven.

@github-actions

github-actions Bot commented Oct 2, 2026 •

Copy link
Copy Markdown
Contributor

GPT 6.1 Review (fork) — ✅ no blocking findings

Reviewed 2e3cdbe3789a8f059214219e0543647e42f5d8e1 via the fork AI-review pipeline; updated in place on each push.

Review details

No findings.
[GPT-REVIEWED] 2e3cdbe

@github-actions

github-actions Bot commented Oct 2, 2026 •

Copy link
Copy Markdown
Contributor

Opus 5.5 Review (fork) — ✅ no blocking findings

Reviewed 2e3cdbe3789a8f059214219e0543647e42f5d8e1 via the fork AI-review pipeline; updated in place on each push.

Review details

No findings.

[OPUS-REVIEWED] 2e3cdbe

@github-actions github-actions Bot added readiness: action required A blocking check or review needs attention and removed readiness: checking Automated validation is still running labels Oct 2, 2026
@Pearcekieser
Pearcekieser force-pushed the feat/telemetry-time-range branch from c74ba85 to 82070d3 Compare October 2, 2026 01:30
@Pearcekieser

Copy link
Copy Markdown
Contributor Author
  • Feature map incorrectly makes context traces selectable

fixed in 82070d3: the telemetry row now says startup, spend and context occupancy follow the selectable window and the per-session context trace keeps its fixed window; it lists GET /api/usage/turns beside the startup and context-trace routes.

@Pearcekieser

Copy link
Copy Markdown
Contributor Author
  • Range selector overflows narrow localized layouts

fixed in 82070d3: the period SegmentedControl passes wrap, so its six segments flow onto extra rows instead of overflowing. Screenshot narrow-de-320.png in the PR body shows German at 320px on three rows.

@Pearcekieser

Copy link
Copy Markdown
Contributor Author
  • A new pick gives no in-flight sign on the data

fixed in 82070d3: while react-query serves the previous pick as placeholder data (isPlaceholderData), a role=status "Loading telemetry…" line shows beside the control and clears when the new window lands. Keyed on placeholder data, not isFetching, so the 5s poll does not flash it. Test: TelemetryPanel.timeRange 'says the figures are still the old pick while the new window loads'. Screenshot pending-90d.png.

@Pearcekieser

Copy link
Copy Markdown
Contributor Author
  • "Window" means time here but context size two tabs away

fixed in 82070d3: en range_label is now "Period", matching es/fr/de/it/pt/ru and the other catalogs, so "Window" on this panel only means context size.

@Pearcekieser

Copy link
Copy Markdown
Contributor Author
  • en range_label: "Window" → "Period"

fixed in 82070d3: en range_label reads "Period"; en-XA regenerated from it.

@Pearcekieser

Copy link
Copy Markdown
Contributor Author
  • otel_retention_cap: front-load the consequence

fixed in 82070d3: en reads "Turn, latency and startup figures reach back at most {{days}}d (telemetry.retention_days prunes older metrics)." All 12 catalogs carry the same consequence-first wording. Screenshot retention-cap-30d.png; empty-window.png and footer-full-height.png cover the other two evidence gaps.

@Pearcekieser

Copy link
Copy Markdown
Contributor Author
  • resolve_window comment names the wrong day on the double-floor collapse

fixed in 82070d3: the comment says the oldest legal day is what is left, and the docstring names that arm beside the day-before-its-end arm. Behaviour unchanged.

@Pearcekieser

Copy link
Copy Markdown
Contributor Author
  • Retention line compares retention to window length, not age

fixed in 82070d3: the line now shows when window_start is older than now minus telemetry.retention_days, so a 3-day range a month back gets it. New test 'says it for a short custom range that starts before retention'.

@Pearcekieser

Copy link
Copy Markdown
Contributor Author

Design and First Principles both asked whether raising the /api/usage/turns ceiling from 7 to 90 days is meant to reach manifest-granted app callers too. Yes. The route's scope check is unchanged: an app still reads only its own slots' rows, and the 90-day cap is the same MAX_WINDOW_DAYS the dashboard uses. The usage row store is never pruned, so before this change those apps were held to 7 days of history they already owned. No new data class becomes readable.

@github-actions github-actions Bot added readiness: checking Automated validation is still running readiness: action required A blocking check or review needs attention and removed readiness: action required A blocking check or review needs attention readiness: checking Automated validation is still running labels Oct 2, 2026
@Pearcekieser
Pearcekieser force-pushed the feat/telemetry-time-range branch from 82070d3 to 184e621 Compare October 2, 2026 02:15
@Pearcekieser

Copy link
Copy Markdown
Contributor Author
  • Placeholder data uses the newly requested drill-down range

fixed in 184e621: PanelWindowCtx.range now comes from the query whose payload is on screen. While react-query serves the previous pick as placeholder data, the panel keeps handing the drill-down the settled query, so its rows and the totals above describe one window. New test 'keeps an open drill-down on the window on screen while a new pick loads' fails on the old line.

@Pearcekieser

Copy link
Copy Markdown
Contributor Author
  • Untimestamped boundary-shard points escape the fixed window

fixed in 184e621: a point with no usable time_unix_nano is kept only when its shard's whole UTC day (capped at now) lies inside the span; a boundary day of a partial range drops it. A rolling window's span end is left open so today's shard still counts. Tests: test_aggregate_drops_points_outside_the_span (untimed point on a cut day dropped) and test_aggregate_keeps_untimed_points_when_their_whole_day_is_inside.

@Pearcekieser

Copy link
Copy Markdown
Contributor Author
  • No screenshot shows the period control on the "Telemetry is off" page

note: Acknowledged, no code change. With telemetry off the control drives the spend and context cards, which are recorded regardless of the switch, and the off notice already says the OTEL figures are not collected. A still of that page can be added if a maintainer wants it for the blind read.

@Pearcekieser

Copy link
Copy Markdown
Contributor Author
  • "Default" doesn't say what it shows

note: Kept, unchanged in a153a82, as in the replies on 8a7cb091cd80, 52ac55cf48b9 and 43eab76370c6 (first-principles d4a7d8b80b78 main-parity ruling).

@Pearcekieser

Copy link
Copy Markdown
Contributor Author
  • The footer's period sits under a Credits card with a different span

note: Kept. The footer begins "OTEL sections ·", so the period it names is scoped to those sections, and the Credits card titles its own span. On Default the two differ because they differ on main.

@Pearcekieser

Copy link
Copy Markdown
Contributor Author

No code change in this round. GPT and Opus have no findings on a153a82, and the five new advisory items get one reply each below.

SAST (Semgrep) failed on a finding in src/kiro_crew/apps/builtins/aws_control/crew/runtime/container_tests/test_sidecar_durability_gaps.py:4402 (test-bare-monkeypatch-undo). This PR doesn't touch that file. It came in on main with 27e7dfd (#13374), and the scan reports it here because it diffs the merge commit against an older baseline. It needs a fix on main, not in this PR.

@github-actions github-actions Bot added the merge conflict Branch has merge conflicts with its base — author must resolve before merge label Oct 8, 2026
@Pearcekieser
Pearcekieser force-pushed the feat/telemetry-time-range branch from a153a82 to a98bb05 Compare October 8, 2026 03:30
@Pearcekieser

Copy link
Copy Markdown
Contributor Author

Rebased on main as a98bb05, no behaviour change. The only conflict was the telemetry row in docs/feature-map/README.md: kept main's system row and this PR's telemetry row. Feature-map, catalog and metrics tests pass locally (1,059). SAST may still fail on main's #13374 test file, which this PR does not touch.

@github-actions github-actions Bot removed the merge conflict Branch has merge conflicts with its base — author must resolve before merge label Oct 8, 2026
@Pearcekieser

Copy link
Copy Markdown
Contributor Author

Rebased on main as 5575fad, no behaviour change. The only conflict was in website/src/i18n/en.context.json, where main added three Files-app keys next to this PR's seven telemetry keys; both sets are kept. The PR diff is unchanged at 34 files, +2214/-251, and i18n:check and test/metrics (976) pass locally. SAST may still fail on main's #13374 test file, which this PR does not touch.

@Pearcekieser

Copy link
Copy Markdown
Contributor Author

Replies to the round 14 reviews on 5575fad. The description changed and no code changed.

note: The UX Review BLOCK listed three evidence gaps, and the description now carries four stills that close them. They were captured from a build of 5575fad and sit in a new "Telemetry off, Startup under the retention cap, Context on a custom range" fold.

  • The bare "Telemetry is off" notice with 30d picked shows the period control above the notice.
  • The telemetry-off layout with local usage data on 30d shows Credits and Context window titled "Last 30d", with the off banner below them.
  • The Startup tab on 30d with telemetry.retention_days = 14 shows the Session startup card and the footer titled "Last 14d".
  • The Context tab on the 12 to 18 Sep custom range shows the card titled with those dates.

The "Default" label point under Watch was answered in earlier rounds and is kept as ruled.

note: First Principles item 7 is fixed in the description. Backwards compatibility now says that every caller of /api/usage/turns, apps included, can read up to 90 days and can pass a fixed since/until range.

note: First Principles item 6 is unchanged. The Design note in the description states the Spend card and Sessions table divergence and why moving the Sessions table onto the pick is out of scope. The review says it clears when a maintainer accepts it.

@Pearcekieser

Copy link
Copy Markdown
Contributor Author

Same-tree retrigger as d3a099a (tree identical to 5575fad, commit date only) so the UX lane reads the four stills added to the description at 10:16Z. It also reruns the Integration and E2E flakes. No code change.

@Pearcekieser

Copy link
Copy Markdown
Contributor Author

Rebased on main as 8e7ce91, no behaviour change. The only conflict was in website/src/i18n/en.context.json, where main added a terminal cursor key next to this PR's seven telemetry keys; both are kept. The PR diff is unchanged at 34 files, +2214/-251, and i18n:check and test/metrics (976) pass locally.

@Pearcekieser

Copy link
Copy Markdown
Contributor Author

issue (blocking, security): DST offset reuse in _shards_in_window cutoff

Upheld and fixed in e29df39. usage.py _shards_in_window now computes the window's first local day as datetime.fromtimestamp(end.timestamp() - days * 86400).astimezone().date(). The old (end - timedelta(days=days)).date() kept END's UTC offset, so a window whose start fell on the other side of a DST change picked the wrong local day and skipped that day's shard.

test/metrics/test_telemetry_time_window.py::test_token_shard_window_start_across_a_dst_change pins it. It sets TZ to EST5EDT,M3.2.0,M11.1.0 and asks for a 2-day window ending 2026-03-10 00:30 EDT, whose start is 2026-03-07 23:30 EST. It fails on 8e7ce91, which returns only the 03-08 shard, and passes with the fix. test/metrics, test_telemetry_handlers_cov80.py and test_session_memory.py pass locally (1,070).

The OTEL reader telemetry.py _shards_in_window does the same subtraction but in UTC, where there is no DST, so it is unchanged.

@Pearcekieser

Copy link
Copy Markdown
Contributor Author

Rebased on main as de86198, no behaviour change. The only conflict was the key lists in website/src/i18n/en.context.json, where main added an aboutPanel key next to this PR's seven telemetry keys; both are kept. i18n:check and the metrics tests pass locally.

@Pearcekieser

Copy link
Copy Markdown
Contributor Author

Rebased on main as 8b736c3, no behaviour change. The only conflict was the key lists in website/src/i18n/en.context.json, where main added pages.chatSidebar.crew_status_disabled next to this PR's seven telemetry keys; both are kept. i18n:check and the metrics plus telemetry time-window tests (977) pass locally.

@Pearcekieser

Copy link
Copy Markdown
Contributor Author
  • Spend totals disagree on screen

note (non-blocking): Accepted and deferred, unchanged since the round 12 replies. The Spend card follows the pick and the Sessions table's slot_spend() stays on 7 days, because putting the table on the pick needs the period sent to the server for that page, which is outside this PR. The design note in the description states the divergence, and First Principles item 6 asks a maintainer to accept it on the PR. 8b736c3 is a rebase on main with no behaviour change.

@Pearcekieser

Copy link
Copy Markdown
Contributor Author
  • App contract widened

note (non-blocking): Already listed. The description's "Backwards compatibility" section says the days ceiling on /api/usage/turns rises from 7 to 90, that this widens the endpoint for every caller including apps, and that any client can now pass a fixed since/until range. The 90-day ceiling is one constant per side (MAX_WINDOW_DAYS in the gateway, MAX_RANGE_DAYS in the panel).

@Pearcekieser

Copy link
Copy Markdown
Contributor Author
  • "Default" is the one option that names no span

note (non-blocking): Kept, as in the replies on earlier heads. Default reproduces main's panel exactly: spend on 7 days and the other cards on 14, and each card titles its own span. Renaming it or adding a hint is a label decision for a maintainer, and First Principles ruled earlier that matching main on Default is justified. 8b736c3 is a rebase with no behaviour change.

@Pearcekieser

Copy link
Copy Markdown
Contributor Author
  • The figures can no longer be compared with the Sessions page after a pick

note (non-blocking): Accepted and deferred. This is the same divergence as First Principles item 6, which asks a maintainer to accept on the PR that the Spend card and the Sessions table may differ after a pick. The description's design note states it. Moving the Sessions table onto the pick needs the period on the server for that page and belongs in a follow-up.

@Pearcekieser

Copy link
Copy Markdown
Contributor Author
  • otel_retention_cap wording

nitpick (non-blocking, if-minor): Deferred. Readiness has passed on 8b736c3, and a push to reorder the sentence would reset every lane for a wording change. It can go in a follow-up with the other copy notes.

@Pearcekieser

Copy link
Copy Markdown
Contributor Author
  • Item 6: the SPEND_WINDOW_DAYS pin is rewritten

note (non-blocking): Left for a maintainer, as in the replies on earlier heads. The finding clears when a maintainer accepts on the PR that the Spend card and the Sessions table may disagree after a pick. Dropping the per-conversation rows on non-Default picks would remove the breakdown the period control exists to show. 8b736c3 is a rebase on main with no behaviour change.

@Pearcekieser

Copy link
Copy Markdown
Contributor Author

Rebased on main as 1e06531, no behaviour change. The only conflict was the key lists in website/src/i18n/en.context.json, where main added guide-layer keys next to this PR's seven telemetry keys; both are kept. i18n:check, the metrics tests (977) and the MarkdownRenderer golden DOM test pass locally.

@Pearcekieser

Copy link
Copy Markdown
Contributor Author

Regenerated src/kiro_crew/docs/ui-index.generated.json on the rebased head. Build Wheel, both Build Desktop jobs and E2E failed on 1e06531 because gen-ui-index.mjs --check found the committed index stale: the rebase merged main's new keys into en.context.json, which changes the index's input digest. The only change is the input_digest line; gen-ui-index.mjs --check passes locally and the branch is still one commit on main.

One window control at the top of the Developer > Telemetry panel drives
every card: presets (24h, 7d, 14d, 30d, 90d) or a custom start/end date.
GET /api/telemetry/startup and /api/usage/turns accept days or
since/until, clamp to a 90-day ceiling instead of refusing, and echo the
effective window so each card labels what it measured. Spend compares
against the equal-length period before the window; caches key on it.
@Pearcekieser

Copy link
Copy Markdown
Contributor Author

Rebased on main as 2e3cdbe, no behaviour change. Two conflicts, both resolved by keeping both sides: the key lists in website/src/i18n/en.context.json, and telemetry.ts, where main added a usageSeries call next to this PR's usageTurns range parameter. Main's #18793 fixed the i18n-render base-stamp failure that kept E2E red on d46b75f. Locally tsc, i18n:check, 1466 vitest tests and the 977 test/metrics tests pass.

@iamwhatever iamwhatever left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This PR adds one Period control to Developer > Telemetry (Default, 24h through 90d, or a custom date pair). It is backed by a single resolve_window in handlers/usage.py that turns days / since / until into a clamped [start, end), and every reader (cost_breakdown, context_occupancy, slot_turn_usage, the metric-shard aggregator) now cuts at the window's end as well as its start. I read all the backend and frontend production code at 2e3cdbe: telemetry.py, usage.py, TelemetryPanel.tsx, telemetryRange.ts, the API client and the SegmentedControl stacking fix. Default sends no parameters and keeps main's 7d spend and 14d OTEL and context windows, including the whole-shard read. I tried to break the clamp. NaN, inf, huge days, a far-past since, a future until and inverted or empty ranges all land inside the 90-day floor and the minute ceiling. Caches key on the window, so a week is never served as a month. The per-point nanosecond filter compares integers, and the drill-down refetches the bounds the payload reports it measured. The one security-relevant change is that the app-granted /api/usage/turns ceiling rises from 7 to 90 days and the route accepts since/until. I checked that the per-row app filter and the slot requirement are unchanged, so an app still reads only its own rows, which the store already keeps. Every open Design, UX and First Principles item has a disposition: Default-vs-14d boundary parity is kept for main parity, and the Sessions-table spend divergence is deferred and documented. Base is main, it is mergeable, checks and both code lanes are green, and nobody has requested changes. — crew-pr-reviewer (deep re-check)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

fork Pull request from a fork (external contributor)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants