@lemonriver/core 0.4.0 → 0.6.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.
Files changed (115) hide show
  1. package/README.md +14 -4
  2. package/dist/{build-Nl7EeJ6x.js → build-RlcGG-Ve.js} +1 -1
  3. package/dist/cli/bin.js +4 -4
  4. package/dist/{config-CpC0nM3r.js → config-BJT87wE9.js} +4756 -2012
  5. package/dist/{dev-BB3THd5I.js → dev-DR-j_xda.js} +2 -2
  6. package/dist/{preview-BGjgTg7H.js → preview-BTAhTb5B.js} +1 -1
  7. package/dist/{update-DsxZBtwv.js → update-CMRxtTc9.js} +18 -8
  8. package/dist/vite/index.js +1 -1
  9. package/package.json +2 -2
  10. package/src/agent/types.ts +14 -2
  11. package/src/app/components/agent/agent-panel.tsx +17 -5
  12. package/src/app/components/agent/connect-view.tsx +1 -1
  13. package/src/app/components/agent/provider-logo.tsx +10 -1
  14. package/src/app/lemonriver/agent/provider-marks.tsx +53 -0
  15. package/src/app/lemonriver/agent-providers/section.tsx +75 -0
  16. package/src/app/lemonriver/agent-providers/use-providers.ts +61 -0
  17. package/src/app/lemonriver/board/blocks/block-panel.tsx +666 -0
  18. package/src/app/lemonriver/board/blocks/cache.ts +28 -0
  19. package/src/app/lemonriver/board/blocks/change-list.tsx +189 -0
  20. package/src/app/lemonriver/board/blocks/classify.test.ts +209 -0
  21. package/src/app/lemonriver/board/blocks/classify.ts +152 -0
  22. package/src/app/lemonriver/board/blocks/snapshot.ts +116 -0
  23. package/src/app/lemonriver/board/board-canvas.tsx +627 -104
  24. package/src/app/lemonriver/board/board-page.tsx +1702 -91
  25. package/src/app/lemonriver/board/board.css +58 -7
  26. package/src/app/lemonriver/board/layout.test.ts +84 -0
  27. package/src/app/lemonriver/board/layout.ts +112 -11
  28. package/src/app/lemonriver/board/model/agent-tasks.test.ts +200 -0
  29. package/src/app/lemonriver/board/model/agent-tasks.ts +223 -0
  30. package/src/app/lemonriver/board/model/apply-prompt.test.ts +121 -0
  31. package/src/app/lemonriver/board/model/apply-prompt.ts +115 -0
  32. package/src/app/lemonriver/board/model/apply.ts +71 -0
  33. package/src/app/lemonriver/board/model/cards.test.ts +95 -2
  34. package/src/app/lemonriver/board/model/cards.ts +88 -20
  35. package/src/app/lemonriver/board/model/changes.test.ts +244 -0
  36. package/src/app/lemonriver/board/model/changes.ts +268 -0
  37. package/src/app/lemonriver/board/model/filter.test.ts +50 -0
  38. package/src/app/lemonriver/board/model/filter.ts +42 -0
  39. package/src/app/lemonriver/board/model/history.test.ts +71 -0
  40. package/src/app/lemonriver/board/model/history.ts +51 -0
  41. package/src/app/lemonriver/board/model/restructure.test.ts +205 -0
  42. package/src/app/lemonriver/board/model/restructure.ts +169 -0
  43. package/src/app/lemonriver/board/model/self-check.test.ts +329 -0
  44. package/src/app/lemonriver/board/model/self-check.ts +489 -0
  45. package/src/app/lemonriver/board/model/structure.test.ts +249 -0
  46. package/src/app/lemonriver/board/model/structure.ts +209 -0
  47. package/src/app/lemonriver/board/model/timing.test.ts +113 -0
  48. package/src/app/lemonriver/board/model/timing.ts +117 -0
  49. package/src/app/lemonriver/board/page-node.tsx +258 -55
  50. package/src/app/lemonriver/board/self-check-jump.ts +23 -0
  51. package/src/app/lemonriver/board/self-check-panel.tsx +272 -0
  52. package/src/app/lemonriver/board/self-check-runner.tsx +150 -0
  53. package/src/app/lemonriver/board/status-style.ts +25 -0
  54. package/src/app/lemonriver/board/use-board-apply.ts +206 -0
  55. package/src/app/lemonriver/board/use-board-cards.ts +108 -5
  56. package/src/app/lemonriver/board/use-board-changes.ts +108 -0
  57. package/src/app/lemonriver/board/use-board-columns.ts +37 -56
  58. package/src/app/lemonriver/board/use-board-comments.ts +36 -0
  59. package/src/app/lemonriver/board/use-board-restructures.ts +107 -0
  60. package/src/app/lemonriver/board/use-history.ts +86 -0
  61. package/src/app/lemonriver/board/use-page-order.ts +65 -38
  62. package/src/app/lemonriver/board/use-self-check.ts +117 -0
  63. package/src/app/lemonriver/board/use-target-minutes.ts +47 -0
  64. package/src/app/lemonriver/board/views/block-readings.tsx +46 -0
  65. package/src/app/lemonriver/board/views/list-view.tsx +356 -0
  66. package/src/app/lemonriver/board/views/progress.tsx +32 -0
  67. package/src/app/lemonriver/board/views/timeline-view.tsx +341 -0
  68. package/src/app/lemonriver/chrome/filter-pill.tsx +30 -0
  69. package/src/app/lemonriver/chrome/sidebar-extras.tsx +12 -1
  70. package/src/app/lemonriver/features.test.ts +5 -0
  71. package/src/app/lemonriver/features.ts +2 -1
  72. package/src/app/lemonriver/home/deck-card.tsx +10 -0
  73. package/src/app/lemonriver/home/home-page.tsx +55 -6
  74. package/src/app/lemonriver/home/use-deck-times.ts +4 -1
  75. package/src/app/lemonriver/outline/build-team.tsx +42 -0
  76. package/src/app/lemonriver/outline/describe-page.tsx +128 -27
  77. package/src/app/lemonriver/outline/draft.ts +38 -0
  78. package/src/app/lemonriver/outline/model.test.ts +118 -0
  79. package/src/app/lemonriver/outline/model.ts +92 -7
  80. package/src/app/lemonriver/outline/outline-page.tsx +90 -7
  81. package/src/app/lemonriver/outline/pick-style.tsx +282 -0
  82. package/src/app/lemonriver/routes.test.tsx +17 -5
  83. package/src/app/lemonriver/routes.tsx +28 -0
  84. package/src/app/lemonriver/settings/settings-page.tsx +3 -0
  85. package/src/app/lemonriver/slide-extensions.tsx +14 -2
  86. package/src/app/lemonriver/templates/client.ts +60 -0
  87. package/src/app/lemonriver/templates/demo-page.tsx +79 -0
  88. package/src/app/lemonriver/templates/knobs.test.ts +62 -0
  89. package/src/app/lemonriver/templates/knobs.ts +62 -0
  90. package/src/app/lemonriver/templates/library-page.tsx +292 -0
  91. package/src/app/lemonriver/templates/model.test.ts +175 -0
  92. package/src/app/lemonriver/templates/model.ts +339 -0
  93. package/src/app/lemonriver/templates/preview-content.test.ts +117 -0
  94. package/src/app/lemonriver/templates/preview-content.ts +149 -0
  95. package/src/app/lemonriver/templates/recommend.test.ts +71 -0
  96. package/src/app/lemonriver/templates/recommend.ts +72 -0
  97. package/src/app/lemonriver/templates/use-library.ts +58 -0
  98. package/src/app/lemonriver/templates/virtual.d.ts +28 -0
  99. package/src/app/lemonriver/text/en.ts +228 -0
  100. package/src/app/lemonriver/text/es.ts +220 -0
  101. package/src/app/lemonriver/text/ja.ts +220 -0
  102. package/src/app/lemonriver/text/types.ts +243 -0
  103. package/src/app/lemonriver/text/zh-cn.ts +218 -0
  104. package/src/app/lemonriver/text/zh-tw.ts +218 -0
  105. package/src/app/lemonriver/theme/lemon-icon.tsx +6 -0
  106. package/src/app/lemonriver/theme/pages.test.ts +4 -0
  107. package/src/app/lemonriver/theme/pages.ts +6 -1
  108. package/src/app/lemonriver/theme/theme-menu.tsx +3 -2
  109. package/src/app/lemonriver/theme/use-theme.tsx +2 -2
  110. package/src/app/lemonriver/update/prompt.ts +1 -1
  111. package/src/app/lib/agent/use-agent.ts +4 -3
  112. package/src/app/routes/slide.tsx +1 -1
  113. package/src/app/assets/open-slide.svg +0 -39
  114. package/src/app/favicon.ico +0 -0
  115. package/src/app/favicon.svg +0 -39
