Compare commits
22 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| afcbf941a9 | |||
| 49b9778872 | |||
| 6d0dab4889 | |||
| dd509a75be | |||
| e0fc305832 | |||
| c120155170 | |||
| 0241130c2f | |||
| 889af65ae7 | |||
| bdd75c9224 | |||
| f707dceb98 | |||
| 96a44233c0 | |||
| 191cb5cbd2 | |||
| 12e629432c | |||
| 47f0f1d786 | |||
| bf60b8b064 | |||
| b8498f47bb | |||
| f037aa2eeb | |||
| e6520fc26d | |||
| c9d8852609 | |||
| 11e9a257a1 | |||
| ead202ad8b | |||
| effc86e15b |
@@ -0,0 +1,208 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Nexus.Api.Models;
|
||||
using Nexus.Api.Services;
|
||||
|
||||
namespace Nexus.Api.Controllers;
|
||||
|
||||
[ApiController]
|
||||
[Route("api/dashboard")]
|
||||
public class DashboardController(OpenClawGatewayClient gateway, ILogger<DashboardController> logger)
|
||||
: ControllerBase
|
||||
{
|
||||
/// <summary>
|
||||
/// Gateway health + session_status + subagents count.
|
||||
/// Returns HTTP 200 even when gateway is down (gatewayOk: false).
|
||||
/// </summary>
|
||||
[HttpGet("status")]
|
||||
public async Task<DashboardStatus> GetStatus()
|
||||
{
|
||||
try
|
||||
{
|
||||
return await gateway.GetStatusAsync();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
logger.LogWarning(ex, "Dashboard status check failed");
|
||||
return new DashboardStatus(false, "Offline", 0, 0);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns all agents with their current status.
|
||||
/// Combines sessions_list + sub_agents_list.
|
||||
/// </summary>
|
||||
[HttpGet("agents")]
|
||||
public async Task<List<DashboardAgentInfo>> GetAgents()
|
||||
{
|
||||
try
|
||||
{
|
||||
return await gateway.GetAgentsAsync();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
logger.LogWarning(ex, "Dashboard agents fetch failed");
|
||||
return new List<DashboardAgentInfo>();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the latest assistant messages (operations/feed) from the Iris session.
|
||||
/// Filtered to role == "assistant" — those are the work feed entries.
|
||||
/// </summary>
|
||||
[HttpGet("operations")]
|
||||
public async Task<List<FeedEntry>> GetOperations([FromQuery] int limit = 20)
|
||||
{
|
||||
try
|
||||
{
|
||||
var messages = await gateway.GetSessionHistoryAsync("iris", Math.Clamp(limit, 1, 100));
|
||||
var feed = new List<FeedEntry>();
|
||||
|
||||
foreach (var msg in messages)
|
||||
{
|
||||
if (!string.Equals(msg.Role, "assistant", StringComparison.OrdinalIgnoreCase))
|
||||
continue;
|
||||
|
||||
if (string.IsNullOrWhiteSpace(msg.Content))
|
||||
continue;
|
||||
|
||||
// Parse timestamp for display-friendly "time ago"
|
||||
var ts = ParseTimestamp(msg.Timestamp);
|
||||
var timeAgo = FormatTimeAgo(ts);
|
||||
|
||||
// Extract a short agent indicator and action from content
|
||||
var (agent, action) = ExtractAgentAction(msg.Content);
|
||||
|
||||
feed.Add(new FeedEntry(agent, action, msg.Timestamp, timeAgo));
|
||||
}
|
||||
|
||||
return feed;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
logger.LogWarning(ex, "Dashboard operations fetch failed");
|
||||
return new List<FeedEntry>();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Send a chat message to the Iris session.
|
||||
/// </summary>
|
||||
[HttpPost("chat/send")]
|
||||
public async Task<ChatResponse> SendChat([FromBody] ChatRequest request)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(request.Message))
|
||||
return new ChatResponse(false, null, "Message is required");
|
||||
|
||||
try
|
||||
{
|
||||
var sessionKey = string.IsNullOrWhiteSpace(request.SessionKey)
|
||||
? "iris"
|
||||
: request.SessionKey.Trim();
|
||||
|
||||
return await gateway.SendChatMessageAsync(sessionKey, request.Message.Trim());
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
logger.LogWarning(ex, "Dashboard chat send failed");
|
||||
return new ChatResponse(false, null, "Gateway nicht erreichbar");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns chat messages (user + assistant only, not tool messages).
|
||||
/// </summary>
|
||||
[HttpGet("chat/messages")]
|
||||
public async Task<List<MessageEntry>> GetMessages(
|
||||
[FromQuery] string? sessionKey,
|
||||
[FromQuery] int limit = 50,
|
||||
[FromQuery] int offset = 0)
|
||||
{
|
||||
try
|
||||
{
|
||||
var key = string.IsNullOrWhiteSpace(sessionKey) ? "iris" : sessionKey.Trim();
|
||||
var messages = await gateway.GetSessionHistoryAsync(key, Math.Clamp(limit, 1, 200), Math.Max(0, offset));
|
||||
|
||||
// Filter: only user and assistant messages (exclude tool/system)
|
||||
return messages
|
||||
.Where(m => string.Equals(m.Role, "user", StringComparison.OrdinalIgnoreCase)
|
||||
|| string.Equals(m.Role, "assistant", StringComparison.OrdinalIgnoreCase))
|
||||
.ToList();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
logger.LogWarning(ex, "Dashboard messages fetch failed");
|
||||
return new List<MessageEntry>();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the cron queue / pending tasks.
|
||||
/// </summary>
|
||||
[HttpGet("queue")]
|
||||
public async Task<List<QueueItem>> GetQueue()
|
||||
{
|
||||
try
|
||||
{
|
||||
return await gateway.GetQueueAsync();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
logger.LogWarning(ex, "Dashboard queue fetch failed");
|
||||
return new List<QueueItem>();
|
||||
}
|
||||
}
|
||||
|
||||
// ========== Helpers ==========
|
||||
|
||||
private static DateTimeOffset ParseTimestamp(string timestamp)
|
||||
{
|
||||
if (DateTimeOffset.TryParse(timestamp, null, System.Globalization.DateTimeStyles.None, out var dt))
|
||||
return dt;
|
||||
return DateTimeOffset.UtcNow;
|
||||
}
|
||||
|
||||
private static string FormatTimeAgo(DateTimeOffset ts)
|
||||
{
|
||||
var diff = DateTimeOffset.UtcNow - ts;
|
||||
if (diff.TotalMinutes < 1) return "just now";
|
||||
if (diff.TotalMinutes < 60) return $"{(int)diff.TotalMinutes}m ago";
|
||||
if (diff.TotalHours < 24) return $"{(int)diff.TotalHours}h ago";
|
||||
if (diff.TotalDays < 7) return $"{(int)diff.TotalDays}d ago";
|
||||
return ts.ToString("MMM dd");
|
||||
}
|
||||
|
||||
private static (string Agent, string Action) ExtractAgentAction(string content)
|
||||
{
|
||||
// Take first line or first ~80 chars as the action summary
|
||||
var firstLine = content.Split('\n', 2)[0].Trim();
|
||||
var summary = firstLine.Length > 80 ? firstLine[..80] + "…" : firstLine;
|
||||
|
||||
// Try to identify which agent this came from
|
||||
var agent = "Iris";
|
||||
foreach (var marker in new[] { "**Agent:**", "**Agent:** ", "*Agent:* ", "Agent:" })
|
||||
{
|
||||
var idx = content.IndexOf(marker, StringComparison.OrdinalIgnoreCase);
|
||||
if (idx >= 0)
|
||||
{
|
||||
var after = content[(idx + marker.Length)..].TrimStart();
|
||||
var end = after.IndexOfAny(['\n', '\r', ',', '.']);
|
||||
var found = end > 0 ? after[..end].Trim() : after.Split('\n', 2)[0].Trim();
|
||||
if (!string.IsNullOrWhiteSpace(found) && found.Length < 30)
|
||||
{
|
||||
agent = found;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Try to find agent name at the start in brackets like [Agent: Iris]
|
||||
if (agent == "Iris")
|
||||
{
|
||||
var bracketMatch = System.Text.RegularExpressions.Regex.Match(content, @"\[Agent:\s*([^\]]+)\]");
|
||||
if (bracketMatch.Success)
|
||||
agent = bracketMatch.Groups[1].Value.Trim();
|
||||
}
|
||||
|
||||
return (agent, summary);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
namespace Nexus.Api.Models;
|
||||
|
||||
public sealed record DashboardAgentInfo(
|
||||
string Id,
|
||||
string Name,
|
||||
string Role,
|
||||
string Model,
|
||||
bool IsActive,
|
||||
string? CurrentTask
|
||||
);
|
||||
|
||||
public sealed record MessageEntry(
|
||||
string Role,
|
||||
string Content,
|
||||
string Timestamp
|
||||
);
|
||||
|
||||
public sealed record ChatRequest(
|
||||
string Message,
|
||||
string? SessionKey
|
||||
);
|
||||
|
||||
public sealed record ChatResponse(
|
||||
bool Ok,
|
||||
string? Reply,
|
||||
string? Error
|
||||
);
|
||||
|
||||
public sealed record FeedEntry(
|
||||
string Agent,
|
||||
string Action,
|
||||
string Timestamp,
|
||||
string Time
|
||||
);
|
||||
|
||||
public sealed record DashboardStatus(
|
||||
bool GatewayOk,
|
||||
string IrisStatus,
|
||||
int ActiveAgents,
|
||||
int PendingTasks
|
||||
);
|
||||
|
||||
public sealed record QueueItem(
|
||||
string Id,
|
||||
string Name,
|
||||
string Status
|
||||
);
|
||||
@@ -112,6 +112,13 @@ builder.Services.AddHttpClient("gateway", client =>
|
||||
client.Timeout = TimeSpan.FromSeconds(5);
|
||||
});
|
||||
|
||||
builder.Services.AddHttpClient<OpenClawGatewayClient>(client =>
|
||||
{
|
||||
client.BaseAddress = new(builder.Configuration["Integrations:OpenClaw:BaseUrl"]
|
||||
?? "http://127.0.0.1:18789");
|
||||
client.Timeout = TimeSpan.FromSeconds(5);
|
||||
});
|
||||
|
||||
// --- Application Services ---
|
||||
builder.Services.AddTransient<ModelRoutingService>();
|
||||
builder.Services.AddScoped<IAuthService, AuthService>();
|
||||
|
||||
@@ -0,0 +1,293 @@
|
||||
using System.Net.Http.Headers;
|
||||
using System.Net.Http.Json;
|
||||
using System.Text.Json;
|
||||
using System.Text.Json.Nodes;
|
||||
using Nexus.Api.Models;
|
||||
|
||||
namespace Nexus.Api.Services;
|
||||
|
||||
public sealed class OpenClawGatewayClient(HttpClient httpClient, IConfiguration configuration)
|
||||
{
|
||||
private static readonly JsonSerializerOptions JsonOptions = new()
|
||||
{
|
||||
PropertyNameCaseInsensitive = true,
|
||||
PropertyNamingPolicy = JsonNamingPolicy.CamelCase
|
||||
};
|
||||
|
||||
private string? GetPassword()
|
||||
{
|
||||
var password = configuration["Integrations:OpenClaw:Password"];
|
||||
if (string.IsNullOrWhiteSpace(password))
|
||||
password = configuration["Integrations:OpenClaw:Token"];
|
||||
return string.IsNullOrWhiteSpace(password) ? null : password;
|
||||
}
|
||||
|
||||
private void ApplyAuth(HttpRequestMessage request)
|
||||
{
|
||||
var password = GetPassword();
|
||||
if (password is not null)
|
||||
request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", password);
|
||||
}
|
||||
|
||||
public async Task<JsonNode?> InvokeToolAsync(string tool, object? args = null)
|
||||
{
|
||||
try
|
||||
{
|
||||
using var request = new HttpRequestMessage(HttpMethod.Post, "/tools/invoke");
|
||||
ApplyAuth(request);
|
||||
|
||||
var body = new Dictionary<string, object?> { ["tool"] = tool };
|
||||
if (args is not null)
|
||||
body["args"] = args;
|
||||
|
||||
request.Content = JsonContent.Create(body);
|
||||
|
||||
using var response = await httpClient.SendAsync(request);
|
||||
if (!response.IsSuccessStatusCode)
|
||||
return null;
|
||||
|
||||
var json = await response.Content.ReadAsStringAsync();
|
||||
if (string.IsNullOrWhiteSpace(json))
|
||||
return null;
|
||||
|
||||
var node = JsonNode.Parse(json);
|
||||
// Unwrap the { ok: true, result: ... } envelope
|
||||
if (node?["ok"]?.GetValue<bool>() == true && node["result"] is not null)
|
||||
return node["result"];
|
||||
return node;
|
||||
}
|
||||
catch
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Extracts useful data from a tool response that may embed JSON in content[0].text.
|
||||
/// Returns the unwrapped "details" object if present, otherwise the raw result.
|
||||
/// </summary>
|
||||
private static JsonNode? ExtractToolData(JsonNode? result)
|
||||
{
|
||||
if (result is null) return null;
|
||||
// Some tools return { details: {...}, content: [...] }
|
||||
if (result["details"] is JsonNode details && details is not JsonValue)
|
||||
return details;
|
||||
// Some tools wrap in content[0].text as JSON string
|
||||
if (result["content"] is JsonArray content && content.Count > 0)
|
||||
{
|
||||
var text = content[0]?["text"]?.GetValue<string>();
|
||||
if (!string.IsNullOrWhiteSpace(text))
|
||||
{
|
||||
try { return JsonNode.Parse(text); }
|
||||
catch { /* fall through */ }
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public async Task<List<DashboardAgentInfo>> GetAgentsAsync()
|
||||
{
|
||||
// Hardcoded agent list (known from OpenClaw config).
|
||||
// Tools/invoke visibility is restricted to agent:main scope,
|
||||
// so we can't enumerate Iris sessions programmatically.
|
||||
var agentDefs = new[]
|
||||
{
|
||||
new { Id = "iris", Name = "Iris", Model = "GPT-5.4" },
|
||||
new { Id = "programmer", Name = "Programmer", Model = "DeepSeek V4 Flash" },
|
||||
new { Id = "reviewer", Name = "Reviewer", Model = "DeepSeek V4 Pro" },
|
||||
new { Id = "architekt", Name = "DevOps", Model = "DeepSeek V4 Pro" },
|
||||
new { Id = "executor", Name = "Executor", Model = "DeepSeek V4 Flash" },
|
||||
new { Id = "researcher", Name = "Researcher", Model = "DeepSeek V4 Pro" },
|
||||
};
|
||||
|
||||
var agents = new List<DashboardAgentInfo>();
|
||||
foreach (var def in agentDefs)
|
||||
{
|
||||
var isActive = false;
|
||||
string? currentTask = null;
|
||||
|
||||
// Check workspace activity via file timestamps
|
||||
var memDir = $"/mnt/workspace-{def.Id}/memory";
|
||||
try
|
||||
{
|
||||
if (Directory.Exists(memDir))
|
||||
{
|
||||
var latestFile = Directory.GetFiles(memDir, "*", SearchOption.AllDirectories)
|
||||
.Select(f => new FileInfo(f))
|
||||
.OrderByDescending(f => f.LastWriteTimeUtc)
|
||||
.FirstOrDefault();
|
||||
|
||||
if (latestFile is not null)
|
||||
{
|
||||
var age = DateTime.UtcNow - latestFile.LastWriteTimeUtc;
|
||||
isActive = age.TotalMinutes < 15;
|
||||
if (isActive)
|
||||
currentTask = $"Modified: {latestFile.Name}";
|
||||
}
|
||||
}
|
||||
}
|
||||
catch { /* workspace not mounted or inaccessible */ }
|
||||
|
||||
agents.Add(new DashboardAgentInfo(
|
||||
Id: def.Id,
|
||||
Name: def.Name,
|
||||
Role: DeriveRole(def.Id),
|
||||
Model: def.Model,
|
||||
IsActive: isActive,
|
||||
CurrentTask: currentTask
|
||||
));
|
||||
}
|
||||
|
||||
return agents;
|
||||
}
|
||||
|
||||
public async Task<List<MessageEntry>> GetSessionHistoryAsync(string sessionKey, int limit = 50, int offset = 0)
|
||||
{
|
||||
try
|
||||
{
|
||||
var result = await InvokeToolAsync("sessions_history", new { sessionKey, limit, offset });
|
||||
if (result is null) return new List<MessageEntry>();
|
||||
|
||||
var messages = new List<MessageEntry>();
|
||||
var array = result as JsonArray ?? result.AsArray();
|
||||
if (array is null) return messages;
|
||||
|
||||
foreach (var msg in array)
|
||||
{
|
||||
if (msg is null) continue;
|
||||
var role = msg["role"]?.GetValue<string>() ?? "";
|
||||
var content = msg["content"]?.GetValue<string>() ?? "";
|
||||
var timestamp = msg["timestamp"]?.GetValue<string>()
|
||||
?? msg["ts"]?.GetValue<string>()
|
||||
?? msg["createdAt"]?.GetValue<string>()
|
||||
?? DateTimeOffset.UtcNow.ToString("o");
|
||||
|
||||
messages.Add(new MessageEntry(role, content, timestamp));
|
||||
}
|
||||
|
||||
return messages;
|
||||
}
|
||||
catch
|
||||
{
|
||||
return new List<MessageEntry>();
|
||||
}
|
||||
}
|
||||
|
||||
public async Task<ChatResponse> SendChatMessageAsync(string sessionKey, string message)
|
||||
{
|
||||
try
|
||||
{
|
||||
var result = await InvokeToolAsync("sessions_send", new { sessionKey, message });
|
||||
if (result is null) return new ChatResponse(false, null, "Gateway nicht erreichbar");
|
||||
|
||||
var ok = result["ok"]?.GetValue<bool>() ?? false;
|
||||
var reply = result["reply"]?.GetValue<string>()
|
||||
?? result["response"]?.GetValue<string>()
|
||||
?? result["content"]?[0]?["text"]?.GetValue<string>();
|
||||
var error = result["error"]?.GetValue<string>();
|
||||
|
||||
return new ChatResponse(ok, reply, error);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return new ChatResponse(false, null, $"Fehler: {ex.Message}");
|
||||
}
|
||||
}
|
||||
|
||||
public async Task<List<QueueItem>> GetQueueAsync()
|
||||
{
|
||||
try
|
||||
{
|
||||
var result = await InvokeToolAsync("cron", new { action = "list" });
|
||||
var data = ExtractToolData(result);
|
||||
if (data is null) return new List<QueueItem>();
|
||||
|
||||
var items = new List<QueueItem>();
|
||||
var jobs = data["jobs"] as JsonArray ?? data.AsArray();
|
||||
if (jobs is null) return items;
|
||||
|
||||
foreach (var j in jobs)
|
||||
{
|
||||
if (j is null) continue;
|
||||
var id = j["id"]?.GetValue<string>() ?? "";
|
||||
var name = j["name"]?.GetValue<string>() ?? id;
|
||||
var status = j["state"]?["lastStatus"]?.GetValue<string>()
|
||||
?? j["status"]?.GetValue<string>()
|
||||
?? "unknown";
|
||||
|
||||
items.Add(new QueueItem(id, name, status));
|
||||
}
|
||||
return items;
|
||||
}
|
||||
catch
|
||||
{
|
||||
return new List<QueueItem>();
|
||||
}
|
||||
}
|
||||
|
||||
public async Task<DashboardStatus> GetStatusAsync()
|
||||
{
|
||||
var gatewayOk = false;
|
||||
var irisStatus = "Offline";
|
||||
var activeAgents = 0;
|
||||
var pendingTasks = 0;
|
||||
|
||||
// Step 1: Health check (no auth needed)
|
||||
try
|
||||
{
|
||||
using var pingRequest = new HttpRequestMessage(HttpMethod.Get, "/health");
|
||||
using var pingResponse = await httpClient.SendAsync(pingRequest);
|
||||
gatewayOk = pingResponse.IsSuccessStatusCode;
|
||||
}
|
||||
catch
|
||||
{
|
||||
// gatewayOk stays false
|
||||
}
|
||||
|
||||
if (gatewayOk)
|
||||
{
|
||||
// Step 2: Session status
|
||||
try
|
||||
{
|
||||
var sessionResult = await InvokeToolAsync("session_status");
|
||||
if (sessionResult is not null)
|
||||
{
|
||||
irisStatus = sessionResult["status"]?.GetValue<string>()
|
||||
?? sessionResult["sessionKey"]?.GetValue<string>()
|
||||
?? "Active";
|
||||
}
|
||||
}
|
||||
catch { }
|
||||
|
||||
// Step 3: Active agents
|
||||
try
|
||||
{
|
||||
var agents = await GetAgentsAsync();
|
||||
activeAgents = agents.Count(a => a.IsActive);
|
||||
}
|
||||
catch { }
|
||||
|
||||
// Step 4: Queue items
|
||||
try
|
||||
{
|
||||
var queue = await GetQueueAsync();
|
||||
pendingTasks = queue.Count;
|
||||
}
|
||||
catch { }
|
||||
}
|
||||
|
||||
return new DashboardStatus(gatewayOk, irisStatus, activeAgents, pendingTasks);
|
||||
}
|
||||
|
||||
private static string DeriveRole(string agentId) => agentId.ToLowerInvariant() switch
|
||||
{
|
||||
"iris" => "Orchestrator",
|
||||
"programmer" => "Developer",
|
||||
"reviewer" => "Reviewer",
|
||||
"architekt" => "Architect",
|
||||
"executor" => "Executor",
|
||||
"researcher" => "Researcher",
|
||||
"main" => "Assistant",
|
||||
_ => "Custom"
|
||||
};
|
||||
}
|
||||
@@ -54,7 +54,7 @@ defineEmits<{
|
||||
<section class="modal-section">
|
||||
<h3 class="section-label">Live Thinking</h3>
|
||||
<div class="thinking-panel">
|
||||
<div class="thinking-stream" ref="thinkingStreamRef">
|
||||
<div class="thinking-stream">
|
||||
<div
|
||||
v-for="(msg, idx) in agent.thinkingStream"
|
||||
:key="idx"
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
<script setup lang="ts">
|
||||
import { ref, nextTick, watch } from 'vue'
|
||||
import { Bot, Send, LoaderCircle } from '@lucide/vue'
|
||||
import { Bot, Send, LoaderCircle, Maximize2, X } from '@lucide/vue'
|
||||
import type { ChatMessage } from '../../composables/useDashboardData'
|
||||
import { useDashboardData } from '../../composables/useDashboardData'
|
||||
|
||||
const props = defineProps<{
|
||||
messages: ChatMessage[]
|
||||
@@ -9,16 +10,16 @@ const props = defineProps<{
|
||||
irisFocus: string
|
||||
}>()
|
||||
|
||||
const emit = defineEmits<{
|
||||
send: [text: string]
|
||||
}>()
|
||||
const { sendChatMessage } = useDashboardData()
|
||||
|
||||
const inputText = ref('')
|
||||
const chatListRef = ref<HTMLElement | null>(null)
|
||||
const chatModalListRef = ref<HTMLElement | null>(null)
|
||||
const chatModalOpen = ref(false)
|
||||
|
||||
function sendMessage(): void {
|
||||
if (!inputText.value.trim()) return
|
||||
emit('send', inputText.value)
|
||||
sendChatMessage(inputText.value)
|
||||
inputText.value = ''
|
||||
}
|
||||
|
||||
@@ -26,8 +27,9 @@ watch(
|
||||
() => props.messages.length,
|
||||
async () => {
|
||||
await nextTick()
|
||||
if (chatListRef.value) {
|
||||
chatListRef.value.scrollTop = chatListRef.value.scrollHeight
|
||||
const el = chatModalOpen.value ? chatModalListRef.value : chatListRef.value
|
||||
if (el) {
|
||||
el.scrollTop = el.scrollHeight
|
||||
}
|
||||
}
|
||||
)
|
||||
@@ -44,6 +46,9 @@ watch(
|
||||
<LoaderCircle :size="10" class="spin" />
|
||||
<span>Busy</span>
|
||||
</div>
|
||||
<button class="chat-expand-btn" @click="chatModalOpen = true" title="Open larger chat">
|
||||
<Maximize2 :size="14" />
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<!-- Focus Bar -->
|
||||
@@ -90,6 +95,68 @@ watch(
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Expanded Chat Modal -->
|
||||
<Teleport to="body">
|
||||
<div v-if="chatModalOpen" class="chat-modal-overlay" @click.self="chatModalOpen = false">
|
||||
<div class="chat-modal">
|
||||
<div class="chat-modal-header">
|
||||
<div class="chat-modal-header-left">
|
||||
<Bot :size="18" class="chat-header-icon" />
|
||||
<h2>Iris Chat</h2>
|
||||
</div>
|
||||
<div v-if="irisBusy" class="busy-badge">
|
||||
<LoaderCircle :size="10" class="spin" />
|
||||
<span>Busy</span>
|
||||
</div>
|
||||
<button class="chat-modal-close" @click="chatModalOpen = false" title="Close">
|
||||
<X :size="16" />
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div v-if="irisBusy && irisFocus" class="focus-bar">
|
||||
<span class="focus-label">Current Focus</span>
|
||||
<span class="focus-text">{{ irisFocus }}</span>
|
||||
</div>
|
||||
|
||||
<div ref="chatModalListRef" class="chat-modal-messages">
|
||||
<div
|
||||
v-for="msg in messages"
|
||||
:key="msg.id"
|
||||
:class="['msg-row', msg.sender === 'user' ? 'msg-user' : 'msg-iris']"
|
||||
>
|
||||
<div v-if="msg.sender === 'iris'" class="msg-avatar">
|
||||
<Bot :size="14" />
|
||||
</div>
|
||||
<div class="msg-bubble">
|
||||
<p>{{ msg.text }}</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div v-if="messages.length === 0" class="empty-state">
|
||||
<p>No messages yet. Start a conversation with Iris.</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="chat-modal-input-row">
|
||||
<input
|
||||
v-model="inputText"
|
||||
type="text"
|
||||
placeholder="Type a message..."
|
||||
@keyup.enter="sendMessage"
|
||||
/>
|
||||
<button
|
||||
class="send-btn"
|
||||
:disabled="!inputText.trim()"
|
||||
@click="sendMessage"
|
||||
aria-label="Send"
|
||||
>
|
||||
<Send :size="16" />
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</Teleport>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
@@ -152,6 +219,27 @@ watch(
|
||||
to { transform: rotate(360deg); }
|
||||
}
|
||||
|
||||
/* Expand Button */
|
||||
.chat-expand-btn {
|
||||
display: grid;
|
||||
place-items: center;
|
||||
width: 26px;
|
||||
height: 26px;
|
||||
border: 1px solid rgba(255, 255, 255, 0.06);
|
||||
border-radius: 6px;
|
||||
background: rgba(255, 255, 255, 0.03);
|
||||
color: #6b7385;
|
||||
cursor: pointer;
|
||||
flex-shrink: 0;
|
||||
transition: all 0.2s;
|
||||
margin-left: 6px;
|
||||
}
|
||||
.chat-expand-btn:hover {
|
||||
background: rgba(167, 139, 250, 0.12);
|
||||
border-color: rgba(167, 139, 250, 0.25);
|
||||
color: #a78bfa;
|
||||
}
|
||||
|
||||
/* Focus Bar */
|
||||
.focus-bar {
|
||||
display: flex;
|
||||
@@ -293,4 +381,118 @@ watch(
|
||||
.send-btn:not(:disabled):hover {
|
||||
opacity: 0.85;
|
||||
}
|
||||
|
||||
/* Chat Modal Overlay */
|
||||
.chat-modal-overlay {
|
||||
position: fixed;
|
||||
inset: 0;
|
||||
background: rgba(0, 0, 0, 0.55);
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
z-index: 9999;
|
||||
backdrop-filter: blur(4px);
|
||||
-webkit-backdrop-filter: blur(4px);
|
||||
}
|
||||
.chat-modal {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
width: 90%;
|
||||
max-width: 700px;
|
||||
height: 70vh;
|
||||
max-height: 80vh;
|
||||
background: rgba(22, 27, 34, 0.92);
|
||||
border: 1px solid rgba(139, 124, 246, 0.15);
|
||||
border-radius: 16px;
|
||||
backdrop-filter: blur(16px);
|
||||
-webkit-backdrop-filter: blur(16px);
|
||||
box-shadow: 0 8px 40px rgba(0, 0, 0, 0.4);
|
||||
overflow: hidden;
|
||||
animation: modal-in 0.2s ease-out;
|
||||
}
|
||||
@keyframes modal-in {
|
||||
from { opacity: 0; transform: scale(0.95) translateY(10px); }
|
||||
to { opacity: 1; transform: scale(1) translateY(0); }
|
||||
}
|
||||
.chat-modal-header {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
padding: 16px 20px;
|
||||
border-bottom: 1px solid rgba(255, 255, 255, 0.06);
|
||||
}
|
||||
.chat-modal-header-left {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
flex: 1;
|
||||
}
|
||||
.chat-modal-header h2 {
|
||||
margin: 0;
|
||||
font-size: 15px;
|
||||
font-weight: 600;
|
||||
color: #e8eaf0;
|
||||
}
|
||||
.chat-modal-close {
|
||||
display: grid;
|
||||
place-items: center;
|
||||
width: 28px;
|
||||
height: 28px;
|
||||
border: none;
|
||||
border-radius: 6px;
|
||||
background: rgba(255, 255, 255, 0.04);
|
||||
color: #6b7385;
|
||||
cursor: pointer;
|
||||
transition: all 0.2s;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
.chat-modal-close:hover {
|
||||
background: rgba(255, 255, 255, 0.08);
|
||||
color: #e8eaf0;
|
||||
}
|
||||
|
||||
.chat-modal-messages {
|
||||
flex: 1;
|
||||
overflow-y: auto;
|
||||
padding: 16px 20px;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 10px;
|
||||
}
|
||||
.chat-modal-messages::-webkit-scrollbar {
|
||||
width: 6px;
|
||||
}
|
||||
.chat-modal-messages::-webkit-scrollbar-track {
|
||||
background: transparent;
|
||||
}
|
||||
.chat-modal-messages::-webkit-scrollbar-thumb {
|
||||
background: rgba(139, 124, 246, 0.2);
|
||||
border-radius: 3px;
|
||||
}
|
||||
|
||||
.chat-modal-input-row {
|
||||
display: flex;
|
||||
gap: 8px;
|
||||
padding: 12px 16px;
|
||||
border-top: 1px solid rgba(255, 255, 255, 0.06);
|
||||
}
|
||||
.chat-modal-input-row input {
|
||||
flex: 1;
|
||||
padding: 10px 14px;
|
||||
border: 1px solid rgba(255, 255, 255, 0.08);
|
||||
border-radius: 8px;
|
||||
background: rgba(0, 0, 0, 0.3);
|
||||
color: #e8eaf0;
|
||||
font-size: 13px;
|
||||
font-family: inherit;
|
||||
outline: none;
|
||||
transition: border-color 0.2s;
|
||||
min-width: 0;
|
||||
}
|
||||
.chat-modal-input-row input:focus {
|
||||
border-color: #a78bfa;
|
||||
}
|
||||
.chat-modal-input-row input::placeholder {
|
||||
color: #6b7385;
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -0,0 +1,260 @@
|
||||
<script setup lang="ts">
|
||||
import { ref, computed } from 'vue'
|
||||
import { ChevronLeft, ChevronRight, X } from '@lucide/vue'
|
||||
import type { FeedEntry } from '../../composables/useDashboardData'
|
||||
|
||||
const props = defineProps<{
|
||||
entries: FeedEntry[]
|
||||
modelValue: boolean
|
||||
}>()
|
||||
|
||||
const emit = defineEmits<{
|
||||
'update:modelValue': [value: boolean]
|
||||
}>()
|
||||
|
||||
const selectedDayOffset = ref(0) // 0 = today, -1 = yesterday, etc.
|
||||
|
||||
function close() {
|
||||
emit('update:modelValue', false)
|
||||
}
|
||||
|
||||
function dayLabel(offset: number): string {
|
||||
if (offset === 0) return 'Heute'
|
||||
if (offset === -1) return 'Gestern'
|
||||
if (offset === -2) return 'Vorgestern'
|
||||
const d = new Date()
|
||||
d.setDate(d.getDate() + offset)
|
||||
return d.toLocaleDateString('de-DE', { weekday: 'long', day: 'numeric', month: 'long' })
|
||||
}
|
||||
|
||||
function navigateDay(dir: -1 | 1) {
|
||||
const next = selectedDayOffset.value + dir
|
||||
if (next >= -6 && next <= 0) {
|
||||
selectedDayOffset.value = next
|
||||
}
|
||||
}
|
||||
|
||||
const filteredEntries = computed(() => {
|
||||
const targetDate = new Date()
|
||||
targetDate.setDate(targetDate.getDate() + selectedDayOffset.value)
|
||||
const targetStr = targetDate.toISOString().slice(0, 10)
|
||||
return props.entries.filter(e => e.timestamp.slice(0, 10) === targetStr)
|
||||
})
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Teleport to="body">
|
||||
<div v-if="modelValue" class="feed-modal-overlay" @click.self="close">
|
||||
<div class="feed-modal-card">
|
||||
<div class="feed-modal-header">
|
||||
<h2 class="feed-modal-title">Operations Log</h2>
|
||||
<button class="feed-modal-close-btn" @click="close" aria-label="Close">
|
||||
<X :size="16" />
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div class="feed-modal-nav">
|
||||
<button
|
||||
class="feed-nav-btn"
|
||||
:disabled="selectedDayOffset <= -6"
|
||||
@click="navigateDay(-1)"
|
||||
aria-label="Previous day"
|
||||
>
|
||||
<ChevronLeft :size="14" />
|
||||
</button>
|
||||
<span class="feed-nav-label">{{ dayLabel(selectedDayOffset) }}</span>
|
||||
<button
|
||||
class="feed-nav-btn"
|
||||
:disabled="selectedDayOffset >= 0"
|
||||
@click="navigateDay(1)"
|
||||
aria-label="Next day"
|
||||
>
|
||||
<ChevronRight :size="14" />
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div class="feed-modal-entries">
|
||||
<div v-if="filteredEntries.length === 0" class="feed-modal-empty">
|
||||
Keine Einträge für diesen Tag.
|
||||
</div>
|
||||
<div
|
||||
v-for="(entry, idx) in filteredEntries"
|
||||
:key="entry.timestamp + '-' + idx"
|
||||
class="feed-modal-entry"
|
||||
>
|
||||
<span class="feed-time">{{ entry.time }}</span>
|
||||
<span class="feed-bullet">·</span>
|
||||
<span class="feed-agent" :class="'agent-' + entry.agent.toLowerCase()">
|
||||
{{ entry.agent }}
|
||||
</span>
|
||||
<span class="feed-action">{{ entry.action }}</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</Teleport>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.feed-modal-overlay {
|
||||
position: fixed;
|
||||
inset: 0;
|
||||
z-index: 1000;
|
||||
display: grid;
|
||||
place-items: center;
|
||||
background: rgba(0, 0, 0, 0.6);
|
||||
backdrop-filter: blur(4px);
|
||||
padding: 20px;
|
||||
animation: feed-overlay-in 0.2s ease;
|
||||
}
|
||||
@keyframes feed-overlay-in {
|
||||
from { opacity: 0; }
|
||||
to { opacity: 1; }
|
||||
}
|
||||
|
||||
.feed-modal-card {
|
||||
background: #161b22;
|
||||
border: 1px solid rgba(139, 124, 246, 0.15);
|
||||
border-radius: 16px;
|
||||
padding: 24px;
|
||||
width: 100%;
|
||||
max-width: 520px;
|
||||
max-height: 80vh;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 16px;
|
||||
box-shadow: 0 8px 40px rgba(0, 0, 0, 0.5);
|
||||
animation: feed-card-in 0.25s ease;
|
||||
}
|
||||
@keyframes feed-card-in {
|
||||
from { opacity: 0; transform: translateY(12px) scale(0.98); }
|
||||
to { opacity: 1; transform: translateY(0) scale(1); }
|
||||
}
|
||||
|
||||
.feed-modal-header {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 12px;
|
||||
}
|
||||
.feed-modal-title {
|
||||
margin: 0;
|
||||
font-size: 15px;
|
||||
font-weight: 600;
|
||||
color: #e8eaf0;
|
||||
}
|
||||
.feed-modal-close-btn {
|
||||
display: grid;
|
||||
place-items: center;
|
||||
width: 28px;
|
||||
height: 28px;
|
||||
border: none;
|
||||
background: rgba(255, 255, 255, 0.05);
|
||||
border-radius: 6px;
|
||||
color: #7e8799;
|
||||
cursor: pointer;
|
||||
transition: all 0.15s;
|
||||
}
|
||||
.feed-modal-close-btn:hover {
|
||||
background: rgba(255, 255, 255, 0.1);
|
||||
color: #e8eaf0;
|
||||
}
|
||||
|
||||
.feed-modal-nav {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
gap: 12px;
|
||||
}
|
||||
.feed-nav-btn {
|
||||
display: grid;
|
||||
place-items: center;
|
||||
width: 30px;
|
||||
height: 30px;
|
||||
border: 1px solid rgba(139, 124, 246, 0.15);
|
||||
background: rgba(139, 124, 246, 0.08);
|
||||
border-radius: 8px;
|
||||
color: #a78bfa;
|
||||
cursor: pointer;
|
||||
transition: all 0.15s;
|
||||
}
|
||||
.feed-nav-btn:hover:not(:disabled) {
|
||||
background: rgba(139, 124, 246, 0.16);
|
||||
border-color: rgba(139, 124, 246, 0.3);
|
||||
}
|
||||
.feed-nav-btn:disabled {
|
||||
opacity: 0.3;
|
||||
cursor: not-allowed;
|
||||
}
|
||||
.feed-nav-label {
|
||||
font-size: 12px;
|
||||
font-weight: 600;
|
||||
color: #d1d5db;
|
||||
min-width: 100px;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.feed-modal-entries {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 4px;
|
||||
overflow-y: auto;
|
||||
max-height: 50vh;
|
||||
padding-right: 4px;
|
||||
}
|
||||
.feed-modal-empty {
|
||||
text-align: center;
|
||||
padding: 24px 0;
|
||||
font-size: 11px;
|
||||
color: #6b7385;
|
||||
}
|
||||
|
||||
.feed-modal-entry {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 5px;
|
||||
padding: 5px 6px;
|
||||
border-radius: 6px;
|
||||
font-size: 9.5px;
|
||||
line-height: 1.3;
|
||||
transition: background 0.15s;
|
||||
}
|
||||
.feed-modal-entry:hover {
|
||||
background: rgba(255, 255, 255, 0.03);
|
||||
}
|
||||
|
||||
.feed-time {
|
||||
color: #6b7385;
|
||||
flex-shrink: 0;
|
||||
font-variant-numeric: tabular-nums;
|
||||
width: 32px;
|
||||
}
|
||||
.feed-bullet {
|
||||
color: #6b7385;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
.feed-agent {
|
||||
font-weight: 600;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
.agent-iris {
|
||||
color: #a78bfa;
|
||||
}
|
||||
.agent-developer {
|
||||
color: #3b82f6;
|
||||
}
|
||||
.agent-devops {
|
||||
color: #eab308;
|
||||
}
|
||||
.agent-researcher {
|
||||
color: #22c55e;
|
||||
}
|
||||
.agent-reviewer {
|
||||
color: #a855f7;
|
||||
}
|
||||
.feed-action {
|
||||
color: #7e8799;
|
||||
white-space: normal;
|
||||
word-break: break-word;
|
||||
}
|
||||
</style>
|
||||
@@ -1,7 +1,8 @@
|
||||
<script setup lang="ts">
|
||||
import { ref, computed } from 'vue'
|
||||
import { Activity, ChevronLeft, ChevronRight, X } from '@lucide/vue'
|
||||
import { Activity } from '@lucide/vue'
|
||||
import type { FeedEntry } from '../../composables/useDashboardData'
|
||||
import FeedDetailModal from './FeedDetailModal.vue'
|
||||
|
||||
const props = defineProps<{
|
||||
entries: FeedEntry[]
|
||||
@@ -12,41 +13,10 @@ const compactEntries = computed(() => props.entries.slice(0, 5))
|
||||
|
||||
// ── Feed Detail Modal ──
|
||||
const showDetailModal = ref(false)
|
||||
const selectedDayOffset = ref(0) // 0 = today, -1 = yesterday, etc.
|
||||
|
||||
function openDetailModal() {
|
||||
selectedDayOffset.value = 0
|
||||
showDetailModal.value = true
|
||||
}
|
||||
|
||||
function closeDetailModal() {
|
||||
showDetailModal.value = false
|
||||
}
|
||||
|
||||
function dayLabel(offset: number): string {
|
||||
if (offset === 0) return 'Heute'
|
||||
if (offset === -1) return 'Gestern'
|
||||
if (offset === -2) return 'Vorgestern'
|
||||
const d = new Date()
|
||||
d.setDate(d.getDate() + offset)
|
||||
return d.toLocaleDateString('de-DE', { weekday: 'long', day: 'numeric', month: 'long' })
|
||||
}
|
||||
|
||||
function navigateDay(dir: -1 | 1) {
|
||||
const next = selectedDayOffset.value + dir
|
||||
if (next >= -6 && next <= 0) {
|
||||
selectedDayOffset.value = next
|
||||
}
|
||||
}
|
||||
|
||||
const filteredEntries = computed(() => {
|
||||
const targetDate = new Date()
|
||||
targetDate.setDate(targetDate.getDate() + selectedDayOffset.value)
|
||||
const targetStr = targetDate.toISOString().slice(0, 10)
|
||||
return props.entries.filter(e => e.timestamp.slice(0, 10) === targetStr)
|
||||
})
|
||||
|
||||
|
||||
</script>
|
||||
|
||||
<template>
|
||||
@@ -81,55 +51,11 @@ const filteredEntries = computed(() => {
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<!-- ── Feed Detail Modal ── -->
|
||||
<Teleport to="body">
|
||||
<div v-if="showDetailModal" class="modal-overlay" @click.self="closeDetailModal">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h2 class="modal-title">Operations Log</h2>
|
||||
<button class="modal-close-btn" @click="closeDetailModal">
|
||||
<X :size="16" />
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div class="modal-nav">
|
||||
<button
|
||||
class="nav-btn"
|
||||
:disabled="selectedDayOffset <= -6"
|
||||
@click="navigateDay(-1)"
|
||||
>
|
||||
<ChevronLeft :size="14" />
|
||||
</button>
|
||||
<span class="nav-label">{{ dayLabel(selectedDayOffset) }}</span>
|
||||
<button
|
||||
class="nav-btn"
|
||||
:disabled="selectedDayOffset >= 0"
|
||||
@click="navigateDay(1)"
|
||||
>
|
||||
<ChevronRight :size="14" />
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div class="modal-entries">
|
||||
<div v-if="filteredEntries.length === 0" class="modal-empty">
|
||||
Keine Einträge für diesen Tag.
|
||||
</div>
|
||||
<div
|
||||
v-for="(entry, idx) in filteredEntries"
|
||||
:key="entry.timestamp + '-' + idx"
|
||||
class="feed-entry"
|
||||
>
|
||||
<span class="feed-time">{{ entry.time }}</span>
|
||||
<span class="feed-bullet">·</span>
|
||||
<span class="feed-agent" :class="'agent-' + entry.agent.toLowerCase()">
|
||||
{{ entry.agent }}
|
||||
</span>
|
||||
<span class="feed-action">{{ entry.action }}</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</Teleport>
|
||||
<FeedDetailModal
|
||||
:entries="entries"
|
||||
:model-value="showDetailModal"
|
||||
@update:model-value="showDetailModal = $event"
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
@@ -267,104 +193,4 @@ const filteredEntries = computed(() => {
|
||||
.feed-move {
|
||||
transition: transform 0.3s ease;
|
||||
}
|
||||
|
||||
/* ── Modal Overlay ── */
|
||||
:global(.modal-overlay) {
|
||||
position: fixed;
|
||||
inset: 0;
|
||||
z-index: 1000;
|
||||
display: grid;
|
||||
place-items: center;
|
||||
background: rgba(0, 0, 0, 0.6);
|
||||
backdrop-filter: blur(4px);
|
||||
padding: 20px;
|
||||
}
|
||||
:global(.modal-content) {
|
||||
background: #161b22;
|
||||
border: 1px solid rgba(139, 124, 246, 0.15);
|
||||
border-radius: 16px;
|
||||
padding: 24px;
|
||||
width: 100%;
|
||||
max-width: 520px;
|
||||
max-height: 80vh;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 16px;
|
||||
box-shadow: 0 8px 40px rgba(0, 0, 0, 0.5);
|
||||
}
|
||||
:global(.modal-header) {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 12px;
|
||||
}
|
||||
:global(.modal-title) {
|
||||
margin: 0;
|
||||
font-size: 15px;
|
||||
font-weight: 600;
|
||||
color: #e8eaf0;
|
||||
}
|
||||
:global(.modal-close-btn) {
|
||||
display: grid;
|
||||
place-items: center;
|
||||
width: 28px;
|
||||
height: 28px;
|
||||
border: none;
|
||||
background: rgba(255, 255, 255, 0.05);
|
||||
border-radius: 6px;
|
||||
color: #7e8799;
|
||||
cursor: pointer;
|
||||
transition: all 0.15s;
|
||||
}
|
||||
:global(.modal-close-btn:hover) {
|
||||
background: rgba(255, 255, 255, 0.1);
|
||||
color: #e8eaf0;
|
||||
}
|
||||
:global(.modal-nav) {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
gap: 12px;
|
||||
}
|
||||
:global(.nav-btn) {
|
||||
display: grid;
|
||||
place-items: center;
|
||||
width: 30px;
|
||||
height: 30px;
|
||||
border: 1px solid rgba(139, 124, 246, 0.15);
|
||||
background: rgba(139, 124, 246, 0.08);
|
||||
border-radius: 8px;
|
||||
color: #a78bfa;
|
||||
cursor: pointer;
|
||||
transition: all 0.15s;
|
||||
}
|
||||
:global(.nav-btn:hover:not(:disabled)) {
|
||||
background: rgba(139, 124, 246, 0.16);
|
||||
border-color: rgba(139, 124, 246, 0.3);
|
||||
}
|
||||
:global(.nav-btn:disabled) {
|
||||
opacity: 0.3;
|
||||
cursor: not-allowed;
|
||||
}
|
||||
:global(.nav-label) {
|
||||
font-size: 12px;
|
||||
font-weight: 600;
|
||||
color: #d1d5db;
|
||||
min-width: 100px;
|
||||
text-align: center;
|
||||
}
|
||||
:global(.modal-entries) {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 4px;
|
||||
overflow-y: auto;
|
||||
max-height: 50vh;
|
||||
padding-right: 4px;
|
||||
}
|
||||
:global(.modal-empty) {
|
||||
text-align: center;
|
||||
padding: 24px 0;
|
||||
font-size: 11px;
|
||||
color: #6b7385;
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -76,7 +76,7 @@ function onDragEnd(): void {
|
||||
<div class="queue-header" @click="expanded = !expanded">
|
||||
<div class="queue-header-left">
|
||||
<ListTodo :size="14" class="queue-icon" />
|
||||
<h2>Queue</h2>
|
||||
<h2>Chat Queue</h2>
|
||||
<span class="queue-count">{{ items.length }}</span>
|
||||
</div>
|
||||
<button class="queue-toggle" aria-label="Toggle">
|
||||
|
||||
+21
-1
@@ -1,6 +1,6 @@
|
||||
<script setup lang="ts">
|
||||
import { ref } from 'vue'
|
||||
import { Plus, Circle } from '@lucide/vue'
|
||||
import { Plus, Circle, ChevronRight } from '@lucide/vue'
|
||||
import type { OpenTask } from '../../composables/useDashboardData'
|
||||
|
||||
defineProps<{
|
||||
@@ -9,6 +9,7 @@ defineProps<{
|
||||
|
||||
const emit = defineEmits<{
|
||||
newTask: []
|
||||
'go-board': []
|
||||
}>()
|
||||
|
||||
const expandedId = ref<string | null>(null)
|
||||
@@ -67,6 +68,11 @@ function toggleExpand(id: string) {
|
||||
</div>
|
||||
</TransitionGroup>
|
||||
</div>
|
||||
|
||||
<button class="task-board-btn" @click="emit('go-board')">
|
||||
<span>Zum Task Board</span>
|
||||
<ChevronRight :size="14" />
|
||||
</button>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
@@ -223,6 +229,20 @@ function toggleExpand(id: string) {
|
||||
line-height: 1.5;
|
||||
}
|
||||
|
||||
.task-board-btn {
|
||||
width: 100%; margin-top: 12px; padding: 10px;
|
||||
display: flex; align-items: center; justify-content: center; gap: 6px;
|
||||
background: rgba(139, 124, 246, 0.08);
|
||||
border: 1px solid rgba(139, 124, 246, 0.15);
|
||||
border-radius: 10px; color: #a78bfa;
|
||||
font-size: 10px; font-weight: 600; cursor: pointer;
|
||||
transition: all 0.2s;
|
||||
}
|
||||
.task-board-btn:hover {
|
||||
background: rgba(139, 124, 246, 0.15);
|
||||
border-color: rgba(139, 124, 246, 0.3);
|
||||
}
|
||||
|
||||
/* TransitionGroup */
|
||||
.task-enter-active {
|
||||
transition: all 0.3s ease;
|
||||
@@ -1,22 +1,11 @@
|
||||
<script setup lang="ts">
|
||||
import { ref, onMounted, onUnmounted, nextTick, computed } from 'vue'
|
||||
import { ref, computed, toRef } from 'vue'
|
||||
import { Bot, Code2, Server, Shield, Search, Terminal } from '@lucide/vue'
|
||||
|
||||
interface AgentData {
|
||||
id: string
|
||||
name: string
|
||||
role: string
|
||||
description: string
|
||||
tags: string[]
|
||||
color: string
|
||||
icon: string
|
||||
hero?: boolean
|
||||
task?: string
|
||||
runtime?: string
|
||||
}
|
||||
import type { AgentNodeData } from '../../composables/useDashboardData'
|
||||
import { useTeamNetworkSvg } from '../../composables/useTeamNetworkSvg'
|
||||
|
||||
const props = defineProps<{
|
||||
agents: AgentData[]
|
||||
agents: AgentNodeData[]
|
||||
heroId?: string
|
||||
activeAgents?: string[]
|
||||
}>()
|
||||
@@ -25,31 +14,27 @@ const emit = defineEmits<{
|
||||
select: [id: string]
|
||||
}>()
|
||||
|
||||
// ── Layout refs ──
|
||||
// ── Network ref ──
|
||||
const networkRef = ref<HTMLDivElement | null>(null)
|
||||
|
||||
interface CardBox {
|
||||
left: number
|
||||
right: number
|
||||
top: number
|
||||
bottom: number
|
||||
cx: number
|
||||
cy: number
|
||||
width: number
|
||||
height: number
|
||||
}
|
||||
const cardPositions = ref<Record<string, CardBox>>({})
|
||||
const svgWidth = ref(0)
|
||||
const svgHeight = ref(0)
|
||||
|
||||
// ── Computed data ──
|
||||
const hero = computed(() => props.agents.find(a => a.id === props.heroId) ?? props.agents[0])
|
||||
const childAgents = computed(() => props.agents.filter(a => a.id !== props.heroId))
|
||||
const heroId = computed(() => props.heroId ?? props.agents[0]?.id ?? '')
|
||||
|
||||
function isActive(id: string): boolean {
|
||||
return props.activeAgents?.includes(id) ?? false
|
||||
}
|
||||
|
||||
// ── SVG composable ──
|
||||
const {
|
||||
svgWidth,
|
||||
svgHeight,
|
||||
childAgents,
|
||||
connectionPaths,
|
||||
storePathRef,
|
||||
storePulseRef,
|
||||
storePulseRef2,
|
||||
} = useTeamNetworkSvg(networkRef, toRef(props, 'agents'), heroId, isActive)
|
||||
|
||||
// ── Icon resolver ──
|
||||
function resolveIcon(iconName: string) {
|
||||
switch (iconName) {
|
||||
@@ -63,204 +48,15 @@ function resolveIcon(iconName: string) {
|
||||
}
|
||||
}
|
||||
|
||||
// ── Position measurement ──
|
||||
function updatePositions() {
|
||||
if (!networkRef.value) return
|
||||
const rect = networkRef.value.getBoundingClientRect()
|
||||
svgWidth.value = rect.width
|
||||
svgHeight.value = rect.height
|
||||
|
||||
const cards = networkRef.value.querySelectorAll('[data-agent-id]')
|
||||
const positions: Record<string, CardBox> = {}
|
||||
cards.forEach(el => {
|
||||
const id = el.getAttribute('data-agent-id')
|
||||
if (!id) return
|
||||
const r = el.getBoundingClientRect()
|
||||
positions[id] = {
|
||||
left: r.left - rect.left,
|
||||
right: r.left + r.width - rect.left,
|
||||
top: r.top - rect.top,
|
||||
bottom: r.top + r.height - rect.top,
|
||||
cx: r.left + r.width / 2 - rect.left,
|
||||
cy: r.top + r.height / 2 - rect.top,
|
||||
width: r.width,
|
||||
height: r.height,
|
||||
}
|
||||
})
|
||||
cardPositions.value = positions
|
||||
// ── Runtime formatter ──
|
||||
function formatRuntime(seconds: number): string {
|
||||
const m = Math.floor(seconds / 60)
|
||||
const s = seconds % 60
|
||||
return `${String(m).padStart(2, '0')}:${String(s).padStart(2, '0')}`
|
||||
}
|
||||
|
||||
// ── SVG path computation ──
|
||||
interface ConnectionPath {
|
||||
d: string
|
||||
length: number
|
||||
}
|
||||
|
||||
const connectionPaths = computed<Record<string, ConnectionPath | null>>(() => {
|
||||
const result: Record<string, ConnectionPath | null> = {}
|
||||
const pos = cardPositions.value
|
||||
const heroEntry = props.agents.find(a => a.id === props.heroId)
|
||||
const heroId = heroEntry?.id ?? ''
|
||||
const iris = heroId ? pos[heroId] : undefined
|
||||
if (!iris) return result
|
||||
|
||||
const children = childAgents.value
|
||||
const total = children.length
|
||||
if (total === 0) return result
|
||||
|
||||
for (let idx = 0; idx < total; idx++) {
|
||||
const agent = children[idx]
|
||||
const agentPos = pos[agent.id]
|
||||
if (!agentPos) {
|
||||
result[agent.id] = null
|
||||
continue
|
||||
}
|
||||
|
||||
// Spread start points across Iris bottom edge (30%-70% range)
|
||||
const t = total > 1 ? idx / (total - 1) : 0.5
|
||||
const startX = iris.left + iris.width * (0.38 + t * 0.24)
|
||||
const startY = iris.bottom - 1
|
||||
|
||||
// Determine column: left or right of Iris center
|
||||
const isLeftColumn = agentPos.cx < iris.cx
|
||||
|
||||
// End point: approach from side, 8px before card edge
|
||||
const endX = isLeftColumn ? agentPos.right - 8 : agentPos.left + 8
|
||||
const endY = agentPos.cy
|
||||
|
||||
// Bézier control points
|
||||
const cp1x = startX
|
||||
const cp1y = startY + 70
|
||||
const cp2x = endX + (isLeftColumn ? 35 : -35)
|
||||
const cp2y = endY - 10
|
||||
|
||||
const d = `M ${startX} ${startY} C ${cp1x} ${cp1y}, ${cp2x} ${cp2y}, ${endX} ${endY}`
|
||||
result[agent.id] = { d, length: 0 }
|
||||
}
|
||||
return result
|
||||
})
|
||||
|
||||
// ── Pulse animation (JS-driven via requestAnimationFrame) ──
|
||||
let animFrameId: number | null = null
|
||||
let lastAnimTime = 0
|
||||
|
||||
const pathElements = ref<Record<string, SVGPathElement | null>>({})
|
||||
const pulseElements = ref<Record<string, SVGPathElement | null>>({})
|
||||
const pulseOffsets = ref<Record<string, number>>({})
|
||||
|
||||
function storePathRef(id: string) {
|
||||
return (el: SVGPathElement | null) => {
|
||||
pathElements.value[id] = el
|
||||
}
|
||||
}
|
||||
|
||||
function storePulseRef(id: string) {
|
||||
return (el: SVGPathElement | null) => {
|
||||
pulseElements.value[id] = el
|
||||
}
|
||||
}
|
||||
|
||||
function refreshPathLengths() {
|
||||
for (const id of childAgents.value.map(a => a.id)) {
|
||||
const pathEl = pathElements.value[id]
|
||||
const pulseEl = pulseElements.value[id]
|
||||
const p = connectionPaths.value[id]
|
||||
if (pathEl && p) {
|
||||
p.length = pathEl.getTotalLength()
|
||||
}
|
||||
if (pulseEl && p && p.length > 0) {
|
||||
if (pulseOffsets.value[id] === undefined) {
|
||||
pulseOffsets.value[id] = 0
|
||||
}
|
||||
pulseEl.setAttribute('stroke-dasharray', `10 ${p.length}`)
|
||||
pulseEl.setAttribute('stroke-dashoffset', String(-pulseOffsets.value[id]))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function startPulseAnimation() {
|
||||
const speeds: Record<string, number> = {}
|
||||
|
||||
refreshPathLengths()
|
||||
|
||||
for (const id of childAgents.value.map(a => a.id)) {
|
||||
const p = connectionPaths.value[id]
|
||||
if (p && p.length > 0) {
|
||||
speeds[id] = p.length / 3000
|
||||
if (pulseOffsets.value[id] === undefined) {
|
||||
pulseOffsets.value[id] = 0
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
lastAnimTime = performance.now()
|
||||
|
||||
function tick(now: number) {
|
||||
const dt = now - lastAnimTime
|
||||
lastAnimTime = now
|
||||
|
||||
const children = childAgents.value
|
||||
for (let i = 0; i < children.length; i++) {
|
||||
const id = children[i].id
|
||||
const pathEl = pathElements.value[id]
|
||||
const pulseEl = pulseElements.value[id]
|
||||
const p = connectionPaths.value[id]
|
||||
if (!pathEl || !pulseEl || !p) continue
|
||||
|
||||
const len = p.length
|
||||
if (len <= 0) continue
|
||||
|
||||
const currentOffset = pulseOffsets.value[id] ?? 0
|
||||
const newOffset = currentOffset + (speeds[id] ?? len / 3000) * dt
|
||||
const cycleLen = len + 10
|
||||
pulseOffsets.value[id] = newOffset > cycleLen ? newOffset % cycleLen : newOffset
|
||||
|
||||
pulseEl.setAttribute('stroke-dashoffset', String(-pulseOffsets.value[id]))
|
||||
}
|
||||
|
||||
animFrameId = requestAnimationFrame(tick)
|
||||
}
|
||||
|
||||
animFrameId = requestAnimationFrame(tick)
|
||||
}
|
||||
|
||||
function stopPulseAnimation() {
|
||||
if (animFrameId !== null) {
|
||||
cancelAnimationFrame(animFrameId)
|
||||
animFrameId = null
|
||||
}
|
||||
}
|
||||
|
||||
// ── Lifecycle ──
|
||||
let resizeObserver: ResizeObserver | null = null
|
||||
|
||||
onMounted(async () => {
|
||||
await nextTick()
|
||||
updatePositions()
|
||||
|
||||
// Wait for SVG to render so path refs are populated
|
||||
await nextTick()
|
||||
updatePositions()
|
||||
refreshPathLengths()
|
||||
|
||||
startPulseAnimation()
|
||||
|
||||
resizeObserver = new ResizeObserver(() => {
|
||||
updatePositions()
|
||||
// Paths changed — recalculate lengths and dasharrays
|
||||
requestAnimationFrame(() => {
|
||||
refreshPathLengths()
|
||||
})
|
||||
})
|
||||
if (networkRef.value) {
|
||||
resizeObserver.observe(networkRef.value)
|
||||
}
|
||||
})
|
||||
|
||||
onUnmounted(() => {
|
||||
stopPulseAnimation()
|
||||
resizeObserver?.disconnect()
|
||||
})
|
||||
// ── Hero computed ──
|
||||
const hero = computed(() => props.agents.find(a => a.id === heroId.value) ?? props.agents[0])
|
||||
</script>
|
||||
|
||||
<template>
|
||||
@@ -316,7 +112,7 @@ onUnmounted(() => {
|
||||
opacity="0.5"
|
||||
/>
|
||||
|
||||
<!-- Pulse line (white dashed segment moving along) -->
|
||||
<!-- Pulse line 1 (white dashed segment moving along) -->
|
||||
<path
|
||||
v-if="connectionPaths[agent.id]"
|
||||
:ref="storePulseRef(agent.id)"
|
||||
@@ -328,6 +124,19 @@ onUnmounted(() => {
|
||||
stroke-linejoin="round"
|
||||
:opacity="isActive(agent.id) ? 1 : 0.4"
|
||||
/>
|
||||
|
||||
<!-- Pulse line 2 (offset by half cycle) -->
|
||||
<path
|
||||
v-if="connectionPaths[agent.id]"
|
||||
:ref="storePulseRef2(agent.id)"
|
||||
:d="connectionPaths[agent.id]!.d"
|
||||
stroke="white"
|
||||
stroke-width="3"
|
||||
fill="none"
|
||||
stroke-linecap="round"
|
||||
stroke-linejoin="round"
|
||||
:opacity="isActive(agent.id) ? 0.8 : 0.3"
|
||||
/>
|
||||
</template>
|
||||
</svg>
|
||||
|
||||
@@ -356,12 +165,13 @@ onUnmounted(() => {
|
||||
<span class="card-role-tag" :style="{ background: `${hero.color}18`, color: hero.color, borderColor: `${hero.color}30` }">{{ hero.role }}</span>
|
||||
</div>
|
||||
<p class="card-desc">{{ hero.description }}</p>
|
||||
<div v-if="hero.task" class="task-row">
|
||||
<div v-if="hero.currentTask" class="task-row">
|
||||
<span class="node-task">
|
||||
<span class="node-task-dot">●</span>
|
||||
{{ hero.task }}
|
||||
{{ hero.currentTask }}
|
||||
</span>
|
||||
<span v-if="hero.runtime" class="node-runtime">{{ hero.runtime }}</span>
|
||||
<span class="node-runtime">{{ formatRuntime(hero.runtimeSeconds) }}</span>
|
||||
<span v-if="hero.model" class="node-model">{{ hero.model }}</span>
|
||||
</div>
|
||||
<div class="card-tags">
|
||||
<span v-for="tag in hero.tags" :key="tag" class="card-tag" :style="{ background: `${hero.color}18`, color: hero.color }">{{ tag }}</span>
|
||||
@@ -403,12 +213,13 @@ onUnmounted(() => {
|
||||
<span class="card-role-tag" :style="{ background: `${agent.color}18`, color: agent.color, borderColor: `${agent.color}30` }">{{ agent.role }}</span>
|
||||
</div>
|
||||
<p class="card-desc">{{ agent.description }}</p>
|
||||
<div v-if="agent.task" class="task-row">
|
||||
<div v-if="agent.currentTask" class="task-row">
|
||||
<span class="node-task">
|
||||
<span class="node-task-dot">●</span>
|
||||
{{ agent.task }}
|
||||
{{ agent.currentTask }}
|
||||
</span>
|
||||
<span v-if="agent.runtime" class="node-runtime">{{ agent.runtime }}</span>
|
||||
<span class="node-runtime">{{ formatRuntime(agent.runtimeSeconds) }}</span>
|
||||
<span v-if="agent.model" class="node-model">{{ agent.model }}</span>
|
||||
</div>
|
||||
<div class="card-tags">
|
||||
<span v-for="tag in agent.tags" :key="tag" class="card-tag" :style="{ background: `${agent.color}18`, color: agent.color }">{{ tag }}</span>
|
||||
@@ -469,26 +280,33 @@ onUnmounted(() => {
|
||||
transition: border-color 0.3s, box-shadow 0.3s;
|
||||
}
|
||||
|
||||
/* ── Agent Card (inlined from old AgentCard.vue) ── */
|
||||
/* ── Agent Card ── */
|
||||
.agent-card {
|
||||
background: var(--panel, #11141b);
|
||||
border: 1px solid var(--line, #1f2330);
|
||||
background: rgba(18, 22, 30, 0.45);
|
||||
backdrop-filter: blur(12px);
|
||||
-webkit-backdrop-filter: blur(12px);
|
||||
border: 1px solid rgba(255, 255, 255, 0.06);
|
||||
border-radius: 12px;
|
||||
padding: 18px;
|
||||
cursor: pointer;
|
||||
transition: border-color 0.2s, box-shadow 0.2s;
|
||||
transition: border-color 0.2s, box-shadow 0.2s, background 0.2s;
|
||||
overflow: hidden;
|
||||
position: relative;
|
||||
}
|
||||
.agent-card:hover {
|
||||
background: rgba(18, 22, 30, 0.65);
|
||||
border-color: var(--card-color, #8b7cf6);
|
||||
box-shadow: 0 0 16px color-mix(in srgb, var(--card-color, #8b7cf6) 10%, transparent);
|
||||
}
|
||||
.hero-card {
|
||||
border-color: rgba(139, 124, 246, 0.2);
|
||||
background: rgba(18, 22, 30, 0.45);
|
||||
backdrop-filter: blur(12px);
|
||||
-webkit-backdrop-filter: blur(12px);
|
||||
border: 1px solid rgba(255, 255, 255, 0.06);
|
||||
box-shadow: 0 0 20px rgba(139, 124, 246, 0.06);
|
||||
}
|
||||
.hero-card:hover {
|
||||
background: rgba(18, 22, 30, 0.65);
|
||||
border-color: #8b7cf6;
|
||||
box-shadow: 0 0 24px rgba(139, 124, 246, 0.12);
|
||||
}
|
||||
@@ -567,6 +385,13 @@ onUnmounted(() => {
|
||||
font-variant-numeric: tabular-nums;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
.node-model {
|
||||
font-size: 8.5px;
|
||||
color: #6b7385;
|
||||
font-weight: 500;
|
||||
flex-shrink: 0;
|
||||
margin-left: 6px;
|
||||
}
|
||||
|
||||
/* ── Tags ── */
|
||||
.card-tags {
|
||||
@@ -583,7 +408,7 @@ onUnmounted(() => {
|
||||
letter-spacing: 0.02em;
|
||||
}
|
||||
|
||||
/* ── Hover Arrow (bottom-right) ── */
|
||||
/* ── Hover Arrow ── */
|
||||
.card-arrow {
|
||||
position: absolute;
|
||||
right: 12px;
|
||||
|
||||
@@ -1,12 +1,24 @@
|
||||
import { ref, reactive, computed } from 'vue'
|
||||
import { ref, computed } from 'vue'
|
||||
|
||||
// ── Shared State (singleton: same state regardless of how many times useDashboardData() is called) ──
|
||||
const sessionStart = Date.now()
|
||||
|
||||
// Intervals registry for cleanup
|
||||
const intervals: ReturnType<typeof setInterval>[] = []
|
||||
let cleanupRegistered = false
|
||||
|
||||
// ── Interfaces (exported for components) ──
|
||||
|
||||
export interface AgentNodeData {
|
||||
id: string
|
||||
name: string
|
||||
role: string
|
||||
description: string
|
||||
tags: string[]
|
||||
color: string
|
||||
icon: string
|
||||
model?: string
|
||||
hero?: boolean
|
||||
currentTask: string
|
||||
goal: string
|
||||
progress: number
|
||||
@@ -46,249 +58,392 @@ export interface QueueItem {
|
||||
waitTime: string
|
||||
}
|
||||
|
||||
const now = Date.now()
|
||||
// ── API Response Interfaces ──
|
||||
|
||||
export function useDashboardData() {
|
||||
const sessionStart = Date.now()
|
||||
interface DashboardStatusResponse {
|
||||
gatewayOk: boolean
|
||||
irisStatus: string
|
||||
activeAgents: number
|
||||
pendingTasks: number
|
||||
}
|
||||
|
||||
// Runtime counter
|
||||
const runtimeSeconds = ref(0)
|
||||
let runtimeInterval: ReturnType<typeof setInterval> | null = null
|
||||
interface DashboardAgentInfo {
|
||||
id: string
|
||||
name: string
|
||||
role: string
|
||||
model: string
|
||||
isActive: boolean
|
||||
currentTask: string
|
||||
}
|
||||
|
||||
function startRuntime() {
|
||||
const startTs = sessionStart
|
||||
runtimeSeconds.value = Math.floor((Date.now() - startTs) / 1000)
|
||||
runtimeInterval = setInterval(() => {
|
||||
runtimeSeconds.value = Math.floor((Date.now() - startTs) / 1000)
|
||||
}, 1000)
|
||||
interface DashboardOperationEntry {
|
||||
agent: string
|
||||
action: string
|
||||
timestamp: string
|
||||
time: string
|
||||
}
|
||||
|
||||
interface DashboardChatMessage {
|
||||
role: 'user' | 'assistant'
|
||||
content: string
|
||||
timestamp: string
|
||||
}
|
||||
|
||||
interface DashboardSendResponse {
|
||||
ok: boolean
|
||||
reply?: string
|
||||
error?: string
|
||||
}
|
||||
|
||||
interface DashboardQueueItem {
|
||||
id: string
|
||||
name: string
|
||||
status: string
|
||||
}
|
||||
|
||||
// ── Agent Catalog (static enrichment) ──
|
||||
|
||||
const AGENT_CATALOG: Record<string, Partial<AgentNodeData>> = {
|
||||
iris: {
|
||||
description: 'Koordiniert, delegiert, hält das Team tight. Die erste Anlaufstelle zwischen Boss und Maschine.',
|
||||
tags: ['Orchestration', 'Delegation', 'Approval'],
|
||||
color: '#8b7cf6',
|
||||
icon: 'bot',
|
||||
hero: true,
|
||||
goal: 'Complete Mission Control v3',
|
||||
progress: 85,
|
||||
workload: 55,
|
||||
workingFeed: [],
|
||||
thinkingStream: [],
|
||||
},
|
||||
developer: {
|
||||
description: 'Implements features across the stack with TypeScript, C#, and Vue.',
|
||||
tags: ['Coding', 'Development', 'Builds'],
|
||||
color: '#3b82f6',
|
||||
icon: 'code',
|
||||
goal: 'Complete Dungeon CRUD + room generation',
|
||||
progress: 62,
|
||||
workload: 65,
|
||||
workingFeed: [],
|
||||
thinkingStream: [],
|
||||
},
|
||||
devops: {
|
||||
description: 'Manages Docker, deployment pipelines, and system reliability.',
|
||||
tags: ['Deployment', 'Docker', 'CI/CD'],
|
||||
color: '#eab308',
|
||||
icon: 'server',
|
||||
goal: 'Reduce build times by 40%',
|
||||
progress: 45,
|
||||
workload: 40,
|
||||
workingFeed: [],
|
||||
thinkingStream: [],
|
||||
},
|
||||
researcher: {
|
||||
description: 'Researches APIs, patterns, and best practices. Maintains docs.',
|
||||
tags: ['Research', 'Analysis', 'Docs'],
|
||||
color: '#22c55e',
|
||||
icon: 'search',
|
||||
goal: 'Recommend real-time communication strategy',
|
||||
progress: 30,
|
||||
workload: 25,
|
||||
workingFeed: [],
|
||||
thinkingStream: [],
|
||||
},
|
||||
reviewer: {
|
||||
description: 'Reviews pull requests, enforces standards, runs test suites.',
|
||||
tags: ['Code Review', 'Testing', 'Quality'],
|
||||
color: '#a855f7',
|
||||
icon: 'shield',
|
||||
goal: 'Zero critical findings before merge',
|
||||
progress: 80,
|
||||
workload: 50,
|
||||
workingFeed: [],
|
||||
thinkingStream: [],
|
||||
},
|
||||
}
|
||||
|
||||
function enrichAgent(api: DashboardAgentInfo): AgentNodeData {
|
||||
const catalog = AGENT_CATALOG[api.id] ?? AGENT_CATALOG['developer']
|
||||
return {
|
||||
id: api.id,
|
||||
name: api.name,
|
||||
role: api.role,
|
||||
model: api.model,
|
||||
currentTask: api.currentTask ?? 'Idle',
|
||||
active: api.isActive,
|
||||
description: catalog.description ?? '',
|
||||
tags: catalog.tags ?? [],
|
||||
color: catalog.color ?? '#6b7385',
|
||||
icon: catalog.icon ?? 'bot',
|
||||
hero: catalog.hero ?? false,
|
||||
goal: catalog.goal ?? 'No goal set',
|
||||
progress: catalog.progress ?? 0,
|
||||
workload: catalog.workload ?? 0,
|
||||
runtimeSeconds: 0,
|
||||
workingFeed: catalog.workingFeed ?? [],
|
||||
thinkingStream: catalog.thinkingStream ?? [],
|
||||
}
|
||||
}
|
||||
|
||||
function stopRuntime() {
|
||||
if (runtimeInterval) {
|
||||
clearInterval(runtimeInterval)
|
||||
runtimeInterval = null
|
||||
}
|
||||
// ── Helper: API Fetch with auth ──
|
||||
|
||||
async function apiFetch(path: string, init: RequestInit = {}): Promise<Response> {
|
||||
const base = '' // same-origin proxy
|
||||
return fetch(`${base}${path}`, {
|
||||
...init,
|
||||
credentials: 'include',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
...(init.headers as Record<string, string> ?? {}),
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
// ── State ──
|
||||
|
||||
// Status
|
||||
const gatewayOk = ref(true)
|
||||
const irisStatus = ref('Active')
|
||||
const activeAgents = ref(0)
|
||||
const pendingTasks = ref(0)
|
||||
|
||||
// Agents
|
||||
const agents = ref<AgentNodeData[]>([])
|
||||
|
||||
// Chat
|
||||
const chatMessages = ref<ChatMessage[]>([])
|
||||
const irisBusy = ref(false)
|
||||
const irisFocus = ref('')
|
||||
|
||||
// Operations Feed
|
||||
const feedEntries = ref<FeedEntry[]>([])
|
||||
|
||||
// Open Tasks (mock only – no API endpoint)
|
||||
const openTasks = ref<OpenTask[]>([
|
||||
{ id: 't1', title: 'Agent Thinking Panel visualisieren', detail: 'Live-Animation der Denkprozesse im AgentModal', source: 'iris', createdAt: '22:30' },
|
||||
{ id: 't2', title: 'CI/CD Pipeline Monitoring Dashboard', detail: 'Echtzeit-Status der Gitea Actions im Dashboard', source: 'iris', createdAt: '21:15' },
|
||||
{ id: 't3', title: 'Dungeon System Dokumentation', detail: 'API-Doku für Room-Generation-Endpunkte schreiben', source: 'bao', createdAt: '20:00' },
|
||||
])
|
||||
|
||||
// Queue
|
||||
const queue = ref<QueueItem[]>([])
|
||||
|
||||
// Runtime
|
||||
const runtimeSeconds = ref(0)
|
||||
let runtimeInterval: ReturnType<typeof setInterval> | null = null
|
||||
|
||||
// ── Fetch Functions ──
|
||||
|
||||
async function fetchStatus(): Promise<void> {
|
||||
try {
|
||||
const res = await apiFetch('/api/dashboard/status')
|
||||
if (!res.ok) return
|
||||
const data: DashboardStatusResponse = await res.json()
|
||||
gatewayOk.value = data.gatewayOk
|
||||
irisStatus.value = data.irisStatus
|
||||
activeAgents.value = data.activeAgents
|
||||
pendingTasks.value = data.pendingTasks
|
||||
} catch {
|
||||
// API unreachable – keep current values
|
||||
}
|
||||
}
|
||||
|
||||
const formatRuntime = (seconds: number): string => {
|
||||
const m = Math.floor(seconds / 60)
|
||||
const s = seconds % 60
|
||||
return `${String(m).padStart(2, '0')}:${String(s).padStart(2, '0')}`
|
||||
async function fetchAgents(): Promise<void> {
|
||||
try {
|
||||
const res = await apiFetch('/api/dashboard/agents')
|
||||
if (!res.ok) return
|
||||
const data: DashboardAgentInfo[] = await res.json()
|
||||
agents.value = data.map(enrichAgent)
|
||||
} catch {
|
||||
// API unreachable – keep current values
|
||||
}
|
||||
}
|
||||
|
||||
const irisRuntime = computed(() => formatRuntime(runtimeSeconds.value))
|
||||
async function fetchOperations(): Promise<void> {
|
||||
try {
|
||||
const res = await apiFetch('/api/dashboard/operations?limit=20')
|
||||
if (!res.ok) return
|
||||
const data: DashboardOperationEntry[] = await res.json()
|
||||
feedEntries.value = data.map((entry) => ({
|
||||
time: entry.time,
|
||||
agent: entry.agent,
|
||||
action: entry.action,
|
||||
timestamp: entry.timestamp,
|
||||
}))
|
||||
} catch {
|
||||
// API unreachable – keep current values
|
||||
}
|
||||
}
|
||||
|
||||
// Agent runtimes (simulated)
|
||||
const agentStartTimes = reactive<Record<string, number>>({
|
||||
iris: now - 28800000,
|
||||
developer: now - 3600000,
|
||||
devops: now - 1800000,
|
||||
researcher: now - 2700000,
|
||||
reviewer: now - 900000,
|
||||
async function fetchChatMessages(): Promise<void> {
|
||||
try {
|
||||
const res = await apiFetch('/api/dashboard/chat/messages?limit=50')
|
||||
if (!res.ok) return
|
||||
const data: DashboardChatMessage[] = await res.json()
|
||||
chatMessages.value = data.map((msg, idx) => ({
|
||||
id: `msg-${idx}`,
|
||||
sender: msg.role === 'assistant' ? 'iris' : 'user',
|
||||
text: msg.content,
|
||||
timestamp: new Date(msg.timestamp).getTime(),
|
||||
}))
|
||||
} catch {
|
||||
// API unreachable – keep current values
|
||||
}
|
||||
}
|
||||
|
||||
async function fetchQueue(): Promise<void> {
|
||||
try {
|
||||
const res = await apiFetch('/api/dashboard/queue')
|
||||
if (!res.ok) return
|
||||
const data: DashboardQueueItem[] = await res.json()
|
||||
queue.value = data.map((item) => ({
|
||||
id: item.id,
|
||||
text: item.name,
|
||||
priority: (item.status === 'high' || item.status === 'medium' || item.status === 'low')
|
||||
? item.status as 'high' | 'medium' | 'low'
|
||||
: 'medium',
|
||||
waitTime: '--',
|
||||
}))
|
||||
} catch {
|
||||
// API unreachable – keep current values
|
||||
}
|
||||
}
|
||||
|
||||
// ── Chat Send ──
|
||||
|
||||
async function sendChatMessage(text: string): Promise<void> {
|
||||
if (!text.trim()) return
|
||||
|
||||
// Optimistic add
|
||||
chatMessages.value.push({
|
||||
id: `user-${Date.now()}`,
|
||||
sender: 'user',
|
||||
text: text.trim(),
|
||||
timestamp: Date.now(),
|
||||
})
|
||||
|
||||
const getAgentRuntime = (id: string): string => {
|
||||
const start = agentStartTimes[id]
|
||||
if (!start) return '00:00'
|
||||
const secs = Math.floor((now - start) / 1000)
|
||||
const m = Math.floor(secs / 60)
|
||||
const s = secs % 60
|
||||
return `${String(m).padStart(2, '0')}:${String(s).padStart(2, '0')}`
|
||||
}
|
||||
irisBusy.value = true
|
||||
|
||||
// Agents
|
||||
const agents = ref<AgentNodeData[]>([
|
||||
{
|
||||
id: 'iris',
|
||||
name: 'Iris',
|
||||
role: 'Chief of Staff',
|
||||
description: 'Koordiniert, delegiert, hält das Team tight. Die erste Anlaufstelle zwischen Boss und Maschine.',
|
||||
color: '#8b7cf6',
|
||||
icon: 'bot',
|
||||
currentTask: 'Orchestrating Nexus Dashboard redesign',
|
||||
goal: 'Complete Mission Control v3',
|
||||
progress: 85,
|
||||
workload: 55,
|
||||
active: true,
|
||||
runtimeSeconds: 28800,
|
||||
workingFeed: [
|
||||
{ time: '22:38', text: 'Analyzed user feedback on Dashboard' },
|
||||
{ time: '22:36', text: 'Delegated card redesign to Developer' },
|
||||
{ time: '22:34', text: 'Verifying full-width layout deployment' },
|
||||
{ time: '22:32', text: 'Reviewing AgentModal integration' },
|
||||
],
|
||||
thinkingStream: [
|
||||
{ time: '22:24', text: 'Analysing constraint: full-width layout' },
|
||||
{ time: '22:25', text: 'Removing max-width from global CSS' },
|
||||
{ time: '22:26', text: 'Verifying Dashboard grid reflow' },
|
||||
],
|
||||
},
|
||||
{
|
||||
id: 'developer',
|
||||
name: 'Developer',
|
||||
role: 'Backend & Frontend',
|
||||
description: 'Implements features across the stack with TypeScript, C#, and Vue.',
|
||||
color: '#3b82f6',
|
||||
icon: 'code',
|
||||
currentTask: 'Building Dungeon System API endpoints',
|
||||
goal: 'Complete Dungeon CRUD + room generation',
|
||||
progress: 62,
|
||||
workload: 65,
|
||||
active: true,
|
||||
runtimeSeconds: 3600,
|
||||
workingFeed: [
|
||||
{ time: '22:30', text: 'Created DungeonController' },
|
||||
{ time: '22:28', text: 'Defined dungeon schema' },
|
||||
{ time: '22:26', text: 'Implementing room generation algorithm' },
|
||||
{ time: '22:24', text: 'Writing unit tests for RoomFactory' },
|
||||
],
|
||||
thinkingStream: [
|
||||
{ time: '22:22', text: 'Parsing dungeon spec from Iris' },
|
||||
{ time: '22:23', text: 'Designing RoomFactory interface' },
|
||||
{ time: '22:24', text: 'Implementing corridor connection logic' },
|
||||
],
|
||||
},
|
||||
{
|
||||
id: 'devops',
|
||||
name: 'DevOps',
|
||||
role: 'Infrastructure & CI/CD',
|
||||
description: 'Manages Docker, deployment pipelines, and system reliability.',
|
||||
color: '#eab308',
|
||||
icon: 'server',
|
||||
currentTask: 'Optimizing Docker Compose caching',
|
||||
goal: 'Reduce build times by 40%',
|
||||
progress: 45,
|
||||
workload: 40,
|
||||
active: false,
|
||||
runtimeSeconds: 1800,
|
||||
workingFeed: [
|
||||
{ time: '22:20', text: 'Analyzed Docker layer cache' },
|
||||
{ time: '22:18', text: 'Optimized COPY order in Dockerfile' },
|
||||
{ time: '22:16', text: 'Added .dockerignore for node_modules' },
|
||||
{ time: '22:14', text: 'Testing incremental builds' },
|
||||
],
|
||||
thinkingStream: [
|
||||
{ time: '22:20', text: 'Checking build cache hit rates' },
|
||||
{ time: '22:21', text: 'Benchmarking multi-stage vs single-stage' },
|
||||
{ time: '22:22', text: 'Calculating potential speedup from caching' },
|
||||
],
|
||||
},
|
||||
{
|
||||
id: 'researcher',
|
||||
name: 'Researcher',
|
||||
role: 'Analysis & Documentation',
|
||||
description: 'Researches APIs, patterns, and best practices. Maintains docs.',
|
||||
color: '#22c55e',
|
||||
icon: 'search',
|
||||
currentTask: 'Analyzing WebSocket alternatives',
|
||||
goal: 'Recommend real-time communication strategy',
|
||||
progress: 30,
|
||||
workload: 25,
|
||||
active: true,
|
||||
runtimeSeconds: 2700,
|
||||
workingFeed: [
|
||||
{ time: '22:18', text: 'Evaluated WebSocket vs SSE vs WebRTC' },
|
||||
{ time: '22:17', text: 'Documented SignalR limitations' },
|
||||
{ time: '22:16', text: 'Prototyping WebSocket fallback' },
|
||||
],
|
||||
thinkingStream: [
|
||||
{ time: '22:18', text: 'Cross-referencing WebSocket latency benchmarks' },
|
||||
{ time: '22:19', text: 'Checking SSE browser support matrix' },
|
||||
{ time: '22:20', text: 'Drafting recommendation summary' },
|
||||
],
|
||||
},
|
||||
{
|
||||
id: 'reviewer',
|
||||
name: 'Reviewer',
|
||||
role: 'Code Quality & Testing',
|
||||
description: 'Reviews pull requests, enforces standards, runs test suites.',
|
||||
color: '#a855f7',
|
||||
icon: 'shield',
|
||||
currentTask: 'Reviewing Dungeon System PR',
|
||||
goal: 'Zero critical findings before merge',
|
||||
progress: 80,
|
||||
workload: 50,
|
||||
active: false,
|
||||
runtimeSeconds: 900,
|
||||
workingFeed: [
|
||||
{ time: '22:15', text: 'Reviewed DungeonController.cs' },
|
||||
{ time: '22:14', text: 'Found 3 minor style issues' },
|
||||
{ time: '22:13', text: 'Approved RoomValidator' },
|
||||
{ time: '22:12', text: 'Running integration tests' },
|
||||
],
|
||||
thinkingStream: [
|
||||
{ time: '22:15', text: 'Analyzing DungeonController PR diff' },
|
||||
{ time: '22:16', text: 'Checking RoomValidator edge cases' },
|
||||
{ time: '22:17', text: 'Verifying integration test coverage' },
|
||||
],
|
||||
},
|
||||
])
|
||||
try {
|
||||
const res = await apiFetch('/api/dashboard/chat/send', {
|
||||
method: 'POST',
|
||||
body: JSON.stringify({ message: text.trim() }),
|
||||
})
|
||||
const data: DashboardSendResponse = await res.json()
|
||||
|
||||
// Open Tasks
|
||||
const openTasks = ref<OpenTask[]>([
|
||||
{ id: 't1', title: 'Agent Thinking Panel visualisieren', detail: 'Live-Animation der Denkprozesse im AgentModal', source: 'iris', createdAt: '22:30' },
|
||||
{ id: 't2', title: 'CI/CD Pipeline Monitoring Dashboard', detail: 'Echtzeit-Status der Gitea Actions im Dashboard', source: 'iris', createdAt: '21:15' },
|
||||
{ id: 't3', title: 'Dungeon System Dokumentation', detail: 'API-Doku für Room-Generation-Endpunkte schreiben', source: 'bao', createdAt: '20:00' },
|
||||
])
|
||||
|
||||
// Feed
|
||||
const ts = (offset: number) => new Date(now + offset).toISOString()
|
||||
const feedEntries = ref<FeedEntry[]>([
|
||||
{ time: '22:50', agent: 'Developer', action: 'Created DungeonController endpoints', timestamp: ts(-120000) },
|
||||
{ time: '22:46', agent: 'DevOps', action: 'Optimized Docker COPY order for layer caching', timestamp: ts(-360000) },
|
||||
{ time: '22:42', agent: 'Iris', action: 'Delegated room generation to Developer with spec', timestamp: ts(-600000) },
|
||||
{ time: '22:35', agent: 'Researcher', action: 'Documented WebSocket vs SSE analysis results', timestamp: ts(-960000) },
|
||||
{ time: '22:28', agent: 'Reviewer', action: 'Approved RoomValidator PR with minor fixes', timestamp: ts(-1200000) },
|
||||
{ time: '22:18', agent: 'DevOps', action: 'Added .dockerignore for node_modules and build artifacts', timestamp: ts(-1500000) },
|
||||
{ time: '22:08', agent: 'Iris', action: 'Broke down Dungeon System tasks into sub-tasks', timestamp: ts(-1800000) },
|
||||
{ time: '21:55', agent: 'Developer', action: 'Defined dungeon schema models with validation', timestamp: ts(-2400000) },
|
||||
])
|
||||
|
||||
// Chat
|
||||
const chatMessages = ref<ChatMessage[]>([
|
||||
{ id: 'm1', sender: 'iris', text: 'Guten Abend, Bao. Ready to continue the Dungeon System?', timestamp: now - 600000 },
|
||||
{ id: 'm2', sender: 'user', text: "Yes, what's the status?", timestamp: now - 540000 },
|
||||
{ id: 'm3', sender: 'iris', text: "Developer is at 62% on room generation. Reviewer approved the schema. I'd recommend focusing on the room connection logic next.", timestamp: now - 480000 },
|
||||
])
|
||||
|
||||
const irisBusy = ref(true)
|
||||
const irisFocus = ref('Breaking down Dungeon System for DevOps and Developer')
|
||||
|
||||
// Queue
|
||||
const queue = ref<QueueItem[]>([
|
||||
{ id: 'q1', text: 'Deploy latest dashboard build to preview', priority: 'high', waitTime: '2 min' },
|
||||
{ id: 'q2', text: 'Review infrastructure cost analysis', priority: 'medium', waitTime: '8 min' },
|
||||
{ id: 'q3', text: 'Schedule B2 German lesson review', priority: 'low', waitTime: '15 min' },
|
||||
{ id: 'q4', text: 'Update project roadmap document', priority: 'medium', waitTime: '12 min' },
|
||||
])
|
||||
|
||||
function sendChat(text: string): void {
|
||||
if (!text.trim()) return
|
||||
if (data.ok && data.reply) {
|
||||
chatMessages.value.push({
|
||||
id: `iris-${Date.now()}`,
|
||||
sender: 'iris',
|
||||
text: data.reply,
|
||||
timestamp: Date.now(),
|
||||
})
|
||||
} else if (data.error) {
|
||||
chatMessages.value.push({
|
||||
id: `error-${Date.now()}`,
|
||||
sender: 'iris',
|
||||
text: `⚠️ ${data.error}`,
|
||||
timestamp: Date.now(),
|
||||
})
|
||||
}
|
||||
} catch {
|
||||
chatMessages.value.push({
|
||||
id: `user-${Date.now()}`,
|
||||
sender: 'user',
|
||||
text: text.trim(),
|
||||
id: `error-${Date.now()}`,
|
||||
sender: 'iris',
|
||||
text: '⚠️ Connection error. Please try again.',
|
||||
timestamp: Date.now(),
|
||||
})
|
||||
} finally {
|
||||
irisBusy.value = false
|
||||
irisFocus.value = text.trim()
|
||||
}
|
||||
}
|
||||
|
||||
function removeQueueItem(id: string): void {
|
||||
const idx = queue.value.findIndex(q => q.id === id)
|
||||
if (idx !== -1) queue.value.splice(idx, 1)
|
||||
}
|
||||
// ── Queue Operations ──
|
||||
|
||||
function moveQueueItem(fromIdx: number, toIdx: number): void {
|
||||
if (toIdx < 0 || toIdx >= queue.value.length) return
|
||||
const [item] = queue.value.splice(fromIdx, 1)
|
||||
queue.value.splice(toIdx, 0, item)
|
||||
}
|
||||
function removeQueueItem(id: string): void {
|
||||
const idx = queue.value.findIndex(q => q.id === id)
|
||||
if (idx !== -1) queue.value.splice(idx, 1)
|
||||
}
|
||||
|
||||
function changeQueuePriority(id: string, priority: QueueItem['priority']): void {
|
||||
const item = queue.value.find(q => q.id === id)
|
||||
if (item) item.priority = priority
|
||||
function moveQueueItem(fromIdx: number, toIdx: number): void {
|
||||
if (toIdx < 0 || toIdx >= queue.value.length) return
|
||||
const [item] = queue.value.splice(fromIdx, 1)
|
||||
queue.value.splice(toIdx, 0, item)
|
||||
}
|
||||
|
||||
function changeQueuePriority(id: string, priority: QueueItem['priority']): void {
|
||||
const item = queue.value.find(q => q.id === id)
|
||||
if (item) item.priority = priority
|
||||
}
|
||||
|
||||
// ── Runtime ──
|
||||
|
||||
function startRuntime(): void {
|
||||
const startTs = sessionStart
|
||||
runtimeSeconds.value = Math.floor((Date.now() - startTs) / 1000)
|
||||
runtimeInterval = setInterval(() => {
|
||||
runtimeSeconds.value = Math.floor((Date.now() - startTs) / 1000)
|
||||
}, 1000)
|
||||
}
|
||||
|
||||
function stopRuntime(): void {
|
||||
if (runtimeInterval) {
|
||||
clearInterval(runtimeInterval)
|
||||
runtimeInterval = null
|
||||
}
|
||||
}
|
||||
|
||||
const formatRuntime = (seconds: number): string => {
|
||||
const m = Math.floor(seconds / 60)
|
||||
const s = seconds % 60
|
||||
return `${String(m).padStart(2, '0')}:${String(s).padStart(2, '0')}`
|
||||
}
|
||||
|
||||
const irisRuntime = computed(() => formatRuntime(runtimeSeconds.value))
|
||||
|
||||
const getAgentRuntime = (_id: string): string => {
|
||||
// Could be extended to track per-agent runtimes from API
|
||||
return formatRuntime(runtimeSeconds.value)
|
||||
}
|
||||
|
||||
// ── Polling starten (nur einmal) ──
|
||||
|
||||
function startPolling(): void {
|
||||
if (cleanupRegistered) return
|
||||
cleanupRegistered = true
|
||||
|
||||
// Initial fetches
|
||||
fetchStatus()
|
||||
fetchAgents()
|
||||
fetchOperations()
|
||||
fetchChatMessages()
|
||||
fetchQueue()
|
||||
|
||||
// Polling intervals
|
||||
intervals.push(setInterval(fetchStatus, 5000))
|
||||
intervals.push(setInterval(fetchAgents, 10000))
|
||||
intervals.push(setInterval(fetchOperations, 10000))
|
||||
intervals.push(setInterval(fetchChatMessages, 3000))
|
||||
intervals.push(setInterval(fetchQueue, 10000))
|
||||
}
|
||||
|
||||
function stopPolling(): void {
|
||||
for (const interval of intervals) {
|
||||
clearInterval(interval)
|
||||
}
|
||||
intervals.length = 0
|
||||
cleanupRegistered = false
|
||||
}
|
||||
|
||||
// ── Composable Export ──
|
||||
|
||||
export function useDashboardData() {
|
||||
// Start polling on first call
|
||||
startPolling()
|
||||
|
||||
return {
|
||||
// State
|
||||
agents,
|
||||
openTasks,
|
||||
feedEntries,
|
||||
@@ -297,14 +452,29 @@ export function useDashboardData() {
|
||||
irisFocus,
|
||||
irisRuntime,
|
||||
queue,
|
||||
gatewayOk,
|
||||
irisStatus,
|
||||
pendingTasks,
|
||||
activeAgents,
|
||||
|
||||
// Runtime
|
||||
runtimeSeconds,
|
||||
getAgentRuntime,
|
||||
startRuntime,
|
||||
stopRuntime,
|
||||
formatRuntime,
|
||||
sendChat,
|
||||
|
||||
// Actions
|
||||
sendChatMessage,
|
||||
removeQueueItem,
|
||||
moveQueueItem,
|
||||
changeQueuePriority,
|
||||
|
||||
// Fetch (for manual refresh)
|
||||
fetchStatus,
|
||||
fetchAgents,
|
||||
fetchOperations,
|
||||
fetchChatMessages,
|
||||
fetchQueue,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,266 @@
|
||||
import { ref, computed, onMounted, onUnmounted, nextTick, type Ref } from 'vue'
|
||||
import type { AgentNodeData } from './useDashboardData'
|
||||
|
||||
export interface CardBox {
|
||||
left: number
|
||||
right: number
|
||||
top: number
|
||||
bottom: number
|
||||
cx: number
|
||||
cy: number
|
||||
width: number
|
||||
height: number
|
||||
}
|
||||
|
||||
export interface ConnectionPath {
|
||||
d: string
|
||||
length: number
|
||||
}
|
||||
|
||||
export function useTeamNetworkSvg(
|
||||
networkRef: Ref<HTMLElement | null>,
|
||||
agents: Ref<AgentNodeData[]>,
|
||||
heroId: Ref<string>,
|
||||
isActive: (id: string) => boolean,
|
||||
) {
|
||||
// ── Layout ──
|
||||
const cardPositions = ref<Record<string, CardBox>>({})
|
||||
const svgWidth = ref(0)
|
||||
const svgHeight = ref(0)
|
||||
|
||||
const childAgents = computed(() => agents.value.filter(a => a.id !== heroId.value))
|
||||
|
||||
function updatePositions() {
|
||||
const el = networkRef.value
|
||||
if (!el) return
|
||||
const rect = el.getBoundingClientRect()
|
||||
svgWidth.value = rect.width
|
||||
svgHeight.value = rect.height
|
||||
|
||||
const cards = el.querySelectorAll('[data-agent-id]')
|
||||
const positions: Record<string, CardBox> = {}
|
||||
cards.forEach(card => {
|
||||
const id = card.getAttribute('data-agent-id')
|
||||
if (!id) return
|
||||
const r = card.getBoundingClientRect()
|
||||
positions[id] = {
|
||||
left: r.left - rect.left,
|
||||
right: r.left + r.width - rect.left,
|
||||
top: r.top - rect.top,
|
||||
bottom: r.top + r.height - rect.top,
|
||||
cx: r.left + r.width / 2 - rect.left,
|
||||
cy: r.top + r.height / 2 - rect.top,
|
||||
width: r.width,
|
||||
height: r.height,
|
||||
}
|
||||
})
|
||||
cardPositions.value = positions
|
||||
}
|
||||
|
||||
// ── Connection paths ──
|
||||
const connectionPaths = computed<Record<string, ConnectionPath | null>>(() => {
|
||||
const result: Record<string, ConnectionPath | null> = {}
|
||||
const pos = cardPositions.value
|
||||
const iris = pos[heroId.value]
|
||||
if (!iris) return result
|
||||
|
||||
const children = childAgents.value
|
||||
const total = children.length
|
||||
if (total === 0) return result
|
||||
|
||||
for (let idx = 0; idx < total; idx++) {
|
||||
const agent = children[idx]
|
||||
const agentPos = pos[agent.id]
|
||||
if (!agentPos) {
|
||||
result[agent.id] = null
|
||||
continue
|
||||
}
|
||||
|
||||
// Spread start points across Iris bottom edge (30%-70% range)
|
||||
const t = total > 1 ? idx / (total - 1) : 0.5
|
||||
const startX = iris.left + iris.width * (0.38 + t * 0.24)
|
||||
const startY = iris.bottom - 1
|
||||
|
||||
// Determine column: left or right of Iris center
|
||||
const isLeftColumn = agentPos.cx < iris.cx
|
||||
|
||||
// End point: approach from side, 8px before card edge
|
||||
const endX = isLeftColumn ? agentPos.right - 8 : agentPos.left + 8
|
||||
const endY = agentPos.cy
|
||||
|
||||
// Bézier control points
|
||||
const cp1x = startX
|
||||
const cp1y = startY + 70
|
||||
const cp2x = endX + (isLeftColumn ? 35 : -35)
|
||||
const cp2y = endY - 10
|
||||
|
||||
const d = `M ${startX} ${startY} C ${cp1x} ${cp1y}, ${cp2x} ${cp2y}, ${endX} ${endY}`
|
||||
result[agent.id] = { d, length: 0 }
|
||||
}
|
||||
return result
|
||||
})
|
||||
|
||||
// ── Path refs (template ref functions) ──
|
||||
const pathElements = ref<Record<string, SVGPathElement | null>>({})
|
||||
const pulseElements = ref<Record<string, SVGPathElement | null>>({})
|
||||
const pulseElements2 = ref<Record<string, SVGPathElement | null>>({})
|
||||
const pulseOffsets = ref<Record<string, number>>({})
|
||||
const pulseOffsets2 = ref<Record<string, number>>({})
|
||||
|
||||
function storePathRef(id: string) {
|
||||
return (el: SVGPathElement | null) => {
|
||||
pathElements.value[id] = el
|
||||
}
|
||||
}
|
||||
|
||||
function storePulseRef(id: string) {
|
||||
return (el: SVGPathElement | null) => {
|
||||
pulseElements.value[id] = el
|
||||
}
|
||||
}
|
||||
|
||||
function storePulseRef2(id: string) {
|
||||
return (el: SVGPathElement | null) => {
|
||||
pulseElements2.value[id] = el
|
||||
}
|
||||
}
|
||||
|
||||
// ── Pulse animation ──
|
||||
let animFrameId: number | null = null
|
||||
let lastAnimTime = 0
|
||||
const speeds: Record<string, number> = {}
|
||||
|
||||
function refreshPathLengths() {
|
||||
for (const id of childAgents.value.map(a => a.id)) {
|
||||
const pathEl = pathElements.value[id]
|
||||
const pulseEl = pulseElements.value[id]
|
||||
const p = connectionPaths.value[id]
|
||||
if (pathEl && p) {
|
||||
p.length = pathEl.getTotalLength()
|
||||
}
|
||||
if (pulseEl && p && p.length > 0) {
|
||||
if (pulseOffsets.value[id] === undefined) {
|
||||
pulseOffsets.value[id] = 0
|
||||
}
|
||||
pulseEl.setAttribute('stroke-dasharray', `40 ${p.length}`)
|
||||
pulseEl.setAttribute('stroke-dashoffset', String(-pulseOffsets.value[id]))
|
||||
}
|
||||
const pulseEl2 = pulseElements2.value[id]
|
||||
if (pulseEl2 && p && p.length > 0) {
|
||||
if (pulseOffsets2.value[id] === undefined) {
|
||||
pulseOffsets2.value[id] = 0
|
||||
}
|
||||
pulseEl2.setAttribute('stroke-dasharray', `40 ${p.length}`)
|
||||
pulseEl2.setAttribute('stroke-dashoffset', String(-pulseOffsets2.value[id]))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function startPulseAnimation() {
|
||||
refreshPathLengths()
|
||||
|
||||
for (const id of childAgents.value.map(a => a.id)) {
|
||||
const p = connectionPaths.value[id]
|
||||
if (p && p.length > 0) {
|
||||
speeds[id] = p.length / 3000
|
||||
if (pulseOffsets.value[id] === undefined) pulseOffsets.value[id] = 0
|
||||
if (pulseOffsets2.value[id] === undefined) pulseOffsets2.value[id] = 0
|
||||
}
|
||||
}
|
||||
|
||||
lastAnimTime = performance.now()
|
||||
|
||||
function tick(now: number) {
|
||||
const dt = now - lastAnimTime
|
||||
lastAnimTime = now
|
||||
|
||||
const children = childAgents.value
|
||||
for (let i = 0; i < children.length; i++) {
|
||||
const id = children[i].id
|
||||
const pathEl = pathElements.value[id]
|
||||
const pulseEl = pulseElements.value[id]
|
||||
const pulseEl2 = pulseElements2.value[id]
|
||||
const p = connectionPaths.value[id]
|
||||
if (!pathEl || !pulseEl || !p) continue
|
||||
|
||||
const len = p.length
|
||||
if (len <= 0) continue
|
||||
|
||||
const speed = speeds[id] ?? len / 3000
|
||||
const cycleLen = len + 40
|
||||
|
||||
// Pulse 1
|
||||
const currentOffset = pulseOffsets.value[id] ?? 0
|
||||
const newOffset = currentOffset + speed * dt
|
||||
pulseOffsets.value[id] = newOffset > cycleLen ? newOffset % cycleLen : newOffset
|
||||
pulseEl.setAttribute('stroke-dashoffset', String(-pulseOffsets.value[id]))
|
||||
|
||||
// Pulse 2 (offset by half cycle)
|
||||
if (pulseEl2) {
|
||||
const offset2 = (pulseOffsets.value[id] + cycleLen / 2) % cycleLen
|
||||
pulseOffsets2.value[id] = offset2
|
||||
pulseEl2.setAttribute('stroke-dashoffset', String(-offset2))
|
||||
}
|
||||
}
|
||||
|
||||
animFrameId = requestAnimationFrame(tick)
|
||||
}
|
||||
|
||||
animFrameId = requestAnimationFrame(tick)
|
||||
}
|
||||
|
||||
function stopPulseAnimation() {
|
||||
if (animFrameId !== null) {
|
||||
cancelAnimationFrame(animFrameId)
|
||||
animFrameId = null
|
||||
}
|
||||
}
|
||||
|
||||
// ── Lifecycle ──
|
||||
let resizeObserver: ResizeObserver | null = null
|
||||
|
||||
onMounted(async () => {
|
||||
await nextTick()
|
||||
updatePositions()
|
||||
|
||||
// Wait for SVG to render so path refs are populated
|
||||
await nextTick()
|
||||
updatePositions()
|
||||
refreshPathLengths()
|
||||
|
||||
startPulseAnimation()
|
||||
|
||||
resizeObserver = new ResizeObserver(() => {
|
||||
updatePositions()
|
||||
requestAnimationFrame(() => {
|
||||
refreshPathLengths()
|
||||
})
|
||||
})
|
||||
if (networkRef.value) {
|
||||
resizeObserver.observe(networkRef.value)
|
||||
}
|
||||
})
|
||||
|
||||
onUnmounted(() => {
|
||||
stopPulseAnimation()
|
||||
resizeObserver?.disconnect()
|
||||
})
|
||||
|
||||
return {
|
||||
cardPositions,
|
||||
svgWidth,
|
||||
svgHeight,
|
||||
childAgents,
|
||||
connectionPaths,
|
||||
pathElements,
|
||||
pulseElements,
|
||||
pulseElements2,
|
||||
pulseOffsets,
|
||||
pulseOffsets2,
|
||||
storePathRef,
|
||||
storePulseRef,
|
||||
storePulseRef2,
|
||||
updatePositions,
|
||||
refreshPathLengths,
|
||||
}
|
||||
}
|
||||
@@ -1,19 +1,19 @@
|
||||
<script setup lang="ts">
|
||||
import { onMounted, onUnmounted, ref } from 'vue'
|
||||
import TaskCard from '../components/dashboard/MissionCard.vue'
|
||||
import TaskCard from '../components/dashboard/TaskCard.vue'
|
||||
import OperationsFeed from '../components/dashboard/OperationsFeed.vue'
|
||||
import TeamNetwork from '../components/dashboard/TeamNetwork.vue'
|
||||
import ChatPanel from '../components/dashboard/ChatPanel.vue'
|
||||
import QueuePanel from '../components/dashboard/QueuePanel.vue'
|
||||
import AgentModal from '../components/dashboard/AgentModal.vue'
|
||||
import { useDashboardData } from '../composables/useDashboardData'
|
||||
import type { AgentNodeData } from '../../composables/useDashboardData'
|
||||
import type { AgentNodeData } from '../composables/useDashboardData'
|
||||
|
||||
const {
|
||||
agents, openTasks, feedEntries, chatMessages,
|
||||
irisBusy, irisFocus, irisRuntime, queue,
|
||||
irisBusy, irisFocus, queue,
|
||||
getAgentRuntime, startRuntime, stopRuntime,
|
||||
sendChat, removeQueueItem, moveQueueItem, changeQueuePriority,
|
||||
sendChatMessage, removeQueueItem, moveQueueItem, changeQueuePriority,
|
||||
} = useDashboardData()
|
||||
|
||||
const selectedAgent = ref<AgentNodeData | null>(null)
|
||||
@@ -26,8 +26,6 @@ function onAgentSelect(id: string) {
|
||||
onMounted(startRuntime)
|
||||
onUnmounted(stopRuntime)
|
||||
|
||||
function onChatSend(text: string): void { sendChat(text) }
|
||||
|
||||
function onQueueMoveUp(id: string): void {
|
||||
const idx = queue.value.findIndex(q => q.id === id)
|
||||
if (idx > 0) moveQueueItem(idx, idx - 1)
|
||||
@@ -48,7 +46,7 @@ function onQueueExecuteNow(id: string): void {
|
||||
<div class="dashboard">
|
||||
<div class="col-left">
|
||||
<section class="missions-section">
|
||||
<TaskCard :tasks="openTasks" @new-task="console.log('New task requested')" />
|
||||
<TaskCard :tasks="openTasks" @new-task="console.log('New task requested')" @go-board="console.log('Go to Task Board')" />
|
||||
</section>
|
||||
<OperationsFeed :entries="feedEntries" />
|
||||
</div>
|
||||
@@ -68,9 +66,6 @@ function onQueueExecuteNow(id: string): void {
|
||||
<TeamNetwork
|
||||
hero-id="iris"
|
||||
:agents="agents"
|
||||
:iris-runtime="irisRuntime"
|
||||
:get-agent-runtime="getAgentRuntime"
|
||||
:iris-focus="irisFocus"
|
||||
@select="onAgentSelect"
|
||||
/>
|
||||
|
||||
@@ -91,7 +86,7 @@ function onQueueExecuteNow(id: string): void {
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-right">
|
||||
<ChatPanel :messages="chatMessages" :iris-busy="irisBusy" :iris-focus="irisFocus" @send="onChatSend" />
|
||||
<ChatPanel :messages="chatMessages" :iris-busy="irisBusy" :iris-focus="irisFocus" />
|
||||
<QueuePanel :items="queue" @remove="removeQueueItem" @move-up="onQueueMoveUp" @move-down="onQueueMoveDown" @change-priority="changeQueuePriority" @execute-now="onQueueExecuteNow" />
|
||||
</div>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user