OpenHands / OpenHands/enterprise
Negative time values displayed in UI due to timezone mismatch
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 4
- Forks
- 2
- Avg merge
- 1d 22h
- Merged PRs (30d)
- 101
Description
Bug Description
Conversations are displaying negative time values in the UI (e.g., "-850 seconds ago", "-949 seconds ago"). This occurs on the home page under "Recent Conversations" and potentially other pages displaying timestamps.
Environment
- Browser: Set to local European time (Germany)
- Server: May be running in non-UTC timezone (e.g., Europe/Berlin)
Root Cause
The backend uses datetime.now() (naive local time) in several places instead of datetime.now(timezone.utc) or the standard utc_now() helper. When the server runs in a non-UTC timezone:
- Server writes local time (e.g.,
2026-04-27T15:37:04in German time) without timezone indicator - Frontend
parseDateAsUTC()assumes naive timestamps are UTC, parsing it as2026-04-27T15:37:04Z - The actual UTC time was
2026-04-27T13:37:04Z(2 hours earlier) - The timestamp appears in the future, causing
now - timestampto be negative
Affected Files
Enterprise code (enterprise/server/utils/conversation_callback_utils.py):
- Line 118:
callback.updated_at = datetime.now() - Line 145:
conversation.last_updated_at = datetime.now() - Line 232:
conversation_work.updated_at = datetime.now().isoformat()
Core code (openhands/events/stream.py):
- Line 168:
event._timestamp = datetime.now().isoformat()
Other files:
enterprise/server/logger.py:42:obj = {"ts": datetime.now().isoformat(), **obj}
Suggested Fix
Replace all datetime.now() calls with timezone-aware UTC datetimes:
# Option 1: Use the existing utc_now() helper
from openhands.agent_server.utils import utc_now
callback.updated_at = utc_now()
# Option 2: Use datetime with timezone directly
from datetime import datetime, timezone
callback.updated_at = datetime.now(timezone.utc)
Why _fix_timezone() Does Not Solve This
The _fix_timezone() method in sql_app_conversation_info_service.py adds UTC timezone to naive datetimes when reading from the database:
def _fix_timezone(self, value: datetime | None) -> datetime:
if not value.tzinfo:
value = value.replace(tzinfo=UTC)
return value
This only works if the original datetime was actually in UTC. When datetime.now() writes local time, _fix_timezone() incorrectly labels it as UTC.
Impact
- Severity: Minor (cosmetic)
- User Impact: Confusion when viewing conversation timestamps
- Scope: Recent Conversations list, potentially other timestamp displays
Steps to Reproduce
- Run OpenHands server in a non-UTC timezone (e.g., Europe/Berlin)
- Create or update a conversation
- View the "Recent Conversations" list on the home page
- Observe negative time values for recently updated conversations
This issue was created by an AI agent (OpenHands) based on a customer report.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the listed datetime.now() calls in enterprise/server/utils/conversation_callback_utils.py, enterprise/server/logger.py, and openhands/events/stream.py, then inspect the existing utc_now() helper and _fix_timezone() behavior. Update the affected timestamp writes to use UTC-aware values and reproduce the issue in a non-UTC timezone to confirm that recent conversation times are no longer negative.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Active
- Clarity
- Clearly specified
- Newbie friendliness
- 70/100