@parhelia/core 0.1.12565 → 0.1.12572

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.
Files changed (29) hide show
  1. package/dist/editor/ai/AgentTerminal.js +18 -0
  2. package/dist/editor/ai/AgentTerminal.js.map +1 -1
  3. package/dist/editor/ai/ToolCallDisplay.js +134 -111
  4. package/dist/editor/ai/ToolCallDisplay.js.map +1 -1
  5. package/dist/editor/client/EditorShell.js +74 -23
  6. package/dist/editor/client/EditorShell.js.map +1 -1
  7. package/dist/editor/services/agentService.d.ts +11 -0
  8. package/dist/editor/services/agentService.js +7 -0
  9. package/dist/editor/services/agentService.js.map +1 -1
  10. package/dist/editor/settings/IndexOverview.js +3 -1
  11. package/dist/editor/settings/IndexOverview.js.map +1 -1
  12. package/dist/editor/settings/index/CollectionWarningsDisplay.d.ts +10 -0
  13. package/dist/editor/settings/index/CollectionWarningsDisplay.js +16 -0
  14. package/dist/editor/settings/index/CollectionWarningsDisplay.js.map +1 -0
  15. package/dist/editor/settings/index/useIndexStatus.js +3 -0
  16. package/dist/editor/settings/index/useIndexStatus.js.map +1 -1
  17. package/dist/editor/settings/panels/SearchConfigPanel.js +64 -3
  18. package/dist/editor/settings/panels/SearchConfigPanel.js.map +1 -1
  19. package/dist/editor/settings/panels/StatusPanel.js +7 -2
  20. package/dist/editor/settings/panels/StatusPanel.js.map +1 -1
  21. package/dist/editor/template-wizard/TemplateStructureInlineEditor.js +3 -2
  22. package/dist/editor/template-wizard/TemplateStructureInlineEditor.js.map +1 -1
  23. package/dist/revision.d.ts +2 -2
  24. package/dist/revision.js +2 -2
  25. package/dist/setup/services/setupWizardService.d.ts +9 -0
  26. package/dist/setup/services/setupWizardService.js +20 -0
  27. package/dist/setup/services/setupWizardService.js.map +1 -1
  28. package/dist/types.d.ts +6 -0
  29. package/package.json +1 -1
