Skip to content

Comments

feat (#1858), Implement settings change listener. #2801

Open
FosanzDev wants to merge 1 commit intoChainlit:mainfrom
FosanzDev:main
Open

feat (#1858), Implement settings change listener. #2801
FosanzDev wants to merge 1 commit intoChainlit:mainfrom
FosanzDev:main

Conversation

@FosanzDev
Copy link

@FosanzDev FosanzDev commented Feb 22, 2026

WHAT DOES THIS DO?

It basically adds a new listener for when the settings change in the frontend, not just when they're updated. This way you can resend a new set of settings to the frontend to render.

EDIT: Changed naming from on_chat_settings_edit > on_settings_edit for the sake of readability on a forced push.

Code example:

@cl.on_settings_edit
async def on_settings_edit(settings):
    provider = settings.get("Provider")
    if provider == "OpenAI":
        models = ["gpt-3.5-turbo", "gpt-4"]
    elif provider == "Anthropic":
        models = ["claude-2", "claude-instant-1"]
    
    # Update the settings widgets dynamically
    await cl.ChatSettings([
        cl.input_widget.Select(id="Provider", label="Provider", values=["OpenAI", "Anthropic"], initial_value=provider),
        cl.input_widget.Select(id="Model", label="Model", values=models)
    ]).send()

POC (in my case, multi-language bible version selection for a personal project)

Screencast.from.2026-02-22.17-04-22.webm

Note: There might be some changes in the code linting bc of my IDE settings


Summary by cubic

Adds a live chat settings edit listener so the app can react to on-the-fly changes and push updated widgets back to the UI. Implements the settings change listener requested in Linear #1858.

  • New Features
    • Backend: new @cl.on_settings_edit decorator; added to CodeSettings; wired via a "chat_settings_edit" socket event (runs in WS context).
    • Frontend: ChatSettings emits "chat_settings_edit" on form changes with a lodash isEqual guard; react-client exposes editChatSettings.
    • Non-breaking: existing on_settings_update remains unchanged.

Written for commit 912ed3d. Summary will update on new commits.

@dosubot dosubot bot added the size:M This PR changes 30-99 lines, ignoring generated files. label Feb 22, 2026
@dosubot
Copy link

dosubot bot commented Feb 22, 2026

Related Documentation

Checked 0 published document(s) in 1 knowledge base(s). No updates required.

How did I do? Any feedback?  Join Discord

@dosubot dosubot bot added the frontend Pertains to the frontend. label Feb 22, 2026
Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

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

2 issues found across 6 files

Prompt for AI agents (all issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="backend/chainlit/__init__.py">

<violation number="1" location="backend/chainlit/__init__.py:86">
P2: New callback is imported but missing from __all__, so it won’t be exposed in the package’s public API list or wildcard imports like other callbacks.</violation>
</file>

<file name="libs/react-client/src/useChatInteract.ts">

<violation number="1" location="libs/react-client/src/useChatInteract.ts:135">
P2: editChatSettings is defined but never returned from useChatInteract, so consumers cannot invoke the new chat_settings_edit socket event.</violation>
</file>

Since this is your first cubic review, here's how it works:

  • cubic automatically reviews your code and comments on bugs and improvements
  • Teach cubic by replying to its comments. cubic learns from your replies and gets better over time
  • Add one-off context when rerunning by tagging @cubic-dev-ai with guidance or docs links (including llms.txt)
  • Ask questions if you need clarification on any suggestion

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.

This way you can read what changed and return a new set of settings dinamically.
@dokterbob
Copy link
Collaborator

Re-running failed E2E tests. If they keep failing, means there's a problem!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

frontend Pertains to the frontend. size:M This PR changes 30-99 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants