Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Sep 29, 2025

Fixes date display consistency by showing years for older dates in contact chat history, matching the behavior used for inbox dates.

Problem

Contact chat message timestamps were using Luxon's toRelative() method which displayed older dates as "44 years ago" instead of showing the actual date with year. This was inconsistent with inbox date formatting which includes years for clarity.

Solution

Updated the TembaDate component to use the existing timeSince() function for duration display instead of store.getShortDuration(). The timeSince() function already implements the correct logic:

const year = date.getFullYear() == now.getFullYear() ? '' : ' ' + date.getFullYear();

Changes

  • TembaDate.ts: Replaced store.getShortDuration() with timeSince() for duration display
  • Added comprehensive tests covering all date scenarios to ensure correct behavior

Behavior

Date Type Before After
Very old dates "44 years ago" "18 Nov 1978"
Different year "3 years ago" "15 Jun 2021"
Same year, old "6 months ago" "15 Jan"
Recent dates "2h" "2h" (unchanged)

The change ensures that:

  • Dates from different years show the full date with year
  • Dates from the same year show month/day without year
  • Recent dates continue to show relative time (hours, minutes)

Testing

  • All existing tests pass (909 tests)
  • Added 4 new test cases covering edge cases
  • Manual verification in browser confirms correct behavior
  • No regressions in other date display modes
