Skip to content

change timing markers to be precise on the timeline #2775

Open
mitul-s wants to merge 1 commit into
mainfrom
ms/timing-markers
Open

change timing markers to be precise on the timeline #2775
mitul-s wants to merge 1 commit into
mainfrom
ms/timing-markers

Conversation

@mitul-s

@mitul-s mitul-s commented Jul 4, 2026

Copy link
Copy Markdown
Contributor

What

Makes the timing labels on the trace viewer timeline precise when zoomed in.

When the timeline is zoomed in far enough that the ruler's tick step drops below one second, the tick labels were formatted with whole-second precision. This produced duplicate, imprecise labels — e.g. a ~3s window with a 500ms step rendered 0s, 1s, 1s, 2s, 2s, 3s instead of distinct values. This PR scales each label's decimal precision to the tick step so every tick reads accurately.

Changes

  • computeTimeMarkers (new-trace-viewer/utils.ts) — derive fractionDigits from the tick interval. Steps >= 1s keep clean whole-second labels; sub-second steps use enough decimals to stay distinct (e.g. 500ms, 1.5s, 2.5s).
  • formatDurationPrecise (lib/utils.ts)
    • Added an optional fractionDigits argument (default 2) that controls both the number of decimals and the rounding granularity.
    • Trailing zeros are now trimmed, so 2.00s2s and 1.50s1.5s, while sub-second detail is preserved (1626ms1.63s, never 2s).
    • Dropped the fixed two-digit Intl.NumberFormat helper in favor of toFixed(fractionDigits).
  • Timeline gap labels & hover cursor label — switched from formatDuration to formatDurationPrecise so gap durations and the hovered-time indicator show the same precise values.

Tests

  • Added computeTimeMarkers tests covering sub-second, whole-second, and millisecond-zoom windows, asserting labels are distinct.
  • Added formatDurationPrecise tests for millisecond values, sub-second precision, trailing-zero trimming, the custom fractionDigits argument, and minute-plus decomposition.

Changeset

Patch release for @workflow/web-shared.

@mitul-s mitul-s requested review from a team and ijjk as code owners July 4, 2026 22:02
@changeset-bot

changeset-bot Bot commented Jul 4, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 60e16a7

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 16 packages
Name Type
@workflow/web-shared Patch
@workflow/web Patch
@workflow/cli Patch
@workflow/nitro Patch
workflow Patch
@workflow/world-testing Patch
@workflow/nuxt Patch
@workflow/core Patch
@workflow/builders Patch
@workflow/next Patch
@workflow/vitest Patch
@workflow/astro Patch
@workflow/nest Patch
@workflow/rollup Patch
@workflow/sveltekit Patch
@workflow/vite Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@vercel

vercel Bot commented Jul 4, 2026

Copy link
Copy Markdown
Contributor

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
example-nextjs-workflow-turbopack Ready Ready Preview, Comment Jul 4, 2026 10:02pm
example-nextjs-workflow-webpack Ready Ready Preview, Comment Jul 4, 2026 10:02pm
example-workflow Ready Ready Preview, Comment Jul 4, 2026 10:02pm
workbench-astro-workflow Ready Ready Preview, Comment Jul 4, 2026 10:02pm
workbench-express-workflow Ready Ready Preview, Comment Jul 4, 2026 10:02pm
workbench-fastify-workflow Ready Ready Preview, Comment Jul 4, 2026 10:02pm
workbench-hono-workflow Ready Ready Preview, Comment Jul 4, 2026 10:02pm
workbench-nitro-workflow Ready Ready Preview, Comment Jul 4, 2026 10:02pm
workbench-nuxt-workflow Ready Ready Preview, Comment Jul 4, 2026 10:02pm
workbench-sveltekit-workflow Ready Ready Preview, Comment Jul 4, 2026 10:02pm
workbench-tanstack-start-workflow Ready Ready Preview, Comment Jul 4, 2026 10:02pm
workbench-vite-workflow Ready Ready Preview, Comment Jul 4, 2026 10:02pm
workflow-swc-playground Ready Ready Preview, Comment Jul 4, 2026 10:02pm
workflow-tarballs Ready Ready Preview, Comment Jul 4, 2026 10:02pm
workflow-web Ready Ready Preview, Comment Jul 4, 2026 10:02pm

@vercel vercel Bot 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.

Additional Suggestion:

Old test file test/format-duration-precise.test.ts still asserts two-decimal output ("45.20s", "1m 0.00s") that no longer matches the trimmed-zero output of formatDurationPrecise, so pnpm test/CI fails.

Fix on Vercel

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant