Skip to content

Commit e51e967

Browse files
committed
fix: use formatKeybind constant, remove keybinds from comments
- Use formatKeybind(KEYBINDS.CANCEL_EDIT) consistently instead of hardcoded 'Esc' - Remove comment that repeated specific keybind values (brittle) - Add AGENTS.md note about not repeating constants in comments
1 parent a0c0bfb commit e51e967

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

docs/AGENTS.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@ Avoid mock-heavy tests that verify implementation details rather than behavior.
108108
- Let types drive design: prefer discriminated unions for state, minimize runtime checks, and simplify when types feel unwieldy.
109109
- Use `using` declarations (or equivalent disposables) for processes, file handles, etc., to ensure cleanup even on errors.
110110
- Centralize magic constants under `src/constants/`; share them instead of duplicating values across layers.
111+
- Never repeat constant values (like keybinds) in comments—they become stale when the constant changes.
111112

112113
## Component State & Storage
113114

src/browser/components/ChatInput/index.tsx

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -907,7 +907,6 @@ export const ChatInput: React.FC<ChatInputProps> = (props) => {
907907
}
908908

909909
// Note: ESC handled by VimTextArea (for mode transitions) and CommandSuggestions (for dismissal)
910-
// Edit canceling is Esc (non-vim) or Esc twice (vim), stream interruption is Ctrl+C (vim) or Esc (normal)
911910

912911
// Don't handle keys if command suggestions are visible
913912
if (
@@ -935,7 +934,7 @@ export const ChatInput: React.FC<ChatInputProps> = (props) => {
935934
// Workspace variant placeholders
936935
if (editingMessage) {
937936
const cancelHint = vimEnabled
938-
? "Esc×2 to cancel"
937+
? `${formatKeybind(KEYBINDS.CANCEL_EDIT)}×2 to cancel`
939938
: `${formatKeybind(KEYBINDS.CANCEL_EDIT)} to cancel`;
940939
return `Edit your message... (${cancelHint}, ${formatKeybind(KEYBINDS.SEND_MESSAGE)} to send)`;
941940
}
@@ -1088,8 +1087,8 @@ export const ChatInput: React.FC<ChatInputProps> = (props) => {
10881087
{/* Editing indicator - workspace only */}
10891088
{variant === "workspace" && editingMessage && (
10901089
<div className="text-edit-mode text-[11px] font-medium">
1091-
Editing message ({vimEnabled ? "Esc×2" : formatKeybind(KEYBINDS.CANCEL_EDIT)} to
1092-
cancel)
1090+
Editing message ({formatKeybind(KEYBINDS.CANCEL_EDIT)}
1091+
{vimEnabled ? "×2" : ""} to cancel)
10931092
</div>
10941093
)}
10951094

0 commit comments

Comments
 (0)