← Back to PRs

#19555: feat(android): collapsible thinking/code blocks in chat

by gregmousseau open 2026-02-17 23:23 View on GitHub →
app: android size: S
## Summary Describe the problem and fix in 2–5 bullets: - **Problem:** Long thinking blocks (`<thinking>...`) and large code snippets clutter the mobile chat UI, forcing users to scroll past 1000+ lines of text to see the actual answer. - **Why it matters:** Mobile screens have limited vertical space; intermediate reasoning steps are useful but shouldn't dominate the view. - **What changed:** 1. Added a new `CollapsibleBlock` UI component. 2. Updated `ChatMarkdown` parser to detect `<thinking>` blocks and collapse them by default (showing a "💭 Thinking" header). 3. Updated `ChatMarkdown` to detect code blocks longer than 10 lines and collapse them by default (showing language + line count). - **What did NOT change:** Short code blocks (<10 lines) remain expanded. Non-thinking text remains unchanged. ## Change Type (select all) - [ ] Bug fix - [x] Feature - [ ] Refactor - [ ] Docs - [ ] Security hardening - [ ] Chore/infra ## Scope (select all touched areas) - [ ] Gateway / orchestration - [ ] Skills / tool execution - [ ] Auth / tokens - [ ] Memory / storage - [ ] Integrations - [ ] API / contracts - [x] UI / DX (Android) - [ ] CI/CD / infra ## User-visible / Behavior Changes - **Thinking Blocks:** Now appear as a collapsed "💭 Thinking" row. Tapping expands it. - **Long Code:** Code blocks >10 lines appear collapsed with "📄 python (28 lines)". Tapping expands it. - **Auto-scroll:** Chat now smoothly scrolls to the newest message when content changes. ## Security Impact (required) - New permissions/capabilities? (No) - Secrets/tokens handling changed? (No) - New/changed network calls? (No) - Command/tool execution surface changed? (No) - Data access scope changed? (No) ## Repro + Verification ### Environment - OS: Android 15 (OnePlus 12) ### Steps 1. Ask a question requiring reasoning (e.g., "How many r's in strawberry?"). 2. Ask for a long code snippet (e.g., "Write a binary search tree in Python"). ### Expected - Thinking steps are hidden behind a toggle. - Long code is hidden behind a toggle. ### Actual - Both behave as expected. ## Evidence ![Screenshot_2026-02-17-14-21-44-59_9e4f220af4158cf313504e53a3b01c8c](https://github.com/user-attachments/assets/ee956f33-9b62-48f6-a68f-5f055c225ed4) ## Human Verification (required) What you personally verified (not just CI), and how: - Verified on OnePlus 12. - Confirmed thinking blocks collapse correctly. - Confirmed code blocks >10 lines collapse, while short ones stay expanded. ## Compatibility / Migration - Backward compatible? (Yes) 🤖 AI-Assisted: Yes (Claude via OpenClaw) <!-- greptile_comment --> <h3>Greptile Summary</h3> Added collapsible UI components for thinking blocks and long code snippets in Android chat to improve mobile UX. Thinking blocks (`<thinking>` tags) are now collapsed by default with a "💭 Thinking" header, and code blocks longer than 10 lines are collapsed with language + line count displayed. <h3>Confidence Score: 5/5</h3> - This PR is safe to merge with minimal risk - The implementation is well-structured and focused. It adds a clean new UI component (`CollapsibleBlock`) with proper animation and state management, and integrates it cleanly into the existing markdown parsing flow. The parsing logic correctly handles `<thinking>` tags (including `antml:` namespace variant) and maintains proper order of operations. No security concerns, no breaking changes, and the 10-line threshold is reasonable. - No files require special attention <sub>Last reviewed commit: 9e99ab4</sub> <!-- greptile_other_comments_section --> <sub>(5/5) You can turn off certain types of comments like style [here](https://app.greptile.com/review/github)!</sub> <!-- /greptile_comment -->

Most Similar PRs