refactor(client): converge search lists on shared multilingual fuzzy filter
Fixes #6681
This commit is contained in:
1 parent
505b2bc0e6
commit
a5bdc28238
104 files changed
+1336
-390
No files matched your search
@@ -101,6 +101,7 @@ External packages installed for runtime use or embedded in distributed Host or b
|
||||
| [`execa`](https://github.com/sindresorhus/execa) | MIT |
|
||||
| [`fast-xml-parser`](https://github.com/NaturalIntelligence/fast-xml-parser) | MIT |
|
||||
| [`fflate`](https://github.com/101arrowz/fflate) | MIT |
|
||||
| [`fuzzysort`](https://github.com/farzher/fuzzysort) | MIT |
|
||||
| [`got`](https://github.com/sindresorhus/got) | MIT |
|
||||
| [`hosted-git-info`](https://github.com/npm/hosted-git-info) | ISC |
|
||||
| [`immer`](https://github.com/immerjs/immer) | MIT |
|
||||
|
||||
@@ -5396,6 +5396,7 @@ Imported as libraries by other packages; a `cordis.yml` cannot load them.
|
||||
| `@deepseek-ai/dsh-util-crypto` | — | [`packages/util/crypto/src/index.ts`](../packages/util/crypto/src/index.ts) |
|
||||
| `@deepseek-ai/dsh-util-file-drag` | — | [`packages/util/file-drag/src/index.ts`](../packages/util/file-drag/src/index.ts) |
|
||||
| `@deepseek-ai/dsh-util-ripgrep` | — | [`packages/util/ripgrep/src/index.ts`](../packages/util/ripgrep/src/index.ts) |
|
||||
| `@deepseek-ai/dsh-util-text-search` | — | [`packages/util/text-search/src/index.ts`](../packages/util/text-search/src/index.ts) |
|
||||
| `@deepseek-ai/dsh-util-time` | — | [`packages/util/time/src/index.ts`](../packages/util/time/src/index.ts) |
|
||||
| `@deepseek-ai/dsh-util-values` | — | [`packages/util/values/src/index.ts`](../packages/util/values/src/index.ts) |
|
||||
| `@deepseek-ai/dsh-util-workspace-path` | — | [`packages/util/workspace-path/src/index.ts`](../packages/util/workspace-path/src/index.ts) |
|
||||
|
||||
@@ -5398,6 +5398,7 @@ export interface Config {
|
||||
| `@deepseek-ai/dsh-util-crypto` | — | [`packages/util/crypto/src/index.ts`](../packages/util/crypto/src/index.ts) |
|
||||
| `@deepseek-ai/dsh-util-file-drag` | — | [`packages/util/file-drag/src/index.ts`](../packages/util/file-drag/src/index.ts) |
|
||||
| `@deepseek-ai/dsh-util-ripgrep` | — | [`packages/util/ripgrep/src/index.ts`](../packages/util/ripgrep/src/index.ts) |
|
||||
| `@deepseek-ai/dsh-util-text-search` | — | [`packages/util/text-search/src/index.ts`](../packages/util/text-search/src/index.ts) |
|
||||
| `@deepseek-ai/dsh-util-time` | — | [`packages/util/time/src/index.ts`](../packages/util/time/src/index.ts) |
|
||||
| `@deepseek-ai/dsh-util-values` | — | [`packages/util/values/src/index.ts`](../packages/util/values/src/index.ts) |
|
||||
| `@deepseek-ai/dsh-util-workspace-path` | — | [`packages/util/workspace-path/src/index.ts`](../packages/util/workspace-path/src/index.ts) |
|
||||
|
||||
@@ -28,6 +28,7 @@ flowchart TD
|
||||
pkg_util_crypto["util-crypto"]
|
||||
pkg_util_file_drag["util-file-drag"]
|
||||
pkg_util_ripgrep["util-ripgrep"]
|
||||
pkg_util_text_search["util-text-search"]
|
||||
pkg_util_time["util-time"]
|
||||
pkg_util_values["util-values"]
|
||||
pkg_util_workspace_path["util-workspace-path"]
|
||||
@@ -1589,6 +1590,7 @@ flowchart TD
|
||||
| [`util-code-language`](../packages/util/code-language) | `util` | — |
|
||||
| [`util-crypto`](../packages/util/crypto) | `util` | — |
|
||||
| [`util-file-drag`](../packages/util/file-drag) | `util` | — |
|
||||
| [`util-text-search`](../packages/util/text-search) | `util` | — |
|
||||
| [`util-time`](../packages/util/time) | `util` | — |
|
||||
| [`util-values`](../packages/util/values) | `util` | — |
|
||||
| [`util-workspace-path`](../packages/util/workspace-path) | `util` | — |
|
||||
|
||||
@@ -30,6 +30,7 @@ flowchart TD
|
||||
pkg_util_crypto["util-crypto"]
|
||||
pkg_util_file_drag["util-file-drag"]
|
||||
pkg_util_ripgrep["util-ripgrep"]
|
||||
pkg_util_text_search["util-text-search"]
|
||||
pkg_util_time["util-time"]
|
||||
pkg_util_values["util-values"]
|
||||
pkg_util_workspace_path["util-workspace-path"]
|
||||
@@ -1591,6 +1592,7 @@ flowchart TD
|
||||
| [`util-code-language`](../packages/util/code-language) | `util` | — |
|
||||
| [`util-crypto`](../packages/util/crypto) | `util` | — |
|
||||
| [`util-file-drag`](../packages/util/file-drag) | `util` | — |
|
||||
| [`util-text-search`](../packages/util/text-search) | `util` | — |
|
||||
| [`util-time`](../packages/util/time) | `util` | — |
|
||||
| [`util-values`](../packages/util/values) | `util` | — |
|
||||
| [`util-workspace-path`](../packages/util/workspace-path) | `util` | — |
|
||||
|
||||
@@ -185,7 +185,9 @@ Exact-read consumer that prepares immutable cross-session message context.
|
||||
* Discovery runs at keystroke rate, so titles and subagent labels only ever
|
||||
* come from projection reads; sessions without either fall back to their id.
|
||||
* @param agent - target agent; self is excluded and its cwd drives ranking.
|
||||
* @param query - optional case-insensitive session-id/cwd/title/display-title substring.
|
||||
* @param query - optional search text: label and display title match
|
||||
* fuzzily, session id and working directory as substrings. Matches keep the
|
||||
* working-directory affinity order; relevance breaks ties within it.
|
||||
* @param limit - optional positive result cap.
|
||||
* @param signal - optional cancellation boundary for host autocomplete teardown.
|
||||
* @returns candidates with canonical mention labels and presentation titles.
|
||||
@@ -197,7 +199,7 @@ async listCandidates( agent: Agent, query: string = '', limit: number = this.con
|
||||
* applies, and every candidate carries the canonical mention a host inserts
|
||||
* into the prompt draft.
|
||||
* @param agent - target agent; self is excluded and its cwd drives ranking.
|
||||
* @param query - optional case-insensitive session-id/cwd/title substring.
|
||||
* @param query - optional search text, matched as {@link listCandidates} matches it.
|
||||
* @param signal - caller cancellation.
|
||||
* @returns mention-carrying candidates in rank order.
|
||||
*/
|
||||
|
||||
@@ -185,7 +185,9 @@ Exact-read consumer that prepares immutable cross-session message context.
|
||||
* Discovery runs at keystroke rate, so titles and subagent labels only ever
|
||||
* come from projection reads; sessions without either fall back to their id.
|
||||
* @param agent - target agent; self is excluded and its cwd drives ranking.
|
||||
* @param query - optional case-insensitive session-id/cwd/title/display-title substring.
|
||||
* @param query - optional search text: label and display title match
|
||||
* fuzzily, session id and working directory as substrings. Matches keep the
|
||||
* working-directory affinity order; relevance breaks ties within it.
|
||||
* @param limit - optional positive result cap.
|
||||
* @param signal - optional cancellation boundary for host autocomplete teardown.
|
||||
* @returns candidates with canonical mention labels and presentation titles.
|
||||
@@ -197,7 +199,7 @@ async listCandidates( agent: Agent, query: string = '', limit: number = this.con
|
||||
* applies, and every candidate carries the canonical mention a host inserts
|
||||
* into the prompt draft.
|
||||
* @param agent - target agent; self is excluded and its cwd drives ranking.
|
||||
* @param query - optional case-insensitive session-id/cwd/title substring.
|
||||
* @param query - optional search text, matched as {@link listCandidates} matches it.
|
||||
* @param signal - caller cancellation.
|
||||
* @returns mention-carrying candidates in rank order.
|
||||
*/
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
# Bilingual-pair consistency record for guide.md (docs/i18n/README.md): per heading
|
||||
# section, a hash of its English and Chinese blocks outside code blocks and generated regions.
|
||||
# After editing either side, bring the other along and re-record with:
|
||||
# pnpm run verify-translation-pairing --write docs/upgrade-guide/v0.2.2-rc.2/shared-search-filter/guide.md
|
||||
/:
|
||||
en: e844e06044ae4528
|
||||
zh: 0685de150de3ee75
|
||||
/shared-search-filter-replaces-rankbyname-and-searchmode:
|
||||
en: 056d8f43542817b6
|
||||
zh: 57993ea06eab6dd4
|
||||
/shared-search-filter-replaces-rankbyname-and-searchmode/change:
|
||||
en: 10f142aa7be3f9d4
|
||||
zh: bdcc63c40f895564
|
||||
/shared-search-filter-replaces-rankbyname-and-searchmode/migration:
|
||||
en: e574d0daa01c7cfb
|
||||
zh: aaaab2d24ab55cf9
|
||||
@@ -0,0 +1,18 @@
|
||||
---
|
||||
kind: upgrade-guide
|
||||
description: "ui-primitives no longer exports rankByName, and popupSelect commands no longer accept searchMode."
|
||||
---
|
||||
|
||||
# Shared search filter replaces rankByName and searchMode
|
||||
|
||||
English | [中文](guide.zh.md)
|
||||
|
||||
## Change
|
||||
|
||||
`@deepseek-ai/dsh-client-ui-primitives` exported `rankByName(items, query)`, which ranked items by an ordered subsequence of `name` or `label`. It is removed. `@deepseek-ai/dsh-client-ui-commands` accepted `searchMode: 'substring' | 'fuzzy-label'` on a `popupSelect` command spec and exported the `PopupSearchMode` type; both are removed. Every popup now filters its options one way: labels match fuzzily and details match as substrings, ranked within each group. The shared search is [`TextSearchIndex`](../../../../packages/util/text-search/README.md) in `@deepseek-ai/dsh-util-text-search`. Plugin authors who import `rankByName`, or who set `searchMode` or import `PopupSearchMode`, are affected.
|
||||
|
||||
## Migration
|
||||
|
||||
1. Replace `rankByName(items, query)` with a `TextSearchIndex` imported from `@deepseek-ai/dsh-util-text-search`: build `new TextSearchIndex(items, item => ({ fuzzy: [item.name, item.label] }))` when the list changes, and call `index.search(query)` per query. Add that package to the plugin's `devDependencies` for a Client plugin or `dependencies` for a Host plugin. Put descriptions or other long text in `substring`, and pass every language of a `LocalizedText` through `localizedValues`.
|
||||
2. Delete `searchMode` from each `popupSelect` spec and remove any `PopupSearchMode` import.
|
||||
3. Confirm the plugin typechecks, and that typing part of an option label in its popup still finds that option.
|
||||
@@ -0,0 +1,18 @@
|
||||
---
|
||||
kind: upgrade-guide
|
||||
description: "ui-primitives 不再导出 rankByName,popupSelect 命令不再接受 searchMode。"
|
||||
---
|
||||
|
||||
# 共享搜索过滤器取代 rankByName 和 searchMode
|
||||
|
||||
[English](guide.md) | 中文
|
||||
|
||||
## 变更
|
||||
|
||||
`@deepseek-ai/dsh-client-ui-primitives` 曾导出 `rankByName(items, query)`,它按 `name` 或 `label` 的有序子序列对条目排序。该函数已移除。`@deepseek-ai/dsh-client-ui-commands` 曾在 `popupSelect` 命令规格上接受 `searchMode: 'substring' | 'fuzzy-label'`,并导出 `PopupSearchMode` 类型;两者均已移除。现在每个弹窗都用同一种方式过滤选项:标签模糊匹配,详情按子串匹配,选项在各自分组内排序。共享搜索是 `@deepseek-ai/dsh-util-text-search` 中的 [`TextSearchIndex`](../../../../packages/util/text-search/README.zh.md)。受影响的是导入 `rankByName`、设置 `searchMode` 或导入 `PopupSearchMode` 的插件作者。
|
||||
|
||||
## 迁移
|
||||
|
||||
1. 把 `rankByName(items, query)` 替换为从 `@deepseek-ai/dsh-util-text-search` 导入的 `TextSearchIndex`:列表变化时构建 `new TextSearchIndex(items, item => ({ fuzzy: [item.name, item.label] }))`,每次查询时调用 `index.search(query)`。把该包加入插件的依赖:Client 插件加入 `devDependencies`,Host 插件加入 `dependencies`。把描述或其他长文本放进 `substring`,并通过 `localizedValues` 传入 `LocalizedText` 的所有语言。
|
||||
2. 从每个 `popupSelect` 规格中删除 `searchMode`,并移除所有 `PopupSearchMode` 导入。
|
||||
3. 确认插件通过类型检查,并确认在其弹窗中键入选项标签的一部分仍能找到该选项。
|
||||
@@ -133,7 +133,7 @@ User search queries over a list follow one rule, so a query finds the same item
|
||||
- Results rank name prefix, then name substring, then fuzzy name, then text substring; equal matches keep the list's own order.
|
||||
- Facet selections, such as status, category, or label filters, stay exact.
|
||||
|
||||
The rule covers lists filtered in memory, including a Host search that supplies a Client list, such as `@` Session candidates. Searches backed by their own index keep their matcher: Session content search runs literal SQLite full-text terms over Session text, and the plugin market ranks its paged index on the Host. The sidebar's title, Workspace, and id matching follows this rule; only its content results use the full-text matcher.
|
||||
The rule covers lists filtered in memory, including a Host search that supplies a Client list, such as `@` Session candidates; [`TextSearchIndex`](../util/text-search/README.md) implements it for both. Searches backed by their own index keep their matcher: Session content search runs literal SQLite full-text terms over Session text, and the plugin market ranks its paged index on the Host. The sidebar's title, Workspace, and id matching follows this rule; only its content results use the full-text matcher.
|
||||
|
||||
## Testing and coverage
|
||||
|
||||
|
||||
@@ -97,7 +97,7 @@ function compiledClientStyle(
|
||||
* Everything else under @deepseek-ai/* is either a module-table entry
|
||||
* (external) or a leak the purity gate rejects.
|
||||
*/
|
||||
export const INLINE_SAFE = /^(?:@deepseek-ai\/dsh-(?:file-reference|fs-patch|session|llm|tools|brand|error|official-bundles|deque|output-retention|typert-protocol|util-crypto|util-time|util-values|util-workspace-path)(?:\/|$)|@deepseek-ai\/dsh-util-file-drag$|@deepseek-ai\/dsh-token-meter\/client$|@deepseek-ai\/dsh-commands\/builtin$|@deepseek-ai\/dsh-native-command\/types$|@deepseek-ai\/dsh-host-open-in-app\/shared$|@deepseek-ai\/dsh-plugin-manager\/registry$|@deepseek-ai\/dsh-agent-preset-registry\/display$|@deepseek-ai\/dsh-api-workspace-controller\/default-workspace$|@deepseek-ai\/dsh-spill-policy\/notice$)/
|
||||
export const INLINE_SAFE = /^(?:@deepseek-ai\/dsh-(?:file-reference|fs-patch|session|llm|tools|brand|error|official-bundles|deque|output-retention|typert-protocol|util-crypto|util-text-search|util-time|util-values|util-workspace-path)(?:\/|$)|@deepseek-ai\/dsh-util-file-drag$|@deepseek-ai\/dsh-token-meter\/client$|@deepseek-ai\/dsh-commands\/builtin$|@deepseek-ai\/dsh-native-command\/types$|@deepseek-ai\/dsh-host-open-in-app\/shared$|@deepseek-ai\/dsh-plugin-manager\/registry$|@deepseek-ai\/dsh-agent-preset-registry\/display$|@deepseek-ai\/dsh-api-workspace-controller\/default-workspace$|@deepseek-ai\/dsh-spill-policy\/notice$)/
|
||||
|
||||
/**
|
||||
* Vendored framework libraries: rescoped into @deepseek-ai, so the gate below
|
||||
|
||||
@@ -18,8 +18,8 @@
|
||||
en: c325c9eaca4efe47
|
||||
zh: dbbc29cc9cec54bc
|
||||
/deepseek-ai-dsh-client-ui-commands/use-this-package/kinds-and-decorations:
|
||||
en: 57679a20574d8b3f
|
||||
zh: 98d5e5a7781e6de1
|
||||
en: af1cf6b11bd61331
|
||||
zh: 9ad85e6dbca1d4ec
|
||||
/deepseek-ai-dsh-client-ui-commands/use-this-package/built-in-row-faces:
|
||||
en: e96156be95ea87e3
|
||||
zh: f5350db26483ec9f
|
||||
|
||||
@@ -35,7 +35,7 @@ A popupSelect spec may supply `searchLabels()` to resolve its placeholder, empty
|
||||
|
||||
Options may carry `group: { name, label }`: `name` identifies the group and `label` supplies its localized sticky heading. Equal names share one group; groups retain first-occurrence order in the loaded options, including when a query hides earlier rows. Ungrouped options form one headingless block at their first occurrence. Groups without matching rows are hidden.
|
||||
|
||||
The optional `searchMode` defaults to `'substring'`, matching `label` and `detail` case-insensitively without ranking. `'fuzzy-label'` matches only labels as ordered, case-insensitive subsequences and ranks within each group: prefixes first, then alignment score, then original row order. Both modes ignore leading and trailing query spaces; a blank query keeps every row in group order. Rendering, keyboard navigation, and selection use the same filtered order. `/model` opts into `'fuzzy-label'`; other commands retain substring matching unless they opt in.
|
||||
Popup search uses the shared [text search](../../util/text-search/README.md): labels match fuzzily, details match as substrings, and rows rank by match within each group. A blank query keeps every row in group order. Rendering, keyboard navigation, and selection use the same filtered order.
|
||||
|
||||
### Built-in row faces
|
||||
|
||||
|
||||
@@ -35,7 +35,7 @@ popupSelect 规格可提供 `searchLabels()`,在每次打开时解析占位文
|
||||
|
||||
选项可携带 `group: { name, label }`:`name` 标识分组,`label` 提供本地化吸顶标题。同名选项归入同一组;分组保持在已加载选项中首次出现的顺序,即使查询隐藏了较早的行也不变。未分组选项在首次出现的位置组成一个无标题区块。没有匹配行的分组会隐藏。
|
||||
|
||||
可选的 `searchMode` 默认为 `'substring'`,不区分大小写地匹配 `label` 与 `detail` 的子串,不进行相关性排序。`'fuzzy-label'` 仅匹配标签中按顺序、不区分大小写的子序列,并在组内排序:前缀优先,其次按匹配得分,最后按原始行顺序。两种模式均忽略查询首尾空格;空查询按分组顺序保留所有行。渲染、键盘导航与选择使用相同的筛选顺序。`/model` 启用 `'fuzzy-label'`;其他命令未显式启用时仍使用子串匹配。
|
||||
弹窗搜索使用共享的[文本搜索](../../util/text-search/README.zh.md):标签模糊匹配,详情按子串匹配,各行在组内按匹配程度排序。空查询按分组顺序保留所有行。渲染、键盘导航与选择使用相同的筛选顺序。
|
||||
|
||||
### 内置行的展示面
|
||||
|
||||
|
||||
@@ -64,7 +64,8 @@
|
||||
"@deepseek-ai/dsh-util-values": "workspace:*",
|
||||
"@deepseek-ai/dsh-client-ui-renderer": "workspace:*",
|
||||
"@deepseek-ai/dsh-client-ui-session": "workspace:*",
|
||||
"clsx": "^2.0.0"
|
||||
"clsx": "^2.0.0",
|
||||
"@deepseek-ai/dsh-util-text-search": "workspace:*"
|
||||
},
|
||||
"files": [
|
||||
"locale/*.json",
|
||||
|
||||
@@ -48,8 +48,8 @@ export function PopupSelectView({ popup, t }: PopupSelectViewProps) {
|
||||
const cardRef = useRef<HTMLDivElement>(null)
|
||||
const searchRef = useRef<HTMLInputElement>(null)
|
||||
const viewportRef = useRef<HTMLDivElement>(null)
|
||||
const rows = useMemo(() => filterOptions(state.options, state.search, state.searchMode),
|
||||
[state.options, state.search, state.searchMode])
|
||||
const rows = useMemo(() => filterOptions(state.options, state.search),
|
||||
[state.options, state.search])
|
||||
const groups = useMemo(() => groupOptions(rows), [rows])
|
||||
useEffect(() => {
|
||||
const viewport = viewportRef.current
|
||||
|
||||
@@ -23,9 +23,6 @@ export interface SelectOptionGroup {
|
||||
readonly label: string
|
||||
}
|
||||
|
||||
/** Search behavior selected by the popup owner. */
|
||||
export type PopupSearchMode = 'substring' | 'fuzzy-label'
|
||||
|
||||
/** One option row of a popupSelect shell. */
|
||||
export interface SelectOption {
|
||||
readonly id: string
|
||||
@@ -63,8 +60,6 @@ export interface PopupSearchLabels {
|
||||
*/
|
||||
export interface PopupSelectSpec {
|
||||
readonly kind: 'popupSelect'
|
||||
/** Defaults to substring search; fuzzy-label ranks names within each group. */
|
||||
readonly searchMode?: PopupSearchMode
|
||||
/**
|
||||
* Supply localized search copy for this opening; omitted uses the shell's generic copy.
|
||||
* @returns search placeholder and empty-state labels.
|
||||
|
||||
@@ -28,7 +28,7 @@ export type { PopupSelectDeps, PopupSpec, PopupState, TokenSegment } from './pop
|
||||
export type { PopupSelectInjected, PopupSelectViewProps } from './PopupSelectView.tsx'
|
||||
export type {
|
||||
ActionSpec, CommandContribution, CommandDecoration, CommandUiContract, CommandUiSpec, PopupSearchLabels, PopupSelectSpec,
|
||||
SelectConfirmation, SelectOption, SelectOptionGroup, PopupSearchMode,
|
||||
SelectConfirmation, SelectOption, SelectOptionGroup,
|
||||
} from './contract.ts'
|
||||
export type { CommandKey } from './locales.ts'
|
||||
|
||||
|
||||
@@ -12,8 +12,8 @@
|
||||
import { createSnapshotStore } from '@deepseek-ai/dsh-client-store'
|
||||
import type { SnapshotStore } from '@deepseek-ai/dsh-client-store'
|
||||
import type { TokenSpan } from '@deepseek-ai/dsh-client-ui-input-trigger/client'
|
||||
import type { PopupSearchLabels, PopupSearchMode, PopupSelectSpec, SelectOption } from './contract.ts'
|
||||
import { rankByName } from '@deepseek-ai/dsh-client-ui-primitives'
|
||||
import { TextSearchIndex } from '@deepseek-ai/dsh-util-text-search'
|
||||
import type { PopupSearchLabels, PopupSelectSpec, SelectOption } from './contract.ts'
|
||||
import { groupOptions } from './option-groups.ts'
|
||||
|
||||
/**
|
||||
@@ -33,7 +33,7 @@ export type TokenSegment =
|
||||
* session wiring passes its session projection; the controller only carries
|
||||
* it from open() to the callbacks).
|
||||
*/
|
||||
export interface PopupSpec<TCtx> extends Pick<PopupSelectSpec, 'searchLabels' | 'searchMode'> {
|
||||
export interface PopupSpec<TCtx> extends Pick<PopupSelectSpec, 'searchLabels'> {
|
||||
/** Load the option rows once per open (retry after failure reuses the same signal). */
|
||||
options(context: TCtx, signal: AbortSignal): Promise<readonly SelectOption[]>
|
||||
/** Settle the picked option against the open-time context. */
|
||||
@@ -67,8 +67,6 @@ export interface PopupState {
|
||||
readonly search: string
|
||||
/** Command-owned copy for this opening; null uses generic shell labels. */
|
||||
readonly searchLabels: PopupSearchLabels | null
|
||||
/** Search policy resolved from the command spec at opening. */
|
||||
readonly searchMode: PopupSearchMode
|
||||
/**
|
||||
* Highlight index into the filtered row list: 0 until options land; afterwards
|
||||
* the row the loaded list marks as the current value
|
||||
@@ -87,31 +85,20 @@ export interface PopupState {
|
||||
}
|
||||
|
||||
const CLOSED: PopupState = {
|
||||
open: false, command: null, status: 'pending', options: [], search: '', searchLabels: null, searchMode: 'substring', active: 0,
|
||||
open: false, command: null, status: 'pending', options: [], search: '', searchLabels: null, active: 0,
|
||||
submitting: false, confirming: null, acknowledged: false, error: null,
|
||||
}
|
||||
|
||||
/**
|
||||
* Filter rows using substring matching, or rank labels fuzzily within each group.
|
||||
* Blank search keeps every row; fuzzy matching preserves group order.
|
||||
* Filter and rank rows within each group: labels match fuzzily, details as substrings.
|
||||
* Blank search keeps every row; groups keep their order.
|
||||
* @param options - the loaded rows.
|
||||
* @param search - the shell's search text.
|
||||
* @param mode - the command's policy; defaults to substring over label and detail.
|
||||
* @returns the original option objects in the order shown and used for selection.
|
||||
*/
|
||||
export function filterOptions(
|
||||
options: readonly SelectOption[], search: string, mode: PopupSearchMode = 'substring',
|
||||
): readonly SelectOption[] {
|
||||
const query = search.trim().toLowerCase()
|
||||
const groups = groupOptions(options)
|
||||
const ordered = groups.some(group => group.group !== undefined) ? groups.flatMap(group => group.rows) : options
|
||||
if (query === '') return ordered
|
||||
if (mode === 'fuzzy-label') {
|
||||
return groups.flatMap(group => rankByName(
|
||||
group.rows.map(option => ({ name: option.label, option })), query,
|
||||
).map(row => row.option))
|
||||
}
|
||||
return ordered.filter(o => o.label.toLowerCase().includes(query) || (o.detail?.toLowerCase().includes(query) ?? false))
|
||||
export function filterOptions(options: readonly SelectOption[], search: string): readonly SelectOption[] {
|
||||
return groupOptions(options).flatMap(group =>
|
||||
new TextSearchIndex(group.rows, option => ({ fuzzy: [option.label], substring: [option.detail] })).search(search))
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -121,11 +108,10 @@ export function filterOptions(
|
||||
* made without looking confirms that value instead of the topmost row.
|
||||
* @param options - the loaded rows.
|
||||
* @param search - the shell's live filter text (non-empty after a retry).
|
||||
* @param mode - the command's search policy.
|
||||
* @returns index into the filtered rows.
|
||||
*/
|
||||
function currentIndex(options: readonly SelectOption[], search: string, mode: PopupSearchMode): number {
|
||||
const at = filterOptions(options, search, mode).findIndex(option => option.active === true)
|
||||
function currentIndex(options: readonly SelectOption[], search: string): number {
|
||||
const at = filterOptions(options, search).findIndex(option => option.active === true)
|
||||
return at === -1 ? 0 : at
|
||||
}
|
||||
|
||||
@@ -173,7 +159,7 @@ export class PopupSelectController<TCtx = unknown> {
|
||||
this.binding?.abort.abort()
|
||||
const binding: OpenBinding<TCtx> = { command, spec, context, segment, abort: new AbortController() }
|
||||
this.binding = binding
|
||||
this.state.set({ ...CLOSED, open: true, command, searchLabels, searchMode: spec.searchMode ?? 'substring' })
|
||||
this.state.set({ ...CLOSED, open: true, command, searchLabels })
|
||||
this.load(binding)
|
||||
}
|
||||
|
||||
@@ -183,7 +169,7 @@ export class PopupSelectController<TCtx = unknown> {
|
||||
(options) => {
|
||||
if (this.binding !== binding) return
|
||||
const current = this.state.getSnapshot()
|
||||
this.state.set({ ...current, status: 'ready', options, active: currentIndex(options, current.search, current.searchMode), error: null })
|
||||
this.state.set({ ...current, status: 'ready', options, active: currentIndex(options, current.search), error: null })
|
||||
},
|
||||
(error: unknown) => {
|
||||
if (this.binding !== binding) return
|
||||
@@ -222,7 +208,7 @@ export class PopupSelectController<TCtx = unknown> {
|
||||
move(dir: 1 | -1): void {
|
||||
const s = this.state.getSnapshot()
|
||||
if (!s.open || s.status !== 'ready' || s.submitting || s.confirming !== null) return
|
||||
const rows = filterOptions(s.options, s.search, s.searchMode)
|
||||
const rows = filterOptions(s.options, s.search)
|
||||
if (rows.length === 0) return
|
||||
const active = (s.active + dir + rows.length) % rows.length
|
||||
this.state.set({ ...s, active })
|
||||
@@ -236,7 +222,7 @@ export class PopupSelectController<TCtx = unknown> {
|
||||
highlight(index: number): void {
|
||||
const s = this.state.getSnapshot()
|
||||
if (!s.open || s.status !== 'ready' || s.submitting || s.confirming !== null) return
|
||||
if (index < 0 || index >= filterOptions(s.options, s.search, s.searchMode).length || index === s.active) return
|
||||
if (index < 0 || index >= filterOptions(s.options, s.search).length || index === s.active) return
|
||||
this.state.set({ ...s, active: index })
|
||||
}
|
||||
|
||||
@@ -254,7 +240,7 @@ export class PopupSelectController<TCtx = unknown> {
|
||||
const binding = this.binding
|
||||
const s = this.state.getSnapshot()
|
||||
if (binding === null || !s.open || s.status !== 'ready' || s.submitting || s.confirming !== null) return
|
||||
const option = filterOptions(s.options, s.search, s.searchMode)[index]
|
||||
const option = filterOptions(s.options, s.search)[index]
|
||||
if (option === undefined) return
|
||||
if (option.confirmation !== undefined) {
|
||||
this.state.set({ ...s, confirming: option, acknowledged: false, error: null })
|
||||
|
||||
@@ -5,8 +5,10 @@
|
||||
* catalog with contributions by availability, gives built-in Host rows their
|
||||
* localized face (presentation.ts), then position-filters; an empty query
|
||||
* lists the Add and Commands sections in usage order, a typed query ranks
|
||||
* every row by the `/` menu's shared name-and-label ranking (ui-primitives
|
||||
* `rankByName`). A host/contribution name collision fails loud. Every
|
||||
* every row through the shared search filter (`dsh-util-text-search`) over
|
||||
* name and label. Descriptions stay unmatched: this source shares one menu and
|
||||
* its default highlight with other sources, so a description-only hit would
|
||||
* take Enter from a name another group matched. A host/contribution name collision fails loud. Every
|
||||
* execute addresses the session's agent by sessionId — sessions are always
|
||||
* agent-backed.
|
||||
* Catalog RPCs retain an existing Client Session through completion and
|
||||
@@ -23,7 +25,7 @@ import type { ISessions, SessionBinding } from '@deepseek-ai/dsh-api-session-con
|
||||
import type { SessionId } from '@deepseek-ai/dsh-session/types'
|
||||
import { WeakMapWithValues } from '@deepseek-ai/dsh-util-values'
|
||||
import type { TranslateNS } from '@deepseek-ai/dsh-client-locale/client'
|
||||
import { rankByName } from '@deepseek-ai/dsh-client-ui-primitives'
|
||||
import { TextSearchIndex } from '@deepseek-ai/dsh-util-text-search'
|
||||
import type {
|
||||
CandidateRequest, ClientSessionContext, CommandClaim, PickOutcome, InputTriggerCandidate, InputTriggerPick,
|
||||
SubmitAttachment, SubmitEnvelope, SubmitOutcome,
|
||||
@@ -219,7 +221,7 @@ export class CommandUiRuntime extends Service implements CommandUiContract {
|
||||
/**
|
||||
* Menu candidates: host catalog + contribution availability, built-in rows
|
||||
* localized, then position filtering; sections for an empty query, the
|
||||
* shared name-and-label ranking for a typed one.
|
||||
* shared search filter for a typed one.
|
||||
*/
|
||||
private async candidates(session: ClientSessionContext, req: CandidateRequest): Promise<readonly InputTriggerCandidate[]> {
|
||||
const list = await this.directory.ensureReady(session.sessionId, req.signal)
|
||||
@@ -246,7 +248,7 @@ export class CommandUiRuntime extends Service implements CommandUiContract {
|
||||
})
|
||||
}
|
||||
const visible = rows.filter(c => req.position === 'leading' || c.hint === undefined)
|
||||
return req.query === '' ? sectionRows(visible, this.t) : rankByName(visible, req.query)
|
||||
return req.query === '' ? sectionRows(visible, this.t) : new TextSearchIndex(visible, row => ({ fuzzy: [row.name, row.label] })).search(req.query)
|
||||
}
|
||||
|
||||
/** Decision table, menu column: contribution/decorated-host → popup or action; host input → claim; host bare → detached execute. */
|
||||
|
||||
@@ -90,7 +90,7 @@ describe('PopupSelectView', () => {
|
||||
{ id: 'other', label: 'Unmatched', group: { name: 'other', label: 'Other provider' } },
|
||||
]
|
||||
const onSelect = vi.fn()
|
||||
const { search } = await mountOpen({ searchMode: 'fuzzy-label', options: () => Promise.resolve(options), onSelect })
|
||||
const { search } = await mountOpen({ options: () => Promise.resolve(options), onSelect })
|
||||
expect(screen.getAllByRole('group').map(group => group.querySelector('[data-menu-group-heading]')?.textContent))
|
||||
.toEqual(['Alpha provider', 'Beta provider', 'Other provider'])
|
||||
expect(rowLabels()).toEqual(['DeepSeek Flash', 'Flash Lite', 'Flash Beta', 'Unmatched'])
|
||||
|
||||
@@ -58,14 +58,14 @@ describe('filterOptions', () => {
|
||||
|
||||
it('keeps provider order while ranking fuzzy label matches within each group', () => {
|
||||
expect(filterOptions(grouped, '')).toEqual([grouped[0], grouped[2], grouped[1]])
|
||||
expect(filterOptions(grouped, ' FLASH ', 'fuzzy-label')).toEqual([grouped[2], grouped[0], grouped[1]])
|
||||
expect(filterOptions(grouped, 'fslt', 'fuzzy-label')).toEqual([grouped[2]])
|
||||
expect(filterOptions(grouped, 'Alpha provider', 'fuzzy-label')).toEqual([])
|
||||
expect(filterOptions(grouped, ' FLASH ')).toEqual([grouped[2], grouped[0], grouped[1]])
|
||||
expect(filterOptions(grouped, 'fslt')).toEqual([grouped[2]])
|
||||
expect(filterOptions(grouped, 'Alpha provider')).toEqual([])
|
||||
})
|
||||
|
||||
it('uses that same displayed order for highlighting and selection, then resets the mode on reopen', async () => {
|
||||
it('uses that same displayed order for highlighting and selection', async () => {
|
||||
const onSelect = vi.fn()
|
||||
const { popup } = await readyPopup({ searchMode: 'fuzzy-label', options: () => Promise.resolve(grouped), onSelect })
|
||||
const { popup } = await readyPopup({ options: () => Promise.resolve(grouped), onSelect })
|
||||
expect(popup.state.getSnapshot().active).toBe(1)
|
||||
popup.setSearch('flash')
|
||||
expect(popup.state.getSnapshot().active).toBe(0)
|
||||
@@ -73,16 +73,15 @@ describe('filterOptions', () => {
|
||||
expect(popup.state.getSnapshot().active).toBe(2)
|
||||
await popup.select(2)
|
||||
expect(onSelect).toHaveBeenCalledWith(grouped[1], CTX_A)
|
||||
popup.open('theme', spec(), CTX_A, SEGMENT)
|
||||
await Promise.resolve()
|
||||
expect(popup.state.getSnapshot().searchMode).toBe('substring')
|
||||
})
|
||||
|
||||
it('matches case-insensitively over label and detail; blank keeps all', () => {
|
||||
expect(filterOptions(OPTIONS, '')).toBe(OPTIONS)
|
||||
expect(filterOptions(OPTIONS, ' ')).toBe(OPTIONS)
|
||||
it('matches labels fuzzily and details as substrings; blank keeps all', () => {
|
||||
expect(filterOptions(OPTIONS, '')).toEqual(OPTIONS)
|
||||
expect(filterOptions(OPTIONS, ' ')).toEqual(OPTIONS)
|
||||
expect(filterOptions(OPTIONS, 'DARK')).toEqual([OPTIONS[0]])
|
||||
expect(filterOptions(OPTIONS, 'lgt')).toEqual([OPTIONS[1]])
|
||||
expect(filterOptions(OPTIONS, 'warm')).toEqual([OPTIONS[2]])
|
||||
expect(filterOptions(OPTIONS, 'wrm')).toEqual([])
|
||||
expect(filterOptions(OPTIONS, 'nope')).toEqual([])
|
||||
})
|
||||
})
|
||||
|
||||
@@ -8,6 +8,9 @@
|
||||
"src"
|
||||
],
|
||||
"references": [
|
||||
{
|
||||
"path": "../../util/text-search"
|
||||
},
|
||||
{
|
||||
"path": "../../api/remotes/tsconfig.client.json"
|
||||
},
|
||||
|
||||
@@ -30,8 +30,8 @@
|
||||
en: b4c2e8c1f7ab4de5
|
||||
zh: 5dd0e14aa5f9d334
|
||||
/deepseek-ai-dsh-client-ui-model-selection/understand-the-implementation:
|
||||
en: c1d14a925c92950f
|
||||
zh: f80f8169bc283c60
|
||||
en: a11207241d0606e8
|
||||
zh: 6e4f3fb27527f5b6
|
||||
/deepseek-ai-dsh-client-ui-model-selection/further-exploration:
|
||||
en: 14acd4692e923480
|
||||
zh: ff89aed852aa0da8
|
||||
|
||||
@@ -73,7 +73,7 @@ Menus use the shared `MenuSurface` material, including the macOS backing for bac
|
||||
<details>
|
||||
<summary>Implementation internals — click to expand</summary>
|
||||
|
||||
The composer `ModelSelect` and `/model` option builder share [provider ordering](src/client/provider-order.ts), while both searches use `rankByName` within each provider. The command supplies optional groups and `searchMode: 'fuzzy-label'` through the [popupSelect API](../ui-commands/README.md#use-this-package); both entries use `MenuGroup` and rebuild its sticky observer when the rendered groups change. The command popup fills the composer overlay, while the button retains its compact menu.
|
||||
The composer `ModelSelect` and `/model` option builder share [provider ordering](src/client/provider-order.ts), while both searches use the shared [text search](../../util/text-search/README.md) within each provider. The command supplies optional groups through the [popupSelect API](../ui-commands/README.md#use-this-package); both entries use `MenuGroup` and rebuild its sticky observer when the rendered groups change. The command popup fills the composer overlay, while the button retains its compact menu.
|
||||
|
||||
Two entries over ONE per-session directory owned by `ModelDirectoryResolver` (`ctx.modelDirectories`): the `/model` popupSelect contribution (registered through `ctx.commandUi`) and the composer's named `conversation.input.model` seat both load the session's available directory through `session.models` and submit through `session.selectModel` via the same `ModelDirectory` instance, so a switch made in either entry is what the other shows next. Directory loads and selections share a generation counter so an older response never overwrites a newer one. The directory publishes the latest submitted selection as `pending` until it settles or a connection reset invalidates it; a connection reset drops every resident projection and repulls the Host-restored selection before display. Directories are per-session, resolved lazily, and disposed with the session scope; addressed subagent sessions expose neither entry. Every resident directory refetches directly on forwarded `llm/adapters-updated`, `llm/models-updated`, `settings/document-updated`, and credential update events.
|
||||
|
||||
|
||||
@@ -73,7 +73,7 @@ composer 菜单中的模型名称和推理等级均使用 400(regular)字重
|
||||
<details>
|
||||
<summary>实现细节——点击展开</summary>
|
||||
|
||||
composer 的 `ModelSelect` 与 `/model` 选项构建器共用[提供方排序](src/client/provider-order.ts),两个搜索框均在每个提供方内使用 `rankByName`。命令通过 [popupSelect API](../ui-commands/README.zh.md#use-this-package) 提供可选分组与 `searchMode: 'fuzzy-label'`;两个入口均使用 `MenuGroup`,并在渲染分组变化时重建其吸顶观察器。命令弹窗撑满 composer 浮层,按钮则保留紧凑菜单。
|
||||
composer 的 `ModelSelect` 与 `/model` 选项构建器共用[提供方排序](src/client/provider-order.ts),两个搜索框均在每个提供方内使用共享的[文本搜索](../../util/text-search/README.zh.md)。命令通过 [popupSelect API](../ui-commands/README.zh.md#use-this-package) 提供可选分组;两个入口均使用 `MenuGroup`,并在渲染分组变化时重建其吸顶观察器。命令弹窗撑满 composer 浮层,按钮则保留紧凑菜单。
|
||||
|
||||
两个入口共用一份由 `ModelDirectoryResolver`(`ctx.modelDirectories`)持有的会话级目录:`/model` popupSelect 贡献项(经 `ctx.commandUi` 注册)与 composer 的具名 `conversation.input.model` 位都经 `session.models` 加载会话的可用目录、经 `session.selectModel` 通过同一个 `ModelDirectory` 实例提交,因此任一入口所做的切换正是另一个入口接下来显示的。目录加载与选择共享一个代次计数器,旧响应不会覆盖新结果。目录把最近一次提交的选择发布为 `pending`,直到它完成或被连接重置作废;连接重置丢弃所有常驻投影,并在显示前重新拉取 Host 恢复的选择。目录按会话惰性解析,随会话作用域一并 dispose(资源释放);已寻址 subagent 会话不公开任一入口。每份常驻目录都会直接在转发的 `llm/adapters-updated`、`llm/models-updated`、`settings/document-updated` 与凭据更新事件上重拉。
|
||||
|
||||
|
||||
@@ -67,7 +67,8 @@
|
||||
"@deepseek-ai/dsh-client-ui-renderer": "workspace:*",
|
||||
"@deepseek-ai/dsh-client-ui-session": "workspace:*",
|
||||
"clsx": "^2.1.1",
|
||||
"@deepseek-ai/dsh-client-product-analytics": "workspace:*"
|
||||
"@deepseek-ai/dsh-client-product-analytics": "workspace:*",
|
||||
"@deepseek-ai/dsh-util-text-search": "workspace:*"
|
||||
},
|
||||
"files": [
|
||||
"locale/*.json",
|
||||
|
||||
@@ -37,11 +37,12 @@ import clsx from 'clsx'
|
||||
import type { ModelReasoningEffort, ModelSelection } from '@deepseek-ai/dsh-api-remotes/client'
|
||||
import {
|
||||
IconCheckOutlineRegular, IconChevronDownOutlineRegular, IconChevronRightOutlineRegular, IconCloseFillRegular,
|
||||
IconDataOutlineRegular, IconWarningOutlineRegular, Input, isMobileDevice, rankByName, StateDot, Tag, Toast,
|
||||
IconDataOutlineRegular, IconWarningOutlineRegular, Input, isMobileDevice, StateDot, Tag, Toast,
|
||||
} from '@deepseek-ai/dsh-client-ui-primitives'
|
||||
import type { PropsLocale, PropsRenderSlots, PropsRuntime } from '@deepseek-ai/dsh-client-ui-slots'
|
||||
import type { ModelLabelOwner, ModelMenuControls, ModelMenuPaneRef, ModelSelectInjected } from './slots.ts'
|
||||
import css from './ModelSelect.module.css'
|
||||
import { TextSearchIndex } from '@deepseek-ai/dsh-util-text-search'
|
||||
import { orderModelProviders } from './provider-order.ts'
|
||||
|
||||
/** Which pane the dropdown shows: the root menu, one drilled-in list, or a plugin-owned detail pane. */
|
||||
@@ -124,9 +125,12 @@ export function ModelSelect(
|
||||
} satisfies ModelSelection,
|
||||
}))), [groups])
|
||||
const showSearch = choices.length > 4
|
||||
const filteredGroups = useMemo(() => groups.map(group => ({
|
||||
...group, models: rankByName(group.models, showSearch ? query.trim() : ''),
|
||||
})).filter(group => group.models.length > 0), [groups, query, showSearch])
|
||||
const groupIndexes = useMemo(() => groups.map(group => ({
|
||||
group, index: new TextSearchIndex(group.models, model => ({ fuzzy: [model.name, model.id], substring: [model.description] })),
|
||||
})), [groups])
|
||||
const filteredGroups = useMemo(() => groupIndexes.map(({ group, index }) => ({
|
||||
...group, models: index.search(showSearch ? query : ''),
|
||||
})).filter(group => group.models.length > 0), [groupIndexes, query, showSearch])
|
||||
const visibleModels = useMemo(() => filteredGroups.flatMap(group => group.models.map(model => ({
|
||||
provider: group.id, model: model.id,
|
||||
}))), [filteredGroups])
|
||||
|
||||
@@ -134,7 +134,6 @@ export function apply(ctx: ClientContext): void {
|
||||
available: session => sessions.subagentAddress(session.sessionId) === undefined,
|
||||
ui: {
|
||||
kind: 'popupSelect',
|
||||
searchMode: 'fuzzy-label',
|
||||
searchLabels: () => ({
|
||||
placeholder: t('search.placeholder'),
|
||||
empty: t('empty.models'),
|
||||
|
||||
@@ -245,7 +245,6 @@ describe('ui-model-selection dual entry', () => {
|
||||
])
|
||||
expect(options.map(option => option.group?.label)).toEqual(['DeepSeek', 'DeepSeek', 'External Provider'])
|
||||
expect(options.every(option => option.detail === undefined)).toBe(true)
|
||||
expect(b.popup().searchMode).toBe('fuzzy-label')
|
||||
expect(options[0]?.active).toBe(true)
|
||||
expect(options[1]?.active).toBeUndefined()
|
||||
expect(b.popup().searchLabels?.()).toEqual(locale === 'zh'
|
||||
|
||||
@@ -11,6 +11,9 @@
|
||||
{
|
||||
"path": "../../core/agent"
|
||||
},
|
||||
{
|
||||
"path": "../../util/text-search"
|
||||
},
|
||||
{
|
||||
"path": "../../api/remotes/tsconfig.client.json"
|
||||
},
|
||||
|
||||
@@ -27,8 +27,8 @@
|
||||
en: 188ebf6f1590bad1
|
||||
zh: e6d41e8586190fa0
|
||||
/deepseek-ai-dsh-client-ui-plugin-manager/use-this-package/switching-one-row-of-a-bundle:
|
||||
en: d3627d4dba5e6cc2
|
||||
zh: e0d0eada4c20331f
|
||||
en: 5f93ebe75d13b7cf
|
||||
zh: 9c28f150263d041e
|
||||
/deepseek-ai-dsh-client-ui-plugin-manager/use-this-package/configuration-pages:
|
||||
en: e9da90f03691101b
|
||||
zh: 902cda935a4ce3c8
|
||||
|
||||
@@ -82,7 +82,7 @@ A bundle's page shows its full package name under the title. Its **Source** sect
|
||||
|
||||
### Switching one row of a bundle
|
||||
|
||||
A row's switch on the bundle's page calls `pluginManager.setPluginEnabled`, which records the row's enablement in the profile's `cordis.patch.yml` under the [toggle rules](../../boot/plugin-manager/README.md#use-this-package). The tree recomposes at once on a profile with HMR, so the row's host half unmounts or mounts while the rest of the bundle keeps running, and the page follows the client module graph without reloading. Rows use the shared status marker for their Host fiber phase: pending and disabled are idle, loading and unloading are ongoing, active is done, and failed is error. The switch appears only on a bundle that is on; a row without a live entry, or one the Host will not address through the profile patch, is locked with the Host's reason. A list longer than ten rows gets a filter over localized titles, descriptions, row ids, and module names.
|
||||
A row's switch on the bundle's page calls `pluginManager.setPluginEnabled`, which records the row's enablement in the profile's `cordis.patch.yml` under the [toggle rules](../../boot/plugin-manager/README.md#use-this-package). The tree recomposes at once on a profile with HMR, so the row's host half unmounts or mounts while the rest of the bundle keeps running, and the page follows the client module graph without reloading. Rows use the shared status marker for their Host fiber phase: pending and disabled are idle, loading and unloading are ongoing, active is done, and failed is error. The switch appears only on a bundle that is on; a row without a live entry, or one the Host will not address through the profile patch, is locked with the Host's reason. A list longer than ten rows gets a filter through the shared [text search](../../util/text-search/README.md): row ids, module names, and every declared language of titles match fuzzily, and every language of descriptions matches as a substring; rows display in the current language.
|
||||
|
||||
### Configuration pages
|
||||
|
||||
|
||||
@@ -82,7 +82,7 @@ Host 将网络失败或超时归因于 GitHub 地址,且提供 npmmirror 时
|
||||
|
||||
### 切换组合包里的一行
|
||||
|
||||
组合包页面上行的开关调用 `pluginManager.setPluginEnabled`,按[开关规则](../../boot/plugin-manager/README.zh.md#use-this-package)在 profile 的 `cordis.patch.yml` 中记录该行的启用状态。启用了 HMR 的 profile 的树随即重组,该行的宿主半区卸下或挂上,组合包其余部分照常运行,页面无需重载即跟随客户端模块图。行使用共享状态标记表示 Host fiber 阶段:pending 与 disabled 为 idle,loading 与 unloading 为 ongoing,active 为 done,failed 为 error。开关只出现在已打开的组合包上;没有存活条目的行,以及 Host 不通过 profile patch 寻址的行,带着 Host 的原因锁定。超过十行的列表带一个按本地化标题、描述、行 id 和模块名筛选的输入框。
|
||||
组合包页面上行的开关调用 `pluginManager.setPluginEnabled`,按[开关规则](../../boot/plugin-manager/README.zh.md#use-this-package)在 profile 的 `cordis.patch.yml` 中记录该行的启用状态。启用了 HMR 的 profile 的树随即重组,该行的宿主半区卸下或挂上,组合包其余部分照常运行,页面无需重载即跟随客户端模块图。行使用共享状态标记表示 Host fiber 阶段:pending 与 disabled 为 idle,loading 与 unloading 为 ongoing,active 为 done,failed 为 error。开关只出现在已打开的组合包上;没有存活条目的行,以及 Host 不通过 profile patch 寻址的行,带着 Host 的原因锁定。超过十行的列表带一个筛选框,使用共享的[文本搜索](../../util/text-search/README.zh.md):行 id、模块名和标题的所有声明语言模糊匹配,描述的所有语言按子串匹配;各行以当前语言显示。
|
||||
|
||||
### 配置页
|
||||
|
||||
|
||||
@@ -74,7 +74,8 @@
|
||||
"@deepseek-ai/dsh-util-crypto": "workspace:*",
|
||||
"@deepseek-ai/dsh-client-ui-settings": "workspace:*",
|
||||
"@deepseek-ai/dsh-plugin-manager": "workspace:*",
|
||||
"@deepseek-ai/dsh-client-product-analytics": "workspace:*"
|
||||
"@deepseek-ai/dsh-client-product-analytics": "workspace:*",
|
||||
"@deepseek-ai/dsh-util-text-search": "workspace:*"
|
||||
},
|
||||
"files": [
|
||||
"locale/*.json",
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
* the page declares.
|
||||
*/
|
||||
|
||||
import { useEffect, useId, useRef, useState, type ReactNode } from 'react'
|
||||
import { useEffect, useId, useMemo, useRef, useState, type ReactNode } from 'react'
|
||||
import { createPortal } from 'react-dom'
|
||||
import type { PluginInstallFailureKind, Registry } from '@deepseek-ai/dsh-api-remotes/client'
|
||||
import {
|
||||
@@ -22,6 +22,7 @@ import {
|
||||
} from '@deepseek-ai/dsh-client-ui-primitives'
|
||||
import type { InjectFace, PropsLocale, PropsRenderSlots, PropsRuntime, PropsStore } from '@deepseek-ai/dsh-client-ui-slots'
|
||||
import { EXTENSION_BUNDLES, HIDDEN_BUNDLES, MORE_BUNDLES } from '@deepseek-ai/dsh-official-bundles'
|
||||
import { localizedValues, TextSearchIndex } from '@deepseek-ai/dsh-util-text-search'
|
||||
import type { createNavigationStore } from './navigation-store.ts'
|
||||
import type { PluginHeaderLayoutFace } from './header-scroll.ts'
|
||||
import { rowConfigKey, type OfficialItem } from './config-ledger.ts'
|
||||
@@ -282,10 +283,12 @@ function RowsSection({ rows, t, resolveText, toggle, configure }: {
|
||||
readonly configure?: RowConfigure | undefined
|
||||
}): ReactNode {
|
||||
const [filter, setFilter] = useState('')
|
||||
const query = filter.trim().toLowerCase()
|
||||
const localized = rows.map(row => ({ row, ...rowText(row, resolveText) }))
|
||||
const shown = query === '' ? localized : localized.filter(({ row, title, description }) =>
|
||||
[title, description, row.rowId, row.moduleName].some(value => value?.toLowerCase().includes(query)))
|
||||
// Rows display one language; matching covers every language a value carries.
|
||||
const rowIndex = useMemo(() => new TextSearchIndex(rows, row => ({
|
||||
fuzzy: [row.rowId, row.moduleName, ...localizedValues(row.meta?.title)],
|
||||
substring: localizedValues(row.meta?.description),
|
||||
})), [rows])
|
||||
const shown = rowIndex.search(filter).map(row => ({ row, ...rowText(row, resolveText) }))
|
||||
return (
|
||||
<section className={css.detailSection} data-plugin-rows>
|
||||
<div className={css.sectionHead}>
|
||||
|
||||
@@ -1219,8 +1219,12 @@ describe('PluginManagerPage', () => {
|
||||
fireEvent.click(toggle)
|
||||
expect(actions.setRowEnabled).toHaveBeenCalledExactlyOnceWith('include:sidebar', false)
|
||||
|
||||
// The Chinese page still finds the row by its English title.
|
||||
fireEvent.change(search, { target: { value: 'Sidebar component' } })
|
||||
expect(document.querySelectorAll('[data-plugin-row]')).toHaveLength(1)
|
||||
fireEvent.change(search, { target: { value: 'no such row' } })
|
||||
expect(screen.getByText(zh.partsFilterEmpty)).toBeTruthy()
|
||||
fireEvent.change(search, { target: { value: 'Sidebar component' } })
|
||||
setLanguage(en)
|
||||
expect(screen.getByRole('button', { name: en.configureRow.replace('{name}', 'Sidebar component') })).toBeTruthy()
|
||||
fireEvent.click(screen.getByRole('button', { name: en.configureRow.replace('{name}', 'Sidebar component') }))
|
||||
|
||||
@@ -6,6 +6,9 @@
|
||||
"tsBuildInfoFile": "lib/tsconfig.client.tsbuildinfo"
|
||||
},
|
||||
"references": [
|
||||
{
|
||||
"path": "../../util/text-search"
|
||||
},
|
||||
{
|
||||
"path": "../../util/package-manifest"
|
||||
},
|
||||
|
||||
@@ -21,8 +21,8 @@
|
||||
en: 11686b52743a702d
|
||||
zh: d865bb79d8f56ee1
|
||||
/deepseek-ai-dsh-client-ui-primitives/use-this-package/controls-and-icons:
|
||||
en: 69acdb3375548a62
|
||||
zh: c392c11faf88938f
|
||||
en: fd3499ef403a0594
|
||||
zh: 3a17727316d3c666
|
||||
/deepseek-ai-dsh-client-ui-primitives/use-this-package/rendering-agent-output:
|
||||
en: 7fed4894a6d0d568
|
||||
zh: c22881bfcef2d4b6
|
||||
|
||||
@@ -97,7 +97,7 @@ Writing your own component in your own package is fine when the need is genuinel
|
||||
|
||||
### Controls and icons
|
||||
|
||||
The catalog above lists what each export is for; this section covers the behavior that props alone do not show. Product icon names omit artboard sizes and end in `Regular` or `Medium`. Line artwork uses stroke widths of 1 and 1.3 SVG user units respectively; the `size` prop controls rendered dimensions. Strokes scale with the viewport: a 1-unit stroke in a 16-unit view box renders at 0.875 CSS px at 14px and 0.75 CSS px at 12px, before further transforms. The renderer does not apply non-scaling strokes; filled contours scale as geometry and do not respond to stroke-width changes. Shared menus render icons at 14px, or 12px in compact lists, through `Menu.module.css`; these are rendered sizes, not fixed stroke widths. Named components keep the chosen weight visible at import sites; the library owns stroke geometry instead of consumer CSS overrides. Each product icon renders an `<svg>` box with one `<use>` of its `dsw-icon-<glyph>-<weight>` symbol, for example `dsw-icon-search-outline-regular`, and names that id in `data-icon`. `ICON_SYMBOLS` holds every symbol's default SVG document; ui-theme renders the document icon sprite from it, and an icon whose symbol is missing renders nothing. Artwork reached through `<use>` inherits `currentColor` and CSS variables from the use site. Each product, reference, link, and permission glyph intentionally keeps both weight exports even when the current product uses only one, so callers can choose emphasis without adding another API later; fill-only pairs render identically. `IconMailReadOutlineRegular`/`Medium` show an open envelope; `IconMailUnreadOutlineRegular`/`Medium` show a closed envelope with an unread dot. `IconWarningOutlineRegular`/`Medium` use a circle; `IconWarningTriangleOutlineRegular`/`Medium` use a rounded triangle. `IconEyeOutlineRegular`/`Medium` draw an open eye with a pupil and `IconEyeOffOutlineRegular`/`Medium` the same contour crossed by a diagonal slash, for paired show and hide toggles. `FishLogo` and `BrandWordmark` fill brand slots. `FileTypeIcon` renders the traditional 28px spreadsheet, folder, HTML, image, Markdown, generic, PDF, PPT, video, and Word glyphs, and uses the imported square technology artwork for the established 48 code and configuration categories. The import replaces artwork only: archive-only categories do not extend `CodeFileType`. `classifyFileType` applies exact filename, prefix, suffix, optional project-context, and extension rules in that order; React names win over TypeScript/JavaScript, Angular suffixes win over their base extension, and a Dart file becomes Flutter only when the supplied project files contain a `pubspec.yaml` with `flutter:`. Markdown and SVG remain traditional Markdown and image files. Spreadsheet mappings include CSV, TSV, Excel workbooks and templates, OpenDocument spreadsheets, and Numbers; KEY maps to slides, while RTF/ODT/Pages map to documents. `fileExtension` exposes the same basename and final-dot parsing for adjacent metadata labels. Traditional glyphs use a solid category-colored sheet with a white mark and translucent white corner; the generic code glyph uses angle brackets and a slash at the supplied 1.35px stroke; the generic file uses a grey sheet and darker grey corner. Callers may override the sheet color through `--dsh-file-type-icon-color`. The full-color technology artwork is the deliberate exception and retains its embedded palette. All glyphs are decorative and carry no label. `LinkIconMedium` is the leading glyph for clickable artifact links — globe, folder, code, image, document, or plain paper, and for a `url` link the mark of a well-known site named by its `href` — the developer sites a transcript usually cites (GitHub, GitLab, npm, PyPI, Stack Overflow, MDN, Wikipedia, Hacker News, YouTube, X, Bilibili, Zhihu, Juejin, CSDN) and mainstream search, video, social, shopping, and reference sites (Google, Baidu, DuckDuckGo, TikTok, Netflix, Spotify, Facebook, Instagram, Reddit, Telegram, WhatsApp, WeChat, QQ, Weibo, Taobao, AliExpress, eBay, Quora, V2EX, Apple) — while `classifyLinkPath` folds the shared file types into that existing six-category vocabulary. `ConnectionIndicator` renders a warning-colored disconnected action whose permanent retry glyph marks the retry action beside the owner-supplied outage label, the shared ongoing loader in the same warning color as its label whose one-to-three dots advance every 500ms independently of retry timing, or a success-colored recovered status. Clicking either warning state requests an immediate reconnect; no hover interaction changes the copy. The pill fades in on appearance, fades out for 150ms before unmounting, and sizes to its current label. Its owner supplies visibility, the recovery hold, localized labels, and the immediate-reconnect callback; the primitive uses no native title tooltip. `useAnchoredMaxHeight` keeps bottom-anchored overlays within the visible viewport; an oversized panel keeps the near margin instead of slidLine truncated
|
||||
The catalog above lists what each export is for; this section covers the behavior that props alone do not show. Product icon names omit artboard sizes and end in `Regular` or `Medium`. Line artwork uses stroke widths of 1 and 1.3 SVG user units respectively; the `size` prop controls rendered dimensions. Strokes scale with the viewport: a 1-unit stroke in a 16-unit view box renders at 0.875 CSS px at 14px and 0.75 CSS px at 12px, before further transforms. The renderer does not apply non-scaling strokes; filled contours scale as geometry and do not respond to stroke-width changes. Shared menus render icons at 14px, or 12px in compact lists, through `Menu.module.css`; these are rendered sizes, not fixed stroke widths. Named components keep the chosen weight visible at import sites; the library owns stroke geometry instead of consumer CSS overrides. Each product icon renders an `<svg>` box with one `<use>` of its `dsw-icon-<glyph>-<weight>` symbol, for example `dsw-icon-search-outline-regular`, and names that id in `data-icon`. `ICON_SYMBOLS` holds every symbol's default SVG document; ui-theme renders the document icon sprite from it, and an icon whose symbol is missing renders nothing. Artwork reached through `<use>` inherits `currentColor` and CSS variables from the use site. Each product, reference, link, and permission glyph intentionally keeps both weight exports even when the current product uses only one, so callers can choose emphasis without adding another API later; fill-only pairs render identically. `IconMailReadOutlineRegular`/`Medium` show an open envelope; `IconMailUnreadOutlineRegular`/`Medium` show a closed envelope with an unread dot. `IconWarningOutlineRegular`/`Medium` use a circle; `IconWarningTriangleOutlineRegular`/`Medium` use a rounded triangle. `IconEyeOutlineRegular`/`Medium` draw an open eye with a pupil and `IconEyeOffOutlineRegular`/`Medium` the same contour crossed by a diagonal slash, for paired show and hide toggles. `FishLogo` and `BrandWordmark` fill brand slots. `FileTypeIcon` renders the traditional 28px spreadsheet, folder, HTML, image, Markdown, generic, PDF, PPT, video, and Word glyphs, and uses the imported square technology artwork for the established 48 code and configuration categories. The import replaces artwork only: archive-only categories do not extend `CodeFileType`. `classifyFileType` applies exact filename, prefix, suffix, optional project-context, and extension rules in that order; React names win over TypeScript/JavaScript, Angular suffixes win over their base extension, and a Dart file becomes Flutter only when the supplied project files contain a `pubspec.yaml` with `flutter:`. Markdown and SVG remain traditional Markdown and image files. Spreadsheet mappings include CSV, TSV, Excel workbooks and templates, OpenDocument spreadsheets, and Numbers; KEY maps to slides, while RTF/ODT/Pages map to documents. `fileExtension` exposes the same basename and final-dot parsing for adjacent metadata labels. Traditional glyphs use a solid category-colored sheet with a white mark and translucent white corner; the generic code glyph uses angle brackets and a slash at the supplied 1.35px stroke; the generic file uses a grey sheet and darker grey corner. Callers may override the sheet color through `--dsh-file-type-icon-color`. The full-color technology artwork is the deliberate exception and retains its embedded palette. All glyphs are decorative and carry no label. `LinkIconMedium` is the leading glyph for clickable artifact links — globe, folder, code, image, document, or plain paper, and for a `url` link the mark of a well-known site named by its `href` — the developer sites a transcript usually cites (GitHub, GitLab, npm, PyPI, Stack Overflow, MDN, Wikipedia, Hacker News, YouTube, X, Bilibili, Zhihu, Juejin, CSDN) and mainstream search, video, social, shopping, and reference sites (Google, Baidu, DuckDuckGo, TikTok, Netflix, Spotify, Facebook, Instagram, Reddit, Telegram, WhatsApp, WeChat, QQ, Weibo, Taobao, AliExpress, eBay, Quora, V2EX, Apple) — while `classifyLinkPath` folds the shared file types into that existing six-category vocabulary. `ConnectionIndicator` renders a warning-colored disconnected action whose permanent retry glyph marks the retry action beside the owner-supplied outage label, the shared ongoing loader in the same warning color as its label whose one-to-three dots advance every 500ms independently of retry timing, or a success-colored recovered status. Clicking either warning state requests an immediate reconnect; no hover interaction changes the copy. The pill fades in on appearance, fades out for 150ms before unmounting, and sizes to its current label. Its owner supplies visibility, the recovery hold, localized labels, and the immediate-reconnect callback; the primitive uses no native title tooltip. `useAnchoredMaxHeight` keeps bottom-anchored overlays within the visible viewport; an oversized panel keeps the near margin instead of slidLine truncated
|
||||
|
||||
`Tooltip` reads the anchor on hover or keyboard focus and fits its bubble from `ResizeObserver` border-box sizes. It stays hidden until its first fit, prefers the requested side, then tries the opposite and perpendicular sides, sliding along the anchor without covering it when a side fits. Horizontal placements keep a 10px gap; vertical placements use `gap` (8px by default). Width and height stay within a 12px viewport margin; text wraps, and content taller than the viewport scrolls when pinned. If no side fits, a stable viewport-bounded fallback can overlap the anchor. Viewport resize refreshes the anchor coordinates; label-size changes reuse them. Fitting does not synchronously measure the bubble or trigger a React render. Touch presses dismiss unpinned hints and do not trigger hover hints, including compatibility mouse events. Mouse entry opens hints only while `(any-hover: hover)` reports an available hover-capable input, excluding iOS mouse entry caused by a tapped icon changing. Keyboard focus and explicit click-to-open explanations remain available on touch-only devices. Opt-in `openOnClick` lets an informational button pin the bubble by click or tap and associates it with the anchor description. Another click or tap, Escape, Tab, or an outside pointerdown closes it. Ordinary action buttons execute their action directly without a touch tooltip. Opt-in `onlyWhenClipped` shows the bubble only when the anchor or an HTML element inside it overflows horizontally when the bubble is about to show, so a label that repeats ellipsis-cut text appears only while it adds information.
|
||||
|
||||
|
||||
@@ -97,7 +97,7 @@ kind: "package-library"
|
||||
|
||||
### 控件与图标
|
||||
|
||||
上面的目录说明每个导出的用途;本节讲 props 本身看不出来的行为。产品图标名称不含画板尺寸,以 `Regular` 或 `Medium` 结尾。线条图形分别使用 1 和 1.3 SVG 用户单位的描边宽度;`size` prop 控制渲染尺寸。描边随视口缩放:16 单位 viewBox 中宽度为 1 的描边,在 14px 下为 0.875 CSS px,在 12px 下为 0.75 CSS px,尚未计入额外变换。渲染器不使用非缩放描边;填充轮廓随几何缩放,不受 stroke-width 变化影响。共享菜单通过 `Menu.module.css` 将图标渲染为 14px,紧凑列表为 12px;这些是渲染尺寸,不是固定描边宽度。具名组件让所选线重在导入处可见;描边几何由组件库拥有,而不是由消费方 CSS 覆盖。每个产品图标渲染一个 `<svg>` 框,其中包含一个引用对应 `dsw-icon-<glyph>-<weight>` symbol 的 `<use>`,例如 `dsw-icon-search-outline-regular`,并在 `data-icon` 中写出该 id。`ICON_SYMBOLS` 保存每个 symbol 的默认 SVG 文档;ui-theme 据此渲染文档的图标 sprite,缺少对应 symbol 的图标不渲染任何内容。通过 `<use>` 引用的图形会从使用处继承 `currentColor` 与 CSS 变量。每个产品、引用、链接与权限图形都会有意保留两种线重导出,即使当前产品只使用其中一种,也让调用方无需再次扩展 API 就能选择强调程度;仅填充的成对图形外观相同。`IconMailReadOutlineRegular`/`Medium` 使用打开的信封,`IconMailUnreadOutlineRegular`/`Medium` 使用带未读圆点的闭合信封。`IconWarningOutlineRegular`/`Medium` 使用圆形;`IconWarningTriangleOutlineRegular`/`Medium` 使用圆角三角形。`IconEyeOutlineRegular`/`Medium` 绘制带瞳孔的睁眼,`IconEyeOffOutlineRegular`/`Medium` 在同一轮廓上加一条斜线,用于成对的显示与隐藏开关。`FishLogo` 与 `BrandWordmark` 填充品牌 slot。`FileTypeIcon` 渲染传统的 28px spreadsheet、folder、HTML、image、Markdown、generic、PDF、PPT、video 与 Word 图形,并为现有 48 个代码和配置类别使用导入的方形技术图形。该导入只替换图形:资源包中额外的类别不会扩展 `CodeFileType`。`classifyFileType` 按完整文件名、前缀、后缀、可选项目上下文、扩展名的顺序匹配;React 文件名优先于 TypeScript/JavaScript,Angular 后缀优先于基础扩展名,只有传入的项目文件包含带 `flutter:` 的 `pubspec.yaml` 时 Dart 文件才使用 Flutter。Markdown 与 SVG 仍分别使用传统 Markdown 与图片图形。表格映射包括 CSV、TSV、Excel 工作簿与模板、OpenDocument 表格和 Numbers;KEY 映射为幻灯片,RTF/ODT/Pages 映射为文档。`fileExtension` 为相邻元数据 label 暴露同一套 basename 与最终点号解析。传统图形使用实色分类底板、白色标记和半透明白色折角;通用代码图形使用尖括号与斜线,保留原图 1.35px 描边;通用文件使用灰色底板与较深灰色折角。调用方可通过 `--dsh-file-type-icon-color` 覆盖底板颜色。全彩技术图形是明确例外,会保留其内嵌调色板。所有图形都是装饰性的,不自带 label。`LinkIconMedium` 是可点击产物链接的前置图形——地球、文件夹、代码、图片、文档或纸张,`url` 链接的 `href` 指向已知站点时则改用该站点自己的标记——转写内容常引用的开发者站点(GitHub、GitLab、npm、PyPI、Stack Overflow、MDN、Wikipedia、Hacker News、YouTube、X、Bilibili、知乎、掘金、CSDN),以及主流搜索、视频、社交、购物与参考资料站点(Google、百度、DuckDuckGo、TikTok、Netflix、Spotify、Facebook、Instagram、Reddit、Telegram、WhatsApp、微信、QQ、微博、淘宝、速卖通、eBay、Quora、V2EX、Apple)——`classifyLinkPath` 把共享文件类型折叠进原有六类词汇。`ConnectionIndicator` 可渲染警告色的断联操作(常驻重试图形指明重试动作,断联文案由持有方提供)、与文案使用相同警告色的共享 ongoing loading 加一至三个点以独立于 retry 时序的 500ms 节奏推进的连接中状态,或成功色的恢复状态。点击任一警告状态都会请求立即重连;没有任何悬停交互会改变文案。药丸出现时淡入、卸载前淡出 150ms,宽度随当前 label 自适应。它的持有方提供可见性、恢复驻留时间、本地化 label 与立即重连回调;该原语不使用原生 title tooltip。`useAnchoredMaxHeight` 将底部锚定浮层限制在可见视口内;过大的面板保留近端边距,不会滑出该边缘。portal 模式的 `Menu` 按布局视口限制卡片高度,固定页脚位于内部滚动区域之外;子卡片使用各自的 body portal,父级滚动不会裁剪它们。`HoverCard` 在框架发布的顶部占用量上增加 20px,原生全屏时保留 20px,普通浏览器中沿用自身的最小边距;Line truncated
|
||||
上面的目录说明每个导出的用途;本节讲 props 本身看不出来的行为。产品图标名称不含画板尺寸,以 `Regular` 或 `Medium` 结尾。线条图形分别使用 1 和 1.3 SVG 用户单位的描边宽度;`size` prop 控制渲染尺寸。描边随视口缩放:16 单位 viewBox 中宽度为 1 的描边,在 14px 下为 0.875 CSS px,在 12px 下为 0.75 CSS px,尚未计入额外变换。渲染器不使用非缩放描边;填充轮廓随几何缩放,不受 stroke-width 变化影响。共享菜单通过 `Menu.module.css` 将图标渲染为 14px,紧凑列表为 12px;这些是渲染尺寸,不是固定描边宽度。具名组件让所选线重在导入处可见;描边几何由组件库拥有,而不是由消费方 CSS 覆盖。每个产品图标渲染一个 `<svg>` 框,其中包含一个引用对应 `dsw-icon-<glyph>-<weight>` symbol 的 `<use>`,例如 `dsw-icon-search-outline-regular`,并在 `data-icon` 中写出该 id。`ICON_SYMBOLS` 保存每个 symbol 的默认 SVG 文档;ui-theme 据此渲染文档的图标 sprite,缺少对应 symbol 的图标不渲染任何内容。通过 `<use>` 引用的图形会从使用处继承 `currentColor` 与 CSS 变量。每个产品、引用、链接与权限图形都会有意保留两种线重导出,即使当前产品只使用其中一种,也让调用方无需再次扩展 API 就能选择强调程度;仅填充的成对图形外观相同。`IconMailReadOutlineRegular`/`Medium` 使用打开的信封,`IconMailUnreadOutlineRegular`/`Medium` 使用带未读圆点的闭合信封。`IconWarningOutlineRegular`/`Medium` 使用圆形;`IconWarningTriangleOutlineRegular`/`Medium` 使用圆角三角形。`IconEyeOutlineRegular`/`Medium` 绘制带瞳孔的睁眼,`IconEyeOffOutlineRegular`/`Medium` 在同一轮廓上加一条斜线,用于成对的显示与隐藏开关。`FishLogo` 与 `BrandWordmark` 填充品牌 slot。`FileTypeIcon` 渲染传统的 28px spreadsheet、folder、HTML、image、Markdown、generic、PDF、PPT、video 与 Word 图形,并为现有 48 个代码和配置类别使用导入的方形技术图形。该导入只替换图形:资源包中额外的类别不会扩展 `CodeFileType`。`classifyFileType` 按完整文件名、前缀、后缀、可选项目上下文、扩展名的顺序匹配;React 文件名优先于 TypeScript/JavaScript,Angular 后缀优先于基础扩展名,只有传入的项目文件包含带 `flutter:` 的 `pubspec.yaml` 时 Dart 文件才使用 Flutter。Markdown 与 SVG 仍分别使用传统 Markdown 与图片图形。表格映射包括 CSV、TSV、Excel 工作簿与模板、OpenDocument 表格和 Numbers;KEY 映射为幻灯片,RTF/ODT/Pages 映射为文档。`fileExtension` 为相邻元数据 label 暴露同一套 basename 与最终点号解析。传统图形使用实色分类底板、白色标记和半透明白色折角;通用代码图形使用尖括号与斜线,保留原图 1.35px 描边;通用文件使用灰色底板与较深灰色折角。调用方可通过 `--dsh-file-type-icon-color` 覆盖底板颜色。全彩技术图形是明确例外,会保留其内嵌调色板。所有图形都是装饰性的,不自带 label。`LinkIconMedium` 是可点击产物链接的前置图形——地球、文件夹、代码、图片、文档或纸张,`url` 链接的 `href` 指向已知站点时则改用该站点自己的标记——转写内容常引用的开发者站点(GitHub、GitLab、npm、PyPI、Stack Overflow、MDN、Wikipedia、Hacker News、YouTube、X、Bilibili、知乎、掘金、CSDN),以及主流搜索、视频、社交、购物与参考资料站点(Google、百度、DuckDuckGo、TikTok、Netflix、Spotify、Facebook、Instagram、Reddit、Telegram、WhatsApp、微信、QQ、微博、淘宝、速卖通、eBay、Quora、V2EX、Apple)——`classifyLinkPath` 把共享文件类型折叠进原有六类词汇。`ConnectionIndicator` 可渲染警告色的断联操作(常驻重试图形指明重试动作,断联文案由持有方提供)、与文案使用相同警告色的共享 ongoing loading 加一至三个点以独立于 retry 时序的 500ms 节奏推进的连接中状态,或成功色的恢复状态。点击任一警告状态都会请求立即重连;没有任何悬停交互会改变文案。药丸出现时淡入、卸载前淡出 150ms,宽度随当前 label 自适应。它的持有方提供可见性、恢复驻留时间、本地化 label 与立即重连回调;该原语不使用原生 title tooltip。`useAnchoredMaxHeight` 将底部锚定浮层限制在可见视口内;过大的面板保留近端边距,不会滑出该边缘。portal 模式的 `Menu` 按布局视口限制卡片高度,固定页脚位于内部滚动区域之外;子卡片使用各自的 body portal,父级滚动不会裁剪它们。`HoverCard` 在框架发布的顶部占用量上增加 20px,原生全屏时保留 20px,普通浏览器中沿用自身的最小边距;Line truncated
|
||||
|
||||
`Tooltip` 在悬停或键盘聚焦时读取锚点位置,再根据 `ResizeObserver` 提供的边框盒尺寸调整气泡。首次定位前保持隐藏,优先使用指定方向,再尝试相反方向和垂直于该方向的两侧;只要某一侧容得下,就沿锚点平移而不遮挡锚点。左右放置保留 10px 间距,上下放置使用 `gap`(默认 8px)。宽高限制在视口内并保留 12px 边距;文本自动换行,超出视口高度的内容在固定气泡后可滚动。若所有方向都放不下,则使用稳定的视口内回退位置,可能遮挡锚点。视口尺寸变化会重新读取锚点坐标,标签尺寸变化则复用坐标;定位不会同步测量气泡,也不会触发 React 渲染。 触摸按下会关闭未固定的提示,且不会触发悬停提示,包括触摸后的兼容鼠标事件。只有 `(any-hover: hover)` 表明存在可悬停的输入设备时,鼠标进入才会打开提示,从而排除 iOS 因已点击图标变化而生成的鼠标进入事件。仅有触摸输入的设备仍可使用键盘聚焦提示和显式点击打开的说明。信息按钮可显式启用 `openOnClick`,通过鼠标或触摸点击固定气泡供阅读,并将内容关联为锚点的无障碍描述;再次点击、Escape、Tab 或外部 pointerdown 会关闭。普通操作按钮在触摸点击时直接执行操作,不显示 Tooltip。可选的 `onlyWhenClipped` 只在气泡即将显示时锚点或其内部某个 HTML 元素横向溢出才显示气泡,因此重复被省略号截断文本的标签只在能补充信息时出现。
|
||||
|
||||
|
||||
@@ -92,7 +92,6 @@ export type {
|
||||
export { CODE_HIGHLIGHT_EXTENSIONS, languageForPath, useCodeHighlighter } from './code-highlighting.ts'
|
||||
export type { CodeHighlighter, HighlightSpan } from './code-highlighting.ts'
|
||||
export { relativeTime } from './relative-time.ts'
|
||||
export { rankByName } from './rank-by-name.ts'
|
||||
export { isDarwinDesktop } from './darwin-desktop.ts'
|
||||
export type { RelativeTime, RelativeTimeUnit } from './relative-time.ts'
|
||||
export { JsonTree } from './JsonTree.tsx'
|
||||
|
||||
@@ -1,93 +0,0 @@
|
||||
/**
|
||||
* Shared ranking for `/` menu candidates: the query must be a
|
||||
* case-insensitive ordered subsequence of the candidate name or, when the
|
||||
* candidate carries one, of its display label (a localized title). Prefix
|
||||
* hits rank first, then the strongest alignment score over either key, then
|
||||
* the source order of the input. Decision record:
|
||||
* .agents/notes/archived/feature/2026-08-04-web-slash-command-fuzzy-discovery.md
|
||||
*/
|
||||
|
||||
/** One match with its stable source position. */
|
||||
interface Ranked<T> {
|
||||
readonly item: T
|
||||
readonly index: number
|
||||
readonly prefix: boolean
|
||||
readonly score: number
|
||||
}
|
||||
|
||||
/** Extra weight for name starts and separator boundaries. */
|
||||
function boundaryBonus(name: string, index: number): number {
|
||||
return index === 0 || name.charAt(index - 1) === '-' || name.charAt(index - 1) === '_' ? 8 : 0
|
||||
}
|
||||
|
||||
/**
|
||||
* Score the strongest ordered-subsequence alignment in O(name × query).
|
||||
* Boundary and adjacent matches earn weight; skipped and leading characters
|
||||
* cost weight. Undefined when the query is not a subsequence of the name.
|
||||
*/
|
||||
function alignmentScore(name: string, query: string): number | undefined {
|
||||
if (query.length > name.length) return undefined
|
||||
const noMatch = Number.NEGATIVE_INFINITY
|
||||
let previous = Array<number>(name.length).fill(noMatch)
|
||||
for (let index = 0; index < name.length; index++) {
|
||||
if (name.charAt(index) === query.charAt(0)) previous[index] = 1 + boundaryBonus(name, index) - index
|
||||
}
|
||||
for (let queryIndex = 1; queryIndex < query.length; queryIndex++) {
|
||||
const current = Array<number>(name.length).fill(noMatch)
|
||||
// Sweep the previous row once: `left` is its score one character back
|
||||
// (the adjacent continuation), `leftLeft` two back (the earliest gapped one).
|
||||
let left = noMatch
|
||||
let leftLeft = noMatch
|
||||
let bestGapped = noMatch
|
||||
for (const [index, prior] of previous.entries()) {
|
||||
if (leftLeft !== noMatch) bestGapped = Math.max(bestGapped, leftLeft + index - 2)
|
||||
if (name.charAt(index) === query.charAt(queryIndex)) {
|
||||
const bonus = 1 + boundaryBonus(name, index)
|
||||
let score = noMatch
|
||||
if (left !== noMatch) score = left + bonus + 4
|
||||
if (bestGapped !== noMatch) score = Math.max(score, bestGapped + bonus + 1 - index)
|
||||
current[index] = score
|
||||
}
|
||||
leftLeft = left
|
||||
left = prior
|
||||
}
|
||||
previous = current
|
||||
}
|
||||
let best = noMatch
|
||||
for (const score of previous) best = Math.max(best, score)
|
||||
return best === noMatch ? undefined : best
|
||||
}
|
||||
|
||||
/**
|
||||
* Rank named items by a menu query.
|
||||
* @param items - candidates in source order (a host catalog, then client
|
||||
* contributions); an item's optional `label` is a second search key beside
|
||||
* its name.
|
||||
* @param rawQuery - the text typed after the trigger, matched case-insensitively.
|
||||
* @returns the matching items: prefix hits first, then by alignment score,
|
||||
* then in source order. The input list itself for an empty query.
|
||||
*/
|
||||
export function rankByName<T extends { readonly name: string; readonly label?: string }>(
|
||||
items: readonly T[],
|
||||
rawQuery: string,
|
||||
): readonly T[] {
|
||||
const query = rawQuery.toLowerCase()
|
||||
if (query === '') return items
|
||||
const ranked: Ranked<T>[] = []
|
||||
items.forEach((item, index) => {
|
||||
const keys = item.label === undefined ? [item.name] : [item.name, item.label]
|
||||
let prefix = false
|
||||
let score: number | undefined
|
||||
for (const key of keys) {
|
||||
const lower = key.toLowerCase()
|
||||
const keyScore = alignmentScore(lower, query)
|
||||
if (keyScore === undefined) continue
|
||||
prefix ||= lower.startsWith(query)
|
||||
score = score === undefined ? keyScore : Math.max(score, keyScore)
|
||||
}
|
||||
if (score !== undefined) ranked.push({ item, index, prefix, score })
|
||||
})
|
||||
ranked.sort((left, right) =>
|
||||
Number(right.prefix) - Number(left.prefix) || right.score - left.score || left.index - right.index)
|
||||
return ranked.map(match => match.item)
|
||||
}
|
||||
@@ -1,55 +0,0 @@
|
||||
/**
|
||||
* Shared `/` menu ranker: case-insensitive ordered-subsequence matching,
|
||||
* prefix hits first, alignment score next, source order for ties.
|
||||
*/
|
||||
import { describe, expect, it } from 'vitest'
|
||||
import { rankByName } from '@deepseek-ai/dsh-client-ui-primitives'
|
||||
|
||||
const named = (...names: string[]) => names.map(name => ({ name }))
|
||||
const names = (items: readonly { name: string }[]) => items.map(item => item.name)
|
||||
|
||||
describe('rankByName', () => {
|
||||
it('returns the input list itself for an empty query', () => {
|
||||
const items = named('b', 'a')
|
||||
expect(rankByName(items, '')).toBe(items)
|
||||
})
|
||||
|
||||
it('matches case-insensitive subsequences and ranks prefixes, boundaries, adjacency, gaps, then source order', () => {
|
||||
const items = named('q-xylophone', 'qx-long', 'fabulous', 'foo-bar', 'zuv', 'zu1v', 'yu1v', 'zu12v')
|
||||
expect(names(rankByName(items, 'QX'))).toEqual(['qx-long', 'q-xylophone'])
|
||||
expect(names(rankByName(items, 'fb'))).toEqual(['foo-bar', 'fabulous'])
|
||||
expect(names(rankByName(items, 'uv'))).toEqual(['zuv', 'zu1v', 'yu1v', 'zu12v'])
|
||||
expect(names(rankByName(items, 'zzz'))).toEqual([])
|
||||
expect(names(rankByName(items, 'query-longer-than-every-name'))).toEqual([])
|
||||
})
|
||||
|
||||
it('a prefix hit outranks a stronger non-prefix alignment', () => {
|
||||
// 'z_a_b' aligns both characters on separator boundaries and outscores
|
||||
// every non-prefix rival; a name that starts with the query still wins.
|
||||
expect(names(rankByName(named('z_a_b', 'xabc'), 'ab'))).toEqual(['z_a_b', 'xabc'])
|
||||
expect(names(rankByName(named('z_a_b', 'abc'), 'ab'))).toEqual(['abc', 'z_a_b'])
|
||||
})
|
||||
|
||||
it('takes the stronger of an adjacent and a gapped alignment for the same character', () => {
|
||||
expect(names(rankByName(named('aab', 'ab'), 'ab'))).toEqual(['ab', 'aab'])
|
||||
})
|
||||
|
||||
it('matches the display label as a second key and keeps the stronger alignment', () => {
|
||||
const items = [
|
||||
{ name: 'goal', label: '目标' },
|
||||
{ name: 'plan', label: '计划' },
|
||||
{ name: 'permission', label: '权限' },
|
||||
]
|
||||
expect(names(rankByName(items, '目标'))).toEqual(['goal'])
|
||||
expect(names(rankByName(items, 'goal'))).toEqual(['goal'])
|
||||
expect(names(rankByName(items, 'p'))).toEqual(['plan', 'permission'])
|
||||
expect(names(rankByName(items, '划'))).toEqual(['plan'])
|
||||
// A label prefix hit ranks like a name prefix hit.
|
||||
expect(names(rankByName([{ name: 'xplan', label: 'plan' }, { name: 'plant' }], 'pla'))).toEqual(['xplan', 'plant'])
|
||||
})
|
||||
|
||||
it('returns the ranked items with their payload intact', () => {
|
||||
const items = [{ name: 'goal', description: 'g' }, { name: 'plan', description: 'p' }]
|
||||
expect(rankByName(items, 'pl')).toEqual([{ name: 'plan', description: 'p' }])
|
||||
})
|
||||
})
|
||||
@@ -81,7 +81,8 @@
|
||||
"clsx": "^2.1.1",
|
||||
"@deepseek-ai/cordis": "workspace:~",
|
||||
"react": "^18.2.0",
|
||||
"react-dom": "^18.2.0"
|
||||
"react-dom": "^18.2.0",
|
||||
"@deepseek-ai/dsh-util-text-search": "workspace:*"
|
||||
},
|
||||
"files": [
|
||||
"locale/*.json",
|
||||
|
||||
@@ -4,6 +4,7 @@ import type { ReactNode } from 'react'
|
||||
import clsx from 'clsx'
|
||||
import type { PropsLocale } from '@deepseek-ai/dsh-client-ui-slots'
|
||||
import { IconChevronDownOutlineRegular } from '@deepseek-ai/dsh-client-ui-primitives'
|
||||
import { TextSearchIndex } from '@deepseek-ai/dsh-util-text-search'
|
||||
import { TaskMenu } from './TaskMenu.tsx'
|
||||
import type { TaskMenuEntry } from './TaskMenu.tsx'
|
||||
import { zoneChoices, zoneName } from './schedule-format.ts'
|
||||
@@ -56,10 +57,21 @@ export function RuleZoneRow({ value, disabled, onChange, t }: PropsLocale<'sched
|
||||
}
|
||||
return [...byLabel.values()]
|
||||
}, [value, systemZone, t])
|
||||
const normalized = query.trim().toLocaleLowerCase(t('time.locale'))
|
||||
const matches = catalog.filter(item => `${item.zones.join(' ')} ${item.label}`.toLocaleLowerCase(t('time.locale')).includes(normalized))
|
||||
.map(item => ({ ...item, id: item.zones.find(zone => zone.toLocaleLowerCase(t('time.locale')) === normalized) ?? item.id }))
|
||||
const recentItems = normalized === '' ? recent.flatMap((zone) => {
|
||||
// A row groups zones that share one label. The zone saved is the one the query
|
||||
// names, by the same matching that kept the row; the row's own id wins only
|
||||
// while the query names it or names no zone at all. The label answers query
|
||||
// terms that name no zone, such as a localized city name.
|
||||
const rowIndex = useMemo(() => new TextSearchIndex(
|
||||
catalog.map(item => ({ item, zones: new TextSearchIndex(item.zones, zone => ({ fuzzy: [zone, item.label] })) })),
|
||||
({ item }) => ({ fuzzy: [...item.zones, item.label] }),
|
||||
), [catalog])
|
||||
const searching = query.trim() !== ''
|
||||
const matches = rowIndex.search(query).map(({ item, zones }) => {
|
||||
if (!searching) return item
|
||||
const named = zones.search(query)
|
||||
return { ...item, id: named.includes(item.id) ? item.id : named[0] ?? item.id }
|
||||
})
|
||||
const recentItems = !searching ? recent.flatMap((zone) => {
|
||||
const item = catalog.find(item => item.zones.includes(zone))
|
||||
return item === undefined ? [] : [{ ...item, id: zone }]
|
||||
}).filter((item, index, items) => items.findIndex(candidate => candidate.label === item.label) === index) : []
|
||||
|
||||
@@ -12,6 +12,7 @@ import type { ScheduleId, ScheduleCatalogEntry, ScheduleCreateRequest } from '@d
|
||||
import type { TaskCreateOutcome } from './TaskDetail.tsx'
|
||||
import type { TaskEditorStoreProps } from './editor-store.ts'
|
||||
import { taskNextRunAt, taskSessionId } from './task-record.ts'
|
||||
import { TextSearchIndex } from '@deepseek-ai/dsh-util-text-search'
|
||||
import type { CatalogSnapshot } from './catalog-source.ts'
|
||||
import { CatalogFeedback } from './CatalogFeedback.tsx'
|
||||
import { TaskDetail, useTaskDetail, type TaskDetailInjected } from './TaskDetail.tsx'
|
||||
@@ -93,16 +94,12 @@ export function TaskManagerPage(props: TaskManagerPageProps) {
|
||||
() => records.filter(record => record.status === 'ended').length,
|
||||
[records],
|
||||
)
|
||||
const rows = useMemo(() => {
|
||||
const query = search.trim().toLowerCase()
|
||||
return records.filter(record => (
|
||||
(statusFilter === 'all' || record.status === statusFilter)
|
||||
&& (record.prompt.toLowerCase().includes(query)
|
||||
|| (taskSessionId(record) ?? '').toLowerCase().includes(query)
|
||||
|| taskName(record).toLowerCase().includes(query))
|
||||
)).toSorted((left, right) =>
|
||||
Date.parse(taskNextRunAt(left)) - Date.parse(taskNextRunAt(right)))
|
||||
}, [records, search, statusFilter])
|
||||
const rowIndex = useMemo(() => new TextSearchIndex(
|
||||
records.filter(record => statusFilter === 'all' || record.status === statusFilter)
|
||||
.toSorted((left, right) => Date.parse(taskNextRunAt(left)) - Date.parse(taskNextRunAt(right))),
|
||||
record => ({ fuzzy: [taskName(record)], substring: [taskSessionId(record), record.prompt] }),
|
||||
), [records, statusFilter])
|
||||
const rows = useMemo(() => rowIndex.search(search), [rowIndex, search])
|
||||
|
||||
const emptyTitle = search.trim() !== '' ? 'list.noMatches'
|
||||
: statusFilter === 'paused' ? 'list.emptyPaused'
|
||||
|
||||
@@ -1624,6 +1624,38 @@ describe('time zone menu', () => {
|
||||
expectSavedRule(h, 'DTSTART;TZID=Europe/Bucharest:20990101T090000\nRRULE:FREQ=WEEKLY;INTERVAL=1;BYDAY=MO,WE')
|
||||
})
|
||||
|
||||
it("keeps the row's own zone when a search names several zones of the row or none alone", () => {
|
||||
pinSystemZone('UTC')
|
||||
vi.mocked(Intl.supportedValuesOf).mockReturnValue(['Europe/Athens', 'Europe/Bucharest'])
|
||||
// The stored zone makes Bucharest the shared row's own zone, while Athens is the row's first zone.
|
||||
mount([{ ...task, rrule: task.rrule.replace('TZID=UTC', 'TZID=Europe/Bucharest') }])
|
||||
const detail = openEdit()
|
||||
// `eur` names both zones; `athens bucharest` names neither zone with both terms.
|
||||
for (const query of ['eur', 'athens bucharest']) {
|
||||
openZones(detail)
|
||||
searchZones(query)
|
||||
fireEvent.click(screen.getByRole('menuitem', { name: zoneName('Europe/Bucharest', 'UTC', t) }))
|
||||
expect((JSON.parse(localStorage.getItem(RECENT)!) as string[])[0]).toBe('Europe/Bucharest')
|
||||
}
|
||||
})
|
||||
|
||||
it('saves the zone a fuzzy or full-width search names inside a shared row', async () => {
|
||||
pinSystemZone('UTC')
|
||||
vi.mocked(Intl.supportedValuesOf).mockReturnValue(['Europe/Athens', 'Europe/Bucharest'])
|
||||
expect(zoneName('Europe/Bucharest', 'UTC', t)).toContain('European')
|
||||
// The last query's second term matches only the shared label, not a zone id.
|
||||
for (const query of ['bchrst', 'BUCHAREST', 'bucharest european']) {
|
||||
const h = mount()
|
||||
const detail = openEdit()
|
||||
openZones(detail)
|
||||
searchZones(query)
|
||||
fireEvent.click(screen.getByRole('menuitem', { name: zoneName('Europe/Bucharest', 'UTC', t) }))
|
||||
await save(detail)
|
||||
expectSavedRule(h, 'DTSTART;TZID=Europe/Bucharest:20990101T090000\nRRULE:FREQ=WEEKLY;INTERVAL=1;BYDAY=MO,WE')
|
||||
cleanup()
|
||||
}
|
||||
})
|
||||
|
||||
it('offers the system zone alone without a separator and says when no zone matches', () => {
|
||||
pinSystemZone('UTC')
|
||||
mount()
|
||||
|
||||
@@ -706,6 +706,11 @@ describe('Task manager catalog', () => {
|
||||
expect(taskNames()).toEqual([])
|
||||
fireEvent.change(input, { target: { value: 'numbers' } })
|
||||
expect(taskNames()).toEqual(['Quarterly report'])
|
||||
// Names match fuzzily; the long instruction matches only contiguous text.
|
||||
fireEvent.change(input, { target: { value: 'qrtly' } })
|
||||
expect(taskNames()).toEqual(['Quarterly report'])
|
||||
fireEvent.change(input, { target: { value: 'sndnum' } })
|
||||
expect(taskNames()).toEqual([])
|
||||
})
|
||||
|
||||
it('combines search with the status filter and keeps both behind the empty state action', () => {
|
||||
|
||||
@@ -8,6 +8,9 @@
|
||||
"src"
|
||||
],
|
||||
"references": [
|
||||
{
|
||||
"path": "../../util/text-search"
|
||||
},
|
||||
{
|
||||
"path": "../../api/session-controller/tsconfig.client.json"
|
||||
},
|
||||
|
||||
@@ -58,7 +58,8 @@
|
||||
"@deepseek-ai/dsh-client-ui-renderer": "workspace:*",
|
||||
"@deepseek-ai/dsh-util-values": "workspace:*",
|
||||
"@deepseek-ai/dsh-remote-mock": "workspace:*",
|
||||
"@deepseek-ai/dsh-client-product-analytics": "workspace:*"
|
||||
"@deepseek-ai/dsh-client-product-analytics": "workspace:*",
|
||||
"@deepseek-ai/dsh-util-text-search": "workspace:*"
|
||||
},
|
||||
"dependencies": {
|
||||
"@deepseek-ai/schemastery": "workspace:~"
|
||||
|
||||
@@ -22,6 +22,7 @@ import { useEffect, useMemo, useState } from 'react'
|
||||
import type { ReactNode } from 'react'
|
||||
import type { LlmDiscoveredModel } from '@deepseek-ai/dsh-api-remotes/client'
|
||||
import { AnimatedRows, Button, IconPlusOutlineRegular, Modal } from '@deepseek-ai/dsh-client-ui-primitives'
|
||||
import { TextSearchIndex } from '@deepseek-ai/dsh-util-text-search'
|
||||
import { formatCapacity, parseCapacity } from './DeepSeekModelsEditor.tsx'
|
||||
import type { ModelsOperations } from './operations.ts'
|
||||
import type { DeepSeekModelDraft } from './DeepSeekModelsEditor.tsx'
|
||||
@@ -251,6 +252,10 @@ export function ModelListEditor(props: ModelListEditorProps): ReactNode {
|
||||
const isPicked = (id: string): boolean => pickedByDefault(id) !== flipped.has(id)
|
||||
|
||||
const activeCandidates = candidates ?? []
|
||||
const candidateIndex = useMemo(
|
||||
() => new TextSearchIndex(candidates ?? [], candidate => ({ fuzzy: [candidate.id, candidate.name] })),
|
||||
[candidates],
|
||||
)
|
||||
const listed = new Set(activeCandidates.map(candidate => candidate.id))
|
||||
// An unchecked candidate leaves the list. A row the listing does not name,
|
||||
// including a half-typed row without an id, is outside the picker and stays.
|
||||
@@ -283,11 +288,7 @@ export function ModelListEditor(props: ModelListEditorProps): ReactNode {
|
||||
})
|
||||
}
|
||||
|
||||
const normalizedCandidateQuery = candidateQuery.trim().toLowerCase()
|
||||
const visibleCandidates = normalizedCandidateQuery.length === 0
|
||||
? activeCandidates
|
||||
: activeCandidates.filter(candidate => candidate.id.toLowerCase().includes(normalizedCandidateQuery)
|
||||
|| candidate.name?.toLowerCase().includes(normalizedCandidateQuery) === true)
|
||||
const visibleCandidates = candidateIndex.search(candidateQuery)
|
||||
const allVisibleCandidatesPicked = visibleCandidates.length > 0
|
||||
&& visibleCandidates.every(candidate => isPicked(candidate.id))
|
||||
|
||||
|
||||
@@ -8,6 +8,9 @@
|
||||
"src"
|
||||
],
|
||||
"references": [
|
||||
{
|
||||
"path": "../../util/text-search"
|
||||
},
|
||||
{
|
||||
"path": "../../host/webserver"
|
||||
},
|
||||
|
||||
@@ -18,8 +18,8 @@
|
||||
en: 67637808e7940157
|
||||
zh: d4d0716ea4d33e4a
|
||||
/deepseek-ai-dsh-client-ui-settings-plugin-inventory/use-this-package/reading-a-card:
|
||||
en: 3cb7d3a63d5c0fea
|
||||
zh: d127dfbb58e50e4b
|
||||
en: 23f533442ed22d44
|
||||
zh: f2ac59b57878aed1
|
||||
/deepseek-ai-dsh-client-ui-settings-plugin-inventory/use-this-package/the-preset-switcher:
|
||||
en: 84e5938329199a22
|
||||
zh: 6f5cfaac56433e8b
|
||||
|
||||
@@ -33,7 +33,7 @@ A failed installation with pending pnpm build permissions offers **Allow these s
|
||||
|
||||
Each collapsed card uses the plugin's localized title and description when available; a description shows at most two lines until its card is expanded. Settings shortens literal package-name or module-name fallbacks by removing the npm scope and the `cordis:`, `cordis-plugin-`, or `dsh-`/`dsh-host-`/`dsh-client-` prefix; locale titles remain unchanged. The Host supplies locale and package-field fallbacks in `meta`; the Client selects the current language. Full module specifiers remain available in details and search. Missing descriptions are omitted, and metadata diagnostics appear with the card. This compact naming applies only to Settings, not the sidebar's Plugins page.
|
||||
|
||||
A small enablement tag marks only the states that differ from plainly enabled: disabled, conditional, provided by presets, and failed; a plainly enabled row carries no tag. A colored root-fiber status dot marks the live phases no tag states: `pending` maps to idle, while `loading` and `unloading` map to ongoing; an `active` or `failed` fiber shows no dot. The stable entry id appears in a code chip at the card's bottom-left, in line with the title, only when it differs from the title: a composition-generated id drops its leading `include:` marker there, and an id that then repeats the title is omitted. Whenever the chip shows, its hover text and the card's accessible name carry the complete id; search and expanded details always retain it. Long entry ids truncate in the chip and remain available on hover. Expanding one card reveals its full description, the declared entry id, the full module specifier, and the state facts: a preset row names the preset it comes from, its runtime status when the composition is live, and its disable condition when it carries one; a preset-provided global row explains that agent presets provide it per session, names the presets that enable it. Preset names resolve through the shared `presetDisplayText` fold (`dsh-agent-preset-registry/display`) over [`ui-agent-preset`](../ui-agent-preset/README.md)'s dictionaries: shipped presets follow the active locale while user-authored ones keep their own metadata, so an English surface never echoes the preset declarations' Chinese names. Search filters both groups by localized title and description, module name, and entry id.
|
||||
A small enablement tag marks only the states that differ from plainly enabled: disabled, conditional, provided by presets, and failed; a plainly enabled row carries no tag. A colored root-fiber status dot marks the live phases no tag states: `pending` maps to idle, while `loading` and `unloading` map to ongoing; an `active` or `failed` fiber shows no dot. The stable entry id appears in a code chip at the card's bottom-left, in line with the title, only when it differs from the title: a composition-generated id drops its leading `include:` marker there, and an id that then repeats the title is omitted. Whenever the chip shows, its hover text and the card's accessible name carry the complete id; search and expanded details always retain it. Long entry ids truncate in the chip and remain available on hover. Expanding one card reveals its full description, the declared entry id, the full module specifier, and the state facts: a preset row names the preset it comes from, its runtime status when the composition is live, and its disable condition when it carries one; a preset-provided global row explains that agent presets provide it per session, names the presets that enable it. Preset names resolve through the shared `presetDisplayText` fold (`dsh-agent-preset-registry/display`) over [`ui-agent-preset`](../ui-agent-preset/README.md)'s dictionaries: shipped presets follow the active locale while user-authored ones keep their own metadata, so an English surface never echoes the preset declarations' Chinese names. Search filters both groups through the shared [text search](../../util/text-search/README.md): module name, entry id, and every declared language of the title match fuzzily, and every language of the description matches as a substring.
|
||||
|
||||
A card paints its hover surface only where the pointer can hover: a tap answers with the pressed fill, and an expanded card keeps its open surface on every device. The search field takes a 16px face under a coarse pointer, so iOS Safari does not zoom the page for a focused field.
|
||||
|
||||
|
||||
@@ -33,7 +33,7 @@ kind: "package-reference"
|
||||
|
||||
每张收起的卡片使用插件可用的本地化标题与描述;描述最多显示两行,展开卡片后显示全文。设置页会缩短字面的包名或模块名回退值,移除 npm scope 以及 `cordis:`、`cordis-plugin-` 或 `dsh-`/`dsh-host-`/`dsh-client-` 前缀;locale 标题保持原样。Host 在 `meta` 中提供 locale 与包字段的回退结果,Client 选择当前语言。详情与搜索仍保留完整模块标识。缺失的描述不显示,元信息诊断随卡片展示。这种短名显示仅用于设置页,不影响侧栏的插件页。
|
||||
|
||||
表示启停状态的小标签只标记与普通启用不同的状态:已停用、条件启用、由预设提供与启动失败;普通启用的行不带标签。彩色根 fiber 状态圆点标记没有标签表达的存活阶段:`pending` 映射为 idle,`loading` 与 `unloading` 映射为 ongoing;`active` 或 `failed` fiber 不显示圆点。稳定的条目 id 仅在与标题不同时显示,位于卡片左下角的代码标签中,与标题左对齐:组合生成的 id 在此省略开头的 `include:` 标记,省略后与标题相同的 id 不再重复显示。显示代码标签时,其悬停提示与卡片的无障碍名称带完整 id;搜索与展开详情始终保留完整 id。长条目 id 会在代码标签内截断,悬停时仍可查看完整值。展开卡片后会显示完整描述、声明的条目 id、完整模块标识与状态事实:预设行说明它来自哪个预设、组合存活时的运行状态,以及它携带的禁用条件;被预设提供的全局行说明它由 Agent 预设按会话提供、列出启用它的预设。预设名经共享的 `presetDisplayText` 纯函数(`dsh-agent-preset-registry/display`)叠在 [`ui-agent-preset`](../ui-agent-preset/README.zh.md) 的字典上解析:内置预设走当前语言,用户自建预设保留自己的元数据,因此英文界面不会回显预设声明里的中文名。搜索按本地化标题与描述、模块名称及条目 id 过滤两组。
|
||||
表示启停状态的小标签只标记与普通启用不同的状态:已停用、条件启用、由预设提供与启动失败;普通启用的行不带标签。彩色根 fiber 状态圆点标记没有标签表达的存活阶段:`pending` 映射为 idle,`loading` 与 `unloading` 映射为 ongoing;`active` 或 `failed` fiber 不显示圆点。稳定的条目 id 仅在与标题不同时显示,位于卡片左下角的代码标签中,与标题左对齐:组合生成的 id 在此省略开头的 `include:` 标记,省略后与标题相同的 id 不再重复显示。显示代码标签时,其悬停提示与卡片的无障碍名称带完整 id;搜索与展开详情始终保留完整 id。长条目 id 会在代码标签内截断,悬停时仍可查看完整值。展开卡片后会显示完整描述、声明的条目 id、完整模块标识与状态事实:预设行说明它来自哪个预设、组合存活时的运行状态,以及它携带的禁用条件;被预设提供的全局行说明它由 Agent 预设按会话提供、列出启用它的预设。预设名经共享的 `presetDisplayText` 纯函数(`dsh-agent-preset-registry/display`)叠在 [`ui-agent-preset`](../ui-agent-preset/README.zh.md) 的字典上解析:内置预设走当前语言,用户自建预设保留自己的元数据,因此英文界面不会回显预设声明里的中文名。搜索通过共享的[文本搜索](../../util/text-search/README.zh.md)过滤两组:模块名称、条目 id 和标题的所有声明语言模糊匹配,描述的所有语言按子串匹配。
|
||||
|
||||
卡片只在可悬停的指针下绘制悬停底色:点按以按下填充回馈,展开的卡片在任何设备上保持展开底色。搜索框在粗指针下使用 16px 字号,iOS Safari 不会因聚焦而放大页面。
|
||||
|
||||
|
||||
@@ -62,7 +62,8 @@
|
||||
"@deepseek-ai/dsh-client-ui-renderer": "workspace:*",
|
||||
"@deepseek-ai/dsh-agent-preset-registry": "workspace:*",
|
||||
"@deepseek-ai/dsh-client-modules": "workspace:*",
|
||||
"@deepseek-ai/dsh-client-store": "workspace:*"
|
||||
"@deepseek-ai/dsh-client-store": "workspace:*",
|
||||
"@deepseek-ai/dsh-util-text-search": "workspace:*"
|
||||
},
|
||||
"files": [
|
||||
"locale/*.json",
|
||||
|
||||
+30
-24
@@ -12,6 +12,7 @@ import {
|
||||
} from '@deepseek-ai/dsh-client-ui-primitives'
|
||||
import type { StateDotState, TagTone } from '@deepseek-ai/dsh-client-ui-primitives'
|
||||
import type { InjectFace, PropsLocale, PropsRuntime } from '@deepseek-ai/dsh-client-ui-slots'
|
||||
import { localizedValues, TextSearchIndex, type SearchKeys } from '@deepseek-ai/dsh-util-text-search'
|
||||
import type { PluginInventoryLocaleKey } from './locales.ts'
|
||||
import css from './PluginInventorySettingsTab.module.css'
|
||||
|
||||
@@ -99,12 +100,12 @@ function pluginText(row: PluginInventoryEntry | AgentPresetRow, resolveText: Plu
|
||||
}
|
||||
}
|
||||
|
||||
/** Match translated text alongside the row's technical module and entry identities. */
|
||||
function matches(row: PluginInventoryEntry | AgentPresetRow, normalizedQuery: string, resolveText: PluginInventorySettingsTabInjected['resolveText']): boolean {
|
||||
if (normalizedQuery.length === 0) return true
|
||||
const { title, description } = pluginText(row, resolveText)
|
||||
return [row.moduleName, row.entryId, title, description]
|
||||
.some(value => value?.toLocaleLowerCase().includes(normalizedQuery))
|
||||
/** Search text of one row: its module and entry identities and every language of its title and description. */
|
||||
function searchKeys(row: PluginInventoryEntry | AgentPresetRow): SearchKeys {
|
||||
return {
|
||||
fuzzy: [row.moduleName, row.entryId ?? undefined, ...localizedValues(row.meta?.title)],
|
||||
substring: localizedValues(row.meta?.description),
|
||||
}
|
||||
}
|
||||
|
||||
/** The roster row shown when the preset switcher has no explicit choice. */
|
||||
@@ -272,8 +273,7 @@ export function PluginInventorySettingsTab(
|
||||
return () => { current = false }
|
||||
}, [list, request])
|
||||
|
||||
const normalizedQuery = query.trim().toLocaleLowerCase()
|
||||
const searching = normalizedQuery.length > 0
|
||||
const searching = query.trim().length > 0
|
||||
const snapshot = state.status === 'ready' ? state.snapshot : undefined
|
||||
const presets = snapshot?.agentPresets ?? []
|
||||
const selected = presets.find(preset => preset.id === chosenPreset) ?? fallbackPreset(presets)
|
||||
@@ -293,24 +293,30 @@ export function PluginInventorySettingsTab(
|
||||
}, [presets])
|
||||
|
||||
const entries = snapshot?.entries ?? []
|
||||
const failedEntries: PluginInventoryEntry[] = []
|
||||
const regularEntries: PluginInventoryEntry[] = []
|
||||
for (const entry of entries) {
|
||||
if (entry.fiberPhase === 'failed') failedEntries.push(entry)
|
||||
else regularEntries.push(entry)
|
||||
}
|
||||
|
||||
const entryMatch = (entry: PluginInventoryEntry): boolean => matches(entry, normalizedQuery, resolveText)
|
||||
const rowMatch = (row: AgentPresetRow): boolean => matches(row, normalizedQuery, resolveText)
|
||||
const filteredFailed = failedEntries.filter(entryMatch)
|
||||
const filteredRegular = regularEntries.filter(entryMatch)
|
||||
// One index per list, built when the snapshot changes; typing only searches them.
|
||||
const indexes = useMemo(() => {
|
||||
const failed: PluginInventoryEntry[] = []
|
||||
const regular: PluginInventoryEntry[] = []
|
||||
for (const entry of snapshot?.entries ?? []) {
|
||||
if (entry.fiberPhase === 'failed') failed.push(entry)
|
||||
else regular.push(entry)
|
||||
}
|
||||
return {
|
||||
failed: new TextSearchIndex(failed, searchKeys),
|
||||
regular: new TextSearchIndex(regular, searchKeys),
|
||||
presets: (snapshot?.agentPresets ?? []).map(preset => ({ preset, index: new TextSearchIndex(preset.rows, searchKeys) })),
|
||||
}
|
||||
}, [snapshot])
|
||||
const filteredFailed = indexes.failed.search(query)
|
||||
const filteredRegular = indexes.regular.search(query)
|
||||
const globalCount = filteredFailed.length + filteredRegular.length
|
||||
const selectedRows = selected === undefined ? [] : selected.rows.filter(rowMatch)
|
||||
const otherPresetMatches = searching
|
||||
? presets.filter(preset => preset !== selected && preset.rows.some(rowMatch))
|
||||
const selectedRows = indexes.presets.find(({ preset }) => preset === selected)?.index.search(query) ?? []
|
||||
const otherMatches = searching
|
||||
? indexes.presets.flatMap(({ preset, index }) => preset === selected ? [] : [{ preset, count: index.search(query).length }])
|
||||
.filter(match => match.count > 0)
|
||||
: []
|
||||
const otherMatchCount = otherPresetMatches
|
||||
.reduce((total, preset) => total + preset.rows.filter(rowMatch).length, 0)
|
||||
const otherPresetMatches = otherMatches.map(match => match.preset)
|
||||
const otherMatchCount = otherMatches.reduce((total, match) => total + match.count, 0)
|
||||
|
||||
// The preset group starts open and the larger global plane folded; a search opens both for as long as it lasts.
|
||||
const presetEffectiveOpen = searching || (presetOpen ?? true)
|
||||
|
||||
@@ -228,8 +228,12 @@ describe('PluginInventorySettingsTab', () => {
|
||||
fireEvent.change(search, { target: { value: '运行会话命令' } })
|
||||
expect(screen.getAllByRole('listitem')).toHaveLength(1)
|
||||
expect(screen.getByRole('button', { name: '会话执行器, include:preset-runner, 已启用' })).toBeTruthy()
|
||||
// The Chinese page still finds the row by its English description.
|
||||
fireEvent.change(search, { target: { value: 'Run per session' } })
|
||||
expect(screen.getByRole('button', { name: '会话执行器, include:preset-runner, 已启用' })).toBeTruthy()
|
||||
fireEvent.change(search, { target: { value: 'no such plugin' } })
|
||||
expect(screen.getByText(zh.emptySearch)).toBeTruthy()
|
||||
fireEvent.change(search, { target: { value: 'Run per session' } })
|
||||
locale.setLocale('en')
|
||||
view.rerender(<PluginInventorySettingsTab {...pageProps} />)
|
||||
expect(screen.getByRole('button', { name: 'Session runner, include:preset-runner, Enabled' })).toBeTruthy()
|
||||
@@ -288,7 +292,9 @@ describe('PluginInventorySettingsTab', () => {
|
||||
expect(screen.getAllByRole('listitem')).toHaveLength(1)
|
||||
locale.setLocale('en')
|
||||
view.rerender(<PluginInventorySettingsTab {...pageProps} />)
|
||||
expect(screen.getByText(en.emptySearch)).toBeTruthy()
|
||||
// The English page still finds the row by its Chinese description, shown in English.
|
||||
expect(screen.getAllByRole('listitem')).toHaveLength(1)
|
||||
expect(screen.queryByText('中文主题说明。')).toBeNull()
|
||||
fireEvent.change(screen.getByRole('searchbox', { name: en.search }), { target: { value: '@acme/dsh-theme/client' } })
|
||||
expect(screen.getAllByRole('listitem')).toHaveLength(1)
|
||||
expect(screen.getByRole('button', { name: '@acme/dsh-theme, include:theme, Enabled' }).getAttribute('aria-describedby')).toBeNull()
|
||||
|
||||
@@ -8,6 +8,9 @@
|
||||
"src"
|
||||
],
|
||||
"references": [
|
||||
{
|
||||
"path": "../../util/text-search"
|
||||
},
|
||||
{
|
||||
"path": "../../util/package-manifest"
|
||||
},
|
||||
|
||||
@@ -58,7 +58,8 @@
|
||||
"@deepseek-ai/dsh-brand": "workspace:*",
|
||||
"clsx": "^2.1.1",
|
||||
"react": "^18.2.0",
|
||||
"@deepseek-ai/dsh-client-test-runtime": "workspace:*"
|
||||
"@deepseek-ai/dsh-client-test-runtime": "workspace:*",
|
||||
"@deepseek-ai/dsh-util-text-search": "workspace:*"
|
||||
},
|
||||
"files": [
|
||||
"locale/*.json",
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
/** Searchable editable shortcut reference and its General Settings row. */
|
||||
import { useCallback, useEffect, useLayoutEffect, useRef, useState } from 'react'
|
||||
import { Button, IconCloseOutlineRegular, IconRefreshOutlineRegular, Modal, ShortcutKeys, Tooltip, Toast, focusWithoutRing, isBehindModal, rankByName } from '@deepseek-ai/dsh-client-ui-primitives'
|
||||
import { useCallback, useEffect, useLayoutEffect, useMemo, useRef, useState } from 'react'
|
||||
import { Button, IconCloseOutlineRegular, IconRefreshOutlineRegular, Modal, ShortcutKeys, Tooltip, Toast, focusWithoutRing, isBehindModal } from '@deepseek-ai/dsh-client-ui-primitives'
|
||||
import { TextSearchIndex } from '@deepseek-ai/dsh-util-text-search'
|
||||
import type { InjectFace, PropsLocale, PropsRuntime } from '@deepseek-ai/dsh-client-ui-slots'
|
||||
import type { ObservableSnapshot, PropsStore } from '@deepseek-ai/dsh-client-store'
|
||||
import type { ShortcutCatalogEntry, ShortcutPlatform, Shortcuts } from '@deepseek-ai/dsh-client-shortcuts/client'
|
||||
@@ -133,7 +134,7 @@ export function ShortcutReference({
|
||||
if (open && input !== null && !isBehindModal(input)) focusWithoutRing(input)
|
||||
}, [open, focusRequest])
|
||||
// Stop stays after the other fixed input actions.
|
||||
const entries = [
|
||||
const entryIndex = useMemo(() => new TextSearchIndex([
|
||||
...catalog.map(row => ({
|
||||
...row,
|
||||
names: [...row.aliases, row.keys.filter(key => key !== '+').join('+'), row.keys.filter(key => key !== '+').join(''), row.aria ?? '', row.aria?.replace('Meta', 'Cmd') ?? ''],
|
||||
@@ -142,9 +143,8 @@ export function ShortcutReference({
|
||||
...fixedCatalog.map(row => ({ ...row, names: [row.id, row.keys.join(' ')] })),
|
||||
].sort((left, right) => Number(left.id === 'response.stop') - Number(right.id === 'response.stop')
|
||||
|| (coreActionOrder.get(left.id) ?? coreActionOrder.size) - (coreActionOrder.get(right.id) ?? coreActionOrder.size)
|
||||
|| Number(left.id > right.id) - Number(left.id < right.id))
|
||||
const ranked = rankByName(entries.flatMap(row => row.names.map(name => ({ name, label: row.label, row }))), query.trim())
|
||||
const matches = [...new Set(ranked.map(match => match.row))]
|
||||
|| Number(left.id > right.id) - Number(left.id < right.id)), row => ({ fuzzy: [row.label, ...row.names] })), [catalog, fixedCatalog])
|
||||
const matches = entryIndex.search(query)
|
||||
const modifiedCount = Object.keys(config.document.profiles[`${runtime}:${platform}`] ?? {}).length
|
||||
useLayoutEffect(() => {
|
||||
const input = search.current
|
||||
|
||||
@@ -8,6 +8,9 @@
|
||||
"src"
|
||||
],
|
||||
"references": [
|
||||
{
|
||||
"path": "../../util/text-search"
|
||||
},
|
||||
{
|
||||
"path": "../../../vendor/cordis"
|
||||
},
|
||||
|
||||
@@ -18,8 +18,8 @@
|
||||
en: 2f17d0875048ef3c
|
||||
zh: 6878ee4c75f2b2cf
|
||||
/deepseek-ai-dsh-client-ui-skill/use-this-package/what-the-source-offers:
|
||||
en: 2ba1a6158c85b46e
|
||||
zh: 9ab58ceef8743849
|
||||
en: fa23ec0de0463e30
|
||||
zh: 1772d637d96843b6
|
||||
/deepseek-ai-dsh-client-ui-skill/use-this-package/the-skill-tool-row:
|
||||
en: 270bc37a226ed247
|
||||
zh: 15a1c4c82c3a1f00
|
||||
|
||||
@@ -29,7 +29,7 @@ Type `/` in the composer and pick a skill from the suggestions, or type `/name`
|
||||
|
||||
### What the source offers
|
||||
|
||||
Ordinary-session candidates come from the `skills/list` Remote; the host serves every user-invocable skill, and a `modelInvocable: false` entry (a `disable-model-invocation` skill, whose only entry point is this path) wears the user-only marker as a description prefix in the active language. Results rank through the `/` menu's shared name ranker, `rankByName` from ui-primitives: the query matches a case-insensitive ordered subsequence of the skill name, prefix hits rank first, and ties keep the host order ([ranking decision](../../../.agents/notes/archived/feature/2026-08-04-web-slash-command-fuzzy-discovery.md)). A failed `skills/list` call is logged and folded into a silent menu-group drop — the menu shows only pending/ready states.
|
||||
Ordinary-session candidates come from the `skills/list` Remote; the host serves every user-invocable skill, and a `modelInvocable: false` entry (a `disable-model-invocation` skill, whose only entry point is this path) wears the user-only marker as a description prefix in the active language. Results filter through the same [text search](../../util/text-search/README.md) as the command group: the skill name matches fuzzily and ties keep the host order. Descriptions do not match, because the `/` menu highlights its first row across all groups and a description hit in an earlier group would take Enter from the skill the user named. A failed `skills/list` call is logged and folded into a silent menu-group drop — the menu shows only pending/ready states.
|
||||
|
||||
### The skill tool row
|
||||
|
||||
|
||||
@@ -29,7 +29,7 @@ kind: "package-reference"
|
||||
|
||||
### source 提供什么
|
||||
|
||||
普通会话的候选来自 `skills/list` Remote;宿主提供每一个用户可调用的 skill,`modelInvocable: false` 的条目(即 `disable-model-invocation` skill,此路径是其唯一入口)会以当前语言把仅限用户标记作为描述前缀带上。结果经 `/` 菜单共享的名字排序器(ui-primitives 的 `rankByName`)排名:查询作为不区分大小写的有序子序列匹配 skill 名,前缀命中排最前,同分保持宿主顺序([排名决策](../../../.agents/notes/archived/feature/2026-08-04-web-slash-command-fuzzy-discovery.md))。`skills/list` 调用失败时会被记录并静默丢弃该菜单组——菜单只显示 pending/ready 状态。
|
||||
普通会话的候选来自 `skills/list` Remote;宿主提供每一个用户可调用的 skill,`modelInvocable: false` 的条目(即 `disable-model-invocation` skill,此路径是其唯一入口)会以当前语言把仅限用户标记作为描述前缀带上。结果与命令组使用同一套[文本搜索](../../util/text-search/README.zh.md)筛选:skill 名称按模糊匹配,得分相同的结果保持宿主给出的顺序。描述不参与匹配,因为 `/` 菜单高亮的是所有分组合在一起的第一行;如果较前分组中有描述命中,Enter 会选中这一行,而不是用户输入名称对应的 skill。`skills/list` 调用失败时会被记录并静默丢弃该菜单组——菜单只显示 pending/ready 状态。
|
||||
|
||||
### skill 工具行
|
||||
|
||||
|
||||
@@ -69,7 +69,8 @@
|
||||
"react-dom": "^18.2.0",
|
||||
"@deepseek-ai/dsh-client-ui-sidebar-right": "workspace:*",
|
||||
"@deepseek-ai/dsh-util-values": "workspace:*",
|
||||
"@deepseek-ai/dsh-util-workspace-path": "workspace:*"
|
||||
"@deepseek-ai/dsh-util-workspace-path": "workspace:*",
|
||||
"@deepseek-ai/dsh-util-text-search": "workspace:*"
|
||||
},
|
||||
"files": [
|
||||
"locale/*.json",
|
||||
|
||||
@@ -42,7 +42,7 @@ import type {} from '@deepseek-ai/dsh-plugin-manager/types'
|
||||
import type { SessionId } from '@deepseek-ai/dsh-session/types'
|
||||
import type { InputTriggerServiceContract, InputTriggerSource } from '@deepseek-ai/dsh-client-ui-input-trigger/client'
|
||||
import { fileAddressFor } from '@deepseek-ai/dsh-util-workspace-path'
|
||||
import { rankByName } from '@deepseek-ai/dsh-client-ui-primitives'
|
||||
import { TextSearchIndex } from '@deepseek-ai/dsh-util-text-search'
|
||||
// Type-only: pulls the locale plugin's Context merge (ctx.locale).
|
||||
import type {} from '@deepseek-ai/dsh-client-locale/client'
|
||||
// Type-only: pulls the SlotRegistry service merge (ctx.slots).
|
||||
@@ -173,9 +173,8 @@ export function apply(ctx: ClientContext): void {
|
||||
const skills = await fetchCatalog(session.sessionId).promise
|
||||
// Superseded keystroke: the shared fetch stays warm, this caller yields.
|
||||
if (signal.aborted) return []
|
||||
// The same ranking as the command group of this menu: case-insensitive
|
||||
// ordered subsequence, prefix hits first.
|
||||
return rankByName(skills, query)
|
||||
// The same filter as the command group of this menu, over names only.
|
||||
return new TextSearchIndex(skills, skill => ({ fuzzy: [skill.name] })).search(query)
|
||||
.map(skill => ({
|
||||
name: skill.name,
|
||||
// The user-only marker rides the description (the menu's only
|
||||
|
||||
@@ -260,7 +260,7 @@ describe('candidates: sessionId addressing', () => {
|
||||
}
|
||||
})
|
||||
|
||||
it('lists via {sessionId} and ranks case-insensitive subsequence matches with prefixes first', async () => {
|
||||
it('lists via {sessionId} and ranks prefix, substring, then fuzzy name matches', async () => {
|
||||
const { list, payloads } = countingList()
|
||||
const { source } = await bench(list)
|
||||
const items = await source.candidates(proj('s1'), req('co'))
|
||||
@@ -271,10 +271,12 @@ describe('candidates: sessionId addressing', () => {
|
||||
{ name: 'code-review', description: 'review flow' },
|
||||
])
|
||||
const names = async (query: string) => (await source.candidates(proj('s1'), req(query))).map(c => c.name)
|
||||
// 'de' prefixes deploy and is a subsequence of code-review: the prefix ranks first.
|
||||
// 'de' prefixes deploy and occurs inside code-review: the prefix ranks first.
|
||||
await expect(names('de')).resolves.toEqual(['deploy', 'code-review'])
|
||||
await expect(names('REV')).resolves.toEqual(['code-review'])
|
||||
await expect(names('zzz')).resolves.toEqual([])
|
||||
// Descriptions do not match: 'flow' appears only in descriptions.
|
||||
await expect(names('flow')).resolves.toEqual([])
|
||||
})
|
||||
|
||||
it('rejects on a failed result (the slash shell owns the menu-side fold)', async () => {
|
||||
|
||||
@@ -8,6 +8,9 @@
|
||||
"src"
|
||||
],
|
||||
"references": [
|
||||
{
|
||||
"path": "../../util/text-search"
|
||||
},
|
||||
{
|
||||
"path": "../../api/remotes/tsconfig.client.json"
|
||||
},
|
||||
|
||||
@@ -24,8 +24,8 @@
|
||||
en: cd8635fa6516441d
|
||||
zh: c06e251fe3dd895b
|
||||
/deepseek-ai-dsh-client-ui-workspace/use-this-package/search:
|
||||
en: 148f2ab562fecc09
|
||||
zh: 9ba7c07999705b31
|
||||
en: 1a1e90c2ed1fd3c1
|
||||
zh: b57fedcec1f00367
|
||||
/deepseek-ai-dsh-client-ui-workspace/use-this-package/managing-sessions:
|
||||
en: 0515aae59aa89cce
|
||||
zh: 83b150ab0e233d8a
|
||||
|
||||
@@ -55,7 +55,7 @@ On devices without hover, expanded Workspace rows keep their menu and New Sessio
|
||||
|
||||
The search shortcut expands a closed sidebar, including a drawer that retains its wide content, before focusing the search field.
|
||||
|
||||
Collapsed search is one header action beside the view and add actions: activating it expands the field across the header. Opening or closing search in the expanded sidebar animates header spacing and field expansion together over 180 ms, disabled for reduced motion. Expanding the sidebar from its rail places the header at its final geometry while preserving the content fade-in. Rail search prepares the open field before expanding the sidebar, so the first wide render already contains the expanded field. Search titles leave space before the Unarchive click target even when truncated. A non-blank query replaces either browsing mode with one flat result list — case-insensitive title, Workspace, and Session id substring matches appear immediately, while a 250 ms debounced Host request adds ranked current-conversation content matches and snippets. Each new query aborts the preceding request; a failed content search leaves metadata matches visible without an additional warning. The list is capped at 20. Choosing an unarchived result clears and collapses search, opens the Session, and scrolls its row into view in the configured browsing mode; grouped browsing also expands its Workspace and the full Session list when required. Archived results offer Unarchive; attempting to open one explains that restriction without clearing the query or navigating.
|
||||
Collapsed search is one header action beside the view and add actions: activating it expands the field across the header. Opening or closing search in the expanded sidebar animates header spacing and field expansion together over 180 ms, disabled for reduced motion. Expanding the sidebar from its rail places the header at its final geometry while preserving the content fade-in. Rail search prepares the open field before expanding the sidebar, so the first wide render already contains the expanded field. Search titles leave space before the Unarchive click target even when truncated. A non-blank query replaces either browsing mode with one flat result list — title, Workspace, and Session id matches from the shared [text search](../../util/text-search/README.md) appear immediately, best match first, while a 250 ms debounced Host request adds ranked current-conversation content matches and snippets. Each new query aborts the preceding request; a failed content search leaves metadata matches visible without an additional warning. The list is capped at 20. Choosing an unarchived result clears and collapses search, opens the Session, and scrolls its row into view in the configured browsing mode; grouped browsing also expands its Workspace and the full Session list when required. Archived results offer Unarchive; attempting to open one explains that restriction without clearing the query or navigating.
|
||||
|
||||
### Managing sessions
|
||||
|
||||
|
||||
@@ -55,7 +55,7 @@ kind: "package-reference"
|
||||
|
||||
搜索快捷键会先展开已关闭的侧栏,包括保留展开内容的抽屉,再聚焦搜索框。
|
||||
|
||||
折叠搜索是视图和添加操作旁的一枚区头按钮:激活后输入框会扩展并占据区头。在展开的侧栏中打开或关闭搜索时,区头间距与输入框展开采用同步的 180 ms 过渡,减少动态效果模式下禁用。从折叠栏展开侧栏时,区头直接采用最终几何位置,同时保留内容淡入。折叠栏搜索会在展开侧栏前准备好输入框的打开状态,因此首个宽栏渲染就包含已展开的输入框。搜索标题即使被截断,也会在取消归档的点击区域前留出间距。非空白查询会以单一扁平结果列表替代任一浏览模式——不区分大小写的标题、Workspace 和 Session id 子串匹配项会立即显示,经 250 ms 防抖的 Host 请求则会加入经过排序的当前对话内容匹配项及其摘要片段。每次新查询都会中止前一个请求;内容搜索失败时,元数据匹配项仍会显示,不另给警告。列表最多显示 20 条结果。选择未归档结果会清空并收起搜索、打开 Session,并在当前浏览模式中将其行滚动到可见区域;分组浏览还会按需展开所属 Workspace 和完整 Session 列表。已归档结果提供取消归档操作;尝试打开时会说明限制,不清空查询,也不导航。
|
||||
折叠搜索是视图和添加操作旁的一枚区头按钮:激活后输入框会扩展并占据区头。在展开的侧栏中打开或关闭搜索时,区头间距与输入框展开采用同步的 180 ms 过渡,减少动态效果模式下禁用。从折叠栏展开侧栏时,区头直接采用最终几何位置,同时保留内容淡入。折叠栏搜索会在展开侧栏前准备好输入框的打开状态,因此首个宽栏渲染就包含已展开的输入框。搜索标题即使被截断,也会在取消归档的点击区域前留出间距。非空白查询会以单一扁平结果列表替代任一浏览模式——标题、Workspace 和 Session id 经共享[文本搜索](../../util/text-search/README.zh.md)得到的匹配项会立即显示,最佳匹配在前,经 250 ms 防抖的 Host 请求则会加入经过排序的当前对话内容匹配项及其摘要片段。每次新查询都会中止前一个请求;内容搜索失败时,元数据匹配项仍会显示,不另给警告。列表最多显示 20 条结果。选择未归档结果会清空并收起搜索、打开 Session,并在当前浏览模式中将其行滚动到可见区域;分组浏览还会按需展开所属 Workspace 和完整 Session 列表。已归档结果提供取消归档操作;尝试打开时会说明限制,不清空查询,也不导航。
|
||||
|
||||
### 管理会话
|
||||
|
||||
|
||||
@@ -87,7 +87,8 @@
|
||||
"react": "^18.2.0",
|
||||
"@deepseek-ai/dsh-client-shortcuts": "workspace:*",
|
||||
"@deepseek-ai/dsh-client-product-analytics": "workspace:*",
|
||||
"@deepseek-ai/dsh-client-ui-context-menu": "workspace:*"
|
||||
"@deepseek-ai/dsh-client-ui-context-menu": "workspace:*",
|
||||
"@deepseek-ai/dsh-util-text-search": "workspace:*"
|
||||
},
|
||||
"files": [
|
||||
"locale/*.json",
|
||||
|
||||
@@ -34,7 +34,7 @@ import type { PropsRenderSlots } from '@deepseek-ai/dsh-client-ui-slots'
|
||||
import type { WorkspaceBrowserProps } from '../contract/slots.ts'
|
||||
import type { ArchivedFilter, GroupNode, SessionNode, SessionOrderBy, SessionRowState } from '../tree.ts'
|
||||
import {
|
||||
deriveFlat, deriveGroups, deriveSearchResults, orderByRecency, owningGroupKey, owningParentFolder,
|
||||
deriveFlat, deriveGroups, deriveSearchResults, orderByRecency, sessionSearchIndex, owningGroupKey, owningParentFolder,
|
||||
pinCurrentBlank, reconcileManualOrder, sessionMemberIds, UNGROUPED_KEY,
|
||||
} from '../tree.ts'
|
||||
import { ProjectRowItem, SearchResultItem, SessionNodeItem } from './Rows.tsx'
|
||||
@@ -823,6 +823,18 @@ function SearchResults({
|
||||
const currentRemote = remote.query === query
|
||||
? remote
|
||||
: { query, status: 'loading' as const, items: [], hasMore: false }
|
||||
// The Session list republishes while replies run; each republish updates the
|
||||
// previous index so unchanged titles, labels, and ids keep their preparation.
|
||||
const [built, setBuilt] = useState(() => ({
|
||||
list, workspaces, archivedSessionIds, archivedFilter,
|
||||
index: sessionSearchIndex(list, workspaces, archivedSessionIds, archivedFilter),
|
||||
}))
|
||||
let index = built.index
|
||||
if (built.list !== list || built.workspaces !== workspaces
|
||||
|| built.archivedSessionIds !== archivedSessionIds || built.archivedFilter !== archivedFilter) {
|
||||
index = sessionSearchIndex(list, workspaces, archivedSessionIds, archivedFilter, built.index)
|
||||
setBuilt({ list, workspaces, archivedSessionIds, archivedFilter, index })
|
||||
}
|
||||
const results = useMemo(
|
||||
() => deriveSearchResults(
|
||||
list,
|
||||
@@ -833,8 +845,9 @@ function SearchResults({
|
||||
statuses,
|
||||
currentRemote,
|
||||
resultLimit,
|
||||
index,
|
||||
),
|
||||
[list, workspaces, query, archivedSessionIds, archivedFilter, statuses, currentRemote, resultLimit],
|
||||
[list, workspaces, query, archivedSessionIds, archivedFilter, statuses, currentRemote, resultLimit, index],
|
||||
)
|
||||
const pending = currentRemote.status === 'loading'
|
||||
const currentId = panelActive
|
||||
|
||||
@@ -11,6 +11,7 @@ import type {
|
||||
SessionStatusSnapshot,
|
||||
} from '@deepseek-ai/dsh-client-ui-session-status/client'
|
||||
import type { SessionId } from '@deepseek-ai/dsh-session/types'
|
||||
import { TextSearchIndex, type SearchKeys } from '@deepseek-ai/dsh-util-text-search'
|
||||
import { assertNever } from '@deepseek-ai/dsh-util-values'
|
||||
import { workspaceTitleOf } from '@deepseek-ai/dsh-util-workspace-path'
|
||||
|
||||
@@ -522,10 +523,52 @@ export function deriveFlat(
|
||||
.map(session => sessionNode(session, list, statuses, pinned, archived))
|
||||
}
|
||||
|
||||
/** Display label of each Session's Workspace: its first Workspace's title, else its cwd label. */
|
||||
function workspaceLabels(workspaces: readonly WorkspaceView[]): (summary: SessionSummary) => string {
|
||||
const workspaceBySession = new Map<SessionId, string>()
|
||||
for (const workspace of workspaces) {
|
||||
for (const sessionId of workspace.sessionIds) {
|
||||
if (!workspaceBySession.has(sessionId)) workspaceBySession.set(sessionId, workspace.title)
|
||||
}
|
||||
}
|
||||
return summary => workspaceBySession.get(summary.id) ?? workspaceLabel(summary.cwd)
|
||||
}
|
||||
|
||||
/**
|
||||
* Merge immediate title/Workspace/Session id substring matches with ranked Host content
|
||||
* matches. Local rows lead newest-first, content-only rows retain backend
|
||||
* order, and duplicate sessions receive the backend snippet in place.
|
||||
* Search index over the Sessions sidebar search can show, newest first: title
|
||||
* and Workspace match fuzzily, the Session id as a substring. Blank placeholders
|
||||
* are left out because their canonical title displays localized.
|
||||
* @param list - session metadata authority.
|
||||
* @param workspaces - Workspace membership and display labels.
|
||||
* @param archivedSessionIds - registry-global archive set (members match per the archived filter).
|
||||
* @param archivedFilter - archived-row visibility choice; search follows it.
|
||||
* @param previous - the index of an earlier list; its prepared titles, labels, and ids are reused.
|
||||
* @returns the index {@link deriveSearchResults} searches.
|
||||
*/
|
||||
export function sessionSearchIndex(
|
||||
list: SessionListState,
|
||||
workspaces: readonly WorkspaceView[],
|
||||
archivedSessionIds: readonly SessionId[],
|
||||
archivedFilter: ArchivedFilter,
|
||||
previous?: TextSearchIndex<SessionSummary>,
|
||||
): TextSearchIndex<SessionSummary> {
|
||||
const archived = new Set(archivedSessionIds)
|
||||
const current = mainSessionId(list)
|
||||
const labelOf = workspaceLabels(workspaces)
|
||||
const visible = list.ids.filter((id) => {
|
||||
const summary = list.byId[id]
|
||||
return summary !== undefined && !summary.blank && sessionVisible(summary, current, archived, archivedFilter)
|
||||
})
|
||||
const sessions = orderByRecency(visible, list.byId).map(id => list.byId[id] as SessionSummary)
|
||||
const keys = (summary: SessionSummary): SearchKeys => ({ fuzzy: [sessionTitle(summary), labelOf(summary)], substring: [summary.id] })
|
||||
return previous === undefined ? new TextSearchIndex(sessions, keys) : previous.update(sessions, keys)
|
||||
}
|
||||
|
||||
/**
|
||||
* Merge immediate title/Workspace/Session id fuzzy matches with ranked Host content
|
||||
* matches. Local rows lead best match first, newest first among equal matches;
|
||||
* content-only rows retain backend order, and duplicate sessions receive the
|
||||
* backend snippet in place.
|
||||
* @param list - session metadata authority.
|
||||
* @param workspaces - Workspace membership and display labels.
|
||||
* @param query - caller text; surrounding whitespace is ignored.
|
||||
@@ -534,6 +577,7 @@ export function deriveFlat(
|
||||
* @param statuses - unified UI status by Session.
|
||||
* @param content - ranked Host content-search page.
|
||||
* @param limit - protocol-owned maximum merged row count.
|
||||
* @param index - {@link sessionSearchIndex} of the same list, Workspaces, and archive choice.
|
||||
* @returns bounded deduplicated flat rows and a refine-query hint bit.
|
||||
*/
|
||||
export function deriveSearchResults(
|
||||
@@ -545,42 +589,18 @@ export function deriveSearchResults(
|
||||
statuses: SessionStatuses,
|
||||
content: { items: readonly SessionSearchResultItem[]; hasMore: boolean },
|
||||
limit: number,
|
||||
index: TextSearchIndex<SessionSummary>,
|
||||
): SearchResultSet {
|
||||
const q = query.trim().toLowerCase()
|
||||
if (q === '') return { items: [], hasMore: false }
|
||||
if (query.trim() === '') return { items: [], hasMore: false }
|
||||
const archived = new Set(archivedSessionIds)
|
||||
const current = mainSessionId(list)
|
||||
|
||||
const workspaceBySession = new Map<SessionId, string>()
|
||||
for (const workspace of workspaces) {
|
||||
for (const sessionId of workspace.sessionIds) {
|
||||
if (!workspaceBySession.has(sessionId)) workspaceBySession.set(sessionId, workspace.title)
|
||||
}
|
||||
}
|
||||
const labelOf = (summary: SessionSummary): string =>
|
||||
workspaceBySession.get(summary.id) ?? workspaceLabel(summary.cwd)
|
||||
const labelOf = workspaceLabels(workspaces)
|
||||
const contentBySession = new Map<SessionId, SessionSearchResultItem>()
|
||||
for (const item of content.items) {
|
||||
if (!contentBySession.has(item.sessionId)) contentBySession.set(item.sessionId, item)
|
||||
}
|
||||
|
||||
const local: SessionSummary[] = []
|
||||
for (const id of list.ids) {
|
||||
const summary = list.byId[id]
|
||||
// Blank placeholders never match a query (their canonical title displays
|
||||
// localized, so matching it would tie search to one language).
|
||||
if (summary === undefined || summary.blank || !sessionVisible(summary, current, archived, archivedFilter)) continue
|
||||
if (
|
||||
sessionTitle(summary).toLowerCase().includes(q)
|
||||
|| labelOf(summary).toLowerCase().includes(q)
|
||||
|| summary.id.toLowerCase().includes(q)
|
||||
) {
|
||||
local.push(summary)
|
||||
}
|
||||
}
|
||||
const localById = new Map(local.map(summary => [summary.id, summary]))
|
||||
const orderedLocal = orderByRecency(local.map(summary => summary.id), list.byId)
|
||||
.map(id => localById.get(id) as SessionSummary)
|
||||
const orderedLocal = index.search(query)
|
||||
|
||||
const ordered: SessionSummary[] = []
|
||||
const included = new Set<SessionId>()
|
||||
|
||||
@@ -10,11 +10,21 @@ import type { JsonValue } from '@deepseek-ai/dsh-util-values'
|
||||
import type { SessionProjectionSnapshot } from '@deepseek-ai/dsh-api-session-controller/client'
|
||||
import {
|
||||
type ArchivedFilter,
|
||||
deriveFlat, deriveGroups, deriveSearchResults, orderByRecency, owningGroupKey, owningParentFolder,
|
||||
deriveFlat, deriveGroups, deriveSearchResults, orderByRecency, sessionSearchIndex, owningGroupKey, owningParentFolder,
|
||||
pinCurrentBlank, reconcileManualOrder, sessionMemberIds, visibleSessionIds, workspaceLabel, UNGROUPED_KEY,
|
||||
} from '../src/client/tree.ts'
|
||||
import { createWorkspaceViewStore } from '../src/client/stores.ts'
|
||||
|
||||
type SearchArgs = Parameters<typeof deriveSearchResults>
|
||||
/** Sidebar search as the component runs it: build the list's index, then search it. */
|
||||
function searchResults(
|
||||
sessions: SearchArgs[0], workspaces: SearchArgs[1], query: string, archivedIds: SearchArgs[3],
|
||||
archivedFilter: SearchArgs[4], statuses: SearchArgs[5], content: SearchArgs[6], limit: number,
|
||||
): ReturnType<typeof deriveSearchResults> {
|
||||
const index = sessionSearchIndex(sessions, workspaces, archivedIds, archivedFilter)
|
||||
return deriveSearchResults(sessions, workspaces, query, archivedIds, archivedFilter, statuses, content, limit, index)
|
||||
}
|
||||
|
||||
const sid = (id: string) => id as SessionId
|
||||
const wid = (id: string) => id as WorkspaceId
|
||||
const summary = (id: string, updatedAt: number, cwd?: string): SessionSummary => ({
|
||||
@@ -335,6 +345,20 @@ describe('deriveGroups', () => {
|
||||
expect(strayGroups.map(group => group.key)).toEqual(['first'])
|
||||
})
|
||||
|
||||
it('matches titles fuzzily and orders local results by match, then recency', () => {
|
||||
const newer = { ...summary('newer', 3), title: 'Weekly sync notes' }
|
||||
const older = { ...summary('older', 2), title: 'Sync dashboard' }
|
||||
const other = { ...summary('other', 4), title: 'Unrelated' }
|
||||
const sessions = list(newer, older, other)
|
||||
const search = (query: string) => searchResults(
|
||||
sessions, [workspace('first', ['newer', 'older', 'other'])], query, noArchive, 'default',
|
||||
noAttention, { items: [], hasMore: false }, 10,
|
||||
).items.map(item => item.id)
|
||||
expect(search('sync')).toEqual([older.id, newer.id])
|
||||
expect(search('wksn')).toEqual([newer.id])
|
||||
expect(search('zzz')).toEqual([])
|
||||
})
|
||||
|
||||
it('projects the completion reminder into session and search rows (absent = false)', () => {
|
||||
const done = summary('done', 3)
|
||||
const plain = summary('plain', 2)
|
||||
@@ -349,7 +373,7 @@ describe('deriveGroups', () => {
|
||||
expect(plainNode.completed).toBe(false)
|
||||
expect(deriveFlat(sessions, visibleSessionIds(sessions, noArchive, 'default'), noRows, statuses)
|
||||
.find(node => node.id === done.id)!.completed).toBe(true)
|
||||
const search = deriveSearchResults(
|
||||
const search = searchResults(
|
||||
sessions, [workspace('first', ['done', 'plain'])], 'done', noArchive, 'default',
|
||||
statuses, { items: [], hasMore: false }, 10,
|
||||
)
|
||||
@@ -364,7 +388,7 @@ describe('deriveGroups', () => {
|
||||
})]])
|
||||
const rows = deriveFlat(sessions, visibleSessionIds(sessions, noArchive, 'default'), noRows, statuses)
|
||||
expect(rows[0]).toMatchObject({ completed: unread, failed: unread })
|
||||
const search = deriveSearchResults(sessions, [], 'failed', noArchive, 'default', statuses, { items: [], hasMore: false }, 10)
|
||||
const search = searchResults(sessions, [], 'failed', noArchive, 'default', statuses, { items: [], hasMore: false }, 10)
|
||||
expect(search.items[0]).toMatchObject({ completed: unread, failed: unread })
|
||||
})
|
||||
|
||||
@@ -407,7 +431,7 @@ describe('deriveGroups', () => {
|
||||
.map(node => [node.id, node.runningSubagentCount])).toEqual([
|
||||
[parent.id, 1], [fork.id, 1],
|
||||
])
|
||||
expect(deriveSearchResults(
|
||||
expect(searchResults(
|
||||
sessions, [workspace('first', ['parent', 'fork'])], 'parent', noArchive, 'default',
|
||||
noAttention, { items: [], hasMore: false }, 10,
|
||||
).items[0]).toMatchObject({ id: parent.id, runningSubagentCount: 1 })
|
||||
@@ -432,7 +456,7 @@ describe('deriveGroups', () => {
|
||||
const counts = (snapshot: SessionStatusSnapshot) => [
|
||||
deriveGroups(sessions, [workspace('first', ['parent'])], noRows, snapshot, view(['first']))[0]!.sessions[0]!.runningSubagentCount,
|
||||
deriveFlat(sessions, [parent.id], noRows, snapshot)[0]!.runningSubagentCount,
|
||||
deriveSearchResults(sessions, [], 'parent', noArchive, 'default', snapshot, { items: [], hasMore: false }, 10).items[0]!.runningSubagentCount,
|
||||
searchResults(sessions, [], 'parent', noArchive, 'default', snapshot, { items: [], hasMore: false }, 10).items[0]!.runningSubagentCount,
|
||||
]
|
||||
expect(counts(statuses)).toEqual([1, 1, 1])
|
||||
statuses.set(child.id, status(undefined, { running: false }))
|
||||
@@ -646,7 +670,7 @@ describe('deriveSearchResults archive filtering', () => {
|
||||
hit.title = hit.displayTitle = 'Needle row'
|
||||
const gone = summary('gone', 1)
|
||||
gone.title = gone.displayTitle = 'Needle archived'
|
||||
const result = deriveSearchResults(
|
||||
const result = searchResults(
|
||||
list(hit, gone),
|
||||
[],
|
||||
'needle',
|
||||
@@ -662,7 +686,7 @@ describe('deriveSearchResults archive filtering', () => {
|
||||
it('matches archived sessions and flags them while the view shows them', () => {
|
||||
const gone = summary('gone', 1)
|
||||
gone.title = gone.displayTitle = 'Needle archived'
|
||||
const result = deriveSearchResults(
|
||||
const result = searchResults(
|
||||
list(gone), [], 'needle', archived('gone'), 'show', noAttention, { items: [], hasMore: false }, 10,
|
||||
)
|
||||
expect(result.items.map(item => [item.id, item.archived])).toEqual([[gone.id, true]])
|
||||
@@ -673,7 +697,7 @@ describe('deriveSearchResults archive filtering', () => {
|
||||
hit.title = hit.displayTitle = 'Needle row'
|
||||
const gone = summary('gone', 1)
|
||||
gone.title = gone.displayTitle = 'Needle archived'
|
||||
const result = deriveSearchResults(
|
||||
const result = searchResults(
|
||||
list(hit, gone), [], 'needle', archived('gone'), 'only', noAttention, { items: [], hasMore: false }, 10,
|
||||
)
|
||||
expect(result.items.map(item => [item.id, item.archived])).toEqual([[gone.id, true]])
|
||||
@@ -686,7 +710,7 @@ describe('deriveSearchResults branch marks', () => {
|
||||
source.title = source.displayTitle = 'Needle source'
|
||||
const branch = summary('my-branch', 2)
|
||||
branch.title = branch.displayTitle = 'Needle branch'
|
||||
const result = deriveSearchResults(
|
||||
const result = searchResults(
|
||||
branchedList([source, branch], branch.id, { sourceSessionId: source.id }),
|
||||
[workspace('first', ['shared', 'my-branch'])],
|
||||
'needle',
|
||||
@@ -701,6 +725,22 @@ describe('deriveSearchResults branch marks', () => {
|
||||
})
|
||||
|
||||
describe('deriveSearchResults', () => {
|
||||
it('updates the previous index to the same results as a fresh one', () => {
|
||||
const first = { ...summary('first', 1), title: 'Weekly sync notes' }
|
||||
const second = { ...summary('second', 2), title: 'Sync dashboard' }
|
||||
const before = list(first, second)
|
||||
const previous = sessionSearchIndex(before, [], noArchive, 'default')
|
||||
previous.search('sync')
|
||||
// A republish rebuilds every summary object; one title changes and one Session is new.
|
||||
const after = list({ ...first, title: 'Weekly planning' }, { ...second }, { ...summary('third', 3), title: 'Sync retro' })
|
||||
const updated = sessionSearchIndex(after, [], noArchive, 'default', previous)
|
||||
const fresh = sessionSearchIndex(after, [], noArchive, 'default')
|
||||
for (const query of ['sync', 'wkpl', 'retro']) {
|
||||
expect(updated.search(query).map(row => row.id)).toEqual(fresh.search(query).map(row => row.id))
|
||||
}
|
||||
expect(updated.search('sync').map(row => row.id)).toEqual([sid('third'), sid('second')])
|
||||
})
|
||||
|
||||
it('merges local title/Workspace matches before ranked content hits and enriches duplicates', () => {
|
||||
const titleHit = summary('title-hit', 30, '/projects/a')
|
||||
titleHit.title = titleHit.displayTitle = 'Needle title'
|
||||
@@ -708,7 +748,7 @@ describe('deriveSearchResults', () => {
|
||||
workspaceHit.title = workspaceHit.displayTitle = 'Ordinary title'
|
||||
const contentHit = summary('content-hit', 10, '/projects/c')
|
||||
const sessions = list(titleHit, workspaceHit, contentHit)
|
||||
const result = deriveSearchResults(
|
||||
const result = searchResults(
|
||||
sessions,
|
||||
[
|
||||
workspace('a', ['title-hit'], 'Alpha'),
|
||||
@@ -775,7 +815,7 @@ describe('deriveSearchResults', () => {
|
||||
idHit.title = idHit.displayTitle = 'Ordinary title'
|
||||
const other = summary('b7e0d4aa-session', 1)
|
||||
other.title = other.displayTitle = 'Another title'
|
||||
const result = deriveSearchResults(
|
||||
const result = searchResults(
|
||||
list(idHit, other), [], '9A2C71', noArchive, 'default', noAttention, { items: [], hasMore: false }, 10,
|
||||
)
|
||||
expect(result.items.map(item => [item.id, item.title])).toEqual([[idHit.id, 'Ordinary title']])
|
||||
@@ -787,7 +827,7 @@ describe('deriveSearchResults', () => {
|
||||
const sessions = list(currentBlank, staleBlank)
|
||||
// Blank placeholders never match — not their localized-display title, not
|
||||
// their id, and not even a backend content hit naming them.
|
||||
const result = deriveSearchResults(
|
||||
const result = searchResults(
|
||||
sessions,
|
||||
[workspace('first', ['opaque-current', 'new session stale'])],
|
||||
'new session',
|
||||
@@ -812,7 +852,7 @@ describe('deriveSearchResults', () => {
|
||||
item.title = item.displayTitle = `Needle ${String(index)}`
|
||||
return item
|
||||
})
|
||||
const overflow = deriveSearchResults(
|
||||
const overflow = searchResults(
|
||||
list(...rows),
|
||||
[],
|
||||
'needle',
|
||||
@@ -825,7 +865,7 @@ describe('deriveSearchResults', () => {
|
||||
expect(overflow.items).toHaveLength(3)
|
||||
expect(overflow.hasMore).toBe(true)
|
||||
|
||||
const backendMore = deriveSearchResults(
|
||||
const backendMore = searchResults(
|
||||
list(summary('body', 1)),
|
||||
[],
|
||||
'needle',
|
||||
@@ -837,7 +877,7 @@ describe('deriveSearchResults', () => {
|
||||
)
|
||||
expect(backendMore.items).toHaveLength(1)
|
||||
expect(backendMore.hasMore).toBe(true)
|
||||
expect(deriveSearchResults(list(), [], ' ', noArchive, 'default', noAttention, { items: [], hasMore: true }, 3))
|
||||
expect(searchResults(list(), [], ' ', noArchive, 'default', noAttention, { items: [], hasMore: true }, 3))
|
||||
.toEqual({ items: [], hasMore: false })
|
||||
})
|
||||
})
|
||||
|
||||
@@ -8,6 +8,9 @@
|
||||
"src"
|
||||
],
|
||||
"references": [
|
||||
{
|
||||
"path": "../../util/text-search"
|
||||
},
|
||||
{
|
||||
"path": "../../api/session-controller/tsconfig.client.json"
|
||||
},
|
||||
|
||||
@@ -24,8 +24,8 @@
|
||||
en: 0942e28bfd0d07da
|
||||
zh: ca109508b18b4c14
|
||||
/deepseek-ai-dsh-session-reference/use-this-package/finding-sessions-to-reference:
|
||||
en: 169f100ba62f2120
|
||||
zh: 3fd4fc0bd73b2370
|
||||
en: a2e89081a84b9aeb
|
||||
zh: b85f189a1deccdac
|
||||
/deepseek-ai-dsh-session-reference/use-this-package/configuration:
|
||||
en: 5dfb1f0c52d300bf
|
||||
zh: ae731dd6fcd93027
|
||||
|
||||
@@ -39,7 +39,7 @@ For a truncated reference, an optional spill backend saves the full captured tex
|
||||
|
||||
### Finding sessions to reference
|
||||
|
||||
`listCandidates(agent, query?, limit?)` lists sessions other than the agent's own, filters case-insensitively by id, working directory, projected title, or display title, and ranks same-directory sessions first. Each candidate carries its latest title as `label`, falling back to the session id when the title is absent or unreadable. Its display title prefers a subagent's durable creation label over that title. The candidate also reports whether its working directory is the requesting agent's so a host can surface a location only when it distinguishes the row. Browser consumers call the same discovery as `ctx.remote.sessionReferenceResolver.candidates`, which labels the canonical mention with `displayTitle` when present.
|
||||
`listCandidates(agent, query?, limit?)` lists sessions other than the agent's own, filters through the shared [text search](../../util/text-search/README.md) (projected title and display title fuzzily; session id and working directory as substrings, including an id that stands in for a missing title), and ranks same-directory sessions first, then by match. Each candidate carries its latest title as `label`, falling back to the session id when the title is absent or unreadable. Its display title prefers a subagent's durable creation label over that title. The candidate also reports whether its working directory is the requesting agent's so a host can surface a location only when it distinguishes the row. Browser consumers call the same discovery as `ctx.remote.sessionReferenceResolver.candidates`, which labels the canonical mention with `displayTitle` when present.
|
||||
|
||||
### Configuration
|
||||
|
||||
|
||||
@@ -39,7 +39,7 @@ kind: "package-reference"
|
||||
|
||||
### 查找可引用的会话
|
||||
|
||||
`listCandidates(agent, query?, limit?)` 列出除 agent 自身外的会话,按 id、工作目录、投影标题或显示标题做不区分大小写的过滤,并把同目录会话排在前面。每个候选的 `label` 使用最新标题;标题缺失或不可读时回退到会话 id。显示标题优先使用 subagent 的持久创建 label,再回退到该标题。候选还会报告其工作目录是否就是发起方 agent 的工作目录,宿主因此可以只在位置能区分该行时才显示它。浏览器消费方通过 `ctx.remote.sessionReferenceResolver.candidates` 调用同一发现能力;该方法在 `displayTitle` 存在时用它标记规范 mention。
|
||||
`listCandidates(agent, query?, limit?)` 列出除 agent 自身外的会话,通过共享的[文本搜索](../../util/text-search/README.zh.md)过滤(投影标题和显示标题模糊匹配;会话 id 和工作目录按子串匹配,包括标题缺失时代替标题的 id),先把同目录会话排在前面,再按匹配程度排序。每个候选的 `label` 使用最新标题;标题缺失或不可读时回退到会话 id。显示标题优先使用 subagent 的持久创建 label,再回退到该标题。候选还会报告其工作目录是否就是发起方 agent 的工作目录,宿主因此可以只在位置能区分该行时才显示它。浏览器消费方通过 `ctx.remote.sessionReferenceResolver.candidates` 调用同一发现能力;该方法在 `displayTitle` 存在时用它标记规范 mention。
|
||||
|
||||
### 配置
|
||||
|
||||
|
||||
@@ -51,6 +51,7 @@
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@deepseek-ai/dsh-brand": "workspace:*",
|
||||
"@deepseek-ai/dsh-util-text-search": "workspace:*",
|
||||
"@deepseek-ai/dsh-util-values": "workspace:*",
|
||||
"@deepseek-ai/schemastery": "workspace:~",
|
||||
"zod": "4.6.6"
|
||||
|
||||
@@ -9,6 +9,7 @@ import { Context } from '@deepseek-ai/cordis'
|
||||
import z from '@deepseek-ai/schemastery'
|
||||
import type { Agent, PreStepDecision } from '@deepseek-ai/dsh-agent'
|
||||
import { Remote, TypertRemoteService } from '@deepseek-ai/dsh-typert-protocol'
|
||||
import { TextSearchIndex, type SearchKeys } from '@deepseek-ai/dsh-util-text-search'
|
||||
import { createUserMessage, freezeMessage, LlmError } from '@deepseek-ai/dsh-llm'
|
||||
import type { ContentBlock, LlmCallConfig, LlmResolvedModelInfo, UserMessage } from '@deepseek-ai/dsh-llm'
|
||||
import type { SessionId } from '@deepseek-ai/dsh-session'
|
||||
@@ -84,6 +85,24 @@ interface RenderedSource {
|
||||
capturedFormatVersion: number
|
||||
}
|
||||
|
||||
/** A Session record with the labels candidate discovery shows and matches. */
|
||||
interface LabelledCandidate {
|
||||
readonly record: SessionRecord
|
||||
readonly label: string
|
||||
readonly displayTitle: string
|
||||
}
|
||||
|
||||
/**
|
||||
* Candidate search text. A Session without a title is labelled by its id,
|
||||
* which matches only as a substring.
|
||||
*/
|
||||
function candidateKeys({ record, label, displayTitle }: LabelledCandidate): SearchKeys {
|
||||
return {
|
||||
fuzzy: [label, displayTitle].filter(name => name !== record.header.id),
|
||||
substring: [record.header.id, record.header.cwd],
|
||||
}
|
||||
}
|
||||
|
||||
/** Exact-read consumer that prepares immutable cross-session message context. */
|
||||
export class SessionReferenceResolver extends TypertRemoteService {
|
||||
static inject = ['sessionQuery']
|
||||
@@ -95,6 +114,8 @@ export class SessionReferenceResolver extends TypertRemoteService {
|
||||
})
|
||||
|
||||
private readonly config: Required<Omit<Config, 'maxReferenceBytes'>> & { maxReferenceBytes: number | undefined }
|
||||
/** The latest candidate search index; each discovery call updates it with the complete current list. */
|
||||
private candidateIndex: TextSearchIndex<LabelledCandidate> | undefined
|
||||
|
||||
constructor(ctx: Context, config: Config = {}) {
|
||||
super(ctx, 'sessionReferenceResolver')
|
||||
@@ -177,7 +198,9 @@ export class SessionReferenceResolver extends TypertRemoteService {
|
||||
* Discovery runs at keystroke rate, so titles and subagent labels only ever
|
||||
* come from projection reads; sessions without either fall back to their id.
|
||||
* @param agent - target agent; self is excluded and its cwd drives ranking.
|
||||
* @param query - optional case-insensitive session-id/cwd/title/display-title substring.
|
||||
* @param query - optional search text: label and display title match
|
||||
* fuzzily, session id and working directory as substrings. Matches keep the
|
||||
* working-directory affinity order; relevance breaks ties within it.
|
||||
* @param limit - optional positive result cap.
|
||||
* @param signal - optional cancellation boundary for host autocomplete teardown.
|
||||
* @returns candidates with canonical mention labels and presentation titles.
|
||||
@@ -191,21 +214,19 @@ export class SessionReferenceResolver extends TypertRemoteService {
|
||||
if (!Number.isSafeInteger(limit) || limit <= 0) {
|
||||
throw new SessionReferenceError('candidate limit must be a positive safe integer', 'SESSION_REFERENCE_INVALID_REFERENCE')
|
||||
}
|
||||
const needle = query.toLocaleLowerCase()
|
||||
const targetCwd = agent.session.header.cwd
|
||||
assertNotCancelled(signal)
|
||||
const records = (await settleWithCancellation(this.ctx.sessionQuery.listSessions(signal), signal))
|
||||
.filter(record => record.header.id !== agent.id)
|
||||
.map((record, index) => ({ record, index }))
|
||||
.map(record => ({ record }))
|
||||
const labelled = this.projectedLabels(records)
|
||||
return labelled.filter(({ record, label, displayTitle }) => {
|
||||
if (needle === '') return true
|
||||
return record.header.id.toLocaleLowerCase().includes(needle)
|
||||
|| record.header.cwd?.toLocaleLowerCase().includes(needle) === true
|
||||
|| label.toLocaleLowerCase().includes(needle)
|
||||
|| displayTitle.toLocaleLowerCase().includes(needle)
|
||||
}).sort((a, b) => candidateRank(a.record.header.cwd, targetCwd) - candidateRank(b.record.header.cwd, targetCwd)
|
||||
|| a.index - b.index)
|
||||
// Discovery runs at keystroke rate: each call updates the previous call's
|
||||
// index so unchanged titles, ids, and paths keep their preparation.
|
||||
const index = this.candidateIndex?.update(labelled, candidateKeys) ?? new TextSearchIndex(labelled, candidateKeys)
|
||||
this.candidateIndex = index
|
||||
return index.search(query).map((match, rank) => ({ ...match, rank }))
|
||||
.sort((a, b) => candidateRank(a.record.header.cwd, targetCwd) - candidateRank(b.record.header.cwd, targetCwd)
|
||||
|| a.rank - b.rank)
|
||||
.slice(0, limit)
|
||||
.map(({ record, label, displayTitle }) => ({
|
||||
sessionId: record.header.id,
|
||||
@@ -274,7 +295,7 @@ export class SessionReferenceResolver extends TypertRemoteService {
|
||||
* applies, and every candidate carries the canonical mention a host inserts
|
||||
* into the prompt draft.
|
||||
* @param agent - target agent; self is excluded and its cwd drives ranking.
|
||||
* @param query - optional case-insensitive session-id/cwd/title substring.
|
||||
* @param query - optional search text, matched as {@link listCandidates} matches it.
|
||||
* @param signal - caller cancellation.
|
||||
* @returns mention-carrying candidates in rank order.
|
||||
*/
|
||||
|
||||
@@ -664,6 +664,17 @@ describe('session reference discovery and preparation', () => {
|
||||
await expect(ctx.sessionReferenceResolver.listCandidates(fakeAgent(target), 'LATEST', 1)).resolves.toEqual([
|
||||
{ sessionId: brandString<SessionId>('same-later'), label: 'Latest title', displayTitle: 'Latest title', cwd: '/same', sameWorkspace: true, createdAt: 25 },
|
||||
])
|
||||
// Titles match fuzzily; the working directory matches only contiguous text.
|
||||
await expect(ctx.sessionReferenceResolver.listCandidates(fakeAgent(target), 'lttl', 1)).resolves.toEqual([
|
||||
{ sessionId: brandString<SessionId>('same-later'), label: 'Latest title', displayTitle: 'Latest title', cwd: '/same', sameWorkspace: true, createdAt: 25 },
|
||||
])
|
||||
await expect(ctx.sessionReferenceResolver.listCandidates(fakeAgent(target), '/se')).resolves.toEqual([])
|
||||
// An untitled Session's label falls back to its id, which matches only as a substring:
|
||||
// `a1` occurs in this id only as scattered characters.
|
||||
ctx.sessions.create(brandString<SessionId>('a0000000-0000-4000-8000-000000000001'), { meta: { cwd: '/same', createdAt: 50 } })
|
||||
await expect(ctx.sessionReferenceResolver.listCandidates(fakeAgent(target), 'a1')).resolves.toEqual([])
|
||||
await expect(ctx.sessionReferenceResolver.listCandidates(fakeAgent(target), '0001')).resolves
|
||||
.toMatchObject([{ sessionId: brandString<SessionId>('a0000000-0000-4000-8000-000000000001'), label: 'a0000000-0000-4000-8000-000000000001' }])
|
||||
await expect(ctx.sessionReferenceResolver.listCandidates(fakeAgent(target), '', 0))
|
||||
.rejects.toThrow(expectCode('SESSION_REFERENCE_INVALID_REFERENCE'))
|
||||
|
||||
|
||||
@@ -8,6 +8,9 @@
|
||||
"src"
|
||||
],
|
||||
"references": [
|
||||
{
|
||||
"path": "../../util/text-search"
|
||||
},
|
||||
{
|
||||
"path": "../../../vendor/cosmokit"
|
||||
},
|
||||
|
||||
@@ -3412,13 +3412,13 @@ export const SERVICE_API: readonly ServiceApiEntry[] = [
|
||||
{
|
||||
signature: 'async listCandidates( agent: Agent, query: string = \'\', limit: number = this.config.candidateLimit, signal?: AbortSignal, ): Promise<SessionReferenceCandidate[]>',
|
||||
description: 'List reference candidates, ranked by working-directory affinity.\n\nDiscovery runs at keystroke rate, so titles and subagent labels only ever come from projection reads; sessions without either fall back to their id.',
|
||||
parameters: [{ name: 'agent', description: 'target agent; self is excluded and its cwd drives ranking.' }, { name: 'query', description: 'optional case-insensitive session-id/cwd/title/display-title substring.' }, { name: 'limit', description: 'optional positive result cap.' }, { name: 'signal', description: 'optional cancellation boundary for host autocomplete teardown.' }],
|
||||
parameters: [{ name: 'agent', description: 'target agent; self is excluded and its cwd drives ranking.' }, { name: 'query', description: 'optional search text: label and display title match fuzzily, session id and working directory as substrings. Matches keep the working-directory affinity order; relevance breaks ties within it.' }, { name: 'limit', description: 'optional positive result cap.' }, { name: 'signal', description: 'optional cancellation boundary for host autocomplete teardown.' }],
|
||||
returns: 'candidates with canonical mention labels and presentation titles.',
|
||||
},
|
||||
{
|
||||
signature: '@Remote(\'candidates\') async remoteExportCandidates( agent: Agent, query: string, signal: AbortSignal, ): Promise<SessionReferenceMentionCandidate[]>',
|
||||
description: 'Remote face of listCandidates: the configured candidate limit applies, and every candidate carries the canonical mention a host inserts into the prompt draft.',
|
||||
parameters: [{ name: 'agent', description: 'target agent; self is excluded and its cwd drives ranking.' }, { name: 'query', description: 'optional case-insensitive session-id/cwd/title substring.' }, { name: 'signal', description: 'caller cancellation.' }],
|
||||
parameters: [{ name: 'agent', description: 'target agent; self is excluded and its cwd drives ranking.' }, { name: 'query', description: 'optional search text, matched as {@link listCandidates} matches it.' }, { name: 'signal', description: 'caller cancellation.' }],
|
||||
returns: 'mention-carrying candidates in rank order.',
|
||||
},
|
||||
{
|
||||
|
||||
@@ -3,20 +3,20 @@
|
||||
# After editing either side, bring the other along and re-record with:
|
||||
# pnpm run verify-translation-pairing --write packages/util/README.md
|
||||
/:
|
||||
en: 4e92398c76bf480f
|
||||
zh: 18840c65a44a8c38
|
||||
en: 717ac90453e30c77
|
||||
zh: 6407d2f55d40e2a1
|
||||
/util-shared-utilities:
|
||||
en: 7283f2afb343d150
|
||||
zh: 32c56bd67c0314c6
|
||||
/util-shared-utilities/summary:
|
||||
en: e1aa918f27dccf20
|
||||
zh: 7d415fdc8c0248ed
|
||||
en: 65b0050fa5de3502
|
||||
zh: 188dd7402e091cba
|
||||
/util-shared-utilities/table-of-contents:
|
||||
en: 1eb35b015a6c423f
|
||||
zh: a8a3dceee2c9e943
|
||||
/util-shared-utilities/packages:
|
||||
en: 461990a6f0e944bd
|
||||
zh: 788c91b2b1cf0426
|
||||
en: 287d9c624edbbcf9
|
||||
zh: 1eaef6c9c858d905
|
||||
/util-shared-utilities/related-documentation:
|
||||
en: 432ae81110914571
|
||||
zh: c5bf4efc007311f3
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
---
|
||||
description: "Package map for shared utilities: atomic file writes, branded ids, deques, JSON values, harness home paths, launch environment, native commands, packaged ripgrep, output retention, time and zone vocabulary, timeouts, and official package lists."
|
||||
description: "Package map for shared utilities: atomic file writes, branded ids, deques, JSON values, harness home paths, launch environment, native commands, packaged ripgrep, output retention, in-memory search filtering, time and zone vocabulary, timeouts, and official package lists."
|
||||
kind: "package-group"
|
||||
---
|
||||
|
||||
@@ -9,7 +9,7 @@ English | [中文](README.zh.md)
|
||||
|
||||
## Summary
|
||||
|
||||
The `util/` group gives capability packages shared mechanical primitives instead of duplicate implementations. It covers atomic writes, branded ids, deques, lossless JSON values, UUIDs, Harness-home paths, launch environments, outbound proxy policy, native commands, packaged ripgrep execution, output retention, time-zone, instant, and span vocabulary, and timeout handling. Every root entry here is a library: it registers no product service or event, and the consuming capability retains the business semantics. The exception is `official-bundles`: instead of a mechanical primitive, it holds the installation's and the plugin manager's official package lists as data their consumers apply.
|
||||
The `util/` group gives capability packages shared mechanical primitives instead of duplicate implementations. It covers atomic writes, branded ids, deques, lossless JSON values, UUIDs, Harness-home paths, launch environments, outbound proxy policy, native commands, packaged ripgrep execution, output retention, in-memory search filtering, time-zone, instant, and span vocabulary, and timeout handling. Every root entry here is a library: it registers no product service or event, and the consuming capability retains the business semantics. The exception is `official-bundles`: instead of a mechanical primitive, it holds the installation's and the plugin manager's official package lists as data their consumers apply.
|
||||
|
||||
## Table of Contents
|
||||
|
||||
@@ -44,6 +44,7 @@ Each package provides one primitive or one data set; open a package page for how
|
||||
| [`native-command/`](native-command/README.md) | Runs host-native commands directly, never through a shell string |
|
||||
| [`ripgrep/`](ripgrep/README.md) | Resolves the packaged ripgrep binary, spawns it through the caller's subprocess service, and streams its output records |
|
||||
| [`workspace-path/`](workspace-path/README.md) | Provides browser-safe Workspace path and display helpers |
|
||||
| [`text-search/`](text-search/README.md) | Filters and ranks in-memory search lists: names fuzzily, longer text as substrings, in every language a value carries |
|
||||
| [`code-language/`](code-language/README.md) | Maps a filename suffix to the syntax-highlighting language that the Code preview, diff review, and the read card render |
|
||||
| [`output-retention/`](output-retention/README.md) | Bounds model-facing output and reports exact omission metadata |
|
||||
| [`time/`](time/README.md) | Parses strict instants, local calendars, and caller-reported IANA zones, and holds a millisecond span |
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
---
|
||||
description: "共享工具家族的包映射:原子文件写入、品牌化 id、双端队列、JSON 值、harness 主目录路径、启动环境、原生命令、打包 ripgrep、输出保留、时间与时区词汇、超时,以及官方包列表。"
|
||||
description: "共享工具家族的包映射:原子文件写入、品牌化 id、双端队列、JSON 值、harness 主目录路径、启动环境、原生命令、打包 ripgrep、输出保留、内存搜索过滤、时间与时区词汇、超时,以及官方包列表。"
|
||||
kind: "package-group"
|
||||
---
|
||||
|
||||
@@ -9,7 +9,7 @@ kind: "package-group"
|
||||
|
||||
## 概述
|
||||
|
||||
`util/` 组为能力包提供共享的机制原语,避免重复实现。它涵盖原子写入、品牌化 id、双端队列、无损 JSON 值、UUID、Harness home 路径、启动环境、出站代理策略、原生命令、打包 ripgrep 的执行、输出保留、时区、时刻与时间段词汇,以及超时处理。这里的每个根入口都是库:它不注册产品服务或事件,业务语义仍由消费它的能力负责。例外是 `official-bundles`:它不是机制原语,而是以纯数据形式保存安装方和插件管理器的官方包列表,由各自的消费方应用。
|
||||
`util/` 组为能力包提供共享的机制原语,避免重复实现。它涵盖原子写入、品牌化 id、双端队列、无损 JSON 值、UUID、Harness home 路径、启动环境、出站代理策略、原生命令、打包 ripgrep 的执行、输出保留、内存搜索过滤、时区、时刻与时间段词汇,以及超时处理。这里的每个根入口都是库:它不注册产品服务或事件,业务语义仍由消费它的能力负责。例外是 `official-bundles`:它不是机制原语,而是以纯数据形式保存安装方和插件管理器的官方包列表,由各自的消费方应用。
|
||||
|
||||
## 目录
|
||||
|
||||
@@ -44,6 +44,7 @@ kind: "package-group"
|
||||
| [`native-command/`](native-command/README.zh.md) | 直接运行宿主原生命令,绝不拼 shell 字符串 |
|
||||
| [`ripgrep/`](ripgrep/README.zh.md) | 解析打包的 ripgrep 二进制,通过调用方的子进程服务启动它,并流式读取输出记录 |
|
||||
| [`workspace-path/`](workspace-path/README.zh.md) | 提供浏览器安全的 Workspace 路径与显示辅助函数 |
|
||||
| [`text-search/`](text-search/README.zh.md) | 过滤内存搜索列表并排序:名称按模糊匹配,较长文本按子串匹配,覆盖值所带的每种语言 |
|
||||
| [`code-language/`](code-language/README.zh.md) | 把文件名后缀映射为 Code 预览、diff 审阅与 read 卡片所渲染的语法高亮语言 |
|
||||
| [`output-retention/`](output-retention/README.zh.md) | 限制面向模型的输出并报告精确的省略元数据 |
|
||||
| [`time/`](time/README.zh.md) | 解析严格的时刻、本地日历与调用方所报的 IANA 时区,并持有毫秒精度的时间段 |
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
# Bilingual-pair consistency record for README.md (docs/i18n/README.md): per heading
|
||||
# section, a hash of its English and Chinese blocks outside code blocks and generated regions.
|
||||
# After editing either side, bring the other along and re-record with:
|
||||
# pnpm run verify-translation-pairing --write packages/util/text-search/README.md
|
||||
/:
|
||||
en: 007ab32164ceae3f
|
||||
zh: aba970d895f23de0
|
||||
/dsh-util-text-search:
|
||||
en: 32ceb63844402e40
|
||||
zh: 24646e3e3d7322db
|
||||
/dsh-util-text-search/summary:
|
||||
en: ab079a968e937b49
|
||||
zh: f0e00e1e40e8c854
|
||||
/dsh-util-text-search/table-of-contents:
|
||||
en: cd2a60a905c978d6
|
||||
zh: cc71d387d0cbd442
|
||||
/dsh-util-text-search/use-this-package:
|
||||
en: 08d2d2bc1c0c18e9
|
||||
zh: 3fd2dec893d3c00b
|
||||
/dsh-util-text-search/api:
|
||||
en: 4fbc544f66856819
|
||||
zh: e403bb676f2097ef
|
||||
/dsh-util-text-search/model-experience:
|
||||
en: ce4ba96f1f25ee8e
|
||||
zh: 1425688e714bf6b6
|
||||
/dsh-util-text-search/model-experience/kv-cache-effect:
|
||||
en: 3729e5630da1b5e8
|
||||
zh: c56bc426600e375a
|
||||
/dsh-util-text-search/known-limitations-and-deferred-work:
|
||||
en: d196f430e3c21f1c
|
||||
zh: 775505641b5b5fb3
|
||||
/dsh-util-text-search/known-limitations-and-deferred-work/dev-note:
|
||||
en: b193fa395f503e74
|
||||
zh: b2a69b31f43b9b84
|
||||
@@ -0,0 +1,93 @@
|
||||
---
|
||||
description: "Multilingual fuzzy search index for maintainers adding a search box or filter over an in-memory list."
|
||||
kind: "package-library"
|
||||
---
|
||||
|
||||
# dsh-util-text-search
|
||||
|
||||
English | [中文](README.zh.md)
|
||||
|
||||
## Summary
|
||||
|
||||
One search index for every in-memory search list in the Web client and for Host lists that feed it, such as `@` Session candidates. It implements the [client search rule](../../client/AGENTS.md#search-and-filter): results display in the current locale, matching covers every declared language and every field a user can identify an item by, and matching is fuzzy. Name matching uses [fuzzysort](https://github.com/farzher/fuzzysort), pinned to an exact version.
|
||||
|
||||
## Table of Contents
|
||||
|
||||
- [Use this package](#use-this-package)
|
||||
- [API](#api)
|
||||
- [Model Experience](#model-experience)
|
||||
- [Known Limitations and Deferred Work](#known-limitations-and-deferred-work)
|
||||
- [Dev Note](#dev-note)
|
||||
|
||||
-----
|
||||
|
||||
<a id="use-this-package"></a>
|
||||
## Use this package
|
||||
|
||||
It is a **library, not a service or plugin**: no `ctx` and registers nothing. The caller owns each index; browser bundles inline it.
|
||||
|
||||
```ts
|
||||
import type { LocalizedText } from '@deepseek-ai/dsh-package-manifest'
|
||||
import { localizedValues, TextSearchIndex, type SearchKeys } from '@deepseek-ai/dsh-util-text-search'
|
||||
|
||||
interface Row { readonly id: string; readonly meta?: { readonly title?: LocalizedText; readonly description?: LocalizedText } }
|
||||
const keys = (row: Row): SearchKeys => ({
|
||||
fuzzy: [row.id, ...localizedValues(row.meta?.title)],
|
||||
substring: localizedValues(row.meta?.description),
|
||||
})
|
||||
|
||||
const rows: readonly Row[] = [{ id: 'plugin-filter', meta: { title: { en: 'Plugin filter', zh: '插件筛选' } } }]
|
||||
const index = new TextSearchIndex(rows, keys)
|
||||
const shown = index.search('筛选')
|
||||
|
||||
const next = index.update([...rows, { id: 'session-search' }], keys)
|
||||
```
|
||||
|
||||
Build the index when the list changes and call `search` on every keystroke; a React component builds it in `useMemo` over the list. When the list changes often, as the sidebar's Session list does while replies run, keep the previous index and call `update` with the complete new list. Put short identifying text (names, titles, labels, readable ids) in `fuzzy` and longer text or opaque ids (descriptions, prompts, paths, UUIDs) in `substring`. Pass every language of a localized value, not the resolved display string.
|
||||
|
||||
-----
|
||||
|
||||
<a id="api"></a>
|
||||
## API
|
||||
|
||||
| Export | Role |
|
||||
|---|---|
|
||||
| `new TextSearchIndex(items, keys)` | Calls `keys` once per item and prepares every key string. The index holds `items` by reference; callers must not mutate the list or its items. |
|
||||
| `index.search(query)` | Returns the build list itself for a blank query. Otherwise splits the query on whitespace, keeps the items where every term matches some key, and orders them by total score, then build order. |
|
||||
| `index.update(items, keys)` | Returns a new index over the complete new list; additions, removals, reorders, and changed keys are all expressed by that list. Key strings this index already prepared are reused, strings no item uses any more are dropped, and this index stays valid. |
|
||||
| `localizedValues(text)` | Every language of a `LocalizedText`; `[]` for `undefined`. |
|
||||
| `SearchKeys` | `{ fuzzy?, substring? }`; `undefined` and empty values never match. |
|
||||
|
||||
Matching rules:
|
||||
|
||||
- Both key kinds and the query are compared after NFKC normalization, removal of Latin-style diacritics (U+0300–U+036F) and letter strokes, and lowercasing, so `web` matches `WEB` and `lodz` matches `Łódź`. Marks that change a letter in other scripts, such as kana voicing, stay. A query term made only of removed marks is ignored.
|
||||
- A **`fuzzy`** key matches when the term is a substring of it, or a fuzzysort subsequence of it that starts at a word start (after a separator, at a camel-case hump, or at any CJK character), so `cpt` matches `compact` but `fab` does not match `Refactor build`.
|
||||
- A **`substring`** key matches only when the term is a contiguous substring. A subsequence scattered across a sentence does not count, so `invoice` does not match an unrelated task prompt.
|
||||
- Each term scores by tier: `fuzzy`-key prefix, then `fuzzy`-key substring, then fuzzy subsequence by fuzzysort score, then `substring`-key hit; equal scores keep the build order.
|
||||
|
||||
<a id="model-experience"></a>
|
||||
## Model Experience
|
||||
|
||||
None, as the package filters caller-owned lists for search boxes and registers nothing model-facing.
|
||||
|
||||
#### KV Cache effect
|
||||
|
||||
None; consumers own any request content.
|
||||
|
||||
## Known Limitations and Deferred Work
|
||||
|
||||
<a id="known-limitations-and-deferred-work"></a>
|
||||
|
||||
- **No typo tolerance** — a transposed or wrong letter (`pluign`) does not match; fuzzysort matches subsequences only.
|
||||
- **Dictionary copy matches one language** — client locale dictionaries resolve only the active language through `t()`, so lists whose labels come from them, such as built-in `/` commands and shortcut names, match those labels only in the current language. Their names still match in every language.
|
||||
- **Plugin market and file `@` search are separate** — the plugin market keeps its MiniSearch index on the Host, and file references keep their path ranking; both serve larger lists than this package targets.
|
||||
|
||||
<a id="dev-note"></a>
|
||||
### Dev Note
|
||||
|
||||
<details>
|
||||
<summary>Working context for maintainers — click to expand</summary>
|
||||
|
||||
fuzzysort is pinned to an exact version because its scores order every search list; an upgrade changes visible ordering and must update the affected tests together.
|
||||
|
||||
</details>
|
||||
@@ -0,0 +1,93 @@
|
||||
---
|
||||
description: "面向为内存列表添加搜索框或过滤器的维护者,说明多语言模糊搜索索引。"
|
||||
kind: "package-library"
|
||||
---
|
||||
|
||||
# dsh-util-text-search
|
||||
|
||||
[English](README.md) | 中文
|
||||
|
||||
## 概述
|
||||
|
||||
Web 客户端中的所有内存搜索列表,以及为其提供数据的 Host 列表(例如 `@` 会话候选项),都使用同一个搜索索引。它实现[客户端搜索规则](../../client/AGENTS.md#search-and-filter):结果按当前语言显示,匹配覆盖所有已声明的语言以及用户可用来识别条目的每个字段,并且匹配是模糊匹配。名称匹配使用 [fuzzysort](https://github.com/farzher/fuzzysort),并固定到精确版本。
|
||||
|
||||
## 目录
|
||||
|
||||
- [使用本包](#use-this-package)
|
||||
- [API](#api)
|
||||
- [模型体验](#model-experience)
|
||||
- [已知限制与延期工作](#known-limitations-and-deferred-work)
|
||||
- [开发备注](#dev-note)
|
||||
|
||||
-----
|
||||
|
||||
<a id="use-this-package"></a>
|
||||
## 使用本包
|
||||
|
||||
它是**库,不是服务也不是插件**:无 `ctx`,也不注册任何东西。每个索引由调用方持有;浏览器打包产物会内联本包。
|
||||
|
||||
```ts
|
||||
import type { LocalizedText } from '@deepseek-ai/dsh-package-manifest'
|
||||
import { localizedValues, TextSearchIndex, type SearchKeys } from '@deepseek-ai/dsh-util-text-search'
|
||||
|
||||
interface Row { readonly id: string; readonly meta?: { readonly title?: LocalizedText; readonly description?: LocalizedText } }
|
||||
const keys = (row: Row): SearchKeys => ({
|
||||
fuzzy: [row.id, ...localizedValues(row.meta?.title)],
|
||||
substring: localizedValues(row.meta?.description),
|
||||
})
|
||||
|
||||
const rows: readonly Row[] = [{ id: 'plugin-filter', meta: { title: { en: 'Plugin filter', zh: '插件筛选' } } }]
|
||||
const index = new TextSearchIndex(rows, keys)
|
||||
const shown = index.search('筛选')
|
||||
|
||||
const next = index.update([...rows, { id: 'session-search' }], keys)
|
||||
```
|
||||
|
||||
列表变化时构建索引,每次按键时调用 `search`;React 组件在 `useMemo` 中基于列表构建索引。列表频繁变化时(例如回复运行期间侧边栏的会话列表),保留上一个索引,并用完整的新列表调用 `update`。把简短的标识文本(名称、标题、标签、可读 id)放进 `fuzzy`,把较长的文本或不透明 id(描述、提示词、路径、UUID)放进 `substring`。本地化值要传入它的所有语言,而不是解析后的显示字符串。
|
||||
|
||||
-----
|
||||
|
||||
<a id="api"></a>
|
||||
## API
|
||||
|
||||
| 导出 | 角色 |
|
||||
|---|---|
|
||||
| `new TextSearchIndex(items, keys)` | 对每个条目调用一次 `keys`,并预处理每个键字符串。索引按引用持有 `items`;调用方不得修改该列表及其中的条目。 |
|
||||
| `index.search(query)` | 查询为空白时直接返回构建时的列表本身。否则按空白字符拆分查询,保留每个查询词都能匹配至少一个键的条目,并先按总分、再按构建顺序排序。 |
|
||||
| `index.update(items, keys)` | 基于完整的新列表返回一个新索引;新增、删除、重排和键的变化都由这份列表表达。本索引已预处理的键字符串会被复用,不再被任何条目使用的字符串会被丢弃,本索引仍然有效。 |
|
||||
| `localizedValues(text)` | `LocalizedText` 的所有语言值;参数为 `undefined` 时返回 `[]`。 |
|
||||
| `SearchKeys` | `{ fuzzy?, substring? }`;`undefined` 和空值永远不会匹配。 |
|
||||
|
||||
匹配规则:
|
||||
|
||||
- 两类键和查询都先经过 NFKC 规范化、去除拉丁式变音符号(U+0300–U+036F)和字母笔画、转为小写,再进行比较,因此 `web` 匹配 `WEB`,`lodz` 匹配 `Łódź`。在其他文字中会改变字母的附加符号(如假名浊音符号)保持不变。只由被去除的附加符号组成的查询词会被忽略。
|
||||
- 查询词是某个 **`fuzzy`** 键的子串,或是该键的 fuzzysort 子序列且该子序列从词首开始(分隔符之后、驼峰命名的大写字母处,或任一 CJK 字符处)时,该键匹配,因此 `cpt` 匹配 `compact`,但 `fab` 不匹配 `Refactor build`。
|
||||
- 只有查询词是某个 **`substring`** 键的连续子串时,该键才匹配。分散在一句话中的子序列不算匹配,因此 `invoice` 不会匹配无关的任务提示词。
|
||||
- 每个查询词按档位计分,依次为:`fuzzy` 键前缀、`fuzzy` 键子串、模糊子序列(按 fuzzysort 分数)、`substring` 键命中;分数相同时保持构建顺序。
|
||||
|
||||
<a id="model-experience"></a>
|
||||
## 模型体验
|
||||
|
||||
无,因为这个包为搜索框过滤调用方拥有的列表,不注册任何面向模型的内容。
|
||||
|
||||
#### KV Cache 影响
|
||||
|
||||
无;任何请求内容都由消费方拥有。
|
||||
|
||||
## 已知限制与延期工作
|
||||
|
||||
<a id="known-limitations-and-deferred-work"></a>
|
||||
|
||||
- **不容忍拼写错误**:字母调换或写错(`pluign`)时不会匹配;fuzzysort 只匹配子序列。
|
||||
- **字典文案只匹配一种语言**:客户端语言字典通过 `t()` 只解析当前语言,因此标签来自这些字典的列表(例如内置 `/` 命令和快捷键名称)只能按当前语言匹配这些标签。这些条目的名称仍可按所有语言匹配。
|
||||
- **插件市场和文件 `@` 搜索各自独立**:插件市场在 Host 上维护自己的 MiniSearch 索引,文件引用保留自己的路径排序;两者处理的列表都比本包面向的列表更大。
|
||||
|
||||
<a id="dev-note"></a>
|
||||
### 开发备注
|
||||
|
||||
<details>
|
||||
<summary>维护者工作上下文——点击展开</summary>
|
||||
|
||||
fuzzysort 固定到精确版本,因为它的分数决定所有搜索列表的顺序;升级会改变用户可见的排序,必须同时更新受影响的测试。
|
||||
|
||||
</details>
|
||||
@@ -0,0 +1,42 @@
|
||||
{
|
||||
"name": "@deepseek-ai/dsh-util-text-search",
|
||||
"description": "Multilingual fuzzy filtering for in-memory search lists",
|
||||
"version": "0.2.2-rc.2",
|
||||
"publishConfig": {
|
||||
"access": "public"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/deepseek-ai/deepseek-harness.git",
|
||||
"directory": "packages/util/text-search"
|
||||
},
|
||||
"type": "module",
|
||||
"main": "lib/index.js",
|
||||
"types": "lib/types/index.d.ts",
|
||||
"exports": {
|
||||
".": {
|
||||
"types": "./lib/types/index.d.ts",
|
||||
"default": "./lib/index.js"
|
||||
},
|
||||
"./src/*": "./src/*",
|
||||
"./package.json": "./package.json"
|
||||
},
|
||||
"files": [
|
||||
"lib/index.js",
|
||||
"lib/types/**/*.d.ts",
|
||||
"lib/types/**/*.d.ts.map",
|
||||
"lib/**/*.js.map",
|
||||
"src"
|
||||
],
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@deepseek-ai/dsh-package-manifest": "workspace:*",
|
||||
"fuzzysort": "4.0.2"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@deepseek-ai/cordis": "workspace:~"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@deepseek-ai/cordis": "workspace:~"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,301 @@
|
||||
/**
|
||||
* Multilingual fuzzy search over an in-memory list.
|
||||
*
|
||||
* A {@link TextSearchIndex} prepares every key of a list once, then answers
|
||||
* any number of queries over that list. `fuzzy` keys (names, titles, labels,
|
||||
* readable ids) match as substrings or as fuzzysort subsequences that start at
|
||||
* a word start, so `cpt` finds `compact` while `fab` does not match inside
|
||||
* `Refactor build`. `substring` keys (descriptions, prompts, paths, opaque
|
||||
* ids) match only as a contiguous substring of each query term: a subsequence
|
||||
* scattered across a long sentence is noise. Every key may carry several
|
||||
* values, such as every language of a localized title. Both key kinds ignore
|
||||
* case, width (NFKC), U+0300–U+036F diacritics, and the stroke of letters such
|
||||
* as `ł` and `ø`. Matching requires every whitespace-separated query term to
|
||||
* match some key of the item.
|
||||
*
|
||||
* Each term scores by its best tier: a fuzzy-key prefix, then a fuzzy-key
|
||||
* substring, then a fuzzy subsequence ordered by fuzzysort score, then a
|
||||
* substring-key hit. Equal scores keep the build order, so a term that
|
||||
* prefixes every name leaves the list in product order.
|
||||
*
|
||||
* @module @deepseek-ai/dsh-util-text-search
|
||||
*/
|
||||
|
||||
import fuzzysort from 'fuzzysort'
|
||||
import type { Prepared } from 'fuzzysort'
|
||||
import type { LocalizedText } from '@deepseek-ai/dsh-package-manifest'
|
||||
|
||||
/** The text one item offers to a search; absent and empty values never match. */
|
||||
export interface SearchKeys {
|
||||
/** Short identifying text matched as substrings or word-start fuzzy subsequences, ranked first: names, titles, labels, readable ids. */
|
||||
readonly fuzzy?: readonly (string | undefined)[]
|
||||
/** Longer text and opaque ids matched only as contiguous substrings: descriptions, prompts, paths, UUIDs. */
|
||||
readonly substring?: readonly (string | undefined)[]
|
||||
}
|
||||
|
||||
/** Tier bases; a fuzzy subsequence hit adds its fuzzysort score in [0, 1) to its base. */
|
||||
const FUZZY_PREFIX = 4
|
||||
const FUZZY_SUBSTRING = 3
|
||||
const FUZZY_SUBSEQUENCE = 2
|
||||
const SUBSTRING = 1
|
||||
|
||||
/**
|
||||
* Every language of a localized value.
|
||||
* @param text - plain or localized text.
|
||||
* @returns the plain string, or every locale's value; none when absent.
|
||||
*/
|
||||
export function localizedValues(text: LocalizedText | undefined): readonly string[] {
|
||||
if (text === undefined) return []
|
||||
return typeof text === 'string' ? [text] : Object.values(text)
|
||||
}
|
||||
|
||||
const WORD_CHAR = /[\p{L}\p{N}]/u
|
||||
const UPPER = /\p{Lu}/u
|
||||
const LOWER = /\p{Ll}/u
|
||||
/** Scripts written without spaces between words; each of their characters starts a word. */
|
||||
const UNSPACED = /[\p{scx=Han}\p{scx=Hira}\p{scx=Kana}\p{scx=Hang}]/u
|
||||
|
||||
/** The code point starting at UTF-16 offset `index`, which callers keep inside `text`. */
|
||||
function codePointAt(text: string, index: number): string {
|
||||
return String.fromCodePoint(text.codePointAt(index) as number)
|
||||
}
|
||||
|
||||
/** The code point ending just before UTF-16 offset `index`. */
|
||||
function codePointBefore(text: string, index: number): string {
|
||||
const low = text.charCodeAt(index - 1)
|
||||
const start = low >= 0xdc00 && low <= 0xdfff && index >= 2 ? index - 2 : index - 1
|
||||
return codePointAt(text, start)
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether the code point at UTF-16 offset `index` of `text` starts a word: after a separator,
|
||||
* at a camel-case hump, or in an unspaced script.
|
||||
*/
|
||||
function wordStart(text: string, index: number): boolean {
|
||||
if (index === 0) return true
|
||||
const char = codePointAt(text, index)
|
||||
const previous = codePointBefore(text, index)
|
||||
return !WORD_CHAR.test(previous) || UNSPACED.test(char) || (UPPER.test(char) && LOWER.test(previous))
|
||||
}
|
||||
|
||||
const PRINTABLE_ASCII = /^[\x20-\x7e]*$/
|
||||
|
||||
/** Combining diacritical marks; other scripts' combining marks, such as kana voicing or Indic vowel signs, change the letter and stay. */
|
||||
const DIACRITIC = /[\u0300-\u036f]/gu
|
||||
|
||||
/** Letters with a built-in stroke that decomposition leaves intact, mapped to their base letter. */
|
||||
const STROKED: Readonly<Record<string, string>> = {
|
||||
'ø': 'o', 'Ø': 'O', 'ł': 'l', 'Ł': 'L', 'đ': 'd', 'Đ': 'D', 'ð': 'd', 'Ð': 'D', 'ı': 'i', 'ħ': 'h', 'Ħ': 'H', 'ŧ': 't', 'Ŧ': 'T',
|
||||
}
|
||||
const STROKED_CHAR = /[øØłŁđĐðÐıħĦŧŦ]/gu
|
||||
|
||||
/** Width- and diacritic-insensitive form that keeps case, so camel-case humps survive for word starts. */
|
||||
function strip(value: string): string {
|
||||
// Printable ASCII has no width forms or combining marks, and most keys are ASCII.
|
||||
if (PRINTABLE_ASCII.test(value)) return value
|
||||
return value.normalize('NFKD').replace(DIACRITIC, '').normalize('NFKC').replace(STROKED_CHAR, char => STROKED[char] as string)
|
||||
}
|
||||
|
||||
/** Case-, width-, and diacritic-insensitive form used for substring tests. */
|
||||
function fold(value: string): string {
|
||||
return strip(value).toLowerCase()
|
||||
}
|
||||
|
||||
/** One fuzzy key prepared at build; word starts and fuzzysort targets fill in on first fuzzy attempt. */
|
||||
interface PreparedName {
|
||||
readonly stripped: string
|
||||
readonly folded: string
|
||||
/** Word-start positions of `stripped`, computed on the first fuzzy attempt. */
|
||||
starts: readonly number[] | undefined
|
||||
/** fuzzysort targets of `stripped` from one word start onward, prepared on first use. */
|
||||
readonly tails: Map<number, Prepared>
|
||||
}
|
||||
|
||||
/** One item's keys prepared at build. */
|
||||
interface PreparedKeys {
|
||||
readonly fuzzy: readonly PreparedName[]
|
||||
readonly substring: readonly string[]
|
||||
}
|
||||
|
||||
/** One query term in the two forms the tiers compare. */
|
||||
interface Term {
|
||||
readonly stripped: string
|
||||
readonly folded: string
|
||||
}
|
||||
|
||||
/** Prepared key strings of one index, by original string; an update reuses the entries its items still use. */
|
||||
interface Preparations {
|
||||
readonly fuzzy: Map<string, PreparedName>
|
||||
readonly substring: Map<string, string>
|
||||
}
|
||||
|
||||
/**
|
||||
* Prepare one item's keys, reusing an earlier index's preparation of the same string.
|
||||
* @param keys - the item's search text.
|
||||
* @param reuse - preparations of the index being updated, if any.
|
||||
* @param into - preparations of the index being built; receives every string this item uses.
|
||||
*/
|
||||
function prepareKeys(keys: SearchKeys, reuse: Preparations | undefined, into: Preparations): PreparedKeys {
|
||||
const fuzzy = (keys.fuzzy ?? []).flatMap((value) => {
|
||||
if (value === undefined || value === '') return []
|
||||
let name = into.fuzzy.get(value) ?? reuse?.fuzzy.get(value)
|
||||
if (name === undefined) {
|
||||
const stripped = strip(value)
|
||||
name = { stripped, folded: stripped.toLowerCase(), starts: undefined, tails: new Map() }
|
||||
}
|
||||
into.fuzzy.set(value, name)
|
||||
return [name]
|
||||
})
|
||||
const substring = (keys.substring ?? []).flatMap((value) => {
|
||||
if (value === undefined || value === '') return []
|
||||
const folded = into.substring.get(value) ?? reuse?.substring.get(value) ?? fold(value)
|
||||
into.substring.set(value, folded)
|
||||
return [folded]
|
||||
})
|
||||
return { fuzzy, substring }
|
||||
}
|
||||
|
||||
/** Prepare every item's keys. */
|
||||
function build<T>(items: readonly T[], keys: (item: T) => SearchKeys, reuse: Preparations | undefined): {
|
||||
readonly keys: readonly PreparedKeys[]
|
||||
readonly preparations: Preparations
|
||||
} {
|
||||
const preparations: Preparations = { fuzzy: new Map(), substring: new Map() }
|
||||
return { keys: items.map(item => prepareKeys(keys(item), reuse, preparations)), preparations }
|
||||
}
|
||||
|
||||
/** Whether every character of `term` occurs in `text` in order; a cheap filter before fuzzysort. */
|
||||
function inOrder(term: string, text: string): boolean {
|
||||
let at = 0
|
||||
for (const char of term) {
|
||||
at = text.indexOf(char, at)
|
||||
if (at === -1) return false
|
||||
at += char.length
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
/**
|
||||
* The best fuzzysort score of a term over the subsequences of `name` that start at a word start.
|
||||
* fuzzysort reports one alignment per target, so each word start whose character equals the term's
|
||||
* first character is tried as its own target.
|
||||
*/
|
||||
function fuzzyNameScore(term: Term, name: PreparedName): number | undefined {
|
||||
if (!inOrder(term.folded, name.folded)) return undefined
|
||||
if (name.starts === undefined) {
|
||||
const starts: number[] = []
|
||||
let index = 0
|
||||
for (const char of name.stripped) {
|
||||
if (wordStart(name.stripped, index)) starts.push(index)
|
||||
index += char.length
|
||||
}
|
||||
name.starts = starts
|
||||
}
|
||||
const first = codePointAt(term.stripped, 0).toLowerCase()
|
||||
let best: number | undefined
|
||||
for (const start of name.starts) {
|
||||
if (codePointAt(name.stripped, start).toLowerCase() !== first) continue
|
||||
let tail = name.tails.get(start)
|
||||
if (tail === undefined) {
|
||||
// An uncached target: fuzzysort's own target cache would grow with every distinct name for the process lifetime.
|
||||
tail = fuzzysort.prepare(name.stripped.slice(start))
|
||||
name.tails.set(start, tail)
|
||||
}
|
||||
const result = fuzzysort.single(term.stripped, tail)
|
||||
if (result !== null && wordStart(name.stripped, start + (result.indexes[0] as number))) {
|
||||
best = best === undefined ? result.score : Math.max(best, result.score)
|
||||
}
|
||||
}
|
||||
return best
|
||||
}
|
||||
|
||||
/** The best score of one term over one item's keys, or undefined when no key matches. */
|
||||
function termScore(term: Term, keys: PreparedKeys): number | undefined {
|
||||
let best: number | undefined
|
||||
const take = (score: number): void => { best = best === undefined ? score : Math.max(best, score) }
|
||||
for (const name of keys.fuzzy) {
|
||||
const at = name.folded.indexOf(term.folded)
|
||||
if (at === 0) take(FUZZY_PREFIX)
|
||||
else if (at > 0) take(FUZZY_SUBSTRING)
|
||||
else {
|
||||
const score = fuzzyNameScore(term, name)
|
||||
// A fuzzysort score of 1 is reserved for exact matches, which the prefix tier already took.
|
||||
if (score !== undefined) take(FUZZY_SUBSEQUENCE + Math.min(score, 0.99))
|
||||
}
|
||||
}
|
||||
for (const text of keys.substring) {
|
||||
if (text.includes(term.folded)) take(SUBSTRING)
|
||||
}
|
||||
return best
|
||||
}
|
||||
|
||||
/**
|
||||
* Search index over one list. The constructor prepares every key of every
|
||||
* item; {@link TextSearchIndex.search} then answers queries without
|
||||
* re-reading the items or their keys. An index holds its list by reference and
|
||||
* never changes: callers must not mutate the list or its items, and call
|
||||
* {@link TextSearchIndex.update} with a new list when the list or any item's
|
||||
* keys change.
|
||||
*/
|
||||
export class TextSearchIndex<T> {
|
||||
#items: readonly T[]
|
||||
#keys: readonly PreparedKeys[]
|
||||
#preparations: Preparations
|
||||
|
||||
/**
|
||||
* Prepare every key of every item.
|
||||
* @param items - candidates in their display order, which ties keep.
|
||||
* @param keys - the search text of one item, called once per item here.
|
||||
*/
|
||||
constructor(items: readonly T[], keys: (item: T) => SearchKeys) {
|
||||
const built = build(items, keys, undefined)
|
||||
this.#items = items
|
||||
this.#keys = built.keys
|
||||
this.#preparations = built.preparations
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the index of a changed list. Items added, removed, reordered, or
|
||||
* changed are all expressed by the complete new list; a key string that this
|
||||
* index already prepared is reused instead of prepared again, and strings no
|
||||
* item uses any more are not carried over. This index stays valid.
|
||||
* @param items - the complete new list in display order.
|
||||
* @param keys - the search text of one item, called once per item here.
|
||||
* @returns a new index over `items`.
|
||||
*/
|
||||
update(items: readonly T[], keys: (item: T) => SearchKeys): TextSearchIndex<T> {
|
||||
const next = new TextSearchIndex<T>([], keys)
|
||||
const built = build(items, keys, this.#preparations)
|
||||
next.#items = items
|
||||
next.#keys = built.keys
|
||||
next.#preparations = built.preparations
|
||||
return next
|
||||
}
|
||||
|
||||
/**
|
||||
* Filter and rank the indexed items by a query.
|
||||
* @param query - the user's search text.
|
||||
* @returns the build list itself when the query is blank or holds only
|
||||
* combining marks; otherwise the items matching every query term, best total
|
||||
* score first and build order on ties.
|
||||
*/
|
||||
search(query: string): readonly T[] {
|
||||
// A term made only of combining marks folds to nothing and constrains nothing.
|
||||
const terms = query.trim().split(/\s+/u)
|
||||
.map((term): Term => ({ stripped: strip(term), folded: fold(term) }))
|
||||
.filter(term => term.folded !== '')
|
||||
if (terms.length === 0) return this.#items
|
||||
const ranked: { readonly index: number; readonly score: number }[] = []
|
||||
this.#keys.forEach((itemKeys, index) => {
|
||||
let score = 0
|
||||
for (const term of terms) {
|
||||
const hit = termScore(term, itemKeys)
|
||||
if (hit === undefined) return
|
||||
score += hit
|
||||
}
|
||||
ranked.push({ index, score })
|
||||
})
|
||||
ranked.sort((left, right) => right.score - left.score || left.index - right.index)
|
||||
return ranked.map(entry => this.#items[entry.index] as T)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,203 @@
|
||||
/**
|
||||
* Search index contract: fuzzy and substring keys, every query term required,
|
||||
* multilingual values, folding, stable ranking, and updates.
|
||||
*/
|
||||
import { describe, expect, it } from 'vitest'
|
||||
import { localizedValues, TextSearchIndex, type SearchKeys } from '../src/index.ts'
|
||||
|
||||
interface Row { readonly id: string; readonly title?: string; readonly description?: string }
|
||||
|
||||
const rows: readonly Row[] = [
|
||||
{ id: 'compact', title: 'Compact context', description: 'Summarize earlier turns to free model context' },
|
||||
{ id: 'clipboard-paste', title: 'Clipboard paste', description: 'Paste images and text into the composer' },
|
||||
{ id: 'computer-use', title: 'Computer use', description: 'Control the mouse, keyboard, and screen' },
|
||||
{ id: 'session-title', title: 'Session title', description: 'Generate a title for each session with a model' },
|
||||
]
|
||||
const keys = (row: Row): SearchKeys => ({ fuzzy: [row.id, row.title], substring: [row.description] })
|
||||
const search = <T>(items: readonly T[], query: string, itemKeys: (item: T) => SearchKeys): readonly T[] =>
|
||||
new TextSearchIndex(items, itemKeys).search(query)
|
||||
const ids = (query: string, items: readonly Row[] = rows) => search(items, query, keys).map(row => row.id)
|
||||
|
||||
describe('localizedValues', () => {
|
||||
it('returns every language of a localized value', () => {
|
||||
expect(localizedValues(undefined)).toEqual([])
|
||||
expect(localizedValues('Plain')).toEqual(['Plain'])
|
||||
expect(localizedValues({ en: 'Filter', zh: '筛选' })).toEqual(['Filter', '筛选'])
|
||||
})
|
||||
})
|
||||
|
||||
describe('TextSearchIndex.search', () => {
|
||||
it('returns the build list itself for a blank query', () => {
|
||||
expect(search(rows, ' ', keys)).toBe(rows)
|
||||
})
|
||||
|
||||
it('matches fuzzy keys as fuzzy subsequences', () => {
|
||||
expect(ids('cpt')).toEqual(expect.arrayContaining(['compact', 'computer-use']))
|
||||
expect(ids('cpt')).not.toContain('session-title')
|
||||
expect(ids('xyz')).toEqual([])
|
||||
})
|
||||
|
||||
it('ranks fuzzy-key prefixes, then fuzzy-key substrings, then fuzzy subsequences, then substring keys', () => {
|
||||
const items: readonly Row[] = [
|
||||
{ id: 'notes', description: 'Keep model notes' },
|
||||
{ id: 'mxoxdxexl' },
|
||||
{ id: 'big-model' },
|
||||
{ id: 'model-list' },
|
||||
]
|
||||
expect(ids('model', items)).toEqual(['model-list', 'big-model', 'mxoxdxexl', 'notes'])
|
||||
})
|
||||
|
||||
it('orders fuzzy subsequence hits by fuzzysort score', () => {
|
||||
// Word starts outrank letters scattered inside one word.
|
||||
expect(ids('ftr', [{ id: 'filter' }, { id: 'f-t-r-x' }])).toEqual(['f-t-r-x', 'filter'])
|
||||
})
|
||||
|
||||
it('keeps build order among equal matches', () => {
|
||||
const items: readonly Row[] = [{ id: 'open-z' }, { id: 'open-a' }, { id: 'x-open' }]
|
||||
expect(ids('open', items)).toEqual(['open-z', 'open-a', 'x-open'])
|
||||
})
|
||||
|
||||
it('accepts a fuzzy subsequence hit only when it starts at a word start', () => {
|
||||
const items: readonly Row[] = [
|
||||
{ id: 'refactor', title: 'Refactor build pipeline' },
|
||||
{ id: 'flash', title: 'DeepSeekFlash' },
|
||||
{ id: 'zh', title: '插件筛选' },
|
||||
]
|
||||
expect(ids('fab', items)).toEqual([])
|
||||
expect(ids('rbp', items)).toEqual(['refactor'])
|
||||
expect(ids('sflsh', items)).toEqual(['flash'])
|
||||
expect(ids('件选', items)).toEqual(['zh'])
|
||||
// A word start after a separator also begins a match.
|
||||
expect(ids('bz', [{ id: 'foo-bar baz' }])).toEqual(['foo-bar baz'])
|
||||
})
|
||||
|
||||
it('finds a word-start match when an earlier letter mid-word would align first', () => {
|
||||
// fuzzysort aligns `plg` on the `p` inside `Open` and `cpt` on the `c` inside `Script`.
|
||||
expect(ids('plg', [{ id: 'Open plugin manager' }])).toEqual(['Open plugin manager'])
|
||||
expect(ids('cpt', [{ id: 'Script compact' }])).toEqual(['Script compact'])
|
||||
})
|
||||
|
||||
it('scores every term of a multi-term query against the same key', () => {
|
||||
// Both terms reach the fuzzy tier on one name and share its word starts.
|
||||
expect(ids('plgn mngr', [{ id: 'Open plugin manager' }, { id: 'Open plugin list' }])).toEqual(['Open plugin manager'])
|
||||
expect(ids('plgn plg', [{ id: 'Open plugin manager' }])).toEqual(['Open plugin manager'])
|
||||
})
|
||||
|
||||
it('matches opaque ids passed as substring keys only by substring', () => {
|
||||
const items: readonly Row[] = [
|
||||
{ id: 'title-only', description: 'session-3f2a9c1d-77aa-4b1e-9d0e-5a6b7c8d9e0f' },
|
||||
{ id: 'other', description: 'session-a1b2c3d4-0000-4000-8000-000000000000' },
|
||||
]
|
||||
expect(ids('a1', items)).toEqual(['other'])
|
||||
expect(ids('3f2a9c', items)).toEqual(['title-only'])
|
||||
})
|
||||
|
||||
it('matches substring keys only as contiguous substrings', () => {
|
||||
expect(ids('mouse')).toEqual(['computer-use'])
|
||||
// The letters of "invoice" occur in order across the long descriptions, but nowhere contiguously.
|
||||
expect(ids('invoice')).toEqual([])
|
||||
})
|
||||
|
||||
it('requires every query term to match some key', () => {
|
||||
expect(ids('paste composer')).toEqual(['clipboard-paste'])
|
||||
expect(ids('paste mouse')).toEqual([])
|
||||
})
|
||||
|
||||
it('matches every language of localized values', () => {
|
||||
const items = [
|
||||
{ id: 'plugin-filter', title: { en: 'Plugin filter', zh: '插件筛选' }, description: { en: 'Filter by name', zh: '按名称筛选' } },
|
||||
]
|
||||
const localizedKeys = (item: typeof items[number]): SearchKeys => ({
|
||||
fuzzy: [item.id, ...localizedValues(item.title)],
|
||||
substring: localizedValues(item.description),
|
||||
})
|
||||
expect(search(items, '筛选', localizedKeys)).toEqual(items)
|
||||
expect(search(items, '名称', localizedKeys)).toEqual(items)
|
||||
expect(search(items, 'plugin 筛选', localizedKeys)).toEqual(items)
|
||||
expect(search(items, '选筛', localizedKeys)).toEqual([])
|
||||
})
|
||||
|
||||
it('ignores case, width, and diacritics', () => {
|
||||
const items: readonly Row[] = [{ id: 'WEB-search', description: 'Café résumé' }]
|
||||
expect(ids('web', items)).toEqual(['WEB-search'])
|
||||
expect(ids('WEB', items)).toEqual(['WEB-search'])
|
||||
expect(ids('cafe', items)).toEqual(['WEB-search'])
|
||||
expect(ids('RESUME', items)).toEqual(['WEB-search'])
|
||||
})
|
||||
|
||||
it('applies the same normalization to fuzzy subsequence matches', () => {
|
||||
expect(ids('cpt', [{ id: 'Compact' }])).toEqual(['Compact'])
|
||||
expect(ids('wb', [{ id: 'WEB-search' }])).toEqual(['WEB-search'])
|
||||
// A decomposed query and a composed name match alike.
|
||||
expect(ids('re\u0301sm', [{ id: 'Résumé' }])).toEqual(['Résumé'])
|
||||
expect(ids('resm', [{ id: 'Résumé' }])).toEqual(['Résumé'])
|
||||
// Stroked letters fold to their base letter on both paths.
|
||||
expect(ids('lodz', [{ id: 'Łódź' }])).toEqual(['Łódź'])
|
||||
expect(ids('ostf', [{ id: 'Østfold' }])).toEqual(['Østfold'])
|
||||
expect(ids('mlg', [{ id: 'Małgorzata' }])).toEqual(['Małgorzata'])
|
||||
// A kana voicing mark changes the letter, so `か` does not find `が`.
|
||||
expect(ids('か', [{ id: 'が' }])).toEqual([])
|
||||
})
|
||||
|
||||
it('treats a term made only of combining marks as no term', () => {
|
||||
const items: readonly Row[] = [{ id: 'alpha' }, { id: 'beta' }]
|
||||
expect(search(items, '\u0301', row => ({ fuzzy: [row.id] }))).toBe(items)
|
||||
expect(ids('\u0301 beta', items)).toEqual(['beta'])
|
||||
})
|
||||
|
||||
it('finds word starts by code point, including characters outside the BMP', () => {
|
||||
// 𠀀 (U+20000) is a Han character stored as a surrogate pair.
|
||||
expect(ids('𠀀b', [{ id: '中𠀀x-b' }])).toEqual(['中𠀀x-b'])
|
||||
expect(ids('x𠀀', [{ id: 'a 𠀀' }])).toEqual([])
|
||||
})
|
||||
|
||||
it('skips absent and empty values', () => {
|
||||
const items: readonly Row[] = [{ id: '' }, { id: 'kept', title: '' }]
|
||||
expect(search(items, 'kept', row => ({ fuzzy: [row.id, row.title, undefined], substring: [undefined, ''] }))).toEqual([items[1]])
|
||||
expect(search(items, 'kept', () => ({}))).toEqual([])
|
||||
})
|
||||
})
|
||||
|
||||
describe('TextSearchIndex.update', () => {
|
||||
it('searches the complete new list, with removed items gone and added items found', () => {
|
||||
const index = new TextSearchIndex(rows, keys)
|
||||
const kept = rows.filter(row => row.id !== 'compact')
|
||||
const added: Row = { id: 'context-window', title: 'Context window' }
|
||||
const next = index.update([...kept, added], keys)
|
||||
expect(next.search('cpt').map(row => row.id)).not.toContain('compact')
|
||||
expect(next.search('ctx').map(row => row.id)).toEqual(['context-window'])
|
||||
expect(next.search('')).toEqual([...kept, added])
|
||||
})
|
||||
|
||||
it('reads changed keys and leaves the earlier index unchanged', () => {
|
||||
const index = new TextSearchIndex(rows, keys)
|
||||
const renamed = rows.map(row => row.id === 'compact' ? { ...row, id: 'shrink', title: 'Shrink history' } : row)
|
||||
const next = index.update(renamed, keys)
|
||||
expect(next.search('shrnk').map(row => row.id)).toEqual(['shrink'])
|
||||
expect(next.search('cmpct')).toEqual([])
|
||||
expect(index.search('cmpct').map(row => row.id)).toEqual(['compact'])
|
||||
expect(index.search('')).toBe(rows)
|
||||
})
|
||||
|
||||
it('returns what a fresh build of the same list returns', () => {
|
||||
// Searches on the earlier index fill in word starts and fuzzysort targets that the update then reuses.
|
||||
const index = new TextSearchIndex(rows, keys)
|
||||
const queries = ['cpt', 'model', 'mouse', 'paste composer', 'ses tit']
|
||||
for (const query of queries) index.search(query)
|
||||
const changed = [...rows].reverse().filter(row => row.id !== 'computer-use')
|
||||
const next = index.update(changed, keys)
|
||||
const fresh = new TextSearchIndex(changed, keys)
|
||||
for (const query of queries) expect(next.search(query)).toEqual(fresh.search(query))
|
||||
})
|
||||
|
||||
it('reads keys only while building', () => {
|
||||
let calls = 0
|
||||
const counted = (row: Row): SearchKeys => { calls += 1; return keys(row) }
|
||||
const index = new TextSearchIndex(rows, counted)
|
||||
index.search('cpt')
|
||||
index.search('model')
|
||||
expect(calls).toBe(rows.length)
|
||||
index.update(rows, counted)
|
||||
expect(calls).toBe(rows.length * 2)
|
||||
})
|
||||
})
|
||||
@@ -0,0 +1,14 @@
|
||||
{
|
||||
"extends": "../../../tsconfig.base.json",
|
||||
"compilerOptions": {
|
||||
"rootDir": "src",
|
||||
"outDir": "lib/types",
|
||||
"types": []
|
||||
},
|
||||
"include": [
|
||||
"src"
|
||||
],
|
||||
"references": [
|
||||
{ "path": "../package-manifest" }
|
||||
]
|
||||
}
|
||||
Generated
+48
@@ -4342,6 +4342,9 @@ importers:
|
||||
'@deepseek-ai/dsh-session':
|
||||
specifier: workspace:*
|
||||
version: link:../../core/session
|
||||
'@deepseek-ai/dsh-util-text-search':
|
||||
specifier: workspace:*
|
||||
version: link:../../util/text-search
|
||||
'@deepseek-ai/dsh-util-values':
|
||||
specifier: workspace:*
|
||||
version: link:../../util/values
|
||||
@@ -5190,6 +5193,9 @@ importers:
|
||||
'@deepseek-ai/dsh-typert-protocol':
|
||||
specifier: workspace:*
|
||||
version: link:../../typert/protocol
|
||||
'@deepseek-ai/dsh-util-text-search':
|
||||
specifier: workspace:*
|
||||
version: link:../../util/text-search
|
||||
'@deepseek-ai/dsh-util-values':
|
||||
specifier: workspace:*
|
||||
version: link:../../util/values
|
||||
@@ -5488,6 +5494,9 @@ importers:
|
||||
'@deepseek-ai/dsh-util-crypto':
|
||||
specifier: workspace:*
|
||||
version: link:../../util/crypto
|
||||
'@deepseek-ai/dsh-util-text-search':
|
||||
specifier: workspace:*
|
||||
version: link:../../util/text-search
|
||||
'@testing-library/react':
|
||||
specifier: ^16.3.3
|
||||
version: 16.3.3(@testing-library/[email protected])(@types/[email protected](@types/[email protected]))(@types/[email protected])([email protected]([email protected]))([email protected])
|
||||
@@ -5800,6 +5809,9 @@ importers:
|
||||
'@deepseek-ai/dsh-session':
|
||||
specifier: workspace:*
|
||||
version: link:../../core/session
|
||||
'@deepseek-ai/dsh-util-text-search':
|
||||
specifier: workspace:*
|
||||
version: link:../../util/text-search
|
||||
'@deepseek-ai/dsh-util-time':
|
||||
specifier: workspace:*
|
||||
version: link:../../util/time
|
||||
@@ -6198,6 +6210,9 @@ importers:
|
||||
'@deepseek-ai/dsh-remote-mock':
|
||||
specifier: workspace:*
|
||||
version: link:../../test-support/remote-mock
|
||||
'@deepseek-ai/dsh-util-text-search':
|
||||
specifier: workspace:*
|
||||
version: link:../../util/text-search
|
||||
'@deepseek-ai/dsh-util-values':
|
||||
specifier: workspace:*
|
||||
version: link:../../util/values
|
||||
@@ -6246,6 +6261,9 @@ importers:
|
||||
'@deepseek-ai/dsh-package-manifest':
|
||||
specifier: workspace:*
|
||||
version: link:../../util/package-manifest
|
||||
'@deepseek-ai/dsh-util-text-search':
|
||||
specifier: workspace:*
|
||||
version: link:../../util/text-search
|
||||
'@testing-library/react':
|
||||
specifier: ^16.3.3
|
||||
version: 16.3.3(@testing-library/[email protected])(@types/[email protected](@types/[email protected]))(@types/[email protected])([email protected]([email protected]))([email protected])
|
||||
@@ -6468,6 +6486,9 @@ importers:
|
||||
'@deepseek-ai/dsh-client-ui-slots':
|
||||
specifier: workspace:*
|
||||
version: link:../ui-slots
|
||||
'@deepseek-ai/dsh-util-text-search':
|
||||
specifier: workspace:*
|
||||
version: link:../../util/text-search
|
||||
clsx:
|
||||
specifier: ^2.1.1
|
||||
version: 2.1.1
|
||||
@@ -6958,6 +6979,9 @@ importers:
|
||||
'@deepseek-ai/dsh-session':
|
||||
specifier: workspace:*
|
||||
version: link:../../core/session
|
||||
'@deepseek-ai/dsh-util-text-search':
|
||||
specifier: workspace:*
|
||||
version: link:../../util/text-search
|
||||
'@deepseek-ai/dsh-util-values':
|
||||
specifier: workspace:*
|
||||
version: link:../../util/values
|
||||
@@ -7536,6 +7560,9 @@ importers:
|
||||
'@deepseek-ai/dsh-typert-protocol':
|
||||
specifier: workspace:*
|
||||
version: link:../../typert/protocol
|
||||
'@deepseek-ai/dsh-util-text-search':
|
||||
specifier: workspace:*
|
||||
version: link:../../util/text-search
|
||||
'@deepseek-ai/dsh-util-values':
|
||||
specifier: workspace:*
|
||||
version: link:../../util/values
|
||||
@@ -7966,6 +7993,9 @@ importers:
|
||||
'@deepseek-ai/dsh-brand':
|
||||
specifier: workspace:*
|
||||
version: link:../../util/brand
|
||||
'@deepseek-ai/dsh-util-text-search':
|
||||
specifier: workspace:*
|
||||
version: link:../../util/text-search
|
||||
'@deepseek-ai/dsh-util-values':
|
||||
specifier: workspace:*
|
||||
version: link:../../util/values
|
||||
@@ -19033,6 +19063,19 @@ importers:
|
||||
specifier: workspace:*
|
||||
version: link:../../subprocess/subprocess
|
||||
|
||||
packages/util/text-search:
|
||||
dependencies:
|
||||
'@deepseek-ai/dsh-package-manifest':
|
||||
specifier: workspace:*
|
||||
version: link:../package-manifest
|
||||
fuzzysort:
|
||||
specifier: 4.0.2
|
||||
version: 4.0.2
|
||||
devDependencies:
|
||||
'@deepseek-ai/cordis':
|
||||
specifier: workspace:~
|
||||
version: link:../../../vendor/cordis
|
||||
|
||||
packages/util/time:
|
||||
dependencies:
|
||||
'@js-temporal/polyfill':
|
||||
@@ -24882,6 +24925,9 @@ packages:
|
||||
[email protected]:
|
||||
resolution: {integrity: sha512-dsKNQNdj6xA3T+QlADDA7mOSlX0qiMINjn0cgr+eGHGsbSHzTabcIogz2+p/iqP1Xs6EP/sS2SbqH+brGTbq0g==}
|
||||
|
||||
[email protected]:
|
||||
resolution: {integrity: sha512-3c7yD6rK1EXIsqpcu1ZVzXJugODWNMzvUij6yTiziaAHrpNS8kzFOI9mJLE8pmG4K9JOaVgzQRgklfOEk8f4Tg==}
|
||||
|
||||
[email protected]:
|
||||
resolution: {integrity: sha512-5FZy72Rh8LhtjmvDrKkI+lVhrsQrVKVsItxMoDm5mNQE+xR0WVIIs+jzPSJgBvKVsLi24fZhXJIsNI0bihDzFg==}
|
||||
engines: {node: '>=18'}
|
||||
@@ -32668,6 +32714,8 @@ snapshots:
|
||||
|
||||
[email protected]: {}
|
||||
|
||||
[email protected]: {}
|
||||
|
||||
[email protected]([email protected]):
|
||||
dependencies:
|
||||
extend: 3.0.2
|
||||
|
||||
@@ -95,6 +95,7 @@ const PACKAGE_LIBRARIES: Readonly<Record<string, string>> = {
|
||||
'packages/util/brand': 'Stateless nominal-string and canonical-key constructors.',
|
||||
'packages/util/crypto': 'Zero-dependency identifier minting utility.',
|
||||
'packages/util/error': 'Zero-dependency HarnessError base class.',
|
||||
'packages/util/text-search': 'In-memory search filtering library.',
|
||||
'packages/util/deque': 'Zero-dependency circular deque utility.',
|
||||
'packages/util/chunked-list': 'Persistent collection operations and checkpoint validation without a plugin surface.',
|
||||
'packages/util/code-language': 'Zero-dependency file-extension to syntax-highlighting language table.',
|
||||
|
||||
@@ -41,6 +41,7 @@ const DUPLICATE_SAFE_PACKAGES: readonly string[] = [
|
||||
'@deepseek-ai/dsh-typert-protocol',
|
||||
'@deepseek-ai/dsh-util-code-language',
|
||||
'@deepseek-ai/dsh-util-crypto',
|
||||
'@deepseek-ai/dsh-util-text-search',
|
||||
'@deepseek-ai/dsh-util-values',
|
||||
]
|
||||
|
||||
|
||||
Loaded 100 of 104 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user