From de1e76e2f5920b72ef63bf04fc8ccdb870274696 Mon Sep 17 00:00:00 2001 From: Menghuan1918 Date: Mon, 5 Oct 2026 23:01:24 +0800 Subject: [PATCH] =?UTF-8?q?feat(sidebar):=20=E5=90=8E=E5=8F=B0=E6=BF=80?= =?UTF-8?q?=E6=B4=BB=E7=9A=84=E9=A1=B5=E9=9D=A2=E4=B8=8D=E5=86=8D=E9=A1=B6?= =?UTF-8?q?=E6=8E=89=E8=AF=BB=E8=80=85=EF=BC=8C=E6=94=B9=E4=B8=BA=E6=A0=87?= =?UTF-8?q?=E8=AE=B0=E6=9C=AA=E8=AF=BB=E7=BA=A2=E7=82=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 维护者在 #817 上批准了「后台自动激活不接管右侧栏」的行为,并要求同批补上 「后台新开了页面」的提示:事件不能丢,但也不能把读者正在看的页面顶走。 行为: - 被门控跳过的那次激活仍然创建任务管理页,只是不再抢焦点 (`OpenTabSeed.reveal: false` → 宿主 `revealIfOpened: false`,即 「放置但不聚焦」;页面类型本来就没有自己的聚焦路径,已经存在的页面 再开一次也只是一次聚焦,正是门控要拒绝的那件事)。 - 该页在原生右栏芯片与插件底部工作台对应页签上显示一个静态小红点 (`aria-label` = 新词条 `tabUnread`,颜色取既有 `--dsw-alias-danger`)。 - 读者切到该页即清除标记:底部工作台走 service.activateTab;原生栏的 点击插件看不见(`ISidebarRight` 只有 `active()` 读取器,没有选中事件流), 所以由宿主自己的芯片按 `tab.visible` 清除——非可见芯片不清除, 否则宿主为每个展开页签都画标题,红点刚亮就会被抹掉。 - 标记存进会话状态的 `unread: TabType[]`(随布局持久化,跨挂载/跨会话/ 刷新都在),两个承载面读同一份,不会各自为政。 文案:20 份词典同批更新两条设置项描述(门控行为变了)+ 新增 `tabUnread` 词条(ja 真日文)。 测试:`tests/sidebar-auto-activation.spec.tsx` 的门控两条改为断言 「页面仍创建 + revealIfOpened:false + 标记出现」,并加红点生命周期与 「已在任务页/正常激活不标红」三条;新增 `tests/native-tab-unread.spec.tsx` 钉住原生芯片这一承载面(画点、按 visible 清除、非可见不清除、别的类型 不串味、不破坏可访问名)。判别性用 6 处镜像还原逐条证伪(见报告)。 --- src/client/Sidebar.tsx | 10 ++ src/client/TabBar.tsx | 19 +++ src/client/locales-ar.ts | 5 +- src/client/locales-de.ts | 5 +- src/client/locales-fr.ts | 5 +- src/client/locales-hi.ts | 5 +- src/client/locales-id.ts | 5 +- src/client/locales-it.ts | 5 +- src/client/locales-ja.ts | 5 +- src/client/locales-ko.ts | 5 +- src/client/locales-nl.ts | 5 +- src/client/locales-pl.ts | 5 +- src/client/locales-pt.ts | 5 +- src/client/locales-ru.ts | 5 +- src/client/locales-sv.ts | 5 +- src/client/locales-th.ts | 5 +- src/client/locales-tr.ts | 5 +- src/client/locales-vi.ts | 5 +- src/client/locales-zh-HK.ts | 5 +- src/client/locales-zh-MO.ts | 5 +- src/client/locales-zh-TW.ts | 5 +- src/client/locales.ts | 6 +- src/client/native/surface.ts | 6 + src/client/native/tab-adapter.tsx | 44 +++++- src/client/service.ts | 67 ++++++++- src/client/sidebar.module.css | 24 +++ src/client/sidebar/use-host-feeds.ts | 35 ++++- src/client/split-pane.tsx | 16 +- src/client/state.ts | 99 ++++++++++++ tests/consumer-types.ts | 4 + tests/native-tab-unread.spec.tsx | 200 +++++++++++++++++++++++++ tests/sidebar-auto-activation.spec.tsx | 85 ++++++++++- tests/tab-bar-right-actions.spec.tsx | 1 + 33 files changed, 654 insertions(+), 57 deletions(-) create mode 100644 tests/native-tab-unread.spec.tsx diff --git a/src/client/Sidebar.tsx b/src/client/Sidebar.tsx index 5509ef7f..311db8d2 100644 --- a/src/client/Sidebar.tsx +++ b/src/client/Sidebar.tsx @@ -33,6 +33,7 @@ import { referenceInChat as referenceInChatShared } from './reference-in-chat.ts import { DockFallback } from './sidebar/dock-fallback.tsx' import { BOTTOM_MIN, CONVERSATION_MIN, + isUnread, leafWithTab, moveTab, moveTabToEdge, openDiffTab, resizeSplitIn, setBottomHeight, toggleBottomPanel, toggleExpanded, type DropZone, type SidebarStore, type SidebarTab, @@ -657,6 +658,14 @@ export function Sidebar(props: { ctx: Context; store: SidebarStore }) { return {text} } + /** + * Whether one workbench tab carries the unread dot: its page holds + * background work the reader has not looked at yet. Reads the SAME session + * state the native chip does, so the two carriers cannot disagree, and the + * shell re-renders on the store change that sets or retires the mark. + */ + const isTabUnread = (tab: SidebarTab): boolean => isUnread(state, tab.type) + /** * The active tab's right-aligned action area from the tab-type registry: * a descriptor that declares `rightActions` supplies its own toolbar @@ -795,6 +804,7 @@ export function Sidebar(props: { ctx: Context; store: SidebarStore }) { renderTab={renderTab} getTabIcon={tabIconOf} getTabBadge={tabBadgeOf} + isTabUnread={isTabUnread} getTabRightActions={tabRightActionsOf} onRevealInFileManager={revealTabFile} /> diff --git a/src/client/TabBar.tsx b/src/client/TabBar.tsx index 9efc5d72..cd36315e 100644 --- a/src/client/TabBar.tsx +++ b/src/client/TabBar.tsx @@ -69,6 +69,14 @@ export function TabBar(props: { /** Badge resolver for tab labels (reads the descriptor's `badge`; the * resolver returns the rendered pill or null). */ getTabBadge?: (tab: SidebarTab) => ReactNode + /** + * Unread resolver for tab labels: the page has something the reader has not + * looked at yet (a background activation opened it without taking the column + * over). Rendered as a small dot beside the label; `false`/undefined draws + * nothing, so a strip with no marks is byte-identical to one that never had + * the feature. + */ + isTabUnread?: (tab: SidebarTab) => boolean /** * Right-aligned action area resolver for the active tab: returns a * ReactNode rendered at the tab strip's right end (between the + button @@ -91,6 +99,7 @@ export function TabBar(props: { }) { const { paneId, tabs, active, onActivate, onClose, onNewTab, newTabOptions, onDropTab, getTabIcon, getTabBadge, getTabRightActions, + isTabUnread, onRevealInFileManager, } = props const [menuOpen, setMenuOpen] = useState(false) @@ -251,6 +260,16 @@ export function TabBar(props: { {getTabIcon?.(tab) ?? null} {getTabBadge?.(tab) ?? null} {tab.title} + {isTabUnread?.(tab) === true + ? ( + + ) + : null}