terminal icon indicating copy to clipboard operation
terminal copied to clipboard

sendInput doesn't seem to work in multipleActions

Open cinnamon-msft opened this issue 2 years ago • 3 comments

Windows Terminal version

1.15.1863.0

Windows build number

10.0.22824.0

Other Software

No response

Steps to reproduce

I'm attempting to open a new tab and then send input in that new tab using the multipleActions command.

{
    "command": 
    {
        "action": "multipleActions",
        "actions": [
            {
                "action": "newTab"
            },
            {
                "action": "sendInput",
                "input": "\u001b[A"
            }
        ]
    },
    "name": "Send Input Test"
},

Expected Behavior

The new tab should have the input sent from sendInput, which in this case is as if I pressed the up arrow in my buffer.

Actual Behavior

sendInput seems to be completely ignored and my input line is empty.

cinnamon-msft avatar Jul 06 '22 21:07 cinnamon-msft

Huh. Good point. I suspect that we just fire-and-forget these guys after startup. Kinda interesting that the input doesn't go anywhere though - not into the previous tab or the new one. That's odd for real.

zadjii-msft avatar Jul 07 '22 11:07 zadjii-msft

So sendInput is only a problem if it's called after a new terminal control is created. If you just do two sendInput actions one after another they work fine.

The problem with running sendInput after newTab or splitPane is that the ConptyConnection hasn't been started yet - the ConptyConnection::WriteInput() method does nothing if the connection hasn't started.

https://github.com/microsoft/terminal/blob/bbc570d107b6b67b68454355e04724ecea9c9796/src/cascadia/TerminalConnection/ConptyConnection.cpp#L464-L475

I guess you could make WriteInput() store the strings that are sent to it if it's in the NotConnected state, and re-play them once it gets into the Connected state?

ianjoneill avatar Jul 09 '22 11:07 ianjoneill

So sendInput is only a problem if it's called after a new terminal control is created. If you just do two sendInput actions one after another they work fine.

It's not working for me:

{
    "name": "blah",
    "command": {
        "action": "multipleActions",
        "actions": [
            {
                "action": "sendInput",
                "input": "sensible-browser https://...\n"
            },
            {
                "action": "sendInput",
                "input": "sensible-browser https://...\n"
            }
        ]
    }
}

That just launches the first URL for me...

Running it in WSL/Ubuntu Profile.

mccarthyp-snet avatar Aug 04 '22 18:08 mccarthyp-snet

Any known workaround for this bug? Sending the input twice is not working for me

jsilveira avatar Mar 13 '24 16:03 jsilveira