Skip to content

Ability control access to LLM Config menu - #172

Merged
iFurySt merged 2 commits into
AmoyLab:mainfrom
boston008:llm_config_access_option
Jun 30, 2025
Merged

iFurySt merged 2 commits into
AmoyLab:mainfrom
boston008:llm_config_access_option

Conversation

@boston008

@boston008 boston008 commented Jun 28, 2025 •

Copy link
Copy Markdown
Contributor

Ability control access to LLM Config using env variable LLM_CONFIG_ADMIN_ONLY backward compatibility , default value is N everyone has access Display version next to UNLA

Display application version on ui page on top righ next to Unla

Summary by Sourcery

Add environment-based access control for the LLM Config menu and display the application version in the UI layout.

New Features:

  • Introduce LLM_CONFIG_ADMIN_ONLY env var to restrict LLM Config menu visibility to admins when set to 'Y'.
  • Show the current application version next to the Unla logo in the top-right of the layout.

Enhancements:

  • Include LLM_CONFIG_ADMIN_ONLY and version in the runtime config payload served to the frontend.
  • Ensure LLM_CONFIG_ADMIN_ONLY defaults to 'N' on the client side if absent in the runtime config.

Chores:

  • Export the embedded VERSION constant in pkg/version and update the runtime handler to use it.
  • Rename the version variable in version.go to an exported Version.
  • Update .env.example to document the LLM_CONFIG_ADMIN_ONLY variable.

Ability control access to LLM Config using  env variable LLM_CONFIG_ADMIN_ONLY
backward compatibility ,  default value is N  everyone has access
Display version next to UNLA
@sourcery-ai

sourcery-ai Bot commented Jun 28, 2025 •

Copy link
Copy Markdown
Contributor

Reviewer's Guide

This PR implements environment-driven access control for the LLM Config menu and displays the application version next to the Unla logo by propagating runtime settings from the backend to the frontend.

Class diagram for updated runtime config handling

classDiagram
    class RuntimeConfigHandler {
        +HandleRuntimeConfig(c *gin.Context)
    }
    class version {
        +Version string
        +Get() string
    }
    RuntimeConfigHandler --> version : uses Version
Loading

Class diagram for Layout component LLM Config access control

classDiagram
    class Layout {
        +userInfo
        +llmConfigAdminOnly
        +canShowLLM
        +menuGroups
    }
    Layout : +fetchUserInfo()
    Layout : +render()
Loading

File-Level Changes

Change Details Files
LLM Config menu visibility controlled by environment variable
  • Read LLM_CONFIG_ADMIN_ONLY from RUNTIME_CONFIG
  • Determine canShowLLM flag based on variable and user role
  • Conditionally include or omit LLM menu entry
web/src/components/Layout.tsx
Application version displayed in UI header
  • Add version label next to Unla logo
  • Fallback to 'dev' if version is undefined
web/src/components/Layout.tsx
Runtime config endpoint now sources version and admin flag
  • Use pkg/version.Version instead of env var for version
  • Include LLM_CONFIG_ADMIN_ONLY in JSON response
internal/apiserver/handler/runtime_config.go
Version package exports embedded VERSION value
  • Rename internal version variable to public Version
  • Ensure Get() returns updated Version
pkg/version/version.go
Client initialization ensures default admin flag
  • Set default LLM_CONFIG_ADMIN_ONLY to 'N' when missing
  • Merge flag into fetched runtimeConfig object
web/src/main.tsx

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@sourcery-ai sourcery-ai 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.

Hey @boston008 - I've reviewed your changes and they look great!

Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments

### Comment 1
<location> `web/src/main.tsx:111` </location>
<code_context>
         ...(response.data.features || {})
-      }
+      },
+      // Ensure LLM_CONFIG_ADMIN_ONLY is set to 'N' if not present
+      LLM_CONFIG_ADMIN_ONLY: typeof response.data.LLM_CONFIG_ADMIN_ONLY === 'undefined' ? 'N' : response.data.LLM_CONFIG_ADMIN_ONLY
     };
   } catch (error) {
</code_context>

<issue_to_address>
Check for null as well as undefined for LLM_CONFIG_ADMIN_ONLY.

The current check misses cases where LLM_CONFIG_ADMIN_ONLY is null. Use a check like response.data.LLM_CONFIG_ADMIN_ONLY == null to handle both undefined and null values.
</issue_to_address>

<suggested_fix>
<<<<<<< SEARCH
      // Ensure LLM_CONFIG_ADMIN_ONLY is set to 'N' if not present
      LLM_CONFIG_ADMIN_ONLY: typeof response.data.LLM_CONFIG_ADMIN_ONLY === 'undefined' ? 'N' : response.data.LLM_CONFIG_ADMIN_ONLY
=======
      // Ensure LLM_CONFIG_ADMIN_ONLY is set to 'N' if not present (handles undefined and null)
      LLM_CONFIG_ADMIN_ONLY: response.data.LLM_CONFIG_ADMIN_ONLY == null ? 'N' : response.data.LLM_CONFIG_ADMIN_ONLY
>>>>>>> REPLACE

</suggested_fix>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Comment thread web/src/main.tsx
Comment on lines +111 to +112
// Ensure LLM_CONFIG_ADMIN_ONLY is set to 'N' if not present
LLM_CONFIG_ADMIN_ONLY: typeof response.data.LLM_CONFIG_ADMIN_ONLY === 'undefined' ? 'N' : response.data.LLM_CONFIG_ADMIN_ONLY

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.

suggestion (bug_risk): Check for null as well as undefined for LLM_CONFIG_ADMIN_ONLY.

The current check misses cases where LLM_CONFIG_ADMIN_ONLY is null. Use a check like response.data.LLM_CONFIG_ADMIN_ONLY == null to handle both undefined and null values.

Suggested change
// Ensure LLM_CONFIG_ADMIN_ONLY is set to 'N' if not present
LLM_CONFIG_ADMIN_ONLY: typeof response.data.LLM_CONFIG_ADMIN_ONLY === 'undefined' ? 'N' : response.data.LLM_CONFIG_ADMIN_ONLY
// Ensure LLM_CONFIG_ADMIN_ONLY is set to 'N' if not present (handles undefined and null)
LLM_CONFIG_ADMIN_ONLY: response.data.LLM_CONFIG_ADMIN_ONLY == null ? 'N' : response.data.LLM_CONFIG_ADMIN_ONLY

@boston008

Copy link
Copy Markdown
Contributor Author

#173

Add access logic to settings icon in Chat page

@iFurySt iFurySt left a comment

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.

LGTM! Thanks!

@iFurySt
iFurySt merged commit 3cc94de into AmoyLab:main Jun 30, 2025
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.

2 participants