Repository navigation
feat(ai): create, list and delete scheduled reports from the chat (create_report, list_reports, delete_report) - #10234
nishantmonu51 wants to merge 7 commits into
Conversation
…reate_report`, `list_reports`, `delete_report`) Adds tools that let the analyst create scheduled reports for the user, list the user's own reports and delete them, through the admin service's create- and delete-for-user API, with the same create-and-delete-only direction as the alert tools (#10122 and #10123 reviews). - `create_report` creates explore data exports, saved as the report dialog saves them, and AI reports, which run the `ai` resolver. A report on a canvas, as a PDF, is left for later: its state is the dialog's URL parameters, which the tool would have to rebuild in Go. - One `comparison` argument compares an AI report's time range with an earlier period, as Rill time offsets. - Reports open with each recipient's permissions unless the user asks for `open_mode: creator`, which Slack recipients and attached exports need; the tool rejects those without it, and the admin service only sends to project members either way. - A Parquet export can't include a header, as in the dialog. - The export format is parsed with the parser's helper, now exported, instead of another mapping. - `list_reports` reads the user's reports from the runtime catalog, and `delete_report` deletes one once the user confirmed in a later message. Based on #10123. Co-authored-by: dfliess <dfliess@gmail.com>
nishantmonu51
left a comment
There was a problem hiding this comment.
Left a few notes on report setup and delivery.
| } | ||
|
|
||
| var err error | ||
| opts.Resolver = "ai" |
There was a problem hiding this comment.
The page currently can't edit the AI reports this creates. ReportMetadata.svelte disables Edit without an Explore, and when there is one, ScheduledReportDialog.svelte only loads and saves the aggregation query. Could the dialog get an AI edit path that preserves resolver: ai and its properties, or could we hide Edit for AI reports and remove the promise from the tool until it exists?
There was a problem hiding this comment.
Fixed in dd3e1b2: the report page hides Edit for AI reports, and the tools no longer promise editing them (to change one, the analyst creates a new report and deletes the old one); an AI edit path in the dialog can be a follow-up.
| } | ||
| opts.ExportLimit = export.Limit | ||
| opts.ExportIncludeHeader = export.IncludeHeader | ||
| opts.ExportAttach = export.Attach |
There was a problem hiding this comment.
With attach: true, creator mode and only slack_users, the report saves successfully but sends a link. ReportReconciler only generates the attachment when there are email recipients, and admin only defaults to the caller's email when both recipient lists are empty. Could setExploreData ask for an email recipient when the user requests an attachment with Slack-only delivery?
There was a problem hiding this comment.
Fixed in dd3e1b2: an attached export sent only to Slack users is rejected, asking for an email recipient.
| format = "csv" | ||
| } | ||
| opts.ExportFormat, err = parser.ParseExportFormat(format) | ||
| if err != nil || opts.ExportFormat == runtimev1.ExportFormat_EXPORT_FORMAT_PDF { |
There was a problem hiding this comment.
ParseExportFormat also accepts protobuf enum names. EXPORT_FORMAT_UNSPECIFIED slips through here, then parseReport rejects the saved legacy query for having no format. Could we reject it before the admin service writes the file?
| if err != nil || opts.ExportFormat == runtimev1.ExportFormat_EXPORT_FORMAT_PDF { | |
| if err != nil || opts.ExportFormat == runtimev1.ExportFormat_EXPORT_FORMAT_UNSPECIFIED || opts.ExportFormat == runtimev1.ExportFormat_EXPORT_FORMAT_PDF { |
There was a problem hiding this comment.
Fixed in dd3e1b2: the unspecified format is rejected before the admin service writes the report.
| Name: r.Meta.Name.Name, | ||
| DisplayName: spec.DisplayName, | ||
| Dashboard: spec.Annotations["explore"], | ||
| Schedule: spec.RefreshSchedule.GetCron(), |
There was a problem hiding this comment.
0 9 * * 1 alone leaves the analyst guessing whether Monday's report goes out at 9 AM in Madrid or UTC. Could ReportInfo include spec.RefreshSchedule.GetTimeZone(), using UTC for a cron with no configured zone?
There was a problem hiding this comment.
Fixed in dd3e1b2: ReportInfo now has time_zone, UTC when the cron has none.
| if err != nil { | ||
| return err | ||
| } | ||
| if err := checkExploreFields(explore, args.Explore, args.Measures, append(append([]string{}, args.Dimensions...), whereDims...)); err != nil { |
There was a problem hiding this comment.
Could we use slices.Concat(args.Dimensions, whereDims) here? It keeps the field checks in the same order and leaves both input slices alone.
… edit - Reject the unspecified export format, and an attachment sent only to Slack users, before the report is written. - Hide Edit for AI reports on the report page, whose dialog only edits an export's query, and stop the tools from promising it. - list_reports includes the schedule's time zone (UTC when unset) and whether a report is an AI report. - Check the explore's fields with slices.Concat.
|
This looks good. Leaving canvas PDF reports out for now is fine, for the reason you give, and hiding Edit for AI reports in The only change is the one that follows from #10232 and #10233: with Developed in collaboration with Claude Code |
# Conflicts: # runtime/ai/alert_report.go
…em in one call after review - Slack channels count like Slack users for the open_mode 'creator' rule and for the email recipient an attached export needs. - create_report passes Slack channels and rejects Slack recipients when the project has no Slack connector. - delete_report deletes in one call, with the shared confirm-first description. - create_report builds the report's URL with resourcePageURL, since the admin service no longer returns it.
|
@pjain1 Thanks, done in 6c655ae (after merging #10233 in 2afeae4):
|
nishantmonu51
left a comment
There was a problem hiding this comment.
I left a few notes inline.
| if args.Recipients != nil { | ||
| opts.EmailRecipients = args.Recipients.Emails | ||
| opts.SlackUsers = args.Recipients.SlackUsers | ||
| opts.SlackChannels = args.Recipients.SlackChannels |
There was a problem hiding this comment.
Posting AI reports to a channel gives the generated summary a wider audience. SendScheduledReport passes Summary and DisplayName straight into Slack markup, so report text can produce mentions or links that appear to come from Rill. Could it escape both fields with slackTextEscaper, like the alert notifier does for its reason?
There was a problem hiding this comment.
Fixed in ff674b0: the Slack notifier now escapes a report's display name and summary, and an alert's display name too, with a test for each.
| "The report belongs to the user, and they can delete it on its page, and edit an 'explore_data' report there. Only create a file in the project's code instead when the user explicitly asks for that. " + | ||
| confirmBeforeCreating + | ||
| "Reports open with each recipient's own permissions by default (open_mode 'recipient'). " + | ||
| "Sending to Slack users or channels, or attaching the export, needs open_mode 'creator': when the user asks for either, say so in the preview, explaining that with 'creator' every recipient sees the data with the user's permissions, without logging in, and only use it if they agree. " + |
There was a problem hiding this comment.
For a channel delivery, GetReportMeta issues an anonymous token. Someone who gets the forwarded link can open the report with the creator's permissions too. Could we make that explicit in the preview and in the open_mode field description?
| "Sending to Slack users or channels, or attaching the export, needs open_mode 'creator': when the user asks for either, say so in the preview, explaining that with 'creator' every recipient sees the data with the user's permissions, without logging in, and only use it if they agree. " + | |
| "Sending to Slack users or channels, or attaching the export, needs open_mode 'creator'. Explain in the preview that anyone with the report link can see the report with the creator's permissions without logging in, including if the link is forwarded. Only use 'creator' once the user agrees. " + |
There was a problem hiding this comment.
Fixed in ff674b0: the description and open_mode now say that with 'creator' anyone with the report's link, including people it's forwarded to, sees the data with the user's permissions without logging in.
| return errors.New("invalid input: attaching the export needs open_mode 'creator', since the export is run once for every recipient: ask the user") | ||
| } | ||
| // The report only attaches the export to emails, and the user's email is only the default recipient when there are no others. | ||
| if export.Attach && len(opts.EmailRecipients) == 0 && (len(opts.SlackUsers) > 0 || len(opts.SlackChannels) > 0) { |
There was a problem hiding this comment.
Could we put the Slack recipient check on Recipients and reuse it here, in the open_mode check and in checkSlackConfigured? All three encode the same rule about Slack users and channels, and a nil-safe hasSlack() would keep them in sync.
There was a problem hiding this comment.
Fixed in ff674b0: Recipients.hasSlack is now the one check, used by checkSlackConfigured and by the open_mode and attach rules.
…e forwarded after review - The Slack notifier escapes a report's display name and summary, and an alert's display name, which the AI writes, so they can't mention people or add links. - create_report's description and open_mode say that with 'creator', anyone with the report's link sees the data with the user's permissions, including people it's forwarded to. - Recipients.hasSlack is the one check for Slack users or channels, used by checkSlackConfigured and create_report's open_mode and attach rules.
Takes over #10123 with the same direction as the alert tools. Stacked on #10233.
create_reportcreates explore data exports (CSV, XLSX or Parquet), saved as the report dialog saves them, and AI reports.comparisonargument compares an AI report's period.open_modedefaults torecipient. Slack recipients and attached exports needcreator, and the tool rejects them otherwise. The admin service only sends to project members either way, so a creator-mode report can't reach an outside address.ParseExportFormat, not another mapping.list_reportsanddelete_reportwork like the alert tools.tr,tz,f.<mv>,tabs,pdf_*), which the tool would rebuild in Go. That should come with a check against the dialog's output, as the review asked.Checklist: