@kabmo-labs/kabmo 0.14.1 → 0.16.0
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/README.md +1 -0
- package/dist/client/index.html +1 -1
- package/dist/client/index.js +374 -356
- package/dist/client/static/js/{index-w6jx0h0p.js → index-cpydmygd.js} +661 -661
- package/dist/client/static/js/index-fjnq2z2d.css +1 -0
- package/marketplace/plugins/command-runner/README.md +5 -3
- package/marketplace/plugins/command-runner/package.json +2 -2
- package/marketplace/plugins/command-runner/src/app.tsx +3 -3
- package/marketplace/plugins/command-runner/src/panel/Groups.test.tsx +25 -21
- package/marketplace/plugins/command-runner/src/panel/Groups.tsx +4 -1
- package/marketplace/plugins/stats/README.md +27 -8
- package/marketplace/plugins/stats/package.json +2 -2
- package/marketplace/plugins/stats/src/HeaderReadout.test.tsx +2 -1
- package/marketplace/plugins/stats/src/HeaderReadout.tsx +6 -2
- package/marketplace/plugins/stats/src/KillConfirm.test.tsx +159 -0
- package/marketplace/plugins/stats/src/KillConfirm.tsx +145 -0
- package/marketplace/plugins/stats/src/ProcessTable.tsx +54 -8
- package/marketplace/plugins/stats/src/TotalsBar.test.tsx +5 -2
- package/marketplace/plugins/stats/src/TotalsBar.tsx +13 -3
- package/marketplace/plugins/stats/src/app.test.tsx +100 -4
- package/marketplace/plugins/stats/src/app.tsx +51 -4
- package/marketplace/plugins/stats/src/groups.test.ts +1 -1
- package/marketplace/plugins/stats/src/kill.test.ts +131 -0
- package/marketplace/plugins/stats/src/kill.ts +74 -0
- package/marketplace/plugins/stats/src/labels.test.ts +1 -0
- package/marketplace/plugins/stats/src/machine.test.ts +77 -0
- package/marketplace/plugins/stats/src/machine.ts +115 -0
- package/marketplace/plugins/stats/src/proc/darwin.ts +38 -0
- package/marketplace/plugins/stats/src/proc/linux.ts +4 -0
- package/marketplace/plugins/stats/src/proc/ps.ts +1 -0
- package/marketplace/plugins/stats/src/proc/types.ts +11 -0
- package/marketplace/plugins/stats/src/sampler.test.ts +42 -4
- package/marketplace/plugins/stats/src/sampler.ts +32 -18
- package/marketplace/plugins/stats/src/server.ts +29 -2
- package/marketplace/plugins/stats/src/snapshot.ts +31 -3
- package/package.json +3 -2
- package/src/client/components/common/Modal.tsx +7 -0
- package/src/client/components/layout/LeftDock.tsx +1 -0
- package/src/client/components/layout/desktop-layout/WorkspacePanels.tsx +1 -0
- package/src/client/components/mobile/LayoutWrapper.tsx +11 -10
- package/src/client/components/mobile/RightSidebar.tsx +1 -0
- package/src/client/components/mobile/mobile-session-sidebar/use-dock.ts +1 -0
- package/src/client/components/mobile/open-file-payload.test.ts +29 -1
- package/src/client/components/mobile/open-file-payload.ts +28 -0
- package/src/client/components/settings/Modal.tsx +2 -2
- package/src/client/components/workspace/editor/index.tsx +6 -8
- package/src/client/components/workspace/git-panel/branch-modal/index.tsx +4 -3
- package/src/client/components/workspace/git-panel/commit-modal/index.tsx +1 -1
- package/src/client/components/workspace/model-dropdown/Panel.tsx +7 -2
- package/src/client/components/workspace/model-dropdown/Section.test.tsx +13 -0
- package/src/client/components/workspace/model-dropdown/Section.tsx +5 -1
- package/src/client/components/workspace/panels/builtin.tsx +7 -0
- package/src/client/components/workspace/wiki-panel/NavModal.test.tsx +136 -0
- package/src/client/components/workspace/wiki-panel/NavModal.tsx +94 -0
- package/src/client/components/workspace/wiki-panel/PageView.tsx +16 -10
- package/src/client/components/workspace/wiki-panel/index.tsx +44 -9
- package/src/client/hooks/chat/timeline/index.ts +3 -6
- package/src/client/hooks/chat/timeline/jump-landing.ts +121 -0
- package/src/client/hooks/chat/timeline/jump-rail.ts +19 -10
- package/src/client/hooks/chat/timeline/row-window.ts +44 -4
- package/src/client/hooks/chat/timeline/scroll-probe.test-util.ts +23 -10
- package/src/client/hooks/chat/timeline/scroll.test.ts +61 -4
- package/src/client/hooks/chat/timeline/scroll.ts +77 -26
- package/src/client/hooks/workspace/missing-files.test.ts +20 -3
- package/src/client/hooks/workspace/missing-files.ts +41 -7
- package/src/client/tailwind.css +12 -1
- package/src/server/lib/db/schema.ts +11 -0
- package/src/server/lib/lifecycle/memory.test.ts +41 -1
- package/src/server/lib/lifecycle/memory.ts +131 -14
- package/src/server/lib/omp/session/subagent-presence-scan.test.ts +137 -0
- package/src/server/lib/omp/session/subagent-presence-scan.ts +120 -0
- package/src/server/lib/omp/session/subagent-presence-store.test.ts +120 -0
- package/src/server/lib/omp/session/subagent-presence-store.ts +65 -0
- package/src/server/lib/omp/session/subagent-presence.ts +52 -15
- package/src/server/routes/fs/exists.test.ts +26 -1
- package/dist/client/static/js/index-bnrrw242.css +0 -1
|
@@ -123,6 +123,19 @@ describe('model picker section header columns', () => {
|
|
|
123
123
|
expect(chevronSlot.querySelector('svg')).not.toBeNull();
|
|
124
124
|
});
|
|
125
125
|
|
|
126
|
+
test('the header pins to the top of the scrolling list', () => {
|
|
127
|
+
mountSection();
|
|
128
|
+
|
|
129
|
+
// The list is capped (`max-h-80`), so a provider heading that scrolled
|
|
130
|
+
// away left its rows unnamed. `sticky top-0` keeps it in view; the opaque
|
|
131
|
+
// paper background is what hides the rows passing underneath, and z-10
|
|
132
|
+
// keeps the heading above them.
|
|
133
|
+
expect(header().className).toContain('sticky');
|
|
134
|
+
expect(header().className).toContain('top-0');
|
|
135
|
+
expect(header().className).toContain('bg-paper');
|
|
136
|
+
expect(header().className).toContain('z-10');
|
|
137
|
+
});
|
|
138
|
+
|
|
126
139
|
test('a row carries its row id, which the specs card anchors to', () => {
|
|
127
140
|
mountSection();
|
|
128
141
|
|
|
@@ -56,7 +56,11 @@ export function ModelDropdownSection({
|
|
|
56
56
|
<button
|
|
57
57
|
type="button"
|
|
58
58
|
onClick={() => onToggleCollapse(id)}
|
|
59
|
-
|
|
59
|
+
// Sticky: the list is capped at `max-h-80`, and a section heading that
|
|
60
|
+
// scrolled away left the rows below it with no provider to name them.
|
|
61
|
+
// The opaque paper background is what hides those rows as they pass
|
|
62
|
+
// under the pinned heading; `z-10` keeps the heading above the rows.
|
|
63
|
+
className="sticky top-0 z-10 w-full flex items-center justify-between gap-2 pl-1 pr-2 py-1 text-[11px] font-semibold text-ink/60 uppercase tracking-wider hover:text-ink cursor-pointer select-none bg-paper"
|
|
60
64
|
>
|
|
61
65
|
<div className="flex items-center gap-2 min-w-0">
|
|
62
66
|
{iconType === 'star' && (
|
|
@@ -52,6 +52,13 @@ export interface PanelBodyProps {
|
|
|
52
52
|
onClose?: () => void;
|
|
53
53
|
/** The phone's drawer hides a view's own header; the desktop stack does not. */
|
|
54
54
|
showHeader?: boolean;
|
|
55
|
+
/**
|
|
56
|
+
* Which shell is drawing this body. A view with its own small-screen form
|
|
57
|
+
* (the wiki's floating page-list button) must know the PHONE from a merely
|
|
58
|
+
* narrow desktop column; no container or media query can tell the two apart.
|
|
59
|
+
* Omitted means desktop.
|
|
60
|
+
*/
|
|
61
|
+
layout?: 'desktop' | 'phone';
|
|
55
62
|
/**
|
|
56
63
|
* The boot settings snapshot, for the views that read it (the session list
|
|
57
64
|
* passes it to its own Settings modal and to the prewarm's access mode).
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* The narrow wiki nav: an outlined floating trigger opens the page list as a
|
|
8
|
+
* modal, and reaching a page closes it.
|
|
9
|
+
*
|
|
10
|
+
* Three properties are pinned because each is invisible to a markup screenshot:
|
|
11
|
+
* the trigger reports its open state (`aria-expanded`), Escape closes the modal
|
|
12
|
+
* the reader opened (no other UI unmounts it), and a page click closes it too —
|
|
13
|
+
* a modal left covering the page the reader just chose is the bug this pair
|
|
14
|
+
* exists to avoid.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
import { afterAll, afterEach, beforeAll, describe, expect, test } from 'bun:test';
|
|
18
|
+
import { Window } from 'happy-dom';
|
|
19
|
+
import { render, type ComponentChild } from 'preact';
|
|
20
|
+
import { act } from 'preact/test-utils';
|
|
21
|
+
import { WikiNavModal, WikiNavTrigger } from '@/client/components/workspace/wiki-panel/NavModal';
|
|
22
|
+
import { installDomGlobals, restoreDomGlobals } from '@/test-support/pristine-globals';
|
|
23
|
+
import type { WikiNavSection } from '@/shared/types/wiki';
|
|
24
|
+
|
|
25
|
+
const SECTIONS: WikiNavSection[] = [
|
|
26
|
+
{
|
|
27
|
+
title: 'Navigation',
|
|
28
|
+
links: [
|
|
29
|
+
{ label: 'Home', target: 'Home', path: 'Home.md', url: null },
|
|
30
|
+
{ label: 'Deploying', target: 'Deploying', path: 'Deploying.md', url: null },
|
|
31
|
+
],
|
|
32
|
+
notes: ['**Version**: 1.6.0'],
|
|
33
|
+
},
|
|
34
|
+
];
|
|
35
|
+
|
|
36
|
+
let container: HTMLElement | null = null;
|
|
37
|
+
|
|
38
|
+
function mount(node: ComponentChild): HTMLElement {
|
|
39
|
+
container = document.createElement('div');
|
|
40
|
+
document.body.appendChild(container);
|
|
41
|
+
act(() => render(node, container as HTMLElement));
|
|
42
|
+
return container;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
beforeAll(() => {
|
|
46
|
+
installDomGlobals(new Window({ url: 'http://localhost' }));
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
afterEach(() => {
|
|
50
|
+
if (container) {
|
|
51
|
+
render(null, container);
|
|
52
|
+
container.remove();
|
|
53
|
+
container = null;
|
|
54
|
+
}
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
afterAll(() => {
|
|
58
|
+
restoreDomGlobals();
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
describe('WikiNavTrigger', () => {
|
|
62
|
+
test('is an outlined button that reports the state it opens', () => {
|
|
63
|
+
let clicks = 0;
|
|
64
|
+
const root = mount(<WikiNavTrigger open={false} onClick={() => { clicks += 1; }} />);
|
|
65
|
+
const button = root.querySelector('button');
|
|
66
|
+
|
|
67
|
+
expect(button).not.toBeNull();
|
|
68
|
+
expect(button?.getAttribute('aria-expanded')).toBe('false');
|
|
69
|
+
// Outline, not fill: the trigger floats over the document it belongs to.
|
|
70
|
+
expect(button?.getAttribute('class')).toContain('border');
|
|
71
|
+
|
|
72
|
+
act(() => button?.click());
|
|
73
|
+
expect(clicks).toBe(1);
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
test('reports the modal as expanded while it is open', () => {
|
|
77
|
+
const root = mount(<WikiNavTrigger open onClick={() => {}} />);
|
|
78
|
+
expect(root.querySelector('button')?.getAttribute('aria-expanded')).toBe('true');
|
|
79
|
+
});
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
describe('WikiNavModal', () => {
|
|
83
|
+
test('renders nothing while closed', () => {
|
|
84
|
+
const root = mount(
|
|
85
|
+
<WikiNavModal open={false} sections={SECTIONS} selected={null} onSelect={() => {}} onClose={() => {}} />,
|
|
86
|
+
);
|
|
87
|
+
expect(root.querySelector('[role="dialog"]')).toBeNull();
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
test('shows the wiki sections and closes when a page is chosen', () => {
|
|
91
|
+
const selected: string[] = [];
|
|
92
|
+
let closed = 0;
|
|
93
|
+
const root = mount(
|
|
94
|
+
<WikiNavModal
|
|
95
|
+
open
|
|
96
|
+
sections={SECTIONS}
|
|
97
|
+
selected="Home.md"
|
|
98
|
+
onSelect={(path) => selected.push(path)}
|
|
99
|
+
onClose={() => { closed += 1; }}
|
|
100
|
+
/>,
|
|
101
|
+
);
|
|
102
|
+
|
|
103
|
+
const dialog = root.querySelector('[role="dialog"]');
|
|
104
|
+
expect(dialog).not.toBeNull();
|
|
105
|
+
expect(dialog?.getAttribute('aria-label')).toBe('Wiki pages');
|
|
106
|
+
expect(dialog?.textContent).toContain('Navigation');
|
|
107
|
+
expect(dialog?.textContent).toContain('1.6.0');
|
|
108
|
+
|
|
109
|
+
const page = Array.from(dialog?.querySelectorAll<HTMLButtonElement>('button') ?? []).find(
|
|
110
|
+
(button) => button.textContent === 'Deploying',
|
|
111
|
+
);
|
|
112
|
+
expect(page).not.toBeNull();
|
|
113
|
+
act(() => page?.click());
|
|
114
|
+
|
|
115
|
+
expect(selected).toEqual(['Deploying.md']);
|
|
116
|
+
expect(closed).toBe(1);
|
|
117
|
+
});
|
|
118
|
+
|
|
119
|
+
test('Escape closes the modal', () => {
|
|
120
|
+
let closed = 0;
|
|
121
|
+
mount(
|
|
122
|
+
<WikiNavModal
|
|
123
|
+
open
|
|
124
|
+
sections={SECTIONS}
|
|
125
|
+
selected={null}
|
|
126
|
+
onSelect={() => {}}
|
|
127
|
+
onClose={() => { closed += 1; }}
|
|
128
|
+
/>,
|
|
129
|
+
);
|
|
130
|
+
|
|
131
|
+
act(() => {
|
|
132
|
+
document.dispatchEvent(new window.KeyboardEvent('keydown', { key: 'Escape' }));
|
|
133
|
+
});
|
|
134
|
+
expect(closed).toBe(1);
|
|
135
|
+
});
|
|
136
|
+
});
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* The wiki's navigation on the phone: the floating outline-style button in the
|
|
8
|
+
* page, and the page list as a modal.
|
|
9
|
+
*
|
|
10
|
+
* This is the same pattern the phone's markdown editor already uses for its
|
|
11
|
+
* outline (`MobileOutlineButton`): a tap-sized round button outlined rather
|
|
12
|
+
* than filled, floating over the document it belongs to, with the list in the
|
|
13
|
+
* shared `Modal` shell. The desktop panel keeps its nav column and its
|
|
14
|
+
* drill-down when the column is narrow; `WikiPanel` decides which one renders
|
|
15
|
+
* from the `layout` it was handed, never from a container query.
|
|
16
|
+
*
|
|
17
|
+
* Selecting a page closes the modal, because the point of opening it was to
|
|
18
|
+
* reach that page.
|
|
19
|
+
*/
|
|
20
|
+
|
|
21
|
+
import { useEffect } from 'preact/hooks';
|
|
22
|
+
import { ListTree } from 'lucide-preact';
|
|
23
|
+
import { Modal } from '@/client/components/common/Modal';
|
|
24
|
+
import { WikiNav } from '@/client/components/workspace/wiki-panel/Nav';
|
|
25
|
+
import type { WikiNavSection } from '@/shared/types/wiki';
|
|
26
|
+
|
|
27
|
+
interface WikiNavTriggerProps {
|
|
28
|
+
open: boolean;
|
|
29
|
+
onClick: () => void;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export function WikiNavTrigger({ open, onClick }: WikiNavTriggerProps) {
|
|
33
|
+
return (
|
|
34
|
+
<button
|
|
35
|
+
type="button"
|
|
36
|
+
onClick={onClick}
|
|
37
|
+
title="Browse wiki pages"
|
|
38
|
+
aria-label="Browse wiki pages"
|
|
39
|
+
aria-expanded={open}
|
|
40
|
+
className="absolute bottom-3 right-3 z-20 flex h-9 w-9 items-center justify-center rounded-full border border-ink/20 bg-paper text-ink/60 shadow-sm transition-all hover:bg-ink/5 hover:text-ink active:scale-95"
|
|
41
|
+
>
|
|
42
|
+
<ListTree size={16} />
|
|
43
|
+
</button>
|
|
44
|
+
);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
interface WikiNavModalProps {
|
|
48
|
+
open: boolean;
|
|
49
|
+
sections: readonly WikiNavSection[];
|
|
50
|
+
selected: string | null;
|
|
51
|
+
onSelect: (path: string) => void;
|
|
52
|
+
onClose: () => void;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
export function WikiNavModal({ open, sections, selected, onSelect, onClose }: WikiNavModalProps) {
|
|
56
|
+
// A dialog this small is dismissed with Escape in every other surface; the
|
|
57
|
+
// shared `Modal` shell does not bind it, so the owner of the open flag does.
|
|
58
|
+
useEffect(() => {
|
|
59
|
+
if (!open) return;
|
|
60
|
+
const onKeyDown = (event: KeyboardEvent) => {
|
|
61
|
+
if (event.key === 'Escape') onClose();
|
|
62
|
+
};
|
|
63
|
+
document.addEventListener('keydown', onKeyDown);
|
|
64
|
+
return () => document.removeEventListener('keydown', onKeyDown);
|
|
65
|
+
}, [open, onClose]);
|
|
66
|
+
|
|
67
|
+
if (!open) return null;
|
|
68
|
+
|
|
69
|
+
return (
|
|
70
|
+
<Modal
|
|
71
|
+
onClose={onClose}
|
|
72
|
+
maxWidthClass="max-w-sm"
|
|
73
|
+
zClass="z-[70]"
|
|
74
|
+
ariaLabel="Wiki pages"
|
|
75
|
+
header={
|
|
76
|
+
<div className="flex min-w-0 items-center gap-2">
|
|
77
|
+
<ListTree size={15} className="flex-shrink-0 text-ink/50" />
|
|
78
|
+
<span className="text-sm font-medium">Wiki pages</span>
|
|
79
|
+
</div>
|
|
80
|
+
}
|
|
81
|
+
>
|
|
82
|
+
<div className="flex h-[60vh] min-h-0 flex-col">
|
|
83
|
+
<WikiNav
|
|
84
|
+
sections={sections}
|
|
85
|
+
selected={selected}
|
|
86
|
+
onSelect={(path) => {
|
|
87
|
+
onSelect(path);
|
|
88
|
+
onClose();
|
|
89
|
+
}}
|
|
90
|
+
/>
|
|
91
|
+
</div>
|
|
92
|
+
</Modal>
|
|
93
|
+
);
|
|
94
|
+
}
|
|
@@ -29,7 +29,11 @@ interface WikiPageViewProps {
|
|
|
29
29
|
rootPath?: string;
|
|
30
30
|
repoScope: string;
|
|
31
31
|
onNavigate: (path: string) => void;
|
|
32
|
-
|
|
32
|
+
/**
|
|
33
|
+
* The desktop's narrow-column back arrow. Absent on the phone, where the page
|
|
34
|
+
* list is a modal reached by the floating button and nothing needs a back.
|
|
35
|
+
*/
|
|
36
|
+
onBack?: () => void;
|
|
33
37
|
}
|
|
34
38
|
|
|
35
39
|
/** Web URL of one page, for "open on the host". Null for an unknown provider. */
|
|
@@ -66,15 +70,17 @@ export function WikiPageView({
|
|
|
66
70
|
return (
|
|
67
71
|
<div className="flex h-full min-h-0 w-full flex-col bg-paper">
|
|
68
72
|
<div className="flex flex-shrink-0 items-center gap-1.5 border-b border-ink/10 px-2.5 py-1.5">
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
73
|
+
{onBack && (
|
|
74
|
+
<button
|
|
75
|
+
type="button"
|
|
76
|
+
onClick={onBack}
|
|
77
|
+
title="Back to the page list"
|
|
78
|
+
aria-label="Back to the page list"
|
|
79
|
+
className="flex-shrink-0 rounded p-1 text-ink/60 hover:bg-ink/5 hover:text-ink @[520px]:hidden"
|
|
80
|
+
>
|
|
81
|
+
<ArrowLeft size={13} />
|
|
82
|
+
</button>
|
|
83
|
+
)}
|
|
78
84
|
<span className="min-w-0 flex-1 truncate text-[11px] text-ink/50" title={path}>
|
|
79
85
|
{path}
|
|
80
86
|
</span>
|
|
@@ -22,6 +22,7 @@ import { useEffect, useMemo, useState } from 'preact/hooks';
|
|
|
22
22
|
import { AlertCircle, BookOpen, ExternalLink, Loader2, RefreshCw } from 'lucide-preact';
|
|
23
23
|
import { GitRepoPicker } from '@/client/components/workspace/repo-picker';
|
|
24
24
|
import { WikiNav } from '@/client/components/workspace/wiki-panel/Nav';
|
|
25
|
+
import { WikiNavModal, WikiNavTrigger } from '@/client/components/workspace/wiki-panel/NavModal';
|
|
25
26
|
import { WikiPageView } from '@/client/components/workspace/wiki-panel/PageView';
|
|
26
27
|
import { useSessionState } from '@/client/hooks/workspace/session-state';
|
|
27
28
|
import { useRepoList, useRepoScope } from '@/client/hooks/workspace/repo-scope';
|
|
@@ -36,6 +37,12 @@ interface WikiPanelProps {
|
|
|
36
37
|
active?: boolean;
|
|
37
38
|
rootPath?: string;
|
|
38
39
|
refreshKey?: number;
|
|
40
|
+
/**
|
|
41
|
+
* Which shell is drawing this view. The phone gets the floating page-list
|
|
42
|
+
* button; the desktop keeps its nav column and the drill-down a narrow
|
|
43
|
+
* column has always used. Defaults to desktop for a caller that predates it.
|
|
44
|
+
*/
|
|
45
|
+
layout?: 'desktop' | 'phone';
|
|
39
46
|
}
|
|
40
47
|
|
|
41
48
|
/** Why there is no wiki, in the reader's terms. */
|
|
@@ -52,7 +59,15 @@ interface WikiPick {
|
|
|
52
59
|
path: string;
|
|
53
60
|
}
|
|
54
61
|
|
|
55
|
-
export function WikiPanel({
|
|
62
|
+
export function WikiPanel({
|
|
63
|
+
className = '',
|
|
64
|
+
enabled = true,
|
|
65
|
+
active = true,
|
|
66
|
+
rootPath,
|
|
67
|
+
refreshKey = 0,
|
|
68
|
+
layout = 'desktop',
|
|
69
|
+
}: WikiPanelProps) {
|
|
70
|
+
const isPhone = layout === 'phone';
|
|
56
71
|
const { activeRepo, setActiveRepo } = useRepoScope(rootPath);
|
|
57
72
|
const { repos, scanning: reposScanning, rescan: rescanRepos } = useRepoList(rootPath, enabled);
|
|
58
73
|
const scope = wikiScopeKey(rootPath, activeRepo);
|
|
@@ -60,6 +75,10 @@ export function WikiPanel({ className = '', enabled = true, active = true, rootP
|
|
|
60
75
|
// The pick is stored WITH its scope: a page path from another repository names
|
|
61
76
|
// a page this wiki does not have, and restoring it would open a 404.
|
|
62
77
|
const [pick, setPick] = useSessionState<WikiPick | null>('wiki.selectedPage', null);
|
|
78
|
+
// The phone's page-list modal.
|
|
79
|
+
const [navOpen, setNavOpen] = useState(false);
|
|
80
|
+
// The desktop's narrow-column drill-down: the list replaces the page until a
|
|
81
|
+
// page is chosen, then the page carries a back arrow.
|
|
63
82
|
const [narrowShowingPage, setNarrowShowingPage] = useState(false);
|
|
64
83
|
// Bumped by the panel's own Refresh so the open page follows a re-listed tree
|
|
65
84
|
// (the tree's revision is what a page read is anchored to).
|
|
@@ -74,6 +93,9 @@ export function WikiPanel({ className = '', enabled = true, active = true, rootP
|
|
|
74
93
|
() => tree.data?.sidebar ?? sectionsFromEntries(entries),
|
|
75
94
|
[tree.data?.sidebar, entries],
|
|
76
95
|
);
|
|
96
|
+
// A wiki with no links has nothing for the narrow modal to show, so the
|
|
97
|
+
// floating trigger stays away rather than opening an empty sheet.
|
|
98
|
+
const hasNavLinks = useMemo(() => sections.some((section) => section.links.length > 0), [sections]);
|
|
77
99
|
|
|
78
100
|
const storedPath = pick && pick.scope === scope ? pick.path : null;
|
|
79
101
|
// The stored page when it still exists in this wiki, else Home, else the first
|
|
@@ -100,15 +122,17 @@ export function WikiPanel({ className = '', enabled = true, active = true, rootP
|
|
|
100
122
|
setPick({ scope, path: selectedPath });
|
|
101
123
|
}, [selectedPath, storedPath, scope, setPick]);
|
|
102
124
|
|
|
103
|
-
// A different wiki is a different document:
|
|
104
|
-
// so a repo switch lands on the list
|
|
125
|
+
// A different wiki is a different document: close the nav and drop the
|
|
126
|
+
// desktop drill-down so a repo switch lands on the list, not on a page of the
|
|
127
|
+
// old one.
|
|
105
128
|
useEffect(() => {
|
|
129
|
+
setNavOpen(false);
|
|
106
130
|
setNarrowShowingPage(false);
|
|
107
131
|
}, [scope]);
|
|
108
132
|
|
|
109
133
|
const handleSelect = (path: string) => {
|
|
110
134
|
setPick({ scope, path });
|
|
111
|
-
setNarrowShowingPage(true);
|
|
135
|
+
if (!isPhone) setNarrowShowingPage(true);
|
|
112
136
|
};
|
|
113
137
|
|
|
114
138
|
const handleRefresh = () => {
|
|
@@ -209,15 +233,17 @@ export function WikiPanel({ className = '', enabled = true, active = true, rootP
|
|
|
209
233
|
// narrow drill-down's hidden/shown pair needs no second set of rules.
|
|
210
234
|
<div className="flex min-h-0 flex-1 flex-col @[520px]:flex-row-reverse">
|
|
211
235
|
<div
|
|
212
|
-
className={
|
|
213
|
-
narrowShowingPage ? 'hidden @[520px]:flex' : 'flex'
|
|
214
|
-
} flex-col`}
|
|
236
|
+
className={`${
|
|
237
|
+
isPhone ? 'hidden' : narrowShowingPage ? 'hidden @[520px]:flex' : 'flex'
|
|
238
|
+
} min-h-0 w-full flex-col @[520px]:w-52 @[520px]:flex-shrink-0 @[520px]:border-l @[520px]:border-ink/10`}
|
|
215
239
|
>
|
|
216
240
|
<WikiNav sections={sections} selected={selectedPath} onSelect={handleSelect} />
|
|
217
241
|
</div>
|
|
218
242
|
|
|
219
243
|
<div
|
|
220
|
-
className={`min-w-0 min-h-0 flex-1 ${
|
|
244
|
+
className={`relative min-w-0 min-h-0 flex-1 ${
|
|
245
|
+
isPhone ? 'flex' : narrowShowingPage ? 'flex' : 'hidden @[520px]:flex'
|
|
246
|
+
} flex-col`}
|
|
221
247
|
>
|
|
222
248
|
{repo && selectedPath ? (
|
|
223
249
|
<WikiPageView
|
|
@@ -230,13 +256,22 @@ export function WikiPanel({ className = '', enabled = true, active = true, rootP
|
|
|
230
256
|
rootPath={rootPath}
|
|
231
257
|
repoScope={activeRepo}
|
|
232
258
|
onNavigate={handleSelect}
|
|
233
|
-
onBack={() => setNarrowShowingPage(false)}
|
|
259
|
+
onBack={isPhone ? undefined : () => setNarrowShowingPage(false)}
|
|
234
260
|
/>
|
|
235
261
|
) : (
|
|
236
262
|
<div className="flex h-full items-center justify-center px-6 text-center text-[11px] text-ink/40">
|
|
237
263
|
This wiki has no markdown pages.
|
|
238
264
|
</div>
|
|
239
265
|
)}
|
|
266
|
+
|
|
267
|
+
{isPhone && hasNavLinks && <WikiNavTrigger open={navOpen} onClick={() => setNavOpen(true)} />}
|
|
268
|
+
<WikiNavModal
|
|
269
|
+
open={navOpen}
|
|
270
|
+
sections={sections}
|
|
271
|
+
selected={selectedPath}
|
|
272
|
+
onSelect={handleSelect}
|
|
273
|
+
onClose={() => setNavOpen(false)}
|
|
274
|
+
/>
|
|
240
275
|
</div>
|
|
241
276
|
</div>
|
|
242
277
|
)}
|
|
@@ -48,9 +48,8 @@ export function useChatTimeline({
|
|
|
48
48
|
// without re-creating it (useSessionLoad is defined below the scroll hook).
|
|
49
49
|
const loadOlderRef = useRef<() => void>(() => {});
|
|
50
50
|
|
|
51
|
-
const
|
|
52
|
-
|
|
53
|
-
});
|
|
51
|
+
const scroll = useChatTimelineScroll({ onScrollTop: () => loadOlderRef.current() });
|
|
52
|
+
const { scrollRef, scrollNodeRef, contentRef, showScrollBottom, readingBack, handleScroll, scrollToBottom, jumpToBottom, jumpActiveRef, jumpCountRef } = scroll;
|
|
54
53
|
|
|
55
54
|
const { inputValue, setInputValue, inputAttachments, setInputAttachments } = useComposerDraft();
|
|
56
55
|
const [localMessages, setLocalMessages] = useState<ChatMessageData[]>([]);
|
|
@@ -158,9 +157,7 @@ export function useChatTimeline({
|
|
|
158
157
|
sessionId,
|
|
159
158
|
messages: localMessages,
|
|
160
159
|
jumpToTurn,
|
|
161
|
-
|
|
162
|
-
scrollRef,
|
|
163
|
-
scrollNode,
|
|
160
|
+
scroll,
|
|
164
161
|
});
|
|
165
162
|
|
|
166
163
|
// The composer's model/thinking mirrors and the mid-run stash (see the hook).
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* The bottom jump's LANDING: who owns the viewport, and for how long.
|
|
8
|
+
*
|
|
9
|
+
* Split out of `scroll.ts` so that hook stays under the repo's per-file
|
|
10
|
+
* ceiling; the loop is self-contained and talks to the hook only through refs,
|
|
11
|
+
* which is what lets it run for a couple of seconds without a re-render.
|
|
12
|
+
*
|
|
13
|
+
* A one-shot `scrollTo` is not enough on this timeline, for two reasons that
|
|
14
|
+
* both come from the mounted row window (`row-window.ts`):
|
|
15
|
+
*
|
|
16
|
+
* - The rows a jump passes over mount as it goes, and every measurement
|
|
17
|
+
* replaces an estimate with a real height — so `scrollHeight` changes DURING
|
|
18
|
+
* the jump and the target it was issued against is stale. A landing short of
|
|
19
|
+
* the tail re-reads as "the reader is a few hundred px up", which is exactly
|
|
20
|
+
* the state the scroll-bottom button exists for: the button stays up, and the
|
|
21
|
+
* next click finishes the job. That is the reported "it sometimes does not
|
|
22
|
+
* work until I scroll the rest myself".
|
|
23
|
+
* - A measurement above the viewport moves the tail down, and the row window's
|
|
24
|
+
* own correction then writes a position under the animation. So while this
|
|
25
|
+
* watch is armed it is the ONLY writer: the content observer and the row
|
|
26
|
+
* window both stand down (`jumpActiveRef`), and a competing instant pin is
|
|
27
|
+
* what made a landing read as a snap instead of one scroll.
|
|
28
|
+
*
|
|
29
|
+
* The guard is released by the LANDING, never by a clock: a timer released it
|
|
30
|
+
* while a long session was still measuring, and the observer then finished the
|
|
31
|
+
* jump with a snap.
|
|
32
|
+
*/
|
|
33
|
+
|
|
34
|
+
import type { RefObject } from 'preact/compat';
|
|
35
|
+
|
|
36
|
+
/** Frames the viewport must sit at the tail before a jump counts as landed.
|
|
37
|
+
* Three, not one: the correction that lands a stalled jump produces its own
|
|
38
|
+
* scroll event, and a single frame of stillness can be the gap between two
|
|
39
|
+
* layout commits that are still moving the tail. */
|
|
40
|
+
const JUMP_SETTLE_FRAMES = 3;
|
|
41
|
+
|
|
42
|
+
/** Frames without any movement, with the tail still out of reach, that mean
|
|
43
|
+
* the smooth animation is not running (dropped, or never started). */
|
|
44
|
+
const JUMP_STALL_FRAMES = 4;
|
|
45
|
+
|
|
46
|
+
/** A jump's landing deadline. A layout that never settles must not spin the
|
|
47
|
+
* watch forever; past this the viewport is released and the content
|
|
48
|
+
* observer's normal follow pin takes over. */
|
|
49
|
+
const JUMP_DEADLINE_MS = 2000;
|
|
50
|
+
|
|
51
|
+
export interface JumpLandingDeps {
|
|
52
|
+
/** The timeline's scroll container, read at call time. */
|
|
53
|
+
scrollRef: RefObject<HTMLDivElement>;
|
|
54
|
+
/** The guard this watch owns. `true` while a landing is in flight. */
|
|
55
|
+
jumpActiveRef: RefObject<boolean>;
|
|
56
|
+
/** Re-aim at the tail, keeping the animation continuous. */
|
|
57
|
+
pinToBottom: (behavior: ScrollBehavior) => void;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
export interface JumpLanding {
|
|
61
|
+
/** Take the viewport: releases the guard when the tail is reached. */
|
|
62
|
+
start: () => void;
|
|
63
|
+
/** Abandon the current landing (unmount, or a new jump replacing it). */
|
|
64
|
+
stop: () => void;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/** Build the watch. Stable for the life of the hook; a second `start` replaces
|
|
68
|
+
* the first, so two clicks cannot leave two loops fighting for the viewport. */
|
|
69
|
+
export function createJumpLanding({ scrollRef, jumpActiveRef, pinToBottom }: JumpLandingDeps): JumpLanding {
|
|
70
|
+
let frame: number | null = null;
|
|
71
|
+
let deadline = 0;
|
|
72
|
+
|
|
73
|
+
const stop = (): void => {
|
|
74
|
+
if (frame !== null) cancelAnimationFrame(frame);
|
|
75
|
+
frame = null;
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
const start = (): void => {
|
|
79
|
+
stop();
|
|
80
|
+
deadline = performance.now() + JUMP_DEADLINE_MS;
|
|
81
|
+
let lastTop = -1;
|
|
82
|
+
let still = 0;
|
|
83
|
+
let stalled = 0;
|
|
84
|
+
const step = (): void => {
|
|
85
|
+
frame = null;
|
|
86
|
+
const el = scrollRef.current;
|
|
87
|
+
if (!el || !jumpActiveRef.current) return;
|
|
88
|
+
const distance = el.scrollHeight - el.scrollTop - el.clientHeight;
|
|
89
|
+
const moved = Math.abs(el.scrollTop - lastTop) > 1;
|
|
90
|
+
lastTop = el.scrollTop;
|
|
91
|
+
if (distance <= 1) {
|
|
92
|
+
stalled = 0;
|
|
93
|
+
still += 1;
|
|
94
|
+
if (still >= JUMP_SETTLE_FRAMES) {
|
|
95
|
+
jumpActiveRef.current = false;
|
|
96
|
+
return;
|
|
97
|
+
}
|
|
98
|
+
} else {
|
|
99
|
+
still = 0;
|
|
100
|
+
stalled = moved ? 0 : stalled + 1;
|
|
101
|
+
// Still for a few frames with the tail out of reach: the animation is
|
|
102
|
+
// not running (a browser drops a smooth programmatic scroll when the
|
|
103
|
+
// content it scrolls through is replaced), or it landed against a
|
|
104
|
+
// target the measurements have since outgrown. Re-aim — smooth, so a
|
|
105
|
+
// continuation never reads as a second, separate jump.
|
|
106
|
+
if (stalled >= JUMP_STALL_FRAMES) {
|
|
107
|
+
stalled = 0;
|
|
108
|
+
pinToBottom('smooth');
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
if (performance.now() > deadline) {
|
|
112
|
+
jumpActiveRef.current = false;
|
|
113
|
+
return;
|
|
114
|
+
}
|
|
115
|
+
frame = requestAnimationFrame(step);
|
|
116
|
+
};
|
|
117
|
+
frame = requestAnimationFrame(step);
|
|
118
|
+
};
|
|
119
|
+
|
|
120
|
+
return { start, stop };
|
|
121
|
+
}
|
|
@@ -18,8 +18,8 @@
|
|
|
18
18
|
*/
|
|
19
19
|
|
|
20
20
|
import { useMemo } from 'preact/hooks';
|
|
21
|
-
import type { RefObject } from 'preact/compat';
|
|
22
21
|
import { useTimelineRowWindow, type TimelineRowWindow } from '@/client/hooks/chat/timeline/row-window';
|
|
22
|
+
import type { ChatTimelineScrollResult } from '@/client/hooks/chat/timeline/scroll';
|
|
23
23
|
import { useRailJump } from '@/client/hooks/chat/timeline/rail-jump';
|
|
24
24
|
import { useUserTurns } from '@/client/hooks/chat/timeline/user-turns';
|
|
25
25
|
import type { ChatMessageData, UserTurnRef } from '@/shared/types';
|
|
@@ -30,12 +30,15 @@ export interface UseTimelineJumpRailDeps {
|
|
|
30
30
|
messages: ChatMessageData[];
|
|
31
31
|
/** Pages history until the turn's row is mounted (session-pagination). */
|
|
32
32
|
jumpToTurn: (id: string, index: number) => Promise<boolean>;
|
|
33
|
-
/**
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
33
|
+
/**
|
|
34
|
+
* The scroll hook's own state. Three of its refs are the row window's
|
|
35
|
+
* contract, and taking the result keeps them described in ONE place:
|
|
36
|
+
* `followRef` (held off for the whole jump), the container (`scrollRef` and
|
|
37
|
+
* `scrollNode`), `jumpActiveRef` (the row window writes no position while a
|
|
38
|
+
* bottom jump lands) and `jumpCountRef` (a new value claims the tail, so the
|
|
39
|
+
* landing is not corrected back to the reading anchor).
|
|
40
|
+
*/
|
|
41
|
+
scroll: ChatTimelineScrollResult;
|
|
39
42
|
}
|
|
40
43
|
|
|
41
44
|
export interface TimelineJumpRail {
|
|
@@ -49,15 +52,21 @@ export interface TimelineJumpRail {
|
|
|
49
52
|
}
|
|
50
53
|
|
|
51
54
|
export function useTimelineJumpRail(deps: UseTimelineJumpRailDeps): TimelineJumpRail {
|
|
52
|
-
const { sessionId, messages, jumpToTurn,
|
|
55
|
+
const { sessionId, messages, jumpToTurn, scroll } = deps;
|
|
53
56
|
const rowIds = useMemo(() => messages.map((message) => message.id), [messages]);
|
|
54
|
-
const rowWindow = useTimelineRowWindow({
|
|
57
|
+
const rowWindow = useTimelineRowWindow({
|
|
58
|
+
ids: rowIds,
|
|
59
|
+
scrollRef: scroll.scrollRef,
|
|
60
|
+
scrollNode: scroll.scrollNode,
|
|
61
|
+
jumpActiveRef: scroll.jumpActiveRef,
|
|
62
|
+
jumpCountRef: scroll.jumpCountRef,
|
|
63
|
+
});
|
|
55
64
|
const { turns: userTurns, jumping: jumpingTurn, jumpToTurn: pagedJumpToTurn } = useUserTurns({
|
|
56
65
|
sessionId,
|
|
57
66
|
messages,
|
|
58
67
|
jumpToTurn,
|
|
59
68
|
revealRow: rowWindow.revealRow,
|
|
60
69
|
});
|
|
61
|
-
const jumpToUserTurn = useRailJump(pagedJumpToTurn, { followRef, scrollRef });
|
|
70
|
+
const jumpToUserTurn = useRailJump(pagedJumpToTurn, { followRef: scroll.followRef, scrollRef: scroll.scrollRef });
|
|
62
71
|
return { userTurns, jumpingTurn, jumpToUserTurn, rowWindow };
|
|
63
72
|
}
|