fix(skills): render category + assign picker inline & collapse import section into button (0.9.2)

This commit is contained in:
newbie 2026-11-13 09:45:08 +08:00
parent 0de6552059
commit 03e78d95d8
9 changed files with 69 additions and 15 deletions

View File

@ -1255,12 +1255,12 @@ window.__ModuleLoader__.load({
}
// ---- import skills from other tools -------------------------------
function ImportSection() {
var tuple = React.useState({ status: 'loading', sources: [], open: {}, busy: '', notice: null, imported: {} })
function ImportSection(props) {
var onImported = props && typeof props.onImported === 'function' ? props.onImported : null
var tuple = React.useState({ expanded: false, status: 'idle', sources: [], open: {}, busy: '', notice: null, imported: {} })
var s = tuple[0]
var set = tuple[1]
function patch(next) { set(function (prev) { return Object.assign({}, prev, next) }) }
React.useEffect(function () { load() }, [])
function load() {
patch({ status: 'loading', notice: null })
request(API.skills + '/sources', { method: 'GET' }).then(function (res) {
@ -1269,6 +1269,13 @@ window.__ModuleLoader__.load({
} else patch({ status: 'error', notice: { tone: 'bad', text: bodyError(res, '读取来源失败') } })
}, function (error) { patch({ status: 'error', notice: { tone: 'bad', text: messageOf(error) } }) })
}
function openPanel() {
patch({ expanded: true })
if (s.status === 'idle' || s.status === 'error') load()
}
function closePanel() {
patch({ expanded: false })
}
function dshFolders() {
var found = {}
s.sources.forEach(function (source) {
@ -1293,9 +1300,22 @@ window.__ModuleLoader__.load({
var imported = Object.assign({}, s.imported)
imported[skill.folder] = true
patch({ busy: '', imported: imported, notice: { tone: 'ok', text: '已导入「' + skill.name + '」到 DSH,技能文件夹里就能看到。' } })
if (onImported !== null) onImported()
} else patch({ busy: '', notice: { tone: 'bad', text: bodyError(res, '导入失败') } })
}, function (error) { patch({ busy: '', notice: { tone: 'bad', text: messageOf(error) } }) })
}
if (!s.expanded) {
return h(
'div',
{ style: { display: 'flex', alignItems: 'center', justifyContent: 'space-between', gap: '8px', flexWrap: 'wrap' } },
h(Btn, {
label: '从其他软件导入',
ariaLabel: '从其他软件导入',
onClick: openPanel,
}),
s.notice === null ? null : h(Banner, { tone: s.notice.tone }, s.notice.text),
)
}
var mine = dshFolders()
var others = s.sources.filter(function (source) { return !source.writable })
var rows = others.map(function (source) {
@ -1332,7 +1352,18 @@ window.__ModuleLoader__.load({
})),
)
})
return h(Section, { title: '从其他软件导入', hint: '把其他软件技能目录里的技能复制一份到 DSH,原目录不动;同名技能不能重复导入。', aside: h(Btn, { label: '刷新', variant: 'small', onClick: load }) },
return h(
Section,
{
title: '从其他软件导入',
hint: '把其他软件技能目录里的技能复制一份到 DSH,原目录不动;同名技能不能重复导入。',
aside: h(
'div',
{ style: styles.actions },
h(Btn, { label: '刷新', variant: 'small', onClick: load }),
h(Btn, { label: '收起', variant: 'small', onClick: closePanel }),
),
},
s.status === 'loading' ? h('p', { style: styles.hint }, '正在读取来源…')
: others.length === 0 ? h('p', { style: styles.hint }, '没有检测到其他软件的技能目录。')
: h('div', { style: { display: 'flex', flexDirection: 'column', gap: '10px' } }, rows),
@ -1725,7 +1756,13 @@ window.__ModuleLoader__.load({
}
function openAssign(source, group) {
var renameKey = String(source.id) + ':' + group.id
if (tree.assign !== null && tree.assign.sourceId === source.id && tree.assign.groupId === group.id) {
patchTree({ assign: null })
return
}
patchTree({
openGroups: Object.assign({}, tree.openGroups, { [renameKey]: true }),
assign: {
sourceId: source.id,
groupId: group.id,
@ -2603,6 +2640,7 @@ window.__ModuleLoader__.load({
var renameKey = String(source.id) + ':' + group.id
var renaming = tree.edit !== null && tree.edit.kind === 'rename' && tree.edit.key === renameKey
var confirming = tree.confirm === renameKey
var assigning = tree.assign !== null && tree.assign.sourceId === source.id && tree.assign.groupId === group.id
var groupSkills = group.visible === undefined ? group.skills || [] : group.visible
return h(
'div',
@ -2682,12 +2720,15 @@ window.__ModuleLoader__.load({
}),
),
),
assigning ? h('div', { style: styles.nested }, assignBox) : null,
open
? h(
'div',
{ style: styles.nested },
groupSkills.length === 0
? h('p', { style: styles.hint }, group.id === 'unassigned' ? '没有未分类的技能。' : '这个分类还没有技能,点「+」加入。')
? assigning
? null
: h('p', { style: styles.hint }, group.id === 'unassigned' ? '没有未分类的技能。' : '这个分类还没有技能,点「+」加入。')
: groupSkills.map(function (skill) {
return renderSkillRow(source, skill)
}),
@ -2704,7 +2745,12 @@ window.__ModuleLoader__.load({
'div',
{ style: styles.root, key: 'skills' },
h(ImportSection, {}),
h(ImportSection, {
onImported: function () {
loadTree()
loadSkills()
},
}),
h(
Section,

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.0';
const VERSION = '0.9.2';
/** 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.0';
const PROVIDER_VERSION = '0.9.2';
export const definition = defineMemorySpaceProviderDefinition({
manifest: {
apiVersion: MEMORY_SPACE_PROVIDER_API_VERSION,

View File

@ -1,6 +1,6 @@
{
"name": "dsh-brain",
"version": "0.9.1",
"version": "0.9.2",
"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.0'
const VERSION = '0.9.2'
/** 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.0'
const PROVIDER_VERSION = '0.9.2'
export const definition = defineMemorySpaceProviderDefinition({
manifest: {

View File

@ -475,8 +475,16 @@ check('the tree is DSH-only: no source card, no foreign sources',
!skillsText.includes('C:/Users/test/.dsh/skills') && !skillsText.includes('由 Codex 自行加载'))
check('categories render with their counts', skillsText.includes('QQ-Skill') && skillsText.includes('1 项 · 1/1 启用') && skillsText.includes('未分类'))
check('the metadata-only promise is on screen', skillsText.includes('分类只记在这个来源里,不移动文件'))
check('foreign sources appear only as import candidates',
skillsText.includes('Codex') && !skillsText.includes('仅本卡'))
check('foreign sources start collapsed behind the import button',
!skillsText.includes('Codex') && !skillsText.includes('仅本卡'))
const openedImport = await drive('skills', true, '从其他软件导入')
check('clicking the import button reveals foreign sources as import candidates',
openedImport.includes('Codex') && openedImport.includes('收起') && !openedImport.includes('仅本卡'))
const openedAssign = await drive('skills', true, '把技能加入 QQ-Skill')
check('clicking + on a category opens the inline skill assignment picker',
openedAssign.includes('加入分类:QQ-Skill') && openedAssign.includes('保存分类') && openedAssign.includes('parked-one'))
// Categories start collapsed; expanding one must reveal its skills.
const expandedSkills = await drive('skills', true, '展开或收起 未分类')

View File

@ -57,7 +57,7 @@ async function post(path, body) {
}
const caps = await get('/dsh-brain/capabilities')
check('capabilities answers with 0.8.0', caps.body?.version === '0.9.0', String(caps.body?.version))
check('capabilities answers with 0.9.2', caps.body?.version === '0.9.2', 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.0', pkg.version)
check('package version is the delivery version', pkg.version === '0.9.2', pkg.version)
const passed = results.filter((r) => r.ok).length
console.log(`\n${passed}/${results.length} passed`)