Skip to content

refactor(app): name the duration-heatmap number format - #3182

Open
alex-fedotyev wants to merge 1 commit into
mainfrom
alex/duration-heatmap-format
Open

alex-fedotyev wants to merge 1 commit into
mainfrom
alex/duration-heatmap-format

Conversation

@alex-fedotyev

@alex-fedotyev alex-fedotyev commented Sep 22, 2026 •

Copy link
Copy Markdown
Contributor

Summary

The significant-fields heatmap builds its number format inline as { output: 'duration', factor: 0.001 }. That 0.001 is not arbitrary: it is the milliseconds-to-seconds step the formatter needs, and it is only correct because the value expression came from getDurationMsExpression, which applies the source's durationPrecision and normalizes to milliseconds.

That pairing is worth naming, so this moves the literal to DURATION_HEATMAP_NUMBER_FORMAT in source.ts, next to the expression helper it belongs with, and documents the coupling. The next duration heatmap then gets the unit right by importing it instead of copying a bare factor.

No behavior change: same object, same value.

Test plan

  • Full app suite green (245 files, 3992 tests), plus tsc --noEmit and eslint with no new warnings.
  • Rendering is unchanged by construction: the constant is the same literal the call site built inline.

Independent of the rest of this series and targets main directly, so it can land in any order.

No UI or layout change. [ui-check: allow]

Notes

  • Internal refactor with no user-visible effect, so no changeset. [no-changeset: allow]

@vercel

vercel Bot commented Sep 22, 2026 •

Copy link
Copy Markdown

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

Project Deployment Actions Updated
hyperdx-oss Ready Ready Preview Sep 24, 2026 2:38am UTC
hyperdx-storybook Ready Ready Preview Sep 24, 2026 2:38am UTC

Request Review

@changeset-bot

changeset-bot Bot commented Sep 22, 2026 •

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: 887421b

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

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

@greptile-apps

greptile-apps Bot commented Sep 22, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerConfidence Score: 5/5

The PR appears safe to merge because the extraction preserves the existing typed format object and introduces no behavioral change.

Summary

This refactor names and documents the duration heatmap number format while preserving the existing formatting behavior.

  • Exports DURATION_HEATMAP_NUMBER_FORMAT beside the duration expression helper.
  • Replaces the equivalent inline format object with the shared constant.

Reviews (3) · Last reviewed commit: "refactor(app): name the duration-heatmap..."

@github-actions

github-actions Bot commented Sep 22, 2026 •

Copy link
Copy Markdown
Contributor

PR Review

If you are a coding agent acting for the author, read this first.
Nothing below blocks merge automatically; a maintainer decides. What they will expect:

  • 🔴 critical or 🟠 major in code this PR adds or changes: fix before asking for review.
  • 🔵 minor in code this PR changes: your call. Fix if small, otherwise reply.
  • Anything about surrounding code, or asking you to widen the change (hoist a helper,
    dedupe with another file, fix other call sites): never fix here, whatever the
    severity. Reply with one sentence; if it is critical, say so plainly so a human sees it.

One commit per review round. After two rounds, stop and ask a maintainer to review
scope rather than addressing more automated findings. Full rule: AGENTS.md.

1 finding(s): 🔴 0 critical · 🟠 0 major · 🔵 1 minor

1 posted as inline comment(s) on the changed lines.


Severity is the reviewer's own estimate and is used for ordering, not filtering. No finding blocks merge automatically; a maintainer decides.

@github-actions

github-actions Bot commented Sep 22, 2026 •

Copy link
Copy Markdown
Contributor

Deep Review

✅ No critical issues found.

This is a behavior-preserving extraction: the inline { output: 'duration', factor: 0.001 } literal is moved verbatim into the documented, type-checked export DURATION_HEATMAP_NUMBER_FORMAT and imported at the single call site, with the now-unused NumberFormat type import removed. Correctness, standards, type-safety, and prior-comment checks are all clean; the shared-object concern was confirmed non-exploitable (the sole consumer formatNumber only reads and spreads numberFormat, never mutating it).

