@kabmo-labs/kabmo 0.46.0 → 0.46.1
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.
- package/dist/client/index.html +1 -1
- package/dist/client/index.js +1 -1
- package/dist/client/static/js/{CsvGrid-br4j001k.js → CsvGrid-qdkmv8bj.js} +1 -1
- package/dist/client/static/js/{DocxView-kmtkbmmw.js → DocxView-k84ns803.js} +1 -1
- package/dist/client/static/js/{DrawioView-3df0g3jr.js → DrawioView-r1n717f7.js} +1 -1
- package/dist/client/static/js/{ImageView-2r8p5z3y.js → ImageView-jkrdrq8v.js} +1 -1
- package/dist/client/static/js/{LayoutWrapper-rq3d2a4e.js → LayoutWrapper-sh634350.js} +2 -2
- package/dist/client/static/js/{Modal-tmxhxd6q.js → Modal-xe6h99jn.js} +1 -1
- package/dist/client/static/js/{PdfView-p5z7c7eg.js → PdfView-ffg4mccg.js} +1 -1
- package/dist/client/static/js/{SessionsView-t06h6zfx.js → SessionsView-cdcbsee9.js} +1 -1
- package/dist/client/static/js/{SheetView-agw459v2.js → SheetView-89sscpz6.js} +1 -1
- package/dist/client/static/js/{SvgPreview-b9rfy1h6.js → SvgPreview-68c0ccbv.js} +1 -1
- package/dist/client/static/js/{abnfDiagram-O67JEVCF-wbnhzcnj.js → abnfDiagram-O67JEVCF-h3a5s259.js} +1 -1
- package/dist/client/static/js/{architectureDiagram-NJMV4G6O-t2sgevea.js → architectureDiagram-NJMV4G6O-983p0jgn.js} +1 -1
- package/dist/client/static/js/{blockDiagram-BEXU5L5S-v2nzp54a.js → blockDiagram-BEXU5L5S-16pse5mh.js} +1 -1
- package/dist/client/static/js/{c4Diagram-YGBWAQC7-7h03146b.js → c4Diagram-YGBWAQC7-mvnb00zt.js} +1 -1
- package/dist/client/static/js/{classDiagram-v2-NBCMYWYE-m57e9kp1.js → classDiagram-v2-NBCMYWYE-kmpd91xb.js} +1 -1
- package/dist/client/static/js/{cose-bilkent-JH36ORCC-c4tnh4mg.js → cose-bilkent-JH36ORCC-3ek5r5se.js} +1 -1
- package/dist/client/static/js/{cynefinDiagram-VND7K2PF-mjf6njey.js → cynefinDiagram-VND7K2PF-jkbh84zn.js} +1 -1
- package/dist/client/static/js/{dagre-6A5THRUB-6yma9ch3.js → dagre-6A5THRUB-4fdc0sgn.js} +1 -1
- package/dist/client/static/js/{diagram-22UHCM2B-1q4ce2gb.js → diagram-22UHCM2B-hbk61nq9.js} +1 -1
- package/dist/client/static/js/{diagram-3UASUU5V-0ttps29p.js → diagram-3UASUU5V-hfpbr9qh.js} +1 -1
- package/dist/client/static/js/{diagram-ATOU4E4O-1mzexgv1.js → diagram-ATOU4E4O-fn0nt71a.js} +1 -1
- package/dist/client/static/js/{diagram-CDSNMT55-4ae89t23.js → diagram-CDSNMT55-ssswxjeb.js} +1 -1
- package/dist/client/static/js/{diagram-MLGK6HIB-057jaqvh.js → diagram-MLGK6HIB-whnzxv6f.js} +1 -1
- package/dist/client/static/js/{diagram-MPIPVDR6-p6yyq5sx.js → diagram-MPIPVDR6-hk1chzxk.js} +1 -1
- package/dist/client/static/js/{dockerfile-00hqsk9c.js → dockerfile-zmsj8r4g.js} +1 -1
- package/dist/client/static/js/{ebnfDiagram-ZINNZB2B-bsk7dvm4.js → ebnfDiagram-ZINNZB2B-q1vkg5mr.js} +1 -1
- package/dist/client/static/js/{elk-276RUBZZ-dsq91er5.js → elk-276RUBZZ-kt98vg8j.js} +1 -1
- package/dist/client/static/js/{erDiagram-OPXOYQCR-p7p13mbh.js → erDiagram-OPXOYQCR-ey3avsn9.js} +1 -1
- package/dist/client/static/js/flowDiagram-KWPJA3E3-7gvtpn3d.js +1 -0
- package/dist/client/static/js/{ganttDiagram-FUAMR5RP-bwgnttyk.js → ganttDiagram-FUAMR5RP-a9k1at43.js} +1 -1
- package/dist/client/static/js/{gitGraphDiagram-X574FWY7-ca0gj5am.js → gitGraphDiagram-X574FWY7-gnekjfym.js} +1 -1
- package/dist/client/static/js/{index-jkay7aw7.js → index-1ax52p0q.js} +1 -1
- package/dist/client/static/js/{index-064vdkrs.js → index-2a6qp9y6.js} +1 -1
- package/dist/client/static/js/{index-j718pxb3.js → index-3x7h2eqj.js} +1 -1
- package/dist/client/static/js/{index-amys498v.js → index-4cag7w6k.js} +131 -131
- package/dist/client/static/js/{index-ta6gpcpw.js → index-5ka2tyf9.js} +2 -2
- package/dist/client/static/js/{index-x1fqhhpp.js → index-60v30k5h.js} +2 -2
- package/dist/client/static/js/{index-5gf52a6d.js → index-65afr75v.js} +1 -1
- package/dist/client/static/js/{index-4bqssvt6.js → index-83rkg916.js} +1 -1
- package/dist/client/static/js/{index-aagt3382.js → index-84fyq5a6.js} +1 -1
- package/dist/client/static/js/{index-dr5hca5b.js → index-8g7q8mz4.js} +1 -1
- package/dist/client/static/js/{index-bjv5ga2e.js → index-9vv7wr1n.js} +1 -1
- package/dist/client/static/js/{index-pwe6chtp.js → index-amsa0tfs.js} +1 -1
- package/dist/client/static/js/{index-red856x6.js → index-atq9q1s7.js} +1 -1
- package/dist/client/static/js/{index-f7te27n5.js → index-b2e5pwx7.js} +1 -1
- package/dist/client/static/js/{index-ex5dtdx2.js → index-b5dfvget.js} +1 -1
- package/dist/client/static/js/{index-zedt16w7.js → index-bsr7wmj2.js} +1 -1
- package/dist/client/static/js/{index-k5zfzgez.js → index-c9e417cs.js} +1 -1
- package/dist/client/static/js/{index-3bf7r7z4.js → index-dt6q3rws.js} +4 -4
- package/dist/client/static/js/{index-29npynva.js → index-e9cxje00.js} +1 -1
- package/dist/client/static/js/{index-zq0qxb17.js → index-fzngzhww.js} +1 -1
- package/dist/client/static/js/{index-16sd19f0.js → index-hgzntg2j.js} +1 -1
- package/dist/client/static/js/{index-bafe7hmd.js → index-kb14dhrx.js} +1 -1
- package/dist/client/static/js/{index-qn200x1b.js → index-kbhrvep8.js} +6 -6
- package/dist/client/static/js/{index-eqhjs1yv.js → index-m4k054wz.js} +3 -3
- package/dist/client/static/js/{index-8pksqzwq.js → index-pavvxrsz.js} +1 -1
- package/dist/client/static/js/{index-95kese1h.js → index-q9ytjey8.js} +1 -1
- package/dist/client/static/js/{index-3qnjdjg2.js → index-vkqb4dnt.js} +1 -1
- package/dist/client/static/js/{index-7055hdx1.js → index-wrcdc9vz.js} +1 -1
- package/dist/client/static/js/{index-ncpwteyt.js → index-x9r7zfp4.js} +1 -1
- package/dist/client/static/js/{index-y2z8nsvw.js → index-xq5f3nxa.js} +1 -1
- package/dist/client/static/js/{index-gq5w5w8x.js → index-xwjbq003.js} +1 -1
- package/dist/client/static/js/{index-twsbv1yn.js → index-yf93db65.js} +1 -1
- package/dist/client/static/js/{index-9d3n04vb.js → index-ykm7a3cp.js} +2 -2
- package/dist/client/static/js/{index-5h8y54t6.js → index-z25ss7xj.js} +1 -1
- package/dist/client/static/js/{infoDiagram-VRGFBTTK-7q58qdf1.js → infoDiagram-VRGFBTTK-r1p25738.js} +1 -1
- package/dist/client/static/js/{ishikawaDiagram-OU5B5YK6-9jmeszag.js → ishikawaDiagram-OU5B5YK6-afgrqdrt.js} +1 -1
- package/dist/client/static/js/{journeyDiagram-ZHPQQLJL-0d7xe845.js → journeyDiagram-ZHPQQLJL-hepa4wk7.js} +1 -1
- package/dist/client/static/js/{kanban-definition-PNTS6WVX-7p83rwdn.js → kanban-definition-PNTS6WVX-jysft8ya.js} +1 -1
- package/dist/client/static/js/{mermaid.core-hwhzw0wv.js → mermaid.core-0m90b0s8.js} +2 -2
- package/dist/client/static/js/{mindmap-definition-NLK3R4M7-hy0rtr7t.js → mindmap-definition-NLK3R4M7-x2rrzpvr.js} +1 -1
- package/dist/client/static/js/one-dark-pro-09d8p5vy.js +1 -0
- package/dist/client/static/js/one-light-g3ednt6p.js +1 -0
- package/dist/client/static/js/{pegDiagram-GJSIUBJH-kd8t53tx.js → pegDiagram-GJSIUBJH-z7vb7f1z.js} +1 -1
- package/dist/client/static/js/{pieDiagram-5QR66LMP-h3x03f80.js → pieDiagram-5QR66LMP-jqv6v4e6.js} +1 -1
- package/dist/client/static/js/{quadrantDiagram-O4NWA36T-y2b1ncbg.js → quadrantDiagram-O4NWA36T-w2h8yxrv.js} +1 -1
- package/dist/client/static/js/{railroadDiagram-XR7U4H2S-x188rcxf.js → railroadDiagram-XR7U4H2S-nd09yac3.js} +1 -1
- package/dist/client/static/js/{requirementDiagram-PLB6GJNP-g5e9fk17.js → requirementDiagram-PLB6GJNP-t61zxh5v.js} +1 -1
- package/dist/client/static/js/{rust-1v8xbxn9.js → rust-avnkhh0p.js} +1 -1
- package/dist/client/static/js/{sankeyDiagram-IPEJSGJF-y9ht91gf.js → sankeyDiagram-IPEJSGJF-2f7h2cmw.js} +1 -1
- package/dist/client/static/js/{sequenceDiagram-PO4LG4MO-pp8s63rt.js → sequenceDiagram-PO4LG4MO-kfb5d7zd.js} +1 -1
- package/dist/client/static/js/{sizeCapture-INFHLROL-k6dhfxex.js → sizeCapture-INFHLROL-amfg19se.js} +1 -1
- package/dist/client/static/js/{stateDiagram-v2-GCMORJYK-y3akpsm4.js → stateDiagram-v2-GCMORJYK-k5hx7btx.js} +1 -1
- package/dist/client/static/js/{swimlanes-2SLR337P-89081dr3.js → swimlanes-2SLR337P-wv3rp8kk.js} +1 -1
- package/dist/client/static/js/{swimlanesDiagram-TC7HE7FX-3q2a15wc.js → swimlanesDiagram-TC7HE7FX-6y8zdbm4.js} +1 -1
- package/dist/client/static/js/{timeline-definition-EJHVYXUP-tz6r8g3q.js → timeline-definition-EJHVYXUP-0re95wtn.js} +1 -1
- package/dist/client/static/js/{usecaseDiagram-POWQR4AR-yq2y1b09.js → usecaseDiagram-POWQR4AR-yrje14qp.js} +1 -1
- package/dist/client/static/js/{vennDiagram-UO4OBE2U-qdmjf6x3.js → vennDiagram-UO4OBE2U-jxkmrfy5.js} +1 -1
- package/dist/client/static/js/{wardleyDiagram-VNRHLVJA-3n2sm7rj.js → wardleyDiagram-VNRHLVJA-d3v2m9b1.js} +1 -1
- package/dist/client/static/js/{xychartDiagram-PMCCYNJV-d7n2av2t.js → xychartDiagram-PMCCYNJV-9a1s1rjt.js} +1 -1
- package/package.json +1 -1
- package/src/client/components/layout/desktop-layout/LeftColumn.tsx +2 -1
- package/src/client/components/layout/desktop-layout/RightColumn.test.tsx +204 -0
- package/src/client/components/layout/desktop-layout/RightColumn.tsx +37 -16
- package/src/client/components/mobile/RightSidebar.tsx +10 -8
- package/src/client/components/mobile/mobile-session-sidebar/use-drawer-tabs.ts +2 -1
- package/src/client/components/workspace/chat-timeline/MessageList.test.ts +11 -0
- package/src/client/components/workspace/chat-timeline/MessageList.tsx +29 -21
- package/src/client/hooks/chat/timeline/row-measure.ts +75 -0
- package/src/client/hooks/chat/timeline/row-window.test.ts +41 -21
- package/src/client/hooks/chat/timeline/row-window.ts +6 -24
- package/src/client/hooks/workspace/panel-tabs-reveal.test.tsx +20 -17
- package/src/client/hooks/workspace/panel-tabs-reveal.ts +29 -17
- package/src/client/hooks/workspace/panel-tabs.ts +3 -2
- package/src/client/hooks/workspace/session-state/index.test.tsx +145 -0
- package/src/client/hooks/workspace/session-state/index.ts +28 -16
- package/dist/client/static/js/flowDiagram-KWPJA3E3-7b4w6phx.js +0 -1
- package/dist/client/static/js/one-dark-pro-4b8er03c.js +0 -1
- package/dist/client/static/js/one-light-e6r3vsz4.js +0 -1
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* An explicit "open this view" wins over the strip's mirror in BOTH directions.
|
|
8
|
+
*
|
|
9
|
+
* The reported defect: on a session whose right strip already held `Files`, the
|
|
10
|
+
* Stats navbar readout added a `Resources` tab but left `Files` selected and
|
|
11
|
+
* drawn; the tab only appeared to work after switching chats and coming back.
|
|
12
|
+
* The cause was a second writer: a request writes `layout.activeRightPanel`
|
|
13
|
+
* before its tab is opened, so for one commit the stored view names `Resources`
|
|
14
|
+
* while the strip still says `Files`. The mirror effect read that as a strip
|
|
15
|
+
* choice and requested `Files` back, and the next commit repeated the exchange
|
|
16
|
+
* in the other direction — an open/pending request that also re-applied after a
|
|
17
|
+
* session switch, which is how the tab landed in the next chat too.
|
|
18
|
+
*
|
|
19
|
+
* The claim is the PAIR: after a request settles, the stored selection and the
|
|
20
|
+
* strip's active tab name the SAME view, and no request is left pending.
|
|
21
|
+
*/
|
|
22
|
+
|
|
23
|
+
import { afterAll, afterEach, beforeAll, beforeEach, describe, expect, test } from 'bun:test';
|
|
24
|
+
import { h, render } from 'preact';
|
|
25
|
+
import { act } from 'preact/test-utils';
|
|
26
|
+
import { Window } from 'happy-dom';
|
|
27
|
+
import { Group } from '@/client/components/layout/desktop-layout/resizer';
|
|
28
|
+
import { RightColumn } from '@/client/components/layout/desktop-layout/RightColumn';
|
|
29
|
+
import { SessionStateProvider } from '@/client/components/common/session-state-provider/index';
|
|
30
|
+
import { useSessionState } from '@/client/hooks/workspace/session-state';
|
|
31
|
+
import { useRightOpenRequest, type RightOpenRequest } from '@/client/hooks/workspace/right-open-request';
|
|
32
|
+
import type { ResolvedPanel } from '@/client/components/workspace/plugin-panel/catalog';
|
|
33
|
+
import {
|
|
34
|
+
getSessionState,
|
|
35
|
+
getSessionValue,
|
|
36
|
+
hydrateSession,
|
|
37
|
+
resetSessionStateStore,
|
|
38
|
+
} from '@/shared/lib/workspace/session-state/store';
|
|
39
|
+
import { installDomGlobals, restoreDomGlobals } from '@/test-support/pristine-globals';
|
|
40
|
+
|
|
41
|
+
const FILES = 'files';
|
|
42
|
+
const STATS = 'plugin:stats:rightPanel';
|
|
43
|
+
|
|
44
|
+
let container: HTMLElement;
|
|
45
|
+
let requestPanel: ((panelKey: string) => void) | null = null;
|
|
46
|
+
let request: RightOpenRequest | null = null;
|
|
47
|
+
|
|
48
|
+
function panel(id: string, label: string, builtin: boolean): ResolvedPanel {
|
|
49
|
+
return {
|
|
50
|
+
id,
|
|
51
|
+
side: 'right',
|
|
52
|
+
title: `${label} — title`,
|
|
53
|
+
label,
|
|
54
|
+
name: builtin ? '' : 'Stats',
|
|
55
|
+
builtin,
|
|
56
|
+
requiresWorkspace: false,
|
|
57
|
+
liveWhileHidden: false,
|
|
58
|
+
minWidth: 200,
|
|
59
|
+
defaultWidth: 420,
|
|
60
|
+
defaultFraction: 0.3,
|
|
61
|
+
render: () => h('div', { 'data-body': id }, `${label} body`),
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
const CATALOG = [panel(FILES, 'Files', true), panel(STATS, 'Resources', false)];
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* The desktop layout's own wiring, reduced to what the two effects read: the
|
|
69
|
+
* restored selection, its request handle, and the rail's toggle-on-select rule.
|
|
70
|
+
*/
|
|
71
|
+
function Harness() {
|
|
72
|
+
const [activeRightPanel, setActiveRightPanel] = useSessionState<string>('layout.activeRightPanel', FILES);
|
|
73
|
+
const [showRightPanel, setShowRightPanel] = useSessionState<boolean>('layout.showRightPanel', true);
|
|
74
|
+
const handle = useRightOpenRequest(setActiveRightPanel);
|
|
75
|
+
requestPanel = handle.requestPanel;
|
|
76
|
+
request = handle.request;
|
|
77
|
+
|
|
78
|
+
const onSelectPanel = (id: string) => {
|
|
79
|
+
if (activeRightPanel === id && showRightPanel) {
|
|
80
|
+
setShowRightPanel(false);
|
|
81
|
+
return;
|
|
82
|
+
}
|
|
83
|
+
setShowRightPanel(true);
|
|
84
|
+
handle.requestPanel(id);
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
return h(
|
|
88
|
+
Group,
|
|
89
|
+
{ orientation: 'horizontal', children: h(RightColumn, {
|
|
90
|
+
panelRef: { current: null },
|
|
91
|
+
open: showRightPanel,
|
|
92
|
+
width: 420,
|
|
93
|
+
minWidth: 200,
|
|
94
|
+
maxWidth: undefined,
|
|
95
|
+
catalog: CATALOG,
|
|
96
|
+
shownPanel: activeRightPanel,
|
|
97
|
+
selectedPanel: activeRightPanel,
|
|
98
|
+
activePanelFound: true,
|
|
99
|
+
hasActiveContext: false,
|
|
100
|
+
refreshKey: 0,
|
|
101
|
+
onRefresh: () => {},
|
|
102
|
+
onOpenFile: () => {},
|
|
103
|
+
onClose: () => {},
|
|
104
|
+
navStyle: 'tabs',
|
|
105
|
+
onSelectPanel,
|
|
106
|
+
openRequest: handle.request,
|
|
107
|
+
}) },
|
|
108
|
+
);
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
/** Render the provider on a session id and drain the load's promise chain. */
|
|
112
|
+
async function show(sessionId: string): Promise<void> {
|
|
113
|
+
await act(async () => {
|
|
114
|
+
render(h(SessionStateProvider, { sessionId, children: h(Harness, null) }), container);
|
|
115
|
+
});
|
|
116
|
+
await drain();
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
async function drain(): Promise<void> {
|
|
120
|
+
for (let i = 0; i < 20; i += 1) await act(async () => {});
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
function activeTab(): string | null {
|
|
124
|
+
return container.querySelector('[role="tab"][aria-selected="true"]')?.getAttribute('data-panel-tab') ?? null;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
beforeAll(() => {
|
|
128
|
+
installDomGlobals(new Window({ url: 'http://localhost' }));
|
|
129
|
+
const target = globalThis as unknown as Record<string, unknown>;
|
|
130
|
+
target.fetch = async (input: unknown, init?: { method?: string }) => {
|
|
131
|
+
const method = init?.method ?? 'GET';
|
|
132
|
+
const sessionId = String(input).split('/sessions/')[1]?.split('/')[0] ?? 'x';
|
|
133
|
+
if (method === 'POST') return new Response(JSON.stringify({ success: true }), { status: 200 });
|
|
134
|
+
return new Response(
|
|
135
|
+
JSON.stringify({ sessionId, state: { ...(getSessionState(sessionId) ?? {}) } }),
|
|
136
|
+
{ status: 200 },
|
|
137
|
+
);
|
|
138
|
+
};
|
|
139
|
+
});
|
|
140
|
+
|
|
141
|
+
afterAll(() => {
|
|
142
|
+
restoreDomGlobals();
|
|
143
|
+
});
|
|
144
|
+
|
|
145
|
+
beforeEach(() => {
|
|
146
|
+
resetSessionStateStore();
|
|
147
|
+
requestPanel = null;
|
|
148
|
+
request = null;
|
|
149
|
+
container = document.createElement('div');
|
|
150
|
+
document.body.appendChild(container);
|
|
151
|
+
hydrateSession('s-a', {
|
|
152
|
+
'layout.rightPanelTabs': { tabs: [FILES], active: FILES, home: false },
|
|
153
|
+
'layout.activeRightPanel': FILES,
|
|
154
|
+
'layout.showRightPanel': true,
|
|
155
|
+
});
|
|
156
|
+
hydrateSession('s-b', {});
|
|
157
|
+
});
|
|
158
|
+
|
|
159
|
+
afterEach(() => {
|
|
160
|
+
render(null, container);
|
|
161
|
+
container.remove();
|
|
162
|
+
});
|
|
163
|
+
|
|
164
|
+
describe('an explicit open request beside the strip mirror', () => {
|
|
165
|
+
test('the requested view is the one stored AND the one drawn, and nothing stays pending', async () => {
|
|
166
|
+
await show('s-a');
|
|
167
|
+
expect(activeTab()).toBe(FILES);
|
|
168
|
+
|
|
169
|
+
await act(async () => {
|
|
170
|
+
requestPanel?.(STATS);
|
|
171
|
+
});
|
|
172
|
+
await drain();
|
|
173
|
+
|
|
174
|
+
// The race this test exists for: on the buggy code the two writers keep
|
|
175
|
+
// swapping, so the stored selection and the drawn tab disagree in every
|
|
176
|
+
// commit — whichever parity the drains happen to land on.
|
|
177
|
+
expect(getSessionValue<{ active: string }>('s-a', 'layout.rightPanelTabs')?.active).toBe(STATS);
|
|
178
|
+
expect(activeTab()).toBe(STATS);
|
|
179
|
+
expect(getSessionValue<string>('s-a', 'layout.activeRightPanel')).toBe(STATS);
|
|
180
|
+
expect(container.textContent).toContain('Resources body');
|
|
181
|
+
|
|
182
|
+
// A pending request would be re-applied by the next commit (and by the next
|
|
183
|
+
// session). Settled means the nonce stops moving.
|
|
184
|
+
const settled = request?.nonce;
|
|
185
|
+
await drain();
|
|
186
|
+
expect(request?.nonce).toBe(settled);
|
|
187
|
+
});
|
|
188
|
+
|
|
189
|
+
test('a request that settled under one session is not replayed in the next', async () => {
|
|
190
|
+
await show('s-a');
|
|
191
|
+
await act(async () => {
|
|
192
|
+
requestPanel?.(STATS);
|
|
193
|
+
});
|
|
194
|
+
await drain();
|
|
195
|
+
|
|
196
|
+
await show('s-b');
|
|
197
|
+
|
|
198
|
+
// A still-pending nonce would open `Resources` here on the switch commit —
|
|
199
|
+
// the reported tab in every chat. A fresh session owns no tab and no pick.
|
|
200
|
+
expect(container.querySelectorAll('[role="tab"]').length).toBe(0);
|
|
201
|
+
expect(getSessionValue('s-b', 'layout.rightPanelTabs')).toBeUndefined();
|
|
202
|
+
expect(getSessionValue('s-b', 'layout.activeRightPanel')).toBeUndefined();
|
|
203
|
+
});
|
|
204
|
+
});
|
|
@@ -43,6 +43,7 @@ import { useLeftDock } from '@/client/hooks/workspace/left-dock';
|
|
|
43
43
|
import { usePanelTabs } from '@/client/hooks/workspace/panel-tabs';
|
|
44
44
|
import { useRevealEdge, useRevealPanelTab } from '@/client/hooks/workspace/panel-tabs-reveal';
|
|
45
45
|
import { useSessionStateContext } from '@/client/hooks/workspace/session-state/context';
|
|
46
|
+
import { getSessionValue } from '@/shared/lib/workspace/session-state/store';
|
|
46
47
|
import { resolvePanelNav, type PanelNavStyle } from '@/shared/lib/workspace/panel-nav';
|
|
47
48
|
|
|
48
49
|
export interface RightColumnProps {
|
|
@@ -126,10 +127,14 @@ export function RightColumn({
|
|
|
126
127
|
// for. The Stats readout, which names a panel, already opened one — this is
|
|
127
128
|
// the same answer for the click that names no view. See `panel-tabs-reveal`.
|
|
128
129
|
const revealed = useRevealEdge(open);
|
|
130
|
+
// The view this session PICKED, not the fallback `files`: a fresh chat has
|
|
131
|
+
// never stored one, and treating the fallback as a pick is what opened the
|
|
132
|
+
// file explorer in every new session.
|
|
133
|
+
const storedView = getSessionValue<string>(sessionId, 'layout.activeRightPanel') ?? null;
|
|
129
134
|
useRevealPanelTab({
|
|
130
135
|
enabled: tabsMode,
|
|
131
136
|
revealed,
|
|
132
|
-
|
|
137
|
+
storedView,
|
|
133
138
|
home: tabsState.home,
|
|
134
139
|
chosenHome: tabsState.chosenHome,
|
|
135
140
|
openTab: tabsState.open,
|
|
@@ -146,21 +151,6 @@ export function RightColumn({
|
|
|
146
151
|
// would mark a view active behind the catalog, and a view that re-reads on
|
|
147
152
|
// activation would fetch for a page nobody is looking at.
|
|
148
153
|
const effectivePanel = tabsMode ? (tabsState.home ? null : tabsState.active) : shownPanel;
|
|
149
|
-
// Opening a tab from the home page happens through the strip, which writes the
|
|
150
|
-
// hook; the effect above then mirrors it into the stored selection. `pinned`
|
|
151
|
-
// is null here, so `active` is the user's own choice and may be `null`.
|
|
152
|
-
useEffect(() => {
|
|
153
|
-
if (!tabsMode || tabsState.home || tabsState.active === null) return;
|
|
154
|
-
if (tabsState.active !== shownPanel) onSelectPanel?.(tabsState.active);
|
|
155
|
-
}, [tabsMode, tabsState.home, tabsState.active, shownPanel, onSelectPanel]);
|
|
156
|
-
|
|
157
|
-
/**
|
|
158
|
-
* The OTHER direction, and it listens to a REQUEST rather than to
|
|
159
|
-
* `shownPanel` — see `openRequest`. A restored selection is not an opening:
|
|
160
|
-
* this column's default is the home page, so the only thing that may add a
|
|
161
|
-
* tab without the user pressing something in the strip is a caller that
|
|
162
|
-
* asked for a view by name.
|
|
163
|
-
*/
|
|
164
154
|
const { open: openTab } = tabsState;
|
|
165
155
|
/**
|
|
166
156
|
* Each request is applied ONCE, tracked by its nonce.
|
|
@@ -174,6 +164,37 @@ export function RightColumn({
|
|
|
174
164
|
const appliedRequest = useRef<number | null>(null);
|
|
175
165
|
const requestKey = openRequest?.panelKey;
|
|
176
166
|
const requestNonce = openRequest?.nonce;
|
|
167
|
+
/**
|
|
168
|
+
* A request that has not been applied yet is AHEAD of the strip: it writes
|
|
169
|
+
* `layout.activeRightPanel` in its event handler, while the tab it names is
|
|
170
|
+
* only opened by the effect below. For that commit `shownPanel` names the
|
|
171
|
+
* requested view and `tabsState.active` names the one the user is leaving —
|
|
172
|
+
* the mirror effect would read that as a strip choice and request the OLD
|
|
173
|
+
* view right back. The two then alternate every commit: measured on a session
|
|
174
|
+
* whose strip held `Files`, clicking the Stats readout added `Resources` but
|
|
175
|
+
* left `Files` selected and drawn, and the still-pending request re-applied
|
|
176
|
+
* after a session switch — the tab appeared in the next chat too.
|
|
177
|
+
*/
|
|
178
|
+
const requestPending = requestNonce !== undefined && appliedRequest.current !== requestNonce;
|
|
179
|
+
// Opening a tab from the home page happens through the strip, which writes the
|
|
180
|
+
// hook; the effect above then mirrors it into the stored selection. `pinned`
|
|
181
|
+
// is null here, so `active` is the user's own choice and may be `null`.
|
|
182
|
+
useEffect(() => {
|
|
183
|
+
if (!tabsMode || tabsState.home || tabsState.active === null) return;
|
|
184
|
+
if (tabsState.active === shownPanel) return;
|
|
185
|
+
// The divergence a pending request creates is not a strip choice; only the
|
|
186
|
+
// request may answer it, and it does so in the effect below.
|
|
187
|
+
if (requestPending) return;
|
|
188
|
+
onSelectPanel?.(tabsState.active);
|
|
189
|
+
}, [tabsMode, tabsState.home, tabsState.active, shownPanel, onSelectPanel, requestPending]);
|
|
190
|
+
|
|
191
|
+
/**
|
|
192
|
+
* The OTHER direction, and it listens to a REQUEST rather than to
|
|
193
|
+
* `shownPanel` — see `openRequest`. A restored selection is not an opening:
|
|
194
|
+
* this column's default is the home page, so the only thing that may add a
|
|
195
|
+
* tab without the user pressing something in the strip is a caller that
|
|
196
|
+
* asked for a view by name.
|
|
197
|
+
*/
|
|
177
198
|
useEffect(() => {
|
|
178
199
|
if (!tabsMode || requestKey === undefined || requestNonce === undefined) return;
|
|
179
200
|
if (appliedRequest.current === requestNonce) return;
|
|
@@ -99,23 +99,25 @@ export function MobileRightSidebar({
|
|
|
99
99
|
const tabsMode = navStyle === 'tabs';
|
|
100
100
|
const known = useMemo(() => new Set(catalog.map((panel) => panel.id)), [catalog]);
|
|
101
101
|
const tabsState = usePanelTabs('right', known, null);
|
|
102
|
-
//
|
|
103
|
-
//
|
|
104
|
-
//
|
|
102
|
+
// Whether the session's blob actually holds a right-drawer view. Read through
|
|
103
|
+
// the store (not the hook's fallback), because "unset" and "set to the
|
|
104
|
+
// default" are different facts here — and only the former is a session the
|
|
105
|
+
// header's reveal may open a view for.
|
|
106
|
+
const hasStoredTab = getSessionValue<string>(sessionId, 'layout.mobileRightPanel') !== undefined;
|
|
107
|
+
// The header's "Open Right Panel" is a reveal, so it shows the view this
|
|
108
|
+
// session PICKED. A fresh chat never picked one (`activeTab` is the `files`
|
|
109
|
+
// fallback), so it keeps its catalog — the reported defect was a new chat
|
|
110
|
+
// opening a `Files` tab every time the drawer was revealed.
|
|
105
111
|
useRevealPanelTab({
|
|
106
112
|
enabled: tabsMode,
|
|
107
113
|
revealed: useRevealSignal(revealSignal),
|
|
108
|
-
|
|
114
|
+
storedView: hasStoredTab ? activeTab : null,
|
|
109
115
|
home: tabsState.home,
|
|
110
116
|
chosenHome: tabsState.chosenHome,
|
|
111
117
|
openTab: tabsState.open,
|
|
112
118
|
known,
|
|
113
119
|
});
|
|
114
120
|
const { open: openTab, tabs: openTabIds } = tabsState;
|
|
115
|
-
// Whether the session's blob actually holds a right-drawer view. Read through
|
|
116
|
-
// the store (not the hook's fallback), because "unset" and "set to the
|
|
117
|
-
// default" are different facts here.
|
|
118
|
-
const hasStoredTab = getSessionValue<string>(sessionId, 'layout.mobileRightPanel') !== undefined;
|
|
119
121
|
|
|
120
122
|
/**
|
|
121
123
|
* Every gesture that CHANGES the view must arm the soft keyboard before the
|
|
@@ -46,7 +46,8 @@ export function useMobileDrawerTabs(dock: MobileDockState, revealSignal: number)
|
|
|
46
46
|
useRevealPanelTab({
|
|
47
47
|
enabled: dock.tabsMode,
|
|
48
48
|
revealed: useRevealSignal(revealSignal),
|
|
49
|
-
view
|
|
49
|
+
// The left drawer pins the session list, so it always has a view to reveal.
|
|
50
|
+
storedView: dock.activeView,
|
|
50
51
|
home: tabs?.home ?? false,
|
|
51
52
|
chosenHome: tabs?.chosenHome ?? false,
|
|
52
53
|
openTab: tabs?.open ?? null,
|
|
@@ -186,6 +186,17 @@ describe('MessageList mounted window', () => {
|
|
|
186
186
|
expect(footers(el)).toBe(1);
|
|
187
187
|
});
|
|
188
188
|
|
|
189
|
+
test('the trailing footer marks the row whose measured slot it fills', async () => {
|
|
190
|
+
// The footer is a sibling of the row group, outside the row's rect, so the
|
|
191
|
+
// row window learns its height from this marker only. Without it the
|
|
192
|
+
// content height changes when the row at the window's edge mounts — the
|
|
193
|
+
// up/down flicker at the end of a stream (pinned by `row-window.test.ts`).
|
|
194
|
+
const messages = [user('u1'), ai('a1'), user('u2'), ai('a2')];
|
|
195
|
+
const el = await mountWindowed(messages, window(0, 2, 0, 500));
|
|
196
|
+
const marker = el.querySelector('[data-row-footer-for]');
|
|
197
|
+
expect(marker?.getAttribute('data-row-footer-for')).toBe('a1');
|
|
198
|
+
});
|
|
199
|
+
|
|
189
200
|
test('an errored answer renders the failure instead of an empty bubble', async () => {
|
|
190
201
|
const el = await mount([
|
|
191
202
|
user('u1'),
|
|
@@ -150,7 +150,8 @@ export const MessageList = memo(function MessageList({
|
|
|
150
150
|
// The run footer belongs to the run but NOT to its trace: it is a model
|
|
151
151
|
// and duration stamp, not a step. Left inside the rail container it drew
|
|
152
152
|
// the line 58px past the last node (measured), so it renders after the
|
|
153
|
-
// grouped rows instead
|
|
153
|
+
// grouped rows instead — outside its row's rect, which is why the
|
|
154
|
+
// sibling below marks which row's measured slot it fills.
|
|
154
155
|
const lastIdx = group.rows[group.rows.length - 1];
|
|
155
156
|
const trailingFooter = footers[lastIdx];
|
|
156
157
|
return (
|
|
@@ -215,26 +216,33 @@ export const MessageList = memo(function MessageList({
|
|
|
215
216
|
})}
|
|
216
217
|
</div>
|
|
217
218
|
{trailingFooter && (
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
219
|
+
// `data-row-footer-for` is a measurement contract, not decoration:
|
|
220
|
+
// the footer is a SIBLING of the row above (the rail must not run
|
|
221
|
+
// through it), so it sits outside that row's rect — the row window
|
|
222
|
+
// attributes it back by this marker. `flow-root` so the footer's own
|
|
223
|
+
// `mt-2` is inside the rect the window measures.
|
|
224
|
+
<div data-row-footer-for={messages[lastIdx].id} style={{ display: 'flow-root' }}>
|
|
225
|
+
<RunFooter
|
|
226
|
+
msg={trailingFooter.msg}
|
|
227
|
+
provider={provider}
|
|
228
|
+
providerNames={providerNames}
|
|
229
|
+
modelName={modelName}
|
|
230
|
+
modelNames={modelNames}
|
|
231
|
+
thinkingLevel={thinkingLevel}
|
|
232
|
+
{...(harness ? { harness } : {})}
|
|
233
|
+
durationMs={trailingFooter.durationMs}
|
|
234
|
+
answerText={trailingFooter.answerText}
|
|
235
|
+
retryTargetId={trailingFooter.runUserId}
|
|
236
|
+
onRetry={onRetry}
|
|
237
|
+
onNewChat={onNewChat}
|
|
238
|
+
onFork={onFork}
|
|
239
|
+
isMobile={isMobile}
|
|
240
|
+
showActions={userActions}
|
|
241
|
+
changedFiles={changedFilesByOwner.get(trailingFooter.ownerIndex)}
|
|
242
|
+
sessionId={sessionId}
|
|
243
|
+
runWindow={runWindows.get(trailingFooter.ownerIndex)}
|
|
244
|
+
/>
|
|
245
|
+
</div>
|
|
238
246
|
)}
|
|
239
247
|
</Fragment>
|
|
240
248
|
);
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Measuring the mounted window into the layout's height map.
|
|
8
|
+
*
|
|
9
|
+
* Split out of `row-window.ts` so that hook stays under the repo's per-file
|
|
10
|
+
* ceiling; the arithmetic is self-contained (DOM in, slot map out) and the
|
|
11
|
+
* subtlety it encodes is worth its own module.
|
|
12
|
+
*
|
|
13
|
+
* A row's SLOT is its wrapper PLUS the run footer that closes it. The footer is
|
|
14
|
+
* a sibling of the row GROUP — it is a model/duration stamp, not a step of the
|
|
15
|
+
* trace rail, so it cannot live inside the rail's container — which puts it
|
|
16
|
+
* outside the row's own rect. Left out of the layout, the rendered content
|
|
17
|
+
* height depended on which rows were mounted: the row at the window's edge
|
|
18
|
+
* pulled its footer in with it, the total grew by the footer's height, the tail
|
|
19
|
+
* pin followed, and the next frame's window started one row later and dropped
|
|
20
|
+
* it again — measured in Chromium at a run's settle as scrollTop 1938 → 1968 →
|
|
21
|
+
* 1938 with scrollHeight 2236 → 2266 → 2236, i.e. the reported up/down flicker
|
|
22
|
+
* at the end of a stream. The marker (`data-row-footer-for`) is set by
|
|
23
|
+
* `MessageList`; the pad then carries the footer for a row that is unmounted,
|
|
24
|
+
* exactly as it carries the row.
|
|
25
|
+
*/
|
|
26
|
+
|
|
27
|
+
/** A measurement is only adopted when it differs by more than this. */
|
|
28
|
+
const MEASURE_EPSILON_PX = 0.5;
|
|
29
|
+
|
|
30
|
+
export interface RowMeasurement {
|
|
31
|
+
/** At least one slot changed by more than the epsilon. */
|
|
32
|
+
changed: boolean;
|
|
33
|
+
/** A measured row sits at or above the viewport's top, so the content ABOVE
|
|
34
|
+
* the reader moved. */
|
|
35
|
+
above: boolean;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/** Read the mounted rows (and their footers) into `measured`, keyed by row id.
|
|
39
|
+
*
|
|
40
|
+
* A height survives the row being unmounted and remounted, which is what keeps
|
|
41
|
+
* the scrollbar steady — so this only ever ADDS or REFRESHES entries. */
|
|
42
|
+
export function measureRows(el: HTMLElement, measured: Map<string, number>): RowMeasurement {
|
|
43
|
+
let above = false;
|
|
44
|
+
const slots = new Map<string, number>();
|
|
45
|
+
for (const node of el.querySelectorAll<HTMLElement>('[data-row-id]')) {
|
|
46
|
+
const id = node.dataset.rowId;
|
|
47
|
+
if (!id) continue;
|
|
48
|
+
const rect = node.getBoundingClientRect();
|
|
49
|
+
const height = rect.height;
|
|
50
|
+
// A row measured while hidden reports 0; averaging it in would drag every
|
|
51
|
+
// unmeasured row toward nothing.
|
|
52
|
+
if (height <= 0) continue;
|
|
53
|
+
slots.set(id, height);
|
|
54
|
+
// A row at or above the viewport's top moves the content ABOVE the reader;
|
|
55
|
+
// the tail pin must not follow it (see `skipTailPinRef`).
|
|
56
|
+
if (rect.bottom <= 0) above = true;
|
|
57
|
+
}
|
|
58
|
+
for (const node of el.querySelectorAll<HTMLElement>('[data-row-footer-for]')) {
|
|
59
|
+
const id = node.dataset.rowFooterFor;
|
|
60
|
+
if (!id) continue;
|
|
61
|
+
// Only a mounted row has its footer on screen; an unmounted one takes the
|
|
62
|
+
// slot height recorded when it last was.
|
|
63
|
+
const height = slots.get(id);
|
|
64
|
+
if (height === undefined) continue;
|
|
65
|
+
slots.set(id, height + node.getBoundingClientRect().height);
|
|
66
|
+
}
|
|
67
|
+
let changed = false;
|
|
68
|
+
for (const [id, height] of slots) {
|
|
69
|
+
const previous = measured.get(id);
|
|
70
|
+
if (previous !== undefined && Math.abs(previous - height) <= MEASURE_EPSILON_PX) continue;
|
|
71
|
+
measured.set(id, height);
|
|
72
|
+
changed = true;
|
|
73
|
+
}
|
|
74
|
+
return { changed, above };
|
|
75
|
+
}
|
|
@@ -84,6 +84,16 @@ function installScroller(top: number): HTMLDivElement {
|
|
|
84
84
|
return el;
|
|
85
85
|
}
|
|
86
86
|
|
|
87
|
+
/** Mount `ROWS` stubbed row nodes, each reporting the rect `rectFor` returns. */
|
|
88
|
+
function installRows(scroller: HTMLDivElement, rectFor: (index: number, id: string) => DOMRect): void {
|
|
89
|
+
for (let i = 0; i < ROWS; i += 1) {
|
|
90
|
+
const node = document.createElement('div');
|
|
91
|
+
node.dataset.rowId = `r-${i}`;
|
|
92
|
+
node.getBoundingClientRect = () => rectFor(i, node.dataset.rowId!);
|
|
93
|
+
scroller.appendChild(node);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
|
|
87
97
|
interface JumpStub {
|
|
88
98
|
active: { current: boolean };
|
|
89
99
|
behavior: { current: ScrollBehavior };
|
|
@@ -236,12 +246,7 @@ describe('useTimelineRowWindow', () => {
|
|
|
236
246
|
// is what lands the open in the commit that measured the rows instead of
|
|
237
247
|
// one rAF later (measured in the browser: one painted frame 2 044 px short).
|
|
238
248
|
const scroller = installScroller(20_000);
|
|
239
|
-
|
|
240
|
-
const node = document.createElement('div');
|
|
241
|
-
node.dataset.rowId = `r-${i}`;
|
|
242
|
-
node.getBoundingClientRect = () => ({ height: ROW_HEIGHT }) as DOMRect;
|
|
243
|
-
scroller.appendChild(node);
|
|
244
|
-
}
|
|
249
|
+
installRows(scroller, () => ({ height: ROW_HEIGHT }) as DOMRect);
|
|
245
250
|
const tail = ROWS * ROW_HEIGHT - VIEWPORT;
|
|
246
251
|
await mount(scroller, { active: { current: true }, behavior: { current: 'instant' } });
|
|
247
252
|
await act(async () => {});
|
|
@@ -266,12 +271,7 @@ describe('useTimelineRowWindow', () => {
|
|
|
266
271
|
// snapping shut).
|
|
267
272
|
const scroller = installScroller(20_000);
|
|
268
273
|
const heights = new Map<string, number>();
|
|
269
|
-
|
|
270
|
-
const node = document.createElement('div');
|
|
271
|
-
node.dataset.rowId = `r-${i}`;
|
|
272
|
-
node.getBoundingClientRect = () => ({ height: heights.get(node.dataset.rowId!) ?? ROW_HEIGHT }) as DOMRect;
|
|
273
|
-
scroller.appendChild(node);
|
|
274
|
-
}
|
|
274
|
+
installRows(scroller, (_i, id) => ({ height: heights.get(id) ?? ROW_HEIGHT }) as DOMRect);
|
|
275
275
|
await mount(scroller);
|
|
276
276
|
await act(async () => {});
|
|
277
277
|
const opened = rowWindow!.start;
|
|
@@ -298,15 +298,10 @@ describe('useTimelineRowWindow', () => {
|
|
|
298
298
|
// must win, and the geometry pin must stand down for that delivery.
|
|
299
299
|
const scroller = installScroller(ROWS * ROW_HEIGHT - VIEWPORT);
|
|
300
300
|
const heights = new Map<string, number>();
|
|
301
|
-
|
|
302
|
-
const
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
const height = heights.get(node.dataset.rowId!) ?? ROW_HEIGHT;
|
|
306
|
-
return { height, bottom: i * ROW_HEIGHT + height - scroller.scrollTop } as DOMRect;
|
|
307
|
-
};
|
|
308
|
-
scroller.appendChild(node);
|
|
309
|
-
}
|
|
301
|
+
installRows(scroller, (i, id) => {
|
|
302
|
+
const height = heights.get(id) ?? ROW_HEIGHT;
|
|
303
|
+
return { height, bottom: i * ROW_HEIGHT + height - scroller.scrollTop } as DOMRect;
|
|
304
|
+
});
|
|
310
305
|
const skip = { current: false };
|
|
311
306
|
const jump = { active: { current: true }, behavior: { current: 'instant' as ScrollBehavior } };
|
|
312
307
|
await mount(scroller, jump, skip);
|
|
@@ -324,4 +319,29 @@ describe('useTimelineRowWindow', () => {
|
|
|
324
319
|
expect(scroller.scrollTop).toBe(before + 1_000);
|
|
325
320
|
expect(skip.current).toBe(true);
|
|
326
321
|
});
|
|
322
|
+
|
|
323
|
+
test('a run footer is measured into the slot of the row it closes', async () => {
|
|
324
|
+
// The reported up/down flicker at the end of a stream: the footer is a
|
|
325
|
+
// SIBLING of the row group (the rail must not run through it), so its
|
|
326
|
+
// height is outside the row's rect. Left out of the layout, the content
|
|
327
|
+
// height depended on the mounted window — the row at its edge pulled the
|
|
328
|
+
// footer in with it, the total grew by the footer's height, the tail pin
|
|
329
|
+
// followed, and the next frame's window started one row later and dropped
|
|
330
|
+
// it again (measured in Chromium: scrollTop 1938 → 1968 → 1938 with
|
|
331
|
+
// scrollHeight 2236 → 2266 → 2236). The spacer must carry it instead.
|
|
332
|
+
const scroller = installScroller(20_000);
|
|
333
|
+
installRows(scroller, () => ({ height: ROW_HEIGHT }) as DOMRect);
|
|
334
|
+
const footer = document.createElement('div');
|
|
335
|
+
footer.dataset.rowFooterFor = 'r-150';
|
|
336
|
+
footer.getBoundingClientRect = () => ({ height: 30 }) as DOMRect;
|
|
337
|
+
scroller.appendChild(footer);
|
|
338
|
+
|
|
339
|
+
await mount(scroller);
|
|
340
|
+
await act(async () => {});
|
|
341
|
+
|
|
342
|
+
// `r-150` is above the mounted window, so its slot (row + footer) is
|
|
343
|
+
// inside `padTop`: the spacer describes the session, not the window.
|
|
344
|
+
expect(rowWindow!.start).toBeGreaterThan(150);
|
|
345
|
+
expect(rowWindow!.padTop).toBe(rowWindow!.start * ROW_HEIGHT + 30);
|
|
346
|
+
});
|
|
327
347
|
});
|
|
@@ -33,9 +33,7 @@ import type { RefObject } from 'preact/compat';
|
|
|
33
33
|
import { useEffect, useLayoutEffect, useMemo, useRef, useState } from 'preact/hooks';
|
|
34
34
|
import { layoutTimelineRows, rowIndex, timelineWindow } from '@/shared/lib/chat/timeline/row-window';
|
|
35
35
|
import { createRevealRow, writeScrollTop } from '@/client/hooks/chat/timeline/row-window-reveal';
|
|
36
|
-
|
|
37
|
-
/** A measurement is only adopted when it differs by more than this. */
|
|
38
|
-
const MEASURE_EPSILON_PX = 0.5;
|
|
36
|
+
import { measureRows } from '@/client/hooks/chat/timeline/row-measure';
|
|
39
37
|
|
|
40
38
|
/** Distance from the bottom, in px, that makes a reader "at the tail". Mirrors
|
|
41
39
|
* `FOLLOW_BOTTOM_THRESHOLD_PX` in `scroll.ts`: below it, follow mode is on. */
|
|
@@ -206,30 +204,14 @@ export function useTimelineRowWindow({
|
|
|
206
204
|
// row every frame, an accordion expands, an image decodes — and a stale height
|
|
207
205
|
// there is a scrollbar that describes a session shorter than it is, which is
|
|
208
206
|
// what makes a jump land short. `range` is a dependency because a new window
|
|
209
|
-
// means a new set of nodes to observe.
|
|
207
|
+
// means a new set of nodes to observe. The run footers are observed for the
|
|
208
|
+
// same reason: `changedFiles` lands in one a second after the turn, and its
|
|
209
|
+
// growth belongs to the row's slot (see `row-measure.ts`).
|
|
210
210
|
useLayoutEffect(() => {
|
|
211
211
|
if (!enabled) return;
|
|
212
212
|
const el = element;
|
|
213
213
|
if (!el) return;
|
|
214
|
-
const measure = ()
|
|
215
|
-
let changed = false;
|
|
216
|
-
let above = false;
|
|
217
|
-
for (const node of el.querySelectorAll<HTMLElement>('[data-row-id]')) {
|
|
218
|
-
const id = node.dataset.rowId;
|
|
219
|
-
if (!id) continue;
|
|
220
|
-
const rect = node.getBoundingClientRect();
|
|
221
|
-
const height = rect.height;
|
|
222
|
-
if (height <= 0) continue;
|
|
223
|
-
const previous = measuredRef.current.get(id);
|
|
224
|
-
if (previous !== undefined && Math.abs(previous - height) <= MEASURE_EPSILON_PX) continue;
|
|
225
|
-
measuredRef.current.set(id, height);
|
|
226
|
-
// A row at or above the viewport's top moves the content ABOVE the
|
|
227
|
-
// reader; the tail pin must not follow it (see `skipTailPinRef`).
|
|
228
|
-
if (rect.bottom <= 0) above = true;
|
|
229
|
-
changed = true;
|
|
230
|
-
}
|
|
231
|
-
return { changed, above };
|
|
232
|
-
};
|
|
214
|
+
const measure = () => measureRows(el, measuredRef.current);
|
|
233
215
|
const adopt = (above: boolean): void => {
|
|
234
216
|
// Which row the reader is looking at, under the geometry they are still
|
|
235
217
|
// seeing: `el.scrollTop` has not moved yet (a browser does not adjust it
|
|
@@ -309,7 +291,7 @@ export function useTimelineRowWindow({
|
|
|
309
291
|
if (result.changed) adopt(result.above);
|
|
310
292
|
});
|
|
311
293
|
});
|
|
312
|
-
for (const node of el.querySelectorAll('[data-row-id]')) observer.observe(node);
|
|
294
|
+
for (const node of el.querySelectorAll('[data-row-id], [data-row-footer-for]')) observer.observe(node);
|
|
313
295
|
return () => {
|
|
314
296
|
observer.disconnect();
|
|
315
297
|
if (frame !== null) cancelAnimationFrame(frame);
|