![Date Display Test Results](https://github.com/user-attachments/assets/bb9db260-2c18-4e1d-95b9-dd416b13ea61)

The screenshot demonstrates the new behavior working correctly across different date scenarios.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • example.com
    • Triggering command: /home/REDACTED/work/temba-components/temba-components/node_modules/puppeteer/.local-chromium/linux-982053/chrome-linux/chrome --disable-REDACTED-networking --enable-features=NetworkService,NetworkServiceInProcess --disable-REDACTED-timer-throttling --disable-REDACTEDing-occluded-windows --disable-breakpad --disable-client-side-phishing-detection --disable-component-extensions-with-REDACTED-pages --disable-default-apps --disable-dev-shm-usage --disable-extensions --disable-features=Translate,BackForwardCache --disable-hang-monitor --disable-ipc-flooding-protection --disable-popup-blocking --disable-prompt-on-repost --disable-renderer-REDACTEDing --disable-sync --force-color-profile=srgb --metrics-recording-only --no-first-run --enable-automation --password-store=basic --use-mock-keychain --enable-blink-features=IdleDetection --export-tagged-pdf --headless --hide-scrollbars --mute-audio --font-render-hinting=medium --force-color-profile=srgb --hide-scrollbars --disable-web-security --force-device-scale-factor=1 --no-sandbox --disable-gpu --disable-font-subpixel-positioning --disable-lcd-text --force-prefers-reduced-motion --disable-REDACTED-timer-throttling --disable-REDACTEDing-occluded-windows --disable-renderer-REDACTEDing --disable-gpu-sandbox --disable-software-rasterizer --disable-REDACTED-networking --disable-default-apps --disable-extensions --disable-sync --disable-translate --hide-crash-restore-bubble --metrics-recording-only --no-first-run --safebrowsing-disable-auto-update --use-mock-keychain --disable-ipc-flooding-protection --disable-component-update --disable-domain-reliability --remote-debugging-port=0 --user-data-dir=/tmp/puppeteer_dev_chrome_profile-wUTvCC about:blank (dns block)
    • Triggering command: /home/REDACTED/work/temba-components/temba-components/node_modules/puppeteer/.local-chromium/linux-982053/chrome-linux/chrome --disable-REDACTED-networking --enable-features=NetworkService,NetworkServiceInProcess --disable-REDACTED-timer-throttling --disable-REDACTEDing-occluded-windows --disable-breakpad --disable-client-side-phishing-detection --disable-component-extensions-with-REDACTED-pages --disable-default-apps --disable-dev-shm-usage --disable-extensions --disable-features=Translate,BackForwardCache --disable-hang-monitor --disable-ipc-flooding-protection --disable-popup-blocking --disable-prompt-on-repost --disable-renderer-REDACTEDing --disable-sync --force-color-profile=srgb --metrics-recording-only --no-first-run --enable-automation --password-store=basic --use-mock-keychain --enable-blink-features=IdleDetection --export-tagged-pdf --headless --hide-scrollbars --mute-audio --font-render-hinting=medium --force-color-profile=srgb --hide-scrollbars --disable-web-security --force-device-scale-factor=1 --no-sandbox --disable-gpu --disable-font-subpixel-positioning --disable-lcd-text --force-prefers-reduced-motion --disable-REDACTED-timer-throttling --disable-REDACTEDing-occluded-windows --disable-renderer-REDACTEDing --disable-gpu-sandbox --disable-software-rasterizer --disable-REDACTED-networking --disable-default-apps --disable-extensions --disable-sync --disable-translate --hide-crash-restore-bubble --metrics-recording-only --no-first-run --safebrowsing-disable-auto-update --use-mock-keychain --disable-ipc-flooding-protection --disable-component-update --disable-domain-reliability --remote-debugging-port=0 --user-data-dir=/tmp/puppeteer_dev_chrome_profile-3OvH8m about:blank (dns block)
    • Triggering command: /home/REDACTED/work/temba-components/temba-components/node_modules/puppeteer/.local-chromium/linux-982053/chrome-linux/chrome --disable-REDACTED-networking --enable-features=NetworkService,NetworkServiceInProcess --disable-REDACTED-timer-throttling --disable-REDACTEDing-occluded-windows --disable-breakpad --disable-client-side-phishing-detection --disable-component-extensions-with-REDACTED-pages --disable-default-apps --disable-dev-shm-usage --disable-extensions --disable-features=Translate,BackForwardCache --disable-hang-monitor --disable-ipc-flooding-protection --disable-popup-blocking --disable-prompt-on-repost --disable-renderer-REDACTEDing --disable-sync --force-color-profile=srgb --metrics-recording-only --no-first-run --enable-automation --password-store=basic --use-mock-keychain --enable-blink-features=IdleDetection --export-tagged-pdf --headless --hide-scrollbars --mute-audio --font-render-hinting=medium --force-color-profile=srgb --hide-scrollbars --disable-web-security --force-device-scale-factor=1 --no-sandbox --disable-gpu --disable-font-subpixel-positioning --disable-lcd-text --force-prefers-reduced-motion --disable-REDACTED-timer-throttling --disable-REDACTEDing-occluded-windows --disable-renderer-REDACTEDing --disable-gpu-sandbox --disable-software-rasterizer --disable-REDACTED-networking --disable-default-apps --disable-extensions --disable-sync --disable-translate --hide-crash-restore-bubble --metrics-recording-only --no-first-run --safebrowsing-disable-auto-update --use-mock-keychain --disable-ipc-flooding-protection --disable-component-update --disable-domain-reliability --remote-debugging-port=0 --user-data-dir=/tmp/puppeteer_dev_chrome_profile-ZkH3j9 about:blank (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Original prompt

This section details on the original issue you should resolve

<issue_title>Contact chat history should include year in older dates</issue_title>
<issue_description>Using same logic we use for whether to include year in inbox dates?</issue_description>

Comments on the Issue (you are @copilot in this section)

Fixes #655

💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

- Update TembaDate component to use timeSince function for duration display
- Replace Luxon's toRelative() with timeSince logic that includes years
- Add comprehensive tests for different date scenarios
- Maintain backward compatibility for all other display modes

Co-authored-by: rowanseymour <[email protected]>
Copilot AI changed the title [WIP] Contact chat history should include year in older dates Include year in older dates for contact chat history Sep 29, 2025
Copilot AI requested a review from rowanseymour September 29, 2025 22:17
Copilot finished work on behalf of rowanseymour September 29, 2025 22:17
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.

Contact chat history should include year in older dates

2 participants