#1332

Bug: Backspace appends a control byte instead of deleting in MCP form fields

Opensammyhassopened 27d ago

Issue details

Backspace does not delete in the fields of the /mcp add server form. It appends the raw byte to the field, so the field shows a stray escape and the value that gets saved can contain a control character.

Steps to reproduce on fx 0.0.14 (macOS, TERM=xterm-256color):

  1. Run fx.
  2. Run /mcp.
  3. Press a to open the add server form.
  4. Type ab in the Name field.
  5. Press Backspace.

Expected: the field shows a.

Actual: the field shows ab followed by a control byte, and nothing is deleted. Holding or repeating Backspace keeps appending bytes until the field overflows and renders with an ellipsis.

The same happens in the Command field, with Ctrl-H (0x08) as well as Backspace (0x7f), and in the Arguments field, which shares the code path. Backspace works in the main prompt, in the /mcp filter field (/), and in the /model picker search, so the problem is limited to the MCP add and argument forms.

Impact: the control byte becomes part of the field value. The add form writes those values to the server entry, so a field edited with Backspace can store a control character in ~/.fx/mcp.json. It also breaks the ordinary editing flow of the form, because there is no way to correct a typo.

Cause, from reading main:

  • handleMcpAddInput and handleMcpArgumentInput in src/core/app/app_input_runtime.zig special-case \t and \r and send every other byte to handleTextByte, which appends it to the composer draft.
  • The terminal decoder has already resolved the byte into a composer_shortcut (.delete_backward for 127 and 8 in src/ui/input/shortcuts.zig), but these two handlers receive only the byte and never the shortcut.
  • The MCP filter field in the same file handles 0x7f explicitly, which is why the filter deletes correctly.

I reproduced this with FX_RECORD and have a fix with a regression test ready to open as a pull request.

Trace

No response

Sensitive information

  • I reviewed the information above and removed secrets and other sensitive data.

Activity

0

No activity yet.