dsh-tidy-display 0.2.2 → 0.2.3-beta.2

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.
@@ -0,0 +1,45 @@
1
+ import React, { useRef, useState } from 'react';
2
+ import { createRoot } from 'react-dom/client';
3
+ import { StickyLane } from '../src/client/StickyLane.js';
4
+ import { Disclosure } from '../src/client/motion.js';
5
+ import css from '../src/client/Reader.module.css';
6
+
7
+ /** Mirrors the user report: a closed turn whose long answer is read mid-scroll. */
8
+ function Fixture() {
9
+ const [expanded, setExpanded] = useState(false);
10
+ const button = useRef<HTMLButtonElement>(null);
11
+ const button2 = useRef<HTMLButtonElement>(null);
12
+ return <div data-conversation-scroll id="scrollport" style={{ height: 'calc(100vh - 32px)', overflow: 'auto' }}>
13
+ <div className={css.root} data-dsh-tidy-display="fixture">
14
+ <div className={css.column} data-chat-flow="">
15
+ <StickyLane kind="toolbar" className={css.toolbar}>
16
+ <button className={css.textButton}>自动折叠开</button>
17
+ </StickyLane>
18
+ <section className={css.turn} data-reader-turn="1">
19
+ <div style={{ height: 120, background: '#eef2ff', alignSelf: 'flex-end', width: '65%' }}>用户消息</div>
20
+ <StickyLane kind="status" className={css.turnProcessSticky}>
21
+ <Disclosure open={expanded} onChange={setExpanded} buttonRef={button} label={<span>用时 4 分 1 秒</span>} />
22
+ </StickyLane>
23
+ <div className={css.closedProcessSummary} data-reader-closed-summary="思考×15 · 输出×1 · 工具×22 · 记录×1">
24
+ <div className={css.summaryRow}>
25
+ <Disclosure open={expanded} onChange={setExpanded} controls="body" buttonRef={button2} ariaLabel="过程详情"
26
+ label={<span>思考×15·输出×1·工具×22·记录×1</span>} />
27
+ </div>
28
+ </div>
29
+ <div id="body" data-reader-answer style={{ padding: '8px 0' }}>
30
+ {Array.from({ length: 40 }, (_, i) => (
31
+ <div key={i} style={{ padding: '6px 0 6px 40px', borderBottom: '1px solid #eee' }}>
32
+ 回答正文行 {i} —— .agent-presets/standard-win/ ⚠ 必须改 硬编码了 linux 绝对路径
33
+ </div>
34
+ ))}
35
+ </div>
36
+ </section>
37
+ <section className={css.turn} data-reader-turn="2" style={{ paddingTop: 20 }}>
38
+ <div style={{ height: 400, background: '#f2fff2' }}>下一轮内容占位</div>
39
+ </section>
40
+ </div>
41
+ </div>
42
+ </div>;
43
+ }
44
+
45
+ createRoot(document.getElementById('app')!).render(<Fixture />);
@@ -67,11 +67,26 @@ function bundledDeclarations(className: string): Map<string, string> {
67
67
  return declarations;
68
68
  }
69
69
 
70
+ /** Turn-level rows are content: they scroll with the transcript and never pin. */
71
+ const FLOW_ROWS = ['.turnProcessSticky', '.flowCell[data-flow-summary]', '.closedProcessSummary'];
72
+
73
+ test('turn-level rows scroll in flow — only the toolbar lane may pin', () => {
74
+ for (const lane of FLOW_ROWS) {
75
+ const declarations = mergedDeclarations(css, lane);
76
+ const position = declarations.get('position');
77
+ assert.ok(
78
+ position !== 'sticky' && position !== 'fixed',
79
+ `${lane} must scroll with the transcript, not pin (got position: ${position})`,
80
+ );
81
+ assert.equal(declarations.get('top'), undefined, `${lane} must not declare a pin offset`);
82
+ }
83
+ });
84
+
70
85
  test('clamped reader lanes stay strictly below the host footer band', () => {
71
86
  for (const lane of CLAMPED_LANES) {
72
87
  const declarations = mergedDeclarations(css, lane);
73
88
  const zIndex = declarations.get('z-index');
74
- assert.ok(zIndex, `${lane} still declares its lane z-index`);
89
+ if (zIndex === undefined) continue; // flow rows no longer declare a lane z-index
75
90
  assert.ok(
76
91
  Number(zIndex) < HOST_FOOTER_Z,
77
92
  `${lane} must stay below the host composer seat (z-index ${HOST_FOOTER_Z}), got ${zIndex}`,
@@ -85,18 +100,10 @@ test('the top toolbar lane stays at 7 and pins to the scrollport top', () => {
85
100
  assert.equal(declarations.get('top'), '0');
86
101
  });
87
102
 
88
- test('the live status lane pins below the toolbar lane instead of over it', () => {
89
- const declarations = mergedDeclarations(css, '.turnProcessSticky');
90
- assert.match(
91
- declarations.get('top') ?? '',
92
- /var\(--reader-toolbar-height/,
93
- 'the status lane shares the measured lane below the toolbar',
94
- );
95
- });
96
-
97
- test('the closed summary lane shares that same measured lane', () => {
98
- const declarations = mergedDeclarations(css, '.flowCell[data-flow-summary]');
99
- assert.match(declarations.get('top') ?? '', /var\(--reader-toolbar-height/);
103
+ test('the live status row and the closed summary row do not pin', () => {
104
+ for (const lane of FLOW_ROWS) {
105
+ assert.notEqual(mergedDeclarations(css, lane).get('position'), 'sticky', `${lane} must not be sticky`);
106
+ }
100
107
  });
101
108
 
102
109
  test('skin mode does not reintroduce a lane above the footer band', () => {
@@ -116,14 +123,13 @@ test('skin mode does not reintroduce a lane above the footer band', () => {
116
123
  });
117
124
 
118
125
  test('the committed client bundle carries the same lane ladder', () => {
119
- for (const lane of ['turnProcessSticky', 'liveFoldContainer']) {
120
- const bundled = bundledDeclarations(lane);
121
- const zIndex = bundled.get('z-index');
122
- assert.ok(zIndex, `${lane} is present in the built bundle`);
123
- assert.ok(
124
- Number(zIndex) < HOST_FOOTER_Z,
125
- `${lane} in lib/client.js must stay below ${HOST_FOOTER_Z}, got ${zIndex}`,
126
- );
127
- }
126
+ const statusRow = bundledDeclarations('turnProcessSticky');
127
+ assert.notEqual(statusRow.get('position'), 'sticky', 'turnProcessSticky must not pin in lib/client.js either');
128
+ const liveFold = bundledDeclarations('liveFoldContainer');
129
+ assert.ok(liveFold.get('z-index'), 'liveFoldContainer is present in the built bundle');
130
+ assert.ok(
131
+ Number(liveFold.get('z-index')) < HOST_FOOTER_Z,
132
+ `liveFoldContainer in lib/client.js must stay below ${HOST_FOOTER_Z}, got ${liveFold.get('z-index')}`,
133
+ );
128
134
  assert.equal(bundledDeclarations('toolbar').get('z-index'), String(HOST_FOOTER_Z));
129
135
  });