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

'typing' dots being displaced inwards #81

Closed
cosmicespresso opened this issue May 13, 2020 · 11 comments
Closed

'typing' dots being displaced inwards #81

cosmicespresso opened this issue May 13, 2020 · 11 comments

Comments

@cosmicespresso
Copy link
Owner

cosmicespresso commented May 13, 2020

@agnescameron any clues as to when that started?

image

@agnescameron
Copy link
Collaborator

ah hm i notice this from time to time: I remember this issue existing already but perhaps we thought it went away. I think maybe first noticed this a few weeks ago?

@cosmicespresso
Copy link
Owner Author

ahh this is very elusive - it only seems to happen when the bot double-texts (never when it's the first response to a user message). When did you add that functionality?

@agnescameron
Copy link
Collaborator

agnescameron commented May 14, 2020

it's been there for a couple of months, but we're using it more now -- when there's punctuation in a bot's response, it splits the message in two and adds it to bot queue. It doesn't use anything special though: everything just goes through the bot queue.

recently I added in a 'line break' character that allows the bot to text over multiple lines without having punctuation to split them, which is probably why we're seeing this more.

@cosmicespresso
Copy link
Owner Author

ohhh ok great thats helpful - yes the \n can totally be the culprit here

@agnescameron
Copy link
Collaborator

ahhh it's not a \n though -- it's just appending 2 messages to the queue separately

@agnescameron
Copy link
Collaborator

hmmmmmmm.... what it does is splits the sentence into an array, and concatenates that to the bot queue... which is maybe not quite the same

  processResponse = (text) => {
    //check if message pure punctuation, let it pass if so
    if (text.match(/[a-zA-Z]/g)){
      //breaks sentences into different messages
      text = text
        .match(/[^.!?%]+[.!?]*/g)
        .map(str => str.trim());
    }
    else if (!text) {
      text = handleError();
    }

    this.botQueue = this.botQueue.concat(text);

    // random pause before the bot starts typing, as if thinking
    setTimeout(() => this.setState({isBotTyping: true}, () => 
      this.processBotQueue()), this.getRandomInt(1100, 3500));
  }

@agnescameron
Copy link
Collaborator

so the regex is looking for punctuation, or the 'newline' character %: if there's punctuation it splits and keeps the punctuation, if there's a % it splits and gets rid of the %.

@cosmicespresso
Copy link
Owner Author

ok I will play a bit with that and report back

@agnescameron
Copy link
Collaborator

yeah. there's also one tiny hack that I did to make the bot dots appear at the start of rounds (they only get appended once there are messages on the screen) that just appends a blank message, before the bot starts typing. but the dots aren't distorted underneath that I don't think (+ I feel like we'd already seen the dots getting displaced before that...)

that's done here:

      if(this.state.messages.length === 0) {
        //if start of interaction, adds a blank 
        //message to kickstart the 'bot dots'
        this.appendMessage('');
        this.processResponse(response); 
      }

@cosmicespresso
Copy link
Owner Author

^ very likely this is the reason, but I'm also investigating whether the trim() function you are using has the results we want (whether it creates a new variable or operates on the existing one)

@cosmicespresso
Copy link
Owner Author

image

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