eleven / ocho Public

web: down arrow cancels an unedited ↑-to-edit (#37)

↑ on an empty composer loads your last message for editing. If you
then hit ↓ without changing anything, treat it as "never mind" and
drop back to a normal empty composer instead of leaving an unwanted
edit session open.
Co-authored-by: Claude <noreply@anthropic.com>
James Adam afdb8e49b67423d98ae2ecb164a4784faec66679 parent faf106e
1 file changed, +10 −0
  • web/static/chat.js +10 −0
diff --git a/web/static/chat.js b/web/static/chat.js
index d8f5877..a4e572b 100644
--- a/web/static/chat.js
+++ b/web/static/chat.js
@@ -675,6 +675,16 @@ function renderApp() {
startEdit(id);
}
}
+ // ↓ undoes an accidental ↑-to-edit: only when nothing was typed (still the
+ // original message) and there's no line below the cursor to navigate to.
+ if (e.key === "ArrowDown" && editing != null) {
+ const original = msgData[editing]?.data?.text ?? "";
+ const afterCursor = text.value.slice(text.selectionEnd);
+ if (text.value === original && !afterCursor.includes("\n")) {
+ e.preventDefault();
+ cancelEdit();
+ }
+ }
});
composer.onsubmit = (e) => {
e.preventDefault();