GridCore: add ai assistant toolbar item#33189
GridCore: add ai assistant toolbar item#33189anna-shakhova wants to merge 4 commits intoDevExpress:26_1from
Conversation
There was a problem hiding this comment.
Pull request overview
This PR introduces an AI Assistant feature hook for DataGrid/TreeList by adding aiAssistant options, wiring a controller/view pair, and registering a toolbar button in the header panel that toggles an AI chat popup.
Changes:
- Add
aiAssistantconfiguration (enabled,title) with per-grid default options and internal option typing. - Implement a new
AIAssistantViewControllerthat registers/removes a header toolbar button and delegatesshow/hide/toggleto the view. - Extend the AI chat wrapper to support
toggle()and adjust default popup options.
Reviewed changes
Copilot reviewed 12 out of 12 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| packages/devextreme/js/__internal/grids/tree_list/module_not_extended/ai_assistant.ts | Switch to new AI assistant view/controller names and add default aiAssistant options. |
| packages/devextreme/js/__internal/grids/data_grid/module_not_extended/ai_assistant.ts | Same as TreeList: wire new view/controller and add default aiAssistant options. |
| packages/devextreme/js/__internal/grids/grid_core/m_types.ts | Add internal aiAssistant option typing. |
| packages/devextreme/js/__internal/grids/grid_core/header_panel/m_header_panel.ts | Make _getToolbarButtonClass callable from outside the class (now used by AI assistant button init). |
| packages/devextreme/js/__internal/grids/grid_core/ai_chat/const.ts | Update default popup options (shading: false). |
| packages/devextreme/js/__internal/grids/grid_core/ai_chat/ai_chat.ts | Use internal popup implementation import and add toggle() API on AIChat. |
| packages/devextreme/js/__internal/grids/grid_core/ai_assistant/m_ai_assistant_view_controller.ts | Remove legacy AI assistant controller implementation (replaced by new controller). |
| packages/devextreme/js/__internal/grids/grid_core/ai_assistant/m_ai_assistant_view_controller.test.ts | Remove legacy unit tests for the old controller. |
| packages/devextreme/js/__internal/grids/grid_core/ai_assistant/ai_assistant_view.ts | Make isVisible() strictly boolean and add toggle() delegating to AI chat. |
| packages/devextreme/js/__internal/grids/grid_core/ai_assistant/ai_assistant_view_controller.ts | New controller registering/removing a header toolbar item and delegating show/hide/toggle. |
| packages/devextreme/js/__internal/grids/grid_core/ai_assistant/tests/ai_assistant_view.test.ts | Update imports to match new file layout. |
| packages/devextreme/js/__internal/grids/grid_core/ai_assistant/tests/ai_assistant_view_controller.integration.test.ts | Add integration tests for toolbar registration, option changes, a11y attribute, and delegation. |
packages/devextreme/js/__internal/grids/grid_core/ai_assistant/ai_assistant_view_controller.ts
Outdated
Show resolved
Hide resolved
packages/devextreme/js/__internal/grids/data_grid/module_not_extended/ai_assistant.ts
Show resolved
Hide resolved
packages/devextreme/js/__internal/grids/tree_list/module_not_extended/ai_assistant.ts
Show resolved
Hide resolved
21ebe3c to
94a38e7
Compare
packages/devextreme/js/__internal/grids/grid_core/ai_assistant/ai_assistant_view_controller.ts
Show resolved
Hide resolved
packages/devextreme/js/__internal/grids/grid_core/header_panel/m_header_panel.ts
Outdated
Show resolved
Hide resolved
packages/devextreme/js/__internal/grids/data_grid/module_not_extended/ai_assistant.ts
Show resolved
Hide resolved
packages/devextreme/js/__internal/grids/grid_core/ai_assistant/ai_assistant_view_controller.ts
Show resolved
Hide resolved
f4fb1ec to
ce86ab0
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 18 out of 18 changed files in this pull request and generated 3 comments.
Comments suppressed due to low confidence (1)
packages/devextreme/js/__internal/grids/grid_core/ai_assistant/ai_assistant_view.ts:42
aiChatInstanceis lazily created in_renderCore(), but it’s declared with a definite assignment assertion (!) while the methods still treat it as optional via?./fallbacks. Consider making the field optional (AIChat | undefined) to accurately reflect its lifecycle and avoid masking initialization issues.
packages/devextreme/js/__internal/grids/grid_core/ai_assistant/ai_assistant_view_controller.ts
Show resolved
Hide resolved
packages/devextreme/js/__internal/grids/data_grid/module_not_extended/ai_assistant.ts
Show resolved
Hide resolved
packages/devextreme/js/__internal/grids/tree_list/module_not_extended/ai_assistant.ts
Show resolved
Hide resolved
ce86ab0 to
81ee689
Compare
| this.aiAssistantView = this.getView('aiAssistantView'); | ||
| this.headerPanel = this.getView('headerPanel'); | ||
|
|
||
| this.aiAssistantView.onVisibilityChanged = (visible: boolean): void => { |
There was a problem hiding this comment.
I think it’s better for us to add a callback at the aiAssistantView level, for example, visibilityChanged.
You can register the callback using the callbackNames method.
| import { ViewController } from '../m_modules'; | ||
| import type { AIAssistantView } from './ai_assistant_view'; | ||
|
|
||
| const AI_ASSISTANT_BUTTON_NAME = 'aiAssistantButton'; |
There was a problem hiding this comment.
I suggest moving the constants to a separate file - const.ts
| const aiAssistantToolbarItem = this.createAiAssistantToolbarItem(); | ||
|
|
||
| this.headerPanel?.applyToolbarItem(AI_ASSISTANT_BUTTON_NAME, aiAssistantToolbarItem); | ||
| this.aiAssistantView._invalidate(); |
There was a problem hiding this comment.
Most likely, calling this method won’t trigger a re-render of aiAssistantView (recreating the aiChatInstance), since aiAssistantView._renderCore only creates the aiChatInstance once.
|
|
||
| if (this.headerPanel) { | ||
| const aiAssistantClass = this.addWidgetPrefix(AI_ASSISTANT_BUTTON_CLASS); | ||
| this.$aiAssistantButton.addClass(this.headerPanel.getToolbarButtonClass(aiAssistantClass)); |
There was a problem hiding this comment.
Is it possible to set a class using elementAttr?
No description provided.