-
Notifications
You must be signed in to change notification settings - Fork 2.8k
feat: add sticky user message navigation #10693
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
roomote
wants to merge
1
commit into
main
Choose a base branch
from
feature/sticky-user-message-nav
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+118
−1
Draft
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,63 @@ | ||
| import React, { memo } from "react" | ||
| import { useTranslation } from "react-i18next" | ||
| import { ChevronUp, User } from "lucide-react" | ||
| import type { ClineMessage } from "@roo-code/types" | ||
| import { cn } from "@/lib/utils" | ||
|
|
||
| interface StickyUserMessageNavProps { | ||
| /** The user message to display in the sticky nav */ | ||
| message: ClineMessage | null | ||
| /** Callback when the sticky nav is clicked to scroll to the message */ | ||
| onNavigate: () => void | ||
| /** Whether the sticky nav should be visible */ | ||
| isVisible: boolean | ||
| } | ||
|
|
||
| /** | ||
| * A sticky navigation component that appears at the top of the chat when the user | ||
| * scrolls up past their messages. Clicking it scrolls back to the most recent | ||
| * user message that is out of view. | ||
| */ | ||
| const StickyUserMessageNav = memo(({ message, onNavigate, isVisible }: StickyUserMessageNavProps) => { | ||
| const { t } = useTranslation() | ||
|
|
||
| if (!isVisible || !message) { | ||
| return null | ||
| } | ||
|
|
||
| // Truncate message text for display | ||
| const displayText = message.text || "" | ||
| const truncatedText = displayText.length > 80 ? displayText.substring(0, 80) + "..." : displayText | ||
|
|
||
| return ( | ||
| <div | ||
| className={cn( | ||
| "sticky top-0 z-10 flex items-center gap-2 px-3 py-2 cursor-pointer", | ||
| "bg-vscode-editor-background/95 backdrop-blur-sm", | ||
| "border-b border-vscode-editorGroup-border", | ||
| "transition-all duration-200 ease-in-out", | ||
| "hover:bg-vscode-list-hoverBackground", | ||
| )} | ||
| onClick={onNavigate} | ||
| role="button" | ||
| tabIndex={0} | ||
| onKeyDown={(e) => { | ||
| if (e.key === "Enter" || e.key === " ") { | ||
| e.preventDefault() | ||
| onNavigate() | ||
| } | ||
| }} | ||
| aria-label={t("chat:stickyNav.scrollToMessage")}> | ||
| <ChevronUp className="w-4 h-4 text-vscode-descriptionForeground shrink-0" /> | ||
| <User className="w-4 h-4 text-vscode-descriptionForeground shrink-0" /> | ||
| <span className="text-sm text-vscode-foreground truncate flex-1">{truncatedText}</span> | ||
| <span className="text-xs text-vscode-descriptionForeground shrink-0"> | ||
| {t("chat:stickyNav.clickToJump")} | ||
| </span> | ||
| </div> | ||
| ) | ||
| }) | ||
|
|
||
| StickyUserMessageNav.displayName = "StickyUserMessageNav" | ||
|
|
||
| export default StickyUserMessageNav |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The
!isAtBottomcondition prevents the sticky nav from showing when the user is at the bottom of the chat. Based on issue #10690, the primary use case is when a user is at the bottom viewing a long AI response and wants to jump back to their previous messages. With this condition, the nav won't appear in that scenario sinceisAtBottomwould be true. Consider removing!isAtBottomor inverting the logic if the intent is to show the nav when user messages are scrolled out of view above.Fix it with Roo Code or mention @roomote and request a fix.