Skip to content
This repository was archived by the owner on Sep 20, 2026. It is now read-only.

fix(combat-insights): compact wide recap impact tooltips - #226

Merged
cauyxy merged 1 commit into
masterfrom
codex/fix-recap-impact-tooltip
Aug 6, 2026
Merged

cauyxy merged 1 commit into
masterfrom
codex/fix-recap-impact-tooltip

Conversation

@pengx17

@pengx17 pengx17 commented Aug 6, 2026

Copy link
Copy Markdown
Member

改动重点

  • Recap Combat Impact Tooltip: 对超长 target/source 明细改为只展示分组汇总,避免 hover 时同步构建大量 native preview 与布局节点。
  • 效果图标: 将 *Targets / 派生属性 key 映射到 native keyword icon key,修复 Repair / Transform 等行缺图标的问题。
  • 行头布局: 效果行改成固定 icon 列 + label 列 + metric 列,没有图标时也保持对齐。
  • 回归测试: 补充无人机粉碎者这类 repair/destroy/transform/haste 高基数战斗的数据形态测试,以及阈值与 icon key 映射测试。

Context
玩家在 Recap 中 hover 中文卡牌“无人机粉碎者”时,游戏主线程会长时间卡住;来源录像是 https://www.bilibili.com/video/BV1Z8un61ECZ。这个战斗比较特殊,同一张卡在一个战斗中反复触发修复、摧毁、转化、加速,导致 Recap 的 Combat Impact 数据里出现大量不同 target/source 明细。

本地用临时 Debug 复现场景把详细行上限拉到 300 后确认会明显卡住;恢复生产策略后,用户反馈进游戏不卡。临时 synthetic/debug 入口已在提交前清理,本 PR 只保留正式修复和测试。

协作过程

sequenceDiagram
    participant User as 用户
    participant Codex as Codex
    participant CCFable as ccfable
    participant Game as 本地游戏验证

    User->>Codex: 提供录像与截图:hover 无人机粉碎者时 Recap 卡死
    Codex->>CCFable: 请求只读复核卡顿假设
    CCFable-->>Codex: 指出不是无限循环,而是超长 per-target rows × 同步布局重建
    Note over Codex,CCFable: destroy/transform/repair/haste 会产生随 use count 增长的 unique target/source 明细,hover 时一次性构建 TMP、preview、layout tree
    Codex->>Game: 加临时 Debug synthetic report,把明细上限拉到 300
    User-->>Codex: 确认 300 场景确实卡住,但等待后能恢复
    Codex->>Game: 恢复生产上限策略,只展示汇总
    User-->>Codex: 确认进游戏不卡;随后发现 Repair/Transform 图标缺失且不对齐
    Codex->>Codex: 对照反编译 native TooltipTypography/Data keyword 表
    Note over Codex: `TransformTargets` / `RepairTargets` 不是可靠的 icon lookup key,应映射到 native keyword `Transform` / `Repair`
    Codex->>Codex: 清理临时复现入口,保留阈值策略、icon 映射、固定 icon 列和回归测试
Loading

方案讨论

ADR-001: 超长明细的展示策略

Context: 旧实现会为每个 target/source 生成明细行与 native card preview,再交给 tooltip fit/trim loop 逐行裁剪;高基数数据会把成本集中到 hover 的主线程路径。

Considered Options:

  • 继续渲染所有明细,再优化布局裁剪循环。
  • 在数据聚合层截断 target/source。
  • 在 UI 呈现层对超长分组直接隐藏明细,只保留最终汇总。

Decision: 选择 UI 呈现层阈值策略,超过 MaximumDetailedEntityRows = 12 时不渲染该分组的 per-target/per-source 明细。

Consequences: 保留了分组总次数和最终统计,避免超长明细产生大量 TMP、preview 与 layout rebuild;代价是极端战斗中不再展开每个目标的明细。

ADR-002: 效果图标 key 的来源

Context: native TooltipTypography.GetKeywordStringWithIconNoScale(key, "") 在 key 未命中时返回空字符串。RepairTargets / TransformTargets 是 action target attribute,不一定是 native keyword 配置里的 icon key,导致图标消失;图标作为内联文本拼在 label 前时,缺图标行还会左移。

Considered Options:

  • 继续使用 raw nativeAttributeKey
  • 为 Repair/Transform 单独特判。
  • 建立集中 helper,将展示属性 key 映射到 native keyword icon key,并用测试覆盖。

