Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。
TypeScript agentai-agentai-assistantandroidclaude-codecodexelectroniosllmmacosreact-nativetypescriptwindows
feat(desktop): IM 官方栏对齐个人栏卡片模式并内嵌共享工作目录
Liziff6b243f8226
diff --git a/apps/desktop/src/renderer/components/settings/HookConnectionsSection.tsx b/apps/desktop/src/renderer/components/settings/HookConnectionsSection.tsxindex bdb0a6f830..ed86a674be 100644--- a/apps/desktop/src/renderer/components/settings/HookConnectionsSection.tsx+++ b/apps/desktop/src/renderer/components/settings/HookConnectionsSection.tsx@@ -1,36 +1,40 @@/**- * HookConnectionsSection —— 「Tina」页的「Slack 连接」块(原「远程控制」页- * 子块, 迁移后 i18n key 刻意留在 settings.remoteControl.hook.* 命名空间 ——- * 50+ 条 × 4 语言的纯搬家徒增 diff 与漏改风险)。+ * HookConnectionsSection —— 「IM 机器人」页「官方」栏(Cindy 渠道)。+ * i18n key 刻意留在 settings.remoteControl.hook.* 命名空间(50+ 条 × 4 语言的+ * 纯搬家徒增 diff 与漏改风险)。* ---------------------------------------------------------------------------- * 中心 slack-hook-server 的接入面(单条内置连接, 零凭证配置):+ * 中心 slack-hook-server 的接入面(内置连接, 零凭证配置)。结构与「个人」栏+ * 对齐: 每个渠道一张 ImChannelSettingsCard 手风琴卡, 同刻最多展开一张 ——*- * - 固定一行「Slack」+ 总开关: 地址内置、鉴权走登录 JWT, 没有- * 服务器地址 / 密钥表单;- * - 开关即绑定: 开 = 连接, main 自动发起 Sign in with Slack(OIDC)弹系统- * 浏览器, 授权后自动变「已绑定」; 关 = 解除绑定并断开(再开需重新授权)。- * 取消授权 / 超时(关掉浏览器) / 被顶, main 会自动关开关(toggle 弹回),- * 这里只按推送渲染。授权中顶部行临时给「复制链接」(远程控制时浏览器落- * 被控机, 复制到本机完成授权是兜底通路, 规则 26); 失败态显示原因一行;+ * - Slack 卡: 收起行 = 状态徽章 + 绑定摘要 + 总开关。开关即绑定: 开 = 连接,+ * main 自动发起 Sign in with Slack(OIDC)弹系统浏览器; 关 = 解除绑定并+ * 断开(再开需重新授权)。展开区承载授权进度与「复制链接」兜底(远程控制+ * 时浏览器落被控机, 复制到本机完成授权, 规则 26)、未安装 App 引导、+ * 失败原因, 以及 multi-team 的 workspace 绑定列表(每绑定一行: team ++ * 用户 + 解绑; displaced 行给「重新绑定」; 「添加」入口仅 server 宣告+ * multi-team 时显示);* - toggle 视觉开态 = 绑定 confirmed(不是 enabled 意图): 连接中 / 授权中 /- * 待安装等在途态一律显示为关, 进度由状态行文案(连接中… / 授权中… /- * 待安装 App)承载 —— 开着但没绑定的样子会被误读为"已可用"。在途态再点- * toggle = 取消本轮流程(关回), 与"未安装 App"确认框的取消同语义;+ * 待安装等在途态一律显示为关, 进度由徽章与摘要承载 —— 开着但没绑定的+ * 样子会被误读为"已可用"。在途态再点 toggle = 取消本轮流程(关回)。+ * 打开渠道开关时自动展开对应卡, 让授权进度与兜底动作立即可见;* - workspace 未装 App(failed + not-installed): 弹确认框问要不要安装,* 确认开安装授权页、等 server 装完自动补完绑定(免二次授权), 取消关回* 开关; 等待期显示引导行(安装/复制链接 + 等待提示);- * - 开启后展开: 绑定状态行 + 工作目录清单(别名 -> 本地目录, 系统目录- * 选择器添加, 别名可改, 变更即保存)。目录清单**整块可折叠**(标题行即- * 开关, 默认收起); 展开后每张目录卡直接显示偏好编辑行(不再有单卡折叠);+ * - Telegram 卡: 同构 —— 开关 + 状态徽章 + 关联动作(打开 bot / 加群 /+ * 解绑);+ * - 工作目录映射内嵌在每张渠道卡的展开区: 目录清单**设备共享**(所有渠道+ * 同一份, 刻意设计, 任一卡里增删都作用于全部渠道), 运行偏好按渠道隔离,+ * 由所在卡决定读写哪个渠道的那份(Slack 多绑定时再叠 workspace 归属+ * chip); 系统目录选择器添加, 别名可改, 变更即保存;* - 状态经 onStatusChanged 推送实时刷新; 数据先取后渲染, 无 loading 态,* 状态迁移不增删提示行避免布局跳动(规则 7)。*- * 颜色全部走主题 token; 状态点沿用 --remote-status-* 语义色(已备案例外)。+ * 颜色全部走主题 token; 状态徽章沿用「个人」栏的 --settings-badge-* 语义色。*/import { useCallback, useEffect, useRef, useState } from 'react';import { useTranslation } from 'react-i18next';-import { ChevronDown, ChevronRight, Plus, Send, Trash2 } from 'lucide-react';+import { ChevronDown, Plus, Trash2 } from 'lucide-react';import { Switch } from '@/components/ui/switch';import {@@ -51,28 +55,62 @@ import {type HookTeamBindingView,type SlackHookView,} from '../../../shared/hookControlIpc';-import {- useHookWorkspacePrefs,- WorkspacePrefsEditor,- type HookPrefsProvider,-} from './HookWorkspacePrefsEditor';+import { useHookWorkspacePrefs, WorkspacePrefsEditor } from './HookWorkspacePrefsEditor';+import { ImChannelSettingsCard } from './ImChannelSettingsCard';++/** 「官方」栏的渠道手风琴卡(同刻最多展开一张, 交互对齐「个人」栏)。 */+type CindyImCard = 'slack' | 'telegram';++/** 渠道卡状态徽章的色调档(映射到「个人」栏同款 --settings-badge-* token)。 */+type ChannelBadgeTone = 'ok' | 'progress' | 'attention' | 'error';++function badgeToneColor(tone: ChannelBadgeTone): string {+ switch (tone) {+ case 'ok':+ return 'var(--settings-badge-connected)';+ case 'progress':+ return 'var(--settings-badge-saved)';+ case 'error':+ return 'var(--settings-badge-error)';+ default:+ return 'var(--settings-badge-needs-config)';+ }+}-/** 状态点颜色(语义同 SSH 主机行)。 */-function statusDot(status: SlackHookView['status']): string {+/** 传输状态 → 徽章色调(Slack 与 Telegram 的 status 同一枚举语义)。 */+function transportBadgeTone(status: SlackHookView['status']): ChannelBadgeTone {switch (status) {case 'connected':- return 'var(--remote-status-ready)';+ return 'ok';case 'connecting':- return 'var(--remote-status-progress)';case 'standby':- return 'var(--remote-status-disconnected)';+ return 'progress';case 'error':- return 'var(--remote-status-failed)';+ return 'error';default:- return 'var(--remote-status-disconnected)';+ return 'attention';}}+/** 收起行状态徽章(结构与 FeishuBotSection 的状态 pill 逐字对齐)。 */+function ChannelStatusBadge({ tone, label }: { tone: ChannelBadgeTone; label: string }) {+ const color = badgeToneColor(tone);+ return (+ <span+ className="inline-flex items-center gap-1.5 rounded-full border border-[var(--settings-badge-border)] bg-[var(--settings-badge-bg)] px-2.5 py-1 text-11 font-medium"+ style={{+ letterSpacing: '0.12px',+ color: tone === 'ok' ? 'var(--settings-badge-connected-text)' : color,+ }}+ role="status"+ aria-live="polite"+ >+ <span className="h-1.5 w-1.5 rounded-full" style={{ backgroundColor: color }} aria-hidden />+ {label}+ </span>+ );+}+/** 小号胶囊按钮(「复制链接 / 安装 Slack App」共用)。 */const pillBtn ='flex h-6 shrink-0 items-center rounded-full border border-[var(--border-default)] px-2.5 text-11 text-[var(--text-secondary)] transition-colors hover:text-[var(--text-primary)] disabled:opacity-50';@@ -134,12 +172,13 @@ export function HookConnectionsSection() {/** 最近一次与 main 对齐的 workspaces 序列化(判断外部变更用)。 */const syncedRef = useRef<string>('');/**- * 「工作目录映射」整块的折叠(标题行即开关): 默认收起 —— 目录清单是低频- * 配置, 折叠标题自带目录数摘要; 收起时提示语 / 卡片 / 添加按钮全部隐藏。+ * 渠道卡同刻最多展开一张(交互对齐「个人」栏 PersonalGroupContent), 默认+ * 全收起 —— 收起行自带状态徽章与绑定摘要。打开渠道开关时自动展开对应卡,+ * 让授权进度与兜底动作(复制链接 / 安装引导)立即可见。*/- const [workspacesOpen, setWorkspacesOpen] = useState(false);- /** 同一份目录清单下,Slack / Telegram 各自维护独立的运行偏好。 */- const [prefsProvider, setPrefsProvider] = useState<HookPrefsProvider>('slack');+ const [expandedCard, setExpandedCard] = useState<CindyImCard | null>(null);+ const toggleCard = (card: CindyImCard) =>+ setExpandedCard((current) => (current === card ? null : card));/** Older IPC replies and server pushes must never overwrite a newer view transition. */const viewRevisionRef = useRef(0);/**@@ -212,6 +251,7 @@ export function HookConnectionsSection() {*/const handleToggle = useCallback((enabled: boolean) => {+ if (enabled) setExpandedCard('slack');const requestedAtRevision = ++viewRevisionRef.current;void window.electronAPI.hookControl.setEnabled(enabled)@@ -378,15 +418,6 @@ export function HookConnectionsSection() {// provider 开关切换时改变 React hook 顺序。const slackPrefsState = useHookWorkspacePrefs(hook, 'slack');const telegramPrefsState = useHookWorkspacePrefs(hook, 'telegram');- const prefsState = prefsProvider === 'telegram' ? telegramPrefsState : slackPrefsState;- useEffect(() => {- if (hook === null) return;- if (prefsProvider === 'slack' && !hook.enabled && hook.telegram.enabled) {- setPrefsProvider('telegram');- } else if (prefsProvider === 'telegram' && !hook.telegram.enabled && hook.enabled) {- setPrefsProvider('slack');- }- }, [hook, prefsProvider]);/** 复制授权链接(远程控制兜底: 到本机浏览器打开, 规则 26)。 */const handleCopyLink = async () => {@@ -412,6 +443,7 @@ export function HookConnectionsSection() {};const handleTelegramToggle = (enabled: boolean) => {+ if (enabled) setExpandedCard('telegram');runHookAction(() => window.electronAPI.hookControl.setProviderEnabled('telegram', enabled));};@@ -554,15 +586,14 @@ export function HookConnectionsSection() {? t('settings.remoteControl.hook.notInstalled.status'): t('settings.remoteControl.hook.statusUnbound');/**- * 顶部状态行文本: 关闭态且本地还留有绑定(multi-team 关开关不清绑定)时给- * 「已关闭 · N 个 workspace 绑定已保留」, 其余 = 连接状态 + 绑定摘要拼接。+ * Slack 卡收起行摘要: 关闭态且本地还留有绑定(multi-team 关开关不清绑定)+ * 时给「已关闭 · N 个 workspace 绑定已保留」, 其余用绑定摘要(连接状态由+ * 徽章单独承载, 不再拼接)。*/- const statusLine =+ const slackSummary =!hook.enabled && multiUi && hook.bindings.length > 0? t('settings.remoteControl.hook.multi.statusOffKept', { count: hook.bindings.length })- : [t(`settings.remoteControl.hook.status.${hook.status}`), bindingLabel]- .filter(Boolean)- .join(' · ');+ : bindingLabel;// transport 的稳定错误标识换成人话;其它瞬时网络错误保留原文供诊断。const errorText =hook.lastError === 'not logged in'@@ -592,26 +623,167 @@ export function HookConnectionsSection() {// it on while Telegram is waiting for /start confirmation so clicking it is// an unsurprising cancel/disable action.const telegramToggleChecked = telegram.enabled;- const telegramStatusLine = !telegram.enabled- ? t('settings.remoteControl.hook.telegram.status.disabled')+ /** Telegram 卡的状态徽章: 只承载传输/能力状态, 绑定细节走摘要与展开区。 */+ const telegramBadge: { tone: ChannelBadgeTone; label: string } = !telegram.enabled+ ? { tone: 'attention', label: t('settings.remoteControl.hook.telegram.status.disabled') }: telegram.status === 'error'- ? t('settings.remoteControl.hook.status.error')+ ? { tone: 'error', label: t('settings.remoteControl.hook.status.error') }: telegram.capabilityPending- ? t('settings.remoteControl.hook.telegram.status.checking')+ ? { tone: 'progress', label: t('settings.remoteControl.hook.telegram.status.checking') }: !telegram.available- ? t('settings.remoteControl.hook.telegram.status.unavailable')- : telegram.status !== 'connected'- ? t(`settings.remoteControl.hook.status.${telegram.status}`)- : telegramConfirmed- ? t('settings.remoteControl.hook.telegram.status.confirmed', {- user: telegramBinding?.principalName ?? telegramBinding?.principalId ?? '',- bot: telegramBinding?.scopeName ?? '',- })- : t(`settings.remoteControl.hook.telegram.status.${telegramState}`);+ ? {+ tone: 'attention',+ label: t('settings.remoteControl.hook.telegram.status.unavailable'),+ }+ : {+ tone: transportBadgeTone(telegram.status),+ label: t(`settings.remoteControl.hook.status.${telegram.status}`),+ };+ /** Telegram 绑定态一行(收起行摘要与展开区共用文案)。 */+ const telegramBindingLine =+ telegram.enabled &&+ telegram.available &&+ !telegram.capabilityPending &&+ telegram.status === 'connected'+ ? telegramConfirmed+ ? t('settings.remoteControl.hook.telegram.status.confirmed', {+ user: telegramBinding?.principalName ?? telegramBinding?.principalId ?? '',+ bot: telegramBinding?.scopeName ?? '',+ })+ : t(`settings.remoteControl.hook.telegram.status.${telegramState}`)+ : null;const telegramErrorText =telegram.lastError === 'not logged in'? t('settings.remoteControl.hook.loginRequired'): telegram.lastError;+ const workdirCount = Object.keys(hook.workspaces).length;++ /**+ * 工作目录映射区块(渲染进每张渠道卡的展开区): 目录清单是设备级共享的+ * 同一份 —— 在任一渠道卡里增删目录都作用于全部渠道(区块描述已标注),+ * 运行偏好按渠道隔离, 由所在卡决定传入哪份 prefsState, 因此不再需要+ * 渠道切换 chip。用普通函数而非内联子组件渲染: 内联组件每次渲染都会+ * 重建类型导致子树 remount, 别名输入框会在输入中途失焦。+ */+ const renderWorkdirSection = (prefsState: ReturnType<typeof useHookWorkspacePrefs>) => (+ <>+ <div className="h-px w-full bg-[var(--border-default)]" />+ <div className="flex flex-col gap-1.5">+ <div className="flex flex-wrap items-center gap-2">+ <span className="text-12 font-medium text-[var(--text-secondary)]">+ {t('settings.remoteControl.hook.form.workspacesCardTitle')}+ </span>+ <span className="text-12 text-[var(--text-tertiary)]">+ · {t('settings.remoteControl.hook.form.workspacesBoundCount', { count: workdirCount })}+ </span>+ {/* (multi-team)偏好归属 team 切换 chip: 多绑定时显示, 选中 team+ 决定下方偏好编辑读写哪个 workspace 的那份 */}+ {prefsState.showTeamChip ? (+ <DropdownMenu>+ <DropdownMenuTrigger+ aria-label={t('settings.tina.prefs.teamChipAria')}+ className="flex shrink-0 items-center gap-1 rounded-full bg-[var(--surface-chip)] px-2.5 py-1 text-11 text-[var(--text-secondary)] outline-none transition-colors hover:text-[var(--text-primary)]"+ >+ <span className="max-w-40 truncate">+ {prefsState.teams.find((tm) => tm.teamId === prefsState.selectedTeamId)+ ?.teamName ??+ prefsState.selectedTeamId ??+ ''}+ </span>+ <ChevronDown size={12} />+ </DropdownMenuTrigger>+ <DropdownMenuContent align="end">+ {prefsState.teams.map((tm) => (+ <DropdownMenuItem+ key={tm.teamId}+ onClick={() => prefsState.selectTeam(tm.teamId)}+ >+ {tm.teamName ?? tm.teamId}+ </DropdownMenuItem>+ ))}+ </DropdownMenuContent>+ </DropdownMenu>+ ) : null}+ </div>+ <span className="text-11 leading-relaxed text-[var(--text-tertiary)]">+ {t('settings.remoteControl.hook.form.workspacesCardDescription')}+ </span>+ {prefsState.hint !== null && (+ <div className="flex items-center gap-2 text-11 text-[var(--text-tertiary)]">+ <span>{prefsState.hint}</span>+ {prefsState.retry !== null && (+ <button+ type="button"+ onClick={prefsState.retry}+ className="rounded-md border border-[var(--border-default)] px-2 py-0.5 text-11 text-[var(--text-secondary)]"+ >+ {t('settings.tina.prefs.retry')}+ </button>+ )}+ </div>+ )}+ {/* 内置「对话」伪目录: 与真实目录同级, 常驻第一位, 不可改名/删除;+ Slack 那头对应保留别名 chat, 偏好与 /model 选 chat 同一份 */}+ <div className="flex flex-col gap-2 rounded-xl border border-[var(--border-default)] p-2.5">+ <div className="flex items-center gap-1.5">+ <span className="w-36 shrink-0 px-2.5 py-1.5 text-13 font-medium text-[var(--text-primary)]">+ {t('settings.tina.chat.title')}+ </span>+ <span className="min-w-0 flex-1 truncate text-12 text-[var(--text-tertiary)]">+ {t('settings.tina.chat.description')}+ </span>+ </div>+ <WorkspacePrefsEditor alias={HOOK_CHAT_WORKSPACE_ALIAS} state={prefsState} />+ </div>+ {rows.map((row, i) => (+ <div+ key={row.dir}+ className="flex flex-col gap-2 rounded-xl border border-[var(--border-default)] p-2.5"+ >+ <div className="flex items-center gap-1.5">+ <input+ value={row.alias}+ onChange={(e) => {+ const next = rows.slice();+ next[i] = { ...next[i], alias: e.target.value };+ setRows(next);+ }}+ onBlur={() => void saveWorkspaces(rows)}+ maxLength={32}+ className="shrink-0 w-36 rounded-lg border border-transparent px-2.5 py-1.5 text-13 text-[var(--settings-input-text)] bg-transparent outline-none hover:border-[var(--border-default)] focus:border-[var(--border-default)] transition-colors"+ />+ <button+ type="button"+ onClick={() => void handleChangeDir(i)}+ title={t('settings.remoteControl.hook.form.changeDir')}+ className="min-w-0 flex-1 truncate text-left text-12 text-[var(--text-tertiary)] transition-colors hover:text-[var(--text-primary)]"+ >+ {row.dir}+ </button>+ <button+ type="button"+ onClick={() => void handleRemoveWorkspace(i)}+ aria-label={t('settings.remoteControl.hook.form.removeWorkspace')}+ className="shrink-0 rounded-md p-1.5 text-[var(--text-tertiary)] transition-colors hover:text-[var(--text-primary)]"+ >+ <Trash2 size={13} />+ </button>+ </div>+ {/* 会话偏好编辑行: 偏好按别名归属(与 Slack /model 卡同键) */}+ <WorkspacePrefsEditor alias={row.alias.trim()} state={prefsState} />+ </div>+ ))}+ <button+ type="button"+ onClick={() => void handleAddWorkspace()}+ className="flex h-7 w-fit items-center gap-1.5 rounded-full border border-[var(--border-default)] px-3 text-12 text-[var(--text-secondary)] transition-colors hover:text-[var(--text-primary)]"+ >+ <Plus size={12} />+ {t('settings.remoteControl.hook.form.addWorkspace')}+ </button>+ </div>+ </>+ );return (<div className="flex flex-col gap-3">@@ -619,37 +791,19 @@ export function HookConnectionsSection() {{t('settings.remoteControl.hook.description')}</p>- <div className="rounded-xl border border-[var(--border-default)] px-4 py-3">- {/* 固定一行: Slack + 状态 + 总开关(无任何地址/密钥表单)。 */}- <div className="flex items-center gap-3">- <span- className="h-1.5 w-1.5 shrink-0 rounded-full"- style={{ backgroundColor: statusDot(hook.status) }}- aria-hidden+ {/* ── Slack 渠道卡 ─────────────────────────────────────────────── */}+ <ImChannelSettingsCard+ id="cindy-im-slack"+ title={t('settings.tina.prefs.providerSlack')}+ description={t('settings.remoteControl.hook.slackDescription')}+ routeSummary={slackSummary}+ status={+ <ChannelStatusBadge+ tone={transportBadgeTone(hook.status)}+ label={t(`settings.remoteControl.hook.status.${hook.status}`)}/>- <div className="flex min-w-0 flex-1 flex-col gap-0.5">- <span className="truncate text-13 font-medium text-[var(--text-primary)]">- {t('settings.tina.prefs.providerSlack')}- </span>- <span className="truncate text-11 text-[var(--text-tertiary)]">{statusLine}</span>- {hook.status === 'error' && errorText ? (- <span className="truncate text-11 text-[var(--error-fg)]">{errorText}</span>- ) : hook.status === 'standby' ? (- <span className="truncate text-11 text-[var(--text-tertiary)]">- {t('settings.remoteControl.hook.standbyHint')}- </span>- ) : null}- </div>- {/* 授权进行中的唯一附加动作: 复制授权链接 —— 远程控制时 openExternal- 落被控机, 复制到本机浏览器完成授权是兜底通路(规则 26)。浏览器已- 自动弹出, 不再放整块提示; 状态行的「授权中…」即进度反馈。- multi-team 列表模式的复制按钮在下方 pending 行里, 顶部只在首绑- (列表未出现)时给 */}- {hook.enabled && !multiUi && bindingState === 'pending' && hook.binding?.authorizeUrl ? (- <button type="button" onClick={() => void handleCopyLink()} className={pillBtn}>- {t('settings.remoteControl.hook.binding.copyLink')}- </button>- ) : null}+ }+ headerAction={<Switchchecked={toggleChecked}onCheckedChange={(next) => {@@ -659,159 +813,326 @@ export function HookConnectionsSection() {}}aria-label={t('settings.remoteControl.hook.toggleAria')}/>- </div>-- {/* 授权检出 workspace 未安装 App(bind.update failed + reason=not-installed):- 专属引导行 —— 安装是能用的前提, 给「安装 Slack App」按钮(302 直跳- Slack 安装授权页)+ 说明。安装成功与否无从主动探测, 装完重开开关走- 新一轮授权即验证。授权成功 = workspace 必已安装(server 绑定时校验),- 所以已绑定/平时都不出现安装入口。远程控制时 openExternal 落被控机,- 「复制链接」到本机浏览器完成安装是兜底通路(规则 26) */}- {!multiUi && isNotInstalled ? (- <div className="mt-3 flex flex-col gap-1.5 border-t border-[var(--border-default)] pt-3">- <div className="flex items-center gap-2">- <span className="min-w-0 flex-1 text-11 leading-relaxed text-[var(--error-fg)]">- {t('settings.remoteControl.hook.notInstalled.title')}- </span>- <button- type="button"- onClick={() => {- if (installUrl) void window.electronAPI.openExternal(installUrl);- }}- className={pillBtn}- >- {t('settings.remoteControl.hook.installApp')}- </button>- <button- type="button"- onClick={() => void handleCopyInstallLink()}- className={pillBtn}- >- {t('settings.remoteControl.hook.binding.copyLink')}- </button>- </div>+ }+ expanded={expandedCard === 'slack'}+ onToggle={() => toggleCard('slack')}+ >+ <div className="flex flex-col gap-2">+ {/* 传输层错误 / 待机说明(收起态由徽章给概要, 详情在展开区) */}+ {hook.status === 'error' && errorText ? (+ <span className="text-11 leading-relaxed text-[var(--error-fg)]">{errorText}</span>+ ) : hook.status === 'standby' ? (<span className="text-11 leading-relaxed text-[var(--text-tertiary)]">- {hook.enabled- ? t('settings.remoteControl.hook.notInstalled.waitingHint')- : t('settings.remoteControl.hook.notInstalled.hint')}+ {t('settings.remoteControl.hook.standbyHint')}</span>- </div>- ) : null}+ ) : null}- {/* 取消授权 / 授权失败 / 超时 / 被新设备顶掉: 开关已自动弹回, 显示原因;- 绑定记录保留, 重新打开开关即自动重连并(未绑定时)重新发起授权 */}- {!multiUi && isBindingFailure && !isNotInstalled ? (- <div className="mt-3 flex flex-col gap-1 border-t border-[var(--border-default)] pt-3">- <span className="text-11 leading-relaxed text-[var(--error-fg)]">- {hook.binding?.message ??- t(`settings.remoteControl.hook.binding.state.${bindingState}`)}- </span>+ {/* 关闭态引导(失败/未安装的原因行会一并跟在下方) */}+ {!hook.enabled ? (<span className="text-11 leading-relaxed text-[var(--text-tertiary)]">- {t('settings.remoteControl.hook.binding.retryHint')}+ {t('settings.remoteControl.hook.slackDisabledHint')}</span>- </div>- ) : null}+ ) : null}- {/* (multi-team)首绑失败兜底: 首次授权终止(denied/expired/failed/装 App- 超时)时 manager 会 setEnabled(false) 弹回开关, 下方列表区块随- enabled 一起消失 —— 终止态原因与未安装引导必须在这里独立于 enabled- 渲染, 否则用户只看到开关静默弹回、没有任何原因与重试提示。已有- 绑定时列表区块可见, 终止态行由列表内的对应行承载, 这里不重复。 */}- {multiUi && !hook.enabled && isNotInstalled ? (- <div className="mt-3 flex flex-col gap-1.5 border-t border-[var(--border-default)] pt-3">- <div className="flex items-center gap-2">- <span className="min-w-0 flex-1 text-11 leading-relaxed text-[var(--error-fg)]">- {t('settings.remoteControl.hook.notInstalled.title')}+ {/* 单绑定授权中: 复制授权链接 —— 远程控制时 openExternal 落被控机,+ 复制到本机浏览器完成授权是兜底通路(规则 26)。浏览器已自动弹出,+ 摘要的「授权中…」即进度反馈; multi-team 列表模式的复制按钮在+ 下方 pending 行里 */}+ {hook.enabled && !multiUi && bindingState === 'pending' && hook.binding?.authorizeUrl ? (+ <div className="flex items-center gap-2 rounded-xl border border-dashed border-[var(--border-default)] px-2.5 py-2">+ <span className="min-w-0 flex-1 truncate text-12 text-[var(--text-tertiary)]">+ {t('settings.remoteControl.hook.authorizing')}</span>- <button- type="button"- onClick={() => {- if (installUrl) void window.electronAPI.openExternal(installUrl);- }}- className={pillBtn}- >- {t('settings.remoteControl.hook.installApp')}- </button>- <button- type="button"- onClick={() => void handleCopyInstallLink()}- className={pillBtn}- >+ <button type="button" onClick={() => void handleCopyLink()} className={pillBtn}>{t('settings.remoteControl.hook.binding.copyLink')}</button></div>- <span className="text-11 leading-relaxed text-[var(--text-tertiary)]">- {t('settings.remoteControl.hook.notInstalled.hint')}- </span>- </div>- ) : null}- {multiUi &&- !hook.enabled &&- !isNotInstalled &&- hook.pendingBind !== null &&- hook.pendingBind.state !== 'pending' ? (- <div className="mt-3 flex flex-col gap-1 border-t border-[var(--border-default)] pt-3">- <span className="text-11 leading-relaxed text-[var(--error-fg)]">- {hook.pendingBind.message ??- t(`settings.remoteControl.hook.binding.state.${hook.pendingBind.state}`)}- </span>- <span className="text-11 leading-relaxed text-[var(--text-tertiary)]">- {t('settings.remoteControl.hook.binding.retryHint')}- </span>- </div>- ) : null}+ ) : null}- {telegramVisible ? (- <div className="mt-3 flex flex-col gap-2 border-t border-[var(--border-default)] pt-3">- <div className="flex items-center gap-3">- <span- className="h-1.5 w-1.5 shrink-0 rounded-full"- style={{- backgroundColor: statusDot(telegram.enabled ? telegram.status : 'disabled'),- }}- aria-hidden- />- <Send- size={14}- strokeWidth={1.75}- className="shrink-0 text-[var(--text-secondary)]"- />- <div className="flex min-w-0 flex-1 flex-col gap-0.5">- <span className="truncate text-13 font-medium text-[var(--text-primary)]">- {t('settings.tina.prefs.providerTelegram')}+ {/* 授权检出 workspace 未安装 App(bind.update failed + reason=not-installed):+ 专属引导行 —— 安装是能用的前提, 给「安装 Slack App」按钮(302 直跳+ Slack 安装授权页)+ 说明。安装成功与否无从主动探测, 装完重开开关走+ 新一轮授权即验证。远程控制时 openExternal 落被控机, 「复制链接」到+ 本机浏览器完成安装是兜底通路(规则 26)。multi-team 首绑失败时+ manager 会 setEnabled(false) 弹回开关、列表区块随 enabled 消失, 故+ 这段独立于列表渲染(带「取消」入口的版本在下方列表区块内) */}+ {isNotInstalled && (!multiUi || !hook.enabled) ? (+ <div className="flex flex-col gap-1.5">+ <div className="flex items-center gap-2">+ <span className="min-w-0 flex-1 text-11 leading-relaxed text-[var(--error-fg)]">+ {t('settings.remoteControl.hook.notInstalled.title')}</span>- <span- className={`truncate text-11 ${- telegramState === 'failed' ||- telegramState === 'denied' ||- telegramState === 'expired' ||- telegramState === 'superseded'- ? 'text-[var(--error-fg)]'- : 'text-[var(--text-tertiary)]'- }`}+ <button+ type="button"+ onClick={() => {+ if (installUrl) void window.electronAPI.openExternal(installUrl);+ }}+ className={pillBtn}>- {telegramStatusLine}- </span>+ {t('settings.remoteControl.hook.installApp')}+ </button>+ <button+ type="button"+ onClick={() => void handleCopyInstallLink()}+ className={pillBtn}+ >+ {t('settings.remoteControl.hook.binding.copyLink')}+ </button></div>- <Switch- checked={telegramToggleChecked}- disabled={!telegram.enabled && telegram.url.length === 0}- onCheckedChange={handleTelegramToggle}- aria-label={t('settings.remoteControl.hook.telegram.toggleAria')}- />+ <span className="text-11 leading-relaxed text-[var(--text-tertiary)]">+ {hook.enabled+ ? t('settings.remoteControl.hook.notInstalled.waitingHint')+ : t('settings.remoteControl.hook.notInstalled.hint')}+ </span>+ </div>+ ) : null}++ {/* 取消授权 / 授权失败 / 超时 / 被新设备顶掉: 开关已自动弹回, 显示原因;+ 绑定记录保留, 重新打开开关即自动重连并(未绑定时)重新发起授权 */}+ {!multiUi && isBindingFailure && !isNotInstalled ? (+ <div className="flex flex-col gap-1">+ <span className="text-11 leading-relaxed text-[var(--error-fg)]">+ {hook.binding?.message ??+ t(`settings.remoteControl.hook.binding.state.${bindingState}`)}+ </span>+ <span className="text-11 leading-relaxed text-[var(--text-tertiary)]">+ {t('settings.remoteControl.hook.binding.retryHint')}+ </span>+ </div>+ ) : null}++ {/* (multi-team)首绑终止态兜底(取消授权/超时/失败, 非未安装): 首绑+ 失败时列表区块随 enabled 消失, 原因行必须独立渲染, 否则用户只+ 看到开关静默弹回。已有绑定时终止态行由列表内对应行承载 */}+ {multiUi &&+ !hook.enabled &&+ !isNotInstalled &&+ hook.pendingBind !== null &&+ hook.pendingBind.state !== 'pending' ? (+ <div className="flex flex-col gap-1">+ <span className="text-11 leading-relaxed text-[var(--error-fg)]">+ {hook.pendingBind.message ??+ t(`settings.remoteControl.hook.binding.state.${hook.pendingBind.state}`)}+ </span>+ <span className="text-11 leading-relaxed text-[var(--text-tertiary)]">+ {t('settings.remoteControl.hook.binding.retryHint')}+ </span>+ </div>+ ) : null}++ {/* (multi-team)workspace 绑定列表: 每绑定一行(team + 用户 + 状态+ 标注 + 解绑), displaced 行给「重新绑定」; 在途授权挂列表尾部+ (授权中 + 复制链接 + 取消), 未安装引导行挂 pending 行下;+ 「添加」入口仅 server 宣告 multi-team 时显示 */}+ {hook.enabled && multiUi ? (+ <div className="flex flex-col gap-1.5">+ {hook.bindings.map((b) => (+ <div+ key={b.teamId}+ className="flex items-center gap-2 rounded-xl border border-[var(--border-default)] px-2.5 py-2"+ >+ <div className="flex min-w-0 flex-1 flex-col gap-0.5">+ <span className="truncate text-13 font-medium text-[var(--text-primary)]">+ {b.teamName ?? b.teamId}+ </span>+ <span className="truncate text-12 text-[var(--text-tertiary)]">+ @{b.slackUserName ?? b.slackUserId}+ </span>+ </div>+ {b.displaced ? (+ <>+ {/* 被另一台设备顶掉: 标注 + 重新绑定(pin 到该 team 的授权页) */}+ <span className="shrink-0 text-11 text-[var(--error-fg)]">+ {t('settings.remoteControl.hook.multi.displaced')}+ </span>+ <button+ type="button"+ onClick={() =>+ runHookAction(() => window.electronAPI.hookControl.rebindTeam(b.teamId))+ }+ className={pillBtn}+ >+ {t('settings.remoteControl.hook.multi.rebind')}+ </button>+ </>+ ) : null}+ <button+ type="button"+ onClick={() => void handleRemoveBinding(b)}+ aria-label={t('settings.remoteControl.hook.multi.removeAria')}+ className="shrink-0 rounded-md p-1.5 text-[var(--text-tertiary)] transition-colors hover:text-[var(--text-primary)]"+ >+ <Trash2 size={13} />+ </button>+ </div>+ ))}+ {hook.pendingBind?.state === 'pending' ? (+ <div className="flex items-center gap-2 rounded-xl border border-dashed border-[var(--border-default)] px-2.5 py-2">+ <span className="min-w-0 flex-1 truncate text-12 text-[var(--text-tertiary)]">+ {t('settings.remoteControl.hook.authorizing')}+ </span>+ {hook.pendingBind.authorizeUrl ? (+ <button type="button" onClick={() => void handleCopyLink()} className={pillBtn}>+ {t('settings.remoteControl.hook.binding.copyLink')}+ </button>+ ) : null}+ <button+ type="button"+ onClick={() =>+ runHookAction(() => window.electronAPI.hookControl.cancelPendingBind())+ }+ className={pillBtn}+ >+ {t('settings.remoteControl.hook.multi.cancelPending')}+ </button>+ </div>+ ) : null}+ {/* 未安装引导行(添加的 workspace 没装 App; 确认框逻辑与单绑定共用) */}+ {isNotInstalled ? (+ <div className="flex flex-col gap-1.5">+ <div className="flex items-center gap-2">+ <span className="min-w-0 flex-1 text-11 leading-relaxed text-[var(--error-fg)]">+ {t('settings.remoteControl.hook.notInstalled.title')}+ </span>+ <button+ type="button"+ onClick={() => {+ if (installUrl) void window.electronAPI.openExternal(installUrl);+ }}+ className={pillBtn}+ >+ {t('settings.remoteControl.hook.installApp')}+ </button>+ <button+ type="button"+ onClick={() => void handleCopyInstallLink()}+ className={pillBtn}+ >+ {t('settings.remoteControl.hook.binding.copyLink')}+ </button>+ <button+ type="button"+ onClick={() =>+ runHookAction(() => window.electronAPI.hookControl.cancelPendingBind())+ }+ className={pillBtn}+ >+ {t('settings.remoteControl.hook.multi.cancelPending')}+ </button>+ </div>+ <span className="text-11 leading-relaxed text-[var(--text-tertiary)]">+ {t('settings.remoteControl.hook.notInstalled.waitingHint')}+ </span>+ </div>+ ) : null}+ {/* 添加/重绑的终止态(取消授权/超时/失败, 非未安装): 一行原因 + 可清除 */}+ {hook.pendingBind !== null &&+ hook.pendingBind.state !== 'pending' &&+ !isNotInstalled ? (+ <div className="flex items-center gap-2">+ <span className="min-w-0 flex-1 text-11 leading-relaxed text-[var(--error-fg)]">+ {hook.pendingBind.reason === HOOK_BIND_REASON_ALREADY_BOUND+ ? t('settings.remoteControl.hook.multi.alreadyBound', {+ team:+ hook.bindings.find((b) => b.teamId === hook.pendingBind?.teamId)+ ?.teamName ??+ hook.pendingBind.teamId ??+ '',+ })+ : (hook.pendingBind.message ??+ t(`settings.remoteControl.hook.binding.state.${hook.pendingBind.state}`))}+ </span>+ <button+ type="button"+ onClick={() =>+ runHookAction(() => window.electronAPI.hookControl.cancelPendingBind())+ }+ className={pillBtn}+ >+ {t('settings.remoteControl.hook.multi.dismiss')}+ </button>+ </div>+ ) : null}+ {hook.serverMultiTeam ? (+ <button+ type="button"+ onClick={() => runHookAction(() => window.electronAPI.hookControl.addBinding())}+ className="flex h-7 w-fit items-center gap-1.5 rounded-full border border-[var(--border-default)] px-3 text-12 text-[var(--text-secondary)] transition-colors hover:text-[var(--text-primary)]"+ >+ <Plus size={12} />+ {t('settings.remoteControl.hook.multi.addWorkspace')}+ </button>+ ) : null}</div>+ ) : null}++ {/* 单绑定已完成: 说明开关的反向语义(关 = 解绑, 重开需再授权),+ 避免展开区空白 */}+ {hook.enabled && !multiUi && bindingState === 'confirmed' ? (+ <span className="text-11 leading-relaxed text-[var(--text-tertiary)]">+ {t('settings.remoteControl.hook.slackBoundHint')}+ </span>+ ) : null}++ {/* 工作目录映射(清单共享, 偏好取 Slack 那份) */}+ {hook.enabled ? renderWorkdirSection(slackPrefsState) : null}+ </div>+ </ImChannelSettingsCard>++ {/* ── Telegram 渠道卡 ──────────────────────────────────────────── */}+ {telegramVisible ? (+ <ImChannelSettingsCard+ id="cindy-im-telegram"+ title={t('settings.tina.prefs.providerTelegram')}+ description={t('settings.remoteControl.hook.telegram.description')}+ routeSummary={telegramBindingLine}+ status={<ChannelStatusBadge tone={telegramBadge.tone} label={telegramBadge.label} />}+ headerAction={+ <Switch+ checked={telegramToggleChecked}+ disabled={!telegram.enabled && telegram.url.length === 0}+ onCheckedChange={handleTelegramToggle}+ aria-label={t('settings.remoteControl.hook.telegram.toggleAria')}+ />+ }+ expanded={expandedCard === 'telegram'}+ onToggle={() => toggleCard('telegram')}+ >+ <div className="flex flex-col gap-2">+ {!telegram.enabled ? (+ <span className="text-11 leading-relaxed text-[var(--text-tertiary)]">+ {t('settings.remoteControl.hook.telegram.disabledHint')}+ </span>+ ) : null}++ {/* 绑定进度/结果一行(「点 Start 完成关联」引导、失败原因等;+ 已关联的摘要由收起行承载, 展开区不重复) */}+ {telegramBindingLine !== null && !telegramConfirmed ? (+ <span+ className={`text-11 leading-relaxed ${+ telegramState === 'failed' ||+ telegramState === 'denied' ||+ telegramState === 'expired' ||+ telegramState === 'superseded'+ ? 'text-[var(--error-fg)]'+ : 'text-[var(--text-tertiary)]'+ }`}+ >+ {telegramBindingLine}+ </span>+ ) : null}{telegram.enabled &&telegram.status === 'error' &&telegramErrorText &&- telegramErrorText !== telegramStatusLine ? (- <span className="pl-8 text-11 leading-relaxed text-[var(--error-fg)]">+ telegramErrorText !== telegramBadge.label ? (+ <span className="text-11 leading-relaxed text-[var(--error-fg)]">{telegramErrorText}</span>) : null}{telegram.enabled && telegram.available ? (- <div className="flex flex-wrap items-center gap-2 pl-8">+ <div className="flex flex-wrap items-center gap-2">{telegramInProgress && telegramBinding?.connectUrl ? (<>{telegramActions.includes('open_connect_url') ? (@@ -892,330 +1213,12 @@ export function HookConnectionsSection() {) : null}</div>) : null}- </div>- ) : null}-- {hook.enabled || hook.telegram.enabled ? (- <>- {/* (multi-team)Slack workspaces 区块: 每个绑定一行(team + 用户 +- 状态标注 + 解绑), displaced 行给「重新绑定」; 在途授权挂列表尾部- (授权中 + 复制链接 + 取消), 未安装引导行挂 pending 行下;- 「添加」入口仅 server 宣告 multi-team 时显示 */}- {hook.enabled && multiUi ? (- <div className="mt-3 flex flex-col gap-1.5 border-t border-[var(--border-default)] pt-3">- <span className="text-12 font-medium text-[var(--text-secondary)]">- {t('settings.remoteControl.hook.multi.title')}- </span>- {hook.bindings.map((b) => (- <div- key={b.teamId}- className="flex items-center gap-2 rounded-xl border border-[var(--border-default)] px-2.5 py-2"- >- <div className="flex min-w-0 flex-1 flex-col gap-0.5">- <span className="truncate text-13 font-medium text-[var(--text-primary)]">- {b.teamName ?? b.teamId}- </span>- <span className="truncate text-12 text-[var(--text-tertiary)]">- @{b.slackUserName ?? b.slackUserId}- </span>- </div>- {b.displaced ? (- <>- {/* 被另一台设备顶掉: 标注 + 重新绑定(pin 到该 team 的授权页) */}- <span className="shrink-0 text-11 text-[var(--error-fg)]">- {t('settings.remoteControl.hook.multi.displaced')}- </span>- <button- type="button"- onClick={() =>- runHookAction(() => window.electronAPI.hookControl.rebindTeam(b.teamId))- }- className={pillBtn}- >- {t('settings.remoteControl.hook.multi.rebind')}- </button>- </>- ) : null}- <button- type="button"- onClick={() => void handleRemoveBinding(b)}- aria-label={t('settings.remoteControl.hook.multi.removeAria')}- className="shrink-0 rounded-md p-1.5 text-[var(--text-tertiary)] transition-colors hover:text-[var(--text-primary)]"- >- <Trash2 size={13} />- </button>- </div>- ))}- {hook.pendingBind?.state === 'pending' ? (- <div className="flex items-center gap-2 rounded-xl border border-dashed border-[var(--border-default)] px-2.5 py-2">- <span className="min-w-0 flex-1 truncate text-12 text-[var(--text-tertiary)]">- {t('settings.remoteControl.hook.authorizing')}- </span>- {hook.pendingBind.authorizeUrl ? (- <button- type="button"- onClick={() => void handleCopyLink()}- className={pillBtn}- >- {t('settings.remoteControl.hook.binding.copyLink')}- </button>- ) : null}- <button- type="button"- onClick={() =>- runHookAction(() => window.electronAPI.hookControl.cancelPendingBind())- }- className={pillBtn}- >- {t('settings.remoteControl.hook.multi.cancelPending')}- </button>- </div>- ) : null}- {/* 未安装引导行(添加的 workspace 没装 App; 确认框逻辑与单绑定共用) */}- {isNotInstalled ? (- <div className="flex flex-col gap-1.5">- <div className="flex items-center gap-2">- <span className="min-w-0 flex-1 text-11 leading-relaxed text-[var(--error-fg)]">- {t('settings.remoteControl.hook.notInstalled.title')}- </span>- <button- type="button"- onClick={() => {- if (installUrl) void window.electronAPI.openExternal(installUrl);- }}- className={pillBtn}- >- {t('settings.remoteControl.hook.installApp')}- </button>- <button- type="button"- onClick={() => void handleCopyInstallLink()}- className={pillBtn}- >- {t('settings.remoteControl.hook.binding.copyLink')}- </button>- <button- type="button"- onClick={() =>- runHookAction(() => window.electronAPI.hookControl.cancelPendingBind())- }- className={pillBtn}- >- {t('settings.remoteControl.hook.multi.cancelPending')}- </button>- </div>- <span className="text-11 leading-relaxed text-[var(--text-tertiary)]">- {t('settings.remoteControl.hook.notInstalled.waitingHint')}- </span>- </div>- ) : null}- {/* 添加/重绑的终止态(取消授权/超时/失败, 非未安装): 一行原因 + 可清除 */}- {hook.pendingBind !== null &&- hook.pendingBind.state !== 'pending' &&- !isNotInstalled ? (- <div className="flex items-center gap-2">- <span className="min-w-0 flex-1 text-11 leading-relaxed text-[var(--error-fg)]">- {hook.pendingBind.reason === HOOK_BIND_REASON_ALREADY_BOUND- ? t('settings.remoteControl.hook.multi.alreadyBound', {- team:- hook.bindings.find((b) => b.teamId === hook.pendingBind?.teamId)- ?.teamName ??- hook.pendingBind.teamId ??- '',- })- : (hook.pendingBind.message ??- t(`settings.remoteControl.hook.binding.state.${hook.pendingBind.state}`))}- </span>- <button- type="button"- onClick={() =>- runHookAction(() => window.electronAPI.hookControl.cancelPendingBind())- }- className={pillBtn}- >- {t('settings.remoteControl.hook.multi.dismiss')}- </button>- </div>- ) : null}- {hook.serverMultiTeam ? (- <button- type="button"- onClick={() => runHookAction(() => window.electronAPI.hookControl.addBinding())}- className="flex h-7 w-fit items-center gap-1.5 rounded-full border border-[var(--border-default)] px-3 text-12 text-[var(--text-secondary)] transition-colors hover:text-[var(--text-primary)]"- >- <Plus size={12} />- {t('settings.remoteControl.hook.multi.addWorkspace')}- </button>- ) : null}- </div>- ) : null}- {/* 工作目录清单: 整块可折叠(标题行即开关, 默认收起);- 展开后系统目录选择器添加, 别名 blur 提交, 变更即保存 */}- <div className="mt-3 flex flex-col gap-1.5 border-t border-[var(--border-default)] pt-3">- <div className="flex items-center gap-2">- <button- type="button"- onClick={() => setWorkspacesOpen((v) => !v)}- aria-expanded={workspacesOpen}- className="flex min-w-0 flex-1 items-center gap-1 text-left text-[var(--text-tertiary)] transition-colors hover:text-[var(--text-primary)]"- >- {workspacesOpen ? <ChevronDown size={14} /> : <ChevronRight size={14} />}- <span className="text-12 font-medium text-[var(--text-secondary)]">- {t('settings.remoteControl.hook.form.workspaces')}- </span>- {/* 目录数摘要并进折叠标题(「已绑定 N 个本地工作目录」), 收起时也能看到规模 */}- <span className="text-12 text-[var(--text-tertiary)]">- ·{' '}- {t('settings.remoteControl.hook.form.workspacesBoundCount', {- count: Object.keys(hook.workspaces).length,- })}- </span>- </button>- <div- className="flex shrink-0 items-center rounded-full bg-[var(--surface-chip)] p-0.5"- role="group"- aria-label={t('settings.tina.prefs.providerAria')}- >- {hook.enabled ? (- <button- type="button"- aria-pressed={prefsProvider === 'slack'}- onClick={() => setPrefsProvider('slack')}- className={`rounded-full px-2 py-0.5 text-11 transition-colors ${- prefsProvider === 'slack'- ? 'bg-[var(--background-primary)] text-[var(--text-primary)]'- : 'text-[var(--text-tertiary)] hover:text-[var(--text-secondary)]'- }`}- >- {t('settings.tina.prefs.providerSlack')}- </button>- ) : null}- {hook.telegram.enabled ? (- <button- type="button"- aria-pressed={prefsProvider === 'telegram'}- onClick={() => setPrefsProvider('telegram')}- className={`rounded-full px-2 py-0.5 text-11 transition-colors ${- prefsProvider === 'telegram'- ? 'bg-[var(--background-primary)] text-[var(--text-primary)]'- : 'text-[var(--text-tertiary)] hover:text-[var(--text-secondary)]'- }`}- >- {t('settings.tina.prefs.providerTelegram')}- </button>- ) : null}- </div>- {/* (multi-team)偏好归属 team 切换 chip: 多绑定展开时显示, 选中- team 决定下方偏好编辑读写哪个 workspace 的那份 */}- {workspacesOpen && prefsState.showTeamChip ? (- <DropdownMenu>- <DropdownMenuTrigger- aria-label={t('settings.tina.prefs.teamChipAria')}- className="flex shrink-0 items-center gap-1 rounded-full bg-[var(--surface-chip)] px-2.5 py-1 text-11 text-[var(--text-secondary)] outline-none transition-colors hover:text-[var(--text-primary)]"- >- <span className="max-w-40 truncate">- {prefsState.teams.find((tm) => tm.teamId === prefsState.selectedTeamId)- ?.teamName ??- prefsState.selectedTeamId ??- ''}- </span>- <ChevronDown size={12} />- </DropdownMenuTrigger>- <DropdownMenuContent align="end">- {prefsState.teams.map((tm) => (- <DropdownMenuItem- key={tm.teamId}- onClick={() => prefsState.selectTeam(tm.teamId)}- >- {tm.teamName ?? tm.teamId}- </DropdownMenuItem>- ))}- </DropdownMenuContent>- </DropdownMenu>- ) : null}- </div>- {workspacesOpen && (- <>- {prefsState.hint !== null && (- <div className="flex items-center gap-2 text-11 text-[var(--text-tertiary)]">- <span>{prefsState.hint}</span>- {prefsState.retry !== null && (- <button- type="button"- onClick={prefsState.retry}- className="rounded-md border border-[var(--border-default)] px-2 py-0.5 text-11 text-[var(--text-secondary)]"- >- {t('settings.tina.prefs.retry')}- </button>- )}- </div>- )}- {/* 内置「对话」伪目录: 与真实目录同级, 常驻第一位, 不可改名/删除;- Slack 那头对应保留别名 chat, 偏好与 /model 选 chat 同一份 */}- <div className="flex flex-col gap-2 rounded-xl border border-[var(--border-default)] p-2.5">- <div className="flex items-center gap-1.5">- <span className="w-36 shrink-0 px-2.5 py-1.5 text-13 font-medium text-[var(--text-primary)]">- {t('settings.tina.chat.title')}- </span>- <span className="min-w-0 flex-1 truncate text-12 text-[var(--text-tertiary)]">- {t('settings.tina.chat.description')}- </span>- </div>- <WorkspacePrefsEditor alias={HOOK_CHAT_WORKSPACE_ALIAS} state={prefsState} />- </div>- {rows.map((row, i) => (- <div- key={row.dir}- className="flex flex-col gap-2 rounded-xl border border-[var(--border-default)] p-2.5"- >- <div className="flex items-center gap-1.5">- <input- value={row.alias}- onChange={(e) => {- const next = rows.slice();- next[i] = { ...next[i], alias: e.target.value };- setRows(next);- }}- onBlur={() => void saveWorkspaces(rows)}- maxLength={32}- className="shrink-0 w-36 rounded-lg border border-transparent px-2.5 py-1.5 text-13 text-[var(--settings-input-text)] bg-transparent outline-none hover:border-[var(--border-default)] focus:border-[var(--border-default)] transition-colors"- />- <button- type="button"- onClick={() => void handleChangeDir(i)}- title={t('settings.remoteControl.hook.form.changeDir')}- className="min-w-0 flex-1 truncate text-left text-12 text-[var(--text-tertiary)] transition-colors hover:text-[var(--text-primary)]"- >- {row.dir}- </button>- <button- type="button"- onClick={() => void handleRemoveWorkspace(i)}- aria-label={t('settings.remoteControl.hook.form.removeWorkspace')}- className="shrink-0 rounded-md p-1.5 text-[var(--text-tertiary)] transition-colors hover:text-[var(--text-primary)]"- >- <Trash2 size={13} />- </button>- </div>- {/* 会话偏好编辑行: 偏好按别名归属(与 Slack /model 卡同键) */}- <WorkspacePrefsEditor alias={row.alias.trim()} state={prefsState} />- </div>- ))}- <button- type="button"- onClick={() => void handleAddWorkspace()}- className="flex h-7 w-fit items-center gap-1.5 rounded-full border border-[var(--border-default)] px-3 text-12 text-[var(--text-secondary)] transition-colors hover:text-[var(--text-primary)]"- >- <Plus size={12} />- {t('settings.remoteControl.hook.form.addWorkspace')}- </button>- </>- )}- </div>- </>- ) : null}- </div>+ {/* 工作目录映射(清单共享, 偏好取 Telegram 那份) */}+ {telegram.enabled ? renderWorkdirSection(telegramPrefsState) : null}+ </div>+ </ImChannelSettingsCard>+ ) : null}</div>);}diff --git a/apps/desktop/src/renderer/components/settings/ImChannelSettingsCard.tsx b/apps/desktop/src/renderer/components/settings/ImChannelSettingsCard.tsxindex 7ecc4d68da..d65eb7aba6 100644--- a/apps/desktop/src/renderer/components/settings/ImChannelSettingsCard.tsx+++ b/apps/desktop/src/renderer/components/settings/ImChannelSettingsCard.tsx@@ -77,7 +77,9 @@ export function ImChannelSettingsCard({'bg-[var(--settings-theme-card-bg)]',)}>- <div className="flex items-center">+ {/* hover 高亮挂在整行容器上: headerAction 在按钮外, 挂按钮会让行尾+ (开关区)缺一截高亮 */}+ <div className="flex items-center transition-colors hover:bg-[var(--surface-hover-soft)]"><buttontype="button"aria-expanded={expanded}@@ -85,7 +87,6 @@ export function ImChannelSettingsCard({onClick={onToggle}className={cn('flex min-h-[76px] min-w-0 flex-1 select-none items-center gap-4 px-4 py-3 text-left',- 'transition-colors hover:bg-[var(--surface-hover-soft)]','focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-[var(--focus-ring)]',)}>diff --git a/apps/desktop/src/renderer/components/settings/__tests__/HookConnectionsSection.test.tsx b/apps/desktop/src/renderer/components/settings/__tests__/HookConnectionsSection.test.tsxindex 3e1eec9846..58ec32e772 100644--- a/apps/desktop/src/renderer/components/settings/__tests__/HookConnectionsSection.test.tsx+++ b/apps/desktop/src/renderer/components/settings/__tests__/HookConnectionsSection.test.tsx@@ -69,6 +69,13 @@ vi.mock('../HookWorkspacePrefsEditor', () => ({import { deriveAlias, HookConnectionsSection, workspaceRowsToMap } from '../HookConnectionsSection';+/** 渠道卡收起时内容卸载(Collapse), 交互前先点开对应卡的头部行。 */+async function expandChannelCard(titleKey: RegExp) {+ fireEvent.click(await screen.findByRole('button', { name: titleKey }));+}+const SLACK_CARD = /settings\.tina\.prefs\.providerSlack/;+const TELEGRAM_CARD = /settings\.tina\.prefs\.providerTelegram/;+const BASE_HOOK: SlackHookView = {enabled: false,url: 'wss://im.example.test',@@ -147,6 +154,7 @@ describe('HookConnectionsSection Telegram binding actions', () => {ipc.providerBindStart.mockResolvedValue({ hook: BASE_HOOK });render(<HookConnectionsSection />);+ await expandChannelCard(TELEGRAM_CARD);fireEvent.click(await screen.findByRole('button', {@@ -182,6 +190,7 @@ describe('HookConnectionsSection Telegram binding actions', () => {ipc.get.mockResolvedValue({ hook });render(<HookConnectionsSection />);+ await expandChannelCard(TELEGRAM_CARD);const openButton = await screen.findByRole('button', {name: 'settings.remoteControl.hook.telegram.openTelegram',@@ -370,6 +379,7 @@ describe('HookConnectionsSection Telegram binding actions', () => {});render(<HookConnectionsSection />);+ await expandChannelCard(TELEGRAM_CARD);expect(await screen.findByText('Unexpected server response: 503')).toBeTruthy();});@@ -412,6 +422,7 @@ describe('HookConnectionsSection Telegram binding actions', () => {},});});+ await expandChannelCard(TELEGRAM_CARD);expect(await screen.findByRole('button', {name: 'settings.remoteControl.hook.telegram.cancel',@@ -451,6 +462,7 @@ describe('HookConnectionsSection Telegram binding actions', () => {);render(<HookConnectionsSection />);+ await expandChannelCard(TELEGRAM_CARD);const connect = await screen.findByRole('button', {name: 'settings.remoteControl.hook.telegram.connect',});@@ -541,6 +553,7 @@ describe('HookConnectionsSection Telegram binding actions', () => {ipc.get.mockResolvedValue({ hook: confirmed('binding-1') });render(<HookConnectionsSection />);+ await expandChannelCard(TELEGRAM_CARD);fireEvent.click(await screen.findByRole('button', {name: 'settings.remoteControl.hook.telegram.unlink',@@ -589,6 +602,7 @@ describe('HookConnectionsSection Telegram binding actions', () => {ipc.get.mockResolvedValue({ hook: withBinding(false) });render(<HookConnectionsSection />);+ await expandChannelCard(SLACK_CARD);fireEvent.click(await screen.findByRole('button', {name: 'settings.remoteControl.hook.multi.removeAria',diff --git a/apps/desktop/src/renderer/components/settings/__tests__/ImChannelSettingsCard.test.tsx b/apps/desktop/src/renderer/components/settings/__tests__/ImChannelSettingsCard.test.tsxindex 9ad286a6ed..a29d575fe5 100644--- a/apps/desktop/src/renderer/components/settings/__tests__/ImChannelSettingsCard.test.tsx+++ b/apps/desktop/src/renderer/components/settings/__tests__/ImChannelSettingsCard.test.tsx@@ -1,7 +1,7 @@// @vitest-environment jsdomimport { cleanup, fireEvent, render, screen, waitFor } from '@testing-library/react';-import { afterEach, describe, expect, it } from 'vitest';+import { afterEach, describe, expect, it, vi } from 'vitest';import { useState } from 'react';import { ImChannelSettingsCard } from '../ImChannelSettingsCard';@@ -23,6 +23,28 @@ function Harness() {);}+function HeaderActionHarness({ onAction }: { onAction: () => void }) {+ const [expanded, setExpanded] = useState(false);+ return (+ <ImChannelSettingsCard+ id="channel-action-test"+ title="Slack"+ description="Cindy channel"+ status={<span>Connected</span>}+ routeSummary={null}+ headerAction={+ <button type="button" onClick={onAction}>+ Enable+ </button>+ }+ expanded={expanded}+ onToggle={() => setExpanded((value) => !value)}+ >+ <button type="button">Edit Channel</button>+ </ImChannelSettingsCard>+ );+}+describe('ImChannelSettingsCard', () => {afterEach(() => cleanup());@@ -42,4 +64,17 @@ describe('ImChannelSettingsCard', () => {expect(screen.getByRole('button', { name: 'Edit Channel' })).toBeTruthy();});});++ it('does not toggle expansion when the header action is clicked', () => {+ const onAction = vi.fn();+ render(<HeaderActionHarness onAction={onAction} />);++ fireEvent.click(screen.getByRole('button', { name: 'Enable' }));++ expect(onAction).toHaveBeenCalledOnce();+ expect(screen.getByRole('button', { name: /Slack/ }).getAttribute('aria-expanded')).toBe(+ 'false',+ );+ expect(screen.queryByRole('button', { name: 'Edit Channel' })).toBeNull();+ });});diff --git a/apps/desktop/src/renderer/i18n/locales/en/common.json b/apps/desktop/src/renderer/i18n/locales/en/common.jsonindex 9e1809ed6b..c6115efcac 100644--- a/apps/desktop/src/renderer/i18n/locales/en/common.json+++ b/apps/desktop/src/renderer/i18n/locales/en/common.json@@ -1896,6 +1896,9 @@},"hook": {"description": "Connect Slack and Telegram to the same Cindy. Messages are dispatched to this device and share its project list and session runner; each provider keeps its own account and preferences.",+ "slackDescription": "Bind Slack workspaces and hand tasks to Cindy from Slack.",+ "slackDisabledHint": "Turn on the switch to start Slack authorization; once bound you can dispatch tasks from Slack.",+ "slackBoundHint": "Binding complete. Turning the switch off unbinds this device; turning it back on requires authorizing again.","toggleAria": "Toggle the Slack connection","installApp": "Install Slack App","status": {@@ -1906,7 +1909,8 @@"error": "Connection failed"},"form": {- "workspaces": "Working directory mapping (alias → local absolute path)",+ "workspacesCardTitle": "Workdir mappings",+ "workspacesCardDescription": "Alias → local absolute path; the directory list is shared across channels while run preferences stay per channel.","workspacesBoundCount_one": "{{count}} local working directory bound","workspacesBoundCount_other": "{{count}} local working directories bound","aliasPlaceholder": "Alias, e.g. my-server",@@ -1947,7 +1951,6 @@"waitingHint": "Waiting for the installation to finish… Binding completes automatically once installed, no re-authorization needed."},"multi": {- "title": "Slack workspaces","statusWorkspaces_one": "{{count}} workspace","statusWorkspaces_other": "{{count}} workspaces","statusPendingSuffix_one": " ({{count}} pending)",@@ -1967,6 +1970,8 @@"alreadyBound": "You authorized {{team}}, which is already linked. To add another workspace, switch workspaces in the top-right corner of the Slack authorization page before allowing."},"telegram": {+ "description": "Link your Telegram account and dispatch tasks to Cindy via the official bot.",+ "disabledHint": "Turn on the switch, then follow the prompts in Telegram to link your account.","toggleAria": "Toggle the Telegram connection","connect": "Link Telegram","openTelegram": "Open Telegram",@@ -2026,8 +2031,7 @@"toast": {"saveFailed": "Failed to save directory preferences"},- "teamChipAria": "Choose which Slack workspace these preferences belong to",- "providerAria": "Choose which IM provider these preferences belong to"+ "teamChipAria": "Choose which Slack workspace these preferences belong to"}},"devices": {diff --git a/apps/desktop/src/renderer/i18n/locales/ja/common.json b/apps/desktop/src/renderer/i18n/locales/ja/common.jsonindex 033eb68c28..b32cb31bd7 100644--- a/apps/desktop/src/renderer/i18n/locales/ja/common.json+++ b/apps/desktop/src/renderer/i18n/locales/ja/common.json@@ -1895,6 +1895,9 @@},"hook": {"description": "Slack と Telegram を同じ Cindy に接続します。メッセージはこのデバイスに送られ、プロジェクト一覧とセッション実行基盤を共有します。アカウント連携と設定はプロバイダーごとに分離されます。",+ "slackDescription": "Slack ワークスペースを連携し、Slack から Cindy にタスクを依頼できます。",+ "slackDisabledHint": "スイッチをオンにすると Slack 認証が始まります。連携が完了すると Slack からタスクを依頼できます。",+ "slackBoundHint": "連携が完了しました。スイッチをオフにすると連携が解除され、再びオンにするには再認証が必要です。","toggleAria": "Slack 接続の有効状態を切り替え","installApp": "Slack アプリをインストール","status": {@@ -1905,7 +1908,8 @@"error": "接続失敗"},"form": {- "workspaces": "作業ディレクトリのマッピング(エイリアス → ローカル絶対パス)",+ "workspacesCardTitle": "作業ディレクトリのマッピング",+ "workspacesCardDescription": "エイリアス → ローカル絶対パス。ディレクトリ一覧は全チャンネル共通で、実行設定はチャンネルごとに独立します。","workspacesBoundCount_one": "ローカル作業ディレクトリを {{count}} 個バインド済み","workspacesBoundCount_other": "ローカル作業ディレクトリを {{count}} 個バインド済み","aliasPlaceholder": "エイリアス(例: my-server)",@@ -1946,7 +1950,6 @@"waitingHint": "インストールの完了を待っています…完了するとバインドは自動的に行われ、再認証は不要です。"},"multi": {- "title": "Slack ワークスペース","statusWorkspaces_one": "{{count}} 個のワークスペース","statusWorkspaces_other": "{{count}} 個のワークスペース","statusPendingSuffix_one": "({{count}} 件対応待ち)",@@ -1966,6 +1969,8 @@"alreadyBound": "認可されたのはすでに連携済みの {{team}} です。別のワークスペースを追加するには、Slack の認可ページ右上でワークスペースを切り替えてから許可してください。"},"telegram": {+ "description": "Telegram アカウントを連携し、公式 bot 経由で Cindy にタスクを依頼できます。",+ "disabledHint": "スイッチをオンにして、Telegram 内の案内に従ってアカウント連携を完了してください。","toggleAria": "Telegram 接続を切り替える","connect": "Telegram と連携","openTelegram": "Telegram を開く",@@ -2025,8 +2030,7 @@"toast": {"saveFailed": "ディレクトリ設定の保存に失敗しました"},- "teamChipAria": "設定の対象となる Slack ワークスペースを選択",- "providerAria": "設定の対象となる IM プロバイダーを選択"+ "teamChipAria": "設定の対象となる Slack ワークスペースを選択"}},"devices": {diff --git a/apps/desktop/src/renderer/i18n/locales/ko/common.json b/apps/desktop/src/renderer/i18n/locales/ko/common.jsonindex a9f4db9cc3..f2836be101 100644--- a/apps/desktop/src/renderer/i18n/locales/ko/common.json+++ b/apps/desktop/src/renderer/i18n/locales/ko/common.json@@ -1895,6 +1895,9 @@},"hook": {"description": "Slack과 Telegram을 하나의 Cindy에 연결합니다. 메시지는 이 기기로 전달되며 프로젝트 목록과 세션 실행기를 공유합니다. 계정 연동과 설정은 공급자별로 분리됩니다.",+ "slackDescription": "Slack 워크스페이스를 연결하고 Slack에서 Cindy에게 작업을 맡기세요.",+ "slackDisabledHint": "스위치를 켜면 Slack 인증이 시작됩니다. 연결이 완료되면 Slack에서 작업을 맡길 수 있습니다.",+ "slackBoundHint": "연결이 완료되었습니다. 스위치를 끄면 연결이 해제되며 다시 켜려면 재인증이 필요합니다.","toggleAria": "Slack 연결 활성 상태 전환","installApp": "Slack 앱 설치","status": {@@ -1905,7 +1908,8 @@"error": "연결 실패"},"form": {- "workspaces": "작업 디렉터리 매핑(별칭 → 로컬 절대 경로)",+ "workspacesCardTitle": "작업 디렉터리 매핑",+ "workspacesCardDescription": "별칭 → 로컬 절대 경로. 디렉터리 목록은 모든 채널이 공유하며 실행 설정은 채널별로 독립적입니다.","workspacesBoundCount_one": "로컬 작업 디렉터리 {{count}}개 바인딩됨","workspacesBoundCount_other": "로컬 작업 디렉터리 {{count}}개 바인딩됨","aliasPlaceholder": "별칭, 예: my-server",@@ -1946,7 +1950,6 @@"waitingHint": "설치 완료를 기다리는 중… 설치되면 바인딩이 자동으로 완료되며 재인증은 필요 없습니다."},"multi": {- "title": "Slack 워크스페이스","statusWorkspaces_one": "워크스페이스 {{count}}개","statusWorkspaces_other": "워크스페이스 {{count}}개","statusPendingSuffix_one": "({{count}}개 처리 대기)",@@ -1966,6 +1969,8 @@"alreadyBound": "이미 연동된 {{team}}이(가) 인증되었습니다. 다른 워크스페이스를 추가하려면 Slack 인증 페이지 오른쪽 위에서 워크스페이스를 전환한 후 허용하세요."},"telegram": {+ "description": "Telegram 계정을 연결하고 공식 bot을 통해 Cindy에게 작업을 맡기세요.",+ "disabledHint": "스위치를 켠 뒤 Telegram의 안내에 따라 계정 연결을 완료하세요.","toggleAria": "Telegram 연결 전환","connect": "Telegram 연결","openTelegram": "Telegram 열기",@@ -2025,8 +2030,7 @@"toast": {"saveFailed": "디렉터리 설정을 저장하지 못했습니다"},- "teamChipAria": "환경설정이 속한 Slack 워크스페이스 선택",- "providerAria": "환경설정이 속한 IM 공급자 선택"+ "teamChipAria": "환경설정이 속한 Slack 워크스페이스 선택"}},"devices": {diff --git a/apps/desktop/src/renderer/i18n/locales/zh-CN/common.json b/apps/desktop/src/renderer/i18n/locales/zh-CN/common.jsonindex 70bd26b749..c2117c9fe1 100644--- a/apps/desktop/src/renderer/i18n/locales/zh-CN/common.json+++ b/apps/desktop/src/renderer/i18n/locales/zh-CN/common.json@@ -1895,6 +1895,9 @@},"hook": {"description": "把 Slack 和 Telegram 接入同一个 Cindy:消息都会派发到这台设备,共享项目清单与 session 执行链;账号绑定和运行偏好按渠道隔离。",+ "slackDescription": "绑定 Slack workspace,在 Slack 里 @Cindy 派发任务。",+ "slackDisabledHint": "打开开关即发起 Slack 授权,绑定完成后即可在 Slack 里派活。",+ "slackBoundHint": "已完成绑定。关闭开关将解除绑定,重新打开需再次授权。","toggleAria": "切换 Slack 连接的启用状态","installApp": "安装 Slack App","status": {@@ -1905,7 +1908,8 @@"error": "连接失败"},"form": {- "workspaces": "工作目录映射(别名 → 本地绝对路径)",+ "workspacesCardTitle": "工作目录映射",+ "workspacesCardDescription": "别名 → 本地绝对路径;目录清单所有渠道共用,运行偏好按渠道独立。","workspacesBoundCount_one": "已绑定 {{count}} 个本地工作目录","workspacesBoundCount_other": "已绑定 {{count}} 个本地工作目录","aliasPlaceholder": "别名, 如 my-server",@@ -1946,7 +1950,6 @@"waitingHint": "等待安装完成…装好后会自动完成绑定, 无需再次授权。"},"multi": {- "title": "Slack workspaces","statusWorkspaces_one": "{{count}} 个 workspace","statusWorkspaces_other": "{{count}} 个 workspace","statusPendingSuffix_one": "({{count}} 个待处理)",@@ -1966,6 +1969,8 @@"alreadyBound": "授权的是已绑定的 {{team}}。要添加其它 workspace, 请在 Slack 授权页右上角先切换到目标 workspace 再点允许。"},"telegram": {+ "description": "关联 Telegram 账号,通过官方 bot 给 Cindy 派发任务。",+ "disabledHint": "打开开关后,按提示在 Telegram 里完成账号关联。","toggleAria": "切换 Telegram 连接","connect": "关联 Telegram","openTelegram": "打开 Telegram",@@ -2025,8 +2030,7 @@"toast": {"saveFailed": "保存目录偏好失败"},- "teamChipAria": "选择偏好所属的 Slack workspace",- "providerAria": "选择偏好所属的 IM 渠道"+ "teamChipAria": "选择偏好所属的 Slack workspace"}},"devices": {