Skip to content

fix(app): keyboard navigation previous/next message#15047

Merged
adamdotdevin merged 1 commit intoanomalyco:devfrom
neriousy:fix/keyboard-nav
Feb 25, 2026
Merged

fix(app): keyboard navigation previous/next message#15047
adamdotdevin merged 1 commit intoanomalyco:devfrom
neriousy:fix/keyboard-nav

Conversation

@neriousy
Copy link
Contributor

@neriousy neriousy commented Feb 25, 2026

Issue for this PR

Closes #15046

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

Keyboard message navigation in Session view was faulty: from live/bottom state it could skip to the wrong user turn, and jumped messages could appear partially hidden under the sticky session header. Update navigation to use pinned message state (messageId) and apply sticky-header offset during scroll targeting so previous/next and hash jumps land on the correct, fully visible message.

How did you verify your code works?

  1. Open a session
  2. Write some messages
  3. Press CTRL + UP/DOWN Arrows

Screenshots / recordings

If this is a UI change, please include a screenshot or recording.

2026-02-25.11-26-12.mp4

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

If you do not follow this template your PR will be automatically rejected.

Copilot AI review requested due to automatic review settings February 25, 2026 10:32
@github-actions github-actions bot added needs:compliance This means the issue will auto-close after 2 hours. contributor labels Feb 25, 2026
@github-actions github-actions bot removed the needs:compliance This means the issue will auto-close after 2 hours. label Feb 25, 2026
@github-actions
Copy link
Contributor

Thanks for updating your PR! It now meets our contributing guidelines. 👍

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

Fixes incorrect keyboard navigation in the Session message timeline when starting from the live/bottom state, and ensures hash/shortcut jumps scroll messages fully into view (not hidden under the sticky session header).

Changes:

  • Adjust message prev/next navigation to use the pinned store.messageId state rather than activeMessage() fallback behavior.
  • Add a data-session-title marker to the sticky session header container in the timeline.
  • Update hash/anchor scrolling to apply a sticky-header height inset when computing the scroll target position.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
packages/app/src/pages/session/use-session-hash-scroll.ts Applies sticky-header offset when scrolling to an element/message by hash or navigation.
packages/app/src/pages/session/message-timeline.tsx Adds a data-session-title attribute to the sticky session header for scroll inset detection.
packages/app/src/pages/session.tsx Fixes previous/next message keyboard navigation indexing from live/bottom state using store.messageId.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 47 to 51
const b = root.getBoundingClientRect()
const top = a.top - b.top + root.scrollTop
const sticky = root.querySelector("[data-session-title]")
const inset = sticky instanceof HTMLElement ? sticky.offsetHeight : 0
const top = Math.max(0, a.top - b.top + root.scrollTop - inset)
root.scrollTo({ top, behavior })
Copy link

Copilot AI Feb 25, 2026

Choose a reason for hiding this comment

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

The new sticky-header inset logic in scrollToElement isn’t covered by tests. Since this module already has a test file, consider adding a small DOM-based unit test (stubbing getBoundingClientRect/offsetHeight and asserting the scrollTo({ top }) value) to prevent regressions where hash/keyboard jumps land under the sticky header again.

Copilot uses AI. Check for mistakes.
@adamdotdevin adamdotdevin merged commit 45191ad into anomalyco:dev Feb 25, 2026
17 of 18 checks passed
neostfox pushed a commit to neostfox/opencode that referenced this pull request Feb 26, 2026
sebishogun pushed a commit to sebishogun/opencode that referenced this pull request Feb 26, 2026
jonathanmiddleton pushed a commit to jonathanmiddleton/opencode that referenced this pull request Mar 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] Keyboard navigation previous/next message

3 participants