@@ -0,0 +1,341 @@
1
+ import {
2
+ closestCenter,
3
+ DndContext,
4
+ type DragEndEvent,
5
+ KeyboardSensor,
6
+ PointerSensor,
7
+ useSensor,
8
+ useSensors,
9
+ } from '@dnd-kit/core';
10
+ import {
11
+ horizontalListSortingStrategy,
12
+ SortableContext,
13
+ sortableKeyboardCoordinates,
14
+ useSortable,
15
+ } from '@dnd-kit/sortable';
16
+ import { CSS } from '@dnd-kit/utilities';
17
+ import { useEffect, useState } from 'react';
18
+ import { format, useLocale } from '@/lib/use-locale';
19
+ import { cn, pad2 } from '@/lib/utils';
20
+ import type { Page } from '../../../lib/sdk';
21
+ import { useLrText } from '../../text';
22
+ import type { Block } from '../blocks/classify';
23
+ import { pageName } from '../layout';
24
+ import type { BoardCard } from '../model/cards';
25
+ import { type BoardColumn, chapterProgress, columnStarts } from '../model/structure';
26
+ import {
27
+ estimateSeconds,
28
+ formatDuration,
29
+ type Timing,
30
+ timelineSegments,
31
+ xForSeconds,
32
+ } from '../model/timing';
33
+ import { useStatusLabels } from '../page-node';
34
+ import { STATUS_STYLE } from '../status-style';
35
+ import { Progress } from './progress';
36
+
37
+ type Props = {
38
+ pages: Page[];
39
+ keys: string[];
40
+ cards: (BoardCard | undefined)[];
41
+ columns: BoardColumn[];
42
+ notes?: (string | undefined)[];
43
+ dimmed: boolean[];
44
+ selected: number[];
45
+ target: number | null;
46
+ targetFor: (minutes: number | null) => void;
47
+ onSelect: (indices: number[]) => void;
48
+ onOpenPage: (index: number) => void;
49
+ onMovePages: (moving: number[], to: number) => void;
50
+ blocksOfPage: (key: string) => Block[] | null;
51
+ };
52
+
53
+ const pageIndexOf = (id: string) => Number(id.replace('page-', ''));
54
+
55
+ const BASIS: Record<Timing['basis'], 'basisNotes' | 'basisPage' | 'basisNone'> = {
56
+ notes: 'basisNotes',
57
+ page: 'basisPage',
58
+ none: 'basisNone',
59
+ };
60
+
61
+ /**
62
+ * The deck laid out as the talk it will be: every page a stretch of the track as
63
+ * wide as it takes to say, chapter after chapter, with the target marked on it.
64
+ */
65
+ export function TimelineView({
66
+ pages,
67
+ keys,
68
+ cards,
69
+ columns,
70
+ notes,
71
+ dimmed,
72
+ selected,
73
+ target,
74
+ targetFor,
75
+ onSelect,
76
+ onOpenPage,
77
+ onMovePages,
78
+ blocksOfPage,
79
+ }: Props) {
80
+ const lr = useLrText();
81
+ const locale = useLocale();
82
+ const [draft, setDraft] = useState(target === null ? '' : String(target));
83
+
84
+ useEffect(() => setDraft(target === null ? '' : String(target)), [target]);
85
+
86
+ const sensors = useSensors(
87
+ useSensor(PointerSensor, { activationConstraint: { distance: 5 } }),
88
+ useSensor(KeyboardSensor, { coordinateGetter: sortableKeyboardCoordinates }),
89
+ );
90
+
91
+ const timings = pages.map((_, index) => {
92
+ const key = keys[index];
93
+ return estimateSeconds({ notes: notes?.[index], blocks: key ? blocksOfPage(key) : null });
94
+ });
95
+ const seconds = timings.map((timing) => timing.seconds);
96
+ const segments = timelineSegments(seconds);
97
+ const total = seconds.reduce((sum, value) => sum + value, 0);
98
+ const trackWidth = segments.reduce((sum, segment) => sum + segment.width, 0);
99
+
100
+ const targetSeconds = target === null ? null : target * 60;
101
+ const over = targetSeconds !== null && total > targetSeconds;
102
+ const targetX = targetSeconds === null ? null : xForSeconds(seconds, targetSeconds);
103
+
104
+ const starts = columnStarts(columns);
105
+ const chapterOf = (index: number) => {
106
+ for (let i = starts.length - 1; i >= 0; i--) if (index >= starts[i]) return i;
107
+ return 0;
108
+ };
109
+ const byKey = cards.reduce<Record<string, BoardCard>>((all, card, index) => {
110
+ const key = keys[index];
111
+ if (card && key) all[key] = card;
112
+ return all;
113
+ }, {});
114
+
115
+ const onDragEnd = (event: DragEndEvent) => {
116
+ const { active, over: on } = event;
117
+ if (!on || active.id === on.id) return;
118
+ const from = pageIndexOf(String(active.id));
119
+ const to = pageIndexOf(String(on.id));
120
+ if (!Number.isInteger(from) || !Number.isInteger(to)) return;
121
+ onMovePages([from], to);
122
+ };
123
+
124
+ const commitTarget = (value: string) => {
125
+ setDraft(value);
126
+ if (!value.trim()) {
127
+ targetFor(null);
128
+ return;
129
+ }
130
+ const minutes = Math.trunc(Number(value));
131
+ if (Number.isInteger(minutes) && minutes >= 1 && minutes <= 180) targetFor(minutes);
132
+ };
133
+
134
+ return (
135
+ <div className="flex h-full min-h-0 min-w-0 flex-col" data-lr-timeline-view>
136
+ <div className="flex shrink-0 items-center gap-3 border-b border-hairline px-6 py-2.5">
137
+ <span
138
+ className={cn('text-[13px] tabular-nums', over ? 'text-destructive' : 'text-foreground')}
139
+ data-lr-total
140
+ data-over={over ? 'true' : 'false'}
141
+ >
142
+ {format(lr.board.totalDuration, { d: formatDuration(total, locale.id) })}
143
+ </span>
144
+ {target !== null && targetSeconds !== null && (
145
+ <span
146
+ className={cn(
147
+ 'text-[12px] tabular-nums',
148
+ over ? 'text-destructive' : 'text-muted-foreground',
149
+ )}
150
+ data-lr-target-diff
151
+ >
152
+ {over
153
+ ? format(lr.board.overTarget, {
154
+ d: formatDuration(total - targetSeconds, locale.id),
155
+ })
156
+ : format(lr.board.underTarget, {
157
+ d: formatDuration(targetSeconds - total, locale.id),
158
+ })}
159
+ </span>
160
+ )}
161
+ <label className="ml-auto flex items-center gap-1.5 text-[12px] text-muted-foreground">
162
+ {lr.board.target}
163
+ <input
164
+ type="number"
165
+ min={1}
166
+ max={180}
167
+ value={draft}
168
+ aria-label={lr.board.target}
169
+ data-lr-target
170
+ onChange={(event) => commitTarget(event.currentTarget.value)}
171
+ className="w-16 rounded-[4px] border border-hairline bg-background px-2 py-1 text-[12.5px] tabular-nums text-foreground outline-none focus:ring-1 focus:ring-brand/50"
172
+ />
173
+ </label>
174
+ </div>
175
+
176
+ <div className="min-h-0 w-full flex-1 overflow-auto px-6 py-5">
177
+ {pages.length === 0 ? null : (
178
+ <DndContext sensors={sensors} collisionDetection={closestCenter} onDragEnd={onDragEnd}>
179
+ <div className="relative" style={{ width: trackWidth }}>
180
+ <div className="mb-2 flex">
181
+ {columns.map((column, columnIndex) => {
182
+ const from = starts[columnIndex] ?? 0;
183
+ const width = segments
184
+ .slice(from, from + column.size)
185
+ .reduce((sum, segment) => sum + segment.width, 0);
186
+ const chapterSeconds = seconds
187
+ .slice(from, from + column.size)
188
+ .reduce((sum, value) => sum + value, 0);
189
+ const progress = chapterProgress(byKey, keys.slice(from, from + column.size));
190
+ return (
191
+ <div
192
+ // biome-ignore lint/suspicious/noArrayIndexKey: a chapter is its position in the deck
193
+ key={`chapter-${columnIndex}`}
194
+ data-lr-timeline-chapter
195
+ className={cn(
196
+ 'flex min-w-0 items-baseline gap-1.5 overflow-hidden pr-2',
197
+ columnIndex > 0 && 'border-l border-hairline pl-2',
198
+ )}
199
+ style={{ width }}
200
+ >
201
+ <span className="eyebrow truncate text-foreground">
202
+ {column.title || format(lr.board.columnFallback, { n: columnIndex + 1 })}
203
+ </span>
204
+ {/* A short chapter cannot show its numbers; the name is what it
205
+ has to keep. */}
206
+ {width >= 120 && (
207
+ <span className="shrink-0 text-[11px] text-muted-foreground tabular-nums">
208
+ {formatDuration(chapterSeconds, locale.id)}
209
+ </span>
210
+ )}
211
+ {width >= 140 && <Progress progress={progress} compact={width < 260} />}
212
+ </div>
213
+ );
214
+ })}
215
+ </div>
216
+
217
+ <div className="relative flex h-20" data-lr-timeline-track>
218
+ <SortableContext
219
+ items={segments.map((_, index) => `page-${index}`)}
220
+ strategy={horizontalListSortingStrategy}
221
+ >
222
+ {segments.map((segment, index) => {
223
+ const chapter = chapterOf(index);
224
+ const chapterHead = index === starts[chapter];
225
+ return (
226
+ <Segment
227
+ // biome-ignore lint/suspicious/noArrayIndexKey: a page is its position in the deck
228
+ key={`page-${index}`}
229
+ id={`page-${index}`}
230
+ index={index}
231
+ width={segment.width}
232
+ chapterHead={chapterHead}
233
+ pages={pages}
234
+ card={cards[index]}
235
+ timing={timings[index]}
236
+ dimmed={dimmed[index] === true}
237
+ beyond={
238
+ targetX !== null && segment.start >= targetX && targetSeconds !== null
239
+ }
240
+ selected={selected.includes(index)}
241
+ onSelect={() => onSelect([index])}
242
+ onOpen={() => onOpenPage(index)}
243
+ />
244
+ );
245
+ })}
246
+ </SortableContext>
247
+
248
+ {targetX !== null && (
249
+ <span
250
+ aria-hidden
251
+ data-lr-target-line
252
+ className="pointer-events-none absolute top-0 bottom-0 w-px bg-destructive/70"
253
+ style={{ left: Math.min(targetX, trackWidth) }}
254
+ />
255
+ )}
256
+ </div>
257
+ </div>
258
+ </DndContext>
259
+ )}
260
+ </div>
261
+ </div>
262
+ );
263
+ }
264
+
265
+ function Segment({
266
+ id,
267
+ index,
268
+ width,
269
+ chapterHead,
270
+ pages,
271
+ card,
272
+ timing,
273
+ dimmed,
274
+ beyond,
275
+ selected,
276
+ onSelect,
277
+ onOpen,
278
+ }: {
279
+ id: string;
280
+ index: number;
281
+ width: number;
282
+ chapterHead: boolean;
283
+ pages: Page[];
284
+ card?: BoardCard;
285
+ timing: Timing;
286
+ dimmed: boolean;
287
+ beyond: boolean;
288
+ selected: boolean;
289
+ onSelect: () => void;
290
+ onOpen: () => void;
291
+ }) {
292
+ const lr = useLrText();
293
+ const locale = useLocale();
294
+ const labels = useStatusLabels();
295
+ const { attributes, listeners, setNodeRef, transform, transition, isDragging } = useSortable({
296
+ id,
297
+ });
298
+ const status = card?.status;
299
+ const title = card?.title || pageName(pages[index]) || '';
300
+ const duration = formatDuration(timing.seconds, locale.id);
301
+ const hint = [
302
+ `${pad2(index + 1)}${title ? ` ${title}` : ''}`,
303
+ duration,
304
+ lr.board[BASIS[timing.basis]],
305
+ status ? labels[status] : null,
306
+ ]
307
+ .filter(Boolean)
308
+ .join(' · ');
309
+
310
+ return (
311
+ <button
312
+ ref={setNodeRef}
313
+ type="button"
314
+ title={hint}
315
+ data-lr-timeline-segment
316
+ data-page={index + 1}
317
+ data-selected={selected ? 'true' : 'false'}
318
+ onClick={onSelect}
319
+ onDoubleClick={onOpen}
320
+ style={{ width, transform: CSS.Transform.toString(transform), transition }}
321
+ className={cn(
322
+ 'relative flex h-full flex-col items-start justify-start overflow-hidden rounded-[4px] border-r border-background px-1.5 py-1 text-left',
323
+ status ? STATUS_STYLE[status].bar : 'bg-muted',
324
+ 'hover:brightness-[0.97]',
325
+ chapterHead && 'border-l-2 border-l-foreground/25',
326
+ selected && 'ring-2 ring-brand ring-inset',
327
+ dimmed && 'opacity-35',
328
+ beyond && 'opacity-40',
329
+ isDragging && 'z-10 opacity-70 shadow-[var(--lr-shadow-1)]',
330
+ )}
331
+ {...attributes}
332
+ {...listeners}
333
+ >
334
+ <span className="text-[11px] tabular-nums text-muted-foreground">{pad2(index + 1)}</span>
335
+ {width >= 120 && title && (
336
+ <span className="line-clamp-2 text-[11.5px] text-foreground/80">{title}</span>
337
+ )}
338
+ <span className="mt-auto text-[10.5px] tabular-nums text-muted-foreground">{duration}</span>
339
+ </button>
340
+ );
341
+ }
@@ -0,0 +1,30 @@
1
+ import { cn } from '@/lib/utils';
2
+
3
+ /** The single-choice occasion chips shared by the home list and the template library. */
4
+ export function FilterPill({
5
+ label,
6
+ active,
7
+ onSelect,
8
+ }: {
9
+ label: string;
10
+ active: boolean;
11
+ onSelect: () => void;
12
+ }) {
13
+ return (
14
+ // biome-ignore lint/a11y/useSemanticElements: a row of pills, as elsewhere in the app
15
+ <button
16
+ type="button"
17
+ role="radio"
18
+ aria-checked={active}
19
+ onClick={onSelect}
20
+ className={cn(
21
+ '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',
22
+ active
23
+ ? 'border-[var(--lr-focus)] bg-[var(--lr-accent-soft)] text-foreground'
24
+ : 'border-border bg-card text-muted-foreground hover:border-[var(--lr-text-3)] hover:text-foreground',
25
+ )}
26
+ >
27
+ {label}
28
+ </button>
29
+ );
30
+ }
@@ -1,9 +1,10 @@
1
- import { Plus, Settings, Trash2 } from 'lucide-react';
1
+ import { LayoutTemplate, Plus, Settings, Trash2 } from 'lucide-react';
2
2
  import { createPortal } from 'react-dom';
