Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions docs/SETTINGS.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ Unknown keys, wrong types, unsupported values or an empty `changes` object are r
| `chat_language` | `auto` or the 17 recaptured chat languages | `auto` |
| `auto_translate` | boolean | `false` |
| `send_shortcut` | `enter`, `mod_enter` | `enter` |
| `message_folding` | `compact`, `standard`, `none` | `standard` |
| `document_cards` | boolean | `false` |
| `message_folding` (legacy client compatibility) | `compact`, `standard`, `none` | `standard` |
| `document_cards` | boolean. Show document attachments as cards. | `false` |
| `link_previews` | boolean | `true` |
| `task_completion_reminders` | boolean | `true` |
| `likes_visible` / `favorites_visible` | boolean | `true` |
Expand Down
648 changes: 322 additions & 326 deletions docs/inventory/visible-controls.json

Large diffs are not rendered by default.

16 changes: 8 additions & 8 deletions docs/upstream/flybot-workspace-overlay.json
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
},
"services/bot-social/src/openteamily/group-management.ts": {
"path": "src/flybot-workspace/group-management.ts",
"sha256": "04486a2062c7b0c350e52ff464c5410c48912f4f28a1f578752ba917b0bd8b47",
"sha256": "b39f70d08b331fa1cfe8d1f0aedd82eac050c5275f66ecaef4c73db8d4a579fe",
"source_sha256": "04486a2062c7b0c350e52ff464c5410c48912f4f28a1f578752ba917b0bd8b47"
},
"services/bot-social/src/openteamily/index.ts": {
Expand All @@ -82,7 +82,7 @@
},
"services/bot-social/src/openteamily/messenger.ts": {
"path": "src/flybot-workspace/messenger.ts",
"sha256": "8151f14d35d1fcf2ee122ee25496d9efdb4eb120c86e2558cc17f5cf8e9247f4",
"sha256": "e712e23ddef967ca42b8d97177aec978a78af0342c12ed16c3d323e8e94bd5f9",
"source_sha256": "3cbcec62487ace92625a18cbb70efacc89f8068e9a7b07b95c09fae26009a9db"
},
"services/bot-social/src/openteamily/migrate.ts": {
Expand Down Expand Up @@ -137,7 +137,7 @@
},
"services/bot-social/test/openteamily_agent_inbox.test.ts": {
"path": "test/flybot_workspace_agent_inbox.test.ts",
"sha256": "0a247a8bc79f21a82773722ef0d00b403ab6158cd1a3dfc9fa448f33429c4300",
"sha256": "6d89c4f6e007a99db721ef491a7f7df203141f59db6099c6d148b4fdc69e88e2",
"source_sha256": "705789714d7838f5bc2945781a9ce26eacf0a7bdb989f9ead3fd779df48d8211"
},
"services/bot-social/test/openteamily_agent_reply_lease.test.ts": {
Expand Down Expand Up @@ -167,7 +167,7 @@
},
"services/bot-social/test/openteamily_group_reply_policy.test.ts": {
"path": "test/flybot_workspace_group_reply_policy.test.ts",
"sha256": "e1c756ff62ac308f65afc32debf57c1ed77190173d66cf0ea354af3ad4e59299",
"sha256": "fb8e3a01457005b367192a0daecbcde3d813d05417c28af1bedda27d34b6fd05",
"source_sha256": "00c5a82f962f2c83915a81278b9081ea38ce51bff898347018c805474427a8cf"
},
"services/bot-social/test/openteamily_helpers.ts": {
Expand All @@ -187,22 +187,22 @@
},
"services/bot-social/test/openteamily_messenger.test.ts": {
"path": "test/flybot_workspace_messenger.test.ts",
"sha256": "6e0e38b3649650345f3fe5bf3c0dc207785fd4467ca18f5f780c72e5e3aa0bce",
"sha256": "b9e30e8e174b0a99f65ddd4066f9e0cc9f3ad8c10feb3299bbbc08041f0c2024",
"source_sha256": "89be3d344b5d01b59c8ccd989bcfc47546cd0aa093e6a798018947ead5f7e223"
},
"services/bot-social/test/openteamily_native_group_rounds.test.ts": {
"path": "test/flybot_workspace_native_group_rounds.test.ts",
"sha256": "bb624d1205f551a7bef4771aeda9c8b2053216321470452a72ad8b927700328b",
"sha256": "3a6b819953224852157c694ff1fb491c5f8b2ee014fe21521b8f280622b24e81",
"source_sha256": "2a477b7e35cdf1d1245486e6980aeb4769d85fc05c82dac774b32814f6325785"
},
"services/bot-social/test/openteamily_natural_group_chat.test.ts": {
"path": "test/flybot_workspace_natural_group_chat.test.ts",
"sha256": "0911ed727cd68a8122c13ec200ea99b461d858f9857f6d4da40ac18944ae5871",
"sha256": "00b158f6a7363b6cab1d5304bbea77ff24c386fbbde3b0a0dfb81857ccb17593",
"source_sha256": "adcb17b9b66f274c25ee55fe397ebae1d4ae3f66ce9c90d554a977c07364f6c9"
},
"services/bot-social/test/openteamily_personal_groups.test.ts": {
"path": "test/flybot_workspace_personal_groups.test.ts",
"sha256": "90956ecccc157ba195a60ca4cdd608d37e369c4b44fd77a8e07209e7b1f52947",
"sha256": "21e1a724428cb7465b340c67ffc58f1713ca433e95bd1720dc86ffc5b008bd66",
"source_sha256": "065985214d0dff989f46fc44b7b0a8263db10edcf878cfb78bd4f2fb7f51218a"
},
"services/bot-social/test/openteamily_profile_social.test.ts": {
Expand Down
23 changes: 20 additions & 3 deletions flybot_workspace/static/chat/app.css
Original file line number Diff line number Diff line change
Expand Up @@ -1961,12 +1961,29 @@ html[data-theme-resolved="dark"] .plus-create [data-tone="doc"] .plus-ico { colo
.group-roster-chevron { margin-inline-start: auto; }
#conversation-agents-text { flex: none; }
#conversation-agents-count { flex: none; min-width: 1.15rem; padding: .0625rem .25rem; border-radius: 999px; background: var(--ot-accent-soft); color: var(--ot-ink); text-align: center; font-size: .6875rem; }
#conversation-agent-admin {
flex: 0 0 auto;
max-width: min(15rem, 45%);
box-sizing: border-box;
padding: .125rem .45rem;
border-radius: .45rem;
background: var(--ot-accent-soft);
color: var(--ot-accent-hover);
font-size: .75rem;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
#conversation-agent-admin:not(.has-admin) {
background: var(--ot-surface-2);
color: var(--ot-muted);
}
#conversation-agents-preview { display: flex; min-width: 0; align-items: center; gap: .3rem; margin-inline-start: .25rem; overflow: hidden; }
.group-roster-preview-chip { min-width: 0; max-width: 9.5rem; padding: .15rem .4rem; border: 1px solid var(--ot-line); border-radius: .4rem; color: var(--ot-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .75rem; font-weight: 500; }
.group-roster-preview-more { flex: none; color: var(--ot-muted); font-size: .75rem; }
.group-agent-sheet-body { box-sizing: border-box; max-height: min(44dvh, 25rem); overflow: auto; overscroll-behavior: contain; padding: .6rem clamp(.875rem, 2.3vw, 1.5rem) .8rem; border-bottom: 1px solid var(--ot-line); }
.group-roster-head { display: flex; min-width: 0; align-items: center; justify-content: space-between; gap: .5rem; }
#group-agent-manage { flex: none; min-height: 2.375rem; padding: .3rem .65rem; color: var(--ot-accent-hover); font-size: .75rem; }
.group-roster-head { display: flex; flex-wrap: wrap; min-width: 0; align-items: center; justify-content: space-between; gap: .5rem; }
.group-roster-head :is(#group-agent-manage, #group-agent-set-admin) { flex: none; min-height: 2.375rem; padding: .3rem .65rem; color: var(--ot-accent-hover); font-size: .75rem; }
#group-agent-chips .agent-chip { min-height: 1.8rem; gap: .4rem; border-radius: .55rem; padding: .2rem .375rem; }
.group-roster-glyph { display: grid; flex: none; place-items: center; width: 1.375rem; height: 1.375rem; border-radius: .375rem; background: var(--ot-accent-soft); color: var(--ot-accent-hover); font-size: .75rem; font-weight: 650; }
.group-roster-name { min-width: 0; overflow-wrap: anywhere; }
Expand Down Expand Up @@ -2951,7 +2968,7 @@ html[data-chat-keyboard] body.app-workspace.chat-open {
.empty-group strong { color: var(--ot-ink); font-size: 1rem; }
@media (max-width: 700px) {
#main-panel[data-chat-kind="group"] .chat-top { gap: .25rem; padding-inline: .25rem .375rem; }
#conversation-agents-label, #group-agent-manage { min-height: 2.75rem; }
#conversation-agents-label, .group-roster-head :is(#group-agent-manage, #group-agent-set-admin) { min-height: 2.75rem; }
#conversation-agents-preview { gap: .2rem; }
.group-roster-preview-chip { max-width: 7rem; padding-inline: .3rem; }
#group-agent-action .group-agent-sheet-body { max-height: min(39dvh, 21rem); }
Expand Down
82 changes: 54 additions & 28 deletions flybot_workspace/static/chat/app.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { countMentionedGroupMembers, hasEveryoneMention, hasGroupAllMention, mou
import { createGroupBotIdentities, groupBotIdentity, createGroupBotAvatar } from './group-identity.mjs';
import { groupMentionPainter } from './group-mentions-display.mjs';
import { AGENT_FILE_ACCEPT, chatFileDownload, chatUploadProgress, deferModule, localChatFile, mountChatFiles,
ownSocialMessage, ownSocialReceipt, renderChatFile, sendPrivateAttachmentMessage, sendSocialAttachmentMessage, unclearSocialDelivery } from './files.mjs';
isChatImage, ownSocialMessage, ownSocialReceipt, renderChatFile, sendPrivateAttachmentMessage, sendSocialAttachmentMessage, unclearSocialDelivery } from './files.mjs';
import { mountGroupTranslation } from './translation.mjs';
import { mountChatActivity, mountChatApprovalNotice } from './activity.mjs';
import { meetingCodeFromHash, meetingDraftFromCallHref, stageMeetingFromChat } from '../shell/meeting-link.mjs';
Expand Down Expand Up @@ -355,15 +355,14 @@ function mayContainChatMarkdown(text, assistantReply) {
/^(?:#{1,6}\s|[ \t]*(?:>|[-+]\s|\d+[.)]\s|-{3,}$))/m.test(text));
}

function appendMessageMarkdown(doc, parent, source, assistantReply, updatePreview, paintMentions) {
function appendMessageMarkdown(doc, parent, source, assistantReply, paintMentions) {
const node = doc.createElement('div');
node.textContent = source;
parent.append(node);
const format = module => {
if (!assistantReply && !module.hasExplicitRichContent(source)) return;
module.renderChatMarkdown(doc, node, source);
paintMentions?.(node);
updatePreview?.();
};
if (richContent) {
format(richContent);
Expand Down Expand Up @@ -430,18 +429,17 @@ function renderMessageBody(doc, node, text, prefs, assistantReply = false, previ
const rich = mayContainChatMarkdown(source, assistantReply) &&
(!richContent || assistantReply || richContent.hasExplicitRichContent(source));
if (rich) {
renderMessageText(doc, node, source, prefs.message_folding, prefs.link_previews, (parent, value, updatePreview) => {
renderMessageText(doc, node, source, prefs.link_previews, (parent, value) => {
const streamed = assistantReply && streamingReplies.get(preview);
if (!streamed?.markdown || !value.startsWith(streamed.source.trimEnd())) {
appendMessageMarkdown(doc, parent, value, assistantReply, updatePreview, paintMentions);
appendMessageMarkdown(doc, parent, value, assistantReply, paintMentions);
return;
}
richContent.renderStreamingMarkdown(doc, streamed.markdown, value, {complete:true});
parent.append(streamed.markdown);
if (parent.tagName === 'DETAILS') parent.open = true;
});
} else if (inlineBold(source).some(part => part.bold)) fillBold(doc, node, source);
else renderMessageText(doc, node, source, prefs.message_folding, prefs.link_previews);
else renderMessageText(doc, node, source, prefs.link_previews);
const origin = doc.defaultView?.location?.origin;
const references = [
[meetingCallHrefInMessage, '整理会议纪要'],
Expand All @@ -461,7 +459,7 @@ function renderMessageBody(doc, node, text, prefs, assistantReply = false, previ
if (!existing) node.append(link);
}
paintMentions?.(node);
return rich || node.children[0]?.tagName === 'DETAILS';
return rich;
}

export function highlightParts(text, query) {
Expand Down Expand Up @@ -1227,7 +1225,7 @@ export function mount(document, {fetcher = globalThis.fetch.bind(globalThis)} =
let resourceItems = [];
let sendShortcut = 'enter';
let chatLanguage = 'auto';
const defaultChatPreferences = {message_folding:'standard', document_cards:false, link_previews:true};
const defaultChatPreferences = {document_cards:false, link_previews:true};
let chatPreferences = defaultChatPreferences;
let chatSettings = null;
let attachmentSender;
Expand Down Expand Up @@ -1326,7 +1324,10 @@ export function mount(document, {fetcher = globalThis.fetch.bind(globalThis)} =
node.hidden = !conversation || quoteBlocksSend(scope);
if (node.hidden) return;
const people = countMentionedGroupMembers(body, {members:conversation.members, viewerId:currentUser?.id});
const hasFiles = Boolean(attachmentSender?.draftFiles(scope).length);
const files = attachmentSender?.draftFiles(scope) ?? [];
const hasFiles = files.length > 0;
const nativeImage = routing?.native_group_images === true && !replyDrafts.has(scope) &&
body.trim() && isChatImage(files[0]);
const quote = routing && activeGroupAgent(conversation, replyDrafts.get(scope)?.agentTarget);
const auto = groupUsesLegacyAutoReplies(conversation) && agents.some(agent => agent.auto_reply);
let text, kind = 'default';
Expand Down Expand Up @@ -1355,7 +1356,7 @@ export function mount(document, {fetcher = globalThis.fetch.bind(globalThis)} =
} else if (people) {
kind = 'targeted';
text = uiLabel(`将提及 ${people} 位群成员`, `${people} group ${people === 1 ? 'member' : 'members'} will be mentioned`);
} else if (hasFiles) {
} else if (hasFiles && !nativeImage) {
text = agents.length
? uiLabel('用 @ 请智能体根据附言回复', 'Use @ to ask agents to reply to the caption')
: uiLabel('附件将发送给群成员', 'The files will be shared with the group');
Expand Down Expand Up @@ -1384,7 +1385,8 @@ export function mount(document, {fetcher = globalThis.fetch.bind(globalThis)} =
kind = 'attention';
text = uiLabel('写一段附言,让选中的智能体知道要回复什么。', 'Add a caption for the selected agents to answer.');
} else {
text += uiLabel(' · 按附言回复', ' · Replies use the caption');
text += nativeImage ? uiLabel(' · 可查看图片', ' · Agents can see the image')
: uiLabel(' · 按附言回复', ' · Replies use the caption');
}
}
const label = document.getElementById('group-composer-routing-text');
Expand Down Expand Up @@ -6126,27 +6128,53 @@ export function mount(document, {fetcher = globalThis.fetch.bind(globalThis)} =
return groupManagement;
}

async function openGroupSettings(method) {
const target = groupManagementContext();
if (!target) return;
const scope = {...target, conversationId:target.conversation.id};
try {
const controls = await initializeGroupManagement({fromShortcut:true});
if (groupMatches(scope)) controls?.[method]();
} catch {
if (groupMatches(scope)) show('error', uiLabel('无法打开群设置,请重试。', 'Could not open group settings. Try again.'));
}
}

function renderGroupReplyPolicy(conversation) {
const section = document.getElementById('group-reply-policy');
const summary = document.getElementById('group-reply-policy-summary');
const shortcut = document.getElementById('group-reply-shortcut');
const routing = conversation?.group_agent_routing;
const policy = routing?.policy;
const agents = (conversation?.agent_members || []).filter(agent => !agent.archived && !agent.native_deleted);
const admin = policy?.mode === 'lead' && !policy.lead_unavailable ? activeGroupAgent(conversation, policy.lead) : null;
section.hidden = conversation?.kind !== 'group' || Boolean(conversation.public_agent);
if (shortcut) shortcut.hidden = section.hidden || !servedByDsbot || !routing;
const badge = document.getElementById('conversation-agent-admin');
if (badge) {
badge.hidden = section.hidden || !routing || !agents.length;
badge.className = admin ? 'has-admin' : '';
const sameName = admin && agents.some(agent => agent !== admin && agent.name === admin.name);
const name = sameName
? groupAgentName(admin.name, groupAgentOwnerLabel(admin), admin.owner_id, admin.mine === false ? admin.owner_handle : '')
: admin?.name;
badge.textContent = admin ? uiLabel(`管理员 · ${name}`, `Admin · ${name}`) : uiLabel('未设置管理员', 'No admin assigned');
badge.title = badge.textContent;
}
const editAdmin = document.getElementById('group-agent-set-admin');
if (editAdmin) editAdmin.hidden = section.hidden || !servedByDsbot || routing?.can_edit !== true || !agents.length;
if (section.hidden) return;
if (policy?.mode === 'mentions') summary.textContent = uiLabel('仅在被 @ 时回复', 'Only when mentioned');
else if (!conversation.agent_members?.some(agent => !agent.archived && !agent.native_deleted)) {
else if (!agents.length) {
summary.textContent = uiLabel('群里暂无可回复的智能体', 'There are no group agents available to reply');
} else if (policy?.mode === 'everyone') summary.textContent = uiLabel('由所有群内智能体判断是否回复', 'All group agents decide whether to reply');
else if (policy?.mode === 'lead') {
const lead = !policy.lead_unavailable && activeGroupAgent(conversation, policy.lead);
if (lead) {
const name = groupAgentName(lead.name, groupAgentOwnerLabel(lead), lead.owner_id, lead.mine === false ? lead.owner_handle : '');
summary.textContent = uiLabel(`指定智能体优先 · ${name}`, `Preferred agent · ${name}`);
if (admin) {
const name = groupAgentName(admin.name, groupAgentOwnerLabel(admin), admin.owner_id, admin.mine === false ? admin.owner_handle : '');
summary.textContent = uiLabel(`管理员 · ${name}`, `Admin · ${name}`);
} else {
summary.textContent = uiLabel('优先智能体不可用,由其他群内智能体判断是否回复。',
'The preferred agent is unavailable. Other group agents decide whether to reply.');
summary.textContent = uiLabel('管理员暂不可用,由其他群内智能体判断是否回复。',
'The admin is unavailable. Other group agents decide whether to reply.');
}
} else if (groupUsesLegacyAutoReplies(conversation) && conversation.agent_members?.some(
agent => !agent.archived && !agent.native_deleted && agent.auto_reply)) {
Expand Down Expand Up @@ -8961,22 +8989,20 @@ export function mount(document, {fetcher = globalThis.fetch.bind(globalThis)} =
(groupInfoOpener || groupInfoToggle).focus();
});
const replyShortcut = document.getElementById('group-reply-shortcut');
replyShortcut?.addEventListener('click', async () => {
replyShortcut?.addEventListener('click', () => {
if (replyShortcut.hidden) return;
if (currentConversation?.group_agent_routing?.can_edit !== true) {
closeInChatSearch({restoreScroll:false, focus:false});
setGroupInfoOpen(true, replyShortcut);
document.getElementById('group-reply-policy').focus();
return;
}
const target = groupManagementContext();
if (!target) return;
const scope = {...target, conversationId:target.conversation.id};
try {
const controls = await initializeGroupManagement({fromShortcut:true});
if (groupMatches(scope)) controls?.openReplyPolicy();
} catch {
if (groupMatches(scope)) show('error', uiLabel('无法打开群回复规则,请重试。', 'Could not open the group reply policy. Try again.'));
return openGroupSettings('openReplyPolicy');
});
const adminButton = document.getElementById('group-agent-set-admin');
adminButton?.addEventListener('click', () => {
if (!adminButton.hidden && agentRosterCurrent(agentRosterView) && !agentRosterView.direct) {
return openGroupSettings('openAdministrator');
}
});
document.getElementById('group-agent-manage').addEventListener('click', () => {
Expand Down
2 changes: 2 additions & 0 deletions flybot_workspace/static/chat/files.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ function fileType(file) {
const extension = file.name.toLowerCase().split('.').at(-1);
return Object.hasOwn(MEDIA_TYPES, extension) ? MEDIA_TYPES[extension] : file.type;
}
export const isChatImage = file => Boolean(file && /^image\/(png|jpeg|gif|webp)$/i.test(file.type));

const formatBytes = bytes => bytes >= 1048576 ? (bytes / 1048576).toFixed(1) + ' MB'
: bytes >= 1024 ? Math.round(bytes / 1024) + ' KB' : bytes + ' B';

Expand Down
Loading
Loading