@hanzo/build 0.2.126 → 0.2.128

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 (59) hide show
  1. package/lib/api/machines.d.ts +8 -0
  2. package/lib/api/machines.js +16 -5
  3. package/lib/api/places.d.ts +12 -4
  4. package/lib/api/places.js +11 -3
  5. package/lib/automations.js +74 -35
  6. package/lib/awake.d.ts +24 -0
  7. package/lib/awake.js +68 -0
  8. package/lib/clipboard.d.ts +2 -0
  9. package/lib/clipboard.js +10 -0
  10. package/lib/customize/agents.js +149 -31
  11. package/lib/customize/connectors.js +91 -34
  12. package/lib/customize/drafted.js +23 -10
  13. package/lib/customize/index.js +40 -10
  14. package/lib/customize/inventory.d.ts +4 -1
  15. package/lib/customize/inventory.js +66 -17
  16. package/lib/customize/plugins.js +43 -15
  17. package/lib/customize/skills.js +87 -23
  18. package/lib/customize/ui.d.ts +29 -3
  19. package/lib/customize/ui.js +89 -12
  20. package/lib/desk.d.ts +1 -1
  21. package/lib/desk.js +67 -40
  22. package/lib/dev-mode.d.ts +22 -0
  23. package/lib/dev-mode.js +80 -0
  24. package/lib/environment.js +4 -4
  25. package/lib/forge.js +97 -24
  26. package/lib/handoff.d.ts +8 -0
  27. package/lib/handoff.js +22 -0
  28. package/lib/index.d.ts +1 -0
  29. package/lib/index.js +1 -0
  30. package/lib/landing.js +100 -25
  31. package/lib/library.js +108 -39
  32. package/lib/make.js +3 -2
  33. package/lib/mind.d.ts +9 -29
  34. package/lib/mind.js +43 -4
  35. package/lib/pane.d.ts +13 -0
  36. package/lib/pane.js +4 -0
  37. package/lib/panel.d.ts +4 -0
  38. package/lib/panel.js +49 -46
  39. package/lib/plans.js +36 -15
  40. package/lib/project.js +72 -63
  41. package/lib/reply.d.ts +6 -1
  42. package/lib/reply.js +19 -9
  43. package/lib/run.js +23 -41
  44. package/lib/scheduled.js +36 -16
  45. package/lib/settings/account.js +2 -1
  46. package/lib/settings/billing.js +9 -4
  47. package/lib/settings/credits.d.ts +2 -1
  48. package/lib/settings/credits.js +2 -2
  49. package/lib/settings/machines.js +41 -18
  50. package/lib/settings/notifications.js +2 -1
  51. package/lib/shelf.d.ts +4 -1
  52. package/lib/shelf.js +79 -14
  53. package/lib/suggest.d.ts +6 -0
  54. package/lib/suggest.js +7 -1
  55. package/lib/suggestions.js +2 -1
  56. package/lib/summary.js +3 -2
  57. package/lib/sync.js +3 -3
  58. package/lib/transcript.js +13 -6
  59. package/package.json +11 -1
package/lib/landing.js CHANGED
@@ -22,8 +22,8 @@ import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-run
22
22
  import { SizableText, useMedia, XStack, YStack } from '@hanzo/gui';
23
23
  import { phrase } from '@hanzo/i18n';
24
24
  import { useI18n } from '@hanzo/i18n/react';
25
- import { CircleDot, Cloud, Code, GitBranch, LayoutTemplate, Link2, Monitor, Play } from '@hanzogui/lucide-icons-2';
26
- import { Button } from '@hanzo/ui';
25
+ import { CircleDot, Cloud, Code, FolderGit2, GitBranch, LayoutTemplate, Link2, Monitor, Play } from '@hanzogui/lucide-icons-2';
26
+ import { Button, Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from '@hanzo/ui';
27
27
  import { Composer, MEASURE } from '@hanzo/ui/chat';
28
28
  import { BranchSelect, ChipSelect, FooterLink, RepoSelect } from '@hanzo/ui/product';
29
29
  import { useLimits } from '@hanzo/ui/product/useLimits';
@@ -37,10 +37,12 @@ import { plain, read, SETUP, unset } from './api/environment.js';
37
37
  import { homes as readHomes } from './api/work.js';
38
38
  import { SetupDialog } from './environment.js';
39
39
  import { limits as readLimits } from './api/models.js';
40
- import { ready, SANDBOX } from './api/places.js';
40
+ import { displayPlace, ready, SANDBOX } from './api/places.js';
41
41
  import { Address } from './ask.js';
42
42
  import { asHub, gone, isForge, isHub, settle } from './choice.js';
43
43
  import { useCached, useKept, usePlaces, useRead } from './data.js';
44
+ import { useDevMode } from './dev-mode.js';
45
+ import { takeHandoff } from './handoff.js';
44
46
  import { useHost, useTarget } from './host.js';
45
47
  import { level, pacing, useMind } from './mind.js';
46
48
  import { usePrefs } from './prefs.js';
@@ -95,6 +97,7 @@ export function Landing({ onStarted }) {
95
97
  const media = useMedia();
96
98
  const wide = Boolean(media.md);
97
99
  const signed = Boolean(host.person);
100
+ const [devMode] = useDevMode();
98
101
  const { prefs, save: savePrefs } = usePrefs();
99
102
  const [stored, keep] = useKept(`hanzo.build.new.${host.org ?? 'none'}`, null);
100
103
  // What was chosen here, over the person's coding defaults (Settings → Code), over
@@ -125,6 +128,12 @@ export function Landing({ onStarted }) {
125
128
  useEffect(() => {
126
129
  if (kept.ask || kept.issue)
127
130
  set({ ask: '', issue: 0 });
131
+ // Chat's "Open in Dev" leaves its prompt and code here (handoff.ts).
132
+ const handed = takeHandoff(window.sessionStorage);
133
+ if (handed) {
134
+ setDraft(handed);
135
+ setNote(t('Imported from Chat — ready to run in Dev.'));
136
+ }
128
137
  // The handover is read on this mount only.
129
138
  // eslint-disable-next-line react-hooks/exhaustive-deps
130
139
  }, []);
@@ -378,21 +387,39 @@ export function Landing({ onStarted }) {
378
387
  setNote('');
379
388
  set({ repo: row, branch: row.default_branch });
380
389
  };
381
- // Cloud is the sandbox, set up by the chosen codebase's environment; the rest are the org's machines.
382
- const placeItems = useMemo(() => (places.value.length ? places.value : [SANDBOX]).map((p) => ({
383
- id: p.id || 'sandbox',
384
- label: p.id ? p.label : t('Cloud'),
385
- hint: p.id ? [p.status, p.capacity].filter(Boolean).join(' · ') : '',
386
- icon: p.id ? _jsx(Monitor, { size: 13, color: "$soft" }) : _jsx(Cloud, { size: 13, color: "$soft" }),
387
- disabled: !ready(p),
388
- place: p,
389
- })), [places.value, t]);
390
+ // Cloud is the managed workspace, set up by the chosen project's environment; the rest are the org's machines.
391
+ const placeItems = useMemo(() => (places.value.length ? places.value : [SANDBOX]).map((p) => {
392
+ const display = displayPlace(p, { devMode, say: t });
393
+ return {
394
+ id: p.id || 'sandbox',
395
+ label: display.title,
396
+ hint: p.id
397
+ ? devMode
398
+ ? [p.status, p.capacity].filter(Boolean).join(' · ')
399
+ : p.status === 'online'
400
+ ? t('Online')
401
+ : p.status
402
+ : devMode
403
+ ? ''
404
+ : t('Cloud workspace'),
405
+ detail: display.detail,
406
+ icon: p.id ? _jsx(Monitor, { size: 13, color: "$soft" }) : _jsx(Cloud, { size: 13, color: "$soft" }),
407
+ disabled: !ready(p),
408
+ place: p,
409
+ };
410
+ }), [places.value, devMode, t]);
411
+ const activePlaceDisplay = useMemo(() => displayPlace(place, { devMode, say: t }), [place, devMode, t]);
412
+ const placeTooltip = place.id
413
+ ? t('Runs locally in your Hanzo folder')
414
+ : t('Runs automatically in your Hanzo cloud workspace');
415
+ const placeHardwareHint = place.id && !devMode ? activePlaceDisplay.detail : undefined;
390
416
  const branch = kept.branch || kept.repo?.default_branch || 'main';
391
417
  const forge = isForge(kept.repo);
418
+ const hasRepo = Boolean(isForge(kept.repo) || isHub(kept.repo));
392
419
  const screen = (to) => () => host.go(path({ kind: 'screen', screen: to }));
393
420
  // The composer's pills: where the run goes, which repository, which branch.
394
- const pills = (_jsxs(_Fragment, { children: [_jsx(ChipSelect, { name: t('Where the run runs'), icon: place.id ? _jsx(Monitor, { size: 13, color: "$soft" }) : _jsx(Cloud, { size: 13, color: "$soft" }), label: place.id ? place.label : t('Cloud'), chosen: placeItems.find((i) => i.place.id === place.id), items: placeItems, onChange: (i) => set({ place: i.place.id }), placeholder: t('Search machines…'), placement: "top-start", loading: places.loading, error: places.error?.message ?? null, footer: _jsx(FooterLink, { label: t('Manage…'), onPress: () => host.go(path({ kind: 'settings', section: 'machines' })) }) }), _jsx(RepoSelect, { open: picking, onOpenChange: setPicking, value: isForge(kept.repo) ? { ...kept.repo, source: 'forge' } : isHub(kept.repo) ? { ...kept.repo, source: 'github' } : null, onChange: (r) => {
395
- const hub = r.github ? hubs.current.get((r.full_name ?? "").toLowerCase()) : undefined;
421
+ const pills = (_jsxs(_Fragment, { children: [_jsx(TooltipProvider, { delay: 150, children: _jsxs(Tooltip, { placement: "top", offset: 6, children: [_jsx(TooltipTrigger, { asChild: true, children: _jsx(XStack, { items: "center", minW: 0, maxW: "100%", children: _jsx(ChipSelect, { name: t('Where the run runs'), icon: place.id ? _jsx(Monitor, { size: 13, color: "$soft" }) : _jsx(Cloud, { size: 13, color: "$soft" }), label: activePlaceDisplay.title, chosen: placeItems.find((i) => i.place.id === place.id), items: placeItems, onChange: (i) => set({ place: i.place.id }), placeholder: devMode ? t('Search machines…') : t('Search devices…'), placement: "top-start", loading: places.loading, error: places.error?.message ?? null, footer: _jsx(FooterLink, { label: t('Manage…'), onPress: () => host.go(path({ kind: 'settings', section: 'machines' })) }) }) }) }), _jsx(TooltipContent, { maxW: 280, px: "$3", py: "$2", z: "var(--z-popover)", children: _jsxs(YStack, { gap: "$0.5", children: [_jsx(SizableText, { fontFamily: "$body", size: "$1", color: "$ink", children: placeTooltip }), placeHardwareHint ? (_jsx(SizableText, { fontFamily: "$body", size: "$1", color: "$soft", children: placeHardwareHint })) : null] }) })] }) }), _jsx(RepoSelect, { open: picking, onOpenChange: setPicking, value: isForge(kept.repo) ? { ...kept.repo, source: 'forge' } : isHub(kept.repo) ? { ...kept.repo, source: 'github' } : null, onChange: (r) => {
422
+ const hub = r.github ? hubs.current.get((r.full_name ?? '').toLowerCase()) : undefined;
396
423
  setIssue(0);
397
424
  if (hub) {
398
425
  set({ repo: hub, branch: hub.default_branch });
@@ -400,11 +427,14 @@ export function Landing({ onStarted }) {
400
427
  }
401
428
  const row = known.current.get(r.name) ?? chosen(r);
402
429
  set({ repo: row, branch: row.default_branch });
403
- }, load: loadRepos, tabs: [
430
+ }, load: loadRepos, connect: hasRepo ? (_jsx(FooterLink, { label: t('Work without a repository'), onPress: () => {
431
+ drop();
432
+ setPicking(false);
433
+ } })) : undefined, tabs: [
404
434
  { id: 'all', label: t('All') },
405
435
  { id: 'forge', label: t('Organization') },
406
436
  { id: 'github', label: 'GitHub' },
407
- ], troubleshoot: { label: t('Bring a repository from GitHub'), onPress: screen('sync') }, action: {
437
+ ], troubleshoot: { label: t('Link GitHub project…'), onPress: screen('sync') }, action: {
408
438
  label: t('Add to project'),
409
439
  onPress: (r) => {
410
440
  const row = known.current.get(r.name);
@@ -415,37 +445,82 @@ export function Landing({ onStarted }) {
415
445
  name: r.name,
416
446
  });
417
447
  },
418
- }, placeholder: t('Repository'), placement: "top-start", disabled: !signed }), forge ? _jsx(BranchSelect, { open: branching, onOpenChange: setBranching, value: branch, onChange: (b) => set({ branch: b }), load: loadBranches, placement: "top-start" }) : null] }));
448
+ }, placeholder: t('Repository'), placement: "top-start", disabled: !signed }), forge ? (_jsx(BranchSelect, { open: branching, onOpenChange: setBranching, value: branch, onChange: (b) => set({ branch: b }), load: loadBranches, placement: "top-start" })) : null] }));
419
449
  const commands = [
420
450
  { id: 'run', label: t('Run'), keys: 'Ctrl+↵', icon: _jsx(Play, { size: 14, color: "$soft" }), disabled: !draft.trim(), run: () => void send() },
451
+ { id: 'pick-repo', label: t('Link GitHub project…'), icon: _jsx(FolderGit2, { size: 14, color: "$soft" }), run: () => setPicking(true) },
421
452
  { id: 'issues', label: t('View issues'), icon: _jsx(CircleDot, { size: 14, color: "$soft" }), run: screen('issues') },
422
453
  { id: 'templates', label: t('Browse templates'), icon: _jsx(LayoutTemplate, { size: 14, color: "$soft" }), run: screen('templates') },
423
454
  { id: 'projects', label: t('Open projects'), icon: _jsx(Code, { size: 14, color: "$soft" }), run: screen('projects') },
424
- { id: 'sync', label: t('Bring a repository from GitHub'), icon: _jsx(GitBranch, { size: 14, color: "$soft" }), run: screen('sync') },
455
+ { id: 'sync', label: t('Connect GitHub…'), icon: _jsx(GitBranch, { size: 14, color: "$soft" }), run: screen('sync') },
425
456
  { id: 'address', label: t('Use a git URL'), icon: _jsx(Link2, { size: 14, color: "$soft" }), run: () => setGiving(true) },
426
457
  ];
458
+ // The `+` menu's Connectors shelf gives power users 1-click access to attach a GitHub project even when the composer bar is kept clean.
459
+ const connectors = {
460
+ rows: homes.value.homes.slice(0, 12).map((h) => ({
461
+ id: h.name,
462
+ label: h.label,
463
+ note: h.branch,
464
+ icon: _jsx(FolderGit2, { size: 16 }),
465
+ on: codebase !== '' && codebase.toLowerCase() === h.name.toLowerCase(),
466
+ })),
467
+ pick: (id) => {
468
+ if (codebase && codebase.toLowerCase() === id.toLowerCase()) {
469
+ drop();
470
+ return;
471
+ }
472
+ const match = homes.value.homes.find((h) => h.name === id);
473
+ if (match)
474
+ choose(match);
475
+ },
476
+ loading: homes.loading,
477
+ empty: t('Start any prompt directly, or link a GitHub project'),
478
+ create: { label: t('Link GitHub project…'), onPress: () => setPicking(true) },
479
+ browse: { label: t('Connect GitHub…'), onPress: screen('sync') },
480
+ manage: { label: t('Open projects'), onPress: screen('projects') },
481
+ };
482
+ // Dev takes text files, so Sketch's image drawings stay off its `+` and `@` shelves.
483
+ const devPlugins = {
484
+ ...carry.plugins,
485
+ rows: carry.plugins.rows.filter((r) => r.id !== 'sketch'),
486
+ pick: (id) => {
487
+ if (id !== 'sketch')
488
+ carry.plugins.pick(id);
489
+ },
490
+ };
427
491
  // The machines a run can go to, as the `+` menu's Devices: the same choice as the pill's.
428
492
  const devices = {
429
- rows: placeItems.map((i) => ({ id: i.place.id || 'sandbox', label: i.label, note: i.hint, icon: _jsx(Monitor, { size: 16 }), on: i.place.id === place.id })),
493
+ rows: placeItems.map((i) => ({
494
+ id: i.place.id || 'sandbox',
495
+ label: i.label,
496
+ note: i.hint,
497
+ icon: i.place.id ? _jsx(Monitor, { size: 16 }) : _jsx(Cloud, { size: 16 }),
498
+ on: i.place.id === place.id,
499
+ })),
430
500
  pick: (id) => set({ place: id === 'sandbox' ? '' : id }),
431
501
  loading: places.loading,
432
502
  error: places.error?.message ?? null,
503
+ create: { label: t('Link GitHub project…'), onPress: () => setPicking(true) },
504
+ manage: { label: t('Manage devices…'), onPress: () => host.go(path({ kind: 'settings', section: 'machines' })) },
433
505
  };
434
- return (_jsxs(XStack, { flex: 1, width: "100%", height: "100%", minW: 0, minH: 0, overflow: "hidden", children: [_jsxs(YStack, { flex: 1, minW: 0, minH: 0, height: "100%", overflow: "hidden", children: [_jsxs(XStack, { "data-slot": "conversation-head", shrink: 0, items: "center", justify: "space-between", gap: "$2", px: "$3", height: 36, "$max-md": { display: 'none' }, children: [_jsx(XStack, { items: "center", gap: "$2", minW: 0, flex: 1 }), _jsx(XStack, { "data-slot": "conversation-controls", items: "center", gap: "$1", shrink: 0, children: wide ? _jsx(PanelToggle, { open: desk, onToggle: () => setDesk((d) => !d) }) : null })] }), _jsxs(YStack, { display: "grid", gridTemplateRows: wide ? '1fr auto auto 1fr' : 'minmax(0, 1fr) auto', items: "center", "$platform-web": { justifyItems: 'center' }, width: "100%", flex: 1, minH: 0, overflowX: "hidden", "data-slot": "new", children: [wide ? _jsx(YStack, {}) : null, _jsx(YStack, { display: "grid",
506
+ return (_jsxs(XStack, { flex: 1, width: "100%", height: "100%", minW: 0, minH: 0, overflow: "hidden", children: [_jsxs(YStack, { flex: 1, minW: 0, minH: 0, height: "100%", overflow: "hidden", children: [_jsxs(XStack, { "data-slot": "conversation-head", shrink: 0, items: "center", justify: "space-between", gap: "$2", px: "$3", height: 36, "$max-md": { display: 'none' }, children: [_jsx(XStack, { items: "center", gap: "$2", minW: 0, flex: 1 }), _jsx(XStack, { "data-slot": "conversation-controls", items: "center", gap: "$1", shrink: 0, children: wide ? _jsx(PanelToggle, { open: desk, onToggle: () => setDesk((d) => !d) }) : null })] }), _jsxs(YStack, { display: "grid",
507
+ // Optical center (~43% down viewport on desktop) instead of geometric 50% + top bar offset.
508
+ gridTemplateRows: wide ? 'minmax(24px, 0.76fr) auto auto minmax(48px, 1.24fr)' : 'minmax(0, 1fr) auto', items: "center", "$platform-web": { justifyItems: 'center' }, width: "100%", flex: 1, minH: 0, overflowX: "hidden", "data-slot": "new", children: [wide ? _jsx(YStack, {}) : null, _jsx(YStack, { display: "grid",
435
509
  // One track, its question set at the track's foot, just above the composer: a
436
510
  // second `auto` track left the question alone in the first, at the pane's top.
437
- gridTemplateRows: "minmax(0, 1fr)", items: "flex-end", width: "100%", maxW: MEASURE, height: wide ? undefined : '100%', pb: wide ? '$5' : '$3', overflowY: "auto", children: _jsx(SizableText, { render: "h1", fontSize: "$7", lineHeight: "$7", fontWeight: "700", color: "$ink", style: { textAlign: 'center' }, children: t('Build what’s next.') }) }), _jsx(YStack, { width: "100%", maxW: MEASURE, gap: "$2", pb: 12, children: _jsxs(YStack, { gap: "$2", children: [env.value && (env.value.state === 'proposed' || unset(env.value)) && !place.id ? (_jsxs(XStack, { items: "center", justify: "space-between", gap: "$3", px: "$3", py: "$2", rounded: "$10", borderWidth: 1, borderColor: "$borderColor", children: [_jsx(SizableText, { size: "$2", color: "$ink", flex: 1, minW: 0, children: env.value.state === 'proposed'
511
+ gridTemplateRows: "minmax(0, 1fr)", items: "flex-end", width: "100%", maxW: MEASURE, height: wide ? undefined : '100%', px: "$4", pb: "$5", overflowY: "auto", children: _jsx(SizableText, { render: "h1", fontFamily: "$heading", fontSize: "$7", lineHeight: "$7", fontWeight: "600", letterSpacing: '-0.025em', color: "$ink", text: "center", children: t('Build what’s next.') }) }), _jsx(YStack, { width: "100%", maxW: MEASURE, gap: "$2", pb: "$3", children: _jsxs(YStack, { gap: "$2", children: [env.value && (env.value.state === 'proposed' || unset(env.value)) && !place.id ? (_jsxs(XStack, { items: "center", justify: "space-between", gap: "$3", rowGap: "$2", mx: "$3", px: "$3", py: "$2", flexWrap: "wrap", children: [_jsx(SizableText, { size: "$2", color: "$ink", flex: 1, minW: 180, children: env.value.state === 'proposed'
438
512
  ? t('A proposed environment for {repo} is waiting for review.', { repo: codebase })
439
- : t('{repo} has no environment yet, so every run starts it bare.', { repo: codebase }) }), env.value.state === 'proposed' && env.value.session ? (_jsx(Button, { size: "sm", variant: "outline", onPress: () => host.go(env.value.session), children: t('Review') })) : (_jsx(Button, { size: "sm", onPress: () => setOffering(true), children: t('Set up environment') }))] })) : null, note || unhonoured(mode, place.id, t) || mind.note ? (_jsx(SizableText, { size: "$1", color: "$soft", role: "status", children: note || unhonoured(mode, place.id, t) || mind.note })) : null, _jsx(Composer, { column: true, value: draft, onChange: setDraft, onSend: () => void send(), busy: busy, placeholder: t('Ask, build, or run anything…'), label: t('Describe a task or ask a question'), plus: {
513
+ : t('{repo} has no environment yet, so every run starts it bare.', { repo: codebase }) }), env.value.state === 'proposed' && env.value.session ? (_jsx(Button, { size: "sm", variant: "outline", borderColor: "var(--border-strong)", onPress: () => host.go(env.value.session), children: t('Review') })) : (_jsx(Button, { size: "sm", variant: "primary", onPress: () => setOffering(true), children: t('Set up environment') }))] })) : null, note || unhonoured(mode, place.id, t) || mind.note ? (_jsx(SizableText, { size: "$1", color: "$soft", role: "status", px: "$3", children: note || unhonoured(mode, place.id, t) || mind.note })) : null, _jsx(Composer, { column: true, value: draft, onChange: setDraft, onSend: () => void send(), busy: busy, placeholder: t('Ask, build, or run anything…'), label: t('Describe a task or ask a question'), plus: {
440
514
  upload: () => pick(files, setFiles, setNote, t),
441
515
  research: { on: carry.gear.gear.research, set: (on) => carry.gear.set({ research: on }) },
442
516
  skills: carry.skills,
517
+ connectors,
443
518
  design: carry.design,
444
- plugins: carry.plugins,
519
+ plugins: devPlugins,
445
520
  devices,
446
521
  memory: { on: carry.gear.gear.memory, set: (on) => carry.gear.set({ memory: on }) },
447
- }, carried: [...carry.on, ...carrying(files, setFiles)], slash: carry.skills, at: carry.plugins, pills: pills, commands: commands, mode: carry.mode, mind: mind, effort: pacing(mind), limits: limits, onUpgrade: () => host.go(path({ kind: 'screen', screen: 'plans' })), voice: voice, language: prefs.language ?? null, onLanguage: (id) => void savePrefs({ language: id }), talk: talk })] }) }), wide ? _jsx(YStack, {}) : null, _jsx(Publish, { source: adding, onClose: () => setAdding(null) }), _jsx(Address, { open: giving, onOpenChange: setGiving, title: t('Use a git URL'), says: t('Runs work on the GitHub repository at this address until you choose another. A private one needs GitHub connected.'), act: t('Use'), address: "", run: async (at) => give(at) }), carry.dialog, codebase ? (_jsx(SetupDialog, { repo: codebase, homes: homes, open: offering, onOpenChange: setOffering, onStart: setup, onRepo: choose, onSaved: () => {
522
+ }, carried: [...carry.on, ...carrying(files, setFiles)], slash: carry.skills, at: devPlugins, pills: pills, commands: commands, mode: carry.mode, mind: mind, effort: pacing(mind), limits: limits, onUpgrade: () => host.go(path({ kind: 'screen', screen: 'plans' })), voice: voice, language: prefs.language ?? null, onLanguage: (id) => void savePrefs({ language: id }), talk: talk })] }) }), wide ? _jsx(YStack, {}) : null, _jsx(Publish, { source: adding, onClose: () => setAdding(null) }), _jsx(Address, { open: giving, onOpenChange: setGiving, title: t('Use a git URL'), says: t('Runs work on the GitHub repository at this address until you choose another. A private one needs GitHub connected.'), act: t('Use'), address: "", run: async (at) => give(at) }), carry.dialog, codebase ? (_jsx(SetupDialog, { repo: codebase, homes: homes, open: offering, onOpenChange: setOffering, onStart: setup, onRepo: choose, onSaved: () => {
448
523
  setOffering(false);
449
524
  env.reload();
450
- } })) : null] })] }), desk && wide ? (_jsx(YStack, { width: 440, shrink: 0, height: "100%", borderLeftWidth: 1, borderColor: "$borderColor", bg: "$background", minW: 0, minH: 0, overflow: "hidden", children: _jsx(Panel, { side: deck, kinds: [], onHide: () => setDesk(false), label: t('Tabs') }) })) : null] }));
525
+ } })) : null] })] }), desk && wide ? (_jsx(YStack, { width: 440, "$max-lg": { width: 340 }, maxW: "50%", shrink: 0, height: "100%", borderLeftWidth: 1, borderColor: "$borderColor", bg: "$background", minW: 0, minH: 0, overflow: "hidden", children: _jsx(Panel, { side: deck, kinds: [], onHide: () => setDesk(false), label: t('Tabs') }) })) : null] }));
451
526
  }
package/lib/library.js CHANGED
@@ -17,23 +17,24 @@ import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-run
17
17
  * colleague's, a project's and what an item holds are drawn as given.
18
18
  */
19
19
  import { SizableText, useMedia, XStack, YStack } from '@hanzo/gui';
20
- import { AudioLines, Box, Code2, Copy, Download, ExternalLink, FileText, FolderInput, Image as Picture, LayoutGrid, List, MessageSquare, MoreHorizontal, Pencil, Plus, Presentation, Search, Share2, Sparkles, Trash2, Type, Video, } from '@hanzogui/lucide-icons-2';
20
+ import { AudioLines, Box, Check, Code2, Copy, Download, ExternalLink, FileText, FolderInput, Image as Picture, LayoutGrid, List, MessageSquare, MoreHorizontal, Pencil, Plus, Presentation, Search, Share2, Sparkles, Trash2, Type, Video, X, } from '@hanzogui/lucide-icons-2';
21
21
  import { phrase } from '@hanzo/i18n';
22
22
  import { useI18n } from '@hanzo/i18n/react';
23
- import { Button, Dialog, DialogContent, DialogTitle, DropdownMenu, Input } from '@hanzo/ui';
23
+ import { Button, Dialog, DialogContent, DialogTitle, DropdownMenu, Input, Skeleton, toast } from '@hanzo/ui';
24
24
  import { ChipSelect } from '@hanzo/ui/product';
25
25
  import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
26
+ import { copy as toClipboard } from './clipboard.js';
26
27
  import { ago } from './ago.js';
27
28
  import { told } from './api/call.js';
28
29
  import { change, days, get, items as list, KINDS, remove, size, SOURCE } from './api/library.js';
29
30
  import { Confirm, Rename } from './ask.js';
30
31
  import { useKept, useProjects, useRead } from './data.js';
31
32
  import { useHost, useTarget } from './host.js';
32
- import { Chip, Make } from './make.js';
33
+ import { Make } from './make.js';
33
34
  import { KEPT } from './nav.js';
34
35
  import { path, route } from './route.js';
35
36
  import { Panel } from './panel.js';
36
- import { gap, pane } from './pane.js';
37
+ import { gap, pane, RING, RING_INSET } from './pane.js';
37
38
  import { Sites } from './shelf.js';
38
39
  import { useDeck } from './tabs.js';
39
40
  /** Where an item was made: Chat, Dev and Studio by their names, the rest in words, marked (`phrase`) and drawn through `t`. */
@@ -102,12 +103,12 @@ export function Thumb({ x, size: n }) {
102
103
  const primary = still(x);
103
104
  const backup = localStill(x);
104
105
  const src = fallback && backup ? backup : primary;
105
- return (_jsx(YStack, { width: n ?? '100%', height: n, style: n ? undefined : { aspectRatio: '1 / 1' }, rounded: "$3", overflow: "hidden", bg: "$raised", items: "center", justify: "center", shrink: 0, "aria-hidden": true, children: src && !broken ? (_jsx("img", { src: src, alt: "", loading: "lazy", onError: () => {
106
- if (!fallback && backup && backup !== primary)
107
- setFallback(true);
108
- else
109
- setBroken(true);
110
- }, style: { width: '100%', height: '100%', objectFit: 'cover', display: 'block' } })) : (_jsx(YStack, { opacity: 0.7, children: glyph(x.kind, n ? Math.max(14, Math.round(n / 2.6)) : 28) })) }));
106
+ return (_jsx(YStack, { width: n ?? '100%', height: n, aspectRatio: n ? undefined : 1, rounded: "$3", overflow: "hidden", bg: "$raised", items: "center", justify: "center", shrink: 0, "aria-hidden": true, children: src && !broken ? (_jsx(YStack, { render: _jsx("img", { src: src, alt: "", loading: "lazy", onError: () => {
107
+ if (!fallback && backup && backup !== primary)
108
+ setFallback(true);
109
+ else
110
+ setBroken(true);
111
+ } }), width: "100%", height: "100%", "$platform-web": { objectFit: 'cover', display: 'block' } })) : (_jsx(YStack, { opacity: 0.7, children: glyph(x.kind, n ? Math.max(14, Math.round(n / 2.6)) : 28) })) }));
111
112
  }
112
113
  /** What a tile says under its name: where it came from, whose, and when. */
113
114
  function meta(x, t) {
@@ -167,8 +168,9 @@ function useActs(onChanged, onGone) {
167
168
  }
168
169
  };
169
170
  const copy = (text, said) => act(async () => {
170
- await navigator.clipboard.writeText(text);
171
- setNote(said);
171
+ if (!(await toClipboard(text)))
172
+ throw new Error(t('This browser would not copy.'));
173
+ toast.success(said);
172
174
  });
173
175
  const rows = (x) => [
174
176
  ...(x.origin ? [{ key: 'open', label: t('Open where it was made'), icon: _jsx(ExternalLink, { size: 16 }), onSelect: () => host.open(x.origin) }] : []),
@@ -195,16 +197,24 @@ function useActs(onChanged, onGone) {
195
197
  { key: 'move', label: t('Move to project'), icon: _jsx(FolderInput, { size: 16 }), onSelect: () => setMoving(x) },
196
198
  ]
197
199
  : []),
198
- { key: 'studio', label: t('Use in Studio'), icon: _jsx(Sparkles, { size: 16 }), onSelect: () => host.open(`/studio?asset=${encodeURIComponent(x.id)}`) },
199
- { key: 'chat', label: t('Use in Chat'), icon: _jsx(MessageSquare, { size: 16 }), onSelect: () => host.open(`/chat?attach=${encodeURIComponent(x.id)}`) },
200
- ...(x.mine ? [{ key: 'delete', label: t('Delete'), icon: _jsx(Trash2, { size: 16 }), onSelect: () => setDeleting(x) }] : []),
200
+ { key: 'studio', label: t('Use in Studio'), icon: _jsx(Sparkles, { size: 14 }), onSelect: () => host.open(`/design?asset=${encodeURIComponent(x.id)}`) },
201
+ { key: 'chat', label: t('Use in Chat'), icon: _jsx(MessageSquare, { size: 14 }), onSelect: () => host.open(`/chat?attach=${encodeURIComponent(x.id)}`) },
202
+ ...(x.mine
203
+ ? [
204
+ { type: 'separator' },
205
+ { key: 'delete', label: t('Delete'), icon: _jsx(Trash2, { size: 14 }), destructive: true, onSelect: () => setDeleting(x) },
206
+ ]
207
+ : []),
201
208
  ];
202
209
  const dialogs = (_jsxs(_Fragment, { children: [_jsx(Rename, { open: Boolean(renaming), onOpenChange: (o) => !o && setRenaming(null), title: t('Rename'), name: renaming?.name ?? '', run: async (name) => {
203
210
  const next = await change(target, renaming.id, { name });
204
211
  onChanged(next);
212
+ toast.success(t('Renamed to {name}', { name: next.name }));
205
213
  } }), _jsx(Confirm, { open: Boolean(deleting), onOpenChange: (o) => !o && setDeleting(null), title: t('Delete {name}?', { name: deleting?.name ?? '' }), says: t('It leaves the Library and its file is deleted. Anyone it was shared with loses it too.'), act: t('Delete'), run: async () => {
206
- await remove(target, deleting.id);
207
- onGone(deleting.id);
214
+ const dead = deleting;
215
+ await remove(target, dead.id);
216
+ onGone(dead.id);
217
+ toast.success(t('{name} deleted', { name: dead.name }));
208
218
  } }), _jsx(Move, { item: moving, onClose: () => setMoving(null), onMoved: (next) => {
209
219
  onChanged(next);
210
220
  setNote(next.project ? t('{name} is in {project}', { name: next.name, project: next.project }) : t('{name} is in no project', { name: next.name }));
@@ -219,6 +229,15 @@ function Move({ item: x, onClose, onMoved }) {
219
229
  const projects = useProjects(target, Boolean(host.person) && Boolean(x));
220
230
  const [busy, setBusy] = useState(false);
221
231
  const [note, setNote] = useState('');
232
+ const [q, setQ] = useState('');
233
+ useEffect(() => {
234
+ if (!x) {
235
+ setQ('');
236
+ setNote('');
237
+ }
238
+ }, [x]);
239
+ const needle = q.trim().toLowerCase();
240
+ const choices = useMemo(() => [{ slug: '', name: t('No project') }, ...projects.value].filter((p) => !needle || `${p.name} ${p.slug}`.toLowerCase().includes(needle)), [projects.value, needle, t]);
222
241
  const pick = async (project) => {
223
242
  if (!x)
224
243
  return;
@@ -235,7 +254,10 @@ function Move({ item: x, onClose, onMoved }) {
235
254
  setBusy(false);
236
255
  }
237
256
  };
238
- return (_jsx(Dialog, { open: Boolean(x), onOpenChange: (o) => !o && !busy && onClose(), children: _jsxs(DialogContent, { maxW: 420, children: [_jsx(DialogTitle, { children: t('Move to project') }), _jsx(YStack, { gap: "$1", maxH: 320, overflow: "scroll", children: projects.loading && !projects.value.length ? (_jsx(SizableText, { size: "$2", color: "$soft", children: t('Reading projects…') })) : projects.error ? (_jsx(SizableText, { size: "$2", color: "$soft", children: told(projects.error, t) })) : ([{ slug: '', name: t('No project') }, ...projects.value].map((p) => (_jsx(XStack, { render: "button", "aria-label": p.slug ? t('Move to {project}', { project: p.name || p.slug }) : t('Move to no project'), "aria-current": x?.project === p.slug ? 'true' : undefined, disabled: busy, onPress: () => void pick(p.slug), px: "$3", py: "$2", rounded: "$3", bg: x?.project === p.slug ? '$hover' : 'transparent', hoverStyle: { bg: '$hover' }, cursor: "pointer", children: _jsx(SizableText, { size: "$2", color: "$ink", children: p.name || p.slug }) }, p.slug || 'none')))) }), note ? (_jsx(SizableText, { size: "$1", color: "$soft", role: "status", children: note })) : null] }) }));
257
+ return (_jsx(Dialog, { open: Boolean(x), onOpenChange: (o) => !o && !busy && onClose(), children: _jsxs(DialogContent, { maxW: 420, showCloseButton: false, gap: "$3", children: [_jsx(DialogTitle, { children: t('Move to project') }), projects.value.length > 6 ? (_jsx(Input, { value: q, onChangeText: setQ, placeholder: t('Find a project…'), "aria-label": t('Find a project'), startAdornment: _jsx(Search, { size: 14, color: "$soft" }) })) : null, _jsx(YStack, { gap: "$1", maxH: 320, overflow: "scroll", children: projects.loading && !projects.value.length ? (_jsxs(YStack, { gap: "$2", children: [_jsx(SizableText, { size: "$2", color: "$soft", children: t('Reading projects…') }), _jsx(Skeleton, { layout: "block", height: 36, rounded: "$3" }), _jsx(Skeleton, { layout: "block", height: 36, rounded: "$3" }), _jsx(Skeleton, { layout: "block", height: 36, rounded: "$3" })] })) : projects.error ? (_jsx(SizableText, { size: "$2", color: "$soft", children: told(projects.error, t) })) : choices.length === 0 ? (_jsx(SizableText, { size: "$2", color: "$soft", py: "$2", children: t('Nothing matches.') })) : (choices.map((p) => {
258
+ const active = x?.project === p.slug;
259
+ return (_jsxs(XStack, { render: "button", "aria-label": p.slug ? t('Move to {project}', { project: p.name || p.slug }) : t('Move to no project'), "aria-current": active ? 'true' : undefined, disabled: busy, onPress: () => void pick(p.slug), px: "$3", py: "$2", minH: 38, items: "center", justify: "space-between", gap: "$2", "$platform-web": { textAlign: 'start' }, focusVisibleStyle: RING, children: [_jsx(SizableText, { size: "$2", color: "$ink", numberOfLines: 1, flex: 1, children: p.name || p.slug }), active ? _jsx(Check, { size: 14, color: "$ink" }) : null] }, p.slug || 'none'));
260
+ })) }), note ? (_jsx(SizableText, { size: "$1", color: "$soft", role: "status", children: note })) : null, _jsx(XStack, { justify: "flex-end", children: _jsx(Button, { size: "sm", variant: "ghost", disabled: busy, onPress: onClose, children: t('Cancel') }) })] }) }));
239
261
  }
240
262
  /** One item's menu, as a quiet control. */
241
263
  function Acts({ x, rows }) {
@@ -245,12 +267,12 @@ function Acts({ x, rows }) {
245
267
  /** One tile of the grid: the still, then its name and where it came from; its menu beside the name. */
246
268
  function Tile({ x, onOpen, rows }) {
247
269
  const { t } = useI18n();
248
- return (_jsxs(YStack, { role: "listitem", gap: "$2", minW: 0, children: [_jsx(YStack, { render: "button", "aria-label": t('Open {name}', { name: x.name }), onPress: onOpen, rounded: "$4", overflow: "hidden", cursor: "pointer", hoverStyle: { opacity: 0.88 }, focusVisibleStyle: { outlineWidth: 2, outlineStyle: 'solid', outlineColor: '$outlineColor' }, children: _jsx(Thumb, { x: x }) }), _jsxs(XStack, { items: "flex-start", gap: "$1", minW: 0, children: [_jsxs(YStack, { flex: 1, minW: 0, gap: "$0.5", children: [_jsx(SizableText, { size: "$2", color: "$ink", numberOfLines: 1, children: x.name }), _jsx(SizableText, { size: "$1", color: "$soft", numberOfLines: 1, children: meta(x, t) })] }), _jsx(Acts, { x: x, rows: rows })] })] }));
270
+ return (_jsxs(YStack, { role: "listitem", gap: "$2", minW: 0, children: [_jsx(YStack, { render: "button", "aria-label": t('Open {name}', { name: x.name }), onClick: onOpen, width: "100%", rounded: "$4", overflow: "hidden", cursor: "pointer", focusVisibleStyle: RING, children: _jsx(Thumb, { x: x }) }), _jsxs(XStack, { items: "flex-start", gap: "$1", minW: 0, children: [_jsxs(YStack, { flex: 1, minW: 0, gap: "$0.5", children: [_jsx(SizableText, { size: "$2", color: "$ink", numberOfLines: 1, children: x.name }), _jsx(SizableText, { size: "$1", color: "$soft", numberOfLines: 1, children: meta(x, t) })] }), _jsx(Acts, { x: x, rows: rows })] })] }));
249
271
  }
250
272
  /** One row of the list: a small still, its name, where it came from, how large, and its menu. */
251
- function Row({ x, onOpen, rows }) {
273
+ function Row({ x, first, onOpen, rows }) {
252
274
  const { t } = useI18n();
253
- return (_jsxs(XStack, { role: "listitem", items: "center", gap: "$3", px: "$2", py: "$2", rounded: "$3", hoverStyle: { bg: '$hover' }, minW: 0, children: [_jsxs(XStack, { render: "button", "aria-label": t('Open {name}', { name: x.name }), onPress: onOpen, flex: 1, minW: 0, items: "center", gap: "$3", cursor: "pointer", "$platform-web": { textAlign: 'start' }, children: [_jsx(Thumb, { x: x, size: 40 }), _jsxs(YStack, { flex: 1, minW: 0, gap: "$0.5", children: [_jsx(SizableText, { size: "$2", color: "$ink", numberOfLines: 1, children: x.name }), _jsx(SizableText, { size: "$1", color: "$soft", numberOfLines: 1, children: meta(x, t) })] }), _jsx(SizableText, { size: "$1", color: "$soft", width: 72, text: "end", "$max-md": { display: 'none' }, children: size(x.bytes) })] }), _jsx(Acts, { x: x, rows: rows })] }));
275
+ return (_jsxs(XStack, { role: "listitem", items: "center", gap: "$2", pr: "$2", borderTopWidth: first ? 0 : 1, borderColor: "$borderColor", hoverStyle: { bg: '$hover' }, minW: 0, children: [_jsxs(XStack, { render: "button", "aria-label": t('Open {name}', { name: x.name }), onPress: onOpen, flex: 1, minW: 0, minH: 44, px: "$3", py: "$2", items: "center", gap: "$3", "$platform-web": { textAlign: 'start' }, focusVisibleStyle: RING_INSET, children: [_jsx(Thumb, { x: x, size: 40 }), _jsxs(YStack, { flex: 1, minW: 0, gap: "$0.5", children: [_jsx(SizableText, { size: "$2", color: "$ink", numberOfLines: 1, children: x.name }), _jsx(SizableText, { size: "$1", color: "$soft", numberOfLines: 1, children: meta(x, t) })] }), _jsx(SizableText, { size: "$1", color: "$soft", width: 72, text: "end", fontVariant: ['tabular-nums'], "$max-md": { display: 'none' }, children: size(x.bytes) })] }), _jsx(Acts, { x: x, rows: rows })] }));
254
276
  }
255
277
  /** One item, read fresh so its signed URLs are live: the thing itself, then what it is. */
256
278
  export function Preview({ id, rows }) {
@@ -260,7 +282,13 @@ export function Preview({ id, rows }) {
260
282
  const one = useRead(host.person ? () => get(target, id) : null, null, [target, id, host.person]);
261
283
  const x = one.value;
262
284
  if (!x) {
263
- return (_jsx(SizableText, { size: "$2", color: "$soft", children: !host.person ? t('Sign in to open it.') : one.error ? told(one.error, t) : t('Reading…') }));
285
+ if (!host.person) {
286
+ return (_jsx(SizableText, { size: "$2", color: "$soft", children: t('Sign in to open it.') }));
287
+ }
288
+ if (one.error) {
289
+ return (_jsxs(YStack, { gap: "$2.5", items: "flex-start", children: [_jsx(SizableText, { size: "$2", color: "var(--state-error)", children: told(one.error, t) }), _jsx(Button, { size: "sm", variant: "outline", onPress: one.reload, children: t('Try again') })] }));
290
+ }
291
+ return (_jsxs(YStack, { gap: "$3", children: [_jsx(Skeleton, { layout: "block", width: "100%", height: 240, rounded: "$4" }), _jsxs(YStack, { gap: "$1.5", children: [_jsx(Skeleton, { layout: "block", width: "65%", height: 18, rounded: "$2" }), _jsx(Skeleton, { layout: "block", width: "45%", height: 14, rounded: "$2" })] }), _jsx(SizableText, { size: "$1", color: "$soft", children: t('Reading…') })] }));
264
292
  }
265
293
  return (_jsxs(YStack, { gap: "$3", minH: 0, children: [_jsx(Shown, { x: x }), _jsxs(XStack, { items: "flex-start", gap: "$2", children: [_jsxs(YStack, { flex: 1, minW: 0, gap: "$1", children: [_jsx(SizableText, { size: "$3", color: "$ink", children: x.name }), _jsx(SizableText, { size: "$1", color: "$soft", children: [meta(x, t), size(x.bytes), x.width && x.height ? `${x.width}×${x.height}` : '', x.project ? t('in {project}', { project: x.project }) : '', x.shared ? t('shared with the organization') : '']
266
294
  .filter(Boolean)
@@ -269,24 +297,23 @@ export function Preview({ id, rows }) {
269
297
  /** The thing itself, drawn the way its kind is read. */
270
298
  function Shown({ x }) {
271
299
  const [fallback, setFallback] = useState(false);
272
- const box = { width: '100%', maxHeight: '60vh', borderRadius: 12, display: 'block' };
273
300
  const backup = localStill(x);
274
301
  const imgSrc = fallback && backup ? backup : x.url || backup;
275
302
  if (!x.url && !backup)
276
303
  return _jsx(Thumb, { x: x });
277
304
  if (x.kind === 'image' && x.mime !== 'image/svg+xml')
278
- return (_jsx("img", { src: imgSrc, alt: x.name, onError: () => {
279
- if (!fallback && backup && backup !== x.url)
280
- setFallback(true);
281
- }, style: { ...box, objectFit: 'contain' } }));
305
+ return (_jsx(YStack, { render: _jsx("img", { src: imgSrc, alt: x.name, onError: () => {
306
+ if (!fallback && backup && backup !== x.url)
307
+ setFallback(true);
308
+ } }), width: "100%", maxH: "60vh", "$platform-web": { objectFit: 'contain', display: 'block' } }));
282
309
  if (!x.url)
283
310
  return _jsx(Thumb, { x: x });
284
311
  if (x.kind === 'video')
285
- return _jsx("video", { src: x.url, poster: x.preview || undefined, controls: true, preload: "metadata", style: box, "aria-label": x.name });
312
+ return (_jsx(YStack, { render: _jsx("video", { src: x.url, poster: x.preview || undefined, controls: true, preload: "metadata", "aria-label": x.name }), width: "100%", maxH: "60vh", "$platform-web": { display: 'block' } }));
286
313
  if (x.kind === 'audio')
287
- return _jsx("audio", { src: x.url, controls: true, preload: "metadata", style: { width: '100%' }, "aria-label": x.name });
314
+ return _jsx(YStack, { render: _jsx("audio", { src: x.url, controls: true, preload: "metadata", "aria-label": x.name }), width: "100%" });
288
315
  if (x.mime === 'application/pdf')
289
- return _jsx("iframe", { src: x.url, title: x.name, style: { ...box, height: '60vh', border: 0 } });
316
+ return (_jsx(YStack, { render: _jsx("iframe", { src: x.url, title: x.name }), width: "100%", height: "60vh", maxH: "60vh", "$platform-web": { display: 'block' } }));
290
317
  if (x.mime.startsWith('text/') || x.kind === 'code' || x.mime === 'application/json')
291
318
  return _jsx(Text, { x: x });
292
319
  return _jsx(Thumb, { x: x });
@@ -301,8 +328,8 @@ function Text({ x }) {
301
328
  return (await res.text()).slice(0, 200_000);
302
329
  }, '', [x.url]);
303
330
  if (read.error)
304
- return _jsx("iframe", { src: x.url, title: x.name, style: { width: '100%', height: '60vh', border: 0, borderRadius: 12, background: 'white' } });
305
- return (_jsx(YStack, { rounded: "$3", bg: "$raised", p: "$3", maxH: "60vh", overflow: "scroll", children: _jsx(SizableText, { size: "$1", color: "$ink", style: { whiteSpace: 'pre-wrap', fontFamily: 'var(--f-mono, ui-monospace, monospace)' }, children: read.loading && !read.value ? t('Reading…') : read.value }) }));
331
+ return (_jsx(YStack, { render: _jsx("iframe", { src: x.url, title: x.name }), width: "100%", height: "60vh", "$platform-web": { display: 'block' } }));
332
+ return (_jsx(YStack, { rounded: "$3", bg: "$raised", borderWidth: 1, borderColor: "$borderColor", p: "$3", maxH: "60vh", overflow: "scroll", children: read.loading && !read.value ? (_jsxs(YStack, { gap: "$2", children: [_jsx(Skeleton, { layout: "block", width: "90%", height: 13, rounded: "$2" }), _jsx(Skeleton, { layout: "block", width: "76%", height: 13, rounded: "$2" }), _jsx(Skeleton, { layout: "block", width: "82%", height: 13, rounded: "$2" }), _jsx(SizableText, { size: "$1", color: "$soft", children: t('Reading…') })] })) : (_jsx(SizableText, { size: "$1", color: "$ink", fontFamily: "$mono", "$platform-web": { whiteSpace: 'pre-wrap' }, children: read.value })) }));
306
333
  }
307
334
  /** A run's outputs as small tiles: each opens in the Library. */
308
335
  export function Outputs({ ids }) {
@@ -317,7 +344,7 @@ export function Outputs({ ids }) {
317
344
  return (_jsxs(XStack, { gap: "$2", flexWrap: "wrap", rowGap: "$2", pt: "$1.5", role: "list", "aria-label": t('What it made'), children: [shown.map((x) => (_jsx(XStack, { role: "listitem", children: _jsxs(XStack, { render: "button", "aria-label": t('Open {name} in the Library', { name: x.name }), onPress: () => {
318
345
  want(x.id);
319
346
  host.go('-/artifacts');
320
- }, items: "center", gap: "$2", paddingInlineEnd: "$2.5", rounded: "$3", borderWidth: 1, borderColor: "$borderColor", overflow: "hidden", hoverStyle: { bg: '$hover' }, cursor: "pointer", maxW: 240, children: [_jsx(Thumb, { x: x, size: 36 }), _jsx(SizableText, { size: "$1", color: "$ink", numberOfLines: 1, children: x.name })] }) }, x.id))), got.loading && !shown.length ? (_jsx(SizableText, { size: "$1", color: "$soft", children: ids.length === 1 ? t('Reading what it made…') : t('Reading the {n} things it made…', { n: ids.length }) })) : null] }));
347
+ }, items: "center", gap: "$2", minH: 38, paddingInlineEnd: "$2.5", rounded: "$3", borderWidth: 1, borderColor: "$borderColor", overflow: "hidden", cursor: "pointer", maxW: 240, focusVisibleStyle: RING, children: [_jsx(Thumb, { x: x, size: 36 }), _jsx(SizableText, { size: "$1", color: "$ink", numberOfLines: 1, children: x.name })] }) }, x.id))), got.loading && !shown.length ? (_jsx(SizableText, { size: "$1", color: "$soft", children: ids.length === 1 ? t('Reading what it made…') : t('Reading the {n} things it made…', { n: ids.length }) })) : null] }));
321
348
  }
322
349
  /** A list read page by page: the first on every change of filter, the next on reaching its end. */
323
350
  function usePages(load, key) {
@@ -386,18 +413,21 @@ export function Library() {
386
413
  const host = useHost();
387
414
  const target = useTarget();
388
415
  const signed = Boolean(host.person);
389
- const wide = useMedia().md;
416
+ const media = useMedia();
417
+ const wide = media.md;
418
+ const desktop = Boolean(media.sm);
390
419
  // The kind is the address's (-/artifacts/<kind>), so the sidebar, a link and Back all name it.
391
420
  const at = route(host.path);
392
421
  const sitesOnly = at.kind === 'screen' && at.of === 'sites';
393
422
  const making = at.kind === 'screen' && at.of === 'new';
394
423
  const kind = at.kind === 'screen' && at.of && at.of !== 'sites' && at.of !== 'new' ? at.of : '';
395
424
  const setKind = (k) => host.go(path({ kind: 'screen', screen: 'artifacts', ...(k ? { of: k } : {}) }));
396
- const make = (_jsxs(Button, { size: "sm", onPress: () => setKind('new'), children: [_jsx(Plus, { size: 14 }), t('Make something new')] }));
397
425
  const [source, setSource] = useState('');
398
426
  const [scope, setScope] = useState('all');
399
427
  const [typed, setTyped] = useState('');
400
428
  const [q, setQ] = useState('');
429
+ const [siteMatches, setSiteMatches] = useState(0);
430
+ const [moreKinds, setMoreKinds] = useState(false);
401
431
  const [view, setView] = useKept('hanzo.build.library.view', 'grid');
402
432
  // One org's items are not another's: each org's open tabs are kept apart.
403
433
  const side = useDeck(`${DECK}.${host.org ?? ''}`, { tabs: [], at: null });
@@ -444,14 +474,53 @@ export function Library() {
444
474
  const open = shown && side.tabs.length > 0;
445
475
  const groups = days(pages.rows);
446
476
  const narrowed = Boolean(kind || source || q || scope !== 'all');
477
+ const showSites = !sitesOnly && signed && !kind && (source === '' || source === 'dev') && scope !== 'shared';
478
+ useEffect(() => {
479
+ if (!showSites)
480
+ setSiteMatches(0);
481
+ }, [showSites]);
482
+ const emptyUnfiltered = signed && !sitesOnly && !pages.loading && !pages.error && !pages.rows.length && !narrowed;
483
+ const clearFilters = () => {
484
+ setTyped('');
485
+ setQ('');
486
+ setSource('');
487
+ setScope('all');
488
+ if (kind || sitesOnly)
489
+ setKind('');
490
+ };
491
+ const make = (primary) => (_jsxs(Button, { size: "sm", variant: primary ? 'primary' : 'outline', shrink: 0, onPress: () => setKind('new'), children: [_jsx(Plus, { size: 14 }), t('Make something new')] }));
447
492
  // The choices in the reader's words; Chat, Dev and Studio stay their names.
448
493
  const from = FROM.map((f) => ({ ...f, label: t(f.label) }));
449
494
  const whose = WHOSE.map((w) => ({ ...w, label: t(w.label) }));
450
- return (_jsxs(XStack, { flex: 1, minH: 0, minW: 0, width: "100%", children: [_jsx(YStack, { flex: 1, minH: 0, minW: 0, overflow: "scroll", px: "$6", py: "$6", "$max-md": { px: '$4', py: '$4' }, children: _jsxs(YStack, { width: "100%", maxW: 1120, mx: "auto", gap: "$4", children: [_jsxs(XStack, { items: "center", gap: "$3", children: [_jsx(SizableText, { render: "h1", size: "$7", fontWeight: "600", color: "$ink", flex: 1, children: sitesOnly ? t('Sites') : KINDS.find((k) => k.id === kind)?.id ? t(KINDS.find((k) => k.id === kind).label) : t('Library') }), host.sections ? null : make, sitesOnly ? null : (_jsxs(XStack, { role: "radiogroup", "aria-label": t('View'), gap: "$1", children: [_jsx(ViewMark, { label: t('Grid'), on: view === 'grid', onPress: () => setView('grid'), children: _jsx(LayoutGrid, { size: 16 }) }), _jsx(ViewMark, { label: t('List'), on: view === 'list', onPress: () => setView('list'), children: _jsx(List, { size: 16 }) })] }))] }), sitesOnly ? null : (_jsxs(XStack, { items: "center", gap: "$2", maxW: 480, children: [_jsx(Search, { size: 16, opacity: 0.6 }), _jsx(YStack, { flex: 1, minW: 0, children: _jsx(Input, { value: typed, onChangeText: setTyped, placeholder: t('Search your library'), "aria-label": t('Search your library'), disabled: !signed }) })] })), _jsxs(YStack, { gap: "$2", children: [host.sections ? null : (_jsxs(XStack, { role: "radiogroup", "aria-label": t('Kind'), gap: "$2", overflowX: "auto", pb: "$1", "$platform-web": { scrollbarWidth: 'none' }, children: [KINDS.map((k) => (_jsx(Chip, { label: t(k.label), on: !sitesOnly && kind === k.id, onPress: () => setKind(k.id) }, k.id || 'all'))), _jsx(Chip, { label: t('Sites'), on: sitesOnly, onPress: () => setKind('sites') }, "sites")] })), sitesOnly ? null : (_jsxs(XStack, { gap: "$2", flexWrap: "wrap", rowGap: "$2", children: [_jsx(ChipSelect, { name: t('From'), label: from.find((f) => f.id === source).label, chosen: from.find((f) => f.id === source), items: from, onChange: (f) => setSource(f.id), placement: "bottom-start", width: 200 }), _jsx(ChipSelect, { name: t('Whose'), label: whose.find((w) => w.id === scope).label, chosen: whose.find((w) => w.id === scope), items: whose, onChange: (w) => setScope(w.id), placement: "bottom-start", width: 220 })] }))] }), acts.note ? (_jsx(SizableText, { size: "$2", color: "$soft", role: "status", children: acts.note })) : null, sitesOnly ? (_jsx(Sites, {})) : !signed ? (_jsx(Said, { says: t('Sign in to see your library.'), children: _jsx(Button, { size: "sm", onPress: () => host.signIn?.(), children: t('Sign in') }) })) : pages.error && !pages.rows.length ? (_jsx(Said, { says: told(pages.error, t), children: _jsx(Button, { size: "sm", variant: "outline", onPress: pages.reload, children: t('Try again') }) })) : pages.loading && !pages.rows.length ? (_jsx(Said, { says: t('Reading…') })) : !pages.rows.length ? (_jsx(Said, { says: narrowed ? t('Nothing matches.') : t('Nothing here yet. What you make in Chat, Dev and Studio lands here.'), children: narrowed ? null : make })) : (_jsxs(YStack, { gap: "$5", children: [!q && !kind && (source === '' || source === 'dev') && scope !== 'shared' ? (_jsx(YStack, { pb: "$4", borderBottomWidth: 1, borderColor: "$borderColor", children: _jsx(Sites, {}) })) : null, groups.map((g) => (_jsxs(YStack, { gap: "$3", role: "group", "aria-label": t(g.label), children: [_jsx(SizableText, { size: "$2", color: "$soft", fontWeight: "500", children: t(g.label) }), view === 'grid' ? (_jsx(YStack, { role: "list", "aria-label": made(g.label, t), gap: 16, "$platform-web": { display: 'grid', gridTemplateColumns: 'repeat(auto-fill, minmax(min(46%, 168px), 1fr))' }, children: g.rows.map((x) => (_jsx(Tile, { x: x, onOpen: () => look(x), rows: acts.rows(x) }, x.id))) })) : (_jsx(YStack, { role: "list", "aria-label": made(g.label, t), gap: "$0.5", children: g.rows.map((x) => (_jsx(Row, { x: x, onOpen: () => look(x), rows: acts.rows(x) }, x.id))) }))] }, g.label))), _jsx(YStack, { ref: end, height: 1 }), pages.loading ? (_jsx(SizableText, { size: "$1", color: "$soft", children: t('Reading more…') })) : pages.error ? (_jsx(SizableText, { size: "$1", color: "$soft", role: "status", children: told(pages.error, t) })) : null] })), !sitesOnly && signed && !pages.rows.length && !pages.loading && !q && !kind && (source === '' || source === 'dev') && scope !== 'shared' ? (_jsx(YStack, { pt: "$6", borderTopWidth: 1, borderColor: "$borderColor", children: _jsx(Sites, {}) })) : null] }) }), open && !wide ? panel(true) : null, open && wide ? (_jsx(YStack, { "data-slot": "library-side", ...pane, ml: gap, shrink: 0, minH: 0, width: 440, maxW: "45%", children: panel(false) })) : null, acts.dialogs, _jsx(Make, { open: making, onClose: () => host.go(path({ kind: 'screen', screen: 'artifacts' }), { replace: true }) })] }));
495
+ // Progressive disclosure: cap visible kind pills to 6 on desktop (4 on mobile), keeping the active kind visible.
496
+ const allKindPills = useMemo(() => [
497
+ ...KINDS.map((k) => ({ id: k.id, label: t(k.label) })),
498
+ { id: 'sites', label: t('Sites') },
499
+ ], [t]);
500
+ const activeKindId = sitesOnly ? 'sites' : kind;
501
+ const kindCap = desktop ? 6 : 4;
502
+ const kindOverflow = allKindPills.length > kindCap;
503
+ const visibleKindPills = !moreKinds && kindOverflow
504
+ ? (() => {
505
+ const base = allKindPills.slice(0, kindCap);
506
+ if (base.some((p) => p.id === activeKindId))
507
+ return base;
508
+ const chosen = allKindPills.find((p) => p.id === activeKindId);
509
+ return chosen ? [...base.slice(0, Math.max(1, kindCap - 1)), chosen] : base;
510
+ })()
511
+ : allKindPills;
512
+ const hiddenKindCount = allKindPills.length - visibleKindPills.length;
513
+ return (_jsxs(XStack, { flex: 1, minH: 0, minW: 0, width: "100%", children: [_jsx(YStack, { flex: 1, minH: 0, minW: 0, overflow: "scroll", px: "$6", py: "$6", "$max-md": { px: '$4', py: '$4' }, children: _jsxs(YStack, { width: "100%", maxW: 1120, mx: "auto", gap: "$4", children: [_jsxs(XStack, { items: "center", gap: "$3", children: [_jsx(SizableText, { render: "h1", size: "$7", fontWeight: "600", color: "$ink", flex: 1, children: sitesOnly ? t('Sites') : KINDS.find((k) => k.id === kind)?.id ? t(KINDS.find((k) => k.id === kind).label) : t('Library') }), _jsxs(XStack, { items: "center", gap: "$2", shrink: 0, children: [host.sections ? null : make(!emptyUnfiltered && signed), sitesOnly ? null : (_jsxs(XStack, { role: "radiogroup", "aria-label": t('View'), p: 2, gap: 2, rounded: "$3", borderWidth: 1, borderColor: "$borderColor", bg: "$panel", children: [_jsx(ViewMark, { label: t('Grid'), on: view === 'grid', onPress: () => setView('grid'), children: _jsx(LayoutGrid, { size: 15, color: view === 'grid' ? '$ink' : '$soft' }) }), _jsx(ViewMark, { label: t('List'), on: view === 'list', onPress: () => setView('list'), children: _jsx(List, { size: 15, color: view === 'list' ? '$ink' : '$soft' }) })] }))] })] }), _jsxs(YStack, { gap: "$2.5", children: [host.sections ? null : (_jsxs(XStack, { role: "radiogroup", "aria-label": t('Kind'), gap: "$1.5", rowGap: "$1.5", flexWrap: "wrap", width: "100%", children: [visibleKindPills.map((k) => (_jsx(KindChip, { label: k.label, on: activeKindId === k.id, onClick: () => setKind(k.id) }, k.id || 'all'))), kindOverflow ? (_jsx(XStack, { render: "button", "aria-expanded": moreKinds, "aria-label": moreKinds ? t('Show fewer kinds') : t('Show {n} more kinds', { n: hiddenKindCount }), onPress: () => setMoreKinds((v) => !v), items: "center", px: "$3", py: "$1", minH: 32, focusVisibleStyle: RING, children: _jsx(SizableText, { size: "$1", fontWeight: "500", color: "$ink", children: moreKinds ? t('Show less') : t('+{n} more', { n: hiddenKindCount }) }) })) : null] })), sitesOnly ? null : (_jsxs(XStack, { gap: "$2", rowGap: "$2", items: "center", flexWrap: "wrap", children: [_jsx(YStack, { flex: 1, minW: 220, maxW: 420, "$max-sm": { minW: '100%', maxW: '100%' }, children: _jsx(Input, { value: typed, onChangeText: setTyped, placeholder: t('Search your library'), "aria-label": t('Search your library'), disabled: !signed, startAdornment: _jsx(Search, { size: 14, color: "$soft" }), endAdornment: typed ? (_jsx(XStack, { render: "button", "aria-label": t('Clear search'), onPress: () => setTyped(''), minW: 24, minH: 24, items: "center", justify: "center", focusVisibleStyle: RING, children: _jsx(X, { size: 13, color: "$soft" }) })) : undefined, onKeyDown: (e) => {
514
+ if (e.key === 'Escape' && typed)
515
+ setTyped('');
516
+ } }) }), _jsxs(XStack, { gap: "$2", flexWrap: "wrap", rowGap: "$2", items: "center", children: [_jsx(ChipSelect, { name: t('From'), label: from.find((f) => f.id === source).label, chosen: from.find((f) => f.id === source), items: from, onChange: (f) => setSource(f.id), placement: "bottom-start", width: 200 }), _jsx(ChipSelect, { name: t('Whose'), label: whose.find((w) => w.id === scope).label, chosen: whose.find((w) => w.id === scope), items: whose, onChange: (w) => setScope(w.id), placement: "bottom-start", width: 220 }), narrowed ? (_jsx(Button, { size: "sm", variant: "ghost", onPress: clearFilters, children: t('Clear filters') })) : null] })] }))] }), acts.note ? (_jsx(SizableText, { size: "$2", color: "$soft", role: "status", children: acts.note })) : null, sitesOnly ? (_jsx(Sites, {})) : !signed ? (_jsx(Said, { says: t('Sign in to see your library.'), children: _jsx(Button, { size: "sm", onPress: () => host.signIn?.(), children: t('Sign in') }) })) : pages.error && !pages.rows.length ? (_jsx(Said, { says: told(pages.error, t), error: true, children: _jsx(Button, { size: "sm", variant: "outline", onPress: pages.reload, children: t('Try again') }) })) : pages.loading && !pages.rows.length ? (_jsxs(YStack, { gap: "$3", "aria-busy": true, children: [_jsx(SizableText, { size: "$2", color: "$soft", children: t('Reading…') }), view === 'grid' ? (_jsx(YStack, { gap: 16, "$platform-web": { display: 'grid', gridTemplateColumns: 'repeat(auto-fill, minmax(min(46%, 168px), 1fr))' }, children: [0, 1, 2, 3, 4, 5, 6, 7].map((i) => (_jsxs(YStack, { gap: "$2", children: [_jsx(Skeleton, { layout: "block", width: "100%", aspectRatio: 1, rounded: "$4" }), _jsx(Skeleton, { layout: "block", width: "72%", height: 14, rounded: "$2" }), _jsx(Skeleton, { layout: "block", width: "48%", height: 12, rounded: "$2" })] }, i))) })) : (_jsx(YStack, { borderWidth: 1, borderColor: "$borderColor", rounded: "$3", bg: "$panel", overflow: "hidden", children: [0, 1, 2, 3, 4, 5].map((i) => (_jsxs(XStack, { items: "center", gap: "$3", px: "$3", py: "$2.5", borderTopWidth: i ? 1 : 0, borderColor: "$borderColor", children: [_jsx(Skeleton, { layout: "block", width: 40, height: 40, rounded: "$3", shrink: 0 }), _jsxs(YStack, { flex: 1, gap: "$1.5", children: [_jsx(Skeleton, { layout: "block", width: "42%", height: 14, rounded: "$2" }), _jsx(Skeleton, { layout: "block", width: "28%", height: 12, rounded: "$2" })] })] }, i))) }))] })) : !pages.rows.length ? (narrowed ? (_jsxs(YStack, { gap: "$5", children: [showSites ? _jsx(Sites, { q: q, onMatch: setSiteMatches }) : null, !showSites || siteMatches === 0 ? (_jsx(Said, { says: t('Nothing matches.'), children: _jsx(Button, { size: "sm", variant: "outline", onPress: clearFilters, children: t('Clear filters') }) })) : null] })) : (_jsxs(YStack, { gap: "$5", children: [_jsx(Said, { says: t('Nothing here yet. What you make in Chat, Dev and Studio lands here.'), children: make(true) }), showSites ? (_jsx(YStack, { pt: "$6", borderTopWidth: 1, borderColor: "$borderColor", children: _jsx(Sites, { onMatch: setSiteMatches }) })) : null] }))) : (_jsxs(YStack, { gap: "$5", children: [showSites ? (_jsx(YStack, { pb: !q || siteMatches > 0 ? '$4' : 0, borderBottomWidth: !q || siteMatches > 0 ? 1 : 0, borderColor: "$borderColor", children: _jsx(Sites, { q: q, onMatch: setSiteMatches }) })) : null, groups.map((g) => (_jsxs(YStack, { gap: "$3", role: "group", "aria-label": t(g.label), children: [_jsx(SizableText, { size: "$2", color: "$soft", fontWeight: "500", children: t(g.label) }), view === 'grid' ? (_jsx(YStack, { role: "list", "aria-label": made(g.label, t), gap: 16, "$platform-web": { display: 'grid', gridTemplateColumns: 'repeat(auto-fill, minmax(min(46%, 168px), 1fr))' }, children: g.rows.map((x) => (_jsx(Tile, { x: x, onOpen: () => look(x), rows: acts.rows(x) }, x.id))) })) : (_jsx(YStack, { role: "list", "aria-label": made(g.label, t), borderWidth: 1, borderColor: "$borderColor", rounded: "$3", bg: "$panel", overflow: "hidden", children: g.rows.map((x, i) => (_jsx(Row, { x: x, first: i === 0, onOpen: () => look(x), rows: acts.rows(x) }, x.id))) }))] }, g.label))), _jsx(YStack, { ref: end, height: 1 }), pages.loading ? (_jsx(SizableText, { size: "$1", color: "$soft", children: t('Reading more…') })) : pages.error ? (_jsx(SizableText, { size: "$1", color: "$soft", role: "status", children: told(pages.error, t) })) : null] }))] }) }), open && !wide ? panel(true) : null, open && wide ? (_jsx(YStack, { "data-slot": "library-side", ...pane, ml: gap, shrink: 0, minH: 0, width: 440, maxW: "45%", children: panel(false) })) : null, acts.dialogs, _jsx(Make, { open: making, onClose: () => host.go(path({ kind: 'screen', screen: 'artifacts' }), { replace: true }) })] }));
517
+ }
518
+ function KindChip({ label, on, onClick }) {
519
+ return (_jsx(XStack, { render: "button", role: "radio", "aria-checked": on, "aria-label": label, onPress: onClick, items: "center", px: "$3", py: "$1", minH: 32, shrink: 0, focusVisibleStyle: RING, children: _jsx(SizableText, { size: "$1", fontWeight: on ? '500' : '400', color: on ? '$background' : '$soft', children: label }) }));
451
520
  }
452
521
  function ViewMark({ label, on, onPress, children }) {
453
- return (_jsx(XStack, { render: "button", role: "radio", "aria-checked": on, "aria-label": label, onPress: onPress, width: 32, height: 32, items: "center", justify: "center", rounded: "$3", bg: on ? '$hover' : 'transparent', hoverStyle: { bg: '$hover' }, cursor: "pointer", opacity: on ? 1 : 0.6, children: children }));
522
+ return (_jsx(XStack, { render: "button", role: "radio", "aria-checked": on, "aria-label": label, onClick: onPress, minW: 30, minH: 28, items: "center", justify: "center", cursor: "pointer", focusVisibleStyle: RING, children: children }));
454
523
  }
455
- function Said({ says, children }) {
456
- return (_jsxs(YStack, { rounded: "$4", borderWidth: 1, borderColor: "$borderColor", px: "$4", py: "$10", gap: "$3", items: "center", children: [_jsx(SizableText, { size: "$2", color: "$soft", style: { textAlign: 'center' }, children: says }), children] }));
524
+ function Said({ says, error = false, children }) {
525
+ return (_jsxs(YStack, { rounded: "$4", borderWidth: 1, borderColor: "$borderColor", bg: "$panel", px: "$5", py: "$8", gap: "$3", items: "center", children: [_jsx(SizableText, { size: "$2", color: error ? 'var(--state-error)' : '$soft', text: "center", children: says }), children] }));
457
526
  }
package/lib/make.js CHANGED
@@ -17,6 +17,7 @@ import { useI18n } from '@hanzo/i18n/react';
17
17
  import { Bot, Globe, Search, X } from '@hanzogui/lucide-icons-2';
18
18
  import { Button, Dialog, DialogContent, DialogTitle, Input } from '@hanzo/ui';
19
19
  import { useEffect, useMemo, useRef, useState } from 'react';
20
+ import { RING } from './pane.js';
20
21
  import { use } from './api/agents.js';
21
22
  import { told } from './api/call.js';
22
23
  import { APP, catalogue, KIND, KINDS, narrow } from './api/gallery.js';
@@ -26,7 +27,7 @@ import { useHost, useTarget } from './host.js';
26
27
  import { path } from './route.js';
27
28
  /** A chip: one choice among a few, lit when chosen. */
28
29
  export function Chip({ label, on, onPress }) {
29
- return (_jsx(XStack, { render: "button", role: "radio", "aria-checked": on, "aria-label": label, onPress: onPress, height: 32, px: "$3", items: "center", rounded: "$10", shrink: 0, borderWidth: 1, borderColor: on ? '$ink' : '$borderColor', bg: on ? '$ink' : 'transparent', hoverStyle: { bg: on ? '$ink' : '$hover' }, cursor: "pointer", focusVisibleStyle: { outlineWidth: 2, outlineStyle: 'solid', outlineColor: '$outlineColor' }, children: _jsx(SizableText, { size: "$2", color: on ? '$background' : '$ink', children: label }) }));
30
+ return (_jsx(XStack, { render: "button", role: "radio", "aria-checked": on, "aria-label": label, onPress: onPress, height: 32, px: "$3", items: "center", rounded: "$10", shrink: 0, borderWidth: 1, borderColor: on ? '$ink' : '$borderColor', bg: on ? '$ink' : 'transparent', hoverStyle: { bg: on ? '$ink' : '$hover' }, cursor: "pointer", focusVisibleStyle: RING, children: _jsx(SizableText, { size: "$2", color: on ? '$background' : '$ink', children: label }) }));
30
31
  }
31
32
  /** A template's capture, 16:10 from the top of its page, or its kind's mark. */
32
33
  function Still({ x }) {
@@ -109,5 +110,5 @@ export function Make({ open, onClose }) {
109
110
  };
110
111
  return (_jsx(Dialog, { open: open, onOpenChange: (o) => !o && onClose(), children: _jsxs(DialogContent, { "data-slot": "make", showCloseButton: false, p: "$4", gap: "$3", ...(wide ? { width: '100%', maxW: 960, maxH: '88vh' } : { position: 'fixed', t: 0, r: 0, b: 0, l: 0, maxW: '100%', maxH: '100%', rounded: 0, borderWidth: 0 }), children: [_jsx(DialogTitle, { numberOfLines: 1, paddingInlineEnd: 40, children: t('Make something new') }), _jsxs(XStack, { items: "center", gap: "$2", children: [_jsx(Search, { size: 16, opacity: 0.6 }), _jsx(YStack, { flex: 1, minW: 0, children: _jsx(Input, { ref: search, value: q, onChangeText: setQ, placeholder: t('Search templates'), "aria-label": t('Search templates'), onKeyDown: into }) })] }), kinds.length > 1 ? (_jsxs(XStack, { role: "radiogroup", "aria-label": t('Kind'), gap: "$2", overflowX: "auto", overflowY: "hidden", pb: "$1", "$platform-web": { scrollbarWidth: 'none' }, children: [_jsx(Chip, { label: t('All'), on: kind === '', onPress: () => setKind('') }), kinds.map((k) => (_jsx(Chip, { label: t(KIND[k]), on: kind === k, onPress: () => setKind(k) }, k)))] })) : null, note ? (_jsx(SizableText, { size: "$2", color: "$soft", role: "status", children: note })) : null, _jsx(YStack, { shrink: 1, minH: 0, overflowY: "auto", overflowX: "hidden", children: read.error ? (_jsxs(YStack, { gap: "$3", items: "flex-start", py: "$4", children: [_jsx(SizableText, { size: "$2", color: "$soft", children: told(read.error, t) }), _jsx(Button, { size: "sm", variant: "outline", onPress: read.reload, children: t('Try again') })] })) : read.loading && !read.value.length ? (_jsx(SizableText, { size: "$2", color: "$soft", py: "$4", children: t('Reading templates…') })) : !hits.length ? (_jsx(SizableText, { size: "$2", color: "$soft", py: "$4", children: t('Nothing matches.') })) : (_jsx(YStack, { role: "list", "aria-label": t('Templates'), onKeyDown: across, gap: 16, "$platform-web": { display: 'grid', gridTemplateColumns: 'repeat(auto-fill, minmax(min(46%, 200px), 1fr))' }, children: hits.map((x, i) => (_jsx(YStack, { role: "listitem", minW: 0, children: _jsxs(YStack, { ref: (el) => {
111
112
  cells.current[i] = el instanceof HTMLElement ? el : null;
112
- }, render: "button", tabIndex: i === at ? 0 : -1, onFocus: () => setAt(i), "aria-label": t('Start from {template}', { template: x.name }), disabled: Boolean(busy), onPress: () => void pick(x), rounded: "$4", borderWidth: 1, borderColor: "$borderColor", overflow: "hidden", cursor: "pointer", hoverStyle: { bg: '$hover' }, focusVisibleStyle: { outlineWidth: 2, outlineStyle: 'solid', outlineColor: '$outlineColor' }, "$platform-web": { textAlign: 'start' }, children: [_jsx(Still, { x: x }), _jsxs(YStack, { px: "$2.5", py: "$2", gap: "$0.5", minW: 0, children: [_jsx(SizableText, { size: "$2", color: "$ink", numberOfLines: 1, children: x.name }), _jsx(SizableText, { size: "$1", color: "$soft", numberOfLines: 1, children: busy === x.slug ? t('Starting…') : [t(KIND[x.kind]), x.category].filter(Boolean).join(' · ') })] })] }) }, x.slug))) })) }), _jsx(XStack, { render: "button", "aria-label": t('Close'), position: "absolute", t: 14, insetInlineEnd: 14, width: 32, height: 32, items: "center", justify: "center", rounded: "$2", hoverStyle: { bg: '$hover' }, cursor: "pointer", onPress: onClose, children: _jsx(X, { size: 16 }) })] }) }));
113
+ }, render: "button", tabIndex: i === at ? 0 : -1, onFocus: () => setAt(i), "aria-label": t('Start from {template}', { template: x.name }), disabled: Boolean(busy), onPress: () => void pick(x), rounded: "$4", borderWidth: 1, borderColor: "$borderColor", overflow: "hidden", cursor: "pointer", hoverStyle: { bg: '$hover' }, focusVisibleStyle: RING, "$platform-web": { textAlign: 'start' }, children: [_jsx(Still, { x: x }), _jsxs(YStack, { px: "$2.5", py: "$2", gap: "$0.5", minW: 0, children: [_jsx(SizableText, { size: "$2", color: "$ink", numberOfLines: 1, children: x.name }), _jsx(SizableText, { size: "$1", color: "$soft", numberOfLines: 1, children: busy === x.slug ? t('Starting…') : [t(KIND[x.kind]), x.category].filter(Boolean).join(' · ') })] })] }) }, x.slug))) })) }), _jsx(XStack, { render: "button", "aria-label": t('Close'), position: "absolute", t: 14, insetInlineEnd: 14, width: 32, height: 32, items: "center", justify: "center", rounded: "$2", hoverStyle: { bg: '$hover' }, cursor: "pointer", onPress: onClose, children: _jsx(X, { size: 16 }) })] }) }));
113
114
  }