<commit_before>ipc = require 'ipc'
# status

statusView = (model) ->
  div class: 'self span2', ->
    div 'You: ' + model.self.username
    span 'Status: ' + model.connection

# conversations

conversationsListItemView = (conversation) ->
  div class: 'conversation', conversation.name, onclick: (e) ->
    e.preventDefault()
    ipc.send 'conversation:select', conversation.id

conversationsListView = (conversations) ->
  margin =
    style:
      marginTop: '60px'
  div class: 'conversations', ->
    (conversations || []).forEach conversationsListItemView

# messages

messagesUtils =
  messageGetUsername: (model, event) =>
    chat_id = (event.sender_id || event.user_id).chat_id
    return model.identitiesById[chat_id].name
  messageGetText: (model, event) ->
    # Temporary doing this to get something to print
    # while narrowing the different cases
    text = []
    segments = event.chat_message.message_content.segment
    if segments
      segments.forEach (segment) ->
        if segment.type == "TEXT"
          text.push segment.text
        else
          text.push "[#{JSON.stringify(segment)}]"
    if event.chat_message.message_content.attachment
      text.push "[ATTACHMENT]"
    text = text.join " "
    return text


messagesView = (model) ->
  messages = model.messagesByConversationId[model.conversationCurrent] || []
  messages.forEach (message) ->
    div class: 'message', ->
      div class: 'user', messagesUtils.messageGetUsername(model, message)<commit_msg>workaround strange segment format<commit_after>ipc = require 'ipc'
# status

statusView = (model) ->
  div class: 'self span2', ->
    div 'You: ' + model.self.username
    span 'Status: ' + model.connection

# conversations

conversationsListItemView = (conversation) ->
  div class: 'conversation', conversation.name, onclick: (e) ->
    e.preventDefault()
    ipc.send 'conversation:select', conversation.id

conversationsListView = (conversations) ->
  margin =
    style:
      marginTop: '60px'
  div class: 'conversations', ->
    (conversations || []).forEach conversationsListItemView

# messages

messagesUtils =
  messageGetUsername: (model, event) =>
    chat_id = (event.sender_id || event.user_id).chat_id
    return model.identitiesById[chat_id].name
  messageGetText: (model, event) ->
    # Temporary doing this to get something to print
    # while narrowing the different cases
    text = []
    segments = event.chat_message.message_content.segment
    if segments
      segments.forEach (segment) ->
        if segment.type == "TEXT" or segment.type.k == "TEXT"
          text.push segment.text
        else
          text.push "[#{JSON.stringify(segment)}]"
    if event.chat_message.message_content.attachment
      text.push "[ATTACHMENT]"
    text = text.join " "
    return text


messagesView = (model) ->
  messages = model.messagesByConversationId[model.conversationCurrent] || []
  messages.forEach (message) ->
    div class: 'message', ->
      div class: 'user', messagesUtils.messageGetUsername(model, message)
{'fraction_non_alphanumeric': 0.12105263157894737, 'fraction_numerical': 0.001973684210526316, 'mean_word_length': 3.432944606413994, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 27, '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': '5604047', 'n_tokens_mistral': 899, 'n_tokens_neox': 893, 'n_words': 213}