feat(ui): Arrow-Up in an empty composer edits your last message (LC-248) #301
Loading…
Reference in a new issue
No description provided.
Delete branch "feat/lc-248-arrowup-edit-last"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
Implements LC-248 (subtask LC-249). Press Up in an empty composer to jump straight into editing your most recent message (Slack/Discord pattern). Reuses the existing per-message edit route + inline form.
Implementation
room/composer.html): a keydown listener on the textarea. On Arrow-Up with no modifier, not composing, the textarea empty, and no mention/slash popover open, it finds the lastbutton[hx-get$="/edit"]in#messages(that button only renders for the viewer's own editable messages, so the last one is the most recent own message) and clicks it, driving the existingGET /messages/{id}/editswap. Empty-composer-only so Up still navigates the caret in a multi-line draft; the mention/slash combobox keydown handlers run in capture phase andstopPropagationwhen open, so they keep Arrow-Up while a popover is up (explicit guard backs that up).room/edit_form.html): addautofocusto the input so the global after-swap focus handler (layout.html) lands the caret in the editor - this also improves the hover "Edit" path - plus anEscapekeydown that triggers the existing Cancel control to restore the message. Enter already saves (form submit).Scope
Most recent own message in the main
#messageslist, rooms and DMs. Thread panel out of scope.Tests
__lcEditLast); the edit form input carriesautofocus.just testandjust test-saasgreen; clippy + fmt clean.No operator-visible surface, so no
[operator-action]marker.🤖 Generated with Claude Code
Press Up in an empty composer to jump straight into editing your most recent message (Slack/Discord pattern). Reuses the existing per-message edit route + inline form. Composer (room/composer.html): a keydown listener on the textarea. On Arrow-Up with no modifier, not composing, the textarea empty, and no mention/slash popover open, it finds the last `button[hx-get$="/edit"]` in #messages - the edit button only renders for the viewer's own editable messages, so the last one is the most recent own message - and clicks it, driving the existing GET /messages/{id}/edit swap. Empty-composer-only so Up still navigates the caret in a multi-line draft; the mention/slash combobox keydown handlers run in capture phase and stopPropagation when open, so they keep Arrow-Up while a popover is up (an explicit guard backs that up). Edit form (room/edit_form.html): add `autofocus` to the input so the global after-swap focus handler (layout.html) lands the caret in the editor - this also improves the hover "Edit" path - plus an Escape keydown that triggers the existing Cancel control to restore the message. Enter already saves (form submit). Scope: most recent own message in the main #messages list, rooms and DMs; thread panel out of scope. Tests: the room page ships the shortcut (`__lcEditLast`) and the edit form input carries `autofocus`. The find-last-and-click and Esc-cancel interactions are JS-only and fall to the LC-249 QA pass. just test and just test-saas green; clippy + fmt clean. #LC-248 #LC-249 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>