feat(orchestration): multi-agent communication, unified agents, env passthrough
- btmsg: admin role (tier 0), channel messaging (create/list/send/history), admin global feed, mark-read conversations - Rust btmsg module: admin bypass, channels, feed, 8 new Tauri commands - CommsTab: sidebar chat interface with activity feed, DMs, channels (Ctrl+M) - Agent unification: Tier 1 agents rendered as ProjectBoxes via agentToProject() converter, getAllWorkItems() combines agents + projects in ProjectGrid - GroupAgentsPanel: click-to-navigate agents to their ProjectBox - Agent system prompts: generateAgentPrompt() builds comprehensive introductory context (role, environment, team, btmsg/bttask docs, workflow instructions) - AgentSession passes group context to prompt generator via $derived.by() - BTMSG_AGENT_ID env var passthrough: extra_env field flows through full chain (agent-bridge → Rust AgentQueryOptions → NDJSON → sidecar runners → cleanEnv) - workspace store: updateAgent() for Tier 1 agent config persistence
This commit is contained in:
parent
1331d094b3
commit
a158ed9544
19 changed files with 1918 additions and 39 deletions
|
|
@ -54,10 +54,14 @@
|
|||
provider?: ProviderId;
|
||||
capabilities?: ProviderCapabilities;
|
||||
useWorktrees?: boolean;
|
||||
/** Prepended to system_prompt for agent role instructions */
|
||||
agentSystemPrompt?: string;
|
||||
/** Extra env vars injected into agent process (e.g. BTMSG_AGENT_ID) */
|
||||
extraEnv?: Record<string, string>;
|
||||
onExit?: () => void;
|
||||
}
|
||||
|
||||
let { sessionId, projectId, prompt: initialPrompt = '', cwd: initialCwd, profile: profileName, provider: providerId = 'claude', capabilities = DEFAULT_CAPABILITIES, useWorktrees = false, onExit }: Props = $props();
|
||||
let { sessionId, projectId, prompt: initialPrompt = '', cwd: initialCwd, profile: profileName, provider: providerId = 'claude', capabilities = DEFAULT_CAPABILITIES, useWorktrees = false, agentSystemPrompt, extraEnv, onExit }: Props = $props();
|
||||
|
||||
let session = $derived(getAgentSession(sessionId));
|
||||
let inputPrompt = $state(initialPrompt);
|
||||
|
|
@ -165,15 +169,18 @@
|
|||
|
||||
const profile = profileName ? profiles.find(p => p.name === profileName) : undefined;
|
||||
|
||||
// Build system prompt with anchor re-injection if available
|
||||
let systemPrompt: string | undefined;
|
||||
// Build system prompt: agent role instructions + anchor re-injection
|
||||
const promptParts: string[] = [];
|
||||
if (agentSystemPrompt) {
|
||||
promptParts.push(agentSystemPrompt);
|
||||
}
|
||||
if (projectId) {
|
||||
const anchors = getInjectableAnchors(projectId);
|
||||
if (anchors.length > 0) {
|
||||
// Anchors store pre-serialized content — join them directly
|
||||
systemPrompt = anchors.map(a => a.content).join('\n');
|
||||
promptParts.push(anchors.map(a => a.content).join('\n'));
|
||||
}
|
||||
}
|
||||
const systemPrompt = promptParts.length > 0 ? promptParts.join('\n\n') : undefined;
|
||||
|
||||
await queryAgent({
|
||||
provider: providerId,
|
||||
|
|
@ -186,6 +193,7 @@
|
|||
claude_config_dir: profile?.config_dir,
|
||||
system_prompt: systemPrompt,
|
||||
worktree_name: useWorktrees ? sessionId : undefined,
|
||||
extra_env: extraEnv,
|
||||
});
|
||||
inputPrompt = '';
|
||||
if (promptRef) {
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
<script lang="ts">
|
||||
import type { ProjectConfig } from '../../types/groups';
|
||||
import type { ProjectConfig, GroupAgentRole } from '../../types/groups';
|
||||
import { generateAgentPrompt } from '../../utils/agent-prompts';
|
||||
import { getActiveGroup } from '../../stores/workspace.svelte';
|
||||
import {
|
||||
loadProjectAgentState,
|
||||
loadAgentMessages,
|
||||
|
|
@ -31,6 +33,23 @@
|
|||
|
||||
let providerId = $derived(project.provider ?? getDefaultProviderId());
|
||||
let providerMeta = $derived(getProvider(providerId));
|
||||
let group = $derived(getActiveGroup());
|
||||
let agentPrompt = $derived.by(() => {
|
||||
if (!project.isAgent || !project.agentRole || !group) return undefined;
|
||||
return generateAgentPrompt({
|
||||
role: project.agentRole as GroupAgentRole,
|
||||
agentId: project.id,
|
||||
agentName: project.name,
|
||||
group,
|
||||
customPrompt: project.systemPrompt,
|
||||
});
|
||||
});
|
||||
|
||||
// Inject BTMSG_AGENT_ID for agent projects so they can use btmsg/bttask CLIs
|
||||
let agentEnv = $derived.by(() => {
|
||||
if (!project.isAgent) return undefined;
|
||||
return { BTMSG_AGENT_ID: project.id };
|
||||
});
|
||||
|
||||
let sessionId = $state(SessionId(crypto.randomUUID()));
|
||||
let lastState = $state<ProjectAgentState | null>(null);
|
||||
|
|
@ -132,6 +151,8 @@
|
|||
provider={providerId}
|
||||
capabilities={providerMeta?.capabilities}
|
||||
useWorktrees={project.useWorktrees ?? false}
|
||||
agentSystemPrompt={agentPrompt}
|
||||
extraEnv={agentEnv}
|
||||
onExit={handleNewSession}
|
||||
/>
|
||||
{/if}
|
||||
|
|
|
|||
676
v2/src/lib/components/Workspace/CommsTab.svelte
Normal file
676
v2/src/lib/components/Workspace/CommsTab.svelte
Normal file
|
|
@ -0,0 +1,676 @@
|
|||
<script lang="ts">
|
||||
import { onMount, onDestroy } from 'svelte';
|
||||
import { getActiveGroup } from '../../stores/workspace.svelte';
|
||||
import {
|
||||
type BtmsgAgent,
|
||||
type BtmsgMessage,
|
||||
type BtmsgFeedMessage,
|
||||
type BtmsgChannel,
|
||||
type BtmsgChannelMessage,
|
||||
getGroupAgents,
|
||||
getHistory,
|
||||
getAllFeed,
|
||||
sendMessage,
|
||||
markRead,
|
||||
ensureAdmin,
|
||||
getChannels,
|
||||
getChannelMessages,
|
||||
sendChannelMessage,
|
||||
createChannel,
|
||||
} from '../../adapters/btmsg-bridge';
|
||||
|
||||
const ADMIN_ID = 'admin';
|
||||
const ROLE_ICONS: Record<string, string> = {
|
||||
admin: '👤',
|
||||
manager: '🎯',
|
||||
architect: '🏗',
|
||||
tester: '🧪',
|
||||
reviewer: '🔍',
|
||||
project: '📦',
|
||||
};
|
||||
|
||||
type ViewMode =
|
||||
| { type: 'feed' }
|
||||
| { type: 'dm'; agentId: string; agentName: string }
|
||||
| { type: 'channel'; channelId: string; channelName: string };
|
||||
|
||||
let agents = $state<BtmsgAgent[]>([]);
|
||||
let channels = $state<BtmsgChannel[]>([]);
|
||||
let currentView = $state<ViewMode>({ type: 'feed' });
|
||||
let feedMessages = $state<BtmsgFeedMessage[]>([]);
|
||||
let dmMessages = $state<BtmsgMessage[]>([]);
|
||||
let channelMessages = $state<BtmsgChannelMessage[]>([]);
|
||||
let messageInput = $state('');
|
||||
let pollTimer: ReturnType<typeof setInterval> | null = null;
|
||||
let messagesEl: HTMLElement | undefined = $state();
|
||||
let newChannelName = $state('');
|
||||
let showNewChannel = $state(false);
|
||||
|
||||
let group = $derived(getActiveGroup());
|
||||
let groupId = $derived(group?.id ?? '');
|
||||
|
||||
async function loadData() {
|
||||
if (!groupId) return;
|
||||
try {
|
||||
agents = await getGroupAgents(groupId);
|
||||
channels = await getChannels(groupId);
|
||||
} catch {
|
||||
// btmsg.db might not exist
|
||||
}
|
||||
}
|
||||
|
||||
async function loadMessages() {
|
||||
if (!groupId) return;
|
||||
try {
|
||||
if (currentView.type === 'feed') {
|
||||
feedMessages = await getAllFeed(groupId, 100);
|
||||
} else if (currentView.type === 'dm') {
|
||||
dmMessages = await getHistory(ADMIN_ID, currentView.agentId, 100);
|
||||
await markRead(ADMIN_ID, currentView.agentId);
|
||||
} else if (currentView.type === 'channel') {
|
||||
channelMessages = await getChannelMessages(currentView.channelId, 100);
|
||||
}
|
||||
} catch {
|
||||
// silently fail
|
||||
}
|
||||
}
|
||||
|
||||
function scrollToBottom() {
|
||||
if (messagesEl) {
|
||||
requestAnimationFrame(() => {
|
||||
if (messagesEl) messagesEl.scrollTop = messagesEl.scrollHeight;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
$effect(() => {
|
||||
void currentView;
|
||||
loadMessages().then(scrollToBottom);
|
||||
});
|
||||
|
||||
$effect(() => {
|
||||
void groupId;
|
||||
if (groupId) {
|
||||
ensureAdmin(groupId).catch(() => {});
|
||||
loadData();
|
||||
}
|
||||
});
|
||||
|
||||
onMount(() => {
|
||||
pollTimer = setInterval(() => {
|
||||
loadData();
|
||||
loadMessages();
|
||||
}, 3000);
|
||||
});
|
||||
|
||||
onDestroy(() => {
|
||||
if (pollTimer) clearInterval(pollTimer);
|
||||
});
|
||||
|
||||
function selectFeed() {
|
||||
currentView = { type: 'feed' };
|
||||
}
|
||||
|
||||
function selectDm(agent: BtmsgAgent) {
|
||||
currentView = { type: 'dm', agentId: agent.id, agentName: agent.name };
|
||||
}
|
||||
|
||||
function selectChannel(channel: BtmsgChannel) {
|
||||
currentView = { type: 'channel', channelId: channel.id, channelName: channel.name };
|
||||
}
|
||||
|
||||
async function handleSend() {
|
||||
const text = messageInput.trim();
|
||||
if (!text) return;
|
||||
|
||||
try {
|
||||
if (currentView.type === 'dm') {
|
||||
await sendMessage(ADMIN_ID, currentView.agentId, text);
|
||||
} else if (currentView.type === 'channel') {
|
||||
await sendChannelMessage(currentView.channelId, ADMIN_ID, text);
|
||||
} else {
|
||||
return; // Can't send in feed view
|
||||
}
|
||||
messageInput = '';
|
||||
await loadMessages();
|
||||
scrollToBottom();
|
||||
} catch (e) {
|
||||
console.warn('Failed to send message:', e);
|
||||
}
|
||||
}
|
||||
|
||||
function handleKeydown(e: KeyboardEvent) {
|
||||
if (e.key === 'Enter' && !e.shiftKey) {
|
||||
e.preventDefault();
|
||||
handleSend();
|
||||
}
|
||||
}
|
||||
|
||||
async function handleCreateChannel() {
|
||||
const name = newChannelName.trim();
|
||||
if (!name || !groupId) return;
|
||||
try {
|
||||
await createChannel(name, groupId, ADMIN_ID);
|
||||
newChannelName = '';
|
||||
showNewChannel = false;
|
||||
await loadData();
|
||||
} catch (e) {
|
||||
console.warn('Failed to create channel:', e);
|
||||
}
|
||||
}
|
||||
|
||||
function formatTime(ts: string): string {
|
||||
try {
|
||||
const d = new Date(ts + 'Z');
|
||||
return d.toLocaleTimeString('pl-PL', { hour: '2-digit', minute: '2-digit' });
|
||||
} catch {
|
||||
return ts.slice(11, 16);
|
||||
}
|
||||
}
|
||||
|
||||
function getAgentIcon(role: string): string {
|
||||
return ROLE_ICONS[role] ?? '🤖';
|
||||
}
|
||||
|
||||
function isActive(view: ViewMode): boolean {
|
||||
if (currentView.type !== view.type) return false;
|
||||
if (view.type === 'dm' && currentView.type === 'dm') return view.agentId === currentView.agentId;
|
||||
if (view.type === 'channel' && currentView.type === 'channel') return view.channelId === currentView.channelId;
|
||||
return true;
|
||||
}
|
||||
</script>
|
||||
|
||||
<div class="comms-tab">
|
||||
<!-- Conversation list -->
|
||||
<div class="conv-list">
|
||||
<div class="conv-header">
|
||||
<span class="conv-header-title">Messages</span>
|
||||
</div>
|
||||
|
||||
<!-- Activity Feed -->
|
||||
<button
|
||||
class="conv-item"
|
||||
class:active={currentView.type === 'feed'}
|
||||
onclick={selectFeed}
|
||||
>
|
||||
<span class="conv-icon">📡</span>
|
||||
<span class="conv-name">Activity Feed</span>
|
||||
</button>
|
||||
|
||||
<!-- Channels -->
|
||||
{#if channels.length > 0 || showNewChannel}
|
||||
<div class="conv-section-title">
|
||||
<span>Channels</span>
|
||||
<button class="add-btn" onclick={() => showNewChannel = !showNewChannel} title="New channel">+</button>
|
||||
</div>
|
||||
{#each channels as channel (channel.id)}
|
||||
<button
|
||||
class="conv-item"
|
||||
class:active={currentView.type === 'channel' && currentView.channelId === channel.id}
|
||||
onclick={() => selectChannel(channel)}
|
||||
>
|
||||
<span class="conv-icon">#</span>
|
||||
<span class="conv-name">{channel.name}</span>
|
||||
<span class="conv-meta">{channel.memberCount}</span>
|
||||
</button>
|
||||
{/each}
|
||||
{#if showNewChannel}
|
||||
<div class="new-channel">
|
||||
<input
|
||||
type="text"
|
||||
placeholder="channel name"
|
||||
bind:value={newChannelName}
|
||||
onkeydown={(e) => { if (e.key === 'Enter') handleCreateChannel(); }}
|
||||
/>
|
||||
<button onclick={handleCreateChannel}>OK</button>
|
||||
</div>
|
||||
{/if}
|
||||
{:else}
|
||||
<div class="conv-section-title">
|
||||
<span>Channels</span>
|
||||
<button class="add-btn" onclick={() => showNewChannel = !showNewChannel} title="New channel">+</button>
|
||||
</div>
|
||||
{#if showNewChannel}
|
||||
<div class="new-channel">
|
||||
<input
|
||||
type="text"
|
||||
placeholder="channel name"
|
||||
bind:value={newChannelName}
|
||||
onkeydown={(e) => { if (e.key === 'Enter') handleCreateChannel(); }}
|
||||
/>
|
||||
<button onclick={handleCreateChannel}>OK</button>
|
||||
</div>
|
||||
{/if}
|
||||
{/if}
|
||||
|
||||
<!-- Direct Messages -->
|
||||
<div class="conv-section-title">
|
||||
<span>Direct Messages</span>
|
||||
</div>
|
||||
{#each agents.filter(a => a.id !== ADMIN_ID) as agent (agent.id)}
|
||||
{@const statusClass = agent.status === 'active' ? 'active' : agent.status === 'sleeping' ? 'sleeping' : 'stopped'}
|
||||
<button
|
||||
class="conv-item"
|
||||
class:active={currentView.type === 'dm' && currentView.agentId === agent.id}
|
||||
onclick={() => selectDm(agent)}
|
||||
>
|
||||
<span class="conv-icon">{getAgentIcon(agent.role)}</span>
|
||||
<span class="conv-name">{agent.name}</span>
|
||||
<span class="status-dot {statusClass}"></span>
|
||||
{#if agent.unread_count > 0}
|
||||
<span class="unread-badge">{agent.unread_count}</span>
|
||||
{/if}
|
||||
</button>
|
||||
{/each}
|
||||
</div>
|
||||
|
||||
<!-- Chat area -->
|
||||
<div class="chat-area">
|
||||
<div class="chat-header">
|
||||
{#if currentView.type === 'feed'}
|
||||
<span class="chat-title">📡 Activity Feed</span>
|
||||
<span class="chat-subtitle">All agent communication</span>
|
||||
{:else if currentView.type === 'dm'}
|
||||
<span class="chat-title">DM with {currentView.agentName}</span>
|
||||
{:else if currentView.type === 'channel'}
|
||||
<span class="chat-title"># {currentView.channelName}</span>
|
||||
{/if}
|
||||
</div>
|
||||
|
||||
<div class="chat-messages" bind:this={messagesEl}>
|
||||
{#if currentView.type === 'feed'}
|
||||
{#if feedMessages.length === 0}
|
||||
<div class="empty-state">No messages yet. Agents haven't started communicating.</div>
|
||||
{:else}
|
||||
{#each [...feedMessages].reverse() as msg (msg.id)}
|
||||
<div class="message feed-message">
|
||||
<div class="msg-header">
|
||||
<span class="msg-icon">{getAgentIcon(msg.senderRole)}</span>
|
||||
<span class="msg-sender">{msg.senderName}</span>
|
||||
<span class="msg-arrow">→</span>
|
||||
<span class="msg-recipient">{msg.recipientName}</span>
|
||||
<span class="msg-time">{formatTime(msg.createdAt)}</span>
|
||||
</div>
|
||||
<div class="msg-content">{msg.content}</div>
|
||||
</div>
|
||||
{/each}
|
||||
{/if}
|
||||
|
||||
{:else if currentView.type === 'dm'}
|
||||
{#if dmMessages.length === 0}
|
||||
<div class="empty-state">No messages yet. Start the conversation!</div>
|
||||
{:else}
|
||||
{#each dmMessages as msg (msg.id)}
|
||||
{@const isMe = msg.from_agent === ADMIN_ID}
|
||||
<div class="message" class:own={isMe}>
|
||||
<div class="msg-header">
|
||||
<span class="msg-sender">{isMe ? 'You' : (msg.sender_name ?? msg.from_agent)}</span>
|
||||
<span class="msg-time">{formatTime(msg.created_at)}</span>
|
||||
</div>
|
||||
<div class="msg-content">{msg.content}</div>
|
||||
</div>
|
||||
{/each}
|
||||
{/if}
|
||||
|
||||
{:else if currentView.type === 'channel'}
|
||||
{#if channelMessages.length === 0}
|
||||
<div class="empty-state">No messages in this channel yet.</div>
|
||||
{:else}
|
||||
{#each channelMessages as msg (msg.id)}
|
||||
{@const isMe = msg.fromAgent === ADMIN_ID}
|
||||
<div class="message" class:own={isMe}>
|
||||
<div class="msg-header">
|
||||
<span class="msg-icon">{getAgentIcon(msg.senderRole)}</span>
|
||||
<span class="msg-sender">{isMe ? 'You' : msg.senderName}</span>
|
||||
<span class="msg-time">{formatTime(msg.createdAt)}</span>
|
||||
</div>
|
||||
<div class="msg-content">{msg.content}</div>
|
||||
</div>
|
||||
{/each}
|
||||
{/if}
|
||||
{/if}
|
||||
</div>
|
||||
|
||||
{#if currentView.type !== 'feed'}
|
||||
<div class="chat-input">
|
||||
<textarea
|
||||
placeholder={currentView.type === 'dm' ? `Message ${currentView.agentName}...` : `Message #${currentView.channelName}...`}
|
||||
bind:value={messageInput}
|
||||
onkeydown={handleKeydown}
|
||||
rows="1"
|
||||
></textarea>
|
||||
<button class="send-btn" onclick={handleSend} disabled={!messageInput.trim()}>
|
||||
<svg width="16" height="16" viewBox="0 0 24 24" fill="none">
|
||||
<path d="M22 2L11 13M22 2l-7 20-4-9-9-4 20-7z" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
|
||||
</svg>
|
||||
</button>
|
||||
</div>
|
||||
{/if}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<style>
|
||||
.comms-tab {
|
||||
display: flex;
|
||||
min-width: 36rem;
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
/* Conversation list */
|
||||
.conv-list {
|
||||
width: 13rem;
|
||||
flex-shrink: 0;
|
||||
border-right: 1px solid var(--ctp-surface0);
|
||||
overflow-y: auto;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.conv-header {
|
||||
padding: 0.5rem 0.75rem;
|
||||
border-bottom: 1px solid var(--ctp-surface0);
|
||||
}
|
||||
|
||||
.conv-header-title {
|
||||
font-size: 0.7rem;
|
||||
font-weight: 700;
|
||||
text-transform: uppercase;
|
||||
letter-spacing: 0.05em;
|
||||
color: var(--ctp-subtext0);
|
||||
}
|
||||
|
||||
.conv-section-title {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
padding: 0.5rem 0.75rem 0.25rem;
|
||||
font-size: 0.6rem;
|
||||
font-weight: 700;
|
||||
text-transform: uppercase;
|
||||
letter-spacing: 0.05em;
|
||||
color: var(--ctp-overlay0);
|
||||
}
|
||||
|
||||
.add-btn {
|
||||
background: transparent;
|
||||
border: none;
|
||||
color: var(--ctp-overlay0);
|
||||
font-size: 0.8rem;
|
||||
cursor: pointer;
|
||||
padding: 0;
|
||||
line-height: 1;
|
||||
}
|
||||
|
||||
.add-btn:hover {
|
||||
color: var(--ctp-text);
|
||||
}
|
||||
|
||||
.conv-item {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.4rem;
|
||||
width: 100%;
|
||||
padding: 0.35rem 0.75rem;
|
||||
background: transparent;
|
||||
border: none;
|
||||
color: var(--ctp-subtext0);
|
||||
font-size: 0.75rem;
|
||||
cursor: pointer;
|
||||
text-align: left;
|
||||
transition: background 0.1s, color 0.1s;
|
||||
}
|
||||
|
||||
.conv-item:hover {
|
||||
background: var(--ctp-surface0);
|
||||
color: var(--ctp-text);
|
||||
}
|
||||
|
||||
.conv-item.active {
|
||||
background: color-mix(in srgb, var(--ctp-blue) 15%, transparent);
|
||||
color: var(--ctp-text);
|
||||
}
|
||||
|
||||
.conv-icon {
|
||||
font-size: 0.8rem;
|
||||
flex-shrink: 0;
|
||||
width: 1.2rem;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.conv-name {
|
||||
flex: 1;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.conv-meta {
|
||||
font-size: 0.55rem;
|
||||
color: var(--ctp-overlay0);
|
||||
}
|
||||
|
||||
.status-dot {
|
||||
width: 6px;
|
||||
height: 6px;
|
||||
border-radius: 50%;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.status-dot.active {
|
||||
background: var(--ctp-green);
|
||||
box-shadow: 0 0 4px var(--ctp-green);
|
||||
}
|
||||
|
||||
.status-dot.sleeping {
|
||||
background: var(--ctp-yellow);
|
||||
}
|
||||
|
||||
.status-dot.stopped {
|
||||
background: var(--ctp-overlay0);
|
||||
}
|
||||
|
||||
.unread-badge {
|
||||
background: var(--ctp-red);
|
||||
color: var(--ctp-base);
|
||||
border-radius: 0.5rem;
|
||||
padding: 0 0.3rem;
|
||||
font-size: 0.55rem;
|
||||
font-weight: 700;
|
||||
min-width: 0.9rem;
|
||||
text-align: center;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.new-channel {
|
||||
display: flex;
|
||||
gap: 0.25rem;
|
||||
padding: 0.25rem 0.75rem;
|
||||
}
|
||||
|
||||
.new-channel input {
|
||||
flex: 1;
|
||||
background: var(--ctp-surface0);
|
||||
border: 1px solid var(--ctp-surface1);
|
||||
border-radius: 0.2rem;
|
||||
color: var(--ctp-text);
|
||||
font-size: 0.7rem;
|
||||
padding: 0.2rem 0.4rem;
|
||||
outline: none;
|
||||
}
|
||||
|
||||
.new-channel input:focus {
|
||||
border-color: var(--ctp-blue);
|
||||
}
|
||||
|
||||
.new-channel button {
|
||||
background: var(--ctp-blue);
|
||||
color: var(--ctp-base);
|
||||
border: none;
|
||||
border-radius: 0.2rem;
|
||||
font-size: 0.6rem;
|
||||
font-weight: 600;
|
||||
padding: 0.2rem 0.4rem;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
/* Chat area */
|
||||
.chat-area {
|
||||
flex: 1;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.chat-header {
|
||||
display: flex;
|
||||
align-items: baseline;
|
||||
gap: 0.5rem;
|
||||
padding: 0.5rem 0.75rem;
|
||||
border-bottom: 1px solid var(--ctp-surface0);
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.chat-title {
|
||||
font-size: 0.8rem;
|
||||
font-weight: 600;
|
||||
color: var(--ctp-text);
|
||||
}
|
||||
|
||||
.chat-subtitle {
|
||||
font-size: 0.65rem;
|
||||
color: var(--ctp-overlay0);
|
||||
}
|
||||
|
||||
.chat-messages {
|
||||
flex: 1;
|
||||
overflow-y: auto;
|
||||
padding: 0.5rem;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 0.4rem;
|
||||
}
|
||||
|
||||
.empty-state {
|
||||
color: var(--ctp-overlay0);
|
||||
font-size: 0.75rem;
|
||||
text-align: center;
|
||||
padding: 2rem 1rem;
|
||||
}
|
||||
|
||||
.message {
|
||||
padding: 0.4rem 0.6rem;
|
||||
border-radius: 0.375rem;
|
||||
background: var(--ctp-surface0);
|
||||
max-width: 85%;
|
||||
}
|
||||
|
||||
.message.own {
|
||||
align-self: flex-end;
|
||||
background: color-mix(in srgb, var(--ctp-blue) 20%, var(--ctp-surface0));
|
||||
}
|
||||
|
||||
.message.feed-message {
|
||||
max-width: 100%;
|
||||
background: transparent;
|
||||
border-left: 2px solid var(--ctp-surface1);
|
||||
border-radius: 0;
|
||||
padding: 0.3rem 0.6rem;
|
||||
}
|
||||
|
||||
.msg-header {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.3rem;
|
||||
margin-bottom: 0.15rem;
|
||||
}
|
||||
|
||||
.msg-icon {
|
||||
font-size: 0.7rem;
|
||||
}
|
||||
|
||||
.msg-sender {
|
||||
font-size: 0.7rem;
|
||||
font-weight: 600;
|
||||
color: var(--ctp-text);
|
||||
}
|
||||
|
||||
.msg-arrow {
|
||||
font-size: 0.6rem;
|
||||
color: var(--ctp-overlay0);
|
||||
}
|
||||
|
||||
.msg-recipient {
|
||||
font-size: 0.7rem;
|
||||
font-weight: 600;
|
||||
color: var(--ctp-subtext0);
|
||||
}
|
||||
|
||||
.msg-time {
|
||||
font-size: 0.55rem;
|
||||
color: var(--ctp-overlay0);
|
||||
margin-left: auto;
|
||||
}
|
||||
|
||||
.msg-content {
|
||||
font-size: 0.75rem;
|
||||
color: var(--ctp-subtext0);
|
||||
white-space: pre-wrap;
|
||||
word-break: break-word;
|
||||
line-height: 1.4;
|
||||
}
|
||||
|
||||
.message.own .msg-content {
|
||||
color: var(--ctp-text);
|
||||
}
|
||||
|
||||
/* Input */
|
||||
.chat-input {
|
||||
display: flex;
|
||||
gap: 0.4rem;
|
||||
padding: 0.5rem;
|
||||
border-top: 1px solid var(--ctp-surface0);
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.chat-input textarea {
|
||||
flex: 1;
|
||||
background: var(--ctp-surface0);
|
||||
border: 1px solid var(--ctp-surface1);
|
||||
border-radius: 0.375rem;
|
||||
color: var(--ctp-text);
|
||||
font-size: 0.75rem;
|
||||
font-family: inherit;
|
||||
padding: 0.4rem 0.6rem;
|
||||
resize: none;
|
||||
outline: none;
|
||||
line-height: 1.4;
|
||||
}
|
||||
|
||||
.chat-input textarea:focus {
|
||||
border-color: var(--ctp-blue);
|
||||
}
|
||||
|
||||
.send-btn {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
width: 2rem;
|
||||
height: 2rem;
|
||||
background: var(--ctp-blue);
|
||||
color: var(--ctp-base);
|
||||
border: none;
|
||||
border-radius: 0.375rem;
|
||||
cursor: pointer;
|
||||
flex-shrink: 0;
|
||||
transition: opacity 0.1s;
|
||||
}
|
||||
|
||||
.send-btn:disabled {
|
||||
opacity: 0.4;
|
||||
cursor: default;
|
||||
}
|
||||
|
||||
.send-btn:not(:disabled):hover {
|
||||
opacity: 0.9;
|
||||
}
|
||||
</style>
|
||||
|
|
@ -10,21 +10,41 @@
|
|||
|
||||
const settingsIcon = 'M10.3 2L9.9 4.4a7 7 0 0 0-1.8 1l-2.2-.9-1.7 3 1.8 1.5a7 7 0 0 0 0 2l-1.8 1.5 1.7 3 2.2-.9a7 7 0 0 0 1.8 1L10.3 18h3.4l.4-2.4a7 7 0 0 0 1.8-1l2.2.9 1.7-3-1.8-1.5a7 7 0 0 0 0-2l1.8-1.5-1.7-3-2.2.9a7 7 0 0 0-1.8-1L13.7 2h-3.4zM12 8a4 4 0 1 1 0 8 4 4 0 0 1 0-8z';
|
||||
|
||||
function handleSettingsClick() {
|
||||
if (getActiveTab() === 'settings' && expanded) {
|
||||
function handleTabClick(tab: WorkspaceTab) {
|
||||
if (getActiveTab() === tab && expanded) {
|
||||
ontoggle?.();
|
||||
} else {
|
||||
setActiveTab('settings');
|
||||
setActiveTab(tab);
|
||||
if (!expanded) ontoggle?.();
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<nav class="sidebar-rail">
|
||||
<button
|
||||
class="rail-btn"
|
||||
class:active={getActiveTab() === 'comms' && expanded}
|
||||
onclick={() => handleTabClick('comms')}
|
||||
title="Messages (Ctrl+M)"
|
||||
>
|
||||
<svg width="20" height="20" viewBox="0 0 24 24" fill="none">
|
||||
<path
|
||||
d="M21 11.5a8.38 8.38 0 0 1-.9 3.8 8.5 8.5 0 0 1-7.6 4.7 8.38 8.38 0 0 1-3.8-.9L3 21l1.9-5.7a8.38 8.38 0 0 1-.9-3.8 8.5 8.5 0 0 1 4.7-7.6 8.38 8.38 0 0 1 3.8-.9h.5a8.48 8.48 0 0 1 8 8v.5z"
|
||||
stroke="currentColor"
|
||||
stroke-width="1.5"
|
||||
stroke-linecap="round"
|
||||
stroke-linejoin="round"
|
||||
fill="none"
|
||||
/>
|
||||
</svg>
|
||||
</button>
|
||||
|
||||
<div class="rail-spacer"></div>
|
||||
|
||||
<button
|
||||
class="rail-btn"
|
||||
class:active={getActiveTab() === 'settings' && expanded}
|
||||
onclick={handleSettingsClick}
|
||||
onclick={() => handleTabClick('settings')}
|
||||
title="Settings (Ctrl+,)"
|
||||
>
|
||||
<svg width="20" height="20" viewBox="0 0 24 24" fill="none">
|
||||
|
|
@ -75,4 +95,8 @@
|
|||
color: var(--ctp-blue);
|
||||
background: var(--ctp-surface0);
|
||||
}
|
||||
|
||||
.rail-spacer {
|
||||
flex: 1;
|
||||
}
|
||||
</style>
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
<script lang="ts">
|
||||
import { onMount, onDestroy } from 'svelte';
|
||||
import { getActiveGroup, getEnabledProjects } from '../../stores/workspace.svelte';
|
||||
import { getActiveGroup, getEnabledProjects, setActiveProject } from '../../stores/workspace.svelte';
|
||||
import type { GroupAgentConfig, GroupAgentStatus, ProjectConfig } from '../../types/groups';
|
||||
import { getGroupAgents, setAgentStatus, type BtmsgAgent } from '../../adapters/btmsg-bridge';
|
||||
|
||||
|
|
@ -114,7 +114,14 @@
|
|||
<div class="agents-grid">
|
||||
{#each agents as agent (agent.id)}
|
||||
{@const status = getStatus(agent.id)}
|
||||
<div class="agent-card" class:active={status === 'active'} class:sleeping={status === 'sleeping'}>
|
||||
<div
|
||||
class="agent-card"
|
||||
class:active={status === 'active'}
|
||||
class:sleeping={status === 'sleeping'}
|
||||
onclick={() => setActiveProject(agent.id)}
|
||||
role="button"
|
||||
tabindex="0"
|
||||
>
|
||||
<div class="card-top">
|
||||
<span class="agent-icon">{ROLE_ICONS[agent.role] ?? '🤖'}</span>
|
||||
<span class="agent-name">{agent.name}</span>
|
||||
|
|
@ -130,9 +137,8 @@
|
|||
{#if agent.model}
|
||||
<span class="agent-model">{agent.model}</span>
|
||||
{/if}
|
||||
{@const unread = getUnread(agent.id)}
|
||||
{#if unread > 0}
|
||||
<span class="unread-badge">{unread}</span>
|
||||
{#if getUnread(agent.id) > 0}
|
||||
<span class="unread-badge">{getUnread(agent.id)}</span>
|
||||
{/if}
|
||||
</div>
|
||||
<div class="card-actions">
|
||||
|
|
@ -159,7 +165,14 @@
|
|||
<div class="agents-grid">
|
||||
{#each projects as project (project.id)}
|
||||
{@const status = getStatus(project.id)}
|
||||
<div class="agent-card tier2" class:active={status === 'active'} class:sleeping={status === 'sleeping'}>
|
||||
<div
|
||||
class="agent-card tier2"
|
||||
class:active={status === 'active'}
|
||||
class:sleeping={status === 'sleeping'}
|
||||
onclick={() => setActiveProject(project.id)}
|
||||
role="button"
|
||||
tabindex="0"
|
||||
>
|
||||
<div class="card-top">
|
||||
<span class="agent-icon">{project.icon}</span>
|
||||
<span class="agent-name">{project.name}</span>
|
||||
|
|
@ -172,9 +185,8 @@
|
|||
</div>
|
||||
<div class="card-meta">
|
||||
<span class="agent-role">Project</span>
|
||||
{@const unread = getUnread(project.id)}
|
||||
{#if unread > 0}
|
||||
<span class="unread-badge">{unread}</span>
|
||||
{#if getUnread(project.id) > 0}
|
||||
<span class="unread-badge">{getUnread(project.id)}</span>
|
||||
{/if}
|
||||
</div>
|
||||
</div>
|
||||
|
|
@ -309,6 +321,7 @@
|
|||
border: 1px solid var(--ctp-surface0);
|
||||
border-radius: 0.25rem;
|
||||
transition: border-color 0.15s, background 0.15s;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.agent-card:hover {
|
||||
|
|
|
|||
|
|
@ -1,12 +1,12 @@
|
|||
<script lang="ts">
|
||||
import { onMount, onDestroy } from 'svelte';
|
||||
import { getEnabledProjects, getActiveProjectId, setActiveProject } from '../../stores/workspace.svelte';
|
||||
import { getAllWorkItems, getActiveProjectId, setActiveProject } from '../../stores/workspace.svelte';
|
||||
import ProjectBox from './ProjectBox.svelte';
|
||||
|
||||
let containerEl: HTMLDivElement | undefined = $state();
|
||||
let containerWidth = $state(0);
|
||||
|
||||
let projects = $derived(getEnabledProjects());
|
||||
let projects = $derived(getAllWorkItems());
|
||||
let activeProjectId = $derived(getActiveProjectId());
|
||||
let visibleCount = $derived(
|
||||
Math.min(projects.length, Math.max(1, Math.floor(containerWidth / 520))),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue