OpenClaw / wacli
Merged upstreamCorrectnessMerged Aug 5, 2026

Preserve chat ordering during group refresh

Fixed wacli group refresh so metadata updates no longer overwrite chat activity timestamps and disturb chat-list ordering.

openclaw/wacli · #340

Problem

wacli groups refresh wrote the current wall-clock time into chats.last_message_ts for every imported group. Because chats list sorts by that column, a metadata refresh could push genuinely recent DMs and unread chats out of limit-bounded results.

Approach

Added a metadata-only chat upsert that refreshes group identity fields without changing message activity, used it from CLI and internal refresh paths, and kept newly discovered metadata-only groups at unknown activity until message sync supplies a real timestamp.

Impact and scope

  • Preserves chat ordering semantics by keeping last_message_ts tied to message activity instead of metadata refresh time.
  • Prevents group refresh from hiding genuinely recent or unread direct messages in limited chat-list results.
  • Keeps newly discovered groups visible without fabricating ordering data before a real message timestamp exists.

Validation

  • Added refresh-layer and SQLite store regressions for preserving existing timestamps and metadata-only inserts.
  • Documented focused tests, full Go test suites, sqlite_fts5 tests, go vet, build, Node script tests, deadcode, gofmt, and diff checks in the PR.
  • Merged upstream after local proof showed the focused regression failed on main before the fix and passed after the change.