@athenaintel/react 0.10.9 → 0.10.11

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.d.ts CHANGED
@@ -42,6 +42,10 @@ export declare interface AssetPanelState {
42
42
  activeTabId: string | null;
43
43
  viewMode: ViewMode;
44
44
  isFullscreen: boolean;
45
+ /** The current thread ID. Asset panel state is scoped per thread. */
46
+ currentThreadId: string | null;
47
+ /** Per-thread asset panel state — tabs and active tab persist per thread. */
48
+ threadStates: Record<string, ThreadAssetState>;
45
49
  /** Number of registered hosts that can reveal the asset panel. */
46
50
  assetPanelHostCount: number;
47
51
  /** Generation counter for auto-open tracking — incremented on reset */
@@ -59,6 +63,11 @@ export declare interface AssetPanelState {
59
63
  setViewMode: (mode: ViewMode) => void;
60
64
  closePanel: () => void;
61
65
  toggleFullscreen: () => void;
66
+ /**
67
+ * Switch the active thread. Saves the current thread's asset panel state
68
+ * and restores the new thread's state (if any). Pass null to clear.
69
+ */
70
+ setCurrentThread: (threadId: string | null) => void;
62
71
  /** Reset auto-open tracking (increments generation so new assets can auto-open) */
63
72
  resetAutoOpen: () => void;
64
73
  /** Check if an asset should auto-open, and mark it as opened if so */
@@ -928,6 +937,12 @@ export declare const themes: {
928
937
  /** Convert an AthenaTheme object to a CSS variables style object. */
929
938
  export declare function themeToStyleVars(theme: AthenaTheme): Record<string, string>;
930
939
 
940
+ declare interface ThreadAssetState {
941
+ tabs: AssetTab[];
942
+ activeTabId: string | null;
943
+ isOpen: boolean;
944
+ }
945
+
931
946
  export declare function ThreadList({ className }: ThreadListProps): JSX.Element;
932
947
 
933
948
  export declare interface ThreadListProps {
package/dist/index.js CHANGED
@@ -24690,6 +24690,335 @@ const ThreadListRefreshContext = createContext(null);
24690
24690
  function useRefreshThreadList() {
24691
24691
  return useContext(ThreadListRefreshContext);
24692
24692
  }
24693
+ function useAthenaThreadManager() {
24694
+ const runtime = useAssistantRuntime({ optional: true });
24695
+ const remoteId = useThread({ optional: true, selector: (s) => {
24696
+ var _a2;
24697
+ return (_a2 = s.metadata) == null ? void 0 : _a2.remoteId;
24698
+ } });
24699
+ const isThreadLoading = useThread({ optional: true, selector: (s) => s.isLoading }) ?? false;
24700
+ const isListLoading = useThreadList({ optional: true, selector: (s) => s.isLoading });
24701
+ const runtimeRef = useRef(runtime);
24702
+ runtimeRef.current = runtime;
24703
+ const switchToThread = useCallback(
24704
+ (id) => runtimeRef.current.threads.switchToThread(id),
24705
+ []
24706
+ );
24707
+ const switchToNewThread = useCallback(
24708
+ () => runtimeRef.current.threads.switchToNewThread(),
24709
+ []
24710
+ );
24711
+ const activeThreadId = remoteId ?? null;
24712
+ return useMemo(() => {
24713
+ if (!runtime || isListLoading == null) {
24714
+ return null;
24715
+ }
24716
+ return {
24717
+ activeThreadId,
24718
+ isListLoading,
24719
+ isThreadLoading,
24720
+ switchToThread,
24721
+ switchToNewThread
24722
+ };
24723
+ }, [runtime, activeThreadId, isListLoading, isThreadLoading, switchToThread, switchToNewThread]);
24724
+ }
24725
+ function createJSONStorage(getStorage, options) {
24726
+ let storage;
24727
+ try {
24728
+ storage = getStorage();
24729
+ } catch (e) {
24730
+ return;
24731
+ }
24732
+ const persistStorage = {
24733
+ getItem: (name) => {
24734
+ var _a2;
24735
+ const parse2 = (str2) => {
24736
+ if (str2 === null) {
24737
+ return null;
24738
+ }
24739
+ return JSON.parse(str2, void 0);
24740
+ };
24741
+ const str = (_a2 = storage.getItem(name)) != null ? _a2 : null;
24742
+ if (str instanceof Promise) {
24743
+ return str.then(parse2);
24744
+ }
24745
+ return parse2(str);
24746
+ },
24747
+ setItem: (name, newValue) => storage.setItem(name, JSON.stringify(newValue, void 0)),
24748
+ removeItem: (name) => storage.removeItem(name)
24749
+ };
24750
+ return persistStorage;
24751
+ }
24752
+ const toThenable = (fn) => (input) => {
24753
+ try {
24754
+ const result = fn(input);
24755
+ if (result instanceof Promise) {
24756
+ return result;
24757
+ }
24758
+ return {
24759
+ then(onFulfilled) {
24760
+ return toThenable(onFulfilled)(result);
24761
+ },
24762
+ catch(_onRejected) {
24763
+ return this;
24764
+ }
24765
+ };
24766
+ } catch (e) {
24767
+ return {
24768
+ then(_onFulfilled) {
24769
+ return this;
24770
+ },
24771
+ catch(onRejected) {
24772
+ return toThenable(onRejected)(e);
24773
+ }
24774
+ };
24775
+ }
24776
+ };
24777
+ const persistImpl = (config2, baseOptions) => (set2, get2, api) => {
24778
+ let options = {
24779
+ storage: createJSONStorage(() => window.localStorage),
24780
+ partialize: (state) => state,
24781
+ version: 0,
24782
+ merge: (persistedState, currentState) => ({
24783
+ ...currentState,
24784
+ ...persistedState
24785
+ }),
24786
+ ...baseOptions
24787
+ };
24788
+ let hasHydrated = false;
24789
+ let hydrationVersion = 0;
24790
+ const hydrationListeners = /* @__PURE__ */ new Set();
24791
+ const finishHydrationListeners = /* @__PURE__ */ new Set();
24792
+ let storage = options.storage;
24793
+ if (!storage) {
24794
+ return config2(
24795
+ (...args) => {
24796
+ console.warn(
24797
+ `[zustand persist middleware] Unable to update item '${options.name}', the given storage is currently unavailable.`
24798
+ );
24799
+ set2(...args);
24800
+ },
24801
+ get2,
24802
+ api
24803
+ );
24804
+ }
24805
+ const setItem = () => {
24806
+ const state = options.partialize({ ...get2() });
24807
+ return storage.setItem(options.name, {
24808
+ state,
24809
+ version: options.version
24810
+ });
24811
+ };
24812
+ const savedSetState = api.setState;
24813
+ api.setState = (state, replace2) => {
24814
+ savedSetState(state, replace2);
24815
+ return setItem();
24816
+ };
24817
+ const configResult = config2(
24818
+ (...args) => {
24819
+ set2(...args);
24820
+ return setItem();
24821
+ },
24822
+ get2,
24823
+ api
24824
+ );
24825
+ api.getInitialState = () => configResult;
24826
+ let stateFromStorage;
24827
+ const hydrate = () => {
24828
+ var _a2, _b;
24829
+ if (!storage) return;
24830
+ const currentVersion = ++hydrationVersion;
24831
+ hasHydrated = false;
24832
+ hydrationListeners.forEach((cb) => {
24833
+ var _a22;
24834
+ return cb((_a22 = get2()) != null ? _a22 : configResult);
24835
+ });
24836
+ const postRehydrationCallback = ((_b = options.onRehydrateStorage) == null ? void 0 : _b.call(options, (_a2 = get2()) != null ? _a2 : configResult)) || void 0;
24837
+ return toThenable(storage.getItem.bind(storage))(options.name).then((deserializedStorageValue) => {
24838
+ if (deserializedStorageValue) {
24839
+ if (typeof deserializedStorageValue.version === "number" && deserializedStorageValue.version !== options.version) {
24840
+ if (options.migrate) {
24841
+ const migration = options.migrate(
24842
+ deserializedStorageValue.state,
24843
+ deserializedStorageValue.version
24844
+ );
24845
+ if (migration instanceof Promise) {
24846
+ return migration.then((result) => [true, result]);
24847
+ }
24848
+ return [true, migration];
24849
+ }
24850
+ console.error(
24851
+ `State loaded from storage couldn't be migrated since no migrate function was provided`
24852
+ );
24853
+ } else {
24854
+ return [false, deserializedStorageValue.state];
24855
+ }
24856
+ }
24857
+ return [false, void 0];
24858
+ }).then((migrationResult) => {
24859
+ var _a22;
24860
+ if (currentVersion !== hydrationVersion) {
24861
+ return;
24862
+ }
24863
+ const [migrated, migratedState] = migrationResult;
24864
+ stateFromStorage = options.merge(
24865
+ migratedState,
24866
+ (_a22 = get2()) != null ? _a22 : configResult
24867
+ );
24868
+ set2(stateFromStorage, true);
24869
+ if (migrated) {
24870
+ return setItem();
24871
+ }
24872
+ }).then(() => {
24873
+ if (currentVersion !== hydrationVersion) {
24874
+ return;
24875
+ }
24876
+ postRehydrationCallback == null ? void 0 : postRehydrationCallback(stateFromStorage, void 0);
24877
+ stateFromStorage = get2();
24878
+ hasHydrated = true;
24879
+ finishHydrationListeners.forEach((cb) => cb(stateFromStorage));
24880
+ }).catch((e) => {
24881
+ if (currentVersion !== hydrationVersion) {
24882
+ return;
24883
+ }
24884
+ postRehydrationCallback == null ? void 0 : postRehydrationCallback(void 0, e);
24885
+ });
24886
+ };
24887
+ api.persist = {
24888
+ setOptions: (newOptions) => {
24889
+ options = {
24890
+ ...options,
24891
+ ...newOptions
24892
+ };
24893
+ if (newOptions.storage) {
24894
+ storage = newOptions.storage;
24895
+ }
24896
+ },
24897
+ clearStorage: () => {
24898
+ storage == null ? void 0 : storage.removeItem(options.name);
24899
+ },
24900
+ getOptions: () => options,
24901
+ rehydrate: () => hydrate(),
24902
+ hasHydrated: () => hasHydrated,
24903
+ onHydrate: (cb) => {
24904
+ hydrationListeners.add(cb);
24905
+ return () => {
24906
+ hydrationListeners.delete(cb);
24907
+ };
24908
+ },
24909
+ onFinishHydration: (cb) => {
24910
+ finishHydrationListeners.add(cb);
24911
+ return () => {
24912
+ finishHydrationListeners.delete(cb);
24913
+ };
24914
+ }
24915
+ };
24916
+ if (!options.skipHydration) {
24917
+ hydrate();
24918
+ }
24919
+ return stateFromStorage || configResult;
24920
+ };
24921
+ const persist = persistImpl;
24922
+ const useAssetPanelStore = create()(
24923
+ persist(
24924
+ (set2, get2) => ({
24925
+ isOpen: false,
24926
+ tabs: [],
24927
+ activeTabId: null,
24928
+ viewMode: "tabs",
24929
+ isFullscreen: false,
24930
+ currentThreadId: null,
24931
+ threadStates: {},
24932
+ assetPanelHostCount: 0,
24933
+ autoOpenGeneration: 0,
24934
+ autoOpenedAssets: /* @__PURE__ */ new Map(),
24935
+ registerAssetPanelHost: () => set2((state) => ({ assetPanelHostCount: state.assetPanelHostCount + 1 })),
24936
+ unregisterAssetPanelHost: () => set2((state) => ({ assetPanelHostCount: Math.max(0, state.assetPanelHostCount - 1) })),
24937
+ openAsset: (assetId, meta) => set2((s) => {
24938
+ const existing = s.tabs.find((t) => t.id === assetId);
24939
+ if (existing) {
24940
+ const tabs = meta ? s.tabs.map(
24941
+ (t) => t.id === assetId ? { ...t, name: meta.name ?? t.name, type: meta.type ?? t.type } : t
24942
+ ) : s.tabs;
24943
+ return { isOpen: true, tabs, activeTabId: assetId };
24944
+ }
24945
+ const newTab = {
24946
+ id: assetId,
24947
+ name: (meta == null ? void 0 : meta.name) ?? null,
24948
+ type: (meta == null ? void 0 : meta.type) ?? "unknown"
24949
+ };
24950
+ return { isOpen: true, tabs: [...s.tabs, newTab], activeTabId: assetId };
24951
+ }),
24952
+ closeTab: (assetId) => set2((s) => {
24953
+ var _a2;
24954
+ const tabs = s.tabs.filter((t) => t.id !== assetId);
24955
+ if (tabs.length === 0) {
24956
+ return { isOpen: false, tabs: [], activeTabId: null, isFullscreen: false };
24957
+ }
24958
+ const activeTabId = s.activeTabId === assetId ? ((_a2 = tabs[Math.min(s.tabs.findIndex((t) => t.id === assetId), tabs.length - 1)]) == null ? void 0 : _a2.id) ?? null : s.activeTabId;
24959
+ return { tabs, activeTabId };
24960
+ }),
24961
+ setActiveTab: (assetId) => set2({ activeTabId: assetId, viewMode: "tabs" }),
24962
+ setViewMode: (mode) => set2({ viewMode: mode }),
24963
+ closePanel: () => set2({ isOpen: false, tabs: [], activeTabId: null, viewMode: "tabs", isFullscreen: false }),
24964
+ toggleFullscreen: () => set2((s) => ({ isFullscreen: !s.isFullscreen })),
24965
+ setCurrentThread: (threadId) => set2((s) => {
24966
+ if (s.currentThreadId === threadId) {
24967
+ return s;
24968
+ }
24969
+ const threadStates = { ...s.threadStates };
24970
+ if (s.currentThreadId !== null) {
24971
+ threadStates[s.currentThreadId] = {
24972
+ tabs: s.tabs,
24973
+ activeTabId: s.activeTabId,
24974
+ isOpen: s.isOpen
24975
+ };
24976
+ }
24977
+ const restored = threadId !== null ? threadStates[threadId] : void 0;
24978
+ return {
24979
+ currentThreadId: threadId,
24980
+ threadStates,
24981
+ tabs: (restored == null ? void 0 : restored.tabs) ?? [],
24982
+ activeTabId: (restored == null ? void 0 : restored.activeTabId) ?? null,
24983
+ isOpen: (restored == null ? void 0 : restored.isOpen) ?? false,
24984
+ // Reset transient UI state on thread switch
24985
+ isFullscreen: false,
24986
+ viewMode: "tabs"
24987
+ };
24988
+ }),
24989
+ resetAutoOpen: () => set2((s) => ({ autoOpenGeneration: s.autoOpenGeneration + 1 })),
24990
+ markAutoOpened: (assetId) => {
24991
+ const state = get2();
24992
+ if (state.autoOpenedAssets.get(assetId) === state.autoOpenGeneration) {
24993
+ return false;
24994
+ }
24995
+ state.autoOpenedAssets.set(assetId, state.autoOpenGeneration);
24996
+ return true;
24997
+ }
24998
+ }),
24999
+ {
25000
+ name: "athena-react-asset-panel",
25001
+ partialize: ({
25002
+ isOpen,
25003
+ tabs,
25004
+ activeTabId,
25005
+ viewMode,
25006
+ isFullscreen,
25007
+ currentThreadId,
25008
+ threadStates
25009
+ }) => ({
25010
+ isOpen,
25011
+ tabs,
25012
+ activeTabId,
25013
+ viewMode,
25014
+ isFullscreen,
25015
+ currentThreadId,
25016
+ threadStates
25017
+ }),
25018
+ storage: createJSONStorage(() => sessionStorage)
25019
+ }
25020
+ )
25021
+ );
24693
25022
  const THEME_TO_CSS = {
24694
25023
  primary: "--primary",
24695
25024
  primaryForeground: "--primary-foreground",
@@ -25107,7 +25436,19 @@ function AthenaWithThreadList({
25107
25436
  linkClicks,
25108
25437
  citationLinks
25109
25438
  });
25110
- return /* @__PURE__ */ jsx(AssistantRuntimeProvider, { aui, runtime, children: /* @__PURE__ */ jsx(AthenaContext.Provider, { value: athenaConfig, children: /* @__PURE__ */ jsx(ThreadListRefreshContext.Provider, { value: handleRefresh, children: /* @__PURE__ */ jsx(TooltipProvider, { children }) }) }) });
25439
+ return /* @__PURE__ */ jsx(AssistantRuntimeProvider, { aui, runtime, children: /* @__PURE__ */ jsx(AthenaContext.Provider, { value: athenaConfig, children: /* @__PURE__ */ jsx(ThreadListRefreshContext.Provider, { value: handleRefresh, children: /* @__PURE__ */ jsxs(TooltipProvider, { children: [
25440
+ /* @__PURE__ */ jsx(AssetPanelThreadSync, {}),
25441
+ children
25442
+ ] }) }) }) });
25443
+ }
25444
+ function AssetPanelThreadSync() {
25445
+ const threads = useAthenaThreadManager();
25446
+ const setCurrentThread = useAssetPanelStore((s) => s.setCurrentThread);
25447
+ const activeThreadId = (threads == null ? void 0 : threads.activeThreadId) ?? null;
25448
+ useEffect(() => {
25449
+ setCurrentThread(activeThreadId);
25450
+ }, [activeThreadId, setCurrentThread]);
25451
+ return null;
25111
25452
  }
25112
25453
  function AthenaProvider({
25113
25454
  children,
@@ -58864,273 +59205,6 @@ const MentionExtension = Node3.create({
58864
59205
  };
58865
59206
  }
58866
59207
  });
58867
- function createJSONStorage(getStorage, options) {
58868
- let storage;
58869
- try {
58870
- storage = getStorage();
58871
- } catch (e) {
58872
- return;
58873
- }
58874
- const persistStorage = {
58875
- getItem: (name) => {
58876
- var _a2;
58877
- const parse2 = (str2) => {
58878
- if (str2 === null) {
58879
- return null;
58880
- }
58881
- return JSON.parse(str2, void 0);
58882
- };
58883
- const str = (_a2 = storage.getItem(name)) != null ? _a2 : null;
58884
- if (str instanceof Promise) {
58885
- return str.then(parse2);
58886
- }
58887
- return parse2(str);
58888
- },
58889
- setItem: (name, newValue) => storage.setItem(name, JSON.stringify(newValue, void 0)),
58890
- removeItem: (name) => storage.removeItem(name)
58891
- };
58892
- return persistStorage;
58893
- }
58894
- const toThenable = (fn) => (input) => {
58895
- try {
58896
- const result = fn(input);
58897
- if (result instanceof Promise) {
58898
- return result;
58899
- }
58900
- return {
58901
- then(onFulfilled) {
58902
- return toThenable(onFulfilled)(result);
58903
- },
58904
- catch(_onRejected) {
58905
- return this;
58906
- }
58907
- };
58908
- } catch (e) {
58909
- return {
58910
- then(_onFulfilled) {
58911
- return this;
58912
- },
58913
- catch(onRejected) {
58914
- return toThenable(onRejected)(e);
58915
- }
58916
- };
58917
- }
58918
- };
58919
- const persistImpl = (config2, baseOptions) => (set2, get2, api) => {
58920
- let options = {
58921
- storage: createJSONStorage(() => window.localStorage),
58922
- partialize: (state) => state,
58923
- version: 0,
58924
- merge: (persistedState, currentState) => ({
58925
- ...currentState,
58926
- ...persistedState
58927
- }),
58928
- ...baseOptions
58929
- };
58930
- let hasHydrated = false;
58931
- let hydrationVersion = 0;
58932
- const hydrationListeners = /* @__PURE__ */ new Set();
58933
- const finishHydrationListeners = /* @__PURE__ */ new Set();
58934
- let storage = options.storage;
58935
- if (!storage) {
58936
- return config2(
58937
- (...args) => {
58938
- console.warn(
58939
- `[zustand persist middleware] Unable to update item '${options.name}', the given storage is currently unavailable.`
58940
- );
58941
- set2(...args);
58942
- },
58943
- get2,
58944
- api
58945
- );
58946
- }
58947
- const setItem = () => {
58948
- const state = options.partialize({ ...get2() });
58949
- return storage.setItem(options.name, {
58950
- state,
58951
- version: options.version
58952
- });
58953
- };
58954
- const savedSetState = api.setState;
58955
- api.setState = (state, replace2) => {
58956
- savedSetState(state, replace2);
58957
- return setItem();
58958
- };
58959
- const configResult = config2(
58960
- (...args) => {
58961
- set2(...args);
58962
- return setItem();
58963
- },
58964
- get2,
58965
- api
58966
- );
58967
- api.getInitialState = () => configResult;
58968
- let stateFromStorage;
58969
- const hydrate = () => {
58970
- var _a2, _b;
58971
- if (!storage) return;
58972
- const currentVersion = ++hydrationVersion;
58973
- hasHydrated = false;
58974
- hydrationListeners.forEach((cb) => {
58975
- var _a22;
58976
- return cb((_a22 = get2()) != null ? _a22 : configResult);
58977
- });
58978
- const postRehydrationCallback = ((_b = options.onRehydrateStorage) == null ? void 0 : _b.call(options, (_a2 = get2()) != null ? _a2 : configResult)) || void 0;
58979
- return toThenable(storage.getItem.bind(storage))(options.name).then((deserializedStorageValue) => {
58980
- if (deserializedStorageValue) {
58981
- if (typeof deserializedStorageValue.version === "number" && deserializedStorageValue.version !== options.version) {
58982
- if (options.migrate) {
58983
- const migration = options.migrate(
58984
- deserializedStorageValue.state,
58985
- deserializedStorageValue.version
58986
- );
58987
- if (migration instanceof Promise) {
58988
- return migration.then((result) => [true, result]);
58989
- }
58990
- return [true, migration];
58991
- }
58992
- console.error(
58993
- `State loaded from storage couldn't be migrated since no migrate function was provided`
58994
- );
58995
- } else {
58996
- return [false, deserializedStorageValue.state];
58997
- }
58998
- }
58999
- return [false, void 0];
59000
- }).then((migrationResult) => {
59001
- var _a22;
59002
- if (currentVersion !== hydrationVersion) {
59003
- return;
59004
- }
59005
- const [migrated, migratedState] = migrationResult;
59006
- stateFromStorage = options.merge(
59007
- migratedState,
59008
- (_a22 = get2()) != null ? _a22 : configResult
59009
- );
59010
- set2(stateFromStorage, true);
59011
- if (migrated) {
59012
- return setItem();
59013
- }
59014
- }).then(() => {
59015
- if (currentVersion !== hydrationVersion) {
59016
- return;
59017
- }
59018
- postRehydrationCallback == null ? void 0 : postRehydrationCallback(stateFromStorage, void 0);
59019
- stateFromStorage = get2();
59020
- hasHydrated = true;
59021
- finishHydrationListeners.forEach((cb) => cb(stateFromStorage));
59022
- }).catch((e) => {
59023
- if (currentVersion !== hydrationVersion) {
59024
- return;
59025
- }
59026
- postRehydrationCallback == null ? void 0 : postRehydrationCallback(void 0, e);
59027
- });
59028
- };
59029
- api.persist = {
59030
- setOptions: (newOptions) => {
59031
- options = {
59032
- ...options,
59033
- ...newOptions
59034
- };
59035
- if (newOptions.storage) {
59036
- storage = newOptions.storage;
59037
- }
59038
- },
59039
- clearStorage: () => {
59040
- storage == null ? void 0 : storage.removeItem(options.name);
59041
- },
59042
- getOptions: () => options,
59043
- rehydrate: () => hydrate(),
59044
- hasHydrated: () => hasHydrated,
59045
- onHydrate: (cb) => {
59046
- hydrationListeners.add(cb);
59047
- return () => {
59048
- hydrationListeners.delete(cb);
59049
- };
59050
- },
59051
- onFinishHydration: (cb) => {
59052
- finishHydrationListeners.add(cb);
59053
- return () => {
59054
- finishHydrationListeners.delete(cb);
59055
- };
59056
- }
59057
- };
59058
- if (!options.skipHydration) {
59059
- hydrate();
59060
- }
59061
- return stateFromStorage || configResult;
59062
- };
59063
- const persist = persistImpl;
59064
- const useAssetPanelStore = create()(
59065
- persist(
59066
- (set2, get2) => ({
59067
- isOpen: false,
59068
- tabs: [],
59069
- activeTabId: null,
59070
- viewMode: "tabs",
59071
- isFullscreen: false,
59072
- assetPanelHostCount: 0,
59073
- autoOpenGeneration: 0,
59074
- autoOpenedAssets: /* @__PURE__ */ new Map(),
59075
- registerAssetPanelHost: () => set2((state) => ({ assetPanelHostCount: state.assetPanelHostCount + 1 })),
59076
- unregisterAssetPanelHost: () => set2((state) => ({ assetPanelHostCount: Math.max(0, state.assetPanelHostCount - 1) })),
59077
- openAsset: (assetId, meta) => set2((s) => {
59078
- const existing = s.tabs.find((t) => t.id === assetId);
59079
- if (existing) {
59080
- const tabs = meta ? s.tabs.map(
59081
- (t) => t.id === assetId ? { ...t, name: meta.name ?? t.name, type: meta.type ?? t.type } : t
59082
- ) : s.tabs;
59083
- return { isOpen: true, tabs, activeTabId: assetId };
59084
- }
59085
- const newTab = {
59086
- id: assetId,
59087
- name: (meta == null ? void 0 : meta.name) ?? null,
59088
- type: (meta == null ? void 0 : meta.type) ?? "unknown"
59089
- };
59090
- return { isOpen: true, tabs: [...s.tabs, newTab], activeTabId: assetId };
59091
- }),
59092
- closeTab: (assetId) => set2((s) => {
59093
- var _a2;
59094
- const tabs = s.tabs.filter((t) => t.id !== assetId);
59095
- if (tabs.length === 0) {
59096
- return { isOpen: false, tabs: [], activeTabId: null, isFullscreen: false };
59097
- }
59098
- const activeTabId = s.activeTabId === assetId ? ((_a2 = tabs[Math.min(s.tabs.findIndex((t) => t.id === assetId), tabs.length - 1)]) == null ? void 0 : _a2.id) ?? null : s.activeTabId;
59099
- return { tabs, activeTabId };
59100
- }),
59101
- setActiveTab: (assetId) => set2({ activeTabId: assetId, viewMode: "tabs" }),
59102
- setViewMode: (mode) => set2({ viewMode: mode }),
59103
- closePanel: () => set2({ isOpen: false, tabs: [], activeTabId: null, viewMode: "tabs", isFullscreen: false }),
59104
- toggleFullscreen: () => set2((s) => ({ isFullscreen: !s.isFullscreen })),
59105
- resetAutoOpen: () => set2((s) => ({ autoOpenGeneration: s.autoOpenGeneration + 1 })),
59106
- markAutoOpened: (assetId) => {
59107
- const state = get2();
59108
- if (state.autoOpenedAssets.get(assetId) === state.autoOpenGeneration) {
59109
- return false;
59110
- }
59111
- state.autoOpenedAssets.set(assetId, state.autoOpenGeneration);
59112
- return true;
59113
- }
59114
- }),
59115
- {
59116
- name: "athena-react-asset-panel",
59117
- partialize: ({
59118
- isOpen,
59119
- tabs,
59120
- activeTabId,
59121
- viewMode,
59122
- isFullscreen
59123
- }) => ({
59124
- isOpen,
59125
- tabs,
59126
- activeTabId,
59127
- viewMode,
59128
- isFullscreen
59129
- }),
59130
- storage: createJSONStorage(() => sessionStorage)
59131
- }
59132
- )
59133
- );
59134
59208
  const ATHENA_APP_HOSTNAMES = /* @__PURE__ */ new Set(["app.athenaintel.com", "staging-app.athenaintel.com"]);
59135
59209
  const ATHENA_PREVIEW_HOSTNAME_SUFFIX = ".previews.athenaintel.com";
59136
59210
  const ATHENA_WORKSPACE_HOSTNAME_SUFFIXES = [".app.athenaintel.com", ".staging-app.athenaintel.com"];
@@ -66587,38 +66661,6 @@ function ThreadListItem() {
66587
66661
  /* @__PURE__ */ jsx("span", { className: "flex-1 truncate text-left", children: /* @__PURE__ */ jsx(ThreadListItemPrimitiveTitle, { fallback: "Untitled" }) })
66588
66662
  ] }) });