@@ -396,10 +396,15 @@ export function EditorShell({ configuration, className, item: loadItemDescriptor
396
396
  // When switchWorkspace already pushed a URL entry, the follow-up URL sync
397
397
  // effect should only *replace* that entry (not push a second one).
398
398
  const switchWorkspacePushedRef = useRef(false);
399
- // Ref to track the last known URL for the popstate handler
400
- // This is updated both when the popstate handler runs AND when the URL sync effect pushes a new URL
401
- // Without this, the popstate handler would have a stale lastUrl value after pushState calls
402
- const lastUrlRef = useRef(typeof window !== "undefined" ? window.location.href : "");
399
+ // Ref to track the last known URL for the popstate handler.
400
+ // Uses pathname+search (not full href) so comparisons are consistent with the
401
+ // relative URLs produced by the URL sync effect and updateUrl.
402
+ const lastUrlRef = useRef(typeof window !== "undefined"
403
+ ? `${window.location.pathname}${window.location.search}`
404
+ : "");
405
+ // The very first URL sync after initial load should replaceState (not pushState)
406
+ // so the initial bare URL isn't left as a dead-end history entry.
407
+ const isFirstUrlSyncRef = useRef(true);
403
408
  const [inlineEditingFieldElement, setInlineEditingFieldElement] = useState();
404
409
  const [lockedField, setLockedField] = useState();
405
410
  const [itemLanguages, setItemLanguages] = useState([]);
@@ -828,6 +833,39 @@ export function EditorShell({ configuration, className, item: loadItemDescriptor
828
833
  }
829
834
  return window.history.state;
830
835
  }, []);
836
+ useEffect(() => {
837
+ if (isInitialLoad) {
838
+ return;
839
+ }
840
+ const itemid = searchParams.get("itemid");
841
+ const language = searchParams.get("lang") ?? searchParams.get("language");
842
+ const versionParam = searchParams.get("version");
843
+ const version = versionParam ? parseInt(versionParam, 10) : 0;
844
+ const itemId = cleanId(itemid ?? undefined);
845
+ if (!itemId || !language) {
846
+ return;
847
+ }
848
+ const currentDescriptor = currentItemDescriptorRef.current;
849
+ const matchesCurrentDescriptor = currentDescriptor?.id === itemId &&
850
+ currentDescriptor?.language === language &&
851
+ (!version || currentDescriptor?.version === version);
852
+ if (matchesCurrentDescriptor) {
853
+ return;
854
+ }
855
+ isHandlingPopStateRef.current = true;
856
+ loadItemRef
857
+ .current({
858
+ id: itemId,
859
+ language,
860
+ version,
861
+ }, {
862
+ addToBrowseHistory: false,
863
+ skipViewChange: true,
864
+ })
865
+ .finally(() => {
866
+ isHandlingPopStateRef.current = false;
867
+ });
868
+ }, [isInitialLoad, searchParams]);
831
869
  const startTour = useCallback(() => {
832
870
  setIsTourActive(true);
833
871
  // Persist tour state to URL so it survives navigation/remounts
@@ -1097,7 +1135,7 @@ export function EditorShell({ configuration, className, item: loadItemDescriptor
1097
1135
  };
1098
1136
  // Listen for browser navigation events (back/forward buttons)
1099
1137
  const handlePopState = (event) => {
1100
- const newUrl = window.location.href;
1138
+ const newUrl = `${window.location.pathname}${window.location.search}`;
1101
1139
  if (newUrl !== lastUrlRef.current) {
1102
1140
  lastUrlRef.current = newUrl;
1103
1141
  // Mark that we're handling a popstate to prevent URL sync from pushing to history
@@ -1108,20 +1146,18 @@ export function EditorShell({ configuration, className, item: loadItemDescriptor
1108
1146
  if (urlWorkspace && urlWorkspace !== workspaceIdRef.current) {
1109
1147
  setWorkspaceId(urlWorkspace);
1110
1148
  }
1111
- // Handle sidebar changes
1149
+ // Handle sidebar changes — clear when absent so state matches the URL
1112
1150
  const sidebarParam = urlParams.get("sidebar");
1113
- if (sidebarParam !== null) {
1114
- const newSidebars = sidebarParam.split(",").filter(Boolean);
1115
- setOpenSidebars(newSidebars);
1116
- }
1151
+ const newSidebars = sidebarParam
1152
+ ? sidebarParam.split(",").filter(Boolean)
1153
+ : [];
1154
+ setOpenSidebars(newSidebars);
1117
1155
  // Handle wizard ID changes
1118
1156
  const wizardId = urlParams.get("wizardid");
1119
1157
  setCurrentWizardId(wizardId);
1120
- // Handle compare mode changes
1121
- const compareValue = urlParams.get("compare") === "true";
1122
- if (compareValue !== compareMode) {
1123
- setCompareMode(compareValue);
1124
- }
1158
+ // Handle compare mode changes — always set to avoid stale-closure mismatch
1159
+ // (React skips re-render when the value is unchanged)
1160
+ setCompareMode(urlParams.get("compare") === "true");
1125
1161
  // Handle help panel changes
1126
1162
  const helpParam = urlParams.get("help");
1127
1163
  if (helpParam) {
@@ -1134,9 +1170,9 @@ export function EditorShell({ configuration, className, item: loadItemDescriptor
1134
1170
  else {
1135
1171
  handleSetShowHelpTerminal(false);
1136
1172
  }
1137
- // Handle mode changes
1173
+ // Handle mode changes — always set to avoid stale-closure mismatch
1138
1174
  const urlMode = urlParams.get("mode");
1139
- if (urlMode && urlMode !== mode) {
1175
+ if (urlMode) {
1140
1176
  setMode(urlMode);
1141
1177
  }
1142
1178
  // Handle fullscreen changes (shell-level state)
@@ -2003,8 +2039,11 @@ export function EditorShell({ configuration, className, item: loadItemDescriptor
2003
2039
  return;
2004
2040
  }
2005
2041
  if (newUrl !== oldUrl) {
2006
- if (switchWorkspacePushedRef.current || isRestoringLastSyncedUrl) {
2042
+ if (isFirstUrlSyncRef.current ||
2043
+ switchWorkspacePushedRef.current ||
2044
+ isRestoringLastSyncedUrl) {
2007
2045
  window.history.replaceState(getCurrentHistoryState(), "", newUrl);
2046
+ isFirstUrlSyncRef.current = false;
2008
2047
  switchWorkspacePushedRef.current = false;
2009
2048
  }
2010
2049
  else {
@@ -2012,11 +2051,22 @@ export function EditorShell({ configuration, className, item: loadItemDescriptor
2012
2051
  }
2013
2052
  lastUrlRef.current = newUrl;
2014
2053
  }
2015
- else if (switchWorkspacePushedRef.current) {
2016
- // A workspace change may already have pushed the exact target URL. If we leave
2017
- // this flag set, the next unrelated item navigation will incorrectly replace
2018
- // history instead of pushing a new entry, which breaks browser back/forward.
2019
- switchWorkspacePushedRef.current = false;
2054
+ else {
2055
+ // Even when the first sync is a no-op (URL already matches state), consume
2056
+ // the first-sync flag. Otherwise the *next* real change (e.g. user selecting
2057
+ // a different item) would hit the replaceState branch and overwrite the
2058
+ // landing history entry — eating the "back" target and making browser back
2059
+ // skip past the initial page.
2060
+ if (isFirstUrlSyncRef.current) {
2061
+ isFirstUrlSyncRef.current = false;
2062
+ lastUrlRef.current = newUrl;
2063
+ }
2064
+ if (switchWorkspacePushedRef.current) {
2065
+ // A workspace change may already have pushed the exact target URL. If we leave
2066
+ // this flag set, the next unrelated item navigation will incorrectly replace
2067
+ // history instead of pushing a new entry, which breaks browser back/forward.
2068
+ switchWorkspacePushedRef.current = false;
2069
+ }
2020
2070
  }
2021
2071
  }, [
2022
2072
  currentItemDescriptor,
@@ -2642,6 +2692,7 @@ export function EditorShell({ configuration, className, item: loadItemDescriptor
2642
2692
  : browserPathname;
2643
2693
  if (typeof window !== "undefined") {
2644
2694
  window.history.pushState(getCurrentHistoryState(), "", newUrl);
2695
+ lastUrlRef.current = newUrl;
2645
2696
  }
2646
2697
  else {
2647
2698
  router.push(newUrl, { scroll: false });