eleven / ocho Public

web: press ↑ on an empty composer to edit your last message

Like iMessage/Slack: ArrowUp with an empty composer opens the most recent of your
own messages that's still within the 15-min edit window. Empty-only so it doesn't
interfere with cursor movement in a multi-line draft.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Paul Campbell 97a2d7904c3e3feb766eda04685c89c7d4bab43b parent 4e65bfe
1 file changed, +22 −0
  • web/static/chat.js +22 −0
diff --git a/web/static/chat.js b/web/static/chat.js
index 64af514..1be7a74 100644
--- a/web/static/chat.js
+++ b/web/static/chat.js
@@ -451,6 +451,15 @@ function renderApp() {
e.preventDefault();
composer.requestSubmit();
}
+ // ↑ on an empty composer edits your most recent still-editable message (à la
+ // iMessage/Slack). Only when empty so it doesn't fight cursor movement.
+ if (e.key === "ArrowUp" && editing == null && text.value === "") {
+ const id = lastEditableMine();
+ if (id != null) {
+ e.preventDefault();
+ startEdit(id);
+ }
+ }
});
composer.onsubmit = (e) => {
e.preventDefault();
@@ -1255,6 +1264,19 @@ function sendMessage(raw) {
});
}
+// The id of your most recent message that's still editable (yours, has text, and
+// within the edit window), or null. Drives ↑-to-edit. Message ids are ascending.
+function lastEditableMine() {
+ let best = null;
+ for (const [id, d] of Object.entries(msgData)) {
+ if (d.mine && d.data && d.data.text && Date.now() - d.createdAt * 1000 < EDIT_WINDOW_MS) {
+ const n = Number(id);
+ if (best === null || n > best) best = n;
+ }
+ }
+ return best;
+}
+
// Enter edit mode: load the message text into the composer with an "Editing" banner.
function startEdit(msgId) {
const d = msgData[msgId];