mirror of
https://github.com/openswarm-ai/openswarm.git
synced 2026-09-26 11:34:50 +02:00
[Haik]: CreateBrowserAgent now spawns in the browser to the right of whatever agent created it (like subagents spawn in)
This commit is contained in:
@@ -548,7 +548,7 @@ async def run_browser_agent(
|
||||
}
|
||||
|
||||
|
||||
async def _create_browser_card(dashboard_id: str, url: str) -> str:
|
||||
async def _create_browser_card(dashboard_id: str, url: str, parent_session_id: str | None = None) -> str:
|
||||
"""Create a new browser card on the dashboard and return its browser_id."""
|
||||
from backend.apps.dashboards.dashboards import _load, _save
|
||||
from backend.apps.dashboards.models import BrowserCardPosition, BrowserTab
|
||||
@@ -574,6 +574,7 @@ async def _create_browser_card(dashboard_id: str, url: str) -> str:
|
||||
await ws_manager.broadcast_global("dashboard:browser_card_added", {
|
||||
"dashboard_id": dashboard_id,
|
||||
"browser_card": card.model_dump(mode="json"),
|
||||
"parent_session_id": parent_session_id or "",
|
||||
})
|
||||
return browser_id
|
||||
|
||||
@@ -599,7 +600,7 @@ async def run_browser_agents(
|
||||
url = task_def.get("url", "")
|
||||
|
||||
if not browser_id and dashboard_id:
|
||||
browser_id = await _create_browser_card(dashboard_id, url)
|
||||
browser_id = await _create_browser_card(dashboard_id, url, parent_session_id)
|
||||
await asyncio.sleep(2.0)
|
||||
|
||||
is_pre_selected = browser_id in pre_selected
|
||||
|
||||
@@ -16,7 +16,7 @@ import {
|
||||
closeSessionFromWs,
|
||||
trackAgentNotification,
|
||||
} from '../state/agentsSlice';
|
||||
import { addBrowserCardFromBackend } from '../state/dashboardLayoutSlice';
|
||||
import { addBrowserCardFromBackend, setBrowserCardPosition, GRID_GAP } from '../state/dashboardLayoutSlice';
|
||||
|
||||
type WSEvent = {
|
||||
event: string;
|
||||
@@ -239,6 +239,18 @@ class WebSocketManager {
|
||||
case 'dashboard:browser_card_added':
|
||||
if (data.browser_card) {
|
||||
store.dispatch(addBrowserCardFromBackend(data.browser_card));
|
||||
const parentId = data.parent_session_id;
|
||||
if (parentId) {
|
||||
const layoutState = store.getState().dashboardLayout;
|
||||
const parentCard = layoutState.cards[parentId];
|
||||
if (parentCard) {
|
||||
store.dispatch(setBrowserCardPosition({
|
||||
browserId: data.browser_card.browser_id,
|
||||
x: parentCard.x + parentCard.width + GRID_GAP * 12,
|
||||
y: parentCard.y,
|
||||
}));
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user