refactor(app): introduce attachment storage layer and draft lifecycle management

Replace inline data-URL image handling with a persistent attachment storage service, add draft lifecycle states (active/abandoned/sent) with generation tracking, and update fetchAgent to return project placement alongside agent snapshots.
This commit is contained in:
Mohamed Boudra
2026-02-22 16:22:21 +07:00
parent 2652bdda2e
commit 0c710b09f5
55 changed files with 2381 additions and 350 deletions
+17 -5
View File
@@ -47,20 +47,32 @@ export function applyFetchedAgentDirectory(input: {
serverId: string;
entries: FetchAgentsEntry[];
}): { agents: Map<string, Agent> } {
const { agents, pendingPermissions } = buildAgentDirectoryState(input);
const { agents: fetchedAgents, pendingPermissions } = buildAgentDirectoryState(input);
const store = useSessionStore.getState();
store.setAgents(input.serverId, agents);
store.setAgents(input.serverId, (prev) => {
const merged = new Map(prev);
for (const [id, agent] of fetchedAgents) {
merged.set(id, agent);
}
return merged;
});
const lastActivityByAgentId = new Map<string, Date>();
for (const agent of agents.values()) {
for (const agent of fetchedAgents.values()) {
lastActivityByAgentId.set(agent.id, agent.lastActivityAt);
}
store.setAgentLastActivityBatch(lastActivityByAgentId);
store.setPendingPermissions(input.serverId, pendingPermissions);
store.setPendingPermissions(input.serverId, (prev) => {
const merged = new Map(prev);
for (const [key, entry] of pendingPermissions) {
merged.set(key, entry);
}
return merged;
});
store.setInitializingAgents(input.serverId, new Map());
store.setHasHydratedAgents(input.serverId, true);
return { agents };
return { agents: fetchedAgents };
}