Skip to content

feat: .env UI editor#8520

Draft
royendo wants to merge 62 commits into
mainfrom
feat/env-ui-editor
Draft

feat: .env UI editor#8520
royendo wants to merge 62 commits into
mainfrom
feat/env-ui-editor

Conversation

@royendo

@royendo royendo commented Dec 16, 2025

Copy link
Copy Markdown
Contributor

QA: https://www.loom.com/share/d863c0a6eb3c404d9a24b49c280ca4ac

Adds a visual editor for .env files in Rill Developer with push/pull sync to Rill Cloud.

  • No-code table view for adding, editing, and deleting environment variables alongside the raw code editor
  • Pull/Push buttons to merge variables between local .env and Rill Cloud (disabled when project is not linked, with contextual tooltips)
  • "View in Cloud" link for admins to jump to the cloud env vars settings page
  • Import .env file support in the Add dialog
  • Platform-aware keyboard hints, stable {#each} keys, toast notifications on all CRUD operations
  • Uses dotenv parser consistently (no custom parser)

Decision: We dont need to support all CLI paths, just the main one. From the UI, we wont add support for --path unless specifically asked for it. We can add an Advanced Tab in the dropdown UI in the future.

Checklist:

  • Covered by tests
  • Ran it and it works as intended
  • Reviewed the diff before requesting a review
  • Checked for unhandled edge cases
  • Linked the issues it closes
  • Checked if the docs need to be updated. If so, create a separate Linear DOCS issue
  • Intend to cherry-pick into the release branch
  • I'm proud of this work!

@royendo

royendo commented Dec 16, 2025

Copy link
Copy Markdown
Contributor Author

where to consolidate utils?
web-common/src/features/environment-variables/utils.ts
and
web-admin/src/features/projects/environment-variables/utils.ts

have the same functions and lots of repeat since they are the same functionality

@royendo

royendo commented Dec 17, 2025

Copy link
Copy Markdown
Contributor Author

Before Deploy: Screenshot 2025-12-17 at 13 25 34

After Deploy: Screenshot 2025-12-17 at 13 26 54

Code view Before Deploy:
Screenshot 2025-12-17 at 14 37 39

looks like we didnt habe this already so claude code/cursor did some work and i rebuild proto...
since its new feature it shouldnt effect anything else
@royendo royendo requested a review from mindspank December 17, 2025 19:17
@royendo

royendo commented Dec 17, 2025

Copy link
Copy Markdown
Contributor Author

@begelundmuller , based on Mike's requests to add push-pull button in the UI here: https://rilldata.slack.com/archives/C01A9DYP013/p1765989576246559?thread_ts=1765901488.470909&cid=C01A9DYP013

required some new backend changes, so tagging you as a reviewer for this PR, as well.

If this is "too complicated" or adds brittleness to the code base, we can remove the backend changes and buttons for this PR and tackle it in a dedicated PR in the future.

Thoughts?

@begelundmuller begelundmuller left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The backend code here seems correct at a high level, although it could do with some cleaning up (there are some anti-patterns and no tests)

@royendo

royendo commented Jan 20, 2026

Copy link
Copy Markdown
Contributor Author

Code Review

Professionalism & Code Quality: ⭐⭐⭐⭐⭐ (Excellent)

Strengths:

  • Comprehensive implementation of PullEnv and PushEnv RPC handlers
  • Good use of maps.Equal for checking if variables are up to date
  • Proto definitions are clean with proper comments

Issues to Address:

  1. Error handling could be more specific in cli/pkg/local/server.go:717:

    return nil, fmt.Errorf("failed to write .env file: %w", err)

    Consider distinguishing between permission errors and other I/O errors.

  2. Default environment assumption - The PullEnv defaults to "dev" which may surprise users expecting "prod".

E2E Testing: ⚠️ Missing

No E2E tests for pull/push env functionality.

Recommendations:

  • Add E2E test for rill env pull CLI command
  • Test conflict resolution when local and cloud variables differ
  • Test authentication required scenarios

General Comments:

  • The merge strategy (local first, then cloud overwrites) is clear and documented in the request/response messages
  • Good use of EnsureGitignoreHasDotenv for security

@royendo

royendo commented Jan 22, 2026

Copy link
Copy Markdown
Contributor Author

Just spoke to Mike and got confirmed that we want this in UI

@begelundmuller begelundmuller requested review from k-anshul and removed request for begelundmuller February 18, 2026 13:35
Comment thread cli/cmd/env/pull.go
maps.Copy(vars, existing)
maps.Copy(vars, resVars)
path := pathForEnv(env)
err = godotenv.Write(vars, filepath.Join(projectPath, path))

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This means vars from deep .env file like model/.env gets rewritten to root .env. But it was the same behaviour earlier also. Not sure if it was a bug.

Comment thread proto/rill/admin/v1/api.proto
Comment thread proto/rill/runtime/v1/api.proto Outdated
Comment on lines +378 to +384
// PullEnv pulls environment variables from cloud to local .env file
rpc PullEnv(PullEnvRequest) returns (PullEnvResponse) {
option (google.api.http) = {
post: "/v1/instances/{instance_id}/env/pull",
body: "*"
};
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Could this functionality be covered by the existing ReloadConfig function?

Since in cloud, admin calls ReloadConfig on all runtimes when a variable is changed; so ReloadConfig already serves the purpose of triggering re-pull of variables.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

But ReloadConfig is a no-op for rill developer and it is used in web-local UI as well.
I can route it to ReloadConfig for cloud runtimes if we want to avoid env updates from two places.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Discussed separately; Anshul will update with his findings.

Comment thread proto/rill/runtime/v1/api.proto Outdated
Comment thread proto/rill/admin/v1/api.proto Outdated
Comment thread runtime/drivers/admin.go Outdated
ProvisionConnector(ctx context.Context, name, driver string, args map[string]any) (map[string]any, error)
GetDeploymentConfig(ctx context.Context) (*DeploymentConfig, error)
ListDeployments(ctx context.Context) ([]*Deployment, error)
GetProjectVariables(ctx context.Context, environment string) (map[string]map[string]string, error)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Same question as earlier – isn't this already covered by GetDeploymentConfig?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Same - local runtimes can't use GetDeploymentConfig

Comment thread runtime/server/env.go Outdated
Comment thread runtime/config_reloader.go Outdated
Comment thread runtime/config_reloader.go Outdated
Comment thread runtime/config_reloader.go Outdated
Comment thread runtime/config_reloader.go Outdated
@begelundmuller

Copy link
Copy Markdown
Contributor

FYI the backend implementation has been extracted into this PR: #9294

@royendo

royendo commented Apr 29, 2026

Copy link
Copy Markdown
Contributor Author

okay, ill rework this to a UI only PR after rebasing with main

@royendo royendo requested review from a team as code owners April 29, 2026 15:46
@royendo royendo marked this pull request as draft April 29, 2026 15:49
royendo added 4 commits April 29, 2026 11:53
This reverts commit 1c48d6d.
# Conflicts:
#	admin/server/deployment.go
#	cli/cmd/env/push.go
#	cli/pkg/local/admin.go
#	cli/pkg/local/app.go
#	docs/docs/reference/cli/env/push.md
#	proto/gen/rill/admin/v1/api.pb.go
#	proto/gen/rill/runtime/v1/api.pb.go
#	proto/gen/rill/runtime/v1/api.pb.gw.go
#	proto/gen/rill/runtime/v1/api.pb.validate.go
#	proto/gen/rill/runtime/v1/api_grpc.pb.go
#	proto/gen/rill/runtime/v1/runtime.swagger.yaml
#	proto/rill/runtime/v1/api.proto
#	runtime/config_reloader.go
#	runtime/runtime.go
#	runtime/server/env.go
#	runtime/server/instances.go
#	web-admin/src/routes/[organization]/[project]/-/settings/environment-variables/+page.svelte
#	web-common/src/proto/gen/rill/runtime/v1/api_connect.ts
#	web-common/src/proto/gen/rill/runtime/v1/api_pb.ts
#	web-common/src/runtime-client/v2/gen/runtime-service.ts
#	web-local/src/routes/(application)/(workspace)/files/[...file]/+page.svelte
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.

4 participants