Skip to content

Conversation

@HarshMN2345
Copy link
Member

@HarshMN2345 HarshMN2345 commented Feb 12, 2026

What does this PR do?

(Provide a description of what this PR does.)

Test Plan

example:
image

Related PRs and Issues

(If this PR is related to any other PR or resolves any issue or related to any issue link all related PR and issues here.)

Have you read the Contributing Guidelines on issues?

(Write your answer here.)

Summary by CodeRabbit

  • New Features

    • Interactive Environment Variables manager with create/import/update/delete flows, secret masking, and analytics tracking.
    • Automatic detection, normalization, and merge of runtime-detected variables with visible loading states in function/site creation flows.
    • Configurable product label and customizable documentation link surfaced in variable-related dialogs.
  • Chore

    • Consolidated environment-variable UI into a single reusable component for simpler integration and reduced inline modal complexity.

@appwrite
Copy link

appwrite bot commented Feb 12, 2026

Console (appwrite/console)

Project ID: 688b7bf400350cbd60e9

Sites (1)
Site Status Logs Preview QR
 console-stage
688b7cf6003b1842c9dc
Ready Ready View Logs Preview URL QR Code

Tip

Each function runs in its own isolated container with custom environment variables

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 12, 2026

Walkthrough

Adds a new EnvironmentVariables Svelte component that provides a full UI for managing environment variables and exports: variables, productLabel, docsLink, analyticsSource, analyticsCreateSource, and isLoading. Integrates this component into function and site creation flows, replacing prior inline environment-variable UI and modal state in site configuration. Introduces helpers: DetectedVariable type, normalizeDetectedVariables, and mergeVariables to normalize and merge detected runtime variables. Parametrizes existing variable modals with productLabel and variable editor with docsLink.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: adding auto-fill functionality for detected environment variables in sites and functions.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feat-detection-vars

No actionable comments were generated in the recent review. 🎉

🧹 Recent nitpick comments
src/lib/helpers/variables.ts (1)

26-40: existing entries with undefined key silently collapse in the Map.

Line 30 builds the Map from existing without filtering out entries that have key: undefined. If multiple such entries exist, they'll overwrite each other under the undefined map key. Consider filtering, similar to how detected entries are guarded on line 32–34.

♻️ Suggested defensive filter
 export function mergeVariables(
     existing: Partial<Models.Variable>[],
     detected: Partial<Models.Variable>[]
 ) {
-    const map = new Map(existing.map((variable) => [variable.key, variable]));
+    const map = new Map(
+        existing.filter((v) => v.key).map((variable) => [variable.key, variable])
+    );
     detected.forEach((variable) => {

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Fix all issues with AI agents
In
`@src/routes/`(console)/project-[region]-[project]/sites/create-site/repositories/repository-[repository]/+page.svelte:
- Around line 52-89: Extract the duplicated DetectedVariable type and the
functions normalizeDetectedVariables and mergeVariables into a single shared
helper module (e.g., helpers/variables.ts), export them, and import them from
both pages to eliminate duplication; keep the exact function signatures and
behavior (using Partial<Models.Variable> and the same key/name/value/secret
handling), ensure to import type { Models } from '@appwrite.io/console' in the
helper, remove the inline definitions from each +page.svelte, and replace them
with imports of DetectedVariable, normalizeDetectedVariables, and
mergeVariables.
🧹 Nitpick comments (1)
src/lib/components/variables/environmentVariables.svelte (1)

186-207: Merge adjacent identical {#if !variable?.secret} blocks.

Two consecutive blocks check the same condition. Combining them reduces template noise and makes it clearer these actions are grouped.

♻️ Proposed merge
-                                                       {`#if` !variable?.secret}
-                                                            <ActionMenu.Item.Button
-                                                                leadingIcon={IconPencil}
-                                                                on:click={(e) => {
-                                                                    toggle(e);
-                                                                    currentVariable = variable;
-                                                                    showUpdate = true;
-                                                                }}>
-                                                                Update
-                                                            </ActionMenu.Item.Button>
-                                                        {/if}
-                                                        {`#if` !variable?.secret}
-                                                            <ActionMenu.Item.Button
-                                                                leadingIcon={IconEyeOff}
-                                                                on:click={(e) => {
-                                                                    toggle(e);
-                                                                    currentVariable = variable;
-                                                                    showSecretModal = true;
-                                                                }}>
-                                                                Secret
-                                                            </ActionMenu.Item.Button>
-                                                        {/if}
+                                                       {`#if` !variable?.secret}
+                                                            <ActionMenu.Item.Button
+                                                                leadingIcon={IconPencil}
+                                                                on:click={(e) => {
+                                                                    toggle(e);
+                                                                    currentVariable = variable;
+                                                                    showUpdate = true;
+                                                                }}>
+                                                                Update
+                                                            </ActionMenu.Item.Button>
+                                                            <ActionMenu.Item.Button
+                                                                leadingIcon={IconEyeOff}
+                                                                on:click={(e) => {
+                                                                    toggle(e);
+                                                                    currentVariable = variable;
+                                                                    showSecretModal = true;
+                                                                }}>
+                                                                Secret
+                                                            </ActionMenu.Item.Button>
+                                                        {/if}

Copy link
Member

Choose a reason for hiding this comment

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

  1. Svelte 5 format.
  2. productLabel should have proper union type, site | function | global.

Copy link
Member

Choose a reason for hiding this comment

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

svelte 5


export let variables: Partial<Models.Variable>[] = [];
export let productLabel = 'site';
export let docsLink =
Copy link
Member

Choose a reason for hiding this comment

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

we should do this links building in the component based on productLabel just once.

<Button
secondary
size="s"
on:mousedown={() => {
Copy link
Member

Choose a reason for hiding this comment

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

does this directive work on components too?? 👀

Comment on lines +103 to +107
columns={[
{ id: 'key', width: { min: 300 } },
{ id: 'value', width: { min: 280 } },
{ id: 'actions', width: 40 }
]}>
Copy link
Member

Choose a reason for hiding this comment

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

used twice, extract to a const.

Comment on lines +4 to +7
key?: string;
name?: string;
value?: string;
secret?: boolean;
Copy link
Member

Choose a reason for hiding this comment

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

how come all are optional? I'd expect key and the name to be there. if not, I don't think it constitutes as a valid env format.

Copy link
Member

Choose a reason for hiding this comment

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

in what cases does this happen?

bind:buildCommand
bind:roles
bind:variables
isVariablesLoading={detectingRuntime} />
Copy link
Member

Choose a reason for hiding this comment

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

naming sounds confusing to me. one variable oriented, another runtime.

import { InputText } from '$lib/elements/forms';
import { Accordion, Fieldset, Layout } from '@appwrite.io/pink-svelte';
import type { Models } from '@appwrite.io/console';
import EnvironmentVariables from '$lib/components/variables/environmentVariables.svelte';
Copy link
Member

Choose a reason for hiding this comment

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

lets just make an index.ts [barrel file] and export all variables/* from there. better management and readability.

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