@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.cjs CHANGED
@@ -24729,6 +24729,335 @@ const ThreadListRefreshContext = React.createContext(null);
24729
24729
  function useRefreshThreadList() {
24730
24730
  return React.useContext(ThreadListRefreshContext);
24731
24731
  }
24732
+ function useAthenaThreadManager() {
24733
+ const runtime = useAssistantRuntime({ optional: true });
24734
+ const remoteId = useThread({ optional: true, selector: (s) => {
24735
+ var _a2;
24736
+ return (_a2 = s.metadata) == null ? void 0 : _a2.remoteId;
24737
+ } });
24738
+ const isThreadLoading = useThread({ optional: true, selector: (s) => s.isLoading }) ?? false;
24739
+ const isListLoading = useThreadList({ optional: true, selector: (s) => s.isLoading });
24740
+ const runtimeRef = React.useRef(runtime);
24741
+ runtimeRef.current = runtime;
24742
+ const switchToThread = React.useCallback(
24743
+ (id) => runtimeRef.current.threads.switchToThread(id),
24744
+ []
24745
+ );
24746
+ const switchToNewThread = React.useCallback(
24747
+ () => runtimeRef.current.threads.switchToNewThread(),
24748
+ []
24749
+ );
24750
+ const activeThreadId = remoteId ?? null;
24751
+ return React.useMemo(() => {
24752
+ if (!runtime || isListLoading == null) {
24753
+ return null;
24754
+ }
24755
+ return {
24756
+ activeThreadId,
24757
+ isListLoading,
24758
+ isThreadLoading,
24759
+ switchToThread,
24760
+ switchToNewThread
24761
+ };
24762
+ }, [runtime, activeThreadId, isListLoading, isThreadLoading, switchToThread, switchToNewThread]);
24763
+ }
24764
+ function createJSONStorage(getStorage, options) {
24765
+ let storage;
24766
+ try {
24767
+ storage = getStorage();
24768
+ } catch (e) {
24769
+ return;
24770
+ }
24771
+ const persistStorage = {
24772
+ getItem: (name) => {
24773
+ var _a2;
24774
+ const parse2 = (str2) => {
24775
+ if (str2 === null) {
24776
+ return null;
24777
+ }
24778
+ return JSON.parse(str2, void 0);
24779
+ };
24780
+ const str = (_a2 = storage.getItem(name)) != null ? _a2 : null;
24781
+ if (str instanceof Promise) {
24782
+ return str.then(parse2);
24783
+ }
24784
+ return parse2(str);
24785
+ },
24786
+ setItem: (name, newValue) => storage.setItem(name, JSON.stringify(newValue, void 0)),
24787
+ removeItem: (name) => storage.removeItem(name)
24788
+ };
24789
+ return persistStorage;
24790
+ }
24791
+ const toThenable = (fn) => (input) => {
24792
+ try {
24793
+ const result = fn(input);
24794
+ if (result instanceof Promise) {
24795
+ return result;
24796
+ }
24797
+ return {
24798
+ then(onFulfilled) {
24799
+ return toThenable(onFulfilled)(result);
24800
+ },
24801
+ catch(_onRejected) {
24802
+ return this;
24803
+ }
24804
+ };
24805
+ } catch (e) {
24806
+ return {
24807
+ then(_onFulfilled) {
24808
+ return this;
24809
+ },
24810
+ catch(onRejected) {
24811
+ return toThenable(onRejected)(e);
24812
+ }
24813
+ };
24814
+ }
24815
+ };
24816
+ const persistImpl = (config2, baseOptions) => (set2, get2, api) => {
24817
+ let options = {
24818
+ storage: createJSONStorage(() => window.localStorage),
24819
+ partialize: (state) => state,
24820
+ version: 0,
24821
+ merge: (persistedState, currentState) => ({
24822
+ ...currentState,
24823
+ ...persistedState
24824
+ }),
24825
+ ...baseOptions
24826
+ };
24827
+ let hasHydrated = false;
24828
+ let hydrationVersion = 0;
24829
+ const hydrationListeners = /* @__PURE__ */ new Set();
24830
+ const finishHydrationListeners = /* @__PURE__ */ new Set();
24831
+ let storage = options.storage;
24832
+ if (!storage) {
24833
+ return config2(
24834
+ (...args) => {
24835
+ console.warn(
24836
+ `[zustand persist middleware] Unable to update item '${options.name}', the given storage is currently unavailable.`
24837
+ );
24838
+ set2(...args);
24839
+ },
24840
+ get2,
24841
+ api
24842
+ );
24843
+ }
24844
+ const setItem = () => {
24845
+ const state = options.partialize({ ...get2() });
24846
+ return storage.setItem(options.name, {
24847
+ state,
24848
+ version: options.version
24849
+ });
24850
+ };
24851
+ const savedSetState = api.setState;
24852
+ api.setState = (state, replace2) => {
24853
+ savedSetState(state, replace2);
24854
+ return setItem();
24855
+ };
24856
+ const configResult = config2(
24857
+ (...args) => {
24858
+ set2(...args);
24859
+ return setItem();
24860
+ },
24861
+ get2,
24862
+ api
24863
+ );
24864
+ api.getInitialState = () => configResult;
24865
+ let stateFromStorage;
24866
+ const hydrate = () => {
24867
+ var _a2, _b;
24868
+ if (!storage) return;
24869
+ const currentVersion = ++hydrationVersion;
24870
+ hasHydrated = false;
24871
+ hydrationListeners.forEach((cb) => {
24872
+ var _a22;
24873
+ return cb((_a22 = get2()) != null ? _a22 : configResult);
24874
+ });
24875
+ const postRehydrationCallback = ((_b = options.onRehydrateStorage) == null ? void 0 : _b.call(options, (_a2 = get2()) != null ? _a2 : configResult)) || void 0;
24876
+ return toThenable(storage.getItem.bind(storage))(options.name).then((deserializedStorageValue) => {
24877
+ if (deserializedStorageValue) {
24878
+ if (typeof deserializedStorageValue.version === "number" && deserializedStorageValue.version !== options.version) {
24879
+ if (options.migrate) {
24880
+ const migration = options.migrate(
24881
+ deserializedStorageValue.state,
24882
+ deserializedStorageValue.version
24883
+ );
24884
+ if (migration instanceof Promise) {
24885
+ return migration.then((result) => [true, result]);
24886
+ }
24887
+ return [true, migration];
24888
+ }
24889
+ console.error(
24890
+ `State loaded from storage couldn't be migrated since no migrate function was provided`
24891
+ );
24892
+ } else {
24893
+ return [false, deserializedStorageValue.state];
24894
+ }
24895
+ }
24896
+ return [false, void 0];
24897
+ }).then((migrationResult) => {
24898
+ var _a22;
24899
+ if (currentVersion !== hydrationVersion) {
24900
+ return;
24901
+ }
24902
+ const [migrated, migratedState] = migrationResult;
24903
+ stateFromStorage = options.merge(
24904
+ migratedState,
24905
+ (_a22 = get2()) != null ? _a22 : configResult
24906
+ );
24907
+ set2(stateFromStorage, true);
24908
+ if (migrated) {
24909
+ return setItem();
24910
+ }
24911
+ }).then(() => {
24912
+ if (currentVersion !== hydrationVersion) {
24913
+ return;
24914
+ }
24915
+ postRehydrationCallback == null ? void 0 : postRehydrationCallback(stateFromStorage, void 0);
24916
+ stateFromStorage = get2();
24917
+ hasHydrated = true;
24918
+ finishHydrationListeners.forEach((cb) => cb(stateFromStorage));
24919
+ }).catch((e) => {
24920
+ if (currentVersion !== hydrationVersion) {
24921
+ return;
24922
+ }
24923
+ postRehydrationCallback == null ? void 0 : postRehydrationCallback(void 0, e);
24924
+ });
24925
+ };
24926
+ api.persist = {
24927
+ setOptions: (newOptions) => {
24928
+ options = {
24929
+ ...options,
24930
+ ...newOptions
24931
+ };
24932
+ if (newOptions.storage) {
24933
+ storage = newOptions.storage;
24934
+ }
24935
+ },
24936
+ clearStorage: () => {
24937
+ storage == null ? void 0 : storage.removeItem(options.name);
24938
+ },
24939
+ getOptions: () => options,
24940
+ rehydrate: () => hydrate(),
24941
+ hasHydrated: () => hasHydrated,
24942
+ onHydrate: (cb) => {
24943
+ hydrationListeners.add(cb);
24944
+ return () => {
24945
+ hydrationListeners.delete(cb);
24946
+ };
24947
+ },
24948
+ onFinishHydration: (cb) => {
24949
+ finishHydrationListeners.add(cb);
24950
+ return () => {
24951
+ finishHydrationListeners.delete(cb);
24952
+ };
24953
+ }
24954
+ };
24955
+ if (!options.skipHydration) {
24956
+ hydrate();
24957
+ }
24958
+ return stateFromStorage || configResult;
24959
+ };
24960
+ const persist = persistImpl;
24961
+ const useAssetPanelStore = create()(
24962
+ persist(
24963
+ (set2, get2) => ({
24964
+ isOpen: false,
24965
+ tabs: [],
24966
+ activeTabId: null,
24967
+ viewMode: "tabs",
24968
+ isFullscreen: false,
24969
+ currentThreadId: null,
24970
+ threadStates: {},
24971
+ assetPanelHostCount: 0,
24972
+ autoOpenGeneration: 0,
24973
+ autoOpenedAssets: /* @__PURE__ */ new Map(),
24974
+ registerAssetPanelHost: () => set2((state) => ({ assetPanelHostCount: state.assetPanelHostCount + 1 })),
24975
+ unregisterAssetPanelHost: () => set2((state) => ({ assetPanelHostCount: Math.max(0, state.assetPanelHostCount - 1) })),
24976
+ openAsset: (assetId, meta) => set2((s) => {
24977
+ const existing = s.tabs.find((t) => t.id === assetId);
24978
+ if (existing) {
24979
+ const tabs = meta ? s.tabs.map(
24980
+ (t) => t.id === assetId ? { ...t, name: meta.name ?? t.name, type: meta.type ?? t.type } : t
24981
+ ) : s.tabs;
24982
+ return { isOpen: true, tabs, activeTabId: assetId };
24983
+ }
24984
+ const newTab = {
24985
+ id: assetId,
24986
+ name: (meta == null ? void 0 : meta.name) ?? null,
24987
+ type: (meta == null ? void 0 : meta.type) ?? "unknown"
24988
+ };
24989
+ return { isOpen: true, tabs: [...s.tabs, newTab], activeTabId: assetId };
24990
+ }),
24991
+ closeTab: (assetId) => set2((s) => {
24992
+ var _a2;
24993
+ const tabs = s.tabs.filter((t) => t.id !== assetId);
24994
+ if (tabs.length === 0) {
24995
+ return { isOpen: false, tabs: [], activeTabId: null, isFullscreen: false };
24996
+ }
24997
+ 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;
24998
+ return { tabs, activeTabId };
24999
+ }),
25000
+ setActiveTab: (assetId) => set2({ activeTabId: assetId, viewMode: "tabs" }),
25001
+ setViewMode: (mode) => set2({ viewMode: mode }),
25002
+ closePanel: () => set2({ isOpen: false, tabs: [], activeTabId: null, viewMode: "tabs", isFullscreen: false }),
25003
+ toggleFullscreen: () => set2((s) => ({ isFullscreen: !s.isFullscreen })),
25004
+ setCurrentThread: (threadId) => set2((s) => {
25005
+ if (s.currentThreadId === threadId) {
25006
+ return s;
25007
+ }
25008
+ const threadStates = { ...s.threadStates };
25009
+ if (s.currentThreadId !== null) {
25010
+ threadStates[s.currentThreadId] = {
25011
+ tabs: s.tabs,
25012
+ activeTabId: s.activeTabId,
25013
+ isOpen: s.isOpen
25014
+ };
25015
+ }
25016
+ const restored = threadId !== null ? threadStates[threadId] : void 0;
25017
+ return {
25018
+ currentThreadId: threadId,
25019
+ threadStates,
25020
+ tabs: (restored == null ? void 0 : restored.tabs) ?? [],
25021
+ activeTabId: (restored == null ? void 0 : restored.activeTabId) ?? null,
25022
+ isOpen: (restored == null ? void 0 : restored.isOpen) ?? false,
25023
+ // Reset transient UI state on thread switch
25024
+ isFullscreen: false,
25025
+ viewMode: "tabs"
25026
+ };
25027
+ }),
25028
+ resetAutoOpen: () => set2((s) => ({ autoOpenGeneration: s.autoOpenGeneration + 1 })),
25029
+ markAutoOpened: (assetId) => {
25030
+ const state = get2();
25031
+ if (state.autoOpenedAssets.get(assetId) === state.autoOpenGeneration) {
25032
+ return false;
25033
+ }
25034
+ state.autoOpenedAssets.set(assetId, state.autoOpenGeneration);
25035
+ return true;
25036
+ }
25037
+ }),
25038
+ {
25039
+ name: "athena-react-asset-panel",
25040
+ partialize: ({
25041
+ isOpen,
25042
+ tabs,
25043
+ activeTabId,
25044
+ viewMode,
25045
+ isFullscreen,
25046
+ currentThreadId,
25047
+ threadStates
25048
+ }) => ({
25049
+ isOpen,
25050
+ tabs,
25051
+ activeTabId,
25052
+ viewMode,
25053
+ isFullscreen,
25054
+ currentThreadId,
25055
+ threadStates
25056
+ }),
25057
+ storage: createJSONStorage(() => sessionStorage)
25058
+ }
25059
+ )
25060
+ );
24732
25061
  const THEME_TO_CSS = {
24733
25062
  primary: "--primary",
24734
25063
  primaryForeground: "--primary-foreground",
@@ -25146,7 +25475,19 @@ function AthenaWithThreadList({
25146
25475
  linkClicks,
25147
25476
  citationLinks
25148
25477
  });
25149
- return /* @__PURE__ */ jsxRuntime.jsx(AssistantRuntimeProvider, { aui, runtime, children: /* @__PURE__ */ jsxRuntime.jsx(AthenaContext.Provider, { value: athenaConfig, children: /* @__PURE__ */ jsxRuntime.jsx(ThreadListRefreshContext.Provider, { value: handleRefresh, children: /* @__PURE__ */ jsxRuntime.jsx(TooltipProvider, { children }) }) }) });
25478
+ return /* @__PURE__ */ jsxRuntime.jsx(AssistantRuntimeProvider, { aui, runtime, children: /* @__PURE__ */ jsxRuntime.jsx(AthenaContext.Provider, { value: athenaConfig, children: /* @__PURE__ */ jsxRuntime.jsx(ThreadListRefreshContext.Provider, { value: handleRefresh, children: /* @__PURE__ */ jsxRuntime.jsxs(TooltipProvider, { children: [
25479
+ /* @__PURE__ */ jsxRuntime.jsx(AssetPanelThreadSync, {}),
25480
+ children
25481
+ ] }) }) }) });
25482
+ }
25483
+ function AssetPanelThreadSync() {
25484
+ const threads = useAthenaThreadManager();
25485
+ const setCurrentThread = useAssetPanelStore((s) => s.setCurrentThread);
25486
+ const activeThreadId = (threads == null ? void 0 : threads.activeThreadId) ?? null;
25487
+ React.useEffect(() => {
25488
+ setCurrentThread(activeThreadId);
25489
+ }, [activeThreadId, setCurrentThread]);
25490
+ return null;
25150
25491
  }
