Skip to content
This repository was archived by the owner on Aug 6, 2026. It is now read-only.

fix(autoresearch): clamp observed-time percentages before Progress - #3419

Closed
posthog[bot] wants to merge 1 commit into
mainfrom
posthog-code/clamp-progress-percentages
Closed

fix(autoresearch): clamp observed-time percentages before Progress#3419
posthog[bot] wants to merge 1 commit into
mainfrom
posthog-code/clamp-progress-percentages

Conversation

@posthog

@posthog posthog Bot commented Jul 14, 2026

Copy link
Copy Markdown
Contributor

Problem

The autoresearch observability panel (PostHog Code desktop app, /code/tasks/<id> detail route) throws a React validation error when the observed time for one activity kind exceeds the run's wall-clock duration.

TimeRow computes percentage = Math.round((value / total) * 100), where value is the per-kind observed time and total is the run's elapsed wall-clock time. The per-kind times are derived from event timestamps, which can drift ahead of the client clock (skew between agent-set timestamps and now), so the ratio can exceed 1 and produce a value like 112. Radix Progress rejects any value above its default max of 100 — it logs Invalid prop value ... supplied to Progress and renders an empty bar. Non-fatal, but noisy in error tracking and leaves the panel looking broken.

The same unclamped percentage pattern exists in UsageMeter, UsageButton, and UpdateAvailableModal.

Changes

  • Clamp the observed-time percentage to 0..100 (and guard a zero total) before passing it to Progress in AutoresearchObservability.
  • Apply the same defensive clamp in UsageMeter, UsageButton, and UpdateAvailableModal. In UsageMeter the displayed text still shows the true (possibly >100%) figure; only the progress bar value is clamped.
  • Add a test that reproduces the overflow (a live run whose latest tool timestamp sits ahead of now) and asserts every observed-time bar renders with an in-range aria-valuenow.

How did you test this?

  • Added AutoresearchObservability.test.tsx; confirmed it fails against the pre-fix code (bar renders with no aria-valuenow) and passes with the fix.
  • Ran the full autoresearch and billing test suites in packages/ui — 41 tests pass.
  • biome check clean on all changed files.

Automatic notifications

  • Publish to changelog?
  • Alert Sales and Marketing teams?

Created with PostHog Code from an inbox report.

Per-kind observed time in the autoresearch observability panel can exceed the
run's wall-clock duration (e.g. clock skew between agent-set event timestamps
and the client clock), pushing the computed percentage above 100. Radix
Progress rejects values over its default max and renders nothing plus a console
error.

Clamp the value to 0..100 before passing it to Progress, and guard against a
zero total. Apply the same defensive clamp to the other unclamped percentage
calculations in UsageMeter, UsageButton, and UpdateAvailableModal.

Generated-By: PostHog Code
Task-Id: 88b04cb6-418c-4e80-bf2f-8f8e8f5c3e18
@trunk-io

trunk-io Bot commented Jul 14, 2026

Copy link
Copy Markdown

Merging to main in this repository is managed by Trunk.

  • To merge this pull request, check the box to the left or comment /trunk merge below.

After your PR is submitted to the merge queue, this comment will be automatically updated with its status. If the PR fails, failure details will also be posted here

@github-actions

Copy link
Copy Markdown

React Doctor found no issues in the changed files. 🎉

Reviewed by React Doctor for commit cae58f9.

@charlesvien charlesvien added the stale No recent changes to PR label Jul 22, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

stale No recent changes to PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant