Symptom
Open a device (or any object) detail view in the TUI: the Tags field shows as
a raw Python repr of a list of dicts — e.g. [{'id': 3, 'url': '...', 'display': 'prod', 'name': 'prod', 'slug': 'prod', 'color': '4caf50'}] — instead of a clean
list of tag names (ideally colored, like the list view). The same applies to any
field whose value is a list of objects.
Root cause
nsc/tui/screens/detail.py _value_display (lines 127-147) only special-cases a
single dict (value.get("display")) and has no branch for lists:
- Editable fields (tags are editable) read the raw record value
(self._record.get(row.name)) and fall through to str(value) → raw list-of-dicts.
- Non-editable fields use
flat.get(row.name) but then str(value); with object
colors on, flat yields a list[ColoredValue], which str() turns back into an
ugly repr.
Meanwhile the list table already renders this correctly: it goes through
flatten(...) → _displayify (nsc/output/flatten.py:45-65), which turns a tag
list into colored chips or a comma-joined display/name string, and
nsc/tui/view.py:_cell renders ColoredValue/list[ColoredValue] as Rich Text.
So the fix is to make the detail view reuse the same rendering rather than
stringify.
Desired
In the detail view, list-of-object fields (tags, and any similar M2M/list field)
display like the list table: comma-separated display/name values, colored when
object colors are enabled. The display path should reuse _displayify /
flatten / the _cell logic instead of str(value).
Considerations
_value_display currently returns str; to show colors it would need to return
str | Text (the DataTable already accepts Text, as the list view shows). If
we don't want colors in detail yet, at minimum render the comma-joined
display/name string (no raw dicts).
- Apply to both the editable and non-editable branches — tags are editable, so the
raw-record branch must also format lists nicely (display only; editing the tag
set is a separate concern, see below).
- Single dicts already work via
display; keep that. Choice fields use label
(already handled by _displayify).
- Editing: this issue is about display. Inline-editing a tag list is out of
scope here — the formatted display must not break or be mistaken for an editable
scalar. If a list field is currently treated as editable-scalar, ensure it shows
the nice value and editing it doesn't corrupt the list (split into a follow-up if
needed).
Scope
Affects every detail view (device and all other object types), since the rendering
is generic. Likely a small change centered on detail.py:_value_display plus a
shared helper extracted from view.py/flatten.py.
Symptom
Open a device (or any object) detail view in the TUI: the Tags field shows as
a raw Python repr of a list of dicts — e.g.
[{'id': 3, 'url': '...', 'display': 'prod', 'name': 'prod', 'slug': 'prod', 'color': '4caf50'}]— instead of a cleanlist of tag names (ideally colored, like the list view). The same applies to any
field whose value is a list of objects.
Root cause
nsc/tui/screens/detail.py_value_display(lines 127-147) only special-cases asingle dict (
value.get("display")) and has no branch for lists:(
self._record.get(row.name)) and fall through tostr(value)→ raw list-of-dicts.flat.get(row.name)but thenstr(value); with objectcolors on,
flatyields alist[ColoredValue], whichstr()turns back into anugly repr.
Meanwhile the list table already renders this correctly: it goes through
flatten(...)→_displayify(nsc/output/flatten.py:45-65), which turns a taglist into colored chips or a comma-joined
display/namestring, andnsc/tui/view.py:_cellrendersColoredValue/list[ColoredValue]as RichText.So the fix is to make the detail view reuse the same rendering rather than
stringify.
Desired
In the detail view, list-of-object fields (tags, and any similar M2M/list field)
display like the list table: comma-separated
display/namevalues, colored whenobject colors are enabled. The display path should reuse
_displayify/flatten/ the_celllogic instead ofstr(value).Considerations
_value_displaycurrently returnsstr; to show colors it would need to returnstr | Text(the DataTable already acceptsText, as the list view shows). Ifwe don't want colors in detail yet, at minimum render the comma-joined
display/namestring (no raw dicts).raw-record branch must also format lists nicely (display only; editing the tag
set is a separate concern, see below).
display; keep that. Choice fields uselabel(already handled by
_displayify).scope here — the formatted display must not break or be mistaken for an editable
scalar. If a list field is currently treated as editable-scalar, ensure it shows
the nice value and editing it doesn't corrupt the list (split into a follow-up if
needed).
Scope
Affects every detail view (device and all other object types), since the rendering
is generic. Likely a small change centered on
detail.py:_value_displayplus ashared helper extracted from
view.py/flatten.py.