3
3
  import { useLocation, useNavigate } from 'react-router-dom';
4
4
  import { Button } from '@/components/ui/button';
5
5
  import { useCreateDeck } from '@/lib/agent/use-agent';
6
6
  import { isFeatureEnabled } from '../features';
7
+ import { useTemplateLibrary } from '../templates/use-library';
7
8
  import { useLrText } from '../text';
8
9
  import { pageForPath } from '../theme/pages';
9
10
  import { NavRow } from './nav-row';
@@ -18,6 +19,8 @@ export function SidebarExtras() {
18
19
  const createDeck = useCreateDeck();
19
20
  const lr = useLrText();
20
21
  const page = pageForPath(pathname);
22
+ const library = useTemplateLibrary();
23
+ const templatesOn = isFeatureEnabled('templates') && library?.available === true;
21
24
 
22
25
  return (
23
26
  <>
@@ -33,6 +36,14 @@ export function SidebarExtras() {
33
36
  {nav &&
34
37
  createPortal(
35
38
  <>
39
+ {templatesOn && (
40
+ <NavRow
41
+ icon={<LayoutTemplate className="size-4" strokeWidth={1.75} />}
42
+ label={lr.templates.title}
43
+ current={page === 'templates'}
44
+ onSelect={() => navigate('/templates', { replace: true })}
45
+ />
46
+ )}
36
47
  {isFeatureEnabled('trash') && (
37
48
  <NavRow
38
49
  icon={<Trash2 className="size-4" strokeWidth={1.75} />}
@@ -31,4 +31,9 @@ describe('isFeatureEnabled', () => {
31
31
  expect(isFeatureEnabled('outline', { dev: true })).toBe(true);
32
32
  expect(isFeatureEnabled('outline', { dev: false })).toBe(false);
33
33
  });
34
+
35
+ it('keeps the template library to dev, where its files sit', () => {
36
+ expect(isFeatureEnabled('templates', { dev: true })).toBe(true);
37
+ expect(isFeatureEnabled('templates', { dev: false })).toBe(false);
38
+ });
34
39
  });
@@ -1,5 +1,5 @@
1
1
  export type Tier = 'free' | 'pro';
2
- export type FeatureId = 'board' | 'trash' | 'settings' | 'outline';
2
+ export type FeatureId = 'board' | 'trash' | 'settings' | 'outline' | 'templates';
3
3
 
4
4
  export type Feature = { id: FeatureId; tier: Tier; devOnly: boolean };
5
5
 
@@ -8,6 +8,7 @@ export const FEATURES: readonly Feature[] = [
8
8
  { id: 'trash', tier: 'free', devOnly: true },
9
9
  { id: 'settings', tier: 'free', devOnly: false },
10
10
  { id: 'outline', tier: 'free', devOnly: true },
11
+ { id: 'templates', tier: 'free', devOnly: true },
11
12
  ];
12
13
 
13
14
  /** The single place a paid tier will hook into later; today every tier is unlocked. */
@@ -32,6 +32,7 @@ export function DeckCard({
32
32
  modifiedAt,
33
33
  editing,
34
34
  now,
35
+ templateName,
35
36
  onTitleResolved,
36
37
  actions,
37
38
  }: {
@@ -39,6 +40,7 @@ export function DeckCard({
39
40
  modifiedAt: number | undefined;
40
41
  editing: boolean;
41
42
  now: number;
43
+ templateName?: string | null;
42
44
  onTitleResolved: (id: string, title: string) => void;
43
45
  actions: DeckCardActions;
44
46
  }) {
@@ -135,6 +137,14 @@ export function DeckCard({
135
137
  <span className="max-w-[110px] truncate">{slide.meta.theme}</span>
136
138
  </Link>
137
139
  )}
140
+ {templateName && (
141
+ <span
142
+ data-lr-deck-template={templateName}
143
+ 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"
144
+ >
145
+ {templateName}
146
+ </span>
147
+ )}
138
148
  </p>
139
149
  </div>
140
150
  {import.meta.env.DEV && <DeckMenu actions={actions} />}
@@ -16,8 +16,11 @@ 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 { OCCASIONS } from '../templates/model';
23
+ import { useTemplateLibrary } from '../templates/use-library';
21
24
  import { useLrText } from '../text';
22
25
  import { moveToTrash } from '../trash/api';
23
26
  import { BriefCard } from './brief-card';
@@ -57,8 +60,10 @@ export function LemonRiverHome() {
57
60
  const lr = useLrText();
58
61
  const now = useNow();
59
62
  const times = useDeckTimes();
63
+ const library = useTemplateLibrary();
60
64
  const editing = useEditingDecks();
61
65
  const [query, setQuery] = useState('');
66
+ const [occasion, setOccasion] = useState<string | null>(null);
62
67
  const [sortKey, setSortKey] = useSortPref();
63
68
  const [dialog, setDialog] = useState<Dialog>(null);
64
69
 
@@ -68,13 +73,27 @@ export function LemonRiverHome() {
68
73
  isAll || isDraft ? null : (manifest.folders.find((f) => f.id === selectedId) ?? null);
69
74
  const visible = isAll ? slideIds : isDraft ? draftSlides : (slidesByFolder[selectedId] ?? []);
70
75
  const filtered = useMemo(() => filterDecks(visible, query, titleMap), [visible, query, titleMap]);
76
+ const presentOccasions = useMemo(
77
+ () => OCCASIONS.filter((entry) => visible.some((id) => times[id]?.occasion === entry.id)),
78
+ [visible, times],
79
+ );
80
+ const shown = useMemo(
81
+ () => (occasion ? filtered.filter((id) => times[id]?.occasion === occasion) : filtered),
82
+ [filtered, occasion, times],
83
+ );
71
84
  const sorted = useMemo(
72
- () => sortDecks(filtered, sortKey, (id) => titleMap[id] ?? id, slideCreatedAt),
73
- [filtered, sortKey, titleMap],
85
+ () => sortDecks(shown, sortKey, (id) => titleMap[id] ?? id, slideCreatedAt),
86
+ [shown, sortKey, titleMap],
74
87
  );
75
88
  const searching = query.trim().length > 0;
89
+ const narrowing = searching || occasion !== null;
76
90
  const showLoading = useDelayed(loading);
77
91
  const titleOf = (id: string) => titleMap[id] ?? id;
92
+ const templateNameOf = (id: string): string | null => {
93
+ const templateId = times[id]?.template;
94
+ if (!templateId) return null;
95
+ return library?.templates.find((entry) => entry.id === templateId)?.name ?? null;
96
+ };
78
97
 
79
98
  const greeting = {
80
99
  morning: lr.home.greetingMorning,
@@ -130,8 +149,8 @@ export function LemonRiverHome() {
130
149
  <FolderSwitcher ctx={ctx} />
131
150
  {!loading && (
132
151
  <span className="folio ml-0.5">
133
- {pad2(searching ? filtered.length : visible.length)}
134
- {searching && <span className="opacity-40">/{pad2(visible.length)}</span>}
152
+ {pad2(narrowing ? shown.length : visible.length)}
153
+ {narrowing && <span className="opacity-40">/{pad2(visible.length)}</span>}
135
154
  </span>
136
155
  )}
137
156
  <div className="ml-auto flex w-full items-center gap-2 md:w-auto">
@@ -140,18 +159,47 @@ export function LemonRiverHome() {
140
159
  </div>
141
160
  </div>
142
161
 
162
+ {!loading && library?.available === true && presentOccasions.length > 0 && (
163
+ <div
164
+ role="radiogroup"
165
+ aria-label={lr.templates.occasions}
166
+ data-lr-occasion-filter
167
+ className="mb-4 flex flex-wrap items-center gap-2"
168
+ >
169
+ <FilterPill
170
+ label={lr.templates.all}
171
+ active={occasion === null}
172
+ onSelect={() => setOccasion(null)}
173
+ />
174
+ {presentOccasions.map((entry) => (
175
+ <FilterPill
176
+ key={entry.id}
177
+ label={entry.name}
178
+ active={occasion === entry.id}
179
+ onSelect={() => setOccasion(entry.id)}
180
+ />
181
+ ))}
182
+ </div>
183
+ )}
184
+
143
185
  {loading ? (
144
186
  showLoading ? (
145
187
  <GridSkeleton />
146
188
  ) : null
147
189
  ) : visible.length === 0 ? (
148
190
  <EmptyHome isDraft={isAll || isDraft} folderName={folder?.name} />
149
- ) : filtered.length === 0 ? (
191
+ ) : shown.length === 0 ? (
150
192
  <LemonEmpty
151
193
  state="thinking"
152
194
  title={t.home.noMatches}
153
195
  actions={
154
- <Button variant="outline" onClick={() => setQuery('')}>
196
+ <Button
197
+ variant="outline"
198
+ onClick={() => {
199
+ setQuery('');
200
+ setOccasion(null);
201
+ }}
202
+ >
155
203
  {t.home.clearSearch}
156
204
  </Button>
157
205
  }
@@ -174,6 +222,7 @@ export function LemonRiverHome() {
174
222
  now={now}
175
223
  modifiedAt={times[id]?.modifiedAt}
176
224
  editing={editing.has(id)}
225
+ templateName={templateNameOf(id)}
177
226
  onTitleResolved={ctx.reportTitle}
178
227
  actions={{
179
228
  onRename: () => setDialog({ kind: 'rename', id }),
@@ -1,6 +1,9 @@
1
1
  import { useEffect, useState } from 'react';
2
2
 
3
- export type DeckTimes = Record<string, { modifiedAt: number }>;
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
  }