#22076: [Bug]: Preserve chat draft when aborting
app: web-ui
size: S
Cluster:
Telegram Streaming Enhancements
## Summary
Fixes #22063
When aborting a running chat stream, the UI previously cleared `host.chatMessage` in `handleAbortChat()`, which made users lose draft text typed during generation.
## What changed
- Removed the unconditional draft reset from `ui/src/ui/app-chat.ts`:
- Deleted `host.chatMessage = ""` from `handleAbortChat()`.
- Added regression coverage in `ui/src/ui/app-chat.test.ts`:
- Verifies the typed draft is preserved when `handleAbortChat()` is invoked while connected.
- Verifies no abort request is sent when the UI is disconnected.
## Why this is correct
- Aborting a chat run is server-side cancellation and does not require clearing user input.
- Chat draft input now mirrors expected behavior from mainstream chat UX patterns: stop/abort does not erase in-progress text.
- This is a tightly scoped behavior fix with no protocol/client payload changes and no API surface changes.
## Validation
- Ran targeted UI test:
- `cd ui && pnpm test -- src/ui/app-chat.test.ts`
- Result: pass (2/2)
## Risk Assessment
- Very low risk; only one assignment removal and direct behavioral guardrail.
- No branching behavior changes outside abort path.
- No security, persistence, or transport protocol changes.
## Confidence Score
- 10/10 confidence
- Patch is minimal and deterministic.
- Regression test covers the reported draft-loss path and a disconnected no-op path.
- No unrelated refactors or dependency changes.
- Expected merge impact is limited to UX behavior in `ui/src/ui/app-chat.ts`.
<!-- greptile_comment -->
<h3>Greptile Summary</h3>
Removed unconditional `chatMessage` reset from `handleAbortChat()` in `ui/src/ui/app-chat.ts:67`, preserving user's draft text when aborting a running chat stream. Added regression tests covering both the connected abort path (verifying draft preservation) and disconnected no-op path.
<h3>Confidence Score: 5/5</h3>
- This PR is safe to merge with minimal risk
- The change is a single-line deletion with clear UX improvement, comprehensive test coverage for the regression, and no impact on other code paths or API contracts
- No files require special attention
<sub>Last reviewed commit: f11f34a</sub>
<!-- greptile_other_comments_section -->
<!-- /greptile_comment -->
Most Similar PRs
#14966: fix(webchat): preserve user message visibility after chat.send
by BenediktSchackenberg · 2026-02-12
75.8%
#19479: fix(telegram): skip redundant final edit in partial streaming mode
by v8hid · 2026-02-17
74.8%
#13104: fix: persist user command message in chat transcript
by mcaxtr · 2026-02-10
74.7%
#22440: fix(slack): prevent duplicate final replies from draft previews
by Solvely-Colin · 2026-02-21
74.4%
#14946: fix(webchat): accumulate text across blocks in streaming buffer
by mcaxtr · 2026-02-12
74.1%
#19343: Refactor chat state management: reset chat messages and queue on se...
by saurav470 · 2026-02-17
72.8%
#18678: fix(telegram): preserve draft message when all final payloads are e...
by julianubico · 2026-02-16
72.7%
#7522: fix(webchat): auto-scroll when message queue changes
by alsoknownasfoo · 2026-02-02
72.1%
#20248: fix(slack): flush draft stream before final reply to preserve messa...
by Utkarshbhimte · 2026-02-18
71.9%
#15110: fix: enable auto-scroll during assistant response streaming
by jwchmodx · 2026-02-13
71.6%