langflow icon indicating copy to clipboard operation
langflow copied to clipboard

feat: Add embedded mode configuration flags

Open vjgit96 opened this issue 6 months ago • 4 comments

Summary

Implements core plumbing for LE-906 P2 fixes by adding 7 new configuration flags and exposing them through the config API.

Changes

  • Add 7 new settings: custom_component_admin_only, embedded_mode, hide_logout_button, hide_new_project_button, hide_new_flow_button, hide_starter_projects, mcp_servers_locked (all default: false)
  • All settings configurable via LANGFLOW_* environment variables
  • Expose all flags through ConfigResponse schema
  • Fix hide_getting_started_progress to read from settings (not env)
  • Add frontend type definitions for new flags
  • Implement store initialization and hydration logic

Type

Configuration/Infrastructure

Related

Part 1 of 4 in LE-906 P2 Fixes split

Summary by CodeRabbit

  • New Features

    • Added embedded mode configuration with controls to hide UI elements (logout, new project/flow buttons, starter projects)
    • Added restriction to limit custom component editing to administrators only
    • Added MCP server configuration locking to prevent user modifications
  • Tests

    • Added test validating embedded mode configuration behavior

Review Change Stack

vjgit96 avatar May 12 '26 20:05 vjgit96

[!IMPORTANT]

Review skipped

Auto incremental reviews are disabled on this repository.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: febf505c-82f7-4d13-87f2-e4a13d69e00c

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • [ ] 🔍 Trigger review

Walkthrough

This PR implements an embedded-mode configuration system that controls UI visibility and administrative restrictions across the Langflow application. It extends the settings model with seven new boolean flags, serializes them through the API schema with cascading logic, and integrates them into the frontend Zustand store via the config hook.

Changes

Embedded Mode Configuration System

Layer / File(s) Summary
Settings model extension
src/lfx/src/lfx/services/settings/base.py
Settings gains custom_component_admin_only, embedded_mode, hide_getting_started_progress, hide_logout_button, hide_new_project_button, hide_new_flow_button, hide_starter_projects, and mcp_servers_locked boolean fields with default false values.
API response schema and serialization
src/backend/base/langflow/api/v1/schemas/__init__.py
ConfigResponse exposes the new embedded mode and UI control fields. The from_settings method removes env-var based logic and derives hide-* values from settings, forcing them true when embedded_mode is enabled.
Embedded mode cascading test
src/backend/tests/unit/api/v1/test_endpoints.py
Unit test test_get_config_embedded_mode_cascades_hide_flags verifies that when embedded_mode=True, the /api/v1/config endpoint returns all relevant hide_* flags as true in the authenticated response.
Frontend store type definition
src/frontend/src/types/zustand/utility/index.ts
UtilityStoreType interface extended with embedded mode and UI control boolean fields, each paired with a setter function.
Zustand store implementation
src/frontend/src/stores/utilityStore.ts
useUtilityStore initializes new embedded mode and UI control state properties with default false values and corresponding setter functions.
Config hook and store integration
src/frontend/src/controllers/API/queries/config/use-get-config.ts
useGetConfig hook extends ConfigResponse interface with new fields, reads Zustand setters, and populates store from authenticated /config response with false defaults for missing fields.

🎯 2 (Simple) | ⏱️ ~12 minutes


[!IMPORTANT]

Pre-merge checks failed

Please resolve all errors before merging. Addressing warnings is optional.

❌ Failed checks (1 error, 2 warnings)

