how is it calculated when stock invested in two different states

I worked in CA for 8 months, and CA has state tax. While in CA, let's assume I did stock investment and had loss of $1000.

 

Then I jumped to WA for another 4 months, and WA does not have state tax. While in WA, let's assume my stock has a profit of $2000.

 

Usually if I stayed in CA for the whole year, I only need to pay the tax of $1000. But since I moved to a state without state tax and profited there, should I pay less tax?

 

If so, will turbotax be smart enough to do? How does it know when do I move to WA? will my tax form get from robinhood tell it that?