Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ export class EditDatabaseSchemaComponent implements OnInit, AfterViewInit {
protected applied = signal(false);
protected diagramZoom = signal(1);
protected initialDiagramLoading = signal(false);
private _threadId: string | undefined;

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

try {
const result = await this._tableSchema.generateSchemaChange(this.connectionID, prompt);
const result = await this._tableSchema.generateSchemaChange(this.connectionID, prompt, this._threadId);
if (result.threadId) {
this._threadId = result.threadId;
}
if (result && result.changes.length > 0) {
const summary = result.changes.map(c => `**${c.changeType}** \`${c.targetTableName}\`${c.aiSummary ? ' — ' + c.aiSummary : ''}`).join('\n');
this.messages.update(msgs => [...msgs, {
Expand Down
5 changes: 3 additions & 2 deletions frontend/src/app/services/table-schema.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ export interface SchemaChangeResponse {
export interface SchemaChangeBatchResponse {
batchId: string;
changes: SchemaChangeResponse[];
threadId?: string | null;
}

@Injectable({
Expand All @@ -43,8 +44,8 @@ export interface SchemaChangeBatchResponse {
export class TableSchemaService {
private _api = inject(ApiService);

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

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