This repository was archived by the owner on Jun 26, 2026. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 229
Add dismissible NVIDIA driver warning with versioned suppression #1535
Open
benceruleanlu
wants to merge
5
commits into
main
Choose a base branch
from
issue-1534-nvidia-driver-warning
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 3 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
5a72636
Add dismiss option for NVIDIA driver warning
benceruleanlu e8a7fde
Scope NVIDIA warning dismissal to min driver
benceruleanlu 3910bc7
Drop legacy Nvidia warning suppression flag
benceruleanlu 48a1699
Use min driver constant in tests
benceruleanlu 47491c0
Add NVIDIA driver warning helper
benceruleanlu 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
Some comments aren't visible on the classic Files Changed page.
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -33,13 +33,15 @@ vi.mock('node:fs/promises', () => ({ | |
| })); | ||
|
|
||
| const config = { | ||
| get: vi.fn((key: string) => { | ||
| get: vi.fn((key: string): string | undefined => { | ||
| if (key === 'installState') return 'installed'; | ||
| if (key === 'basePath') return 'valid/base'; | ||
| return undefined; | ||
| }), | ||
| set: vi.fn((key: string, value: string) => { | ||
| if (key !== 'basePath') throw new Error(`Unexpected key: ${key}`); | ||
| if (!value) throw new Error(`Unexpected value: [${value}]`); | ||
| set: vi.fn((key: string, value: unknown) => { | ||
| const allowedKeys = new Set(['basePath', 'suppressNvidiaDriverWarningFor']); | ||
| if (!allowedKeys.has(key)) throw new Error(`Unexpected key: ${key}`); | ||
| if (key === 'basePath' && !value) throw new Error(`Unexpected value: [${value}]`); | ||
| }), | ||
| }; | ||
| vi.mock('@/store/desktopConfig', () => ({ | ||
|
|
@@ -110,6 +112,7 @@ const createMockAppWindow = () => { | |
| send: vi.fn(), | ||
| loadPage: vi.fn(() => Promise.resolve(null)), | ||
| showOpenDialog: vi.fn(), | ||
| showMessageBox: vi.fn(() => Promise.resolve({ response: 0, checkboxChecked: false })), | ||
| maximize: vi.fn(), | ||
| }; | ||
| return mock as unknown as AppWindow; | ||
|
|
@@ -251,6 +254,77 @@ describe('InstallationManager', () => { | |
| cleanup?.(); | ||
| }); | ||
| }); | ||
|
|
||
| describe('warnIfNvidiaDriverTooOld', () => { | ||
| const createInstallation = (device: string) => | ||
| ({ virtualEnvironment: { selectedDevice: device } }) as ComfyInstallation; | ||
|
|
||
| const getManagerMethods = () => | ||
| manager as unknown as { | ||
| warnIfNvidiaDriverTooOld: (installation: ComfyInstallation) => Promise<void>; | ||
| getNvidiaDriverVersionFromSmi: () => Promise<string | undefined>; | ||
| getNvidiaDriverVersionFromSmiFallback: () => Promise<string | undefined>; | ||
| }; | ||
|
|
||
| beforeEach(() => { | ||
| vi.mocked(config.get).mockImplementation((key: string) => { | ||
| if (key === 'installState') return 'installed'; | ||
| if (key === 'basePath') return 'valid/base'; | ||
| return undefined; | ||
| }); | ||
| vi.mocked(config.set).mockClear(); | ||
| vi.mocked(mockAppWindow.showMessageBox).mockClear(); | ||
| }); | ||
|
|
||
| it('skips dialog when warning is suppressed for the current minimum version', async () => { | ||
| const platformSpy = vi.spyOn(process, 'platform', 'get').mockReturnValue('win32'); | ||
| const managerMethods = getManagerMethods(); | ||
| const smiSpy = vi.spyOn(managerMethods, 'getNvidiaDriverVersionFromSmi').mockResolvedValue('570.0'); | ||
| const smiFallbackSpy = vi | ||
| .spyOn(managerMethods, 'getNvidiaDriverVersionFromSmiFallback') | ||
| .mockResolvedValue(undefined); | ||
|
|
||
| try { | ||
| vi.mocked(config.get).mockImplementation((key: string) => { | ||
| if (key === 'installState') return 'installed'; | ||
| if (key === 'basePath') return 'valid/base'; | ||
| if (key === 'suppressNvidiaDriverWarningFor') return '580'; | ||
| return undefined; | ||
| }); | ||
|
|
||
| await managerMethods.warnIfNvidiaDriverTooOld(createInstallation('nvidia')); | ||
|
|
||
| expect(smiSpy).not.toHaveBeenCalled(); | ||
| expect(smiFallbackSpy).not.toHaveBeenCalled(); | ||
| expect(mockAppWindow.showMessageBox).not.toHaveBeenCalled(); | ||
| } finally { | ||
| smiSpy.mockRestore(); | ||
| smiFallbackSpy.mockRestore(); | ||
| platformSpy.mockRestore(); | ||
| } | ||
| }); | ||
|
|
||
| it('stores the current minimum version when dismissed', async () => { | ||
| const platformSpy = vi.spyOn(process, 'platform', 'get').mockReturnValue('win32'); | ||
| const managerMethods = getManagerMethods(); | ||
| const smiSpy = vi.spyOn(managerMethods, 'getNvidiaDriverVersionFromSmi').mockResolvedValue('570.0'); | ||
| const smiFallbackSpy = vi | ||
| .spyOn(managerMethods, 'getNvidiaDriverVersionFromSmiFallback') | ||
| .mockResolvedValue(undefined); | ||
|
|
||
| try { | ||
| vi.mocked(mockAppWindow.showMessageBox).mockResolvedValue({ response: 0, checkboxChecked: true }); | ||
|
|
||
| await managerMethods.warnIfNvidiaDriverTooOld(createInstallation('nvidia')); | ||
|
|
||
| expect(config.set).toHaveBeenCalledWith('suppressNvidiaDriverWarningFor', '580'); | ||
| } finally { | ||
| smiSpy.mockRestore(); | ||
| smiFallbackSpy.mockRestore(); | ||
| platformSpy.mockRestore(); | ||
| } | ||
| }); | ||
| }); | ||
|
||
| }); | ||
|
|
||
| describe('parseNvidiaDriverVersionFromSmiOutput', () => { | ||
|
|
||
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 | 🔵 Trivial
Use
testinstead ofitper coding guidelines.The tests are well-structured with proper mock setup and cleanup. However, per coding guidelines for
tests/unit/**/*.test.{js,ts}: "Usetestinstead ofitfor defining tests."Suggested change
📝 Committable suggestion
🤖 Prompt for AI Agents