Skip to content

Render action item timestamps in the user's local timezone in chat (#4643) - #8483

Merged
kodjima33 merged 7 commits into
BasedHardware:mainfrom
ZachL111:zach/chat-tz-action-items
Jun 28, 2026
Merged

kodjima33 merged 7 commits into
BasedHardware:mainfrom
ZachL111:zach/chat-tz-action-items

Conversation

@ZachL111

@ZachL111 ZachL111 commented Jun 28, 2026 •

Copy link
Copy Markdown
Contributor

Problem

Issue #4643: AI chat refers to event times with the wrong time of day ("tonight" when it was the afternoon, "this afternoon" when it was the morning).

The agentic chat already injects the current time in the user's timezone and renders retrieved conversations in local time (utils/conversations/render.py). But the action items tool the chat agent calls, get_action_items_tool, formatted timestamps with a bare strftime and no timezone:

Due: 2026-06-26 22:00:00

The model reads that UTC wall clock as the user's local time. For a user in America/Los_Angeles, 22:00 UTC is actually 15:00 local, so an item due in mid afternoon gets described as "due tonight."

Fix

Render created_at, due_at, and completed_at in the user's timezone with an explicit label, reusing the same helper conversations already use:

Due: 2026-06-26 15:00:00 America/Los_Angeles
  • Promote the existing _resolve_display_tz in render.py to a public resolve_display_tz so conversations and the action items tool share one timezone resolver (falls back to UTC on a missing or invalid zone).
  • get_action_items_tool fetches the user's timezone with notification_db.get_user_time_zone (the same call conversation_tools makes) and formats each timestamp through a small naive-safe helper.

This is the live path (utils/retrieval/graph.py to the agentic chat to get_action_items_tool), so it directly changes what users see.

Tests

  • New tests/unit/test_action_items_timezone.py: timestamps render in the user's zone with a label; UTC, empty, and invalid zones fall back to UTC without crashing; naive timestamps are treated as UTC. Verified red against the prior code and green with the fix.
  • The tool now imports database.notifications and the render helper, so test_action_item_date_validation.py stubs those. While there I also restored a utils.llm.conversation_folder stub that a recent refactor left out, so that file runs fully green again.

Scope and follow-up

The calendar tool (get_calendar_events_tool) has the same class of issue, but it is an async tool so the timezone read needs an executor offload. I left it for a separate change to keep this one small and obviously correct.

Review in cubic

@cubic-dev-ai cubic-dev-ai Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

1 issue found across 5 files

Confidence score: 3/5

  • In backend/utils/retrieval/tools/action_item_tools.py, the post-retrieval timezone lookup/conversion is unguarded, so a timezone resolution error can fail the entire action-item tool instead of gracefully formatting in UTC; this creates a concrete reliability risk for user-facing retrievals — add exception handling around timezone conversion and explicitly fall back to UTC before merging.

Reply with feedback, questions, or to request a fix.

Re-trigger cubic

@Git-on-my-level

Copy link
Copy Markdown
Member

Thanks for this, @ZachL111 — clean fix. Promoting _resolve_display_tz to a shared resolve_display_tz and routing the action-item timestamps through it is exactly the right call: conversations and action items now use one timezone resolver, consistent with how the chat already renders local time.

The defensive handling looks solid:

  • naive timestamps are treated as UTC in _format_local, so the model never sees an unlabeled wall-clock time
  • the tz lookup is guarded with a UTC fallback so retrieval never aborts on a Firestore/zone error (nice follow-up to the cubic point)
  • UTC / empty / invalid-zone fallbacks are all covered by tests

Rendering created_at / due_at / completed_at with an explicit tz label should directly stop the chat model from misreading the time of day (the core of #4643). Nothing blocking on the code side from my review. Leaving this as a positive signal for a maintainer to take a final look before merge.

@kodjima33 kodjima33 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Backend bug fix (#4643): render action item timestamps in user's local timezone; tests, CI green.

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.

3 participants