Skip to content

Bugfix: pending reply lost when reopening chat after passcode unlock#388

Closed
dazewell wants to merge 1 commit into
risin42:devfrom
dazewell:fix/reply-draft-lost-passcode
Closed

Bugfix: pending reply lost when reopening chat after passcode unlock#388
dazewell wants to merge 1 commit into
risin42:devfrom
dazewell:fix/reply-draft-lost-passcode

Conversation

@dazewell

Copy link
Copy Markdown
Contributor

Problem

With a passcode lock enabled (and set to be locked Immediately for easier repro), the following sequence loses the pending reply reference:

  1. Open a chat
  2. Swipe a message to start a reply
  3. Type some draft text (don't send)
  4. Minimize the app using the system Home gesture
  5. Reopen the app and unlock with passcode/fingerprint (given that it is configured for Immediate lockdown)

Expected:

pending reply + draft text.

Actual:

draft text restored, reply reference lost (or at least not visible).

Root cause

On passcode unlock, LaunchActivity.showPasscodeActivity() calls ActionBarLayout.rebuildFragments(REBUILD_FLAG_REBUILD_LAST), which rebuilds the ChatActivity views via clearViews() while keeping the same fragment instance. replyingMessageObject survives, but the recreated ChatActivityEnterView no longer shows the reply panel. In createView() only setReplyingMessageObject() was called (internal state only), and applyDraftMaybe() skips restoring the panel because replyingMessageObject != null. So the visible reply preview is never re-shown.

Fix

In createView(), when a reply is still pending after a view rebuild, re-show the visible reply panel via showFieldPanelForReply() / showFieldPanelForReplyQuote() (mirroring fallbackFieldPanel logic). This only runs when replyingMessageObject != null, so the normal chat-open path is unaffected.

@coderabbitai

coderabbitai Bot commented Jun 21, 2026

Copy link
Copy Markdown

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: 6cca3d94-9df3-48f3-a5fa-bbd6ccf6d091

📥 Commits

Reviewing files that changed from the base of the PR and between 110a1c2 and 738631f.

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

📝 Walkthrough

Summary by CodeRabbit

  • Bug Fixes
    • Fixed an issue where the reply preview panel would disappear after the app rebuilds during passcode lock flows. The panel now correctly displays when you resume with a pending reply.

Walkthrough

In ChatActivity, a new conditional block is added during enter-view rebuild to re-display the reply preview panel when a pending reply exists. It checks replyingMessageObject against threadMessageObject and calls either showFieldPanelForReplyQuote or showFieldPanelForReply based on whether replyingQuote is set.

Changes

Reply Preview Panel Restoration

Layer / File(s) Summary
Re-show reply preview panel on enter-view rebuild
TMessagesProj/src/main/java/org/telegram/ui/ChatActivity.java
Adds a conditional block that compares replyingMessageObject with threadMessageObject after the enter-view is rebuilt; if they differ, it calls showFieldPanelForReplyQuote(...) or showFieldPanelForReply(...) depending on whether replyingQuote is non-null.
🚥 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 and specifically describes the bug being fixed: a pending reply lost when reopening chat after passcode unlock.
Description check ✅ Passed The description is directly related to the changeset, providing clear problem statement, root cause analysis, and the fix implemented in ChatActivity.
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.43.0)
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.

@dazewell dazewell marked this pull request as draft June 21, 2026 21:51
@dazewell dazewell marked this pull request as ready for review June 21, 2026 22:06
@risin42

risin42 commented Jun 24, 2026

Copy link
Copy Markdown
Owner

can’t reproduce this on my end.

@dazewell dazewell closed this Jun 24, 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