Repository navigation
Revert/undo for a rewording prompt: restore the original text when the rewrite is bad #474
sergiopadure
started this conversation in
Ideas
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Problem
When a rewording prompt replaces a selection (or the whole field, see the related bug), Dictate keeps the original text nowhere. A manual prompt result is not written to the transcription history:
recordHistoryis called only from the dictation finalize path (DictateController.ktmain:2591/2623/2648) and never fromapplyPrompt. The only Dictate-specific undo,undoLastDictation(main:4106-4123, issue #133), merely deletes the last inserted dictation on the floating button. It cannot restore pre-existing text and is not wired to prompt rewrites.The only fallback today is the host app's own undo, reachable through Dictate's existing "Undo" quick action (Ctrl+Z,
EditorInstance.ktv6.4.0:972-976, main:1055-1059,QuickAction.kt:150). That depends on the host editor's undo stack honouring an IME commit. It is not tested in a browser text box, and it is absent or unreliable in some editors.Where that undo is unavailable, a bad rewrite (model drift, wrong prompt, truncated answer) costs the user the original text, and they must retype it by hand.
Found by reading the code. Not reproduced on a device.
Requested
After a prompt rewrite of existing text, keep the original input in memory (never persisted) and offer a one-tap revert that restores the field to its previous content, as a keyboard Smartbar action and in the floating-button hold menu.
For example, extend the
lastDictationmechanism with the pre-rewrite text kept in memory only, plus arevertLastRewording()that deletes the committed result and re-commits the original. Optionally, log prompt results to history with their original text.The original input needs the same password/incognito exclusion as
lastDictationand the history:isSensitiveDictationField(DictateController.ktmain:4257) guards both at main:4066 and :4164 (issue #383). No text from password or incognito fields may be kept at all.Why
A revert that works regardless of the host app makes the rewrite safe to use on long texts. Relying on the host's Ctrl+Z leaves the user without recourse exactly where editors differ.
Proposed fix (minimal)
In
applyPrompt, before committing, keepinput(the exact text that was sent) in a memory-only field, plus the committed result. Apply the sameisSensitiveDictationFieldexclusion aslastDictation(#383): nothing at all for password and incognito fields. Add a "Revert last rewrite" action that runsdeleteLastText(result)thencommitText(original), mirroringundoLastDictation. Clear both on the next user edit.All reactions