@allbluecn/web-app 0.27.10 → 0.27.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (40) hide show
  1. package/package.json +1 -1
  2. package/src/__tests__/bench/baselines/format-timestamp.json +44 -0
  3. package/src/__typeprobe__.d.ts +4 -0
  4. package/src/components/bug/__tests__/peek-modes.test.tsx +1 -0
  5. package/src/components/bug/__tests__/saved-views.test.tsx +1 -0
  6. package/src/components/bug/__tests__/toolbar-shell.test.tsx +1 -0
  7. package/src/components/bug/__tests__/view-type.test.tsx +1 -0
  8. package/src/components/bug/bug-list-view.tsx +3 -1
  9. package/src/components/shared-kit/peek/__tests__/dock-resize.test.tsx +153 -0
  10. package/src/components/shared-kit/peek/dock-resize.ts +214 -0
  11. package/src/components/story/detail/story-detail-toolbar/children.tsx +5 -3
  12. package/src/components/story/peek-panel.tsx +81 -17
  13. package/src/components/story/relations/story-ref-row.tsx +14 -10
  14. package/src/components/story/story-list-view.tsx +1 -1
  15. package/src/components/story/views/story-list/index.tsx +4 -1
  16. package/src/components/story/views/story-list/row.tsx +24 -18
  17. package/src/components/testcase/__tests__/filters.test.tsx +1 -0
  18. package/src/components/testcase/__tests__/list-view-scope.test.tsx +1 -0
  19. package/src/components/testcase/__tests__/list-view.test.tsx +1 -0
  20. package/src/components/testcase/__tests__/peek-panel.test.tsx +1 -0
  21. package/src/components/testcase/__tests__/view-fallback.test.tsx +1 -0
  22. package/src/components/testcase/list-view.tsx +3 -1
  23. package/src/lib/changelog/sdk-versions.ts +2 -2
  24. package/src/lib/collab/use-presence-list-refresh.ts +8 -1
  25. package/src/paraglide/README.md +1 -1
  26. package/src/paraglide/messages/_index.js +89922 -5751
  27. package/src/paraglide/messages/en.js +28780 -0
  28. package/src/paraglide/messages/story_peek_resizepanel1.js +30 -0
  29. package/src/paraglide/messages/zh.js +28778 -0
  30. package/src/server/bug/bug-crud-helpers.ts +9 -3
  31. package/src/server/lib/project-membership.ts +9 -3
  32. package/src/server/lib/validate-assignee.ts +9 -3
  33. package/src/server/serverFns/__tests__/story-crud.test.ts +2 -1
  34. package/src/server/serverFns/bug/__tests__/bug-crud.test.ts +2 -1
  35. package/src/server/serverFns/bug/bug-crud.ts +7 -5
  36. package/src/server/serverFns/story/__tests__/story-crud-date-key.test.ts +3 -0
  37. package/src/server/serverFns/story/story-crud.ts +23 -8
  38. package/src/server/serverFns/testcase/testcase-crud.ts +11 -10
  39. package/src/server/team-access.ts +10 -2
  40. package/src/server/testcase/permissions.ts +4 -2
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@allbluecn/web-app",
3
- "version": "0.27.10",
3
+ "version": "0.27.12",
4
4
  "license": "AGPL-3.0-or-later",
5
5
  "type": "module",
