Skip to content

Complete @mention system with container node refactoring #199

Closed

Description

@malibio

Complete @mention System with Container Node Refactoring

Status: ✅ COMPLETE

Core functionality implemented in commits 764f4a4 and 246aa1b. Date picker functionality deferred to issue #201.

Overview

Complete the implementation of the @mention system for creating and linking nodes, including the container node concept refactoring and improved search logic.


✅ Completed Work

1. Initial @mention Implementation

Commits: dd6c698, dfc8e0b

  • Basic @mention autocomplete modal
  • Node creation from mentions
  • Node reference insertion as markdown links [title](nodespace://id)
  • Markdown rendering as clickable <a> tags
  • Code review fixes (error logging, helper functions, test improvements)

2. Schema Refactoring - Container Node Pattern

Commits: 8c2698e, e38692f

  • BREAKING: Renamed origin_node_id → container_node_id across entire stack
  • Updated database schema, Rust models, Tauri commands, TypeScript types
  • Rationale: "Container" better describes nodes that contain other nodes
  • Pattern: Container nodes have container_node_id = NULL (they ARE containers)
  • Inheritance: Child nodes inherit container_node_id from their container

3. Merge with Embedding Service

Commit: 764f4a4

4. Rust Backend API

Commit: 246aa1b

New Commands:

  • create_container_node() - Creates root-level container nodes with enforced pattern

    • Auto-generates UUID
    • Enforces: parent_id = NULL, container_node_id = NULL, before_sibling_id = NULL
    • Optional mentioned_by parameter creates mention relationship
  • create_mention() - Service method for managing mention relationships

    • Validates both nodes exist
    • Inserts into node_mentions table with INSERT OR IGNORE
  • create_node_mention() - Tauri command exposing mention creation to frontend

Files Modified:

  • packages/core/src/services/node_service.rs - Added create_mention() method
  • packages/desktop-app/src-tauri/src/commands/nodes.rs - Added new commands
  • packages/desktop-app/src-tauri/src/lib.rs - Registered commands in invoke handler

5. Frontend Implementation

Commit: 246aa1b

TypeScript/Svelte Changes:

  • Renamed originNodeId → containerNodeId across all files (17 files modified)
  • Updated isRootNode() → isContainerNode() with correct logic
  • Fixed @mention search logic: Now shows all non-text nodes (Tasks, Persons) + container text nodes

Search Logic (base-node.svelte):

// Show non-text nodes regardless of hierarchy
if (node.nodeType !== 'text') {
  return true;
}

// For text nodes, only show container nodes
const isContainer = node.containerNodeId === null;
return isContainer;

This enables @mention to discover:

  • ✅ All Task nodes (anywhere in hierarchy)
  • ✅ All Person nodes (anywhere in hierarchy)
  • ✅ Top-level text nodes (Topics/Projects/etc.)

Files Modified:

  • packages/desktop-app/src/lib/design/components/base-node.svelte - Search logic + helper
  • packages/desktop-app/src/lib/types/node.ts - Type definitions
  • All TypeScript services - Updated field names

6. Quality & Testing

  • ✅ All quality checks passing (oxlint, eslint, prettier, svelte-check, rustfmt, clippy)
  • ✅ 882/889 tests passing (7 failures are pre-existing unrelated issues)
  • ✅ Rust compilation verified with cargo check

📋 Deferred Work

Date Picker and Shortcuts → Issue #201

The following features were deferred to keep this issue focused on core functionality:

  • Date shortcuts (Today/Tomorrow/Yesterday) in @mention results
  • Date picker integration for "Date (pick)" option
  • Calendar component integration from design-system package

See: Issue #201 - Add date picker and shortcuts to @mention system


Acceptance Criteria

Core Functionality ✅

  • create_container_node() Rust function implemented and working
  • create_mention() service method implemented
  • TypeScript types updated to use containerNodeId
  • isContainerNode() helper renamed and updated
  • @mention search shows correct nodes (non-text + container text nodes)
  • All quality checks passing
  • Tests passing (882/889, failures are pre-existing)

Date Features → Issue #201

  • Date shortcuts (Today/Tomorrow/Yesterday) - Deferred
  • Date picker integration - Deferred

Technical Notes

Container Node Pattern

Container Node (DateNode "2024-01-15")
  ├─ containerNodeId: null (it IS a container)
  ├─ parentId: null
  │
  ├─ Child Note
  │   ├─ containerNodeId: "2024-01-15" (belongs to container)
  │   ├─ parentId: "2024-01-15"
  │   │
  │   └─ Grandchild
  │       ├─ containerNodeId: "2024-01-15" (inherited)
  │       └─ parentId: <child-id>

Mentions Table

CREATE TABLE node_mentions (
  mentioning_node_id TEXT NOT NULL,
  mentions_node_id TEXT NOT NULL,
  PRIMARY KEY (mentioning_node_id, mentions_node_id),
  FOREIGN KEY (mentioning_node_id) REFERENCES nodes(id) ON DELETE CASCADE,
  FOREIGN KEY (mentions_node_id) REFERENCES nodes(id) ON DELETE CASCADE
);

Search Behavior

The @mention search now correctly:

  1. Shows all non-text nodes (Tasks, Persons) regardless of where they are in the hierarchy
  2. Shows only container text nodes (top-level Topics/Projects)
  3. Excludes date nodes (they're accessed via date shortcuts - see Add date picker and shortcuts to @mention system #201)
  4. Filters by query text in title or content

Related Issues

Branch

feature/issue-199-mention-system-container-nodes

Commits

  • dd6c698 - Initial @mention implementation
  • dfc8e0b - Code review fixes
  • 8c2698e - Schema refactoring (origin_node_id → container_node_id)
  • e38692f - Formatting
  • 764f4a4 - Merge origin/main with container_node_id refactoring
  • 246aa1b - Implement container node pattern and @mention improvements

Activity

  1. self-assigned this
    on Oct 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions