feat(skills): category picker with live search, select-all-matched, select-all and clear (0.9.4)

This commit is contained in:
newbie 2026-11-13 10:36:38 +08:00
parent 3d23769899
commit ac1e415208
9 changed files with 82 additions and 44 deletions

View File

@ -2535,26 +2535,42 @@ window.__ModuleLoader__.load({
var hay = (String(skill.name || '') + ' ' + String(skill.folder || '') + ' ' + String(skill.description || '')).toLowerCase()
return hay.indexOf(assignNeedle) >= 0
})
var selectedCount = tree.assign.selection.length
var matchedSelected = 0
filteredAssignable.forEach(function (skill) {
if (tree.assign.selection.indexOf(skill.folder) >= 0) matchedSelected += 1
})
function setSelection(next) {
patchTree({ assign: Object.assign({}, tree.assign, { selection: next }) })
}
function setSelectionFilter(value) {
patchTree({ assign: Object.assign({}, tree.assign, { search: value }) })
}
function selectMany(list, on) {
var next = tree.assign.selection.slice()
list.forEach(function (skill) {
var at = next.indexOf(skill.folder)
if (on && at < 0) next.push(skill.folder)
if (!on && at >= 0) next.splice(at, 1)
})
setSelection(next)
}
assignBox = h(
'div',
{ style: styles.row },
h(
'div',
{ style: styles.rowHead },
h('span', { style: styles.rowTitle }, '加入分类:' + String(assignGroup === undefined ? '' : assignGroup.name)),
h(
'span',
{ style: styles.rowTitle },
'加入分类:' + String(assignGroup === undefined ? '' : assignGroup.name) + '(已选 ' + String(tree.assign.selection.length) + ' 项)',
'div',
{ style: styles.pills },
h(Pill, { label: '可分配', value: String(assignable.length), tone: 'muted' }),
h(Pill, { label: '匹配', value: String(filteredAssignable.length), tone: filteredAssignable.length === 0 ? 'muted' : 'ok' }),
h(Pill, { label: '已选', value: String(selectedCount), tone: selectedCount === 0 ? 'muted' : 'ok' }),
),
h(Btn, {
label: '关闭',
variant: 'small',
onClick: function () {
patchTree({ assign: null })
},
}),
),
h('p', { style: styles.hint }, '勾选要放进这个分类的技能;一个技能只会属于一个分类,取消勾选即回到「未分类」。'),
h('p', { style: styles.hint }, '先搜索再勾选,或直接「全选匹配结果」一次性加入;一个技能只会属于一个分类,取消勾选即回到「未分类」。'),
h(
'div',
{ style: { display: 'flex', gap: '8px', alignItems: 'center', flexWrap: 'wrap' } },
@ -2562,41 +2578,64 @@ window.__ModuleLoader__.load({
type: 'search',
style: Object.assign({}, styles.input, { flex: '1 1 200px', minWidth: 0 }),
value: assignSearch,
placeholder: '搜索技能(按名称、目录或描述筛选)',
autoFocus: true,
placeholder: '搜索技能:名称 / 目录 / 描述',
'aria-label': '搜索要加入分类的技能',
onChange: function (event) {
patchTree({ assign: Object.assign({}, tree.assign, { search: event.target.value }) })
setSelectionFilter(event.target.value)
},
}),
filteredAssignable.length > 0
? h(Btn, {
label: '全选当前结果',
variant: 'small',
disabled: tree.busy !== '',
onClick: function () {
var next = tree.assign.selection.slice()
filteredAssignable.forEach(function (skill) {
if (next.indexOf(skill.folder) < 0) next.push(skill.folder)
})
patchTree({ assign: Object.assign({}, tree.assign, { selection: next }) })
},
})
: null,
assignSearch !== ''
? h(Btn, {
label: '清空搜索',
variant: 'small',
onClick: function () {
patchTree({ assign: Object.assign({}, tree.assign, { search: '' }) })
setSelectionFilter('')
},
})
: null,
),
h(
'div',
{ style: Object.assign({}, styles.actions, { flexWrap: 'wrap' }) },
h(Btn, {
label: '全选匹配结果(' + String(filteredAssignable.length) + ')',
variant: 'small',
disabled: tree.busy !== '' || filteredAssignable.length === 0,
onClick: function () {
selectMany(filteredAssignable, true)
},
}),
h(Btn, {
label: '全选全部(' + String(assignable.length) + ')',
variant: 'small',
disabled: tree.busy !== '' || assignable.length === 0 || selectedCount === assignable.length,
onClick: function () {
selectMany(assignable, true)
},
}),
h(Btn, {
label: '取消勾选匹配项(' + String(matchedSelected) + ')',
variant: 'small',
disabled: tree.busy !== '' || matchedSelected === 0,
onClick: function () {
selectMany(filteredAssignable, false)
},
}),
h(Btn, {
label: '清空已选',
variant: 'small',
disabled: tree.busy !== '' || selectedCount === 0,
onClick: function () {
setSelection([])
},
}),
),
filteredAssignable.length === 0
? h('p', { style: styles.hint }, assignable.length === 0 ? '当前来源还没有可分配的技能。' : '没有匹配「' + assignSearch + '」的技能。')
? h('p', { style: styles.hint }, assignable.length === 0 ? '当前来源还没有可分配的技能。' : '没有匹配「' + assignSearch + '」的技能。换个关键词,或点「清空搜索」看全部。')
: h(
'div',
{ style: { display: 'flex', flexDirection: 'column', gap: '4px', maxHeight: '240px', overflow: 'auto' } },
{ style: { display: 'flex', flexDirection: 'column', gap: '4px', maxHeight: '260px', overflow: 'auto' } },
filteredAssignable.map(function (skill) {
var checked = tree.assign.selection.indexOf(skill.folder) >= 0
return h(
@ -2606,11 +2645,7 @@ window.__ModuleLoader__.load({
type: 'checkbox',
checked: checked,
onChange: function (event) {
var next = tree.assign.selection.slice()
var at = next.indexOf(skill.folder)
if (event.target.checked && at < 0) next.push(skill.folder)
if (!event.target.checked && at >= 0) next.splice(at, 1)
patchTree({ assign: Object.assign({}, tree.assign, { selection: next }) })
selectMany([skill], event.target.checked === true)
},
}),
h(
@ -2627,7 +2662,7 @@ window.__ModuleLoader__.load({
{ style: styles.actions },
h(Btn, {
variant: 'primary',
label: '保存分类',
label: '保存分类(' + String(selectedCount) + ')',
disabled: tree.busy !== '',
onClick: function () {
saveAssign()

View File

@ -26,7 +26,7 @@ export const name = 'dsh-brain';
/** Services required before `apply` runs. */
export const inject = ['webServer'];
/** Version reported by the status card. */
const VERSION = '0.9.3';
const VERSION = '0.9.4';
/** How often the skill directory is reconciled with the cloud center. */
const SKILL_SYNC_INTERVAL_MS = 15 * 60_000;
/** How often queued reports are retried. */

View File

@ -17,7 +17,7 @@ import { descriptor } from "./descriptor.js";
import { LongMemoryProvider } from "./driver.js";
export { LongMemoryProvider, descriptor };
/** Keep in sync with the package version (asserted by the verify script). */
const PROVIDER_VERSION = '0.9.3';
const PROVIDER_VERSION = '0.9.4';
export const definition = defineMemorySpaceProviderDefinition({
manifest: {
apiVersion: MEMORY_SPACE_PROVIDER_API_VERSION,

View File

@ -1,6 +1,6 @@
{
"name": "dsh-brain",
"version": "0.9.3",
"version": "0.9.4",
"description": "Cloud memory for DSH: report one activity turn per conversation round and expose memory_search / memory_read / memory_add tools against a LongMemory cloud endpoint.",
"type": "module",
"license": "MIT",

View File

@ -30,7 +30,7 @@ export const name = 'dsh-brain'
export const inject = ['webServer']
/** Version reported by the status card. */
const VERSION = '0.9.3'
const VERSION = '0.9.4'
/** How often the skill directory is reconciled with the cloud center. */
const SKILL_SYNC_INTERVAL_MS = 15 * 60_000

View File

@ -23,7 +23,7 @@ import { LongMemoryProvider } from './driver.ts'
export { LongMemoryProvider, descriptor }
/** Keep in sync with the package version (asserted by the verify script). */
const PROVIDER_VERSION = '0.9.3'
const PROVIDER_VERSION = '0.9.4'
export const definition = defineMemorySpaceProviderDefinition({
manifest: {

View File

@ -485,7 +485,10 @@ check('clicking the import button reveals foreign sources as import candidates',
const openedAssign = await drive('skills', true, '把技能加入 QQ-Skill')
check('clicking + on a category opens the inline skill assignment picker with search',
openedAssign.includes('加入分类:QQ-Skill') &&
openedAssign.includes('全选当前结果') &&
openedAssign.includes('可分配') &&
openedAssign.includes('全选匹配结果') &&
openedAssign.includes('全选全部') &&
openedAssign.includes('清空已选') &&
openedAssign.includes('保存分类') &&
openedAssign.includes('parked-one'))

View File

@ -57,7 +57,7 @@ async function post(path, body) {
}
const caps = await get('/dsh-brain/capabilities')
check('capabilities answers with 0.9.3', caps.body?.version === '0.9.3', String(caps.body?.version))
check('capabilities answers with 0.9.4', caps.body?.version === '0.9.4', String(caps.body?.version))
check('P3 market is advertised with one provider', caps.body?.features?.skillsMarketplace === true && caps.body?.features?.marketProviders === 1)
check('P3 update and sync-resolve are advertised', caps.body?.features?.skillUpdate === true && caps.body?.features?.syncResolve === true)
check('P4/P5/v1.1 flags are advertised', caps.body?.features?.multiClient === true && caps.body?.features?.brainMigration === 'ready')

View File

@ -74,7 +74,7 @@ for (const name of readdirSync(libDir)) {
}
check('no personal domain remains in shipped lib/', leaked.length === 0, leaked.join(','))
const pkg = JSON.parse(readFileSync(join(process.cwd(), 'package.json'), 'utf8'))
check('package version is the delivery version', pkg.version === '0.9.3', pkg.version)
check('package version is the delivery version', pkg.version === '0.9.4', pkg.version)
const passed = results.filter((r) => r.ok).length
console.log(`\n${passed}/${results.length} passed`)