Skip to content

Implement Global Variables & Secrets Manager - #9

Open
Jacobcdsmith wants to merge 1 commit into
mainfrom
feat/globals-and-secrets-manager-16643472704020951248
Open

Implement Global Variables & Secrets Manager#9
Jacobcdsmith wants to merge 1 commit into
mainfrom
feat/globals-and-secrets-manager-16643472704020951248

Conversation

@Jacobcdsmith

@Jacobcdsmith Jacobcdsmith commented Jul 19, 2026

Copy link
Copy Markdown
Owner

Implemented a fully client-side Environment & State Constants manager for global variables and secrets. Support has been fully integrated into the visual canvas, run execution engine, and live code generators for Python and JavaScript. Also added extensive unit testing.


PR created automatically by Jules for task 16643472704020951248 started by @Jacobcdsmith

Summary by CodeRabbit

  • New Features

    • Added a manager for creating, editing, deleting, and securely viewing global variables and secrets.
    • Added persistent storage for globals and secrets.
    • Added support for using {{global.*}} and {{secret.*}} placeholders in flows.
    • Included globals and secrets in generated Python and JavaScript code.
    • Added validation for key names and duplicate keys.
  • Tests

    • Added coverage for validation, flow substitution, and generated code output.

@google-labs-jules

Copy link
Copy Markdown

👋 Jules, reporting for duty! I'm here to lend a hand with this pull request.

When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down.

I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job!

For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

@vercel

vercel Bot commented Jul 19, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
agent-flow-canvas Ready Ready Preview, Comment Jul 19, 2026 2:56pm

@coderabbitai

coderabbitai Bot commented Jul 19, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

Adds persistent globals and secrets with a management modal, runtime template interpolation, generated Python and JavaScript support, page integration, and tests covering validation, HTTP execution, and code generation.

Changes

Globals and Secrets

Layer / File(s) Summary
Storage and validation contracts
frontend/src/flow/globals.ts, frontend/src/test/globalsAndSecrets.test.ts
Defines persisted global and secret entries, tolerant local storage loading/saving, generated IDs, constructors, and key validation tests.
Globals and secrets manager UI
frontend/src/flow/GlobalsManager.tsx
Adds tabbed editing, key validation, value visibility toggles, item creation, deletion, previews, and modal controls.
Runtime interpolation and page wiring
frontend/src/flow/runFlow.ts, frontend/src/pages/Index.tsx, frontend/src/test/globalsAndSecrets.test.ts
Persists configured values, exposes the manager, passes globals and secrets to flow execution, and interpolates them in node fields and HTTP requests.
Generated Python and JavaScript support
frontend/src/flow/codegen.ts, frontend/src/test/globalsAndSecrets.test.ts
Generates global mappings and environment-backed secret mappings, interpolates placeholders across supported nodes, and tests both output languages.

Estimated code review effort: 4 (Complex) | ~60 minutes

Possibly related PRs

Suggested reviewers: emergent-agent-e1

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly matches the main change: adding a globals and secrets manager.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/globals-and-secrets-manager-16643472704020951248

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.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 73bfe2184e

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +587 to +588
globals,
secrets,

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Include variables in run callback dependencies

When a user edits only globals/secrets in the new manager and then clicks Run, this memoized callback is not recreated because the dependency array still omits globals and secrets, so these fields keep the previous values (often empty) even though the UI/code preview updated. Flows using {{global.*}} or {{secret.*}} therefore execute with stale or blank substitutions until some unrelated dependency changes.

Useful? React with 👍 / 👎.

