@axiom-lattice/react-sdk 2.1.62 → 2.1.64

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.
package/dist/index.js CHANGED
@@ -1063,20 +1063,20 @@ var DEFAULT_MIDDLEWARE_TYPES = [
1063
1063
  type: "object",
1064
1064
  title: "Filesystem Configuration",
1065
1065
  description: "Configure filesystem isolation and access settings",
1066
- required: ["isolatedLevel"],
1066
+ required: ["vmIsolation"],
1067
1067
  properties: {
1068
- isolatedLevel: {
1068
+ vmIsolation: {
1069
1069
  type: "string",
1070
- title: "Isolation Level",
1071
- description: "Controls how filesystem access is isolated between agents and threads",
1072
- enum: ["global", "agent", "thread"],
1070
+ title: "VM Isolation",
1071
+ description: "Controls how filesystem access is isolated between agents and projects",
1072
+ enum: ["global", "agent", "project"],
1073
1073
  default: "global",
1074
1074
  widget: "segmented"
1075
1075
  }
1076
1076
  }
1077
1077
  },
1078
1078
  defaultConfig: {
1079
- isolatedLevel: "global"
1079
+ vmIsolation: "global"
1080
1080
  },
1081
1081
  tools: [
1082
1082
  { id: "sandbox_ls", name: "List Files", description: "List files in the directory" },
@@ -1096,20 +1096,20 @@ var DEFAULT_MIDDLEWARE_TYPES = [
1096
1096
  type: "object",
1097
1097
  title: "Code Evaluation Configuration",
1098
1098
  description: "Configure code execution sandbox settings",
1099
- required: ["isolatedLevel"],
1099
+ required: ["vmIsolation"],
1100
1100
  properties: {
1101
- isolatedLevel: {
1101
+ vmIsolation: {
1102
1102
  type: "string",
1103
- title: "Isolation Level",
1104
- description: "Controls how code execution is isolated between agents and threads",
1105
- enum: ["global", "agent", "thread"],
1103
+ title: "VM Isolation",
1104
+ description: "Controls how code execution is isolated between agents and projects",
1105
+ enum: ["global", "agent", "project"],
1106
1106
  default: "global",
1107
1107
  widget: "segmented"
1108
1108
  }
1109
1109
  }
1110
1110
  },
1111
1111
  defaultConfig: {
1112
- isolatedLevel: "global"
1112
+ vmIsolation: "global"
1113
1113
  },
1114
1114
  tools: [
1115
1115
  { id: "execute_code", name: "Execute Code", description: "Execute code snippets" },
@@ -1125,20 +1125,20 @@ var DEFAULT_MIDDLEWARE_TYPES = [
1125
1125
  type: "object",
1126
1126
  title: "Browser Configuration",
1127
1127
  description: "Configure browser automation settings",
1128
- required: ["isolatedLevel"],
1128
+ required: ["vmIsolation"],
1129
1129
  properties: {
1130
- isolatedLevel: {
1130
+ vmIsolation: {
1131
1131
  type: "string",
1132
- title: "Isolation Level",
1133
- description: "Controls how browser instances are isolated between agents and threads",
1134
- enum: ["global", "agent", "thread"],
1132
+ title: "VM Isolation",
1133
+ description: "Controls how browser instances are isolated between agents and projects",
1134
+ enum: ["global", "agent", "project"],
1135
1135
  default: "agent",
1136
1136
  widget: "segmented"
1137
1137
  }
1138
1138
  }
1139
1139
  },
1140
1140
  defaultConfig: {
1141
- isolatedLevel: "agent",
1141
+ vmIsolation: "agent",
1142
1142
  headless: true
1143
1143
  },
1144
1144
  tools: [
@@ -5423,12 +5423,239 @@ var import_antd8 = require("antd");
5423
5423
  var import_antd_style4 = require("antd-style");
5424
5424
 
5425
5425
  // src/components/GenUI/MarkdownViewer.tsx
5426
- var import_react19 = require("react");
5426
+ var import_react19 = __toESM(require("react"));
5427
5427
  var import_antd7 = require("antd");
5428
5428
  var import_icons4 = require("@ant-design/icons");
5429
5429
  var import_jspdf = require("jspdf");
5430
5430
  var import_html2canvas = __toESM(require("html2canvas"));
5431
5431
  var import_antd_style3 = require("antd-style");
5432
+
5433
+ // src/utils/fileUtils.ts
5434
+ function extractFileName(pathOrUrl) {
5435
+ if (!pathOrUrl) return "";
5436
+ const withoutQuery = pathOrUrl.split("?")[0];
5437
+ return withoutQuery.split("/").pop() || pathOrUrl;
5438
+ }
5439
+ function getFileExtension(pathOrUrl) {
5440
+ const fileName = extractFileName(pathOrUrl);
5441
+ if (!fileName) return "";
5442
+ const extension = fileName.split(".").pop()?.toLowerCase();
5443
+ return extension || "";
5444
+ }
5445
+ function getFileCategory(pathOrUrl) {
5446
+ const extension = getFileExtension(pathOrUrl);
5447
+ if (!extension) return "unknown";
5448
+ if (["md", "markdown", "mdx"].includes(extension)) return "markdown";
5449
+ if ([
5450
+ "txt",
5451
+ "json",
5452
+ "csv",
5453
+ "xml",
5454
+ "yaml",
5455
+ "yml",
5456
+ "ini",
5457
+ "conf",
5458
+ "sh",
5459
+ "bat",
5460
+ "cmd",
5461
+ "ts",
5462
+ "tsx",
5463
+ "js",
5464
+ "jsx",
5465
+ "mjs",
5466
+ "cjs",
5467
+ "py",
5468
+ "rb",
5469
+ "go",
5470
+ "rs",
5471
+ "java",
5472
+ "kt",
5473
+ "swift",
5474
+ "c",
5475
+ "cpp",
5476
+ "h",
5477
+ "hpp",
5478
+ "cs",
5479
+ "php",
5480
+ "vue",
5481
+ "svelte",
5482
+ "sql",
5483
+ "css",
5484
+ "less",
5485
+ "scss",
5486
+ "bash",
5487
+ "zsh",
5488
+ "toml"
5489
+ ].includes(extension)) {
5490
+ return "text";
5491
+ }
5492
+ if (["jpg", "jpeg", "png", "gif", "svg", "bmp", "webp", "ico", "tiff", "tif"].includes(extension)) {
5493
+ return "image";
5494
+ }
5495
+ if (extension === "pdf") return "pdf";
5496
+ if (["mp3", "wav", "ogg", "flac", "aac", "m4a", "wma"].includes(extension)) return "audio";
5497
+ if (["mp4", "webm", "ogv", "mov", "avi", "mkv", "flv"].includes(extension)) return "video";
5498
+ if (["html", "htm"].includes(extension)) return "iframe";
5499
+ return "unknown";
5500
+ }
5501
+ function getLanguageFromFileName(pathOrUrl) {
5502
+ const ext = getFileExtension(pathOrUrl);
5503
+ switch (ext) {
5504
+ case "ts":
5505
+ case "tsx":
5506
+ return "typescript";
5507
+ case "js":
5508
+ case "jsx":
5509
+ case "mjs":
5510
+ case "cjs":
5511
+ return "javascript";
5512
+ case "py":
5513
+ return "python";
5514
+ case "rb":
5515
+ return "ruby";
5516
+ case "go":
5517
+ return "go";
5518
+ case "md":
5519
+ case "markdown":
5520
+ case "mdx":
5521
+ return "markdown";
5522
+ case "json":
5523
+ return "json";
5524
+ case "html":
5525
+ case "htm":
5526
+ return "html";
5527
+ case "css":
5528
+ return "css";
5529
+ case "less":
5530
+ return "less";
5531
+ case "scss":
5532
+ return "scss";
5533
+ case "java":
5534
+ return "java";
5535
+ case "kt":
5536
+ return "kotlin";
5537
+ case "swift":
5538
+ return "swift";
5539
+ case "rs":
5540
+ return "rust";
5541
+ case "c":
5542
+ case "h":
5543
+ return "c";
5544
+ case "cpp":
5545
+ case "hpp":
5546
+ return "cpp";
5547
+ case "cs":
5548
+ return "csharp";
5549
+ case "php":
5550
+ return "php";
5551
+ case "vue":
5552
+ return "vue";
5553
+ case "svelte":
5554
+ return "svelte";
5555
+ case "yaml":
5556
+ case "yml":
5557
+ return "yaml";
5558
+ case "sql":
5559
+ return "sql";
5560
+ case "sh":
5561
+ case "bash":
5562
+ case "zsh":
5563
+ return "bash";
5564
+ case "toml":
5565
+ return "toml";
5566
+ case "xml":
5567
+ return "xml";
5568
+ case "ini":
5569
+ case "conf":
5570
+ return "ini";
5571
+ default:
5572
+ return "text";
5573
+ }
5574
+ }
5575
+ function canPreviewInline(pathOrUrl) {
5576
+ const category = getFileCategory(pathOrUrl);
5577
+ return category !== "unknown";
5578
+ }
5579
+ function isTextFile(pathOrUrl) {
5580
+ const category = getFileCategory(pathOrUrl);
5581
+ return category === "markdown" || category === "text";
5582
+ }
5583
+ var COMMON_FILE_EXTENSIONS = /* @__PURE__ */ new Set([
5584
+ // Code
5585
+ "ts",
5586
+ "tsx",
5587
+ "js",
5588
+ "jsx",
5589
+ "mjs",
5590
+ "cjs",
5591
+ "html",
5592
+ "htm",
5593
+ "css",
5594
+ "less",
5595
+ "scss",
5596
+ "md",
5597
+ "txt",
5598
+ "mdx",
5599
+ "json",
5600
+ "yaml",
5601
+ "yml",
5602
+ "py",
5603
+ "rb",
5604
+ "go",
5605
+ "rs",
5606
+ "java",
5607
+ "kt",
5608
+ "swift",
5609
+ "c",
5610
+ "cpp",
5611
+ "h",
5612
+ "hpp",
5613
+ "cs",
5614
+ "php",
5615
+ "vue",
5616
+ "svelte",
5617
+ "sql",
5618
+ "sh",
5619
+ "bash",
5620
+ "zsh",
5621
+ "toml",
5622
+ "xml",
5623
+ // Media
5624
+ "png",
5625
+ "jpg",
5626
+ "jpeg",
5627
+ "gif",
5628
+ "svg",
5629
+ "webp",
5630
+ "ico",
5631
+ "mp4",
5632
+ "webm",
5633
+ "mp3",
5634
+ "wav",
5635
+ "pdf",
5636
+ // Office
5637
+ "ppt",
5638
+ "pptx",
5639
+ "doc",
5640
+ "docx",
5641
+ "xls",
5642
+ "xlsx",
5643
+ "odt",
5644
+ "ods",
5645
+ "odp",
5646
+ "rtf",
5647
+ "csv",
5648
+ "key",
5649
+ "numbers",
5650
+ "pages"
5651
+ ]);
5652
+ function isFileName(value) {
5653
+ if (!value || typeof value !== "string" || !value.trim()) return false;
5654
+ const ext = getFileExtension(value);
5655
+ return ext ? COMMON_FILE_EXTENSIONS.has(ext) : false;
5656
+ }
5657
+
5658
+ // src/components/GenUI/MarkdownViewer.tsx
5432
5659
  var import_jsx_runtime16 = require("react/jsx-runtime");
5433
5660
  var useStyles = (0, import_antd_style3.createStyles)(({ token, css }) => ({
5434
5661
  container: css`
@@ -5581,6 +5808,15 @@ var MarkdownViewer = ({
5581
5808
  import_antd7.message.error({ content: "Failed to generate PDF", key: "pdf" });
5582
5809
  }
5583
5810
  };
5811
+ const displayContent = import_react19.default.useMemo(() => {
5812
+ const lang = getLanguageFromFileName(fileName);
5813
+ if (lang && lang !== "markdown" && lang !== "text") {
5814
+ return `\`\`\`${lang}
5815
+ ${content}
5816
+ \`\`\``;
5817
+ }
5818
+ return content;
5819
+ }, [content, fileName]);
5584
5820
  return /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("div", { className: cx(styles.container, className), style, children: [
5585
5821
  /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("div", { className: styles.header, children: [
5586
5822
  /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(import_antd7.Tooltip, { title: "Copy Content", children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
@@ -5620,125 +5856,12 @@ var MarkdownViewer = ({
5620
5856
  }
5621
5857
  ) })
5622
5858
  ] }),
5623
- /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("div", { className: styles.contentBody, ref: contentRef, children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(MDResponse, { content }) })
5859
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("div", { className: styles.contentBody, ref: contentRef, children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(MDResponse, { content: displayContent }) })
5624
5860
  ] });
5625
5861
  };
5626
5862
 
5627
5863
  // src/components/GenUI/FileRenderer.tsx
5628
5864
  var import_icons5 = require("@ant-design/icons");
5629
-
5630
- // src/utils/fileUtils.ts
5631
- function extractFileName(pathOrUrl) {
5632
- if (!pathOrUrl) return "";
5633
- const withoutQuery = pathOrUrl.split("?")[0];
5634
- return withoutQuery.split("/").pop() || pathOrUrl;
5635
- }
5636
- function getFileExtension(pathOrUrl) {
5637
- const fileName = extractFileName(pathOrUrl);
5638
- if (!fileName) return "";
5639
- const extension = fileName.split(".").pop()?.toLowerCase();
5640
- return extension || "";
5641
- }
5642
- function getFileCategory(pathOrUrl) {
5643
- const extension = getFileExtension(pathOrUrl);
5644
- if (!extension) return "unknown";
5645
- if (["md", "markdown", "mdx"].includes(extension)) return "markdown";
5646
- if (["txt", "json", "csv", "xml", "yaml", "yml", "ini", "conf", "sh", "bat", "cmd"].includes(extension)) {
5647
- return "text";
5648
- }
5649
- if (["jpg", "jpeg", "png", "gif", "svg", "bmp", "webp", "ico", "tiff", "tif"].includes(extension)) {
5650
- return "image";
5651
- }
5652
- if (extension === "pdf") return "pdf";
5653
- if (["mp3", "wav", "ogg", "flac", "aac", "m4a", "wma"].includes(extension)) return "audio";
5654
- if (["mp4", "webm", "ogv", "mov", "avi", "mkv", "flv"].includes(extension)) return "video";
5655
- if (["html", "htm"].includes(extension)) return "iframe";
5656
- return "unknown";
5657
- }
5658
- function canPreviewInline(pathOrUrl) {
5659
- const category = getFileCategory(pathOrUrl);
5660
- return category !== "unknown";
5661
- }
5662
- function isTextFile(pathOrUrl) {
5663
- const category = getFileCategory(pathOrUrl);
5664
- return category === "markdown" || category === "text";
5665
- }
5666
- var COMMON_FILE_EXTENSIONS = /* @__PURE__ */ new Set([
5667
- // Code
5668
- "ts",
5669
- "tsx",
5670
- "js",
5671
- "jsx",
5672
- "mjs",
5673
- "cjs",
5674
- "html",
5675
- "htm",
5676
- "css",
5677
- "less",
5678
- "scss",
5679
- "md",
5680
- "txt",
5681
- "mdx",
5682
- "json",
5683
- "yaml",
5684
- "yml",
5685
- "py",
5686
- "rb",
5687
- "go",
5688
- "rs",
5689
- "java",
5690
- "kt",
5691
- "swift",
5692
- "c",
5693
- "cpp",
5694
- "h",
5695
- "hpp",
5696
- "cs",
5697
- "php",
5698
- "vue",
5699
- "svelte",
5700
- "sql",
5701
- "sh",
5702
- "bash",
5703
- "zsh",
5704
- "toml",
5705
- "xml",
5706
- // Media
5707
- "png",
5708
- "jpg",
5709
- "jpeg",
5710
- "gif",
5711
- "svg",
5712
- "webp",
5713
- "ico",
5714
- "mp4",
5715
- "webm",
5716
- "mp3",
5717
- "wav",
5718
- "pdf",
5719
- // Office
5720
- "ppt",
5721
- "pptx",
5722
- "doc",
5723
- "docx",
5724
- "xls",
5725
- "xlsx",
5726
- "odt",
5727
- "ods",
5728
- "odp",
5729
- "rtf",
5730
- "csv",
5731
- "key",
5732
- "numbers",
5733
- "pages"
5734
- ]);
5735
- function isFileName(value) {
5736
- if (!value || typeof value !== "string" || !value.trim()) return false;
5737
- const ext = getFileExtension(value);
5738
- return ext ? COMMON_FILE_EXTENSIONS.has(ext) : false;
5739
- }
5740
-
5741
- // src/components/GenUI/FileRenderer.tsx
5742
5865
  var import_jsx_runtime17 = require("react/jsx-runtime");
5743
5866
  var useStyles2 = (0, import_antd_style4.createStyles)(({ token, css }) => ({
5744
5867
  container: css`
@@ -13652,7 +13775,7 @@ var MiddlewareSectionCard = ({ middleware, middlewareType, onToggle, onConfigCha
13652
13775
  if (key === "serverKeys" && middleware.config.connectAll === true) {
13653
13776
  return null;
13654
13777
  }
13655
- if (key === "isolatedLevel") {
13778
+ if (key === "vmIsolation") {
13656
13779
  return null;
13657
13780
  }
13658
13781
  return renderConfigField(
@@ -18032,7 +18155,7 @@ var WorkspaceContextProvider = ({
18032
18155
  );
18033
18156
  const listPathByFolder = (0, import_react56.useCallback)(
18034
18157
  async (folder) => {
18035
- const normalizedPath = folder.startsWith("/") ? folder : `/${folder}`;
18158
+ const normalizedPath = folder.startsWith("/") || folder.startsWith("~/") ? folder : `/${folder}`;
18036
18159
  return listPath(normalizedPath);
18037
18160
  },
18038
18161
  [listPath]
@@ -18059,8 +18182,7 @@ var WorkspaceContextProvider = ({
18059
18182
  );
18060
18183
  const uploadFileToFolder = (0, import_react56.useCallback)(
18061
18184
  async (folder, file) => {
18062
- const normalizedPath = folder.startsWith("/") ? folder : `/${folder}`;
18063
- return uploadFile(normalizedPath, file);
18185
+ return uploadFile(folder, file);
18064
18186
  },
18065
18187
  [uploadFile]
18066
18188
  );
@@ -26477,7 +26599,9 @@ var useStyles18 = (0, import_antd_style31.createStyles)(({ token, css }) => ({
26477
26599
  gap: 8px;
26478
26600
  `
26479
26601
  }));
26480
- var ProjectSelector = () => {
26602
+ var ProjectSelector = ({
26603
+ disableDropdown = true
26604
+ }) => {
26481
26605
  const { styles } = useStyles18();
26482
26606
  const {
26483
26607
  workspaceId,
@@ -26588,12 +26712,20 @@ var ProjectSelector = () => {
26588
26712
  }
26589
26713
  ) }),
26590
26714
  /* @__PURE__ */ (0, import_jsx_runtime104.jsx)("span", { className: styles.divider, children: "/" }),
26591
- /* @__PURE__ */ (0, import_jsx_runtime104.jsxs)("div", { className: styles.projectTrigger, onClick: toggleProjectList, children: [
26592
- /* @__PURE__ */ (0, import_jsx_runtime104.jsx)("div", { className: styles.projectTriggerIcon, children: /* @__PURE__ */ (0, import_jsx_runtime104.jsx)(import_lucide_react25.Folder, { size: 16 }) }),
26593
- /* @__PURE__ */ (0, import_jsx_runtime104.jsx)("div", { className: styles.projectTriggerInfo, children: /* @__PURE__ */ (0, import_jsx_runtime104.jsx)("div", { className: styles.projectTriggerName, children: currentProject?.name || "Select Project" }) }),
26594
- /* @__PURE__ */ (0, import_jsx_runtime104.jsx)("div", { className: `${styles.projectTriggerArrow} ${isProjectListOpen ? "expanded" : ""}`, children: /* @__PURE__ */ (0, import_jsx_runtime104.jsx)(import_lucide_react25.ChevronDown, { size: 14 }) })
26595
- ] }),
26596
- isProjectListOpen && /* @__PURE__ */ (0, import_jsx_runtime104.jsxs)("div", { className: styles.projectDropdown, children: [
26715
+ /* @__PURE__ */ (0, import_jsx_runtime104.jsxs)(
26716
+ "div",
26717
+ {
26718
+ className: styles.projectTrigger,
26719
+ onClick: disableDropdown ? void 0 : toggleProjectList,
26720
+ style: { cursor: disableDropdown ? "default" : "pointer" },
26721
+ children: [
26722
+ /* @__PURE__ */ (0, import_jsx_runtime104.jsx)("div", { className: styles.projectTriggerIcon, children: /* @__PURE__ */ (0, import_jsx_runtime104.jsx)(import_lucide_react25.Folder, { size: 16 }) }),
26723
+ /* @__PURE__ */ (0, import_jsx_runtime104.jsx)("div", { className: styles.projectTriggerInfo, children: /* @__PURE__ */ (0, import_jsx_runtime104.jsx)("div", { className: styles.projectTriggerName, children: currentProject?.name || "Select Project" }) }),
26724
+ !disableDropdown && /* @__PURE__ */ (0, import_jsx_runtime104.jsx)("div", { className: `${styles.projectTriggerArrow} ${isProjectListOpen ? "expanded" : ""}`, children: /* @__PURE__ */ (0, import_jsx_runtime104.jsx)(import_lucide_react25.ChevronDown, { size: 14 }) })
26725
+ ]
26726
+ }
26727
+ ),
26728
+ !disableDropdown && isProjectListOpen && /* @__PURE__ */ (0, import_jsx_runtime104.jsxs)("div", { className: styles.projectDropdown, children: [
26597
26729
  projects.map((project) => /* @__PURE__ */ (0, import_jsx_runtime104.jsxs)(
26598
26730
  "div",
26599
26731
  {
@@ -26666,6 +26798,8 @@ var import_antd_style32 = require("antd-style");
26666
26798
  var import_jsx_runtime105 = require("react/jsx-runtime");
26667
26799
  var useStyles19 = (0, import_antd_style32.createStyles)(({ token, css }) => ({
26668
26800
  container: css`
26801
+ height: 100%;
26802
+ overflow-y: auto;
26669
26803
  padding: 12px;
26670
26804
  font-size: 13px;
26671
26805
  background: transparent;
@@ -27020,42 +27154,46 @@ var ToolPanelFiles = () => {
27020
27154
  const resourceFolders = (0, import_react82.useMemo)(() => {
27021
27155
  return config.resourceFolders && config.resourceFolders.length > 0 ? config.resourceFolders : [{ name: "/", displayName: "Project Assets", allowUpload: true }];
27022
27156
  }, [config.resourceFolders]);
27023
- const loadAssetsForFolder = (0, import_react82.useCallback)(async (folder) => {
27024
- if (!workspaceId || !projectId) {
27025
- setFolderEntries((prev) => ({ ...prev, [folder.name]: [] }));
27026
- return;
27027
- }
27028
- setFolderLoading((prev) => ({ ...prev, [folder.name]: true }));
27029
- try {
27030
- const items = await listPathByFolder(folder.name);
27031
- setFolderEntries((prev) => ({ ...prev, [folder.name]: items }));
27032
- setDirectoryChildren((prev) => {
27033
- const next = { ...prev };
27034
- const folderPath = folder.name === "/" ? "/" : folder.name.replace(/\/$/, "");
27035
- Object.keys(next).forEach((key) => {
27036
- if (key === folderPath || key.startsWith(`${folderPath}/`)) {
27037
- delete next[key];
27038
- }
27039
- });
27040
- return next;
27041
- });
27042
- setDirectoryExpanded((prev) => {
27043
- const next = { ...prev };
27044
- const folderPath = folder.name === "/" ? "/" : folder.name.replace(/\/$/, "");
27045
- Object.keys(next).forEach((key) => {
27046
- if (key === folderPath || key.startsWith(`${folderPath}/`)) {
27047
- delete next[key];
27048
- }
27049
- });
27050
- return next;
27051
- });
27052
- } catch (error) {
27053
- console.error(`Failed to load assets for folder ${folder.name}:`, error);
27054
- setFolderEntries((prev) => ({ ...prev, [folder.name]: [] }));
27055
- } finally {
27056
- setFolderLoading((prev) => ({ ...prev, [folder.name]: false }));
27057
- }
27058
- }, [workspaceId, projectId, listPathByFolder]);
27157
+ const loadAssetsForFolder = (0, import_react82.useCallback)(
27158
+ async (folder, clearSubdirectoryCache = true) => {
27159
+ if (!workspaceId || !projectId) {
27160
+ setFolderEntries((prev) => ({ ...prev, [folder.name]: [] }));
27161
+ return;
27162
+ }
27163
+ setFolderLoading((prev) => ({ ...prev, [folder.name]: true }));
27164
+ try {
27165
+ const items = await listPathByFolder(folder.name);
27166
+ setFolderEntries((prev) => ({ ...prev, [folder.name]: items }));
27167
+ if (clearSubdirectoryCache) {
27168
+ const folderPath = folder.name === "/" ? "/" : folder.name.replace(/\/$/, "");
27169
+ setDirectoryChildren((prev) => {
27170
+ const next = { ...prev };
27171
+ Object.keys(next).forEach((key) => {
27172
+ if (key === folderPath || key.startsWith(`${folderPath}/`)) {
27173
+ delete next[key];
27174
+ }
27175
+ });
27176
+ return next;
27177
+ });
27178
+ setDirectoryExpanded((prev) => {
27179
+ const next = { ...prev };
27180
+ Object.keys(next).forEach((key) => {
27181
+ if (key === folderPath || key.startsWith(`${folderPath}/`)) {
27182
+ delete next[key];
27183
+ }
27184
+ });
27185
+ return next;
27186
+ });
27187
+ }
27188
+ } catch (error) {
27189
+ console.error(`Failed to load assets for folder ${folder.name}:`, error);
27190
+ setFolderEntries((prev) => ({ ...prev, [folder.name]: [] }));
27191
+ } finally {
27192
+ setFolderLoading((prev) => ({ ...prev, [folder.name]: false }));
27193
+ }
27194
+ },
27195
+ [workspaceId, projectId, listPathByFolder]
27196
+ );
27059
27197
  const handleToggleDirectory = (0, import_react82.useCallback)(async (path) => {
27060
27198
  const isExpanded = directoryExpanded[path] || false;
27061
27199
  if (isExpanded) {
@@ -27063,9 +27201,6 @@ var ToolPanelFiles = () => {
27063
27201
  return;
27064
27202
  }
27065
27203
  setDirectoryExpanded((prev) => ({ ...prev, [path]: true }));
27066
- if (directoryChildren[path]) {
27067
- return;
27068
- }
27069
27204
  setDirectoryLoading((prev) => ({ ...prev, [path]: true }));
27070
27205
  try {
27071
27206
  const items = await listPath(path);
@@ -27076,10 +27211,10 @@ var ToolPanelFiles = () => {
27076
27211
  } finally {
27077
27212
  setDirectoryLoading((prev) => ({ ...prev, [path]: false }));
27078
27213
  }
27079
- }, [directoryChildren, directoryExpanded, listPath]);
27214
+ }, [directoryExpanded, listPath]);
27080
27215
  (0, import_react82.useEffect)(() => {
27081
27216
  resourceFolders.forEach((folder) => {
27082
- void loadAssetsForFolder(folder);
27217
+ void loadAssetsForFolder(folder, false);
27083
27218
  });
27084
27219
  }, [resourceFolders, loadAssetsForFolder]);
27085
27220
  const handleAssetClick = (0, import_react82.useCallback)((asset) => {