@robosystems/core 0.15.1 → 0.16.0

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.
@@ -94,6 +94,13 @@ export function ConsoleContent({ config, variant = 'page', }) {
94
94
  // Moves on at every graph switch, so a switch away and back (A → B → A)
95
95
  // still retires a request made before it.
96
96
  const graphEpochRef = useRef(0);
97
+ // The scope a request made now belongs to; true once the console has left it.
98
+ const leftScope = () => {
99
+ const requestGraphId = graphId;
100
+ const requestEpoch = graphEpochRef.current;
101
+ return () => currentGraphRef.current !== requestGraphId ||
102
+ graphEpochRef.current !== requestEpoch;
103
+ };
97
104
  // Terminal state
98
105
  const [terminalMessages, setTerminalMessages] = useState([]);
99
106
  const [commandInput, setCommandInput] = useState('');
@@ -646,6 +653,7 @@ export function ConsoleContent({ config, variant = 'page', }) {
646
653
  return;
647
654
  }
648
655
  addSystemMessage(`Searching for "${searchQuery}"...`);
656
+ const stale = leftScope();
649
657
  try {
650
658
  const body = {
651
659
  query: searchQuery,
@@ -655,6 +663,8 @@ export function ConsoleContent({ config, variant = 'page', }) {
655
663
  path: { graph_id: graphId },
656
664
  body: body,
657
665
  });
666
+ if (stale())
667
+ return;
658
668
  if (res.data) {
659
669
  const data = res.data;
660
670
  if (data.hits.length === 0) {
@@ -681,6 +691,8 @@ export function ConsoleContent({ config, variant = 'page', }) {
681
691
  }
682
692
  }
683
693
  catch (_c) {
694
+ if (stale())
695
+ return;
684
696
  addErrorMessage('An error occurred while searching.');
685
697
  }
686
698
  return;
@@ -710,11 +722,14 @@ export function ConsoleContent({ config, variant = 'page', }) {
710
722
  return;
711
723
  }
712
724
  addSystemMessage(`Recalling memories for "${recallQuery}"...`);
725
+ const stale = leftScope();
713
726
  try {
714
727
  const res = await SDK.recallMemory({
715
728
  path: { graph_id: graphId },
716
729
  body: { query: recallQuery, k: 10 },
717
730
  });
731
+ if (stale())
732
+ return;
718
733
  if (res.data) {
719
734
  const data = res.data;
720
735
  if (data.hits.length === 0) {
@@ -746,6 +761,8 @@ export function ConsoleContent({ config, variant = 'page', }) {
746
761
  }
747
762
  }
748
763
  catch (_d) {
764
+ if (stale())
765
+ return;
749
766
  addErrorMessage('An error occurred while recalling memories.');
750
767
  }
751
768
  return;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@robosystems/core",
3
- "version": "0.15.1",
3
+ "version": "0.16.0",
4
4
  "description": "Shared RoboSystems frontend core library (auth, contexts, task monitoring, UI components) for the RoboSystems Next.js apps",
5
5
  "license": "MIT",
6
6
  "private": false,