Skip to content

Add date picker and shortcuts to @mention system #201

Closed

Description

@malibio

Add Date Picker and Shortcuts to @mention System

Overview

Enhance the @mention autocomplete system with date-specific functionality including a date picker and quick shortcuts for Today/Tomorrow/Yesterday.

Context

This work was deferred from issue #199 to keep the core container node refactoring focused. The @mention system now properly supports discovering all node types, and this issue adds the final date-related UX enhancements.

Requirements

1. Date Shortcuts in Autocomplete

Add shortcuts at the top of @mention results that always appear (filtered by query):

  • @Today → Creates/links to today's DateNode (YYYY-MM-DD format)
  • @Tomorrow → Creates/links to tomorrow's DateNode
  • @Yesterday → Creates/links to yesterday's DateNode
  • Date (pick) → Opens date picker modal

Implementation Location: packages/desktop-app/src/lib/design/components/base-node.svelte

const dateShortcuts = [
  { id: 'today', title: 'Today', type: 'date', isShortcut: true },
  { id: 'tomorrow', title: 'Tomorrow', type: 'date', isShortcut: true },
  { id: 'yesterday', title: 'Yesterday', type: 'date', isShortcut: true },
  { id: 'date-picker', title: 'Date (pick)', type: 'date', isShortcut: true },
].filter(shortcut => 
  shortcut.title.toLowerCase().includes(query.toLowerCase())
);

// Combine: shortcuts first, then search results
autocompleteResults = [...dateShortcuts, ...searchResults];

2. Date Picker Integration

When user selects "Date (pick)" from @mention:

  1. Close autocomplete modal
  2. Show date picker popover at cursor position
  3. Use calendar component from @nodespace/design-system
  4. On date selection:
    • Format as YYYY-MM-DD
    • Create DateNode if it doesn't exist (using create_container_node)
    • Insert reference like [2025-10-15](nodespace://2025-10-15)

Component: Use calendar from packages/design-system/src/lib/components/ui/calendar/

import { Calendar } from '@nodespace/design-system';

3. Date Formatting Logic

Convert shortcuts to actual dates:

function getDateFromShortcut(shortcut: string): string {
  const today = new Date();
  
  switch (shortcut) {
    case 'today':
      return formatDate(today);
    case 'tomorrow':
      const tomorrow = new Date(today);
      tomorrow.setDate(today.getDate() + 1);
      return formatDate(tomorrow);
    case 'yesterday':
      const yesterday = new Date(today);
      yesterday.setDate(today.getDate() - 1);
      return formatDate(yesterday);
    default:
      return formatDate(today);
  }
}

function formatDate(date: Date): string {
  return date.toISOString().split('T')[0]; // YYYY-MM-DD
}

4. DateNode Creation

Use the new create_container_node Rust command from #199:

await invoke('create_container_node', {
  input: {
    content: dateStr, // e.g., "2025-10-15"
    nodeType: 'date',
    properties: {},
    mentionedBy: currentNodeId // Optional: current node mentions this date
  }
});

Acceptance Criteria

  • Date shortcuts (Today/Tomorrow/Yesterday) appear at top of @mention results
  • Date shortcuts filter based on user's query text
  • "Date (pick)" option opens calendar picker at cursor position
  • Calendar picker allows selecting any date
  • Selected date creates DateNode if it doesn't exist
  • Date reference is inserted as markdown link: [YYYY-MM-DD](nodespace://YYYY-MM-DD)
  • Clicking date reference navigates to that date's page
  • All tests passing
  • Quality checks passing

Technical Notes

Calendar Positioning

The date picker should appear near the cursor position, similar to how the autocomplete modal works. Use the same positioning logic from node-autocomplete.svelte.

DateNode Existence Check

Before creating a DateNode, check if it already exists:

const existingNode = await invoke('get_node', { id: dateStr });
if (!existingNode) {
  await invoke('create_container_node', { input: { ... } });
}

Visual Design

  • Date shortcuts should have a calendar icon
  • "Date (pick)" should be visually distinct (perhaps with a different color or icon)
  • Calendar picker should match the design system's theming

Dependencies

Related Files

  • packages/desktop-app/src/lib/design/components/base-node.svelte - Main implementation
  • packages/desktop-app/src/lib/components/ui/node-autocomplete/node-autocomplete.svelte - Autocomplete UI
  • packages/design-system/src/lib/components/ui/calendar/ - Calendar component

Priority

Medium - UX enhancement that improves date node discovery and creation

Activity

  1. added
    enhancement
    on Oct 10, 2025
  2. self-assigned this
    on Oct 30, 2025
  3. added 5 commits that reference this issue on Oct 30, 2025
    c02e1bf
    de3892b
    a623a4b
    452f644
    4bcd4d3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

enhancementui

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions