feat: pass chat_profile to set_starter_categories callback#2849
Draft
EyalAmitay wants to merge 2 commits intoChainlit:mainfrom
Draft
feat: pass chat_profile to set_starter_categories callback#2849EyalAmitay wants to merge 2 commits intoChainlit:mainfrom
EyalAmitay wants to merge 2 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.
Contributor
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( |
Contributor
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 through@cl.set_starter_categorieswith a 3-arg function, switch chat profiles in the UI, verify different categories are returned per profileSummary by cubic
Forward
chat_profilefrom/project/settingsto theset_starter_categoriescallback to enable profile-specific starter categories. The change is fully backward compatible.New Features
chat_profileas a third arg toset_starter_categories.@overloadand updatesCodeSettingstyping to accept(user, language, chat_profile).(user)and(user, language)callbacks viawrap_user_functionintrospection.Refactors
server.pyto satisfyruff.Written for commit 88e726c. Summary will update on new commits.