FIX: Display Current Schema in Chat AI Prompt Actions#30
Open
tahierhussain wants to merge 6 commits intomainfrom
Open
FIX: Display Current Schema in Chat AI Prompt Actions#30tahierhussain wants to merge 6 commits intomainfrom
tahierhussain wants to merge 6 commits intomainfrom
Conversation
- Add currentSchema and setCurrentSchema to project-store - Update explorer-component to use store instead of local state - Enables sharing schema state across components 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
- Create InfoChip.jsx for pill-shaped chip UI pattern - Add CSS classes for InfoChip styling in ChatAI.css - Supports icon, text, tooltip, and optional className prop 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
- Refactor CircularTokenDisplay to use InfoChip for credit display - Add schema chip to PromptActions using InfoChip component - Display current schema name with tooltip next to credit balance 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
|
| Filename | Overview |
|---|---|
| frontend/src/store/project-store.js | Adds currentSchema/setCurrentSchema to the Zustand store; correctly excluded from persistence via the existing partialize filter (only projectDetails and projectName are persisted), so no stale-across-sessions risk. |
| frontend/src/ide/chat-ai/InfoChip.jsx | New reusable chip component; correctly skips the Tooltip wrapper when no tooltipTitle is provided, uses useToken for AntD theme integration inside the tooltip, and has complete PropTypes definitions. |
| frontend/src/ide/chat-ai/ChatAI.css | New InfoChip CSS classes added; normal chip uses custom CSS variables while error variant uses AntD CSS token names — the inconsistency may cause subtle theming drift in light/dark mode switching. |
| frontend/src/ide/chat-ai/CircularTokenDisplay.jsx | Clean refactor to use InfoChip; removes inline style duplication while preserving the same chip states (loading spinner, no-credits error, normal credit display). |
| frontend/src/ide/chat-ai/PromptActions.jsx | Adds schema chip via InfoChip correctly gated on currentSchema being truthy; wraps credit and schema displays in a Space component for consistent layout. |
| frontend/src/ide/explorer/explorer-component.jsx | Local currentSchema useState replaced with Zustand store; adds the missing cleanup useEffect (raised in previous review) that resets the schema to "" on unmount, preventing stale state in the Chat AI panel. |
Sequence Diagram
sequenceDiagram
participant User
participant IdeExplorer
participant ProjectStore as Zustand ProjectStore
participant PromptActions
participant InfoChip
User->>IdeExplorer: Selects / changes schema
IdeExplorer->>ProjectStore: setCurrentSchema(schemaName)
ProjectStore-->>PromptActions: currentSchema (selector subscription)
PromptActions->>InfoChip: render <InfoChip text={currentSchema} icon={DatabaseOutlined} />
InfoChip-->>User: Schema chip displayed in Chat AI toolbar
Note over IdeExplorer,ProjectStore: On unmount: setCurrentSchema("") resets global state
IdeExplorer->>ProjectStore: setCurrentSchema("") [cleanup]
ProjectStore-->>PromptActions: currentSchema = "" → chip hidden
Prompt To Fix All With AI
This is a comment left during a code review.
Path: frontend/src/ide/chat-ai/ChatAI.css
Line: 441-447
Comment:
**Normal chip uses custom CSS variables; error chip uses AntD tokens**
The normal `chat-ai-info-chip` state uses app-level custom properties (`--content-bg`, `--border-color-3`, `--icons-color`), while the error variant (`chat-ai-info-chip-error`) correctly uses the Ant Design CSS variable namespace (`--ant-color-error-*`). If the custom variables aren't kept in sync with the active AntD theme (e.g. light ↔ dark switching), the normal chip's background and border could diverge from the theme while the error chip stays correct.
The original `CircularTokenDisplay` used `token.colorBgContainer` / `token.colorBorder` / `token.colorText` directly from `useToken()`, which are always in sync with the active theme. Consider using the equivalent AntD CSS variables for the normal chip to keep both variants consistent:
```css
.chat-ai-info-chip {
...
background-color: var(--ant-color-bg-container);
border: 1px solid var(--ant-color-border);
...
}
.chat-ai-info-chip-icon {
font-size: 12px;
color: var(--ant-color-text);
}
```
How can I resolve this? If you propose a fix, please make it concise.Reviews (2): Last reviewed commit: "refactor: use selector pattern for setCu..." | Re-trigger Greptile
- Add error variant CSS class (chat-ai-info-chip-error) - Replace inline JSX with InfoChip component for consistency - Reduces code duplication and improves maintainability 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
Add cleanup effect to reset currentSchema when IdeExplorer unmounts, preventing stale schema data from showing in other views. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
Move setCurrentSchema to use selector pattern for consistency with currentSchema, following the same approach used in PromptActions. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
currentSchemastate from local component state inexplorer-component.jsxto global Zustand store (project-store.js)InfoChipcomponent for pill-shaped chip UIPromptActionscomponent next to the credit balance chipCircularTokenDisplayto use the newInfoChipcomponent for both credit display and "No Credits" stateWhy
InfoChipas a reusable component reduces code duplication between the credit chip and schema chipHow
currentSchemaandsetCurrentSchematoproject-store.jsZustand storeexplorer-component.jsxto use the store instead of local stateInfoChip.jsxcomponent with:icon,text,tooltipTitle,tooltipPlacement,classNameChatAI.cssfor styling (including error variant for "No Credits" state)InfoChipthat displays:InfoChipcomponent for both:chat-ai-info-chip-errorclass)Can this PR break any existing features. If yes, please list possible items. If no, please explain why. (PS: Admins do not merge the PR without this section filled)
CircularTokenDisplayvisual output is identical, only the implementation was refactoredDatabase Migrations
Env Config
Relevant Docs
Related Issues or PRs
Dependencies Versions
Notes on Testing
Screenshots
Checklist
I have read and understood the Contribution Guidelines.