<commit_before>class WebTermController extends AppController

  KD.registerAppClass this,
    name         : "WebTerm"
    title        : "Terminal"
    navItem      :
      title      : "Develop"
    route        :
      slug       : "/:name?/Develop/Terminal"
      handler    : ({params:{name}, query})->
        KD.mixpanel "Click open Webterm", name
        KD.utils.wait 800, ->
          router = KD.getSingleton 'router'
          warn "webterm handling itself", name, query, arguments
          router.openSection "WebTerm", name, query
    multiple     : yes
    hiddenHandle : no
    menu         :
      width      : 250
      items      : [
        {title: "customViewAdvancedSettings"}
      ]
    behavior     : "application"
    preCondition :
      condition  : (options, cb)->

        {vmName} = options
        vmController = KD.getSingleton 'vmController'
        vmController.fetchDefaultVmName (defaultVmName)->
          vmName or= defaultVmName
          return cb no  unless vmName
          vmController.info vmName, KD.utils.getTimedOutCallback (err, vm, info)->
            cb  info?.state is 'RUNNING', {vmName, info}
          , ->
            cb yes
            KD.logToExternal "failed to fetch vminfo, couldn't open terminal"
            KD.mixpanel "Can't open Webterm", {vmName}
          , 2500
      failure     : (options, cb)->
        {vmName} = options
        KD.mixpanel "Can't open Webterm", {vmName}
        KD.getSingleton("vmController").askToTurnOn
          appName : 'WebTerm'
          vmName  : vmName
          state   : options.info.state
        , cb

  constructor:(options = {}, data)->
    params              = options.params or {}
    {joinUser, session} = params
    vmName              = params.vmName  or KD.getSingleton("vmController").defaultVmName
    options.view        = new WebTermAppView { vmName, joinUser, session }
    options.appInfo     =
      title             : "Terminal on #{vmName}"
      cssClass          : "webterm"

    super options, data

    KD.mixpanel "Opened webterm", {vmName}

  handleQuery: (query) ->
    @getView().ready =>
      @getView().handleQuery query

<commit_msg>mixpanel: track webterm bug fixes<commit_after>class WebTermController extends AppController

  KD.registerAppClass this,
    name         : "WebTerm"
    title        : "Terminal"
    navItem      :
      title      : "Develop"
    route        :
      slug       : "/:name?/Develop/Terminal"
      handler    : ({params:{name}, query})->
        KD.utils.wait 800, ->
          router = KD.getSingleton 'router'
          warn "webterm handling itself", name, query, arguments
          router.openSection "WebTerm", name, query
    multiple     : yes
    hiddenHandle : no
    menu         :
      width      : 250
      items      : [
        {title: "customViewAdvancedSettings"}
      ]
    behavior     : "application"
    preCondition :
      condition  : (options, cb)->
        KD.mixpanel "Click open Webterm", name

        {vmName} = options
        vmController = KD.getSingleton 'vmController'
        vmController.fetchDefaultVmName (defaultVmName)->
          vmName or= defaultVmName
          return cb no  unless vmName
          vmController.info vmName, KD.utils.getTimedOutCallback (err, vm, info)->
            cb  info?.state is 'RUNNING', {vmName, info}
          , ->
            cb no
            KD.logToExternal "failed to fetch vminfo, couldn't open terminal"
          , 2500
      failure     : (options, cb)->
        {vmName} = options
        KD.mixpanel "Can't open Webterm", {vmName}
        KD.getSingleton("vmController").askToTurnOn
          appName : 'WebTerm'
          vmName  : vmName
          state   : options.info.state
        , cb

  constructor:(options = {}, data)->
    params              = options.params or {}
    {joinUser, session} = params
    vmName              = params.vmName  or KD.getSingleton("vmController").defaultVmName
    options.view        = new WebTermAppView { vmName, joinUser, session }
    options.appInfo     =
      title             : "Terminal on #{vmName}"
      cssClass          : "webterm"

    super options, data

    KD.mixpanel "Opened webterm", {vmName}

  handleQuery: (query) ->
    @getView().ready =>
      @getView().handleQuery query


{'fraction_non_alphanumeric': 0.10130111524163568, 'fraction_numerical': 0.004646840148698885, 'mean_word_length': 1.8604651162790697, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 23, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6987553', 'n_tokens_mistral': 1272, 'n_tokens_neox': 1199, 'n_words': 307}