Skip to content

Commit

Permalink
update name to match other settings, use selector in analyst
Browse files Browse the repository at this point in the history
  • Loading branch information
AyushAgrawal-A2 committed Dec 16, 2024
1 parent 6840d44 commit 84d68bd
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 11 deletions.
7 changes: 3 additions & 4 deletions quadratic-client/src/app/atoms/aiAnalystAtom.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { aiAnalystOfflineChats } from '@/app/ai/offline/aiAnalystChats';
import { getPromptMessages } from '@/app/ai/tools/message.helper';
import { editorInteractionStateUserAtom, editorInteractionStateUuidAtom } from '@/app/atoms/editorInteractionStateAtom';
import { gridSettingsAtom } from '@/app/atoms/gridSettingsAtom';
import { showAIAnalystOnStartupAtom } from '@/app/atoms/gridSettingsAtom';
import { focusGrid } from '@/app/helpers/focusGrid';
import { Chat, ChatMessage } from 'quadratic-shared/typesAndSchemasAI';
import { atom, DefaultValue, selector } from 'recoil';
Expand Down Expand Up @@ -34,10 +34,9 @@ export const aiAnalystAtom = atom<AIAnalystState>({
key: 'aiAnalystAtom',
default: defaultAIAnalystState,
effects: [
async ({ getPromise, setSelf, trigger }) => {
async ({ getPromise, setSelf, trigger, getLoadable }) => {
if (trigger === 'get') {
const gridSettings = await getPromise(gridSettingsAtom);
const showAIAnalyst = !gridSettings.hideAIOnStartup;
const showAIAnalyst = await getPromise(showAIAnalystOnStartupAtom);
setSelf({
...defaultAIAnalystState,
showAIAnalyst,
Expand Down
6 changes: 3 additions & 3 deletions quadratic-client/src/app/atoms/gridSettingsAtom.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export type GridSettings = {
showA1Notation: boolean;
showCodePeek: boolean;
presentationMode: boolean;
hideAIOnStartup: boolean;
showAIAnalystOnStartup: boolean;
};

export const defaultGridSettings: GridSettings = {
Expand All @@ -22,7 +22,7 @@ export const defaultGridSettings: GridSettings = {
showA1Notation: false,
showCodePeek: false,
presentationMode: false,
hideAIOnStartup: false,
showAIAnalystOnStartup: true,
};

// Persist the GridSettings
Expand Down Expand Up @@ -78,4 +78,4 @@ export const showCellTypeOutlinesAtom = createSelector('showCellTypeOutlines');
export const showA1NotationAtom = createSelector('showA1Notation');
export const showCodePeekAtom = createSelector('showCodePeek');
export const presentationModeAtom = createSelector('presentationMode');
export const hideAIOnStartupAtom = createSelector('hideAIOnStartup');
export const showAIAnalystOnStartupAtom = createSelector('showAIAnalystOnStartup');
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Action } from '@/app/actions/actions';
import {
hideAIOnStartupAtom,
presentationModeAtom,
showAIAnalystOnStartupAtom,
showCellTypeOutlinesAtom,
showCodePeekAtom,
showGridLinesAtom,
Expand Down Expand Up @@ -34,7 +34,7 @@ export const ViewMenubarMenu = () => {
const [showGridLines, setShowGridLines] = useRecoilState(showGridLinesAtom);
const [showCellTypeOutlines, setShowCellTypeOutlines] = useRecoilState(showCellTypeOutlinesAtom);
const [showCodePeek, setShowCodePeek] = useRecoilState(showCodePeekAtom);
const [hideAIOnStartup, setHideAIOnStartup] = useRecoilState(hideAIOnStartupAtom);
const [showAIAnalystOnStartup, setShowAIAnalystOnStartup] = useRecoilState(showAIAnalystOnStartupAtom);
const setPresentationMode = useSetRecoilState(presentationModeAtom);

return (
Expand All @@ -52,8 +52,8 @@ export const ViewMenubarMenu = () => {
<MenubarItemCheckbox checked={showCellTypeOutlines} />
Show code cell outlines
</MenubarItem>
<MenubarItem onClick={() => setHideAIOnStartup((prev) => !prev)}>
<MenubarItemCheckbox checked={!hideAIOnStartup} />
<MenubarItem onClick={() => setShowAIAnalystOnStartup((prev) => !prev)}>
<MenubarItemCheckbox checked={showAIAnalystOnStartup} />
Show AI on startup
</MenubarItem>
<MenubarItem onClick={() => setShowCodePeek((prev) => !prev)}>
Expand Down

0 comments on commit 84d68bd

Please sign in to comment.