@michengai/dsh-im-connect 1.0.20 → 1.0.22

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.
Files changed (39) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/CHANGELOG.zh-CN.md +16 -0
  3. package/README.md +18 -10
  4. package/README.zh-CN.md +18 -10
  5. package/client.js +198 -34
  6. package/lib/client.js +198 -34
  7. package/lib/engine/command-messages.d.ts +3 -0
  8. package/lib/engine/command-messages.d.ts.map +1 -1
  9. package/lib/engine/command-messages.js +3 -0
  10. package/lib/engine/command-messages.js.map +1 -1
  11. package/lib/engine/file-delivery.d.ts +1 -3
  12. package/lib/engine/file-delivery.d.ts.map +1 -1
  13. package/lib/engine/file-delivery.js +2 -51
  14. package/lib/engine/file-delivery.js.map +1 -1
  15. package/lib/engine/gateway.d.ts +9 -0
  16. package/lib/engine/gateway.d.ts.map +1 -1
  17. package/lib/engine/gateway.js +44 -0
  18. package/lib/engine/gateway.js.map +1 -1
  19. package/lib/engine/router.d.ts +21 -0
  20. package/lib/engine/router.d.ts.map +1 -1
  21. package/lib/engine/router.js +36 -0
  22. package/lib/engine/router.js.map +1 -1
  23. package/lib/engine/session-id.d.ts +2 -0
  24. package/lib/engine/session-id.d.ts.map +1 -1
  25. package/lib/engine/session-id.js.map +1 -1
  26. package/lib/engine/types.d.ts +2 -0
  27. package/lib/engine/types.d.ts.map +1 -1
  28. package/lib/manager.d.ts +7 -0
  29. package/lib/manager.d.ts.map +1 -1
  30. package/lib/manager.js +57 -11
  31. package/lib/manager.js.map +1 -1
  32. package/package.json +1 -1
  33. package/src/engine/command-messages.ts +4 -0
  34. package/src/engine/file-delivery.ts +2 -34
  35. package/src/engine/gateway.ts +43 -0
  36. package/src/engine/router.ts +43 -0
  37. package/src/engine/session-id.ts +2 -0
  38. package/src/engine/types.ts +2 -0
  39. package/src/manager.ts +66 -12
package/CHANGELOG.md CHANGED
@@ -1,5 +1,21 @@
1
1
  # Changelog
2
2
 