Decision: 新增 CombatImpactEffectIconKey,集中映射高置信属性族,例如 Haste/Slow/Freeze/Charge 的 targets/reduction、Repair、Transform、Enchant、Upgrade、Flying、Destroy、Tempo、Rage、Regen 等。

Consequences: Repair/Transform 等行恢复 native icon,后续新增映射有单测保护;对 native keyword 不明确的属性不强行映射,避免误导性图标。

最终方案

sequenceDiagram
    participant Report as CombatImpactReport
    participant View as NativePostCombatImpactTooltipView
    participant Policy as CombatImpactDetailPresentationPolicy
    participant Icons as CombatImpactEffectIconKey
    participant Native as TooltipTypography

    Report->>View: groups with targets/sources
    View->>Policy: ShouldRenderEntityRows(count)
    alt count <= 12
        View->>View: render detail rows and previews
    else count > 12
        View->>View: render group header summary only
    end
    View->>Icons: Resolve(kind, nativeAttributeKey)
    Icons-->>View: native keyword icon key
    View->>Native: GetKeywordStringWithIconNoScale(iconKey, "")
    View->>View: render fixed icon column + label + right metric
Loading

验证情况

  • ./run.sh format-check
  • dotnet test tests/PostCombatImpact.Tests/PostCombatImpact.Tests.csproj
  • dotnet build src/BazaarPlusPlus/BazaarPlusPlus.csproj -c Release
  • git diff --check

已知局限 / 后续工作

  • 本 PR 没有在聚合层截断 target/source 数据,只在 tooltip 呈现层避免构建超长明细。
  • ReloadCooldownForceUseDisable、经济/等级、Joy*Custom_* 等 native icon key 不够明确的项目没有强行补图标;现在即使为空也会通过固定 icon 列保持对齐。
  • 需要最终在真实 Recap hover 中确认 tooltip 与 native card 的相邻布局、屏幕边界和快速切换行为。

Copilot AI lite review requested due to automatic review settings August 6, 2026 09:59

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 Post-Combat “Recap Combat Impact” tooltip rendering to avoid main-thread stalls caused by extremely wide target/source detail groups, while also fixing missing/misaligned effect icons by mapping attribute keys to native keyword icon keys. It fits into the PostCombatImpact UI pipeline by changing how NativePostCombatImpactTooltipView decides whether to render per-entity detail rows and how it resolves icon keys for group headers.

Changes:

  • Suppress per-target/per-source detail row rendering when a group exceeds MaximumDetailedEntityRows (12), reducing hover-time layout/preview construction.
  • Introduce CombatImpactEffectIconKey to map attribute keys (e.g., RepairTargets, TransformTargets, *Targets, derived reduction keys) to native keyword icon keys, restoring missing icons.
  • Adjust group header layout to a fixed icon column + label + metric columns so rows stay aligned even when an icon is missing.

Reviewed changes

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

Show a summary per file
File Description
tests/PostCombatImpact.Tests/PostCombatImpact.Tests.csproj Links new UI helper/policy source files into the test project build.
tests/PostCombatImpact.Tests/CombatImpactProjectorTests.cs Adds a regression scenario that produces wide unique target groups for repair/destroy/transform/haste.
tests/PostCombatImpact.Tests/CombatImpactEffectIconKeyTests.cs Adds unit tests validating attribute-key → native icon-key mapping behavior (including variants and destroy).
tests/PostCombatImpact.Tests/CombatImpactDetailPresentationPolicyTests.cs Adds unit tests for the “render entity rows only up to threshold” policy.
src/BazaarPlusPlus/Patches/PostCombatImpact/NativePostCombatImpactTooltipView.cs Applies the detail-row suppression policy, resolves icon keys via the new helper, and renders a fixed-width icon column for alignment.
src/BazaarPlusPlus/Game/PostCombatImpact/Ui/CombatImpactEffectIconKey.cs New centralized mapping helper for resolving native keyword icon keys from combat impact kinds/attribute keys.
src/BazaarPlusPlus/Game/PostCombatImpact/Ui/CombatImpactDetailPresentationPolicy.cs New UI presentation policy defining the max detailed row threshold and predicate.

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

@cauyxy
cauyxy merged commit 048679b into master Aug 6, 2026
1 check passed
@cauyxy
cauyxy deleted the codex/fix-recap-impact-tooltip branch August 6, 2026 11:16
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants