Skip to content

Commit

Permalink
Show feedback when Copilot attempts to execute an invalid query
Browse files Browse the repository at this point in the history
  • Loading branch information
MarkMpn committed Aug 2, 2024
1 parent 3aa4543 commit 7ee3709
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
3 changes: 3 additions & 0 deletions MarkMpn.Sql4Cds.XTB/CopilotScriptObject.cs
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,9 @@ private async Task DoRunAsync(AsyncResultCollection<StreamingUpdate> updates)
error = error.InnerException;
}

var html = Markdown.ToHtml($"Errors found while validating a proposed query:\r\n\r\n```sql\r\n{query}\r\n```\r\n\r\n```\r\n{errors[0]}\r\n```\r\n\r\nRetrying...", _markdownPipeline);
await ShowPromptSuggestionAsync("warning", html, null, null);

var showListTablesHint = ex.Errors.Any(e => e.Number == 208);
var showGetColumnsInTableHint = ex.Errors.Any(e => e.Number == 207);
var showFindRelationshipHint = showGetColumnsInTableHint && ContainsJoin(query);
Expand Down
7 changes: 7 additions & 0 deletions MarkMpn.Sql4Cds.XTB/Resources/Copilot.html
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,13 @@
#result .suggestion .block {
margin-left: 10px;
}
#result .suggestion .block pre {
overflow-x: auto;
position: relative;
}
#result .suggestion .block div:has(>pre) {
position: relative;
}
#result .suggestion.info .block {
background-color: #f1faf1;
}
Expand Down

0 comments on commit 7ee3709

Please sign in to comment.