Skip to content

fix: default heatmap reference to first after label#12

Merged
CircleCrop merged 2 commits into
mainfrom
codex/add-helper-for-heatmap-reference-label
Jul 13, 2026
Merged

fix: default heatmap reference to first after label#12
CircleCrop merged 2 commits into
mainfrom
codex/add-helper-for-heatmap-reference-label

Conversation

@CircleCrop

Copy link
Copy Markdown
Member

Motivation

  • Ensure the plan's heatmapReferenceLabel points at an actual comparison column instead of the hardcoded string "After" so downstream heatmap generation does not fail.
  • Preserve variant-derived labels (e.g. Rip) for primary after assets so nested imports like src/rip become valid global references.

Description

  • Added exported helper defaultHeatmapReferenceLabel(frames: WebUploadFramePlan[]) that returns the first frame's after.label and falls back to "After" when there are no frames.
  • Use defaultHeatmapReferenceLabel(frames) instead of the hardcoded heatmapReferenceLabel: "After" in both buildFlatPlan and buildNestedPlan.
  • Preserve variant-derived labels for primary after assets by making assetPlan(..., kind: 'after') use variantLabel(candidate.variant) || "After" instead of always "After".
  • Improve nested after-directory parsing so non-primary directory names (e.g. rip) are passed as the variant override while mapping primary after/output dirs to the standard after variant.
  • Added/updated test in source-scanner.test.ts to assert that a src/rip/flt set produces frames[0].after.label === "Rip" and plan.heatmapReferenceLabel === "Rip".

Testing

  • Ran unit tests for the internal-site package with pnpm --filter @magic-compare/internal-site test -- source-scanner.test.ts, and the test run completed successfully (all tests passed).
  • Ran lint with pnpm --filter @magic-compare/internal-site lint, which succeeded with no errors.

Codex Task

Copilot AI review requested due to automatic review settings July 11, 2026 15:14

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 34ea82a17e

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

}

export function defaultHeatmapReferenceLabel(frames: WebUploadFramePlan[]) {
return frames[0]?.after.label ?? "After";

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Choose a heatmap label shared by every frame

When a scan mixes primary output variants across frames, e.g. frame 1 has *_output.png while frame 2 only has *_rip.png, the new variant-specific after.label values become After and Rip; this default still picks only the first frame's label. generateUploadFrames later calls heatmapAfterAsset for every frame and throws when that label is absent, while the UI's heatmap options intentionally only allow labels common to all frames. Please derive this default from the same common-label set, or add an issue/fallback instead of storing a label that some frames cannot use.

Useful? React with 👍 / 👎.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This PR updates the internal-site web uploader’s source scanning logic so heatmapReferenceLabel defaults to the first frame’s actual after.label (instead of always "After"), and ensures variant-derived labels (e.g. "Rip") are preserved for primary after assets so downstream heatmap selection can find a real comparison column.

Changes:

  • Add defaultHeatmapReferenceLabel(frames) and use it in both flat and nested upload plan builders.
  • Update assetPlan(..., kind: "after") to use variantLabel(candidate.variant) so primary after labels can be "Rip"/etc when appropriate.
  • Refine nested after-directory variant override handling and add a unit test for src/rip/flt nested sets.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
apps/internal-site/components/web-uploader/source-scanner.ts Computes default heatmap reference from the first frame’s after label; preserves variant-derived labels for primary after assets; adjusts nested after-dir variant overrides.
apps/internal-site/components/web-uploader/source-scanner.test.ts Adds coverage asserting src/rip/flt yields after.label === "Rip" and heatmapReferenceLabel === "Rip".

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +618 to +624
const afterParsedResults = layout.afterDirs.map((directory) => {
const directoryVariant = basename(directory).toLowerCase();
return parseEntries(
scopedEntries(directory),
PRIMARY_AFTER_VARIANTS.has(directoryVariant) ? "out" : directoryVariant,
);
});
Comment on lines +68 to +72
it("uses the first after label as the default heatmap reference for src/rip/flt sets", () => {
const plan = scanBrowserUploadFiles(
[
image("case/src/001.png"),
image("case/rip/001.png"),
### Motivation

- Ensure the plan's `heatmapReferenceLabel` points at an actual comparison column instead of the hardcoded string `"After"` so downstream heatmap generation does not fail.
- Preserve variant-derived labels (e.g. `Rip`) for primary after assets so nested imports like `src`/`rip` become valid global references.

### Description

- Added exported helper `defaultHeatmapReferenceLabel(frames: WebUploadFramePlan[])` that returns the first frame's `after.label` and falls back to `"After"` when there are no frames.
- Use `defaultHeatmapReferenceLabel(frames)` instead of the hardcoded `heatmapReferenceLabel: "After"` in both `buildFlatPlan` and `buildNestedPlan`.
- Preserve variant-derived labels for primary after assets by making `assetPlan(..., kind: 'after')` use `variantLabel(candidate.variant) || "After"` instead of always `"After"`.
- Improve nested after-directory parsing so non-primary directory names (e.g. `rip`) are passed as the variant override while mapping primary after/output dirs to the standard after variant.
- Added/updated test in `source-scanner.test.ts` to assert that a `src`/`rip`/`flt` set produces `frames[0].after.label === "Rip"` and `plan.heatmapReferenceLabel === "Rip"`.

### Testing

- Ran unit tests for the internal-site package with `pnpm --filter @magic-compare/internal-site test -- source-scanner.test.ts`, and the test run completed successfully (all tests passed).
- Ran lint with `pnpm --filter @magic-compare/internal-site lint`, which succeeded with no errors.
@CircleCrop

Copy link
Copy Markdown
Member Author

@copilot review update

Copilot AI commented Jul 13, 2026

Copy link
Copy Markdown
Contributor

@copilot review update

Updated. The review feedback has been addressed in commit 9b17ed3 (preserving nested out/output variants and adding flat-plan heatmap reference coverage), and pnpm --filter @magic-compare/internal-site lint plus pnpm --filter @magic-compare/internal-site test -- source-scanner.test.ts pass.

@CircleCrop
CircleCrop merged commit 74fbb66 into main Jul 13, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants