Skip to content

Schema Types sidenav: inline expand/collapse + QueryNodeViewer integration - #962

Merged
malibio merged 2 commits into
mainfrom
feature/issue-960-schema-types-inline-collapsible
Mar 16, 2026
Merged

malibio merged 2 commits into
mainfrom
feature/issue-960-schema-types-inline-collapsible

Conversation

@malibio

@malibio malibio commented Mar 16, 2026

Copy link
Copy Markdown
Collaborator

Closes #960

Replace slide-out SchemaTypesSubPanel with inline Collapsible.Root pattern
matching Collections section. Expanded state is persisted via layout store
(schemaTypesExpanded, version 3 of LayoutPersistenceService).

- Delete schema-types-sub-panel.svelte
- Add Collapsible.Root accordion in navigation-sidebar.svelte (mirrors Collections)
- Add schemaTypesExpanded to LayoutState + setSchemaTypesExpanded helper
- Bump LayoutPersistenceService to version 3 with chained migration
- Update layout store and persistence service tests

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
@malibio

malibio commented Mar 16, 2026

Copy link
Copy Markdown
Collaborator Author

Code Review — PR #962: Schema Types sidenav inline expand/collapse

Initial review. No prior reviews exist on this PR.

Overall Assessment: This is a clean, well-scoped change that is a net positive. The slide-out sub-panel has been replaced with the inline Collapsible.Root accordion pattern that matches Collections exactly, as specified in the issue. The migration chain is correct, deletion is clean, and tests pass. There are two issues worth addressing before merge, one of them a behavioral regression.


Findings

[Improvement] Missing empty-state when both schema groups are empty

File: packages/desktop-app/src/lib/components/layout/navigation-sidebar.svelte, lines 458–503

The deleted schema-types-sub-panel.svelte rendered a "No schema types defined" message when both builtInSchemas.length === 0 and customSchemas.length === 0. The new implementation renders an empty <div class="schema-type-list"> in that case — a completely blank expanded section with no affordance for the user.

The issue spec says "Empty state for custom types: show a subtle 'No custom types' message or nothing." That applies to the custom types group, not the overall state. The old file handled the case where even built-in schemas fail to load. In practice, task should always be present, but defensively this matters: if getAllSchemas() fails (it is wrapped in a try/catch that silently swallows the error), the user sees a blank accordion with no feedback.

Recommendation: add a minimal fallback inside Collapsible.Content when builtInSchemas.length === 0 && customSchemas.length === 0. A single muted-text line ("No types available") is sufficient. This matches what the deleted panel provided.

[Improvement] setSchemaTypesExpanded is not tested in the layout store test suite

File: packages/desktop-app/src/tests/stores/layout.test.ts, around line 748

setCollectionsExpanded and toggleCollectionsExpanded each have dedicated describe blocks with behavioral assertions (lines 727–748). The new setSchemaTypesExpanded function exported from layout.ts has no equivalent test block — it only appears in beforeEach state resets, which does not exercise the function's behaviour.

The layout.ts store also exports setSchemaTypesExpanded but no toggleSchemaTypesExpanded. toggleCollectionsExpanded exists alongside setCollectionsExpanded for toggle-in-place use cases. The sidebar currently uses only the setter (the Collapsible.Root onOpenChange callback), so the toggle isn't needed immediately, but the asymmetry relative to the Collections pair is a minor inconsistency to be aware of.

Recommendation: Add a describe('setSchemaTypesExpanded', ...) block parallel to the setCollectionsExpanded block to verify the setter updates state to true and false correctly. Two test cases, ~10 lines.


Nitpicks

