-
Notifications
You must be signed in to change notification settings - Fork 2.6k
feat: Add indexing status badge to chat view (#4429) #4532
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
Merged
Merged
Changes from 9 commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
53f30bd
feat: add settings navigation and indexing status component
hannesrudolph da57a4d
Delete .claude/settings.local.json
daniel-lxs f6ee13c
fix: address PR review feedback for IndexingStatusBadge
hannesrudolph 68ea1af
fix: add missing translations for IndexingStatusBadge
hannesrudolph a571f34
fix: resolve test failures by clearing mock calls before assertions
hannesrudolph 4db9783
fix: add missing translations
daniel-lxs 27f0cae
revert this
daniel-lxs 526ed71
fix: add codebaseIndexConfig to useExtensionState and conditionally r…
daniel-lxs 32a6a9e
fix: update hover behavior for IndexingStatusDot and refactor mouse e…
daniel-lxs 8120b84
fix: remove test for progress ring during indexing
daniel-lxs d69452f
fix: refactor getStatusColorClass to simplify status color handling
daniel-lxs fa460da
fix: remove onNavigateToSettings prop and update IndexingStatusDot to…
daniel-lxs 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
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
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,135 @@ | ||
| import React, { useState, useEffect, useMemo } from "react" | ||
| import { cn } from "@src/lib/utils" | ||
| import { vscode } from "@src/utils/vscode" | ||
| import { useAppTranslation } from "@/i18n/TranslationContext" | ||
| import { useTooltip } from "@/hooks/useTooltip" | ||
| import type { IndexingStatus, IndexingStatusUpdateMessage } from "@roo/ExtensionMessage" | ||
|
|
||
| interface IndexingStatusDotProps { | ||
| onNavigateToSettings?: () => void | ||
| className?: string | ||
| } | ||
|
|
||
| export const IndexingStatusDot: React.FC<IndexingStatusDotProps> = ({ onNavigateToSettings, className }) => { | ||
| const { t } = useAppTranslation() | ||
| const { showTooltip, handleMouseEnter, handleMouseLeave, cleanup } = useTooltip({ delay: 300 }) | ||
| const [isHovered, setIsHovered] = useState(false) | ||
|
|
||
| const [indexingStatus, setIndexingStatus] = useState<IndexingStatus>({ | ||
| systemStatus: "Standby", | ||
| processedItems: 0, | ||
| totalItems: 0, | ||
| currentItemUnit: "items", | ||
| }) | ||
|
|
||
| useEffect(() => { | ||
| // Request initial indexing status | ||
| vscode.postMessage({ type: "requestIndexingStatus" }) | ||
|
|
||
| // Set up message listener for status updates | ||
| const handleMessage = (event: MessageEvent<IndexingStatusUpdateMessage>) => { | ||
| if (event.data.type === "indexingStatusUpdate") { | ||
| const status = event.data.values | ||
| setIndexingStatus(status) | ||
| } | ||
| } | ||
|
|
||
| window.addEventListener("message", handleMessage) | ||
|
|
||
| return () => { | ||
| window.removeEventListener("message", handleMessage) | ||
| cleanup() | ||
| } | ||
| }, [cleanup]) | ||
|
|
||
| // Calculate progress percentage with memoization | ||
| const progressPercentage = useMemo( | ||
| () => | ||
| indexingStatus.totalItems > 0 | ||
| ? Math.round((indexingStatus.processedItems / indexingStatus.totalItems) * 100) | ||
| : 0, | ||
| [indexingStatus.processedItems, indexingStatus.totalItems], | ||
| ) | ||
|
|
||
| // Get tooltip text with internationalization | ||
| const getTooltipText = () => { | ||
| switch (indexingStatus.systemStatus) { | ||
| case "Standby": | ||
| return t("chat:indexingStatus.ready") | ||
| case "Indexing": | ||
| return t("chat:indexingStatus.indexing", { percentage: progressPercentage }) | ||
| case "Indexed": | ||
| return t("chat:indexingStatus.indexed") | ||
| case "Error": | ||
| return t("chat:indexingStatus.error") | ||
| default: | ||
| return t("chat:indexingStatus.status") | ||
| } | ||
| } | ||
|
|
||
| // Navigate to settings when clicked | ||
| const handleClick = () => { | ||
| if (onNavigateToSettings) { | ||
| onNavigateToSettings() | ||
| } | ||
hannesrudolph marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| } | ||
|
|
||
| const handleMouseEnterButton = () => { | ||
| setIsHovered(true) | ||
| handleMouseEnter() | ||
| } | ||
|
|
||
| const handleMouseLeaveButton = () => { | ||
| setIsHovered(false) | ||
| handleMouseLeave() | ||
| } | ||
|
|
||
| return ( | ||
| <div className={cn("relative inline-block", className)}> | ||
| <button | ||
| onClick={handleClick} | ||
| onMouseEnter={handleMouseEnterButton} | ||
| onMouseLeave={handleMouseLeaveButton} | ||
| className={cn( | ||
| "flex items-center justify-center w-7 h-7 rounded-md", | ||
| "bg-transparent hover:bg-vscode-list-hoverBackground", | ||
| "cursor-pointer transition-all duration-200", | ||
| "opacity-85 hover:opacity-100 relative", | ||
| )} | ||
| aria-label={getTooltipText()}> | ||
| {/* Status dot */} | ||
| <span | ||
| className={cn( | ||
| "inline-block w-2 h-2 rounded-full relative z-10 transition-colors duration-200", | ||
| // Default state - always show muted color | ||
| !isHovered && "bg-vscode-descriptionForeground/60", | ||
daniel-lxs marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| // Hover states - show status colors | ||
| isHovered && indexingStatus.systemStatus === "Standby" && "bg-vscode-descriptionForeground/60", | ||
| isHovered && indexingStatus.systemStatus === "Indexing" && "bg-yellow-500 animate-pulse", | ||
| isHovered && indexingStatus.systemStatus === "Indexed" && "bg-green-500", | ||
| isHovered && indexingStatus.systemStatus === "Error" && "bg-red-500", | ||
| )} | ||
| /> | ||
| </button> | ||
| {showTooltip && ( | ||
| <div | ||
| className={cn( | ||
| "absolute bottom-full left-1/2 transform -translate-x-1/2 mb-2", | ||
| "px-2 py-1 text-xs font-medium text-vscode-foreground", | ||
| "bg-vscode-editor-background border border-vscode-panel-border", | ||
| "rounded shadow-lg whitespace-nowrap z-50", | ||
| )} | ||
| role="tooltip"> | ||
| {getTooltipText()} | ||
| <div | ||
| className={cn( | ||
| "absolute top-full left-1/2 transform -translate-x-1/2", | ||
| "w-0 h-0 border-l-4 border-r-4 border-t-4", | ||
| "border-l-transparent border-r-transparent border-t-vscode-panel-border", | ||
| )} | ||
| /> | ||
| </div> | ||
| )} | ||
| </div> | ||
| ) | ||
| } | ||
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.
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.
Uh oh!
There was an error while loading. Please reload this page.