Skip to content

Auto-reply: include weekday in envelope timestamps#12438

Merged
mbelinky merged 1 commit intomainfrom
fix/envelope-dow
Feb 9, 2026
Merged

Auto-reply: include weekday in envelope timestamps#12438
mbelinky merged 1 commit intomainfrom
fix/envelope-dow

Conversation

@mbelinky
Copy link
Contributor

@mbelinky mbelinky commented Feb 9, 2026

Problem

  • Some models miscompute day-of-week from an absolute date (e.g. interpreting 2026-02-09 as Sunday), causing "today/tonight" confusion when the system prompt omits current date/time by design.

Fix

  • Prefix channel envelope timestamps with a short weekday (Mon/Tue/...) in the same timezone used for the envelope timestamp.
  • Updated test helper + unit tests accordingly.

Testing

  • pnpm test src/auto-reply/envelope.test.ts src/web/auto-reply.web-auto-reply.reconnects-after-connection-close.test.ts
  • pnpm test src/auto-reply/inbound.test.ts src/auto-reply/reply/session-resets.test.ts src/gateway/server-methods/agent-timestamp.test.ts
  • pnpm check

Greptile Overview

Greptile Summary

This PR changes auto-reply envelope timestamp formatting to prefix absolute timestamps with a short weekday (Mon/Tue/…) in the same timezone as the existing timestamp, so models don’t need to derive day-of-week from the date. It updates unit tests and the test timestamp helper to match the new envelope format.

Confidence Score: 4/5

  • Mostly safe to merge, but there is a concrete crash case in the updated timestamp test helper when given whitespace-padded timezones.
  • Core production change in src/auto-reply/envelope.ts is straightforward and covered by updated unit tests. However, the modified test helper can throw a RangeError for padded IANA timezone strings because it reuses the untrimmed zone when calling Intl/formatZonedTimestamp despite trimming for normalization.
  • test/helpers/envelope-timestamp.ts

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

1 file reviewed, 1 comment

Edit Code Review Agent Settings | Greptile

Comment on lines 8 to +18
export function formatEnvelopeTimestamp(date: Date, zone: EnvelopeTimestampZone = "utc"): string {
const normalized = zone.trim().toLowerCase();
const weekday = (() => {
try {
if (normalized === "utc" || normalized === "gmt") {
return new Intl.DateTimeFormat("en-US", { timeZone: "UTC", weekday: "short" }).format(date);
}
if (normalized === "local" || normalized === "host") {
return new Intl.DateTimeFormat("en-US", { weekday: "short" }).format(date);
}
return new Intl.DateTimeFormat("en-US", { timeZone: zone, weekday: "short" }).format(date);
Copy link
Contributor

Choose a reason for hiding this comment

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

Whitespace timezone crash
formatEnvelopeTimestamp() normalizes zone with trim()/toLowerCase(), but still passes the original (untrimmed) zone into Intl.DateTimeFormat({ timeZone: zone }) and later formatZonedTimestamp(date, { timeZone: zone }). If a caller provides a padded timezone like " America/Los_Angeles ", formatZonedTimestamp throws RangeError: invalid time zone (it doesn’t catch Intl exceptions), so this helper can crash tests. Use the trimmed timezone string when passing timeZone to Intl/formatZonedTimestamp (or wrap the zoned formatting call in a try/catch similarly to the weekday formatter).

Prompt To Fix With AI
This is a comment left during a code review.
Path: test/helpers/envelope-timestamp.ts
Line: 8:18

Comment:
**Whitespace timezone crash**
`formatEnvelopeTimestamp()` normalizes `zone` with `trim()`/`toLowerCase()`, but still passes the original (untrimmed) `zone` into `Intl.DateTimeFormat({ timeZone: zone })` and later `formatZonedTimestamp(date, { timeZone: zone })`. If a caller provides a padded timezone like `" America/Los_Angeles "`, `formatZonedTimestamp` throws `RangeError: invalid time zone` (it doesn’t catch Intl exceptions), so this helper can crash tests. Use the trimmed timezone string when passing `timeZone` to Intl/formatZonedTimestamp (or wrap the zoned formatting call in a try/catch similarly to the weekday formatter).

How can I resolve this? If you propose a fix, please make it concise.

@mbelinky mbelinky merged commit 8968d9a into main Feb 9, 2026
22 of 25 checks passed
@mbelinky mbelinky deleted the fix/envelope-dow branch February 9, 2026 07:55
yeboster pushed a commit to yeboster/openclaw that referenced this pull request Feb 9, 2026
chrisbrittan added a commit to chrisbrittan/Moltbot-Voice that referenced this pull request Feb 9, 2026
Conflicts resolved:
- src/auto-reply/envelope.ts: took upstream (centralized format-time utils)
- test/helpers/envelope-timestamp.ts: took upstream (same reason)

Our weekday-in-timestamps feature was independently implemented upstream
in openclaw#12438 with a better architecture (shared format-time modules).

Fix TS2352 cast in session-transcript-repair.ts (AssistantMessage type change).

Co-Authored-By: Claude Opus 4.6 <[email protected]>
NikolasP98 pushed a commit to NikolasP98/openclaw that referenced this pull request Feb 9, 2026
NikolasP98 added a commit to NikolasP98/openclaw that referenced this pull request Feb 9, 2026
Integrated upstream improvements:
- CRITICAL: Fix bundled hooks broken since 2026.2.2 (openclaw#9295)
- Grok web search provider (xAI) with inline citations
- Telegram video note support with tests and docs
- QMD model cache sharing optimization (openclaw#12114)
- Context overflow false positive fix (openclaw#2078)
- Model failover 400 status handling (openclaw#1879)
- Dynamic config loading per-message (openclaw#11372)
- Gateway post-compaction amnesia fix (openclaw#12283)
- Skills watcher: ignore Python venvs and caches
- Telegram send recovery from stale thread IDs
- Cron job parameter recovery (openclaw#12124)
- Auto-reply weekday timestamps (openclaw#12438)
- Utility consolidation refactoring (PNG, JSON, errors)
- Cross-platform test normalization (openclaw#12212)
- macOS Nix defaults support (openclaw#12205)

Preserved DEV enhancements:
- Docker multi-stage build with enhanced tooling (gh, gog, obsidian-cli, uv, nano-pdf, mcporter, qmd)
- Comprehensive .env.example documentation (371 lines)
- Multi-environment docker-compose support (DEV/PRD)
- GOG/Tailscale integration
- Fork-sync and openclaw-docs skills
- UI config editor (Svelte)
- Fork workflow documentation

Merge strategy: Cherry-picked 22 upstream commits, preserved DEV Docker architecture.
Docker files unchanged: Dockerfile, docker-compose.yml, docker-setup.sh, .env.example

Co-Authored-By: Claude Sonnet 4.5 <[email protected]>
Ethermious pushed a commit to Ethermious/openclaw that referenced this pull request Feb 9, 2026
lucasmpramos pushed a commit to butley/openclaw that referenced this pull request Feb 10, 2026
slathrop referenced this pull request in slathrop/openclaw-js Feb 11, 2026
Tasks completed: 2/2
- Port weekday in envelope timestamps (#12438)
- Port timezone trim fix (#12446)

SUMMARY: .planning/phases/16-gateway-cron-ios/16-03-SUMMARY.md
yeboster pushed a commit to yeboster/openclaw that referenced this pull request Feb 13, 2026
skyhawk14 pushed a commit to skyhawk14/openclaw that referenced this pull request Feb 13, 2026
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.

1 participant

Comments