Skip to content

Note date change#1236

Merged
duckduckhero merged 5 commits intomainfrom
note-date-change
Jul 30, 2025
Merged

Note date change#1236
duckduckhero merged 5 commits intomainfrom
note-date-change

Conversation

@duckduckhero
Copy link
Contributor

No description provided.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jul 29, 2025

📝 Walkthrough

Walkthrough

The EventChip component was refactored to introduce a tabbed popover interface for managing event linking and session date editing. New utility functions, state management, and mutations for event detachment and date changes were added. Localization files were updated with new translation keys and adjusted source references.

Changes

Cohort / File(s) Change Summary
EventChip Refactor & Feature Expansion
apps/desktop/src/components/editor-area/note-header/chips/event-chip.tsx
Major refactor of EventChip introducing tabbed UI for event linking and date editing, new utility functions, state management, event detachment mutation, and extracted EventTab/DateTab components. Improved cache handling and UI consistency.
Localization Updates (English)
apps/desktop/src/locales/en/messages.po
Updated source references for several translation entries; added two new translation keys ("Save Date", "Saving..."). No changes to translation strings.
Localization Updates (Korean)
apps/desktop/src/locales/ko/messages.po
Updated source references for several translation entries; added two new untranslated message IDs ("Save Date", "Saving..."). No changes to translation strings.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant EventChip
    participant EventTab
    participant DateTab
    participant Backend

    User->>EventChip: Clicks event chip
    EventChip-->>User: Opens popover (event details or tabbed interface)
    alt Event linked
        User->>EventChip: Clicks "Detach Event"
        EventChip->>Backend: Send detachEvent mutation
        Backend-->>EventChip: Responds (success/error)
        EventChip-->>User: Updates UI
    else No event linked
        User->>EventChip: Selects "Add Event" or "Change Date" tab
        alt Add Event tab
            User->>EventTab: Searches/selects event
            EventTab->>Backend: Assign event mutation
            Backend-->>EventTab: Responds (success/error)
            EventTab-->>EventChip: onSuccess callback
            EventChip-->>User: Updates UI
        else Change Date tab
            User->>DateTab: Picks new date, clicks "Save Date"
            DateTab->>Backend: Update date mutation
            Backend-->>DateTab: Responds (success/error)
            DateTab-->>EventChip: onSuccess callback
            EventChip-->>User: Updates UI
        end
    end
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~40 minutes

Possibly related PRs

  • Fix Event Assignment to New Note #1054: Refactors cache update logic and query synchronization for event assignment/detachment in EventChip, directly overlapping with the event linking and detachment logic in this PR.

Note

⚡️ Unit Test Generation is now available in beta!

Learn more here, or try it out under "Finishing Touches" below.

✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch note-date-change

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

‼️ IMPORTANT
Auto-reply has been disabled for this repository in the CodeRabbit settings. The CodeRabbit bot will not respond to your replies unless it is explicitly tagged.

  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai generate unit tests to generate unit tests for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 4

🧹 Nitpick comments (1)
apps/desktop/src/components/editor-area/note-header/chips/event-chip.tsx (1)

72-86: Add user notification for detach event errors.

The error is only logged to console. Users should be notified when the operation fails.

Consider adding a toast notification or error message display when the detach operation fails, so users are aware of the issue.

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between d0cb012 and 5240069.

