Skip to content

Commit da278f9

Browse files
committed
make genai disclaimer acknowledgement part of settings store
1 parent cc417f4 commit da278f9

10 files changed

Lines changed: 108 additions & 76 deletions

File tree

packages/flowtest-electron/src/ipc/settings.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,17 @@ const registerSettingsEventHandlers = (mainWindow) => {
2020
return Promise.reject(error);
2121
}
2222
});
23+
24+
ipcMain.handle('renderer:add-genAIUsageDisclaimer', async (event, accepted) => {
25+
try {
26+
settingsStore.addGenAIUsageDisclaimer(accepted);
27+
const savedSettings = settingsStore.getAll();
28+
29+
mainWindow.webContents.send('main:saved-settings', savedSettings);
30+
} catch (error) {
31+
return Promise.reject(error);
32+
}
33+
});
2334
};
2435

2536
module.exports = registerSettingsEventHandlers;

packages/flowtest-electron/src/store/settings.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,20 @@ class Settings {
99
this.store.set('logSyncConfig', { enabled, hostUrl, accessId, accessKey });
1010
}
1111

12+
addGenAIUsageDisclaimer(accepted) {
13+
this.store.set('genAIUsageDisclaimer', accepted);
14+
}
15+
1216
getAll() {
1317
return {
1418
logSyncConfig: this.store.get('logSyncConfig') || {},
19+
genAIUsageDisclaimer: this.store.get('genAIUsageDisclaimer') || false,
1520
};
1621
}
1722

1823
clearAll() {
1924
this.store.set('logSyncConfig', {});
25+
this.store.set('genAIUsageDisclaimer', false);
2026
}
2127
}
2228

packages/flowtest-electron/tests/store/settings-store.test.js

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,21 @@ describe('settings-store', () => {
55
const store = new Settings();
66
store.clearAll();
77

8-
expect(store.getAll().logSyncConfig).toEqual({});
8+
let settings = store.getAll();
9+
expect(settings.logSyncConfig).toEqual({});
10+
expect(settings.genAIUsageDisclaimer).toEqual(false);
911

1012
// adding a collection whose directory doesn't exist
1113
store.addLogSyncConfig(true, 'http://localhost:3000', 'access_id', 'access_key');
12-
const config = store.getAll().logSyncConfig;
14+
store.addGenAIUsageDisclaimer(true);
15+
16+
settings = store.getAll();
17+
const config = settings.logSyncConfig;
1318
expect(config.enabled).toEqual(true);
1419
expect(config.hostUrl).toEqual('http://localhost:3000');
1520
expect(config.accessId).toEqual('access_id');
1621
expect(config.accessKey).toEqual('access_key');
22+
23+
expect(settings.genAIUsageDisclaimer).toEqual(true);
1724
});
1825
});

src/components/molecules/headers/TabPanelHeader.js

Lines changed: 12 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,13 @@ import 'react-json-view-lite/dist/index.css';
1818
import { LogLevel } from '../flow/graph/GraphLogger';
1919
import { ShieldCheckIcon, BarsArrowUpIcon, ExclamationTriangleIcon } from '@heroicons/react/24/outline';
2020
import GenAIUsageDisclaimer from '../modals/GenAIUsageDisclaimer';
21-
import { getLocalStorageItem } from 'utils/common';
21+
import useSettingsStore from 'stores/SettingsStore';
2222