Check name Status Explanation Resolution
Test Coverage For New Implementations ❌ Error Only one test added for eight new configuration fields. Test flaw: hide_getting_started_progress pre-set to True skips cascade testing. Missing Settings, env var, and frontend tests. Add unit tests for Settings, environment variables, cascade logic, and frontend store. Set hide_getting_started_progress to False in existing test to properly verify cascade.
Test Quality And Coverage ⚠️ Warning Test cascade assertion is not exercised—it sets hide_getting_started_progress=True upfront (line 306), so assertion passes without cascade logic. Frontend tests missing for 7 new store/hook fields. Set hide_getting_started_progress=False at line 306 to exercise cascade. Add frontend tests for useUtilityStore/useGetConfig. Add tests for mcp_servers_locked and custom_component_admin_only fields.
Test File Naming And Structure ⚠️ Warning Backend test naming is correct but cascade test is ineffective: setting hide_getting_started_progress=TRUE makes assertions pass regardless of cascade implementation. Frontend store tests missing. Set hide_getting_started_progress=False in backend test to verify cascade. Add frontend tests for new useUtilityStore fields in utilityStore.test.ts.
✅ Passed checks (6 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main change: adding embedded mode and related configuration flags across backend, API, and frontend layers.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
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.
Excessive Mock Usage Warning ✅ Passed Test uses 6 monkeypatch calls to test settings-dependent behavior—appropriate for mocking injected dependencies, not excessive, and consistent with other config tests.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • [ ] Create PR with unit tests
  • [ ] Commit unit tests in branch feature/le-906-pr1-config-settings

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.

coderabbitai[bot] avatar May 12 '26 20:05 coderabbitai[bot]

Codecov Report

:x: Patch coverage is 71.76471% with 24 lines in your changes missing coverage. Please review. :white_check_mark: Project coverage is 57.74%. Comparing base (2e41b7f) to head (3e62d8f). :warning: Report is 1 commits behind head on release-1.10.0.

Files with missing lines Patch % Lines
src/frontend/src/types/zustand/utility/index.ts 0.00% 15 Missing :warning:
...c/controllers/API/queries/config/use-get-config.ts 73.52% 9 Missing :warning:

:x: Your project check has failed because the head coverage (52.86%) is below the target coverage (60.00%). You can increase the head coverage or adjust the target coverage.

Additional details and impacted files

Impacted file tree graph

@@                Coverage Diff                 @@
##           release-1.10.0   #13095      +/-   ##
==================================================
+ Coverage           57.58%   57.74%   +0.16%     
==================================================
  Files                2264     2264              
  Lines              216006   216093      +87     
  Branches            30550    32333    +1783     
==================================================
+ Hits               124395   124792     +397     
+ Misses              90196    89886     -310     
  Partials             1415     1415              
Flag Coverage Δ
backend 64.71% <ø> (+0.02%) :arrow_up:
frontend 57.18% <64.70%> (+0.23%) :arrow_up:
lfx 52.86% <100.00%> (+0.02%) :arrow_up:

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
src/frontend/src/stores/utilityStore.ts 100.00% <100.00%> (ø)
src/lfx/src/lfx/services/settings/base.py 77.09% <100.00%> (+0.70%) :arrow_up:
...c/controllers/API/queries/config/use-get-config.ts 70.55% <73.52%> (+4.11%) :arrow_up:
src/frontend/src/types/zustand/utility/index.ts 0.00% <0.00%> (ø)

... and 61 files with indirect coverage changes

:rocket: New features to boost your workflow:
  • :snowflake: Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • :package: JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

codecov[bot] avatar May 12 '26 20:05 codecov[bot]

Frontend Unit Test Coverage Report

Coverage Summary

Lines Statements Branches Functions
Coverage: 42%
42% (55450/132006) 69.22% (7539/10890) 40.75% (1249/3065)

Unit Test Results

Tests Skipped Failures Errors Time
4848 0 :zzz: 0 :x: 0 :fire: 11m 46s :stopwatch:

github-actions[bot] avatar May 12 '26 20:05 github-actions[bot]

⚠️ Test Coverage Advisor — tests appear to be missing

This PR changes source code but does not add or modify any test files. This is an advisory check: it will not block this PR or any other job — please add tests if the change is testable.

Frontend (TS/TSX) — no *.test.* / *.spec.* / tests/ change found

src/frontend/src/controllers/API/queries/config/use-get-config.ts
src/frontend/src/stores/utilityStore.ts
src/frontend/src/types/zustand/utility/index.ts

Advisory check only — it always passes and is never a required status.

github-actions[bot] avatar May 27 '26 18:05 github-actions[bot]