6
6
  "files": [
@@ -0,0 +1,44 @@
1
+ {
2
+ "latency": {
3
+ "aad": 0.048410276139197045,
4
+ "critical": 1.96,
5
+ "df": 1059,
6
+ "mad": 0.022145999999793275,
7
+ "max": 3.373666999999841,
8
+ "mean": 0.94407134433964,
9
+ "min": 0.8770409999997355,
10
+ "moe": 0.007457128456580703,
11
+ "p50": 0.9219379999999546,
12
+ "p75": 0.9482297500001096,
13
+ "p99": 1.549765560000042,
14
+ "p995": 1.6288096400004497,
15
+ "p999": 1.8190369999991707,
16
+ "rme": 0.7898903511150234,
17
+ "samplesCount": 1060,
18
+ "sd": 0.12387066970076242,
19
+ "sem": 0.0038046573758064813,
20
+ "variance": 0.015343942812115383
21
+ },
22
+ "throughput": {
23
+ "aad": 43.792207103583756,
24
+ "critical": 1.96,
25
+ "df": 1059,
26
+ "mad": 25.941182125708224,
27
+ "max": 1140.1975506279657,
28
+ "mean": 1068.8147818211185,
29
+ "min": 296.4133685986338,
30
+ "moe": 4.749020957923807,
31
+ "p50": 1084.6716379180502,
32
+ "p75": 1108.6600489500372,
33
+ "p99": 1137.598277984184,
34
+ "p995": 1138.8284369378687,
35
+ "p999": 1140.1930292151646,
36
+ "rme": 0.4443259055448416,
37
+ "samplesCount": 1060,
38
+ "sd": 78.88618385832574,
39
+ "sem": 2.422969876491738,
40
+ "variance": 6223.030003729573
41
+ },
42
+ "period": 0.9440713443396405,
43
+ "totalTime": 1000.7156250000189
44
+ }
@@ -0,0 +1,4 @@
1
+ import type { IApp, ILeafer, IUI } from "leafer-editor"
2
+ export type A = IApp
3
+ export type B = ILeafer
4
+ export type C = IUI
@@ -61,6 +61,7 @@ vi.mock("@/server/serverFns/project", () => ({
61
61
  listProjectsBriefFn: vi.fn(() => Promise.resolve([])),
62
62
  }));
63
63
  vi.mock("@tanstack/react-router", () => ({
64
+ useRouteContext: () => ({ session: { user: { id: "user_1" } } }),
64
65
  useNavigate: () => vi.fn(),
65
66
  Link: ({
66
67
  to,
@@ -55,6 +55,7 @@ vi.mock("@/server/serverFns/project", () => ({
55
55
  ensureBuiltinProjectFn: vi.fn(() => Promise.resolve(null)),
56
56
  }));
57
57
  vi.mock("@tanstack/react-router", () => ({
58
+ useRouteContext: () => ({ session: { user: { id: "user_1" } } }),
58
59
  useNavigate: () => vi.fn(),
59
60
  }));
60
61
  vi.mock("@/lib/collab/use-presence-list-refresh", () => ({
@@ -55,6 +55,7 @@ vi.mock("@/server/serverFns/project", () => ({
55
55
  ensureBuiltinProjectFn: vi.fn(() => Promise.resolve(null)),
56
56
  }));
57
57
  vi.mock("@tanstack/react-router", () => ({
58
+ useRouteContext: () => ({ session: { user: { id: "user_1" } } }),
58
59
  useNavigate: () => vi.fn(),
59
60
  }));
60
61
  vi.mock("@/lib/collab/use-presence-list-refresh", () => ({
@@ -61,6 +61,7 @@ vi.mock("@/server/serverFns/project", () => ({
61
61
  ensureBuiltinProjectFn: vi.fn(() => Promise.resolve(null)),
62
62
  }));
63
63
  vi.mock("@tanstack/react-router", () => ({
64
+ useRouteContext: () => ({ session: { user: { id: "user_1" } } }),
64
65
  useNavigate: () => vi.fn(),
65
66
  }));
66
67
  vi.mock("@/lib/collab/use-presence-list-refresh", () => ({
@@ -17,6 +17,7 @@
17
17
 
18
18
  import { useCallback, useEffect, useMemo, useState } from "react";
19
19
  import { useNavigate } from "@tanstack/react-router";
20
+ import { useRouteContext } from "@tanstack/react-router";
20
21
  import { usePresenceListRefresh } from "@/lib/collab/use-presence-list-refresh";
21
22
  import { toastError } from "@/lib/toast-error";
22
23
  import { toast } from "@/components/ui/toast";
@@ -81,6 +82,7 @@ function isPeekMode(v: string | null): v is PeekMode {
81
82
  }
82
83
 
83
84
  export function BugListView({ users: initialUsers, projects: initialProjects, labels }: BugListViewProps) {
85
+ const { session } = useRouteContext({ from: "/_nav/bugs/" });
84
86
  const navigate = useNavigate();
85
87
  const [filterConditions, setFilterConditions] = useState<FilterCondition[]>([]);
86
88
  const [projects, setProjects] = useState(initialProjects);
@@ -360,7 +362,7 @@ export function BugListView({ users: initialUsers, projects: initialProjects, la
360
362
  const refreshBugList = useCallback(() => {
361
363
  paged.refresh();
362
364
  }, [paged.refresh]);
363
- usePresenceListRefresh({ module: "bugs", refresh: refreshBugList });
365
+ usePresenceListRefresh({ module: "bugs", refresh: refreshBugList, selfUserId: session?.user?.id });
364
366
 
365
367
  // ── 看板列组装(任务 33 / 任务 41):paged groups 条目数据 → Record<列 key, items> ──
366
368
  // 取舍:bug 无 board 专用 columns serverFn(testcase 的 listTestCaseBoardColumnsFn
@@ -0,0 +1,153 @@
1
+ // SPDX-License-Identifier: AGPL-3.0-or-later
2
+ // AllBlue - 理想之海
3
+ // Copyright (C) 2026 AllBlue Contributors
4
+ //
5
+ // This program is free software: you can redistribute it and/or modify
6
+ // it under the terms of the GNU Affero General Public License as published by
7
+ // the Free Software Foundation, either version 3 of the License, or
8
+ // (at your option) any later version.
9
+ //
10
+ // This program is distributed in the hope that it will be useful,
11
+ // but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
+ // GNU Affero General Public License for more details.
14
+ //
15
+ // You should have received a copy of the GNU Affero General Public License
16
+ // along with this program. If not, see <https://www.gnu.org/licenses/>.
17
+
18
+ // useDockPanelResize:dock 槽位宽度拖拽(恢复钳制 / 拖拽期 rAF 直写槽位 /
19
+ // 范围钳制 / pointerup 同步 state 并持久化)。事件对象用手工桩直接喂给返回的
20
+ // handler(jsdom 无 setPointerCapture/PointerEvent),槽位用带
21
+ // style/getBoundingClientRect 的假元素;rAF 桩成同步执行让每帧直写可断言。
22
+ import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
23
+ import { renderHook, act } from "@testing-library/react";
24
+ import { useDockPanelResize } from "../dock-resize";
25
+
26
+ const SLOT_DEFAULT = 1200;
27
+ const SLOT_MIN = 480;
28
+
29
+ /** 假槽位:宽度由 width 字段表达(getBoundingClientRect 读它) */
30
+ function makeSlot(width: number) {
31
+ const el = {
32
+ width,
33
+ style: { flex: "" } as CSSStyleDeclaration,
34
+ isConnected: true,
35
+ getBoundingClientRect() {
36
+ return { width: this.width, x: 0 } as DOMRect;
37
+ },
38
+ };
39
+ return el as unknown as HTMLElement & { width: number; style: { flex: string } };
40
+ }
41
+
42
+ /** 假把手 pointer 事件 */
43
+ function makePointer(currentTarget: { setPointerCapture: (id: number) => void }, clientX: number) {
44
+ return {
45
+ button: 0,
46
+ clientX,
47
+ pointerId: 1,
48
+ currentTarget,
49
+ preventDefault() {},
50
+ stopPropagation() {},
51
+ } as unknown as React.PointerEvent<HTMLDivElement>;
52
+ }
53
+
54
+ const captureTarget = { setPointerCapture: () => {} };
55
+
56
+ beforeEach(() => {
57
+ // rAF 桩成同步执行:每帧直写槽位 style 在 move 内立即落地,可同步断言
58
+ vi.stubGlobal("requestAnimationFrame", (cb: FrameRequestCallback) => {
59
+ cb(0);
60
+ return 1;
61
+ });
62
+ vi.stubGlobal("cancelAnimationFrame", () => {});
63
+ });
64
+
65
+ afterEach(() => {
66
+ vi.unstubAllGlobals();
67
+ localStorage.clear();
68
+ });
69
+
70
+ describe("useDockPanelResize", () => {
71
+ it("enabled=false 时不恢复持久化宽度", () => {
72
+ localStorage.setItem("test.width", "700");
73
+ const slot = makeSlot(844);
74
+ const { result } = renderHook(() =>
75
+ useDockPanelResize({ slot, storageKey: "test.width", enabled: false }),
76
+ );
77
+ expect(result.current.width).toBeNull();
78
+ });
79
+
80
+ it("恢复持久化宽度并钳到 [480, 1200]", () => {
81
+ localStorage.setItem("test.width", "700");
82
+ const { result } = renderHook(() =>
83
+ useDockPanelResize({ slot: makeSlot(844), storageKey: "test.width", enabled: true }),
84
+ );
85
+ expect(result.current.width).toBe(700);
86
+
87
+ localStorage.setItem("test.width.hi", "2000");
88
+ const { result: hi } = renderHook(() =>
89
+ useDockPanelResize({ slot: makeSlot(844), storageKey: "test.width.hi", enabled: true }),
90
+ );
91
+ expect(hi.current.width).toBe(SLOT_DEFAULT);
92
+
93
+ localStorage.setItem("test.width.lo", "100");
94
+ const { result: lo } = renderHook(() =>
95
+ useDockPanelResize({ slot: makeSlot(844), storageKey: "test.width.lo", enabled: true }),
96
+ );
97
+ expect(lo.current.width).toBe(SLOT_MIN);
98
+ });
99
+
100
+ it("拖拽期 rAF 直写槽位 inline flex(旁路 setState),卸载复位", () => {
101
+ const slot = makeSlot(844);
102
+ const { result, unmount } = renderHook(() =>
103
+ useDockPanelResize({ slot, storageKey: "test.width", enabled: true }),
104
+ );
105
+ act(() => {
106
+ result.current.onHandlePointerDown(makePointer(captureTarget, 900));
107
+ // 把手在面板左缘:向右拖(clientX 增大)= 变窄。844 + (900-1100) = 644
108
+ result.current.onHandlePointerMove(makePointer(captureTarget, 1100));
109
+ });
110
+ expect(slot.style.flex).toBe("0 1 644px");
111
+ unmount();
112
+ expect(slot.style.flex).toBe("");
113
+ });
114
+
115
+ it("拖拽钳制:上限=自然宽、下限=max(480, 自然宽/2),pointerup 同步 state", () => {
116
+ const slot = makeSlot(844);
117
+ const { result } = renderHook(() =>
118
+ useDockPanelResize({ slot, storageKey: "test.width", enabled: true }),
119
+ );
120
+ act(() => {
121
+ result.current.onHandlePointerDown(makePointer(captureTarget, 900));
122
+ result.current.onHandlePointerMove(makePointer(captureTarget, 1500)); // 变窄 240 → 钳 480
123
+ result.current.onHandlePointerUp();
124
+ });
125
+ expect(result.current.width).toBe(SLOT_MIN);
126
+ expect(localStorage.getItem("test.width")).toBe("480");
127
+ act(() => {
128
+ result.current.onHandlePointerDown(makePointer(captureTarget, 900));
129
+ result.current.onHandlePointerMove(makePointer(captureTarget, 100)); // 变宽 1400 → 钳 844
130
+ result.current.onHandlePointerUp();
131
+ });
132
+ expect(result.current.width).toBe(844);
133
+ expect(localStorage.getItem("test.width")).toBe("844");
134
+ });
135
+
136
+ it("pointerup 与最后一次 move 同批时也持久化最终宽度(渲染前旧值回归)", () => {
137
+ // 回归:最终宽度在 move 里同步记录进 dragRef/pendingRef——若从 render 期
138
+ // 的 state 读,pointerup 早于渲染提交会拿到上一帧旧值
139
+ const slot = makeSlot(844);
140
+ const { result } = renderHook(() =>
141
+ useDockPanelResize({ slot, storageKey: "test.width", enabled: true }),
142
+ );
143
+ act(() => {
144
+ result.current.onHandlePointerDown(makePointer(captureTarget, 900));
145
+ result.current.onHandlePointerMove(makePointer(captureTarget, 1100)); // 宽 644
146
+ result.current.onHandlePointerMove(makePointer(captureTarget, 1220)); // 宽 524
147
+ // 不等 React 提交渲染,直接 pointerup
148
+ result.current.onHandlePointerUp();
149
+ });
150
+ expect(localStorage.getItem("test.width")).toBe("524");
151
+ expect(result.current.width).toBe(524);
152
+ });
153
+ });
@@ -0,0 +1,214 @@
1
+ // SPDX-License-Identifier: AGPL-3.0-or-later
2
+ // AllBlue - 理想之海
3
+ // Copyright (C) 2026 AllBlue Contributors
4
+ //
5
+ // This program is free software: you can redistribute it and/or modify
6
+ // it under the terms of the GNU Affero General Public License as published by
7
+ // the Free Software Foundation, either version 3 of the License, or
8
+ // (at your option) any later version.
9
+ //
10
+ // This program is distributed in the hope that it will be useful,
11
+ // but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
+ // GNU Affero General Public License for more details.
14
+ //
15
+ // You should have received a copy of the GNU Affero General Public License
16
+ // along with this program. If not, see <https://www.gnu.org/licenses/>.
17
+
18
+ // 侧边面板(side-dock)宽度拖拽(shared-kit:story 面板先行接入,testcase/bug
19
+ // 面板可按需复用)。交互口径(用户裁决):当前默认宽度即最大宽度,可拖窄至
20
+ // 其一半——把手在面板左缘,向左拖到顶(不超过默认宽)、向右拖到默认宽一半。
21
+ //
22
+ // 宽度落在布局槽(sidebar-03 的 #peek-dock-panel-slot,缺省 basis-300=1200px)
23
+ // 上:用 inline flex-basis 覆盖类上的 basis-300,且保留 shrink=1——窗口压力下
24
+ // 槽位仍按 flex 规则收缩(min-w-120 下限不破),与缺省行为完全同构。拖拽上限
25
+ // = 槽位「自然宽」(清 inline 后 flex 行的解析宽,见 measureNaturalWidth),
26
+ // 下限 = 上限/2 与槽位绝对下限取大。宽度持久化 localStorage(key 由调用方按
27
+ // 模块传入),恢复时钳到绝对上下限,窗口变化交给 flex 收缩兜底。面板卸载
28
+ // 复位槽位样式,不污染后续其他面板对同一槽位的缺省占位。
29
+
30
+ import { useCallback, useEffect, useRef, useState } from "react";
31
+
32
+ /** 布局槽缺省宽(sidebar-03 的 basis-300),px */
33
+ const DOCK_SLOT_DEFAULT_WIDTH = 1200;
34
+ /** 布局槽绝对下限(sidebar-03 的 min-w-120),px */
35
+ const DOCK_SLOT_MIN_WIDTH = 480;
36
+
37
+ export interface DockPanelResizeOptions {
38
+ /** 布局槽元素(usePeekDockSlot 产物);null 时拖拽不生效 */
39
+ slot: HTMLElement | null;
40
+ /** localStorage 持久化 key(按模块区分,如 story.peekDockWidth) */
41
+ storageKey: string;
42
+ /** 仅 dock 布局态启用(浮层/SSR 首帧/窄屏 overlay 态禁用) */
43
+ enabled: boolean;
44
+ }
45
+
46
+ export interface DockPanelResize {
47
+ /** 当前自定义宽度;null = 未拖拽过(走槽位缺省 basis-300) */
48
+ width: number | null;
49
+ /** 把手 pointerdown(move/up 由 setPointerCapture 派发回同一元素) */
50
+ onHandlePointerDown: (e: React.PointerEvent<HTMLDivElement>) => void;
51
+ onHandlePointerMove: (e: React.PointerEvent<HTMLDivElement>) => void;
52
+ /** pointerup 无需事件对象(最终宽度已在 move 中同步记录) */
53
+ onHandlePointerUp: () => void;
54
+ }
55
+
56
+ /** 拖拽上限:槽位的「自然宽」= 清掉 inline flex 后 flex 行的解析宽(内容区
57
+ min-w-120、AI 槽让位、basis-300 上限全部由 flex 一次算准,无需 JS 复刻
58
+ 布局公式);再钳到 [绝对下限, 缺省宽]。测量在 pointerdown 时同步清/恢复
59
+ inline,单次强制 reflow,代价可忽略。 */
60
+ function measureNaturalWidth(slot: HTMLElement): number {
61
+ const prev = slot.style.flex;
62
+ slot.style.flex = "";
63
+ const natural = slot.getBoundingClientRect().width;
64
+ slot.style.flex = prev;
65
+ return Math.max(
66
+ DOCK_SLOT_MIN_WIDTH,
67
+ Math.min(DOCK_SLOT_DEFAULT_WIDTH, Math.round(natural)),
68
+ );
69
+ }
70
+
71
+ export function useDockPanelResize({ slot, storageKey, enabled }: DockPanelResizeOptions): DockPanelResize {
72
+ const [width, setWidth] = useState<number | null>(null);
73
+ // 拖拽会话状态(含 lastWidth):pointermove 里同步记录最终宽度——pointerup
74
+ // 与最后一次 pointermove 常在同一事件批内派发、早于 React 提交渲染,从
75
+ // state/render 侧读会拿到上一帧的旧值(实测 flex=480 却持久化 544)
76
+ const dragRef = useRef<{ startX: number; startWidth: number; maxWidth: number; lastWidth: number } | null>(null);
77
+ // ── 拖拽热路径旁路 React(丝滑关键)──
78
+ // pointermove 只把最新宽度记入 pendingRef,经 rAF 每帧一次直写槽位 style。
79
+ // 逐事件 setState 走「整面板重渲染(StoryPanelHeader 未 memo、含大量下拉/
80
+ // 按钮)→ commit → effect 写 style」链路,而 pointermove 频率可达显示刷新
81
+ // 率的数倍(125-1000Hz 鼠标),每帧多次全树渲染即卡顿。宽度本来落在布局槽
82
+ // 上(面板 w-full 跟随),直写 style 与 effect 写同一属性,语义完全一致。
83
+ const pendingWidthRef = useRef<number | null>(null);
84
+ const rafRef = useRef<number | null>(null);
85
+ // 拖拽期全局光标/禁选(把手仅 6px 宽,捕获拖拽中指针会滑出把手——光标恒为
86
+ // col-resize、避免划选文本);pointerup/pointercancel/unmount 三路恢复
87
+ const bodyDragCleanupRef = useRef<(() => void) | null>(null);
88
+
89
+ const setBodyDragVisual = useCallback(() => {
90
+ document.body.style.cursor = "col-resize";
91
+ document.body.style.userSelect = "none";
92
+ bodyDragCleanupRef.current = () => {
93
+ document.body.style.cursor = "";
94
+ document.body.style.userSelect = "";
95
+ };
96
+ }, []);
97
+ const clearBodyDragVisual = useCallback(() => {
98
+ bodyDragCleanupRef.current?.();
99
+ bodyDragCleanupRef.current = null;
100
+ }, []);
101
+
102
+ /** 取走待应用宽度并取消挂起的 rAF(pointerup/unmount 收尾用) */
103
+ const flushPendingWidth = useCallback((): number | null => {
104
+ if (rafRef.current != null) {
105
+ cancelAnimationFrame(rafRef.current);
106
+ rafRef.current = null;
107
+ }
108
+ const pending = pendingWidthRef.current;
109
+ pendingWidthRef.current = null;
110
+ return pending;
111
+ }, []);
112
+
113
+ // 恢复持久化宽度(钳到绝对上下限;窗口压力下的进一步收缩由 flex 兜底)
114
+ useEffect(() => {
115
+ if (!enabled) return;
116
+ try {
117
+ const raw = localStorage.getItem(storageKey);
118
+ if (!raw) return;
119
+ const parsed = Number.parseInt(raw, 10);
120
+ if (!Number.isFinite(parsed) || parsed <= 0) return;
121
+ setWidth(Math.min(DOCK_SLOT_DEFAULT_WIDTH, Math.max(DOCK_SLOT_MIN_WIDTH, parsed)));
122
+ } catch {
123
+ // localStorage 不可用(隐私模式等)静默降级为不恢复
124
+ }
125
+ }, [enabled, storageKey]);
126
+
127
+ // 应用/复位槽位宽度:inline flex 覆盖类上的 basis-300(shrink 保留,flex 行
128
+ // 压力下仍能收缩);卸载/复位时清掉 inline,槽位回到缺省占位
129
+ useEffect(() => {
130
+ if (!slot) return;
131
+ if (width == null) {
132
+ slot.style.flex = "";
133
+ return;
134
+ }
135
+ slot.style.flex = `0 1 ${width}px`;
136
+ return () => {
137
+ slot.style.flex = "";
138
+ };
139
+ }, [slot, width]);
140
+
141
+ // unmount 兜底:取消挂起的 rAF + 恢复 body + 拖拽中复位槽位(正常路径
142
+ // pointerup 已清)。拖拽中面板被关闭(异步错误兜底等)时:①挂起 rAF 不取消
143
+ // 会在卸载后把宽度重新写回布局槽;②width state 仍是拖拽前值、[slot, width]
144
+ // effect 无 cleanup 注册——直写热路径的 inline 宽度必须在这里复位,否则泄漏
145
+ // 给下一个复用槽位的面板
146
+ useEffect(() => {
147
+ return () => {
148
+ const wasDragging = dragRef.current != null;
149
+ flushPendingWidth();
150
+ clearBodyDragVisual();
151
+ if (wasDragging && slot) slot.style.flex = "";
152
+ };
153
+ }, [flushPendingWidth, clearBodyDragVisual, slot]);
154
+
155
+ const onHandlePointerDown = useCallback(
156
+ (e: React.PointerEvent<HTMLDivElement>) => {
157
+ if (!slot || !enabled || e.button !== 0) return;
158
+ e.preventDefault();
159
+ e.stopPropagation();
160
+ e.currentTarget.setPointerCapture(e.pointerId);
161
+ const startWidth = slot.getBoundingClientRect().width;
162
+ dragRef.current = {
163
+ startX: e.clientX,
164
+ startWidth,
165
+ maxWidth: measureNaturalWidth(slot),
166
+ lastWidth: Math.round(startWidth),
167
+ };
168
+ setBodyDragVisual();
169
+ },
170
+ [slot, enabled, setBodyDragVisual],
171
+ );
172
+
173
+ const onHandlePointerMove = useCallback(
174
+ (e: React.PointerEvent<HTMLDivElement>) => {
175
+ const drag = dragRef.current;
176
+ if (!drag || !slot) return;
177
+ // 把手在面板左缘:宽度 = 起始宽 + (起点 x - 指针 x)。向右拖(clientX 增大)
178
+ // = 变窄。范围 [上限/2, 上限]——用户口径「当前宽即最大宽,可拖窄至一半」;
179
+ // 绝对下限兜极窄窗口。
180
+ const next = drag.startWidth + (drag.startX - e.clientX);
181
+ const minWidth = Math.max(DOCK_SLOT_MIN_WIDTH, drag.maxWidth / 2);
182
+ const clamped = Math.min(drag.maxWidth, Math.max(minWidth, Math.round(next)));
183
+ drag.lastWidth = clamped;
184
+ pendingWidthRef.current = clamped;
185
+ if (rafRef.current == null) {
186
+ rafRef.current = requestAnimationFrame(() => {
187
+ rafRef.current = null;
188
+ const w = pendingWidthRef.current;
189
+ pendingWidthRef.current = null;
190
+ if (w != null && slot.isConnected) slot.style.flex = `0 1 ${w}px`;
191
+ });
192
+ }
193
+ },
194
+ [slot],
195
+ );
196
+
197
+ const onHandlePointerUp = useCallback(() => {
198
+ const drag = dragRef.current;
199
+ if (!drag) return;
200
+ dragRef.current = null;
201
+ clearBodyDragVisual();
202
+ const finalWidth = flushPendingWidth() ?? drag.lastWidth;
203
+ // 拖拽结束同步一次 React 状态(effect 写同一值幂等;此后普通重渲染不回写
204
+ // 拖拽中的直写结果),并持久化
205
+ setWidth(finalWidth);
206
+ try {
207
+ localStorage.setItem(storageKey, String(finalWidth));
208
+ } catch {
209
+ // 持久化失败静默降级(本次会话内仍生效)
210
+ }
211
+ }, [storageKey, flushPendingWidth, clearBodyDragVisual]);
212
+
213
+ return { width, onHandlePointerDown, onHandlePointerMove, onHandlePointerUp };
214
+ }
@@ -369,12 +369,14 @@ export function StoryDetailChildrenPanel({
369
369
  </CollapsibleTrigger>
370
370
  <CollapsibleContent className="pb-2" keepMounted>
371
371
  {/* 完全复刻需求列表(StoryList)结构:双向滚动容器 + 滚动容器外的冻结组头层。
372
- 数据行 min-w 撑出横向滚动;冻结层 absolute 覆盖滚动层可视顶(与原位
373
- 活跃组头同位重叠渲染,视觉单份)、不随横滚(天然不透行直角)。
372
+ 数据行宽随容器自适应(收缩由 flex-1 truncate 姓名吸收、编辑器簇
373
+ shrink-0 不压缩,同 StoryListRow 口径——面板可拖窄后 44rem 横滑
374
+ 会在窄面板内复现溢出,故与主列表同步退役);冻结层 absolute 覆盖
375
+ 滚动层可视顶(与原位活跃组头同位重叠渲染,视觉单份)。
374
376
  活跃组头由滚动位置派生(组头行 ref offsetTop 比对)。 */}
375
377
  <div className="relative flex max-h-[60vh] flex-col overflow-clip rounded-lg border">
376
378
  <div ref={scrollRef} className="relative min-h-0 flex-1 overflow-auto" onScroll={onScroll}>
377
- <div className="min-w-[44rem]">
379
+ <div>
378
380
  {groups.map((group) => {
379
381
  const isCollapsed = collapsed[group.key] ?? false;
380
382
  const groupIds = group.items.map((s) => s.id);