Skip to content

Commit 8627817

Browse files
Merge pull request #1774 from rocket-admin/edit-schema-ai-context
feat: pass threadId across schema generation requests for conversatio…
2 parents a8ed4ee + f9c49ce commit 8627817

2 files changed

Lines changed: 8 additions & 3 deletions

File tree

frontend/src/app/components/edit-database-schema/edit-database-schema.component.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ export class EditDatabaseSchemaComponent implements OnInit, AfterViewInit {
5050
protected applied = signal(false);
5151
protected diagramZoom = signal(1);
5252
protected initialDiagramLoading = signal(false);
53+
private _threadId: string | undefined;
5354

5455
protected pendingBatch = computed(() => {
5556
const msgs = this.messages();
@@ -98,7 +99,10 @@ export class EditDatabaseSchemaComponent implements OnInit, AfterViewInit {
9899
this.submitting.set(true);
99100

100101
try {
101-
const result = await this._tableSchema.generateSchemaChange(this.connectionID, prompt);
102+
const result = await this._tableSchema.generateSchemaChange(this.connectionID, prompt, this._threadId);
103+
if (result.threadId) {
104+
this._threadId = result.threadId;
105+
}
102106
if (result && result.changes.length > 0) {
103107
const summary = result.changes.map(c => `**${c.changeType}** \`${c.targetTableName}\`${c.aiSummary ? ' — ' + c.aiSummary : ''}`).join('\n');
104108
this.messages.update(msgs => [...msgs, {

frontend/src/app/services/table-schema.service.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ export interface SchemaChangeResponse {
3535
export interface SchemaChangeBatchResponse {
3636
batchId: string;
3737
changes: SchemaChangeResponse[];
38+
threadId?: string | null;
3839
}
3940

4041
@Injectable({
@@ -43,8 +44,8 @@ export interface SchemaChangeBatchResponse {
4344
export class TableSchemaService {
4445
private _api = inject(ApiService);
4546

46-
async generateSchemaChange(connectionId: string, userPrompt: string): Promise<SchemaChangeBatchResponse> {
47-
return this._fetchOrThrow<SchemaChangeBatchResponse>(`/table-schema/${connectionId}/generate`, { userPrompt });
47+
async generateSchemaChange(connectionId: string, userPrompt: string, threadId?: string): Promise<SchemaChangeBatchResponse> {
48+
return this._fetchOrThrow<SchemaChangeBatchResponse>(`/table-schema/${connectionId}/generate`, { userPrompt, threadId });
4849
}
4950

5051
async approveBatch(batchId: string, confirmedDestructive?: boolean): Promise<SchemaChangeBatchResponse> {

0 commit comments

Comments
 (0)