@lemonriver/core 0.5.0 → 0.7.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-CS1goZxt.js → build-CKwrex8y.js} +1 -1
- package/dist/cli/bin.js +3 -3
- package/dist/{config-BpbcCbUv.js → config-B1_gk0sy.js} +2983 -266
- package/dist/{dev-BpYnfgLL.js → dev-DZ2Yzl2p.js} +1 -1
- package/dist/{preview-HSzPPkSs.js → preview-hMDcuHfP.js} +1 -1
- package/dist/vite/index.js +1 -1
- package/package.json +1 -1
- package/src/app/lemonriver/board/blocks/classify.test.ts +5 -0
- package/src/app/lemonriver/board/blocks/classify.ts +29 -2
- package/src/app/lemonriver/board/blocks/snapshot.ts +34 -4
- package/src/app/lemonriver/board/board-page.tsx +15 -0
- package/src/app/lemonriver/board/model/agent-tasks.ts +33 -1
- package/src/app/lemonriver/board/model/self-check.test.ts +329 -0
- package/src/app/lemonriver/board/model/self-check.ts +489 -0
- package/src/app/lemonriver/board/page-node.tsx +23 -1
- package/src/app/lemonriver/board/self-check-jump.ts +23 -0
- package/src/app/lemonriver/board/self-check-panel.tsx +272 -0
- package/src/app/lemonriver/board/self-check-runner.tsx +150 -0
- package/src/app/lemonriver/board/use-self-check.ts +117 -0
- package/src/app/lemonriver/chrome/app-chrome.tsx +12 -1
- package/src/app/lemonriver/chrome/filter-pill.tsx +30 -0
- package/src/app/lemonriver/chrome/sidebar-extras.tsx +12 -1
- package/src/app/lemonriver/features.test.ts +10 -0
- package/src/app/lemonriver/features.ts +3 -1
- package/src/app/lemonriver/feedback/pending-toast.ts +7 -2
- package/src/app/lemonriver/home/deck-card.tsx +20 -1
- package/src/app/lemonriver/home/home-page.tsx +107 -7
- package/src/app/lemonriver/home/use-deck-times.ts +4 -1
- package/src/app/lemonriver/outline/build-team.tsx +42 -0
- package/src/app/lemonriver/outline/describe-page.tsx +128 -27
- package/src/app/lemonriver/outline/draft.ts +38 -0
- package/src/app/lemonriver/outline/model.test.ts +79 -0
- package/src/app/lemonriver/outline/model.ts +80 -7
- package/src/app/lemonriver/outline/outline-page.tsx +56 -6
- package/src/app/lemonriver/outline/pick-style.tsx +282 -0
- package/src/app/lemonriver/routes.test.tsx +17 -5
- package/src/app/lemonriver/routes.tsx +28 -0
- package/src/app/lemonriver/share/capture.ts +76 -0
- package/src/app/lemonriver/share/client.ts +162 -0
- package/src/app/lemonriver/share/codes.test.ts +49 -0
- package/src/app/lemonriver/share/codes.ts +30 -0
- package/src/app/lemonriver/share/compare.test.ts +199 -0
- package/src/app/lemonriver/share/compare.ts +367 -0
- package/src/app/lemonriver/share/drop.ts +84 -0
- package/src/app/lemonriver/share/folder.test.ts +42 -0
- package/src/app/lemonriver/share/folder.ts +29 -0
- package/src/app/lemonriver/share/freeze.ts +51 -0
- package/src/app/lemonriver/share/guide.test.ts +78 -0
- package/src/app/lemonriver/share/guide.ts +222 -0
- package/src/app/lemonriver/share/import-dialog.tsx +391 -0
- package/src/app/lemonriver/share/import-entry.tsx +106 -0
- package/src/app/lemonriver/share/model.ts +150 -0
- package/src/app/lemonriver/share/naming.test.ts +59 -0
- package/src/app/lemonriver/share/naming.ts +71 -0
- package/src/app/lemonriver/share/paths.test.ts +75 -0
- package/src/app/lemonriver/share/paths.ts +181 -0
- package/src/app/lemonriver/share/pdf.test.ts +79 -0
- package/src/app/lemonriver/share/pdf.ts +169 -0
- package/src/app/lemonriver/share/share-dialog.tsx +286 -0
- package/src/app/lemonriver/share/summary.ts +47 -0
- package/src/app/lemonriver/slide-extensions.tsx +69 -23
- package/src/app/lemonriver/templates/client.ts +60 -0
- package/src/app/lemonriver/templates/demo-page.tsx +79 -0
- package/src/app/lemonriver/templates/knobs.test.ts +62 -0
- package/src/app/lemonriver/templates/knobs.ts +62 -0
- package/src/app/lemonriver/templates/library-page.tsx +295 -0
- package/src/app/lemonriver/templates/model.test.ts +175 -0
- package/src/app/lemonriver/templates/model.ts +339 -0
- package/src/app/lemonriver/templates/preview-content.test.ts +117 -0
- package/src/app/lemonriver/templates/preview-content.ts +149 -0
- package/src/app/lemonriver/templates/recommend.test.ts +71 -0
- package/src/app/lemonriver/templates/recommend.ts +72 -0
- package/src/app/lemonriver/templates/use-library.ts +58 -0
- package/src/app/lemonriver/templates/virtual.d.ts +28 -0
- package/src/app/lemonriver/text/en.ts +124 -0
- package/src/app/lemonriver/text/es.ts +124 -0
- package/src/app/lemonriver/text/ja.ts +124 -0
- package/src/app/lemonriver/text/types.ts +151 -0
- package/src/app/lemonriver/text/zh-cn.ts +119 -0
- package/src/app/lemonriver/text/zh-tw.ts +119 -0
- package/src/app/lemonriver/theme/pages.test.ts +4 -0
- package/src/app/lemonriver/theme/pages.ts +6 -1
- package/src/app/lemonriver/update/prompt.ts +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Copy, FolderInput, MoreHorizontal, Palette, Pencil, Trash2 } from 'lucide-react';
|
|
1
|
+
import { Copy, FolderInput, MoreHorizontal, Palette, Pencil, Share2, Trash2 } from 'lucide-react';
|
|
2
2
|
import { useEffect, useState } from 'react';
|
|
3
3
|
import { Link } from 'react-router-dom';
|
|
4
4
|
import {
|
|
@@ -16,11 +16,13 @@ import { SlidePageProvider } from '../../lib/page-context';
|
|
|
16
16
|
import type { SlideModule } from '../../lib/sdk';
|
|
17
17
|
import { loadSlide } from '../../lib/slides';
|
|
18
18
|
import { Mascot } from '../brand/mascot';
|
|
19
|
+
import { isFeatureEnabled } from '../features';
|
|
19
20
|
import { useLrText } from '../text';
|
|
20
21
|
import { relativeTime } from './time';
|
|
21
22
|
import { useDelayed } from './use-delayed';
|
|
22
23
|
|
|
23
24
|
export type DeckCardActions = {
|
|
25
|
+
onShare: () => void;
|
|
24
26
|
onRename: () => void;
|
|
25
27
|
onDuplicate: () => void;
|
|
26
28
|
onMove: () => void;
|
|
@@ -32,6 +34,7 @@ export function DeckCard({
|
|
|
32
34
|
modifiedAt,
|
|
33
35
|
editing,
|
|
34
36
|
now,
|
|
37
|
+
templateName,
|
|
35
38
|
onTitleResolved,
|
|
36
39
|
actions,
|
|
37
40
|
}: {
|
|
@@ -39,6 +42,7 @@ export function DeckCard({
|
|
|
39
42
|
modifiedAt: number | undefined;
|
|
40
43
|
editing: boolean;
|
|
41
44
|
now: number;
|
|
45
|
+
templateName?: string | null;
|
|
42
46
|
onTitleResolved: (id: string, title: string) => void;
|
|
43
47
|
actions: DeckCardActions;
|
|
44
48
|
}) {
|
|
@@ -135,6 +139,14 @@ export function DeckCard({
|
|
|
135
139
|
<span className="max-w-[110px] truncate">{slide.meta.theme}</span>
|
|
136
140
|
</Link>
|
|
137
141
|
)}
|
|
142
|
+
{templateName && (
|
|
143
|
+
<span
|
|
144
|
+
data-lr-deck-template={templateName}
|
|
145
|
+
className="ml-auto inline-flex shrink-0 items-center rounded-full border border-border bg-muted/50 px-2 py-0.5 text-[11px] text-muted-foreground"
|
|
146
|
+
>
|
|
147
|
+
{templateName}
|
|
148
|
+
</span>
|
|
149
|
+
)}
|
|
138
150
|
</p>
|
|
139
151
|
</div>
|
|
140
152
|
{import.meta.env.DEV && <DeckMenu actions={actions} />}
|
|
@@ -146,6 +158,7 @@ export function DeckCard({
|
|
|
146
158
|
function DeckMenu({ actions }: { actions: DeckCardActions }) {
|
|
147
159
|
const t = useLocale();
|
|
148
160
|
const lr = useLrText();
|
|
161
|
+
const shareOn = isFeatureEnabled('share');
|
|
149
162
|
return (
|
|
150
163
|
<DropdownMenu>
|
|
151
164
|
<DropdownMenuTrigger
|
|
@@ -160,6 +173,12 @@ function DeckMenu({ actions }: { actions: DeckCardActions }) {
|
|
|
160
173
|
}
|
|
161
174
|
/>
|
|
162
175
|
<DropdownMenuContent align="end" className="min-w-[168px]">
|
|
176
|
+
{shareOn && (
|
|
177
|
+
<DropdownMenuItem onClick={actions.onShare}>
|
|
178
|
+
<Share2 />
|
|
179
|
+
{lr.share.menuItem}
|
|
180
|
+
</DropdownMenuItem>
|
|
181
|
+
)}
|
|
163
182
|
<DropdownMenuItem onClick={actions.onRename}>
|
|
164
183
|
<Pencil />
|
|
165
184
|
{t.common.rename}
|
|
@@ -16,8 +16,16 @@ import { FolderIconChip, SystemViewIcon } from '../../components/sidebar/folder-
|
|
|
16
16
|
import { ALL_SLIDES_ID, DRAFT_ID } from '../../components/sidebar/sidebar';
|
|
17
17
|
import { slideCreatedAt, slideIds } from '../../lib/slides';
|
|
18
18
|
import type { HomeOutletContext } from '../../routes/home-shell';
|
|
19
|
+
import { FilterPill } from '../chrome/filter-pill';
|
|
19
20
|
import { isFeatureEnabled } from '../features';
|
|
20
21
|
import { LemonEmpty } from '../feedback/lemon-empty';
|
|
22
|
+
import { type InspectOk, inspectPackage } from '../share/client';
|
|
23
|
+
import { shareErrorText } from '../share/codes';
|
|
24
|
+
import { ImportDialog } from '../share/import-dialog';
|
|
25
|
+
import { ImportButton, useShareDrop } from '../share/import-entry';
|
|
26
|
+
import { ShareDialog } from '../share/share-dialog';
|
|
27
|
+
import { OCCASIONS } from '../templates/model';
|
|
28
|
+
import { useTemplateLibrary } from '../templates/use-library';
|
|
21
29
|
import { useLrText } from '../text';
|
|
22
30
|
import { moveToTrash } from '../trash/api';
|
|
23
31
|
import { BriefCard } from './brief-card';
|
|
@@ -57,10 +65,15 @@ export function LemonRiverHome() {
|
|
|
57
65
|
const lr = useLrText();
|
|
58
66
|
const now = useNow();
|
|
59
67
|
const times = useDeckTimes();
|
|
68
|
+
const library = useTemplateLibrary();
|
|
60
69
|
const editing = useEditingDecks();
|
|
61
70
|
const [query, setQuery] = useState('');
|
|
71
|
+
const [occasion, setOccasion] = useState<string | null>(null);
|
|
62
72
|
const [sortKey, setSortKey] = useSortPref();
|
|
63
73
|
const [dialog, setDialog] = useState<Dialog>(null);
|
|
74
|
+
const [sharing, setSharing] = useState<{ slideId: string; title: string } | null>(null);
|
|
75
|
+
const [inspection, setInspection] = useState<InspectOk | null>(null);
|
|
76
|
+
const [inspecting, setInspecting] = useState(false);
|
|
64
77
|
|
|
65
78
|
const isAll = selectedId === ALL_SLIDES_ID;
|
|
66
79
|
const isDraft = selectedId === DRAFT_ID;
|
|
@@ -68,13 +81,27 @@ export function LemonRiverHome() {
|
|
|
68
81
|
isAll || isDraft ? null : (manifest.folders.find((f) => f.id === selectedId) ?? null);
|
|
69
82
|
const visible = isAll ? slideIds : isDraft ? draftSlides : (slidesByFolder[selectedId] ?? []);
|
|
70
83
|
const filtered = useMemo(() => filterDecks(visible, query, titleMap), [visible, query, titleMap]);
|
|
84
|
+
const presentOccasions = useMemo(
|
|
85
|
+
() => OCCASIONS.filter((entry) => visible.some((id) => times[id]?.occasion === entry.id)),
|
|
86
|
+
[visible, times],
|
|
87
|
+
);
|
|
88
|
+
const shown = useMemo(
|
|
89
|
+
() => (occasion ? filtered.filter((id) => times[id]?.occasion === occasion) : filtered),
|
|
90
|
+
[filtered, occasion, times],
|
|
91
|
+
);
|
|
71
92
|
const sorted = useMemo(
|
|
72
|
-
() => sortDecks(
|
|
73
|
-
[
|
|
93
|
+
() => sortDecks(shown, sortKey, (id) => titleMap[id] ?? id, slideCreatedAt),
|
|
94
|
+
[shown, sortKey, titleMap],
|
|
74
95
|
);
|
|
75
96
|
const searching = query.trim().length > 0;
|
|
97
|
+
const narrowing = searching || occasion !== null;
|
|
76
98
|
const showLoading = useDelayed(loading);
|
|
77
99
|
const titleOf = (id: string) => titleMap[id] ?? id;
|
|
100
|
+
const templateNameOf = (id: string): string | null => {
|
|
101
|
+
const templateId = times[id]?.template;
|
|
102
|
+
if (!templateId) return null;
|
|
103
|
+
return library?.templates.find((entry) => entry.id === templateId)?.name ?? null;
|
|
104
|
+
};
|
|
78
105
|
|
|
79
106
|
const greeting = {
|
|
80
107
|
morning: lr.home.greetingMorning,
|
|
@@ -99,11 +126,35 @@ export function LemonRiverHome() {
|
|
|
99
126
|
}
|
|
100
127
|
};
|
|
101
128
|
|
|
129
|
+
const inspectBytes = async (bytes: Uint8Array) => {
|
|
130
|
+
if (inspecting) return;
|
|
131
|
+
setInspecting(true);
|
|
132
|
+
try {
|
|
133
|
+
const result = await inspectPackage(bytes);
|
|
134
|
+
if (result.ok) setInspection(result);
|
|
135
|
+
else
|
|
136
|
+
toast.error(
|
|
137
|
+
shareErrorText(lr.share.errors, result.code, result.appVersion, lr.share.unknownVersion),
|
|
138
|
+
);
|
|
139
|
+
} catch {
|
|
140
|
+
toast.error(lr.share.errors.notAPackage);
|
|
141
|
+
} finally {
|
|
142
|
+
setInspecting(false);
|
|
143
|
+
}
|
|
144
|
+
};
|
|
145
|
+
|
|
146
|
+
const { handlers: dropHandlers, hint: dropHint } = useShareDrop({
|
|
147
|
+
onBytes: (bytes) => void inspectBytes(bytes),
|
|
148
|
+
onUnknown: () => toast.error(lr.share.notAPackage),
|
|
149
|
+
});
|
|
150
|
+
|
|
102
151
|
const current = dialog ? dialog.id : null;
|
|
103
152
|
const trashOn = isFeatureEnabled('trash');
|
|
153
|
+
const shareOn = isFeatureEnabled('share');
|
|
104
154
|
|
|
105
155
|
return (
|
|
106
|
-
<div data-lr-home>
|
|
156
|
+
<div data-lr-home {...(shareOn ? dropHandlers : {})}>
|
|
157
|
+
{shareOn && dropHint}
|
|
107
158
|
{import.meta.env.DEV && isAll && (
|
|
108
159
|
<>
|
|
109
160
|
<header className="mb-6">
|
|
@@ -130,28 +181,60 @@ export function LemonRiverHome() {
|
|
|
130
181
|
<FolderSwitcher ctx={ctx} />
|
|
131
182
|
{!loading && (
|
|
132
183
|
<span className="folio ml-0.5">
|
|
133
|
-
{pad2(
|
|
134
|
-
{
|
|
184
|
+
{pad2(narrowing ? shown.length : visible.length)}
|
|
185
|
+
{narrowing && <span className="opacity-40">/{pad2(visible.length)}</span>}
|
|
135
186
|
</span>
|
|
136
187
|
)}
|
|
137
188
|
<div className="ml-auto flex w-full items-center gap-2 md:w-auto">
|
|
189
|
+
{shareOn && (
|
|
190
|
+
<ImportButton onBytes={(bytes) => void inspectBytes(bytes)} disabled={inspecting} />
|
|
191
|
+
)}
|
|
138
192
|
<SortControl value={sortKey} onChange={setSortKey} />
|
|
139
193
|
<SearchInput value={query} onChange={setQuery} />
|
|
140
194
|
</div>
|
|
141
195
|
</div>
|
|
142
196
|
|
|
197
|
+
{!loading && library?.available === true && presentOccasions.length > 0 && (
|
|
198
|
+
<div
|
|
199
|
+
role="radiogroup"
|
|
200
|
+
aria-label={lr.templates.occasions}
|
|
201
|
+
data-lr-occasion-filter
|
|
202
|
+
className="mb-4 flex flex-wrap items-center gap-2"
|
|
203
|
+
>
|
|
204
|
+
<FilterPill
|
|
205
|
+
label={lr.templates.all}
|
|
206
|
+
active={occasion === null}
|
|
207
|
+
onSelect={() => setOccasion(null)}
|
|
208
|
+
/>
|
|
209
|
+
{presentOccasions.map((entry) => (
|
|
210
|
+
<FilterPill
|
|
211
|
+
key={entry.id}
|
|
212
|
+
label={entry.name}
|
|
213
|
+
active={occasion === entry.id}
|
|
214
|
+
onSelect={() => setOccasion(entry.id)}
|
|
215
|
+
/>
|
|
216
|
+
))}
|
|
217
|
+
</div>
|
|
218
|
+
)}
|
|
219
|
+
|
|
143
220
|
{loading ? (
|
|
144
221
|
showLoading ? (
|
|
145
222
|
<GridSkeleton />
|
|
146
223
|
) : null
|
|
147
224
|
) : visible.length === 0 ? (
|
|
148
225
|
<EmptyHome isDraft={isAll || isDraft} folderName={folder?.name} />
|
|
149
|
-
) :
|
|
226
|
+
) : shown.length === 0 ? (
|
|
150
227
|
<LemonEmpty
|
|
151
228
|
state="thinking"
|
|
152
229
|
title={t.home.noMatches}
|
|
153
230
|
actions={
|
|
154
|
-
<Button
|
|
231
|
+
<Button
|
|
232
|
+
variant="outline"
|
|
233
|
+
onClick={() => {
|
|
234
|
+
setQuery('');
|
|
235
|
+
setOccasion(null);
|
|
236
|
+
}}
|
|
237
|
+
>
|
|
155
238
|
{t.home.clearSearch}
|
|
156
239
|
</Button>
|
|
157
240
|
}
|
|
@@ -174,8 +257,10 @@ export function LemonRiverHome() {
|
|
|
174
257
|
now={now}
|
|
175
258
|
modifiedAt={times[id]?.modifiedAt}
|
|
176
259
|
editing={editing.has(id)}
|
|
260
|
+
templateName={templateNameOf(id)}
|
|
177
261
|
onTitleResolved={ctx.reportTitle}
|
|
178
262
|
actions={{
|
|
263
|
+
onShare: () => setSharing({ slideId: id, title: titleOf(id) }),
|
|
179
264
|
onRename: () => setDialog({ kind: 'rename', id }),
|
|
180
265
|
onDuplicate: () => void duplicate(id),
|
|
181
266
|
onMove: () => setDialog({ kind: 'move', id }),
|
|
@@ -220,6 +305,21 @@ export function LemonRiverHome() {
|
|
|
220
305
|
setDialog(null);
|
|
221
306
|
}}
|
|
222
307
|
/>
|
|
308
|
+
{shareOn && (
|
|
309
|
+
<>
|
|
310
|
+
<ShareDialog
|
|
311
|
+
open={sharing !== null}
|
|
312
|
+
slideId={sharing?.slideId ?? ''}
|
|
313
|
+
title={sharing?.title ?? ''}
|
|
314
|
+
onOpenChange={(open) => {
|
|
315
|
+
if (!open) setSharing(null);
|
|
316
|
+
}}
|
|
317
|
+
/>
|
|
318
|
+
{inspection && (
|
|
319
|
+
<ImportDialog inspection={inspection} onClose={() => setInspection(null)} />
|
|
320
|
+
)}
|
|
321
|
+
</>
|
|
322
|
+
)}
|
|
223
323
|
</div>
|
|
224
324
|
);
|
|
225
325
|
}
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import { useEffect, useState } from 'react';
|
|
2
2
|
|
|
3
|
-
export type DeckTimes = Record<
|
|
3
|
+
export type DeckTimes = Record<
|
|
4
|
+
string,
|
|
5
|
+
{ modifiedAt: number; occasion: string | null; template?: string | null }
|
|
6
|
+
>;
|
|
4
7
|
|
|
5
8
|
/** When each deck was last saved. Only the dev server knows; a built site gets nothing. */
|
|
6
9
|
export function useDeckTimes(): DeckTimes {
|
|
@@ -3,6 +3,11 @@ import { toast } from 'sonner';
|
|
|
3
3
|
import { Button } from '@/components/ui/button';
|
|
4
4
|
import { format, plural } from '@/lib/use-locale';
|
|
5
5
|
import { cn } from '@/lib/utils';
|
|
6
|
+
import { problemsOf } from '../board/model/self-check';
|
|
7
|
+
import { SelfCheckFindings, SelfCheckHighlight, useJumpToFinding } from '../board/self-check-panel';
|
|
8
|
+
import { SelfCheckRunner } from '../board/self-check-runner';
|
|
9
|
+
import { useBoardApply } from '../board/use-board-apply';
|
|
10
|
+
import { useSelfCheck } from '../board/use-self-check';
|
|
6
11
|
import {
|
|
7
12
|
HelperMascot,
|
|
8
13
|
type HelperRole,
|
|
@@ -42,12 +47,30 @@ export function BuildTeam({ slideId }: { slideId: string }) {
|
|
|
42
47
|
const prefsLr = useLrText().prefs;
|
|
43
48
|
const { outline, action, running, waitingForAnswer, connected, pause, resume, undo } =
|
|
44
49
|
useBuildDriver(slideId);
|
|
50
|
+
const boardLr = useLrText().board;
|
|
51
|
+
const selfCheck = useSelfCheck(slideId);
|
|
52
|
+
const jumpToFinding = useJumpToFinding(slideId);
|
|
53
|
+
const apply = useBoardApply(slideId, (last, was) => {
|
|
54
|
+
if (was?.task.kind === 'self-check' && last?.ok) {
|
|
55
|
+
toast.success(boardLr.selfCheckDone);
|
|
56
|
+
void selfCheck.run();
|
|
57
|
+
}
|
|
58
|
+
});
|
|
45
59
|
const [events, setEvents] = useState<Event[]>([]);
|
|
46
60
|
const [hidden, setHidden] = useState(false);
|
|
47
61
|
const previous = useRef<typeof outline>(undefined);
|
|
48
62
|
const eventSeq = useRef(0);
|
|
49
63
|
const toasted = useRef(false);
|
|
50
64
|
|
|
65
|
+
const needsCheck =
|
|
66
|
+
outline?.state === 'built' &&
|
|
67
|
+
selfCheck.record !== undefined &&
|
|
68
|
+
(selfCheck.record === null || selfCheck.record.at < outline.updatedAt);
|
|
69
|
+
|
|
70
|
+
useEffect(() => {
|
|
71
|
+
if (needsCheck && !selfCheck.running) void selfCheck.run();
|
|
72
|
+
}, [needsCheck, selfCheck.running, selfCheck.run]);
|
|
73
|
+
|
|
51
74
|
const built = outline?.built ?? 0;
|
|
52
75
|
const total = outline?.items.length ?? 0;
|
|
53
76
|
const state = outline?.state;
|
|
@@ -273,6 +296,25 @@ export function BuildTeam({ slideId }: { slideId: string }) {
|
|
|
273
296
|
))}
|
|
274
297
|
</ul>
|
|
275
298
|
)}
|
|
299
|
+
|
|
300
|
+
{state === 'built' && (
|
|
301
|
+
<SelfCheckFindings
|
|
302
|
+
record={selfCheck.record}
|
|
303
|
+
running={selfCheck.running}
|
|
304
|
+
fixing={apply.starting || apply.applying !== null}
|
|
305
|
+
onFix={() => {
|
|
306
|
+
const findings = problemsOf(selfCheck.record?.findings ?? []);
|
|
307
|
+
if (findings.length === 0) return;
|
|
308
|
+
toast.message(boardLr.selfCheckRunning);
|
|
309
|
+
void apply.start({ kind: 'self-check', findings });
|
|
310
|
+
}}
|
|
311
|
+
onJump={jumpToFinding}
|
|
312
|
+
onRun={() => void selfCheck.run()}
|
|
313
|
+
/>
|
|
314
|
+
)}
|
|
315
|
+
|
|
316
|
+
{selfCheck.runner && <SelfCheckRunner {...selfCheck.runner} />}
|
|
317
|
+
<SelfCheckHighlight />
|
|
276
318
|
</div>
|
|
277
319
|
);
|
|
278
320
|
}
|
|
@@ -17,38 +17,20 @@ import { readPrefs } from '../agent-prefs/prefs';
|
|
|
17
17
|
import { useAgentPrefs } from '../agent-prefs/use-prefs';
|
|
18
18
|
import { Mascot } from '../brand/mascot';
|
|
19
19
|
import { Onboarding } from '../onboarding/onboarding';
|
|
20
|
+
import { OCCASIONS, type OccasionId } from '../templates/model';
|
|
21
|
+
import { useTemplateLibrary } from '../templates/use-library';
|
|
20
22
|
import { useLrText } from '../text';
|
|
23
|
+
import { readDraft, writeDraft } from './draft';
|
|
21
24
|
import { checkFileObject, type FileVerdict, formatSize } from './files';
|
|
22
|
-
import { MAX_BRIEF, OUTLINE_PAGE_SIZES, type Outline, outlinePrompt } from './model';
|
|
25
|
+
import { MAX_AUDIENCE, MAX_BRIEF, OUTLINE_PAGE_SIZES, type Outline, outlinePrompt } from './model';
|
|
23
26
|
import { Steps } from './steps';
|
|
24
27
|
|
|
25
|
-
const DRAFT_KEY = 'lemonriver:new-deck-draft';
|
|
26
|
-
|
|
27
28
|
type DraftFile = { key: string; file: File; verdict: FileVerdict };
|
|
28
29
|
|
|
29
|
-
type StoredDraft = { brief?: unknown; pages?: unknown };
|
|
30
|
-
|
|
31
30
|
function basePath(): string {
|
|
32
31
|
return import.meta.env.BASE_URL.replace(/\/$/, '');
|
|
33
32
|
}
|
|
34
33
|
|
|
35
|
-
function readDraft(): StoredDraft {
|
|
36
|
-
try {
|
|
37
|
-
const raw = sessionStorage.getItem(DRAFT_KEY);
|
|
38
|
-
if (!raw) return {};
|
|
39
|
-
const parsed: unknown = JSON.parse(raw);
|
|
40
|
-
return parsed && typeof parsed === 'object' ? (parsed as StoredDraft) : {};
|
|
41
|
-
} catch {
|
|
42
|
-
return {};
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
function writeDraft(brief: string, pages: number): void {
|
|
47
|
-
try {
|
|
48
|
-
sessionStorage.setItem(DRAFT_KEY, JSON.stringify({ brief, pages }));
|
|
49
|
-
} catch {}
|
|
50
|
-
}
|
|
51
|
-
|
|
52
34
|
function fileKey(file: File): string {
|
|
53
35
|
return `${file.name}:${file.size}:${file.lastModified}:${Math.random().toString(36).slice(2, 7)}`;
|
|
54
36
|
}
|
|
@@ -59,27 +41,50 @@ export function DescribePage() {
|
|
|
59
41
|
const location = useLocation();
|
|
60
42
|
const prefs = useAgentPrefs();
|
|
61
43
|
const { connected, loading, provider } = useAgentStatus();
|
|
44
|
+
const library = useTemplateLibrary();
|
|
62
45
|
const deckId = new URLSearchParams(location.search).get('deck') ?? '';
|
|
46
|
+
const templateParam = new URLSearchParams(location.search).get('template') ?? '';
|
|
63
47
|
const initialState = (location.state ?? {}) as { brief?: unknown };
|
|
48
|
+
const [draft] = useState(readDraft);
|
|
64
49
|
|
|
65
50
|
const [brief, setBrief] = useState(() => {
|
|
66
51
|
if (typeof initialState.brief === 'string') return initialState.brief.slice(0, MAX_BRIEF);
|
|
67
|
-
const draft = readDraft();
|
|
68
52
|
return typeof draft.brief === 'string' ? draft.brief.slice(0, MAX_BRIEF) : '';
|
|
69
53
|
});
|
|
70
54
|
const [pages, setPages] = useState<number>(() => {
|
|
71
|
-
const draft = readDraft();
|
|
72
55
|
return OUTLINE_PAGE_SIZES.find((size) => size === draft.pages) ?? 8;
|
|
73
56
|
});
|
|
57
|
+
const [occasion, setOccasion] = useState<OccasionId | null>(() =>
|
|
58
|
+
OCCASIONS.find((entry) => entry.id === draft.occasion) ? (draft.occasion as OccasionId) : null,
|
|
59
|
+
);
|
|
60
|
+
const [audience, setAudience] = useState(() =>
|
|
61
|
+
typeof draft.audience === 'string' ? draft.audience.slice(0, MAX_AUDIENCE) : '',
|
|
62
|
+
);
|
|
63
|
+
const [templateId, setTemplateId] = useState<string | null>(() => {
|
|
64
|
+
if (templateParam) return templateParam;
|
|
65
|
+
return typeof draft.template === 'string' ? draft.template : null;
|
|
66
|
+
});
|
|
74
67
|
const [files, setFiles] = useState<DraftFile[]>([]);
|
|
75
68
|
const [uploaded, setUploaded] = useState<string[]>([]);
|
|
76
69
|
const [busy, setBusy] = useState(false);
|
|
77
70
|
const input = useRef<HTMLInputElement>(null);
|
|
78
71
|
const replacing = useRef<string | null>(null);
|
|
72
|
+
const appliedTemplate = useRef<string | null>(null);
|
|
73
|
+
|
|
74
|
+
const template = library?.templates.find((entry) => entry.id === templateId) ?? null;
|
|
75
|
+
const occasions = library?.occasions ?? OCCASIONS;
|
|
76
|
+
const occasionPickersShown = library?.available === true;
|
|
77
|
+
|
|
78
|
+
useEffect(() => {
|
|
79
|
+
writeDraft({ brief, pages, occasion, audience, template: templateId });
|
|
80
|
+
}, [brief, pages, occasion, audience, templateId]);
|
|
79
81
|
|
|
80
82
|
useEffect(() => {
|
|
81
|
-
|
|
82
|
-
|
|
83
|
+
if (!templateParam || !template || appliedTemplate.current === templateParam) return;
|
|
84
|
+
appliedTemplate.current = templateParam;
|
|
85
|
+
setTemplateId(template.id);
|
|
86
|
+
setOccasion(template.occasions[0] ?? null);
|
|
87
|
+
}, [templateParam, template]);
|
|
83
88
|
|
|
84
89
|
useEffect(() => {
|
|
85
90
|
if (!deckId) return;
|
|
@@ -151,6 +156,11 @@ export function DescribePage() {
|
|
|
151
156
|
lastTurn: null,
|
|
152
157
|
prefs: readPrefs(localStorage),
|
|
153
158
|
decisions: [],
|
|
159
|
+
occasion,
|
|
160
|
+
audience: audience.trim(),
|
|
161
|
+
templatePrompt: '',
|
|
162
|
+
templateSkeletons: [],
|
|
163
|
+
templateId,
|
|
154
164
|
};
|
|
155
165
|
const started = await fetch('/__lr/outline/start', {
|
|
156
166
|
method: 'POST',
|
|
@@ -161,13 +171,25 @@ export function DescribePage() {
|
|
|
161
171
|
pages,
|
|
162
172
|
files: names,
|
|
163
173
|
prefs: outline.prefs,
|
|
174
|
+
occasion: outline.occasion,
|
|
175
|
+
audience: outline.audience,
|
|
176
|
+
template: templateId,
|
|
164
177
|
}),
|
|
165
178
|
});
|
|
166
179
|
if (!started.ok) throw new Error('start failed');
|
|
180
|
+
// The server reads the occasion's audience and page order from the library.
|
|
181
|
+
const extra = ((await started.json().catch(() => null)) as { prompt?: unknown } | null)
|
|
182
|
+
?.prompt;
|
|
167
183
|
|
|
168
184
|
const session = await createSession(provider.id, slideId);
|
|
169
185
|
setActiveSession(session.id);
|
|
170
|
-
|
|
186
|
+
const prompt = [
|
|
187
|
+
outlinePrompt(outline, slideId, locale.id),
|
|
188
|
+
typeof extra === 'string' ? extra : '',
|
|
189
|
+
]
|
|
190
|
+
.filter((line) => line.trim() !== '')
|
|
191
|
+
.join('\n');
|
|
192
|
+
await sendMessage(session.id, prompt, { slideId });
|
|
171
193
|
window.location.assign(`${basePath()}/s/${encodeURIComponent(slideId)}/outline`);
|
|
172
194
|
} catch {
|
|
173
195
|
toast.error(lr.outline.startFailed);
|
|
@@ -179,6 +201,22 @@ export function DescribePage() {
|
|
|
179
201
|
<div data-lr-new className="max-w-[760px]">
|
|
180
202
|
<Steps current={1} />
|
|
181
203
|
|
|
204
|
+
{template && (
|
|
205
|
+
<div data-lr-selected-template={template.id} className="mt-5 flex items-center gap-2">
|
|
206
|
+
<span className="inline-flex items-center gap-1 rounded-full border border-border bg-[var(--lr-accent-soft)] py-0.5 pr-1 pl-3 text-[13px] font-medium">
|
|
207
|
+
{format(lr.outline.selectedTemplate, { name: template.name })}
|
|
208
|
+
<button
|
|
209
|
+
type="button"
|
|
210
|
+
aria-label={lr.outline.removeTemplate}
|
|
211
|
+
onClick={() => setTemplateId(null)}
|
|
212
|
+
className="rounded-full px-1 text-[15px] leading-none text-muted-foreground hover:text-foreground"
|
|
213
|
+
>
|
|
214
|
+
×
|
|
215
|
+
</button>
|
|
216
|
+
</span>
|
|
217
|
+
</div>
|
|
218
|
+
)}
|
|
219
|
+
|
|
182
220
|
<header className="mt-6 mb-5">
|
|
183
221
|
<h1 className="font-heading text-[28px] font-bold leading-[34px] tracking-[-0.01em]">
|
|
184
222
|
{lr.outline.describeTitle}
|
|
@@ -195,6 +233,69 @@ export function DescribePage() {
|
|
|
195
233
|
className="min-h-[88px] resize-none text-[15px]"
|
|
196
234
|
/>
|
|
197
235
|
|
|
236
|
+
{occasionPickersShown && (
|
|
237
|
+
<div className="mt-5">
|
|
238
|
+
<p className="text-[13px] font-semibold">{lr.outline.occasionLabel}</p>
|
|
239
|
+
<div
|
|
240
|
+
role="radiogroup"
|
|
241
|
+
aria-label={lr.outline.occasionLabel}
|
|
242
|
+
data-lr-occasions
|
|
243
|
+
className="mt-2 flex flex-wrap gap-2"
|
|
244
|
+
>
|
|
245
|
+
{occasions.map((entry) => (
|
|
246
|
+
// biome-ignore lint/a11y/useSemanticElements: a row of pills, as with the page count
|
|
247
|
+
<button
|
|
248
|
+
key={entry.id}
|
|
249
|
+
type="button"
|
|
250
|
+
role="radio"
|
|
251
|
+
aria-checked={occasion === entry.id}
|
|
252
|
+
onClick={() => setOccasion(entry.id)}
|
|
253
|
+
className={cn(
|
|
254
|
+
'h-8 rounded-full border px-3.5 text-[13px] font-medium outline-none transition-colors focus-visible:ring-2 focus-visible:ring-ring/40',
|
|
255
|
+
occasion === entry.id
|
|
256
|
+
? 'border-[var(--lr-focus)] bg-[var(--lr-accent-soft)] text-foreground'
|
|
257
|
+
: 'border-border bg-card text-muted-foreground hover:border-[var(--lr-text-3)]',
|
|
258
|
+
)}
|
|
259
|
+
>
|
|
260
|
+
{entry.name}
|
|
261
|
+
</button>
|
|
262
|
+
))}
|
|
263
|
+
{/* biome-ignore lint/a11y/useSemanticElements: a row of pills, as with the page count */}
|
|
264
|
+
<button
|
|
265
|
+
type="button"
|
|
266
|
+
role="radio"
|
|
267
|
+
aria-checked={occasion === null}
|
|
268
|
+
onClick={() => setOccasion(null)}
|
|
269
|
+
className={cn(
|
|
270
|
+
'h-8 rounded-full border px-3.5 text-[13px] font-medium outline-none transition-colors focus-visible:ring-2 focus-visible:ring-ring/40',
|
|
271
|
+
occasion === null
|
|
272
|
+
? 'border-[var(--lr-focus)] bg-[var(--lr-accent-soft)] text-foreground'
|
|
273
|
+
: 'border-border bg-card text-muted-foreground hover:border-[var(--lr-text-3)]',
|
|
274
|
+
)}
|
|
275
|
+
>
|
|
276
|
+
{lr.outline.unsure}
|
|
277
|
+
</button>
|
|
278
|
+
</div>
|
|
279
|
+
</div>
|
|
280
|
+
)}
|
|
281
|
+
|
|
282
|
+
{occasionPickersShown && (
|
|
283
|
+
<div className="mt-5">
|
|
284
|
+
<label className="text-[13px] font-semibold" htmlFor="lr-audience">
|
|
285
|
+
{lr.outline.audienceLabel}
|
|
286
|
+
</label>
|
|
287
|
+
<input
|
|
288
|
+
id="lr-audience"
|
|
289
|
+
type="text"
|
|
290
|
+
value={audience}
|
|
291
|
+
maxLength={MAX_AUDIENCE}
|
|
292
|
+
onChange={(event) => setAudience(event.target.value.slice(0, MAX_AUDIENCE))}
|
|
293
|
+
placeholder={lr.outline.audiencePlaceholder}
|
|
294
|
+
className="mt-2 h-9 w-full rounded-[6px] border border-border bg-card px-3 text-[14px] outline-none placeholder:text-muted-foreground focus-visible:ring-2 focus-visible:ring-ring/40"
|
|
295
|
+
/>
|
|
296
|
+
</div>
|
|
297
|
+
)}
|
|
298
|
+
|
|
198
299
|
<div className="mt-5">
|
|
199
300
|
<p className="text-[13px] font-semibold">{lr.outline.pagesLabel}</p>
|
|
200
301
|
<div role="radiogroup" aria-label={lr.outline.pagesLabel} className="mt-2 flex gap-2">
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
export const DRAFT_KEY = 'lemonriver:new-deck-draft';
|
|
2
|
+
|
|
3
|
+
export type StoredDraft = {
|
|
4
|
+
brief?: unknown;
|
|
5
|
+
pages?: unknown;
|
|
6
|
+
occasion?: unknown;
|
|
7
|
+
audience?: unknown;
|
|
8
|
+
template?: unknown;
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
export function readDraft(): StoredDraft {
|
|
12
|
+
try {
|
|
13
|
+
const raw = sessionStorage.getItem(DRAFT_KEY);
|
|
14
|
+
if (!raw) return {};
|
|
15
|
+
const parsed: unknown = JSON.parse(raw);
|
|
16
|
+
return parsed && typeof parsed === 'object' ? (parsed as StoredDraft) : {};
|
|
17
|
+
} catch {
|
|
18
|
+
return {};
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export function writeDraft(draft: {
|
|
23
|
+
brief: string;
|
|
24
|
+
pages: number;
|
|
25
|
+
occasion: string | null;
|
|
26
|
+
audience: string;
|
|
27
|
+
template: string | null;
|
|
28
|
+
}): void {
|
|
29
|
+
try {
|
|
30
|
+
sessionStorage.setItem(DRAFT_KEY, JSON.stringify(draft));
|
|
31
|
+
} catch {}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/** The template the user came in with from the library, if they picked one. */
|
|
35
|
+
export function draftTemplateId(): string | null {
|
|
36
|
+
const { template } = readDraft();
|
|
37
|
+
return typeof template === 'string' && template !== '' ? template : null;
|
|
38
|
+
}
|