Skip to content

Implement nodespace:// Link Navigation with Dynamic Tab Creation #297

Closed

Description

@malibio

Problem Statement

Users can create nodespace://{node-uuid} links via the @mention system, but clicking these links currently does nothing. We need to implement a navigation handler that:

  1. Intercepts clicks on nodespace:// links
  2. Resolves the node UUID to determine the appropriate viewer type
  3. Regular Click: Navigate within current tab (browser-like behavior) ✨
  4. Cmd+Click: Create new tab or switch to existing tab for side-by-side viewing
  5. Supports Cmd+Click for opening in a new tab vs. regular click for current tab

📝 Implementation Note: The final implementation uses in-tab navigation for regular clicks instead of tab switching. This provides a more intuitive browser-like experience where clicking links navigates within the current context, while Cmd+Click allows opening in new tabs for comparison.

This is the foundation for the entire tab management system - without link navigation, users cannot leverage the multi-tab architecture.

Current State

What Already Exists:

  • ✅ nodespace://{uuid} links created by @mention system
  • ✅ Basic tab system (tab-system.svelte) with keyboard navigation
  • ✅ Tab store (navigation.ts) with addTab(), setActiveTab(), closeTab()
  • ✅ Multiple viewer types: DateNodeViewer, TaskNodeViewer, TextNodeViewer, AIChatNodeViewer (all verified to exist)
  • ✅ SharedNodeStore with synchronous getNode(nodeId) API
  • ✅ Current routing in /packages/desktop-app/src/routes/+page.svelte

What's Missing:

  • ❌ Click handler for nodespace:// links
  • ❌ Service to resolve node UUID → node type → appropriate viewer
  • ❌ Logic to create/switch tabs dynamically
  • ❌ Cmd+Click support for new tab behavior

[Rest of issue content remains the same...]

Activity

  1. self-assigned this
    on Oct 20, 2025
  2. added a commit that references this issue on Oct 20, 2025
    e4f71e0
  3. malibio commented on Oct 20, 2025

    @malibio
    CollaboratorAuthor

    Implementation Learnings from PR #306

    PR #306 was closed due to fundamental architectural issues. Here are the critical lessons learned:

    Critical Issues Discovered

    1. Module-Level Singleton Exports Cause App Freeze

    // ❌ BAD - Blocks entire app initialization
    export const navigationService = NavigationService.getInstance();
    
    // ✅ GOOD - Lazy initialization
    export function getNavigationService(): NavigationService {
      return NavigationService.getInstance();
    }
    • Module-level singleton exports execute immediately when imported
    • This triggers dependency chain: navigationService → sharedNodeStore → tauriNodeService → backendAdapter → eventBus
    • Result: Complete app freeze before browser can render anything

    2. Top-Level Component Imports Load Everything Eagerly

    // ❌ BAD - Loads all viewers immediately, even unused ones
    import TaskNodeViewer from '$lib/components/viewers/task-node-viewer.svelte';
    import TextNodeViewer from '$lib/components/viewers/text-node-viewer.svelte';
    import AIChatNodeViewer from '$lib/components/viewers/ai-chat-node-viewer.svelte';
    • Unused viewer components were imported at startup
    • One had a Svelte reactive loop bug (effect_update_depth_exceeded)
    • Should use plugin-driven lazy loading instead

    3. Architectural Flaw: Hardcoded Imports

    • Viewers should be discovered via plugin registry, not hardcoded
    • Plugin system should dynamically load the correct viewer for each node type
    • Only DateNodeViewer should load on startup (for Today tab)

    Recommended Approach for Fresh Implementation

    Phase 1: Click Handler Only

    • Add global click handler in app-shell.svelte
    • Console.log nodespace:// clicks
    • No actual navigation yet
    • Test: Verify clicks are intercepted

    Phase 2: Plugin-Based Viewer Discovery

    • Query plugin registry for available viewers
    • No hardcoded imports
    • Test: Verify correct viewer is identified for each node type

    Phase 3: Tab Creation (Placeholder Content)

    • Create tabs dynamically
    • Render simple placeholder text (no actual viewer components)
    • Test: Verify tab switching works

    Phase 4: Dynamic Viewer Loading

    • Use plugin registry to lazy-load viewer components
    • Test each viewer type individually

    Key Principles

    1. ✅ Incremental implementation - Test each phase independently
    2. ✅ Plugin-driven - No hardcoded viewer imports
    3. ✅ Lazy loading - Only load what's needed, when it's needed
    4. ✅ Avoid module-level singletons - Use getter functions
    5. ✅ One change at a time - Don't compound architectural changes

    This approach will prevent the cascading failures we encountered in PR #306.

  4. 85 remaining items

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