feat(skills): category picker with live search, select-all-matched, select-all and clear (0.9.4)
This commit is contained in:
parent
3d23769899
commit
ac1e415208
107
client/index.js
107
client/index.js
|
|
@ -2535,26 +2535,42 @@ window.__ModuleLoader__.load({
|
||||||
var hay = (String(skill.name || '') + ' ' + String(skill.folder || '') + ' ' + String(skill.description || '')).toLowerCase()
|
var hay = (String(skill.name || '') + ' ' + String(skill.folder || '') + ' ' + String(skill.description || '')).toLowerCase()
|
||||||
return hay.indexOf(assignNeedle) >= 0
|
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(
|
assignBox = h(
|
||||||
'div',
|
'div',
|
||||||
{ style: styles.row },
|
{ style: styles.row },
|
||||||
h(
|
h(
|
||||||
'div',
|
'div',
|
||||||
{ style: styles.rowHead },
|
{ style: styles.rowHead },
|
||||||
|
h('span', { style: styles.rowTitle }, '加入分类:' + String(assignGroup === undefined ? '' : assignGroup.name)),
|
||||||
h(
|
h(
|
||||||
'span',
|
'div',
|
||||||
{ style: styles.rowTitle },
|
{ style: styles.pills },
|
||||||
'加入分类:' + String(assignGroup === undefined ? '' : assignGroup.name) + '(已选 ' + String(tree.assign.selection.length) + ' 项)',
|
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(
|
h(
|
||||||
'div',
|
'div',
|
||||||
{ style: { display: 'flex', gap: '8px', alignItems: 'center', flexWrap: 'wrap' } },
|
{ style: { display: 'flex', gap: '8px', alignItems: 'center', flexWrap: 'wrap' } },
|
||||||
|
|
@ -2562,41 +2578,64 @@ window.__ModuleLoader__.load({
|
||||||
type: 'search',
|
type: 'search',
|
||||||
style: Object.assign({}, styles.input, { flex: '1 1 200px', minWidth: 0 }),
|
style: Object.assign({}, styles.input, { flex: '1 1 200px', minWidth: 0 }),
|
||||||
value: assignSearch,
|
value: assignSearch,
|
||||||
placeholder: '搜索技能(按名称、目录或描述筛选)',
|
autoFocus: true,
|
||||||
|
placeholder: '搜索技能:名称 / 目录 / 描述',
|
||||||
'aria-label': '搜索要加入分类的技能',
|
'aria-label': '搜索要加入分类的技能',
|
||||||
onChange: function (event) {
|
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 !== ''
|
assignSearch !== ''
|
||||||
? h(Btn, {
|
? h(Btn, {
|
||||||
label: '清空搜索',
|
label: '清空搜索',
|
||||||
variant: 'small',
|
variant: 'small',
|
||||||
onClick: function () {
|
onClick: function () {
|
||||||
patchTree({ assign: Object.assign({}, tree.assign, { search: '' }) })
|
setSelectionFilter('')
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
: null,
|
: 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
|
filteredAssignable.length === 0
|
||||||
? h('p', { style: styles.hint }, assignable.length === 0 ? '当前来源还没有可分配的技能。' : '没有匹配「' + assignSearch + '」的技能。')
|
? h('p', { style: styles.hint }, assignable.length === 0 ? '当前来源还没有可分配的技能。' : '没有匹配「' + assignSearch + '」的技能。换个关键词,或点「清空搜索」看全部。')
|
||||||
: h(
|
: h(
|
||||||
'div',
|
'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) {
|
filteredAssignable.map(function (skill) {
|
||||||
var checked = tree.assign.selection.indexOf(skill.folder) >= 0
|
var checked = tree.assign.selection.indexOf(skill.folder) >= 0
|
||||||
return h(
|
return h(
|
||||||
|
|
@ -2606,11 +2645,7 @@ window.__ModuleLoader__.load({
|
||||||
type: 'checkbox',
|
type: 'checkbox',
|
||||||
checked: checked,
|
checked: checked,
|
||||||
onChange: function (event) {
|
onChange: function (event) {
|
||||||
var next = tree.assign.selection.slice()
|
selectMany([skill], event.target.checked === true)
|
||||||
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 }) })
|
|
||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
h(
|
h(
|
||||||
|
|
@ -2627,7 +2662,7 @@ window.__ModuleLoader__.load({
|
||||||
{ style: styles.actions },
|
{ style: styles.actions },
|
||||||
h(Btn, {
|
h(Btn, {
|
||||||
variant: 'primary',
|
variant: 'primary',
|
||||||
label: '保存分类',
|
label: '保存分类(' + String(selectedCount) + ')',
|
||||||
disabled: tree.busy !== '',
|
disabled: tree.busy !== '',
|
||||||
onClick: function () {
|
onClick: function () {
|
||||||
saveAssign()
|
saveAssign()
|
||||||
|
|
|
||||||
|
|
@ -26,7 +26,7 @@ export const name = 'dsh-brain';
|
||||||
/** Services required before `apply` runs. */
|
/** Services required before `apply` runs. */
|
||||||
export const inject = ['webServer'];
|
export const inject = ['webServer'];
|
||||||
/** Version reported by the status card. */
|
/** 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. */
|
/** How often the skill directory is reconciled with the cloud center. */
|
||||||
const SKILL_SYNC_INTERVAL_MS = 15 * 60_000;
|
const SKILL_SYNC_INTERVAL_MS = 15 * 60_000;
|
||||||
/** How often queued reports are retried. */
|
/** How often queued reports are retried. */
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,7 @@ import { descriptor } from "./descriptor.js";
|
||||||
import { LongMemoryProvider } from "./driver.js";
|
import { LongMemoryProvider } from "./driver.js";
|
||||||
export { LongMemoryProvider, descriptor };
|
export { LongMemoryProvider, descriptor };
|
||||||
/** Keep in sync with the package version (asserted by the verify script). */
|
/** 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({
|
export const definition = defineMemorySpaceProviderDefinition({
|
||||||
manifest: {
|
manifest: {
|
||||||
apiVersion: MEMORY_SPACE_PROVIDER_API_VERSION,
|
apiVersion: MEMORY_SPACE_PROVIDER_API_VERSION,
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "dsh-brain",
|
"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.",
|
"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",
|
"type": "module",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
|
|
|
||||||
|
|
@ -30,7 +30,7 @@ export const name = 'dsh-brain'
|
||||||
export const inject = ['webServer']
|
export const inject = ['webServer']
|
||||||
|
|
||||||
/** Version reported by the status card. */
|
/** 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. */
|
/** How often the skill directory is reconciled with the cloud center. */
|
||||||
const SKILL_SYNC_INTERVAL_MS = 15 * 60_000
|
const SKILL_SYNC_INTERVAL_MS = 15 * 60_000
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,7 @@ import { LongMemoryProvider } from './driver.ts'
|
||||||
export { LongMemoryProvider, descriptor }
|
export { LongMemoryProvider, descriptor }
|
||||||
|
|
||||||
/** Keep in sync with the package version (asserted by the verify script). */
|
/** 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({
|
export const definition = defineMemorySpaceProviderDefinition({
|
||||||
manifest: {
|
manifest: {
|
||||||
|
|
|
||||||
|
|
@ -485,7 +485,10 @@ check('clicking the import button reveals foreign sources as import candidates',
|
||||||
const openedAssign = await drive('skills', true, '把技能加入 QQ-Skill')
|
const openedAssign = await drive('skills', true, '把技能加入 QQ-Skill')
|
||||||
check('clicking + on a category opens the inline skill assignment picker with search',
|
check('clicking + on a category opens the inline skill assignment picker with search',
|
||||||
openedAssign.includes('加入分类:QQ-Skill') &&
|
openedAssign.includes('加入分类:QQ-Skill') &&
|
||||||
openedAssign.includes('全选当前结果') &&
|
openedAssign.includes('可分配') &&
|
||||||
|
openedAssign.includes('全选匹配结果') &&
|
||||||
|
openedAssign.includes('全选全部') &&
|
||||||
|
openedAssign.includes('清空已选') &&
|
||||||
openedAssign.includes('保存分类') &&
|
openedAssign.includes('保存分类') &&
|
||||||
openedAssign.includes('parked-one'))
|
openedAssign.includes('parked-one'))
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -57,7 +57,7 @@ async function post(path, body) {
|
||||||
}
|
}
|
||||||
|
|
||||||
const caps = await get('/dsh-brain/capabilities')
|
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 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('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')
|
check('P4/P5/v1.1 flags are advertised', caps.body?.features?.multiClient === true && caps.body?.features?.brainMigration === 'ready')
|
||||||
|
|
|
||||||
|
|
@ -74,7 +74,7 @@ for (const name of readdirSync(libDir)) {
|
||||||
}
|
}
|
||||||
check('no personal domain remains in shipped lib/', leaked.length === 0, leaked.join(','))
|
check('no personal domain remains in shipped lib/', leaked.length === 0, leaked.join(','))
|
||||||
const pkg = JSON.parse(readFileSync(join(process.cwd(), 'package.json'), 'utf8'))
|
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
|
const passed = results.filter((r) => r.ok).length
|
||||||
console.log(`\n${passed}/${results.length} passed`)
|
console.log(`\n${passed}/${results.length} passed`)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue