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

This commit is contained in:
Filip
2026-02-25 15:57:13 +01:00
committed by GitHub
parent 2869922696
commit 45191ad144
3 changed files with 10 additions and 6 deletions

View File

@@ -254,12 +254,13 @@ export default function Page() {
const msgs = visibleUserMessages() const msgs = visibleUserMessages()
if (msgs.length === 0) return if (msgs.length === 0) return
const current = activeMessage() const current = store.messageId
const currentIndex = current ? msgs.findIndex((m) => m.id === current.id) : -1 const base = current ? msgs.findIndex((m) => m.id === current) : msgs.length
const targetIndex = currentIndex === -1 ? (offset > 0 ? 0 : msgs.length - 1) : currentIndex + offset const currentIndex = base === -1 ? msgs.length : base
if (targetIndex < 0 || targetIndex >= msgs.length) return const targetIndex = currentIndex + offset
if (targetIndex < 0 || targetIndex > msgs.length) return
if (targetIndex === msgs.length - 1) { if (targetIndex === msgs.length) {
resumeScroll() resumeScroll()
return return
} }

View File

@@ -376,6 +376,7 @@ export function MessageTimeline(props: {
> >
<Show when={showHeader()}> <Show when={showHeader()}>
<div <div
data-session-title
classList={{ classList={{
"sticky top-0 z-30 bg-[linear-gradient(to_bottom,var(--background-stronger)_48px,transparent)]": true, "sticky top-0 z-30 bg-[linear-gradient(to_bottom,var(--background-stronger)_48px,transparent)]": true,
"w-full": true, "w-full": true,

View File

@@ -45,7 +45,9 @@ export const useSessionHashScroll = (input: {
const a = el.getBoundingClientRect() const a = el.getBoundingClientRect()
const b = root.getBoundingClientRect() 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 }) root.scrollTo({ top, behavior })
return true return true
} }