Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
17ec0eb
feat: AI creates and edits personal canvases from the chat and MCP
dfliess Oct 16, 2026
a2b24b3
feat: expose develop_personal_canvas on the org-level MCP server
dfliess Oct 16, 2026
2dd0210
feat: explain why a project doesn't serve a forwarded MCP tool
dfliess Oct 16, 2026
306bd36
fix: address review of personal canvases from the chat
dfliess Oct 16, 2026
c211db6
fix: limit the size of personal canvas edits, and clarify where the t…
dfliess Oct 16, 2026
c413c3c
feat: list canvases so the agent can find the dashboard to edit
dfliess Oct 16, 2026
251c341
refactor: align the personal canvas developer prompt with develop_file
dfliess Oct 16, 2026
8b59dfa
Merge remote-tracking branch 'upstream/main' into feat/personal-dashb…
dfliess Oct 17, 2026
60097d8
Merge remote-tracking branch 'upstream/main' into feat/personal-dashb…
dfliess Oct 26, 2026
ec47b72
docs: move mcpToolErrorf's comment back above it
dfliess Oct 26, 2026
26fcf2e
fix(chat): refresh personal dashboard lists after the AI saves one
dfliess Nov 7, 2026
d0469c6
Merge remote-tracking branch 'upstream/main' into feat/personal-dashb…
dfliess Nov 7, 2026
7b6f1b8
fix(admin): drop environment overrides and name from personal files s…
dfliess Nov 7, 2026
8e1c61d
fix(admin): write resolver properties of alerts and reports as plain …
dfliess Nov 7, 2026
6108ffc
feat(runtime): evaluate AI alerts with the analyst agent
dfliess Nov 7, 2026
6399f31
feat(alerts): add an AI condition to the alert dialog
dfliess Nov 7, 2026
14a852a
feat(admin): save and list alerts and reports on behalf of a user
dfliess Nov 7, 2026
1c5c724
fix(alerts): open formula alerts created through the API in the edit …
dfliess Nov 7, 2026
7d31743
fix(dashboards): read back comparisons saved as rill time expressions
dfliess Nov 7, 2026
8baa805
fix(alerts): name an alert's comparison on its page
dfliess Nov 7, 2026
2dec89d
feat(ai): create, edit and list alerts from the chat
dfliess Nov 7, 2026
22cd364
feat(ai): route alert requests to the analyst and expose the alert to…
dfliess Nov 7, 2026
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: 12 additions & 0 deletions admin/database/database.go
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,9 @@ type DB interface {
FindVirtualFilesByOwner(ctx context.Context, projectID, environment, ownerID string) ([]*VirtualFile, error)
UpsertVirtualFile(ctx context.Context, opts *InsertVirtualFileOptions) error
UpdateVirtualFileDeleted(ctx context.Context, projectID, environment, path string) error
// UpdateVirtualFileDataIfUnchanged updates the data of a virtual file that is not deleted and was last updated at updatedOn.
// It returns ErrNotFound if the file doesn't exist, was deleted, or changed since, so callers don't overwrite a concurrent update.
UpdateVirtualFileDataIfUnchanged(ctx context.Context, opts *UpdateVirtualFileDataOptions) error
DeleteExpiredVirtualFiles(ctx context.Context, retention time.Duration) error

FindAsset(ctx context.Context, id string) (*Asset, error)
Expand Down Expand Up @@ -1312,6 +1315,15 @@ type InsertVirtualFileOptions struct {
Data []byte `validate:"max=131072"` // 128kb
}

// UpdateVirtualFileDataOptions defines options for updating the data of a VirtualFile that was last updated at UpdatedOn.
type UpdateVirtualFileDataOptions struct {
ProjectID string
Environment string
Path string `validate:"required"`
Data []byte `validate:"max=131072"` // 128kb, as for InsertVirtualFileOptions
UpdatedOn time.Time
}

// Asset represents a user-uploaded file asset.
// For example, this can be an upload deploy of a project or a custom logo for an org.
type Asset struct {
Expand Down
13 changes: 13 additions & 0 deletions admin/database/postgres/postgres.go
Original file line number Diff line number Diff line change
Expand Up @@ -3111,6 +3111,19 @@ func (c *connection) UpdateVirtualFileDeleted(ctx context.Context, projectID, en
return checkUpdateRow("virtual file", res, err)
}

func (c *connection) UpdateVirtualFileDataIfUnchanged(ctx context.Context, opts *database.UpdateVirtualFileDataOptions) error {
if err := database.Validate(opts); err != nil {
return err
}

res, err := c.getDB(ctx).ExecContext(ctx, `
UPDATE virtual_files SET
data = $4,
updated_on = now()
WHERE project_id=$1 AND environment=$2 AND path=$3 AND NOT deleted AND updated_on=$5`, opts.ProjectID, opts.Environment, opts.Path, opts.Data, opts.UpdatedOn)
return checkUpdateRow("virtual file", res, err)
}

func (c *connection) DeleteExpiredVirtualFiles(ctx context.Context, retention time.Duration) error {
_, err := c.getDB(ctx).ExecContext(ctx, `DELETE FROM virtual_files WHERE deleted AND updated_on + $1 < now()`, retention)
return parseErr("virtual files", err)
Expand Down
159 changes: 157 additions & 2 deletions admin/server/alerts.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import (
adminv1 "github.com/rilldata/rill/proto/gen/rill/admin/v1"
runtimev1 "github.com/rilldata/rill/proto/gen/rill/runtime/v1"
"github.com/rilldata/rill/runtime"
"github.com/rilldata/rill/runtime/pkg/fileutil"
"github.com/rilldata/rill/runtime/pkg/observability"
"go.opentelemetry.io/otel/attribute"
"google.golang.org/grpc/codes"
Expand Down Expand Up @@ -262,6 +263,118 @@ func (s *Server) EditAlert(ctx context.Context, req *adminv1.EditAlertRequest) (
return &adminv1.EditAlertResponse{}, nil
}

func (s *Server) SaveAlertForUser(ctx context.Context, req *adminv1.SaveAlertForUserRequest) (*adminv1.SaveAlertForUserResponse, error) {
observability.AddRequestAttributes(ctx,
attribute.String("args.project_id", req.ProjectId),
attribute.String("args.user_id", req.UserId),
attribute.String("args.name", req.Name),
)

if req.Name != "" && !personalFileNameRegexp.MatchString(req.Name) {
return nil, status.Errorf(codes.InvalidArgument, "invalid alert name %q", req.Name)
}

proj, err := s.admin.DB.FindProject(ctx, req.ProjectId)
if err != nil {
return nil, err
}

user, permissions, err := s.userForPrimaryDeployment(ctx, proj, req.UserId, "alerts")
if err != nil {
return nil, err
}
if !permissions.CreateAlerts {
return nil, status.Error(codes.PermissionDenied, "user does not have permission to create alerts")
}

depl, err := s.admin.DB.FindDeployment(ctx, *proj.PrimaryDeploymentID)
if err != nil {
return nil, err
}

name := req.Name
var prev *database.VirtualFile
if name == "" {
name, err = s.generateVirtualFileName(ctx, req.Options.DisplayName, func(ctx context.Context, name string) error {
_, err := s.admin.LookupAlert(ctx, depl, name)
return err
})
} else {
prev, err = s.managedFileForEdit(ctx, proj.ID, virtualFilePathForManagedAlert(name), "alert", name, user.ID, req.Version)
}
if err != nil {
return nil, err
}

data, err := s.yamlForManagedAlert(req.Options, user.ID)
if err != nil {
return nil, status.Errorf(codes.InvalidArgument, "failed to generate alert YAML: %s", err.Error())
}

version, err := s.writeManagedFile(ctx, proj.ID, virtualFilePathForManagedAlert(name), data, "alert", name, prev)
if err != nil {
return nil, err
}

err = s.admin.TriggerParserAndAwaitResource(ctx, depl, name, runtime.ResourceKindAlert)
if err != nil {
if errors.Is(err, context.DeadlineExceeded) {
return nil, status.Error(codes.DeadlineExceeded, "timed out waiting for alert to be saved")
}
return nil, fmt.Errorf("failed to reconcile alert: %w", err)
}

org, err := s.admin.DB.FindOrganization(ctx, proj.OrganizationID)
if err != nil {
return nil, err
}

return &adminv1.SaveAlertForUserResponse{
Name: name,
Url: s.admin.URLs.WithCustomDomain(org.CustomDomain).AlertEdit(org.Name, proj.Name, name),
Version: version,
}, nil
}

func (s *Server) ListAlertsForUser(ctx context.Context, req *adminv1.ListAlertsForUserRequest) (*adminv1.ListAlertsForUserResponse, error) {
observability.AddRequestAttributes(ctx,
attribute.String("args.project_id", req.ProjectId),
attribute.String("args.user_id", req.UserId),
)

proj, err := s.admin.DB.FindProject(ctx, req.ProjectId)
if err != nil {
return nil, err
}

user, permissions, err := s.userForPrimaryDeployment(ctx, proj, req.UserId, "alerts")
if err != nil {
return nil, err
}
if !permissions.ReadProject {
return nil, status.Error(codes.PermissionDenied, "user does not have permission to read project")
}

files, err := s.managedFilesForUser(ctx, proj.ID, "alerts", user.ID)
if err != nil {
return nil, err
}

res := &adminv1.ListAlertsForUserResponse{}
for _, vf := range files {
opts, err := alertOptionsFromYAML(vf.Data)
if err != nil {
return nil, fmt.Errorf("failed to read alert %q: %w", vf.Path, err)
}
res.Alerts = append(res.Alerts, &adminv1.AlertForUser{
Name: fileutil.Stem(vf.Path),
Version: managedFileVersion(vf.UpdatedOn),
Options: opts,
})
}
return res, nil
}

func (s *Server) UnsubscribeAlert(ctx context.Context, req *adminv1.UnsubscribeAlertRequest) (*adminv1.UnsubscribeAlertResponse, error) {
observability.AddRequestAttributes(ctx,
attribute.String("args.organization", req.Org),
Expand Down Expand Up @@ -535,7 +648,7 @@ func (s *Server) yamlForManagedAlert(opts *adminv1.AlertOptions, ownerUserID str
res.Intervals.Duration = opts.IntervalDuration
if opts.Resolver != "" {
res.Data = map[string]any{
opts.Resolver: opts.ResolverProperties,
opts.Resolver: opts.ResolverProperties.AsMap(),
}
}
res.Query.Name = opts.QueryName
Expand All @@ -562,6 +675,48 @@ func (s *Server) yamlForManagedAlert(opts *adminv1.AlertOptions, ownerUserID str
return yaml.Marshal(res)
}

// alertOptionsFromYAML returns the options a managed alert was saved with, as yamlForManagedAlert wrote them.
func alertOptionsFromYAML(data []byte) (*adminv1.AlertOptions, error) {
var a alertYAML
if err := yaml.Unmarshal(data, &a); err != nil {
return nil, err
}
resolver, props, err := resolverFromYAML(a.Data)
if err != nil {
return nil, err
}
format, err := exportFormatFromYAML(a.Export.Format)
if err != nil {
return nil, err
}
opts := &adminv1.AlertOptions{
DisplayName: a.DisplayName,
RefreshCron: a.Refresh.Cron,
RefreshTimeZone: a.Refresh.TimeZone,
IntervalDuration: a.Intervals.Duration,
Resolver: resolver,
ResolverProperties: props,
QueryName: a.Query.Name,
QueryArgsJson: a.Query.ArgsJSON,
ExportAttach: a.Export.Attach,
ExportFormat: format,
ExportIncludeHeader: a.Export.IncludeHeader,
ExportLimit: a.Export.Limit,
Renotify: a.Renotify,
RenotifyAfterSeconds: a.RenotifyAfter,
EmailRecipients: a.Notify.Email.Recipients,
SlackUsers: a.Notify.Slack.Users,
SlackChannels: a.Notify.Slack.Channels,
SlackWebhooks: a.Notify.Slack.Webhooks,
WebOpenPath: a.Annotations.WebOpenPath,
WebOpenState: a.Annotations.WebOpenState,
}
if len(a.Refs) > 0 {
opts.MetricsViewName = strings.TrimPrefix(a.Refs[0], "MetricsView/")
}
return opts, nil
}

func (s *Server) yamlForCommittedAlert(opts *adminv1.AlertOptions) ([]byte, error) {
// Format args as pretty YAML
var args map[string]interface{}
Expand All @@ -585,7 +740,7 @@ func (s *Server) yamlForCommittedAlert(opts *adminv1.AlertOptions) ([]byte, erro
res.Intervals.Duration = opts.IntervalDuration
if opts.Resolver != "" {
res.Data = map[string]any{
opts.Resolver: opts.ResolverProperties,
opts.Resolver: opts.ResolverProperties.AsMap(),
}
}
res.Query.Name = opts.QueryName
Expand Down
Loading
Loading