-
Notifications
You must be signed in to change notification settings - Fork 3.5k
fix(harness-init): show runtime-setup overlay on first run only (Closes #5047) #5066
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
senamakel
merged 3 commits into
tinyhumansai:main
from
M3gA-Mind:fix/GH-5047-runtime-setup-first-run-only
Jul 20, 2026
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
d1e8799
fix(harness-init): show runtime-setup overlay on first run only (GH-5…
M3gA-Mind 17a7e7e
Merge remote-tracking branch 'upstream/main' into fix/GH-5047-runtime…
M3gA-Mind 4e2c70c
fix(harness-init): address review — symlink-safe probe, test split, d…
M3gA-Mind 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
98 changes: 98 additions & 0 deletions
98
app/src/components/InitProgressScreen/HarnessInitOverlay.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,98 @@ | ||
| import { fireEvent, screen, waitFor } from '@testing-library/react'; | ||
| import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'; | ||
|
|
||
| import type { HarnessInitSnapshot } from '../../services/harnessInitService'; | ||
| import { renderWithProviders } from '../../test/test-utils'; | ||
| // Imported after the mock is registered. | ||
| import HarnessInitOverlay from './HarnessInitOverlay'; | ||
|
|
||
| // The overlay polls the service; drive it with a controllable mock. | ||
| const fetchHarnessInitStatus = vi.fn<() => Promise<HarnessInitSnapshot | null>>(); | ||
| const runHarnessInit = vi.fn<(force?: boolean) => Promise<HarnessInitSnapshot | null>>(); | ||
|
|
||
| vi.mock('../../services/harnessInitService', () => ({ | ||
| fetchHarnessInitStatus: () => fetchHarnessInitStatus(), | ||
| runHarnessInit: (force?: boolean) => runHarnessInit(force), | ||
| })); | ||
|
|
||
| function snapshot(overrides: Partial<HarnessInitSnapshot> = {}): HarnessInitSnapshot { | ||
| return { | ||
| overall: 'running', | ||
| startedAt: '2026-07-20T00:00:00Z', | ||
| finishedAt: null, | ||
| steps: [ | ||
| { | ||
| id: 'python_runtime', | ||
| label: 'Python runtime', | ||
| required: false, | ||
| state: 'running', | ||
| message: null, | ||
| percent: null, | ||
| updatedAt: null, | ||
| }, | ||
| ], | ||
| ...overrides, | ||
| }; | ||
| } | ||
|
|
||
| beforeEach(() => { | ||
| fetchHarnessInitStatus.mockReset(); | ||
| runHarnessInit.mockReset(); | ||
| window.sessionStorage.clear(); | ||
| }); | ||
|
|
||
| afterEach(() => { | ||
| vi.restoreAllMocks(); | ||
| }); | ||
|
|
||
| describe('HarnessInitOverlay', () => { | ||
| it('renders nothing on a warm start (already done)', async () => { | ||
| fetchHarnessInitStatus.mockResolvedValue(snapshot({ overall: 'done', startedAt: 'warm-run' })); | ||
|
|
||
| const { container } = renderWithProviders(<HarnessInitOverlay />); | ||
|
|
||
| await waitFor(() => expect(fetchHarnessInitStatus).toHaveBeenCalled()); | ||
| expect(screen.queryByText('Run in background')).not.toBeInTheDocument(); | ||
| expect(container).toBeEmptyDOMElement(); | ||
| }); | ||
|
|
||
| it('shows the blocking overlay while a provisioning run is in progress', async () => { | ||
| fetchHarnessInitStatus.mockResolvedValue(snapshot({ startedAt: 'cold-run' })); | ||
|
|
||
| renderWithProviders(<HarnessInitOverlay />); | ||
|
|
||
| expect(await screen.findByText('Run in background')).toBeInTheDocument(); | ||
| }); | ||
|
|
||
| it('keeps the overlay dismissed across a remount for the same run (GH-5047)', async () => { | ||
| const run = snapshot({ startedAt: 'same-run' }); | ||
| fetchHarnessInitStatus.mockResolvedValue(run); | ||
|
|
||
| const first = renderWithProviders(<HarnessInitOverlay />); | ||
| fireEvent.click(await screen.findByText('Run in background')); | ||
| await waitFor(() => expect(screen.queryByText('Run in background')).not.toBeInTheDocument()); | ||
| first.unmount(); | ||
|
|
||
| // Remount while the same run is still in progress — it must not reopen. | ||
| const second = renderWithProviders(<HarnessInitOverlay />); | ||
| await waitFor(() => expect(fetchHarnessInitStatus).toHaveBeenCalled()); | ||
| // Give any pending poll a chance to (wrongly) re-render the overlay. | ||
| await Promise.resolve(); | ||
| expect(screen.queryByText('Run in background')).not.toBeInTheDocument(); | ||
| expect(second.container).toBeEmptyDOMElement(); | ||
| }); | ||
|
|
||
| it('reopens for a genuinely new provisioning run after a prior dismissal', async () => { | ||
| // Dismiss the first run. | ||
| fetchHarnessInitStatus.mockResolvedValue(snapshot({ startedAt: 'run-1' })); | ||
| const first = renderWithProviders(<HarnessInitOverlay />); | ||
| fireEvent.click(await screen.findByText('Run in background')); | ||
| await waitFor(() => expect(screen.queryByText('Run in background')).not.toBeInTheDocument()); | ||
| first.unmount(); | ||
|
|
||
| // A new run (fresh startedAt) is allowed to surface again. | ||
| fetchHarnessInitStatus.mockResolvedValue(snapshot({ startedAt: 'run-2' })); | ||
| renderWithProviders(<HarnessInitOverlay />); | ||
| expect(await screen.findByText('Run in background')).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.
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.