-
Notifications
You must be signed in to change notification settings - Fork 2.3k
feat: add grouped extension loading notification #5529
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
angiejones
merged 1 commit into
block:main
from
jom-sq:jom/feat/grouped-extension-loading-notification
Nov 4, 2025
Merged
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
163 changes: 163 additions & 0 deletions
163
ui/desktop/src/components/GroupedExtensionLoadingToast.tsx
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,163 @@ | ||
| import { useState } from 'react'; | ||
| import { Collapsible, CollapsibleContent, CollapsibleTrigger } from './ui/collapsible'; | ||
| import { ChevronDown, ChevronUp, Loader2 } from 'lucide-react'; | ||
| import { Button } from './ui/button'; | ||
| import { startNewSession } from '../sessions'; | ||
| import { useNavigation } from '../hooks/useNavigation'; | ||
| import { formatExtensionErrorMessage } from '../utils/extensionErrorUtils'; | ||
|
|
||
| export interface ExtensionLoadingStatus { | ||
| name: string; | ||
| status: 'loading' | 'success' | 'error'; | ||
| error?: string; | ||
| recoverHints?: string; | ||
| } | ||
|
|
||
| interface ExtensionLoadingToastProps { | ||
| extensions: ExtensionLoadingStatus[]; | ||
| totalCount: number; | ||
| isComplete: boolean; | ||
| } | ||
|
|
||
| export function GroupedExtensionLoadingToast({ | ||
| extensions, | ||
| totalCount, | ||
| isComplete, | ||
| }: ExtensionLoadingToastProps) { | ||
| const [isOpen, setIsOpen] = useState(false); | ||
| const [copiedExtension, setCopiedExtension] = useState<string | null>(null); | ||
| const setView = useNavigation(); | ||
|
|
||
| const successCount = extensions.filter((ext) => ext.status === 'success').length; | ||
| const errorCount = extensions.filter((ext) => ext.status === 'error').length; | ||
|
|
||
| const getStatusIcon = (status: 'loading' | 'success' | 'error') => { | ||
| switch (status) { | ||
| case 'loading': | ||
| return <Loader2 className="w-4 h-4 animate-spin text-blue-500" />; | ||
| case 'success': | ||
| return <div className="w-4 h-4 rounded-full bg-green-500" />; | ||
| case 'error': | ||
| return <div className="w-4 h-4 rounded-full bg-red-500" />; | ||
| } | ||
| }; | ||
|
|
||
| const getSummaryText = () => { | ||
| if (!isComplete) { | ||
| return `Loading ${totalCount} extension${totalCount !== 1 ? 's' : ''}...`; | ||
| } | ||
|
|
||
| if (errorCount === 0) { | ||
| return `Successfully loaded ${successCount} extension${successCount !== 1 ? 's' : ''}`; | ||
| } | ||
|
|
||
| return `Loaded ${successCount}/${totalCount} extension${totalCount !== 1 ? 's' : ''}`; | ||
| }; | ||
|
|
||
| const getSummaryIcon = () => { | ||
| if (!isComplete) { | ||
| return <Loader2 className="w-5 h-5 animate-spin text-blue-500" />; | ||
| } | ||
|
|
||
| if (errorCount === 0) { | ||
| return <div className="w-5 h-5 rounded-full bg-green-500" />; | ||
| } | ||
|
|
||
| return <div className="w-5 h-5 rounded-full bg-yellow-500" />; | ||
| }; | ||
|
|
||
| return ( | ||
| <div className="w-full"> | ||
| <Collapsible open={isOpen} onOpenChange={setIsOpen}> | ||
| <div className="flex flex-col"> | ||
| {/* Main summary section - clickable */} | ||
| <CollapsibleTrigger asChild> | ||
| <div className="flex items-start gap-3 pr-8 cursor-pointer hover:opacity-90 transition-opacity"> | ||
| <div className="flex items-center gap-3 flex-1 min-w-0"> | ||
| {getSummaryIcon()} | ||
| <div className="flex-1 min-w-0"> | ||
| <div className="font-medium text-base">{getSummaryText()}</div> | ||
| {errorCount > 0 && ( | ||
| <div className="text-sm opacity-90"> | ||
| {errorCount} extension{errorCount !== 1 ? 's' : ''} failed to load | ||
| </div> | ||
| )} | ||
| </div> | ||
| </div> | ||
| </div> | ||
| </CollapsibleTrigger> | ||
|
|
||
| {/* Expanded details section */} | ||
| <CollapsibleContent className="overflow-hidden"> | ||
| <div className="mt-3 pt-3 border-t border-white/20"> | ||
| <div className="space-y-3 max-h-64 overflow-y-auto pr-2 pl-1"> | ||
| {extensions.map((ext) => ( | ||
| <div key={ext.name} className="flex flex-col gap-2"> | ||
| <div className="flex items-center gap-3 text-sm"> | ||
| {getStatusIcon(ext.status)} | ||
| <div className="flex-1 min-w-0 truncate">{ext.name}</div> | ||
| </div> | ||
| {ext.status === 'error' && ext.error && ( | ||
| <div className="ml-7 flex flex-col gap-2"> | ||
| <div className="text-xs opacity-75 break-words"> | ||
| {formatExtensionErrorMessage(ext.error, 'Failed to add extension')} | ||
| </div> | ||
| {ext.recoverHints && setView ? ( | ||
| <Button | ||
| size="sm" | ||
| onClick={(e) => { | ||
| e.stopPropagation(); | ||
| startNewSession(ext.recoverHints, null, setView); | ||
| }} | ||
| className="self-start" | ||
| > | ||
| Ask goose | ||
| </Button> | ||
| ) : ( | ||
| <Button | ||
| size="sm" | ||
| onClick={(e) => { | ||
| e.stopPropagation(); | ||
| navigator.clipboard.writeText(ext.error!); | ||
| setCopiedExtension(ext.name); | ||
| setTimeout(() => setCopiedExtension(null), 2000); | ||
| }} | ||
| className="self-start" | ||
| > | ||
| {copiedExtension === ext.name ? 'Copied!' : 'Copy error'} | ||
| </Button> | ||
| )} | ||
| </div> | ||
| )} | ||
| </div> | ||
| ))} | ||
| </div> | ||
| </div> | ||
| </CollapsibleContent> | ||
|
|
||
| {/* Toggle button */} | ||
| {totalCount > 0 && ( | ||
| <CollapsibleTrigger asChild> | ||
| <button | ||
| className="flex items-center justify-center gap-1 text-xs opacity-60 hover:opacity-100 transition-opacity mt-2 py-1.5 w-full" | ||
| aria-label={isOpen ? 'Collapse details' : 'Expand details'} | ||
| > | ||
| {isOpen ? ( | ||
| <> | ||
| <span>Show less</span> | ||
| <ChevronUp className="w-3 h-3" /> | ||
| </> | ||
| ) : ( | ||
| <> | ||
| <span>Show details</span> | ||
| <ChevronDown className="w-3 h-3" /> | ||
| </> | ||
| )} | ||
| </button> | ||
| </CollapsibleTrigger> | ||
| )} | ||
| </div> | ||
| </Collapsible> | ||
| </div> | ||
| ); | ||
| } |
80 changes: 80 additions & 0 deletions
80
ui/desktop/src/components/__tests__/GroupedExtensionLoadingToast.test.tsx
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,80 @@ | ||
| import { describe, it, expect } from 'vitest'; | ||
| import { render, screen } from '@testing-library/react'; | ||
| import { MemoryRouter } from 'react-router-dom'; | ||
| import { GroupedExtensionLoadingToast } from '../GroupedExtensionLoadingToast'; | ||
|
|
||
| const renderWithRouter = (component: React.ReactElement) => { | ||
| return render(<MemoryRouter>{component}</MemoryRouter>); | ||
| }; | ||
|
|
||
| describe('GroupedExtensionLoadingToast', () => { | ||
| it('renders loading state correctly', () => { | ||
| const extensions = [ | ||
| { name: 'developer', status: 'loading' as const }, | ||
| { name: 'memory', status: 'loading' as const }, | ||
| ]; | ||
|
|
||
| renderWithRouter( | ||
| <GroupedExtensionLoadingToast extensions={extensions} totalCount={2} isComplete={false} /> | ||
| ); | ||
|
|
||
| expect(screen.getByText('Loading 2 extensions...')).toBeInTheDocument(); | ||
| expect(screen.getByText('Show details')).toBeInTheDocument(); | ||
| }); | ||
|
|
||
| it('renders success state correctly', () => { | ||
| const extensions = [ | ||
| { name: 'developer', status: 'success' as const }, | ||
| { name: 'memory', status: 'success' as const }, | ||
| ]; | ||
|
|
||
| renderWithRouter( | ||
| <GroupedExtensionLoadingToast extensions={extensions} totalCount={2} isComplete={true} /> | ||
| ); | ||
|
|
||
| expect(screen.getByText('Successfully loaded 2 extensions')).toBeInTheDocument(); | ||
| expect(screen.getByText('Show details')).toBeInTheDocument(); | ||
| }); | ||
|
|
||
| it('renders partial failure state correctly', () => { | ||
| const extensions = [ | ||
| { name: 'developer', status: 'success' as const }, | ||
| { name: 'memory', status: 'error' as const, error: 'Failed to connect' }, | ||
| ]; | ||
|
|
||
| renderWithRouter( | ||
| <GroupedExtensionLoadingToast extensions={extensions} totalCount={2} isComplete={true} /> | ||
| ); | ||
|
|
||
| expect(screen.getByText('Loaded 1/2 extensions')).toBeInTheDocument(); | ||
| expect(screen.getByText('1 extension failed to load')).toBeInTheDocument(); | ||
| expect(screen.getByText('Show details')).toBeInTheDocument(); | ||
| }); | ||
|
|
||
| it('renders single extension correctly', () => { | ||
| const extensions = [{ name: 'developer', status: 'success' as const }]; | ||
|
|
||
| renderWithRouter( | ||
| <GroupedExtensionLoadingToast extensions={extensions} totalCount={1} isComplete={true} /> | ||
| ); | ||
|
|
||
| expect(screen.getByText('Successfully loaded 1 extension')).toBeInTheDocument(); | ||
| }); | ||
|
|
||
| it('renders mixed status states correctly', () => { | ||
| const extensions = [ | ||
| { name: 'developer', status: 'success' as const }, | ||
| { name: 'memory', status: 'loading' as const }, | ||
| { name: 'Square MCP Server', status: 'error' as const, error: 'Connection failed' }, | ||
| ]; | ||
|
|
||
| renderWithRouter( | ||
| <GroupedExtensionLoadingToast extensions={extensions} totalCount={3} isComplete={false} /> | ||
| ); | ||
|
|
||
| // Summary should show loading state with error count | ||
| expect(screen.getByText('Loading 3 extensions...')).toBeInTheDocument(); | ||
| expect(screen.getByText('1 extension failed to load')).toBeInTheDocument(); | ||
| expect(screen.getByText('Show details')).toBeInTheDocument(); | ||
| }); | ||
| }); |
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
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.
[nitpick] The variable
msgcould have a more descriptive name likeformattedMsgordisplayMsgto better distinguish it from the rawerrMsgand improve code clarity about which message is being used where.