vite-plugin-aipanel 1.2.4 → 1.2.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,6 @@
1
1
  import { CONTEXT_API_PATH } from "@aipanel/core";
2
2
  import { RequestContext, createLogger } from "@aipanel/core/node";
3
+ import { ensureNodeId } from "@aipanel/core";
3
4
  const log = createLogger("Endpoints:Context");
4
5
  function setupContextEndpoint(server, ctx) {
5
6
  server.middlewares.use(CONTEXT_API_PATH, async (req, res) => {
@@ -56,13 +57,17 @@ function setupContextEndpoint(server, ctx) {
56
57
  const data = JSON.parse(body);
57
58
  const tabId = data.tabId != null ? String(data.tabId) : "default";
58
59
  const existing = ctx.getPageContext();
60
+ const selectedElements = data.selectedElements || [];
61
+ selectedElements.forEach((el) => {
62
+ if (el && typeof el === "object") ensureNodeId(el);
63
+ });
59
64
  const newCtx = {
60
65
  url: data.url || "",
61
66
  title: data.title || "",
62
67
  sessionId: data.sessionId,
63
68
  tabId: data.tabId ?? existing.tabId,
64
69
  tabIndex: data.tabIndex ?? existing.tabIndex,
65
- selectedElements: data.selectedElements || []
70
+ selectedElements
66
71
  };
67
72
  ctx.setPageContext(tabId, newCtx);
68
73
  if (data.active) {