📒 Files selected for processing (3)
  • apps/desktop/src/components/editor-area/note-header/chips/event-chip.tsx (5 hunks)
  • apps/desktop/src/locales/en/messages.po (5 hunks)
  • apps/desktop/src/locales/ko/messages.po (5 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
**/*.{js,ts,tsx,rs}

⚙️ CodeRabbit Configuration File

**/*.{js,ts,tsx,rs}: 1. No error handling.
2. No unused imports, variables, or functions.
3. For comments, keep it minimal. It should be about "Why", not "What".

Files:

  • apps/desktop/src/components/editor-area/note-header/chips/event-chip.tsx
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: ci (macos, macos-latest)
  • GitHub Check: ci (windows, windows-latest)
🔇 Additional comments (2)
apps/desktop/src/locales/en/messages.po (1)

1203-1206: LGTM!

The English translations for the new date editing UI elements are properly added.

Also applies to: 1211-1214

apps/desktop/src/components/editor-area/note-header/chips/event-chip.tsx (1)

287-435: Well-implemented event selection logic.

The EventTab component has proper error handling, cache management, and handles the edge case of updating blank session titles when an event is assigned. The filtering and sorting logic for events is also well thought out.

Comment on lines +28 to +33
const isBlankNote = (session: any) => {
return !session?.title?.trim()
&& !session?.raw_memo_html?.trim()
&& !session?.enhanced_memo_html?.trim();
};

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Improve type safety for isBlankNote function.

The function uses any type which bypasses TypeScript's type checking. Consider using a proper type definition.

-const isBlankNote = (session: any) => {
+interface SessionData {
+  title?: string | null;
+  raw_memo_html?: string | null;
+  enhanced_memo_html?: string | null;
+}
+
+const isBlankNote = (session: SessionData | null | undefined) => {
   return !session?.title?.trim()
     && !session?.raw_memo_html?.trim()
     && !session?.enhanced_memo_html?.trim();
 };
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
const isBlankNote = (session: any) => {
return !session?.title?.trim()
&& !session?.raw_memo_html?.trim()
&& !session?.enhanced_memo_html?.trim();
};
interface SessionData {
title?: string | null;
raw_memo_html?: string | null;
enhanced_memo_html?: string | null;
}
const isBlankNote = (session: SessionData | null | undefined) => {
return !session?.title?.trim()
&& !session?.raw_memo_html?.trim()
&& !session?.enhanced_memo_html?.trim();
};
🤖 Prompt for AI Agents
In apps/desktop/src/components/editor-area/note-header/chips/event-chip.tsx
around lines 28 to 33, the isBlankNote function currently uses the any type for
its session parameter, which disables TypeScript's type checking. To fix this,
define a proper interface or type for the session object that includes the
title, raw_memo_html, and enhanced_memo_html properties as strings or possibly
undefined, then update the function parameter to use this type instead of any to
improve type safety.

Comment on lines +109 to +122
<style>
{`
.event-chip-container *:focus {
outline: none !important;
box-shadow: none !important;
border-color: inherit !important;
}
.event-chip-container *:focus-visible {
outline: none !important;
box-shadow: none !important;
border-color: inherit !important;
}
`}
</style>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Extract duplicated focus styles and avoid using !important.

The focus styles are duplicated and use !important which is a code smell. Consider extracting to a CSS module or finding the root cause of focus issues.

-        <style>
-          {`
-            .event-chip-container *:focus {
-              outline: none !important;
-              box-shadow: none !important;
-              border-color: inherit !important;
-            }
-            .event-chip-container *:focus-visible {
-              outline: none !important;
-              box-shadow: none !important;
-              border-color: inherit !important;
-            }
-          `}
-        </style>

Consider using the UI library's built-in focus management or creating a proper CSS module for these styles instead of inline styles with !important.

Also applies to: 216-229

🤖 Prompt for AI Agents
In apps/desktop/src/components/editor-area/note-header/chips/event-chip.tsx
around lines 109 to 122, the focus styles are duplicated and use !important,
which should be avoided. Extract these focus styles into a dedicated CSS module
or stylesheet to remove duplication and eliminate the use of !important.
Investigate the root cause of the focus styling issues and leverage the UI
library's built-in focus management if available, applying styles in a
maintainable way without inline styles or !important overrides. Repeat the same
refactoring for lines 216 to 229.

Comment on lines +479 to 497
const handleDateChange = (e: React.ChangeEvent<HTMLInputElement>) => {
const dateStr = e.target.value;
if (dateStr) {
const [year, month, day] = dateStr.split("-").map(Number);
const newDate = new Date(year, month - 1, day); // month is 0-indexed

const originalTime = new Date(currentSession.created_at);
newDate.setHours(
originalTime.getHours(),
originalTime.getMinutes(),
originalTime.getSeconds(),
originalTime.getMilliseconds(),
);

if (!isNaN(newDate.getTime())) {
setSelectedDate(newDate);
}
}
};
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Potential timezone issue in date handling.

The date conversion logic creates a Date object in local timezone but session dates are stored in ISO format (UTC). This could cause date shifts for users in different timezones.

Consider preserving the timezone information properly:

   const handleDateChange = (e: React.ChangeEvent<HTMLInputElement>) => {
     const dateStr = e.target.value;
     if (dateStr) {
-      const [year, month, day] = dateStr.split("-").map(Number);
-      const newDate = new Date(year, month - 1, day); // month is 0-indexed
-
-      const originalTime = new Date(currentSession.created_at);
-      newDate.setHours(
-        originalTime.getHours(),
-        originalTime.getMinutes(),
-        originalTime.getSeconds(),
-        originalTime.getMilliseconds(),
-      );
+      // Parse the original date to preserve time and timezone
+      const originalDate = new Date(currentSession.created_at);
+      const newDate = new Date(dateStr + 'T00:00:00');
+      
+      // Set the time from original date while preserving timezone
+      newDate.setUTCHours(
+        originalDate.getUTCHours(),
+        originalDate.getUTCMinutes(),
+        originalDate.getUTCSeconds(),
+        originalDate.getUTCMilliseconds()
+      );

       if (!isNaN(newDate.getTime())) {
         setSelectedDate(newDate);
       }
     }
   };
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
const handleDateChange = (e: React.ChangeEvent<HTMLInputElement>) => {
const dateStr = e.target.value;
if (dateStr) {
const [year, month, day] = dateStr.split("-").map(Number);
const newDate = new Date(year, month - 1, day); // month is 0-indexed
const originalTime = new Date(currentSession.created_at);
newDate.setHours(
originalTime.getHours(),
originalTime.getMinutes(),
originalTime.getSeconds(),
originalTime.getMilliseconds(),
);
if (!isNaN(newDate.getTime())) {
setSelectedDate(newDate);
}
}
};
const handleDateChange = (e: React.ChangeEvent<HTMLInputElement>) => {
const dateStr = e.target.value;
if (dateStr) {
// Parse the original date to preserve time and timezone
const originalDate = new Date(currentSession.created_at);
const newDate = new Date(dateStr + 'T00:00:00');
// Set the time from original date while preserving timezone
newDate.setUTCHours(
originalDate.getUTCHours(),
originalDate.getUTCMinutes(),
originalDate.getUTCSeconds(),
originalDate.getUTCMilliseconds()
);
if (!isNaN(newDate.getTime())) {
setSelectedDate(newDate);
}
}
};
🤖 Prompt for AI Agents
In apps/desktop/src/components/editor-area/note-header/chips/event-chip.tsx
around lines 479 to 497, the date conversion creates a Date object in local
timezone while session dates are in UTC ISO format, causing potential timezone
shifts. To fix this, parse the date string as a UTC date rather than local, and
set the time components accordingly in UTC to preserve the correct moment in
time across timezones.

Comment on lines +1203 to +1206
#: src/components/editor-area/note-header/chips/event-chip.tsx:527
msgid "Save Date"
msgstr ""

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Missing Korean translations for new UI elements.

The new translation entries "Save Date" and "Saving..." are missing Korean translations. This will cause English text to appear in the Korean UI.

Please add the appropriate Korean translations:

 #: src/components/editor-area/note-header/chips/event-chip.tsx:527
 msgid "Save Date"
-msgstr ""
+msgstr "날짜 저장"

 #: src/components/editor-area/note-header/chips/event-chip.tsx:527
 msgid "Saving..."
-msgstr ""
+msgstr "저장 중..."

Also applies to: 1211-1214

🤖 Prompt for AI Agents
In apps/desktop/src/locales/ko/messages.po around lines 1203 to 1206 and 1211 to
1214, the Korean translations for the new UI elements "Save Date" and
"Saving..." are missing. Add the correct Korean translations for these msgid
entries in the msgstr fields to ensure the UI displays properly localized text
instead of English.

@duckduckhero duckduckhero merged commit 61a1e43 into main Jul 30, 2025
7 checks passed
This was referenced Jul 30, 2025
@coderabbitai coderabbitai bot mentioned this pull request Aug 12, 2025
@coderabbitai coderabbitai bot mentioned this pull request Oct 10, 2025
@ComputelessComputer ComputelessComputer deleted the note-date-change branch December 14, 2025 15:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant