feat(sidebar): polish loading, floating windows and clue provenance
This commit is contained in:
1 parent
3313b8779f
commit
39ccabcefb
40 files changed
+337
-101
No files matched your search
@@ -69,6 +69,10 @@
|
||||
- 🧪 守护:`tests/market-manifest.spec.ts` 同时校验仓库清单与 `pnpm pack` 后的发布清单,dependencies 必须恰好是 `ws` / `yaml`,且 `src` 仍在 `files` 里。
|
||||
|
||||
|
||||
- ✨ **侧栏细节改进**:内容加载使用居中的环形动画,尊重减少动态效果偏好;转为浮窗后移除原标签页,草稿与滚动位置不变;浮窗边缘稍加粗,文件预览与线索收集使用更清晰的独立图标。
|
||||
- **选区保留来源**:线索正文或评论的「选择并插入」同时携带稳定 `dsh-clue` 引用和选区原文,模型能识别来源;保存引用失败时保留选区供重试,不发送消息。
|
||||
- **设置入口对齐**:标签页、文件预览开关旁始终保留设置按钮;无设置项时禁用,有设置项时即使功能关闭也可配置。开始页「更多」新增「侧边栏设置」。
|
||||
|
||||
- 🧭 **新增「线索收集」Tab:把文件、飞书任务/文档、GitHub issue 与 PR 收进一处,用统一浮窗预览与编辑**:右侧栏多出一个 tab,顶部一条来源分段(本地文件 / GitHub Issues / GitHub Pull requests / 飞书文档 / 飞书任务,最后选中的来源会记住),其下是范围栏(当前仓库或工作区,可切换)与共享 `SearchField`;列表行 30px,行内动作只在悬停或键盘聚焦时出现(触控恒显且 44px)。
|
||||
- **资料类型随栏宽切换**:宽栏横排显示各来源的图标和名称;窄栏保留紧凑下拉。资料浏览和包内添加共用这套控件,调整栏宽不会切换来源。
|
||||
- **资料与资料包采用 VS Code 式可调分区**:多个区块可各自展开、同时显示;用鼠标、触控或键盘上下调整分隔柄。布局写入插件设置,折叠不丢失搜索、列表位置和草稿。
|
||||
|
||||
@@ -71,6 +71,10 @@
|
||||
- 🧪 `tests/market-manifest.spec.ts` checks both the repo and the `pnpm pack` manifest: dependencies must be exactly `ws` / `yaml`, and `src` must stay in `files`.
|
||||
|
||||
|
||||
- ✨ **Sidebar polish**: content loading uses a centered ring animation with reduced-motion support. Floating a window removes its former tab while preserving drafts and scroll position; floating edges are slightly stronger, and file preview and Clues have distinct, clearer icons.
|
||||
- **Selection provenance**: inserting a clue body or comment selection carries both a stable `dsh-clue` reference and the exact excerpt. Failed reference preparation keeps the selection available for retry and never sends a message.
|
||||
- **Aligned settings actions**: tab and viewer switches always reserve a settings button, disabled only when no settings exist. Existing configuration stays accessible even when its feature is off. Start-page More now includes Sidebar settings.
|
||||
|
||||
- 🧭 **New Clues tab: local files, Feishu tasks/docs and GitHub issues/PRs in one place, previewed and edited in one host window**: the right column gains a tab whose top row is a source segment (local files / GitHub issues / GitHub pull requests / Feishu docs / Feishu tasks, remembering the last choice), followed by a scope row (the current repository or workspace) and the shared `SearchField`. Rows are 30px, with row actions only on hover or keyboard focus (always visible at 44px on touch).
|
||||
- **Resource types adapt to the column width**: wide panes show source icons and names in a row; narrow panes use a compact menu. Resizing the browser or pack member picker keeps the selected source.
|
||||
- **Resources and Collections use resizable VS Code-style sections**: expand several together and drag the horizontal dividers, or resize with the keyboard. The layout is remembered, and collapsing a section preserves its search, scroll position, and drafts.
|
||||
|
||||
@@ -43,7 +43,7 @@
|
||||
| 底部终端的恢复语义(#774) | 刷新后重新上屏同一页签时,页面用**同一份 `(sessionId, key, contentId)`** 再次调用宿主的 `webTerminals.view()`:宿主持久化在 localStorage 的 `(sessionId, contentId) → 终端 id` 绑定因此把**同一个** PTY 认回来(`contentId` 是 `dsh-better-sidebar:terminal-bottom:<instance>`——**每个页签一个实例,不再是恒定值**,#926)。插件**不把 terminalId 写进 `tab.meta`**:`view()` 显式传 terminalId 会关掉宿主的「缺了就建」分支,一个过期的 id 会把页签永久卡在 `missingTerminal` 上。DSH 重启后 PTY 全没了而 localStorage 绑定还在,所以「新建终端」按钮把 `tab.meta.terminalRun` +1 换一代 `contentId`,让宿主另铸一个进程,而不是反复认领死绑定 |
|
||||
| 底部工作台的开合 | 落到底部工作台的打开一律展开它(新建与聚焦都算),因此 `openTab` 的落点永远可见;开合按钮注册在 DSH 会话头的 utilities 槽(`conversation.session.header.utilities`),不在插件自己的宿主里 |
|
||||
| 在侧边打开(`target: 'side'`,v0.22.0+) | 原生栏里的 tab **不在插件底部工作台的分栏树里**,所以「在侧边打开」不能写 `bottomSplits`(那样会落到用户没展开的底部工作台 = 点了没反应)。服务改为把这一步交给宿主:带 path 的 `editor` seed 走 `openResource(address, { preferNewPane: true, revealIfOpened: false })`——宿主先按自己的两格上限与空间规则尝试分栏,分不了才回退到当前格;`revealIfOpened: false` 允许与已打开的同名资源并存,因此对同一个文件再点一次也会新开一格。其余类型若传 `target: 'side'`,同样以 `preferNewPane` 落原生栏(组件型 tab 的 path 仍是组件种子)——**唯一的例外是 `bottomOnly` 类型**(#774):它没有原生承载面可落,`target: 'side'` 被改道回 `'bottom'`。path-less 的 `editor`(文件页)与 `'bottom'` 行为不变 |
|
||||
| 开始页接管(v0.31 起) | 插件在 `sidebar.right.tab.guide` 注册一个恒选中的 chain 条目,自己绘制开始页:宽屏每行两张、窄屏一张,行数可配置(默认 6,最小 1,设置与「调整顺序」弹窗共用同一个输入组件),内容默认垂直居中、可切换靠上;设置中的「接管开始页」开关默认开,关闭后恢复宿主自带开始页。超出容量的卡片收进「更多」,菜单行为图标 + 标题;「更多」常驻并恢复宿主的「浏览更多插件」「创建你的插件」动作(`pluginNavigation.openList()` / `uiWorkspace.startSession(..., { agentPreset: 'cordis', whenDraftExists: 'append' })`),服务缺失时对应行隐藏。设置页「侧边栏内容 → 开始页」与「调整顺序」列出**当前注册到官方的全部开始页入口**(本插件、宿主终端、第三方),默认全部显示;本插件自己的 tab 使用与「侧边栏内容」功能卡片相同的 `tabsEnabled` 开关(关闭即禁用并移出开始页,清单行保留以便重新打开),宿主/第三方入口的开关只控制开始页显示、不注销 tab 类型。排序按 `providerId::entryId` 持久化。**第三方 guide 条目仍会出现,但其自定义卡片组件不会被复用**:`sidebar.right.tab.guide.entry` 由宿主 guide body 独占声明,chain 条目拿不到 `renderSlot`。当前官方只有终端的 TerminalGuide 是自定义卡片,插件通过 `ctx.webTerminals.launchShells` / `selectShell` 复刻其 Shell 菜单;其他自定义卡片显示为通用卡片。宿主 `MAX_DESCRIBED_ENTRIES` 的描述隐藏逻辑不再适用,插件卡片始终显示描述。
|
||||
| 开始页接管(v0.31 起) | 插件在 `sidebar.right.tab.guide` 注册一个恒选中的 chain 条目,自己绘制开始页:宽屏每行两张、窄屏一张,行数可配置(默认 6,最小 1,设置与「调整顺序」弹窗共用同一个输入组件),内容默认垂直居中、可切换靠上;设置中的「接管开始页」开关默认开,关闭后恢复宿主自带开始页。超出容量的卡片收进「更多」,菜单行为图标 + 标题;「更多」常驻,提供打开共享设置面的「侧边栏设置」,并恢复宿主的「浏览更多插件」「创建你的插件」动作(`pluginNavigation.openList()` / `uiWorkspace.startSession(..., { agentPreset: 'cordis', whenDraftExists: 'append' })`),服务缺失时对应行隐藏。设置页「侧边栏内容 → 开始页」与「调整顺序」列出**当前注册到官方的全部开始页入口**(本插件、宿主终端、第三方),默认全部显示;本插件自己的 tab 使用与「侧边栏内容」功能卡片相同的 `tabsEnabled` 开关(关闭即禁用并移出开始页,清单行保留以便重新打开),宿主/第三方入口的开关只控制开始页显示、不注销 tab 类型。排序按 `providerId::entryId` 持久化。**第三方 guide 条目仍会出现,但其自定义卡片组件不会被复用**:`sidebar.right.tab.guide.entry` 由宿主 guide body 独占声明,chain 条目拿不到 `renderSlot`。当前官方只有终端的 TerminalGuide 是自定义卡片,插件通过 `ctx.webTerminals.launchShells` / `selectShell` 复刻其 Shell 菜单;其他自定义卡片显示为通用卡片。宿主 `MAX_DESCRIBED_ENTRIES` 的描述隐藏逻辑不再适用,插件卡片始终显示描述。
|
||||
| 新建标签页列表 | 每个 tab 类型在原生 guide 里占一行:标题取 `title` + 图标取 `icon`(缺图标时宿主补一个方块占位),说明取可选的 `description`——**宿主只在 guide 列出的条目 ≤ 4 条时渲染说明**(上游 `MAX_DESCRIBED_ENTRIES = 4`),更长的列表整列丢掉所有说明;未声明 `description` 的条目渲染成单行「图标 + 标题」(rc.1 起 `description` 回到宿主契约,但**宿主与插件都没有兜底句**,所以插件恢复字段而不恢复旧的通用句);`hidden: true` 的类型不占行,**`bottomOnly: true` 的类型同样不占行**(#774:它只活在插件自己的底部 `+` 菜单里)。插件的 `editor` 类型不再单独占行(它认领的文件资源由 `files` 接管页承载同一视图)。**本插件默认贡献 5 个 guide 条目**(文件 / Git / 线索收集 / 任务管理 / 侧边对话),已经超过宿主上限 4,说明整列默认不渲染(宿主的终端条目再占一行);要让说明回来,需在插件设置页关掉足够多的 tab 类型把总数压到 ≤ 4 条 |
|
||||
| 新建面板的种子(alpha.2) | 在新会话打开原生新面板时,宿主从已注册的 guide 条目里播种:恰好 1 个条目 → 直接打开那一页;0 或 ≥2 个条目 → 打开指南。`revealIfOpened` 打开的「页面」在**同一 pane 内**强制去重(已在该 pane 就不再新建);由已有 tab 地址驱动的打开不受该去重影响 |
|
||||
| alpha.2 全局面板(不接入) | 插件**不采用** alpha.2 引入的全局主面板模型——根级 keyed `main` 槽(预留 key `conversation`,由 ui-conversation 注册为 `main.conversation`)、根级 `sidebar.panellist` 列表槽(`SidebarPanelMetadata` / `SidebarPanelIconOwnerProps`)、`ctx.layout.selectPanel(MainPanelId|null)` / `beginNavigation()` / `dispose()`、全局标准 prop `usePanelInfo`,以及改根级并新增会话级 `rightbar.session` 子槽的 `rightbar`——这些只作兼容保留,不向其迁移 |
|
||||
@@ -1087,6 +1087,8 @@ registerSidechatSurfaceAdapter(adapter: SidechatSurfaceAdapter): () => void
|
||||
|
||||
在内置编辑器(`code` / `markdown` / `jsonl` 的 CodeMirror 面,以及 markdown 预览)里划选一段文字,弹窗「添加到对话」会往主会话 composer 落一枚 chip。此处记录它用到的契约与降级,第三方插件若想复刻同一套交互可以照抄。
|
||||
|
||||
线索详情的正文和评论选区另有来源要求:显式插入前,未持久化的候选先调用 `clues.ensure` 取得稳定 ID;已存线索复用现有 ID。随后用内置 `reference` chip 携带 `[[dsh-clue:<id>]]`、空行和选区原文,发送时两者一起展开;不改用只序列化 token 的线索 codec,以免丢失选区。纯文本降级也保留两者。失败时保留菜单,插入本身不发送消息。
|
||||
|
||||
**宿主服务与 chip 身份**
|
||||
|
||||
- 落 chip 走宿主 `conversation` 服务的 `input.for(session).insertReference(ref, span)`(#1052 之后内置的通道;`ref: ReferenceInsert = { source, ref, label, appearance?, clipboardText }`,`span = { draftRev, start, end }`)。`insertDraftReference()` 负责把「插件投影坐标」折成编辑器检测投影坐标、补前导空格、并在 `snapshot.occurrences` 存在时走 span 通道而不是整框重写(#1002:整框重写会把已有 chip 拍平成纯文本)。
|
||||
@@ -1256,6 +1258,17 @@ if (ctx.betterSidebar.features.includes('tabActions')) {
|
||||
|
||||
---
|
||||
|
||||
### 7.5 统一内容窗口(windowHost)
|
||||
|
||||
`ctx.betterSidebar.windows.open(options)` 按稳定 `id` 打开窗口,返回 `WindowHandle`;重复打开只聚焦现有实例,不替换其草稿或导航栈。内容既可浮动,也可通过 `surface: 'sidebar'` 停靠到打开时所属会话的原生标签页。
|
||||
|
||||
- `handle.dock?.()` 将同一份内容移到原会话的侧栏;不可停靠时返回 `false`。
|
||||
- `handle.float?.()` 先移动原内容,再关闭原生标签页,不保留浮窗提示页;草稿、导航栈和滚动位置继续由同一个实例持有。这不是关闭内容,不运行 `onBeforeClose`。
|
||||
- `handle.close()` 才运行 `onBeforeClose`;拒绝关闭会保留内容。`update()` 不会重置用户放置的几何。
|
||||
- 浮窗边缘使用更强的 `--dsw-alias-border-l4`,宽度为 2px;停靠后不绘制这条浮窗外框。全部视觉值继续走宿主令牌。
|
||||
|
||||
---
|
||||
|
||||
## 8. 声明式设置(v0.4.1+)
|
||||
|
||||
每个注册的 tab / viewer **自动**出现在 DSH 设置页「侧边卡片」分区(`SideCardSection` 按注册表驱动渲染,无硬编码),**`hidden: true` 的 tab 类型除外**:
|
||||
@@ -1263,7 +1276,8 @@ if (ctx.betterSidebar.features.includes('tabActions')) {
|
||||
- 展示:小卡片网格(图标 + 标题 + 类型 id),**高亮 = 启用**,勾选徽标钉在卡片最右端;viewer 卡片额外显示扩展名。`hidden` 类型没有 `+` 菜单行、没有原生 guide 条目,也就没有可切换的承载面,因此不进清单,且 `isTabEnabled()` 对它恒为 true(#1009)。
|
||||
- 持久化:开关写入 `SidebarPrefs.tabsEnabled / viewersEnabled`(开放 map,**缺省 = 启用**,显式 `false` 才禁用;`hidden` 类型的键被忽略)。
|
||||
- 关闭语义:tab 从 `+` 菜单消失、`openTab` 拒绝新开(`console.warn`)、派生流程(子代理自动展开、agent 终端自动补 tab)停止,**已打开的 tab 保留**;viewer 被 `matchFileViewer` 跳过,文件落到下一个匹配。
|
||||
- `settings.toggles`(可选):在卡片行下追加**嵌套设置行**(仅父级启用时显示),绑定 `SidebarPrefs` 字段;通过卡片底部「功能设置」条在原生弹窗中编辑。行控件形状见 §4.1 的 `SettingRow`:`type: 'switch' | 'text' | 'number'`(v0.11.0+;text/number 行 blur/Enter 提交,number 行按 min/max 钳制,unit 渲染单位后缀)与 `type: 'select'`(v0.13.0+;`options` 支持 value/title/desc/icon,`multi` 多选存数组并按 options 顺序提交;任一项带 icon 时渲染大图标选项卡)与 `type: 'patterns'`(可编辑字符串数组——chips + 删除钮 + 常驻添加输入框,add/remove 均原子提交整表,占位符走 `patternsPlaceholder`,值必须存 `string[]`;能力 gate `settingPatterns`)。内置示例:subagent tab 的 `autoOpenSubagent`、editor tab 的 `editorExplorer` 图标化下拉(工作区路径围栏与它的开关已移除,见 §8.1)与 `explorerExclude` 排除模式行。
|
||||
- 功能清单每行始终保留设置齿轮,确保开关对齐;没有可配置项时按钮禁用。配置是否可打开只取决于设置是否存在,不受功能开关影响。
|
||||
- `settings.toggles`(可选):声明**嵌套设置行**,绑定 `SidebarPrefs` 字段;通过行尾的「功能设置」齿轮在弹窗中编辑。行控件形状见 §4.1 的 `SettingRow`:`type: 'switch' | 'text' | 'number'`(v0.11.0+;text/number 行 blur/Enter 提交,number 行按 min/max 钳制,unit 渲染单位后缀)与 `type: 'select'`(v0.13.0+;`options` 支持 value/title/desc/icon,`multi` 多选存数组并按 options 顺序提交;任一项带 icon 时渲染大图标选项卡)与 `type: 'patterns'`(可编辑字符串数组——chips + 删除钮 + 常驻添加输入框,add/remove 均原子提交整表,占位符走 `patternsPlaceholder`,值必须存 `string[]`;能力 gate `settingPatterns`)。内置示例:subagent tab 的 `autoOpenSubagent`、editor tab 的 `editorExplorer` 图标化下拉(工作区路径围栏与它的开关已移除,见 §8.1)与 `explorerExclude` 排除模式行。
|
||||
- `settings.pluginToggles`(可选,v0.12.0+):**插件自有设置行**,行控件与 toggles 相同,但 key 是插件局部的——持久化在 prefs 文档的 `pluginSettings[<descriptor id>]`(开放 map,无需宿主 schema 字段)。tab 与 viewer 都可用(v0.12.0 起 viewer 卡片也有设置条)。**默认值要显式声明**:用户在写入前该 blob 是空的,行读不到值就会显示「—」(switch 行恰好读成关闭,看似正常;select 行则直接不显示当前生效值)。声明 `defaultValue`(JSON 可序列化,与 `options[].value` 同类)后,行在你第一次写入前就显示并返回该值——它表达的是「功能本来就在用的默认」,不是「预填一个待保存的值」;写入后存储值优先。
|
||||
- `settings.render`(可选,v0.12.0+):**自定义设置面板**——追加渲染在行列表之后,可单独存在。props 含 store/service/prefs、本 descriptor 的 `pluginSettings` blob、`updatePluginSetting(key, value)` 与 `close()`;抛错会被吞掉并显示内联错误。
|
||||
|
||||
|
||||
@@ -51,7 +51,7 @@ import type { ClueSelectionActionTarget } from './clues/selection-actions.tsx'
|
||||
import { clearRetargetedPath, closePathTabs, consumeRetargetedPath, pathTabKey, retargetPathTabs } from './tree-mutations.ts'
|
||||
import type { EditorToolbarControls, EditorToolbarState, FileViewerDescriptor, TabActionDescriptor } from './service.ts'
|
||||
import { firstLeaf, insertLeafAt, leafWithTab, mintTabId, type SidebarStore, type SidebarTab } from './state.ts'
|
||||
import { Tabs } from './ui/index.ts'
|
||||
import { LoadingIndicator, Tabs } from './ui/index.ts'
|
||||
import css from './sidebar.module.css'
|
||||
|
||||
/**
|
||||
@@ -945,7 +945,7 @@ export function EditorHost(props: {
|
||||
<div className={css.editorMain}>
|
||||
{actionError !== null && <div className={css.editorError}>{actionError}</div>}
|
||||
{showEmpty && <div className={css.editorPlaceholder}>{t('editorEmptyHint')}</div>}
|
||||
{!showEmpty && load.status === 'loading' && <div className={css.editorPlaceholder}>{t('loading')}</div>}
|
||||
{!showEmpty && load.status === 'loading' && <LoadingIndicator centered />}
|
||||
{!showEmpty && load.status === 'error' && (
|
||||
<div className={css.editorError} role="alert">
|
||||
<div>{load.fileNotFound ? t('editorFileNotFound', { path }) : load.message}</div>
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
* scrolling body, an optional footer and three resize strips.
|
||||
*
|
||||
* Tokens only (`--dsw-alias-*` / `--dsw-font-*`): the frame wears the same
|
||||
* 1px `border-l2` edge, 6px corners and a flat token surface.
|
||||
* 2px `border-l4` edge, 6px corners and a flat token surface.
|
||||
*/
|
||||
.window {
|
||||
position: fixed;
|
||||
@@ -14,7 +14,7 @@
|
||||
min-width: 0;
|
||||
min-height: 0;
|
||||
background: var(--dsw-alias-bg-layer-1);
|
||||
border: 1px solid var(--dsw-alias-border-l2);
|
||||
border: 2px solid var(--dsw-alias-border-l4);
|
||||
border-radius: 6px;
|
||||
box-shadow: none;
|
||||
overflow: hidden;
|
||||
|
||||
@@ -34,7 +34,7 @@
|
||||
* streamed log is the visible drag lag of #315).
|
||||
*
|
||||
* Skin contract: tokens only (`--dsw-alias-*` / `--dsw-font-*`), the floating
|
||||
* layer uses the same flat 1px border and 6px corners as the shared controls.
|
||||
* layer uses a stronger 2px edge and 6px corners to separate it from the page.
|
||||
*/
|
||||
import {
|
||||
Fragment, isValidElement, useCallback, useEffect, useMemo, useRef, useState,
|
||||
|
||||
@@ -3,6 +3,7 @@ import { useEffect, useRef, useState } from 'react'
|
||||
import clsx from 'clsx'
|
||||
import { downloadUrl, mediaUrl, type SessionScope } from './api.ts'
|
||||
import { t } from './locales.ts'
|
||||
import { LoadingIndicator } from './ui/LoadingIndicator.tsx'
|
||||
import css from './sidebar.module.css'
|
||||
|
||||
export function PdfView(props: { scope: SessionScope; path: string; title: string }) {
|
||||
@@ -91,7 +92,7 @@ export function PdfView(props: { scope: SessionScope; path: string; title: strin
|
||||
</a>
|
||||
</div>
|
||||
<div className={css.editorPdfStage}>
|
||||
{load.status === 'loading' && <div className={css.editorPlaceholder}>{t('loading')}</div>}
|
||||
{load.status === 'loading' && <LoadingIndicator centered />}
|
||||
{load.status === 'error' && <div className={css.editorError}>{load.message}</div>}
|
||||
{load.status === 'ready' && (
|
||||
<iframe
|
||||
|
||||
@@ -1724,7 +1724,7 @@ export function SideCardSection(props: SideCardSectionInjected & Partial<PropsRu
|
||||
rowKey: string
|
||||
error?: string
|
||||
onToggle: (next: boolean) => void
|
||||
/** A feature with related settings shows a separate secondary action. */
|
||||
/** An absent handler leaves the aligned settings action disabled. */
|
||||
onOpenSettings?: () => void
|
||||
}) => {
|
||||
const hasSettingsAction = props.onOpenSettings !== undefined
|
||||
@@ -1748,13 +1748,12 @@ export function SideCardSection(props: SideCardSectionInjected & Partial<PropsRu
|
||||
onChange={props.onToggle}
|
||||
/>
|
||||
</div>
|
||||
{hasSettingsAction && (
|
||||
<IconButton
|
||||
icon={<IconSettingsOutlineRegular size={14} />}
|
||||
label={`${props.title} ${t('settingsPopup')}`}
|
||||
onClick={() => { props.onOpenSettings?.() }}
|
||||
/>
|
||||
)}
|
||||
<IconButton
|
||||
icon={<IconSettingsOutlineRegular size={14} />}
|
||||
label={`${props.title} ${t('settingsPopup')}`}
|
||||
disabled={!hasSettingsAction}
|
||||
onClick={() => { props.onOpenSettings?.() }}
|
||||
/>
|
||||
{props.error !== undefined && (
|
||||
<p className={css.cardError} role="alert" data-settings-error={props.rowKey}>
|
||||
{props.error}
|
||||
@@ -1785,9 +1784,7 @@ export function SideCardSection(props: SideCardSectionInjected & Partial<PropsRu
|
||||
rowKey: `tab:${tab.id}`,
|
||||
error: writeErrors[`tab:${tab.id}`],
|
||||
onToggle: (next) => { onToggleTab(tab.id, next) },
|
||||
// The settings gear only while the feature is enabled: its
|
||||
// related settings are dormant while the feature is off.
|
||||
onOpenSettings: prefs.tabsEnabled[tab.id] !== false && hasSettings(tab)
|
||||
onOpenSettings: hasSettings(tab)
|
||||
? () => { setSettingsFor(tab) }
|
||||
: undefined,
|
||||
})}
|
||||
@@ -1828,7 +1825,7 @@ export function SideCardSection(props: SideCardSectionInjected & Partial<PropsRu
|
||||
rowKey: `viewer:${viewer.id}`,
|
||||
error: writeErrors[`viewer:${viewer.id}`],
|
||||
onToggle: (next) => { onToggleViewer(viewer.id, next) },
|
||||
onOpenSettings: prefs.viewersEnabled[viewer.id] !== false && hasSettings(viewer)
|
||||
onOpenSettings: hasSettings(viewer)
|
||||
? () => { setSettingsFor(viewer) }
|
||||
: undefined,
|
||||
})}
|
||||
|
||||
@@ -34,4 +34,6 @@
|
||||
color: var(--dsw-alias-label-primary);
|
||||
}
|
||||
|
||||
/* Clues uses its own token-layered collection artwork (clues/artwork.tsx). */
|
||||
.clues {
|
||||
color: var(--dsw-alias-state-business-primary, var(--dsw-alias-brand-primary));
|
||||
}
|
||||
@@ -6,19 +6,13 @@
|
||||
* tab strip, the native right Sidebar's guide capsules and its tab chips — all
|
||||
* read the same colorful glyph from `descriptor.icon`.
|
||||
*
|
||||
* The color always arrives from a theme token, never from the plugin: the
|
||||
* ordinary glyph is a VSCodicon drawn in `currentColor`, and the wrapper class
|
||||
* supplies that color. Clues instead uses token-colored layered artwork, as do
|
||||
* the collection rows inside its workbench. A skin keeps control (guide §12);
|
||||
* `tests/theme.spec.ts` checks these modules for color literals.
|
||||
*
|
||||
* `files` is the one exception in kind rather than in color: it renders DSH's
|
||||
* own folder artwork (`FileTypeIcon`), matching the file rows this tab shows.
|
||||
* Each glyph draws in `currentColor`; its wrapper supplies a skin-owned
|
||||
* token. File preview and Clues use distinct outline silhouettes so their
|
||||
* meaning remains clear at dense tab-strip sizes. Collection rows retain
|
||||
* their separate layered artwork. `tests/theme.spec.ts` guards the palette.
|
||||
*/
|
||||
import type { ReactNode } from 'react'
|
||||
import { FileTypeIcon } from '@deepseek-ai/dsh-client-ui-primitives'
|
||||
import styles from './tab-icons.module.css'
|
||||
import { CluePackArtwork } from '../clues/artwork.tsx'
|
||||
import {
|
||||
VscCommentDiscussion,
|
||||
VscGitCommit,
|
||||
@@ -26,7 +20,7 @@ import {
|
||||
VscTerminal,
|
||||
} from 'react-icons/vsc'
|
||||
/** The styled wrapper classes; typed so a renamed rule fails the build. */
|
||||
const css = styles as Record<'files' | 'changes' | 'tasks' | 'sidechat' | 'terminal', string>
|
||||
const css = styles as Record<'files' | 'clues' | 'changes' | 'tasks' | 'sidechat' | 'terminal', string>
|
||||
|
||||
/** One tab type's glyph, sized by the caller's surface (14px in a strip). */
|
||||
export type TabIcon = (size: number) => ReactNode
|
||||
@@ -36,11 +30,14 @@ function themed(className: string, glyph: ReactNode): ReactNode {
|
||||
return <span className={className}>{glyph}</span>
|
||||
}
|
||||
|
||||
/** The Files tab: the host's folder artwork, like the rows it opens. */
|
||||
export const filesTabIcon: TabIcon = (size) => (
|
||||
<span className={css.files}>
|
||||
<FileTypeIcon kind="folder" size={size} />
|
||||
</span>
|
||||
/** File preview: a folded document with a clear reading aperture. */
|
||||
export const filesTabIcon: TabIcon = (size) => themed(css.files,
|
||||
<svg width={size} height={size} viewBox="0 0 20 20" fill="none" aria-hidden="true" focusable="false">
|
||||
<path d="M4 2h7l4 4v4M15 16v1a1 1 0 0 1-1 1H4a1 1 0 0 1-1-1V3a1 1 0 0 1 1-1Z" stroke="currentColor" strokeWidth="1.5" strokeLinejoin="round" />
|
||||
<path d="M11 2v4h4M6 6h2M6 9h4" stroke="currentColor" strokeWidth="1.5" strokeLinecap="round" strokeLinejoin="round" />
|
||||
<path d="M8 13.5s2-3 5-3 5 3 5 3-2 3-5 3-5-3-5-3Z" stroke="currentColor" strokeWidth="1.5" />
|
||||
<circle cx="13" cy="13.5" r="1.4" fill="currentColor" />
|
||||
</svg>,
|
||||
)
|
||||
|
||||
/** Changes / diff: the commit glyph, green like the diff affordances. */
|
||||
@@ -67,5 +64,11 @@ export const sidechatTabIcon: TabIcon = (size) =>
|
||||
export const terminalTabIcon: TabIcon = (size) =>
|
||||
themed(css.terminal, <VscTerminal size={Math.max(10, Math.round(size * 0.85))} />)
|
||||
|
||||
/** Clues — the same layered collection artwork used by its directory rows. */
|
||||
export const cluesTabIcon: TabIcon = (size) => <CluePackArtwork size={size} />
|
||||
/** Clues: collected cards with a bookmark, distinct from the file viewer. */
|
||||
export const cluesTabIcon: TabIcon = (size) => themed(css.clues,
|
||||
<svg width={size} height={size} viewBox="0 0 20 20" fill="none" aria-hidden="true" focusable="false">
|
||||
<path d="M3 13H2.5A1.5 1.5 0 0 1 1 11.5v-8A1.5 1.5 0 0 1 2.5 2h10A1.5 1.5 0 0 1 14 3.5V4" stroke="currentColor" strokeWidth="1.5" />
|
||||
<rect x="5" y="6" width="13" height="12" rx="2" stroke="currentColor" strokeWidth="1.5" />
|
||||
<path d="M12 6v6l2-1.5 2 1.5V6M8 14h3M8 16h5" stroke="currentColor" strokeWidth="1.5" strokeLinecap="round" strokeLinejoin="round" />
|
||||
</svg>,
|
||||
)
|
||||
@@ -33,6 +33,7 @@ import type { ClueSourceDescriptor } from '../../clues/types.ts'
|
||||
import { t } from '../locales.ts'
|
||||
import {
|
||||
insertDraftReference,
|
||||
insertReferenceOrText,
|
||||
type ComposerReference,
|
||||
type ComposerSpan,
|
||||
} from '../conversation-draft.ts'
|
||||
@@ -201,6 +202,24 @@ export function insertClueReference(ctx: Context, sessionId: string, request: Cl
|
||||
}
|
||||
}
|
||||
|
||||
/** Insert a selected excerpt with its stable provenance in one model-facing payload. */
|
||||
export function insertClueSelectionReference(ctx: Context, sessionId: string, request: {
|
||||
readonly clueId: string
|
||||
readonly selection: string
|
||||
readonly label?: string
|
||||
}): boolean {
|
||||
if (sessionId === '' || request.selection.trim() === '') return false
|
||||
let token: string
|
||||
try { token = serializeClueToken('clue', request.clueId) } catch { return false }
|
||||
// The built-in reference codec sends this payload verbatim; the clue codec
|
||||
// sends only the source token and would discard the selected excerpt.
|
||||
return insertReferenceOrText(ctx, sessionId, {
|
||||
label: request.label ?? request.selection.trim().split('\n')[0]!.slice(0, 80),
|
||||
text: token + '\n\n' + request.selection,
|
||||
clipboardText: token,
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* Insert a whole pack's reference (no ensure: the pack id is already stable).
|
||||
* @returns whether the chip landed.
|
||||
|
||||
@@ -109,7 +109,8 @@ export function startClueSelectionAction(request: ClueSelectionActionRequest): P
|
||||
}
|
||||
|
||||
/** One insert decision: the parent appends the payload to its composer draft. */
|
||||
interface ClueSelectionInsertInput {
|
||||
export interface ClueSelectionInsertInput {
|
||||
readonly clueId?: string
|
||||
/** Present when the wrapper/bridge knows the owning clue target. */
|
||||
readonly workspaceId?: string
|
||||
readonly sessionId?: string
|
||||
@@ -123,7 +124,7 @@ interface ClueSelectionInsertInput {
|
||||
}
|
||||
|
||||
/** The parent-installed insert callback; `false` may mean "refused". */
|
||||
export type ClueSelectionInsertHandler = (input: ClueSelectionInsertInput) => boolean | void
|
||||
export type ClueSelectionInsertHandler = (input: ClueSelectionInsertInput) => boolean | void | Promise<boolean | void>
|
||||
|
||||
/**
|
||||
* The page-wide bridge. It survives a component tree with no
|
||||
@@ -184,7 +185,7 @@ export function useClueSelectionActionTarget(scope?: ClueSelectionActionScope):
|
||||
const local = useContext(TargetContext)
|
||||
const bridge = useSyncExternalStore(subscribeClueSelectionActionContext, getClueSelectionActionContext, getClueSelectionActionContext)
|
||||
if (local !== undefined) {
|
||||
return bridge?.onInsert === undefined ? local : { ...local, onInsert: bridge.onInsert }
|
||||
return local.onInsert !== undefined || bridge?.onInsert === undefined ? local : { ...local, onInsert: bridge.onInsert }
|
||||
}
|
||||
if (bridge?.workspaceId === undefined || bridge.resource === undefined) return undefined
|
||||
// A module-level target is only safe for the surface it named. A caller
|
||||
@@ -336,8 +337,19 @@ export function SelectionActionMenu(props: SelectionActionMenuProps): ReactNode
|
||||
// A parent may refuse the insert (e.g. the composer moved); keep the
|
||||
// menu and the captured selection available for an explicit retry.
|
||||
const reference = props.reference ?? { label: selection.trim().split('\n')[0]!.slice(0, 80), text: insert }
|
||||
const accepted = onInsert?.({ workspaceId, sessionId, resource, selection, insert, reference })
|
||||
if (accepted !== false) onClose?.()
|
||||
busyRef.current = true
|
||||
setBusy(action)
|
||||
setFailure(null)
|
||||
try {
|
||||
const accepted = await onInsert?.({ workspaceId, sessionId, resource, selection, insert, reference })
|
||||
if (accepted === false) setFailure({ message: t('clueInsertFailed') })
|
||||
else onClose?.()
|
||||
} catch (error) {
|
||||
setFailure({ message: error instanceof Error ? error.message : t('clueInsertFailed') })
|
||||
} finally {
|
||||
busyRef.current = false
|
||||
setBusy(null)
|
||||
}
|
||||
return
|
||||
}
|
||||
// Freeze synchronously as well as visually: two clicks in one render must not mint two intents.
|
||||
@@ -455,6 +467,7 @@ export function SelectionActionMenu(props: SelectionActionMenuProps): ReactNode
|
||||
|
||||
/** Props of the wrapper surface. */
|
||||
interface ResourceSelectionActionsProps {
|
||||
readonly onInsert?: ClueSelectionInsertHandler
|
||||
readonly workspaceId: string
|
||||
readonly sessionId: string
|
||||
readonly resource: ClueClientResourceInput
|
||||
@@ -472,12 +485,13 @@ export function ResourceSelectionActions(props: ResourceSelectionActionsProps):
|
||||
const { workspaceId, sessionId, resource, children, comment } = props
|
||||
const wrapperRef = useRef<HTMLDivElement>(null)
|
||||
const bridge = useClueSelectionActionContext()
|
||||
const onInsert = props.onInsert ?? bridge?.onInsert
|
||||
const target: ClueSelectionActionTarget = {
|
||||
workspaceId,
|
||||
sessionId,
|
||||
resource,
|
||||
...(comment === undefined ? {} : { comment }),
|
||||
...(bridge?.onInsert === undefined ? {} : { onInsert: bridge.onInsert }),
|
||||
...(onInsert === undefined ? {} : { onInsert }),
|
||||
}
|
||||
const popup = useSelectionPopup({
|
||||
onCommit: () => undefined,
|
||||
@@ -546,7 +560,7 @@ export function ResourceSelectionActions(props: ResourceSelectionActionsProps):
|
||||
...(comment === undefined ? {} : { comment }),
|
||||
left: popup.popup.left,
|
||||
top: popup.popup.top,
|
||||
...(bridge?.onInsert === undefined ? {} : { onInsert: bridge.onInsert }),
|
||||
...(onInsert === undefined ? {} : { onInsert }),
|
||||
onClose: () => { popup.hide() },
|
||||
containerRef: popup.popupRef,
|
||||
}),
|
||||
|
||||
@@ -367,7 +367,7 @@ export function CluesTab({ ctx, store, scope, visible }: CluesTabProps): ReactNo
|
||||
{visible && helpOpen && <ClueHelpOverlay onClose={closeHelp} />}
|
||||
|
||||
{!resolved && (
|
||||
<LoadingIndicator className={css.state} />
|
||||
<LoadingIndicator centered />
|
||||
)}
|
||||
{resolved && workspaceId === undefined && (
|
||||
<EmptyState tone="page" title={t('clueTabNoWorkspace')}
|
||||
|
||||
@@ -1261,7 +1261,7 @@ export function ClueBrowser(props: ClueBrowserProps): ReactNode {
|
||||
}} />
|
||||
)}
|
||||
{state.kind === 'idle' && <EmptyState title={t('clueBrowserSearchNeeded')} />}
|
||||
{state.kind === 'loading' && <LoadingIndicator className={css.stateLine} />}
|
||||
{state.kind === 'loading' && <LoadingIndicator centered />}
|
||||
{state.kind === 'needs-scope' && (
|
||||
<EmptyState title={state.reason === 'search' ? t('clueBrowserSearchScopeNeeded') : t('clueScopeNoDefault')}
|
||||
actions={<ActionButton size="sm" onClick={() => { setScopeOpen(true) }}>{t('clueBrowserScopeEdit')}</ActionButton>} />
|
||||
|
||||
@@ -353,6 +353,8 @@
|
||||
overscroll-behavior: contain;
|
||||
scrollbar-width: thin;
|
||||
}
|
||||
.resultArea[data-clue-browser-state='loading'] { display: flex; flex-direction: column; }
|
||||
.resultArea[data-clue-browser-state='loading'] > .listContainer { flex: 1; min-height: 0; }
|
||||
.resultArea:focus-visible {
|
||||
outline: 2px solid var(--dsw-alias-brand-primary);
|
||||
outline-offset: -2px;
|
||||
@@ -494,6 +496,7 @@
|
||||
.packRegion > [data-workbench-section] {
|
||||
max-height: 100%;
|
||||
}
|
||||
.packScroll:has(> [data-loading-indicator][data-centered]) { display: flex; flex-direction: column; }
|
||||
.packScroll {
|
||||
flex: 1;
|
||||
min-height: 0;
|
||||
|
||||
@@ -44,7 +44,7 @@ import { cluesApi, invalidateClueRequests, peekClueRequest } from '../api.ts'
|
||||
import { openShareWindow } from '../windows/share.tsx'
|
||||
import {
|
||||
ActionButton, ConfirmDialog, EmptyState, ErrorBlock, IconButton, ListRow, LoadingIndicator, Menu,
|
||||
Notice, SearchField, StatusLine, TextInput,
|
||||
Notice, SearchField, TextInput,
|
||||
} from '../../ui/index.ts'
|
||||
import { useScrollLoad } from '../../ui/use-scroll-load.ts'
|
||||
import { useListNavigation } from '../../ui/use-list-navigation.ts'
|
||||
@@ -454,7 +454,7 @@ export function CluePacksSection(props: CluePacksSectionProps): ReactNode {
|
||||
)}
|
||||
|
||||
<div ref={scrollRef} className={css.packScroll} data-clue-pack-scroll>
|
||||
{phase === 'loading' && <StatusLine plain text={<LoadingIndicator inline />} />}
|
||||
{phase === 'loading' && <LoadingIndicator centered />}
|
||||
{error !== null && (
|
||||
<ErrorBlock
|
||||
message={error}
|
||||
|
||||
@@ -22,7 +22,7 @@ export interface ResourceDiscussionProps {
|
||||
readonly pathImages?: MarkdownPathImages
|
||||
readonly showAvatars?: boolean
|
||||
/** Captured resource ownership; only each comment's body enters this surface. */
|
||||
readonly selectionTarget?: Pick<ClueSelectionActionTarget, 'workspaceId' | 'sessionId' | 'resource'>
|
||||
readonly selectionTarget?: Pick<ClueSelectionActionTarget, 'workspaceId' | 'sessionId' | 'resource' | 'onInsert'>
|
||||
onLoad(cursor?: string, parentId?: string): void
|
||||
onCreate(body: string, replyToId: string | undefined, requestId: string): Promise<void>
|
||||
}
|
||||
|
||||
@@ -79,7 +79,7 @@ import {
|
||||
} from '../resource-summary.tsx'
|
||||
import { ClueError } from '../../../clues/error.ts'
|
||||
import { ResourceDiscussion } from './comments.tsx'
|
||||
import { ResourceSelectionActions, type ClueSelectionActionTarget } from '../selection-actions.tsx'
|
||||
import { getClueSelectionActionContext, ResourceSelectionActions, type ClueSelectionActionTarget, type ClueSelectionInsertInput } from '../selection-actions.tsx'
|
||||
import { BUILTIN_SOURCE_IDS } from '../../../clues/types.ts'
|
||||
import css from './detail.module.css'
|
||||
|
||||
@@ -269,7 +269,7 @@ function readOnlyReasonCopy(reason: string | undefined): string {
|
||||
|
||||
/** The loading body. */
|
||||
function DetailStatus(props: { readonly text: string }): ReactNode {
|
||||
return createElement('div', { className: css.status }, createElement(LoadingIndicator, { label: props.text }))
|
||||
return createElement(LoadingIndicator, { centered: true, label: props.text })
|
||||
}
|
||||
|
||||
/** One explicit failure that could not even produce a preview. */
|
||||
@@ -608,7 +608,7 @@ function createDetailController(options: ClueDetailWindowOptions): DetailControl
|
||||
// active composer/session later when the reader selects its retained body.
|
||||
const selectionTarget: ClueSelectionActionTarget | undefined = options.sessionId === undefined || options.sessionId === ''
|
||||
? undefined
|
||||
: { workspaceId, sessionId: options.sessionId, resource }
|
||||
: { workspaceId, sessionId: options.sessionId, resource, onInsert: insertSelection }
|
||||
// Optional methods keep existing third-party API fakes body-only.
|
||||
const discussionApi = face.api as typeof face.api & {
|
||||
commentsList?(workspaceId: string, input: ClueClientResourceInput & { cursor?: string; parentId?: string }, signal?: AbortSignal): Promise<ClueDiscussionPage>
|
||||
@@ -771,11 +771,9 @@ function createDetailController(options: ClueDetailWindowOptions): DetailControl
|
||||
}
|
||||
|
||||
function pendingContent(): ReactNode {
|
||||
const header = headerNode()
|
||||
return createElement(
|
||||
'div',
|
||||
{ className: css.view, 'data-clue-detail-view': 'pending' },
|
||||
header ?? null,
|
||||
createElement(DetailStatus, { text: t('loading') }),
|
||||
)
|
||||
}
|
||||
@@ -1577,6 +1575,22 @@ function createDetailController(options: ClueDetailWindowOptions): DetailControl
|
||||
if (commentsCapabilities?.read === true) void loadComments()
|
||||
}
|
||||
|
||||
/** A quote carries the stable source token as well as the exact selected text. */
|
||||
async function insertSelection(input: ClueSelectionInsertInput): Promise<boolean> {
|
||||
const insert = getClueSelectionActionContext()?.onInsert
|
||||
if (insert === undefined || referenceBusy || (target.clueId === undefined && state.read === null)) return false
|
||||
referenceBusy = true
|
||||
render()
|
||||
try {
|
||||
const clueId = target.clueId ?? (await face.api.ensure(workspaceId, ensureInput())).clue.id
|
||||
if (disposed) return false
|
||||
return (await insert({ ...input, clueId })) !== false
|
||||
} finally {
|
||||
referenceBusy = false
|
||||
render()
|
||||
}
|
||||
}
|
||||
|
||||
/** Insert one reference; first persistence carries subtitle/info snapshots. */
|
||||
async function insertReference(): Promise<void> {
|
||||
// A candidate with no authoritative read must not persist the opening
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
*/
|
||||
import { createElement } from 'react'
|
||||
import type { SidebarStore } from '../../state.ts'
|
||||
import type { NativeGuideCatalog } from '../../native/guide-catalog.ts'
|
||||
import type { BetterSidebarService } from '../../service.ts'
|
||||
import type { BetterSidebarWindowsClientFace, WindowHandle } from '../../windows/types.ts'
|
||||
|
||||
@@ -27,6 +28,7 @@ interface OpenClueSettingsWindowOptions {
|
||||
readonly store: SidebarStore
|
||||
readonly service: BetterSidebarService
|
||||
readonly group?: ClueSettingsGroup
|
||||
readonly guideCatalog?: NativeGuideCatalog
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -47,6 +49,7 @@ export function openClueSettingsWindow(options: OpenClueSettingsWindowOptions):
|
||||
store: options.store,
|
||||
service: options.service,
|
||||
initialGroup: group,
|
||||
guideCatalog: options.guideCatalog,
|
||||
}),
|
||||
})
|
||||
}
|
||||
@@ -48,7 +48,7 @@ import { registerGithubSourceClient } from './clues/sources/github/index.tsx'
|
||||
import { registerFeishuSourceClient } from './clues/sources/feishu/index.tsx'
|
||||
import { appDateTime } from './clues/sources/feishu/time.ts'
|
||||
import { installClueInputTriggers } from './clues/mentions.ts'
|
||||
import { insertClueReferenceSpan, setClueNoticeSink } from './clues/insert.ts'
|
||||
import { insertClueReferenceSpan, insertClueSelectionReference, setClueNoticeSink } from './clues/insert.ts'
|
||||
import { clueMentionsCopy, feishuClientLabels } from './clues/locale-copy.ts'
|
||||
import { notifyClue } from './clues/notify.ts'
|
||||
import { resolveWorkspaceIdForSession } from './clues/workspace-id.ts'
|
||||
@@ -263,7 +263,9 @@ export function apply(ctx: Context): void {
|
||||
invalidate: invalidateClueAgentSave,
|
||||
})
|
||||
setClueSelectionActionContext({ onInsert: input => {
|
||||
const inserted = input.sessionId !== undefined && insertReferenceOrText(ctx, input.sessionId, input.reference ?? { label: input.selection.slice(0, 80), text: input.insert })
|
||||
const inserted = input.sessionId !== undefined && (input.clueId === undefined
|
||||
? insertReferenceOrText(ctx, input.sessionId, input.reference ?? { label: input.selection.slice(0, 80), text: input.insert })
|
||||
: insertClueSelectionReference(ctx, input.sessionId, { clueId: input.clueId, selection: input.selection, label: input.reference?.label }))
|
||||
if (!inserted) notifyClue(t('clueInsertFailed'))
|
||||
return inserted
|
||||
} })
|
||||
|
||||
@@ -53,6 +53,8 @@ export interface NativeGuideProps {
|
||||
onBrowsePlugins?: () => void
|
||||
/** Host "create your plugin" action, when the workspace can start a session. */
|
||||
onCreatePlugin?: () => void
|
||||
/** Open the same Sidebar settings used elsewhere in the plugin. */
|
||||
onOpenSettings?: () => void
|
||||
}
|
||||
|
||||
/** The grid's inputs, extracted for direct rendering in tests. */
|
||||
@@ -71,6 +73,8 @@ export interface GuideGridProps {
|
||||
onBrowsePlugins?: () => void
|
||||
/** Host "Create your plugin" action, when the workspace can start a session. */
|
||||
onCreatePlugin?: () => void
|
||||
/** Open the same Sidebar settings used elsewhere in the plugin. */
|
||||
onOpenSettings?: () => void
|
||||
shellMenu?: GuideShellMenu | undefined
|
||||
}
|
||||
|
||||
@@ -204,7 +208,7 @@ function GuideCard(props: {
|
||||
export function GuideGrid(props: GuideGridProps) {
|
||||
const {
|
||||
entries, prefs, width, onOpen, onSaveOrder, onToggleHidden, onSaveRows,
|
||||
onBrowsePlugins, onCreatePlugin, shellMenu,
|
||||
onBrowsePlugins, onCreatePlugin, onOpenSettings, shellMenu,
|
||||
} = props
|
||||
const inventory = props.inventory ?? entries
|
||||
const [orderOpen, setOrderOpen] = useState(false)
|
||||
@@ -262,7 +266,8 @@ export function GuideGrid(props: GuideGridProps) {
|
||||
...(layout.overflow.length === 0 ? [] : [{ type: 'separator' as const, id: 'overflow-separator' }]),
|
||||
...hostActions,
|
||||
...(hostActions.length === 0 ? [] : [{ type: 'separator' as const, id: 'actions-separator' }]),
|
||||
{ id: 'order', label: t('guideOrder'), icon: menuIcon(<IconSettingsOutlineRegular size={14} />) },
|
||||
{ id: 'order', label: t('guideOrder'), icon: menuIcon(<IconEllipsisOutlineRegular size={14} />) },
|
||||
...(onOpenSettings === undefined ? [] : [{ id: 'settings', label: t('clueSettingsWindowTitle'), icon: menuIcon(<IconSettingsOutlineRegular size={14} />) }]),
|
||||
]
|
||||
|
||||
/** The grid body; the More anchor is a card-sized Menu trigger. */
|
||||
@@ -285,6 +290,10 @@ export function GuideGrid(props: GuideGridProps) {
|
||||
onCreatePlugin?.()
|
||||
return
|
||||
}
|
||||
if (id === 'settings') {
|
||||
onOpenSettings?.()
|
||||
return
|
||||
}
|
||||
if (id === 'order') {
|
||||
setOrderOpen(true)
|
||||
return
|
||||
@@ -365,7 +374,7 @@ function useGuideWidth(ref: { current: HTMLDivElement | null }): number {
|
||||
|
||||
/** The chain component registered into the host's guide slot. */
|
||||
export function NativeGuide(props: NativeGuideProps) {
|
||||
const { catalog, store, service, shellMenu, onBrowsePlugins, onCreatePlugin, useTabInfo } = props
|
||||
const { catalog, store, service, shellMenu, onBrowsePlugins, onCreatePlugin, onOpenSettings, useTabInfo } = props
|
||||
const entries = useSyncExternalStore(catalog.subscribe, catalog.getSnapshot, catalog.getSnapshot)
|
||||
const [descriptors, setDescriptors] = useState(() => service.getTabs())
|
||||
useEffect(() => service.subscribe(() => setDescriptors(service.getTabs())), [service])
|
||||
@@ -414,6 +423,7 @@ export function NativeGuide(props: NativeGuideProps) {
|
||||
onSaveRows={(next) => { saveGuideRows(store, next) }}
|
||||
onBrowsePlugins={onBrowsePlugins}
|
||||
onCreatePlugin={onCreatePlugin}
|
||||
onOpenSettings={onOpenSettings}
|
||||
shellMenu={shellMenu}
|
||||
/>
|
||||
</div>
|
||||
|
||||
@@ -36,6 +36,7 @@ import type { SidebarStore } from '../state.ts'
|
||||
import { webTerminals } from '../terminal-client.ts'
|
||||
import type { NativeGuideCatalog } from './guide-catalog.ts'
|
||||
import { NativeGuide } from './guide.tsx'
|
||||
import { openClueSettingsWindow } from '../clues/windows/settings.tsx'
|
||||
import { EDITOR_KIND, FILES_KIND, nativeId } from './guide-ids.ts'
|
||||
import { mountedSessionId } from './surface.ts'
|
||||
import {
|
||||
@@ -391,6 +392,7 @@ export function registerNativeSurface(deps: NativeSurfaceDeps): () => void {
|
||||
catalog,
|
||||
store,
|
||||
service,
|
||||
onOpenSettings: () => { openClueSettingsWindow({ windows: service.windows, store, service, guideCatalog: catalog, group: 'general' }) },
|
||||
...(shellMenu === undefined ? {} : { shellMenu }),
|
||||
...(onBrowsePlugins === undefined ? {} : { onBrowsePlugins }),
|
||||
...(onCreatePlugin === undefined ? {} : { onCreatePlugin }),
|
||||
|
||||
@@ -1,24 +1,30 @@
|
||||
/** Shared loading feedback. CSS motion stops with hidden pages and reduced motion. */
|
||||
import type { AriaRole, ReactNode } from 'react'
|
||||
import clsx from 'clsx'
|
||||
import { IconLoadingOutlineRegular } from '@deepseek-ai/dsh-client-ui-primitives'
|
||||
import { t } from '../locales.ts'
|
||||
import css from './loading-indicator.module.css'
|
||||
|
||||
export interface LoadingIndicatorProps {
|
||||
label?: ReactNode
|
||||
inline?: boolean
|
||||
/** Fill the available content area instead of occupying a status line. */
|
||||
centered?: boolean
|
||||
size?: number
|
||||
className?: string
|
||||
role?: AriaRole
|
||||
}
|
||||
|
||||
export function LoadingIndicator({ label, inline = false, size = 14, className, role = 'status' }: LoadingIndicatorProps): ReactNode {
|
||||
export function LoadingIndicator({ label, inline = false, centered = false, size = centered ? 24 : 14, className, role = 'status' }: LoadingIndicatorProps): ReactNode {
|
||||
const text = label === undefined ? t('loading') : label
|
||||
return <span className={clsx(css.root, inline && css.inline, className)}
|
||||
return <span className={clsx(css.root, inline && css.inline, centered && css.centered, className)}
|
||||
role={role} aria-live={role === 'presentation' || role === 'none' ? undefined : 'polite'} aria-label={text === '' ? t('loading') : undefined}
|
||||
data-loading-indicator data-kind="loading">
|
||||
<span className={css.glyph} aria-hidden="true"><IconLoadingOutlineRegular size={size} /></span>
|
||||
data-loading-indicator data-kind="loading" data-centered={centered || undefined}>
|
||||
<span className={css.glyph} aria-hidden="true">
|
||||
<svg width={size} height={size} viewBox="0 0 24 24" fill="none" focusable="false">
|
||||
<circle className={css.track} cx="12" cy="12" r="9" stroke="currentColor" strokeWidth="2" />
|
||||
<path d="M12 3a9 9 0 0 1 9 9" stroke="currentColor" strokeWidth="2" strokeLinecap="round" />
|
||||
</svg>
|
||||
</span>
|
||||
{text === '' || text === null ? null : <span className={css.label}>{text}</span>}
|
||||
</span>
|
||||
}
|
||||
@@ -140,7 +140,7 @@ export function Notice(props: {
|
||||
}): ReactNode {
|
||||
const tone = props.tone ?? 'well'
|
||||
if (props.kind === 'loading') {
|
||||
return <LoadingIndicator label={props.children} inline={tone === 'inline'} role={props.role}
|
||||
return <LoadingIndicator label={props.children} inline={tone === 'inline'} centered={tone === 'page'} role={props.role}
|
||||
className={clsx(css.notice, tone === 'page' ? css.noticePage : tone === 'inline' ? css.noticeInline : css.noticeWell,
|
||||
css.noticeHint, props.className)} />
|
||||
}
|
||||
|
||||
@@ -1,12 +1,24 @@
|
||||
.root {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
gap: var(--ds-sidebar-space-2);
|
||||
min-width: 0;
|
||||
color: var(--dsw-alias-label-tertiary);
|
||||
font: var(--dsw-font-xxs-12);
|
||||
}
|
||||
.inline { display: inline-flex; }
|
||||
.centered {
|
||||
flex: 1;
|
||||
align-self: stretch;
|
||||
flex-direction: column;
|
||||
justify-content: center;
|
||||
min-height: 96px;
|
||||
padding: 24px;
|
||||
box-sizing: border-box;
|
||||
text-align: center;
|
||||
}
|
||||
.track { opacity: 0.18; }
|
||||
.glyph {
|
||||
display: inline-flex;
|
||||
flex: none;
|
||||
|
||||
@@ -48,6 +48,7 @@ interface RetainedSurfaceProps {
|
||||
readonly surface: WindowView['surface']
|
||||
readonly destination: HTMLElement | undefined
|
||||
readonly children: ReactNode
|
||||
readonly onPlaced: () => void
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -98,6 +99,7 @@ class RetainedSurface extends Component<RetainedSurfaceProps> {
|
||||
node.scrollLeft = position.left
|
||||
}
|
||||
if (active?.isConnected && document.activeElement !== active) active.focus({ preventScroll: true })
|
||||
this.props.onPlaced()
|
||||
}
|
||||
|
||||
componentDidMount(): void { this.place(null) }
|
||||
@@ -124,10 +126,11 @@ function WindowFrame(props: {
|
||||
const changeBox = useCallback((box: WindowView['box']): void => { host.setBox(id, box) }, [host, id])
|
||||
const changeMaximized = useCallback((maximized: boolean): void => { host.setMaximized(id, maximized) }, [host, id])
|
||||
const back = useCallback((): void => { host.popPage(id) }, [host, id])
|
||||
const placed = useCallback((): void => { host.completeSurfaceMove(id) }, [host, id])
|
||||
|
||||
return (
|
||||
<RetainedSurface target={target} id={id} surface={view.surface}
|
||||
destination={view.surface === 'floating' ? document.body : view.sidebarTarget}>
|
||||
destination={view.surface === 'floating' ? document.body : view.sidebarTarget} onPlaced={placed}>
|
||||
<FloatingWindow
|
||||
title={view.title}
|
||||
portalTarget={target}
|
||||
|
||||
@@ -259,7 +259,7 @@ export function ClueFormatHost(props: ClueFormatHostProps): ReactNode {
|
||||
>
|
||||
<div className={css.formatContent}>
|
||||
{editLoading === true
|
||||
? <div className={css.documentStatus} data-window-edit-loading><LoadingIndicator label={t('clueResourceEditLoading')} /></div>
|
||||
? <div className={css.documentStatus} data-window-edit-loading><LoadingIndicator centered label={t('clueResourceEditLoading')} /></div>
|
||||
: body(false)}
|
||||
</div>
|
||||
</section>}
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
* never a second window, never a replaced draft;
|
||||
* - `update` only changes the fields it names: a streamed refresh cannot move
|
||||
* or resize a window the reader placed;
|
||||
* - floating first moves the retained DOM, then removes the native tab;
|
||||
* - a close runs `onBeforeClose` first (async allowed); false/rejection keeps
|
||||
* the window and its content alive;
|
||||
* - the close/unmount path releases the layer subscription, so no listener
|
||||
@@ -61,6 +62,7 @@ interface WindowRecord {
|
||||
readonly id: string
|
||||
readonly sessionId: string | undefined
|
||||
surface: 'floating' | 'sidebar'
|
||||
pendingSidebarClose: boolean
|
||||
sidebarTarget: HTMLElement | undefined
|
||||
/** The window's own (base) title; a pushed page may override it while on top. */
|
||||
title: string
|
||||
@@ -330,6 +332,8 @@ export function createWindowHost(options: WindowHostOptions = {}): WindowHostCon
|
||||
return false
|
||||
}
|
||||
}
|
||||
if (record.surface === 'sidebar' && surface === 'floating') record.pendingSidebarClose = true
|
||||
if (surface === 'sidebar') record.pendingSidebarClose = false
|
||||
record.surface = surface
|
||||
notify()
|
||||
if (surface === 'floating') raiseWindowLayer(layerKey(record.id))
|
||||
@@ -405,6 +409,7 @@ export function createWindowHost(options: WindowHostOptions = {}): WindowHostCon
|
||||
sessionId: options.sessionId ?? optionsSessionId(),
|
||||
surface: 'floating',
|
||||
sidebarTarget: undefined,
|
||||
pendingSidebarClose: false,
|
||||
title: options.title,
|
||||
base: {
|
||||
content: options.content,
|
||||
@@ -509,6 +514,12 @@ export function createWindowHost(options: WindowHostOptions = {}): WindowHostCon
|
||||
const record = currentRecord(id)
|
||||
return record !== undefined && setSurface(record, surface)
|
||||
},
|
||||
completeSurfaceMove(id): void {
|
||||
const record = currentRecord(id)
|
||||
if (record === undefined || record.surface !== 'floating' || !record.pendingSidebarClose) return
|
||||
record.pendingSidebarClose = false
|
||||
if (record.sessionId !== undefined) sidebar?.close(record.id, record.sessionId)
|
||||
},
|
||||
setSidebarTarget(id, sessionId, target): void {
|
||||
const record = currentRecord(id)
|
||||
if (record === undefined || record.sessionId !== sessionId || record.sidebarTarget === target) return
|
||||
|
||||
@@ -8,7 +8,6 @@ import { useLayoutEffect, useRef, useSyncExternalStore, type ReactNode } from 'r
|
||||
import type { Context } from '../../context-types.ts'
|
||||
import type { NativeTabInfo } from '../native/tab-adapter.tsx'
|
||||
import type { WindowHostController } from './types.ts'
|
||||
import { ActionButton } from '../ui/index.ts'
|
||||
import { t } from '../locales.ts'
|
||||
import design from '../ui/design.module.css'
|
||||
import css from './windows.module.css'
|
||||
@@ -67,15 +66,7 @@ function NativeWindowBody({ host, sessionId, useTabInfo }: NativeWindowProps): R
|
||||
if (view?.sidebarTarget === destination) host.setSidebarTarget(id, sessionId, undefined)
|
||||
}
|
||||
}, [host, sessionId, id])
|
||||
const snapshot = useSyncExternalStore(host.subscribe, host.getSnapshot, host.getSnapshot)
|
||||
const view = snapshot.windows.find(window => window.id === id && window.sessionId === sessionId)
|
||||
return <div ref={target} className={`${design.surface} ${css.nativeDestination}`} data-window-sidebar-destination>
|
||||
{view?.surface !== 'sidebar' && <div className={css.documentStatus}>
|
||||
<p>{t('windowFloatingHint')}</p>
|
||||
{view !== undefined && <ActionButton variant="outline" size="sm"
|
||||
onClick={() => { host.setSurface(view.id, 'sidebar') }}>{t('windowDock')}</ActionButton>}
|
||||
</div>}
|
||||
</div>
|
||||
return <div ref={target} className={`${design.surface} ${css.nativeDestination}`} data-window-sidebar-destination />
|
||||
}
|
||||
|
||||
function NativeWindowTitle({ host, sessionId, useTabInfo }: NativeWindowProps): ReactNode {
|
||||
|
||||
@@ -222,7 +222,7 @@ export interface WindowHandle {
|
||||
close(): Promise<void>
|
||||
/** Move this instance to its original session's native sidebar; false when unavailable. */
|
||||
dock?(): boolean
|
||||
/** Return this same instance to its floating frame (optional for external window faces). */
|
||||
/** Float this same instance and close its native tab after moving the content. */
|
||||
float?(): void
|
||||
readonly navigation: WindowNavigation
|
||||
}
|
||||
@@ -306,6 +306,8 @@ export interface WindowHostController extends BetterSidebarWindowsClientFace {
|
||||
attachSidebar(sidebar: WindowSidebarAdapter): () => void
|
||||
/** @internal Move a live window without replacing its content. */
|
||||
setSurface(id: string, surface: 'floating' | 'sidebar'): boolean
|
||||
/** @internal Release the old tab after the retained DOM has moved to the floating frame. */
|
||||
completeSurfaceMove(id: string): void
|
||||
/** @internal Attach/detach the native body's DOM destination. */
|
||||
setSidebarTarget(id: string, sessionId: string, target: HTMLElement | undefined): void
|
||||
/** @internal Native close path, sharing the same draft guard. */
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
* toolbar and an explicit retry.
|
||||
*/
|
||||
// @vitest-environment jsdom
|
||||
import { afterEach, beforeAll, beforeEach, expect, it } from 'vitest'
|
||||
import { afterEach, beforeAll, beforeEach, expect, it, vi } from 'vitest'
|
||||
import { act } from 'react-dom/test-utils'
|
||||
import { createElement, Fragment, type ReactNode } from 'react'
|
||||
import { renderRoot, setupReactAct, type RenderedRoot } from './test-utils.ts'
|
||||
@@ -35,6 +35,7 @@ import { FeishuDocsPreview } from '../src/client/clues/sources/feishu/docs-previ
|
||||
import { FeishuTaskEditor } from '../src/client/clues/sources/feishu/task-editor.tsx'
|
||||
import { DEFAULT_FEISHU_LABELS } from '../src/client/clues/sources/feishu/labels.ts'
|
||||
import { SidebarApiError } from '../src/client/api.ts'
|
||||
import { setClueSelectionActionContext } from '../src/client/clues/selection-actions.tsx'
|
||||
setupReactAct()
|
||||
beforeAll(() => { Object.defineProperty(navigator, 'language', { value: 'en-US', configurable: true }) })
|
||||
const VIEWPORT = { width: 1_000, height: 800 }
|
||||
@@ -191,11 +192,12 @@ beforeEach(() => {
|
||||
Object.defineProperty(window, 'innerHeight', { configurable: true, value: VIEWPORT.height })
|
||||
})
|
||||
afterEach(() => {
|
||||
setClueSelectionActionContext(null)
|
||||
view?.unmount(); view = undefined; host?.dispose(); host = undefined; document.body.innerHTML = ''
|
||||
})
|
||||
/** Mount the real window host and open one detail. */
|
||||
async function mountDetail(options: FaceOptions = {}, extra: {
|
||||
readCache?: ClueDetailReadCache; target?: ClueDetailTarget; subtitle?: string; info?: ClueResourceInfo
|
||||
readCache?: ClueDetailReadCache; target?: ClueDetailTarget; subtitle?: string; info?: ClueResourceInfo; sessionId?: string
|
||||
insert?: boolean; onInsertClue?: (clueId: string, title: string) => boolean; onAddToPack?: (target: ClueDetailTarget) => void
|
||||
} = {}): Promise<Calls> {
|
||||
const { face, calls } = faceOf(options)
|
||||
@@ -203,7 +205,7 @@ async function mountDetail(options: FaceOptions = {}, extra: {
|
||||
view = renderRoot(createElement(WindowHost, { host, formats: face }))
|
||||
act(() => {
|
||||
openClueDetailWindow({
|
||||
windows: host!, face, workspaceId: 'ws-1',
|
||||
windows: host!, face, workspaceId: 'ws-1', sessionId: extra.sessionId,
|
||||
target: { ...(extra.target ?? TARGET), ...(extra.subtitle === undefined ? {} : { subtitle: extra.subtitle }), ...(extra.info === undefined ? {} : { info: extra.info }) },
|
||||
...(extra.readCache === undefined ? {} : { readCache: extra.readCache }),
|
||||
...(extra.insert === true || extra.onInsertClue !== undefined ? { onInsertClue: extra.onInsertClue ?? (() => true) } : {}),
|
||||
@@ -247,6 +249,30 @@ async function closeWindow(): Promise<void> {
|
||||
const close = q<HTMLButtonElement>('button[aria-label="Close"]')
|
||||
await act(async () => { close.click(); await Promise.resolve() })
|
||||
}
|
||||
it.each([undefined, 'stored-clue'])('preserves selection ownership and ensures only an unstored source (%s)', async clueId => {
|
||||
const insert = vi.fn(() => true)
|
||||
setClueSelectionActionContext({ onInsert: insert })
|
||||
const target = { ...TARGET, clueId }
|
||||
const calls = await mountDetail({}, { target, sessionId: 'selection-session' })
|
||||
const heading = q<HTMLElement>('[data-window-document-body] h1')
|
||||
const range = document.createRange()
|
||||
range.selectNodeContents(heading)
|
||||
const selection = window.getSelection()!
|
||||
selection.removeAllRanges()
|
||||
selection.addRange(range)
|
||||
act(() => { heading.dispatchEvent(new MouseEvent('mouseup', { bubbles: true })) })
|
||||
const action = document.querySelector<HTMLButtonElement>('[data-clue-selection-action="insert"]')!
|
||||
expect(action).not.toBeNull()
|
||||
await act(async () => { action.click(); await Promise.resolve() })
|
||||
await flush()
|
||||
expect(calls.ensure).toHaveLength(clueId === undefined ? 1 : 0)
|
||||
expect(insert).toHaveBeenCalledExactlyOnceWith(expect.objectContaining({
|
||||
clueId: clueId ?? 'c9', workspaceId: 'ws-1', sessionId: 'selection-session', selection: 'Read only',
|
||||
}))
|
||||
expect(document.querySelector('[data-clue-selection-menu]')).toBeNull()
|
||||
selection.removeAllRanges()
|
||||
})
|
||||
|
||||
it('paints a hot cached preview synchronously and never loads the edit document', async () => {
|
||||
const cache: ClueDetailReadCache = {
|
||||
peek: () => ({ ...READ_OLD, data: { title: 'Cached issue title', text: '# body' }, info: { repository: 'acme/widgets', number: 7, state: 'open' } }),
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
*/
|
||||
import { afterEach, describe, expect, it, vi } from 'vitest'
|
||||
import type { Context } from '../src/context-types.ts'
|
||||
import { insertClueSelectionReference } from '../src/client/clues/insert.ts'
|
||||
import {
|
||||
appendText,
|
||||
appendToDraft,
|
||||
@@ -191,6 +192,30 @@ function composerCtx(options: {
|
||||
return { ctx, emitted, setDrafts, chipInserts }
|
||||
}
|
||||
|
||||
describe('clue selection provenance', () => {
|
||||
it('sends the stable source token and exact excerpt together in one chip', () => {
|
||||
const fake = composerCtx()
|
||||
expect(insertClueSelectionReference(fake.ctx, 's1', { clueId: 'c1', selection: 'Selected paragraph.\nSecond line.' })).toBe(true)
|
||||
expect(fake.chipInserts).toEqual([{ ref: {
|
||||
source: 'reference', ref: '[[dsh-clue:c1]]\n\nSelected paragraph.\nSecond line.',
|
||||
label: 'Selected paragraph.', clipboardText: '[[dsh-clue:c1]]',
|
||||
}, span: { draftRev: 0, start: 0, end: 0 } }])
|
||||
expect(fake.setDrafts).toEqual([])
|
||||
})
|
||||
it('keeps provenance and the excerpt when only plain draft insertion is available', () => {
|
||||
const fake = composerCtx({ withChipChannel: false })
|
||||
expect(insertClueSelectionReference(fake.ctx, 's1', { clueId: 'c1', selection: 'Quoted text' })).toBe(true)
|
||||
expect(fake.setDrafts).toEqual(['[[dsh-clue:c1]]\n\nQuoted text'])
|
||||
})
|
||||
it('does not modify the draft for an invalid source or an empty selection', () => {
|
||||
const fake = composerCtx()
|
||||
expect(insertClueSelectionReference(fake.ctx, 's1', { clueId: '', selection: 'Text' })).toBe(false)
|
||||
expect(insertClueSelectionReference(fake.ctx, 's1', { clueId: 'c1', selection: ' ' })).toBe(false)
|
||||
expect(fake.chipInserts).toEqual([])
|
||||
expect(fake.setDrafts).toEqual([])
|
||||
})
|
||||
})
|
||||
|
||||
describe('insertDraftReference', () => {
|
||||
it('hands the host one chip carrying the label and the model text apart', () => {
|
||||
const fake = composerCtx({ draft: 'hello' })
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
import { mkdirSync, realpathSync, writeFileSync } from 'node:fs'
|
||||
import { join } from 'node:path'
|
||||
import { test, expect, type Locator, type Page, type Route } from '@playwright/test'
|
||||
import { floatClueWindow, selectClueSource } from './ui-helpers'
|
||||
import { floatClueWindow, selectClueSource, setTheme } from './ui-helpers'
|
||||
import { composerEditable, composerLocator, createHostApi, dismissOnboarding, gotoPage, hostRpc } from './host'
|
||||
|
||||
const TITLE = 'UI19 local discussion fixture'
|
||||
@@ -42,6 +42,8 @@ interface FixtureState {
|
||||
actions: ActionRequest[]
|
||||
rejectNext?: boolean
|
||||
reads: number
|
||||
readGate?: Promise<void>
|
||||
ensured: unknown[]
|
||||
comments: number
|
||||
blocked: string[]
|
||||
pageErrors: string[]
|
||||
@@ -53,7 +55,7 @@ async function ok(route: Route, value: unknown): Promise<void> {
|
||||
|
||||
/** A closed local response catalogue: no source operation can escape to a CLI. */
|
||||
async function interceptFixture(page: Page): Promise<FixtureState> {
|
||||
const state: FixtureState = { actions: [], reads: 0, comments: 0, blocked: [], pageErrors: [] }
|
||||
const state: FixtureState = { actions: [], reads: 0, ensured: [], comments: 0, blocked: [], pageErrors: [] }
|
||||
page.on('pageerror', error => state.pageErrors.push(error.message))
|
||||
await page.route('**/sidebar/api/clues.*', async route => {
|
||||
const method = new URL(route.request().url()).pathname.split('/').at(-1)!
|
||||
@@ -72,6 +74,7 @@ async function interceptFixture(page: Page): Promise<FixtureState> {
|
||||
case 'clues.read':
|
||||
state.workspaceId = input.workspaceId
|
||||
state.reads += 1
|
||||
await state.readGate
|
||||
await ok(route, { format: 'text/markdown', data: { title: TITLE, body: BODY, text: BODY }, text: BODY, fetchedAt: NOW, freshness: 'live' }); return
|
||||
case 'clues.comments.list':
|
||||
state.comments += 1
|
||||
@@ -79,6 +82,9 @@ async function interceptFixture(page: Page): Promise<FixtureState> {
|
||||
{ id: 'ui19-comment', kind: 'comment', format: 'text/markdown', body: `## Comment-only heading\n\n${COMMENT_SELECTION}`, author: { name: 'Fixture reviewer' }, createdAt: NOW },
|
||||
{ id: 'ui19-review', kind: 'review', format: 'text/plain', body: 'Local review summary.', reviewState: 'APPROVED', author: { name: 'Fixture approver' } },
|
||||
] }); return
|
||||
case 'clues.ensure':
|
||||
state.ensured.push(route.request().postDataJSON())
|
||||
await ok(route, { clue: { id: 'ui19-stable', ...candidate }, created: true }); return
|
||||
case 'clues.clues': await ok(route, { clues: [], revision: 0 }); return
|
||||
case 'clues.pins.list': await ok(route, { pins: [], revision: 0 }); return
|
||||
case 'clues.packs.list': await ok(route, { packs: [], revision: 0 }); return
|
||||
@@ -125,7 +131,7 @@ async function onScreen(page: Page, selector: string): Promise<Locator> {
|
||||
return found!
|
||||
}
|
||||
|
||||
async function openFixture(page: Page): Promise<{ state: FixtureState; surface: Locator; sessionId: string }> {
|
||||
async function openFixture(page: Page, checkLoading?: (frame: Locator) => Promise<void>): Promise<{ state: FixtureState; surface: Locator; sessionId: string }> {
|
||||
expect(process.env.DSH_E2E_WORKSPACE, 'run through the isolated RC mount lane').toBeTruthy()
|
||||
const root = join(process.env.DSH_E2E_WORKSPACE!, `ui19-${Date.now()}-${test.info().testId.replace(/[^a-zA-Z0-9-]/g, '_')}`)
|
||||
mkdirSync(root, { recursive: true })
|
||||
@@ -153,7 +159,16 @@ async function openFixture(page: Page): Promise<{ state: FixtureState; surface:
|
||||
await panel!.locator('[data-sidebar-right-guide-entry="clues"]').click()
|
||||
const tab = panel!.locator('[data-clue-tab]')
|
||||
await expect(tab).toBeVisible()
|
||||
let releaseRead: (() => void) | undefined
|
||||
if (checkLoading !== undefined) state.readGate = new Promise<void>(resolve => { releaseRead = resolve })
|
||||
await tab.locator('[data-clue-browse-region]').getByRole('button', { name: TITLE, exact: true }).click()
|
||||
if (checkLoading !== undefined) {
|
||||
try {
|
||||
const loadingFrame = panel.locator('[data-window-docked="true"]')
|
||||
await expect(loadingFrame.locator('[data-loading-indicator][data-centered]')).toBeVisible()
|
||||
await checkLoading(loadingFrame)
|
||||
} finally { releaseRead?.() }
|
||||
}
|
||||
// A clue window opens DOCKED in the right sidebar; this fixture floats it to
|
||||
// measure content, selection and draft retention on the floating surface.
|
||||
const surface = await floatClueWindow(page, page.locator('[data-window-document-body]'))
|
||||
@@ -197,6 +212,31 @@ function expectQuiet(state: FixtureState): void {
|
||||
expect(state.pageErrors, 'no uncaught errors from the actual mounted client').toEqual([])
|
||||
}
|
||||
|
||||
test('UI19 centers loading feedback and respects reduced motion in both themes', async ({ page }, info) => {
|
||||
const { state, surface } = await openFixture(page, async frame => {
|
||||
const loading = frame.locator('[data-loading-indicator][data-centered]')
|
||||
const glyph = loading.locator('[aria-hidden="true"]')
|
||||
for (const theme of ['light', 'dark'] as const) {
|
||||
await setTheme(page, theme)
|
||||
const body = (await frame.locator('[data-window-body]').boundingBox())!
|
||||
const content = await loading.evaluate(node => {
|
||||
const first = node.firstElementChild!.getBoundingClientRect()
|
||||
const last = node.lastElementChild!.getBoundingClientRect()
|
||||
return { x: (first.left + first.right) / 2, y: (first.top + last.bottom) / 2 }
|
||||
})
|
||||
expect(Math.abs(content.x - body.x - body.width / 2)).toBeLessThan(3)
|
||||
expect(Math.abs(content.y - body.y - body.height / 2)).toBeLessThan(3)
|
||||
expect(await glyph.evaluate(node => getComputedStyle(node).animationName)).not.toBe('none')
|
||||
await frame.screenshot({ path: info.outputPath('loading-centered-' + theme + '.png') })
|
||||
}
|
||||
await page.emulateMedia({ reducedMotion: 'reduce' })
|
||||
await expect(glyph).toHaveCSS('animation-name', 'none')
|
||||
await page.emulateMedia({ reducedMotion: 'no-preference' })
|
||||
})
|
||||
await expect(surface.locator('[data-loading-indicator][data-centered]')).toHaveCount(0)
|
||||
expectQuiet(state)
|
||||
})
|
||||
|
||||
test('UI19 keeps discussion below the body and comment headings out of its outline', async ({ page }) => {
|
||||
const { state, surface } = await openFixture(page)
|
||||
const body = surface.locator('[data-window-document-body]')
|
||||
@@ -252,6 +292,8 @@ test('UI19 selects body and comment actions with readable main/side targets with
|
||||
await menu.locator('[data-clue-selection-action="insert"]').click()
|
||||
const composer = page.getByRole('textbox', { name: /^(Describe what you want to build|Message or run a task|描述你想要构建)/ })
|
||||
await expect(composer).toContainText(COMMENT_SELECTION)
|
||||
await expect(composer.locator('[data-composer-chip="reference"]')).toHaveCount(1)
|
||||
expect(state.ensured).toEqual([expect.objectContaining({ sourceId: SOURCE, typeId: TYPE, locator: candidate.locator })])
|
||||
expect(state.actions).toHaveLength(3)
|
||||
expectQuiet(state)
|
||||
})
|
||||
@@ -290,9 +332,14 @@ test('UI19 moves the same draft and scroll DOM between floating and native sideb
|
||||
expect(await input.evaluate((node, previous) => node === previous, inputNode)).toBe(true)
|
||||
expect(await surface.locator('[data-window-document-body]').evaluate((node, previous) => node === previous, bodyNode)).toBe(true)
|
||||
|
||||
const nativeTab = page.locator('[data-sidebar-right-panel]:visible [data-dockkit-tab][aria-selected="true"]').filter({ hasText: TITLE })
|
||||
const nativeTabNode = await nativeTab.elementHandle()
|
||||
await surface.locator('[data-window-float]').click()
|
||||
await expect(surface).toHaveAttribute('data-floating-window', '')
|
||||
await expect.poll(() => nativeTabNode!.evaluate(node => node.isConnected)).toBe(false)
|
||||
await expect(page.getByText('This content is open in a floating window.', { exact: true })).toHaveCount(0)
|
||||
await expect(surface).not.toHaveAttribute('data-window-docked', 'true')
|
||||
await expect(surface).toHaveCSS('border-top-width', '2px')
|
||||
await expect(dock).toHaveText('Return to sidebar')
|
||||
await expect(dock).toHaveAccessibleName('Return to sidebar')
|
||||
await expect(dock.getByText('Return to sidebar', { exact: true })).toBeVisible()
|
||||
|
||||
@@ -720,8 +720,9 @@ test('clues workbench stays usable across column widths and host themes', async
|
||||
await expect(insertPackAction).toBeVisible()
|
||||
const packFrameBounds = (await packWindow.boundingBox())!
|
||||
const insertPackBounds = (await insertPackAction.boundingBox())!
|
||||
expect(packFrameBounds.x + packFrameBounds.width - insertPackBounds.x - insertPackBounds.width).toBeCloseTo(13, 0)
|
||||
expect(packFrameBounds.y + packFrameBounds.height - insertPackBounds.y - insertPackBounds.height).toBeCloseTo(13, 0)
|
||||
// The footer keeps its 12px gutter inside the stronger 2px floating edge.
|
||||
expect(packFrameBounds.x + packFrameBounds.width - insertPackBounds.x - insertPackBounds.width).toBeCloseTo(14, 0)
|
||||
expect(packFrameBounds.y + packFrameBounds.height - insertPackBounds.y - insertPackBounds.height).toBeCloseTo(14, 0)
|
||||
expect(await packWindow.locator('[data-window-handle]').getByRole('button', { name: 'Insert pack reference', exact: true }).count()).toBe(0)
|
||||
expect(await packWindow.locator('[data-clue-pack-window]').evaluate(node => getComputedStyle(node).paddingLeft)).toBe('12px')
|
||||
|
||||
|
||||
@@ -422,6 +422,17 @@ test('plugin mounts into the DSH shell and survives a built-in tab sweep', async
|
||||
'the terminal card must expose the host shell menu',
|
||||
).toHaveCount(1, { timeout: 30_000 })
|
||||
|
||||
// More opens the same settings surface, not a second settings document.
|
||||
await startPage.locator('[data-guide-more]').click()
|
||||
await page.getByRole('menuitem', { name: 'Sidebar settings', exact: true }).click()
|
||||
const guideSettings = pane.locator('[data-window-docked="true"]').filter({ has: page.locator('[data-sidebar-settings]') })
|
||||
await expect(guideSettings).toBeVisible()
|
||||
await expect(guideSettings.locator('[data-sidebar-settings]')).toContainText('General')
|
||||
await guideSettings.locator('[data-window-float]').click()
|
||||
const floatingGuideSettings = page.locator('[data-floating-window]').filter({ has: page.locator('[data-sidebar-settings]') })
|
||||
await floatingGuideSettings.getByRole('button', { name: 'Close', exact: true }).click()
|
||||
await expect(startPage).toBeVisible()
|
||||
|
||||
// Every built-in descriptor must be registered as a native tab type: the
|
||||
// guide lists one entry per type, so a missing entry is a real regression
|
||||
// (descriptor removed, registration failed, or the type got disabled).
|
||||
|
||||
@@ -35,10 +35,8 @@ export async function floatClueWindow(page: Page, marker: Locator): Promise<Loca
|
||||
} else {
|
||||
await expect(frame).toHaveAttribute('data-floating-window', '')
|
||||
}
|
||||
// Floating keeps the native sidebar tab selected (it now only shows the
|
||||
// "open in a floating window" hint), which would hide the workbench the
|
||||
// caller needs next. Return to the clue guide tab, the surface the window
|
||||
// was opened from.
|
||||
// Floating closes the source tab. Select the retained Clues workbench
|
||||
// explicitly when another native tab became active behind the window.
|
||||
const workbenchTab = page.locator('[data-sidebar-right-panel]:visible [role="tab"]')
|
||||
.filter({ hasText: /^\s*Clues\b/ }).first()
|
||||
await expect(workbenchTab).toHaveCount(1)
|
||||
|
||||
@@ -155,6 +155,7 @@ describe('GuideGrid', () => {
|
||||
it('offers the host browse/create plugin actions in the More menu', async () => {
|
||||
const onBrowsePlugins = vi.fn()
|
||||
const onCreatePlugin = vi.fn()
|
||||
const onOpenSettings = vi.fn()
|
||||
const mounted = renderRoot(createElement(GuideGrid, {
|
||||
entries,
|
||||
prefs: { ...SIDEBAR_PREFS_DEFAULTS },
|
||||
@@ -162,6 +163,7 @@ describe('GuideGrid', () => {
|
||||
onOpen: () => {},
|
||||
onBrowsePlugins,
|
||||
onCreatePlugin,
|
||||
onOpenSettings,
|
||||
}))
|
||||
const trigger = mounted.container.querySelector('[data-guide-more]')
|
||||
await act(async () => {
|
||||
@@ -184,6 +186,12 @@ describe('GuideGrid', () => {
|
||||
.find(node => node.textContent?.includes('Browse more plugins'))
|
||||
act(() => { (browseAgain as HTMLElement).click() })
|
||||
expect(onBrowsePlugins).toHaveBeenCalled()
|
||||
await act(async () => { (trigger as HTMLButtonElement).click(); await Promise.resolve() })
|
||||
const settings = [...document.querySelectorAll('[role="menuitem"]')]
|
||||
.find(node => node.textContent?.includes('Sidebar settings'))
|
||||
expect(settings).toBeDefined()
|
||||
act(() => { (settings as HTMLElement).click() })
|
||||
expect(onOpenSettings).toHaveBeenCalledOnce()
|
||||
mounted.unmount()
|
||||
})
|
||||
|
||||
|
||||
@@ -258,14 +258,12 @@ describe('SideCardSection declarative inventory', () => {
|
||||
expect(html).toContain('png · jpg')
|
||||
})
|
||||
|
||||
it('renders the gear corner button on features that declare related settings', () => {
|
||||
it('reserves a settings gear for every feature and disables empty settings', () => {
|
||||
const { store, service } = mount()
|
||||
const html = renderSection(store, service, 'tabs')
|
||||
// Subagents declares a toggle → its card carries the settings gear
|
||||
// (aria-label = "<title> Feature settings"); Explorer and Image declare
|
||||
// none → no gear, so the total is 1.
|
||||
expect(html.match(/aria-label="[^"]*Feature settings"/g)?.length).toBe(1)
|
||||
expect(html).toContain('Subagents Feature settings')
|
||||
expect(html.match(/aria-label="[^"]*Feature settings"/g)?.length).toBe(2)
|
||||
expect(html).toMatch(/<button[^>]*aria-label="Explorer Feature settings"[^>]*disabled/)
|
||||
expect(html).toMatch(/<button(?=[^>]*aria-label="Subagents Feature settings")(?![^>]*disabled)[^>]*>/)
|
||||
})
|
||||
|
||||
it('renders the dashed "add plugin" cards inside their own groups', () => {
|
||||
@@ -318,12 +316,11 @@ describe('SideCardSection declarative inventory', () => {
|
||||
expect(viewers.match(/data-settings-row="viewer:/g)?.length ?? 0).toBe(1)
|
||||
})
|
||||
|
||||
it('hides the gear of a disabled feature (its related settings are dormant)', () => {
|
||||
it('keeps existing settings accessible when the feature is switched off', () => {
|
||||
const { store, service } = mount()
|
||||
store.setPrefs({ ...store.getPrefs(), tabsEnabled: { subagent: false } })
|
||||
const html = renderSection(store, service, 'tabs')
|
||||
// The disabled Subagents card loses its gear — nothing else renders one.
|
||||
expect(html).not.toContain('Feature settings')
|
||||
expect(html).toMatch(/<button(?=[^>]*aria-label="Subagents Feature settings")(?![^>]*disabled)[^>]*>/)
|
||||
})
|
||||
|
||||
it('renders the custom-CSS escape hatch as its own Appearance group (no scheme dropdown, no strip row)', () => {
|
||||
|
||||
@@ -7,6 +7,10 @@ it('gives the workbench header a visible resting border and distinct press/focus
|
||||
expect(css).toMatch(/\.toggle:active\s*\{[^}]*background:\s*var\(--dsw-alias-interactive-bg-active\)/)
|
||||
expect(css).toMatch(/\.toggle:focus-visible\s*\{[^}]*outline:\s*2px solid var\(/)
|
||||
})
|
||||
it('distinguishes floating frames with a slightly stronger token-driven edge', () => {
|
||||
const css = readFileSync('src/client/FloatingWindow.module.css', 'utf8')
|
||||
expect(css).toMatch(/\.window\s*\{[^}]*border:\s*2px solid var\(--dsw-alias-border-l4\)/)
|
||||
})
|
||||
it('keeps the icon+text transfer control nonshrinking at narrow widths', () => {
|
||||
const css = readFileSync('src/client/FloatingWindow.module.css', 'utf8')
|
||||
expect(css).toMatch(/\.surfaceControl\s*\{[^}]*flex:\s*none;[^}]*white-space:\s*nowrap/)
|
||||
|
||||
@@ -48,6 +48,8 @@ it('moves live content between floating and original-session sidebar without rem
|
||||
act(() => { handle.float!() })
|
||||
expect(document.querySelector('[data-draft]')).toBe(input)
|
||||
expect(sidebar.contains(input)).toBe(false)
|
||||
expect(close).toHaveBeenCalledExactlyOnceWith('retained', 'original')
|
||||
expect(guard).not.toHaveBeenCalled()
|
||||
expect(handle.navigation.depth()).toBe(2)
|
||||
expect(mounted).toHaveBeenCalledTimes(1)
|
||||
expect(unmounted).not.toHaveBeenCalled()
|
||||
|
||||
Reference in new issue
Block a user