block / block/berd

Undo (Ctrl+Z) does not work in the chat composer

Open
#104 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
909
Forks
116
Avg merge
1d 1h
Merged PRs (30d)
156

Description

## Before filing

- [x] I searched open and closed issues for duplicates.
- [x] I reproduced this on the current release (0.6.2).
- [x] This is one issue, not several bundled together.

## Closest existing issue

```
none found
```

---

## Steps to reproduce

1. Launch Berd.
2. Open a new chat.
3. Type a sentence into the composer.
4. Select part of it and delete it, or delete a few words with Backspace.
5. Press Ctrl+Z with the composer focused.

## Expected

The deleted text comes back, the way undo works in any other text field.

## Actual

Nothing happens. The composer's contents are unchanged and there is no way to
recover what was removed short of retyping it.

## Frequency

Every time.

## Version and platform

Berd 0.6.2, Linux (Ubuntu, x86_64), installed from
`Berd_0.6.2_linux-x86_64.deb`.

## Logs

No relevant log output — nothing is written when the key is pressed.

## Additional context

I had a look at the source, in case it's useful. The composer textarea
(`src/features/chat/ui/ChatInput.tsx:1915`) is a controlled React input, and its
value is set programmatically from several places in the component. Assigning a
textarea's value from script rather than through user editing clears the
browser's native undo stack, which would explain why Ctrl+Z
has nothing to restore.

The code already shows awareness of this. There's a comment at
`ChatInput.tsx:1291`:

```
// Plain/Shift+Enter inserts the newline natively, preserving undo.
```

So newline insertion was deliberately kept native to protect the undo stack. The
other programmatic paths appear not to have had the same treatment.

Two directions, whichever fits the architecture better: route the remaining
programmatic edits through `document.execCommand("insertText")` (or an
equivalent that preserves native undo), or maintain an explicit undo history in
the component and handle the shortcut directly.

I have not verified this diagnosis by building from source — treat it as a
starting point, not a conclusion. The reproduction above is what I actually
observed.

Contributor guide

Open the contributing guide

Research direction

Start in src/features/chat/ui/ChatInput.tsx, especially the textarea around line 1915 and the native newline handling near line 1291. Reproduce the deletion and Ctrl+Z steps, then trace the component's programmatic editing paths and determine how they interact with the browser undo stack. Done means deleted composer text is restored reliably with Ctrl+Z on the reported Linux release path.

Written by the indexing model from the issue text.

Assessment

Tech stack
react, typescript
Domain
frontend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
68/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.