Skip to content

Prevent Glance widget row ID collisions that cause “can’t show content”#448

Draft
Copilot wants to merge 6 commits into
masterfrom
copilot/fix-widget-content-display
Draft

Prevent Glance widget row ID collisions that cause “can’t show content”#448
Copilot wants to merge 6 commits into
masterfrom
copilot/fix-widget-content-display

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented May 29, 2026

Users reported home screen widgets rendering as “can’t show content” instead of quote data. The widget pipeline was vulnerable to duplicate/colliding row IDs in Glance lazy grid rendering, which can break widget composition.

  • Widget rendering keying hardening

    • Updated QuotesGrid in GlanceStocksWidget to stop keying rows by symbol.hashCode().
    • Introduced deterministic per-row IDs derived from symbol occurrence sequencing, ensuring IDs are unique for repeated symbols and stable within a render pass.
    • Kept the rest of the widget rendering/data flow unchanged to minimize behavioral risk.
  • Why this addresses the issue

    • Glance lazy containers require unique item IDs; collisions or duplicates can invalidate rendering and surface as host-level “can’t show content”.
    • The new ID strategy removes hash-collision risk from row identity generation.
val keyedQuotes = remember(quotes) {
    val symbolOccurrences = mutableMapOf<String, Int>()
    val stableIds = mutableMapOf<String, Long>()
    var nextId = 0L
    quotes.map { quote ->
        val currentCount = symbolOccurrences.getOrDefault(quote.symbol, 0)
        symbolOccurrences[quote.symbol] = currentCount + 1
        val stableKey = "${quote.symbol}#${currentCount + 1}"
        val itemId = stableIds.getOrPut(stableKey) { nextId++ }
        itemId to quote
    }
}

items(items = keyedQuotes, itemId = { it.first }) { keyedQuote ->
    val stock = keyedQuote.second
    // render row
}

Copilot AI linked an issue May 29, 2026 that may be closed by this pull request
2 tasks
Copilot AI changed the title [WIP] Fix widget displaying "can't show content" error Prevent Glance widget row ID collisions that cause “can’t show content” May 29, 2026
Copilot AI requested a review from premnirmal May 29, 2026 15:22
Copy link
Copy Markdown
Owner

@premnirmal premnirmal left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A widget cannot have duplicate symbols, so what's the need for creating the stableIDs and keyedQuotes?

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.

Widget displays "can't show content"

2 participants