Skip to content

Commit df61f13

Browse files
fix(client): 对齐侧栏记忆入口与原生按钮边缘 (#120)
Co-authored-by: Modusensus <[email protected]>
1 parent a16b266 commit df61f13

2 files changed

Lines changed: 13 additions & 11 deletions

File tree

‎dsh-mneme/lib/client.js‎

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -957,10 +957,9 @@ window.__ModuleLoader__.load({
957957
".mneme-heat--warm{color:var(--dsw-alias-label-secondary)}",
958958
".mneme-heat--cold{color:var(--dsw-alias-label-tertiary)}",
959959
".mneme-heat--cold .mneme-heatpct{display:none}",
960-
// width:100% 与「新会话」同宽(同一弹性父容器);文案对齐交给复制来的
961-
// 原生类,不再用 flex:1/text-align:left 覆盖成左对齐。
962-
".mneme-topentry{display:contents}",
963-
".mneme-topentry-native{width:100%;background:var(--dsw-alias-bg-layer-1);border:1px solid var(--dsw-alias-border-l2);color:var(--dsw-alias-label-primary)}",
960+
// 纵向 flex 容器按原生按钮的宽度与外边距分配空间,保留展开和收起态的对齐。
961+
".mneme-topentry{display:flex;flex-direction:column}",
962+
".mneme-topentry-native{background:var(--dsw-alias-bg-layer-1);border:1px solid var(--dsw-alias-border-l2);color:var(--dsw-alias-label-primary)}",
964963
".mneme-topentry-native:hover{background:var(--dsw-alias-interactive-bg-hover);color:var(--dsw-alias-label-primary)}",
965964
".mneme-topentry-native .mneme-topentry-label{white-space:nowrap}",
966965
// --- 功能开关:一行一开关,Claude 式安静排版 ---
@@ -3807,10 +3806,8 @@ window.__ModuleLoader__.load({
38073806
};
38083807
}, []);
38093808
if (!host) return fallback;
3810-
// wrapper 用 display:contents 隐身:我们的按钮成为侧边栏弹性布局的
3811-
// 直接子元素,与「新会话」按钮同级同距;展开/收起只切换图标与文案。
38123809
return reactDom.createPortal(
3813-
h("div", { className: "mneme-topentry", style: { display: "contents" } },
3810+
h("div", { className: "mneme-topentry" },
38143811
h("button", {
38153812
type: "button",
38163813
className: `${nativeCls} mneme-topentry-native`.trim(),

‎dsh-mneme/test/client.test.js‎

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -163,10 +163,10 @@ test("sidebar entry portals above the workspaces region with footer fallback", (
163163
// Three alignment/softness guarantees born from field feedback: (a) the
164164
// portalled entry keeps tracking the live New-Session class (host and skin
165165
// rewrite it asynchronously, so a mount-time snapshot goes stale), (b) it
166-
// fills the same width as that button and inherits its native centering,
166+
// inherits that button's width and margins along with its native centering,
167167
// (c) the toolbar dropdown escapes the transform stacking trap — the
168168
// container needs the z-index because transform creates the context.
169-
test("entry tracks native class, fills native width, and lifts the toolbar dropdown", () => {
169+
test("entry tracks native class, inherits native sizing, and lifts the toolbar dropdown", () => {
170170
assert.ok(
171171
clientSource.includes("new MutationObserver"),
172172
"the entry must re-sync the copied class via MutationObserver"
@@ -175,9 +175,14 @@ test("entry tracks native class, fills native width, and lifts the toolbar dropd
175175
clientSource.includes('attributeFilter: ["class"]'),
176176
"the observer must watch class attribute changes"
177177
);
178+
assert.doesNotMatch(
179+
clientSource,
180+
/\.mneme-topentry-native\{(?:[^}]*;)?width:/,
181+
"the entry must use the native button width, which reserves its horizontal margins"
182+
);
178183
assert.ok(
179-
/\.mneme-topentry-native\{width:100%;/.test(clientSource),
180-
"the entry button must fill the same width as the New-Session row"
184+
clientSource.includes(".mneme-topentry{display:flex;flex-direction:column}"),
185+
"the entry wrapper must stretch the native button within a column flex layout"
181186
);
182187
assert.equal(
183188
clientSource.includes(".mneme-topentry-native .mneme-topentry-label{flex:1;min-width:0;text-align:left;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}"),

0 commit comments

Comments
 (0)