Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 51 additions & 1 deletion webview-ui/src/components/chat/ChatView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ import SystemPromptWarning from "./SystemPromptWarning"
import ProfileViolationWarning from "./ProfileViolationWarning"
import { CheckpointWarning } from "./CheckpointWarning"
import { QueuedMessages } from "./QueuedMessages"
import { MessageNavigator } from "./MessageNavigator"

export interface ChatViewProps {
isHidden: boolean
Expand Down Expand Up @@ -193,6 +194,7 @@ const ChatViewComponent: React.ForwardRefRenderFunction<ChatViewRef, ChatViewPro
const [showCheckpointWarning, setShowCheckpointWarning] = useState<boolean>(false)
const [isCondensing, setIsCondensing] = useState<boolean>(false)
const [showAnnouncementModal, setShowAnnouncementModal] = useState(false)
const [showMessageNavigator, setShowMessageNavigator] = useState(false)
const everVisibleMessagesTsRef = useRef<LRUCache<number, boolean>>(
new LRUCache({
max: 100,
Expand Down Expand Up @@ -1728,8 +1730,13 @@ const ChatViewComponent: React.ForwardRefRenderFunction<ChatViewRef, ChatViewPro
switchToNextMode()
}
}
// Check for Cmd/Ctrl + F to open message navigator
if ((event.metaKey || event.ctrlKey) && event.key === "f" && task) {
event.preventDefault()
setShowMessageNavigator(true)
}
},
[switchToNextMode, switchToPreviousMode],
[switchToNextMode, switchToPreviousMode, task],
)

useEffect(() => {
Expand Down Expand Up @@ -1759,6 +1766,40 @@ const ChatViewComponent: React.ForwardRefRenderFunction<ChatViewRef, ChatViewPro
vscode.postMessage({ type: "condenseTaskContextRequest", text: taskId })
}

// Handle navigation to a specific message
const handleNavigateToMessage = useCallback(
(messageIndex: number) => {
// Find the message in visibleMessages
const targetMessage = visibleMessages[messageIndex]
if (targetMessage && virtuosoRef.current) {
// Find the index in groupedMessages
const groupIndex = groupedMessages.findIndex((item) => {
if (Array.isArray(item)) {
return item.some((msg) => msg.ts === targetMessage.ts)
}
return item.ts === targetMessage.ts
})

if (groupIndex !== -1) {
// Scroll to the message
virtuosoRef.current.scrollToIndex({
index: groupIndex,
behavior: "smooth",
align: "center",
})

// Optionally expand the message if it's collapsible
if (!Array.isArray(groupedMessages[groupIndex])) {
const message = groupedMessages[groupIndex] as ClineMessage
setExpandedRows((prev) => ({ ...prev, [message.ts]: true }))
}
}
}
setShowMessageNavigator(false)
},
[visibleMessages, groupedMessages],
)

const areButtonsVisible = showScrollToBottom || primaryButtonText || secondaryButtonText || isStreaming

return (
Expand Down Expand Up @@ -1790,6 +1831,7 @@ const ChatViewComponent: React.ForwardRefRenderFunction<ChatViewRef, ChatViewPro
buttonsDisabled={sendingDisabled}
handleCondenseContext={handleCondenseContext}
todos={latestTodos}
onOpenNavigator={() => setShowMessageNavigator(true)}
/>

{hasSystemPromptOverride && (
Expand Down Expand Up @@ -2013,6 +2055,14 @@ const ChatViewComponent: React.ForwardRefRenderFunction<ChatViewRef, ChatViewPro
)}

<div id="roo-portal" />

{/* Message Navigator Overlay */}
<MessageNavigator
messages={visibleMessages}
onNavigateToMessage={handleNavigateToMessage}
isVisible={showMessageNavigator}
onClose={() => setShowMessageNavigator(false)}
/>
</div>
)
}
Expand Down
Loading
Loading