-
Notifications
You must be signed in to change notification settings - Fork 8
feat: UI/UX improvements and unified schema selector #55
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
base: main
Are you sure you want to change the base?
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,13 @@ | ||
| import { memo, useEffect, useMemo } from "react"; | ||
| import { Space, Typography, Select, Switch, Segmented, Tooltip } from "antd"; | ||
| import { memo, useCallback, useEffect, useMemo } from "react"; | ||
| import { | ||
| Space, | ||
| Typography, | ||
| Select, | ||
| Switch, | ||
| Segmented, | ||
| Tooltip, | ||
| message, | ||
| } from "antd"; | ||
| import { | ||
| ConsoleSqlOutlined, | ||
| DatabaseOutlined, | ||
|
|
@@ -8,13 +16,15 @@ import { | |
| WalletOutlined, | ||
| } from "@ant-design/icons"; | ||
| import PropTypes from "prop-types"; | ||
| import Cookies from "js-cookie"; | ||
|
|
||
| import { CHAT_INTENTS } from "./helper"; | ||
| import CircularTokenDisplay from "./CircularTokenDisplay"; | ||
| import InfoChip from "./InfoChip"; | ||
| import { useTokenStore } from "../../store/token-store"; | ||
| import { useSessionStore } from "../../store/session-store"; | ||
| import { useProjectStore } from "../../store/project-store"; | ||
| import { orgStore } from "../../store/org-store"; | ||
| import { useAxiosPrivate } from "../../service/axios-service"; | ||
|
|
||
| // Define hidden intents and a fixed order array | ||
| const HIDDEN_CHAT_INTENTS = ["AUTO", "NOTA", "INFO"]; | ||
|
|
@@ -53,6 +63,39 @@ const PromptActions = memo(function PromptActions({ | |
| const { tokenBalance, isLoading: isTokenLoading } = useTokenStore(); | ||
| const isCloud = useSessionStore((state) => state.sessionDetails?.is_cloud); | ||
| const currentSchema = useProjectStore((state) => state.currentSchema); | ||
| const setCurrentSchema = useProjectStore((state) => state.setCurrentSchema); | ||
| const schemaList = useProjectStore((state) => state.schemaList); | ||
| const projectId = useProjectStore((state) => state.projectId); | ||
| const { selectedOrgId } = orgStore(); | ||
| const axios = useAxiosPrivate(); | ||
|
|
||
| const schemaOptions = useMemo( | ||
| () => schemaList.map((s) => ({ label: s, value: s })), | ||
| [schemaList] | ||
| ); | ||
|
|
||
| const handleSchemaChange = useCallback( | ||
| (value) => { | ||
| const csrfToken = Cookies.get("csrftoken"); | ||
| axios({ | ||
| url: `/api/v1/visitran/${ | ||
| selectedOrgId || "default_org" | ||
| }/project/${projectId}/set_schema`, | ||
| method: "POST", | ||
| data: { schema_name: value }, | ||
| headers: { "X-CSRFToken": csrfToken }, | ||
| }) | ||
| .then(() => { | ||
| setCurrentSchema(value); | ||
| message.success("Schema updated successfully"); | ||
| }) | ||
| .catch((error) => { | ||
| console.error(error); | ||
| message.error("Failed to update schema"); | ||
| }); | ||
| }, | ||
| [axios, selectedOrgId, projectId, setCurrentSchema] | ||
| ); | ||
|
|
||
| const llmOptions = useMemo( | ||
| () => | ||
|
|
@@ -169,13 +212,22 @@ const PromptActions = memo(function PromptActions({ | |
| </a> | ||
| )} | ||
|
|
||
| {/* Schema indicator */} | ||
| {currentSchema && ( | ||
| <InfoChip | ||
| icon={<DatabaseOutlined className="chat-ai-info-chip-icon" />} | ||
| text={currentSchema} | ||
| tooltipTitle="All new models generated will be created inside this schema. To modify it, click the settings icon from the left explorer." | ||
| /> | ||
| {/* Schema selector */} | ||
| {schemaList.length > 0 && ( | ||
| <div className="chat-ai-info-chip chat-ai-info-chip-clickable"> | ||
| <DatabaseOutlined className="chat-ai-info-chip-icon" /> | ||
| <Select | ||
| size="small" | ||
| variant="borderless" | ||
| showSearch | ||
| placeholder="Schema" | ||
| value={currentSchema || undefined} | ||
| onChange={handleSchemaChange} | ||
| options={schemaOptions} | ||
| popupMatchSelectWidth={false} | ||
| className="chat-ai-schema-select" | ||
| /> | ||
| </div> | ||
| )} | ||
|
Comment on lines
+216
to
231
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Consider either fetching the schema list directly in this component as a fallback, or pre-populating Prompt To Fix With AIThis is a comment left during a code review.
Path: frontend/src/ide/chat-ai/PromptActions.jsx
Line: 216-231
Comment:
**Schema selector invisible until Explorer is mounted**
`schemaList` is only populated in `project-store.js` by the Explorer component's `getSchemas()` call. If a user navigates directly to the AI Chat tab without visiting Explorer first (or on a hard refresh since `schemaList` is not persisted), `schemaList.length === 0` and the selector is hidden entirely — so there's no way for the user to change the schema from AI Chat alone.
Consider either fetching the schema list directly in this component as a fallback, or pre-populating `schemaList` from the project details response that is already loaded before the IDE renders.
How can I resolve this? If you propose a fix, please make it concise.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The Explorer component is always mounted in the IDE layout before the AI Chat panel is accessible — they share the same view. Schema list gets populated on IDE load via Explorer's |
||
| </Space> | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changing
max_lengthfrom 20 → 1024 on aCharFieldis a DDL change that requires a Django migration. Without one,python manage.py makemigrations --checkwill fail in CI and the actual database column will remainVARCHAR(20), silently truncating any schema name longer than 20 characters on databases that enforce column lengths (MySQL/PostgreSQL). Thebackend/backend/core/migrations/directory currently has no new migration for this change.Run
python manage.py makemigrations coreto generate the migration and commit it alongside this change.Prompt To Fix With AI
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Migration is intentionally not included —
makemigrationsrequires eventlet and stripe modules which are not available in the local dev environment. The migration will be generated and applied in the deployment environment as part of the release process. This is a known workflow for this repo.