Skip to content

feat(ai): create, edit and list scheduled reports from the chat (save_report, list_reports) - #10123

Closed
dfliess wants to merge 24 commits into
rilldata:mainfrom
dfliess:dfliess/chat-reports
Closed

dfliess wants to merge 24 commits into
rilldata:mainfrom
dfliess:dfliess/chat-reports

Conversation

@dfliess

@dfliess dfliess commented Nov 7, 2026

Copy link
Copy Markdown
Contributor

Hey @nishantmonu51 @k-anshul,

Last of four stacked PRs, on top of #10122. Draft, to ask for your opinion. Only the commits after #10122's are new here.

The same as #10122, for scheduled reports: "send me the sales by region every Monday at 9" in the chat. Feel free to modify, adapt or discard it, or suggest changes.

  • save_report creates a report for the user, or edits one of their own, of the three kinds the dialog makes: an explore data export (measures, dimensions, filters, time range, CSV, XLSX or Parquet, limit, header and attachment), a canvas PDF (filters per metrics view, tabs, whether it shows the filters), or an AI report (prompt, data context, comparison period). It writes what the report dialog writes, so the report opens and edits there.
  • open_mode. Whether the report opens with each recipient's permissions (the default) or the creator's, as in the dialog.
  • list_reports lists the user's own reports with their definition in save_report's arguments.
  • Shared with alerts: the confirmation instruction, edits by name and version with the list of changes, explore names from a metrics view name, "contains" filters, and keeping the filters the tool can't write.
  • Who it opens as. When a report opens with the creator's permissions (attachments, or recipients outside the project), the preview has to say so, and the admin checks the creator may do it (feat(admin): save and list alerts and reports on behalf of a user #10121).

Things we were not sure about

  • Export formats. The mapping from the API's export formats to the YAML names now exists in the parser, admin/server/reports.go and here. We kept a small local map instead of moving the others, to not touch more code. Happy to share one helper if you prefer.
  • Canvas filters replace the whole filter of each metrics view passed, measure filters included. Keeping those would mean writing them into the canvas state too, so we left it.

Happy to rename things or rework it, and just as happy to keep it on our side if you don't want it.


Developed in collaboration with Claude Code

Adds a `develop_personal_canvas` tool to the analyst agent. It runs a sub-agent
with the canvas instructions that saves the dashboard as a personal canvas of
the session's user through a new `write_personal_canvas` tool, which reports
parse and reconcile errors back so the sub-agent can fix them.

Personal canvases are stored by the admin service, so the runtime saves them
through a new internal RPC, `SavePersonalFileForUser`. Only the project's
deployment can call it, the owner must be a user with read access to the
project, annotations in the YAML are dropped, and edits keep the canvas'
sharing state. The tools need the `personal_canvases` feature flag and a user
in the session, and `write_personal_canvas` is only available inside
`develop_personal_canvas`.
Personal canvases are owned by the user rather than stored in the repo, so creating one
doesn't need the edit access the other unforwarded tools require. The runtime still
rejects calls for projects without the personal_canvases feature flag.
The org-level MCP server lists the same tools for every project, so a client only learns
that a project lacks one when it calls it. Instead of passing on the runtime's "unknown
tool" error, say why, and for develop_personal_canvas, that the project doesn't enable
personal canvases.
- Read a personal canvas' parse status only after the project parser has
  pulled and parsed it. Waiting for idle while ignoring hidden resources
  returned before the (hidden) parser finished, so a broken canvas could be
  reported as saved.
- Only the project's primary deployment can save personal files, since they
  live in the prod environment, and the tools are hidden outside prod.
- Edits fail instead of overwriting a canvas the user shared, unshared or
  deleted while it was being saved, using a conditional update.
- Hide the tools from service tokens, which carry a user id but no email.
- Only mention get_canvas to the sub-agent when the client can call it.
- Validate edited names, take the display name from the YAML on edits, and
  require project_id and yaml in the request.
- Reword the MCP error for an unavailable develop_personal_canvas, and
  document the tool.
…ool is available

Conditional updates of virtual files now apply the same 128kb limit as inserts.
The docs say the tool is Rill Cloud only, and the MCP error mentions service tokens.
The agent couldn't find the name of a personal canvas to edit from a new
conversation: it was given the display name, develop_personal_canvas
returned not found and the agent created a duplicate dashboard instead.

list_canvases lists the canvases the user can see, including their own
personal canvases marked with personal: true. Other users' personal
canvases are never listed, even for project admins who can open them.
Move the prompt to a userPrompt method and split it into important and
additional context, as develop_file does. Add the user's memories, so
preferences stated to the analyst also apply to the dashboards it builds.
…oard-from-chat

# Conflicts:
#	proto/gen/rill/admin/v1/api.pb.go
…oard-from-chat

# Conflicts:
#	proto/gen/rill/admin/v1/api.pb.go
#	runtime/drivers/admin.go
#	runtime/testruntime/noopadmin.go
#	runtime/testruntime/testruntime.go
A dashboard the AI saved from the chat did not show in the personal
dashboards list until a full reload: nothing refetched the admin's
ListPersonalFiles, and queries don't refetch on mount or focus, so going
back to the page reused the cached list too.

- The chat tool registry's onResult for develop_personal_canvas, the hook
  update_memory uses, refetches the runtime resources and emits
  personal-files-changed on the event bus. web-admin owns the admin
  query, so a listener mounted by the project layout refetches
  ListPersonalFiles on it. Both use refetchType "all": an invalidated
  query nobody observes is not refetched when it mounts again.
- getPersonalFilteredResources refetches both lists on mount, as the
  alerts and reports lists do, so a dashboard saved away from the page
  (e.g. over MCP) shows up when coming back.
…oard-from-chat

# Conflicts:
#	admin/server/mcp.go
#	proto/gen/rill/admin/v1/api.pb.go
#	runtime/ai/ai.go
…aved on behalf of a user

The sanitizer only dropped the top-level annotations, but the parser applies
prod:, env: and environment_overrides: over them, so the model's YAML could
still share a personal canvas, change its owner or turn off admin_managed.
A name or namespace also registered the canvas under another name than its
file's, which broke the returned link and later edits.

Drop those keys too, and test the sanitized YAML through the parser as a
primary deployment parses it.
…YAML

Alerts and reports created through the API with a resolver serialized its
properties as the protobuf Struct's internals (fields/kind/stringvalue), so
the runtime parsed different properties than it was given.
An alert with the ai resolver has its prompt judged as a condition by the
analyst agent, which ends with a structured verdict. A met condition returns
one row with the verdict's reason and the conversation, so the alert fires;
a malformed verdict or an exhausted tool budget is an evaluation error.
The check runs with the alert's own claims, and notifications show the
reason and link to the conversation.
The data tab switches between criteria and an AI condition written as a
sentence. AI alerts load into and save from the dialog however they were
created, and the alert page and history show the condition and the reason
an AI alert triggered.
Adds SaveAlertForUser, ListAlertsForUser, SaveReportForUser and
ListReportsForUser, and exposes them to the runtime through the admin
service driver. They let the runtime create and edit alerts and reports
for the user of its session, as the alert and report dialogs do.

Only the project's primary deployment can call them, and only for a
user with access to the project. They write the same managed YAML as
CreateAlert and CreateReport, owned by that user, and only edit
alerts and reports the user owns.

An edit is based on the version a list returned, and fails if the
file changed since, so it doesn't overwrite a change made from the
dialog in the meantime. A report that opens with each recipient's own
permissions is rejected if a recipient or option needs the creator's,
with an error that explains the alternative.
…dialog

The dialog waited for the dashboard state decoded from web_open_state
before editing any alert but an AI one. An alert created through the
API may have no web_open_state, so such a formula alert never opened.
Editing builds its values, filters and time controls from the alert's
spec alone, so only creating waits for the dashboard state now.
A comparison of a rill time expression is saved as the expression with
the option's offset, like "offset -1M" for the previous month. Reading
it back had no branch for expressions, so the alert and report dialogs
showed every such comparison as the previous period, and opening an
alert or report on its dashboard did the same. It now takes the option
from the trailing offset; any other expression reads as before.
The alert page labelled a comparison saved as a rill time expression,
like "offset -1M", as the previous period: getComparisonLabel took a
range with neither ISO offset nor duration for one. The criteria named
the comparison from the ISO offset only, falling back to an untranslated
"previous period". Both now read the comparison option from the
expression's offset, as the dialog's mappers do, and the criteria fall
back to the translated previous period.
Adds the save_alert and list_alerts tools to the analyst. They save
alerts through the admin service on behalf of the session's user, as
the alert dialog saves them: a formula alert over the dialog's
MetricsViewAggregation query, or an AI alert judged by the ai
resolver. The user owns them and can keep editing them in the dialog.

An edit starts from the alert as listed and only changes the arguments
it sends, so settings the arguments can't express, like the dashboards'
measure filters or a time range saved as an ISO duration, are kept.
It's based on the version the list returned, and fails if the alert
changed since.

The tools are only offered to users present to confirm what they save,
in prod deployments: not to service tokens, nor to the sessions of AI
reports and alerts.
…ols over MCP

Requests to create or change an alert go to the analyst, which saves
an alert the user owns, unless the user asks for a file in the
project. The org-level MCP server forwards save_alert and list_alerts,
which don't need runtime.EditRepo since the alerts they save aren't
stored in the repo.
@nishantmonu51
nishantmonu51 requested a review from pjain1 November 17, 2026 06:01
@pjain1

pjain1 commented Nov 27, 2026

Copy link
Copy Markdown
Member

The same direction as #10122 applies here: create and delete only, with a slim list, and no editing from the chat for now. All three report kinds are fine to keep.

Create and delete only. save_report reuses the patch machinery from #10122 and has the same problems. Changing measures or dimensions on a dialog-created report leaves q.Sort untouched, so the query can end up sorting by a field it no longer selects. Please drop name, version and Changes, add delete_report for the user's own reports, and slim list_reports down to what is needed to find a report and link to it.

open_mode: creator needs a hard gate. checkReportNeedsCreator returns as soon as the mode is creator, so nothing in code stops the model from sending a no-login, creator-permission report to an outside address. The enforced confirmation described on #10122 needs to cover this.

AI reports cannot be edited anywhere. The report dialog does not build AI reports, and ReportMetadata.svelte hides Edit for them, so a chat-created AI report can only be deleted and recreated. That is acceptable for now. A UI to create and edit AI reports should come as separate work, and before chat editing is considered.

Canvas reports. applyCanvasArgs re-implements the dialog's URL parameters in Go (tr, tz, f.<mv>, tabs, pdf_*), and f.<mv> has to stay consistent with metrics_view_filters. Please add a test that checks the Go output against what the dialog writes for the same report.

Smaller points.

  • The export format mapping is now in four places (parser, admin server, reconciler and here). Please use one shared helper.
  • comparison and compare_to_previous_period overlap; one is enough.
  • export.include_header is accepted with Parquet, while the UI forces it off.
  • The kind description says "CSV or XLSX" while export.format also accepts Parquet.

Developed in collaboration with Claude Code

@nishantmonu51

Copy link
Copy Markdown
Collaborator

I just raised a follow-up that handles the review comments: #10234. @pjain1 please check.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants