-
Notifications
You must be signed in to change notification settings - Fork 3
Description
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":
foodsubroll: text="strawberry", source="food", position 0-10fruitsubroll: text="strawberry", source="fruit", position 0-10berrysubroll: text="strawberry", source="berry", position 0-10
For [fruit] → "apple":
foodsubroll: text="apple", source="food", position 0-5fruitsubroll: text="apple", source="fruit", position 0-5
The Bug
Our filtering logic in InteractiveRollResult.tsx was either:
- Removing ALL overlapping subrolls (making nothing clickable)
- Keeping the wrong subroll (keeping "food" instead of "berry")
The Fix
We implemented smart filtering that:
- Identifies overlapping subrolls (same position + text)
- Excludes broad root sections (output, food)
- 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.