Skip to content

fix(nlp): parse day after tomorrow distinctly#940

Open
DhruvalBhinsara1 wants to merge 2 commits into
Charushi06:mainfrom
DhruvalBhinsara1:codex/fix-day-after-tomorrow
Open

fix(nlp): parse day after tomorrow distinctly#940
DhruvalBhinsara1 wants to merge 2 commits into
Charushi06:mainfrom
DhruvalBhinsara1:codex/fix-day-after-tomorrow

Conversation

@DhruvalBhinsara1
Copy link
Copy Markdown

@DhruvalBhinsara1 DhruvalBhinsara1 commented May 29, 2026

What

Fixes the frontend NLP fallback so day after tomorrow resolves two days ahead instead of being swallowed by the shorter tomorrow match. This keeps the browser fallback behavior aligned with the server fallback and closes #939.

How

Moved the day after tomorrow check before the generic tomorrow regex in js/utils/nlpDateExtractor.js. Added a focused Node regression test that imports the browser ESM helper through a file:// URL, pins the timezone to UTC for deterministic date assertions, and verifies tomorrow and day after tomorrow resolve to distinct dates.

Testing

  • npm test
  • npx -y node@20 --test
  • git diff --check
  • node --input-type=module --check < js/utils/nlpDateExtractor.js

Risks / Notes

No UI change, so screenshots are not applicable. npm ci completed successfully and reported existing moderate audit findings; no dependencies were changed.

Related Issue

Closes #939

Summary

Corrects relative-day parsing in the frontend fallback extractor.

Changes Made

  • Prioritized day after tomorrow before the shorter tomorrow pattern.
  • Added a regression test for the relative-day parser.
  • Hardened the test after review by using a file URL import and UTC assertions.

Screenshots

N/A - parser logic only.

Checklist

  • Code follows project style
  • Tested locally
  • No unrelated changes included
  • Documentation updated (not applicable)

Copilot AI review requested due to automatic review settings May 29, 2026 09:22
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

Fixes a bug in matchRelativeDay where the "tomorrow" regex would match before the more specific "day after tomorrow" pattern, causing the latter to be misclassified as "tomorrow". Adds a Node test that validates both phrases resolve to the correct dates.

Changes:

  • Reordered regex checks in matchRelativeDay so "day after tomorrow" is matched before "tomorrow".
  • Added a new Node-based test that loads the ESM module via a data URL and asserts both relative-day cases.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
js/utils/nlpDateExtractor.js Reorders relative-day matching so the more specific "day after tomorrow" pattern is checked first.
tests/nlpDateExtractor.test.js New test exercising both "tomorrow" and "day after tomorrow" inputs using a fixed now.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread tests/nlpDateExtractor.test.js Outdated
Comment thread tests/nlpDateExtractor.test.js
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.

bug: Frontend NLP parses "day after tomorrow" as tomorrow

2 participants