refactor: add promoteDraftToAgent store action with tests

This commit is contained in:
Mohamed Boudra
2026-03-04 15:37:46 +07:00
parent 430ad54d77
commit 7578846c27
3 changed files with 193 additions and 7 deletions
@@ -411,6 +411,7 @@ function WorkspaceScreenContent({
const openOrFocusTab = useWorkspaceTabsStore((state) => state.openOrFocusTab);
const focusTab = useWorkspaceTabsStore((state) => state.focusTab);
const closeWorkspaceTab = useWorkspaceTabsStore((state) => state.closeTab);
const promoteDraftToAgent = useWorkspaceTabsStore((state) => state.promoteDraftToAgent);
const reorderWorkspaceTabs = useWorkspaceTabsStore((state) => state.reorderTabs);
useEffect(() => {
@@ -971,15 +972,11 @@ function WorkspaceScreenContent({
draftId={target.draftId}
onCreated={(agentSnapshot) => {
const tabId = activeTabId ?? target.draftId;
const nextAgentTabId = openOrFocusTab({
const nextAgentTabId = promoteDraftToAgent({
serverId: normalizedServerId,
workspaceId: normalizedWorkspaceId,
target: { kind: "agent", agentId: agentSnapshot.id },
});
closeWorkspaceTab({
serverId: normalizedServerId,
workspaceId: normalizedWorkspaceId,
tabId,
draftTabId: tabId,
agentId: agentSnapshot.id,
});
if (nextAgentTabId) {
navigateToTabId(nextAgentTabId);