Newer
Older
navi-1 / webclient / src / components / chat / BackgroundTasksChip.vue
<template>
  <Transition name="fade">
    <div v-if="taskList.length || chat.queuedMessages.count" class="task-chips">
      <div
        v-if="taskList.length"
        class="task-chip"
        :title="titles"
      >
        <i class="ph ph-arrows-out"></i>
        <span>
          {{ taskList.length }} in background — {{ toolNames }}
        </span>
      </div>
      <div v-if="chat.queuedMessages.count" class="task-chip queued">
        <i class="ph ph-inbox"></i>
        <span>
          {{ chat.queuedMessages.count }} message{{ chat.queuedMessages.count === 1 ? '' : 's' }} queued
        </span>
      </div>
    </div>
  </Transition>
</template>

<script setup>
import { computed } from 'vue'
import { useChatStore } from '@/stores/chat.js'

const chat = useChatStore()

const taskList = computed(() => Object.values(chat.backgroundTasks))
const toolNames = computed(() => {
  const names = [...new Set(taskList.value.map(t => t.tool))]
  return names.join(', ')
})
const titles = computed(() =>
  taskList.value.map(t => `${t.tool} — ${t.status}`).join('\n')
)
</script>

<style scoped>
.task-chips {
  display: flex;
  gap: 8px;
  padding: 4px 16px 0;
  flex-wrap: wrap;
}

.task-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  border-radius: 999px;
  border: 1px solid var(--border-color-muted, rgba(128, 128, 128, 0.25));
  background: var(--surface-panel-muted, rgba(128, 128, 128, 0.08));
  font-size: 12px;
  color: var(--color-text-medium, #999);

  i { color: var(--color-warning, #e0af68); }
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;

  &.queued i { color: var(--color-primary, #7aa2f7); }
}

.fade-enter-active, .fade-leave-active { transition: opacity 0.2s; }
.fade-enter-from, .fade-leave-to { opacity: 0; }
</style>