Skip to content

Add stat effects to menu options and improve popover positioning#184

Merged
mikkisguy merged 2 commits into
mainfrom
161-add-stat-effects-to-menu-choices
Jun 2, 2026
Merged

Add stat effects to menu options and improve popover positioning#184
mikkisguy merged 2 commits into
mainfrom
161-add-stat-effects-to-menu-choices

Conversation

@mikkisguy

@mikkisguy mikkisguy commented Jun 1, 2026

Copy link
Copy Markdown
Owner

Summary by CodeRabbit

  • New Features
    • Technical popover now automatically repositions upward when there isn’t enough space below, keeping it fully visible.
    • Demo/test data includes richer technical badge variations with additional effect values, showing more diverse stat changes and new label lines.

@mikkisguy mikkisguy linked an issue Jun 1, 2026 that may be closed by this pull request
@mikkisguy mikkisguy self-assigned this Jun 1, 2026
@coderabbitai

coderabbitai Bot commented Jun 1, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 442ab7d3-11f6-439c-9fb8-cc5cc2a7f9b3

📥 Commits

Reviewing files that changed from the base of the PR and between 3076f9e and ed73ff7.

📒 Files selected for processing (1)
  • apps/frontend/src/components/write-mode/TechnicalPopover.tsx
🚧 Files skipped from review as they are similar to previous changes (1)
  • apps/frontend/src/components/write-mode/TechnicalPopover.tsx

📝 Walkthrough

Walkthrough

Backend: add optional effects.stats to labelLines schema and seed data (enriches multiple menuOptions and adds two new label lines). Frontend: TechnicalPopover now measures viewport space and flips above the anchor when needed.

Changes

Backend effects.stats support

Layer / File(s) Summary
Schema and service type updates
apps/backend/src/db/schema/tables/label-lines.ts, apps/backend/src/services/labels.service.ts
menuOptions JSON schema is extended with an optional effects?: { stats?: Record<string, number> }; resolveJumpTargets generic constraint is broadened to accept the updated shape.
Test seed data with stat effects
apps/backend/scripts/seed-technical-badges.ts
Line 2, Line 6, and Line 9 menu choices now include effects.stats deltas; two new label lines (Line 11 and Line 12) added with multi-value and mixed sign effects.stats choices and resolved menuOptions targets.

Frontend popover adaptive positioning

Layer / File(s) Summary
Popover viewport-aware positioning
apps/frontend/src/components/write-mode/TechnicalPopover.tsx
Adds isFlipped state and a measurement callback; uses useLayoutEffect to measure and re-run on resize/scroll; toggles container classes between top-full mt-1 and bottom-full mb-1 based on available viewport space.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

  • mikkisguy/branchforge#183: Modifies labelLines.menuOptions shape and resolveJumpTargets typing to support richer menu options with targetLabelName and case-insensitive name→ID resolution.
  • mikkisguy/branchforge#169: Initial technical-badges and ProseEditor badge integration affecting seed-technical-badges.ts and TechnicalPopover.tsx.

Poem

🐰 I seed the stats with careful hops and grins,

choices that change where each adventure begins.
When space is tight I nudge the popover high,
a floppy-eared flip beneath the sky.
Small rabbit cheers for code that fits just right!

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 33.33% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title Check ✅ Passed Title check skipped as CodeRabbit has written the PR title.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch 161-add-stat-effects-to-menu-choices

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot changed the title @coderabbitai Add stat effects to menu options and improve popover positioning Jun 1, 2026

@coderabbitai coderabbitai 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.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@apps/frontend/src/components/write-mode/TechnicalPopover.tsx`:
- Around line 72-87: The positioning effect in TechnicalPopover (the useEffect
that reads popoverRef and calls setIsFlipped) must be made robust: replace
useEffect with useLayoutEffect so the flip is computed before paint (preventing
the initial layout jump), include the props that change content (type and data)
in the dependency array, and register window resize and scroll listeners that
call the same measurement function (reading popoverRef.getBoundingClientRect(),
computing spaceBelow, and calling setIsFlipped) with proper cleanup in the
returned disposer; keep the measurement logic factored into a named function
(e.g., measureAndSetFlip) so it can be invoked from the layout effect and event
handlers.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 55a88ecd-d0aa-4266-8b40-fc83b3ab2cfe

📥 Commits

Reviewing files that changed from the base of the PR and between 74b5f0a and 3076f9e.

📒 Files selected for processing (4)
  • apps/backend/scripts/seed-technical-badges.ts
  • apps/backend/src/db/schema/tables/label-lines.ts
  • apps/backend/src/services/labels.service.ts
  • apps/frontend/src/components/write-mode/TechnicalPopover.tsx

Comment thread apps/frontend/src/components/write-mode/TechnicalPopover.tsx Outdated
@mikkisguy mikkisguy merged commit 0f526fe into main Jun 2, 2026
5 checks passed
@mikkisguy mikkisguy deleted the 161-add-stat-effects-to-menu-choices branch June 2, 2026 13:04
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.

Add stat effects to menu choices

1 participant