@lemonriver/core 0.3.0 → 0.4.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/dist/{build-Bqo69DWP.js → build-Nl7EeJ6x.js} +1 -1
- package/dist/cli/bin.js +3 -3
- package/dist/{config-teo3kWz7.d.ts → config-CYNOR93W.d.ts} +1 -1
- package/dist/{config-DJ5rkMMg.js → config-CpC0nM3r.js} +697 -2
- package/dist/{dev-B2FJD5bJ.js → dev-BB3THd5I.js} +1 -1
- 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-BGjgTg7H.js} +1 -1
- package/dist/{types-DFK02XVv.d.ts → types-tdaXSyah.d.ts} +1 -0
- 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 +1 -1
- package/src/agent/prompt.ts +2 -0
- package/src/app/components/agent/agent-panel.tsx +2 -0
- 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-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/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 +633 -0
- package/src/app/lemonriver/outline/model.ts +443 -0
- package/src/app/lemonriver/outline/outline-page.tsx +504 -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 +211 -0
- package/src/app/lemonriver/slide-extensions.tsx +31 -24
- package/src/app/lemonriver/text/en.ts +149 -0
- package/src/app/lemonriver/text/es.ts +148 -0
- package/src/app/lemonriver/text/ja.ts +150 -0
- package/src/app/lemonriver/text/text.test.ts +33 -0
- package/src/app/lemonriver/text/types.ts +169 -0
- package/src/app/lemonriver/text/zh-cn.ts +146 -0
- package/src/app/lemonriver/text/zh-tw.ts +146 -0
- package/src/app/lemonriver/theme/app.css +12 -1
- package/src/app/lemonriver/theme/pages.test.ts +4 -0
- package/src/app/lemonriver/theme/pages.ts +11 -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/routes/home.tsx +13 -5
- package/src/app/routes/slide.tsx +70 -13
- 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
|
@@ -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,12 @@
|
|
|
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 { HelperMascot, type HelperRole } from '../brand/mascot';
|
|
9
|
+
import { ONBOARDED_KEY } from '../onboarding/onboarding';
|
|
4
10
|
import { useLrText } from '../text';
|
|
5
11
|
import { setReduceMotionSetting, useReduceMotionSetting } from '../theme/motion';
|
|
6
12
|
import { LR_THEME_CHOICES, type LrThemeChoice } from '../theme/themes';
|
|
@@ -16,6 +22,8 @@ const SWATCH: Record<LrThemeChoice, { bg: string; fg: string }> = {
|
|
|
16
22
|
export function SettingsPage() {
|
|
17
23
|
const t = useLocale();
|
|
18
24
|
const lr = useLrText();
|
|
25
|
+
const navigate = useNavigate();
|
|
26
|
+
const prefs = useAgentPrefs();
|
|
19
27
|
const { theme, setTheme } = useTheme();
|
|
20
28
|
const reduceMotion = useReduceMotionSetting();
|
|
21
29
|
const [mounted, setMounted] = useState(false);
|
|
@@ -31,6 +39,63 @@ export function SettingsPage() {
|
|
|
31
39
|
lime: lr.theme.lime,
|
|
32
40
|
};
|
|
33
41
|
|
|
42
|
+
function replayOnboarding() {
|
|
43
|
+
try {
|
|
44
|
+
localStorage.removeItem(ONBOARDED_KEY);
|
|
45
|
+
} catch {}
|
|
46
|
+
navigate('/new');
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
const helpers: {
|
|
50
|
+
role: HelperRole;
|
|
51
|
+
label: string;
|
|
52
|
+
value: string;
|
|
53
|
+
apply: (value: string) => void;
|
|
54
|
+
options: { value: string; label: string }[];
|
|
55
|
+
}[] = [
|
|
56
|
+
{
|
|
57
|
+
role: 'research',
|
|
58
|
+
label: lr.build.research,
|
|
59
|
+
value: prefs.research,
|
|
60
|
+
apply: (value) => updateAgentPrefs({ research: value as AgentPrefs['research'] }),
|
|
61
|
+
options: [
|
|
62
|
+
{ value: 'uploads', label: lr.prefs.researchUploads },
|
|
63
|
+
{ value: 'web', label: lr.prefs.researchWeb },
|
|
64
|
+
],
|
|
65
|
+
},
|
|
66
|
+
{
|
|
67
|
+
role: 'outline',
|
|
68
|
+
label: lr.build.outline,
|
|
69
|
+
value: prefs.outline,
|
|
70
|
+
apply: (value) => updateAgentPrefs({ outline: value as AgentPrefs['outline'] }),
|
|
71
|
+
options: [
|
|
72
|
+
{ value: 'review', label: lr.prefs.outlineReview },
|
|
73
|
+
{ value: 'direct', label: lr.prefs.outlineDirect },
|
|
74
|
+
],
|
|
75
|
+
},
|
|
76
|
+
{
|
|
77
|
+
role: 'design',
|
|
78
|
+
label: lr.build.design,
|
|
79
|
+
value: prefs.design,
|
|
80
|
+
apply: (value) => updateAgentPrefs({ design: value as AgentPrefs['design'] }),
|
|
81
|
+
options: [
|
|
82
|
+
{ value: 'visual', label: lr.prefs.designVisual },
|
|
83
|
+
{ value: 'balanced', label: lr.prefs.designBalanced },
|
|
84
|
+
{ value: 'dense', label: lr.prefs.designDense },
|
|
85
|
+
],
|
|
86
|
+
},
|
|
87
|
+
{
|
|
88
|
+
role: 'review',
|
|
89
|
+
label: lr.build.review,
|
|
90
|
+
value: prefs.review,
|
|
91
|
+
apply: (value) => updateAgentPrefs({ review: value as AgentPrefs['review'] }),
|
|
92
|
+
options: [
|
|
93
|
+
{ value: 'strict', label: lr.prefs.reviewStrict },
|
|
94
|
+
{ value: 'numbers', label: lr.prefs.reviewNumbers },
|
|
95
|
+
],
|
|
96
|
+
},
|
|
97
|
+
];
|
|
98
|
+
|
|
34
99
|
return (
|
|
35
100
|
<div data-lr-settings className="max-w-[760px]">
|
|
36
101
|
<header className="mb-6">
|
|
@@ -98,6 +163,152 @@ export function SettingsPage() {
|
|
|
98
163
|
/>
|
|
99
164
|
</div>
|
|
100
165
|
</section>
|
|
166
|
+
|
|
167
|
+
{import.meta.env.DEV && (
|
|
168
|
+
<section
|
|
169
|
+
data-lr-agent-prefs
|
|
170
|
+
className="mt-5 rounded-[16px] border border-border bg-card px-6 py-5 shadow-[var(--lr-shadow-1)]"
|
|
171
|
+
>
|
|
172
|
+
<h2 className="text-[16px] font-semibold">{lr.prefs.title}</h2>
|
|
173
|
+
<p className="mt-1 mb-2 text-[14px] text-muted-foreground">{lr.prefs.hint}</p>
|
|
174
|
+
|
|
175
|
+
<PrefsSwitch
|
|
176
|
+
label={lr.prefs.confirmEachPage}
|
|
177
|
+
hint={lr.prefs.confirmEachPageHint}
|
|
178
|
+
checked={prefs.confirmEachPage}
|
|
179
|
+
onChange={(value) => updateAgentPrefs({ confirmEachPage: value })}
|
|
180
|
+
/>
|
|
181
|
+
<PrefsSwitch
|
|
182
|
+
label={lr.prefs.askOnMismatch}
|
|
183
|
+
hint={lr.prefs.askOnMismatchHint}
|
|
184
|
+
checked={prefs.askOnMismatch}
|
|
185
|
+
onChange={(value) => updateAgentPrefs({ askOnMismatch: value })}
|
|
186
|
+
/>
|
|
187
|
+
<PrefsSwitch
|
|
188
|
+
label={lr.prefs.autoImages}
|
|
189
|
+
hint={lr.prefs.autoImagesHint}
|
|
190
|
+
checked={prefs.autoImages}
|
|
191
|
+
onChange={(value) => updateAgentPrefs({ autoImages: value })}
|
|
192
|
+
/>
|
|
193
|
+
|
|
194
|
+
<div className="mt-4 border-t border-border pt-4">
|
|
195
|
+
<p className="text-[14px] font-semibold">{lr.prefs.tone}</p>
|
|
196
|
+
<div className="mt-2 flex flex-wrap gap-1.5">
|
|
197
|
+
<PrefPill
|
|
198
|
+
pressed={prefs.tone === 'steady'}
|
|
199
|
+
onClick={() => updateAgentPrefs({ tone: 'steady' })}
|
|
200
|
+
>
|
|
201
|
+
{lr.prefs.toneSteady}
|
|
202
|
+
</PrefPill>
|
|
203
|
+
<PrefPill
|
|
204
|
+
pressed={prefs.tone === 'friendly'}
|
|
205
|
+
onClick={() => updateAgentPrefs({ tone: 'friendly' })}
|
|
206
|
+
>
|
|
207
|
+
{lr.prefs.toneFriendly}
|
|
208
|
+
</PrefPill>
|
|
209
|
+
<PrefPill
|
|
210
|
+
pressed={prefs.tone === 'concise'}
|
|
211
|
+
onClick={() => updateAgentPrefs({ tone: 'concise' })}
|
|
212
|
+
>
|
|
213
|
+
{lr.prefs.toneConcise}
|
|
214
|
+
</PrefPill>
|
|
215
|
+
</div>
|
|
216
|
+
</div>
|
|
217
|
+
|
|
218
|
+
<div className="mt-4 grid grid-cols-2 gap-2.5 border-t border-border pt-4 sm:grid-cols-4">
|
|
219
|
+
{helpers.map((helper) => (
|
|
220
|
+
<div
|
|
221
|
+
key={helper.role}
|
|
222
|
+
data-lr-pref-helper={helper.role}
|
|
223
|
+
className="flex flex-col items-center gap-1.5 rounded-[12px] border border-border bg-muted/30 px-2 py-3 text-center"
|
|
224
|
+
>
|
|
225
|
+
<HelperMascot role={helper.role} state="idle" size={32} />
|
|
226
|
+
<span className="text-[12px] font-semibold">{helper.label}</span>
|
|
227
|
+
<div className="flex flex-wrap justify-center gap-1">
|
|
228
|
+
{helper.options.map((option) => (
|
|
229
|
+
<PrefPill
|
|
230
|
+
key={option.value}
|
|
231
|
+
compact
|
|
232
|
+
pressed={helper.value === option.value}
|
|
233
|
+
onClick={() => helper.apply(option.value)}
|
|
234
|
+
>
|
|
235
|
+
{option.label}
|
|
236
|
+
</PrefPill>
|
|
237
|
+
))}
|
|
238
|
+
</div>
|
|
239
|
+
</div>
|
|
240
|
+
))}
|
|
241
|
+
</div>
|
|
242
|
+
|
|
243
|
+
<div className="mt-4 border-t border-border pt-3">
|
|
244
|
+
<button
|
|
245
|
+
type="button"
|
|
246
|
+
onClick={replayOnboarding}
|
|
247
|
+
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"
|
|
248
|
+
>
|
|
249
|
+
{lr.prefs.replayOnboarding}
|
|
250
|
+
</button>
|
|
251
|
+
</div>
|
|
252
|
+
</section>
|
|
253
|
+
)}
|
|
101
254
|
</div>
|
|
102
255
|
);
|
|
103
256
|
}
|
|
257
|
+
|
|
258
|
+
function PrefsSwitch({
|
|
259
|
+
label,
|
|
260
|
+
hint,
|
|
261
|
+
checked,
|
|
262
|
+
onChange,
|
|
263
|
+
}: {
|
|
264
|
+
label: string;
|
|
265
|
+
hint: string;
|
|
266
|
+
checked: boolean;
|
|
267
|
+
onChange: (value: boolean) => void;
|
|
268
|
+
}) {
|
|
269
|
+
return (
|
|
270
|
+
<div className="mt-3 flex items-center gap-4 border-t border-border pt-3">
|
|
271
|
+
<div className="min-w-0 flex-1">
|
|
272
|
+
<p className="text-[14px] font-semibold">{label}</p>
|
|
273
|
+
<p className="text-[12px] text-muted-foreground">{hint}</p>
|
|
274
|
+
</div>
|
|
275
|
+
<button
|
|
276
|
+
type="button"
|
|
277
|
+
role="switch"
|
|
278
|
+
aria-checked={checked}
|
|
279
|
+
aria-label={label}
|
|
280
|
+
onClick={() => onChange(!checked)}
|
|
281
|
+
className="lr-switch outline-none focus-visible:ring-2 focus-visible:ring-ring/40"
|
|
282
|
+
/>
|
|
283
|
+
</div>
|
|
284
|
+
);
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
function PrefPill({
|
|
288
|
+
pressed,
|
|
289
|
+
compact = false,
|
|
290
|
+
onClick,
|
|
291
|
+
children,
|
|
292
|
+
}: {
|
|
293
|
+
pressed: boolean;
|
|
294
|
+
compact?: boolean;
|
|
295
|
+
onClick: () => void;
|
|
296
|
+
children: ReactNode;
|
|
297
|
+
}) {
|
|
298
|
+
return (
|
|
299
|
+
<button
|
|
300
|
+
type="button"
|
|
301
|
+
aria-pressed={pressed}
|
|
302
|
+
onClick={onClick}
|
|
303
|
+
className={cn(
|
|
304
|
+
'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',
|
|
305
|
+
compact ? 'px-2.5 text-[11.5px]' : '',
|
|
306
|
+
pressed
|
|
307
|
+
? 'border-[var(--lr-accent)] bg-[var(--lr-accent-soft)] text-foreground'
|
|
308
|
+
: 'border-border bg-card text-muted-foreground hover:border-[var(--lr-text-3)]',
|
|
309
|
+
)}
|
|
310
|
+
>
|
|
311
|
+
{children}
|
|
312
|
+
</button>
|
|
313
|
+
);
|
|
314
|
+
}
|
|
@@ -8,6 +8,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 = {
|
|
@@ -44,30 +45,36 @@ export function SlideExtensions({ slideId, overviewOpen }: Props) {
|
|
|
44
45
|
return () => window.removeEventListener('keydown', onKey);
|
|
45
46
|
}, [enabled, navigate, overviewOpen, slideId]);
|
|
46
47
|
|
|
47
|
-
if (!enabled
|
|
48
|
+
if (!enabled) return null;
|
|
48
49
|
|
|
49
|
-
return
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
<
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
50
|
+
return (
|
|
51
|
+
<>
|
|
52
|
+
{slot &&
|
|
53
|
+
createPortal(
|
|
54
|
+
<Tooltip>
|
|
55
|
+
<TooltipTrigger
|
|
56
|
+
render={
|
|
57
|
+
<button
|
|
58
|
+
type="button"
|
|
59
|
+
onClick={() => navigate(`/s/${encodeURIComponent(slideId)}/board`)}
|
|
60
|
+
aria-label={lr.board.openBoard}
|
|
61
|
+
className={cn(
|
|
62
|
+
'flex size-5 items-center justify-center rounded-[3px] text-muted-foreground/70 outline-none',
|
|
63
|
+
'motion-safe:transition-colors hover:bg-muted hover:text-foreground',
|
|
64
|
+
'focus-visible:ring-1 focus-visible:ring-brand',
|
|
65
|
+
)}
|
|
66
|
+
>
|
|
67
|
+
<Workflow className="size-3.5" strokeWidth={1.75} />
|
|
68
|
+
</button>
|
|
69
|
+
}
|
|
70
|
+
/>
|
|
71
|
+
<TooltipContent side="bottom" sideOffset={6}>
|
|
72
|
+
{lr.board.openBoard}
|
|
73
|
+
</TooltipContent>
|
|
74
|
+
</Tooltip>,
|
|
75
|
+
slot,
|
|
76
|
+
)}
|
|
77
|
+
<PendingPages slideId={slideId} />
|
|
78
|
+
</>
|
|
72
79
|
);
|
|
73
80
|
}
|