Repository navigation
fix: wire device timezone into AI chat for relative times (Fixes #4643) - #13857
Conversation
chore: sync fork main from BasedHardware/omi
) Add optional time_zone on SendMessageRequest, persist device-reported IANA zones via PUT /v1/users/time-zone, and pass resolved tz through chat streaming so relative time language matches the user. Extend the datetime prompt block with explicit relative-time guidance. Verification: pytest tests/unit/test_chat_timezone_sync.py tests/unit/test_prompt_metadata_safety.py Co-authored-by: Apoorv Darshan <[email protected]>
Include IANA time_zone on each chat message, sync timezone on auth without requiring FCM registration, and regenerate app-client TypeScript types. Co-authored-by: Apoorv Darshan <[email protected]>
Regenerate app-client OpenAPI from FastAPI export and update TS/Swift generators. Register PUT /v1/users/time-zone in route_policy_manifest.yaml. Co-authored-by: Apoorv Darshan <[email protected]>
Move sync_user_time_zone_from_client to utils/chat_time_zone.py and only invoke it when the client sends time_zone, preserving hermetic chat router tests that stub database.notifications. Co-authored-by: Apoorv Darshan <[email protected]>
Co-authored-by: Apoorv Darshan <[email protected]>
Move sync_user_time_zone_from_client to database.notifications and wire the shared chat router harness stub so loading routers.chat does not import real Firestore protos. Co-authored-by: Apoorv Darshan <[email protected]>
Co-authored-by: Apoorv Darshan <[email protected]>
Avoid importing utils.llm.chat in test_chat_timezone_sync, which exceeded the 1s per-test CI duration gate when loading the full chat module. Co-authored-by: Apoorv Darshan <[email protected]>
There was a problem hiding this comment.
All reported issues were addressed across 21 files
You’re at about 92% of the monthly reviewed-line limit. You may want to disable incremental reviews to conserve quota. Reviews will continue until that limit is exceeded. If you need help avoiding interruptions, please contact [email protected].
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
- Catch Firestore failures in sync_user_time_zone_from_client; still return request_tz - Offload chat send timezone sync via run_blocking(db_executor, ...) - PUT /v1/users/time-zone uses sync_user_time_zone_from_client; BYOK policy fix - set_user_time_zone uses get_firestore_client injectable seam - Flutter: unawaited timezone sync on sign-in; omit time_zone when TZ lookup fails Verification: backend/.venv/bin/python -m pytest tests/unit/test_chat_timezone_sync.py -q (8 passed) Co-authored-by: Apoorv Darshan <[email protected]>
Build request body with conditional map entry instead of post-hoc body['time_zone'] assignment so app-client schema inventory stays clean. Verification: inventory_app_client_schemas.py --operation-id send_message_v2_messages_post; test_app_client_schema_inventory.py Co-authored-by: Apoorv Darshan <[email protected]>
Listen Pusher Stack Gauntlet failed with httpx.ReadTimeout in _rest_finalization_survives_listener_restart; PR diff does not touch listen/pusher stack paths. Co-authored-by: Apoorv Darshan <[email protected]>
|
Thanks @apoorvdarshan — well-scoped fix for #4643, and the cc9f425 follow-ups (fail-open persist, offloaded sync, injectable Firestore seam) address the right things. I verified the wiring end-to-end on the current head; all checks are green. What looks good, file by file:
Two non-blocking observations:
Leaving for human maintainer review rather than formal approval: this adds a new authenticated first-party endpoint and user-profile write plus a change to the model-facing by AI on behalf of David — if you need David’s attention urgently, please @Git-on-my-level and escalate with |
|
PR: #14102 AUTO (AI Agent). |
Fixes #4643
Problem
AI chat often defaulted to UTC because the user's IANA timezone was only persisted when FCM push registration ran. Without that, relative phrases like "tonight" and "this afternoon" did not match the user's local day.
Solution
time_zoneonPOST /v2/messages, validate as IANA, persist on the user profile when it changes, and pass the resolved zone through chat streaming (client_tz) so the datetime block and tools share one timezone.PUT /v1/users/time-zoneso clients can sync timezone without push registration.<current_datetime>block: relative time words must be interpreted in the user's timezone.time_zoneon every chat message; sync timezone after auth via the new endpoint (fire-and-forget so sign-in is not blocked).time_zoneon each chat message.Review follow-ups (cc9f425)
sync_user_time_zone_from_client(chat send proceeds with request tz).run_blocking(db_executor, ...)inside the stream generator.PUT /v1/users/time-zoneusessync_user_time_zone_from_client; BYOK policyvalidated_when_headers_present.set_user_time_zoneusesget_firestore_client()injectable seam.unawaitedtimezone sync on token refresh; omittime_zonewhen device TZ lookup fails.Verification
14 passed (includes cc9f425 regressions).
PR checks
Line-Count-Exception: backend/routers/chat.py | 2175 -> 2182 | client timezone sync via run_blocking in stream + review fixes
Line-Count-Exception: backend/utils/llm/chat.py | 1514 -> 1535 | sync helper + relative-time prompt guidance for #4643
Failure-Class: none