Skip to content
Open
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
16 changes: 16 additions & 0 deletions src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@ import GitVegasLogo from './assets/GitVegas.svg?react';
// Form context for sharing form state across components
interface FormContextType {
username: string;
usernames: string[];
isMultiUser: boolean;
groupByUsers: boolean;
setGroupByUsers: (value: boolean) => void;
startDate: string;
endDate: string;
githubToken: string;
Expand Down Expand Up @@ -77,6 +81,7 @@ function App() {
const [isManuallySpinning, setIsManuallySpinning] = useState(false);
const [isDataLoadingComplete, setIsDataLoadingComplete] = useState(false);
const [searchText, setSearchText] = useLocalStorage('header-search-text', '');
const [groupByUsers, setGroupByUsers] = useLocalStorage<boolean>('group-by-users', false);

const handleUrlParamsProcessed = useCallback(() => {
setInitialLoadingCount(1);
Expand Down Expand Up @@ -110,6 +115,12 @@ function App() {

const { username, startDate, endDate, githubToken, apiMode } = formSettings;

// Parse usernames for multi-user detection
const usernames = useMemo(() => {
return username ? username.split(',').map(u => u.trim()).filter(Boolean) : [];
}, [username]);
const isMultiUser = usernames.length > 1;

const {
results,
searchItemsCount,
Expand All @@ -124,6 +135,7 @@ function App() {
apiMode,
searchText,
githubToken,
isMultiUser: isMultiUser && groupByUsers,
});

const {
Expand Down Expand Up @@ -423,6 +435,10 @@ function App() {
<FormContext.Provider
value={{
username,
usernames,
isMultiUser,
groupByUsers,
setGroupByUsers,
startDate,
endDate,
githubToken,
Expand Down
116 changes: 77 additions & 39 deletions src/components/SearchForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import {
TextInput,
Flash,
UnderlineNav,
ToggleSwitch,
Text,
} from '@primer/react';
import { useFormContext } from '../App';
import { validateUsernameList, validateGitHubUsernames } from '../utils';
Expand All @@ -29,6 +31,9 @@ const SearchForm = memo(function SearchForm() {
eventsCount,
// rawEventsCount removed as it's not used
githubToken,
isMultiUser,
groupByUsers,
setGroupByUsers,
} = useFormContext();

// Track if validation is in progress
Expand Down Expand Up @@ -194,59 +199,92 @@ const SearchForm = memo(function SearchForm() {
</FormControl>
</Box>
{/* API Mode Switch */}
<Box
sx={{
<Box
sx={{
mb: 2,
display: 'flex',
alignItems: 'center',
gap: 3,
'@media (max-width: 767px)': {
overflowX: 'auto',
overflowY: 'hidden',
'& nav': {
whiteSpace: 'nowrap',
},
flexDirection: 'column',
alignItems: 'stretch',
},
}}
>
<UnderlineNav
aria-label="GitHub API Mode"
<Box
sx={{
flex: 1,
'@media (max-width: 767px)': {
minWidth: 'fit-content',
overflowX: 'auto',
overflowY: 'hidden',
'& nav': {
whiteSpace: 'nowrap',
},
},
}}
>
<UnderlineNav.Item
href="#"
aria-current={apiMode === 'summary' ? 'page' : undefined}
onSelect={e => {
e.preventDefault();
setApiMode('summary');
}}
>
Summary
</UnderlineNav.Item>
<UnderlineNav.Item
href="#"
aria-current={apiMode === 'search' ? 'page' : undefined}
counter={searchItemsCount > 0 ? searchItemsCount : undefined}
onSelect={e => {
e.preventDefault();
setApiMode('search');
<UnderlineNav
aria-label="GitHub API Mode"
sx={{
'@media (max-width: 767px)': {
minWidth: 'fit-content',
},
}}
>
GitHub Issues & PRs
</UnderlineNav.Item>
<UnderlineNav.Item
href="#"
aria-current={apiMode === 'events' ? 'page' : undefined}
counter={eventsCount > 0 ? eventsCount : undefined}
onSelect={e => {
e.preventDefault();
setApiMode('events');
<UnderlineNav.Item
href="#"
aria-current={apiMode === 'summary' ? 'page' : undefined}
onSelect={e => {
e.preventDefault();
setApiMode('summary');
}}
>
Summary
</UnderlineNav.Item>
<UnderlineNav.Item
href="#"
aria-current={apiMode === 'search' ? 'page' : undefined}
counter={searchItemsCount > 0 ? searchItemsCount : undefined}
onSelect={e => {
e.preventDefault();
setApiMode('search');
}}
>
GitHub Issues & PRs
</UnderlineNav.Item>
<UnderlineNav.Item
href="#"
aria-current={apiMode === 'events' ? 'page' : undefined}
counter={eventsCount > 0 ? eventsCount : undefined}
onSelect={e => {
e.preventDefault();
setApiMode('events');
}}
>
GitHub Events
</UnderlineNav.Item>
</UnderlineNav>
</Box>
{isMultiUser && (
<Box
sx={{
display: 'flex',
alignItems: 'center',
gap: 2,
flexShrink: 0,
}}
>
GitHub Events
</UnderlineNav.Item>
</UnderlineNav>
<Text sx={{ fontSize: 1, color: 'fg.muted', whiteSpace: 'nowrap' }}>
Group by users
</Text>
<ToggleSwitch
size="small"
checked={groupByUsers}
onChange={() => setGroupByUsers(!groupByUsers)}
aria-label="Group by users"
/>
Comment on lines +277 to +285

Copilot AI Feb 20, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The "Group by users" label (line 277-279) is visually associated with the ToggleSwitch but not semantically linked for screen readers. Consider wrapping both in a FormControl component with a proper label element, or adding an id to the Text and connecting it via aria-labelledby on the ToggleSwitch to improve accessibility for users relying on assistive technology.

Suggested change
<Text sx={{ fontSize: 1, color: 'fg.muted', whiteSpace: 'nowrap' }}>
Group by users
</Text>
<ToggleSwitch
size="small"
checked={groupByUsers}
onChange={() => setGroupByUsers(!groupByUsers)}
aria-label="Group by users"
/>
<FormControl>
<FormControl.Label sx={{ fontSize: 1, color: 'fg.muted', whiteSpace: 'nowrap', mb: 0 }}>
Group by users
</FormControl.Label>
<ToggleSwitch
size="small"
checked={groupByUsers}
onChange={() => setGroupByUsers(!groupByUsers)}
/>
</FormControl>

Copilot uses AI. Check for mistakes.
</Box>
)}
</Box>
</Box>

Expand Down
33 changes: 23 additions & 10 deletions src/hooks/useGitHubDataProcessing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ interface UseGitHubDataProcessingProps {
apiMode: 'search' | 'events' | 'summary';
searchText: string;
githubToken?: string;
isMultiUser?: boolean;
}

interface UseGitHubDataProcessingReturn {
Expand All @@ -30,6 +31,7 @@ export const useGitHubDataProcessing = ({
apiMode,
searchText,
githubToken,
isMultiUser = false,
}: UseGitHubDataProcessingProps): UseGitHubDataProcessingReturn => {
const [enrichedResults, setEnrichedResults] = useState<GitHubItem[]>([]);
const [isEnriching, setIsEnriching] = useState(false);
Expand All @@ -44,45 +46,55 @@ export const useGitHubDataProcessing = ({
return categorizeRawSearchItems(
indexedDBSearchItems as unknown as GitHubItem[],
startDate,
endDate
endDate,
isMultiUser
);
} else if (apiMode === 'summary') {
// Summary view: merge both events AND search items for complete picture
const processedEvents = processRawEvents(indexedDBEvents, startDate, endDate);
const processedSearchItems = categorizeRawSearchItems(
indexedDBSearchItems as unknown as GitHubItem[],
startDate,
endDate
endDate,
isMultiUser
);


if (isMultiUser) {
// Multi-user: skip deduplication, keep all items from both sources
const combinedResults = [...processedSearchItems, ...processedEvents];
return combinedResults.sort((a, b) =>
new Date(b.updated_at).getTime() - new Date(a.updated_at).getTime()
);
}

// Combine both datasets, removing duplicates based on html_url
const urlSet = new Set<string>();
const combinedResults: GitHubItem[] = [];

// Add search items first (they are more complete/accurate)
processedSearchItems.forEach(item => {
if (!urlSet.has(item.html_url)) {
urlSet.add(item.html_url);
combinedResults.push(item);
}
});

// Add events that aren't already covered by search items
processedEvents.forEach(item => {
if (!urlSet.has(item.html_url)) {
urlSet.add(item.html_url);
combinedResults.push(item);
}
});

// Sort by updated_at (newest first)
return combinedResults.sort((a, b) =>
return combinedResults.sort((a, b) =>
new Date(b.updated_at).getTime() - new Date(a.updated_at).getTime()
);
} else {
return [];
}
}, [apiMode, indexedDBEvents, indexedDBSearchItems, startDate, endDate]);
}, [apiMode, indexedDBEvents, indexedDBSearchItems, startDate, endDate, isMultiUser]);

// Enrich items with PR details when a token is available
// Uses SWR pattern: show cached data immediately, then fetch fresh data in background
Expand Down Expand Up @@ -148,10 +160,11 @@ export const useGitHubDataProcessing = ({
const rawSearchItems = categorizeRawSearchItems(
indexedDBSearchItems as unknown as GitHubItem[],
startDate,
endDate
endDate,
isMultiUser
);
return filterItemsByAdvancedSearch(rawSearchItems, searchText).length;
}, [indexedDBSearchItems, startDate, endDate, searchText]);
}, [indexedDBSearchItems, startDate, endDate, searchText, isMultiUser]);

const eventsCount = useMemo(() => {
const rawEvents = processRawEvents(indexedDBEvents, startDate, endDate);
Expand Down
12 changes: 9 additions & 3 deletions src/utils/rawDataUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -582,7 +582,8 @@ export const processRawEvents = (
export const categorizeRawSearchItems = (
rawItems: GitHubItem[],
startDate?: string,
endDate?: string
endDate?: string,
skipDedup = false
): GitHubItem[] => {
// Set up date filtering if dates are provided
const startDateTime = startDate ? new Date(startDate).getTime() : 0;
Expand All @@ -595,7 +596,7 @@ export const categorizeRawSearchItems = (
console.warn('Skipping item with missing title:', item.html_url || item.id);
return false;
}

const itemTime = new Date(item.updated_at).getTime();

// Filter by date range if dates are provided
Expand All @@ -609,10 +610,15 @@ export const categorizeRawSearchItems = (
return true;
});

// Skip deduplication in multi-user mode to preserve per-user items
if (skipDedup) {
return dateFilteredItems;
}

// Then remove duplicates based on html_url (unique identifier for issues/PRs)
const urlSet = new Set<string>();
const deduplicatedItems: GitHubItem[] = [];

dateFilteredItems.forEach(item => {
if (!urlSet.has(item.html_url)) {
urlSet.add(item.html_url);
Expand Down
Loading