Repository navigation
Description
Overview
Implement comprehensive query and listing system for NodeSpace, enabling users to create queries, view results in multiple formats (list, table, kanban), and persist view preferences. Primary use case is AI chat creating queries as child nodes.
Architecture References
- How to Add New Node Type:
docs/architecture/development/how-to-add-new-node-type.md - Node Behavior System:
docs/architecture/business-logic/node-behavior-system.md - Component Architecture Guide:
docs/architecture/components/component-architecture-guide.md - SurrealDB Schema Design:
docs/architecture/data/surrealdb-schema-design.md - Persistence Architecture:
docs/architecture/persistence-architecture.md
Epic Scope
This epic encompasses the complete query system from data model to user interface, designed for AI-first interaction with support for manual query creation.
Problem Statement
NodeSpace needs a way to create, store, execute, and view queries that filter/search nodes. The system must:
- Store structured query definitions as first-class nodes
- Execute queries efficiently against the database
- Present results in multiple view types (list, table, kanban)
- Remember user view preferences per query
- Support AI chat creating queries as child nodes
- Enable future inline query embeds without refactoring
Architecture Overview
┌─────────────────────────────────────────────────────────┐
│ QueryNode (Data) │
│ ┌───────────────────────────────────────────────────┐ │
│ │ Rust: QueryNodeBehavior in behaviors/mod.rs │ │
│ │ Schema: query spoke table (auto-generated) │ │
│ │ Content: Full QueryDefinition JSON │ │
│ └───────────────────────────────────────────────────┘ │
└─────────────────────────────────────────────────────────┘
↓
┌─────────────────────────────────────────────────────────┐
│ QueryService (Execution) │
│ ┌───────────────────────────────────────────────────┐ │
│ │ Core Rust Service: packages/core │ │
│ │ SurrealQL Query Building │ │
│ │ Hub-and-spoke query patterns │ │
│ └───────────────────────────────────────────────────┘ │
└─────────────────────────────────────────────────────────┘
↓
┌─────────────────────────────────────────────────────────┐
│ QueryNodeViewer (Presentation) │
│ ┌───────────────────────────────────────────────────┐ │
│ │ Specialized Viewer (like DateNodeViewer) │ │
│ │ View Tabs: List | Table | Kanban │ │
│ └───────────────────────────────────────────────────┘ │
│ ↓ │
│ ┌─────────────┬─────────────────┬─────────────────┐ │
│ │ ListView │ TableView │ KanbanView │ │
│ └─────────────┴─────────────────┴─────────────────┘ │
└─────────────────────────────────────────────────────────┘
↓
┌─────────────────────────────────────────────────────────┐
│ QueryPreferencesService (Persistence) │
│ ┌───────────────────────────────────────────────────┐ │
│ │ Last-used view per query │ │
│ │ localStorage + in-memory cache │ │
│ └───────────────────────────────────────────────────┘ │
└─────────────────────────────────────────────────────────┘
Implementation Plan
Phase 1: Foundation
-
QueryNode Behavior (QueryNode Behavior and Core Type Definitions #439)
- QueryNodeBehavior in
packages/core/src/behaviors/mod.rs - Core schema in
get_core_schemas() - TypeScript type definitions
- Frontend plugin definition
- QueryNodeBehavior in
-
QueryService (QueryService with SQL Query Execution #440)
- Core Rust service in
packages/core/src/services/ - SurrealQL query translation
- Property filters via spoke table (
data.property) - Relationship filters via graph edges
- Core Rust service in
Deliverable: QueryNode can be created and queries can be executed
Phase 2: User Interface
-
QueryNodeViewer (QueryNodeViewer with Multi-View Rendering Support #441)
- Specialized full-page viewer
- Multi-view rendering (list/table/kanban)
- Loading/error/empty states
-
QueryEditor (QueryEditor with JSON Textarea Interface #442)
- JSON textarea for query editing
- Validation and error display
- Query examples and templates
-
QueryPreferencesService (QueryPreferencesService for User View Preferences #443)
- Per-query view preferences
- localStorage persistence
- In-memory caching
Deliverable: Users can create, edit, and view queries with persisted preferences
Sub-Issues
Foundation
- QueryNode Behavior and Core Type Definitions #439 QueryNode Behavior and Core Type Definitions
- QueryService with SQL Query Execution #440 QueryService with SQL Query Execution
User Interface
- QueryNodeViewer with Multi-View Rendering Support #441 QueryNodeViewer with Multi-View Rendering Support
- QueryEditor with JSON Textarea Interface #442 QueryEditor with JSON Textarea Interface
- QueryPreferencesService for User View Preferences #443 QueryPreferencesService for User View Preferences
Acceptance Criteria
- QueryNode can be created and persisted
- Queries execute and return matching nodes
- Results render in list, table, and kanban views
- View tabs switch seamlessly
- User view preferences persist across sessions
- Query editor allows JSON editing with validation
- AI chat can create QueryNode children
- All tests pass (
bun run test:all) - Code passes
bun run quality:fix - Architecture supports future inline embeds
Key Design Decisions
1. Query vs View Separation
QueryNode stores ONLY query definition (no view preferences). Preferences stored via QueryPreferencesService (#443).
2. Specialized Viewer Pattern
QueryNodeViewer is specialized (like DateNodeViewer), NOT wrapping BaseNodeViewer. Different use case = different pattern.
3. Core Rust Service
QueryService in packages/core (not Tauri-specific). Reusable by Tauri commands, MCP servers, CLI tools.
4. JSON Editor First
Start with JSON textarea, not visual builder. Immediate functionality, full power, progressive enhancement path.
5. AI Query Ownership
AI-generated queries are children of chat nodes. Uses has_child graph edges for hierarchical organization.
Common Patterns to Follow
Component Naming:
*Node= Individual node components wrapping BaseNode*NodeViewer= Page-level viewers
Service Pattern:
- Singleton exported instance
- Async methods with error handling
- In-memory caching where appropriate
Type Safety:
- Discriminated unions for ViewConfig
- Explicit error types
- Proper null handling
Resources & References
Architecture Documentation
docs/architecture/development/how-to-add-new-node-type.mddocs/architecture/components/component-architecture-guide.mddocs/architecture/business-logic/node-behavior-system.md
Similar Implementations
- DateNodeViewer: Pattern reference for specialized viewers
- SharedNodeStore: Caching pattern reference
Technology Stack
- Backend: Rust with SurrealDB
- Frontend: Svelte 5.x with $state/$derived runes
- Testing: Vitest with Happy-DOM
Future Enhancements (Not in This Epic)
- Visual query builder UI
- Natural language query interface
- Inline query embeds in markdown
- Real-time query updates
- Query optimization and indexing
- Export functionality
Epic Status: Ready to Begin
Total Issues: 5 (all created and tracked)
Start Here: #439 (QueryNode Behavior)
Activity
Update how-to-add-new-node-type.md to reflect current architecture
Update how-to-add-new-node-type.md to reflect current architecture
Update how-to-add-new-node-type.md to reflect current architecture
feat: complete query system — property filters, editor, and preferenc…
Add property filter support to query_nodes MCP handler (#1044)
malibio commentedon Apr 5, 2026
All sub-issues complete (#439, #440, #441, #442, #443, #1036). Epic done.
Add property filter support to query_nodes MCP handler (#1044)