This commit is contained in:
2026-11-08 20:08:53 +08:00
parent 7526a5fe4d
commit 9b924747c5
2692 changed files with 394867 additions and 0 deletions

View File

@@ -0,0 +1,27 @@
import { messagingMenuHelpers } from "@mail/../tests/mock_server/controllers/discuss/messaging_menu";
import { patch } from "@web/core/utils/patch";
// Mirrors `ai_agentic/controllers/messaging_menu.py` (AIAgenticMessagingMenuController):
// registers the Automation tab on top of the AI chat one.
patch(messagingMenuHelpers, {
_get_menu_tab_domain(env, tab_id) {
if (tab_id.startsWith("ai-automation:")) {
// the mock discuss.channel has no `from_ai_automation` field:
// the base ai_chat domain is close enough for the counters
const agentId = Number(tab_id.split(":")[1]);
return [
["channel_type", "=", "ai_chat"],
["ai_agent_id", "=", agentId],
];
}
return super._get_menu_tab_domain(env, tab_id);
},
_get_menu_tab_filter_domain(env, tab_id, filter_id) {
if (tab_id.startsWith("ai-automation:") && filter_id === "ai_automation_unread") {
return [["self_member_id.is_unread", "=", true]];
}
return super._get_menu_tab_filter_domain(env, tab_id, filter_id);
},
});

View File

@@ -0,0 +1,33 @@
import { AIAgent } from "@ai/../tests/mock_server/mock_models/ai_agent";
import { patch } from "@web/core/utils/patch";
// Mirrors `ai_agentic/models/ai_agent.py` `open_agent_chat`.
patch(AIAgent.prototype, {
open_agent_chat(idOrIds) {
const agent = this.browse(idOrIds)[0];
const session = this.env["ai.session"]
._filter([
["agent_id", "=", agent.id],
["ai_composer_id", "=", false],
])
.find((session) => {
const channel = this.env["discuss.channel"].browse(session.channel_id)[0];
return channel.channel_type === "ai_chat" && !channel.message_ids?.length;
});
let channelId = session?.channel_id;
if (!channelId) {
channelId = this.browse(agent.id)._create_ai_chat_channel();
this.env["ai.session"].create({ agent_id: agent.id, channel_id: channelId });
}
return {
type: "ir.actions.client",
tag: "mail.action_discuss",
context: {
active_id: `discuss.channel_${channelId}`,
scoped_ai_agent_id: agent.id,
},
};
},
});