refactor: rename services to scripts and extract reusable components

This commit is contained in:
Mohamed Boudra
2026-04-09 18:54:25 +07:00
parent 5cf806dc77
commit 397d454de0
48 changed files with 1356 additions and 983 deletions
@@ -0,0 +1,28 @@
import type { ScriptStatusUpdateMessage } from "@server/shared/messages";
import type { WorkspaceDescriptor } from "@/stores/session-store";
import { resolveWorkspaceMapKeyByIdentity } from "@/utils/workspace-execution";
export function patchWorkspaceScripts(
workspaces: Map<string, WorkspaceDescriptor>,
update: ScriptStatusUpdateMessage["payload"],
): Map<string, WorkspaceDescriptor> {
const workspaceKey = resolveWorkspaceMapKeyByIdentity({
workspaces,
workspaceIdentity: update.workspaceId,
});
if (!workspaceKey) {
return workspaces;
}
const existing = workspaces.get(workspaceKey);
if (!existing) {
return workspaces;
}
const next = new Map(workspaces);
next.set(workspaceKey, {
...existing,
scripts: update.scripts.map((s) => ({ ...s })),
});
return next;
}