25151
25492
  function AthenaProvider({
25152
25493
  children,
@@ -58903,273 +59244,6 @@ const MentionExtension = Node3.create({
58903
59244
  };
58904
59245
  }
58905
59246
  });
58906
- function createJSONStorage(getStorage, options) {
58907
- let storage;
58908
- try {
58909
- storage = getStorage();
58910
- } catch (e) {
58911
- return;
58912
- }
58913
- const persistStorage = {
58914
- getItem: (name) => {
58915
- var _a2;
58916
- const parse2 = (str2) => {
58917
- if (str2 === null) {
58918
- return null;
58919
- }
58920
- return JSON.parse(str2, void 0);
58921
- };
58922
- const str = (_a2 = storage.getItem(name)) != null ? _a2 : null;
58923
- if (str instanceof Promise) {
58924
- return str.then(parse2);
58925
- }
58926
- return parse2(str);
58927
- },
58928
- setItem: (name, newValue) => storage.setItem(name, JSON.stringify(newValue, void 0)),
58929
- removeItem: (name) => storage.removeItem(name)
58930
- };
58931
- return persistStorage;
58932
- }
58933
- const toThenable = (fn) => (input) => {
58934
- try {
58935
- const result = fn(input);
58936
- if (result instanceof Promise) {
58937
- return result;
58938
- }
58939
- return {
58940
- then(onFulfilled) {
58941
- return toThenable(onFulfilled)(result);
58942
- },
58943
- catch(_onRejected) {
58944
- return this;
58945
- }
58946
- };
58947
- } catch (e) {
58948
- return {
58949
- then(_onFulfilled) {
58950
- return this;
58951
- },
58952
- catch(onRejected) {
58953
- return toThenable(onRejected)(e);
58954
- }
58955
- };
58956
- }
58957
- };
58958
- const persistImpl = (config2, baseOptions) => (set2, get2, api) => {
58959
- let options = {
58960
- storage: createJSONStorage(() => window.localStorage),
58961
- partialize: (state) => state,
58962
- version: 0,
58963
- merge: (persistedState, currentState) => ({
58964
- ...currentState,
58965
- ...persistedState
58966
- }),
58967
- ...baseOptions
58968
- };
58969
- let hasHydrated = false;
58970
- let hydrationVersion = 0;
58971
- const hydrationListeners = /* @__PURE__ */ new Set();
58972
- const finishHydrationListeners = /* @__PURE__ */ new Set();
58973
- let storage = options.storage;
58974
- if (!storage) {
58975
- return config2(
58976
- (...args) => {
58977
- console.warn(
58978
- `[zustand persist middleware] Unable to update item '${options.name}', the given storage is currently unavailable.`
58979
- );
58980
- set2(...args);
58981
- },
58982
- get2,
58983
- api
58984
- );
58985
- }
58986
- const setItem = () => {
58987
- const state = options.partialize({ ...get2() });
58988
- return storage.setItem(options.name, {
58989
- state,
58990
- version: options.version
58991
- });
58992
- };
58993
- const savedSetState = api.setState;
58994
- api.setState = (state, replace2) => {
58995
- savedSetState(state, replace2);
58996
- return setItem();
58997
- };
58998
- const configResult = config2(
58999
- (...args) => {
59000
- set2(...args);
59001
- return setItem();
59002
- },
59003
- get2,
59004
- api
59005
- );
59006
- api.getInitialState = () => configResult;
59007
- let stateFromStorage;
59008
- const hydrate = () => {
59009
- var _a2, _b;
59010
- if (!storage) return;
59011
- const currentVersion = ++hydrationVersion;
59012
- hasHydrated = false;
59013
- hydrationListeners.forEach((cb) => {
59014
- var _a22;
59015
- return cb((_a22 = get2()) != null ? _a22 : configResult);
59016
- });
59017
- const postRehydrationCallback = ((_b = options.onRehydrateStorage) == null ? void 0 : _b.call(options, (_a2 = get2()) != null ? _a2 : configResult)) || void 0;
59018
- return toThenable(storage.getItem.bind(storage))(options.name).then((deserializedStorageValue) => {
59019
- if (deserializedStorageValue) {
59020
- if (typeof deserializedStorageValue.version === "number" && deserializedStorageValue.version !== options.version) {
59021
- if (options.migrate) {
59022
- const migration = options.migrate(
59023
- deserializedStorageValue.state,
59024
- deserializedStorageValue.version
59025
- );
59026
- if (migration instanceof Promise) {
59027
- return migration.then((result) => [true, result]);
59028
- }
59029
- return [true, migration];
59030
- }
59031
- console.error(
59032
- `State loaded from storage couldn't be migrated since no migrate function was provided`
59033
- );
59034
- } else {
59035
- return [false, deserializedStorageValue.state];
59036
- }
59037
- }
59038
- return [false, void 0];
59039
- }).then((migrationResult) => {
59040
- var _a22;
59041
- if (currentVersion !== hydrationVersion) {
59042
- return;
59043
- }
59044
- const [migrated, migratedState] = migrationResult;
59045
- stateFromStorage = options.merge(
59046
- migratedState,
59047
- (_a22 = get2()) != null ? _a22 : configResult
59048
- );
59049
- set2(stateFromStorage, true);
59050
- if (migrated) {
59051
- return setItem();
59052
- }
59053
- }).then(() => {
59054
- if (currentVersion !== hydrationVersion) {
59055
- return;
59056
- }
59057
- postRehydrationCallback == null ? void 0 : postRehydrationCallback(stateFromStorage, void 0);
59058
- stateFromStorage = get2();
59059
- hasHydrated = true;
59060
- finishHydrationListeners.forEach((cb) => cb(stateFromStorage));
59061
- }).catch((e) => {
59062
- if (currentVersion !== hydrationVersion) {
59063
- return;
59064
- }
59065
- postRehydrationCallback == null ? void 0 : postRehydrationCallback(void 0, e);
59066
- });
59067
- };
59068
- api.persist = {
59069
- setOptions: (newOptions) => {
59070
- options = {
59071
- ...options,
59072
- ...newOptions
59073
- };
59074
- if (newOptions.storage) {
59075
- storage = newOptions.storage;
59076
- }
59077
- },
59078
- clearStorage: () => {
59079
- storage == null ? void 0 : storage.removeItem(options.name);
59080
- },
59081
- getOptions: () => options,
59082
- rehydrate: () => hydrate(),
59083
- hasHydrated: () => hasHydrated,
59084
- onHydrate: (cb) => {
59085
- hydrationListeners.add(cb);
59086
- return () => {
59087
- hydrationListeners.delete(cb);
59088
- };
59089
- },
59090
- onFinishHydration: (cb) => {
59091
- finishHydrationListeners.add(cb);
59092
- return () => {
59093
- finishHydrationListeners.delete(cb);
59094
- };
59095
- }
59096
- };
59097
- if (!options.skipHydration) {
59098
- hydrate();
59099
- }
59100
- return stateFromStorage || configResult;
59101
- };
59102
- const persist = persistImpl;
59103
- const useAssetPanelStore = create()(
59104
- persist(
59105
- (set2, get2) => ({
59106
- isOpen: false,
59107
- tabs: [],
59108
- activeTabId: null,
59109
- viewMode: "tabs",
59110
- isFullscreen: false,
59111
- assetPanelHostCount: 0,
59112
- autoOpenGeneration: 0,
59113
- autoOpenedAssets: /* @__PURE__ */ new Map(),
59114
- registerAssetPanelHost: () => set2((state) => ({ assetPanelHostCount: state.assetPanelHostCount + 1 })),
59115
- unregisterAssetPanelHost: () => set2((state) => ({ assetPanelHostCount: Math.max(0, state.assetPanelHostCount - 1) })),
59116
- openAsset: (assetId, meta) => set2((s) => {
59117
- const existing = s.tabs.find((t) => t.id === assetId);
59118
- if (existing) {
59119
- const tabs = meta ? s.tabs.map(
59120
- (t) => t.id === assetId ? { ...t, name: meta.name ?? t.name, type: meta.type ?? t.type } : t
59121
- ) : s.tabs;
59122
- return { isOpen: true, tabs, activeTabId: assetId };
59123
- }
59124
- const newTab = {
59125
- id: assetId,
59126
- name: (meta == null ? void 0 : meta.name) ?? null,
59127
- type: (meta == null ? void 0 : meta.type) ?? "unknown"
59128
- };
59129
- return { isOpen: true, tabs: [...s.tabs, newTab], activeTabId: assetId };
59130
- }),
59131
- closeTab: (assetId) => set2((s) => {
59132
- var _a2;
59133
- const tabs = s.tabs.filter((t) => t.id !== assetId);
59134
- if (tabs.length === 0) {
59135
- return { isOpen: false, tabs: [], activeTabId: null, isFullscreen: false };
59136
- }
59137
- 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;
59138
- return { tabs, activeTabId };
59139
- }),
59140
- setActiveTab: (assetId) => set2({ activeTabId: assetId, viewMode: "tabs" }),
59141
- setViewMode: (mode) => set2({ viewMode: mode }),
59142
- closePanel: () => set2({ isOpen: false, tabs: [], activeTabId: null, viewMode: "tabs", isFullscreen: false }),
59143
- toggleFullscreen: () => set2((s) => ({ isFullscreen: !s.isFullscreen })),
59144
- resetAutoOpen: () => set2((s) => ({ autoOpenGeneration: s.autoOpenGeneration + 1 })),
59145
- markAutoOpened: (assetId) => {
59146
- const state = get2();
59147
- if (state.autoOpenedAssets.get(assetId) === state.autoOpenGeneration) {
59148
- return false;
59149
- }
59150
- state.autoOpenedAssets.set(assetId, state.autoOpenGeneration);
59151
- return true;
59152
- }
59153
- }),
59154
- {
59155
- name: "athena-react-asset-panel",
59156
- partialize: ({
59157
- isOpen,
59158
- tabs,
59159
- activeTabId,
59160
- viewMode,
59161
- isFullscreen
59162
- }) => ({
59163
- isOpen,
59164
- tabs,
59165
- activeTabId,
59166
- viewMode,
59167
- isFullscreen
59168
- }),
59169
- storage: createJSONStorage(() => sessionStorage)
59170
- }
59171
- )
59172
- );
59173
59247
  const ATHENA_APP_HOSTNAMES = /* @__PURE__ */ new Set(["app.athenaintel.com", "staging-app.athenaintel.com"]);