66589
66663
  }
66590
- function useAthenaThreadManager() {
66591
- const runtime = useAssistantRuntime({ optional: true });
66592
- const remoteId = useThread({ optional: true, selector: (s) => {
66593
- var _a2;
66594
- return (_a2 = s.metadata) == null ? void 0 : _a2.remoteId;
66595
- } });
66596
- const isThreadLoading = useThread({ optional: true, selector: (s) => s.isLoading }) ?? false;
66597
- const isListLoading = useThreadList({ optional: true, selector: (s) => s.isLoading });
66598
- const runtimeRef = useRef(runtime);
66599
- runtimeRef.current = runtime;
66600
- const switchToThread = useCallback(
66601
- (id) => runtimeRef.current.threads.switchToThread(id),
66602
- []
66603
- );
66604
- const switchToNewThread = useCallback(
66605
- () => runtimeRef.current.threads.switchToNewThread(),
66606
- []
66607
- );
66608
- const activeThreadId = remoteId ?? null;
66609
- return useMemo(() => {
66610
- if (!runtime || isListLoading == null) {
66611
- return null;
66612
- }
66613
- return {
66614
- activeThreadId,
66615
- isListLoading,
66616
- isThreadLoading,
66617
- switchToThread,
66618
- switchToNewThread
66619
- };
66620
- }, [runtime, activeThreadId, isListLoading, isThreadLoading, switchToThread, switchToNewThread]);
66621
- }
66622
66664
  function useAppendToComposer() {
66623
66665
  const aui = useAui();
66624
66666
  return useCallback(