Fix chat history truncation and remaining node_num==0 falsy checks - #15
Conversation
… falsy checks read_messages() sorted ascending before applying LIMIT, so once a user's message table exceeded the 5000-row default, startup silently loaded the oldest 5000 messages and dropped everything newer instead of showing recent history. Now selects the newest N (rowid as a deterministic tiebreaker), then re-sorts that selection chronologically. Also fixes two remaining `if value` truthiness checks on node_num/to that mishandle a legitimate node_num==0 or to==0: _device_summary()'s NodeDB lookup/id-formatting, and the inbound "to" field resolution in _on_text_received(). Most instances of this bug class were already fixed in earlier PRs; these two were missed. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
|
Warning Review limit reached
Next review available in: 11 minutes You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (5)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
…on unfixed code With toNum=0xDEADBEEF, both old and new code classified to=0 as a DM (0xDEADBEEF is not BROADCAST_NUM in either path), so the assertion could never catch the regression. With toNum=0xFFFFFFFF (BROADCAST_NUM), the old `to or toNum` path classifies as broadcast (destination_num=None) while the fixed path uses to=0 as a DM (destination_num=sender_num). Also update the stale comment in _POST_MIGRATE_INDEXES that referenced the old "ORDER BY observed_at ASC LIMIT ?" shape that read_messages() no longer uses after the newest-N subquery fix. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Summary
MonitorStore.read_messages()sortedORDER BY observed_at ASC LIMIT ?— once a user's message table exceeds the 5000-row default loaded at startup, this returned the oldest N messages and silently dropped every message newer than that, instead of showing recent chat history. Now selects the newest N (usingrowidas a deterministic tiebreaker for same-timestamp rows), then re-sorts that selection chronologically for display.if valuetruthiness checks on node_num/tofields that mishandle a legitimatenode_num == 0orto == 0(most instances of this bug class were already fixed in earlier PRs — these two were missed):_device_summary(): NodeDB lookup and node-id formatting both skipped forlocal_num == 0._on_text_received():to_num = packet.get("to") or packet.get("toNum")would fall through totoNumeven when a genuineto == 0was present.Risk assessment
Low risk, isolated correctness fixes. No schema changes, no behavior change for the common case (table under the limit).
read_messages()'s new query is a subquery + re-sort, tested against >limit, under-limit, DM/channel-mixed, and same-timestamp-tiebreak cases.Test plan
pytest -q— 361 passed (25 new:test_monitor_store_message_history.py,test_zero_value_handling.py)ruff check src tests scripts— cleanmypy src/meshchat— cleannode_num == 0NodeDB lookup/id formatting;to == 0inbound packet resolves as a direct message instead of falling through totoNum.🤖 Generated with Claude Code