Skip to content

feat(zzz): teammate team buffs on optimize page#3225

Open
IsPherz wants to merge 4 commits into
frzyc:masterfrom
IsPherz:feat/zzz-teammate-buffs-ui
Open

feat(zzz): teammate team buffs on optimize page#3225
IsPherz wants to merge 4 commits into
frzyc:masterfrom
IsPherz:feat/zzz-teammate-buffs-ui

Conversation

@IsPherz

@IsPherz IsPherz commented Jun 1, 2026

Copy link
Copy Markdown

Describe your changes

I load teammate gear and kit into the calc on the ZZZ optimize page and show controls for buffs in teamBuff.listing that apply to the main unit. Sheet UI is filtered to those listings; conditionals that gate them still show up. Teammate conditionals use src=teammateKey while buffs route to the main character.

This PR is UI + calc wiring only. I left two follow-ups out of the branch on purpose:

  • B: auto-infer registerBuff(..., team:) listing from et in sheet.ts (in next pr)
  • C: small formula fixes (e.g. Weeping Cradle teamBuff, Pulchra M6 trap) as local uncommitted edits

Until B lands, some team buffs may not appear in the listing even when the calc would apply them.

Issue or discord link

Follow-up to teammate work; replaces the older teammate-buffs PR approach.

Testing/validation

  • Picked teammates with team-buff gear and toggled conditionals on optimize.
  • Ran nx run zzz-page-optimize:eslint:lint locally.

Checklist before requesting a review (leave this PR as draft if any part of this list is not done.)

  • I have commented my code in hard-to understand areas.
  • I have made corresponding changes to README or wiki.
  • For front-end changes, I have updated the corresponding English translations.
  • I have run yarn run mini-ci locally to validate format and lint.
  • If I have added a new library or app, I have updated the deployment scripts to ignore changes as needed

Summary by CodeRabbit

  • New Features

    • Teammates section is always visible and includes a new teammate buffs panel showing equipped loadouts (engine, discs, pieces) in dedicated cards.
    • Added teammate equipment displays for engines and disc sets with compact, titled document views.
    • New hook to derive teammate-visible buff display data and improved calculator entry composition; additional public re-exports.
  • Bug Fixes

    • Conditional display now preserves the correct destination context so teammate buff tags render correctly.

@coderabbitai

coderabbitai Bot commented Jun 1, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Walkthrough

Refactors char calculator inputs to include teammate entries, adds a hook to discover/filter teammate-visible buffs, introduces teammate equipment display components, and wires teammates UI with TagContext and conditional remapping for correct teammate-as-src rendering.

Changes

Teammate buff visibility and calculation

Layer / File(s) Summary
TagContext dst null-coalescing fallback
libs/game-opt/sheet-ui/src/components/ConditionalDisplay.tsx
TagContext's dst now falls back to tag.dst when the conditional's dst is null, preserving an existing context destination.
Team calculator entry construction refactor
libs/zzz/formula-ui/src/char/CharCalcProvider.tsx
Introduces EMPTY_ENTRIES, extracts buildTeamCalculatorEntries and teammateCountEntries, adds useTeammateMemberEntries/useFullTeammateMemberEntries, updates imports/types, and centralizes member+equipment entry composition for the calculator.
Teammate buff discovery and filtering hook
libs/zzz/page-optimize/src/useTeammateBuffDisplayData.ts
Adds useTeammateBuffDisplayData to collect teammate-scoped team-buff reads, compute required conditional keys, filter kit/wengine/disc documents by discovered buff tags and mindscape gating, build disc 2pc/4pc displays, and emit listing-only fallback reads.
Teammates section UI and conditional provider
libs/zzz/page-optimize/src/Teammates.tsx
TeammatesSection persists by mainCharacterKey, ensures teammate creation on selection, refactors slot layout, and provides TeammateBuffs, TeammateBuffsContent, and TeammateConditionalProvider to remap conditionals (teammate as src, main as dst) and render filtered teammate documents.
Teammate equipment UI components and exports
libs/zzz/formula-ui/src/teammate/TeammateEquipmentSheets.tsx, libs/zzz/formula-ui/src/teammate/index.ts, libs/zzz/formula-ui/src/index.ts
Adds TeammateWengineSheetDisplay, TeammateDiscSheetDisplay, related types and FilteredDocumentStack, and re-exports them via the teammate barrel and the formula-ui package index.
Feature enablement in character optimize
libs/zzz/page-optimize/src/CharacterOptDisplay.tsx
TeammatesSection is now always included in character info sections instead of being gated by a dev-only flag.

Sequence Diagram(s)