lines.push(`import os`);
lines.push(`SECRETS = {`);
secrets.forEach((s) => {
lines.push(` ${pyStr(s.key)}: os.environ.get(${pyStr(s.key)}, ${pyStr(s.value)}),`);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Keep secret values out of generated code

When a user has a real secret configured and opens or copies the generated Python, this writes the secret value into the source as the environment-variable fallback. That makes the secrets manager silently leak credentials into shared snippets or committed generated files; the generated runtime should reference the environment variable without embedding the browser-stored secret value.

Useful? React with 👍 / 👎.

@coderabbitai coderabbitai Bot 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.

Actionable comments posted: 3

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
frontend/src/flow/runFlow.ts (1)

266-273: 🔒 Security & Privacy | 🟡 Minor | ⚡ Quick win

Interpolated secret leaks into run logs. The tool node returns args after interpolation, so any {{secret.*}} value becomes part of state.last_output and is captured in stateSnapshot, which is rendered verbatim in the run-log panel (Index.tsx). That defeats the masking applied everywhere else for secrets.

Consider redacting known secret values from node output/snapshots before logging (e.g. replace secret values with •••• in the emitted args/snapshot).

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@frontend/src/flow/runFlow.ts` around lines 266 - 273, Redact secret values
from the interpolated args returned by the “tool” case in runFlow before they
enter state.last_output or stateSnapshot. Reuse the existing secret values from
opts.secrets, replacing each known value with the established masked placeholder
while preserving non-secret interpolation and the simulated tool response.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@frontend/src/flow/codegen.ts`:
- Around line 123-127: Remove plaintext secret values from both generated-code
paths: in frontend/src/flow/codegen.ts lines 123-127, update the Python
os.environ.get generation; in frontend/src/flow/codegen.ts lines 482-486, update
the JavaScript process.env fallback. Use an empty or omitted default so
generated flow.py and flow.js rely only on environment-provided secrets, then
update the corresponding assertions in globalsAndSecrets.test.ts.
- Around line 622-624: Update the generated http node assignments for url,
headersStr, and bodyStr to embed their config values using JSON.stringify,
matching the llm, tool, subagent, and human node generation paths. Preserve the
existing fallback to empty strings while ensuring backticks and interpolation
sequences remain literal in generated JavaScript.

In `@frontend/src/pages/Index.tsx`:
- Around line 587-588: Update the dependency array of the runFlowAction
useCallback to include globals and secrets, ensuring the callback uses the
latest manager edits while preserving its existing dependencies.

---

Outside diff comments:
In `@frontend/src/flow/runFlow.ts`:
- Around line 266-273: Redact secret values from the interpolated args returned
by the “tool” case in runFlow before they enter state.last_output or
stateSnapshot. Reuse the existing secret values from opts.secrets, replacing
each known value with the established masked placeholder while preserving
non-secret interpolation and the simulated tool response.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: e24d5102-611a-4b28-b56b-899e968dcb9f

📥 Commits

Reviewing files that changed from the base of the PR and between 936640f and 73bfe21.

⛔ Files ignored due to path filters (1)
  • start_output.log is excluded by !**/*.log
📒 Files selected for processing (6)
  • frontend/src/flow/GlobalsManager.tsx
  • frontend/src/flow/codegen.ts
  • frontend/src/flow/globals.ts
  • frontend/src/flow/runFlow.ts
  • frontend/src/pages/Index.tsx
  • frontend/src/test/globalsAndSecrets.test.ts

Comment on lines +123 to +127
lines.push(`SECRETS = {`);
secrets.forEach((s) => {
lines.push(` ${pyStr(s.key)}: os.environ.get(${pyStr(s.key)}, ${pyStr(s.value)}),`);
});
lines.push(`}`);

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.

🔒 Security & Privacy | 🟡 Minor | ⚡ Quick win

Secrets embedded as plaintext fallbacks in generated code. Both generators inline the actual secret value as the env fallback default, so a copied/downloaded flow.py/flow.js carries secrets in cleartext — contradicting the module's "Sensitive keys/values never leave the browser" contract in globals.ts. Consider emitting an empty/placeholder default (e.g. rely on env only) and update the corresponding assertions in globalsAndSecrets.test.ts.

  • frontend/src/flow/codegen.ts#L123-L127: drop the pyStr(s.value) plaintext default from os.environ.get(...) (e.g. use "" or omit the default).
  • frontend/src/flow/codegen.ts#L482-L486: drop the JSON.stringify(s.value) plaintext fallback from process.env.<key> ?? ....
📍 Affects 1 file
  • frontend/src/flow/codegen.ts#L123-L127 (this comment)
  • frontend/src/flow/codegen.ts#L482-L486
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@frontend/src/flow/codegen.ts` around lines 123 - 127, Remove plaintext secret
values from both generated-code paths: in frontend/src/flow/codegen.ts lines
123-127, update the Python os.environ.get generation; in
frontend/src/flow/codegen.ts lines 482-486, update the JavaScript process.env
fallback. Use an empty or omitted default so generated flow.py and flow.js rely
only on environment-provided secrets, then update the corresponding assertions
in globalsAndSecrets.test.ts.

Comment on lines +622 to +624
`let url = \`${c.url || ""}\`;`,
`let headersStr = \`${headersJson}\`;`,
`let bodyStr = \`${c.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.

🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

Unsafe/inconsistent template embedding in generated JS http node. url, headersStr, and bodyStr are emitted as backtick template literals with the raw config inlined. Every other JS node (llm, tool, subagent, human) uses JSON.stringify(...). A backtick or ${...} in the URL/headers/body will break the generated file or be evaluated at generated-code parse time (injection).

🐛 Use JSON.stringify for consistency and safety
-          `let url = \`${c.url || ""}\`;`,
-          `let headersStr = \`${headersJson}\`;`,
-          `let bodyStr = \`${c.body || ""}\`;`,
+          `let url = ${JSON.stringify(c.url || "")};`,
+          `let headersStr = ${JSON.stringify(headersJson)};`,
+          `let bodyStr = ${JSON.stringify(c.body || "")};`,
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
`let url = \`${c.url || ""}\`;`,
`let headersStr = \`${headersJson}\`;`,
`let bodyStr = \`${c.body || ""}\`;`,
`let url = ${JSON.stringify(c.url || "")};`,
`let headersStr = ${JSON.stringify(headersJson)};`,
`let bodyStr = ${JSON.stringify(c.body || "")};`,
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@frontend/src/flow/codegen.ts` around lines 622 - 624, Update the generated
http node assignments for url, headersStr, and bodyStr to embed their config
values using JSON.stringify, matching the llm, tool, subagent, and human node
generation paths. Preserve the existing fallback to empty strings while ensuring
backticks and interpolation sequences remain literal in generated JavaScript.

Comment on lines +587 to +588
globals,
secrets,

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.

🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

Stale closure: add globals/secrets to runFlowAction deps. These new references are read inside the useCallback, but its dependency array (Line 637) omits globals and secrets. The memoized callback will keep capturing the values from the render when it was last recreated, so edits made in the manager won't be reflected on the next run.

🐛 Add the missing dependencies (Line 637)
  }, [nodes, edges, gateways, gatewayInvalid, gatewayIssues, visualSpeed, initialStateStr, pendingApproval, globals, secrets]);
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@frontend/src/pages/Index.tsx` around lines 587 - 588, Update the dependency
array of the runFlowAction useCallback to include globals and secrets, ensuring
the callback uses the latest manager edits while preserving its existing
dependencies.

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.

1 participant