botui/ui/suite/sources/index.html
Rodrigo Rodriguez (Pragmatismo) 664211d6db Add Repositories and Apps tabs to Sources for @mention context in chat
- Added Repositories tab with GitHub/GitLab/Bitbucket support
- Added Apps tab for previously created HTMX apps
- @mention autocomplete in chat for repos (@botserver) and apps (@myapp)
- Task context storage for autonomous task execution
- CSS for repo and app cards with connection status
- Mention suggestions dropdown with keyboard navigation
2025-12-12 23:45:56 -03:00

970 lines
26 KiB
HTML

{% extends "suite/base.html" %}
{% block title %}Sources - General Bots Suite{% endblock %}
{% block content %}
<div class="sources-container">
<!-- Header -->
<header class="sources-header">
<div class="header-left">
<h1>Sources</h1>
<p class="header-subtitle">Repositories, Apps, Prompts, Templates & MCP Servers</p>
</div>
<div class="header-right">
<div class="search-box">
<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
<circle cx="11" cy="11" r="8"></circle>
<line x1="21" y1="21" x2="16.65" y2="16.65"></line>
</svg>
<input type="text"
placeholder="Search sources..."
name="q"
hx-get="/api/sources/search"
hx-trigger="keyup changed delay:300ms"
hx-target="#content-area"
hx-swap="innerHTML">
</div>
</div>
</header>
<!-- Tab Navigation -->
<nav class="tab-nav" role="tablist">
<button class="tab-btn active"
role="tab"
aria-selected="true"
hx-get="/api/sources/repositories"
hx-target="#content-area"
hx-swap="innerHTML"
onclick="setActiveTab(this)">
<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
<path d="M9 19c-5 1.5-5-2.5-7-3m14 6v-3.87a3.37 3.37 0 0 0-.94-2.61c3.14-.35 6.44-1.54 6.44-7A5.44 5.44 0 0 0 20 4.77 5.07 5.07 0 0 0 19.91 1S18.73.65 16 2.48a13.38 13.38 0 0 0-7 0C6.27.65 5.09 1 5.09 1A5.07 5.07 0 0 0 5 4.77a5.44 5.44 0 0 0-1.5 3.78c0 5.42 3.3 6.61 6.44 7A3.37 3.37 0 0 0 9 18.13V22"></path>
</svg>
Repositories
</button>
<button class="tab-btn"
role="tab"
aria-selected="false"
hx-get="/api/sources/apps"
hx-target="#content-area"
hx-swap="innerHTML"
onclick="setActiveTab(this)">
<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
<rect x="3" y="3" width="7" height="7"></rect>
<rect x="14" y="3" width="7" height="7"></rect>
<rect x="14" y="14" width="7" height="7"></rect>
<rect x="3" y="14" width="7" height="7"></rect>
</svg>
Apps
</button>
<button class="tab-btn"
role="tab"
aria-selected="false"
hx-get="/api/sources/prompts"
hx-target="#content-area"
hx-swap="innerHTML"
onclick="setActiveTab(this)">
<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
<path d="M9.663 17h4.673M12 3v1m6.364 1.636l-.707.707M21 12h-1M4 12H3m3.343-5.657l-.707-.707m2.828 9.9a5 5 0 117.072 0l-.548.547A3.374 3.374 0 0014 18.469V19a2 2 0 11-4 0v-.531c0-.895-.356-1.754-.988-2.386l-.548-.547z"></path>
</svg>
Prompts
</button>
<button class="tab-btn"
role="tab"
aria-selected="false"
hx-get="/api/sources/templates"
hx-target="#content-area"
hx-swap="innerHTML"
onclick="setActiveTab(this)">
<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
<path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"></path>
<polyline points="14 2 14 8 20 8"></polyline>
<line x1="16" y1="13" x2="8" y2="13"></line>
<line x1="16" y1="17" x2="8" y2="17"></line>
<polyline points="10 9 9 9 8 9"></polyline>
</svg>
Templates
</button>
<button class="tab-btn"
role="tab"
aria-selected="false"
hx-get="/api/sources/news"
hx-target="#content-area"
hx-swap="innerHTML"
onclick="setActiveTab(this)">
<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
<path d="M19 20H5a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h10a2 2 0 0 1 2 2v1m2 13a2 2 0 0 1-2-2V7m2 13a2 2 0 0 0 2-2V9a2 2 0 0 0-2-2h-2"></path>
</svg>
News
</button>
<button class="tab-btn"
role="tab"
aria-selected="false"
hx-get="/api/sources/mcp-servers"
hx-target="#content-area"
hx-swap="innerHTML"
onclick="setActiveTab(this)">
<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
<rect x="2" y="2" width="20" height="8" rx="2" ry="2"></rect>
<rect x="2" y="14" width="20" height="8" rx="2" ry="2"></rect>
<line x1="6" y1="6" x2="6.01" y2="6"></line>
<line x1="6" y1="18" x2="6.01" y2="18"></line>
</svg>
MCP Servers
</button>
<button class="tab-btn"
role="tab"
aria-selected="false"
hx-get="/api/sources/llm-tools"
hx-target="#content-area"
hx-swap="innerHTML"
onclick="setActiveTab(this)">
<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
<path d="M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.77-3.77a6 6 0 0 1-7.94 7.94l-6.91 6.91a2.12 2.12 0 0 1-3-3l6.91-6.91a6 6 0 0 1 7.94-7.94l-3.76 3.76z"></path>
</svg>
LLM Tools
</button>
<button class="tab-btn"
role="tab"
aria-selected="false"
hx-get="/api/sources/models"
hx-target="#content-area"
hx-swap="innerHTML"
onclick="setActiveTab(this)">
<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
<rect x="4" y="4" width="16" height="16" rx="2" ry="2"></rect>
<rect x="9" y="9" width="6" height="6"></rect>
<line x1="9" y1="1" x2="9" y2="4"></line>
<line x1="15" y1="1" x2="15" y2="4"></line>
<line x1="9" y1="20" x2="9" y2="23"></line>
<line x1="15" y1="20" x2="15" y2="23"></line>
<line x1="20" y1="9" x2="23" y2="9"></line>
<line x1="20" y1="14" x2="23" y2="14"></line>
<line x1="1" y1="9" x2="4" y2="9"></line>
<line x1="1" y1="14" x2="4" y2="14"></line>
</svg>
Models
</button>
</nav>
<!-- Main Content Area -->
<main class="content-area" id="content-area" hx-get="/api/sources/repositories" hx-trigger="load" hx-swap="innerHTML">
<!-- Content loaded via HTMX -->
<div class="loading-spinner">
<div class="spinner"></div>
<p>Loading sources...</p>
</div>
</main>
</div>
<!-- Prompts Panel Template (loaded via HTMX) -->
<template id="prompts-template">
<div class="panel-layout">
<!-- Categories Sidebar -->
<aside class="categories-sidebar">
<h3>Categories</h3>
<div class="category-list">
<button class="category-item active"
hx-get="/api/sources/prompts?category=all"
hx-target="#prompts-grid"
hx-swap="innerHTML">
<span class="category-icon" style="background: var(--primary);">
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
<rect x="3" y="3" width="7" height="7"></rect>
<rect x="14" y="3" width="7" height="7"></rect>
<rect x="14" y="14" width="7" height="7"></rect>
<rect x="3" y="14" width="7" height="7"></rect>
</svg>
</span>
<span class="category-name">All Prompts</span>
<span class="category-count">42</span>
</button>
<!-- Categories loaded dynamically -->
</div>
</aside>
<!-- Prompts Grid -->
<section class="prompts-section">
<div class="section-header">
<h2>Featured Prompts</h2>
<div class="view-controls">
<button class="view-btn active" title="Grid view">
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
<rect x="3" y="3" width="7" height="7"></rect>
<rect x="14" y="3" width="7" height="7"></rect>
<rect x="14" y="14" width="7" height="7"></rect>
<rect x="3" y="14" width="7" height="7"></rect>
</svg>
</button>
<button class="view-btn" title="List view">
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
<line x1="8" y1="6" x2="21" y2="6"></line>
<line x1="8" y1="12" x2="21" y2="12"></line>
<line x1="8" y1="18" x2="21" y2="18"></line>
<line x1="3" y1="6" x2="3.01" y2="6"></line>
<line x1="3" y1="12" x2="3.01" y2="12"></line>
<line x1="3" y1="18" x2="3.01" y2="18"></line>
</svg>
</button>
</div>
</div>
<div class="prompts-grid" id="prompts-grid">
<!-- Prompts loaded dynamically -->
</div>
</section>
</div>
</template>
<style>
.sources-container {
display: flex;
flex-direction: column;
height: calc(100vh - 56px);
overflow: hidden;
background: var(--bg);
}
/* Header */
.sources-header {
display: flex;
align-items: center;
justify-content: space-between;
padding: 20px 24px;
background: var(--surface);
border-bottom: 1px solid var(--border);
}
.sources-header h1 {
font-size: 24px;
font-weight: 700;
margin: 0;
}
.header-subtitle {
font-size: 14px;
color: var(--text-secondary);
margin: 4px 0 0 0;
}
.search-box {
display: flex;
align-items: center;
gap: 10px;
background: var(--surface-hover);
border: 1px solid var(--border);
border-radius: 8px;
padding: 10px 16px;
min-width: 300px;
}
.search-box svg {
color: var(--text-secondary);
flex-shrink: 0;
}
.search-box input {
flex: 1;
background: transparent;
border: none;
outline: none;
color: var(--text);
font-size: 14px;
}
.search-box input::placeholder {
color: var(--text-secondary);
}
/* Tab Navigation */
.tab-nav {
display: flex;
gap: 4px;
padding: 12px 24px;
background: var(--surface);
border-bottom: 1px solid var(--border);
overflow-x: auto;
}
.tab-btn {
display: flex;
align-items: center;
gap: 8px;
padding: 10px 16px;
background: transparent;
border: none;
border-radius: 8px;
color: var(--text-secondary);
font-size: 14px;
font-weight: 500;
cursor: pointer;
transition: all 0.15s;
white-space: nowrap;
}
.tab-btn:hover {
background: var(--surface-hover);
color: var(--text);
}
.tab-btn.active {
background: var(--primary);
color: white;
}
.tab-btn svg {
flex-shrink: 0;
}
/* Content Area */
.content-area {
flex: 1;
overflow-y: auto;
padding: 24px;
}
/* Panel Layout */
.panel-layout {
display: grid;
grid-template-columns: 260px 1fr;
gap: 24px;
height: 100%;
}
/* Categories Sidebar */
.categories-sidebar {
background: var(--surface);
border-radius: 12px;
padding: 16px;
height: fit-content;
position: sticky;
top: 0;
}
.categories-sidebar h3 {
font-size: 12px;
font-weight: 600;
text-transform: uppercase;
color: var(--text-secondary);
margin: 0 0 12px 0;
padding: 0 8px;
}
.category-list {
display: flex;
flex-direction: column;
gap: 4px;
}
.category-item {
display: flex;
align-items: center;
gap: 12px;
width: 100%;
padding: 10px 12px;
background: transparent;
border: none;
border-radius: 8px;
color: var(--text);
font-size: 14px;
text-align: left;
cursor: pointer;
transition: all 0.15s;
}
.category-item:hover {
background: var(--surface-hover);
}
.category-item.active {
background: var(--primary-light);
}
.category-icon {
width: 32px;
height: 32px;
border-radius: 8px;
display: flex;
align-items: center;
justify-content: center;
flex-shrink: 0;
}
.category-icon svg {
color: white;
}
.category-name {
flex: 1;
}
.category-count {
font-size: 12px;
color: var(--text-secondary);
background: var(--surface-hover);
padding: 2px 8px;
border-radius: 10px;
}
/* Section Header */
.section-header {
display: flex;
align-items: center;
justify-content: space-between;
margin-bottom: 20px;
}
.section-header h2 {
font-size: 18px;
font-weight: 600;
margin: 0;
}
.view-controls {
display: flex;
gap: 4px;
background: var(--surface);
border-radius: 8px;
padding: 4px;
}
.view-btn {
width: 32px;
height: 32px;
border: none;
border-radius: 6px;
background: transparent;
color: var(--text-secondary);
cursor: pointer;
display: flex;
align-items: center;
justify-content: center;
transition: all 0.15s;
}
.view-btn:hover {
color: var(--text);
}
.view-btn.active {
background: var(--surface-hover);
color: var(--text);
}
/* Prompts Grid */
.prompts-grid {
display: grid;
grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
gap: 16px;
}
/* Prompt Card */
.prompt-card {
background: var(--surface);
border: 1px solid var(--border);
border-radius: 12px;
padding: 20px;
cursor: pointer;
transition: all 0.2s;
}
.prompt-card:hover {
border-color: var(--primary);
transform: translateY(-2px);
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}
.prompt-card-header {
display: flex;
align-items: flex-start;
gap: 12px;
margin-bottom: 12px;
}
.prompt-icon {
width: 40px;
height: 40px;
border-radius: 10px;
display: flex;
align-items: center;
justify-content: center;
flex-shrink: 0;
}
.prompt-icon svg {
color: white;
}
.prompt-info {
flex: 1;
min-width: 0;
}
.prompt-name {
font-size: 15px;
font-weight: 600;
margin: 0 0 4px 0;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
.prompt-category {
font-size: 12px;
color: var(--text-secondary);
}
.prompt-description {
font-size: 13px;
color: var(--text-secondary);
line-height: 1.5;
margin-bottom: 16px;
display: -webkit-box;
-webkit-line-clamp: 2;
-webkit-box-orient: vertical;
overflow: hidden;
}
.prompt-footer {
display: flex;
align-items: center;
justify-content: space-between;
}
.prompt-rating {
display: flex;
align-items: center;
gap: 4px;
font-size: 13px;
color: var(--text-secondary);
}
.prompt-rating svg {
color: #eab308;
fill: #eab308;
}
.prompt-actions {
display: flex;
gap: 8px;
}
.prompt-action-btn {
width: 32px;
height: 32px;
border: none;
border-radius: 6px;
background: var(--surface-hover);
color: var(--text-secondary);
cursor: pointer;
display: flex;
align-items: center;
justify-content: center;
transition: all 0.15s;
}
.prompt-action-btn:hover {
background: var(--primary);
color: white;
}
/* MCP Server Card */
.server-card {
background: var(--surface);
border: 1px solid var(--border);
border-radius: 12px;
padding: 20px;
transition: all 0.2s;
}
.server-card:hover {
border-color: var(--primary);
}
.server-header {
display: flex;
align-items: center;
gap: 12px;
margin-bottom: 12px;
}
.server-icon {
width: 44px;
height: 44px;
border-radius: 10px;
background: var(--surface-hover);
display: flex;
align-items: center;
justify-content: center;
}
.server-icon svg {
color: var(--primary);
}
.server-info {
flex: 1;
}
.server-name {
font-size: 15px;
font-weight: 600;
margin: 0 0 4px 0;
}
.server-type {
display: inline-flex;
align-items: center;
gap: 4px;
padding: 2px 8px;
background: var(--primary-light);
color: var(--primary);
font-size: 11px;
font-weight: 500;
border-radius: 4px;
}
.server-description {
font-size: 13px;
color: var(--text-secondary);
line-height: 1.5;
margin-bottom: 12px;
}
.server-meta {
display: flex;
align-items: center;
gap: 16px;
font-size: 12px;
color: var(--text-secondary);
}
.server-meta-item {
display: flex;
align-items: center;
gap: 4px;
}
/* Model Card */
.model-card {
background: var(--surface);
border: 1px solid var(--border);
border-radius: 12px;
padding: 20px;
transition: all 0.2s;
}
.model-card:hover {
border-color: var(--primary);
}
.model-header {
display: flex;
align-items: center;
justify-content: space-between;
margin-bottom: 12px;
}
.model-name {
font-size: 16px;
font-weight: 600;
}
.model-status {
padding: 4px 10px;
border-radius: 12px;
font-size: 11px;
font-weight: 500;
}
.model-status.active {
background: rgba(34, 197, 94, 0.1);
color: #22c55e;
}
.model-status.coming-soon {
background: rgba(234, 179, 8, 0.1);
color: #eab308;
}
.model-provider {
font-size: 12px;
color: var(--text-secondary);
margin-bottom: 8px;
}
.model-description {
font-size: 13px;
color: var(--text-secondary);
line-height: 1.5;
margin-bottom: 16px;
}
.model-tags {
display: flex;
flex-wrap: wrap;
gap: 6px;
}
.model-tag {
padding: 4px 10px;
background: var(--surface-hover);
border-radius: 6px;
font-size: 11px;
color: var(--text-secondary);
}
/* Loading Spinner */
.loading-spinner {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
padding: 60px;
color: var(--text-secondary);
}
.spinner {
width: 40px;
height: 40px;
border: 3px solid var(--border);
border-top-color: var(--primary);
border-radius: 50%;
animation: spin 1s linear infinite;
margin-bottom: 16px;
}
@keyframes spin {
to { transform: rotate(360deg); }
}
/* Empty State */
.empty-state {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
padding: 60px;
text-align: center;
}
.empty-state svg {
width: 64px;
height: 64px;
color: var(--text-secondary);
margin-bottom: 16px;
opacity: 0.5;
}
.empty-state h3 {
font-size: 18px;
font-weight: 600;
margin: 0 0 8px 0;
}
.empty-state p {
color: var(--text-secondary);
margin: 0;
}
/* Template Card */
.template-card {
background: var(--surface);
border: 1px solid var(--border);
border-radius: 12px;
overflow: hidden;
transition: all 0.2s;
}
.template-card:hover {
border-color: var(--primary);
transform: translateY(-2px);
}
.template-preview {
height: 120px;
background: var(--surface-hover);
display: flex;
align-items: center;
justify-content: center;
}
.template-preview svg {
width: 48px;
height: 48px;
color: var(--text-secondary);
opacity: 0.5;
}
.template-content {
padding: 16px;
}
.template-name {
font-size: 14px;
font-weight: 600;
margin: 0 0 4px 0;
}
.template-meta {
font-size: 12px;
color: var(--text-secondary);
}
/* News Card */
.news-card {
background: var(--surface);
border: 1px solid var(--border);
border-radius: 12px;
padding: 20px;
display: flex;
gap: 16px;
transition: all 0.2s;
}
.news-card:hover {
border-color: var(--primary);
}
.news-image {
width: 100px;
height: 80px;
border-radius: 8px;
background: var(--surface-hover);
flex-shrink: 0;
}
.news-content {
flex: 1;
}
.news-title {
font-size: 15px;
font-weight: 600;
margin: 0 0 8px 0;
line-height: 1.4;
}
.news-excerpt {
font-size: 13px;
color: var(--text-secondary);
line-height: 1.5;
margin-bottom: 8px;
}
.news-meta {
display: flex;
align-items: center;
gap: 12px;
font-size: 12px;
color: var(--text-secondary);
}
/* Responsive */
@media (max-width: 1024px) {
.panel-layout {
grid-template-columns: 1fr;
}
.categories-sidebar {
display: none;
}
}
@media (max-width: 768px) {
.sources-header {
flex-direction: column;
gap: 16px;
align-items: stretch;
}
.search-box {
min-width: auto;
}
.tab-nav {
padding: 12px 16px;
}
.tab-btn span:not(.tab-icon) {
display: none;
}
.content-area {
padding: 16px;
}
.prompts-grid {
grid-template-columns: 1fr;
}
}
</style>
<script>
// Tab switching
function setActiveTab(btn) {
document.querySelectorAll('.tab-btn').forEach(t => {
t.classList.remove('active');
t.setAttribute('aria-selected', 'false');
});
btn.classList.add('active');
btn.setAttribute('aria-selected', 'true');
}
// Category switching</script>
document.addEventListener('click', function(e) {
const categoryItem = e.target.closest('.category-item');
if (categoryItem) {
document.querySelectorAll('.category-item').forEach(c => c.classList.remove('active'));
categoryItem.classList.add('active');
}
});
// View toggle
document.addEventListener('click', function(e) {
const viewBtn = e.target.closest('.view-btn');
if (viewBtn) {
const controls = viewBtn.closest('.view-controls');
controls.querySelectorAll('.view-btn').forEach(b => b.classList.remove('active'));
viewBtn.classList.add('active');
const grid = document.querySelector('.prompts-grid, .templates-grid, .servers-grid, .models-grid');
if (grid) {
if (viewBtn.title === 'List view') {
grid.classList.add('list-view');
} else {
grid.classList.remove('list-view');
}
}
}
});
// Keyboard shortcuts
document.addEventListener('keydown', function(e) {
// Ctrl+K to focus search
if ((e.ctrlKey || e.metaKey) && e.key === 'k') {
e.preventDefault();
document.querySelector('.search-box input').focus();
}
// Tab navigation with number keys
if (!e.ctrlKey && !e.metaKey && !e.altKey) {
const tabs = document.querySelectorAll('.tab-btn');
const num = parseInt(e.key);
if (num >= 1 && num <= tabs.length) {
tabs[num - 1].click();
}
}
});
// HTMX events
document.body.addEventListener('htmx:beforeRequest', function(e) {
if (e.detail.target.id === 'content-area') {
e.detail.target.innerHTML = `
<div class="loading-spinner">
<div class="spinner"></div>
<p>Loading...</p>
</div>
`;
}
});
</script>
{% endblock %}