@michengai/dsh-im-connect 1.0.18 → 1.0.20
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +14 -0
- package/CHANGELOG.zh-CN.md +14 -0
- package/README.md +19 -2
- package/README.zh-CN.md +19 -2
- package/assets/icon.svg +27 -0
- package/client.js +349 -27
- package/lib/api-base.d.ts +1 -1
- package/lib/api-base.js +1 -1
- package/lib/channels/meta.d.ts +7 -0
- package/lib/channels/meta.d.ts.map +1 -1
- package/lib/channels/meta.js +11 -0
- package/lib/channels/meta.js.map +1 -1
- package/lib/client.js +350 -28
- package/lib/engine/command-messages.d.ts +1 -0
- package/lib/engine/command-messages.d.ts.map +1 -1
- package/lib/engine/command-messages.js +1 -0
- package/lib/engine/command-messages.js.map +1 -1
- package/lib/engine/gateway.d.ts +16 -0
- package/lib/engine/gateway.d.ts.map +1 -1
- package/lib/engine/gateway.js +94 -3
- package/lib/engine/gateway.js.map +1 -1
- package/lib/engine/router.js +1 -1
- package/lib/engine/router.js.map +1 -1
- package/lib/engine/segments.d.ts +20 -0
- package/lib/engine/segments.d.ts.map +1 -0
- package/lib/engine/segments.js +80 -0
- package/lib/engine/segments.js.map +1 -0
- package/lib/engine/session-id.d.ts +11 -3
- package/lib/engine/session-id.d.ts.map +1 -1
- package/lib/engine/session-id.js +16 -10
- package/lib/engine/session-id.js.map +1 -1
- package/lib/engine/types.d.ts +8 -0
- package/lib/engine/types.d.ts.map +1 -1
- package/lib/index.d.ts +9 -1
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +41 -1
- package/lib/index.js.map +1 -1
- package/lib/manager.d.ts +17 -0
- package/lib/manager.d.ts.map +1 -1
- package/lib/manager.js +81 -5
- package/lib/manager.js.map +1 -1
- package/package.json +3 -2
- package/src/api-base.ts +1 -1
- package/src/channels/meta.ts +16 -0
- package/src/engine/command-messages.ts +2 -0
- package/src/engine/gateway.ts +92 -3
- package/src/engine/router.ts +1 -1
- package/src/engine/segments.ts +85 -0
- package/src/engine/session-id.ts +17 -11
- package/src/engine/types.ts +8 -0
- package/src/index.ts +55 -0
- package/src/manager.ts +94 -6
package/client.js
CHANGED
|
@@ -14,6 +14,7 @@ window.__ModuleLoader__.load({
|
|
|
14
14
|
const HostMenu = primitives.Menu;
|
|
15
15
|
const HostModal = primitives.Modal;
|
|
16
16
|
const HostSegmentedTabs = primitives.SegmentedTabs;
|
|
17
|
+
const HostTooltip = primitives.Tooltip;
|
|
17
18
|
const PrimitiveSwitch = primitives.Switch;
|
|
18
19
|
// 宿主 Button 由 forwardRef 包成对象,typeof 是 object,不是 function。
|
|
19
20
|
function isHostComponent(component) {
|
|
@@ -418,6 +419,9 @@ window.__ModuleLoader__.load({
|
|
|
418
419
|
}
|
|
419
420
|
|
|
420
421
|
const IconSettingsOutline16 = pickHostIcon("IconSettingsOutlineRegular", "IconSettingsOutline16");
|
|
422
|
+
// 已通过逐条投递验证的渠道,与宿主端 channels/meta.ts 的 supportsSegmentReply 保持一致。
|
|
423
|
+
const SEGMENT_REPLY_PLATFORMS = ["qq"];
|
|
424
|
+
const supportsSegmentReply = (platform) => SEGMENT_REPLY_PLATFORMS.indexOf(platform) >= 0;
|
|
421
425
|
const CHANNEL_SETTINGS_EVENT = "dsh-im-connect:open-channel-settings";
|
|
422
426
|
const CHANNEL_SETTINGS_STORAGE_KEY = "dsh-im-connect:pending-channel-settings";
|
|
423
427
|
const SETTINGS_CODEX_TRIGGER_SELECTOR = "[data-dcu-settings-trigger]";
|
|
@@ -586,7 +590,7 @@ window.__ModuleLoader__.load({
|
|
|
586
590
|
}
|
|
587
591
|
const EMPTY_EXTRA_TABS = [];
|
|
588
592
|
const inject = ["slots", "sessions", "workspaces", "locale"];
|
|
589
|
-
const API_BASE = "/api/dsh-im-connect";
|
|
593
|
+
const API_BASE = "/api/michengai/dsh-im-connect";
|
|
590
594
|
const TAB_KEY = "dsh-native-sidebar.tab";
|
|
591
595
|
const ACCOUNT_SELECTION_KEY = "dsh-im-connect.settings.selected-account";
|
|
592
596
|
const IM_LOCALE_NS = "im-connect";
|
|
@@ -612,9 +616,10 @@ window.__ModuleLoader__.load({
|
|
|
612
616
|
"settings.label": "IM助理", "settings.title": "IM助理", "settings.description": "管理各渠道账号。每个账号独立选择工作区、模型和权限,配置仅保存在本机。", "settings.viewProject": "GitHub", "settings.feedback": "问题反馈",
|
|
613
617
|
"sidebar.entry.title": "侧边栏入口", "sidebar.entry.desc": "在侧栏显示即时通讯管理入口。设置里的入口不变。", "sidebar.entry.toggle": "切换侧边栏入口",
|
|
614
618
|
"update.entry.title": "在线更新", "update.entry.desc": "允许检查并在线安装即时通讯插件的新版本。关闭后隐藏更新入口。", "update.entry.toggle": "切换在线更新", "error.update.disabled": "在线更新已被禁用",
|
|
619
|
+
"taskTreeSessions.entry.title": "在任务树显示 IM 会话", "taskTreeSessions.entry.desc": "在官方工作区任务树中显示各渠道会话。关闭后仅在侧栏「频道」页签中显示", "taskTreeSessions.entry.toggle": "切换在任务树显示 IM 会话",
|
|
615
620
|
"settings.aria": "IM助理", "settings.publicChatNotice": "未批准用户可以发起聊天,但不能批准工具调用。", "pending.notice": "有访问请求。批准后该用户才能驱动本机助手。", "action.approve": "批准", "action.deny": "拒绝", "loading": "加载中…",
|
|
616
|
-
"account.presetUnavailable": "预设不可用", "
|
|
617
|
-
"account.workspace": "工作区", "account.currentWorkspace": "当前工作区", "account.selectWorkspace": "请选择工作区", "account.selectModel": "请选择模型", "account.selectPermission": "请选择权限", "account.privateAccess": "私聊准入", "account.privateApproved": "仅已批准用户", "account.privateAll": "允许所有私聊用户",
|
|
621
|
+
"account.presetUnavailable": "预设不可用", "action.settings": "设置", "command.dm": "私聊命令", "command.group": "群聊命令", "command.enabled": "可以执行命令", "command.disabled": "仅正常对话",
|
|
622
|
+
"account.workspace": "工作区", "account.currentWorkspace": "当前工作区", "account.selectWorkspace": "请选择工作区", "account.selectModel": "请选择模型", "account.selectPermission": "请选择权限", "account.privateAccess": "私聊准入", "account.privateApproved": "仅已批准用户", "account.privateAll": "允许所有私聊用户", "account.sendMode": "发送方式", "account.sendQueue": "排队发送", "account.sendSteer": "插话发送", "account.sendSteerNote": "插话发送会把消息作为补充指令立即交给运行中的任务;任务空闲时与排队发送相同。", "account.segmentReply": "分段回复", "account.segmentFull": "完整发送", "account.segmentSplit": "分段发送", "account.segmentReplyNote": "选择分段发送时助手会把一次回复拆成多条短消息,在分隔标记处切开逐条发送;完整发送时仍是一条完整回复。", "account.segmentGap": "发送间隔", "account.segmentGapMin": "最小间隔", "account.segmentGapMax": "最大间隔", "account.segmentGapNote": "每条分段消息之间会从这个区间里随机取一个间隔,单位秒,可直接填写。", "account.segmentGapInvalid": "请填写 0 到 60 之间的秒数", "account.segmentGapOrder": "上限不能低于下限", "account.seconds": "秒", "account.autoNameNote": "绑定成功后会自动生成账号名,无需手动填写。需要区分使用者时,可在账号行填写备注。", "account.proxyMode": "网络代理", "account.proxyInherit": "跟随宿主", "account.proxyDirect": "直接连接", "account.proxyCustom": "手动配置", "account.proxyUrl": "代理地址", "account.proxyNote": "仅影响当前账号;保存后自动重连生效。", "account.proxySaved": "代理地址已保存;留空保存可保留当前地址。", "account.defaultName": "{channel}账号 {count}",
|
|
618
623
|
"account.remark": "名称备注", "account.remarkNote": "只在本机设置页区分账号,留空恢复自动名称。", "account.rename": "修改名称备注",
|
|
619
624
|
"account.count": "{count} 个账号", "account.statusProcessing": "处理中…", "account.statusNotConnected": "未连接", "account.receive": "接收消息", "account.receiveDescription": "关闭后保留账号配置,但不接收新消息", "account.removeConfirm": "确定移除这个账号?本机保存的配置和凭据将一并删除。",
|
|
620
625
|
"action.addAccount": "添加账号", "action.generateQr": "生成二维码", "action.checkConnection": "诊断连接", "action.reconnectAccount": "重新连接", "action.removeAccount": "移除接入", "status.saving": "保存中…", "status.saved": "已保存",
|
|
@@ -643,9 +648,10 @@ window.__ModuleLoader__.load({
|
|
|
643
648
|
"settings.label": "IM Assistant", "settings.title": "IM Assistant", "settings.description": "Manage accounts across channels. Each account has its own workspace, model, and permission settings, stored only on this machine.", "settings.viewProject": "GitHub", "settings.feedback": "Issues",
|
|
644
649
|
"sidebar.entry.title": "Sidebar entry", "sidebar.entry.desc": "Show IM Connect in the sidebar. The Settings entry stays either way.", "sidebar.entry.toggle": "Toggle sidebar entry",
|
|
645
650
|
"update.entry.title": "Online updates", "update.entry.desc": "Allow checking and installing new versions online. Hides the update entry when disabled.", "update.entry.toggle": "Toggle online updates", "error.update.disabled": "Online updates are disabled",
|
|
651
|
+
"taskTreeSessions.entry.title": "Show IM sessions in task tree", "taskTreeSessions.entry.desc": "Show messaging channel sessions in the official workspace task tree. When disabled, sessions are shown only under the 'Channels' tab.", "taskTreeSessions.entry.toggle": "Toggle show IM sessions in task tree",
|
|
646
652
|
"settings.aria": "IM Assistant", "settings.publicChatNotice": "Unapproved users can start chats, but they cannot approve tool calls.", "pending.notice": "There are access requests. Approve a user before they can control the local assistant.", "action.approve": "Approve", "action.deny": "Deny", "loading": "Loading…",
|
|
647
|
-
"account.presetUnavailable": "Preset unavailable", "
|
|
648
|
-
"account.workspace": "Workspace", "account.currentWorkspace": "Current workspace", "account.selectWorkspace": "Select a workspace", "account.selectModel": "Select a model", "account.selectPermission": "Select a permission", "account.privateAccess": "Private chat access", "account.privateApproved": "Approved users only", "account.privateAll": "Allow all DM users",
|
|
653
|
+
"account.presetUnavailable": "Preset unavailable", "action.settings": "Settings", "command.dm": "DM commands", "command.group": "Group commands", "command.enabled": "Commands enabled", "command.disabled": "Conversation only",
|
|
654
|
+
"account.workspace": "Workspace", "account.currentWorkspace": "Current workspace", "account.selectWorkspace": "Select a workspace", "account.selectModel": "Select a model", "account.selectPermission": "Select a permission", "account.privateAccess": "Private chat access", "account.privateApproved": "Approved users only", "account.privateAll": "Allow all DM users", "account.sendMode": "Send mode", "account.sendQueue": "Queue", "account.sendSteer": "Steer", "account.sendSteerNote": "Steer hands the message to the running task as additional instructions at its next step; when the task is idle it behaves like Queue.", "account.segmentReply": "Segmented replies", "account.segmentFull": "Send as whole", "account.segmentSplit": "Send in segments", "account.segmentReplyNote": "When set to Send in segments, the assistant splits one reply into several short messages at the separator and sends them one by one; Send as whole keeps the entire reply in a single message.", "account.segmentGap": "Send gap", "account.segmentGapMin": "Minimum gap", "account.segmentGapMax": "Maximum gap", "account.segmentGapNote": "Each segmented message waits a random gap inside this range, in seconds. Type the values directly.", "account.segmentGapInvalid": "Enter a number of seconds between 0 and 60.", "account.segmentGapOrder": "The maximum gap cannot be lower than the minimum.", "account.seconds": "s", "account.autoNameNote": "The account name is generated automatically after setup. Add a remark on the account row if you need to tell users apart.", "account.proxyMode": "Network proxy", "account.proxyInherit": "Follow Host", "account.proxyDirect": "Connect directly", "account.proxyCustom": "Configure manually", "account.proxyUrl": "Proxy address", "account.proxyNote": "Affects only this account. The channel reconnects automatically after saving.", "account.proxySaved": "A proxy address is saved. Leave the field blank to keep it.", "account.defaultName": "{channel} account {count}",
|
|
649
655
|
"account.remark": "Name remark", "account.remarkNote": "Shown only in settings to tell accounts apart. Leave blank to restore the automatic name.", "account.rename": "Edit name remark",
|
|
650
656
|
"account.count": "{count} accounts", "account.statusProcessing": "Processing…", "account.statusNotConnected": "Not connected", "account.receive": "Receive messages", "account.receiveDescription": "Turn this off to keep the account settings without receiving new messages", "account.removeConfirm": "Remove this account? Its saved settings and credentials will also be deleted.",
|
|
651
657
|
"action.addAccount": "Add account", "action.generateQr": "Generate QR code", "action.checkConnection": "Diagnose connection", "action.reconnectAccount": "Reconnect", "action.removeAccount": "Remove", "status.saving": "Saving…", "status.saved": "Saved",
|
|
@@ -671,6 +677,10 @@ window.__ModuleLoader__.load({
|
|
|
671
677
|
return children;
|
|
672
678
|
}
|
|
673
679
|
|
|
680
|
+
const QUEUE_ICON_PATHS = '<path d="M5 6.75H11"/><path d="M5 9H8"/><path d="M2.37067 11.2497C1.5872 9.89252 1.32042 8.29798 1.61945 6.7597C1.91847 5.22141 2.76317 3.84293 3.99801 2.87809C5.23285 1.91325 6.7747 1.427 8.33964 1.50888C9.90458 1.59076 11.3873 2.23526 12.5147 3.32369C13.6422 4.41232 14.3384 5.8717 14.4751 7.43304C14.6118 8.99438 14.1797 10.5525 13.2585 11.8205C12.3372 13.0885 10.9889 13.9809 9.4617 14.3334C8.18666 14.6277 6.8587 14.529 5.64964 14.0601C5.17095 13.8745 4.76937 13.4929 4.26509 13.3963C3.67389 13.2832 2.95232 13.5595 2.0377 14.3334"/>';
|
|
681
|
+
const QUEUE_ICON_SVG = `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" fill="none" stroke="black" stroke-width="1.3" stroke-linecap="round" stroke-linejoin="round">${QUEUE_ICON_PATHS}</svg>`;
|
|
682
|
+
const QUEUE_ICON_MASK = `url("data:image/svg+xml,${encodeURIComponent(QUEUE_ICON_SVG)}")`;
|
|
683
|
+
|
|
674
684
|
const CSS = `
|
|
675
685
|
.ima-page,.ima-account-modal,.ima-bind-modal,.ima-inspector{--ima-text:var(--dsw-alias-label-primary,var(--dsh-text,#e6edf3));--ima-muted:var(--dsw-alias-label-tertiary,var(--dsh-text-muted,#8b949e));--ima-line:var(--dsw-alias-border-l2,var(--dsh-border,rgba(255,255,255,.1)));--ima-card:var(--dsw-alias-bg-layer-2,rgba(255,255,255,.04));--ima-card-hover:var(--dsw-alias-interactive-bg-hover,rgba(255,255,255,.06));--ima-ok:var(--dsw-alias-state-success-primary,#3fb950);--ima-warning:var(--dsw-alias-state-warning-primary,#d29922);--ima-danger:var(--dsw-alias-state-error-primary,#f85149);--ima-accent:var(--dsw-alias-brand-primary,#4b7cff)}
|
|
676
686
|
.ima-page{box-sizing:border-box;max-width:none;width:100%;margin:0;padding:0 0 32px;color:var(--ima-text)}
|
|
@@ -680,7 +690,7 @@ window.__ModuleLoader__.load({
|
|
|
680
690
|
.ima-title-links{display:flex;align-items:center;gap:8px;flex-wrap:wrap}
|
|
681
691
|
.ima-title-links>span[data-mpi-check]{display:inline-flex;align-items:center}
|
|
682
692
|
[data-ima-nav-icon]>svg{display:none!important}
|
|
683
|
-
[data-ima-nav-icon]::before{content:'';flex:none;width:16px;height:16px;background:currentColor;-webkit-mask
|
|
693
|
+
[data-ima-nav-icon]::before{content:'';flex:none;width:16px;height:16px;background-color:currentColor;-webkit-mask:${QUEUE_ICON_MASK} center/contain no-repeat;mask:${QUEUE_ICON_MASK} center/contain no-repeat;-webkit-mask-repeat:no-repeat;mask-repeat:no-repeat;-webkit-mask-position:center;mask-position:center;-webkit-mask-size:16px 16px;mask-size:16px 16px}
|
|
684
694
|
.ima-btn{display:inline-flex;align-items:center;justify-content:center;gap:4px;height:32px;padding:0 12px;border:0.5px solid var(--dsw-alias-border-l3,#555);border-radius:var(--dsw-radius-sm,8px);background:transparent;color:var(--dsw-alias-label-primary,#eee);font:inherit;font-size:13px;line-height:20px;cursor:pointer;user-select:none;box-sizing:border-box;text-decoration:none;transition:border-color 120ms ease,color 120ms ease,background 120ms ease}
|
|
685
695
|
.ima-btn:not(.is-primary):not(.ima-btn-danger){color:var(--dsw-alias-label-primary,#eee)!important}
|
|
686
696
|
.ima-btn:hover:not(:disabled):not(.ima-btn-danger){border-color:var(--dsw-alias-border-l3,#666)!important;color:var(--dsw-alias-label-primary,#fff)!important;background:var(--dsw-alias-interactive-bg-hover,rgba(255,255,255,.06))!important}
|
|
@@ -814,6 +824,9 @@ window.__ModuleLoader__.load({
|
|
|
814
824
|
把宿主的 content 区设为滚动容器,footer 保持在容器外可见。 */
|
|
815
825
|
.ima-bind-modal>.ima-modal-content,.ima-account-modal>.ima-modal-content{flex:1 1 auto;min-height:0;overflow-y:auto;overscroll-behavior:contain;scrollbar-gutter:stable}
|
|
816
826
|
.ima-account-settings{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:14px 16px;width:100%;box-sizing:border-box}
|
|
827
|
+
.ima-segment-gap{display:flex;align-items:center;gap:8px;width:100%}
|
|
828
|
+
.ima-segment-gap-input{flex:1 1 0;min-width:0}
|
|
829
|
+
.ima-segment-gap-sep,.ima-segment-gap-unit{color:var(--ima-muted, #8a8a8a);white-space:nowrap}
|
|
817
830
|
.ima-account-settings.compact{grid-template-columns:1fr}
|
|
818
831
|
.ima-proxy-settings{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:14px 16px;width:100%;box-sizing:border-box}
|
|
819
832
|
.ima-proxy-settings>.ima-picker-note{grid-column:1/-1}
|
|
@@ -899,6 +912,7 @@ window.__ModuleLoader__.load({
|
|
|
899
912
|
const value = String(sessionId || "");
|
|
900
913
|
const mapped = channelSessionChannels.get(value);
|
|
901
914
|
if (mapped) return mapped;
|
|
915
|
+
// 统一 UUID 不含渠道信息,映射未到达前只能返回空;旧语义 ID 仍可从字符串反解。
|
|
902
916
|
if (!value.startsWith("im:")) return undefined;
|
|
903
917
|
const rest = value.slice(3);
|
|
904
918
|
const split = rest.indexOf(":");
|
|
@@ -906,7 +920,11 @@ window.__ModuleLoader__.load({
|
|
|
906
920
|
const platform = instance.split("_", 1)[0];
|
|
907
921
|
return platform || undefined;
|
|
908
922
|
}
|
|
909
|
-
|
|
923
|
+
// 新旧两代 IM 前缀都要认,否则存量会话升级后会掉出渠道页签。
|
|
924
|
+
const isChannelSession = (id) => {
|
|
925
|
+
const value = String(id);
|
|
926
|
+
return value.startsWith("dsh-im-session-") || value.startsWith("im:") || channelSessionIds.has(value);
|
|
927
|
+
};
|
|
910
928
|
const subscribeChannelMembership = (listener) => {
|
|
911
929
|
channelMembershipListeners.add(listener);
|
|
912
930
|
return () => channelMembershipListeners.delete(listener);
|
|
@@ -1411,6 +1429,9 @@ window.__ModuleLoader__.load({
|
|
|
1411
1429
|
permission: defaults && defaults.permission || "",
|
|
1412
1430
|
privateAccess: "approved",
|
|
1413
1431
|
sendMode: "queue",
|
|
1432
|
+
segmentReply: false,
|
|
1433
|
+
segmentDelayMinSecs: 1,
|
|
1434
|
+
segmentDelayMaxSecs: 2,
|
|
1414
1435
|
agentPreset: defaults && defaults.agentPreset || "standard",
|
|
1415
1436
|
};
|
|
1416
1437
|
});
|
|
@@ -1587,6 +1608,7 @@ window.__ModuleLoader__.load({
|
|
|
1587
1608
|
permissionT,
|
|
1588
1609
|
presetT,
|
|
1589
1610
|
showAutoNameNote: true,
|
|
1611
|
+
segmentReplySupported: supportsSegmentReply(ch.id),
|
|
1590
1612
|
t,
|
|
1591
1613
|
}),
|
|
1592
1614
|
h(CommandPermissionSettings, { value: settings.commandPermissions, onSave: commandPermissions => setSettings(current => ({ ...current, commandPermissions })), t }),
|
|
@@ -1685,10 +1707,17 @@ window.__ModuleLoader__.load({
|
|
|
1685
1707
|
const permissionT = props.permissionT || ((key) => key);
|
|
1686
1708
|
const presetT = props.presetT || ((key) => key);
|
|
1687
1709
|
const value = props.value || {};
|
|
1710
|
+
const segmentDelayMinSecs = Number.isInteger(value.segmentDelayMinSecs) ? value.segmentDelayMinSecs : 1;
|
|
1711
|
+
const segmentDelayMaxSecs = Number.isInteger(value.segmentDelayMaxSecs) ? value.segmentDelayMaxSecs : 2;
|
|
1688
1712
|
const [addBusy, setAddBusy] = useState(false);
|
|
1689
1713
|
const [hint, setHint] = useState("");
|
|
1690
1714
|
const [confirmingFullAccess, setConfirmingFullAccess] = useState(false);
|
|
1691
1715
|
const [fullAccessAcknowledged, setFullAccessAcknowledged] = useState(false);
|
|
1716
|
+
const [segmentGapMinDraft, setSegmentGapMinDraft] = useState(String(segmentDelayMinSecs));
|
|
1717
|
+
const [segmentGapMaxDraft, setSegmentGapMaxDraft] = useState(String(segmentDelayMaxSecs));
|
|
1718
|
+
const [segmentGapError, setSegmentGapError] = useState("");
|
|
1719
|
+
useEffect(() => { setSegmentGapMinDraft(String(segmentDelayMinSecs)); }, [segmentDelayMinSecs]);
|
|
1720
|
+
useEffect(() => { setSegmentGapMaxDraft(String(segmentDelayMaxSecs)); }, [segmentDelayMaxSecs]);
|
|
1692
1721
|
const items = props.workspaces || [];
|
|
1693
1722
|
const providers = props.catalog || [];
|
|
1694
1723
|
const permissions = props.permissions || [];
|
|
@@ -1699,6 +1728,10 @@ window.__ModuleLoader__.load({
|
|
|
1699
1728
|
const permission = value.permission || "";
|
|
1700
1729
|
const privateAccess = value.privateAccess === "all" ? "all" : "approved";
|
|
1701
1730
|
const sendMode = value.sendMode === "steer" ? "steer" : "queue";
|
|
1731
|
+
const segmentSupported = typeof props.segmentReplySupported === "boolean"
|
|
1732
|
+
? props.segmentReplySupported
|
|
1733
|
+
: supportsSegmentReply(value.platform);
|
|
1734
|
+
const segmentReply = value.segmentReply === true;
|
|
1702
1735
|
const workspace = items.find((item) => item.path === cwd);
|
|
1703
1736
|
const modelGroups = providers.map((item) => {
|
|
1704
1737
|
const providerName = formatProviderLabel(item.id, item.name || item.id, modelT);
|
|
@@ -1736,6 +1769,27 @@ window.__ModuleLoader__.load({
|
|
|
1736
1769
|
if (typeof props.onChange === "function") props.onChange(patch);
|
|
1737
1770
|
};
|
|
1738
1771
|
|
|
1772
|
+
// 分段间隔手填秒数:失焦时统一校验,不合法就保留草稿并提示,不提交脏值。
|
|
1773
|
+
const parseSegmentSecs = (raw) => {
|
|
1774
|
+
const text = String(raw == null ? "" : raw).trim();
|
|
1775
|
+
if (text === "") return undefined;
|
|
1776
|
+
const parsed = Number(text);
|
|
1777
|
+
if (!Number.isFinite(parsed)) return undefined;
|
|
1778
|
+
return Math.min(60, Math.max(0, Math.round(parsed)));
|
|
1779
|
+
};
|
|
1780
|
+
const commitSegmentGap = () => {
|
|
1781
|
+
const min = parseSegmentSecs(segmentGapMinDraft);
|
|
1782
|
+
const max = parseSegmentSecs(segmentGapMaxDraft);
|
|
1783
|
+
if (min === undefined || max === undefined) { setSegmentGapError(t("account.segmentGapInvalid")); return; }
|
|
1784
|
+
if (max < min) { setSegmentGapError(t("account.segmentGapOrder")); return; }
|
|
1785
|
+
setSegmentGapError("");
|
|
1786
|
+
const patch = {};
|
|
1787
|
+
if (min !== segmentDelayMinSecs) patch.segmentDelayMinSecs = min;
|
|
1788
|
+
if (max !== segmentDelayMaxSecs) patch.segmentDelayMaxSecs = max;
|
|
1789
|
+
if (patch.segmentDelayMinSecs === undefined && patch.segmentDelayMaxSecs === undefined) return;
|
|
1790
|
+
update(patch);
|
|
1791
|
+
};
|
|
1792
|
+
|
|
1739
1793
|
const addWorkspace = (path) => {
|
|
1740
1794
|
const next = (path || "").trim();
|
|
1741
1795
|
if (!next) { setHint(t("error.chooseWorkspace")); return Promise.resolve(); }
|
|
@@ -1788,6 +1842,29 @@ window.__ModuleLoader__.load({
|
|
|
1788
1842
|
picker,
|
|
1789
1843
|
);
|
|
1790
1844
|
|
|
1845
|
+
const segmentReplyTip = t("account.segmentReplyNote");
|
|
1846
|
+
const tipAnchor = h("span", {
|
|
1847
|
+
className: "ima-label-tip",
|
|
1848
|
+
title: HostTooltip ? undefined : segmentReplyTip,
|
|
1849
|
+
"aria-label": segmentReplyTip,
|
|
1850
|
+
role: "button",
|
|
1851
|
+
tabIndex: 0,
|
|
1852
|
+
style: {
|
|
1853
|
+
display: "inline-flex",
|
|
1854
|
+
alignItems: "center",
|
|
1855
|
+
cursor: "help",
|
|
1856
|
+
color: "var(--dsw-alias-label-tertiary, var(--ima-muted))",
|
|
1857
|
+
marginLeft: 2,
|
|
1858
|
+
},
|
|
1859
|
+
}, h(IconInfoOutline, { size: 12 }));
|
|
1860
|
+
|
|
1861
|
+
const segmentReplyLabel = h("span", { style: { display: "inline-flex", alignItems: "center", gap: 4 } },
|
|
1862
|
+
h("span", null, t("account.segmentReply")),
|
|
1863
|
+
HostTooltip
|
|
1864
|
+
? h(HostTooltip, { label: segmentReplyTip, portal: true, side: "top" }, tipAnchor)
|
|
1865
|
+
: tipAnchor,
|
|
1866
|
+
);
|
|
1867
|
+
|
|
1791
1868
|
return h("div", { className: "ima-account-settings" + (props.compact ? " compact" : "") },
|
|
1792
1869
|
field("workspace", props.workspaceLabel || t("account.workspace"), items.length === 0
|
|
1793
1870
|
? h("div", null,
|
|
@@ -1876,8 +1953,51 @@ window.__ModuleLoader__.load({
|
|
|
1876
1953
|
],
|
|
1877
1954
|
onChange: (next) => update({ sendMode: next }),
|
|
1878
1955
|
})),
|
|
1879
|
-
|
|
1956
|
+
segmentSupported && field("segmentReply", segmentReplyLabel, h(Select, {
|
|
1957
|
+
className: "ima-account-picker",
|
|
1958
|
+
value: segmentReply ? "segmented" : "full",
|
|
1959
|
+
"aria-label": t("account.segmentReply"),
|
|
1960
|
+
options: [
|
|
1961
|
+
{ value: "full", label: t("account.segmentFull") },
|
|
1962
|
+
{ value: "segmented", label: t("account.segmentSplit") },
|
|
1963
|
+
],
|
|
1964
|
+
onChange: (next) => update({ segmentReply: next === "segmented" }),
|
|
1965
|
+
})),
|
|
1880
1966
|
sendMode === "steer" && h("div", { className: "ima-picker-note" }, t("account.sendSteerNote")),
|
|
1967
|
+
segmentSupported && segmentReply && field("segmentGap", t("account.segmentGap"), h("div", { className: "ima-segment-gap" },
|
|
1968
|
+
h(Input, {
|
|
1969
|
+
type: "number",
|
|
1970
|
+
min: 0,
|
|
1971
|
+
max: 60,
|
|
1972
|
+
step: 1,
|
|
1973
|
+
inputMode: "numeric",
|
|
1974
|
+
className: "ima-segment-gap-input",
|
|
1975
|
+
value: segmentGapMinDraft,
|
|
1976
|
+
placeholder: "1",
|
|
1977
|
+
"aria-label": t("account.segmentGapMin"),
|
|
1978
|
+
onChange: (event) => { setSegmentGapMinDraft(event.target.value); setSegmentGapError(""); },
|
|
1979
|
+
onBlur: commitSegmentGap,
|
|
1980
|
+
onKeyDown: (event) => { if (event.key === "Enter") event.currentTarget.blur(); },
|
|
1981
|
+
}),
|
|
1982
|
+
h("span", { className: "ima-segment-gap-sep" }, "~"),
|
|
1983
|
+
h(Input, {
|
|
1984
|
+
type: "number",
|
|
1985
|
+
min: 0,
|
|
1986
|
+
max: 60,
|
|
1987
|
+
step: 1,
|
|
1988
|
+
inputMode: "numeric",
|
|
1989
|
+
className: "ima-segment-gap-input",
|
|
1990
|
+
value: segmentGapMaxDraft,
|
|
1991
|
+
placeholder: "2",
|
|
1992
|
+
"aria-label": t("account.segmentGapMax"),
|
|
1993
|
+
onChange: (event) => { setSegmentGapMaxDraft(event.target.value); setSegmentGapError(""); },
|
|
1994
|
+
onBlur: commitSegmentGap,
|
|
1995
|
+
onKeyDown: (event) => { if (event.key === "Enter") event.currentTarget.blur(); },
|
|
1996
|
+
}),
|
|
1997
|
+
h("span", { className: "ima-segment-gap-unit" }, t("account.seconds")),
|
|
1998
|
+
)),
|
|
1999
|
+
segmentSupported && segmentReply && segmentGapError && h("div", { className: "ima-picker-note warning" }, segmentGapError),
|
|
2000
|
+
segmentSupported && segmentReply && h("div", { className: "ima-picker-note" }, t("account.segmentGapNote")),
|
|
1881
2001
|
privateAccess === "all" && h("div", { className: "ima-picker-note warning" }, t("settings.publicChatNotice")),
|
|
1882
2002
|
hint && h("div", { className: "ima-picker-note" }, hint),
|
|
1883
2003
|
props.showAutoNameNote && h("div", { className: "ima-picker-note" }, t("account.autoNameNote")),
|
|
@@ -1985,7 +2105,7 @@ window.__ModuleLoader__.load({
|
|
|
1985
2105
|
setDraft(account);
|
|
1986
2106
|
setProxyModeDraft(account.proxyMode || "inherit");
|
|
1987
2107
|
setNote("");
|
|
1988
|
-
}, [account.id, account.cwd, account.permission, account.agentPreset, account.privateAccess, account.sendMode, account.proxyMode, account.proxyConfigured, JSON.stringify(account.commandPermissions), account.receiveEnabled, account.assistant && account.assistant.provider, account.assistant && account.assistant.model, account.assistant && account.assistant.reasoningEffort]);
|
|
2108
|
+
}, [account.id, account.cwd, account.permission, account.agentPreset, account.privateAccess, account.sendMode, account.segmentReply, account.segmentDelayMinSecs, account.segmentDelayMaxSecs, account.proxyMode, account.proxyConfigured, JSON.stringify(account.commandPermissions), account.receiveEnabled, account.assistant && account.assistant.provider, account.assistant && account.assistant.model, account.assistant && account.assistant.reasoningEffort]);
|
|
1989
2109
|
useEffect(() => {
|
|
1990
2110
|
setProxyUrlDraft(account.proxyUrl || "");
|
|
1991
2111
|
}, [account.id, account.proxyUrl]);
|
|
@@ -2004,6 +2124,9 @@ window.__ModuleLoader__.load({
|
|
|
2004
2124
|
permission: next.permission,
|
|
2005
2125
|
privateAccess: next.privateAccess,
|
|
2006
2126
|
sendMode: next.sendMode,
|
|
2127
|
+
segmentReply: next.segmentReply === true,
|
|
2128
|
+
segmentDelayMinSecs: next.segmentDelayMinSecs,
|
|
2129
|
+
segmentDelayMaxSecs: next.segmentDelayMaxSecs,
|
|
2007
2130
|
agentPreset: next.agentPreset,
|
|
2008
2131
|
commandPermissions: next.commandPermissions,
|
|
2009
2132
|
};
|
|
@@ -2054,6 +2177,7 @@ window.__ModuleLoader__.load({
|
|
|
2054
2177
|
h(AccountSettingsPicker, {
|
|
2055
2178
|
value: draft,
|
|
2056
2179
|
onChange: applySettings,
|
|
2180
|
+
segmentReplySupported: account.segmentReplySupported !== false,
|
|
2057
2181
|
catalog,
|
|
2058
2182
|
permissions,
|
|
2059
2183
|
agentPresets,
|
|
@@ -2735,15 +2859,6 @@ window.__ModuleLoader__.load({
|
|
|
2735
2859
|
return css;
|
|
2736
2860
|
}
|
|
2737
2861
|
|
|
2738
|
-
let settingsNavIconMaskValue;
|
|
2739
|
-
/** 设置导航图标:用宿主 IconQueueOutline 的几何生成 mask,保持皮肤安全。 */
|
|
2740
|
-
function settingsNavIconMask() {
|
|
2741
|
-
if (settingsNavIconMaskValue !== undefined) return settingsNavIconMaskValue;
|
|
2742
|
-
const markup = channelMarkup(h(IconQueueOutline, { size: 16 })).split("currentColor").join("#000");
|
|
2743
|
-
settingsNavIconMaskValue = `url("data:image/svg+xml,${encodeURIComponent(markup)}")`;
|
|
2744
|
-
return settingsNavIconMaskValue;
|
|
2745
|
-
}
|
|
2746
|
-
|
|
2747
2862
|
/**
|
|
2748
2863
|
* 官方视图选项菜单没有扩展位,注入第四个分组项「按频道」。
|
|
2749
2864
|
* 只在频道页签挂载期间生效。
|
|
@@ -3506,6 +3621,9 @@ window.__ModuleLoader__.load({
|
|
|
3506
3621
|
onToggleOnlineUpdate,
|
|
3507
3622
|
onlineUpdateDisabled,
|
|
3508
3623
|
onlineUpdateLocked = false,
|
|
3624
|
+
taskTreeSessionsEnabled = false,
|
|
3625
|
+
onToggleTaskTreeSessions,
|
|
3626
|
+
taskTreeSessionsDisabled = false,
|
|
3509
3627
|
} = props;
|
|
3510
3628
|
|
|
3511
3629
|
const SwitchComponent = PrimitiveSwitch || Switch;
|
|
@@ -3544,6 +3662,23 @@ window.__ModuleLoader__.load({
|
|
|
3544
3662
|
);
|
|
3545
3663
|
}
|
|
3546
3664
|
|
|
3665
|
+
if (typeof onToggleTaskTreeSessions === "function") {
|
|
3666
|
+
rows.push(
|
|
3667
|
+
h("div", { key: "task-tree-sessions", className: "ima-bundle-row" },
|
|
3668
|
+
h("div", { className: "ima-bundle-label-box" },
|
|
3669
|
+
h("span", { className: "ima-bundle-title" }, t("taskTreeSessions.entry.title")),
|
|
3670
|
+
h("span", { className: "ima-bundle-desc" }, t("taskTreeSessions.entry.desc"))
|
|
3671
|
+
),
|
|
3672
|
+
h(SwitchComponent, {
|
|
3673
|
+
checked: taskTreeSessionsEnabled,
|
|
3674
|
+
onChange: onToggleTaskTreeSessions,
|
|
3675
|
+
label: t("taskTreeSessions.entry.toggle"),
|
|
3676
|
+
disabled: taskTreeSessionsDisabled,
|
|
3677
|
+
})
|
|
3678
|
+
)
|
|
3679
|
+
);
|
|
3680
|
+
}
|
|
3681
|
+
|
|
3547
3682
|
return h(React.Fragment, null, rows);
|
|
3548
3683
|
}
|
|
3549
3684
|
|
|
@@ -3551,8 +3686,10 @@ window.__ModuleLoader__.load({
|
|
|
3551
3686
|
const [enabled, setEnabled] = useState(props.getEnabled);
|
|
3552
3687
|
const [onlineUpdateEnabled, setOnlineUpdateEnabled] = useState(props.getOnlineUpdateEnabled ? props.getOnlineUpdateEnabled : () => true);
|
|
3553
3688
|
const [onlineUpdateLocked, setOnlineUpdateLocked] = useState(props.getOnlineUpdateLocked ? props.getOnlineUpdateLocked : () => false);
|
|
3689
|
+
const [taskTreeSessionsEnabled, setTaskTreeSessionsEnabled] = useState(props.getTaskTreeSessionsEnabled ? props.getTaskTreeSessionsEnabled : () => false);
|
|
3554
3690
|
const [savingSidebar, setSavingSidebar] = useState(false);
|
|
3555
3691
|
const [savingUpdate, setSavingUpdate] = useState(false);
|
|
3692
|
+
const [savingTaskTreeSessions, setSavingTaskTreeSessions] = useState(false);
|
|
3556
3693
|
|
|
3557
3694
|
useEffect(() => {
|
|
3558
3695
|
setEnabled(props.getEnabled());
|
|
@@ -3562,6 +3699,9 @@ window.__ModuleLoader__.load({
|
|
|
3562
3699
|
if (props.getOnlineUpdateLocked) {
|
|
3563
3700
|
setOnlineUpdateLocked(props.getOnlineUpdateLocked());
|
|
3564
3701
|
}
|
|
3702
|
+
if (props.getTaskTreeSessionsEnabled) {
|
|
3703
|
+
setTaskTreeSessionsEnabled(props.getTaskTreeSessionsEnabled());
|
|
3704
|
+
}
|
|
3565
3705
|
return props.subscribe(() => {
|
|
3566
3706
|
setEnabled(props.getEnabled());
|
|
3567
3707
|
if (props.getOnlineUpdateEnabled) {
|
|
@@ -3570,6 +3710,9 @@ window.__ModuleLoader__.load({
|
|
|
3570
3710
|
if (props.getOnlineUpdateLocked) {
|
|
3571
3711
|
setOnlineUpdateLocked(props.getOnlineUpdateLocked());
|
|
3572
3712
|
}
|
|
3713
|
+
if (props.getTaskTreeSessionsEnabled) {
|
|
3714
|
+
setTaskTreeSessionsEnabled(props.getTaskTreeSessionsEnabled());
|
|
3715
|
+
}
|
|
3573
3716
|
});
|
|
3574
3717
|
}, [props]);
|
|
3575
3718
|
|
|
@@ -3596,6 +3739,18 @@ window.__ModuleLoader__.load({
|
|
|
3596
3739
|
});
|
|
3597
3740
|
} : undefined;
|
|
3598
3741
|
|
|
3742
|
+
const onToggleTaskTreeSessions = props.setTaskTreeSessions ? (next) => {
|
|
3743
|
+
setSavingTaskTreeSessions(true);
|
|
3744
|
+
setTaskTreeSessionsEnabled(next);
|
|
3745
|
+
props.setTaskTreeSessions(next).catch(() => {
|
|
3746
|
+
if (props.getTaskTreeSessionsEnabled) {
|
|
3747
|
+
setTaskTreeSessionsEnabled(props.getTaskTreeSessionsEnabled());
|
|
3748
|
+
}
|
|
3749
|
+
}).finally(() => {
|
|
3750
|
+
setSavingTaskTreeSessions(false);
|
|
3751
|
+
});
|
|
3752
|
+
} : undefined;
|
|
3753
|
+
|
|
3599
3754
|
return h(ImBundleConfigCard, {
|
|
3600
3755
|
t: props.t,
|
|
3601
3756
|
enabled,
|
|
@@ -3605,9 +3760,14 @@ window.__ModuleLoader__.load({
|
|
|
3605
3760
|
onlineUpdateDisabled: savingUpdate,
|
|
3606
3761
|
onlineUpdateLocked,
|
|
3607
3762
|
onToggleOnlineUpdate,
|
|
3763
|
+
taskTreeSessionsEnabled,
|
|
3764
|
+
taskTreeSessionsDisabled: savingTaskTreeSessions,
|
|
3765
|
+
onToggleTaskTreeSessions,
|
|
3608
3766
|
});
|
|
3609
3767
|
}
|
|
3610
3768
|
|
|
3769
|
+
const STORAGE_KEY_TASK_TREE_SESSIONS = "dsh-im-connect.task-tree-sessions";
|
|
3770
|
+
|
|
3611
3771
|
function setupSidebarEntry(ctx, options) {
|
|
3612
3772
|
if (!ctx.locale) {
|
|
3613
3773
|
return {
|
|
@@ -3615,7 +3775,10 @@ window.__ModuleLoader__.load({
|
|
|
3615
3775
|
isSupported: () => false,
|
|
3616
3776
|
setEnabled: async () => false,
|
|
3617
3777
|
isOnlineUpdateEnabled: () => true,
|
|
3778
|
+
isOnlineUpdateLocked: () => false,
|
|
3618
3779
|
setOnlineUpdate: async () => false,
|
|
3780
|
+
isTaskTreeSessionsEnabled: () => false,
|
|
3781
|
+
setTaskTreeSessions: async () => false,
|
|
3619
3782
|
destroy: () => {},
|
|
3620
3783
|
};
|
|
3621
3784
|
}
|
|
@@ -3757,6 +3920,62 @@ window.__ModuleLoader__.load({
|
|
|
3757
3920
|
})
|
|
3758
3921
|
.catch(() => {});
|
|
3759
3922
|
|
|
3923
|
+
let taskTreeSessionsEnabled = (() => {
|
|
3924
|
+
try {
|
|
3925
|
+
return localStorage.getItem(STORAGE_KEY_TASK_TREE_SESSIONS) === "true";
|
|
3926
|
+
} catch {
|
|
3927
|
+
return false;
|
|
3928
|
+
}
|
|
3929
|
+
})();
|
|
3930
|
+
let taskTreeEpoch = 0;
|
|
3931
|
+
|
|
3932
|
+
const setTaskTreeSessions = async (next) => {
|
|
3933
|
+
const currentEpoch = ++taskTreeEpoch;
|
|
3934
|
+
taskTreeSessionsEnabled = next;
|
|
3935
|
+
try {
|
|
3936
|
+
localStorage.setItem(STORAGE_KEY_TASK_TREE_SESSIONS, next ? "true" : "false");
|
|
3937
|
+
} catch {}
|
|
3938
|
+
notify();
|
|
3939
|
+
if (typeof options.onTaskTreeSessionsChange === "function") {
|
|
3940
|
+
try { options.onTaskTreeSessionsChange(next); } catch {}
|
|
3941
|
+
}
|
|
3942
|
+
try {
|
|
3943
|
+
await callApi("/task-tree-sessions", {
|
|
3944
|
+
method: "POST",
|
|
3945
|
+
body: JSON.stringify({ enabled: next }),
|
|
3946
|
+
});
|
|
3947
|
+
return next;
|
|
3948
|
+
} catch (err) {
|
|
3949
|
+
if (currentEpoch === taskTreeEpoch) {
|
|
3950
|
+
taskTreeSessionsEnabled = !next;
|
|
3951
|
+
try {
|
|
3952
|
+
localStorage.setItem(STORAGE_KEY_TASK_TREE_SESSIONS, (!next) ? "true" : "false");
|
|
3953
|
+
} catch {}
|
|
3954
|
+
notify();
|
|
3955
|
+
if (typeof options.onTaskTreeSessionsChange === "function") {
|
|
3956
|
+
try { options.onTaskTreeSessionsChange(!next); } catch {}
|
|
3957
|
+
}
|
|
3958
|
+
}
|
|
3959
|
+
throw err;
|
|
3960
|
+
}
|
|
3961
|
+
};
|
|
3962
|
+
|
|
3963
|
+
const loadTaskTreeEpoch = taskTreeEpoch;
|
|
3964
|
+
callApi("/task-tree-sessions")
|
|
3965
|
+
.then((res) => {
|
|
3966
|
+
if (taskTreeEpoch === loadTaskTreeEpoch && res && typeof res.enabled === "boolean") {
|
|
3967
|
+
taskTreeSessionsEnabled = res.enabled;
|
|
3968
|
+
try {
|
|
3969
|
+
localStorage.setItem(STORAGE_KEY_TASK_TREE_SESSIONS, res.enabled ? "true" : "false");
|
|
3970
|
+
} catch {}
|
|
3971
|
+
notify();
|
|
3972
|
+
if (typeof options.onTaskTreeSessionsChange === "function") {
|
|
3973
|
+
try { options.onTaskTreeSessionsChange(taskTreeSessionsEnabled); } catch {}
|
|
3974
|
+
}
|
|
3975
|
+
}
|
|
3976
|
+
})
|
|
3977
|
+
.catch(() => {});
|
|
3978
|
+
|
|
3760
3979
|
if (typeof ctx.inject === "function") {
|
|
3761
3980
|
ctx.inject(["layout"], (scoped) => {
|
|
3762
3981
|
layoutService = scoped.layout;
|
|
@@ -3782,6 +4001,8 @@ window.__ModuleLoader__.load({
|
|
|
3782
4001
|
getOnlineUpdateEnabled: () => onlineUpdateEnabled,
|
|
3783
4002
|
getOnlineUpdateLocked: () => onlineUpdateLocked,
|
|
3784
4003
|
setOnlineUpdate: setOnlineUpdate,
|
|
4004
|
+
getTaskTreeSessionsEnabled: () => taskTreeSessionsEnabled,
|
|
4005
|
+
setTaskTreeSessions: setTaskTreeSessions,
|
|
3785
4006
|
subscribe: (fn) => {
|
|
3786
4007
|
listeners.add(fn);
|
|
3787
4008
|
return () => { listeners.delete(fn); };
|
|
@@ -3797,6 +4018,8 @@ window.__ModuleLoader__.load({
|
|
|
3797
4018
|
isOnlineUpdateEnabled: () => onlineUpdateEnabled,
|
|
3798
4019
|
isOnlineUpdateLocked: () => onlineUpdateLocked,
|
|
3799
4020
|
setOnlineUpdate,
|
|
4021
|
+
isTaskTreeSessionsEnabled: () => taskTreeSessionsEnabled,
|
|
4022
|
+
setTaskTreeSessions,
|
|
3800
4023
|
destroy: () => {
|
|
3801
4024
|
listeners.clear();
|
|
3802
4025
|
if (offRow) {
|
|
@@ -3846,6 +4069,7 @@ window.__ModuleLoader__.load({
|
|
|
3846
4069
|
const permissionT = ctx.locale.bind("permission.access");
|
|
3847
4070
|
const modelT = ctx.locale.bind("model");
|
|
3848
4071
|
const presetT = ctx.locale.bind("settings.agentPreset");
|
|
4072
|
+
let syncActiveTaskTreeFilter = () => {};
|
|
3849
4073
|
const sidebarController = setupSidebarEntry(ctx, {
|
|
3850
4074
|
callApi: api,
|
|
3851
4075
|
renderPanel: (ownerProps) => h(LocalizedSettingsPage, ownerProps),
|
|
@@ -3860,6 +4084,9 @@ window.__ModuleLoader__.load({
|
|
|
3860
4084
|
onOnlineUpdateChange: () => {
|
|
3861
4085
|
if (typeof window !== "undefined") window.dispatchEvent(new CustomEvent("ima-update-toggle"));
|
|
3862
4086
|
},
|
|
4087
|
+
onTaskTreeSessionsChange: () => {
|
|
4088
|
+
syncActiveTaskTreeFilter();
|
|
4089
|
+
},
|
|
3863
4090
|
});
|
|
3864
4091
|
ctx.effect(() => () => sidebarController.destroy(), "im-connect: sidebar entry");
|
|
3865
4092
|
ctx.effect(() => observePluginUpdate({
|
|
@@ -3916,19 +4143,51 @@ window.__ModuleLoader__.load({
|
|
|
3916
4143
|
};
|
|
3917
4144
|
|
|
3918
4145
|
const NAV_ICON_MARKER = "data-ima-nav-icon";
|
|
3919
|
-
const NAV_ROW_SELECTOR = '[role="dialog"] nav button';
|
|
4146
|
+
const NAV_ROW_SELECTOR = '[role="dialog"] nav button, [data-shortcut-modal="settings"] nav button';
|
|
4147
|
+
const NAV_ICON_STYLE_ID = "ima-settings-nav-icon-style";
|
|
4148
|
+
const KNOWN_NAV_LABELS = new Set(["im助理", "imassistant"]);
|
|
4149
|
+
|
|
4150
|
+
const QUEUE_ICON_PATHS = '<path d="M5 6.75H11"/><path d="M5 9H8"/><path d="M2.37067 11.2497C1.5872 9.89252 1.32042 8.29798 1.61945 6.7597C1.91847 5.22141 2.76317 3.84293 3.99801 2.87809C5.23285 1.91325 6.7747 1.427 8.33964 1.50888C9.90458 1.59076 11.3873 2.23526 12.5147 3.32369C13.6422 4.41232 14.3384 5.8717 14.4751 7.43304C14.6118 8.99438 14.1797 10.5525 13.2585 11.8205C12.3372 13.0885 10.9889 13.9809 9.4617 14.3334C8.18666 14.6277 6.8587 14.529 5.64964 14.0601C5.17095 13.8745 4.76937 13.4929 4.26509 13.3963C3.67389 13.2832 2.95232 13.5595 2.0377 14.3334"/>';
|
|
4151
|
+
const QUEUE_ICON_SVG = `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" fill="none" stroke="black" stroke-width="1.3" stroke-linecap="round" stroke-linejoin="round">${QUEUE_ICON_PATHS}</svg>`;
|
|
4152
|
+
const QUEUE_ICON_MASK = `url("data:image/svg+xml,${encodeURIComponent(QUEUE_ICON_SVG)}")`;
|
|
4153
|
+
|
|
4154
|
+
const NAV_ICON_CSS = `[${NAV_ICON_MARKER}]>svg{display:none!important}[${NAV_ICON_MARKER}]::before{content:'';flex:none;width:16px;height:16px;background-color:currentColor;-webkit-mask:${QUEUE_ICON_MASK} center/contain no-repeat;mask:${QUEUE_ICON_MASK} center/contain no-repeat;-webkit-mask-repeat:no-repeat;mask-repeat:no-repeat;-webkit-mask-position:center;mask-position:center;-webkit-mask-size:16px 16px;mask-size:16px 16px}`;
|
|
4155
|
+
|
|
4156
|
+
function ensureNavIconStyle(doc) {
|
|
4157
|
+
const targetDoc = doc || (typeof document !== "undefined" ? document : null);
|
|
4158
|
+
if (!targetDoc || typeof targetDoc.getElementById !== "function") return;
|
|
4159
|
+
if (targetDoc.getElementById(NAV_ICON_STYLE_ID) !== null) return;
|
|
4160
|
+
const style = typeof targetDoc.createElement === "function" ? targetDoc.createElement("style") : null;
|
|
4161
|
+
if (!style) return;
|
|
4162
|
+
style.id = NAV_ICON_STYLE_ID;
|
|
4163
|
+
style.textContent = NAV_ICON_CSS;
|
|
4164
|
+
const targetParent = targetDoc.head ?? targetDoc.documentElement;
|
|
4165
|
+
if (targetParent && typeof targetParent.appendChild === "function") {
|
|
4166
|
+
targetParent.appendChild(style);
|
|
4167
|
+
}
|
|
4168
|
+
}
|
|
4169
|
+
|
|
4170
|
+
function getNavButtonText(button) {
|
|
4171
|
+
if (!button) return "";
|
|
4172
|
+
const span = typeof button.querySelector === "function" ? button.querySelector("span") : null;
|
|
4173
|
+
const label = span && span.textContent ? span.textContent : button.textContent;
|
|
4174
|
+
return String(label ?? "").trim();
|
|
4175
|
+
}
|
|
3920
4176
|
|
|
3921
4177
|
function isOwnNavRow(rowText, wantedLabel) {
|
|
3922
|
-
const
|
|
3923
|
-
if (
|
|
3924
|
-
const
|
|
3925
|
-
|
|
4178
|
+
const normRow = String(rowText ?? "").replace(/\s+/g, "").toLowerCase();
|
|
4179
|
+
if (normRow.length === 0) return false;
|
|
4180
|
+
const normWanted = String(wantedLabel ?? "").replace(/\s+/g, "").toLowerCase();
|
|
4181
|
+
if (normWanted.length > 0 && normWanted !== "settings.label" && !KNOWN_NAV_LABELS.has(normWanted)) {
|
|
4182
|
+
return false;
|
|
4183
|
+
}
|
|
4184
|
+
if (KNOWN_NAV_LABELS.has(normRow)) return true;
|
|
4185
|
+
return normWanted.length > 0 && normRow === normWanted;
|
|
3926
4186
|
}
|
|
3927
4187
|
|
|
3928
4188
|
function applySettingsNavIcon(button, wantedLabel) {
|
|
3929
|
-
const isOwn = isOwnNavRow(button
|
|
4189
|
+
const isOwn = isOwnNavRow(getNavButtonText(button), typeof wantedLabel === "function" ? wantedLabel() : wantedLabel);
|
|
3930
4190
|
if (isOwn) {
|
|
3931
|
-
button.style.setProperty("--ima-nav-icon-mask", settingsNavIconMask());
|
|
3932
4191
|
if (button.getAttribute(NAV_ICON_MARKER) === "") return false;
|
|
3933
4192
|
button.setAttribute(NAV_ICON_MARKER, "");
|
|
3934
4193
|
return true;
|
|
@@ -3948,6 +4207,7 @@ window.__ModuleLoader__.load({
|
|
|
3948
4207
|
|
|
3949
4208
|
function installSettingsNavIcon(targetCtx, resolveLabel) {
|
|
3950
4209
|
if (typeof document === "undefined") return;
|
|
4210
|
+
ensureNavIconStyle(document);
|
|
3951
4211
|
targetCtx.effect(() => {
|
|
3952
4212
|
let disposed = false;
|
|
3953
4213
|
let scheduled = false;
|
|
@@ -3955,6 +4215,7 @@ window.__ModuleLoader__.load({
|
|
|
3955
4215
|
const sync = () => {
|
|
3956
4216
|
scheduled = false;
|
|
3957
4217
|
if (disposed) return;
|
|
4218
|
+
ensureNavIconStyle(document);
|
|
3958
4219
|
for (const row of document.querySelectorAll(NAV_ROW_SELECTOR)) {
|
|
3959
4220
|
applySettingsNavIcon(row, resolveLabel);
|
|
3960
4221
|
}
|
|
@@ -3967,8 +4228,9 @@ window.__ModuleLoader__.load({
|
|
|
3967
4228
|
};
|
|
3968
4229
|
|
|
3969
4230
|
sync();
|
|
4231
|
+
const targetRoot = document.documentElement || document.body;
|
|
3970
4232
|
const observer = new MutationObserver(schedule);
|
|
3971
|
-
observer.observe(
|
|
4233
|
+
observer.observe(targetRoot, { childList: true, subtree: true, characterData: true });
|
|
3972
4234
|
|
|
3973
4235
|
return () => {
|
|
3974
4236
|
disposed = true;
|
|
@@ -4032,11 +4294,59 @@ window.__ModuleLoader__.load({
|
|
|
4032
4294
|
let ownedRegistry = null;
|
|
4033
4295
|
let removeInsertedTab = () => {};
|
|
4034
4296
|
let removeInsertedOpener = () => {};
|
|
4297
|
+
let removeInsertedFilter = () => {};
|
|
4298
|
+
let activeFilterRegistry = null;
|
|
4299
|
+
let filterInstalled = false;
|
|
4300
|
+
let warnedUnsupportedFilter = false;
|
|
4035
4301
|
let stopInsertedTabLocale = () => {};
|
|
4036
4302
|
let insertedTabRegistry = null;
|
|
4037
4303
|
let syncing = false;
|
|
4038
4304
|
// 与定时插件共享通知,补足直接替换 component 不触发宿主插槽通知的情况。
|
|
4039
4305
|
const notifyPeers = () => { queueMicrotask(() => window.dispatchEvent(new Event("dsh-native-sidebar-change"))); };
|
|
4306
|
+
const clearFilter = () => {
|
|
4307
|
+
if (filterInstalled) {
|
|
4308
|
+
removeInsertedFilter();
|
|
4309
|
+
removeInsertedFilter = () => {};
|
|
4310
|
+
filterInstalled = false;
|
|
4311
|
+
}
|
|
4312
|
+
warnedUnsupportedFilter = false;
|
|
4313
|
+
};
|
|
4314
|
+
const ensureFilter = (registry) => {
|
|
4315
|
+
if (registry !== activeFilterRegistry) {
|
|
4316
|
+
clearFilter();
|
|
4317
|
+
activeFilterRegistry = registry;
|
|
4318
|
+
}
|
|
4319
|
+
if (!registry) {
|
|
4320
|
+
clearFilter();
|
|
4321
|
+
return;
|
|
4322
|
+
}
|
|
4323
|
+
const showSessions = typeof sidebarController !== "undefined"
|
|
4324
|
+
&& sidebarController
|
|
4325
|
+
&& typeof sidebarController.isTaskTreeSessionsEnabled === "function"
|
|
4326
|
+
? sidebarController.isTaskTreeSessionsEnabled()
|
|
4327
|
+
: false;
|
|
4328
|
+
if (showSessions) {
|
|
4329
|
+
clearFilter();
|
|
4330
|
+
return;
|
|
4331
|
+
}
|
|
4332
|
+
if (!filterInstalled) {
|
|
4333
|
+
if (typeof registry.addSessionFilter === "function") {
|
|
4334
|
+
const dispose = registry.addSessionFilter((sessionId) => {
|
|
4335
|
+
return !isChannelSession(sessionId);
|
|
4336
|
+
});
|
|
4337
|
+
removeInsertedFilter = () => {
|
|
4338
|
+
dispose();
|
|
4339
|
+
};
|
|
4340
|
+
filterInstalled = true;
|
|
4341
|
+
} else if (!warnedUnsupportedFilter) {
|
|
4342
|
+
warnedUnsupportedFilter = true;
|
|
4343
|
+
console.warn("[dsh-im-connect] 外壳注册表未支持 addSessionFilter 协议,无法在任务树过滤会话");
|
|
4344
|
+
}
|
|
4345
|
+
}
|
|
4346
|
+
};
|
|
4347
|
+
syncActiveTaskTreeFilter = () => {
|
|
4348
|
+
ensureFilter(insertedTabRegistry || ownedRegistry);
|
|
4349
|
+
};
|
|
4040
4350
|
const installSessionOpener = (registry) => {
|
|
4041
4351
|
if (!registry || typeof registry.addSessionOpener !== "function") return () => {};
|
|
4042
4352
|
if (registry.sessionOpeners && registry.sessionOpeners.some((item) => item.id === "im-connect")) return () => {};
|
|
@@ -4059,10 +4369,13 @@ window.__ModuleLoader__.load({
|
|
|
4059
4369
|
removeInsertedTab = () => {};
|
|
4060
4370
|
removeInsertedOpener();
|
|
4061
4371
|
removeInsertedOpener = () => {};
|
|
4372
|
+
clearFilter();
|
|
4062
4373
|
insertedTabRegistry = null;
|
|
4063
4374
|
};
|
|
4064
4375
|
const unwrap = () => {
|
|
4065
4376
|
clearInsertedTab();
|
|
4377
|
+
clearFilter();
|
|
4378
|
+
activeFilterRegistry = null;
|
|
4066
4379
|
if (wrappedEntry) {
|
|
4067
4380
|
if (originalComp && wrappedEntry.component === ownedWrapper) wrappedEntry.component = originalComp;
|
|
4068
4381
|
if (wrappedEntry.__dshNativeTabs === ownedRegistry) delete wrappedEntry.__dshNativeTabs;
|
|
@@ -4081,6 +4394,7 @@ window.__ModuleLoader__.load({
|
|
|
4081
4394
|
insertedTabRegistry = registry;
|
|
4082
4395
|
removeInsertedOpener = installSessionOpener(registry);
|
|
4083
4396
|
}
|
|
4397
|
+
ensureFilter(registry);
|
|
4084
4398
|
if (registry.getTabs().some((item) => item.id === "channels")) return true;
|
|
4085
4399
|
const refreshInsertedTab = () => {
|
|
4086
4400
|
removeInsertedTab = registry.insert({
|
|
@@ -4134,6 +4448,7 @@ window.__ModuleLoader__.load({
|
|
|
4134
4448
|
const registry = createNativeTabRegistry(originalComp);
|
|
4135
4449
|
ownedRegistry = registry;
|
|
4136
4450
|
removeInsertedOpener = installSessionOpener(registry);
|
|
4451
|
+
ensureFilter(registry);
|
|
4137
4452
|
const tree = originalComp;
|
|
4138
4453
|
attachNativeTabRegistry(official, registry);
|
|
4139
4454
|
function DshNativeTabWorkspaceShell(innerProps) {
|
|
@@ -4168,7 +4483,14 @@ window.__ModuleLoader__.load({
|
|
|
4168
4483
|
sync();
|
|
4169
4484
|
if (insertedTabRegistry || ++retries >= 20) window.clearInterval(retryTimer);
|
|
4170
4485
|
}, 250);
|
|
4171
|
-
return () => {
|
|
4486
|
+
return () => {
|
|
4487
|
+
syncActiveTaskTreeFilter = () => {};
|
|
4488
|
+
window.clearInterval(retryTimer);
|
|
4489
|
+
unsub();
|
|
4490
|
+
unsubSidebar();
|
|
4491
|
+
window.removeEventListener("dsh-native-sidebar-change", sync);
|
|
4492
|
+
unwrap();
|
|
4493
|
+
};
|
|
4172
4494
|
});
|
|
4173
4495
|
}
|
|
4174
4496
|
|