Skip to content

Bugfix: properly select all-between when messages were rescheduled afterwards#375

Closed
dazewell wants to merge 2 commits into
risin42:devfrom
dazewell:bufgix/select_between_holes
Closed

Bugfix: properly select all-between when messages were rescheduled afterwards#375
dazewell wants to merge 2 commits into
risin42:devfrom
dazewell:bufgix/select_between_holes

Conversation

@dazewell
Copy link
Copy Markdown
Contributor

Repro

  1. schedule message "1" to 12:34
  2. schedule message "2" to 12:35
  3. schedule message "4" to 12:38
  4. schedule message "3" to 12:39

    at this point, you should have messages in the following order: 1, 2, 4, 3

  5. open scheduled messages view
  6. rescheduled message "3" to 12:36

    at this point, you should have messages in the following order: 1, 2, 3, 4

  7. long tap and select message "1"
  8. long tap and select message "4"
  9. click the "select all between" button in the action bar

Expected

All messages are selected: 1, 2, 3, 4

Actual

Only the following messages are selected: 1, 2, 4

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 27, 2026

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 22372aec-83f6-447e-9147-7624cb51df44

📥 Commits

Reviewing files that changed from the base of the PR and between c5b60cd and 426f931.

📒 Files selected for processing (2)
  • TMessagesProj/src/main/java/org/telegram/ui/ChatActivity.java
  • TMessagesProj/src/main/java/tw/nekomimi/nekogram/helpers/ChatsHelper.java
💤 Files with no reviewable changes (1)
  • TMessagesProj/src/main/java/tw/nekomimi/nekogram/helpers/ChatsHelper.java

📝 Walkthrough

Summary by CodeRabbit

  • Refactor
    • Improved range-based message selection to use positional bounds, making multi-message selection more consistent and reliable.
  • Bug Fixes
    • Fixed edge cases when selecting between messages at selection limit so the correct start message is included.

Walkthrough

The PR refactors the "select between messages" logic in ChatActivity. The private isSelectableBetweenMessage method is simplified to accept only a MessageObject, removing the previous id-range guard. Both canSelectBetweenMessages() and performSelectBetweenMessages() are updated to compute positional bounds by scanning the messages list, then test candidate messages between those positions using the simplified method.

Changes

Select Between Messages Refactoring

Layer / File(s) Summary
Simplified selection predicate & helpers
TMessagesProj/src/main/java/org/telegram/ui/ChatActivity.java
isSelectableBetweenMessage is refactored to accept only a MessageObject; new helpers hasSelectedMessagesRange() and isMessageSelectedForBetween(MessageObject) are added to gate and check selected-message membership.
Caller-side positional bounds computation and action
TMessagesProj/src/main/java/org/telegram/ui/ChatActivity.java
canSelectBetweenMessages() and performSelectBetweenMessages() now scan messages to compute minPos/maxPos from selected items and select messages strictly between those positions; selection-limit handling in performSelectBetweenMessages() adds the begin message via messages.get(minPos) when the limit is reached.
Remove id-bounds utility
TMessagesProj/src/main/java/tw/nekomimi/nekogram/helpers/ChatsHelper.java
Removed ChatsHelper.getSelectBetweenBounds(...), eliminating the id-based bounds helper previously used by the callers.
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main bugfix: selecting messages between positions fails when messages were rescheduled afterward.
Description check ✅ Passed The description provides detailed reproduction steps, expected vs actual behavior, and is directly related to the message selection logic changes.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ast-grep (0.42.3)
TMessagesProj/src/main/java/org/telegram/ui/ChatActivity.java

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1


ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 8ab33a2e-4ba6-4893-a361-4af7789b9e71

📥 Commits

Reviewing files that changed from the base of the PR and between 918dd4e and c5b60cd.

📒 Files selected for processing (1)
  • TMessagesProj/src/main/java/org/telegram/ui/ChatActivity.java

Comment thread TMessagesProj/src/main/java/org/telegram/ui/ChatActivity.java Outdated
@risin42
Copy link
Copy Markdown
Owner

risin42 commented May 30, 2026

Fixed in 79d9b3e. Thanks.

@risin42 risin42 closed this May 30, 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.

2 participants