Name sessions opened by handed-off work, and hide empty ones from activity
A session the coordinator's delegation, a routine or a hook opened has no user message and no reply, so it was never named and showed as "Untitled conversation". Tasks now name their session too, and a session with no user message is named from the bot's own messages. Until a session is named, Latest activity shows what it opened with, and sessions with no messages are left out of it. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
import type { SessionOpeningMessage } from "@/src/functions/backend/db/bot-sessions/grab-session-opening";
|
||||
|
||||
type Params = {
|
||||
messages: SessionOpeningMessage[];
|
||||
};
|
||||
|
||||
/**
|
||||
* Whether a session's opening says enough to name it: the bot has said
|
||||
* something of its own (a carried summary doesn't count), and, when the
|
||||
* user wrote, after the user's first message. A session with no user
|
||||
* message at all is work handed to the bot (the coordinator's delegations,
|
||||
* routines, hooks), named from the bot's own messages.
|
||||
*/
|
||||
export default function sessionReadyToName({ messages }: Params) {
|
||||
const has_bot_message = messages.some(
|
||||
(message) => message.author == "bot" && !message.carried_from_session_id,
|
||||
);
|
||||
|
||||
if (!has_bot_message) return false;
|
||||
|
||||
const first_user = messages.findIndex((message) => message.author == "user");
|
||||
|
||||
if (first_user < 0) return true;
|
||||
|
||||
return messages
|
||||
.slice(first_user + 1)
|
||||
.some((message) => message.author == "bot" && !message.carried_from_session_id);
|
||||
}
|
||||
Reference in New Issue
Block a user