<commit_before>class SessionStackView extends KDView

  constructor: (options, data) ->

    super options, data

    @loader = new KDLoaderView
      size          : width : 16
      showLoader    : yes
      loaderOptions :
        color       : '#ffffff'

    {kite} = @getOptions()
    @sessions = new KDCustomHTMLView
      tagName : "ul"
    kite.webtermGetSessions().then (sessions) =>
      @loader.hide()
      sessions.forEach (session, index) => @addSession session, index
    .catch (err) =>
      @loader.hide()
      @addSubView new KDCustomHTMLView partial: "Sessions are not available"


  pistachio: ->
    {alias} = @getOptions()
    """
    #{alias}
    {{> @loader }}
    {{> @sessions }}
    """


  viewAppended: JView::viewAppended


  addSession: (session, index)->
    {vm, delegate} = @getOptions()
    @sessions.addSubView new SessionItemView {session, delegate, vm, index: index + 1}<commit_msg>Terminal: with new tab, session information in terminal start tab is updated<commit_after>class SessionStackView extends KDView

  constructor: (options, data) ->

    super options, data

    @loader = new KDLoaderView
      size          : width : 16
      showLoader    : yes
      loaderOptions :
        color       : '#ffffff'

    {delegate} = @getOptions()
    @sessions = new KDCustomHTMLView
      tagName : "ul"

    delegate.on "WebTermConnected", @bound "updateSessions"

    @updateSessions()

  updateSessions: ->
    @loader.show()
    {kite} = @getOptions()
    kite.webtermGetSessions().then (sessions) =>
      @sessions.destroySubViews()
      @show()
      @loader.hide()
      sessions.forEach (session, index) => @addSession session, index
    .catch (err) =>
      @hide()
      @loader.hide()
      @addSubView new KDCustomHTMLView partial: "Sessions are not available"


  pistachio: ->
    {alias} = @getOptions()
    """
    #{alias.replace 'koding.kd.io', 'kd.io'}
    {{> @loader }}
    {{> @sessions }}
    """


  viewAppended: JView::viewAppended


  addSession: (session, index)->
    {vm, delegate} = @getOptions()
    @sessions.addSubView new SessionItemView {session, delegate, vm, index: index + 1}
{'fraction_non_alphanumeric': 0.13061602593793423, 'fraction_numerical': 0.002779064381658175, 'mean_word_length': 2.7435008665511265, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 20, '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': '3855249', 'n_tokens_mistral': 693, 'n_tokens_neox': 666, 'n_words': 166}