Nit: packages/desktop-app/src/lib/components/layout/navigation-sidebar.svelte, lines 459–476 and 483–501 — The 4-shape SVG icon is duplicated verbatim inside the builtInSchemas loop and the customSchemas loop. Since both loops render the same icon for every item, this SVG block (7 lines) is repeated in two places. Extracting a {#snippet schemaTypeIcon()} or an inline helper would eliminate the duplication (DRY). This is pre-existing for the header icon too, so it is minor scope — not a blocker.

Nit: packages/desktop-app/src/lib/services/layout-persistence-service.ts, line 106 — The log.debug on load only interpolates sidebarCollapsed but now omits schemaTypesExpanded from the loaded-state message, while the save log message (line 68) was correctly updated to include all three fields. Minor inconsistency in observability.


Requirements Validation (Issue #960 Part 1)

Criterion Status
Schema Types expands/collapses inline — no slide-out panel PASS
Expanded state persisted in layout store (schemaTypesExpanded) PASS
Built-in types shown first (only task), custom types below with separator PASS
Empty state handled when no custom types PASS (custom group simply not rendered)
schema-types-sub-panel.svelte deleted PASS — confirmed no remaining references
Visual style mirrors Collections (indentation, font-size, hover) PASS
Collapsed sidebar icon expands sidebar and opens section PASS
Tests pass (bun run test:all) PASS — 3720/3720

Part 2 is correctly deferred pending #441.


Migration Chain

v1 → v2 → v3 chain is correct. The sequential if (s.version === 1) / if (s.version === 2) guards handle chained migration properly without a return between steps. v3 identity (no-op) is implicitly correct because neither condition matches. The new test case "does not modify version 3 state" closes the coverage gap that was left when the v2 test was renamed.


Verdict: Approve with the improvements above noted. The behavioral gap (empty state on failed schema load) is low probability in practice given task is a core type, but the test coverage gap for setSchemaTypesExpanded is a straightforward fix. Neither is a blocker for a pre-release greenfield project, but both should be addressed before this pattern is replicated for additional sidenav sections.

🤖 Reviewed by Claude Sonnet 4.6 via /pragmatic-code-review

@malibio malibio left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Implementation is correct and clean. Two non-blocking improvements noted in the inline review comment: add an empty-state fallback when schema load fails (defensive against the try/catch swallowing errors on mount), and add a setSchemaTypesExpanded unit test block parallel to the existing setCollectionsExpanded coverage. Migration chain and deletion are verified clean.

- Add empty-state fallback ("No types available") inside Collapsible.Content
  when getAllSchemas() fails or returns empty — closes behavioral regression
  vs. deleted sub-panel
- Extract {#snippet schemaTypeItemIcon()} to DRY duplicate SVG in both
  builtInSchemas and customSchemas loops
- Add setSchemaTypesExpanded unit test block in layout.test.ts parallel to
  setCollectionsExpanded coverage
- Fix load log in layout-persistence-service.ts to include all three fields
  (consistent with save log)

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
@malibio

malibio commented Mar 16, 2026

Copy link
Copy Markdown
Collaborator Author

Review Feedback Addressed

All 4 recommendations from the review have been implemented:

✅ Empty-state fallback — Added {#if builtInSchemas.length === 0 && customSchemas.length === 0} guard in Collapsible.Content showing "No types available" (muted, italic). Closes the behavioral gap vs. the deleted sub-panel.

✅ Duplicate SVG DRY — Extracted {#snippet schemaTypeItemIcon()} used by both builtInSchemas and customSchemas loops.

✅ setSchemaTypesExpanded unit tests — Added describe('setSchemaTypesExpanded', ...) block with two tests parallel to the existing setCollectionsExpanded coverage. Test count: 3722 (was 3720).

✅ Load log consistency — Updated layout-persistence-service.ts load debug message to include all three fields (sidebarCollapsed, collectionsExpanded, schemaTypesExpanded), matching the save log.

Tests: 3722/3722 ✅ | Quality: clean ✅

@malibio
malibio merged commit a5ace4b into main Mar 16, 2026
@malibio
malibio deleted the feature/issue-960-schema-types-inline-collapsible branch March 16, 2026 21:32
malibio added a commit that referenced this pull request Jun 22, 2026
…ation (#962)

* Schema Types sidenav: inline expand/collapse (closes #960 Part 1)

Replace slide-out SchemaTypesSubPanel with inline Collapsible.Root pattern
matching Collections section. Expanded state is persisted via layout store
(schemaTypesExpanded, version 3 of LayoutPersistenceService).

- Delete schema-types-sub-panel.svelte
- Add Collapsible.Root accordion in navigation-sidebar.svelte (mirrors Collections)
- Add schemaTypesExpanded to LayoutState + setSchemaTypesExpanded helper
- Bump LayoutPersistenceService to version 3 with chained migration
- Update layout store and persistence service tests

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>

* Address review feedback for PR #962

- Add empty-state fallback ("No types available") inside Collapsible.Content
  when getAllSchemas() fails or returns empty — closes behavioral regression
  vs. deleted sub-panel
- Extract {#snippet schemaTypeItemIcon()} to DRY duplicate SVG in both
  builtInSchemas and customSchemas loops
- Add setSchemaTypesExpanded unit test block in layout.test.ts parallel to
  setCollectionsExpanded coverage
- Fix load log in layout-persistence-service.ts to include all three fields
  (consistent with save log)

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>

---------

Co-authored-by: Claude Sonnet 4.6 <[email protected]>
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.

Schema Types sidenav: inline expand/collapse + QueryNodeViewer integration

1 participant