Skip to content

feat: pass chat_profile to set_starter_categories callback#2849

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

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

Conversation

@EyalAmitay
Copy link
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
  • Manual: configure @cl.set_starter_categories with a 3-arg function, switch chat profiles in the UI, verify different categories are returned per profile

Summary by cubic

Forward chat_profile from /project/settings to the set_starter_categories callback to enable profile-specific starter categories. The change is fully backward compatible.

  • New Features

    • Passes chat_profile as a third arg to set_starter_categories.
    • Adds a third @overload and updates CodeSettings typing to accept (user, language, chat_profile).
    • Maintains compatibility with existing (user) and (user, language) callbacks via wrap_user_function introspection.
  • Refactors

    • Formats a long line in server.py to satisfy ruff.

Written for commit 88e726c. Summary will update on new commits.

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
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
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

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:M This PR changes 30-99 lines, ignoring generated files. unit-tests Has unit tests.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant