Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

QA: Nov 13th #2071

Merged
merged 104 commits into from
Nov 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
104 commits
Select commit Hold shift + click to select a range
b69be09
fix: inline editor arrow key interactions (edit & enter states)
AyushAgrawal-A2 Oct 15, 2024
526c629
Merge branch 'qa' of github.com:quadratichq/quadratic into ayush/1961
AyushAgrawal-A2 Oct 15, 2024
1676921
Merge branch 'qa' of github.com:quadratichq/quadratic into ayush/1961
AyushAgrawal-A2 Oct 15, 2024
63d315f
fix bugs
AyushAgrawal-A2 Oct 17, 2024
e0f6f13
Merge branch 'qa' of github.com:quadratichq/quadratic into ayush/1961
AyushAgrawal-A2 Oct 17, 2024
9fafe8e
bug
AyushAgrawal-A2 Oct 17, 2024
7be1442
inline cursor mode ui
AyushAgrawal-A2 Oct 18, 2024
b079e74
tweak appearance
jimniels Oct 18, 2024
f501620
Update BottomBar.tsx
jimniels Oct 18, 2024
f941ab0
fix cursor flash at (0,0)
AyushAgrawal-A2 Oct 18, 2024
f05e22b
Merge branch 'ayush/1961' of github.com:quadratichq/quadratic into ay…
AyushAgrawal-A2 Oct 18, 2024
d7d7ae5
fix insert cell highlight showing corners
AyushAgrawal-A2 Oct 18, 2024
e7b312b
DK feedback
AyushAgrawal-A2 Oct 19, 2024
823f6eb
Merge branch 'qa' of github.com:quadratichq/quadratic into ayush/1961
AyushAgrawal-A2 Oct 19, 2024
2d192d2
fix bug
AyushAgrawal-A2 Oct 19, 2024
51dc576
Merge branch 'qa' into ayush/1961
AyushAgrawal-A2 Oct 22, 2024
7334456
initial commit
jimniels Oct 30, 2024
eecda97
tweaks
jimniels Oct 30, 2024
25e280b
Merge branch 'qa' into ayush/1961
AyushAgrawal-A2 Nov 6, 2024
353444b
Merge branch 'qa' into ayush/1961
AyushAgrawal-A2 Nov 6, 2024
e724666
fix: disable few default keybindings in inline monaco editor
AyushAgrawal-A2 Nov 7, 2024
cffeca8
fix bug with custom dates closing when editing in format menu
davidfig Nov 10, 2024
381826c
possibly fix bug
davidfig Nov 10, 2024
7ffff63
perf: use plotly cdn for python charts
AyushAgrawal-A2 Nov 10, 2024
69b0317
duplicate code
AyushAgrawal-A2 Nov 10, 2024
a447f9d
fix: ERROR: TypeError: this.pyodide.globals.get(...) is not a function
AyushAgrawal-A2 Nov 10, 2024
9f912fe
fix test
AyushAgrawal-A2 Nov 11, 2024
3b5d0bd
updates
jimniels Nov 12, 2024
17e24ac
Merge branch 'qa' into ayush/plotly_cdn
AyushAgrawal-A2 Nov 12, 2024
7264bbd
fix bug with a '%' in rust code
davidfig Nov 12, 2024
eeb808a
Merge branch 'qa' into fix-custom-dates
davidfig Nov 12, 2024
da43f8d
merge latest from qa
jimniels Nov 12, 2024
c6d6723
fix new file in ocmmand palette
jimniels Nov 12, 2024
8023add
Merge branch 'qa' of github.com:quadratichq/quadratic into ayush/1996
AyushAgrawal-A2 Nov 12, 2024
c6fd73d
Merge branch 'qa' of github.com:quadratichq/quadratic into ayush/1996
AyushAgrawal-A2 Nov 12, 2024
a08bb15
prevent browser defaults from inline editor
AyushAgrawal-A2 Nov 12, 2024
4f3c1c9
add goto and find shortcuts to inline editor
AyushAgrawal-A2 Nov 12, 2024
0045c8a
tweaks
jimniels Nov 12, 2024
e134f93
command palette, switch sheet
AyushAgrawal-A2 Nov 13, 2024
e3b84c1
Merge branch 'qa' of github.com:quadratichq/quadratic into ayush/1996
AyushAgrawal-A2 Nov 13, 2024
941af16
updates
jimniels Nov 13, 2024
aa76382
Update FileDragDrop.tsx
jimniels Nov 13, 2024
d395b81
Merge pull request #2070 from quadratichq/main
davidkircos Nov 13, 2024
32c3a26
Merge pull request #2058 from quadratichq/ayush/plotly_cdn
davidkircos Nov 13, 2024
6a36286
Merge branch 'qa' into ayush/1996
AyushAgrawal-A2 Nov 14, 2024
cba19c5
Update NewFileButton.tsx
jimniels Nov 14, 2024
fc5f565
fix: deleted code cell artifacts still showing up
AyushAgrawal-A2 Nov 17, 2024
6cd3267
Merge branch 'qa' into jim-new-file
jimniels Nov 18, 2024
e1c03bd
remove unused code
jimniels Nov 18, 2024
b2a13b4
feat: request proxying for JS & fix auth header override for both JS …
AyushAgrawal-A2 Nov 18, 2024
1200b35
avoid url object
AyushAgrawal-A2 Nov 18, 2024
95e9761
initial commit
jimniels Nov 18, 2024
40c19dc
initial commit
jimniels Nov 18, 2024
58db43c
updates
jimniels Nov 18, 2024
921d17f
fix bug
jimniels Nov 18, 2024
7f952db
Update Toolbar.tsx
jimniels Nov 18, 2024
9c25583
Merge pull request #2047 from quadratichq/ayush/1996
davidkircos Nov 19, 2024
24dbed4
Merge branch 'qa' into jim-ai-assistant-tweaks
jimniels Nov 19, 2024
8a6fdee
fix 1px issue
jimniels Nov 19, 2024
28d28ac
Merge pull request #2086 from quadratichq/jim-ai-assistant-tweaks
jimniels Nov 19, 2024
c60f970
Merge branch 'qa' into jim-code-editor-header
jimniels Nov 19, 2024
2ad031d
Merge branch 'qa' into jim-code-editor-header
jimniels Nov 19, 2024
6a55d20
small fixes
jimniels Nov 19, 2024
b14be0f
Merge pull request #2004 from quadratichq/jim-new-file
davidkircos Nov 19, 2024
bcfaec8
Merge pull request #2060 from quadratichq/ayush/pyodide_error
davidkircos Nov 19, 2024
335b640
unsafe unwrap
AyushAgrawal-A2 Nov 19, 2024
ba07e0c
Merge pull request #2081 from quadratichq/ayush/2078
davidkircos Nov 19, 2024
6044cf6
mask x-proxy-authorization header in logs
AyushAgrawal-A2 Nov 19, 2024
f0b1f83
Merge branch 'qa' into ayush/1899
AyushAgrawal-A2 Nov 19, 2024
19a19c1
Merge branch 'qa' of github.com:quadratichq/quadratic into ayush/1961
AyushAgrawal-A2 Nov 19, 2024
94941bb
Merge branch 'ayush/1961' of github.com:quadratichq/quadratic into ay…
AyushAgrawal-A2 Nov 19, 2024
c412fe4
Merge branch 'qa' into jim-code-editor-header
jimniels Nov 19, 2024
b82966f
Update ResizeControl.css
jimniels Nov 19, 2024
334f309
Merge branch 'jim-code-editor-header' of github.com:quadratichq/quadr…
jimniels Nov 19, 2024
e455a0b
initial commit
jimniels Nov 19, 2024
1cf0ecb
Merge pull request #2085 from quadratichq/jim-code-editor-header
jimniels Nov 19, 2024
2f67599
Update AIAnalystExamplePrompts.tsx
jimniels Nov 19, 2024
e40f895
Merge pull request #2089 from quadratichq/jim-fix-back-btn
davidkircos Nov 19, 2024
33fcdc9
Merge pull request #2083 from quadratichq/ayush/1899
davidkircos Nov 19, 2024
0c9766b
updates
jimniels Nov 19, 2024
b7fa0c2
Merge branch 'qa' into jim-ai-fixes-misc
jimniels Nov 20, 2024
51156b2
Merge pull request #2057 from quadratichq/fix-custom-dates
davidkircos Nov 20, 2024
1973e31
Merge branch 'qa' of github.com:quadratichq/quadratic into ayush/1961
AyushAgrawal-A2 Nov 20, 2024
44dfb23
reverse mode display and icon size / pos
AyushAgrawal-A2 Nov 20, 2024
5933819
fix height
AyushAgrawal-A2 Nov 20, 2024
5809b4a
revert height
AyushAgrawal-A2 Nov 20, 2024
987a7e7
fixes
jimniels Nov 20, 2024
3980d41
Update AIAnalystExamplePrompts.tsx
jimniels Nov 20, 2024
d612ae2
Cmd K to toggle AI sidepanel
AyushAgrawal-A2 Nov 20, 2024
bd6b546
focusGrid on app open
AyushAgrawal-A2 Nov 20, 2024
acc11bc
prevent submit prompt when loading
AyushAgrawal-A2 Nov 20, 2024
9a6784f
ask ai not to include answer in reply
AyushAgrawal-A2 Nov 20, 2024
db74123
show ai api errors to user as chat response
AyushAgrawal-A2 Nov 20, 2024
4c52080
fix focus for new chat
AyushAgrawal-A2 Nov 20, 2024
b8411ef
conditional returns
AyushAgrawal-A2 Nov 20, 2024
cab0e8f
Merge branch 'qa' into jim-ai-fixes-misc
AyushAgrawal-A2 Nov 21, 2024
96a6c53
add console log for debugging autofocus on build
AyushAgrawal-A2 Nov 21, 2024
87ece0c
Merge branch 'jim-ai-fixes-misc' of github.com:quadratichq/quadratic …
AyushAgrawal-A2 Nov 21, 2024
9c15210
fix autofocus
AyushAgrawal-A2 Nov 21, 2024
5378d8b
add : adn ! to wantsCellRef
AyushAgrawal-A2 Nov 21, 2024
322dfbc
Merge pull request #1972 from quadratichq/ayush/1961
davidkircos Nov 21, 2024
3a1800b
Merge pull request #2090 from quadratichq/jim-ai-fixes-misc
davidkircos Nov 21, 2024
614b21b
fix: code cell outlines
AyushAgrawal-A2 Nov 21, 2024
ce3b362
Merge pull request #2093 from quadratichq/ayush/code_cell
davidkircos Nov 21, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -92,5 +92,8 @@
},
"[javascript]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[html]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
}
}
21 changes: 11 additions & 10 deletions quadratic-api/src/routes/ai/anthropic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,12 @@ anthropic_router.post('/anthropic/chat', validateAccessToken, ai_rate_limiter, a
});
response.json(result.content);
} catch (error: any) {
if (error.response) {
response.status(error.response.status).json(error.response.data);
console.log(error.response.status, error.response.data);
if (error instanceof Anthropic.APIError) {
response.status(error.status ?? 400).json(error.message);
console.log(error.status, error.message);
} else {
response.status(400).json(error.message);
console.log(error.message);
response.status(400).json(error);
console.log(error);
}
}
});
Expand Down Expand Up @@ -75,14 +75,15 @@ anthropic_router.post(
}
} catch (error: any) {
if (!response.headersSent) {
if (error.response) {
response.status(error.response.status).json(error.response.data);
console.log(error.response.status, error.response.data);
if (error instanceof Anthropic.APIError) {
response.status(error.status ?? 400).json(error.message);
console.log(error.status, error.message);
} else {
response.status(400).json(error.message);
console.log(error.message);
response.status(400).json(error);
console.log(error);
}
} else {
response.status(500).json('Error occurred after headers were sent');
console.error('Error occurred after headers were sent:', error);
}
}
Expand Down
21 changes: 11 additions & 10 deletions quadratic-api/src/routes/ai/bedrock.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { AnthropicBedrock } from '@anthropic-ai/bedrock-sdk';
import Anthropic from '@anthropic-ai/sdk';
import { BedrockRuntimeClient, ConverseCommand, ConverseStreamCommand } from '@aws-sdk/client-bedrock-runtime';
import express from 'express';
import { MODEL_OPTIONS } from 'quadratic-shared/AI_MODELS';
Expand Down Expand Up @@ -125,12 +126,12 @@ bedrock_router.post('/bedrock/anthropic/chat', validateAccessToken, ai_rate_limi
});
response.json(result.content);
} catch (error: any) {
if (error.response) {
response.status(error.response.status).json(error.response.data);
console.log(error.response.status, error.response.data);
if (error instanceof Anthropic.APIError) {
response.status(error.status ?? 400).json(error.message);
console.log(error.status, error.message);
} else {
response.status(400).json(error.message);
console.log(error.message);
response.status(400).json(error);
console.log(error);
}
}
});
Expand Down Expand Up @@ -173,12 +174,12 @@ bedrock_router.post(
}
} catch (error: any) {
if (!response.headersSent) {
if (error.response) {
response.status(error.response.status).json(error.response.data);
console.log(error.response.status, error.response.data);
if (error instanceof Anthropic.APIError) {
response.status(error.status ?? 400).json(error.message);
console.log(error.status, error.message);
} else {
response.status(400).json(error.message);
console.log(error.message);
response.status(400).json(error);
console.log(error);
}
} else {
console.error('Error occurred after headers were sent:', error);
Expand Down
20 changes: 10 additions & 10 deletions quadratic-api/src/routes/ai/openai.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,12 @@ openai_router.post('/openai/chat', validateAccessToken, ai_rate_limiter, async (
});
response.json(result.choices[0].message);
} catch (error: any) {
if (error.response) {
response.status(error.response.status).json(error.response.data);
console.log(error.response.status, error.response.data);
if (error instanceof OpenAI.APIError) {
response.status(error.status ?? 400).json(error.message);
console.log(error.status, error.message);
} else {
response.status(400).json(error.message);
console.log(error.message);
response.status(400).json(error);
console.log(error);
}
}
});
Expand Down Expand Up @@ -65,12 +65,12 @@ openai_router.post('/openai/chat/stream', validateAccessToken, ai_rate_limiter,
}
} catch (error: any) {
if (!response.headersSent) {
if (error.response) {
response.status(error.response.status).json(error.response.data);
console.log(error.response.status, error.response.data);
if (error instanceof OpenAI.APIError) {
response.status(error.status ?? 400).json(error.message);
console.log(error.status, error.message);
} else {
response.status(400).json(error.message);
console.log(error.message);
response.status(400).json(error);
console.log(error);
}
} else {
console.error('Error occurred after headers were sent:', error);
Expand Down
4 changes: 2 additions & 2 deletions quadratic-client/src/app/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,8 @@ export const isAvailableBecauseFileLocationIsAccessibleAndWriteable = ({
export const createNewFileAction = {
label: 'New',
isAvailable: isAvailableBecauseFileLocationIsAccessibleAndWriteable,
run({ setEditorInteractionState }: { setEditorInteractionState: SetterOrUpdater<EditorInteractionState> }) {
setEditorInteractionState((prevState) => ({ ...prevState, showNewFileMenu: true }));
run({ teamUuid }: { teamUuid: string }) {
window.location.href = ROUTES.CREATE_FILE_PRIVATE(teamUuid);
},
};

Expand Down
1 change: 1 addition & 0 deletions quadratic-client/src/app/actions/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ export enum Action {
MoveCursorRightWithSelection = 'move_cursor_right_with_selection',
MoveCursorLeftWithSelection = 'move_cursor_left_with_selection',
EditCell = 'edit_cell',
ToggleArrowMode = 'toggle_arrow_mode',
DeleteCell = 'delete_cell',
ShowCellTypeMenu = 'show_cell_type_menu',
CloseInlineEditor = 'close_inline_editor',
Expand Down
50 changes: 42 additions & 8 deletions quadratic-client/src/app/actions/editActionsSpec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {
} from '@/app/grid/actions/clipboard/clipboard';
import { sheets } from '@/app/grid/controller/Sheets';
import { inlineEditorHandler } from '@/app/gridGL/HTMLGrid/inlineEditor/inlineEditorHandler';
import { CursorMode } from '@/app/gridGL/HTMLGrid/inlineEditor/inlineEditorKeyboard';
import { doubleClickCell } from '@/app/gridGL/interaction/pointer/doubleClickCell';
import { pixiAppSettings } from '@/app/gridGL/pixiApp/PixiAppSettings';
import { downloadFile } from '@/app/helpers/downloadFileInBrowser';
Expand Down Expand Up @@ -42,6 +43,7 @@ type EditActionSpec = Pick<
| Action.FillRight
| Action.FillDown
| Action.EditCell
| Action.ToggleArrowMode
| Action.DeleteCell
| Action.CloseInlineEditor
| Action.SaveInlineEditor
Expand Down Expand Up @@ -162,19 +164,51 @@ export const editActionsSpec: EditActionSpec = {
label: 'Edit cell',
run: () => {
if (!inlineEditorHandler.isEditingFormula()) {
const cursor = sheets.sheet.cursor;
const cursorPosition = cursor.cursorPosition;
const column = cursorPosition.x;
const row = cursorPosition.y;
quadraticCore.getCodeCell(sheets.sheet.id, column, row).then((code) => {
const { x, y } = sheets.sheet.cursor.cursorPosition;
quadraticCore.getCodeCell(sheets.sheet.id, x, y).then((code) => {
if (code) {
doubleClickCell({ column: Number(code.x), row: Number(code.y), language: code.language, cell: '' });
doubleClickCell({
column: Number(code.x),
row: Number(code.y),
language: code.language,
cell: '',
});
} else {
quadraticCore.getEditCell(sheets.sheet.id, x, y).then((cell) => {
doubleClickCell({
column: x,
row: y,
cell,
cursorMode: cell ? CursorMode.Edit : CursorMode.Enter,
});
});
}
});
return true;
}
},
},
[Action.ToggleArrowMode]: {
label: 'Toggle arrow mode',
run: () => {
if (!inlineEditorHandler.isEditingFormula()) {
const { x, y } = sheets.sheet.cursor.cursorPosition;
quadraticCore.getCodeCell(sheets.sheet.id, x, y).then((code) => {
if (code) {
doubleClickCell({
column: Number(code.x),
row: Number(code.y),
language: code.language,
cell: '',
cursorMode: CursorMode.Edit,
});
} else {
quadraticCore.getEditCell(sheets.sheet.id, column, row).then((cell) => {
doubleClickCell({ column, row, cell });
quadraticCore.getEditCell(sheets.sheet.id, x, y).then((cell) => {
doubleClickCell({ column: x, row: y, cell, cursorMode: CursorMode.Edit });
});
}
});
return true;
}
},
},
Expand Down
1 change: 0 additions & 1 deletion quadratic-client/src/app/actions/viewActionsSpec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,6 @@ export const viewActionsSpec: ViewActionSpec = {
showConnectionsMenu: false,
showGoToMenu: false,
showFeedbackMenu: false,
showNewFileMenu: false,
showRenameFileMenu: false,
showShareFileMenu: false,
showSearch: false,
Expand Down
7 changes: 3 additions & 4 deletions quadratic-client/src/app/ai/hooks/useAIRequestToAPI.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -356,17 +356,16 @@ export function useAIRequestToAPI() {
});

if (!response.ok) {
const data = await response.json();
const error =
response.status === 429
? 'You have exceeded the maximum number of requests. Please try again later.'
: `Looks like there was a problem. Status Code: ${response.status}`;
: `Looks like there was a problem. Error: ${data}`;
setMessages?.((prev) => [
...prev.slice(0, -1),
{ role: 'assistant', content: error, contextType: 'userPrompt', model, toolCalls: [] },
]);
if (response.status !== 429) {
console.error(`Error retrieving data from AI API: ${response.status}`);
}
console.error(`Error retrieving data from AI API. Error: ${data}`);
return { error: true, content: error, toolCalls: [] };
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ Use any functions that are part of the ${language} library.\n
A code cell can return only one type of value as specified in the Quadratic documentation.\n
A code cell cannot display both a chart and return a data frame at the same time.\n
A code cell cannot display multiple charts at the same time.\n
Do not use conditional returns in code cells.\n
Do not use any markdown syntax besides triple backticks for ${language} code blocks.\n
Do not reply code blocks in plain text, use markdown with triple backticks and language name ${language}.`
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ ${
: 'Choose the language of your response based on the context and user prompt.'
}
Provide complete code blocks with language syntax highlighting. Don't provide small code snippets of changes.
Respond in minimum number of words with direct answer. Include a concise explanation of the answer.
Respond in minimum number of words and include a concise explanation of the actions you are taking. Don't guess the answer itself, just the actions you are taking to respond to the user prompt and what the user can do next.
`,
contextType: 'quadraticDocs',
},
Expand Down
2 changes: 1 addition & 1 deletion quadratic-client/src/app/ai/hooks/useToolUseMessages.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export function useToolUseMessages() {
content: `Note: This is an internal message for context. Do not quote it in your response.\n\n
Following are the tools you should use to do actions in the spreadsheet, use them to respond to the user prompt.\n

Include a concise explanation of the actions you are taking to respond to the user prompt.
Include a concise explanation of the actions you are taking to respond to the user prompt. Never guess the answer itself, just the actions you are taking to respond to the user prompt and what the user can do next.\n

Don't include tool details in your response. Reply in layman's terms what actions you are taking.\n

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,10 @@ Add imports to the top of the code cell and do not use any libraries or function
Use any functions that are part of the code cell language library.\n
A code cell can return only one type of value as specified in the Quadratic documentation.\n
A code cell cannot display both a chart and return a data frame at the same time.\n
Do not use conditional returns in code cells.\n
A code cell cannot display multiple charts at the same time.\n
Do not use any markdown syntax besides triple backticks for code cell language code blocks.\n
Do not reply code blocks in plain text, use markdown with triple backticks and language name code cell language.
Do not reply code blocks in plain text, use markdown with triple backticks and language name code cell language.\n

${erroredCodeCells[0].map(({ x, y, language, code_string, std_out, std_err }) => {
const consoleOutput = {
Expand Down
1 change: 1 addition & 0 deletions quadratic-client/src/app/ai/tools/aiToolsSpec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,7 @@ The required location (x,y) for this code cell is one which satisfies the follow
- If there are multiple tables or data sources being referenced, place the code cell in a location that provides a good balance between proximity to all referenced data and maintaining readability of the currently open sheet.\n
- Consider the overall layout and organization of the currently open sheet when placing the code cell, ensuring it doesn't disrupt existing data or interfere with other code cells.\n
- A plot returned by the code cell occupies just one cell, the plot overlay is larger but the code cell is always just one cell.\n
- Do not use conditional returns in code cells.\n
`,
},
[AITool.MoveCells]: {
Expand Down
20 changes: 17 additions & 3 deletions quadratic-client/src/app/atoms/aiAnalystAtom.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,14 @@ export const aiAnalystAtom = atom<AIAnalystState>({
effects: [
async ({ getPromise, setSelf, trigger }) => {
if (trigger === 'get') {
// Determine if we want to override the default showAIAnalyst value on initialization
const aiAnalystOpenCount = getAiAnalystOpenCount();
const isSheetEmpty = sheets.sheet.bounds.type === 'empty';
if (isSheetEmpty) {
const showAIAnalyst = aiAnalystOpenCount <= 3 ? true : isSheetEmpty;
if (showAIAnalyst) {
setSelf({
...defaultAIAnalystState,
showAIAnalyst: true,
showAIAnalyst,
});
}

Expand All @@ -52,7 +55,7 @@ export const aiAnalystAtom = atom<AIAnalystState>({
const chats = await aiAnalystOfflineChats.loadChats();
setSelf({
...defaultAIAnalystState,
showAIAnalyst: isSheetEmpty,
showAIAnalyst,
chats,
});
} catch (error) {
Expand Down Expand Up @@ -271,3 +274,14 @@ export const aiAnalystCurrentChatMessagesCountAtom = selector<number>({
key: 'aiAnalystCurrentChatMessagesCountAtom',
get: ({ get }) => getPromptMessages(get(aiAnalystCurrentChatAtom).messages).length,
});

const STORAGE_KEY = 'aiAnalystOpenCount';
export function getAiAnalystOpenCount() {
const count = window.localStorage.getItem(STORAGE_KEY);
return count ? parseInt(count) : 0;
}
export function incrementAiAnalystOpenCount() {
const count = getAiAnalystOpenCount();
const newCount = count + 1;
window.localStorage.setItem(STORAGE_KEY, newCount.toString());
}
5 changes: 0 additions & 5 deletions quadratic-client/src/app/atoms/editorInteractionStateAtom.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ export interface EditorInteractionState {
showConnectionsMenu: boolean;
showGoToMenu: boolean;
showFeedbackMenu: boolean;
showNewFileMenu: boolean;
showRenameFileMenu: boolean;
showShareFileMenu: boolean;
showSearch: boolean | SearchOptions;
Expand All @@ -33,7 +32,6 @@ export const defaultEditorInteractionState: EditorInteractionState = {
showConnectionsMenu: false,
showGoToMenu: false,
showFeedbackMenu: false,
showNewFileMenu: false,
showRenameFileMenu: false,
showShareFileMenu: false,
showSearch: false,
Expand Down Expand Up @@ -62,7 +60,6 @@ export const editorInteractionStateAtom = atom<EditorInteractionState>({
oldValue.showConnectionsMenu ||
oldValue.showGoToMenu ||
oldValue.showFeedbackMenu ||
oldValue.showNewFileMenu ||
oldValue.showRenameFileMenu ||
oldValue.showShareFileMenu ||
oldValue.showSearch ||
Expand All @@ -73,7 +70,6 @@ export const editorInteractionStateAtom = atom<EditorInteractionState>({
newValue.showConnectionsMenu ||
newValue.showGoToMenu ||
newValue.showFeedbackMenu ||
newValue.showNewFileMenu ||
newValue.showRenameFileMenu ||
newValue.showShareFileMenu ||
newValue.showSearch ||
Expand Down Expand Up @@ -103,7 +99,6 @@ export const editorInteractionStateShowCommandPaletteAtom = createSelector('show
export const editorInteractionStateShowConnectionsMenuAtom = createSelector('showConnectionsMenu');
export const editorInteractionStateShowGoToMenuAtom = createSelector('showGoToMenu');
export const editorInteractionStateShowFeedbackMenuAtom = createSelector('showFeedbackMenu');
export const editorInteractionStateShowNewFileMenuAtom = createSelector('showNewFileMenu');
export const editorInteractionStateShowRenameFileMenuAtom = createSelector('showRenameFileMenu');
export const editorInteractionStateShowShareFileMenuAtom = createSelector('showShareFileMenu');
export const editorInteractionStateShowSearchAtom = createSelector('showSearch');
Expand Down
Loading
Loading