feat: pass chat_profile to set_starter_categories callback#2849
feat: pass chat_profile to set_starter_categories callback#2849EyalAmitay wants to merge 6 commits intoChainlit:mainfrom
Conversation
The /project/settings endpoint already receives chat_profile as a query parameter but did not forward it to the set_starter_categories callback. This makes it impossible for consumers to return profile-specific starter categories. - Forward chat_profile as third argument in server.py - Update CodeSettings type annotation in config.py - Add third @overload signature in callbacks.py - Add test for the new 3-arg variant Backwards compatible: wrap_user_function introspects the decorated function's signature and only passes arguments it accepts, so existing (user) and (user, language) callbacks continue to work.
There was a problem hiding this comment.
1 issue found across 4 files
Prompt for AI agents (unresolved 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/tests/test_callbacks.py">
<violation number="1" location="backend/tests/test_callbacks.py:591">
P2: The new test validates direct callback invocation, but it does not verify that `/project/settings` actually reads and forwards `chat_profile` to `set_starter_categories`.</violation>
</file>
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
|
|
||
| assert test_config.code.set_starter_categories is not None | ||
|
|
||
| result = await test_config.code.set_starter_categories( |
There was a problem hiding this comment.
P2: The new test validates direct callback invocation, but it does not verify that /project/settings actually reads and forwards chat_profile to set_starter_categories.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At backend/tests/test_callbacks.py, line 591:
<comment>The new test validates direct callback invocation, but it does not verify that `/project/settings` actually reads and forwards `chat_profile` to `set_starter_categories`.</comment>
<file context>
@@ -563,6 +563,46 @@ async def get_starter_categories(user, language):
+
+ assert test_config.code.set_starter_categories is not None
+
+ result = await test_config.code.set_starter_categories(
+ None, "en", "test-profile"
+ )
</file context>
There was a problem hiding this comment.
Please address this comment, then we should be good to merge.
There was a problem hiding this comment.
Thanks—I'll make sure that comment is addressed.
There was a problem hiding this comment.
@hayescode Added an integration test in test_server.py that hits GET /project/settings?chat_profile=creative and asserts the response contains the profile-specific starter categories. Also verifies the default (no profile) case.
Verify that /project/settings forwards the chat_profile query parameter to set_starter_categories and returns profile-specific categories in the response. Addresses PR review feedback.
Summary
chat_profilequery parameter to theset_starter_categoriescallback in the/project/settingsendpoint, enabling profile-specific starter categories@overloadsignature and update theCodeSettingstype annotation to accept the new parameterwrap_user_functionintrospects the decorated function's signature and only passes arguments it accepts, so existing(user)and(user, language)callbacks continue to workTest plan
test_set_starter_categories(2-arg) passes — confirms backwards compatibilitytest_set_starter_categories_with_chat_profile(3-arg) passes — confirms profile value flows throughtest_project_settings_forwards_chat_profile_to_starter_categories— endpoint integration test verifying/project/settingsforwardschat_profileto the callback and returns profile-specific categories in the response@cl.set_starter_categorieswith a 3-arg function, switch chat profiles in the UI, verify different categories are returned per profileScreen.Recording.2026-04-03.at.2.44.33.PM.mov