<commit_before>var port = self.port;
var last = '';
var src_prefix = window.location.protocol + '//' + window.location.host;

// Send heartbeats
setInterval(function() {
  if ($('#chatMainPanel').length > 0) {
    port.emit('heartbeat', true);
  }
}, 3000);

// Listen to DOM mutations
new MutationObserver(function() {
  var msg = captureMessage();
  if (msg.id && msg.id !== last) {
    port.emit('bullet', msg);
    last = msg.id;
  }
}).observe(document.getElementById('chatMainPanel'), { 'childList': true, 'subtree': true });
<commit_msg>Store history messages in a queue<commit_after>var port = self.port;
var history = new Array(10);
var src_prefix = window.location.protocol + '//' + window.location.host;

// Send heartbeats
setInterval(function() {
  if ($('#chatMainPanel').length > 0) {
    port.emit('heartbeat', true);
  }
}, 3000);

// Listen to DOM mutations
new MutationObserver(function() {
  var i, msg = captureMessage();
  for (i = 0; i < history.length; i++) {
    if (history[i] == msg.id) {
      break;
    }
  }
  if (i == history.length) {
    port.emit('bullet', msg);
    history.shift();
    history.push(msg.id);
  }
}).observe(document.getElementById('chatMainPanel'), { 'childList': true, 'subtree': true });

{'fraction_non_alphanumeric': 0.1850362027353178, 'fraction_numerical': 0.010458567980691875, 'mean_word_length': 3.8030888030888033, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1820926', 'n_tokens_mistral': 421, 'n_tokens_neox': 406, 'n_words': 97}