Chain of commands

You cannot "insert" new command into Cypress command chainopen in new window from outside.

cy.wait(10_000) // sleep 10 seconds
setTimeout(() => {
  cy.log('New command!')
}, 5_000)

Cypress throws an error if you try to add more commands from outside

Instead, you should be able to add commands from other Cypress commands, like cy.thenopen in new window:

cy.log('first').then(() => {
  // insert more commands
  // before the "LOG third" command
  cy.log('second')
})
cy.log('third')

Cypress inserts new commands correctly

Read the blog post Cypress Cannot Add Out-Of-Band Commandsopen in new window.