Skip to content

refactor(plugin-redis): replace recursive DisclosureGroup with OutlineGroup#1132

Merged
datlechin merged 21 commits intomainfrom
refactor/datagrid-stage-15-redis-outline
May 8, 2026
Merged

refactor(plugin-redis): replace recursive DisclosureGroup with OutlineGroup#1132
datlechin merged 21 commits intomainfrom
refactor/datagrid-stage-15-redis-outline

Conversation

@datlechin
Copy link
Copy Markdown
Member

Summary

  • RedisKeyTreeView previously rendered the namespace tree via a recursive renderNodes(_:) -> AnyView function with nested ForEach + DisclosureGroup. The AnyView wrap was needed because Swift can't express the recursive view-tree type, but it kills SwiftUI's view diffing.
  • Replace with SwiftUI's native OutlineGroup(nodes, children: \.children) in 91 LoC. No AnyView, no recursion in code — SwiftUI handles arbitrary depth.
  • Drop the explicit expandedPrefixes: Set<String> binding from the viewmodel and the call site. SwiftUI manages expansion state per branch identifier (via RedisKeyNode.id); state persists across re-renders for branches whose ID survives, which matches what the explicit set was approximating.
  • Add var children: [RedisKeyNode]? computed property to RedisKeyNode (returns the children array for .namespace, nil for .key) so OutlineGroup can navigate.

Picked SwiftUI OutlineGroup over AppKit NSOutlineView because the surrounding sidebar is a SwiftUI List with Sections; embedding NSOutlineView would create a hybrid with its own scroll view, different selection chrome, and different keyboard nav.

Stacked on #1131. Review that one first.

Test plan

  • Connect to Redis with hierarchical keys (user:1, user:2:profile, cache:foo, session:abc)
  • Tree shows namespaces with folder icons + key counts
  • Click chevron → namespace expands; click again → collapses
  • Arrow keys (Right/Left when row is focused) expand/collapse natively
  • Click namespace label (not chevron) → opens namespace browse view
  • Click key row → opens key value editor
  • Type in search → tree filters; expand state preserved for surviving namespaces
  • Clear search → tree returns to full
  • Empty database → "No keys" caption
  • Database with >50,000 keys → "Showing first 50,000 keys" footer
  • Switch Redis connection → tree resets cleanly
  • Other sidebar sections (tables, views) scroll together with Redis tree as one unified list

datlechin added 20 commits May 8, 2026 21:01
@chatgpt-codex-connector
Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

Base automatically changed from refactor/datagrid-stage-9b-revised to main May 8, 2026 18:55
Signed-off-by: Ngô Quốc Đạt <datlechin@gmail.com>
@datlechin datlechin merged commit 1d2e86e into main May 8, 2026
1 check passed
@datlechin datlechin deleted the refactor/datagrid-stage-15-redis-outline branch May 8, 2026 18:56
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.

1 participant