sequenceDiagram
  participant TeammatesSection
  participant TeammateBuffs
  participant useTeammateBuffDisplayData
  participant CharCalcProvider
  participant TeammateConditionalProvider
  TeammatesSection->>TeammateBuffs: provide teammateKey, mainCharacterKey
  TeammateBuffs->>useTeammateBuffDisplayData: request filtered documents (teammateKey, sets, wengine, mindscape)
  useTeammateBuffDisplayData->>CharCalcProvider: inspect calc listings/compute(meta.conds) for reads
  CharCalcProvider-->>useTeammateBuffDisplayData: return calc-derived conditional keys / entries
  useTeammateBuffDisplayData-->>TeammateBuffs: return filtered kit/wengine/disc docs + listing-only reads
  TeammateBuffs->>TeammateConditionalProvider: wrap display with teammate-as-src / main-as-dst contexts
  TeammateConditionalProvider-->>TeammateBuffs: provide remapped conditional values for rendering
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes


Possibly related PRs

Suggested labels

ZO

Suggested reviewers

  • nguyentvan7
  • priolette

Poem

I stayed up past my pity timer, keys clacking in the night,
teammates lined up like banners, buffs whispering numbers bright,
I coalesce dsts, memoize entries, and graft a filtered view,
one more PR, one more rerun—sleep can wait, the gacha drew.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 7.14% 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
Title check ✅ Passed The title directly describes the main feature: adding teammate team buffs display on the ZZZ optimize page, which is the core objective of this PR.
Description check ✅ Passed The description covers what changed (teammate gear/kit loading, buff controls, filtered sheet UI, conditional routing), intentional follow-ups deferred, testing performed, and acknowledges unchecked checklist items—comprehensive and clear.
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.

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

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

Load teammate builds into the calc and render teamBuff.listing controls on the optimize page. Sheet docs are filtered to listed buffs; conditionals that gate those buffs stay visible.
@IsPherz IsPherz force-pushed the feat/zzz-teammate-buffs-ui branch from 34972d2 to c7bee37 Compare June 1, 2026 15:41

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

Actionable comments posted: 2

🤖 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 `@libs/zzz/page-optimize/src/Teammates.tsx`:
- Around line 260-279: The srcDstDisplay currently rebuilds the whole map
(dstDisplay = {}) and loses parent labels; instead read the parent
SrcDstDisplayContext and merge it with the teammate-specific srcDisplay so
existing dstDisplay mappings are preserved. Update the component to use
useContext(SrcDstDisplayContext) (or the existing parent variable) and change
the srcDstDisplay useMemo to return { srcDisplay: { [teammateKey]:
<CharacterName characterKey={teammateKey} /> }, dstDisplay: {
...parentSrcDst.dstDisplay } } (or merge with parentDstDisplay) so nested {dst}
labels continue to resolve; keep dependencies [parentSrcDst, teammateKey].

In `@libs/zzz/page-optimize/src/useTeammateBuffDisplayData.ts`:
- Around line 62-68: The logic is incorrectly deduplicating and matching buffs
by tag.name only (e.g., teamBuffNames) which allows collisions across different
sheets; change all places that build or check sets from tag.name to a composite
key including sheet and name (for example `${tag.sheet}:${tag.name}`) so that
teamBuffNames, any coverage sets, and filters (including uses inside
teamBuffReads and listingOnlyReads logic) use this sheet-scoped key; update the
map and filter expressions (and the corresponding type guards) wherever .map(({
tag }) => tag.name) or Set of names is used so comparisons and lookups compare
the composite key instead of the name alone.
🪄 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: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 95f9613f-fbb5-410a-948f-9747c10469e3

📥 Commits

Reviewing files that changed from the base of the PR and between 1688721 and c7bee37.

📒 Files selected for processing (8)
  • libs/game-opt/sheet-ui/src/components/ConditionalDisplay.tsx
  • libs/zzz/formula-ui/src/char/CharCalcProvider.tsx
  • libs/zzz/formula-ui/src/index.ts
  • libs/zzz/formula-ui/src/teammate/TeammateEquipmentSheets.tsx
  • libs/zzz/formula-ui/src/teammate/index.ts
  • libs/zzz/page-optimize/src/CharacterOptDisplay.tsx
  • libs/zzz/page-optimize/src/Teammates.tsx
  • libs/zzz/page-optimize/src/useTeammateBuffDisplayData.ts

Comment thread libs/zzz/page-optimize/src/Teammates.tsx
Comment thread libs/zzz/page-optimize/src/useTeammateBuffDisplayData.ts Outdated
Felipe Cardona added 3 commits June 1, 2026 11:03
Frostbite and other sheet=anomaly team buffs stay on AnomalySection. Hide zero-value listing fallback rows on teammate cards.
Match listed buffs by sheet:name and merge parent SrcDstDisplayContext so targeted conditionals keep main-unit labels.
Restructure teammate team-buff discovery and optimize-page UI without changing behavior.

