{{ message }}
Repository navigation
mitmweb: apply text options on blur or Enter, not per keystroke - #8476
Open
Cassian433 wants to merge 1 commit into
Open
Cassian433 wants to merge 1 commit into
Cassian433 wants to merge 1 commit into
Conversation
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Description
Fixes #7655.
The Options editor sends a PUT /options for every keystroke in a text or number field.
update()inweb/src/js/ducks/options.tsused to be throttled, but the throttle was commented out back in 2021 (46cd40f) andOptionInput.tsxdispatches straight from onChange. For most options that is just noise. Forsave_stream_fileit is real damage:Save.configureopens the file on every update, so each prefix of the path ends up as an empty file on disk, which is exactly what the reporter saw.I didn't bring the throttle back. It was a single throttle shared by every option, so of several updates to different options inside the same 500 ms window only the first and last got sent. It would also still write a partial file every half second while someone types. Instead the string, int and float inputs keep the typed text in local state and only call onChange on blur or Enter, and only if the text actually changed. The "sequence of str" textarea commits on blur (Enter has to stay a newline there) and now sizes itself from the local text, since
valueno longer changes while you type. Checkboxes and selects still apply immediately.Tested with jest (web
npm test: eslint, tsc, 347 tests pass). The new specs in OptionSpec.tsx fail on main: renderingOptionInputforsave_stream_fileand typing/tmp/flows.mitmmakes 15 fetch calls there, 1 on this branch.I also ran it end to end: mitmweb from this checkout on 127.0.0.1 with an empty working dir, the vite dev server, and headless Chrome typing
flows.mitminto save_stream_file one key at a time over CDP, then Tab. On main that was 10 PUTs and 10 zero-byte files in the working dir (f,fl,flo...flows.mitm). On the branch it was 1 PUT and onlyflows.mitm, and the field kept its value afterwards.One behaviour change to be aware of: if you type into a field and close the modal with Escape before leaving the field, the edit is dropped. Clicking the close button or anywhere else still applies it, because the input blurs first.
Checklist