Skip to content

Schema Types sidenav item listing available node types - #946

Merged
malibio merged 2 commits into
mainfrom
feature/issue-940-schema-types-sidenav
Mar 14, 2026
Merged

malibio merged 2 commits into
mainfrom
feature/issue-940-schema-types-sidenav

Conversation

@malibio

@malibio malibio commented Mar 14, 2026

Copy link
Copy Markdown
Collaborator

Closes #940

…closes #940)

- Add SchemaTypesSubPanel component with slide-out behavior matching CollectionSubPanel
- Show built-in types (task only) first, then custom schema types with section labels
- 4-shape icon (triangle, square, square, diamond) in specified viewBox style
- Clicking a schema type opens it as a new tab using BaseNodeViewer
- Click-outside and sidebar-collapse handlers close the panel automatically
- Panel handles empty state when no custom schemas are defined

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

malibio commented Mar 14, 2026

Copy link
Copy Markdown
Collaborator Author

Code Review Summary

This PR implements a Schema Types sidenav item with a slide-out panel, following the established CollectionSubPanel pattern. It is a clean, focused change that satisfies all acceptance criteria. The implementation is a net positive and is ready to merge with one improvement worth addressing first.


Requirements Validation

All acceptance criteria from issue #940 are met:

  • "Schema Types" sidenav item appears below Collections with the specified 4-shape icon
  • Clicking the item opens a Schema Types panel
  • Panel queries getAllSchemas() and renders schemas grouped (built-in first, then custom)
  • Only the task built-in type is shown from built-in schemas (s.isCore && s.id === 'task')
  • Clicking a schema type opens it as a new tab using BaseNodeViewer (via addTab with nodeType: 'schema')
  • Panel handles empty state ("No schema types defined")
  • Tests pass (117 test files, 3704 tests — all green)
  • Code passes bun run quality:fix

Findings

[Improvement] — No error handling on getAllSchemas() in handleSchemaTypesClick

File: navigation-sidebar.svelte, handleSchemaTypesClick function

getAllSchemas() is awaited without a try/catch. If the Tauri invoke fails (backend unavailable, IPC error, etc.), the exception will propagate uncaught and schemaTypesOpen will never be set to true, leaving the UI silently stuck. The collections panel has the same gap, but this PR adds a second instance of the pattern rather than addressing it. Per project standards, errors should be surfaced using the createLogger utility rather than swallowed.

Suggested fix:

async function handleSchemaTypesClick() {
  if (schemaTypesOpen) {
    schemaTypesOpen = false;
    return;
  }
  if (subPanelOpen) {
    collectionsState.clearSelection();
  }
  try {
    schemas = await backendAdapter.getAllSchemas();
    schemaTypesOpen = true;
  } catch (err) {
    log.error('Failed to load schemas', err);
  }
}

[Improvement] — No tests for the new SchemaTypesSubPanel component or handleSchemaClick logic

File: schema-types-sub-panel.svelte, navigation-sidebar.svelte

The handleSchemaClick function contains meaningful tab deduplication logic (checking for an existing tab before creating a new one) that mirrors the pattern in handleNodeClick. No unit tests were added for this flow or for the panel's rendering/grouping logic (builtInSchemas/customSchemas derived state). The issue acceptance criteria explicitly lists "Tests pass (bun run test:all)" but this is checked by confirming the pre-existing suite passes — there is no new coverage for the new code paths.

Given the project's stated testing requirements, at minimum the $derived grouping logic and handleSchemaClick deduplication path should have unit coverage.


Nitpicks

  • Nit: schema-types-sub-panel.svelte lines 55–84 — The full 4-shape SVG icon is copy-pasted twice inside the schema list (once for built-in, once for custom items). Since the icon is identical for both groups, a single inline SVG snippet or a small local helper would eliminate the duplication and make future icon changes a single edit.

  • Nit: navigation-sidebar.svelte collapsed branch (lines 494–518) — The collapsed onclick only calls toggleSidebar(), identical to the Collections collapsed button. This is consistent with the existing Collections behavior, but neither item teaches the user why clicking the icon expands the sidebar. A title="Expand sidebar to access Schema Types" would be slightly more informative than the generic title="Schema Types" since the panel can only open when expanded.

  • Nit: The $effect blocks for collapse-close (lines 64–68 in the diff) and click-outside (lines 93–113) are structurally identical to the existing collections equivalents. As this sidebar grows, these repeated effect patterns will become harder to maintain. A future refactor into a small createSubPanelState() utility (returning open, toggle, and cleanup effects) would reduce the duplication significantly — worth tracking as a follow-up issue rather than blocking this PR.


Verdict

Approved with improvement suggestions. The error handling gap in handleSchemaTypesClick is the one item worth fixing before merge; the missing tests are a stronger concern than a nit but not blocking given the low complexity of the new logic and the greenfield context documented in CLAUDE.md. Everything else is clean, consistent with the codebase patterns, and correct.

@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.

Reviewed. Approving with two improvement suggestions documented in the comment above — error handling on getAllSchemas() and test coverage for the new component logic. Neither is a blocker given project context.

- Wrap getAllSchemas() in try/catch with createLogger error logging in
  handleSchemaTypesClick — prevents uncaught IPC failures from silently
  breaking the panel open state
- Deduplicate schema item SVG in schema-types-sub-panel by separating
  section label/separator conditionals from the #each loops

Skipped: tests for SchemaTypesSubPanel grouping logic and handleSchemaClick
deduplication — low-complexity derived state mirroring existing patterns,
worth a follow-up issue per greenfield context.

Skipped: $effect sub-panel utility refactor — future scope, not blocking.

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

malibio commented Mar 14, 2026

Copy link
Copy Markdown
Collaborator Author

Review Addressed

Addressed (2):

  • ✅ Added try/catch with createLogger error logging around getAllSchemas() in handleSchemaTypesClick — prevents uncaught IPC failures from silently breaking panel state
  • ✅ Deduplicated schema item SVG in schema-types-sub-panel.svelte — separated section label/separator conditionals from #each loops so the icon path is defined once per group

Skipped (3):

  • ⏭️ Tests for SchemaTypesSubPanel — low-complexity derived state mirroring existing patterns; worth a follow-up issue per greenfield context
  • ⏭️ Collapsed button title text — marginal UX value, not worth scope creep
  • ⏭️ $effect utility refactor — future scope, not blocking this PR

All 117 test files / 3704 tests still passing.

@malibio
malibio merged commit 3e4d92d into main Mar 14, 2026
@malibio
malibio deleted the feature/issue-940-schema-types-sidenav branch March 14, 2026 14:18
malibio added a commit that referenced this pull request Jun 22, 2026
* Add Schema Types sidenav item with panel listing available node types (closes #940)

- Add SchemaTypesSubPanel component with slide-out behavior matching CollectionSubPanel
- Show built-in types (task only) first, then custom schema types with section labels
- 4-shape icon (triangle, square, square, diamond) in specified viewBox style
- Clicking a schema type opens it as a new tab using BaseNodeViewer
- Click-outside and sidebar-collapse handlers close the panel automatically
- Panel handles empty state when no custom schemas are defined

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

* Address review: error handling and duplicate SVG cleanup

- Wrap getAllSchemas() in try/catch with createLogger error logging in
  handleSchemaTypesClick — prevents uncaught IPC failures from silently
  breaking the panel open state
- Deduplicate schema item SVG in schema-types-sub-panel by separating
  section label/separator conditionals from the #each loops

Skipped: tests for SchemaTypesSubPanel grouping logic and handleSchemaClick
deduplication — low-complexity derived state mirroring existing patterns,
worth a follow-up issue per greenfield context.

Skipped: $effect sub-panel utility refactor — future scope, not blocking.

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 item listing available node types

1 participant