Repository navigation
Description
Overview
Implement QueryNodeViewer component as a specialized full-page viewer with a Table view (primary). The viewer loads a QueryNode by its nodeId, derives the target type and column definitions from the associated schema, executes the query, and renders results in a table. Rows are clickable to open nodes in another panel.
This viewer is also the target for Schema Types sidenav navigation — clicking a schema type (e.g. "task") opens a tab routed to QueryNodeViewer with the schema's nodeId. Since every schema is itself a node, no synthetic config is needed: the schema's nodeId is passed directly.
Architecture References
- Component Architecture:
packages/desktop-app/src/lib/design/components/—*Node/*NodeViewerpatterns - Plugin Registry:
packages/desktop-app/src/lib/plugins/core-plugins.ts— line 528,queryNodePluginviewer registration (TODO comment) - Pane Routing:
packages/desktop-app/src/lib/components/layout/pane-content.svelte— viewer dispatch via plugin registry - Query Types:
packages/desktop-app/src/lib/types/query.ts—QueryNode,TableViewConfig,ColumnConfig - Schema Types:
packages/desktop-app/src/lib/types/schema-node.ts—SchemaNode,isSchemaNode()
Problem Statement
Users need to view all nodes of a given type in a structured table format. The QueryNodeViewer is the canonical component for this — driven by a QueryNode's nodeId, it fetches the associated schema to determine columns, executes the query filtered by targetType, and renders results. Clicking a row opens the node for editing in another panel.
Component Naming Convention
*Node= Individual node component wrapping BaseNode*NodeViewer= Page-level viewer (like DateNodeViewer, CollectionNodeViewer)
QueryNodeViewer is a specialized viewer — does NOT wrap BaseNodeViewer, because it shows flat query results rather than a hierarchical node collection.
Key Design Decisions
Everything is a Node
A QueryNode has a nodeId. A schema type (e.g. "task") also has a nodeId. When the Schema Types sidenav opens a query view for a type, it passes the schema's nodeId — QueryNodeViewer loads the schema node, reads targetType from it, fetches column definitions from the schema's property definitions, and executes the query.
No synthetic/ephemeral query configs. No special cases. The schema node IS the query definition for type-based views.
Column Definitions from Schema
Columns are derived from the schema definition for targetType — not by enumerating property keys from result nodes (non-deterministic, poor UX). TableViewConfig.columns overrides schema-derived defaults when present, enabling future user customization.
Row Click Navigation
Clicking a row title/content opens the node via navigateToNodeInOtherPane() — splits the pane or uses the existing other pane. This matches the established cmd+click pattern used throughout the app.
Proposed Solution
Component Structure
QueryNodeViewer (page-level, manages state)
└─ TableView (primary view, pure rendering)
└─ rows with clickable title → navigateToNodeInOtherPane()
List and Kanban views are non-goals for this issue (future enhancement).
QueryNodeViewer Component
File: packages/desktop-app/src/lib/components/viewers/query-node-viewer.svelte
<script lang="ts">
import { onMount } from 'svelte';
import { sharedNodeStore } from '$lib/services/shared-node-store';
import { backendAdapter } from '$lib/services/backend-adapter';
import { getNavigationService } from '$lib/services/navigation-service';
import TableView from '$lib/components/query/table-view.svelte';
import type { Node } from '$lib/types/nodes';
import type { SchemaNode } from '$lib/types/schema-node';
let { nodeId, paneId }: { nodeId: string; paneId?: string } = $props();
let schemaNode = $state<SchemaNode | null>(null);
let results = $state<Node[]>([]);
let queryState = $state<'idle' | 'loading' | 'success' | 'error'>('idle');
let error = $state<string | null>(null);
onMount(async () => {
// nodeId is the schema node's id (e.g. the "task" schema node)
// Load schema to get targetType and column definitions
const node = await sharedNodeStore.get(nodeId);
schemaNode = node as SchemaNode;
await executeQuery();
});
async function executeQuery() {
if (!schemaNode) return;
queryState = 'loading';
try {
// Query all nodes of this type
results = await backendAdapter.getNodesByType(schemaNode.id);
queryState = 'success';
} catch (e) {
error = (e as Error).message;
queryState = 'error';
}
}
function handleRowClick(clickedNodeId: string) {
getNavigationService().navigateToNodeInOtherPane(clickedNodeId, paneId);
}
</script>
<div class="query-node-viewer">
<header class="query-header">
<h1>{schemaNode?.content ?? 'Loading...'}</h1>
<button onclick={executeQuery}>Refresh</button>
</header>
{#if queryState === 'loading'}
<div class="loading-state">Loading...</div>
{:else if queryState === 'error'}
<div class="error-state">{error} <button onclick={executeQuery}>Retry</button></div>
{:else if results.length === 0}
<div class="empty-state">No nodes of this type yet.</div>
{:else}
<TableView {results} schema={schemaNode} onRowClick={handleRowClick} />
{/if}
</div>TableView Component
File: packages/desktop-app/src/lib/components/query/table-view.svelte
- Derives columns from
schema.properties(schema-driven, not property key enumeration) - Always includes
content(title) as the first column — rendered as a clickable link - Additional columns: one per schema property definition, in schema order
- Cell values: read from
node.properties[columnKey], rendered as plain text (formatted by type) - Clicking the title/content cell calls
onRowClick(node.id)
Plugin Registration
Register QueryNodeViewer in core-plugins.ts for nodeType: 'query' (the TODO at line 528).
Acceptance Criteria
-
QueryNodeViewerloads a schema node bynodeIdand displays itscontentas the page title - Executes a query for all nodes matching
targetType(the schema's type id) -
TableViewderives columns from schema property definitions — not from enumerating result node keys - First column is always
content(title), rendered as a clickable element - Clicking a row's title calls
navigateToNodeInOtherPane()— opens node in other panel (split if needed) - Loading, error, and empty states handled
- Refresh button re-executes the query
-
QueryNodeViewerregistered in plugin registry fornodeType: 'query' - List and Kanban views are NOT in scope (future issues)
- Tests pass (
bun run test:all) - Code passes
bun run quality:fix
Technical Specifications
Files to Create
packages/desktop-app/src/lib/components/viewers/query-node-viewer.sveltepackages/desktop-app/src/lib/components/query/table-view.svelte
Files to Modify
packages/desktop-app/src/lib/plugins/core-plugins.ts— register QueryNodeViewer fornodeType: 'query'
Reference Components
packages/desktop-app/src/lib/components/viewers/collection-node-viewer.svelte— loading/error/empty state patternpackages/desktop-app/src/lib/components/viewers/date-node-viewer.svelte— specialized viewer patternpackages/desktop-app/src/lib/services/navigation-service.ts—navigateToNodeInOtherPane()(lines 320–388)
Non-Goals
- List view and Kanban view (future issues)
- Query editing UI (QueryEditor with JSON Textarea Interface #442)
- View preference persistence (QueryPreferencesService for User View Preferences #443)
- Column sorting/filtering in the table (future enhancement)
- Virtual scrolling (add if performance issues arise)
- Inline embedded query views (future)
Activity
Address review: Fix test counts and improve consistency
QueryNode Behavior and Core Type Definitions (#719)
QueryNode Behavior and Core Type Definitions (#719)
QueryNode Behavior and Core Type Definitions (#719)
QueryNode Behavior and Core Type Definitions (#719)
malibio commentedon Mar 16, 2026
Frontend baseline: 118 test files, 3719 tests passed
feat: QueryNodeViewer with TableView rendering support (closes #441)
QueryNodeViewer with Multi-View Rendering Support (#961)