59174
59248
  const ATHENA_PREVIEW_HOSTNAME_SUFFIX = ".previews.athenaintel.com";
59175
59249
  const ATHENA_WORKSPACE_HOSTNAME_SUFFIXES = [".app.athenaintel.com", ".staging-app.athenaintel.com"];
@@ -66626,38 +66700,6 @@ function ThreadListItem() {
66626
66700
  /* @__PURE__ */ jsxRuntime.jsx("span", { className: "flex-1 truncate text-left", children: /* @__PURE__ */ jsxRuntime.jsx(ThreadListItemPrimitiveTitle, { fallback: "Untitled" }) })
66627
66701
  ] }) });
66628
66702
  }
66629
- function useAthenaThreadManager() {
66630
- const runtime = useAssistantRuntime({ optional: true });
66631
- const remoteId = useThread({ optional: true, selector: (s) => {
66632
- var _a2;
66633
- return (_a2 = s.metadata) == null ? void 0 : _a2.remoteId;
66634
- } });
66635
- const isThreadLoading = useThread({ optional: true, selector: (s) => s.isLoading }) ?? false;
66636
- const isListLoading = useThreadList({ optional: true, selector: (s) => s.isLoading });
66637
- const runtimeRef = React.useRef(runtime);
66638
- runtimeRef.current = runtime;
66639
- const switchToThread = React.useCallback(
66640
- (id) => runtimeRef.current.threads.switchToThread(id),
66641
- []
66642
- );
66643
- const switchToNewThread = React.useCallback(
66644
- () => runtimeRef.current.threads.switchToNewThread(),
66645
- []
66646
- );
66647
- const activeThreadId = remoteId ?? null;
66648
- return React.useMemo(() => {
66649
- if (!runtime || isListLoading == null) {
66650
- return null;
66651
- }
66652
- return {
66653
- activeThreadId,
66654
- isListLoading,
66655
- isThreadLoading,
66656
- switchToThread,
66657
- switchToNewThread
66658
- };
66659
- }, [runtime, activeThreadId, isListLoading, isThreadLoading, switchToThread, switchToNewThread]);
66660
- }
66661
66703
  function useAppendToComposer() {
66662
66704
  const aui = useAui();
66663
66705
  return React.useCallback(