3
+ ## 1.0.22 - 2026-11-03
4
+
5
+ - File delivery now sends only what the assistant explicitly delivers (#54): previously, any file the assistant touched (a memory note, a config edit, a log write) could be treated as this turn's output and pushed into the chat, which is especially awkward in group conversations. Only files the assistant declares as deliverables are returned now; ordinary file writes, code edits and state files no longer appear in chat.
6
+ - Upgrade note: if you relied on "the assistant writes a file and it arrives automatically", ask the assistant to deliver that file explicitly. `/export` for session logs is unaffected.
7
+ - New three-way entry location setting: the plugin details page switch became "Entry location" with Both / Sidebar only / Settings only, applied immediately without a reload. The default stays "Settings only", matching the previous behavior; accounts that had the sidebar entry enabled carry over to Both and keep their icon.
8
+ - In "Sidebar only" mode the duplicated **Settings → IM Assistant** tab is no longer shown and configuration happens in the sidebar panel; switch back to Both on the plugin details page to bring the settings tab back.
9
+ - Accessibility hardening: the new control now carries the identifiers and accessible names the host primitive requires, so screen readers announce the control and its three options.
10
+ - Documentation: both READMEs now describe the entry location states, its default value, and the file-delivery rule as implemented.
11
+
12
+ ## 1.0.21 - 2026-10-30
13
+
14
+ - Add idle session auto-rotation: After a long pause in conversation, incoming messages can automatically start a fresh session, preventing previous conversation context from polluting new topics; previous sessions are preserved in history and can be resumed anytime via `/sessions` (PR #52).
15
+ - Per-account configuration: Added an "Idle session rotation" dropdown right below "Send mode" in each account's settings modal, supporting customizable thresholds (30 min, 1 hr, 2 hrs, 6 hrs, 12 hrs, 24 hrs, or Disabled); existing accounts default to Disabled to preserve original behavior.
16
+ - Running task safety protection: Sessions currently executing tasks are never interrupted or rotated, ensuring follow-up instructions for long tasks remain in the same context; slash commands such as `/sessions`, `/workspace`, and `/help` automatically refresh activity timing.
17
+ - Account settings UI polish: Removed redundant explanatory text beneath the segmented reply interval inputs, cleanly aligning the two-column settings form for a more compact layout.
18
+
3
19
  ## 1.0.20 - 2026-10-29
4
20
 
5
21
  - Fix missing settings navigation icon in latest DSH Alpha Web host: Eliminate dynamic React rendering and `<use>` sprite references, resolving an issue where browser SVG Data URL security sandboxing produced a 100% transparent mask.
@@ -4,6 +4,22 @@
4
4
 
5
5
  以下记录近期发布的版本。Git 标签与 GitHub Release 现已和这些条目同步;历史条目继续保留原始发布提交链接。
6
6
 
7
+ ## 1.0.22 - 2026-11-03
8
+
9
+ - 文件回传改为只发助手明确交付的文件(#54):以前助手只要改动了文件(例如写记忆、改配置、记录日志)就会把该文件当成本轮产出发到聊天里,群聊中往往还有其他成员;现在只有助手明确声明「这是本轮要交付的文件」才会回传,普通写文件、改代码、写状态文件都不再出现在聊天里。
10
+ - 升级提示:若你以前依赖「助手写了文件就自动发过来」,请让助手明确交付该文件;`/export` 导出会话日志不受影响。
11
+ - 新增入口位置三态设置:插件详情页的「侧边栏入口」开关升级为「入口展示位置」,可在「全部展示 / 仅侧边栏 / 仅设置」之间切换,改完即时生效无需刷新。默认仍是「仅设置」,与升级前行为一致;原本开启过侧边栏入口的账号会沿用到「全部展示」,不会丢图标。
12
+ - 「仅侧边栏」模式下不再重复显示「设置 → IM助理」页签,配置从侧栏面板进入;想找回设置页签时在插件详情页切回「全部展示」即可。
13
+ - 无障碍补强:新的三态控件补齐了宿主原语要求的标识与可访问名称,读屏器能正确读出控件名与三个选项。
14
+ - 文档同步:中英文 README 的入口位置说明、默认值与文件回传规则已按当前行为更新。
15
+
16
+ ## 1.0.21 - 2026-10-30
17
+
18
+ - 新增空闲超时自动新开会话功能:长时间未交流后再次发送新消息,助手可自动开启全新会话,避免旧会话上下文与新话题混杂;旧会话仍完好保留在历史中,随时可用 `/sessions` 命令切换找回(PR #52)。
19
+ - 支持账号独立配置:在账号「设置」弹窗中的「发送方式」下方新增「空闲新开会话」选项,支持按需配置超时时长(30分钟、1小时、2小时、6小时、12小时、24小时或关闭),各账号互不干扰;存量账号默认保持关闭,行为与以前完全一致。
20
+ - 会话安全保护机制:当旧会话当前正在执行任务时绝不切断或轮换,确保长任务的追问与补充要求仍在原会话中继续;执行 `/sessions`、`/workspace`、`/help` 等命令交互会自动刷新活跃计时。
21
+ - 账号设置界面优化:移除分段发送间隔输入框下方冗余的通栏文字,使表单双列网格自然对齐,界面更整洁紧凑。
22
+
7
23
  ## 1.0.20 - 2026-10-29
8
24
 
9
25
  - 修复最新 DSH Alpha Web 宿主下设置导航图标空白问题:彻底移除运行时 React 动态渲染与 `<use>` 隐式引用,解决独立 SVG Data URL 遮罩受浏览器跨文档安全沙箱限制导致图标 100% 透明空白的根因。
package/README.md CHANGED
@@ -103,8 +103,8 @@ WeChat, WeCom, DingTalk, Feishu, Lark, QQ, Telegram, Discord, and Slack accept o
103
103
 
104
104
  WeChat, WeCom, DingTalk, Feishu, Lark, QQ, Telegram, Discord, and Slack can return files produced by the assistant. For example: “Create a PDF report and send me the file.”
105
105
 
106
- - Files successfully created or edited with Chat's supported file tools are sent after the reply. On hosts with `present`, explicitly presented files are also sent, including existing files.
107
- - File access follows Chat: files outside the workspace are allowed when the host can read them. The plugin does not extract arbitrary paths from reply text. Files created through shell commands need to be presented explicitly.
106
+ - Aligned with DSH Host delivery contracts: when the assistant explicitly declares deliverables via `tool-present` (`deliverables/presented`), the corresponding files are returned as chat attachments. Ordinary low-level tool mutations (such as editing code or writing state files) are not sent automatically, preventing chat noise and credential leakage.
107
+ - File access follows Chat: files outside the workspace are allowed when the host can read them. The plugin does not extract arbitrary paths from reply text. Files created through shell commands or scripts need to be presented explicitly by the assistant.
108
108
  - Supported hosts use Chat's complete-file download service and its configured size limit. Directories and symbolic links are not sent; channel-specific file limits still apply.
109
109
  - A failed transfer produces a message naming the file and does not stop the remaining files. Switching away from the session or stopping the account prevents pending delivery from continuing to a different target.
110
110
  - Send `/export` as a standalone command to receive the current linked session’s Chat ZIP logs in this chat, without child sessions. The ZIP limit is 32 MiB; channel limits also apply. If the file is too large or cannot be sent, use `/export` in web Chat. Paths and other session IDs are not accepted.
@@ -239,15 +239,15 @@ The configuration output should contain `im-connect`. Restart DSH Web and hard-r
239
239
  The plugin follows standard DSH bundle configuration conventions. Options are located at:
240
240
  > **Sidebar → Plugins → Click `@michengai/dsh-im-connect`** (the host's `plugins.bundle.config` slot).
241
241
 
242
- Three native switches are available. Their values are persisted in `channels.json` under the plugin's `stateDir` and survive restarts; they are not equivalent Cordis YAML options. `sidebarEntry` and `taskTreeSessions` are managed through this UI, while `onlineUpdate` is also subject to the host lock described below:
242
+ Native configuration options are provided here. Their values are persisted in `channels.json` under the plugin's `stateDir` and survive restarts; they are not equivalent Cordis YAML options. `location` and `taskTreeSessions` are managed through this UI, while `onlineUpdate` is also subject to the host lock described below:
243
243
 
244
- ### 1. Sidebar Entry (`sidebarEntry`)
245
- - **Default**: Disabled (`false`)
246
- - **Description**: Displays a persistent **IM Connect** navigation icon in the host's left primary sidebar.
247
- - **Effect**:
248
- - When enabled, clicking the sidebar icon opens the IM Assistant management page directly in the primary workspace with a **960px centered container** (matching host plugin manager conventions). This eliminates vertical scrolling constraints in narrow settings dialogs;
249
- - When disabled, unregisters the sidebar entry cleanly (and resets active panel gracefully if currently viewing the panel, preventing blank views);
250
- - The standard **Settings → IM Assistant** view remains active either way, and state is synchronized live across both entry points.
244
+ ### 1. Entry Location (`location`)
245
+ - **Default**: Settings only (`settings`)
246
+ - **Description**: Controls where the IM Assistant management page is displayed in the host navigation, supporting three states (matching host bundle entry conventions):
247
+ - **Both (`both`)**: Displays a persistent icon in the left primary sidebar and retains the entry in **Settings → IM Assistant**;
248
+ - **Sidebar only (`sidebar`)**: Displays only the sidebar icon, omitting the global settings entry;
249
+ - **Settings only (`settings`)**: Unregisters the sidebar icon (gracefully switching active views if currently open) and retains only the entry in **Settings → IM Assistant**.
250
+ - **Effect**: Clicking the sidebar icon opens the IM Assistant management page directly in the primary workspace with a **960px centered container** (matching host plugin manager conventions). This eliminates vertical scrolling constraints in narrow settings dialogs; state is synchronized live across both entry points.
251
251
 
252
252
  ### 2. Online Updates (`onlineUpdate` / `updater`)
253
253
  - **Default**: Enabled (`true`)
@@ -322,6 +322,14 @@ When **Segmented replies** is set to Send in segments for an account, the assist
322
322
  - **Separator**: set by the plugin configuration `segmentMarker`, default `<<<MSG>>>`, and must occupy its own line. The same text inside a fenced code block never splits a reply, so code samples stay intact.
323
323
  - **Where it is stored**: the toggle and range live per account in `channels.json`; the plugin configuration `segmentReply` acts as the default for every account, with the account setting taking precedence. If one segment fails to send, the rest stop instead of resending the whole reply, so no duplicate messages.
324
324
 
325
+ ### Idle session rotation
326
+
327
+ Groups and DMs bind one session per chat, so a message after a long pause easily continues the previous topic. Configure **Idle session rotation** right below Send mode in account settings; when more than that many minutes passed since the last user message, the next message starts a new session with a single notice in the chat. The previous session is kept and `/sessions` can switch back. The default is Disabled (keep session).
328
+
329
+ - A session that is still running is never rotated, so follow-up instructions for a long task stay in the same context; the switch happens before the next message is submitted.
330
+ - The timer is stored per chat as `lastInboundAt` in `sessions.json` and keeps counting across restarts; explicit `/new`, `/session`, and `/workspace` are unaffected.
331
+ - Configurable per account in settings (30 min, 1 hr, 2 hrs, 6 hrs, 12 hrs, 24 hrs, or Disabled).
332
+
325
333
  ### Connecting Slack
326
334
 
327
335
  Slack uses a Socket Mode long connection, so no public URL or request URL is required:
package/README.zh-CN.md CHANGED
@@ -105,8 +105,8 @@
105
105
 
106
106
  微信、企业微信、钉钉、飞书、Lark、QQ、Telegram、Discord 和 Slack 均可回传助手产出的文件。例如:“整理成 PDF 报告,并把文件发给我。”
107
107
 
108
- - 使用 Chat 支持的文件工具成功新建或修改的文件,会在回复后发送;宿主支持 `present` 时,也会发送明确交付的文件,包括已有文件。
109
- - 文件访问范围与 Chat 一致,允许宿主可读取的工作区外文件。不从回复正文中猜测文件路径;通过脚本等方式生成的文件,需要助手明确 `present` 交付。
108
+ - 遵循 DSH 宿主交付契约:当助手通过 `tool-present`(`deliverables/presented`)显式声明交付时,对应文件将作为附件发到聊天中;底层的普通工具写操作(如修改代码、记录状态文件)不会被自动当作产物发送,防止群聊噪音与隐私泄露。
109
+ - 文件访问范围与 Chat 一致,允许宿主可读取的工作区外文件。不从回复正文中猜测文件路径;通过脚本等方式生成的文件,由助手明确 `present` 交付。
110
110
  - 已支持的宿主使用 Chat 完整文件下载服务及其配置的大小上限。目录和符号链接不发送,渠道自身的文件限制仍然适用。
111
111
  - 单个文件发送失败会明确提示文件名,并继续处理其他文件;切走会话或停止账号后,不会把尚未投递的文件转发到其他聊天。
112
112
  - 单独发送 `/export`,可将当前聊天绑定会话的 Chat ZIP 日志发回当前聊天(不含子会话)。ZIP 上限为 32 MiB,渠道自身限制仍适用;超限或发送失败时可在网页 Chat 使用 `/export` 下载。不接受路径或其他会话 ID 参数。
@@ -239,15 +239,15 @@ dsh --profile web --dump-config
239
239
  插件遵循 DSH 官方扩展配置规范,配置项位于:
240
240
  > **主界面侧边栏「插件」→ 点击 `@michengai/dsh-im-connect` 详情页**(对应宿主 `plugins.bundle.config` 槽位)。
241
241
 
242
- 此处提供三个原生扁平行开关。界面开关值保存在插件 `stateDir` 下的 `channels.json` 中,重启后保留;它们不是等价的 Cordis YAML 配置项。`sidebarEntry` 和 `taskTreeSessions` 只通过此界面管理,`onlineUpdate` 另受下述宿主锁定规则约束:
242
+ 此处提供原生配置项。界面配置值保存在插件 `stateDir` 下的 `channels.json` 中,重启后保留;它们不是等价的 Cordis YAML 配置项。`location` 和 `taskTreeSessions` 只通过此界面管理,`onlineUpdate` 另受下述宿主锁定规则约束:
243
243
 
244
- ### 1. 侧边栏入口 (`sidebarEntry`)
245
- - **默认状态**:关闭(`false`)
246
- - **功能说明**:在宿主左侧主导航栏增加常驻的 **「即时通讯」** 图标入口。
247
- - **生效效果**:
248
- - 开启后,在侧边栏点击即可直达 IM 助理中心,并在主工作区以 **960px 居中版心**(对齐官方插件管理与市场规范)展开完整大面板,彻底告别在设置弹窗狭窄视口内滚动的局限;
249
- - 关闭后安全注销侧栏槽位(若当前正停留在 IM 面板,会自动安全切回默认视图,防止悬空和白屏);
250
- - 无论是否开启侧栏入口,DSH 原有的「设置 → IM助理」入口始终保留,两处界面数据与状态 100% 实时同步。
244
+ ### 1. 入口位置 (`location`)
245
+ - **默认状态**:仅设置(`settings`)
246
+ - **功能说明**:控制 IM 管理面板在宿主中的导航入口展示位置,支持三态切换(对齐官方扩展入口规范):
247
+ - **全部展示 (`both`)**:同时在左侧侧边栏常驻图标并在「设置 → IM助理」保留入口;
248
+ - **仅侧边栏 (`sidebar`)**:仅在左侧主导航栏显示图标入口,不在全局设置侧栏中显示;
249
+ - **仅设置 (`settings`)**:注销侧边栏图标(若当前正停留在 IM 面板,会自动安全切回默认视图,防止悬空和白屏),仅在「设置 → IM助理」保留入口。
250
+ - **生效效果**:在侧边栏点击即可直达 IM 助理中心,并在主工作区以 **960px 居中版心**(对齐官方插件管理与市场规范)展开完整大面板,彻底告别在设置弹窗狭窄视口内滚动的局限;两处入口数据与状态 100% 实时同步。
251
251
 
252
252
  ### 2. 在线更新 (`onlineUpdate` / `updater`)
253
253
  - **默认状态**:开启(`true`)
@@ -316,6 +316,14 @@ Telegram 话题默认使用第一条非兜底会话标题自动命名一次,
316
316
  - **分隔标记**:由插件配置 `segmentMarker` 指定,默认 `<<<MSG>>>`,必须独占一行;围栏代码块里的同名标记不会触发分段,代码示例不会被拆散。
317
317
  - **配置位置**:开关和间隔按账号保存在 `channels.json`;插件配置 `segmentReply` 可作为所有账号的默认值,账号设置优先。分段发送中途失败就停止,不整条重发,避免重复消息。
318
318
 
319
+ ### 空闲新开会话
320
+
321
+ 群聊和私聊都按「聊天」绑定会话,隔了很久再说话容易接着上一个话题。在账号设置里的「发送方式」下方配置「空闲新开会话」,距上一条用户消息超过该时间后,下一条消息会新开一个会话,并在聊天里提示一次;旧会话照常保留,用 `/sessions` 可以切回。缺省为关闭(保持原会话),行为与以前一致。
322
+
323
+ - 旧会话仍在运行时不切换,避免把长任务的补充指令切进新上下文;切换发生在下一条消息提交之前。
324
+ - 计时按聊天持久化在 `sessions.json` 的 `lastInboundAt`,重启后继续累计;`/new`、`/session`、`/workspace` 等手动命令不受影响。
325
+ - 支持在账号设置弹窗中直接选择:30 分钟、1 小时、2 小时、6 小时、12 小时、24 小时或关闭。
326
+
319
327
  ### Slack 接入步骤
320
328
 
321
329
  Slack 走 Socket Mode 长连接,不需要公网地址,也不用配置请求网址:
package/client.js CHANGED
@@ -16,6 +16,7 @@ window.__ModuleLoader__.load({
16
16
  const HostSegmentedTabs = primitives.SegmentedTabs;
17
17
  const HostTooltip = primitives.Tooltip;
18
18
  const PrimitiveSwitch = primitives.Switch;
19
+ const PrimitiveSegmentedControl = primitives.SegmentedControl;
19
20
  // 宿主 Button 由 forwardRef 包成对象,typeof 是 object,不是 function。
20
21
  function isHostComponent(component) {
21
22
  return typeof component === "function" || (!!component && typeof component === "object" && typeof component.render === "function");
@@ -615,11 +616,12 @@ window.__ModuleLoader__.load({
615
616
  "connection.next.connected": "可在原聊天发送消息验证收发;私聊仍需符合准入设置。", "connection.next.connecting": "请稍后再次检查;等待扫码时请完成手机确认。", "connection.next.reconnecting": "渠道正在尝试恢复,请稍后再次检查。", "connection.next.disconnected": "请重新连接;需要扫码的渠道可重新添加绑定。", "connection.next.stopped": "请点击重新连接以启动账号。", "connection.next.error": "请尝试重新连接;仍有异常时查看本机日志。", "connection.next.unknown": "暂时无法确认状态,请稍后再检查或查看本机日志。",
616
617
  "settings.label": "IM助理", "settings.title": "IM助理", "settings.description": "管理各渠道账号。每个账号独立选择工作区、模型和权限,配置仅保存在本机。", "settings.viewProject": "GitHub", "settings.feedback": "问题反馈",
617
618
  "sidebar.entry.title": "侧边栏入口", "sidebar.entry.desc": "在侧栏显示即时通讯管理入口。设置里的入口不变。", "sidebar.entry.toggle": "切换侧边栏入口",
619
+ "entry.location.title": "入口展示位置", "entry.location.desc": "选择即时通信功能在界面上的显示入口(侧边栏或设置页面)", "entry.location.both": "全部显示", "entry.location.sidebar": "仅侧边栏", "entry.location.settings": "仅设置",
618
620
  "update.entry.title": "在线更新", "update.entry.desc": "允许检查并在线安装即时通讯插件的新版本。关闭后隐藏更新入口。", "update.entry.toggle": "切换在线更新", "error.update.disabled": "在线更新已被禁用",
619
621
  "taskTreeSessions.entry.title": "在任务树显示 IM 会话", "taskTreeSessions.entry.desc": "在官方工作区任务树中显示各渠道会话。关闭后仅在侧栏「频道」页签中显示", "taskTreeSessions.entry.toggle": "切换在任务树显示 IM 会话",
620
622
  "settings.aria": "IM助理", "settings.publicChatNotice": "未批准用户可以发起聊天,但不能批准工具调用。", "pending.notice": "有访问请求。批准后该用户才能驱动本机助手。", "action.approve": "批准", "action.deny": "拒绝", "loading": "加载中…",
621
623
  "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}",
624
+ "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.sessionIdle": "空闲新开会话", "account.sessionIdleOff": "关闭(保持原会话)", "account.sessionIdleMin": "{n} 分钟", "account.sessionIdleHour": "{n} 小时", "account.sessionIdleHours": "{n} 小时", "account.sessionIdleNote": "距上一条消息超过该时间后再收到新消息,将开启新会话;旧会话仍可用 /sessions 找回。设为 0 表示关闭。", "account.segmentReply": "分段回复", "account.segmentFull": "完整发送", "account.segmentSplit": "分段发送", "account.segmentReplyNote": "选择分段发送时助手会把一次回复拆成多条短消息,在分隔标记处切开逐条发送;完整发送时仍是一条完整回复。", "account.segmentGap": "发送间隔", "account.segmentGapMin": "最小间隔", "account.segmentGapMax": "最大间隔", "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}",
623
625
  "account.remark": "名称备注", "account.remarkNote": "只在本机设置页区分账号,留空恢复自动名称。", "account.rename": "修改名称备注",
624
626
  "account.count": "{count} 个账号", "account.statusProcessing": "处理中…", "account.statusNotConnected": "未连接", "account.receive": "接收消息", "account.receiveDescription": "关闭后保留账号配置,但不接收新消息", "account.removeConfirm": "确定移除这个账号?本机保存的配置和凭据将一并删除。",
625
627
  "action.addAccount": "添加账号", "action.generateQr": "生成二维码", "action.checkConnection": "诊断连接", "action.reconnectAccount": "重新连接", "action.removeAccount": "移除接入", "status.saving": "保存中…", "status.saved": "已保存",
@@ -647,11 +649,12 @@ window.__ModuleLoader__.load({
647
649
  "connection.next.connected": "Send a message in the original chat to verify delivery. Private chats still follow access settings.", "connection.next.connecting": "Check again shortly. Complete confirmation on your phone if a QR scan is pending.", "connection.next.reconnecting": "The channel is attempting to recover. Check again shortly.", "connection.next.disconnected": "Reconnect the account. QR channels may need to be added again.", "connection.next.stopped": "Select Reconnect to start the account.", "connection.next.error": "Try reconnecting. If the issue persists, check the local logs.", "connection.next.unknown": "The current state could not be confirmed. Check again later or inspect the local logs.",
648
650
  "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",
649
651
  "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",
652
+ "entry.location.title": "Entry location", "entry.location.desc": "Choose where IM Connect is displayed (sidebar or Settings page)", "entry.location.both": "Both", "entry.location.sidebar": "Sidebar only", "entry.location.settings": "Settings only",
650
653
  "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
654
  "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",
652
655
  "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…",
653
656
  "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}",
657
+ "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.sessionIdle": "Idle session rotation", "account.sessionIdleOff": "Disabled (keep session)", "account.sessionIdleMin": "{n} min", "account.sessionIdleHour": "{n} hr", "account.sessionIdleHours": "{n} hrs", "account.sessionIdleNote": "Start a new session when the next message arrives after this idle period; previous sessions remain accessible via /sessions. Set to 0 to disable.", "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.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}",
655
658
  "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",
656
659
  "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.",
657
660
  "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",
@@ -1865,6 +1868,49 @@ window.__ModuleLoader__.load({
1865
1868
  : tipAnchor,
1866
1869
  );
1867
1870
 
1871
+ const sessionIdleMinutes = Number.isFinite(value.sessionIdleMinutes) ? Math.max(0, Math.round(value.sessionIdleMinutes)) : 0;
1872
+ const sessionIdleTip = t("account.sessionIdleNote");
1873
+ const sessionIdleTipAnchor = h("span", {
1874
+ className: "ima-label-tip",
1875
+ title: HostTooltip ? undefined : sessionIdleTip,
1876
+ "aria-label": sessionIdleTip,
1877
+ role: "button",
1878
+ tabIndex: 0,
1879
+ style: {
1880
+ display: "inline-flex",
1881
+ alignItems: "center",
1882
+ cursor: "help",
1883
+ color: "var(--dsw-alias-label-tertiary, var(--ima-muted))",
1884
+ marginLeft: 2,
1885
+ },
1886
+ }, h(IconInfoOutline, { size: 12 }));
1887
+
1888
+ const sessionIdleLabel = h("span", { style: { display: "inline-flex", alignItems: "center", gap: 4 } },
1889
+ h("span", null, t("account.sessionIdle")),
1890
+ HostTooltip
1891
+ ? h(HostTooltip, { label: sessionIdleTip, portal: true, side: "top" }, sessionIdleTipAnchor)
1892
+ : sessionIdleTipAnchor,
1893
+ );
1894
+
1895
+ const standardIdlePresets = [0, 30, 60, 120, 360, 720, 1440];
1896
+ const sessionIdleOptions = standardIdlePresets.map((mins) => {
1897
+ if (mins === 0) return { value: "0", label: t("account.sessionIdleOff") };
1898
+ if (mins < 60) return { value: String(mins), label: t("account.sessionIdleMin", { n: mins }) };
1899
+ const hours = mins / 60;
1900
+ return {
1901
+ value: String(mins),
1902
+ label: hours === 1 ? t("account.sessionIdleHour", { n: hours }) : t("account.sessionIdleHours", { n: hours }),
1903
+ };
1904
+ });
1905
+ if (sessionIdleMinutes > 0 && !standardIdlePresets.includes(sessionIdleMinutes)) {
1906
+ sessionIdleOptions.splice(1, 0, {
1907
+ value: String(sessionIdleMinutes),
1908
+ label: sessionIdleMinutes % 60 === 0
1909
+ ? t("account.sessionIdleHours", { n: sessionIdleMinutes / 60 })
1910
+ : t("account.sessionIdleMin", { n: sessionIdleMinutes }),
1911
+ });
1912
+ }
1913
+
1868
1914
  return h("div", { className: "ima-account-settings" + (props.compact ? " compact" : "") },
1869
1915
  field("workspace", props.workspaceLabel || t("account.workspace"), items.length === 0
1870
1916
  ? h("div", null,
@@ -1953,6 +1999,13 @@ window.__ModuleLoader__.load({
1953
1999
  ],
1954
2000
  onChange: (next) => update({ sendMode: next }),
1955
2001
  })),
2002
+ field("sessionIdle", sessionIdleLabel, h(Select, {
2003
+ className: "ima-account-picker",
2004
+ value: String(sessionIdleMinutes),
2005
+ "aria-label": t("account.sessionIdle"),
2006
+ options: sessionIdleOptions,
2007
+ onChange: (next) => update({ sessionIdleMinutes: Number(next) }),
2008
+ })),
1956
2009
  segmentSupported && field("segmentReply", segmentReplyLabel, h(Select, {
1957
2010
  className: "ima-account-picker",
1958
2011
  value: segmentReply ? "segmented" : "full",
@@ -1997,7 +2050,6 @@ window.__ModuleLoader__.load({
1997
2050
  h("span", { className: "ima-segment-gap-unit" }, t("account.seconds")),
1998
2051
  )),
1999
2052
  segmentSupported && segmentReply && segmentGapError && h("div", { className: "ima-picker-note warning" }, segmentGapError),
2000
- segmentSupported && segmentReply && h("div", { className: "ima-picker-note" }, t("account.segmentGapNote")),
2001
2053
  privateAccess === "all" && h("div", { className: "ima-picker-note warning" }, t("settings.publicChatNotice")),
2002
2054
  hint && h("div", { className: "ima-picker-note" }, hint),
2003
2055
  props.showAutoNameNote && h("div", { className: "ima-picker-note" }, t("account.autoNameNote")),
@@ -2105,7 +2157,7 @@ window.__ModuleLoader__.load({
2105
2157
  setDraft(account);
2106
2158
  setProxyModeDraft(account.proxyMode || "inherit");
2107
2159
  setNote("");
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]);
2160
+ }, [account.id, account.cwd, account.permission, account.agentPreset, account.privateAccess, account.sendMode, account.sessionIdleMinutes, 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]);
2109
2161
  useEffect(() => {
2110
2162
  setProxyUrlDraft(account.proxyUrl || "");
2111
2163
  }, [account.id, account.proxyUrl]);
@@ -2124,6 +2176,7 @@ window.__ModuleLoader__.load({
2124
2176
  permission: next.permission,
2125
2177
  privateAccess: next.privateAccess,
2126
2178
  sendMode: next.sendMode,
2179
+ sessionIdleMinutes: Number.isFinite(next.sessionIdleMinutes) ? Math.max(0, Math.round(next.sessionIdleMinutes)) : 0,
2127
2180
  segmentReply: next.segmentReply === true,
2128
2181
  segmentDelayMinSecs: next.segmentDelayMinSecs,
2129
2182
  segmentDelayMaxSecs: next.segmentDelayMaxSecs,
@@ -3617,6 +3670,8 @@ window.__ModuleLoader__.load({
3617
3670
  enabled,
3618
3671
  onToggle,
3619
3672
  disabled,
3673
+ location,
3674
+ onLocationChange,
3620
3675
  onlineUpdateEnabled = true,
3621
3676
  onToggleOnlineUpdate,
3622
3677
  onlineUpdateDisabled,
@@ -3627,19 +3682,48 @@ window.__ModuleLoader__.load({
3627
3682
  } = props;
3628
3683
 
3629
3684
  const SwitchComponent = PrimitiveSwitch || Switch;
3685
+ const SegmentedControlComponent = PrimitiveSegmentedControl;
3686
+ const currentLocation = location || (enabled ? 'both' : 'settings');
3687
+ const locationOptions = [
3688
+ { label: t("entry.location.both"), value: "both" },
3689
+ { label: t("entry.location.sidebar"), value: "sidebar" },
3690
+ { label: t("entry.location.settings"), value: "settings" },
3691
+ ];
3692
+
3630
3693
  const rows = [
3631
- h("div", { key: "sidebar-entry", className: "ima-bundle-row" },
3632
- h("div", { className: "ima-bundle-label-box" },
3633
- h("span", { className: "ima-bundle-title" }, t("sidebar.entry.title")),
3634
- h("span", { className: "ima-bundle-desc" }, t("sidebar.entry.desc"))
3635
- ),
3636
- h(SwitchComponent, {
3637
- checked: enabled,
3638
- onChange: onToggle,
3639
- label: t("sidebar.entry.toggle"),
3640
- disabled: disabled,
3641
- })
3642
- ),
3694
+ SegmentedControlComponent
3695
+ ? h("div", { key: "sidebar-entry", className: "ima-bundle-row" },
3696
+ h("div", { className: "ima-bundle-label-box" },
3697
+ h("span", { className: "ima-bundle-title" }, t("entry.location.title")),
3698
+ h("span", { className: "ima-bundle-desc" }, t("entry.location.desc"))
3699
+ ),
3700
+ h(SegmentedControlComponent, {
3701
+ id: "ima-bundle-entry-location",
3702
+ value: currentLocation,
3703
+ options: locationOptions,
3704
+ label: t("entry.location.title"),
3705
+ onChange: (val) => {
3706
+ if (typeof onLocationChange === "function") {
3707
+ onLocationChange(val);
3708
+ } else if (typeof onToggle === "function") {
3709
+ onToggle(val !== "settings");
3710
+ }
3711
+ },
3712
+ disabled: disabled,
3713
+ })
3714
+ )
3715
+ : h("div", { key: "sidebar-entry", className: "ima-bundle-row" },
3716
+ h("div", { className: "ima-bundle-label-box" },
3717
+ h("span", { className: "ima-bundle-title" }, t("sidebar.entry.title")),
3718
+ h("span", { className: "ima-bundle-desc" }, t("sidebar.entry.desc"))
3719
+ ),
3720
+ h(SwitchComponent, {
3721
+ checked: enabled,
3722
+ onChange: onToggle,
3723
+ label: t("sidebar.entry.toggle"),
3724
+ disabled: disabled,
3725
+ })
3726
+ ),
3643
3727
  ];
3644
3728
 
3645
3729
  if (typeof onToggleOnlineUpdate === "function") {
@@ -3683,6 +3767,7 @@ window.__ModuleLoader__.load({
3683
3767
  }
3684
3768
 
3685
3769
  function ImBundleConfigCardWrapper(props) {
3770
+ const [location, setLocation] = useState(props.getLocation ? props.getLocation : () => (props.getEnabled() ? 'both' : 'settings'));
3686
3771
  const [enabled, setEnabled] = useState(props.getEnabled);
3687
3772
  const [onlineUpdateEnabled, setOnlineUpdateEnabled] = useState(props.getOnlineUpdateEnabled ? props.getOnlineUpdateEnabled : () => true);
3688
3773
  const [onlineUpdateLocked, setOnlineUpdateLocked] = useState(props.getOnlineUpdateLocked ? props.getOnlineUpdateLocked : () => false);
@@ -3692,6 +3777,7 @@ window.__ModuleLoader__.load({
3692
3777
  const [savingTaskTreeSessions, setSavingTaskTreeSessions] = useState(false);
3693
3778
 
3694
3779
  useEffect(() => {
3780
+ if (props.getLocation) setLocation(props.getLocation());
3695
3781
  setEnabled(props.getEnabled());
3696
3782
  if (props.getOnlineUpdateEnabled) {
3697
3783
  setOnlineUpdateEnabled(props.getOnlineUpdateEnabled());
@@ -3703,6 +3789,7 @@ window.__ModuleLoader__.load({
3703
3789
  setTaskTreeSessionsEnabled(props.getTaskTreeSessionsEnabled());
3704
3790
  }
3705
3791
  return props.subscribe(() => {
3792
+ if (props.getLocation) setLocation(props.getLocation());
3706
3793
  setEnabled(props.getEnabled());
3707
3794
  if (props.getOnlineUpdateEnabled) {
3708
3795
  setOnlineUpdateEnabled(props.getOnlineUpdateEnabled());
@@ -3716,16 +3803,23 @@ window.__ModuleLoader__.load({
3716
3803
  });
3717
3804
  }, [props]);
3718
3805
 
3719
- const onToggleSidebar = (next) => {
3806
+ const onLocationChange = (next) => {
3720
3807
  setSavingSidebar(true);
3721
- setEnabled(next);
3722
- props.setSidebar(next).catch(() => {
3808
+ setLocation(next);
3809
+ setEnabled(next !== "settings");
3810
+ const p = props.setLocation ? props.setLocation(next) : props.setSidebar(next !== "settings");
3811
+ p.catch(() => {
3812
+ if (props.getLocation) setLocation(props.getLocation());
3723
3813
  setEnabled(props.getEnabled());
3724
3814
  }).finally(() => {
3725
3815
  setSavingSidebar(false);
3726
3816
  });
3727
3817
  };
3728
3818
 
3819
+ const onToggleSidebar = (next) => {
3820
+ onLocationChange(next ? "both" : "settings");
3821
+ };
3822
+
3729
3823
  const onToggleOnlineUpdate = props.setOnlineUpdate ? (next) => {
3730
3824
  if (onlineUpdateLocked) return;
3731
3825
  setSavingUpdate(true);
@@ -3753,6 +3847,8 @@ window.__ModuleLoader__.load({
3753
3847
 
3754
3848
  return h(ImBundleConfigCard, {
3755
3849
  t: props.t,
3850
+ location,
3851
+ onLocationChange,
3756
3852
  enabled,
3757
3853
  disabled: savingSidebar,
3758
3854
  onToggle: onToggleSidebar,
@@ -3783,6 +3879,7 @@ window.__ModuleLoader__.load({
3783
3879
  };
3784
3880
  }
3785
3881
  const { callApi, renderPanel, ns } = options;
3882
+ let entryLocation = "settings";
3786
3883
  let sidebarEntryEnabled = false;
3787
3884
  let sidebarSupported = false;
3788
3885
  let offPanel = null;
@@ -3790,11 +3887,15 @@ window.__ModuleLoader__.load({
3790
3887
  let epoch = 0;
3791
3888
  let layoutService;
3792
3889
  const listeners = new Set();
3890
+ const locationListeners = new Set();
3793
3891
 
3794
3892
  const notify = () => {
3795
3893
  for (const listener of listeners) {
3796
3894
  try { listener(); } catch {}
3797
3895
  }
3896
+ for (const listener of locationListeners) {
3897
+ try { listener(entryLocation); } catch {}
3898
+ }
3798
3899
  };
3799
3900
 
3800
3901
  const sync = () => {
@@ -3840,20 +3941,27 @@ window.__ModuleLoader__.load({
3840
3941
  }
3841
3942
  };
3842
3943
 
3843
- const setEnabled = async (next) => {
3944
+ const setLocation = async (next) => {
3945
+ if (next !== "both" && next !== "sidebar" && next !== "settings") {
3946
+ throw new Error("location must be one of 'both', 'sidebar', or 'settings'");
3947
+ }
3948
+ const prevLocation = entryLocation;
3949
+ const prevEnabled = sidebarEntryEnabled;
3844
3950
  const currentEpoch = ++epoch;
3845
- sidebarEntryEnabled = next;
3951
+ entryLocation = next;
3952
+ sidebarEntryEnabled = next !== "settings";
3846
3953
  sync();
3847
3954
  notify();
3848
3955
  try {
3849
3956
  await callApi("/sidebar-entry", {
3850
3957
  method: "POST",
3851
- body: JSON.stringify({ enabled: next }),
3958
+ body: JSON.stringify({ location: next }),
3852
3959
  });
3853
3960
  return next;
3854
3961
  } catch (err) {
3855
3962
  if (currentEpoch === epoch) {
3856
- sidebarEntryEnabled = !next;
3963
+ entryLocation = prevLocation;
3964
+ sidebarEntryEnabled = prevEnabled;
3857
3965
  sync();
3858
3966
  notify();
3859
3967
  }
@@ -3861,6 +3969,10 @@ window.__ModuleLoader__.load({
3861
3969
  }
3862
3970
  };
3863
3971
 
3972
+ const setEnabled = async (next) => {
3973
+ return (await setLocation(next ? "both" : "settings")) !== "settings";
3974
+ };
3975
+
3864
3976
  let onlineUpdateEnabled = true;
3865
3977
  let onlineUpdateLocked = false;
3866
3978
  let updateEpoch = 0;
@@ -3898,8 +4010,14 @@ window.__ModuleLoader__.load({
3898
4010
  const loadEpoch = epoch;
3899
4011
  callApi("/sidebar-entry")
3900
4012
  .then((res) => {
3901
- if (epoch === loadEpoch && res && typeof res.enabled === "boolean") {
3902
- sidebarEntryEnabled = res.enabled;
4013
+ if (epoch === loadEpoch && res) {
4014
+ if (res.location === "both" || res.location === "sidebar" || res.location === "settings") {
4015
+ entryLocation = res.location;
4016
+ sidebarEntryEnabled = entryLocation !== "settings";
4017
+ } else if (typeof res.enabled === "boolean") {
4018
+ sidebarEntryEnabled = res.enabled;
4019
+ entryLocation = res.enabled ? "both" : "settings";
4020
+ }
3903
4021
  sync();
3904
4022
  notify();
3905
4023
  }
@@ -3996,6 +4114,8 @@ window.__ModuleLoader__.load({
3996
4114
  if (ownerProps && ownerProps.view === "summary") return null;
3997
4115
  return h(ImBundleConfigCardWrapper, {
3998
4116
  t: ctx.locale.bind(ns),
4117
+ getLocation: () => entryLocation,
4118
+ setLocation: setLocation,
3999
4119
  getEnabled: () => sidebarEntryEnabled,
4000
4120
  setSidebar: setEnabled,
4001
4121
  getOnlineUpdateEnabled: () => onlineUpdateEnabled,
@@ -4012,6 +4132,13 @@ window.__ModuleLoader__.load({
4012
4132
  });
4013
4133
 
4014
4134
  return {
4135
+ getLocation: () => entryLocation,
4136
+ setLocation,
4137
+ isSettingsSectionEnabled: () => entryLocation !== "sidebar",
4138
+ onLocationChange: (fn) => {
4139
+ locationListeners.add(fn);
4140
+ return () => { locationListeners.delete(fn); };
4141
+ },
4015
4142
  isEnabled: () => sidebarEntryEnabled,
4016
4143
  isSupported: () => sidebarSupported,
4017
4144
  setEnabled,
@@ -4244,21 +4371,58 @@ window.__ModuleLoader__.load({
4244
4371
 
4245
4372
  installSettingsNavIcon(ctx, () => t("settings.label"));
4246
4373
 
4247
- ctx.slots.inject("settings.section", () => ctx.slots.register({
4374
+ let unregSettings = null;
4375
+ const mountSettingsSection = () => {
4376
+ if (unregSettings) return;
4377
+ const res = (ctx.slots.register({
4248
4378
  name: "settings.section",
4249
4379
  id: "im-assistant",
4250
4380
  order: 40,
4251
4381
  label: () => t("settings.label"),
4252
4382
  icon: "chat",
4253
4383
  locale: IM_LOCALE_NS,
4254
- inject: () => ({
4255
- createWorkspace: typeof ctx.workspaces?.create === "function" ? (input) => ctx.workspaces.create(input) : undefined,
4256
- pickDirectory: () => pickHostDirectory(ctx),
4257
- permissionT,
4258
- modelT,
4259
- presetT,
4260
- }),
4261
- }, LocalizedSettingsPage));
4384
+ inject: () => ({
4385
+ createWorkspace: typeof ctx.workspaces?.create === "function" ? (input) => ctx.workspaces.create(input) : undefined,
4386
+ pickDirectory: () => pickHostDirectory(ctx),
4387
+ permissionT,
4388
+ modelT,
4389
+ presetT,
4390
+ }),
4391
+ }, LocalizedSettingsPage));
4392
+ unregSettings = typeof res === "function" ? res : () => {};
4393
+ };
4394
+
4395
+ const unmountSettingsSection = () => {
4396
+ if (!unregSettings) return;
4397
+ try { unregSettings(); } catch {}
4398
+ unregSettings = null;
4399
+ };
4400
+
4401
+ let settingsSlotInjected = false;
4402
+ const syncSettingsSection = () => {
4403
+ if (!settingsSlotInjected) return;
4404
+ const shouldShow = sidebarController && typeof sidebarController.isSettingsSectionEnabled === "function"
4405
+ ? sidebarController.isSettingsSectionEnabled()
4406
+ : true;
4407
+ if (shouldShow) {
4408
+ mountSettingsSection();
4409
+ } else {
4410
+ unmountSettingsSection();
4411
+ }
4412
+ };
4413
+
4414
+ ctx.slots.inject("settings.section", () => {
4415
+ settingsSlotInjected = true;
4416
+ syncSettingsSection();
4417
+ return () => {
4418
+ unmountSettingsSection();
4419
+ settingsSlotInjected = false;
4420
+ };
4421
+ });
4422
+
4423
+ if (sidebarController && typeof sidebarController.onLocationChange === "function") {
4424
+ sidebarController.onLocationChange(() => syncSettingsSection());
4425
+ }
4262
4426
 
4263
4427
  ctx.slots.inject("sidebar.channels", () => ctx.slots.register({
4264
4428
  name: "sidebar.channels",