- useTeammateBuffDisplayData: extract listingKeysFromTags, fieldsFromDocument, discDisplaysFromSets, and related helpers; match buffs by sheet:name consistently.

- Teammates: split slot/profile/buff components; keep src/dst TagContext and merge parent SrcDstDisplayContext for conditionals.

- CharCalcProvider: share useEquipmentTagEntries between main and teammates; split buildTeamCalculatorEntries into focused helpers.

- TeammateEquipmentSheets: shared FilteredDocumentStack for filtered wengine/disc documents.

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

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 `@libs/zzz/page-optimize/src/Teammates.tsx`:
- Around line 81-87: The render is reading the wrong teammate index causing an
off-by-one shift: in the EXTRA_TEAMMATE_SLOTS map it passes
teammateKey={team.teammates[slot]?.characterKey} but teammates are stored using
slot - 1 elsewhere; update the prop to use team.teammates[slot -
1]?.characterKey so the TeammateSlotColumn (and its keying) matches the
persisted storage and avoid reading a phantom teammate when slot === 1; keep the
rest of the map (EXTRA_TEAMMATE_SLOTS, setPickingSlot, mainCharacterKey)
unchanged.
🪄 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: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: ab39d404-c53f-47fa-8694-54c76eda9f32

📥 Commits

Reviewing files that changed from the base of the PR and between eab73d4 and eff1537.

📒 Files selected for processing (4)
  • libs/zzz/formula-ui/src/char/CharCalcProvider.tsx
  • libs/zzz/formula-ui/src/teammate/TeammateEquipmentSheets.tsx
  • libs/zzz/page-optimize/src/Teammates.tsx
  • libs/zzz/page-optimize/src/useTeammateBuffDisplayData.ts
🚧 Files skipped from review as they are similar to previous changes (3)
  • libs/zzz/formula-ui/src/teammate/TeammateEquipmentSheets.tsx
  • libs/zzz/formula-ui/src/char/CharCalcProvider.tsx
  • libs/zzz/page-optimize/src/useTeammateBuffDisplayData.ts

Comment on lines +81 to +87
{EXTRA_TEAMMATE_SLOTS.map((slot) => (
<TeammateSlotColumn
key={slot}
slot={slot}
teammateKey={team.teammates[slot]?.characterKey}
mainCharacterKey={mainCharacterKey}
onPick={() => setPickingSlot(slot)}

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.

⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Fix the slot read index before this rolls a phantom teammate.

Line 85 is a classic off-by-one pity loss: Lines 59-60 store the teammate into slot - 1, but this render path reads team.teammates[slot]. That shifts the displayed teammate by one slot and makes the second slot read past the stored entry. Read team.teammates[slot - 1] here so the UI matches persistence.

Suggested patch
       {EXTRA_TEAMMATE_SLOTS.map((slot) => (
         <TeammateSlotColumn
           key={slot}
           slot={slot}
-          teammateKey={team.teammates[slot]?.characterKey}
+          teammateKey={team.teammates[slot - 1]?.characterKey}
           mainCharacterKey={mainCharacterKey}
           onPick={() => setPickingSlot(slot)}
         />
       ))}
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
{EXTRA_TEAMMATE_SLOTS.map((slot) => (
<TeammateSlotColumn
key={slot}
slot={slot}
teammateKey={team.teammates[slot]?.characterKey}
mainCharacterKey={mainCharacterKey}
onPick={() => setPickingSlot(slot)}
{EXTRA_TEAMMATE_SLOTS.map((slot) => (
<TeammateSlotColumn
key={slot}
slot={slot}
teammateKey={team.teammates[slot - 1]?.characterKey}
mainCharacterKey={mainCharacterKey}
onPick={() => setPickingSlot(slot)}
🤖 Prompt for 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.

In `@libs/zzz/page-optimize/src/Teammates.tsx` around lines 81 - 87, The render is
reading the wrong teammate index causing an off-by-one shift: in the
EXTRA_TEAMMATE_SLOTS map it passes
teammateKey={team.teammates[slot]?.characterKey} but teammates are stored using
slot - 1 elsewhere; update the prop to use team.teammates[slot -
1]?.characterKey so the TeammateSlotColumn (and its keying) matches the
persisted storage and avoid reading a phantom teammate when slot === 1; keep the
rest of the map (EXTRA_TEAMMATE_SLOTS, setPickingSlot, mainCharacterKey)
unchanged.

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