Skip to content

🤯 LobeHub - Super-Agents on Your Team. Add super-agents to the chats your team already uses.They take on work by themselves and get better every week.

🐛 fix(desktop): avoid the navigation owner circular re-export (#23195)

Max-Reisinger27a1b99ea785
diff --git a/src/features/NavPanel/backOrigin/locationOwner.ts b/src/features/NavPanel/backOrigin/locationOwner.ts
new file mode 100644
index 00000000000..a80cbfa7252
--- /dev/null
+++ b/src/features/NavPanel/backOrigin/locationOwner.ts
@@ -0,0 +1,14 @@
+/** The owner of locations that do not belong to an Electron tab. */
+export const MAIN_OWNER = 'main';
+
+/** The owners open in one tab scope (personal or a workspace). */
+export interface OpenOwners {
+ ids: string[];
+ scope: string;
+}
+
+export const parseOpenOwners = (key: string | null): OpenOwners | null => {
+ if (key === null) return null;
+ const [scope, ...ids] = key.split('\n');
+ return { ids, scope };
+};
diff --git a/src/features/NavPanel/backOrigin/useLocationOwner.desktop.ts b/src/features/NavPanel/backOrigin/useLocationOwner.desktop.ts
index 2a39ee16044..b544902ba1d 100644
--- a/src/features/NavPanel/backOrigin/useLocationOwner.desktop.ts
+++ b/src/features/NavPanel/backOrigin/useLocationOwner.desktop.ts
@@ -1,9 +1,9 @@
import { tabScopeKey } from '@/features/Electron/titlebar/TabBar/scope';
import { useElectronStore } from '@/store/electron';
-import { MAIN_OWNER } from './useLocationOwner';
+import { MAIN_OWNER } from './locationOwner';
-export { MAIN_OWNER, type OpenOwners, parseOpenOwners } from './useLocationOwner';
+export { MAIN_OWNER, type OpenOwners, parseOpenOwners } from './locationOwner';
/**
* Which history a location belongs to: each Electron tab (or split pane) keeps
diff --git a/src/features/NavPanel/backOrigin/useLocationOwner.test.ts b/src/features/NavPanel/backOrigin/useLocationOwner.test.ts
new file mode 100644
index 00000000000..a7cc7b0db52
--- /dev/null
+++ b/src/features/NavPanel/backOrigin/useLocationOwner.test.ts
@@ -0,0 +1,25 @@
+// @vitest-environment node
+import { fileURLToPath } from 'node:url';
+
+import { build } from 'vite';
+import { it } from 'vitest';
+
+import { vitePlatformResolve } from '../../../../plugins/vite/platformResolve';
+
+it.each(['desktop', 'web'] as const)('bundles the navigation tracker for %s', async (platform) => {
+ await build({
+ build: {
+ lib: {
+ entry: fileURLToPath(new URL('./Tracker.tsx', import.meta.url)),
+ formats: ['es'],
+ },
+ rolldownOptions: {
+ external: (id) => id === 'react' || id.startsWith('react/') || id.startsWith('@/'),
+ },
+ write: false,
+ },
+ configFile: false,
+ logLevel: 'error',
+ plugins: [vitePlatformResolve(platform)],
+ });
+});
diff --git a/src/features/NavPanel/backOrigin/useLocationOwner.ts b/src/features/NavPanel/backOrigin/useLocationOwner.ts
index 97db4c38b62..21b1cb4bf38 100644
--- a/src/features/NavPanel/backOrigin/useLocationOwner.ts
+++ b/src/features/NavPanel/backOrigin/useLocationOwner.ts
@@ -1,11 +1,6 @@
-/** The owner of locations that do not belong to an Electron tab. */
-export const MAIN_OWNER = 'main';
+import { MAIN_OWNER } from './locationOwner';
-/** The owners open in one tab scope (personal or a workspace). */
-export interface OpenOwners {
- ids: string[];
- scope: string;
-}
+export { MAIN_OWNER, type OpenOwners, parseOpenOwners } from './locationOwner';
/** Which history a location belongs to. The web app has one router. */
export const useLocationOwner = (): string => MAIN_OWNER;
@@ -15,9 +10,3 @@ export const useLocationOwner = (): string => MAIN_OWNER;
* when owners never close.
*/
export const useOpenOwnersKey = (): string | null => null;
-
-export const parseOpenOwners = (key: string | null): OpenOwners | null => {
- if (key === null) return null;
- const [scope, ...ids] = key.split('\n');
- return { ids, scope };
-};