Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Oct 24, 2025

Problem

The chat input box was navigating history when the user pressed the up arrow while the cursor was anywhere on the first line. This was confusing for screen readers, as users would unexpectedly jump to history when trying to navigate within their current input text.

Solution

Modified the history navigation enablement logic to only trigger when the cursor is at the very first position (line 1, column 1), matching the behavior of the SCM view.

Expected Behavior

Starting on the second line in chat input:

  1. Arrow up → cursor moves up a line
  2. Arrow up → cursor moves to first index of first line
  3. Arrow up → history navigation triggers

Implementation

Changed the historyNavigationBackwardsEnablement condition in chatInputPart.ts:

Before:

this.historyNavigationBackwardsEnablement.set(atTop);
// atTop = position.lineNumber === 1 && position.column - 1 <= lineLength
// Enabled history navigation ANYWHERE on the first line

After:

// Only enable history navigation when cursor is at the very first position (line 1, column 1)
// This matches SCM behavior and improves accessibility for screen readers
const atFirstPosition = position.lineNumber === 1 && position.column === 1;
this.historyNavigationBackwardsEnablement.set(atFirstPosition);

This matches the pattern used in:

  • SCM view (scmViewPane.ts line 1933)
  • Suggest-enabled input (suggestEnabledInput.ts line 448)

Benefits

  • More predictable navigation for screen readers - users won't unexpectedly jump to history while navigating text
  • Consistent with existing patterns - matches the familiar SCM view behavior
  • User control - history navigation only occurs when the user explicitly positions the cursor at the start

Note on Context Keys

The broader chatCursorAtTop context key (true anywhere on first line) was intentionally preserved, as it's used for other actions like "Focus Chat List" (Cmd+Up on Mac). Only the history navigation enablement was modified.

Fixes: History navigation in chat input box should only happen on up arrow if on first char of line

cc @jooyoungseo @rperez030

Original prompt

This section details on the original issue you should resolve

<issue_title>History navigation in chat input box should only happen on up arrow if on first char of line</issue_title>
<issue_description>Currently, our chat input box navigates history if a user is anywhere on the first line and presses up arrow. This is confusing for screen readers. We should follow the behavior of the SCM view and only navigate up if the cursor is in the first position.

So, on the second line in chat input:

  • arrow up -> cursor moves up a line
  • arrow up -> cursor moves to first index of first line
  • arrow up -> history

cc @jooyoungseo, @rperez030 </issue_description>

Comments on the Issue (you are @copilot in this section)


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

- Modified onDidChangeCursorPosition in chatInputPart.ts to only enable history navigation when cursor is at position (1,1)
- This matches SCM view behavior and improves accessibility for screen readers
- History navigation now requires: arrow up at first position -> cursor moves to first line -> arrow up again -> history

Co-authored-by: meganrogge <29464607+meganrogge@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix history navigation in chat input on first character only Fix chat input history navigation to only trigger at first position Oct 24, 2025
Copilot AI requested a review from meganrogge October 24, 2025 19:35
Copilot finished work on behalf of meganrogge October 24, 2025 19:35
@meganrogge meganrogge added this to the October 2025 milestone Oct 27, 2025
@meganrogge
Copy link
Contributor

input.mov

@meganrogge meganrogge marked this pull request as ready for review October 27, 2025 14:09
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR fixes the chat input history navigation to only trigger when the cursor is at the very first position (line 1, column 1), rather than anywhere on the first line. This improves accessibility for screen reader users by preventing unexpected history navigation while navigating within their input text.

Key changes:

  • Modified history navigation enablement logic to check for exact first position instead of just first line
  • Preserved the broader chatCursorAtTop context key for other actions that need first-line detection

@meganrogge meganrogge requested a review from Tyriar October 27, 2025 14:47
@meganrogge meganrogge enabled auto-merge (squash) October 27, 2025 14:48
Copy link
Member

@Tyriar Tyriar left a comment

Choose a reason for hiding this comment

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

Does pressing up to navigate multiple history items require only a single up arrow to navigate each one? Currently pressing up causes the cursor to be at the end of the first line:

Image

I would have expected more changes than just a context key change for that.

@meganrogge
Copy link
Contributor

scm just uses context keys. we should have one for next in history though too

KeybindingsRegistry.registerCommandAndKeybindingRule({
...viewNextCommitCommand,
id: 'scm.viewNextCommit',
when: ContextKeyExpr.and(ContextKeyExpr.has('scmRepository'), ContextKeyExpr.has('scmInputIsInLastPosition'), SuggestContext.Visible.toNegated()),
primary: KeyCode.DownArrow
});
KeybindingsRegistry.registerCommandAndKeybindingRule({
...viewPreviousCommitCommand,
id: 'scm.viewPreviousCommit',
when: ContextKeyExpr.and(ContextKeyExpr.has('scmRepository'), ContextKeyExpr.has('scmInputIsInFirstPosition'), SuggestContext.Visible.toNegated()),
primary: KeyCode.UpArrow
});

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.

History navigation in chat input box should only happen on up arrow if on first char of line

3 participants