#19555: feat(android): collapsible thinking/code blocks in chat
app: android
size: S
Cluster:
Model Reasoning Fixes
## 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

## 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
#20050: fix: Telegram polling regression and thinking blocks corruption (AI...
by Vaibhavee89 · 2026-02-18
77.6%
#23462: fix: extract thinking blocks as fallback in extractTextFromChatContent
by nszhsl · 2026-02-22
77.3%
#22797: Feat/auto thinking mode
by jrthib · 2026-02-21
77.2%
#16733: fix(ui): avoid injected newlines when tool output is hidden
by jp117 · 2026-02-15
77.0%
#6521: fix: addressed style issue for chat compose and thread on mobile
by spencer-rafada · 2026-02-01
76.4%
#11010: fix(control-ui): hide tool call cards when thinking toggle is off
by Annaxiebot · 2026-02-07
75.5%
#9716: feat(ui): add GitHub-style floating copy button to code blocks
by BigUncle · 2026-02-05
74.7%
#12079: TUI: improve thinking UX, tool readability, and live running status...
by rubenfb23 · 2026-02-08
74.3%
#10097: fix: add empty thinking blocks to tool call messages when thinking is…
by cyxer000 · 2026-02-06
74.2%
#17304: feat(gemini): robust handling for non-XML reasoning headers (`Think...
by YoshiaKefasu · 2026-02-15
74.1%