This commit is contained in:
Timothy Jaeryang Baek committed 2026-07-12 01:08:52 -05:00
1 parent 72e9b35cb4
commit fc07e9bcad
3 files changed
+43 -15

No files matched your search

+2
View File
@@ -218,6 +218,8 @@ class Chat(Base):
.where(
Chat.user_id == user_id,
workspace.in_(paths),
Chat.meta["internal"].as_boolean().is_not(True),
Chat.meta["subagent"].as_boolean().is_not(True),
Chat.updated_at > func.coalesce(Chat.last_read_at, 0),
)
.group_by(workspace)
+41 -14
View File
@@ -202,6 +202,7 @@ async def _inject_completion(record: dict[str, Any]) -> None:
from cptr.utils.chat_task import get_pending_input_lock, start_task
assistant_msg = None
direct_timer_completion = False
async with get_pending_input_lock(parent_chat_id):
all_msgs = await ChatMessage.get_all_by_chat(parent_chat_id)
active = any(m.role == "assistant" and not m.done for m in all_msgs)
@@ -216,29 +217,55 @@ async def _inject_completion(record: dict[str, Any]) -> None:
if active:
meta["async_subagent_pending"] = True
user_msg = await ChatMessage.create(
chat_id=parent_chat_id,
role="user",
content=content,
parent_id=parent_id,
model=model_id,
meta=meta,
created_at=now_ms(),
)
if not active:
if record.get("timer_chat_id") and not active:
direct_timer_completion = True
meta["timer_completion"] = True
assistant_msg = await ChatMessage.create(
chat_id=parent_chat_id,
role="assistant",
content="",
parent_id=user_msg.id,
content=record.get("summary") or "Timer completed.",
parent_id=parent_id,
model=model_id,
done=False,
done=True,
meta=meta,
created_at=now_ms(),
)
await Chat.update_current_message(parent_chat_id, assistant_msg.id, now_ms())
else:
user_msg = await ChatMessage.create(
chat_id=parent_chat_id,
role="user",
content=content,
parent_id=parent_id,
model=model_id,
meta=meta,
created_at=now_ms(),
)
if not active:
assistant_msg = await ChatMessage.create(
chat_id=parent_chat_id,
role="assistant",
content="",
parent_id=user_msg.id,
model=model_id,
done=False,
created_at=now_ms(),
)
await Chat.update_current_message(parent_chat_id, assistant_msg.id, now_ms())
await export_chat_to_file(parent_chat_id)
if direct_timer_completion:
await emit_to_user(
user_id,
{
"chat_id": parent_chat_id,
"message_id": assistant_msg.id,
"pending_inputs_processed": True,
},
)
return
if not assistant_msg:
await emit_to_user(
user_id,
-1
View File
@@ -2620,7 +2620,6 @@ GLOBAL_CHAT_DISABLED_TOOLS = {
*BUILTIN_TOOL_GROUPS["browser"],
*BUILTIN_TOOL_GROUPS["automations"],
*BUILTIN_TOOL_GROUPS["images"],
*BUILTIN_TOOL_GROUPS["subagents"],
"manage_skill",
}