Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

funky terminal formatting #15

Open
jrmylee opened this issue Dec 7, 2022 · 2 comments
Open

funky terminal formatting #15

jrmylee opened this issue Dec 7, 2022 · 2 comments

Comments

@jrmylee
Copy link

jrmylee commented Dec 7, 2022

Running into some funky terminal outputs when using this repo. I essentially have the same setup as the source code, but when running commands like ls, I get ordering problems, and missing characters like below. Is this a known issue and are there potential work around?

Screen Shot 2022-12-07 at 2 04 06 AM

@jrmylee
Copy link
Author

jrmylee commented Dec 7, 2022

fixed it. Looks like some messages were coming back out of order. Just need to keep track of the last seq number to fix this.

` var lastSeqNum = -1;
var buffer = [];
const message = function (event) {
var agentMessage = ssm.decode(event.data);
ssm.sendACK(socket, agentMessage);

    if (agentMessage.payloadType === 17) {
        ssm.sendInitMessage(socket, termOptions);
        return;
    }

    if (agentMessage.payloadType === 1) {
        if (agentMessage.sequenceNumber - 1 !== lastSeqNum) {
            buffer.push(agentMessage);
        } else {
            lastSeqNum = agentMessage.sequenceNumber;
            writeToTerminal(textDecoder.decode(agentMessage.payload));
            if (buffer.length > 0) {
                let length = buffer.length;
                for (let i = length - 1; i >= 0; i--) {
                    if (buffer[i].sequenceNumber - 1 === lastSeqNum) {
                        lastSeqNum = buffer[i].sequenceNumber;
                        writeToTerminal(textDecoder.decode(buffer[i].payload));
                        buffer.splice(i, 1);
                    }
                }
            }
        }
    }
}

`

@rupertbg
Copy link

rupertbg commented May 2, 2023

also might be related to terminal size? #16

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants