feat(zzz): teammate team buffs on optimize page#3225
Conversation
WalkthroughRefactors 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. ChangesTeammate buff visibility and calculation
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
Estimated code review effort🎯 4 (Complex) | ⏱️ ~60 minutes Possibly related PRs
Suggested labels
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
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.
34972d2 to
c7bee37
Compare
There was a problem hiding this comment.
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
📒 Files selected for processing (8)
libs/game-opt/sheet-ui/src/components/ConditionalDisplay.tsxlibs/zzz/formula-ui/src/char/CharCalcProvider.tsxlibs/zzz/formula-ui/src/index.tslibs/zzz/formula-ui/src/teammate/TeammateEquipmentSheets.tsxlibs/zzz/formula-ui/src/teammate/index.tslibs/zzz/page-optimize/src/CharacterOptDisplay.tsxlibs/zzz/page-optimize/src/Teammates.tsxlibs/zzz/page-optimize/src/useTeammateBuffDisplayData.ts
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.
There was a problem hiding this comment.
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
📒 Files selected for processing (4)
libs/zzz/formula-ui/src/char/CharCalcProvider.tsxlibs/zzz/formula-ui/src/teammate/TeammateEquipmentSheets.tsxlibs/zzz/page-optimize/src/Teammates.tsxlibs/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
| {EXTRA_TEAMMATE_SLOTS.map((slot) => ( | ||
| <TeammateSlotColumn | ||
| key={slot} | ||
| slot={slot} | ||
| teammateKey={team.teammates[slot]?.characterKey} | ||
| mainCharacterKey={mainCharacterKey} | ||
| onPick={() => setPickingSlot(slot)} |
There was a problem hiding this comment.
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.
| {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.
Describe your changes
I load teammate gear and kit into the calc on the ZZZ optimize page and show controls for buffs in
teamBuff.listingthat apply to the main unit. Sheet UI is filtered to those listings; conditionals that gate them still show up. Teammate conditionals usesrc=teammateKeywhile buffs route to the main character.This PR is UI + calc wiring only. I left two follow-ups out of the branch on purpose:
registerBuff(..., team:)listing frometinsheet.ts(in next pr)teamBuff, Pulchra M6 trap) as local uncommitted editsUntil 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
nx run zzz-page-optimize:eslint:lintlocally.Checklist before requesting a review (leave this PR as draft if any part of this list is not done.)
yarn run mini-cilocally to validate format and lint.Summary by CodeRabbit
New Features
Bug Fixes