Having 2 jobs isn't inherently illegal. But pretty much every single full-time employment contract for an SWE that I've seen, stipulated that I am not allowed to have any other full-time job for the period of my employment.
In both of the contracts I had signed so far, there was an exclusivity clause saying that I would only work (as a software engineer) for the company I was signing with.
Legal or not, if you tell your manager that you are also working for another company half the time (unless you work odd hours), will they be OK? If so then good. If not then it's a matter of transparency and trust.
Also doesn't the contract has something about the number of hours? It may not be enforceable, but it's on paper.
I do not tell my employer everything, that is a scenario to demonstrate that you doing a second job violates basic trust, or even the contract. That is different than you looking for a new job, which should always be at the back of any manager's mind.
when you are hired they tell you exactly the basis on which you are hired, either to sit in an office/in front on slack at specific hours (FTE) or outcome-based (freelancing or FTE on flex terms).
It's totally cool that we as professionals discuss our commitment and get a flexible working arrangement. It's not cool to say you will be available to respond to incidents and what not and then not do that.
It is not their concern what I do on social media. It is unfortunate that there is so much power imbalance that most employees are afraid to criticize their employers in public.
For SWE or other programming/code related positions I can see that making sense. You may only write 30 minutes of code in a day but the other 7.5 hours is spent either cogitating over the problem and creating the environment that allows you to solve the problem or participating in your team to make sure everyone is on the same page.
You split that 8 hours between 2 companies and unless you are significantly under-employed at both jobs (2X in both locations or more) you're not going to be able to give your all.