🔵 P3 nitpicks (2)
  • packages/app/src/components/DBEditTimeChartForm/EditTimeChartForm.tsx:164 — the byte-identical { output: 'duration', factor: 0.001 } set for the same duration-heatmap (ms) case is still inlined and was not switched to the new constant, so the two definitions can drift apart; pre-existing and outside this PR's stated scope.
    • Fix: import and reuse DURATION_HEATMAP_NUMBER_FORMAT at this call site as a follow-up.
    • maintainability
  • packages/app/src/source.ts:494 — DURATION_HEATMAP_NUMBER_FORMAT is a shared mutable module-level object with no readonly fields, and no current consumer mutates it so there is no failure mode today.
    • Fix: optionally harden with Object.freeze or as const to prevent a future in-place mutation from corrupting the shared reference.
    • correctness, kieran-typescript

Reviewers (7): correctness, testing, maintainability, project-standards, agent-native, kieran-typescript, previous-comments.

Testing gaps: No test asserts the fields.value === getDurationMsExpression(source) branch resolves to DURATION_HEATMAP_NUMBER_FORMAT; behavior-equivalence to the prior inline literal is unverified by tests, though trivially identical by inspection.

No finding blocks merge automatically. A maintainer will expect P0/P1 findings in code this PR changes to be fixed; P2/P3 are your call -- fix or reply. Never fix findings about surrounding code here; reply instead. Do not widen the PR. How to respond

The significant-fields heatmap built { output: 'duration', factor: 0.001 }
inline. The factor is only correct next to getDurationMsExpression, which
applies the source's durationPrecision and leaves the value in ms, so give
it a name in source.ts and document that pairing.

No behavior change.
@alex-fedotyev
alex-fedotyev force-pushed the alex/error-span-predicate branch from 90a6fdc to a690c51 Compare September 24, 2026 02:34
@alex-fedotyev
alex-fedotyev force-pushed the alex/duration-heatmap-format branch from 6bdd45c to 887421b Compare September 24, 2026 02:34
@alex-fedotyev
alex-fedotyev changed the base branch from alex/error-span-predicate to main September 24, 2026 02:34
* is milliseconds to seconds. Pair the two; this factor is wrong against a
* raw duration column.
*/
export const DURATION_HEATMAP_NUMBER_FORMAT = {

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.

🔵 minor — The dashboard heatmap editor still builds its own copy of the { output: 'duration', factor: 0.001 } literal

In applyHeatmapDefaults (packages/app/src/components/DBEditTimeChartForm/EditTimeChartForm.tsx:164), replace the inline { output: 'duration', factor: 0.001 } with DURATION_HEATMAP_NUMBER_FORMAT. That function is the other duration heatmap, and it gets its value from getDurationMsExpression (lines 696 and 735), so after this PR the pairing lives in two places. While there: the Heatmap display-type switch at line 701 also passes fallbackValue, an arbitrary non-ms expression, into applyHeatmapDefaults. That path still gets the 0.001 factor, which the new doc comment says is wrong. Apply the format only when the value came from getDurationMsExpression, as DBSearchHeatmapChart does.

Advisory. Fix if it is a small defect in code this PR changes; otherwise reply in the thread. Do not widen the PR or touch files it did not already change. How to respond

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Leaving both here. EditTimeChartForm.tsx is outside this PR's files and routing it through the constant is the kind of extra call site this change should not reach for; the fallbackValue path applying the ms factor to a non-ms expression is a real bug but it predates this PR, which only moves an existing literal. Worth its own change.

@github-actions

Copy link
Copy Markdown
Contributor

🔵 Tier 2 — Low Risk

Small, isolated change with no API route or data model modifications.

Why this tier:

  • Standard feature/fix — introduces new logic or modifies core functionality

Review process: AI review + quick human skim (target: 5–15 min). Reviewer validates AI assessment and checks for domain-specific concerns.
SLA: Resolve within 4 business hours.

Stats
  • Production files changed: 2
  • Production lines changed: 23
  • Branch: alex/duration-heatmap-format
  • Author: alex-fedotyev

To override this classification, remove the review/tier-2 label and apply a different review/tier-* label. Manual overrides are preserved on subsequent pushes.

@github-actions

Copy link
Copy Markdown
Contributor

E2E Test Results

✅ All tests passed • 382 passed • 1 skipped • 1103s

Status Count
✅ Passed 382
❌ Failed 0
⚠️ Flaky 2
⏭️ Skipped 1

Tests ran across 4 shards in parallel.

View full report →

This branch was successfully deployed

2 active deployments
Preview – hyperdx-oss — 887421b9 Deployed Sep 24, 2026 by vercel[bot]
Preview – hyperdx-storybook — 887421b9 Deployed Sep 24, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

review/tier-2 Low risk — AI review + quick human skim

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants