<commit_before>import React from 'react';
import TabItem from '../tab-item/tab-item.jsx';
import styles from './popup.scss';

export default class Popup extends React.Component {
  constructor(props) {
    super(props);
    this.state = {
      windows: [],
      filter: ''
    };
  }
  componentDidMount() {
    chrome.windows.getAll({populate: true}, (windows) => {
      this.setState({windows: windows});
    });
  }
  filter(event) {
    this.setState({filter: event.target.value});
  }
  closeTab(tab, event) {
    // Don't close the window when closing tabs
    event.stopPropagation();

    // Close the tab and refresh the list of windows
    chrome.tabs.remove(tab.id);
    chrome.windows.getAll({populate: true}, (windows) => {
      this.setState({windows: windows});
    });
  }
  render() {
    const {filter, windows} = this.state;
    return (
      <div>
        <nav className={styles.navigation}>
          <div>
            <input className={styles.filter} type="text" placeholder="Search" onChange={this.filter.bind(this)}/>
          </div>
        </nav>
        <main className={styles.main}>
          {
            windows.map($window =>
              <section className={styles.window} key={$window.id}>
                <header className={styles.heading}>
                  <h2 className={styles.headingText}>{$window.tabs.length} tabs</h2>
                </header>
                <ul className={styles.tabList}>
                  {
                    $window.tabs
                      .filter(tab => filter.trim().length === 0 || tab.title.indexOf(filter) >= 0 || tab.url.indexOf(filter) >= 0)
                      .map(tab => <TabItem key={tab.id} tab={tab} onClose={this.closeTab.bind(this)}></TabItem>)
                  }
                </ul>
              </section>
            )
          }
        </main>
      </div>
    );
  }
}<commit_msg>Focus input field when extension is shown<commit_after>import React from 'react';
import TabItem from '../tab-item/tab-item.jsx';
import styles from './popup.scss';

export default class Popup extends React.Component {
  constructor(props) {
    super(props);
    this.state = {
      windows: [],
      filter: ''
    };
  }
  componentDidMount() {
    chrome.windows.getAll({populate: true}, (windows) => {
      this.setState({windows: windows});
    });
    this.refs.filter.focus();
  }
  filter(event) {
    this.setState({filter: event.target.value});
  }
  closeTab(tab, event) {
    // Don't close the window when closing tabs
    event.stopPropagation();

    // Close the tab and refresh the list of windows
    chrome.tabs.remove(tab.id);
    chrome.windows.getAll({populate: true}, (windows) => {
      this.setState({windows: windows});
    });
  }
  render() {
    const {filter, windows} = this.state;
    return (
      <div>
        <nav className={styles.navigation}>
          <div>
            <input className={styles.filter} ref="filter" type="text" placeholder="Search" onChange={this.filter.bind(this)}/>
          </div>
        </nav>
        <main className={styles.main}>
          {
            windows.map($window =>
              <section className={styles.window} key={$window.id}>
                <header className={styles.heading}>
                  <h2 className={styles.headingText}>{$window.tabs.length} tabs</h2>
                </header>
                <ul className={styles.tabList}>
                  {
                    $window.tabs
                      .filter(tab => filter.trim().length === 0 || tab.title.indexOf(filter) >= 0 || tab.url.indexOf(filter) >= 0)
                      .map(tab => <TabItem key={tab.id} tab={tab} onClose={this.closeTab.bind(this)}></TabItem>)
                  }
                </ul>
              </section>
            )
          }
        </main>
      </div>
    );
  }
}
{'fraction_non_alphanumeric': 0.15638823835545146, 'fraction_numerical': 0.0026021337496747333, 'mean_word_length': 1.9388379204892967, 'pattern_counts': {'":': 0, '<': 41, '<?xml version=': 0, '>': 55, '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': '3493104', 'n_tokens_mistral': 1124, 'n_tokens_neox': 1091, 'n_words': 218}