Skip to content

Assigns view shows list and tuple elements in sorted order instead of their real order #1011

Open

Description

@RaphaelFakhri

Bug Description

The Assigns section sorts the elements of every list and tuple before it displays them. The displayed term no longer matches the real assign value. Tuples are affected the most, because element position is their meaning.

The sorting comes from to_children/1 in lib/live_debugger/app/utils/term_parser.ex, added in #896 together with map key sorting for #886.

Actual Behavior

  • assign(socket, result: {:ok, 5}) displays as {5, :ok}.
  • assign(socket, date: {2026, 10, 21}) displays as {10, 21, 2026}.
  • assign(socket, items: [3, 1, 2]) displays as [1, 2, 3].

Updates make it inconsistent as well. TermDiffer computes list insertions and deletions by position in the real list, and TermParser.update_by_diff/2 applies them by index to the sorted children. Changing [3, 1, 2] to [3, 1, 2, 0] shows [1, 2, 3, 0], while a fresh render of the same value shows [0, 1, 2, 3].

Expected Behavior

Lists and tuples keep their element order, the same as inspect/2 and the "copy" button output. Map and struct keys can stay sorted.

Steps to Reproduce

I reproduced this at the TermParser level, not in the live UI:

alias LiveDebugger.App.Utils.TermParser

TermParser.term_to_display_tree({:ok, 5}).children
|> Enum.map(fn {_, node} -> hd(node.content).text end)
#=> ["5", ":ok"]

Elixir version with Erlang/OTP

Elixir 1.19.1 (OTP 28)

LiveDebugger version

main (6c6d992, 1.1.0-dev); present since #896

Phoenix version

1.8.15

Phoenix LiveView version

1.2.12

Operating system

Linux

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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