2323
const TabPanelHeader = () => {
2424
const focusTabId = useTabStore((state) => state.focusTabId);
2525
const tabs = useTabStore((state) => state.tabs);
2626
const focusTab = tabs.find((t) => t.id === focusTabId);
2727

28-
const graphRunLogs = useCanvasStore((state) => state.logs);
2928
const setTimeout = useCanvasStore((state) => state.setTimeout);
3029

3130
const [slidingPaneState, setSlidingPaneState] = useState({
@@ -146,10 +145,6 @@ const TabPanelHeader = () => {
146145
}
147146
};
148147

149-
const showDisclaimerMsg = () => {
150-
return getLocalStorageItem('show_gen_ai_disclaimer');
151-
};
152-
153148
return (
154149
<>
155150
{focusTab ? (
@@ -233,9 +228,7 @@ const TabPanelHeader = () => {
233228
btnType={BUTTON_TYPES.secondary}
234229
isDisabled={false}
235230
onClickHandle={() => {
236-
const showMsg = showDisclaimerMsg();
237-
console.log(`\n \n showMsg : ${showMsg} \n`);
238-
if (showMsg === 'false') {
231+
if (useSettingsStore.getState().genAIUsageDisclaimer === true) {
239232
setGenerateFlowTestModalOpen(true);
240233
} else {
241234
setGenAiUsageDisclaimerModalOpen(true);
@@ -247,20 +240,16 @@ const TabPanelHeader = () => {
247240
<SparklesIcon className='h-5 w-5' />
248241
Generate
249242
</Button>
250-
{/* ToDo: Discuss: I think having a user profile file on disk for this setting and all the future settings will be better */}
251-
{showDisclaimerMsg() === 'false' ? (
252-
<GenerateFlowTestModal
253-
closeFn={() => setGenerateFlowTestModalOpen(false)}
254-
open={generateFlowTestModalOpen}
255-
collectionId={focusTab.collectionId}
256-
/>
257-
) : (
258-
<GenAIUsageDisclaimer
259-
closeFn={() => setGenAiUsageDisclaimerModalOpen(false)}
260-
open={genAiUsageDisclaimerModalOpen}
261-
collectionId={focusTab.collectionId}
262-
/>
263-
)}
243+
<GenerateFlowTestModal
244+
closeFn={() => setGenerateFlowTestModalOpen(false)}
245+
open={generateFlowTestModalOpen}
246+
collectionId={focusTab.collectionId}
247+
/>
248+
<GenAIUsageDisclaimer
249+
closeFn={() => setGenAiUsageDisclaimerModalOpen(false)}
250+
open={genAiUsageDisclaimerModalOpen}
251+
openGenerateFlowTestModal={() => setGenerateFlowTestModalOpen(true)}
252+
/>
264253
</div>
265254
)}
266255
</div>

src/components/molecules/modals/GenAIUsageDisclaimer.js

Lines changed: 16 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,9 @@ import { PropTypes } from 'prop-types';
33
import { Dialog, Transition } from '@headlessui/react';
44
import Button from 'components/atoms/common/Button';
55
import { BUTTON_INTENT_TYPES, BUTTON_TYPES } from 'constants/Common';
6-
import TextInput from 'components/atoms/common/TextInput';
7-
import GenerateFlowTestModal from './GenerateFlowTestModal';
8-
import { setLocalStorageItem } from 'utils/common';
6+
import { addGenAIUsageDisclaimer } from 'service/settings';
97

10-
const GenAIUsageDisclaimer = ({ closeFn = () => null, open = false, collectionId }) => {
11-
const [generateFlowTestModalOpen, setGenerateFlowTestModalOpen] = useState(false);
8+
const GenAIUsageDisclaimer = ({ closeFn = () => null, open = false, openGenerateFlowTestModal = () => null }) => {
129
return (
1310
<>
1411
<Transition appear show={open} as={Fragment}>
@@ -48,22 +45,17 @@ const GenAIUsageDisclaimer = ({ closeFn = () => null, open = false, collectionId
4845
</Dialog.Title>
4946
<div className='flex flex-col pb-6'>
5047
<p className='mt-2 text-xl font-semibold italic 2xl:mt-4'>
51-
This tool utilizes OpenAI&#39;s and Amazon Bedrock Claude language model to provide information
48+
This tool utilizes OpenAI&#39;s and Amazon Bedrock&#39;s language models to provide information
5249
and assistance. While we strive to ensure the accuracy and reliability of the information
5350
provided, the responses generated by the model may not always be accurate, complete, or
5451
up-to-date.
5552
</p>
5653
<ul className='font-montserrat'>
5754
<li className='py-2'>
5855
<span className='font-semibold'>Information Accuracy:</span> The information and responses
59-
provided by the tool are generated based on the data and patterns recognized by OpenAI&#39;s
60-
language model. Users should independently verify any critical information before relying on it.
61-
</li>
62-
<li className='py-2'>
63-
<span className='font-semibold'>No Professional Advice:</span> The responses generated by the
64-
tool do not constitute professional advice, including but not limited to medical, legal,
65-
financial, or any other professional service. Always seek the advice of a qualified professional
66-
with any questions you may have.
56+
provided by the tool are generated based on the data and patterns recognized by OpenAI&#39;s and
57+
Amazon Bedrock&#39;s language models. Users should independently verify any critical information
58+
before relying on it.
6759
</li>
6860
<li className='py-2'>
6961
<span className='font-semibold'>User Responsibility:</span> Users are responsible for how they
@@ -72,15 +64,15 @@ const GenAIUsageDisclaimer = ({ closeFn = () => null, open = false, collectionId
7264
</li>
7365
<li className='py-2'>
7466
<span className='font-semibold'>Company Policies:</span> If your company has policies or
75-
guidelines related to the use of OpenAI or AI-generated content, please ensure that you adhere
76-
to those policies when using this tool. It is your responsibility to comply with your
77-
company&#39;s regulations and standards.
67+
guidelines related to the use of OpenAI or AWS Bedrock or AI-generated content, please ensure
68+
that you adhere to those policies when using this tool. It is your responsibility to comply with
69+
your company&#39;s regulations and standards.
7870
</li>
7971
<li className='py-2'>
80-
<span className='font-semibold'>Privacy and Data Use:</span> The tool may collect data input by
81-
users to improve the quality of the service. Please review our privacy policy for more
82-
information on how we handle your data. By using this tool, you acknowledge that you understand
83-
and agree to this disclaimer and our terms of service.
72+
<span className='font-semibold'>Privacy and Data Use:</span> This tool itself DOES NOT collect
73+
any data input by users. Please review the respective LLM&#39;s privacy policy for more
74+
information on how they handle your data. By using this tool, you acknowledge that you
75+
understand and agree to this disclaimer and our terms of service.
8476
</li>
8577
</ul>
8678
</div>
@@ -100,10 +92,10 @@ const GenAIUsageDisclaimer = ({ closeFn = () => null, open = false, collectionId
10092
btnType={BUTTON_TYPES.primary}
10193
isDisabled={false}
10294
fullWidth={true}
103-
onClickHandle={() => {
95+
onClickHandle={async () => {
96+
await addGenAIUsageDisclaimer(true);
10497
closeFn();
105-
setGenerateFlowTestModalOpen(true);
106-
setLocalStorageItem('show_gen_ai_disclaimer', false);
98+
openGenerateFlowTestModal();
10799
}}
108100
>
109101
Acknowledge
@@ -115,11 +107,6 @@ const GenAIUsageDisclaimer = ({ closeFn = () => null, open = false, collectionId
115107
</div>
116108
</Dialog>
117109
</Transition>
118-
<GenerateFlowTestModal
119-
closeFn={() => setGenerateFlowTestModalOpen(false)}
120-
open={generateFlowTestModalOpen}
121-
collectionId={collectionId}
122-
/>
123110
</>
124111
);
125112
};

src/components/molecules/workspace/EmptyWorkSpaceContent.js

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,23 +10,27 @@ import GenerateFlowTestModal from '../modals/GenerateFlowTestModal';
1010
import NewFlowTestModal from '../modals/flow/NewFlowTestModal';
1111
import NewEnvironmentFileModal from '../modals/sidebar/NewEnvironmentFileModal';
1212
import OpenCollectionModal from '../modals/OpenCollectionModal';
13+
import GenAIUsageDisclaimer from '../modals/GenAIUsageDisclaimer';
14+
import useSettingsStore from 'stores/SettingsStore';
1315

1416
const EmptyWorkSpaceContent = () => {
1517
const collections = useCollectionStore((state) => state.collections);
1618
const [openCollectionModal, setOpenCollectionModal] = useState(false);
1719
const [importCollectionModal, setImportCollectionModal] = useState(false);
1820
const [newFlowTestModal, setNewFlowTestModal] = useState(false);
1921
const [generateFlowTestModalOpen, setGenerateFlowTestModalOpen] = useState(false);
22+
const [genAiUsageDisclaimerModalOpen, setGenAiUsageDisclaimerModalOpen] = useState(false);
2023
const [newEnvironmentFileModal, setNewEnvironmentFileModal] = useState(false);
24+
2125
return (
22-
<div className='flex items-center justify-center h-full text-cyan-900'>
23-
<div className='flex flex-col max-w-xl gap-8 2xl:gap-10'>
26+
<div className='flex h-full items-center justify-center text-cyan-900'>
27+
<div className='flex max-w-xl flex-col gap-8 2xl:gap-10'>
2428
<div className='text-center'>
2529
<div className='flex items-center justify-center'>
26-
<RectangleStackIcon className='w-24 h-24' />
30+
<RectangleStackIcon className='h-24 w-24' />
2731
</div>
2832
<p className='text-2xl'>
29-
A <span className='italic font-semibold font-montserrat'>Collection</span> is a ...
33+
A <span className='font-montserrat font-semibold italic'>Collection</span> is a ...
3034
</p>
3135
<p className='mt-2 text-sm italic 2xl:mt-4'>
3236
A Collection is a set of flows where each flow is a set of API requests chained together, along with each
@@ -48,7 +52,13 @@ const EmptyWorkSpaceContent = () => {
4852
<Button
4953
btnType={BUTTON_TYPES.primary}
5054
isDisabled={false}
51-
onClickHandle={() => setGenerateFlowTestModalOpen(true)}
55+
onClickHandle={() => {
56+
if (useSettingsStore.getState().genAIUsageDisclaimer === true) {
57+
setGenerateFlowTestModalOpen(true);
58+
} else {
59+
setGenAiUsageDisclaimerModalOpen(true);
60+
}
61+
}}
5262
fullWidth={true}
5363
>
5464
Generate a Flow
@@ -81,10 +91,10 @@ const EmptyWorkSpaceContent = () => {
8191
<HorizontalDivider themeColor={'bg-cyan-900'} themeStyles={'opacity-75'} />
8292
<div className='text-center'>
8393
<div className='flex items-center justify-center'>
84-
<Square3Stack3DIcon className='w-24 h-24' />
94+
<Square3Stack3DIcon className='h-24 w-24' />
8595
</div>
8696
<p className='text-2xl'>
87-
An <span className='italic font-semibold font-montserrat'>Environment</span> is a ...
97+
An <span className='font-montserrat font-semibold italic'>Environment</span> is a ...
8898
</p>
8999
<p className='mt-2 text-sm italic 2xl:mt-4'>
90100
An environment is a set of one or more variables that you can reference when sending API requests using
@@ -113,6 +123,11 @@ const EmptyWorkSpaceContent = () => {
113123
<ImportCollectionModal closeFn={() => setImportCollectionModal(false)} open={importCollectionModal} />
114124
<NewFlowTestModal closeFn={() => setNewFlowTestModal(false)} open={newFlowTestModal} />
115125
<GenerateFlowTestModal closeFn={() => setGenerateFlowTestModalOpen(false)} open={generateFlowTestModalOpen} />
126+
<GenAIUsageDisclaimer
127+
closeFn={() => setGenAiUsageDisclaimerModalOpen(false)}
128+
open={genAiUsageDisclaimerModalOpen}
129+
openGenerateFlowTestModal={() => setGenerateFlowTestModalOpen(true)}
130+
/>
116131
<NewEnvironmentFileModal closeFn={() => setNewEnvironmentFileModal(false)} open={newEnvironmentFileModal} />
117132
</div>
118133
);

src/ipc/settings.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import useSettingsStore from 'stores/SettingsStore';
33

44
const registerSettingsEventHandlers = () => {
55
const _addLogSyncConfig = useSettingsStore((state) => state.addLogSyncConfig);
6+
const _addGenAIUsageDisclaimer = useSettingsStore((state) => state.addGenAIUsageDisclaimer);
67

78
useEffect(() => {
89
const { ipcRenderer } = window;
@@ -12,6 +13,10 @@ const registerSettingsEventHandlers = () => {
1213
const config = savedSettings.logSyncConfig;
1314
_addLogSyncConfig(config.enabled || false, config.hostUrl || '', config.accessId || '', config.accessKey || '');
1415
}
16+
17+
if (savedSettings.genAIUsageDisclaimer) {
18+
_addGenAIUsageDisclaimer(savedSettings.genAIUsageDisclaimer);
19+
}
1520
});
1621

1722
ipcRenderer.invoke('renderer:settings-window-ready');

src/service/settings.js

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,26 @@
11
export const addLogSyncConfig = (enabled, hostUrl, accessId, accessKey) => {
2-
const { ipcRenderer } = window;
2+
try {
3+
const { ipcRenderer } = window;
34

4-
return new Promise((resolve, reject) => {
5-
ipcRenderer
6-
.invoke('renderer:add-logsyncconfig', { enabled, hostUrl, accessId, accessKey })
7-
.then(resolve)
8-
.catch(reject);
9-
});
5+
return new Promise((resolve, reject) => {
6+
ipcRenderer
7+
.invoke('renderer:add-logsyncconfig', { enabled, hostUrl, accessId, accessKey })
8+
.then(resolve)
9+
.catch(reject);
10+
});
11+
} catch (error) {
12+
return Promise.reject(new Error('Unable to update config'));
13+
}
14+
};
15+
16+
export const addGenAIUsageDisclaimer = (accepted) => {
17+
try {
18+
const { ipcRenderer } = window;
19+
20+
return new Promise((resolve, reject) => {
21+
ipcRenderer.invoke('renderer:add-genAIUsageDisclaimer', accepted).then(resolve).catch(reject);
22+
});
23+
} catch (error) {
24+
return Promise.reject(new Error('Unable to acknowledge'));
25+
}
1026
};

src/stores/SettingsStore.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,13 @@ import { create } from 'zustand';
22

33
const useSettingsStore = create((set, get) => ({
44
logSyncConfig: {},
5+
genAIUsageDisclaimer: false,
56
addLogSyncConfig: (enabled, hostUrl, accessId, accessKey) => {
67
set((state) => ({ logSyncConfig: { ...state.logSyncConfig, ...{ enabled, hostUrl, accessId, accessKey } } }));
78
},
9+
addGenAIUsageDisclaimer: (accepted) => {
10+
set((state) => ({ genAIUsageDisclaimer: accepted }));
11+
},
812
}));
913

1014
export default useSettingsStore;

src/utils/common.js

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,3 @@ export const isEmptyObj = (obj) => {
4545
}
4646
return JSON.stringify(obj) === JSON.stringify({});
4747
};
48-
49-
export const setLocalStorageItem = (itemKey, itemValue) => {
50-
localStorage.setItem(itemKey, itemValue);
51-
};
52-
53-
export const getLocalStorageItem = (itemKey) => {
54-
return localStorage.getItem(itemKey);
55-
};

0 commit comments

Comments
 (0)