Skip to content

Add keyboard shortcuts: 'a' to accept, 'd' to dismiss threads#52

Merged
HamptonMakes merged 2 commits intomainfrom
feat/keyboard-accept-dismiss
Mar 23, 2026
Merged

Add keyboard shortcuts: 'a' to accept, 'd' to dismiss threads#52
HamptonMakes merged 2 commits intomainfrom
feat/keyboard-accept-dismiss

Conversation

@HamptonMakes
Copy link
Collaborator

When navigating threads with j/k, pressing 'a' accepts a pending thread (pending → todo) and 'd' discards it (pending → discarded).

Implementation:

  • Same input guard pattern as j/k/r — skips in inputs/textareas/contentEditable and with modifier keys
  • Uses data-action-name attributes on forms for robust DOM selection
  • Submits via form.requestSubmit() so Turbo intercepts properly
  • MutationObserver on #plan-threads detects broadcast DOM updates before auto-advancing
  • Refactored findOpenPopover() as shared helper (was duplicated in focusReply)

Tests: 3 new system tests — accept, discard, and textarea input guard.

Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: a5631cf349

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +145 to +148
if (this.currentIndex >= highlights.length) {
this.currentIndex = 0
}
this.navigateTo(highlights[this.currentIndex])

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Normalize negative index before post-action navigation

If a user opens a thread popover via mouse click (without j/k), currentIndex stays -1. After pressing a or d, the mutation callback runs advanceAfterAction, skips the >= highlights.length guard, and calls navigateTo(highlights[-1]), which is undefined and causes a runtime error in navigateTo. This breaks shortcut flow whenever at least one open highlight remains after the action (e.g., any accept, or discard with other open threads).

Useful? React with 👍 / 👎.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch — this is a real bug. When the popover is opened via mouse click, currentIndex stays at -1, and highlights[-1] is undefined. Fixed in 27bd0a4: currentIndex is now normalized to 0 before dispatching the action.

if (this.currentIndex >= highlights.length) {
this.currentIndex = 0
}
this.navigateTo(highlights[this.currentIndex])

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Advance to the next thread after accept action

advanceAfterAction re-navigates to highlights[this.currentIndex] without incrementing the index first. For accept (pending -> todo), the thread remains open, so it stays in openHighlights and focus returns to the same thread instead of advancing. This contradicts the intended auto-advance behavior and forces an extra j press after every accept.

Useful? React with 👍 / 👎.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Correct — accept changes pending→todo, which is still an open status, so the thread stays in openHighlights at the same index. Fixed in 27bd0a4: advanceAfterAction now takes a shouldAdvance flag. For accept, it increments the index; for discard, the thread drops out of the list so the current index naturally points to the next one.

HamptonMakes and others added 2 commits March 23, 2026 17:17
When navigating threads with j/k, pressing 'a' accepts a pending thread
(pending → todo) and 'd' discards it (pending → discarded). Uses the
same input guard pattern — skips when in inputs/textareas or when
modifier keys are held.

Implementation:
- Finds the open popover and submits the accept/discard form via
  form.requestSubmit() so Turbo intercepts properly
- Uses data-action-name attributes on forms for robust selection
- MutationObserver on #plan-threads detects broadcast DOM updates
  before auto-advancing to the next thread
- Refactored findOpenPopover() as shared helper (was duplicated
  in focusReply)

Amp-Thread-ID: https://ampcode.com/threads/T-019d1c41-53b2-73c9-9b51-d9f0e53de461
Co-authored-by: Amp <amp@ampcode.com>
- Normalize currentIndex to 0 when popover was opened via mouse click
  (not j/k navigation), preventing highlights[-1] → undefined error
- For accept (pending→todo), explicitly advance index since the thread
  stays in openHighlights; for discard, the thread leaves the list so
  the current index naturally points to the next one

Amp-Thread-ID: https://ampcode.com/threads/T-019d1c41-53b2-73c9-9b51-d9f0e53de461
Co-authored-by: Amp <amp@ampcode.com>
@HamptonMakes HamptonMakes force-pushed the feat/keyboard-accept-dismiss branch from c6650fa to 6376262 Compare March 23, 2026 22:17
@HamptonMakes HamptonMakes merged commit 0a73359 into main Mar 23, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant