fix(tui): copilot review on #16707 — naming, label consistency, esc priority

- Rename `removeAt` → `removeAtInPlace` and document the mutation
  contract; the old name read like a non-mutating helper.
- Hotkey table + queue header: use `Ctrl+X` / `Esc` to match the
  rest of the UI (was `⌃X` / `esc`).
- Render the queued header as a single template literal so JSX
  text-node whitespace can't sneak into the rendered line.
- Make `Esc` while editing beat the `terminal.hasSelection` clear:
  the header promises 'Esc cancel', so an active selection
  shouldn't silently consume the keystroke.
This commit is contained in:
Brooklyn Nicholson 2026-04-27 15:37:54 -05:00
parent 32b068560d
commit 718088c382
5 changed files with 21 additions and 15 deletions

View file

@ -1,6 +1,8 @@
import { useCallback, useRef, useState } from 'react'
export function removeAt<T>(arr: T[], i: number): T[] {
// Mutates `arr` in place; returned reference is the same input array, kept
// so callers can chain. Use `Array.prototype.toSpliced` if you need a copy.
export function removeAtInPlace<T>(arr: T[], i: number): T[] {
if (i < 0 || i >= arr.length) {
return arr
}
@ -50,7 +52,7 @@ export function useQueue() {
(i: number) => {
const before = queueRef.current.length
removeAt(queueRef.current, i)
removeAtInPlace(queueRef.current, i)
if (queueRef.current.length !== before) {
syncQueue()