Skip to content

Nested Subroll Highlighting Bug #28

@ptaranat

Description

@ptaranat

The Nested Subroll Highlighting Bug

Problem Description

Subroll highlighting was broken for deeply nested table references. When you had table chains like [food] → [fruit] → [berry] → "strawberry", the final result (strawberry) would not be clickable/highlighted, even though simpler chains like [food] → [fruit] → "apple" worked fine.

Root Cause

When the TableRoller processes nested references, it creates multiple subrolls with identical positions and text but different sources:

For [fruit] → [berry] → "strawberry":

  • food subroll: text="strawberry", source="food", position 0-10
  • fruit subroll: text="strawberry", source="fruit", position 0-10
  • berry subroll: text="strawberry", source="berry", position 0-10

For [fruit] → "apple":

  • food subroll: text="apple", source="food", position 0-5
  • fruit subroll: text="apple", source="fruit", position 0-5

The Bug

Our filtering logic in InteractiveRollResult.tsx was either:

  1. Removing ALL overlapping subrolls (making nothing clickable)
  2. Keeping the wrong subroll (keeping "food" instead of "berry")

The Fix

We implemented smart filtering that:

  1. Identifies overlapping subrolls (same position + text)
  2. Excludes broad root sections (output, food)
  3. Keeps the most specific subroll (berry > fruit > food)

Result

  • [fruit] → "apple" shows as clickable "fruit"
  • [fruit] → [berry] → "strawberry" shows as clickable "berry" ✅ (was broken before)
  • Users can reroll at the appropriate level of specificity

Key Insight

Nested table references should collapse to one clickable element representing the most specific source, not create multiple overlapping targets or remove all targets entirely.

This was a subtle but critical bug that affected the core interactivity of deeply nested table structures.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions