Skip to content

Create Tauri command layer for desktop app integration #110

Closed

Description

@malibio

Overview

Create Tauri command layer for Text, Task, and Date nodes (initial E2E testing scope), including database path configuration.

Scope: Text/Task/Date Nodes Only

This issue focuses on exposing Text, Task, and Date node operations to the frontend for E2E testing. Person and Project node commands will be added in separate issues after E2E testing is complete.

Database Path Management

User-Selectable Database Location:

  • Provide folder picker for users to choose database location
  • Default to platform-specific app data directory if not selected
  • Save user preference for subsequent launches
  • Support cloud-synced folders (Dropbox, iCloud, etc.) for automatic backup

Implementation Tasks

  • Create Tauri commands for NodeService operations (Text/Task/Date only)
  • Add database path selection command with folder picker
  • Implement preference storage for database location
  • Add database initialization with user-selected or default path
  • Add error mapping from Rust errors to Tauri responses
  • Implement state management for DatabaseService and NodeService instances

Acceptance Criteria

  • select_db_location command with native folder picker
  • Database path preference saved and loaded correctly
  • Default app data directory fallback when no preference exists
  • CRUD operations for Text/Task/Date nodes exposed as Tauri commands
  • Hierarchy operations accessible from frontend (get_children, move_node)
  • Error handling provides clear messages to frontend
  • DatabaseService and NodeService properly managed in Tauri state
  • Database works in user-selected locations (including cloud folders)

Technical Specifications

Database Path Commands:
```rust
use tauri::Manager;
use tauri_plugin_dialog::DialogExt;
use crate::db::DatabaseService;
use crate::services::NodeService;

#[tauri::command]
async fn select_db_location(app: AppHandle) -> Result<String, String> {
let folder = app.dialog()
.file()
.pick_folder()
.await
.map_err(|e| e.to_string())?;

let db_path = folder.join("nodespace.db");

// Save preference
save_db_path_preference(&app, &db_path)?;

// Initialize services
let db_service = DatabaseService::new(db_path.clone()).await
    .map_err(|e| e.to_string())?;
let node_service = NodeService::new(db_service.clone()).await
    .map_err(|e| e.to_string())?;

// Store in Tauri state
app.manage(db_service);
app.manage(node_service);

Ok(db_path.to_string_lossy().to_string())

}

#[tauri::command]
async fn initialize_database(app: AppHandle) -> Result<(), String> {
let db_path = if let Some(saved) = load_db_path_preference(&app)? {
saved
} else {
app.path()
.app_data_dir()
.map_err(|e| e.to_string())?
.join("nodespace.db")
};

let db_service = DatabaseService::new(db_path).await
    .map_err(|e| e.to_string())?;
let node_service = NodeService::new(db_service.clone()).await
    .map_err(|e| e.to_string())?;

app.manage(db_service);
app.manage(node_service);
Ok(())

}
```

Node CRUD Commands (Text/Task/Date only):
```rust
#[tauri::command]
async fn create_node(
service: State<'_, NodeService>,
node: Node
) -> Result<String, String> {
// Validate node_type is text, task, or date
if !["text", "task", "date"].contains(&node.node_type.as_str()) {
return Err("Only text, task, and date nodes are supported".to_string());
}

service.create_node(node).await
    .map_err(|e| e.to_string())

}

#[tauri::command]
async fn get_node(
service: State<'_, NodeService>,
id: String
) -> Result<Option, String> {
service.get_node(&id).await
.map_err(|e| e.to_string())
}

#[tauri::command]
async fn update_node(
service: State<'_, NodeService>,
id: String,
update: NodeUpdate
) -> Result<(), String> {
service.update_node(&id, update).await
.map_err(|e| e.to_string())
}

#[tauri::command]
async fn delete_node(
service: State<'_, NodeService>,
id: String
) -> Result<(), String> {
service.delete_node(&id).await
.map_err(|e| e.to_string())
}

#[tauri::command]
async fn get_children(
service: State<'_, NodeService>,
parent_id: String
) -> Result<Vec, String> {
service.get_children(&parent_id).await
.map_err(|e| e.to_string())
}
```

Frontend Usage:
```typescript
import { invoke } from '@tauri-apps/api/core';

// Let user choose database location
const dbPath = await invoke('select_db_location');

// Or use default location
await invoke('initialize_database');

// Create Text node
const textNode = await invoke('create_node', {
node: {
node_type: 'text',
content: 'Hello World',
...
}
});

// Create Task node
const taskNode = await invoke('create_node', {
node: {
node_type: 'task',
content: 'Complete feature',
properties: { status: 'pending', priority: 2 }
}
});

// Create Date node
const dateNode = await invoke('create_node', {
node: {
node_type: 'date',
content: '2025-01-15',
id: '2025-01-15' // deterministic
}
});
```

Dependencies:

Related Issues

This provides the Tauri integration for Text/Task/Date E2E testing before expanding to other node types.

Activity

  1. self-assigned this
    on Oct 3, 2025
  2. added a commit that references this issue on Oct 3, 2025
    34bd4c7
  3. added 2 commits that reference this issue on Feb 4, 2026
    d2655eb
    e6cfcf7
  4. added a commit that references this issue on Feb 26, 2026
    121b58c
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