Skip to content

Commit f09dcb6

Browse files
committed
Implement Neural Link Drag & Drop Inspection #8172
1 parent d92b241 commit f09dcb6

4 files changed

Lines changed: 53 additions & 0 deletions

File tree

ai/mcp/server/neural-link/openapi.yaml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,29 @@ paths:
129129
schema:
130130
$ref: '#/components/schemas/ErrorResponse'
131131

132+
/drag/state:
133+
post:
134+
summary: Get Drag State
135+
operationId: get_drag_state
136+
x-pass-as-object: true
137+
description: Retrieves the state of the DragCoordinator.
138+
requestBody:
139+
content:
140+
application/json:
141+
schema:
142+
type: object
143+
properties:
144+
sessionId:
145+
type: string
146+
description: Target App Worker Session ID
147+
responses:
148+
'200':
149+
description: Drag Coordinator State
150+
content:
151+
application/json:
152+
schema:
153+
type: object
154+
132155
/page/reload:
133156
post:
134157
summary: Reload Page

ai/mcp/server/neural-link/services/ConnectionService.mjs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -283,6 +283,16 @@ class ConnectionService extends Base {
283283
return await this.#call(windowId, 'get_vnode_tree', {depth, rootId})
284284
}
285285

286+
/**
287+
* Retrieves the state of the DragCoordinator.
288+
* @param {Object} opts
289+
* @param {String} [opts.sessionId]
290+
* @returns {Promise<Object>}
291+
*/
292+
async getDragState({sessionId}) {
293+
return await this.#call(sessionId, 'get_drag_state', {})
294+
}
295+
286296
/**
287297
* Retrieves the topology of all connected windows.
288298
* @returns {Promise<Object[]>} List of windows.

ai/mcp/server/neural-link/services/toolService.mjs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ const openApiFilePath = path.join(__dirname, '../openapi.yaml');
1010
const serviceMapping = {
1111
get_component_property: ConnectionService.getComponentProperty.bind(ConnectionService),
1212
get_component_tree : ConnectionService.getComponentTree.bind(ConnectionService),
13+
get_drag_state : ConnectionService.getDragState.bind(ConnectionService),
1314
get_vdom_tree : ConnectionService.getVdomTree.bind(ConnectionService),
1415
get_vnode_tree : ConnectionService.getVnodeTree.bind(ConnectionService),
1516
get_window_topology : ConnectionService.getWindowTopology.bind(ConnectionService),

src/ai/Client.mjs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,25 @@ class Client extends Base {
144144
case 'get_component_tree':
145145
return {tree: me.serializeComponent(me.getComponentRoot(params.rootId), params.depth || -1)};
146146

147+
case 'get_drag_state':
148+
const dragCoordinator = Neo.manager?.DragCoordinator;
149+
150+
if (dragCoordinator) {
151+
return {
152+
activeTargetZone: dragCoordinator.activeTargetZone ? {
153+
id : dragCoordinator.activeTargetZone.id,
154+
sortGroup: dragCoordinator.activeTargetZone.sortGroup,
155+
windowId : dragCoordinator.activeTargetZone.windowId
156+
} : null,
157+
sortZones: Array.from(dragCoordinator.sortZones.entries()).map(([group, map]) => ({
158+
group,
159+
windows: Array.from(map.keys())
160+
}))
161+
}
162+
}
163+
164+
return {};
165+
147166
case 'get_vdom_tree':
148167
component = me.getComponentRoot(params.rootId);
149168
if (!component) throw new Error('Root component not found');

0 commit comments

Comments
 (0)