From c7907735c34dbd49405a41920f659d9fcb5a91ac Mon Sep 17 00:00:00 2001 From: newbie Date: Fri, 27 Nov 2026 18:05:55 +0800 Subject: [PATCH] fix(ui): settle overview requests independently and fix three layout faults - Overview: Promise.allSettled per endpoint, so one failing auxiliary call no longer blanks the whole page or hides the version. - MemoryTab: distinguish 'no memories yet' from 'no match on this page'. - RawTab: auto-fit grid so the two columns collapse on a narrow panel. - Pills: clip long values instead of overflowing the rounded box. --- client/index.js | 51 ++++++++++++++++---------- src-client/components.tsx | 4 +- src-client/panel/BrainPanel.module.css | 6 +++ src-client/panel/MemoryTab.tsx | 2 +- src-client/panel/Overview.tsx | 36 ++++++++++-------- src-client/panel/RawTab.tsx | 2 +- src-client/styles.ts | 3 +- 7 files changed, 64 insertions(+), 40 deletions(-) diff --git a/client/index.js b/client/index.js index 72749bc..c5d6e92 100644 --- a/client/index.js +++ b/client/index.js @@ -268,7 +268,8 @@ window.__ModuleLoader__.load({ fontSize: "12px", maxWidth: "100%", whiteSpace: "nowrap", - flex: "0 0 auto" + overflow: "hidden", + flex: "0 1 auto" }, table: { width: "100%", @@ -485,7 +486,15 @@ window.__ModuleLoader__.load({ const h$13 = react.createElement; function Pill$1(props) { var tone = styles[props.tone] === void 0 ? styles.muted : styles[props.tone]; - return h$13("span", { style: Object.assign({}, styles.pill, tone) }, h$13("span", { style: { opacity: .75 } }, props.label), h$13("span", { style: { fontWeight: 600 } }, String(props.value))); + return h$13("span", { style: Object.assign({}, styles.pill, tone) }, h$13("span", { style: { + opacity: .75, + flex: "0 0 auto" + } }, props.label), h$13("span", { style: { + fontWeight: 600, + overflow: "hidden", + textOverflow: "ellipsis", + minWidth: 0 + } }, String(props.value))); } function Banner(props) { var tone = styles[props.tone] === void 0 ? styles.muted : styles[props.tone]; @@ -4131,7 +4140,7 @@ window.__ModuleLoader__.load({ }))); } // \0dsh-brain-css:src-client/panel/BrainPanel.module.css.mjs - const css = "/* Adapted from dsh-mnemon MnemonWorkspace.dshbrain_1xedgey.dshbrain_holtzx (MIT), see vendor/dsh-mnemon/LICENSE. */\n.dshbrain_1y11fqi {\n box-sizing: border-box;\n position: relative;\n z-index: 2;\n display: flex;\n width: 100%;\n height: 100%;\n min-width: 0;\n min-height: 0;\n overflow: hidden;\n flex: 1 1 auto;\n padding-block-start: var(--dsh-frame-top-clearance, 0px);\n}\n\n.dshbrain_1y11fqi > * {\n min-width: 0;\n flex: 1 1 auto;\n}\n\n.dshbrain_131vunv {\n position: absolute;\n inset: 0 0 auto;\n height: var(--dsh-frame-top-clearance, 0px);\n}\n\n.dshbrain_oyvdy4 {\n display: flex;\n flex-direction: column;\n gap: 14px;\n padding: 18px 20px 24px;\n overflow: auto;\n font-size: 13px;\n line-height: 1.55;\n color: var(--dsw-alias-label-primary, inherit);\n}\n\n.dshbrain_of3f1r {\n display: flex;\n align-items: flex-start;\n justify-content: space-between;\n gap: 12px;\n flex-wrap: wrap;\n}\n\n.dshbrain_vnw8w9 {\n display: flex;\n flex-direction: column;\n gap: 2px;\n min-width: 0;\n}\n\n.dshbrain_g8fis8 {\n margin: 0;\n font-size: 16px;\n font-weight: 650;\n letter-spacing: 0.01em;\n}\n\n.dshbrain_1milhhm {\n margin: 0;\n font-size: 11.5px;\n opacity: 0.58;\n}\n\n.dshbrain_xnx8bm {\n display: flex;\n gap: 4px;\n padding: 3px;\n border-radius: 13px;\n border: 1px solid var(--dsw-alias-border-subtle, rgba(127,127,127,0.22));\n background: var(--dsw-alias-bg-subtle, rgba(127,127,127,0.06));\n flex-wrap: wrap;\n}\n\n.dshbrain_7mndvh {\n flex: 1 1 auto;\n min-width: 88px;\n font: inherit;\n font-size: 12.5px;\n padding: 7px 12px;\n border-radius: 10px;\n border: 1px solid transparent;\n background: transparent;\n color: inherit;\n cursor: pointer;\n white-space: nowrap;\n}\n\n.dshbrain_rvx7lj {\n border: 1px solid var(--dsw-alias-border-subtle, rgba(127,127,127,0.30));\n background: var(--dsw-alias-interactive-bg-hover, rgba(127,127,127,0.14));\n box-shadow: 0 1px 3px rgba(0,0,0,0.10);\n font-weight: 600;\n}\n\n.dshbrain_1rfmkcf {\n display: flex;\n flex-direction: column;\n gap: 12px;\n min-width: 0;\n}\n\n.dshbrain_c36neh {\n display: flex;\n flex-direction: column;\n gap: 12px;\n}\n\n.dshbrain_1a7ley4 {\n display: flex;\n flex-direction: column;\n gap: 10px;\n border: 1px solid var(--dsw-alias-border-subtle, rgba(127,127,127,0.22));\n border-radius: 16px;\n padding: 16px 18px;\n min-width: 0;\n}\n\n.dshbrain_1f1qv8u {\n display: flex;\n align-items: center;\n justify-content: space-between;\n gap: 10px;\n flex-wrap: wrap;\n}\n\n.dshbrain_1t5691m {\n margin: 0;\n font-size: 13.5px;\n font-weight: 650;\n}\n\n.dshbrain_updgou {\n display: flex;\n flex-wrap: wrap;\n gap: 8px;\n}\n\n.dshbrain_xwrsl5 {\n display: inline-flex;\n align-items: center;\n gap: 6px;\n padding: 3px 10px;\n border-radius: 999px;\n border: 1px solid var(--dsw-alias-border-subtle, rgba(127,127,127,0.35));\n font-size: 12px;\n white-space: nowrap;\n}\n\n.dshbrain_mvsf69 {\n opacity: 0.75;\n}\n\n.dshbrain_1xby9uu {\n font-weight: 600;\n}\n\n.dshbrain_1bzyta0 { border-color: rgba(22,163,74,0.55); background: rgba(22,163,74,0.12); }\n.dshbrain_1hx5ob5 { border-color: rgba(220,38,38,0.55); background: rgba(220,38,38,0.12); }\n.dshbrain_amukxq { border-color: rgba(217,119,6,0.55); background: rgba(217,119,6,0.12); }\n.dshbrain_uf6ztt { }\n\n.dshbrain_1vi102j {\n margin: 0;\n font-size: 11.5px;\n opacity: 0.58;\n}\n\n.dshbrain_qmj948 {\n padding: 10px 13px;\n border-radius: 11px;\n border: 1px solid rgba(220,38,38,0.55);\n background: rgba(220,38,38,0.12);\n font-size: 12.5px;\n}\n\n.dshbrain_1ex8b80 {\n display: flex;\n align-items: baseline;\n flex-wrap: wrap;\n}\n\n.dshbrain_1048ygk {\n display: inline-flex;\n align-items: baseline;\n gap: 6px;\n padding-right: 18px;\n margin-right: 18px;\n border-right: 1px solid var(--dsw-alias-border-subtle, rgba(127,127,127,0.20));\n}\n\n.dshbrain_1bvujjo {\n display: inline-flex;\n align-items: baseline;\n gap: 6px;\n}\n\n.dshbrain_d75ahw {\n font-size: 17px;\n font-weight: 700;\n}\n"; + const css = "/* Adapted from dsh-mnemon MnemonWorkspace.dshbrain_1xedgey.dshbrain_holtzx (MIT), see vendor/dsh-mnemon/LICENSE. */\n.dshbrain_1y11fqi {\n box-sizing: border-box;\n position: relative;\n z-index: 2;\n display: flex;\n width: 100%;\n height: 100%;\n min-width: 0;\n min-height: 0;\n overflow: hidden;\n flex: 1 1 auto;\n padding-block-start: var(--dsh-frame-top-clearance, 0px);\n}\n\n.dshbrain_1y11fqi > * {\n min-width: 0;\n flex: 1 1 auto;\n}\n\n.dshbrain_131vunv {\n position: absolute;\n inset: 0 0 auto;\n height: var(--dsh-frame-top-clearance, 0px);\n}\n\n.dshbrain_oyvdy4 {\n display: flex;\n flex-direction: column;\n gap: 14px;\n padding: 18px 20px 24px;\n overflow: auto;\n font-size: 13px;\n line-height: 1.55;\n color: var(--dsw-alias-label-primary, inherit);\n}\n\n.dshbrain_of3f1r {\n display: flex;\n align-items: flex-start;\n justify-content: space-between;\n gap: 12px;\n flex-wrap: wrap;\n}\n\n.dshbrain_vnw8w9 {\n display: flex;\n flex-direction: column;\n gap: 2px;\n min-width: 0;\n}\n\n.dshbrain_g8fis8 {\n margin: 0;\n font-size: 16px;\n font-weight: 650;\n letter-spacing: 0.01em;\n}\n\n.dshbrain_1milhhm {\n margin: 0;\n font-size: 11.5px;\n opacity: 0.58;\n}\n\n.dshbrain_xnx8bm {\n display: flex;\n gap: 4px;\n padding: 3px;\n border-radius: 13px;\n border: 1px solid var(--dsw-alias-border-subtle, rgba(127,127,127,0.22));\n background: var(--dsw-alias-bg-subtle, rgba(127,127,127,0.06));\n flex-wrap: wrap;\n}\n\n.dshbrain_7mndvh {\n flex: 1 1 auto;\n min-width: 88px;\n font: inherit;\n font-size: 12.5px;\n padding: 7px 12px;\n border-radius: 10px;\n border: 1px solid transparent;\n background: transparent;\n color: inherit;\n cursor: pointer;\n white-space: nowrap;\n}\n\n.dshbrain_rvx7lj {\n border: 1px solid var(--dsw-alias-border-subtle, rgba(127,127,127,0.30));\n background: var(--dsw-alias-interactive-bg-hover, rgba(127,127,127,0.14));\n box-shadow: 0 1px 3px rgba(0,0,0,0.10);\n font-weight: 600;\n}\n\n.dshbrain_1rfmkcf {\n display: flex;\n flex-direction: column;\n gap: 12px;\n min-width: 0;\n}\n\n.dshbrain_c36neh {\n display: flex;\n flex-direction: column;\n gap: 12px;\n}\n\n.dshbrain_1a7ley4 {\n display: flex;\n flex-direction: column;\n gap: 10px;\n border: 1px solid var(--dsw-alias-border-subtle, rgba(127,127,127,0.22));\n border-radius: 16px;\n padding: 16px 18px;\n min-width: 0;\n}\n\n.dshbrain_1f1qv8u {\n display: flex;\n align-items: center;\n justify-content: space-between;\n gap: 10px;\n flex-wrap: wrap;\n}\n\n.dshbrain_1t5691m {\n margin: 0;\n font-size: 13.5px;\n font-weight: 650;\n}\n\n.dshbrain_updgou {\n display: flex;\n flex-wrap: wrap;\n gap: 8px;\n}\n\n.dshbrain_xwrsl5 {\n display: inline-flex;\n align-items: center;\n gap: 6px;\n padding: 3px 10px;\n border-radius: 999px;\n border: 1px solid var(--dsw-alias-border-subtle, rgba(127,127,127,0.35));\n font-size: 12px;\n white-space: nowrap;\n overflow: hidden;\n max-width: 100%;\n}\n\n.dshbrain_mvsf69 {\n opacity: 0.75;\n flex: 0 0 auto;\n}\n\n.dshbrain_1xby9uu {\n font-weight: 600;\n overflow: hidden;\n text-overflow: ellipsis;\n min-width: 0;\n}\n\n.dshbrain_1bzyta0 { border-color: rgba(22,163,74,0.55); background: rgba(22,163,74,0.12); }\n.dshbrain_1hx5ob5 { border-color: rgba(220,38,38,0.55); background: rgba(220,38,38,0.12); }\n.dshbrain_amukxq { border-color: rgba(217,119,6,0.55); background: rgba(217,119,6,0.12); }\n.dshbrain_uf6ztt { }\n\n.dshbrain_1vi102j {\n margin: 0;\n font-size: 11.5px;\n opacity: 0.58;\n}\n\n.dshbrain_qmj948 {\n padding: 10px 13px;\n border-radius: 11px;\n border: 1px solid rgba(220,38,38,0.55);\n background: rgba(220,38,38,0.12);\n font-size: 12.5px;\n}\n\n.dshbrain_1ex8b80 {\n display: flex;\n align-items: baseline;\n flex-wrap: wrap;\n}\n\n.dshbrain_1048ygk {\n display: inline-flex;\n align-items: baseline;\n gap: 6px;\n padding-right: 18px;\n margin-right: 18px;\n border-right: 1px solid var(--dsw-alias-border-subtle, rgba(127,127,127,0.20));\n}\n\n.dshbrain_1bvujjo {\n display: inline-flex;\n align-items: baseline;\n gap: 6px;\n}\n\n.dshbrain_d75ahw {\n font-size: 17px;\n font-weight: 700;\n}\n"; const tagId = "src-client/panel/BrainPanel.module.css"; if (typeof document !== "undefined" && typeof document.querySelector === "function" && typeof document.createElement === "function") { let tag = document.querySelector("style[data-plugin-css=" + JSON.stringify(tagId) + "]"); @@ -4202,23 +4211,25 @@ window.__ModuleLoader__.load({ if (!active) return; let cancelled = false; const load = async () => { - try { - const [statusResult, capabilitiesResult, memoryResult] = await Promise.all([ - request(API.status), - request(API.capabilities), - request("/dsh-brain/local-memory/status?scope=global") - ]); - if (cancelled) return; - if (statusResult.status === 200 && statusResult.body !== null && statusResult.body.ok === true) { - setStatus(statusResult.body); + const [statusSettled, capabilitiesSettled, memorySettled] = await Promise.allSettled([ + request(API.status), + request(API.capabilities), + request("/dsh-brain/local-memory/status?scope=global") + ]); + if (cancelled) return; + if (statusSettled.status === "fulfilled") { + const result = statusSettled.value; + if (result.status === 200 && result.body !== null && result.body.ok === true) { + setStatus(result.body); setError(null); - } else setError("读取插件状态失败(HTTP " + String(statusResult.status) + ")"); - if (capabilitiesResult.status === 200 && capabilitiesResult.body !== null && capabilitiesResult.body.ok === true) setCapabilities(capabilitiesResult.body); - if (memoryResult.status === 200 && memoryResult.body !== null && memoryResult.body.ok === true) setMemory(memoryResult.body); - else setMemory(null); - } catch (failure) { - if (!cancelled) setError(messageOf(failure)); + } else setError("读取插件状态失败(HTTP " + String(result.status) + ")"); + } else setError(messageOf(statusSettled.reason)); + if (capabilitiesSettled.status === "fulfilled") { + const result = capabilitiesSettled.value; + if (result.status === 200 && result.body !== null && result.body.ok === true) setCapabilities(result.body); } + if (memorySettled.status === "fulfilled" && memorySettled.value.status === 200 && memorySettled.value.body !== null && memorySettled.value.body.ok === true) setMemory(memorySettled.value.body); + else setMemory(null); }; load(); const timer = setInterval(() => { @@ -4446,7 +4457,7 @@ window.__ModuleLoader__.load({ variant: "small", onClick: () => memories.reload() })) - }, notice === null ? null : h$4(Banner, { tone: notice.tone }, notice.text), memories.error === null ? null : h$4(Banner, { tone: "bad" }, memories.error), memories.status === "loading" && items.length === 0 ? h$4("p", { style: styles.hint }, "正在读取记忆…") : null, filtered.length === 0 ? h$4("p", { style: styles.hint }, "当前页没有匹配的记忆条目。") : h$4("div", { style: { + }, notice === null ? null : h$4(Banner, { tone: notice.tone }, notice.text), memories.error === null ? null : h$4(Banner, { tone: "bad" }, memories.error), memories.status === "loading" && items.length === 0 ? h$4("p", { style: styles.hint }, "正在读取记忆…") : null, filtered.length === 0 ? h$4("p", { style: styles.hint }, total === 0 && needle === "" ? "还没有记忆条目。对话中让助手记住,或用 memory_add 写入。" : "当前页没有匹配的记忆条目。") : h$4("div", { style: { display: "flex", flexDirection: "column", gap: "8px" @@ -4666,7 +4677,7 @@ window.__ModuleLoader__.load({ }, layout: { display: "grid", - gridTemplateColumns: "minmax(240px, .78fr) minmax(0, 1.55fr)", + gridTemplateColumns: "repeat(auto-fit, minmax(min(240px, 100%), 1fr))", gap: "12px", alignItems: "start" }, diff --git a/src-client/components.tsx b/src-client/components.tsx index 2c1894e..ccb2793 100644 --- a/src-client/components.tsx +++ b/src-client/components.tsx @@ -10,8 +10,8 @@ export function Pill(props) { return h( 'span', { style: Object.assign({}, styles.pill, tone) }, - h('span', { style: { opacity: 0.75 } }, props.label), - h('span', { style: { fontWeight: 600 } }, String(props.value)), + h('span', { style: { opacity: 0.75, flex: '0 0 auto' } }, props.label), + h('span', { style: { fontWeight: 600, overflow: 'hidden', textOverflow: 'ellipsis', minWidth: 0 } }, String(props.value)), ) } diff --git a/src-client/panel/BrainPanel.module.css b/src-client/panel/BrainPanel.module.css index c907154..83d081a 100644 --- a/src-client/panel/BrainPanel.module.css +++ b/src-client/panel/BrainPanel.module.css @@ -146,14 +146,20 @@ border: 1px solid var(--dsw-alias-border-subtle, rgba(127,127,127,0.35)); font-size: 12px; white-space: nowrap; + overflow: hidden; + max-width: 100%; } .pillLabel { opacity: 0.75; + flex: 0 0 auto; } .pillValue { font-weight: 600; + overflow: hidden; + text-overflow: ellipsis; + min-width: 0; } .ok { border-color: rgba(22,163,74,0.55); background: rgba(22,163,74,0.12); } diff --git a/src-client/panel/MemoryTab.tsx b/src-client/panel/MemoryTab.tsx index b658060..3e44096 100644 --- a/src-client/panel/MemoryTab.tsx +++ b/src-client/panel/MemoryTab.tsx @@ -81,7 +81,7 @@ export function MemoryTab(props: BrainScope & { active?: boolean }): any { notice === null ? null : h(Banner, { tone: notice.tone }, notice.text), memories.error === null ? null : h(Banner, { tone: 'bad' }, memories.error), memories.status === 'loading' && items.length === 0 ? h('p', { style: styles.hint }, '正在读取记忆…') : null, - filtered.length === 0 ? h('p', { style: styles.hint }, '当前页没有匹配的记忆条目。') : h('div', { style: { display: 'flex', flexDirection: 'column', gap: '8px' } }, + filtered.length === 0 ? h('p', { style: styles.hint }, total === 0 && needle === '' ? '还没有记忆条目。对话中让助手记住,或用 memory_add 写入。' : '当前页没有匹配的记忆条目。') : h('div', { style: { display: 'flex', flexDirection: 'column', gap: '8px' } }, filtered.map((item) => h('div', { key: item.id, style: styles.row }, h('div', { style: styles.rowHead }, h('div', { style: styles.pills }, diff --git a/src-client/panel/Overview.tsx b/src-client/panel/Overview.tsx index 3dbc4e5..aca9e65 100644 --- a/src-client/panel/Overview.tsx +++ b/src-client/panel/Overview.tsx @@ -41,25 +41,31 @@ export function Overview(props: { active?: boolean }): any { if (!active) return let cancelled = false const load = async (): Promise => { - try { - const [statusResult, capabilitiesResult, memoryResult] = await Promise.all([ - request(API.status), - request(API.capabilities), - request('/dsh-brain/local-memory/status?scope=global'), - ]) - if (cancelled) return - if (statusResult.status === 200 && statusResult.body !== null && statusResult.body.ok === true) { - setStatus(statusResult.body) + // Each endpoint settles on its own: a failing auxiliary endpoint must not + // discard the primary status payload or blank the whole overview. + const [statusSettled, capabilitiesSettled, memorySettled] = await Promise.allSettled([ + request(API.status), + request(API.capabilities), + request('/dsh-brain/local-memory/status?scope=global'), + ]) + if (cancelled) return + if (statusSettled.status === 'fulfilled') { + const result = statusSettled.value + if (result.status === 200 && result.body !== null && result.body.ok === true) { + setStatus(result.body) setError(null) } else { - setError('读取插件状态失败(HTTP ' + String(statusResult.status) + ')') + setError('读取插件状态失败(HTTP ' + String(result.status) + ')') } - if (capabilitiesResult.status === 200 && capabilitiesResult.body !== null && capabilitiesResult.body.ok === true) setCapabilities(capabilitiesResult.body) - if (memoryResult.status === 200 && memoryResult.body !== null && memoryResult.body.ok === true) setMemory(memoryResult.body) - else setMemory(null) - } catch (failure) { - if (!cancelled) setError(messageOf(failure)) + } else { + setError(messageOf(statusSettled.reason)) } + if (capabilitiesSettled.status === 'fulfilled') { + const result = capabilitiesSettled.value + if (result.status === 200 && result.body !== null && result.body.ok === true) setCapabilities(result.body) + } + if (memorySettled.status === 'fulfilled' && memorySettled.value.status === 200 && memorySettled.value.body !== null && memorySettled.value.body.ok === true) setMemory(memorySettled.value.body) + else setMemory(null) } void load() const timer = setInterval(() => { void load() }, 15000) diff --git a/src-client/panel/RawTab.tsx b/src-client/panel/RawTab.tsx index 3c55a2b..4458281 100644 --- a/src-client/panel/RawTab.tsx +++ b/src-client/panel/RawTab.tsx @@ -58,7 +58,7 @@ const s: Record = { chips: { display: 'flex', gap: '4px', padding: '2px', borderRadius: '9px', border: '1px solid rgba(127,127,127,0.18)' }, chip: { font: 'inherit', fontSize: '11.5px', padding: '5px 9px', borderRadius: '7px', border: '1px solid transparent', background: 'transparent', color: 'inherit', cursor: 'pointer' }, chipActive: { border: '1px solid rgba(99,102,241,0.45)', background: 'rgba(99,102,241,0.14)', fontWeight: 600 }, - layout: { display: 'grid', gridTemplateColumns: 'minmax(240px, .78fr) minmax(0, 1.55fr)', gap: '12px', alignItems: 'start' }, + layout: { display: 'grid', gridTemplateColumns: 'repeat(auto-fit, minmax(min(240px, 100%), 1fr))', gap: '12px', alignItems: 'start' }, card: { border: '1px solid rgba(127,127,127,0.22)', borderRadius: '16px', padding: '16px', minWidth: 0, display: 'flex', flexDirection: 'column', gap: '10px' }, cardHead: { display: 'flex', alignItems: 'baseline', justifyContent: 'space-between', gap: '8px', flexWrap: 'wrap' }, cardTitle: { margin: 0, fontSize: '13.5px', fontWeight: 650 }, diff --git a/src-client/styles.ts b/src-client/styles.ts index 0499396..7cd2718 100644 --- a/src-client/styles.ts +++ b/src-client/styles.ts @@ -161,7 +161,8 @@ export const styles = { fontSize: '12px', maxWidth: '100%', whiteSpace: 'nowrap', - flex: '0 0 auto', + overflow: 'hidden', + flex: '0 1 auto', }, table: { width: '100%',