-
Notifications
You must be signed in to change notification settings - Fork 148
fix: reduce jank when analyzing repository cards #199
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
AmintaCCCP
merged 5 commits into
AmintaCCCP:main
from
xinvxueyuan:fix/repository-card-ai-analysis-freeze
Jun 6, 2026
Merged
Changes from 1 commit
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
25ea9ae
fix: reduce jank when analyzing repository cards
xinvxueyuan 357e0bf
fix: address AI review persistence concerns
xinvxueyuan 45ed403
fix: handle persist storage failures
xinvxueyuan 9f6b428
fix: harden IndexedDB persistence fallback
AmintaCCCP 13cc02f
fix: propagate localStorage fallback failures
AmintaCCCP 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,85 @@ | ||
| import { beforeAll, beforeEach, describe, expect, it, vi } from 'vitest'; | ||
| import { Repository } from '../types'; | ||
|
|
||
| let useAppStore: typeof import('./useAppStore').useAppStore; | ||
|
|
||
| beforeAll(async () => { | ||
| ({ useAppStore } = await vi.importActual<typeof import('./useAppStore')>('./useAppStore')); | ||
| }); | ||
|
|
||
| const createRepository = (id: number, overrides: Partial<Repository> = {}): Repository => ({ | ||
| id, | ||
| name: `repo-${id}`, | ||
| full_name: `owner/repo-${id}`, | ||
| description: 'A test repository', | ||
| html_url: `https://github.com/owner/repo-${id}`, | ||
| stargazers_count: 10, | ||
| forks_count: 1, | ||
| forks: 1, | ||
| language: 'TypeScript', | ||
| created_at: '2026-01-01T00:00:00.000Z', | ||
| updated_at: '2026-01-02T00:00:00.000Z', | ||
| pushed_at: '2026-01-03T00:00:00.000Z', | ||
| owner: { | ||
| login: 'owner', | ||
| avatar_url: 'https://github.com/avatar.png', | ||
| }, | ||
| topics: ['test'], | ||
| ...overrides, | ||
| }); | ||
|
|
||
| describe('useAppStore repository performance guards', () => { | ||
| beforeEach(() => { | ||
| useAppStore.setState({ | ||
| repositories: [], | ||
| searchResults: [], | ||
| analyzingRepositoryIds: new Set(), | ||
| }); | ||
| }); | ||
|
|
||
| it('does not notify subscribers when updateRepository receives an equivalent repository', () => { | ||
| const repo = createRepository(1); | ||
| useAppStore.setState({ repositories: [repo], searchResults: [repo] }); | ||
|
|
||
| const previousRepositories = useAppStore.getState().repositories; | ||
| const previousSearchResults = useAppStore.getState().searchResults; | ||
| let notifications = 0; | ||
| const unsubscribe = useAppStore.subscribe(() => { | ||
| notifications++; | ||
| }); | ||
|
|
||
| useAppStore.getState().updateRepository({ ...repo }); | ||
| unsubscribe(); | ||
|
|
||
| expect(notifications).toBe(0); | ||
| expect(useAppStore.getState().repositories).toBe(previousRepositories); | ||
| expect(useAppStore.getState().searchResults).toBe(previousSearchResults); | ||
| }); | ||
|
|
||
| it('updates only lists that contain the repository', () => { | ||
| const repo = createRepository(1); | ||
| useAppStore.setState({ repositories: [repo], searchResults: [] }); | ||
|
|
||
| const previousSearchResults = useAppStore.getState().searchResults; | ||
| useAppStore.getState().updateRepository({ ...repo, ai_summary: 'Updated summary' }); | ||
|
|
||
| expect(useAppStore.getState().repositories[0].ai_summary).toBe('Updated summary'); | ||
| expect(useAppStore.getState().searchResults).toBe(previousSearchResults); | ||
| }); | ||
|
|
||
| it('does not notify subscribers when analyzing state is unchanged', () => { | ||
| useAppStore.setState({ analyzingRepositoryIds: new Set([1]) }); | ||
|
|
||
| const previousAnalyzingIds = useAppStore.getState().analyzingRepositoryIds; | ||
| let notifications = 0; | ||
| const unsubscribe = useAppStore.subscribe(() => { | ||
| notifications++; | ||
| }); | ||
|
|
||
| useAppStore.getState().setAnalyzingRepository(1, true); | ||
| unsubscribe(); | ||
|
|
||
| expect(notifications).toBe(0); | ||
| expect(useAppStore.getState().analyzingRepositoryIds).toBe(previousAnalyzingIds); | ||
| }); | ||
| }); | ||
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.