project-chat inheritance toggle

Alessandro committed Feb 16, 2026 at 14:42 UTC e6d716d7b519fcf7577a6956583728784adf490a
3 files changed +25 -9
python/api/chat_create.py
+8 -9
@@ -1,7 +1,7 @@
1 from python.helpers.api import ApiHandler, Input, Output, Request, Response
2
3
4 -from python.helpers import projects, guids
4 +from python.helpers import settings, projects, guids
5 from agent import AgentContext
6
7
@@ -17,14 +17,13 @@ class CreateChat(ApiHandler):
17 new_context = self.use_context(new_ctxid)
18
19 # copy selected data from current to new context
20 - # do not create new chats in the same project anymore, it can be annoying
21 - # if current_context:
22 - # current_data_1 = current_context.get_data(projects.CONTEXT_DATA_KEY_PROJECT)
23 - # if current_data_1:
24 - # new_context.set_data(projects.CONTEXT_DATA_KEY_PROJECT, current_data_1)
25 - # current_data_2 = current_context.get_output_data(projects.CONTEXT_DATA_KEY_PROJECT)
26 - # if current_data_2:
27 - # new_context.set_output_data(projects.CONTEXT_DATA_KEY_PROJECT, current_data_2)
20 + if current_context and settings.get_settings().get("chat_inherit_project", True):
21 + current_data_1 = current_context.get_data(projects.CONTEXT_DATA_KEY_PROJECT)
22 + if current_data_1:
23 + new_context.set_data(projects.CONTEXT_DATA_KEY_PROJECT, current_data_1)
24 + current_data_2 = current_context.get_output_data(projects.CONTEXT_DATA_KEY_PROJECT)
25 + if current_data_2:
26 + new_context.set_output_data(projects.CONTEXT_DATA_KEY_PROJECT, current_data_2)
27
28 # New context should appear in other tabs' chat lists via state_push.
29 from python.helpers.state_monitor_integration import mark_dirty_all
python/helpers/settings.py
+2
@@ -157,6 +157,7 @@ class Settings(TypedDict):
157 litellm_global_kwargs: dict[str, Any]
158
159 update_check_enabled: bool
160 + chat_inherit_project: bool
161
162
163 class PartialSettings(Settings, total=False):
@@ -599,6 +600,7 @@ def get_default_settings() -> Settings:
600 secrets="",
601 litellm_global_kwargs=get_default_value("litellm_global_kwargs", {}),
602 update_check_enabled=get_default_value("update_check_enabled", True),
603 + chat_inherit_project=get_default_value("chat_inherit_project", True),
604 )
605
606
webui/components/settings/agent/agent.html
+15
@@ -43,6 +43,21 @@
43 </select>
44 </div>
45 </div>
46 +
47 + <div class="field">
48 + <div class="field-label">
49 + <div class="field-title">Inherit active project</div>
50 + <div class="field-description">
51 + When creating a new chat, automatically inherit the active project from the current chat.
52 + </div>
53 + </div>
54 + <div class="field-control">
55 + <label class="toggle">
56 + <input type="checkbox" x-model="$store.settings.settings.chat_inherit_project">
57 + <span class="toggler"> </span>
58 + </label>
59 + </div>
60 + </div>
61 </div>
62 </template>
63 </div>