chore: Add chat widget migration (#40635)

## Description

Update the field for widget in AI chat widget

## Automation

/ok-to-test tags="@tag.Sanity"

### 🔍 Cypress test results
<!-- This is an auto-generated comment: Cypress test results  -->
> [!TIP]
> 🟢 🟢 🟢 All cypress tests have passed! 🎉 🎉 🎉
> Workflow run:
<https://github.com/appsmithorg/appsmith/actions/runs/14970367321>
> Commit: ce4a027e3892b8610a46ce07b6632b6f9a64c6c8
> <a
href="https://internal.appsmith.com/app/cypress-dashboard/rundetails-65890b3c81d7400d08fa9ee5?branch=master&workflowId=14970367321&attempt=1"
target="_blank">Cypress dashboard</a>.
> Tags: `@tag.Sanity`
> Spec:
> <hr>Mon, 12 May 2025 11:35:44 UTC
<!-- end of auto-generated comment: Cypress test results  -->


## Communication
Should the DevRel and Marketing teams inform users about this change?
- [ ] Yes
- [ ] No


<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

## Summary by CodeRabbit

- **New Features**
- Updated AI chat widget configuration to use dynamic query references,
enhancing flexibility and tracking.
- **Chores**
  - Upgraded the DSL migration system to support the latest version.
- **Bug Fixes**
- Improved reliability when creating or updating data sources by
ensuring actions complete before proceeding.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
This commit is contained in:
Hetu Nandu 2025-05-12 17:12:11 +05:30 committed by GitHub
parent b206824e8e
commit 74b7afee10
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 45 additions and 1 deletions

View File

@ -92,9 +92,10 @@ import { migrateChartwidgetCustomEchartConfig } from "./migrations/087-migrate-c
import { migrateCustomWidgetDynamicHeight } from "./migrations/088-migrate-custom-widget-dynamic-height";
import { migrateTableWidgetV2CurrentRowInValidationsBinding } from "./migrations/089-migrage-table-widget-v2-currentRow-binding";
import { migrateTableComputeValueBinding } from "./migrations/090-migrate-table-compute-value-binding";
import { migrateAIChatWidget } from "./migrations/092-update-ai-chat-widget";
import type { DSLWidget } from "./types";
export const LATEST_DSL_VERSION = 92;
export const LATEST_DSL_VERSION = 93;
export const calculateDynamicHeight = () => {
const DEFAULT_GRID_ROW_HEIGHT = 10;
@ -630,6 +631,11 @@ const migrateVersionedDSL = async (currentDSL: DSLWidget, newPage = false) => {
* What we missed was that, the auto-commit does not handle clientVersion, which lead to this bug: https://github.com/appsmithorg/appsmith/issues/38511
* We are bumping this version to make sure that the auto-commit will handle this version bump.
*/
currentDSL.version = 92;
}
if (currentDSL.version === 92) {
currentDSL = migrateAIChatWidget(currentDSL);
currentDSL.version = LATEST_DSL_VERSION;
}

View File

@ -0,0 +1,25 @@
// This migration updates the ai chat widget to use dynamic bindings
// Earlier we had chatQuery which was a static field of the name of the query
// Now we have queryRun which is a dynamic binding path which points to the actionId of the query
// Old format: [QueryName]
// New format: {{[QueryName].actionId}}
import type { DSLWidget, WidgetProps } from "../types";
import { traverseDSLAndMigrate } from "../utils";
export const migrateAIChatWidget = (currentDSL: DSLWidget) => {
return traverseDSLAndMigrate(currentDSL, (widget: WidgetProps) => {
if (widget.type !== "WDS_AI_CHAT_WIDGET") return;
const queryName = widget.chatQuery;
if (!queryName) return;
widget.queryRun = `{{${queryName}.actionId}}`;
widget.dynamicBindingPathList = widget.dynamicBindingPathList
.filter((path: string) => path !== "chatQuery")
.concat({ key: "queryRun" });
delete widget.chatQuery;
});
};

View File

@ -91,6 +91,7 @@ import * as m87 from "../migrations/087-migrate-chart-widget-customechartdata";
import * as m88 from "../migrations/088-migrate-custom-widget-dynamic-height";
import * as m89 from "../migrations/089-migrage-table-widget-v2-currentRow-binding";
import * as m90 from "../migrations/090-migrate-table-compute-value-binding";
import * as m92 from "../migrations/092-update-ai-chat-widget";
interface Migration {
functionLookup: {
@ -941,9 +942,19 @@ const migrations: Migration[] = [
version: 90,
},
{
// This migration is skipped
functionLookup: [],
version: 91,
},
{
functionLookup: [
{
moduleObj: m92,
functionName: "migrateAIChatWidget",
},
],
version: 92,
},
];
const mockFnObj: Record<number, any> = {};

View File

@ -1168,6 +1168,8 @@ export function* createOrUpdateDataSourceWithAction(
type: ReduxActionTypes.CREATE_ACTION_REQUEST,
});
yield take(ReduxActionTypes.CREATE_ACTION_SUCCESS);
yield put(setIdeEditorViewMode(EditorViewMode.SplitScreen));
const actions: ActionDataState = yield select(getActions);