-
-
Notifications
You must be signed in to change notification settings - Fork 6
feat: Add calendar UI with place/time context integration #371
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
ngoiyaeric
wants to merge
2
commits into
main
Choose a base branch
from
feature/calendar-place-time-context
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,169 @@ | ||
| # Calendar UI Enhancement with Place/Time Context | ||
|
|
||
| ## Overview | ||
|
|
||
| This enhancement adds comprehensive place and time context management to the QCX calendar system, integrating with Mapbox MCP to provide structured location and temporal information. | ||
|
|
||
| ## Features | ||
|
|
||
| ### 1. Enhanced Time Management | ||
| - **Time Picker**: Select specific time (HH:MM:SS) for calendar notes | ||
| - **Timezone Support**: Choose from 20+ common timezones | ||
| - **Auto-detection**: Automatically detects user's current timezone | ||
|
|
||
| ### 2. Location Tagging with Mapbox MCP | ||
| - **Map Integration**: Tag notes with current map position | ||
| - **Geocoding**: Automatically fetches place names using Mapbox MCP | ||
| - **Visual Feedback**: Shows tagged coordinates in real-time | ||
|
|
||
| ### 3. Structured Context Format | ||
| All location-tagged notes display context in the standardized format: | ||
| ``` | ||
| latitude, longitude TIME (HH:MM:SS): DD/MM/YYYY Timezone | ||
| ``` | ||
|
|
||
| Example: | ||
| ``` | ||
| 40.758896, -73.985130 TIME (14:30:45): 20/11/2025 America/New_York | ||
| ``` | ||
|
|
||
| ## Implementation Details | ||
|
|
||
| ### Database Schema Changes | ||
|
|
||
| Added `timezone` field to `calendar_notes` table: | ||
| ```sql | ||
| ALTER TABLE calendar_notes ADD COLUMN timezone VARCHAR(100); | ||
| ``` | ||
|
|
||
| ### New Components | ||
|
|
||
| 1. **CalendarNotepadEnhanced** (`components/calendar-notepad-enhanced.tsx`) | ||
| - Enhanced version of the calendar notepad | ||
| - Includes time and timezone selectors | ||
| - Integrates with Mapbox MCP for geocoding | ||
|
|
||
| 2. **Calendar Context Utilities** (`lib/utils/calendar-context.ts`) | ||
| - `formatPlaceTimeContext()`: Formats notes into standardized context string | ||
| - `parsePlaceTimeContext()`: Parses context strings back into components | ||
| - `createGeoJSONPoint()`: Creates GeoJSON Point objects | ||
| - `getCurrentTimezone()`: Gets user's current timezone | ||
| - `COMMON_TIMEZONES`: List of 20+ common timezones | ||
|
|
||
| ### Updated Files | ||
|
|
||
| - `lib/db/schema.ts`: Added timezone field | ||
| - `lib/types/index.ts`: Updated CalendarNote type | ||
| - `components/chat.tsx`: Switched to CalendarNotepadEnhanced | ||
| - `drizzle/migrations/0002_add_timezone_to_calendar_notes.sql`: Migration file | ||
|
|
||
| ## Usage | ||
|
|
||
| ### Creating a Note with Location and Time | ||
|
|
||
| 1. Open the calendar view in QCX | ||
| 2. Select the desired date from the date picker | ||
| 3. Set the time using the time picker (defaults to current time) | ||
| 4. Select the appropriate timezone | ||
| 5. Navigate the map to your desired location | ||
| 6. Click the MapPin icon to tag the location | ||
| 7. Type your note content | ||
| 8. Press Cmd+Enter (Mac) or Ctrl+Enter (Windows) to save | ||
|
|
||
| ### Viewing Notes | ||
|
|
||
| Notes with location tags display: | ||
| - The note content | ||
| - A formatted context string with coordinates, time, date, and timezone | ||
| - A MapPin button to fly to the location on the map | ||
|
|
||
| ### Mapbox MCP Integration | ||
|
|
||
| The calendar automatically integrates with Mapbox MCP when available: | ||
| - **Connected**: Automatically geocodes coordinates to place names | ||
| - **Disconnected**: Falls back to simple coordinate tagging | ||
|
|
||
| ## API | ||
|
|
||
| ### formatPlaceTimeContext(note: CalendarNote): string | ||
|
|
||
| Formats a calendar note into the standardized context string. | ||
|
|
||
| **Parameters:** | ||
| - `note`: CalendarNote object with locationTags | ||
|
|
||
| **Returns:** | ||
| - Formatted string: `"lat, lng TIME (HH:MM:SS): DD/MM/YYYY Timezone"` | ||
| - Empty string if no location tags | ||
|
|
||
| ### parsePlaceTimeContext(contextString: string): object | null | ||
|
|
||
| Parses a context string back into components. | ||
|
|
||
| **Parameters:** | ||
| - `contextString`: Formatted context string | ||
|
|
||
| **Returns:** | ||
| ```typescript | ||
| { | ||
| latitude: number | ||
| longitude: number | ||
| time: string // HH:MM:SS | ||
| date: string // DD/MM/YYYY | ||
| timezone: string | ||
| } | ||
| ``` | ||
|
|
||
| ## Supported Timezones | ||
|
|
||
| The system supports 20+ common timezones including: | ||
| - UTC | ||
| - Americas: New York, Chicago, Denver, Los Angeles, Toronto, Mexico City, São Paulo | ||
| - Europe: London, Paris, Berlin, Moscow | ||
| - Asia: Dubai, Kolkata, Shanghai, Tokyo, Seoul, Singapore | ||
| - Oceania: Sydney, Auckland | ||
|
|
||
| ## Migration | ||
|
|
||
| To apply the database changes: | ||
|
|
||
| ```bash | ||
| bun run db:migrate | ||
| ``` | ||
|
|
||
| Or manually run the migration: | ||
| ```bash | ||
| psql -d your_database -f drizzle/migrations/0002_add_timezone_to_calendar_notes.sql | ||
| ``` | ||
|
|
||
| ## Testing | ||
|
|
||
| The enhanced calendar can be tested by: | ||
| 1. Creating notes with different times and timezones | ||
| 2. Tagging locations from the map | ||
| 3. Verifying the context string format | ||
| 4. Flying to tagged locations | ||
| 5. Testing with and without Mapbox MCP connection | ||
|
|
||
| ## Future Enhancements | ||
|
|
||
| Potential improvements: | ||
| - Recurring events support | ||
| - Calendar export (iCal format) | ||
| - Time range queries | ||
| - Timezone conversion display | ||
| - Location-based note search | ||
| - Integration with external calendar services | ||
|
|
||
| ## Dependencies | ||
|
|
||
| - Mapbox MCP server (optional, for enhanced geocoding) | ||
| - Mapbox GL JS (for map integration) | ||
| - Lucide React (for icons) | ||
| - Drizzle ORM (for database) | ||
|
|
||
| ## Compatibility | ||
|
|
||
| - Works with existing calendar notes (timezone defaults to UTC) | ||
| - Backward compatible with original CalendarNotepad | ||
| - Mobile and desktop responsive | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧹 Nitpick | 🔵 Trivial
Clean up markdownlint issues (headings, fenced blocks, and clarify UTC default wording)
A few small doc nits:
Add blank lines before/after headings like lines 9, 14, 19 to satisfy MD022.
Ensure fenced blocks are surrounded by blank lines (e.g., around the context-format example and TypeScript object snippet).
Add explicit languages to bare code fences:
text:-
-latitude, longitude TIME (HH:MM:SS): DD/MM/YYYY Timezone -+
text +latitude, longitude TIME (HH:MM:SS): DD/MM/YYYY Timezone +note.timezone || 'UTC'when formatting the context string), not as a DB default. Consider rephrasing to something like “notes without an explicit timezone are displayed as UTC” to avoid implying a stored DB default.Also applies to: 35-37, 107-115, 130-137
🧰 Tools
🪛 markdownlint-cli2 (0.18.1)
9-9: Headings should be surrounded by blank lines
Expected: 1; Actual: 0; Below
(MD022, blanks-around-headings)
14-14: Headings should be surrounded by blank lines
Expected: 1; Actual: 0; Below
(MD022, blanks-around-headings)
19-19: Headings should be surrounded by blank lines
Expected: 1; Actual: 0; Below
(MD022, blanks-around-headings)
21-21: Fenced code blocks should be surrounded by blank lines
(MD031, blanks-around-fences)
21-21: Fenced code blocks should have a language specified
(MD040, fenced-code-language)
26-26: Fenced code blocks should be surrounded by blank lines
(MD031, blanks-around-fences)
26-26: Fenced code blocks should have a language specified
(MD040, fenced-code-language)
🤖 Prompt for AI Agents