Skip to content

feat(preprod): Add insight comparison#103774

Merged
rbro112 merged 9 commits intomasterfrom
ryan/add_insight_comparison
Dec 8, 2025
Merged

feat(preprod): Add insight comparison#103774
rbro112 merged 9 commits intomasterfrom
ryan/add_insight_comparison

Conversation

@rbro112
Copy link
Copy Markdown
Member

@rbro112 rbro112 commented Nov 20, 2025

Adds backend code for insight comparison. Only produces diffs of insights or content within insights (files/groups), per offline chat with Trevor we're going against the designs to show "unresolved" files/insights.

@rbro112 rbro112 requested a review from a team as a code owner November 20, 2025 21:43
@github-actions github-actions bot added the Scope: Backend Automatically applied to PRs that change backend components label Nov 20, 2025
Copy link
Copy Markdown
Member Author

rbro112 commented Nov 20, 2025

This stack of pull requests is managed by Graphite. Learn more about stacking.

@rbro112 rbro112 marked this pull request as draft November 20, 2025 21:47
@rbro112 rbro112 changed the title Add insight comparison feat(preprod): Add insight comparison Nov 20, 2025
@codecov
Copy link
Copy Markdown

codecov bot commented Nov 20, 2025

Codecov Report

❌ Patch coverage is 96.49123% with 8 lines in your changes missing coverage. Please review.
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
src/sentry/preprod/size_analysis/insight_models.py 92.10% 6 Missing ⚠️
src/sentry/preprod/size_analysis/compare.py 98.24% 2 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           master   #103774      +/-   ##
===========================================
- Coverage   80.62%    80.52%   -0.11%     
===========================================
  Files        9357      9353       -4     
  Lines      402540    400614    -1926     
  Branches    25700     25700              
===========================================
- Hits       324549    322581    -1968     
- Misses      77523     77565      +42     
  Partials      468       468              

@rbro112 rbro112 force-pushed the ryan/add_insight_comparison branch from 5c83064 to 75fccb0 Compare December 6, 2025 01:12
@rbro112 rbro112 marked this pull request as ready for review December 6, 2025 01:15
# For unchanged groups, we need to show all files as unchanged
if size_diff == 0 and len(file_diffs) == 0:
# No size change and no file diffs, so the group is unchanged
return []

This comment was marked as outdated.

raise ValueError("Both head and base insights are None")

if head_insight is None:
# Should never happen, but here for mypy passing
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Surprised these are needed 🤔

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Yeah very weird, was failing until I added these 🤷

continue

# Determine status and create diff item
if head_insight is not None and base_insight is None:
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Is this necessary? It seems like you could just do a single:

            insight_diff_item = _diff_insight(insight_type, head_insight, base_insight)
            if insight_diff_item:
                insight_diff_items.append(insight_diff_item)

since _diff_insight() handles the params being None.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Good catch, meant to do that but forgot to remove this. Done

download_size: int
install_size: int
treemap: TreemapResults | None
insights: AndroidInsightResults | AppleInsightResults | None
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Making a note that we might want to start a shared repo for all these models since now almost everything is ported over.

@rbro112 rbro112 force-pushed the ryan/add_insight_comparison branch from ea0a162 to d24fb45 Compare December 8, 2025 22:40
continue

# Always add group-level diff for groups that exist in both
diff_type = DiffType.INCREASED if size_diff > 0 else DiffType.DECREASED
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.

Bug: Zero size diff incorrectly labeled as DECREASED

When size_diff is exactly zero but there are file-level changes within a group (files added and removed with offsetting sizes), the diff_type is incorrectly assigned DiffType.DECREASED because 0 > 0 evaluates to False. A group with no overall size change contains changes but is misleadingly labeled as "decreased" instead of being handled as a distinct case (e.g., unchanged at the aggregate level).

Fix in Cursor Fix in Web

@rbro112 rbro112 merged commit c176899 into master Dec 8, 2025
68 checks passed
@rbro112 rbro112 deleted the ryan/add_insight_comparison branch December 8, 2025 23:23
ryan953 pushed a commit that referenced this pull request Dec 9, 2025
Adds backend code for insight comparison. Only produces diffs of
insights or content within insights (files/groups), per offline chat
with Trevor we're going against the designs to show "unresolved"
files/insights.

---------

Co-authored-by: getsantry[bot] <66042841+getsantry[bot]@users.noreply.github.com>
@github-actions github-actions bot locked and limited conversation to collaborators Dec 24, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Scope: Backend Automatically applied to PRs that change backend components

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants