Skip to content

feat: pass chat_profile to set_starter_categories callback#2849

Open
EyalAmitay wants to merge 6 commits intoChainlit:mainfrom
EyalAmitay:feat/pass-chat-profile-to-set-starter-categories
Open

feat: pass chat_profile to set_starter_categories callback#2849
EyalAmitay wants to merge 6 commits intoChainlit:mainfrom
EyalAmitay:feat/pass-chat-profile-to-set-starter-categories

Conversation

@EyalAmitay
Copy link
Copy Markdown
Contributor

@EyalAmitay EyalAmitay commented Mar 19, 2026

Summary

  • Forward the chat_profile query parameter to the set_starter_categories callback in the /project/settings endpoint, enabling profile-specific starter categories
  • Add a third @overload signature and update the CodeSettings type annotation to accept the new parameter
  • Fully 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

Test plan

  • Existing test_set_starter_categories (2-arg) passes — confirms backwards compatibility
  • New test_set_starter_categories_with_chat_profile (3-arg) passes — confirms profile value flows through
  • New test_project_settings_forwards_chat_profile_to_starter_categories — endpoint integration test verifying /project/settings forwards chat_profile to the callback and returns profile-specific categories in the response
  • Manual: configure @cl.set_starter_categories with a 3-arg function, switch chat profiles in the UI, verify different categories are returned per profile
Screen.Recording.2026-04-03.at.2.44.33.PM.mov

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.
@dosubot dosubot bot added size:M This PR changes 30-99 lines, ignoring generated files. backend Pertains to the Python backend. enhancement New feature or request unit-tests Has unit tests. labels Mar 19, 2026
@EyalAmitay EyalAmitay marked this pull request as draft March 19, 2026 14:20
Copy link
Copy Markdown
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.

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(
Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai bot Mar 19, 2026

Choose a reason for hiding this comment

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

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>
Fix with Cubic

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.

Please address this comment, then we should be good to merge.

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.

Thanks—I'll make sure that comment is addressed.

Copy link
Copy Markdown
Contributor Author

@EyalAmitay EyalAmitay Apr 3, 2026

Choose a reason for hiding this comment

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

@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.
@EyalAmitay EyalAmitay marked this pull request as ready for review April 3, 2026 11:26
@dosubot dosubot bot added size:L This PR changes 100-499 lines, ignoring generated files. and removed size:M This PR changes 30-99 lines, ignoring generated files. labels Apr 3, 2026
Copy link
Copy Markdown
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.

No issues found across 5 files

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

Labels

backend Pertains to the Python backend. enhancement New feature or request size:L This PR changes 100-499 lines, ignoring generated files. unit-tests Has unit tests.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants