Skip to content

feat(md): add yesterday to date pickers and use relative date formatting #2271

Merged
sedson merged 2 commits intomainfrom
seamus/yesterday-date-formatting
Mar 30, 2026
Merged

feat(md): add yesterday to date pickers and use relative date formatting #2271
sedson merged 2 commits intomainfrom
seamus/yesterday-date-formatting

Conversation

@sedson
Copy link
Copy Markdown
Contributor

@sedson sedson commented Mar 30, 2026

  • Preserve date mention displayFormat labels
  • add more formatting special cases

@sedson sedson requested a review from a team as a code owner March 30, 2026 18:45
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Mar 30, 2026

📝 Walkthrough

Summary by CodeRabbit

  • New Features
    • Dates now display in relative format (e.g., "Yesterday", "Today", "Tomorrow").
    • Hovering over dates shows a detailed tooltip with full date information including weekday and month.
    • Added "Yesterday" as a quick date preset for search and filtering.

Walkthrough

Added relative date formatting and tooltip display to date mentions using date-fns functions, showing labels like "Yesterday/Today/Tomorrow" with hover tooltips. Introduced a new "yesterday" date preset with search keywords and display labels for date filtering.

Changes

Cohort / File(s) Summary
Date Mention Display
js/app/packages/core/component/LexicalMarkdown/component/decorator/DateMention.tsx
Introduced formatRelativeDate and formatTooltipDate helpers for relative date rendering. Added hover state tracking and interactive tooltip via Portal + floatWithElement, displayed when mention is hovered and date picker is closed. Updated display format to use relative labels falling back to standard format.
Date Search Presets
js/app/packages/core/util/dateSearch/presets.ts
Added new DATE_PRESETS entry with id: 'yesterday' including display labels (label: 'Yesterday', shortLabel: 'Yest'), keywords for search (['yesterday', 'yest']), and date computation logic using addDays(endOfDay(baseDate), -1).
🚥 Pre-merge checks | ✅ 1 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Title check ⚠️ Warning The title exceeds the 72-character limit (73 characters) and lacks conventional commits format compliance with length constraint, though it follows the feat: prefix convention. Shorten the title to 72 characters or less while maintaining the feat(md): prefix and core message, e.g., 'feat(md): add yesterday preset and relative date formatting'.
✅ Passed checks (1 passed)
Check name Status Explanation
Description check ✅ Passed The description is related to the changeset, mentioning date mention displayFormat labels and formatting special cases that align with the PR changes.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions
Copy link
Copy Markdown

Copy link
Copy Markdown
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: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In
`@js/app/packages/core/component/LexicalMarkdown/component/decorator/DateMention.tsx`:
- Line 140: The inline Tailwind hex shadow "shadow-[`#000`]/5" in the DateMention
TSX element should be replaced with a semantic design token; locate the class
string in the DateMention component (file DateMention.tsx) and swap the raw hex
shadow for the project’s semantic shadow token or CSS variable (e.g. the
design-system shadow token class or a var(--token-*)) so the shadow color comes
from the theme tokens instead of a hardcoded hex value; ensure the resulting
class string preserves the shadow size (shadow-md) and uses the established
token name used across js/app (or wrap a semantic shadow variable if required).
- Line 82: The code currently persists a relative label by calling
node.setDisplayFormat(formatRelativeDate(newDate)) in DateMention.tsx; instead
store a stable absolute representation (e.g., an ISO timestamp or an absolute
formatted date) in the node state via node.setDisplayFormat(absoluteValue) and
move any relative formatting (formatRelativeDate) to the render path so the UI
computes "Tomorrow"/"2 days ago" at render time rather than persisting it;
update the DateMention render logic to call
formatRelativeDate(node.getDisplayFormat() or node.getDate()) when displaying
the node.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: 04e88911-082f-4e4d-be44-31c1e6f1668e

📥 Commits

Reviewing files that changed from the base of the PR and between a76fe87 and d4acdf2.

📒 Files selected for processing (2)
  • js/app/packages/core/component/LexicalMarkdown/component/decorator/DateMention.tsx
  • js/app/packages/core/util/dateSearch/presets.ts

if ($isDateMentionNode(node)) {
node.setDate(newDate.toISOString());
node.setDisplayFormat(formatDate(newDate));
node.setDisplayFormat(formatRelativeDate(newDate));
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

Do not persist relative labels into node state.

At Line [82], writing formatRelativeDate(newDate) to displayFormat stores time-relative text in serialized node data, which will become stale (e.g., persisted "Tomorrow" no longer true later). Persist a stable absolute format instead; keep relative formatting only at render time.

💡 Suggested fix
-        node.setDisplayFormat(formatRelativeDate(newDate));
+        node.setDisplayFormat(formatDate(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
node.setDisplayFormat(formatRelativeDate(newDate));
node.setDisplayFormat(formatDate(newDate));
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@js/app/packages/core/component/LexicalMarkdown/component/decorator/DateMention.tsx`
at line 82, The code currently persists a relative label by calling
node.setDisplayFormat(formatRelativeDate(newDate)) in DateMention.tsx; instead
store a stable absolute representation (e.g., an ISO timestamp or an absolute
formatted date) in the node state via node.setDisplayFormat(absoluteValue) and
move any relative formatting (formatRelativeDate) to the render path so the UI
computes "Tomorrow"/"2 days ago" at render time rather than persisting it;
update the DateMention render logic to call
formatRelativeDate(node.getDisplayFormat() or node.getDate()) when displaying
the node.

<Show when={hovered() && !datePickerOpen()}>
<Portal>
<div
class="absolute select-none z-tool-tip bg-panel p-1.5 text-ink-muted text-xs wrap-break-word rounded-sm border border-edge-muted shadow-md shadow-[#000]/5"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion | 🟠 Major

Replace raw hex shadow color with a semantic token.

Line [140] uses shadow-[#000]/5, which bypasses the design-token system for color styling in TSX.

As per coding guidelines: js/app/**/*.tsx: Use semantic color tokens instead of default tailwind styles for colors.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@js/app/packages/core/component/LexicalMarkdown/component/decorator/DateMention.tsx`
at line 140, The inline Tailwind hex shadow "shadow-[`#000`]/5" in the DateMention
TSX element should be replaced with a semantic design token; locate the class
string in the DateMention component (file DateMention.tsx) and swap the raw hex
shadow for the project’s semantic shadow token or CSS variable (e.g. the
design-system shadow token class or a var(--token-*)) so the shadow color comes
from the theme tokens instead of a hardcoded hex value; ensure the resulting
class string preserves the shadow size (shadow-md) and uses the established
token name used across js/app (or wrap a semantic shadow variable if required).

@sedson sedson merged commit 47dd69d into main Mar 30, 2026
23 checks passed
@sedson sedson deleted the seamus/yesterday-date-formatting branch March 30, 2026 18:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants