-
Notifications
You must be signed in to change notification settings - Fork 27
Description
Project
ide
Description
In mounted Test Coverage, switching to a different project in the same window does not rebind the testing context to the new workspace.
Visible result:
- open project
Ain the current window, - let testing initialize there,
- switch to project
Bin the same window, - trigger Run Tests with Coverage,
- the coverage run can still target project
Aand its old framework instead of the newly opened workspace.
So the coverage command can run against the wrong project after a same-window workspace switch.
Root Cause
Same-window workspace switches are event-driven and do not remount the app providers:
/src/utils/workingSurface.ts:24-28openWorkspaceSurface(...)persists the new project path- dispatches
workspace:open-folder - dispatches
folder:did-open
/src/context/OptimizedProviders.tsx:212TestingProvideris mounted globally with the app providers
Other contexts explicitly listen for the same-window workspace-open event and update themselves:
/src/context/WorkspaceContext.tsx:479-507- listens for
workspace:open-folder - replaces workspace folders in the current window
- listens for
/src/context/SDKContext.tsx:214-220- listens for
workspace:open-folder - updates SDK cwd tracking
- listens for
But TestingContext does not follow that workspace switch.
It only initializes from the project path once on mount:
/src/context/TestingContext.tsx:2021-2040- registers testing event listeners
- loads settings
/src/context/TestingContext.tsx:2115-2117- reads
getProjectPath()once - schedules
discoverTests(projectPath)once after mount
- reads
discoverTests(...) stores the project path in state:
/src/context/TestingContext.tsx:453-455setState("projectPath", projectPath)
But later refreshes keep using that stored path:
/src/context/TestingContext.tsx:542-545refreshTests()callsdiscoverTests(state.projectPath)
And the coverage command also uses the stored testing state instead of re-reading the current workspace:
/src/context/TestingContext.tsx:1505-1537runWithCoverage()usesstate.projectPath- and
state.framework.framework
There is a second stale-state problem on top of that: framework detection only runs when no framework has already been cached:
/src/context/TestingContext.tsx:458-460if (!state.framework) { await detectFramework(projectPath); }
So even if some later path manually calls discoverTests(newProjectPath), the old framework from the previous workspace can still survive.
That leaves the coverage path able to run with:
- the old project path,
- the old framework,
- or both,
after the UI has already switched to a different workspace.
Error Message
Debug Logs
System Information
- Cortex IDE `alpha`
- Platform: anyScreenshots
output.mp4
Steps to Reproduce
- Open project
Ain the current window.- Example: a Vitest or Jest workspace.
- Let the testing context initialize in that workspace.
- Without reloading the app, open project
Bin the same window using a same-window workspace-open flow.- Example: Recent Projects in current window, or another path that dispatches
workspace:open-folder.
- Example: Recent Projects in current window, or another path that dispatches
- Run Run Tests with Coverage.
- Observe which project/framework the coverage run actually uses.
Expected Behavior
After a same-window project switch, Run Tests with Coverage should target the newly opened workspace.
Testing state should be rebound to the new workspace, including:
projectPath- detected framework
- discovered tests
- coverage state that belongs to the previous workspace
Actual Behavior
TestingContext keeps using stale project/framework state captured from the previous workspace.
As a result, Run Tests with Coverage can continue targeting the old project after the UI has already switched to a different one.
Additional Context
This is not the same as the current live/local Test Coverage issues:
- live
#29745Run Tests with Coverage auto-enables coverage decorations without explicit opt-in - live
#29746Toggle Code Coverage Overlay command toggles decoration mode, not overlay/panel mode - live
#29748Coverage decoration stylesheet is injected globally and never removed - live
#29749Branch coverage hover can renderNaN%when branch total is zero - live
#29764Statement coverage is mirrored from line coverage, masking statement-specific gaps - local bug-report-test-coverage-failed-runs-can-leave-stale-previous-editor-decorations-visible-because-runwithcoverage-never-clears-old-coverage-state.md
Those issues cover opt-in behavior, overlay command semantics, stylesheet lifecycle, hover math, metric mapping, and stale editor decorations after a failed rerun.
This report is specifically about same-window workspace switching:
- the workspace changes,
TestingContextdoes not follow the new workspace,- and Run Tests with Coverage can still execute against the previous project.
Duplicate Check
Re-checked local (bug-3, bugs-codex) and targeted live repo searches across open and closed issues with:
coverage workspace switch old projectrun with coverage old project after workspace switchtesting context workspace switch stale projectPathtest coverage stale project switchtesting provider workspace switch project path- local grep for
coverage.*workspace switch,workspace switch.*coverage,old project.*coverage, andstale projectPath.*coverage
Findings:
- Local: no matching draft found for coverage commands continuing to use stale testing workspace state after a same-window project switch.
- Live repo: no matching issue found in
PlatformNetwork/bounty-challengefor this exact frontend workspace-switch / stale-coverage-target bug at check time (2026-03-24 UTC). - Closest live/local items are different:
- coverage opt-in behavior,
- overlay command semantics,
- stylesheet lifecycle,
- stale decorations after a failed rerun.
- Why they are different:
- none of those reports cover
TestingContextmissing the same-windowworkspace:open-folderrebinding path and then using stalestate.projectPath/state.frameworkwhenrunWithCoverage()is triggered.
- none of those reports cover