refactor(components): apply branded types at Svelte component call sites
GroupAgentsPanel, TaskBoardTab, SettingsTab now use GroupId/AgentId branded constructors at their IPC call sites.
This commit is contained in:
parent
ce389a2a39
commit
46df7949a7
3 changed files with 11 additions and 7 deletions
|
|
@ -3,6 +3,7 @@
|
|||
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';
|
||||
import type { AgentId } from '../../types/ids';
|
||||
|
||||
/** Runtime agent status from btmsg database */
|
||||
let btmsgAgents = $state<BtmsgAgent[]>([]);
|
||||
|
|
@ -46,12 +47,12 @@
|
|||
if (pollTimer) clearInterval(pollTimer);
|
||||
});
|
||||
|
||||
function getStatus(agentId: string): GroupAgentStatus {
|
||||
function getStatus(agentId: AgentId): GroupAgentStatus {
|
||||
const btAgent = btmsgAgents.find(a => a.id === agentId);
|
||||
return (btAgent?.status as GroupAgentStatus) ?? 'stopped';
|
||||
}
|
||||
|
||||
function getUnread(agentId: string): number {
|
||||
function getUnread(agentId: AgentId): number {
|
||||
const btAgent = btmsgAgents.find(a => a.id === agentId);
|
||||
return btAgent?.unreadCount ?? 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@
|
|||
switchGroup,
|
||||
} from '../../stores/workspace.svelte';
|
||||
import { deriveIdentifier, type GroupAgentRole, AGENT_ROLE_ICONS } from '../../types/groups';
|
||||
import { ProjectId, GroupId } from '../../types/ids';
|
||||
import { generateAgentPrompt } from '../../utils/agent-prompts';
|
||||
import { getSetting, setSetting } from '../../adapters/settings-bridge';
|
||||
import { getCurrentTheme, setTheme } from '../../stores/theme.svelte';
|
||||
|
|
@ -284,7 +285,7 @@
|
|||
|
||||
function handleAddProject() {
|
||||
if (!newName.trim() || !newCwd.trim() || !activeGroupId) return;
|
||||
const id = crypto.randomUUID();
|
||||
const id = ProjectId(crypto.randomUUID());
|
||||
addProject(activeGroupId, {
|
||||
id,
|
||||
name: newName.trim(),
|
||||
|
|
@ -304,7 +305,7 @@
|
|||
|
||||
function handleAddGroup() {
|
||||
if (!newGroupName.trim()) return;
|
||||
const id = crypto.randomUUID();
|
||||
const id = GroupId(crypto.randomUUID());
|
||||
addGroup({ id, name: newGroupName.trim(), projects: [] });
|
||||
newGroupName = '';
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,9 +1,11 @@
|
|||
<script lang="ts">
|
||||
import { onMount, onDestroy } from 'svelte';
|
||||
import { listTasks, updateTaskStatus, createTask, deleteTask, addTaskComment, type Task, type TaskComment, getTaskComments } from '../../adapters/bttask-bridge';
|
||||
import type { GroupId } from '../../types/ids';
|
||||
import { AgentId } from '../../types/ids';
|
||||
|
||||
interface Props {
|
||||
groupId: string;
|
||||
groupId: GroupId;
|
||||
projectId?: string;
|
||||
}
|
||||
|
||||
|
|
@ -92,7 +94,7 @@
|
|||
async function handleAddTask() {
|
||||
if (!newTitle.trim()) return;
|
||||
try {
|
||||
await createTask(newTitle.trim(), newDesc.trim(), newPriority, groupId, 'admin');
|
||||
await createTask(newTitle.trim(), newDesc.trim(), newPriority, groupId, AgentId('admin'));
|
||||
newTitle = '';
|
||||
newDesc = '';
|
||||
newPriority = 'medium';
|
||||
|
|
@ -129,7 +131,7 @@
|
|||
async function handleAddComment() {
|
||||
if (!expandedTaskId || !newComment.trim()) return;
|
||||
try {
|
||||
await addTaskComment(expandedTaskId, 'admin', newComment.trim());
|
||||
await addTaskComment(expandedTaskId, AgentId('admin'), newComment.trim());
|
||||
newComment = '';
|
||||
taskComments = await getTaskComments(expandedTaskId);
|
||||
} catch (e) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue