Files
Dialectic.Frontend/src
hzhang 7dca2c3110 fix(api): normalize null lists to [] (backend serializes empty as null)
The Go backend serializes empty slices as JSON null in several places
(e.g. {count:0, topics:null} when no rows match). The SPA assumed
arrays and crashed on .length:

  TypeError: Cannot read properties of null (reading 'length')
    at Hh (TopicList.tsx:64:45)

Fix in api.ts so every list-returning helper normalizes null → [] once,
centrally. Three call sites covered:
  - listTopics       — topics field
  - listArguments    — arguments field
  - getAgentSummary  — recent_topics field

Components stay as-is; nullable handling moves out of UI code where it
belongs in the data layer. getTopic preserves camps:null vs camps:[]
distinction (null = not yet allocated, [] would be allocated-with-zero
which the allocator contract forbids — keep them meaningfully distinct).

No backend change. Tested on prod with empty topics — list page now
renders 'no topics match this filter' instead of crashing.
2026-05-24 01:18:26 +01:00
..