@lemonriver/core 0.3.0 → 0.5.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 +14 -4
- package/dist/{build-Bqo69DWP.js → build-CS1goZxt.js} +1 -1
- package/dist/cli/bin.js +4 -4
- package/dist/{config-DJ5rkMMg.js → config-BpbcCbUv.js} +3835 -1532
- package/dist/{config-teo3kWz7.d.ts → config-CYNOR93W.d.ts} +1 -1
- package/dist/{dev-B2FJD5bJ.js → dev-BpYnfgLL.js} +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +1 -1
- package/dist/locale/index.d.ts +1 -1
- package/dist/locale/index.js +1 -1
- package/dist/{preview-C93BOZL1.js → preview-HSzPPkSs.js} +1 -1
- package/dist/{types-DFK02XVv.d.ts → types-tdaXSyah.d.ts} +1 -0
- package/dist/{update-DsxZBtwv.js → update-CMRxtTc9.js} +18 -8
- package/dist/vite/index.d.ts +1 -1
- package/dist/vite/index.js +1 -1
- package/dist/{zh-tw-DwTAZKa6.js → zh-tw-DcrDeKxr.js} +5 -0
- package/package.json +2 -2
- package/src/agent/prompt.ts +2 -0
- package/src/agent/types.ts +14 -2
- package/src/app/components/agent/agent-panel.tsx +19 -5
- package/src/app/components/agent/connect-view.tsx +1 -1
- package/src/app/components/agent/provider-logo.tsx +10 -1
- package/src/app/components/player.tsx +105 -23
- package/src/app/components/present/curtain.tsx +52 -0
- package/src/app/components/present/last-slide-hint.tsx +36 -0
- package/src/app/components/sidebar/sidebar-footer.tsx +6 -1
- package/src/app/components/thumbnail-rail.tsx +1 -0
- package/src/app/lemonriver/agent/lemon.tsx +16 -1
- package/src/app/lemonriver/agent/provider-marks.tsx +53 -0
- package/src/app/lemonriver/agent-prefs/prefs.test.ts +173 -0
- package/src/app/lemonriver/agent-prefs/prefs.ts +137 -0
- package/src/app/lemonriver/agent-prefs/use-prefs.ts +36 -0
- package/src/app/lemonriver/agent-providers/section.tsx +75 -0
- package/src/app/lemonriver/agent-providers/use-providers.ts +61 -0
- package/src/app/lemonriver/board/blocks/block-panel.tsx +666 -0
- package/src/app/lemonriver/board/blocks/cache.ts +28 -0
- package/src/app/lemonriver/board/blocks/change-list.tsx +189 -0
- package/src/app/lemonriver/board/blocks/classify.test.ts +204 -0
- package/src/app/lemonriver/board/blocks/classify.ts +125 -0
- package/src/app/lemonriver/board/blocks/snapshot.ts +86 -0
- package/src/app/lemonriver/board/board-canvas.tsx +627 -104
- package/src/app/lemonriver/board/board-page.tsx +1687 -91
- package/src/app/lemonriver/board/board.css +58 -7
- package/src/app/lemonriver/board/layout.test.ts +84 -0
- package/src/app/lemonriver/board/layout.ts +112 -11
- package/src/app/lemonriver/board/model/agent-tasks.test.ts +200 -0
- package/src/app/lemonriver/board/model/agent-tasks.ts +191 -0
- package/src/app/lemonriver/board/model/apply-prompt.test.ts +121 -0
- package/src/app/lemonriver/board/model/apply-prompt.ts +115 -0
- package/src/app/lemonriver/board/model/apply.ts +71 -0
- package/src/app/lemonriver/board/model/cards.test.ts +95 -2
- package/src/app/lemonriver/board/model/cards.ts +88 -20
- package/src/app/lemonriver/board/model/changes.test.ts +244 -0
- package/src/app/lemonriver/board/model/changes.ts +268 -0
- package/src/app/lemonriver/board/model/filter.test.ts +50 -0
- package/src/app/lemonriver/board/model/filter.ts +42 -0
- package/src/app/lemonriver/board/model/history.test.ts +71 -0
- package/src/app/lemonriver/board/model/history.ts +51 -0
- package/src/app/lemonriver/board/model/restructure.test.ts +205 -0
- package/src/app/lemonriver/board/model/restructure.ts +169 -0
- package/src/app/lemonriver/board/model/structure.test.ts +249 -0
- package/src/app/lemonriver/board/model/structure.ts +209 -0
- package/src/app/lemonriver/board/model/timing.test.ts +113 -0
- package/src/app/lemonriver/board/model/timing.ts +117 -0
- package/src/app/lemonriver/board/page-node.tsx +236 -55
- package/src/app/lemonriver/board/status-style.ts +25 -0
- package/src/app/lemonriver/board/use-board-apply.ts +206 -0
- package/src/app/lemonriver/board/use-board-cards.ts +108 -5
- package/src/app/lemonriver/board/use-board-changes.ts +108 -0
- package/src/app/lemonriver/board/use-board-columns.ts +37 -56
- package/src/app/lemonriver/board/use-board-comments.ts +36 -0
- package/src/app/lemonriver/board/use-board-restructures.ts +107 -0
- package/src/app/lemonriver/board/use-history.ts +86 -0
- package/src/app/lemonriver/board/use-page-order.ts +65 -38
- package/src/app/lemonriver/board/use-target-minutes.ts +47 -0
- package/src/app/lemonriver/board/views/block-readings.tsx +46 -0
- package/src/app/lemonriver/board/views/list-view.tsx +356 -0
- package/src/app/lemonriver/board/views/progress.tsx +32 -0
- package/src/app/lemonriver/board/views/timeline-view.tsx +341 -0
- package/src/app/lemonriver/brand/mascot.tsx +86 -0
- package/src/app/lemonriver/brand/mascots/design-done.png +0 -0
- package/src/app/lemonriver/brand/mascots/design-idle.png +0 -0
- package/src/app/lemonriver/brand/mascots/design-needs-you.png +0 -0
- package/src/app/lemonriver/brand/mascots/design-working.png +0 -0
- package/src/app/lemonriver/brand/mascots/outline-done.png +0 -0
- package/src/app/lemonriver/brand/mascots/outline-idle.png +0 -0
- package/src/app/lemonriver/brand/mascots/outline-needs-you.png +0 -0
- package/src/app/lemonriver/brand/mascots/outline-working.png +0 -0
- package/src/app/lemonriver/brand/mascots/research-done.png +0 -0
- package/src/app/lemonriver/brand/mascots/research-idle.png +0 -0
- package/src/app/lemonriver/brand/mascots/research-needs-you.png +0 -0
- package/src/app/lemonriver/brand/mascots/research-working.png +0 -0
- package/src/app/lemonriver/brand/mascots/review-done.png +0 -0
- package/src/app/lemonriver/brand/mascots/review-idle.png +0 -0
- package/src/app/lemonriver/brand/mascots/review-needs-you.png +0 -0
- package/src/app/lemonriver/brand/mascots/review-working.png +0 -0
- package/src/app/lemonriver/chrome/app-chrome.tsx +2 -0
- package/src/app/lemonriver/features.test.ts +5 -0
- package/src/app/lemonriver/features.ts +2 -1
- package/src/app/lemonriver/home/brief-card.tsx +8 -1
- package/src/app/lemonriver/home/home-page.tsx +11 -7
- package/src/app/lemonriver/onboarding/onboarding.tsx +182 -0
- package/src/app/lemonriver/outline/build-team.tsx +278 -0
- package/src/app/lemonriver/outline/describe-page.tsx +380 -0
- package/src/app/lemonriver/outline/files.test.ts +90 -0
- package/src/app/lemonriver/outline/files.ts +69 -0
- package/src/app/lemonriver/outline/model.test.ts +672 -0
- package/src/app/lemonriver/outline/model.ts +455 -0
- package/src/app/lemonriver/outline/outline-page.tsx +537 -0
- package/src/app/lemonriver/outline/pending-pages.tsx +39 -0
- package/src/app/lemonriver/outline/rule.ts +3 -0
- package/src/app/lemonriver/outline/steps.tsx +43 -0
- package/src/app/lemonriver/outline/use-build-driver.ts +258 -0
- package/src/app/lemonriver/routes.test.tsx +6 -6
- package/src/app/lemonriver/routes.tsx +28 -0
- package/src/app/lemonriver/settings/settings-page.tsx +214 -0
- package/src/app/lemonriver/slide-extensions.tsx +45 -26
- package/src/app/lemonriver/text/en.ts +320 -0
- package/src/app/lemonriver/text/es.ts +311 -0
- package/src/app/lemonriver/text/ja.ts +313 -0
- package/src/app/lemonriver/text/text.test.ts +33 -0
- package/src/app/lemonriver/text/types.ts +339 -0
- package/src/app/lemonriver/text/zh-cn.ts +307 -0
- package/src/app/lemonriver/text/zh-tw.ts +307 -0
- package/src/app/lemonriver/theme/app.css +12 -1
- package/src/app/lemonriver/theme/lemon-icon.tsx +6 -0
- package/src/app/lemonriver/theme/pages.test.ts +4 -0
- package/src/app/lemonriver/theme/pages.ts +11 -2
- package/src/app/lemonriver/theme/theme-menu.tsx +3 -2
- package/src/app/lemonriver/theme/use-theme.tsx +2 -2
- package/src/app/lemonriver/update/beta-badge.tsx +26 -0
- package/src/app/lemonriver/update/prompt.test.ts +84 -0
- package/src/app/lemonriver/update/prompt.ts +48 -0
- package/src/app/lemonriver/update/update-prompt.tsx +113 -0
- package/src/app/lib/agent/use-agent.ts +4 -3
- package/src/app/routes/home.tsx +13 -5
- package/src/app/routes/slide.tsx +71 -14
- package/src/locale/en.ts +1 -0
- package/src/locale/es.ts +1 -0
- package/src/locale/ja.ts +1 -0
- package/src/locale/types.ts +1 -0
- package/src/locale/zh-cn.ts +1 -0
- package/src/locale/zh-tw.ts +1 -0
- package/src/app/assets/open-slide.svg +0 -39
- package/src/app/favicon.ico +0 -0
- package/src/app/favicon.svg +0 -39
|
@@ -0,0 +1,258 @@
|
|
|
1
|
+
import { useCallback, useEffect, useSyncExternalStore } from 'react';
|
|
2
|
+
import {
|
|
3
|
+
createSession,
|
|
4
|
+
sendMessage,
|
|
5
|
+
setActiveSession,
|
|
6
|
+
useAgentSession,
|
|
7
|
+
useAgentSessions,
|
|
8
|
+
useAgentStatus,
|
|
9
|
+
} from '@/lib/agent/use-agent';
|
|
10
|
+
import type { AgentProviderId, AgentSession, AgentSessionSummary } from '../../../agent/types';
|
|
11
|
+
import { type DriverAction, driverAction, type Outline } from './model';
|
|
12
|
+
|
|
13
|
+
const POLL_BUILD_MS = 2000;
|
|
14
|
+
const POLL_IDLE_MS = 10_000;
|
|
15
|
+
|
|
16
|
+
type Snapshot = {
|
|
17
|
+
slideId: string | null;
|
|
18
|
+
outline: Outline | null | undefined;
|
|
19
|
+
running: boolean;
|
|
20
|
+
waitingForAnswer: boolean;
|
|
21
|
+
action: DriverAction;
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
type AgentView = {
|
|
25
|
+
sessions: AgentSessionSummary[];
|
|
26
|
+
active: AgentSession | null;
|
|
27
|
+
providerId: AgentProviderId | null;
|
|
28
|
+
connected: boolean;
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
let view: Snapshot = {
|
|
32
|
+
slideId: null,
|
|
33
|
+
outline: undefined,
|
|
34
|
+
running: false,
|
|
35
|
+
waitingForAnswer: false,
|
|
36
|
+
action: 'idle',
|
|
37
|
+
};
|
|
38
|
+
let agent: AgentView = { sessions: [], active: null, providerId: null, connected: false };
|
|
39
|
+
let timer: number | null = null;
|
|
40
|
+
let subscribers = 0;
|
|
41
|
+
let sending = false;
|
|
42
|
+
|
|
43
|
+
const listeners = new Set<() => void>();
|
|
44
|
+
|
|
45
|
+
function notify() {
|
|
46
|
+
for (const listener of listeners) listener();
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
function subscribe(listener: () => void): () => void {
|
|
50
|
+
listeners.add(listener);
|
|
51
|
+
return () => {
|
|
52
|
+
listeners.delete(listener);
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
function getSnapshot(): Snapshot {
|
|
57
|
+
return view;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/** The outline the team panel is following; the confirmation card reads it too. */
|
|
61
|
+
export function useBuildOutline(): Outline | null | undefined {
|
|
62
|
+
return useSyncExternalStore(
|
|
63
|
+
subscribe,
|
|
64
|
+
() => view.outline,
|
|
65
|
+
() => undefined,
|
|
66
|
+
);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
function currentAction(now: number): DriverAction {
|
|
70
|
+
if (!view.outline) return 'idle';
|
|
71
|
+
const action = driverAction(view.outline, { running: view.running, now });
|
|
72
|
+
return action === 'send' && !agent.connected ? 'interrupted' : action;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
function recompute() {
|
|
76
|
+
const action = currentAction(Date.now());
|
|
77
|
+
if (action === view.action) return;
|
|
78
|
+
view = { ...view, action };
|
|
79
|
+
notify();
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
async function sendPrompt(slideId: string, text: string): Promise<void> {
|
|
83
|
+
const existing = agent.sessions.find((session) => session.slideId === slideId);
|
|
84
|
+
if (existing) {
|
|
85
|
+
setActiveSession(existing.id);
|
|
86
|
+
await sendMessage(existing.id, text, { slideId });
|
|
87
|
+
return;
|
|
88
|
+
}
|
|
89
|
+
if (!agent.providerId) throw new Error('no agent');
|
|
90
|
+
const created = await createSession(agent.providerId, slideId);
|
|
91
|
+
await sendMessage(created.id, text, { slideId });
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
async function dispatch(slideId: string, resume: boolean): Promise<void> {
|
|
95
|
+
if (sending || !agent.connected) return;
|
|
96
|
+
sending = true;
|
|
97
|
+
try {
|
|
98
|
+
const res = await fetch('/__lr/outline/next', {
|
|
99
|
+
method: 'POST',
|
|
100
|
+
headers: { 'content-type': 'application/json' },
|
|
101
|
+
body: JSON.stringify({ slideId, resume }),
|
|
102
|
+
});
|
|
103
|
+
if (!res.ok) return;
|
|
104
|
+
const { prompt } = (await res.json()) as { prompt: string };
|
|
105
|
+
await sendPrompt(slideId, prompt);
|
|
106
|
+
await refresh(slideId);
|
|
107
|
+
} catch {
|
|
108
|
+
} finally {
|
|
109
|
+
sending = false;
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
function schedule() {
|
|
114
|
+
if (timer !== null || view.slideId === null) return;
|
|
115
|
+
const delay = view.outline?.state === 'building' ? POLL_BUILD_MS : POLL_IDLE_MS;
|
|
116
|
+
timer = window.setTimeout(() => {
|
|
117
|
+
timer = null;
|
|
118
|
+
const slideId = view.slideId;
|
|
119
|
+
if (slideId) void tick(slideId);
|
|
120
|
+
}, delay);
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
async function tick(slideId: string): Promise<void> {
|
|
124
|
+
await refresh(slideId);
|
|
125
|
+
schedule();
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
async function refresh(slideId: string): Promise<void> {
|
|
129
|
+
try {
|
|
130
|
+
const res = await fetch(`/__lr/outline?slideId=${encodeURIComponent(slideId)}`);
|
|
131
|
+
if (!res.ok) return;
|
|
132
|
+
const body = (await res.json()) as { outline: Outline | null };
|
|
133
|
+
if (view.slideId !== slideId) return;
|
|
134
|
+
view = { ...view, outline: body.outline };
|
|
135
|
+
const action = currentAction(Date.now());
|
|
136
|
+
const changed = action !== view.action;
|
|
137
|
+
view = { ...view, action };
|
|
138
|
+
if (changed) notify();
|
|
139
|
+
if (action === 'send') void dispatch(slideId, false);
|
|
140
|
+
} catch {}
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
function attach(slideId: string) {
|
|
144
|
+
subscribers += 1;
|
|
145
|
+
if (view.slideId !== slideId) {
|
|
146
|
+
if (timer !== null) {
|
|
147
|
+
window.clearTimeout(timer);
|
|
148
|
+
timer = null;
|
|
149
|
+
}
|
|
150
|
+
view = {
|
|
151
|
+
slideId,
|
|
152
|
+
outline: undefined,
|
|
153
|
+
running: false,
|
|
154
|
+
waitingForAnswer: false,
|
|
155
|
+
action: 'idle',
|
|
156
|
+
};
|
|
157
|
+
notify();
|
|
158
|
+
void refresh(slideId);
|
|
159
|
+
}
|
|
160
|
+
schedule();
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
function detach() {
|
|
164
|
+
subscribers = Math.max(subscribers - 1, 0);
|
|
165
|
+
if (subscribers > 0) return;
|
|
166
|
+
if (timer !== null) {
|
|
167
|
+
window.clearTimeout(timer);
|
|
168
|
+
timer = null;
|
|
169
|
+
}
|
|
170
|
+
view = { ...view, slideId: null };
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
function syncAgent(input: AgentView & { running: boolean; waitingForAnswer: boolean }) {
|
|
174
|
+
agent = {
|
|
175
|
+
sessions: input.sessions,
|
|
176
|
+
active: input.active,
|
|
177
|
+
providerId: input.providerId,
|
|
178
|
+
connected: input.connected,
|
|
179
|
+
};
|
|
180
|
+
if (view.running !== input.running || view.waitingForAnswer !== input.waitingForAnswer) {
|
|
181
|
+
view = { ...view, running: input.running, waitingForAnswer: input.waitingForAnswer };
|
|
182
|
+
notify();
|
|
183
|
+
}
|
|
184
|
+
recompute();
|
|
185
|
+
if (view.action === 'send' && view.slideId) void dispatch(view.slideId, false);
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
async function post(path: string, slideId: string, body: Record<string, unknown> = {}) {
|
|
189
|
+
try {
|
|
190
|
+
return await fetch(path, {
|
|
191
|
+
method: 'POST',
|
|
192
|
+
headers: { 'content-type': 'application/json' },
|
|
193
|
+
body: JSON.stringify({ slideId, ...body }),
|
|
194
|
+
});
|
|
195
|
+
} catch {
|
|
196
|
+
return null;
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
function lastIsPendingQuestion(session: AgentSession | null): boolean {
|
|
201
|
+
const last = session?.items.at(-1);
|
|
202
|
+
return last?.kind === 'question' && last.status === 'pending';
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
export function useBuildDriver(slideId: string) {
|
|
206
|
+
const { sessions, activeId } = useAgentSessions();
|
|
207
|
+
const active = useAgentSession(activeId);
|
|
208
|
+
const { connected, provider } = useAgentStatus();
|
|
209
|
+
|
|
210
|
+
const running = sessions.some(
|
|
211
|
+
(session) => session.slideId === slideId && session.status === 'running',
|
|
212
|
+
);
|
|
213
|
+
const waitingForAnswer = active?.slideId === slideId && lastIsPendingQuestion(active);
|
|
214
|
+
|
|
215
|
+
const snapshot = useSyncExternalStore(subscribe, getSnapshot, getSnapshot);
|
|
216
|
+
|
|
217
|
+
useEffect(() => {
|
|
218
|
+
attach(slideId);
|
|
219
|
+
return detach;
|
|
220
|
+
}, [slideId]);
|
|
221
|
+
|
|
222
|
+
useEffect(() => {
|
|
223
|
+
syncAgent({
|
|
224
|
+
sessions,
|
|
225
|
+
active,
|
|
226
|
+
providerId: provider?.id ?? null,
|
|
227
|
+
connected,
|
|
228
|
+
running,
|
|
229
|
+
waitingForAnswer,
|
|
230
|
+
});
|
|
231
|
+
}, [sessions, active, provider, connected, running, waitingForAnswer]);
|
|
232
|
+
|
|
233
|
+
const pause = useCallback(async () => {
|
|
234
|
+
const res = await post('/__lr/outline/pause', slideId, { paused: true });
|
|
235
|
+
if (res?.ok) await refresh(slideId);
|
|
236
|
+
}, [slideId]);
|
|
237
|
+
|
|
238
|
+
const resume = useCallback(async () => {
|
|
239
|
+
await post('/__lr/outline/pause', slideId, { paused: false });
|
|
240
|
+
await dispatch(slideId, true);
|
|
241
|
+
}, [slideId]);
|
|
242
|
+
|
|
243
|
+
const undo = useCallback(async () => {
|
|
244
|
+
const res = await post('/__lr/outline/undo', slideId);
|
|
245
|
+
return res?.ok ?? false;
|
|
246
|
+
}, [slideId]);
|
|
247
|
+
|
|
248
|
+
return {
|
|
249
|
+
outline: snapshot.slideId === slideId ? snapshot.outline : undefined,
|
|
250
|
+
action: snapshot.slideId === slideId ? snapshot.action : ('idle' as DriverAction),
|
|
251
|
+
running: snapshot.running,
|
|
252
|
+
waitingForAnswer: snapshot.waitingForAnswer,
|
|
253
|
+
connected,
|
|
254
|
+
pause,
|
|
255
|
+
resume,
|
|
256
|
+
undo,
|
|
257
|
+
};
|
|
258
|
+
}
|
|
@@ -14,11 +14,11 @@ const paths = (routes: unknown[]) =>
|
|
|
14
14
|
routes.filter(Boolean).map((r) => (r as ReactElement<{ path: string }>).props.path);
|
|
15
15
|
|
|
16
16
|
describe('lemonRiverRoutes', () => {
|
|
17
|
-
it('adds the board and the not-found page', () => {
|
|
18
|
-
expect(paths(lemonRiverRoutes())).toEqual(['/s/:slideId/board', '*']);
|
|
17
|
+
it('adds the board, the outline and the not-found page', () => {
|
|
18
|
+
expect(paths(lemonRiverRoutes())).toEqual(['/s/:slideId/board', '/s/:slideId/outline', '*']);
|
|
19
19
|
});
|
|
20
20
|
|
|
21
|
-
it('drops the
|
|
21
|
+
it('drops the pages whose feature is off', () => {
|
|
22
22
|
vi.mocked(isFeatureEnabled).mockReturnValue(false);
|
|
23
23
|
expect(paths(lemonRiverRoutes())).toEqual(['*']);
|
|
24
24
|
vi.mocked(isFeatureEnabled).mockReturnValue(true);
|
|
@@ -26,12 +26,12 @@ describe('lemonRiverRoutes', () => {
|
|
|
26
26
|
});
|
|
27
27
|
|
|
28
28
|
describe('lemonRiverShellRoutes', () => {
|
|
29
|
-
it('puts our home first, then settings and trash', () => {
|
|
30
|
-
expect(paths(lemonRiverShellRoutes())).toEqual(['/', '/settings', '/trash']);
|
|
29
|
+
it('puts our home and the guided flow first, then settings and trash', () => {
|
|
30
|
+
expect(paths(lemonRiverShellRoutes())).toEqual(['/', '/new', '/settings', '/trash']);
|
|
31
31
|
});
|
|
32
32
|
|
|
33
33
|
it('leaves out the pages whose feature is off', () => {
|
|
34
34
|
vi.mocked(isFeatureEnabled).mockImplementation((id) => id !== 'trash');
|
|
35
|
-
expect(paths(lemonRiverShellRoutes())).toEqual(['/', '/settings']);
|
|
35
|
+
expect(paths(lemonRiverShellRoutes())).toEqual(['/', '/new', '/settings']);
|
|
36
36
|
});
|
|
37
37
|
});
|
|
@@ -7,6 +7,12 @@ import { SettingsPage } from './settings/settings-page';
|
|
|
7
7
|
import { TrashPage } from './trash/trash-page';
|
|
8
8
|
|
|
9
9
|
const BoardPage = lazy(() => import('./board/board-page').then((m) => ({ default: m.Board })));
|
|
10
|
+
const DescribePage = lazy(() =>
|
|
11
|
+
import('./outline/describe-page').then((m) => ({ default: m.DescribePage })),
|
|
12
|
+
);
|
|
13
|
+
const OutlinePage = lazy(() =>
|
|
14
|
+
import('./outline/outline-page').then((m) => ({ default: m.OutlineView })),
|
|
15
|
+
);
|
|
10
16
|
|
|
11
17
|
/** Routes of our own, outside the home shell. Placed before the official catch-all. */
|
|
12
18
|
export function lemonRiverRoutes() {
|
|
@@ -22,6 +28,17 @@ export function lemonRiverRoutes() {
|
|
|
22
28
|
}
|
|
23
29
|
/>
|
|
24
30
|
),
|
|
31
|
+
isFeatureEnabled('outline') && (
|
|
32
|
+
<Route
|
|
33
|
+
key="outline"
|
|
34
|
+
path="/s/:slideId/outline"
|
|
35
|
+
element={
|
|
36
|
+
<Suspense fallback={null}>
|
|
37
|
+
<OutlinePage />
|
|
38
|
+
</Suspense>
|
|
39
|
+
}
|
|
40
|
+
/>
|
|
41
|
+
),
|
|
25
42
|
<Route key="not-found" path="*" element={<NotFound />} />,
|
|
26
43
|
];
|
|
27
44
|
}
|
|
@@ -30,6 +47,17 @@ export function lemonRiverRoutes() {
|
|
|
30
47
|
export function lemonRiverShellRoutes() {
|
|
31
48
|
return [
|
|
32
49
|
<Route key="home" path="/" element={<LemonRiverHome />} />,
|
|
50
|
+
isFeatureEnabled('outline') && (
|
|
51
|
+
<Route
|
|
52
|
+
key="new"
|
|
53
|
+
path="/new"
|
|
54
|
+
element={
|
|
55
|
+
<Suspense fallback={null}>
|
|
56
|
+
<DescribePage />
|
|
57
|
+
</Suspense>
|
|
58
|
+
}
|
|
59
|
+
/>
|
|
60
|
+
),
|
|
33
61
|
isFeatureEnabled('settings') && (
|
|
34
62
|
<Route key="settings" path="/settings" element={<SettingsPage />} />
|
|
35
63
|
),
|
|
@@ -1,6 +1,13 @@
|
|
|
1
|
+
import type { ReactNode } from 'react';
|
|
1
2
|
import { useEffect, useState } from 'react';
|
|
3
|
+
import { useNavigate } from 'react-router-dom';
|
|
2
4
|
import { useLocale } from '@/lib/use-locale';
|
|
3
5
|
import { cn } from '@/lib/utils';
|
|
6
|
+
import type { AgentPrefs } from '../agent-prefs/prefs';
|
|
7
|
+
import { updateAgentPrefs, useAgentPrefs } from '../agent-prefs/use-prefs';
|
|
8
|
+
import { AgentProvidersSection } from '../agent-providers/section';
|
|
9
|
+
import { HelperMascot, type HelperRole } from '../brand/mascot';
|
|
10
|
+
import { ONBOARDED_KEY } from '../onboarding/onboarding';
|
|
4
11
|
import { useLrText } from '../text';
|
|
5
12
|
import { setReduceMotionSetting, useReduceMotionSetting } from '../theme/motion';
|
|
6
13
|
import { LR_THEME_CHOICES, type LrThemeChoice } from '../theme/themes';
|
|
@@ -16,6 +23,8 @@ const SWATCH: Record<LrThemeChoice, { bg: string; fg: string }> = {
|
|
|
16
23
|
export function SettingsPage() {
|
|
17
24
|
const t = useLocale();
|
|
18
25
|
const lr = useLrText();
|
|
26
|
+
const navigate = useNavigate();
|
|
27
|
+
const prefs = useAgentPrefs();
|
|
19
28
|
const { theme, setTheme } = useTheme();
|
|
20
29
|
const reduceMotion = useReduceMotionSetting();
|
|
21
30
|
const [mounted, setMounted] = useState(false);
|
|
@@ -31,6 +40,63 @@ export function SettingsPage() {
|
|
|
31
40
|
lime: lr.theme.lime,
|
|
32
41
|
};
|
|
33
42
|
|
|
43
|
+
function replayOnboarding() {
|
|
44
|
+
try {
|
|
45
|
+
localStorage.removeItem(ONBOARDED_KEY);
|
|
46
|
+
} catch {}
|
|
47
|
+
navigate('/new');
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
const helpers: {
|
|
51
|
+
role: HelperRole;
|
|
52
|
+
label: string;
|
|
53
|
+
value: string;
|
|
54
|
+
apply: (value: string) => void;
|
|
55
|
+
options: { value: string; label: string }[];
|
|
56
|
+
}[] = [
|
|
57
|
+
{
|
|
58
|
+
role: 'research',
|
|
59
|
+
label: lr.build.research,
|
|
60
|
+
value: prefs.research,
|
|
61
|
+
apply: (value) => updateAgentPrefs({ research: value as AgentPrefs['research'] }),
|
|
62
|
+
options: [
|
|
63
|
+
{ value: 'uploads', label: lr.prefs.researchUploads },
|
|
64
|
+
{ value: 'web', label: lr.prefs.researchWeb },
|
|
65
|
+
],
|
|
66
|
+
},
|
|
67
|
+
{
|
|
68
|
+
role: 'outline',
|
|
69
|
+
label: lr.build.outline,
|
|
70
|
+
value: prefs.outline,
|
|
71
|
+
apply: (value) => updateAgentPrefs({ outline: value as AgentPrefs['outline'] }),
|
|
72
|
+
options: [
|
|
73
|
+
{ value: 'review', label: lr.prefs.outlineReview },
|
|
74
|
+
{ value: 'direct', label: lr.prefs.outlineDirect },
|
|
75
|
+
],
|
|
76
|
+
},
|
|
77
|
+
{
|
|
78
|
+
role: 'design',
|
|
79
|
+
label: lr.build.design,
|
|
80
|
+
value: prefs.design,
|
|
81
|
+
apply: (value) => updateAgentPrefs({ design: value as AgentPrefs['design'] }),
|
|
82
|
+
options: [
|
|
83
|
+
{ value: 'visual', label: lr.prefs.designVisual },
|
|
84
|
+
{ value: 'balanced', label: lr.prefs.designBalanced },
|
|
85
|
+
{ value: 'dense', label: lr.prefs.designDense },
|
|
86
|
+
],
|
|
87
|
+
},
|
|
88
|
+
{
|
|
89
|
+
role: 'review',
|
|
90
|
+
label: lr.build.review,
|
|
91
|
+
value: prefs.review,
|
|
92
|
+
apply: (value) => updateAgentPrefs({ review: value as AgentPrefs['review'] }),
|
|
93
|
+
options: [
|
|
94
|
+
{ value: 'strict', label: lr.prefs.reviewStrict },
|
|
95
|
+
{ value: 'numbers', label: lr.prefs.reviewNumbers },
|
|
96
|
+
],
|
|
97
|
+
},
|
|
98
|
+
];
|
|
99
|
+
|
|
34
100
|
return (
|
|
35
101
|
<div data-lr-settings className="max-w-[760px]">
|
|
36
102
|
<header className="mb-6">
|
|
@@ -98,6 +164,154 @@ export function SettingsPage() {
|
|
|
98
164
|
/>
|
|
99
165
|
</div>
|
|
100
166
|
</section>
|
|
167
|
+
|
|
168
|
+
{import.meta.env.DEV && <AgentProvidersSection />}
|
|
169
|
+
|
|
170
|
+
{import.meta.env.DEV && (
|
|
171
|
+
<section
|
|
172
|
+
data-lr-agent-prefs
|
|
173
|
+
className="mt-5 rounded-[16px] border border-border bg-card px-6 py-5 shadow-[var(--lr-shadow-1)]"
|
|
174
|
+
>
|
|
175
|
+
<h2 className="text-[16px] font-semibold">{lr.prefs.title}</h2>
|
|
176
|
+
<p className="mt-1 mb-2 text-[14px] text-muted-foreground">{lr.prefs.hint}</p>
|
|
177
|
+
|
|
178
|
+
<PrefsSwitch
|
|
179
|
+
label={lr.prefs.confirmEachPage}
|
|
180
|
+
hint={lr.prefs.confirmEachPageHint}
|
|
181
|
+
checked={prefs.confirmEachPage}
|
|
182
|
+
onChange={(value) => updateAgentPrefs({ confirmEachPage: value })}
|
|
183
|
+
/>
|
|
184
|
+
<PrefsSwitch
|
|
185
|
+
label={lr.prefs.askOnMismatch}
|
|
186
|
+
hint={lr.prefs.askOnMismatchHint}
|
|
187
|
+
checked={prefs.askOnMismatch}
|
|
188
|
+
onChange={(value) => updateAgentPrefs({ askOnMismatch: value })}
|
|
189
|
+
/>
|
|
190
|
+
<PrefsSwitch
|
|
191
|
+
label={lr.prefs.autoImages}
|
|
192
|
+
hint={lr.prefs.autoImagesHint}
|
|
193
|
+
checked={prefs.autoImages}
|
|
194
|
+
onChange={(value) => updateAgentPrefs({ autoImages: value })}
|
|
195
|
+
/>
|
|
196
|
+
|
|
197
|
+
<div className="mt-4 border-t border-border pt-4">
|
|
198
|
+
<p className="text-[14px] font-semibold">{lr.prefs.tone}</p>
|
|
199
|
+
<div className="mt-2 flex flex-wrap gap-1.5">
|
|
200
|
+
<PrefPill
|
|
201
|
+
pressed={prefs.tone === 'steady'}
|
|
202
|
+
onClick={() => updateAgentPrefs({ tone: 'steady' })}
|
|
203
|
+
>
|
|
204
|
+
{lr.prefs.toneSteady}
|
|
205
|
+
</PrefPill>
|
|
206
|
+
<PrefPill
|
|
207
|
+
pressed={prefs.tone === 'friendly'}
|
|
208
|
+
onClick={() => updateAgentPrefs({ tone: 'friendly' })}
|
|
209
|
+
>
|
|
210
|
+
{lr.prefs.toneFriendly}
|
|
211
|
+
</PrefPill>
|
|
212
|
+
<PrefPill
|
|
213
|
+
pressed={prefs.tone === 'concise'}
|
|
214
|
+
onClick={() => updateAgentPrefs({ tone: 'concise' })}
|
|
215
|
+
>
|
|
216
|
+
{lr.prefs.toneConcise}
|
|
217
|
+
</PrefPill>
|
|
218
|
+
</div>
|
|
219
|
+
</div>
|
|
220
|
+
|
|
221
|
+
<div className="mt-4 grid grid-cols-2 gap-2.5 border-t border-border pt-4 sm:grid-cols-4">
|
|
222
|
+
{helpers.map((helper) => (
|
|
223
|
+
<div
|
|
224
|
+
key={helper.role}
|
|
225
|
+
data-lr-pref-helper={helper.role}
|
|
226
|
+
className="flex flex-col items-center gap-1.5 rounded-[12px] border border-border bg-muted/30 px-2 py-3 text-center"
|
|
227
|
+
>
|
|
228
|
+
<HelperMascot role={helper.role} state="idle" size={32} />
|
|
229
|
+
<span className="text-[12px] font-semibold">{helper.label}</span>
|
|
230
|
+
<div className="flex flex-wrap justify-center gap-1">
|
|
231
|
+
{helper.options.map((option) => (
|
|
232
|
+
<PrefPill
|
|
233
|
+
key={option.value}
|
|
234
|
+
compact
|
|
235
|
+
pressed={helper.value === option.value}
|
|
236
|
+
onClick={() => helper.apply(option.value)}
|
|
237
|
+
>
|
|
238
|
+
{option.label}
|
|
239
|
+
</PrefPill>
|
|
240
|
+
))}
|
|
241
|
+
</div>
|
|
242
|
+
</div>
|
|
243
|
+
))}
|
|
244
|
+
</div>
|
|
245
|
+
|
|
246
|
+
<div className="mt-4 border-t border-border pt-3">
|
|
247
|
+
<button
|
|
248
|
+
type="button"
|
|
249
|
+
onClick={replayOnboarding}
|
|
250
|
+
className="rounded text-[13px] text-muted-foreground underline-offset-2 outline-none hover:text-foreground hover:underline focus-visible:ring-2 focus-visible:ring-ring/40"
|
|
251
|
+
>
|
|
252
|
+
{lr.prefs.replayOnboarding}
|
|
253
|
+
</button>
|
|
254
|
+
</div>
|
|
255
|
+
</section>
|
|
256
|
+
)}
|
|
257
|
+
</div>
|
|
258
|
+
);
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
function PrefsSwitch({
|
|
262
|
+
label,
|
|
263
|
+
hint,
|
|
264
|
+
checked,
|
|
265
|
+
onChange,
|
|
266
|
+
}: {
|
|
267
|
+
label: string;
|
|
268
|
+
hint: string;
|
|
269
|
+
checked: boolean;
|
|
270
|
+
onChange: (value: boolean) => void;
|
|
271
|
+
}) {
|
|
272
|
+
return (
|
|
273
|
+
<div className="mt-3 flex items-center gap-4 border-t border-border pt-3">
|
|
274
|
+
<div className="min-w-0 flex-1">
|
|
275
|
+
<p className="text-[14px] font-semibold">{label}</p>
|
|
276
|
+
<p className="text-[12px] text-muted-foreground">{hint}</p>
|
|
277
|
+
</div>
|
|
278
|
+
<button
|
|
279
|
+
type="button"
|
|
280
|
+
role="switch"
|
|
281
|
+
aria-checked={checked}
|
|
282
|
+
aria-label={label}
|
|
283
|
+
onClick={() => onChange(!checked)}
|
|
284
|
+
className="lr-switch outline-none focus-visible:ring-2 focus-visible:ring-ring/40"
|
|
285
|
+
/>
|
|
101
286
|
</div>
|
|
102
287
|
);
|
|
103
288
|
}
|
|
289
|
+
|
|
290
|
+
function PrefPill({
|
|
291
|
+
pressed,
|
|
292
|
+
compact = false,
|
|
293
|
+
onClick,
|
|
294
|
+
children,
|
|
295
|
+
}: {
|
|
296
|
+
pressed: boolean;
|
|
297
|
+
compact?: boolean;
|
|
298
|
+
onClick: () => void;
|
|
299
|
+
children: ReactNode;
|
|
300
|
+
}) {
|
|
301
|
+
return (
|
|
302
|
+
<button
|
|
303
|
+
type="button"
|
|
304
|
+
aria-pressed={pressed}
|
|
305
|
+
onClick={onClick}
|
|
306
|
+
className={cn(
|
|
307
|
+
'min-h-8 rounded-full border px-3 py-1 text-center text-[12.5px] leading-snug font-medium outline-none transition-colors focus-visible:ring-2 focus-visible:ring-ring/40',
|
|
308
|
+
compact ? 'px-2.5 text-[11.5px]' : '',
|
|
309
|
+
pressed
|
|
310
|
+
? 'border-[var(--lr-accent)] bg-[var(--lr-accent-soft)] text-foreground'
|
|
311
|
+
: 'border-border bg-card text-muted-foreground hover:border-[var(--lr-text-3)]',
|
|
312
|
+
)}
|
|
313
|
+
>
|
|
314
|
+
{children}
|
|
315
|
+
</button>
|
|
316
|
+
);
|
|
317
|
+
}
|
|
@@ -3,11 +3,12 @@ import { useEffect } from 'react';
|
|
|
3
3
|
import { createPortal } from 'react-dom';
|
|
4
4
|
import { useNavigate } from 'react-router-dom';
|
|
5
5
|
import { Tooltip, TooltipContent, TooltipTrigger } from '@/components/ui/tooltip';
|
|
6
|
-
import { hasModifier,
|
|
6
|
+
import { hasModifier, isTypingTarget } from '@/lib/keys';
|
|
7
7
|
import { cn } from '@/lib/utils';
|
|
8
8
|
import { useSlot } from './chrome/use-slot';
|
|
9
9
|
import { isFeatureEnabled } from './features';
|
|
10
10
|
import { useNewDeckBrief } from './home/brief';
|
|
11
|
+
import { PendingPages } from './outline/pending-pages';
|
|
11
12
|
import { useLrText } from './text';
|
|
12
13
|
|
|
13
14
|
type Props = {
|
|
@@ -15,6 +16,18 @@ type Props = {
|
|
|
15
16
|
overviewOpen: boolean;
|
|
16
17
|
};
|
|
17
18
|
|
|
19
|
+
/**
|
|
20
|
+
* A key pressed with focus inside a menu or dialog belongs to that overlay. A
|
|
21
|
+
* focused button does not: the shortcut has to reach the page from any view,
|
|
22
|
+
* including the asset grid, whose own controls sit under the pointer.
|
|
23
|
+
*/
|
|
24
|
+
function isInsideOverlay(target: EventTarget | null): boolean {
|
|
25
|
+
return (
|
|
26
|
+
target instanceof Element &&
|
|
27
|
+
!!target.closest('[role="dialog"], [role="menu"], [role="listbox"]')
|
|
28
|
+
);
|
|
29
|
+
}
|
|
30
|
+
|
|
18
31
|
export function SlideExtensions({ slideId, overviewOpen }: Props) {
|
|
19
32
|
const enabled = isFeatureEnabled('board');
|
|
20
33
|
const navigate = useNavigate();
|
|
@@ -27,7 +40,7 @@ export function SlideExtensions({ slideId, overviewOpen }: Props) {
|
|
|
27
40
|
const onKey = (e: KeyboardEvent) => {
|
|
28
41
|
if (
|
|
29
42
|
isTypingTarget(e.target) ||
|
|
30
|
-
|
|
43
|
+
isInsideOverlay(e.target) ||
|
|
31
44
|
e.isComposing ||
|
|
32
45
|
e.keyCode === 229 ||
|
|
33
46
|
e.defaultPrevented
|
|
@@ -44,30 +57,36 @@ export function SlideExtensions({ slideId, overviewOpen }: Props) {
|
|
|
44
57
|
return () => window.removeEventListener('keydown', onKey);
|
|
45
58
|
}, [enabled, navigate, overviewOpen, slideId]);
|
|
46
59
|
|
|
47
|
-
if (!enabled
|
|
60
|
+
if (!enabled) return null;
|
|
48
61
|
|
|
49
|
-
return
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
<
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
62
|
+
return (
|
|
63
|
+
<>
|
|
64
|
+
{slot &&
|
|
65
|
+
createPortal(
|
|
66
|
+
<Tooltip>
|
|
67
|
+
<TooltipTrigger
|
|
68
|
+
render={
|
|
69
|
+
<button
|
|
70
|
+
type="button"
|
|
71
|
+
onClick={() => navigate(`/s/${encodeURIComponent(slideId)}/board`)}
|
|
72
|
+
aria-label={lr.board.openBoard}
|
|
73
|
+
className={cn(
|
|
74
|
+
'flex size-5 items-center justify-center rounded-[3px] text-muted-foreground/70 outline-none',
|
|
75
|
+
'motion-safe:transition-colors hover:bg-muted hover:text-foreground',
|
|
76
|
+
'focus-visible:ring-1 focus-visible:ring-brand',
|
|
77
|
+
)}
|
|
78
|
+
>
|
|
79
|
+
<Workflow className="size-3.5" strokeWidth={1.75} />
|
|
80
|
+
</button>
|
|
81
|
+
}
|
|
82
|
+
/>
|
|
83
|
+
<TooltipContent side="bottom" sideOffset={6}>
|
|
84
|
+
{lr.board.openBoard}
|
|
85
|
+
</TooltipContent>
|
|
86
|
+
</Tooltip>,
|
|
87
|
+
slot,
|
|
88
|
+
)}
|
|
89
|
+
<PendingPages slideId={slideId} />
|
|
90
|
+
</>
|
|
72
91
|
);
|
|
73
92
|
}
|