@michengai/dsh-im-connect 0.1.49 → 0.1.51

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/lib/client.js CHANGED
@@ -303,7 +303,151 @@ window.__ModuleLoader__.load({
303
303
  const React = require("react");
304
304
  const { useState, useEffect, useLayoutEffect, useCallback, useRef, useSyncExternalStore } = React;
305
305
  const ReactDOM = require("react-dom");
306
- const { RiskConfirmation, IconListPenOutline16, IconRefreshOutline16, IconDownloadOutline16, IconCopyOutline16, IconCloseOutline16 } = require("@deepseek-ai/dsh-client-ui-primitives");
306
+ const primitives = require("@deepseek-ai/dsh-client-ui-primitives");
307
+ const {
308
+ RiskConfirmation,
309
+ Button,
310
+ Menu,
311
+ Modal,
312
+ IconListPenOutline16,
313
+ IconRefreshOutline16,
314
+ IconDownloadOutline16,
315
+ IconCopyOutline16,
316
+ IconCloseOutline16,
317
+ IconEditOutline16,
318
+ IconBranchOutline16,
319
+ IconArchiveOutline20,
320
+ IconTrashOutline16,
321
+ IconEllipsisOutline16,
322
+ } = primitives;
323
+ const HoverCard = primitives.HoverCard;
324
+ const StateDot = primitives.StateDot;
325
+ const IconSettingsOutline16 = primitives.IconSettingsOutline16;
326
+ const ARCHIVE_MANAGER_PLUGIN = "@michengai/dsh-archive-manager";
327
+ function hasArchiveManagerPlugin(root) {
328
+ return !!(root && typeof root.querySelector === "function" && root.querySelector('[data-plugin="' + ARCHIVE_MANAGER_PLUGIN + '"]'));
329
+ }
330
+ function canDeleteChannelSession(archiveManagerInstalled, deleteSession) {
331
+ return archiveManagerInstalled && typeof deleteSession === "function";
332
+ }
333
+ function canArchiveChannelGroup(archiveManagerInstalled, archiveSession) {
334
+ return archiveManagerInstalled && typeof archiveSession === "function";
335
+ }
336
+ async function archiveChannelGroup(sessionIds, archiveSession) {
337
+ for (const sessionId of sessionIds) await archiveSession(sessionId);
338
+ }
339
+ const CHANNEL_SETTINGS_EVENT = "dsh-im-connect:open-channel-settings";
340
+ const CHANNEL_SETTINGS_STORAGE_KEY = "dsh-im-connect:pending-channel-settings";
341
+ const SETTINGS_CODEX_TRIGGER_SELECTOR = "[data-dcu-settings-trigger]";
342
+ const SETTINGS_CODEX_PAGE_SELECTOR = "[data-dcu-settings-page]";
343
+ const SETTINGS_OPEN_SECTION_EVENT = "dcu-settings-open-section";
344
+ function parseChannelSettingsRequest(value) {
345
+ if (!value || typeof value !== "object") return undefined;
346
+ const channelId = typeof value.channelId === "string" ? value.channelId.trim() : "";
347
+ if (!channelId) return undefined;
348
+ return { channelId, name: typeof value.name === "string" ? value.name : "" };
349
+ }
350
+ function writeChannelSettingsRequest(storage, request) {
351
+ try { storage && storage.setItem(CHANNEL_SETTINGS_STORAGE_KEY, JSON.stringify(request)); } catch { /* ignore */ }
352
+ }
353
+ function requestChannelSettings(request) {
354
+ if (typeof window === "undefined") return;
355
+ writeChannelSettingsRequest(window.sessionStorage, request);
356
+ window.dispatchEvent(new CustomEvent(CHANNEL_SETTINGS_EVENT, { detail: request }));
357
+ }
358
+ function readChannelSettingsRequest(storage) {
359
+ if (!storage) return undefined;
360
+ try {
361
+ const raw = storage.getItem(CHANNEL_SETTINGS_STORAGE_KEY);
362
+ return raw == null ? undefined : parseChannelSettingsRequest(JSON.parse(raw));
363
+ } catch { return undefined; }
364
+ }
365
+ function clearChannelSettingsRequest(storage) {
366
+ try { storage && storage.removeItem(CHANNEL_SETTINGS_STORAGE_KEY); } catch { /* ignore */ }
367
+ }
368
+ function resolveChannelSettingsTarget(request, channels) {
369
+ const parsed = parseChannelSettingsRequest(request);
370
+ if (!parsed || !Array.isArray(channels)) return undefined;
371
+ const channel = channels.find((item) => item && item.id === parsed.channelId);
372
+ if (!channel) return undefined;
373
+ const accounts = channel.accounts || [];
374
+ return { channelId: channel.id, accountId: accounts.length === 1 ? accounts[0].id : undefined };
375
+ }
376
+ function pickSettingsSectionButton(buttons, labels) {
377
+ for (const label of labels) {
378
+ const target = String(label || "").trim();
379
+ if (!target) continue;
380
+ const match = buttons.find((button) => String(button.textContent || "").replace(/\s+/g, " ").trim() === target);
381
+ if (match) return match;
382
+ }
383
+ return undefined;
384
+ }
385
+ function pickSettingsLauncher(buttons) {
386
+ const named = buttons.find((button) => {
387
+ const label = `${button.textContent || ""} ${typeof button.getAttribute === "function" ? button.getAttribute("aria-label") || "" : ""}`.trim();
388
+ return /(^|\s)(设置|settings)(\s|$)/i.test(label);
389
+ });
390
+ return named || (buttons.length === 1 ? buttons[0] : undefined);
391
+ }
392
+ function requestCodexSettingsSection(labels) {
393
+ const trigger = typeof document !== "undefined" && document.querySelector(SETTINGS_CODEX_TRIGGER_SELECTOR);
394
+ if (!trigger) return false;
395
+ const request = new CustomEvent(SETTINGS_OPEN_SECTION_EVENT, { detail: { labels: [...labels] }, cancelable: true });
396
+ return !trigger.dispatchEvent(request);
397
+ }
398
+ function openSettingsSection(labels, onSelected, onMissing) {
399
+ if (typeof document === "undefined" || typeof window === "undefined") {
400
+ if (onMissing) onMissing();
401
+ return;
402
+ }
403
+ if (requestCodexSettingsSection(labels)) {
404
+ if (onSelected) onSelected();
405
+ return;
406
+ }
407
+ const launchers = [...document.querySelectorAll('button[aria-haspopup="dialog"]')];
408
+ const launcher = pickSettingsLauncher(launchers);
409
+ const pageTrigger = document.querySelector(SETTINGS_CODEX_TRIGGER_SELECTOR);
410
+ const dialogOpen = document.querySelector('[role="dialog"]') !== null;
411
+ const pageOpen = document.querySelector(SETTINGS_CODEX_PAGE_SELECTOR) !== null;
412
+ if (!dialogOpen && !pageOpen && !launcher && !pageTrigger) {
413
+ if (onMissing) onMissing();
414
+ return;
415
+ }
416
+ if (!dialogOpen && !pageOpen) (pageTrigger || launcher).click();
417
+ let frame;
418
+ let finished = false;
419
+ const observer = new MutationObserver(() => { schedule(); });
420
+ const cleanup = () => {
421
+ if (finished) return;
422
+ finished = true;
423
+ observer.disconnect();
424
+ window.clearTimeout(timeout);
425
+ if (frame !== undefined) window.cancelAnimationFrame(frame);
426
+ };
427
+ const select = () => {
428
+ const buttons = [
429
+ ...document.querySelectorAll('[role="dialog"] nav button'),
430
+ ...document.querySelectorAll(SETTINGS_CODEX_PAGE_SELECTOR + " nav button"),
431
+ ];
432
+ const target = pickSettingsSectionButton(buttons, labels);
433
+ if (!target) return false;
434
+ cleanup();
435
+ target.click();
436
+ if (onSelected) onSelected();
437
+ return true;
438
+ };
439
+ const schedule = () => {
440
+ if (finished || frame !== undefined) return;
441
+ frame = window.requestAnimationFrame(() => { frame = undefined; select(); });
442
+ };
443
+ const timeout = window.setTimeout(() => {
444
+ if (select()) return;
445
+ cleanup();
446
+ if (onMissing) onMissing();
447
+ }, 1500);
448
+ observer.observe(document.body, { childList: true, subtree: true });
449
+ schedule();
450
+ }
307
451
  const EMPTY_EXTRA_TABS = [];
308
452
  const inject = ["slots", "sessions", "workspaces", "locale"];
309
453
  const API_BASE = "/api/dsh-im-connect";
@@ -358,8 +502,9 @@ window.__ModuleLoader__.load({
358
502
  "error.loadAssistant": "无法加载账号配置", "error.noModels": "当前 Host 还没有可用模型,请先在网页里配置提供商", "error.save": "保存失败", "error.chooseWorkspace": "请选择工作区目录", "error.workspaceUnavailable": "当前 Host 无法新增工作区", "error.addWorkspace": "新增工作区失败", "error.load": "加载失败", "error.connection": "无法连接本机 IM 助理接口", "error.request": "请求失败", "error.action": "操作失败", "error.qr": "无法生成二维码", "error.detailsInLog": "操作失败,请查看服务器日志。",
359
503
  "composer.aria": "全局会话配置", "composer.project": "选择项目", "composer.projectAria": "项目", "composer.noWorkspaces": "暂无工作区", "composer.addWorkspace": "添加工作区…", "composer.permission": "权限", "composer.noModels": "暂无模型", "composer.workspacePath": "工作区路径", "action.cancel": "取消", "action.adding": "添加中…",
360
504
  "permission.readOnly": "只读", "permission.workspaceWrite": "工作区写入", "permission.fullAccess": "完全访问",
361
- "rail.workspace": "工作区", "rail.search": "搜索", "rail.searchPlaceholder": "搜索会话...", "rail.clearSearch": "清除搜索", "rail.filter": "筛选", "rail.group": "分组方式", "rail.byWorkspace": "按工作区", "rail.list": "单列表", "rail.sort": "排序方式", "rail.manual": "手动排序", "rail.recent": "最近更新", "rail.running": "运行中", "rail.idle": "空闲", "rail.renameAria": "重命名会话", "rail.rename": "重命名", "rail.fork": "分叉会话", "rail.archive": "归档会话", "rail.archiveFailed": "归档失败,未移除会话。请稍后重试或检查宿主日志。", "rail.empty": "还没有频道会话。先在设置 → IM助理 里连接渠道,并给机器人发一条消息。", "rail.noTasks": "暂无网页任务", "rail.ungrouped": "未分组", "rail.tabsAria": "工作区分类", "rail.tasks": "任务", "rail.channels": "频道",
362
- "time.now": "刚刚", "time.minutes": "{count}分钟前", "time.hours": "{count}小时前", "time.days": "{count}天前",
505
+ "rail.workspace": "工作区", "rail.search": "搜索", "rail.searchPlaceholder": "搜索会话...", "rail.clearSearch": "清除搜索", "rail.filter": "筛选", "rail.group": "分组方式", "rail.byWorkspace": "按工作区", "rail.list": "单列表", "rail.sort": "排序方式", "rail.manual": "手动排序", "rail.recent": "最近更新", "rail.running": "运行中", "rail.idle": "空闲", "rail.renameAria": "重命名会话", "rail.rename": "重命名", "rail.fork": "分叉会话", "rail.archive": "归档会话", "rail.archiveFailed": "归档失败,未移除会话。请稍后重试或检查宿主日志。", "rail.deleteSession": "删除会话", "rail.deleteSessionConfirm": "删除会话", "rail.deleteSessionDescription": "将永久删除会话“{name}”及其子代理(含正在运行的)和全部记录(对话内容、统计、缓存),此操作不可恢复。", "rail.deleteSessionPending": "正在删除会话…", "rail.deleteSessionFailed": "删除会话失败:{message}", "rail.deleteSessionClose": "关闭", "rail.deleteSessionCancel": "取消", "rail.groupActions": "“{name}”的频道操作", "rail.channelSettings": "渠道设置", "rail.archiveGroup": "归档整组会话", "rail.archiveGroupConfirm": "确认归档", "rail.archiveGroupDescription": "将归档“{name}”下的 {count} 个会话。归档后可以在“设置 → 已归档”中恢复。", "rail.archiveGroupPending": "正在归档整组会话…", "rail.archiveGroupFailed": "部分会话归档失败:{message}", "rail.archiveGroupClose": "关闭", "rail.archiveGroupCancel": "取消", "rail.empty": "还没有频道会话。先在设置 → IM助理 里连接渠道,并给机器人发一条消息。", "rail.noTasks": "暂无网页任务", "rail.ungrouped": "未分组", "rail.tabsAria": "工作区分类", "rail.tasks": "任务", "rail.channels": "频道",
506
+ "time.now": "刚刚", "time.minutes": "{n}分钟", "time.hours": "{n}小时", "time.days": "{n}天", "time.months": "{n}个月", "time.years": "{n}年", "time.ago": "{t}前",
507
+ "copy": "复制", "hover.copied": "已复制",
363
508
  "server.unknownChannel": "未知渠道", "server.channelUnconfigured": "渠道未配置", "server.sessionMissing": "会话不存在", "server.accountMissing": "账号不存在", "server.accountConnectFailed": "账号连接失败,请查看本机日志", "server.accountReconnectFailed": "重新连接失败,请查看本机日志", "server.selectAccountSettings": "请选择提供商、模型、工作区或权限", "server.selectModel": "请选择提供商和模型", "server.selectWorkspace": "请选择工作区", "server.selectPermission": "请选择权限", "server.missingCredentials": "凭据不足,无法启动渠道", "server.qrUnsupported": "该渠道不支持扫码绑定", "server.qrExpired": "二维码已过期", "server.qrIncomplete": "扫码未完成", "server.accessDenied": "未授权:请管理员在设置 → IM助理 中批准你的访问。",
364
509
  "status.disconnected": "已断开", "status.reconnectFailed": "重连失败", "status.connectingSocket": "连接中", "status.waitHandshake": "等待网关握手", "status.authenticating": "鉴权中", "status.reconnecting": "重连中", "status.connectionError": "连接错误", "status.connectionFailed": "连接失败", "status.streamConnected": "Stream 已连接", "status.stopped": "已停止", "status.longConnection": "长连接已建立", "status.polling": "轮询中", "status.notLoggedIn": "未登录", "status.waitQr": "等待扫码", "status.loggedIn": "已登录", "status.loggedInRecovered": "已登录(自动恢复)", "status.loggingIn": "登录中",
365
510
  },
@@ -384,8 +529,9 @@ window.__ModuleLoader__.load({
384
529
  "error.loadAssistant": "Could not load account settings", "error.noModels": "No models are available in the Host. Configure a provider in the web app first.", "error.save": "Could not save", "error.chooseWorkspace": "Choose a workspace directory", "error.workspaceUnavailable": "This Host cannot create workspaces", "error.addWorkspace": "Could not add workspace", "error.load": "Could not load", "error.connection": "Could not connect to the local IM Assistant API", "error.request": "Request failed", "error.action": "Action failed", "error.qr": "Could not generate a QR code", "error.detailsInLog": "The operation failed. Check the server logs for details.",
385
530
  "composer.aria": "Global session settings", "composer.project": "Select project", "composer.projectAria": "Project", "composer.noWorkspaces": "No workspaces", "composer.addWorkspace": "Add workspace…", "composer.permission": "Permission", "composer.noModels": "No models", "composer.workspacePath": "Workspace path", "action.cancel": "Cancel", "action.adding": "Adding…",
386
531
  "permission.readOnly": "Read Only", "permission.workspaceWrite": "Workspace Write", "permission.fullAccess": "Full access",
387
- "rail.workspace": "Workspaces", "rail.search": "Search", "rail.searchPlaceholder": "Search sessions...", "rail.clearSearch": "Clear search", "rail.filter": "Filter", "rail.group": "Group by", "rail.byWorkspace": "By workspace", "rail.list": "Single list", "rail.sort": "Sort by", "rail.manual": "Manual", "rail.recent": "Recently updated", "rail.running": "Running", "rail.idle": "Idle", "rail.renameAria": "Rename session", "rail.rename": "Rename", "rail.fork": "Fork session", "rail.archive": "Archive session", "rail.archiveFailed": "Archive failed. The session was kept. Retry or check the Host logs.", "rail.empty": "No channel sessions yet. Connect a channel in Settings → IM Assistant, then send the bot a message.", "rail.noTasks": "No web tasks", "rail.ungrouped": "Ungrouped", "rail.tabsAria": "Workspace categories", "rail.tasks": "Tasks", "rail.channels": "Channels",
388
- "time.now": "Just now", "time.minutes": "{count} min ago", "time.hours": "{count} hr ago", "time.days": "{count} days ago",
532
+ "rail.workspace": "Workspaces", "rail.search": "Search", "rail.searchPlaceholder": "Search sessions...", "rail.clearSearch": "Clear search", "rail.filter": "Filter", "rail.group": "Group by", "rail.byWorkspace": "By workspace", "rail.list": "Single list", "rail.sort": "Sort by", "rail.manual": "Manual", "rail.recent": "Recently updated", "rail.running": "Running", "rail.idle": "Idle", "rail.renameAria": "Rename session", "rail.rename": "Rename", "rail.fork": "Fork session", "rail.archive": "Archive session", "rail.archiveFailed": "Archive failed. The session was kept. Retry or check the Host logs.", "rail.deleteSession": "Delete session", "rail.deleteSessionConfirm": "Delete session", "rail.deleteSessionDescription": "This permanently deletes session “{name}”, its child agents (including any that are still running), and all of its records (conversation, stats, cache). This cannot be undone.", "rail.deleteSessionPending": "Deleting session…", "rail.deleteSessionFailed": "Could not delete the session: {message}", "rail.deleteSessionClose": "Close", "rail.deleteSessionCancel": "Cancel", "rail.groupActions": "Actions for {name}", "rail.channelSettings": "Channel settings", "rail.archiveGroup": "Archive all conversations", "rail.archiveGroupConfirm": "Archive all", "rail.archiveGroupDescription": "Archive all {count} conversations for “{name}”. You can restore them later in Settings → Archived.", "rail.archiveGroupPending": "Archiving conversations…", "rail.archiveGroupFailed": "Some conversations could not be archived: {message}", "rail.archiveGroupClose": "Close", "rail.archiveGroupCancel": "Cancel", "rail.empty": "No channel sessions yet. Connect a channel in Settings → IM Assistant, then send the bot a message.", "rail.noTasks": "No web tasks", "rail.ungrouped": "Ungrouped", "rail.tabsAria": "Workspace categories", "rail.tasks": "Tasks", "rail.channels": "Channels",
533
+ "time.now": "now", "time.minutes": "{n}min", "time.hours": "{n}h", "time.days": "{n}d", "time.months": "{n}mo", "time.years": "{n}y", "time.ago": "{t} ago",
534
+ "copy": "Copy", "hover.copied": "Copied",
389
535
  "server.unknownChannel": "Unknown channel", "server.channelUnconfigured": "Channel is not configured", "server.sessionMissing": "Session does not exist", "server.accountMissing": "Account does not exist", "server.accountConnectFailed": "Could not connect the account. Check the local logs.", "server.accountReconnectFailed": "Could not reconnect the account. Check the local logs.", "server.selectAccountSettings": "Select a provider, model, workspace, or permission setting", "server.selectModel": "Select a provider and model", "server.selectWorkspace": "Select a workspace", "server.selectPermission": "Select a permission", "server.missingCredentials": "The channel cannot start because credentials are missing", "server.qrUnsupported": "This channel does not support QR setup", "server.qrExpired": "QR code has expired", "server.qrIncomplete": "QR setup was not completed", "server.accessDenied": "Access denied: ask an administrator to approve you in Settings → IM Assistant.",
390
536
  "status.disconnected": "Disconnected", "status.reconnectFailed": "Reconnect failed", "status.connectingSocket": "Connecting", "status.waitHandshake": "Waiting for gateway handshake", "status.authenticating": "Authenticating", "status.reconnecting": "Reconnecting", "status.connectionError": "Connection error", "status.connectionFailed": "Connection failed", "status.streamConnected": "Stream connected", "status.stopped": "Stopped", "status.longConnection": "Long connection established", "status.polling": "Polling", "status.notLoggedIn": "Not signed in", "status.waitQr": "Waiting for scan", "status.loggedIn": "Signed in", "status.loggedInRecovered": "Signed in (restored)", "status.loggingIn": "Signing in",
391
537
  },
@@ -466,7 +612,7 @@ window.__ModuleLoader__.load({
466
612
  .ima-error{color:var(--ima-danger);font-size:12px;margin:0 0 12px}
467
613
  .ima-pending{margin:0 0 14px;padding:10px 12px;border:1px solid rgba(210,153,34,.35);border-radius:12px}
468
614
  .ima-pending-row{display:flex;gap:8px;align-items:center;margin-top:8px}
469
- .ima-wrap{display:flex;flex-direction:column;min-height:0;flex:1;height:100%;overflow:hidden}.ima-official-tree{flex:1;min-height:0;display:flex;flex-direction:column;overflow:hidden}.ima-native,.ima-rail.ima-native,.ima-rail.dcu-wb{box-sizing:border-box;padding-right:var(--dsh-sidebar-inline-padding,12px)}
615
+ .ima-wrap{display:flex;flex-direction:column;min-height:0;flex:1;height:100%;overflow:hidden}.ima-official-tree{flex:1;min-height:0;display:flex;flex-direction:column;overflow:hidden}.ima-native.ima-rail,.ima-rail.dcu-wb{box-sizing:border-box;overflow:hidden}
470
616
  .ima-tabs{display:flex;gap:18px;padding:4px 12px 0;border-bottom:1px solid var(--ima-line)}
471
617
  .ima-tab{appearance:none;border:0;background:transparent;color:var(--ima-muted);padding:8px 0;font-size:13px;cursor:pointer}
472
618
  .ima-tab.on{color:var(--ima-text);box-shadow:inset 0 -2px 0 currentColor}
@@ -709,12 +855,133 @@ window.__ModuleLoader__.load({
709
855
  return translated === key ? t("qr.default") : translated;
710
856
  }
711
857
 
858
+ // 有 reflect 时只 probe,不能硬读未注入的官方导航服务,否则 Cordis 会挡住插件激活。
859
+ function probeService(ctx, name) {
860
+ if (!ctx) return undefined;
861
+ const reflect = ctx.reflect;
862
+ if (reflect && typeof reflect.get === "function") {
863
+ try {
864
+ const found = reflect.get(name);
865
+ if (found !== undefined) return found;
866
+ } catch { /* 未注入时不硬读 ctx[name],改走 get */ }
867
+ }
868
+ if (typeof ctx.get === "function") {
869
+ try {
870
+ const found = ctx.get(name);
871
+ if (found !== undefined) return found;
872
+ } catch { return undefined; }
873
+ }
874
+ if (reflect && typeof reflect.get === "function") return undefined;
875
+ try { return ctx[name]; } catch { return undefined; }
876
+ }
877
+ // 旧宿主读 list.current;alpha.2 主视图改由 retainedBy.mainView 标记。
878
+ function currentSessionId(state) {
879
+ if (!state) return null;
880
+ if (typeof state.current === "string" && state.current) return state.current;
881
+ const byId = state.byId || {};
882
+ const ids = Array.isArray(state.ids) && state.ids.length ? state.ids : Object.keys(byId);
883
+ const pick = (id, row) => {
884
+ if (!row || !row.retainedBy || (row.retainedBy.mainView ?? 0) <= 0) return null;
885
+ const explicit = row.id && String(row.id).trim();
886
+ return explicit || id;
887
+ };
888
+ for (let i = 0; i < ids.length; i++) {
889
+ const found = pick(ids[i], byId[ids[i]]);
890
+ if (found) return found;
891
+ }
892
+ for (const id in byId) {
893
+ if (ids.indexOf(id) !== -1) continue;
894
+ const found = pick(id, byId[id]);
895
+ if (found) return found;
896
+ }
897
+ return null;
898
+ }
899
+ function resolveHostSessionId(sessionId, sessionById) {
900
+ if (!sessionId) return sessionId;
901
+ const listed = sessionById && sessionById[sessionId];
902
+ const fromKey = listed && (listed.id || listed.sessionId);
903
+ if (fromKey && String(fromKey).trim()) return String(fromKey).trim();
904
+ return sessionId;
905
+ }
906
+ function isCurrentListedSession(selectedId, sessionId, sessionById) {
907
+ if (!selectedId || !sessionId) return false;
908
+ if (selectedId === sessionId) return true;
909
+ const listed = sessionById && sessionById[sessionId];
910
+ if (listed && (listed.id === selectedId || listed.sessionId === selectedId)) return true;
911
+ const selected = sessionById && sessionById[selectedId];
912
+ if (selected && (selected.id === sessionId || selected.sessionId === sessionId)) return true;
913
+ return false;
914
+ }
915
+ function openHostSession(ctx, id) {
916
+ if (!id) return false;
917
+ const uiWorkspace = probeService(ctx, "uiWorkspace");
918
+ if (uiWorkspace && typeof uiWorkspace.openSession === "function") {
919
+ uiWorkspace.openSession(id);
920
+ return true;
921
+ }
922
+ // alpha.2 有 retain:旧的 sessions.open 即使还在也不会写入 mainView,点了等于没打开。
923
+ if (ctx.sessions && typeof ctx.sessions.retain === "function") return false;
924
+ if (ctx.sessions && typeof ctx.sessions.open === "function") {
925
+ ctx.sessions.open(id);
926
+ return true;
927
+ }
928
+ return false;
929
+ }
930
+ function pickHostDirectory(ctx) {
931
+ const uiWorkspace = probeService(ctx, "uiWorkspace");
932
+ if (uiWorkspace && typeof uiWorkspace.pickDirectory === "function") return uiWorkspace.pickDirectory();
933
+ if (ctx.workspaces && typeof ctx.workspaces.pickDirectory === "function") return ctx.workspaces.pickDirectory();
934
+ }
935
+ function archiveHostSession(ctx, id) {
936
+ const uiWorkspace = probeService(ctx, "uiWorkspace");
937
+ if (uiWorkspace && typeof uiWorkspace.archiveSession === "function") return uiWorkspace.archiveSession(id);
938
+ if (ctx.workspaces && typeof ctx.workspaces.archiveSession === "function") return ctx.workspaces.archiveSession(id);
939
+ }
940
+ function forkHostSession(ctx, id) {
941
+ const uiWorkspace = probeService(ctx, "uiWorkspace");
942
+ if (uiWorkspace && typeof uiWorkspace.forkSession === "function") return Promise.resolve(uiWorkspace.forkSession(id));
943
+ if (!ctx.sessions || typeof ctx.sessions.fork !== "function") return Promise.resolve();
944
+ return ctx.sessions.fork({ sessionId: id, increaseTitle: true })
945
+ .then((childId) => { openHostSession(ctx, childId); })
946
+ .catch(() => undefined);
947
+ }
948
+ async function renameHostSession(ctx, sessionId, title) {
949
+ const sessions = ctx.sessions;
950
+ if (!sessions) throw new Error("unknown session");
951
+ const renameBound = async (session) => {
952
+ if (!session || typeof session.rename !== "function") throw new Error("unknown session");
953
+ const result = await session.rename(title);
954
+ if (result && result.ok === false) throw new Error((result.error && result.error.message) || "rename failed");
955
+ };
956
+ if (typeof sessions.using === "function") {
957
+ return sessions.using(sessionId, { source: "controllerOperation" }, async (reference) => {
958
+ if (reference && reference.ready) await reference.ready;
959
+ return renameBound(reference && reference.binding && reference.binding.session);
960
+ });
961
+ }
962
+ const existing = sessions.binding && sessions.binding(sessionId);
963
+ if (existing && existing.session) return renameBound(existing.session);
964
+ if (typeof sessions.retain !== "function") throw new Error("unknown session");
965
+ const ref = sessions.retain(sessionId, { source: "controllerOperation" });
966
+ try {
967
+ if (ref && ref.ready) await ref.ready;
968
+ return renameBound(ref && ref.binding && ref.binding.session);
969
+ } finally {
970
+ if (ref && typeof ref.release === "function") ref.release();
971
+ }
972
+ }
973
+
712
974
  let openImSession = (id) => {
713
975
  try {
714
976
  if (window.__dshSessionsOpen) { window.__dshSessionsOpen(id); return true; }
715
977
  } catch { /* ignore */ }
716
978
  return false;
717
979
  };
980
+ const tryOpenListedSession = (id, hostOpen) => {
981
+ if (openImSession(id)) return true;
982
+ if (typeof hostOpen !== "function") return false;
983
+ try { hostOpen(id); return true; } catch { return false; }
984
+ };
718
985
  const openListedSession = (id, hostOpen) => {
719
986
  if (!id) return;
720
987
  if (isChannelSession(id)) {
@@ -732,8 +999,7 @@ window.__ModuleLoader__.load({
732
999
  }).catch((error) => console.warn("[dsh-im-connect] 无法恢复会话", id, error));
733
1000
  return;
734
1001
  }
735
- if (typeof hostOpen === "function") hostOpen(id);
736
- else openImSession(id);
1002
+ tryOpenListedSession(id, hostOpen);
737
1003
  };
738
1004
  let channelSkin = "native";
739
1005
 
@@ -1472,6 +1738,7 @@ window.__ModuleLoader__.load({
1472
1738
  const [selected, setSelected] = useState(storedAccountSelection);
1473
1739
  const [settingsAccount, setSettingsAccount] = useState(null);
1474
1740
  const [expanded, setExpanded] = useState({ weixin: true });
1741
+ const [channelSettingsRequest, setChannelSettingsRequest] = useState(() => typeof window !== "undefined" ? readChannelSettingsRequest(window.sessionStorage) : undefined);
1475
1742
  const [catalog, setCatalog] = useState({ providers: [], permissions: [], assistant: null, cwd: "", permission: "" });
1476
1743
  const workspaces = props.useWorkspaces ? (props.useWorkspaces((state) => state && state.items || []) || []) : [];
1477
1744
  const refreshSeq = useRef(0);
@@ -1507,6 +1774,31 @@ window.__ModuleLoader__.load({
1507
1774
  }).catch(() => undefined);
1508
1775
  }, [refresh]);
1509
1776
  useEffect(() => { const timer = setInterval(refresh, 4000); return () => clearInterval(timer); }, [refresh]);
1777
+ useEffect(() => {
1778
+ if (typeof window === "undefined") return undefined;
1779
+ const onRequest = (event) => {
1780
+ const request = parseChannelSettingsRequest(event.detail);
1781
+ if (request) setChannelSettingsRequest(request);
1782
+ };
1783
+ window.addEventListener(CHANNEL_SETTINGS_EVENT, onRequest);
1784
+ return () => window.removeEventListener(CHANNEL_SETTINGS_EVENT, onRequest);
1785
+ }, []);
1786
+ useEffect(() => {
1787
+ if (!channelSettingsRequest || channels == null) return;
1788
+ const target = resolveChannelSettingsTarget(channelSettingsRequest, channels);
1789
+ clearChannelSettingsRequest(typeof window !== "undefined" ? window.sessionStorage : undefined);
1790
+ setChannelSettingsRequest(undefined);
1791
+ if (!target) return;
1792
+ setExpanded((current) => Object.assign({}, current, { [target.channelId]: true }));
1793
+ if (target.accountId) {
1794
+ selectAccount(target.accountId);
1795
+ setSettingsAccount(target.accountId);
1796
+ }
1797
+ if (typeof document !== "undefined") {
1798
+ const node = document.querySelector('[data-ima-platform="' + target.channelId + '"]');
1799
+ if (node && typeof node.scrollIntoView === "function") node.scrollIntoView({ block: "nearest" });
1800
+ }
1801
+ }, [channelSettingsRequest, channels, selectAccount]);
1510
1802
 
1511
1803
  const onAction = (id, action, body) => {
1512
1804
  const removalFallback = action === "remove"
@@ -1566,7 +1858,7 @@ window.__ModuleLoader__.load({
1566
1858
  const canExpand = (ch.accounts || []).length > 0;
1567
1859
  const open = canExpand && Boolean(expanded[ch.id]);
1568
1860
  const toggleExpanded = canExpand ? () => setExpanded({ ...expanded, [ch.id]: !open }) : undefined;
1569
- return h("div", { key: ch.id, className: "ima-platform" + (open ? " open" : "") + (canExpand ? "" : " empty") },
1861
+ return h("div", { key: ch.id, className: "ima-platform" + (open ? " open" : "") + (canExpand ? "" : " empty"), "data-ima-platform": ch.id },
1570
1862
  h("div", { className: "ima-platform-head", role: canExpand ? "button" : undefined, tabIndex: canExpand ? 0 : undefined, "aria-expanded": canExpand ? open : undefined, onClick: toggleExpanded, onKeyDown: canExpand ? (e) => { if (e.key === "Enter" || e.key === " ") { e.preventDefault(); toggleExpanded(); } } : undefined },
1571
1863
  h(Logo, { id: ch.id }),
1572
1864
  h("span", { className: "ima-platform-title" }, channelLabel(ch, t)),
@@ -1625,9 +1917,9 @@ window.__ModuleLoader__.load({
1625
1917
  }),
1626
1918
  );
1627
1919
  }
1628
- const WB_CSS = `.dcu-wb,.ima-native{display:flex;flex:1;min-height:0;flex-direction:column;padding:0;padding-right:var(--dsh-sidebar-inline-padding,12px);box-sizing:border-box;color:var(--dsw-alias-label-primary,var(--ima-text));font:14px/20px inherit}.ima-n-toolbar{box-sizing:border-box;flex:none;height:36px;margin:2px -4px 4px 0;padding-left:4px;display:flex;justify-content:flex-end;align-items:center;gap:4px;overflow:visible;position:relative;z-index:2;color:var(--dsw-alias-label-tertiary,#81858C);border-radius:12px}.ima-n-head-label{white-space:nowrap;min-width:0;max-width:45%;flex:none;line-height:20px;font-size:14px;overflow:hidden;transition:max-width .18s var(--ds-ease-in-out,ease),margin-right .18s var(--ds-ease-in-out,ease),opacity .12s var(--ds-ease-in-out,ease),transform .18s var(--ds-ease-in-out,ease),visibility 0s linear}.ima-n-toolbar.is-search .ima-n-head-label{opacity:0;visibility:hidden;max-width:0;margin-right:-4px;transform:translate(-4px);transition-delay:0s,0s,0s,0s,.18s}.ima-n-search-slot{box-sizing:border-box;min-width:28px;max-width:28px;transition:max-width .18s var(--ds-ease-in-out,ease);flex:none;align-items:center;margin-left:auto;display:flex;position:relative;z-index:2}.ima-n-toolbar.is-search .ima-n-search-slot{flex:1;min-width:0;max-width:100%}.ima-n-search{box-sizing:border-box;cursor:text;width:100%;height:28px;color:var(--dsw-alias-label-secondary);transition:width .18s var(--ds-ease-in-out,ease),padding .18s var(--ds-ease-in-out,ease),border-color .18s var(--ds-ease-in-out,ease);background:transparent;border:none;border-radius:50%;flex:none;align-items:center;margin:0;padding:0;display:flex;overflow:hidden}.ima-n-toolbar.is-search .ima-n-search{border:1px solid var(--dsw-alias-border-l2,rgba(255,255,255,.10));width:calc(100% + 4px);height:30px;border-radius:10px;margin-inline:-2px;padding:0 4px 0 0}.ima-n-search-btn,.ima-n-head-btn{cursor:pointer;width:28px;height:28px;min-width:28px;min-height:28px;position:relative;z-index:1;color:var(--dsw-alias-label-secondary);background:transparent;border:none;border-radius:50%;flex:none;justify-content:center;align-items:center;padding:0;display:inline-flex}.ima-n-toolbar.is-search .ima-n-search-btn{width:28px;height:30px}.ima-n-search-btn:hover,.ima-n-head-btn:hover,.ima-n-head-btn.on{background:var(--dsw-alias-interactive-bg-hover,rgba(255,255,255,.06));color:var(--dsw-alias-label-primary,var(--ima-text))}.ima-n-toolbar.is-search .ima-n-search-btn:hover{background:transparent}.ima-n-head-acts{opacity:1;visibility:visible;max-width:32px;transition:max-width .18s var(--ds-ease-in-out,ease),opacity .12s var(--ds-ease-in-out,ease),transform .18s var(--ds-ease-in-out,ease),visibility 0s linear;flex:none;align-items:center;gap:4px;display:flex;overflow:visible;position:relative}.ima-n-toolbar.is-search .ima-n-head-acts{opacity:0;visibility:hidden;pointer-events:none;max-width:0;transform:translate(4px);transition-delay:0s,0s,0s,.18s}.ima-n-head-filter{position:relative}.ima-n-search-input{display:none;opacity:0;pointer-events:none;width:0;min-width:0;flex:none;color:var(--dsw-alias-label-primary,var(--ima-text));transition:opacity .12s var(--ds-ease-in-out,ease);background:transparent;border:none;outline:none;flex:1;font-size:13px;line-height:18px}.ima-n-toolbar.is-search .ima-n-search-input{display:block;opacity:1;pointer-events:auto;margin-left:-2px;width:auto;flex:1;min-width:0}.ima-n-search-input::placeholder{color:var(--dsw-alias-label-tertiary,#81858C)}.ima-n-search-clear{cursor:pointer;width:24px;height:24px;color:var(--dsw-alias-label-secondary);background:transparent;border:none;border-radius:50%;flex:none;justify-content:center;align-items:center;padding:0;display:inline-flex}.ima-n-search-clear:hover{background:var(--dsw-alias-interactive-bg-hover,rgba(255,255,255,.06))}@media (prefers-reduced-motion:reduce){.ima-n-head-label,.ima-n-search-slot,.ima-n-search,.ima-n-head-acts,.ima-n-search-input{transition:none}}.ima-n-filter-menu{position:absolute;right:0;top:calc(100% + 6px);z-index:30;min-width:196px;padding:8px 6px;border:1px solid var(--dsw-alias-border-inverted,rgba(255,255,255,.12));border-radius:12px;background:var(--dsw-specific-menu,var(--dsw-alias-bg-layer-2,#1c2128));box-shadow:var(--dsw-shadow-lv3,0 8px 24px rgba(0,0,0,.36))}.ima-n-filter-label{padding:6px 10px 4px;font-size:12px;line-height:18px;color:var(--dsw-alias-label-tertiary,#81858C)}.ima-n-filter-split{height:1px;margin:6px 8px;background:var(--dsw-alias-border-l2,rgba(255,255,255,.1))}.ima-n-filter-menu button{display:flex;align-items:center;justify-content:space-between;gap:12px;width:100%;min-height:36px;padding:6px 10px;border:0;border-radius:8px;background:transparent;color:inherit;font:14px/20px inherit;cursor:pointer;text-align:left}.ima-n-filter-menu button:hover{background:var(--dsw-alias-interactive-bg-hover,rgba(255,255,255,.06))}.ima-n-filter-tick{width:16px;height:16px;flex:none}.ima-native-tree,.dcu-wb-tree{padding:0 0 16px;scrollbar-gutter:stable}.ima-native-project+.ima-native-project,.dcu-wb-project+.dcu-wb-project{margin-top:4px}.ima-native-project>*+*,.dcu-wb-project>*+*{margin-top:2px}
1920
+ const WB_CSS = `.dcu-wb,.ima-native{--dsh-session-list-edge-inset:var(--dsh-sidebar-inline-padding,12px);--dsh-session-list-scrollbar-width:8px;--dsh-session-list-scrollbar-offset:2px;display:flex;flex:1;min-width:0;min-height:0;flex-direction:column;padding:0;padding-right:var(--dsh-session-list-edge-inset);box-sizing:border-box;overflow:hidden;color:var(--dsw-alias-label-primary,var(--ima-text));font:14px/20px inherit}.ima-n-toolbar{box-sizing:border-box;flex:none;height:36px;margin:2px -4px 4px 0;padding-left:4px;display:flex;justify-content:flex-end;align-items:center;gap:4px;overflow:visible;position:relative;z-index:2;color:var(--dsw-alias-label-tertiary,#81858C);border-radius:12px}.ima-n-head-label{white-space:nowrap;min-width:0;max-width:45%;flex:none;line-height:20px;font-size:14px;overflow:hidden;transition:max-width .18s var(--ds-ease-in-out,ease),margin-right .18s var(--ds-ease-in-out,ease),opacity .12s var(--ds-ease-in-out,ease),transform .18s var(--ds-ease-in-out,ease),visibility 0s linear}.ima-n-toolbar.is-search .ima-n-head-label{opacity:0;visibility:hidden;max-width:0;margin-right:-4px;transform:translate(-4px);transition-delay:0s,0s,0s,0s,.18s}.ima-n-search-slot{box-sizing:border-box;min-width:28px;max-width:28px;transition:max-width .18s var(--ds-ease-in-out,ease);flex:none;align-items:center;margin-left:auto;display:flex;position:relative;z-index:2}.ima-n-toolbar.is-search .ima-n-search-slot{flex:1;min-width:0;max-width:100%}.ima-n-search{box-sizing:border-box;cursor:text;width:100%;height:28px;color:var(--dsw-alias-label-secondary);transition:width .18s var(--ds-ease-in-out,ease),padding .18s var(--ds-ease-in-out,ease),border-color .18s var(--ds-ease-in-out,ease);background:transparent;border:none;border-radius:50%;flex:none;align-items:center;margin:0;padding:0;display:flex;overflow:hidden}.ima-n-toolbar.is-search .ima-n-search{border:.5px solid var(--dsw-alias-border-l4);width:calc(100% + 4px);height:30px;color:var(--dsw-alias-label-caption);border-radius:10px;margin-inline:-2px;padding:0 4px 0 0}.ima-n-search-btn,.ima-n-head-btn{cursor:pointer;width:28px;height:28px;min-width:28px;min-height:28px;position:relative;z-index:1;color:var(--dsw-alias-label-secondary);background:transparent;border:none;border-radius:50%;flex:none;justify-content:center;align-items:center;padding:0;display:inline-flex}.ima-n-toolbar.is-search .ima-n-search-btn{width:28px;height:30px}.ima-n-search-btn:hover,.ima-n-head-btn:hover,.ima-n-head-btn.on{background:var(--dsw-alias-interactive-bg-hover,rgba(255,255,255,.06));color:var(--dsw-alias-label-primary,var(--ima-text))}.ima-n-toolbar.is-search .ima-n-search-btn:hover{background:transparent}.ima-n-head-acts{opacity:1;visibility:visible;max-width:32px;transition:max-width .18s var(--ds-ease-in-out,ease),opacity .12s var(--ds-ease-in-out,ease),transform .18s var(--ds-ease-in-out,ease),visibility 0s linear;flex:none;align-items:center;gap:4px;display:flex;overflow:visible;position:relative}.ima-n-toolbar.is-search .ima-n-head-acts{opacity:0;visibility:hidden;pointer-events:none;max-width:0;transform:translate(4px);transition-delay:0s,0s,0s,.18s}.ima-n-head-filter{position:relative}.ima-n-search-input{display:none;opacity:0;pointer-events:none;width:0;min-width:0;flex:none;color:var(--dsw-alias-label-primary,var(--ima-text));transition:opacity .12s var(--ds-ease-in-out,ease);background:transparent;border:none;outline:none;flex:1;font-size:13px;line-height:18px}.ima-n-toolbar.is-search .ima-n-search-input{display:block;opacity:1;pointer-events:auto;margin-left:-2px;width:auto;flex:1;min-width:0}.ima-n-search-input::placeholder{color:var(--dsw-alias-label-tertiary,#81858C)}.ima-n-search-clear{cursor:pointer;width:24px;height:24px;color:var(--dsw-alias-label-secondary);background:transparent;border:none;border-radius:50%;flex:none;justify-content:center;align-items:center;padding:0;display:inline-flex}.ima-n-search-clear:hover{background:var(--dsw-alias-interactive-bg-hover,rgba(255,255,255,.06))}@media (prefers-reduced-motion:reduce){.ima-n-head-label,.ima-n-search-slot,.ima-n-search,.ima-n-head-acts,.ima-n-search-input{transition:none}}.ima-n-filter-menu{position:absolute;right:0;top:calc(100% + 6px);z-index:30;min-width:196px;padding:8px 6px;border:1px solid var(--dsw-alias-border-inverted,rgba(255,255,255,.12));border-radius:12px;background:var(--dsw-specific-menu,var(--dsw-alias-bg-layer-2,#1c2128));box-shadow:var(--dsw-shadow-lv3,0 8px 24px rgba(0,0,0,.36))}.ima-n-filter-label{padding:6px 10px 4px;font-size:12px;line-height:18px;color:var(--dsw-alias-label-tertiary,#81858C)}.ima-n-filter-split{height:1px;margin:6px 8px;background:var(--dsw-alias-border-l2,rgba(255,255,255,.1))}.ima-n-filter-menu button{display:flex;align-items:center;justify-content:space-between;gap:12px;width:100%;min-height:36px;padding:6px 10px;border:0;border-radius:8px;background:transparent;color:inherit;font:14px/20px inherit;cursor:pointer;text-align:left}.ima-n-filter-menu button:hover{background:var(--dsw-alias-interactive-bg-hover,rgba(255,255,255,.06))}.ima-n-filter-tick{width:16px;height:16px;flex:none}.ima-n-list-area,.dcu-wb-list-area{min-height:0;margin-left:-4px;margin-right:calc(-1 * var(--dsh-session-list-edge-inset));flex-direction:column;flex:1;padding-left:4px;display:flex;overflow:visible}.ima-native-tree,.dcu-wb-tree{flex:1;min-width:0;min-height:0;overflow-x:hidden;overflow-y:auto;user-select:none;margin-left:-4px;margin-right:var(--dsh-session-list-scrollbar-offset);padding-top:0;padding-bottom:16px;padding-left:4px;padding-right:calc(var(--dsh-session-list-edge-inset) - var(--dsh-session-list-scrollbar-width) - var(--dsh-session-list-scrollbar-offset));scrollbar-gutter:stable}.ima-native-project,.dcu-wb-project{position:relative;min-width:0;max-width:100%}.ima-native-project+.ima-native-project,.dcu-wb-project+.dcu-wb-project{margin-top:4px}.ima-native-project>*+*,.dcu-wb-project>*+*{margin-top:2px}
1629
1921
  .dcu-wb *,.ima-native *{box-sizing:border-box}
1630
- .dcu-wb-tree,.ima-native-tree{flex:1;min-height:0;overflow-y:auto;padding-bottom:16px;user-select:none}
1922
+ .dcu-wb-tree,.ima-native-tree{flex:1;min-height:0}
1631
1923
  .dcu-wb-project-head,.ima-native-head,.dcu-wb-session,.ima-native-session{display:flex;align-items:center;gap:6px;width:100%;border:0;border-radius:8px;padding:0 8px;background:transparent;color:inherit;cursor:pointer;font:inherit;text-align:left}
1632
1924
  .dcu-wb-project-head,.ima-native-head{height:34px}
1633
1925
  .dcu-wb-project-head:hover,.dcu-wb-session:hover,.dcu-wb-session.dcu-wb-selected,.ima-native-head:hover,.ima-native-session:hover,.ima-native-session.on{background:var(--dsw-alias-interactive-bg-hover,var(--dcu-sidebar-hover,rgba(255,255,255,.06)))}
@@ -1638,32 +1930,43 @@ window.__ModuleLoader__.load({
1638
1930
  .dcu-wb-actions,.ima-native-actions{display:none;align-items:center;flex:none}
1639
1931
  .dcu-wb-session:hover .dcu-wb-actions,.dcu-wb-session.dcu-wb-menu-open .dcu-wb-actions,.ima-native-session:hover .ima-native-actions,.ima-native-session.menu-on .ima-native-actions{display:flex}
1640
1932
  .dcu-wb-more,.ima-native-more{display:grid;place-items:center;width:20px;height:20px;border:0;border-radius:4px;padding:0;background:transparent;color:var(--dsw-alias-label-secondary,var(--ima-muted));cursor:pointer}
1641
- .dcu-wb-empty,.ima-native-empty{padding:14px 8px;color:var(--dsw-alias-label-tertiary,var(--ima-muted));font-size:13px}
1933
+ .dcu-wb-empty,.ima-native-empty{padding:16px 12px;color:var(--dsw-alias-label-tertiary,var(--ima-muted));font-size:13px}
1642
1934
  .ima-sess-menu{position:fixed;right:auto;top:auto;min-width:132px;padding:6px;border:1px solid var(--dsw-alias-stroke-primary,var(--ima-line));border-radius:10px;background:var(--dsw-specific-menu,var(--dsw-alias-bg-layer-2));z-index:4000}
1643
1935
  .ima-sess-menu button{display:block;width:100%;text-align:left;border:0;background:transparent;color:inherit;padding:7px 10px;border-radius:6px;cursor:pointer;font:13px/18px inherit}
1644
1936
  .ima-sess-menu button:hover{background:var(--dsw-alias-interactive-bg-hover,rgba(255,255,255,.06))}
1645
1937
  .ima-sess-menu button.danger{color:var(--dsw-alias-state-error-primary,var(--ima-danger))}
1646
1938
  .ima-rename{flex:1;min-width:0;min-height:28px;padding:2px 8px;border-radius:6px;border:1px solid var(--dsw-alias-stroke-primary,var(--ima-line));background:transparent;color:inherit;font:inherit}
1647
- .ima-n-row,.ima-n-sess{display:flex;align-items:center;gap:6px;border-radius:8px;padding:0 8px 0 12px;cursor:pointer;user-select:none;width:100%;border:0;background:transparent;color:var(--dsw-alias-label-primary,var(--ima-text));font:14px/20px inherit;text-align:left;box-sizing:border-box}
1939
+ .ima-n-row,.ima-n-sess{display:flex;align-items:center;max-width:100%;gap:6px;border-radius:8px;padding:0 8px;padding-inline-start:calc(8px + var(--dsh-workspace-indent,0px));cursor:pointer;user-select:none;width:100%;border:0;background:transparent;color:var(--dsw-alias-label-primary,var(--ima-text));font:14px/20px inherit;text-align:left;box-sizing:border-box}
1648
1940
  .ima-n-row{height:34px}
1649
- .ima-n-sess{height:32px;gap:0;position:relative}
1650
- .ima-n-row:hover,.ima-n-sess:hover,.ima-n-sess.on,.ima-n-row.menu-on,.ima-n-sess.menu-on{background:var(--dsw-alias-interactive-bg-hover,rgba(255,255,255,.06))}
1651
- .ima-n-slot{flex:none;width:16px;height:20px;display:inline-flex;align-items:center;justify-content:center;color:var(--dsw-alias-label-tertiary,#81858C)}.ima-run-dot{flex:none;color:var(--dsw-static-deepseek-450,#4c8dff)}.ima-run-dot-cell{fill:currentColor;opacity:.15;animation:ima-run-chase 1s infinite}@keyframes ima-run-chase{0%,12.4%{opacity:1}12.5%,24.9%{opacity:.6}25%,37.4%{opacity:.35}37.5%,100%{opacity:.15}}
1941
+ .ima-n-sess{height:32px;gap:0;position:relative;appearance:none}
1942
+ .ima-n-row:hover,.ima-n-sess:hover,.ima-n-sess.on,.ima-n-sess.is-on,.ima-n-row.menu-on,.ima-n-row.is-menu,.ima-n-sess.menu-on,.ima-n-sess.is-menu{background:var(--dsw-alias-interactive-bg-hover,rgba(255,255,255,.06))}
1943
+ .ima-n-row.has-current-session .ima-n-folder{color:var(--dsw-alias-state-business-primary,#4c8dff)}
1944
+ .ima-n-chevron{display:none;color:var(--dsw-alias-label-caption,#ADB2B8)}
1945
+ .ima-n-row:hover .ima-n-chevron{display:inline-flex}
1946
+ .ima-n-row:hover .ima-n-folder{display:none}
1947
+ .ima-n-arrow{transition:transform .15s var(--ds-ease-in-out,ease)}
1948
+ .ima-n-arrow.is-open{transform:rotate(90deg)}
1949
+ .ima-n-project-text{flex-direction:column;flex:1;gap:2px;min-width:0;display:flex}
1950
+ .ima-n-row .ima-n-acts{height:20px}
1951
+ .ima-n-sess.is-flat-idle .ima-n-title{margin-left:0}
1952
+ .ima-n-sess:focus{outline:none}.ima-n-sess:focus-visible:not(.is-on){box-shadow:inset 0 0 0 2px var(--dsw-alias-state-business-primary,#4c8dff)}
1953
+ .ima-n-slot{flex:none;width:16px;min-width:16px;height:20px;display:inline-flex;align-items:center;justify-content:center;color:var(--dsw-alias-label-tertiary,#81858C)}.ima-run-dot{flex:none;color:var(--dsw-static-deepseek-450,#4c8dff)}.ima-run-dot-cell{fill:currentColor;opacity:.15;animation:ima-run-chase 1s infinite}@keyframes ima-run-chase{0%,12.4%{opacity:1}12.5%,24.9%{opacity:.6}25%,37.4%{opacity:.35}37.5%,100%{opacity:.15}}
1652
1954
  .ima-n-folder{color:var(--dsw-alias-label-secondary,#9ca39f)}
1653
1955
  .ima-n-lead{color:var(--dsw-alias-label-tertiary,#81858C)}
1654
1956
  .ima-n-corner{color:var(--dsw-alias-label-caption,#ADB2B8);width:8px}
1655
- .ima-n-hover{position:fixed;z-index:4100;min-width:188px;max-width:280px;padding:12px 14px;border:1px solid var(--dsw-alias-border-inverted,rgba(255,255,255,.12));border-radius:12px;background:var(--dsw-specific-menu,var(--dsw-alias-bg-layer-2,#1c2128));box-shadow:var(--dsw-shadow-lv3,0 8px 24px rgba(0,0,0,.36));color:var(--dsw-alias-label-primary,var(--ima-text))}
1656
- .ima-n-hover-title{font-size:14px;line-height:20px;font-weight:500}
1657
- .ima-n-hover-time{margin-top:4px;font-size:12px;line-height:18px;color:var(--dsw-alias-label-tertiary,#81858C)}
1658
- .ima-n-hover-state{display:flex;align-items:center;gap:6px;margin-top:8px;font-size:12px;line-height:18px;color:var(--dsw-alias-label-secondary,#9ca39f)}
1659
- .ima-n-hover-dot{width:8px;height:8px;border-radius:50%;background:#34c759;flex:none}
1660
- .ima-n-hover-dot.is-run{background:#4c8dff}
1957
+ .ima-n-hover{--dsw-hovercard-bg:#2C2C2E;position:fixed;z-index:100;box-sizing:border-box;width:244px;padding:12px 16px;border:0;border-radius:12px;background:var(--dsw-hovercard-bg);box-shadow:var(--dsw-shadow-lv3,0 8px 24px rgba(0,0,0,.36))}
1958
+ .ima-n-hover-content{display:flex;flex-direction:column;gap:8px;min-width:0}
1959
+ .ima-n-hover-title{color:#fff;font-size:14px;line-height:20px;font-weight:400;overflow-wrap:break-word}
1960
+ .ima-n-hover-time{margin:0;color:#cfd3d6;font-size:12px;line-height:16px}
1961
+ .ima-n-hover-state{display:flex;align-items:center;gap:8px;margin:0;font-size:12px;line-height:20px;color:#adb2b8}
1962
+ .ima-n-hover-dot{width:10px;height:10px;border-radius:50%;background:var(--dsw-alias-state-success-primary,#34c759);flex:none;position:relative}
1963
+ .ima-n-hover-dot.is-run{background:var(--dsw-static-deepseek-450,#4c8dff)}
1661
1964
  .ima-n-title{min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-size:14px;line-height:20px;flex:1;font-weight:400}
1662
1965
  .ima-n-sess .ima-n-title{margin:0 6px 0 4px}
1663
- .ima-n-time{flex:none;font-size:12px;line-height:20px;color:var(--dsw-alias-label-tertiary,#81858C)}
1966
+ .ima-n-time{flex:none;font-size:12px;line-height:20px;color:var(--dsw-alias-label-tertiary,#81858C);white-space:nowrap}
1664
1967
  .ima-n-acts{flex:none;display:none;align-items:center;gap:12px}
1665
- .ima-n-row:hover .ima-n-acts,.ima-n-sess:hover .ima-n-acts,.ima-n-row.menu-on .ima-n-acts,.ima-n-sess.menu-on .ima-n-acts{display:inline-flex}
1666
- .ima-n-sess:hover .ima-n-time,.ima-n-sess.menu-on .ima-n-time{display:none}
1968
+ .ima-n-row:hover .ima-n-acts,.ima-n-sess:hover .ima-n-acts,.ima-n-row.menu-on .ima-n-acts,.ima-n-row.is-menu .ima-n-acts,.ima-n-sess.menu-on .ima-n-acts,.ima-n-sess.is-menu .ima-n-acts{display:inline-flex}
1969
+ .ima-n-sess:hover .ima-n-time,.ima-n-sess.menu-on .ima-n-time,.ima-n-sess.is-menu .ima-n-time{display:none}
1667
1970
  .ima-n-ico{display:inline-flex;align-items:center;justify-content:center;width:16px;height:16px;border:0;border-radius:4px;padding:0;background:transparent;cursor:pointer;color:var(--dsw-alias-label-tertiary,#81858C)}
1668
1971
  .ima-n-ico:hover{color:var(--dsw-alias-label-primary,var(--ima-text))}
1669
1972
  .ima-n-menu{position:fixed;right:auto;top:auto;z-index:4000;min-width:218px;max-width:360px;box-sizing:border-box;padding:4px;display:flex;flex-direction:column;border:1px solid var(--dsw-alias-border-inverted,rgba(255,255,255,.12));border-radius:12px;background:var(--dsw-specific-menu,var(--dsw-alias-bg-layer-2));box-shadow:var(--dsw-shadow-lv3,0 8px 24px rgba(0,0,0,.36))}
@@ -1672,7 +1975,14 @@ window.__ModuleLoader__.load({
1672
1975
  .ima-n-mi{display:inline-flex;flex:none;width:16px;height:16px;align-items:center;justify-content:center;color:var(--dsw-alias-label-tertiary,#81858C)}
1673
1976
  .ima-n-menu button.danger{color:var(--dsw-alias-state-error-primary,#f85149)}
1674
1977
  .ima-n-menu button.danger .ima-n-mi{color:inherit}
1675
- .ima-n-menu button.danger:hover{background:var(--dsw-alias-interactive-bg-hover-danger,rgba(248,81,73,.12))}`;
1978
+ .ima-n-menu button.danger:hover{background:var(--dsw-alias-interactive-bg-hover-danger,rgba(248,81,73,.12))}
1979
+ .ima-n-rename{flex:1;min-width:0;margin:0 6px 0 4px;border:.5px solid var(--dsw-alias-border-l4);border-radius:4px;outline:none;background:var(--dsw-alias-button-elevated-fill,rgba(255,255,255,.04));color:inherit;padding:0 2px;font-size:14px;line-height:20px}
1980
+ .ima-n-dialog-actions{display:flex;justify-content:flex-end;gap:8px}
1981
+ .ima-n-dialog-copy{margin:0;color:var(--dsw-alias-label-secondary);font-size:14px;line-height:22px}
1982
+ .ima-n-dialog-status{margin-top:12px;color:var(--dsw-alias-label-secondary);font-size:13px;line-height:20px}
1983
+ .ima-n-dialog-error{margin-top:12px;color:var(--dsw-alias-state-error-primary,#f85149);font-size:13px;line-height:20px}
1984
+ .ima-n-danger-button{color:var(--dsw-alias-state-error-primary,#f85149)!important}
1985
+ .ima-n-danger-button:hover{background:var(--dsw-alias-interactive-bg-hover-danger,rgba(248,81,73,.12))!important}`;
1676
1986
 
1677
1987
  function NativeSvg(viewBox, size, children) {
1678
1988
  return h("svg", { viewBox, width: size, height: size, fill: "none", xmlns: "http://www.w3.org/2000/svg", "aria-hidden": "true" }, children);
@@ -1680,37 +1990,6 @@ window.__ModuleLoader__.load({
1680
1990
  function NativePath(d, extra) {
1681
1991
  return h("path", Object.assign({ d, fill: "currentColor" }, extra || {}));
1682
1992
  }
1683
- function IconEllipsis() {
1684
- return NativeSvg("0 0 16 16", 16, [
1685
- NativePath("M4.55146 8.00001C4.55146 8.63513 4.03659 9.15001 3.40146 9.15001C2.76634 9.15001 2.25146 8.63513 2.25146 8.00001C2.25146 7.36488 2.76634 6.85001 3.40146 6.85001C4.03659 6.85001 4.55146 7.36488 4.55146 8.00001Z"),
1686
- NativePath("M9.1476 8.00001C9.1476 8.63513 8.63273 9.15001 7.9976 9.15001C7.36248 9.15001 6.8476 8.63513 6.8476 8.00001C6.8476 7.36488 7.36248 6.85001 7.9976 6.85001C8.63273 6.85001 9.1476 7.36488 9.1476 8.00001Z"),
1687
- NativePath("M13.7486 8.00001C13.7486 8.63513 13.2338 9.15001 12.5986 9.15001C11.9635 9.15001 11.4486 8.63513 11.4486 8.00001C11.4486 7.36488 11.9635 6.85001 12.5986 6.85001C13.2338 6.85001 13.7486 7.36488 13.7486 8.00001Z"),
1688
- ]);
1689
- }
1690
- function IconEdit() {
1691
- return NativeSvg("0 0 16 16", 16, NativePath("M9.941 1.349a2.54 2.54 0 0 1 2.473 0c.292.171.555.442.897.784.341.341.612.604.783.896a2.54 2.54 0 0 1 0 2.473c-.171.292-.442.555-.784.896L6.659 13.05c-.378.378-.652.661-.994.86-.341.199-.722.298-1.238.44l-1.183.326c-.469.13-.899.25-1.243.292-.349.043-.821.033-1.19-.336-.369-.369-.379-.841-.336-1.19.042-.344.163-.774.292-1.243l.326-1.183c.143-.516.242-.897.44-1.238.199-.342.482-.615.86-.994l6.652-6.651c.341-.342.604-.613.896-.784Zm1.759 1.222a1.16 1.16 0 0 0-1.045 0c-.095.056-.206.158-.61.562L9.456 3.721l2.265 2.265.589-.588c.404-.403.507-.515.562-.61a1.16 1.16 0 0 0 0-1.045c-.056-.095-.158-.206-.562-.61-.404-.404-.515-.507-.61-.562ZM3.394 9.784c-.429.429-.551.56-.637.706-.085.147-.138.318-.3.903l-.326 1.183c-.129.468-.209.766-.242.978.212-.033.51-.112.979-.241l1.183-.327c.585-.161.756-.214.902-.3.147-.085.277-.208.706-.636l5.062-5.063-2.265-2.265-5.062 5.062Z"));
1692
- }
1693
- function IconBranch() {
1694
- return NativeSvg("0 0 16 16", 16, NativePath("M13.076 1.372c1.008 0 1.826.819 1.826 1.827s-.818 1.826-1.826 1.826c-.78 0-1.444-.488-1.706-1.175H4.355c.439.415.804.915 1.062 1.485l1.69 3.733a4.83 4.83 0 0 0 4.312 2.97c.29-.626.923-1.061 1.658-1.061 1.008 0 1.826.818 1.826 1.826s-.818 1.826-1.826 1.826c-.823 0-1.519-.545-1.747-1.293a6.34 6.34 0 0 1-5.406-3.731L4.232 5.871A3.83 3.83 0 0 0 1.098 3.85V2.549h10.272c.263-.687.927-1.177 1.706-1.177Zm0 10.904a.525.525 0 1 0 0 1.052.525.525 0 0 0 0-1.052Zm0-9.603a.526.526 0 1 0 0 1.053.526.526 0 0 0 0-1.053Z", { fillRule: "evenodd", clipRule: "evenodd" }));
1695
- }
1696
- function IconArchive() {
1697
- return NativeSvg("0 0 20 20", 16, [
1698
- NativePath("M15.866 2.06a2.526 2.526 0 0 1 2.525 2.525v.902c0 .54-.172 1.04-.461 1.45l.009.085v5.866c0 .746 0 1.35-.039 1.837-.035.434-.106.825-.262 1.189l-.072.154a3.03 3.03 0 0 1-1.262 1.366l-.236.132c-.408.208-.848.294-1.344.334-.488.04-1.091.04-1.837.04H7.111c-.746 0-1.35 0-1.837-.04-.434-.035-.825-.105-1.189-.261l-.154-.073a3.03 3.03 0 0 1-1.366-1.262l-.132-.235a2.53 2.53 0 0 1-.335-1.344c-.04-.487-.039-1.091-.039-1.837V7.022c0-.029.005-.057.008-.086A2.48 2.48 0 0 1 1.609 5.487v-.902A2.526 2.526 0 0 1 4.134 2.06h11.732Zm.632 5.87a2.48 2.48 0 0 1-.632.083H4.134a2.48 2.48 0 0 1-.634-.083v4.959c0 .77 0 1.304.034 1.72.034.406.095.635.182.806l.076.137c.191.311.465.565.792.731l.141.061c.156.055.361.096.666.121.415.034.95.035 1.72.035h5.775c.77 0 1.305 0 1.72-.035.407-.033.636-.095.807-.182l.138-.077c.311-.191.565-.464.731-.791l.06-.142c.056-.155.097-.36.122-.665.034-.415.034-.95.034-1.72V7.93ZM4.134 3.5a1.086 1.086 0 0 0-1.085 1.085v.902c0 .599.486 1.085 1.085 1.085h11.732c.599 0 1.085-.486 1.085-1.085v-.902A1.086 1.086 0 0 0 15.866 3.5H4.134Z", { fillRule: "evenodd", clipRule: "evenodd" }),
1699
- NativePath("M12.796 12.566v-1.483H7.205v1.483h5.591Z"),
1700
- ]);
1701
- }
1702
- function IconTrash() {
1703
- return NativeSvg("0 0 16 16", 16, NativePath("M14.478 4.841 14.214 10.115c-.104 2.072-.147 2.896-.827 3.846a3.53 3.53 0 0 1-1.044.993c-.519.333-1.101.478-1.784.546-.671.067-1.509.066-2.559.066s-1.887.001-2.558-.066c-.683-.068-1.266-.213-1.784-.546a3.53 3.53 0 0 1-1.044-.993c-.681-.95-.724-1.774-.828-3.846L1.522 4.841l1.368-.068.263 5.273c.109 2.176.171 2.556.573 3.117a2.16 2.16 0 0 0 .673.64c.263.169.603.277 1.179.334.587.059 1.345.06 2.422.06s1.834-.001 2.422-.06c.575-.057.916-.165 1.179-.335.262-.168.49-.386.672-.64.402-.56.464-.94.573-3.116l.263-5.273 1.369.068ZM5.43 6.228h1.37v5.163H5.43V6.228Zm3.77 0h1.37v5.163H9.2V6.228ZM8.536.434c.644 0 1.116-.007 1.56.137.14.045.276.101.406.168.416.212.745.552 1.2 1.007l.796.795h2.876v1.37H.626V2.541h2.876l.796-.795c.456-.455.784-.795 1.2-1.007.13-.067.266-.123.405-.168C6.348.427 6.82.434 7.464.434h1.072Zm-1.072 1.37c-.732 0-.948.008-1.138.07a2.2 2.2 0 0 0-.206.085c-.156.08-.296.204-.678.583h5.117c-.382-.379-.522-.503-.679-.583a2.2 2.2 0 0 0-.205-.085c-.191-.062-.406-.07-1.138-.07H7.464Z"));
1704
- }
1705
- function IconFolderClose() {
1706
- return NativeSvg("0 0 16 16", 16, h("path", { fill: "currentColor", transform: "translate(1.5 2.429)", d: "M5.05582 0.518756L4.50669 0.86654L5.05582 0.518756ZM13 9.4837L13.65 9.4837L13.65 3.53962L13 3.53962L12.35 3.53962L12.35 9.4837L13 9.4837ZM11.3264 1.86603L11.3264 1.21603L6.52313 1.21603L6.52313 1.86603L6.52313 2.51603L11.3264 2.51603L11.3264 1.86603ZM5.58054 1.34727L6.12968 0.999489L5.60495 0.170972L5.05582 0.518756L4.50669 0.86654L5.03141 1.69506L5.58054 1.34727ZM4.11323 1.23058e-13L4.11323 -0.65L1.67359 -0.65L1.67359 5.00699e-14L1.67359 0.65L4.11323 0.65L4.11323 1.23058e-13ZM0 1.67359L-0.65 1.67359L-0.65 9.4837L0 9.4837L0.65 9.4837L0.65 1.67359L0 1.67359ZM11.3264 11.1573L11.3264 10.5073L1.67359 10.5073L1.67359 11.1573L1.67359 11.8073L11.3264 11.8073L11.3264 11.1573ZM0 9.4837L-0.65 9.4837C-0.65 10.767 0.390308 11.8073 1.67359 11.8073L1.67359 11.1573L1.67359 10.5073C1.10828 10.5073 0.65 10.049 0.65 9.4837L0 9.4837ZM1.67359 5.00699e-14L1.67359 -0.65C0.390307 -0.65 -0.65 0.390309 -0.65 1.67359L0 1.67359L0.65 1.67359C0.65 1.10828 1.10828 0.65 1.67359 0.65L1.67359 5.00699e-14ZM5.05582 0.518756L5.60495 0.170972C5.28121 -0.340193 4.71829 -0.65 4.11323 -0.65L4.11323 1.23058e-13L4.11323 0.65C4.27282 0.65 4.4213 0.731715 4.50669 0.86654L5.05582 0.518756ZM6.52313 1.86603L6.52313 1.21603C6.36354 1.21603 6.21507 1.13431 6.12968 0.999489L5.58054 1.34727L5.03141 1.69506C5.35515 2.20622 5.91808 2.51603 6.52313 2.51603L6.52313 1.86603ZM13 3.53962L13.65 3.53962C13.65 2.25634 12.6097 1.21603 11.3264 1.21603L11.3264 1.86603L11.3264 2.51603C11.8917 2.51603 12.35 2.97431 12.35 3.53962L13 3.53962ZM13 9.4837L12.35 9.4837C12.35 10.049 11.8917 10.5073 11.3264 10.5073L11.3264 11.1573L11.3264 11.8073C12.6097 11.8073 13.65 10.767 13.65 9.4837L13 9.4837Z" }));
1707
- }
1708
- function IconFolderOpen() {
1709
- return NativeSvg("0 0 16 16", 16, [
1710
- NativePath("M5.19629 1.57104C5.81144 1.5711 6.38623 1.8786 6.72754 2.39038L7.19922 3.09839C7.28454 3.22635 7.42824 3.30344 7.58203 3.30347H12.1699C13.5039 3.30348 14.5859 4.38548 14.5859 5.71948V6.62671C15.2694 7.02689 15.6605 7.85012 15.4385 8.68726L14.3848 12.658C14.1037 13.7164 13.1449 14.4527 12.0498 14.4529H2.91699C1.51651 14.4529 0.451662 13.2814 0.501954 11.9519V3.98706C0.501954 2.65305 1.58396 1.57104 2.91797 1.57104H5.19629ZM3.7793 7.75562C3.30994 7.75562 2.89883 8.07153 2.77832 8.52515L1.91602 11.7722C1.74167 12.4291 2.23734 13.073 2.91699 13.073H12.0498C12.5191 13.0728 12.9304 12.757 13.0508 12.3035L14.1045 8.33374C14.1819 8.04202 13.9619 7.756 13.6602 7.75562H3.7793ZM2.91797 2.9519C2.34625 2.9519 1.88281 3.41534 1.88281 3.98706V7.2937C2.33068 6.7269 3.02249 6.37476 3.7793 6.37476H13.2051V5.71948C13.2051 5.14777 12.7416 4.68434 12.1699 4.68433H7.58203C6.96675 4.6843 6.39209 4.37595 6.05078 3.86401L5.5791 3.15601C5.49379 3.02821 5.34995 2.95196 5.19629 2.9519H2.91797Z"),
1711
- h("path", { fill: "currentColor", opacity: "0.2", d: "M13.6602 7.75525C13.9618 7.7556 14.1815 8.04179 14.1045 8.33337L13.0508 12.3031C12.9304 12.7567 12.5191 13.0725 12.0498 13.0726H2.91701C2.23744 13.0725 1.7417 12.4287 1.91603 11.7719L2.77834 8.52478C2.89898 8.07146 3.31018 7.75532 3.77931 7.75525H13.6602ZM5.1963 2.95154C5.34985 2.95159 5.49377 3.02803 5.57912 3.15564L6.0508 3.86365C6.39205 4.37553 6.96685 4.68385 7.58205 4.68396H12.1699C12.7416 4.68396 13.2049 5.14754 13.2051 5.71912V6.37439H3.77931C3.02267 6.37444 2.33067 6.72671 1.88283 7.29333V3.98669C1.88299 3.4152 2.34649 2.95168 2.91798 2.95154H5.1963Z" }),
1712
- ]);
1713
- }
1714
1993
  function IconChevron() {
1715
1994
  return NativeSvg("0 0 14 14", 14, NativePath("M4.25 2.828v8.344c0 .49.592.735.939.389l4.172-4.172a.55.55 0 0 0 0-.778L5.189 2.439c-.347-.347-.939-.101-.939.389Z"));
1716
1995
  }
@@ -1780,18 +2059,35 @@ window.__ModuleLoader__.load({
1780
2059
  NativePath("M0 0L-0.5 0L-0.5 7L0 7L0.5 7L0.5 0L0 0ZM3 10L3 10.5L8 10.5L8 10L8 9.5L3 9.5L3 10ZM0 7L-0.5 7C-0.5 8.933 1.067 10.5 3 10.5L3 10L3 9.5C1.61929 9.5 0.5 8.38071 0.5 7L0 7Z"),
1781
2060
  );
1782
2061
  }
1783
- function SessionHoverCard({ title, time, running, style, cardRef, t = fallbackT }) {
1784
- return h("div", { className: "ima-n-hover", style, ref: cardRef },
2062
+ function ChannelSettingsIcon() {
2063
+ return typeof IconSettingsOutline16 === "function" ? h(IconSettingsOutline16, { size: 16 }) : NativeSvg("0 0 16 16", 16, NativePath("M8 2.2a1.2 1.2 0 0 1 1.15.84l.16.5.5.16A1.2 1.2 0 0 1 11.3 5.3l.45.45a1.2 1.2 0 0 1 0 1.7l-.45.45-.16.5A1.2 1.2 0 0 1 10.3 9.7l-.5.16-.16.5A1.2 1.2 0 0 1 8.5 11.8H7.5a1.2 1.2 0 0 1-1.15-.84l-.16-.5-.5-.16A1.2 1.2 0 0 1 4.7 9.7l-.45-.45a1.2 1.2 0 0 1 0-1.7l.45-.45.16-.5A1.2 1.2 0 0 1 5.7 5.3l.5-.16.16-.5A1.2 1.2 0 0 1 7.5 2.2H8Zm0 4.3A1.5 1.5 0 1 0 8 9.5 1.5 1.5 0 0 0 8 6.5Z"));
2064
+ }
2065
+ function SessionHoverStatusDot({ running }) {
2066
+ if (typeof StateDot === "function") return h(StateDot, { state: running ? "ongoing" : "done" });
2067
+ return h("span", { className: running ? "ima-n-hover-dot is-run" : "ima-n-hover-dot" });
2068
+ }
2069
+ function SessionHoverContent({ title, time, running, t = fallbackT }) {
2070
+ return h("div", { className: "ima-n-hover-content" },
1785
2071
  h("div", { className: "ima-n-hover-title" }, title),
1786
2072
  time ? h("div", { className: "ima-n-hover-time" }, time) : null,
1787
2073
  h("div", { className: "ima-n-hover-state" },
1788
- h("span", { className: running ? "ima-n-hover-dot is-run" : "ima-n-hover-dot" }),
2074
+ h(SessionHoverStatusDot, { running }),
1789
2075
  running ? t("rail.running") : t("rail.idle"),
1790
2076
  ),
1791
2077
  );
1792
2078
  }
1793
- function MoreIcon() {
1794
- return h(IconEllipsis);
2079
+ function SessionHoverCard({ title, time, running, style, cardRef, onMouseEnter, onMouseLeave, t = fallbackT }) {
2080
+ return h("div", { className: "ima-n-hover", style, ref: cardRef, onMouseEnter, onMouseLeave },
2081
+ h(SessionHoverContent, { title, time, running, t }),
2082
+ );
2083
+ }
2084
+ function nativeSessionHoverStyle(row, card, viewport) {
2085
+ const pad = 8;
2086
+ const left = row.right + pad;
2087
+ const top = row.top + card.height > viewport.height - pad
2088
+ ? Math.max(pad, viewport.height - card.height - pad)
2089
+ : Math.max(pad, row.top);
2090
+ return { position: "fixed", zIndex: 4100, left: Math.round(left) + "px", top: Math.round(top) + "px" };
1795
2091
  }
1796
2092
  const RUN_CELLS = [[0,0],[4,0],[8,0],[8,4],[8,8],[4,8],[0,8],[0,4]];
1797
2093
  function RunningStateDot() {
@@ -1801,61 +2097,37 @@ window.__ModuleLoader__.load({
1801
2097
  })
1802
2098
  );
1803
2099
  }
1804
- function relativeTime(value, t = fallbackT) {
2100
+ function relativeTimeParts(value, now) {
1805
2101
  const ts = Date.parse(value || "");
1806
- if (!Number.isFinite(ts)) return "";
1807
- const delta = Math.max(0, Date.now() - ts);
1808
- const min = Math.floor(delta / 60000);
1809
- if (min < 1) return t("time.now");
1810
- if (min < 60) return t("time.minutes", { count: min });
1811
- const hour = Math.floor(min / 60);
1812
- if (hour < 24) return t("time.hours", { count: hour });
1813
- return t("time.days", { count: Math.floor(hour / 24) });
2102
+ if (!Number.isFinite(ts)) return null;
2103
+ const MIN = 6e4;
2104
+ const HOUR = 36e5;
2105
+ const DAY = 864e5;
2106
+ const diff = Math.max(0, (now || Date.now()) - ts);
2107
+ if (diff < MIN) return { unit: "now", n: 0 };
2108
+ if (diff < HOUR) return { unit: "minutes", n: Math.floor(diff / MIN) };
2109
+ if (diff < DAY) return { unit: "hours", n: Math.floor(diff / HOUR) };
2110
+ if (diff < 30 * DAY) return { unit: "days", n: Math.floor(diff / DAY) };
2111
+ if (diff < 365 * DAY) return { unit: "months", n: Math.floor(diff / (30 * DAY)) };
2112
+ return { unit: "years", n: Math.floor(diff / (365 * DAY)) };
2113
+ }
2114
+ function timeLabel(value, t = fallbackT, now) {
2115
+ const parts = relativeTimeParts(value, now);
2116
+ if (!parts) return "";
2117
+ return parts.unit === "now" ? t("time.now") : t("time." + parts.unit, { n: parts.n, count: parts.n });
2118
+ }
2119
+ function hoverTimeLabel(value, t = fallbackT, now) {
2120
+ const parts = relativeTimeParts(value, now);
2121
+ if (!parts) return "";
2122
+ if (parts.unit === "now") return t("time.now");
2123
+ return t("time.ago", { t: t("time." + parts.unit, { n: parts.n, count: parts.n }) });
1814
2124
  }
1815
-
1816
-
1817
- function pointerPoint(event) {
1818
- const x = Number(event && event.clientX);
1819
- const y = Number(event && event.clientY);
1820
- return {
1821
- x: Number.isFinite(x) ? x : 8,
1822
- y: Number.isFinite(y) ? y : 8,
1823
- };
1824
- }
1825
- function clampMenuPoint(x, y, width, height) {
1826
- const pad = 8;
1827
- const vw = window.innerWidth || width + pad * 2;
1828
- const vh = window.innerHeight || height + pad * 2;
1829
- return {
1830
- x: Math.max(pad, Math.min(x, Math.max(pad, vw - width - pad))),
1831
- y: Math.max(pad, Math.min(y, Math.max(pad, vh - height - pad))),
1832
- };
1833
- }
1834
- function SessionPointerMenu({ native, x, y, items, onPick }) {
1835
- const ref = useRef(null);
1836
- const [pos, setPos] = useState(() => clampMenuPoint(x, y, native ? 218 : 132, native ? 176 : 140));
1837
- useLayoutEffect(() => {
1838
- const el = ref.current;
1839
- if (!el) return;
1840
- const rect = el.getBoundingClientRect();
1841
- setPos(clampMenuPoint(x, y, rect.width, rect.height));
1842
- }, [x, y]);
1843
- const node = h("div", {
1844
- ref,
1845
- className: native ? "ima-n-menu" : "ima-sess-menu",
1846
- "data-ima-session-menu": "",
1847
- style: { left: pos.x + "px", top: pos.y + "px" },
1848
- onClick: (event) => event.stopPropagation(),
1849
- }, items.map((item) => h("button", {
1850
- key: item.id,
1851
- type: "button",
1852
- className: item.danger ? "danger" : undefined,
1853
- onClick: () => onPick(item),
1854
- }, native && h("span", { className: "ima-n-mi" }, item.icon), item.label)));
1855
- return ReactDOM.createPortal(node, document.body);
2125
+ function relativeTime(value, t = fallbackT) {
2126
+ return timeLabel(value, t);
1856
2127
  }
1857
2128
 
1858
- function ChannelSessionRow({ sess, selected, onOpen, onChanged, skin, sessionActions, sessionById, menuOpen, onMenuChange }) {
2129
+
2130
+ function ChannelSessionRow({ sess, selected, onOpen, onChanged, skin, sessionActions, sessionById, menuOpen, onMenuChange, canDelete, onDeleteSession, flat }) {
1859
2131
  const t = arguments[0].t || fallbackT;
1860
2132
  const menu = !!menuOpen;
1861
2133
  const setMenu = (next) => onMenuChange(!!next);
@@ -1868,7 +2140,9 @@ window.__ModuleLoader__.load({
1868
2140
  const [hoverStyle, setHoverStyle] = useState({});
1869
2141
  const title = sess.title || sess.chatId;
1870
2142
  const native = skin !== "codex";
2143
+ const useOfficialHover = native && typeof HoverCard === "function";
1871
2144
  const running = !!(sess.running || (sessionById && sessionById[sess.sessionId] && sessionById[sess.sessionId].running));
2145
+ const hoverTitle = (sessionById && sessionById[sess.sessionId] && (sessionById[sess.sessionId].displayTitle || sessionById[sess.sessionId].title)) || title;
1872
2146
  const showHover = () => {
1873
2147
  if (menu || !native) return;
1874
2148
  if (hoverTimer.current) window.clearTimeout(hoverTimer.current);
@@ -1880,15 +2154,27 @@ window.__ModuleLoader__.load({
1880
2154
  };
1881
2155
  useLayoutEffect(() => {
1882
2156
  if (!hoverOpen || menu || !rowRef.current) return;
1883
- const row = rowRef.current.getBoundingClientRect();
1884
2157
  const card = hoverRef.current;
1885
- const height = card && card.offsetHeight ? card.offsetHeight : 96;
1886
- const top = row.top + height > window.innerHeight - 8 ? Math.max(8, window.innerHeight - height - 8) : Math.max(8, row.top);
1887
- setHoverStyle({ position: "fixed", zIndex: 4100, left: Math.round(row.right + 8) + "px", top: Math.round(top) + "px" });
2158
+ const size = card ? { width: card.offsetWidth || 220, height: card.offsetHeight || 96 } : { width: 220, height: 96 };
2159
+ const update = () => {
2160
+ if (!rowRef.current) return;
2161
+ setHoverStyle(nativeSessionHoverStyle(rowRef.current.getBoundingClientRect(), {
2162
+ width: (hoverRef.current && hoverRef.current.offsetWidth) || size.width,
2163
+ height: (hoverRef.current && hoverRef.current.offsetHeight) || size.height,
2164
+ }, { width: window.innerWidth, height: window.innerHeight }));
2165
+ };
2166
+ update();
2167
+ window.addEventListener("resize", update);
2168
+ document.addEventListener("scroll", update, true);
2169
+ return () => {
2170
+ window.removeEventListener("resize", update);
2171
+ document.removeEventListener("scroll", update, true);
2172
+ };
1888
2173
  }, [hoverOpen, menu, title, running]);
1889
2174
  useEffect(() => () => { if (hoverTimer.current) window.clearTimeout(hoverTimer.current); }, []);
2175
+ const omitStatusSlot = native && !!flat && !running;
1890
2176
  const rowClass = native
1891
- ? ("ima-native-session" + (selected ? " on" : "") + (menu ? " menu-on" : ""))
2177
+ ? ("ima-n-sess" + (selected ? " is-on" : "") + (menu ? " is-menu" : "") + (omitStatusSlot ? " is-flat-idle" : ""))
1892
2178
  : ("dcu-wb-session" + (selected ? " dcu-wb-selected" : "") + (menu ? " dcu-wb-menu-open" : ""));
1893
2179
  const syncList = (groups) => { if (groups) onChanged(groups); };
1894
2180
  const run = (action, extra) => {
@@ -1941,9 +2227,9 @@ window.__ModuleLoader__.load({
1941
2227
  }).then((data) => { if (data.ok) syncList(data.groups); }).catch(() => undefined);
1942
2228
  };
1943
2229
  if (renaming) {
1944
- return h("div", { className: rowClass },
2230
+ return h("div", { className: rowClass, ref: rowRef },
1945
2231
  h("input", {
1946
- className: "ima-rename",
2232
+ className: native ? "ima-n-rename" : "ima-rename",
1947
2233
  value: draft,
1948
2234
  autoFocus: true,
1949
2235
  "aria-label": t("rail.renameAria"),
@@ -1958,50 +2244,116 @@ window.__ModuleLoader__.load({
1958
2244
  );
1959
2245
  }
1960
2246
  const menuItems = [
1961
- { id: "rename", label: t("rail.rename"), icon: h(IconEdit), go: () => { setRenaming(true); } },
1962
- { id: "fork", label: t("rail.fork"), icon: h(IconBranch), go: () => run("fork") },
1963
- { id: "archive", label: t("rail.archive"), icon: h(IconArchive), go: () => run("archive") },
2247
+ { id: "rename", label: t("rail.rename"), icon: h(IconEditOutline16) },
2248
+ { id: "fork", label: t("rail.fork"), icon: h(IconBranchOutline16) },
2249
+ { id: "archive", label: t("rail.archive"), icon: h(IconArchiveOutline20, { size: 16 }) },
2250
+ ...(canDelete ? [{ id: "delete-session", label: t("rail.deleteSession"), icon: h(IconTrashOutline16), danger: true }] : []),
1964
2251
  ];
1965
- return h("div", {
2252
+ const row = h("div", {
1966
2253
  ref: rowRef,
1967
- className: native ? ("ima-n-sess" + (selected ? " on" : "") + (menu ? " menu-on" : "")) : rowClass,
2254
+ className: rowClass,
1968
2255
  role: "treeitem",
1969
2256
  tabIndex: 0,
1970
2257
  "aria-selected": selected,
2258
+ "data-n-menu-root": sess.sessionId,
1971
2259
  onClick: () => { setMenu(false); hideHover(); onOpen(sess.sessionId); },
1972
- onMouseEnter: showHover,
1973
- onMouseLeave: hideHover,
2260
+ onMouseEnter: useOfficialHover ? undefined : showHover,
2261
+ onMouseLeave: useOfficialHover ? undefined : hideHover,
1974
2262
  onKeyDown: (e) => { if (e.key === "Enter" || e.key === " ") { e.preventDefault(); setMenu(false); onOpen(sess.sessionId); } },
1975
- onContextMenu: (e) => { e.preventDefault(); e.stopPropagation(); hideHover(); onMenuChange(true, e); },
2263
+ onContextMenu: (e) => { e.preventDefault(); e.stopPropagation(); hideHover(); onMenuChange(true); },
1976
2264
  },
1977
- native && h("span", { className: "ima-n-slot" }, running ? h(RunningStateDot) : null),
2265
+ native && !omitStatusSlot && h("span", { className: "ima-n-slot" }, running ? h(RunningStateDot) : null),
1978
2266
  h("span", { className: native ? "ima-n-title" : "dcu-wb-session-title" }, title),
1979
- native && h("span", { className: "ima-n-time" }, relativeTime(sess.updatedAt, t)),
2267
+ native && h("span", { className: "ima-n-time" }, timeLabel(sess.updatedAt, t)),
1980
2268
  h("span", { className: native ? "ima-n-acts" : "dcu-wb-actions" },
1981
- h("button", {
1982
- type: "button",
1983
- className: native ? "ima-n-ico" : "dcu-wb-more",
1984
- "data-ima-session-more": "",
1985
- "aria-expanded": menu,
1986
- "aria-label": t("action.more", { channel: title }),
1987
- onClick: (e) => { e.stopPropagation(); onMenuChange(!menu, e); },
1988
- }, native ? h(IconEllipsis) : h(MoreIcon)),
2269
+ h(Menu, {
2270
+ open: menu,
2271
+ onClose: () => onMenuChange(false),
2272
+ items: menuItems,
2273
+ onSelect: (action) => {
2274
+ onMenuChange(false);
2275
+ if (action === "rename") setRenaming(true);
2276
+ if (action === "fork") run("fork");
2277
+ if (action === "archive") run("archive");
2278
+ if (action === "delete-session") onDeleteSession && onDeleteSession();
2279
+ },
2280
+ portal: true,
2281
+ closeOnPointerLeave: true,
2282
+ anchor: h("button", {
2283
+ type: "button",
2284
+ className: native ? "ima-n-ico" : "dcu-wb-more",
2285
+ "data-ima-session-more": "",
2286
+ "aria-expanded": menu,
2287
+ "aria-label": t("action.more", { channel: title }),
2288
+ onMouseDown: (e) => e.stopPropagation(),
2289
+ onClick: (e) => { e.stopPropagation(); hideHover(); onMenuChange(!menu); },
2290
+ }, h(IconEllipsisOutline16, { size: 16 })),
2291
+ }),
1989
2292
  ),
1990
- hoverOpen && !menu && native && h(SessionHoverCard, {
1991
- title,
1992
- time: relativeTime(sess.updatedAt, t),
2293
+ !useOfficialHover && hoverOpen && !menu && native && typeof document !== "undefined" && ReactDOM.createPortal(h(SessionHoverCard, {
2294
+ title: hoverTitle,
2295
+ time: hoverTimeLabel(sess.updatedAt, t),
1993
2296
  running,
1994
2297
  t,
1995
2298
  style: hoverStyle,
1996
2299
  cardRef: hoverRef,
1997
- }),
1998
- menu && h(SessionPointerMenu, {
1999
- native,
2000
- x: menuOpen && menuOpen.x,
2001
- y: menuOpen && menuOpen.y,
2002
- items: menuItems,
2003
- onPick: (item) => { setMenu(false); item.go(); },
2004
- }),
2300
+ onMouseEnter: showHover,
2301
+ onMouseLeave: hideHover,
2302
+ }), document.body),
2303
+ );
2304
+ if (useOfficialHover) {
2305
+ return h(HoverCard, {
2306
+ anchor: row,
2307
+ content: h(SessionHoverContent, { title: hoverTitle, time: hoverTimeLabel(sess.updatedAt, t), running, t }),
2308
+ disabled: menu,
2309
+ copyText: title,
2310
+ copyLabel: t("copy"),
2311
+ copiedLabel: t("hover.copied"),
2312
+ });
2313
+ }
2314
+ return row;
2315
+ }
2316
+
2317
+ function ChannelGroupRow({ id, name, expanded, hasCurrentSession, menuOpen, canArchiveGroup, onToggle, onMenuChange, onChannelSettings, onArchiveGroup, t = fallbackT }) {
2318
+ const items = [
2319
+ { id: "channel-settings", label: t("rail.channelSettings"), icon: h(ChannelSettingsIcon) },
2320
+ ...(canArchiveGroup ? [
2321
+ { type: "separator", id: "archive-separator" },
2322
+ { id: "archive-group", label: t("rail.archiveGroup"), icon: h(IconArchiveOutline20, { size: 16 }), danger: true },
2323
+ ] : []),
2324
+ ];
2325
+ const rowClass = "ima-n-row" + (hasCurrentSession ? " has-current-session" : "") + (menuOpen ? " is-menu" : "");
2326
+ return h("div", {
2327
+ className: rowClass,
2328
+ role: "treeitem",
2329
+ "aria-expanded": expanded,
2330
+ "data-n-group": id,
2331
+ onClick: onToggle,
2332
+ },
2333
+ h("span", { className: "ima-n-slot ima-n-folder" }, h(Logo, { id, small: true })),
2334
+ h("span", { className: "ima-n-slot ima-n-chevron" }, h("span", { className: expanded ? "ima-n-arrow is-open" : "ima-n-arrow" }, h(IconChevron))),
2335
+ h("span", { className: "ima-n-project-text" }, h("span", { className: "ima-n-title" }, name)),
2336
+ h("span", { className: "ima-n-acts" },
2337
+ h(Menu, {
2338
+ open: menuOpen,
2339
+ onClose: () => onMenuChange(false),
2340
+ items,
2341
+ onSelect: (action) => {
2342
+ onMenuChange(false);
2343
+ if (action === "channel-settings") onChannelSettings && onChannelSettings();
2344
+ if (action === "archive-group") onArchiveGroup && onArchiveGroup();
2345
+ },
2346
+ portal: true,
2347
+ closeOnPointerLeave: true,
2348
+ anchor: h("button", {
2349
+ type: "button",
2350
+ className: "ima-n-ico",
2351
+ "aria-label": t("rail.groupActions", { name }),
2352
+ onMouseDown: (e) => e.stopPropagation(),
2353
+ onClick: (e) => { e.stopPropagation(); onMenuChange(!menuOpen); },
2354
+ }, h(IconEllipsisOutline16, { size: 16 })),
2355
+ }),
2356
+ ),
2005
2357
  );
2006
2358
  }
2007
2359
 
@@ -2012,7 +2364,7 @@ window.__ModuleLoader__.load({
2012
2364
 
2013
2365
  function ChannelRailWithSessions(props) {
2014
2366
  const selectedId = typeof props.useSessions === "function"
2015
- ? props.useSessions((state) => (state && state.current) || null)
2367
+ ? props.useSessions((state) => currentSessionId(state))
2016
2368
  : (props.selectedId || null);
2017
2369
  const archivedIds = typeof props.useWorkspaces === "function"
2018
2370
  ? props.useWorkspaces((state) => (state && state.archivedSessionIds) || [])
@@ -2032,15 +2384,25 @@ window.__ModuleLoader__.load({
2032
2384
  const [groups, setGroups] = useState([]);
2033
2385
  const [folded, setFolded] = useState({});
2034
2386
  const [error, setError] = useState("");
2035
- const [openMenu, setOpenMenu] = useState(null);
2387
+ const [openMenu, setOpenMenu] = useState();
2388
+ const [openGroupMenu, setOpenGroupMenu] = useState();
2036
2389
  const [query, setQuery] = useState("");
2037
2390
  const [sort, setSort] = useState("time");
2038
2391
  const [groupMode, setGroupMode] = useState("workspace");
2392
+ const [archiveManagerInstalled, setArchiveManagerInstalled] = useState(() => typeof document !== "undefined" && hasArchiveManagerPlugin(document));
2393
+ const [deleteTarget, setDeleteTarget] = useState();
2394
+ const [deleteBusy, setDeleteBusy] = useState(false);
2395
+ const [deleteError, setDeleteError] = useState();
2396
+ const [archiveGroupTarget, setArchiveGroupTarget] = useState();
2397
+ const [archiveGroupBusy, setArchiveGroupBusy] = useState(false);
2398
+ const [archiveGroupError, setArchiveGroupError] = useState();
2039
2399
  const selectedId = props.selectedId;
2040
2400
  const archived = new Set(props.archivedIds || []);
2041
2401
  const skin = props.skin || channelSkin;
2042
2402
  const native = skin !== "codex";
2043
- const open = (id) => openListedSession(id, props.openSession || props.open);
2403
+ const open = (id) => openListedSession(resolveHostSessionId(id, props.sessionById), props.openSession || props.open);
2404
+ const canDelete = canDeleteChannelSession(archiveManagerInstalled, props.deleteSession);
2405
+ const canArchiveGroup = canArchiveChannelGroup(archiveManagerInstalled, props.archiveSession);
2044
2406
  useEffect(() => {
2045
2407
  ensureStyle();
2046
2408
  const load = () => api("/channels").then((data) => {
@@ -2052,22 +2414,39 @@ window.__ModuleLoader__.load({
2052
2414
  return () => clearInterval(timer);
2053
2415
  }, []);
2054
2416
  useEffect(() => {
2055
- if (!openMenu) return undefined;
2056
- const onPointerDown = (event) => {
2057
- const target = event.target;
2058
- if (target && target.closest && target.closest("[data-ima-session-menu],[data-ima-session-more]")) return;
2059
- setOpenMenu(null);
2060
- };
2061
- const onKeyDown = (event) => {
2062
- if (event.key === "Escape") setOpenMenu(null);
2063
- };
2064
- document.addEventListener("pointerdown", onPointerDown, true);
2065
- document.addEventListener("keydown", onKeyDown);
2066
- return () => {
2067
- document.removeEventListener("pointerdown", onPointerDown, true);
2068
- document.removeEventListener("keydown", onKeyDown);
2069
- };
2070
- }, [openMenu]);
2417
+ if (typeof document === "undefined" || typeof MutationObserver === "undefined") return undefined;
2418
+ const refresh = () => { setArchiveManagerInstalled(hasArchiveManagerPlugin(document)); };
2419
+ refresh();
2420
+ const observer = new MutationObserver(refresh);
2421
+ observer.observe(document.documentElement, { childList: true, subtree: true });
2422
+ return () => observer.disconnect();
2423
+ }, []);
2424
+ const confirmDelete = () => {
2425
+ if (!deleteTarget || typeof props.deleteSession !== "function" || deleteBusy) return;
2426
+ const target = deleteTarget;
2427
+ setDeleteBusy(true);
2428
+ setDeleteError(undefined);
2429
+ Promise.resolve(props.deleteSession(target.id))
2430
+ .then(() => api("/sessions/remove", {
2431
+ method: "POST",
2432
+ headers: { "content-type": "application/json" },
2433
+ body: JSON.stringify({ sessionId: target.id }),
2434
+ }).then((data) => { if (data.ok && data.groups) setGroups(data.groups); }).catch(() => undefined))
2435
+ .then(() => { setDeleteTarget(undefined); })
2436
+ .catch((caught) => { setDeleteError(caught instanceof Error ? caught.message : t("error.action")); })
2437
+ .finally(() => { setDeleteBusy(false); });
2438
+ };
2439
+ const confirmArchiveGroup = () => {
2440
+ if (!archiveGroupTarget || typeof props.archiveSession !== "function" || archiveGroupBusy) return;
2441
+ const target = archiveGroupTarget;
2442
+ setArchiveGroupBusy(true);
2443
+ setArchiveGroupError(undefined);
2444
+ archiveChannelGroup(target.sessionIds, props.archiveSession)
2445
+ .then(() => api("/channels").then((data) => { if (data.ok) setGroups(data.groups || []); }).catch(() => undefined))
2446
+ .then(() => { setArchiveGroupTarget(undefined); })
2447
+ .catch((caught) => { setArchiveGroupError(caught instanceof Error ? caught.message : t("error.action")); })
2448
+ .finally(() => { setArchiveGroupBusy(false); });
2449
+ };
2071
2450
  const needle = query.trim().toLowerCase();
2072
2451
  const visibleGroups = groups.map((g) => {
2073
2452
  const sessions = (g.sessions || []).map((sess) => {
@@ -2096,43 +2475,73 @@ window.__ModuleLoader__.load({
2096
2475
  return h("div", { className: native ? "ima-native ima-rail" : "dcu-wb ima-rail" },
2097
2476
  h("style", null, WB_CSS),
2098
2477
  h(ChannelWorkspaceHead, { query, sort, groupMode, onQuery: setQuery, onSort: setSort, onGroupMode: setGroupMode, t }),
2478
+ h("div", { className: native ? "ima-n-list-area" : "dcu-wb-list-area" },
2099
2479
  h("div", { className: native ? "ima-native-tree" : "dcu-wb-tree", role: "tree" },
2100
2480
  error && h("div", { className: native ? "ima-native-empty" : "dcu-wb-empty" }, error),
2101
2481
  !error && visibleGroups.length === 0 && h("div", { className: native ? "ima-native-empty" : "dcu-wb-empty" }, t("rail.empty")),
2102
2482
  ...visibleGroups.map((g) => {
2103
2483
  const visible = g.sessions || [];
2104
2484
  const expanded = !folded[g.id];
2485
+ const hasCurrentSession = typeof selectedId === "string" && visible.some((sess) => isCurrentListedSession(selectedId, sess.sessionId, props.sessionById));
2105
2486
  return h("div", { key: g.id, className: native ? "ima-native-project" : "dcu-wb-project" },
2106
- groupMode !== "list" && h("button", {
2107
- className: native ? "ima-n-row" : "dcu-wb-project-head",
2108
- type: "button",
2109
- role: "treeitem",
2110
- "aria-expanded": expanded,
2111
- onClick: () => setFolded({ ...folded, [g.id]: !folded[g.id] }),
2112
- },
2113
- native
2114
- ? [
2115
- h("span", { key: "folder", className: "ima-n-slot ima-n-folder" }, h(Logo, { id: g.id, small: true })),
2116
- h("span", { key: "title", className: "ima-n-title" }, channelLabel(g, t)),
2117
- ]
2118
- : [
2119
- h("span", { key: "folder", className: "dcu-wb-folder" }, h(Logo, { id: g.id, small: true })),
2120
- h("span", { key: "title", className: "dcu-wb-project-title" }, channelLabel(g, t)),
2121
- ],
2487
+ groupMode !== "list" && (native
2488
+ ? h(ChannelGroupRow, {
2489
+ id: g.id,
2490
+ name: channelLabel(g, t),
2491
+ expanded,
2492
+ hasCurrentSession,
2493
+ menuOpen: openGroupMenu === g.id,
2494
+ canArchiveGroup,
2495
+ onToggle: () => setFolded({ ...folded, [g.id]: !folded[g.id] }),
2496
+ onMenuChange: (next) => {
2497
+ setOpenMenu(undefined);
2498
+ setOpenGroupMenu(next ? g.id : undefined);
2499
+ },
2500
+ onChannelSettings: () => {
2501
+ if (typeof props.openChannelSettings === "function") props.openChannelSettings({ channelId: g.id, name: channelLabel(g, t) });
2502
+ },
2503
+ onArchiveGroup: () => {
2504
+ setArchiveGroupError(undefined);
2505
+ setArchiveGroupTarget({
2506
+ id: g.id,
2507
+ name: channelLabel(g, t),
2508
+ sessionIds: visible.map((sess) => sess.sessionId),
2509
+ });
2510
+ },
2511
+ t,
2512
+ })
2513
+ : h("button", {
2514
+ className: "dcu-wb-project-head",
2515
+ type: "button",
2516
+ role: "treeitem",
2517
+ "aria-expanded": expanded,
2518
+ onClick: () => setFolded({ ...folded, [g.id]: !folded[g.id] }),
2519
+ },
2520
+ h("span", { className: "dcu-wb-folder" }, h(Logo, { id: g.id, small: true })),
2521
+ h("span", { className: "dcu-wb-project-title" }, channelLabel(g, t)),
2522
+ )
2122
2523
  ),
2123
2524
  (groupMode === "list" || !folded[g.id]) && visible.length > 0 && visible.map((sess) => h(ChannelSessionRow, {
2124
2525
  key: sess.sessionId,
2125
2526
  sess,
2126
- selected: selectedId === sess.sessionId,
2527
+ flat: groupMode === "list",
2528
+ selected: isCurrentListedSession(selectedId, sess.sessionId, props.sessionById),
2127
2529
  sessionById: props.sessionById,
2128
- menuOpen: openMenu && openMenu.id === sess.sessionId ? openMenu : null,
2129
- onMenuChange: (open, event) => setOpenMenu((cur) => {
2130
- if (!open) return cur && cur.id === sess.sessionId ? null : cur;
2131
- const point = pointerPoint(event);
2132
- return { id: sess.sessionId, x: point.x, y: point.y };
2133
- }),
2134
- onOpen: open,
2530
+ menuOpen: openMenu === sess.sessionId,
2531
+ onMenuChange: (next) => {
2532
+ setOpenGroupMenu(undefined);
2533
+ setOpenMenu(next ? sess.sessionId : undefined);
2534
+ },
2535
+ onOpen: (id) => { setOpenMenu(undefined); open(id); },
2135
2536
  onChanged: (next) => setGroups(next),
2537
+ canDelete,
2538
+ onDeleteSession: () => {
2539
+ setDeleteError(undefined);
2540
+ setDeleteTarget({
2541
+ id: sess.sessionId,
2542
+ title: String((props.sessionById && props.sessionById[sess.sessionId] && (props.sessionById[sess.sessionId].displayTitle || props.sessionById[sess.sessionId].title)) || sess.title || sess.chatId || sess.sessionId),
2543
+ });
2544
+ },
2136
2545
  skin,
2137
2546
  sessionActions: {
2138
2547
  renameSession: props.renameSession,
@@ -2146,6 +2555,35 @@ window.__ModuleLoader__.load({
2146
2555
  );
2147
2556
  }),
2148
2557
  ),
2558
+ ),
2559
+ h(Modal, {
2560
+ open: !!archiveGroupTarget,
2561
+ onClose: () => { if (!archiveGroupBusy) { setArchiveGroupTarget(undefined); setArchiveGroupError(undefined); } },
2562
+ closeLabel: t("rail.archiveGroupClose"),
2563
+ title: t("rail.archiveGroup"),
2564
+ footer: h("div", { className: "ima-n-dialog-actions" },
2565
+ h(Button, { variant: "outline", disabled: archiveGroupBusy, onClick: () => { setArchiveGroupTarget(undefined); setArchiveGroupError(undefined); } }, t("rail.archiveGroupCancel")),
2566
+ h(Button, { variant: "outline", className: "ima-n-danger-button", disabled: archiveGroupBusy, onClick: confirmArchiveGroup }, t("rail.archiveGroupConfirm")),
2567
+ ),
2568
+ },
2569
+ h("p", { className: "ima-n-dialog-copy" }, archiveGroupTarget ? t("rail.archiveGroupDescription", { name: archiveGroupTarget.name, count: archiveGroupTarget.sessionIds.length }) : ""),
2570
+ archiveGroupBusy && h("div", { className: "ima-n-dialog-status", role: "status" }, t("rail.archiveGroupPending")),
2571
+ archiveGroupError && h("div", { className: "ima-n-dialog-error", role: "alert" }, t("rail.archiveGroupFailed", { message: archiveGroupError })),
2572
+ ),
2573
+ h(Modal, {
2574
+ open: !!deleteTarget,
2575
+ onClose: () => { if (!deleteBusy) { setDeleteTarget(undefined); setDeleteError(undefined); } },
2576
+ closeLabel: t("rail.deleteSessionClose"),
2577
+ title: t("rail.deleteSession"),
2578
+ footer: h("div", { className: "ima-n-dialog-actions" },
2579
+ h(Button, { variant: "outline", disabled: deleteBusy, onClick: () => { setDeleteTarget(undefined); setDeleteError(undefined); } }, t("rail.deleteSessionCancel")),
2580
+ h(Button, { variant: "outline", className: "ima-n-danger-button", disabled: deleteBusy, onClick: confirmDelete }, t("rail.deleteSessionConfirm")),
2581
+ ),
2582
+ },
2583
+ h("p", { className: "ima-n-dialog-copy" }, deleteTarget ? t("rail.deleteSessionDescription", { name: deleteTarget.title }) : ""),
2584
+ deleteBusy && h("div", { className: "ima-n-dialog-status", role: "status" }, t("rail.deleteSessionPending")),
2585
+ deleteError && h("div", { className: "ima-n-dialog-error", role: "alert" }, t("rail.deleteSessionFailed", { message: deleteError })),
2586
+ ),
2149
2587
  );
2150
2588
  }
2151
2589
 
@@ -2184,7 +2622,7 @@ window.__ModuleLoader__.load({
2184
2622
  .map((id) => snap.byId[id])
2185
2623
  .filter((item) => item && !assigned.has(item.id) && isTaskSessionItem(item) && !archived.has(item.id));
2186
2624
  if (ungrouped.length) groups.push({ id: "", label: t("rail.ungrouped"), sessions: ungrouped });
2187
- return h(TaskListView, { groups, current: snap.current, openSession: props.openSession, t });
2625
+ return h(TaskListView, { groups, current: currentSessionId(snap), openSession: props.openSession, t });
2188
2626
  }
2189
2627
 
2190
2628
  function TaskListView({ groups, current, openSession, t = fallbackT }) {
@@ -2318,9 +2756,11 @@ window.__ModuleLoader__.load({
2318
2756
  const [tab, setTab] = useState(() => {
2319
2757
  try { return localStorage.getItem(TAB_KEY) || "tasks"; } catch { return "tasks"; }
2320
2758
  });
2321
- const currentId = typeof rawUseSessions === "function"
2322
- ? rawUseSessions((state) => (state && state.current) || null)
2323
- : (props.selectedId || null);
2759
+ const sessionSnap = typeof rawUseSessions === "function"
2760
+ ? rawUseSessions((state) => state)
2761
+ : undefined;
2762
+ const currentId = sessionSnap ? currentSessionId(sessionSnap) : (props.selectedId || null);
2763
+ const sessionById = (sessionSnap && sessionSnap.byId) || {};
2324
2764
  const useTaskSessions = useCallback((selector, eq) => {
2325
2765
  if (typeof rawUseSessions !== "function") return selector({ ids: [], byId: {}, current: null });
2326
2766
  return rawUseSessions((state) => selector(applyRegistryFilters(filterTaskSessions(state), nativeTabs)), eq);
@@ -2347,8 +2787,10 @@ window.__ModuleLoader__.load({
2347
2787
  const matched = extraTabs.find((item) => item.matchSession && item.matchSession(currentId));
2348
2788
  if (matched && matched.id !== "schedule") setTab(matched.id);
2349
2789
  }, [currentId, extraTabs, membershipRevision]);
2350
- const openSession = (id) => openListedSession(id, props.openSession || props.open);
2351
- const officialProps = Object.assign({}, props, { useSessions: useTaskSessions, t: officialT });
2790
+ const openSession = (id) => {
2791
+ openListedSession(resolveHostSessionId(id, sessionById), props.openSession || props.open);
2792
+ };
2793
+ const officialProps = Object.assign({}, props, { useSessions: useTaskSessions, t: officialT, openSession, open: openSession });
2352
2794
  const channelRail = h(ChannelRail, {
2353
2795
  openSession,
2354
2796
  open: openSession,
@@ -2361,6 +2803,7 @@ window.__ModuleLoader__.load({
2361
2803
  deleteSession: props.deleteSession,
2362
2804
  forkSession: props.forkSession,
2363
2805
  openPath: props.openPath,
2806
+ openChannelSettings: props.openChannelSettings,
2364
2807
  t,
2365
2808
  });
2366
2809
  if (props.wide === false) return Official ? h(Official, officialProps) : null;
@@ -2457,20 +2900,32 @@ window.__ModuleLoader__.load({
2457
2900
  const modelT = ctx.locale.bind("model");
2458
2901
  const subscribeLocale = (listener) => ctx.locale.subscribe(listener);
2459
2902
  const localeSnapshot = () => ctx.locale.getSnapshot();
2903
+ const openChannelSettings = (request) => {
2904
+ const next = parseChannelSettingsRequest(request);
2905
+ if (!next) return;
2906
+ requestChannelSettings(next);
2907
+ openSettingsSection(
2908
+ [t("settings.label"), IM_LOCALES.en["settings.label"], IM_LOCALES.zh["settings.label"]],
2909
+ () => { requestChannelSettings(next); },
2910
+ );
2911
+ };
2460
2912
  function LocalizedChannelRail(props) {
2461
2913
  useSyncExternalStore(subscribeLocale, localeSnapshot, localeSnapshot);
2462
- return h(ChannelRail, Object.assign({}, props, { t }));
2914
+ return h(ChannelRail, Object.assign({}, props, { t, openChannelSettings }));
2463
2915
  }
2464
2916
  function LocalizedSessionSwitcher(props) {
2465
2917
  useSyncExternalStore(subscribeLocale, localeSnapshot, localeSnapshot);
2466
- return h(SessionSwitcher, Object.assign({}, props, { t, officialT: props.t }));
2918
+ return h(SessionSwitcher, Object.assign({}, props, { t, officialT: props.t, openChannelSettings }));
2467
2919
  }
2468
2920
  function LocalizedSettingsPage(props) {
2469
2921
  useSyncExternalStore(subscribeLocale, localeSnapshot, localeSnapshot);
2470
2922
  return h(SettingsPage, Object.assign({}, props, { t, permissionT, modelT }));
2471
2923
  }
2472
2924
  openImSession = (id) => {
2473
- try { ctx.sessions.open(id); return true; }
2925
+ try {
2926
+ if (window.__dshSessionsOpen) { window.__dshSessionsOpen(id); return true; }
2927
+ } catch { /* ignore */ }
2928
+ try { return openHostSession(ctx, id); }
2474
2929
  catch (error) { console.warn("[dsh-im-connect] 无法打开会话", id, error); return false; }
2475
2930
  };
2476
2931
  ctx.slots.inject("settings.section", () => ctx.slots.register({
@@ -2482,7 +2937,7 @@ window.__ModuleLoader__.load({
2482
2937
  locale: IM_LOCALE_NS,
2483
2938
  inject: () => ({
2484
2939
  createWorkspace: (input) => ctx.workspaces.create(input),
2485
- pickDirectory: () => ctx.workspaces.pickDirectory(),
2940
+ pickDirectory: () => pickHostDirectory(ctx),
2486
2941
  permissionT,
2487
2942
  modelT,
2488
2943
  }),
@@ -2493,22 +2948,13 @@ window.__ModuleLoader__.load({
2493
2948
  id: "im-connect-channels",
2494
2949
  locale: IM_LOCALE_NS,
2495
2950
  inject: () => ({
2496
- openSession: (id) => { ctx.sessions.open(id); },
2497
- open: (id) => { ctx.sessions.open(id); },
2498
- archiveSession: (id) => ctx.workspaces.archiveSession(id),
2499
- forkSession: (id) => {
2500
- ctx.sessions.fork({ sessionId: id, increaseTitle: true })
2501
- .then((childId) => { ctx.sessions.open(childId); })
2502
- .catch(() => undefined);
2503
- },
2504
- renameSession: async (sessionId, title) => {
2505
- const session = ctx.sessions.binding && ctx.sessions.binding(sessionId)?.session;
2506
- if (!session) throw new Error("unknown session");
2507
- const result = await session.rename(title);
2508
- if (!result.ok) throw new Error(result.error.message);
2509
- },
2951
+ openSession: (id) => { openHostSession(ctx, id); },
2952
+ open: (id) => { openHostSession(ctx, id); },
2953
+ archiveSession: (id) => archiveHostSession(ctx, id),
2954
+ forkSession: (id) => forkHostSession(ctx, id),
2955
+ renameSession: (sessionId, title) => renameHostSession(ctx, sessionId, title),
2510
2956
  }),
2511
- }, ChannelRail));
2957
+ }, LocalizedChannelRail));
2512
2958
 
2513
2959
  // 只包一层官方任务树,绝不在通知回调里再 register,否则会把启动卡在 Loading plugins。
2514
2960
  ctx.slots.inject("sidebar.workspaces", () => {
@@ -2556,11 +3002,7 @@ window.__ModuleLoader__.load({
2556
3002
  label: t("rail.channels"),
2557
3003
  order: 20,
2558
3004
  matchSession: isChannelSession,
2559
- render: (props) => h(LocalizedChannelRail, Object.assign({}, props, {
2560
- skin: "native",
2561
- openSession: (id) => openListedSession(id, props.openSession || props.open),
2562
- open: (id) => openListedSession(id, props.openSession || props.open),
2563
- })),
3005
+ render: (props) => h(LocalizedChannelRail, Object.assign({}, props, { skin: "native" })),
2564
3006
  });
2565
3007
  };
2566
3008
  refreshInsertedTab();