Skip to content
Merged
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
12 changes: 11 additions & 1 deletion backend/src/entities/ai/ai.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ interface AIGeneratedTableSettings {
columns_view: string[];
ordering: string;
ordering_field: string;
identity_column: string | null;
widgets: Array<{
field_name: string;
widget_type: string;
Expand Down Expand Up @@ -135,6 +136,7 @@ For each table, provide:
5. ordering: Default sort order - either "ASC" or "DESC" (use "DESC" for tables with timestamps to show newest first)
6. ordering_field: Column name to sort by default (prefer created_at, updated_at, or primary key)
7. widgets: For each column, suggest the best widget type from: ${widgetTypes}
8. identity_column: The column that best identifies a row in human-readable format. This is shown when other tables reference this table via foreign keys, so users see meaningful data instead of just IDs. Choose columns like: name, title, email, username, full_name, label, or any descriptive text field. If no good candidate exists, use null.
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Minor: trailing whitespace in prompt string.

There is a trailing space after use null. at the end of line 139. Not functional, but it slightly bloats the prompt sent to the model. Consider trimming.

✂️ Proposed fix
-8. identity_column: The column that best identifies a row in human-readable format. This is shown when other tables reference this table via foreign keys, so users see meaningful data instead of just IDs. Choose columns like: name, title, email, username, full_name, label, or any descriptive text field. If no good candidate exists, use null. 
+8. identity_column: The column that best identifies a row in human-readable format. This is shown when other tables reference this table via foreign keys, so users see meaningful data instead of just IDs. Choose columns like: name, title, email, username, full_name, label, or any descriptive text field. If no good candidate exists, use null.
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
8. identity_column: The column that best identifies a row in human-readable format. This is shown when other tables reference this table via foreign keys, so users see meaningful data instead of just IDs. Choose columns like: name, title, email, username, full_name, label, or any descriptive text field. If no good candidate exists, use null.
8. identity_column: The column that best identifies a row in human-readable format. This is shown when other tables reference this table via foreign keys, so users see meaningful data instead of just IDs. Choose columns like: name, title, email, username, full_name, label, or any descriptive text field. If no good candidate exists, use null.
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@backend/src/entities/ai/ai.service.ts` at line 139, Remove the trailing space
at the end of the prompt string in backend/src/entities/ai/ai.service.ts (the
prompt text ending with "use null."); locate the string literal that contains
"identity_column: The column that best identifies a row in human-readable
format... use null." and trim the trailing whitespace (or apply .trim() where
the prompt is constructed) so the prompt sent to the model no longer includes
the extra space.


Available widget types and when to use them:

Expand Down Expand Up @@ -242,6 +244,7 @@ Respond ONLY with valid JSON in this exact format (no markdown, no explanations)
"columns_view": ["id", "name", "email", "created_at"],
"ordering": "DESC",
"ordering_field": "created_at",
"identity_column": "name",
"widgets": [
{
"field_name": "id",
Expand Down Expand Up @@ -303,7 +306,10 @@ IMPORTANT:

const requiredFieldsWithoutDefault = new Set(
tableInfo?.structure
.filter((col) => !col.allow_null && col.column_default === null && !checkFieldAutoincrement(col.column_default, col.extra))
.filter(
(col) =>
!col.allow_null && col.column_default === null && !checkFieldAutoincrement(col.column_default, col.extra),
)
.map((col) => col.column_name) || [],
);

Expand All @@ -325,6 +331,10 @@ IMPORTANT:
settings.ordering_field = validColumnNames.includes(tableSettings.ordering_field)
? tableSettings.ordering_field
: null;
settings.identity_column =
tableSettings.identity_column && validColumnNames.includes(tableSettings.identity_column)
? tableSettings.identity_column
: null;
settings.table_widgets = tableSettings.widgets
.filter((w) => validColumnNames.includes(w.field_name))
.map((widgetData) => {
Expand Down
Loading