@hanzo/app 0.3.93 → 0.3.95

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 (101) hide show
  1. package/dist/Account.d.ts +9 -3
  2. package/dist/Account.js +142 -141
  3. package/dist/App.js +71 -37
  4. package/dist/Bar.js +1 -1
  5. package/dist/Betas.d.ts +1 -1
  6. package/dist/Betas.js +16 -22
  7. package/dist/Board.js +113 -47
  8. package/dist/CalScheduler.d.ts +1 -0
  9. package/dist/CalScheduler.js +223 -57
  10. package/dist/Chat.js +432 -153
  11. package/dist/Contacts.js +35 -31
  12. package/dist/ContextMenu.js +126 -42
  13. package/dist/Directory.js +1 -1
  14. package/dist/Drawer.js +1 -1
  15. package/dist/Drive.js +351 -119
  16. package/dist/Gate.js +156 -13
  17. package/dist/Home.js +31 -53
  18. package/dist/Inbox.js +29 -15
  19. package/dist/InlineRename.d.ts +6 -0
  20. package/dist/InlineRename.js +41 -0
  21. package/dist/Learning.js +132 -13
  22. package/dist/Market.js +13 -9
  23. package/dist/Meet.d.ts +5 -0
  24. package/dist/Meet.js +75 -51
  25. package/dist/MoreMenu.d.ts +19 -0
  26. package/dist/MoreMenu.js +33 -0
  27. package/dist/NeedMoreUsage.js +2 -2
  28. package/dist/OrgSwitcher.js +6 -2
  29. package/dist/Rail.d.ts +73 -7
  30. package/dist/Rail.js +372 -111
  31. package/dist/Recents.js +77 -24
  32. package/dist/RightPane.js +2 -2
  33. package/dist/Search.d.ts +13 -1
  34. package/dist/Search.js +366 -50
  35. package/dist/Setup.js +34 -5
  36. package/dist/Shared.js +12 -12
  37. package/dist/Shell.js +210 -151
  38. package/dist/Sidebar.d.ts +14 -3
  39. package/dist/Sidebar.js +411 -129
  40. package/dist/SkipLink.d.ts +8 -0
  41. package/dist/SkipLink.js +11 -0
  42. package/dist/Start.js +51 -52
  43. package/dist/Terminals.js +159 -11
  44. package/dist/ToBottom.js +1 -1
  45. package/dist/Upgrade.d.ts +8 -3
  46. package/dist/Upgrade.js +194 -103
  47. package/dist/Usage.d.ts +1 -1
  48. package/dist/Usage.js +186 -82
  49. package/dist/WalletPill.js +8 -2
  50. package/dist/Work.js +162 -53
  51. package/dist/archive.d.ts +8 -0
  52. package/dist/archive.js +16 -0
  53. package/dist/bots/Bots.js +1 -1
  54. package/dist/bots/ComputerDialog.js +53 -26
  55. package/dist/bots/ConnectorsDialog.js +34 -15
  56. package/dist/bots/Make.js +5 -1
  57. package/dist/bots/Panel.js +37 -31
  58. package/dist/bots/Roster.js +18 -13
  59. package/dist/bots/Thread.js +54 -27
  60. package/dist/bots/face.js +6 -2
  61. package/dist/bots/kit.d.ts +1 -0
  62. package/dist/bots/kit.js +1 -1
  63. package/dist/bots/refusal.d.ts +13 -4
  64. package/dist/bots/refusal.js +62 -8
  65. package/dist/chord.d.ts +13 -0
  66. package/dist/chord.js +30 -1
  67. package/dist/crew.js +47 -4
  68. package/dist/ground.d.ts +1 -1
  69. package/dist/ground.js +1 -1
  70. package/dist/help.d.ts +7 -3
  71. package/dist/help.js +19 -14
  72. package/dist/keys.d.ts +28 -0
  73. package/dist/keys.js +58 -0
  74. package/dist/lib/arrival.d.ts +5 -0
  75. package/dist/lib/arrival.js +10 -0
  76. package/dist/lib/betas.d.ts +2 -0
  77. package/dist/lib/betas.js +10 -0
  78. package/dist/lib/branch.d.ts +11 -0
  79. package/dist/lib/branch.js +11 -0
  80. package/dist/lib/chatPreferences.d.ts +1 -1
  81. package/dist/lib/chatPreferences.js +1 -1
  82. package/dist/lib/dev-mode.d.ts +18 -0
  83. package/dist/lib/dev-mode.js +102 -0
  84. package/dist/lib/info-hint.d.ts +7 -0
  85. package/dist/lib/info-hint.js +8 -0
  86. package/dist/lib/model-picker.d.ts +2 -0
  87. package/dist/lib/model-picker.js +12 -0
  88. package/dist/lib/owners.d.ts +5 -0
  89. package/dist/lib/owners.js +15 -0
  90. package/dist/lib/pay.d.ts +2 -0
  91. package/dist/lib/pay.js +4 -0
  92. package/dist/lib/todo.d.ts +6 -0
  93. package/dist/lib/todo.js +37 -25
  94. package/dist/look.js +39 -8
  95. package/dist/rail-open.d.ts +9 -0
  96. package/dist/rail-open.js +34 -0
  97. package/dist/renaming.d.ts +10 -0
  98. package/dist/renaming.js +25 -0
  99. package/dist/thread.d.ts +2 -1
  100. package/dist/thread.js +85 -44
  101. package/package.json +11 -11
package/dist/Inbox.js CHANGED
@@ -31,17 +31,15 @@ import { useCallback, useMemo, useRef, useState } from 'react';
31
31
  import { useI18n } from '@hanzo/i18n/react';
32
32
  import { ChannelHeader } from '@hanzo/ui/agents';
33
33
  import { Composer } from '@hanzo/ui/chat';
34
- import { Box, Text, XStack, YStack } from '@hanzo/ui';
34
+ import { Box, Skeleton, Text, XStack, YStack } from '@hanzo/ui';
35
35
  import { useIam } from '@hanzo/iam/react';
36
- import { Plus } from 'lucide-react';
36
+ import { ArrowLeft, Plus, User } from 'lucide-react';
37
37
  import { useAi } from './lib/ai.js';
38
38
  import { useOpen } from './open.js';
39
- import { Face } from './cast.js';
40
39
  import { plainly } from './failure.js';
41
40
  import { channelName, Network, of, speaker } from './network.js';
42
41
  import { conversationOf, useConversations, } from './conversations.js';
43
42
  import { Directory } from './Directory.js';
44
- import { BAD } from './lib/mix.js';
45
43
  /** Unix SECONDS, which is what the platform sends. Milliseconds here read as 1970. */
46
44
  const when = (seconds, locale) => new Date(seconds * 1000).toLocaleString(locale, {
47
45
  month: 'short',
@@ -70,26 +68,42 @@ function stamp(seconds, locale) {
70
68
  * everybody, so it told nobody apart while looking like somebody's initials.
71
69
  * A disc with nothing to say says '?', which is what it means.
72
70
  */
73
- function Sender({ transport, size = 36 }) {
74
- return (_jsxs(YStack, { width: size, height: size, shrink: 0, position: "relative", children: [_jsx(Face, { size: size }), _jsx(YStack, { position: "absolute", b: -2, insetInlineEnd: -2, children: _jsx(Network, { transport: transport, size: Math.round(size * 0.46) }) })] }));
71
+ function senderInitial(raw) {
72
+ const clean = (raw ?? '').trim().replace(/^[#@]+/, '');
73
+ if (!clean)
74
+ return null;
75
+ // Skip opaque transport IDs (e.g. Slack U0123ABC) so everyone doesn't share 'U'.
76
+ if (/^[UWCDGB][A-Z0-9]{6,}$/.test(clean) || /^\d+$/.test(clean))
77
+ return null;
78
+ const first = clean.charAt(0);
79
+ return /\p{L}/u.test(first) ? first.toUpperCase() : null;
80
+ }
81
+ function Sender({ transport, name, size = 36 }) {
82
+ const initial = senderInitial(name);
83
+ return (_jsxs(YStack, { width: size, height: size, shrink: 0, position: "relative", children: [_jsx(YStack, { width: size, height: size, rounded: "$10", bg: "var(--surface-card-emphasis)", borderWidth: 1, borderColor: "$edge", items: "center", justify: "center", children: initial ? (_jsx(Text, { fontSize: size >= 36 ? '$2' : '$1', fontWeight: "600", color: "$aside", children: initial })) : (_jsx(User, { size: Math.round(size * 0.44), color: "var(--text-secondary)", "aria-hidden": true })) }), _jsx(YStack, { position: "absolute", b: -2, insetInlineEnd: -2, children: _jsx(Network, { transport: transport, size: Math.round(size * 0.46) }) })] }));
75
84
  }
76
85
  /** Where a network is connected. Opens My Channels modal. */
77
86
  function Connect() {
78
87
  const { t } = useI18n();
79
88
  const [modalOpen, setModalOpen] = useState(false);
80
- return (_jsxs(_Fragment, { children: [_jsx(Box, { render: "button", onClick: () => setModalOpen(true), px: "$3", py: "$2", rounded: "$3", borderWidth: 1, borderColor: "$borderColor", hoverStyle: { bg: '$hover' }, cursor: "pointer", children: _jsxs(XStack, { items: "center", gap: "$1.5", children: [_jsx(Plus, { size: 13, "aria-hidden": true }), _jsx(Text, { fontSize: "$2", color: "$ink", children: t('Connect an app') })] }) }), _jsx(Directory, { open: modalOpen, onClose: () => setModalOpen(false), tab: "channels" })] }));
89
+ return (_jsxs(_Fragment, { children: [_jsx(Box, { render: "button", ...{ type: 'button' }, onClick: () => setModalOpen(true), px: "$3", py: "$2", rounded: "$3", borderWidth: 1, borderColor: "var(--border-strong)", bg: "transparent", transition: "quickest", hoverStyle: { bg: '$hover', borderColor: '$ink' }, focusVisibleStyle: { outlineWidth: 2, outlineStyle: 'solid', outlineColor: 'var(--ring)' }, "$max-sm": { minH: 44, display: 'flex', items: 'center' }, cursor: "pointer", children: _jsxs(XStack, { items: "center", gap: "$1.5", children: [_jsx(Plus, { size: 13, color: "var(--foreground)", "aria-hidden": true }), _jsx(Text, { fontSize: "$2", fontWeight: "500", color: "$ink", children: t('Connect an app') })] }) }), _jsx(Directory, { open: modalOpen, onClose: () => setModalOpen(false), tab: "channels" })] }));
81
90
  }
82
91
  function Empty({ children, offer }) {
83
92
  const { t } = useI18n();
84
93
  return (_jsxs(YStack, { flex: 1, items: "center", justify: "center", p: "$6", gap: "$3", children: [_jsx(Text, { render: "h1", fontSize: "$4", fontWeight: "600", color: "$ink", children: t('Inbox') }), _jsx(Text, { fontSize: "$3", color: "$soft", text: "center", maxW: 420, children: children }), offer ? _jsx(Connect, {}) : null] }));
85
94
  }
95
+ /** Calm monochrome layout-matched skeleton for the two-column inbox while messages load. */
96
+ function InboxSkeleton({ span = 320 }) {
97
+ const { t } = useI18n();
98
+ return (_jsxs(XStack, { role: "status", "aria-busy": true, "aria-label": t('Loading messages'), flex: 1, minH: 0, minW: 0, overflow: "hidden", children: [_jsxs(YStack, { flex: 1, $md: { width: span, flex: 0, shrink: 0, borderInlineEndWidth: 1 }, minW: 0, minH: 0, borderColor: "$edge", children: [_jsxs(XStack, { minH: 48, shrink: 0, items: "center", justify: "space-between", px: "$3", py: "$2", gap: "$2", borderBottomWidth: 1, borderColor: "$edge", children: [_jsx(Text, { render: "h1", fontSize: "$3", fontWeight: "600", color: "$ink", children: t('Inbox') }), _jsx(Skeleton, { layout: "block", width: 104, height: 28, rounded: "$3", shrink: 0 })] }), _jsx(YStack, { flex: 1, minH: 0, overflow: "hidden", children: [0, 1, 2, 3, 4, 5].map((i) => (_jsxs(XStack, { gap: "$3", items: "center", p: "$3", minH: 62, borderBottomWidth: 1, borderColor: "$edge", children: [_jsx(Skeleton, { layout: "block", width: 36, height: 36, rounded: "$10", shrink: 0 }), _jsxs(YStack, { flex: 1, minW: 0, gap: "$1.5", children: [_jsxs(XStack, { items: "center", justify: "space-between", gap: "$2", children: [_jsx(Skeleton, { layout: "block", width: i % 2 === 0 ? '48%' : '58%', height: 13, rounded: "$2" }), _jsx(Skeleton, { layout: "block", width: 36, height: 10, rounded: "$2", shrink: 0 })] }), _jsx(Skeleton, { layout: "block", width: i % 2 === 0 ? '82%' : '70%', height: 11, rounded: "$2" })] })] }, i))) })] }), _jsxs(YStack, { display: "none", $md: { display: 'flex' }, flex: 1, minW: 0, minH: 0, children: [_jsxs(XStack, { minH: 48, shrink: 0, items: "center", justify: "space-between", px: "$4", borderBottomWidth: 1, borderColor: "$edge", children: [_jsx(Skeleton, { layout: "block", width: 150, height: 15, rounded: "$2" }), _jsx(Skeleton, { layout: "block", width: 68, height: 12, rounded: "$2" })] }), _jsx(YStack, { flex: 1, minH: 0, p: "$4", gap: "$4", children: [0, 1, 2].map((i) => (_jsxs(XStack, { gap: "$3", items: "flex-start", children: [_jsx(Skeleton, { layout: "block", width: 32, height: 32, rounded: "$10", shrink: 0 }), _jsxs(YStack, { flex: 1, minW: 0, gap: "$1.5", children: [_jsxs(XStack, { gap: "$2", items: "center", children: [_jsx(Skeleton, { layout: "block", width: 110, height: 13, rounded: "$2" }), _jsx(Skeleton, { layout: "block", width: 54, height: 10, rounded: "$2" })] }), _jsx(Skeleton, { layout: "block", width: i === 1 ? '72%' : '86%', height: 12, rounded: "$2" }), _jsx(Skeleton, { layout: "block", width: i === 1 ? '44%' : '58%', height: 12, rounded: "$2" })] })] }, i))) })] })] }));
99
+ }
86
100
  /** The list, which stays on screen while you read down it. */
87
101
  function Arrivals({ conversations, open, onPick, }) {
88
102
  const { t, locale } = useI18n();
89
- return (_jsxs(YStack, { flex: 1, minH: 0, children: [_jsxs(XStack, { height: 48, shrink: 0, items: "center", px: "$3", gap: "$2", borderBottomWidth: 1, borderColor: "$borderColor", children: [_jsx(Text, { flex: 1, fontSize: "$3", fontWeight: "600", color: "$ink", children: t('Inbox') }), _jsx(Connect, {})] }), _jsx(YStack, { flex: 1, minH: 0, overflowY: "auto", overflowX: "hidden", children: conversations.map((one) => (_jsx(Box, { render: "button", onClick: () => onPick(one.key), "aria-current": one.key === open, display: "block", width: "100%", cursor: "pointer", borderBottomWidth: 1, borderColor: "var(--borderColor, var(--white-08))", bg: one.key === open ? 'var(--raised, var(--white-06))' : 'transparent', hoverStyle: { bg: '$hover' }, children: _jsxs(XStack, { gap: "$3", items: "center", p: "$3", children: [_jsx(Sender, { transport: one.transport }), _jsxs(YStack, { flex: 1, minW: 0, gap: "$1", items: "flex-start", children: [_jsxs(XStack, { width: "100%", items: "baseline", gap: "$2", children: [_jsx(Text, { fontSize: "$3", fontWeight: "600", color: "$ink", numberOfLines: 1, flex: 1, text: "start", children: one.title }), one.lastAt ? (_jsx(Text, { fontSize: "$1", color: "$soft", children: _jsx("bdi", { children: stamp(one.lastAt / 1000, locale) }) })) : null] }), one.preview ? (_jsx(Text, { fontSize: "$2", color: "$soft", numberOfLines: 1, children: one.preview })) : null] })] }) }, one.key))) })] }));
103
+ return (_jsxs(YStack, { flex: 1, minH: 0, minW: 0, children: [_jsxs(XStack, { minH: 48, shrink: 0, items: "center", justify: "space-between", flexWrap: "wrap", px: "$3", py: "$2", gap: "$2", borderBottomWidth: 1, borderColor: "$edge", children: [_jsx(Text, { flex: 1, minW: 0, fontSize: "$3", fontWeight: "600", color: "$ink", numberOfLines: 1, children: t('Inbox') }), _jsx(Connect, {})] }), _jsx(YStack, { flex: 1, minH: 0, overflowY: "auto", overflowX: "hidden", children: conversations.map((one) => (_jsx(Box, { render: "button", ...{ type: 'button' }, onClick: () => onPick(one.key), "aria-current": one.key === open, display: "block", width: "100%", minH: 60, "$max-sm": { minH: 64 }, cursor: "pointer", borderWidth: 0, borderBottomWidth: 1, borderColor: "$edge", bg: one.key === open ? '$raised' : 'transparent', transition: "quickest", hoverStyle: { bg: one.key === open ? '$raised' : '$hover' }, focusVisibleStyle: { outlineWidth: 2, outlineStyle: 'solid', outlineColor: 'var(--ring)', outlineOffset: -2 }, children: _jsxs(XStack, { gap: "$3", items: "center", p: "$3", children: [_jsx(Sender, { transport: one.transport, name: one.title }), _jsxs(YStack, { flex: 1, minW: 0, gap: "$1", items: "flex-start", children: [_jsxs(XStack, { width: "100%", items: "baseline", gap: "$2", children: [_jsx(Text, { fontSize: "$3", fontWeight: "600", color: "$ink", numberOfLines: 1, flex: 1, text: "start", children: one.title }), one.lastAt ? (_jsx(Text, { fontSize: "$1", color: "$soft", children: _jsx("bdi", { children: stamp(one.lastAt / 1000, locale) }) })) : null] }), one.preview ? (_jsx(Text, { fontSize: "$2", color: "$soft", numberOfLines: 1, children: one.preview })) : null] })] }) }, one.key))) })] }));
90
104
  }
91
105
  /** What is open, beside the list rather than instead of it. */
92
- function Reading({ channel, reload, }) {
106
+ function Reading({ channel, reload, onBack, }) {
93
107
  const { t, locale } = useI18n();
94
108
  const { client } = useAi();
95
109
  const [draft, setDraft] = useState('');
@@ -134,16 +148,16 @@ function Reading({ channel, reload, }) {
134
148
  setSending(false);
135
149
  }
136
150
  }, [client, draft, sending, channel.transport, channel.channelId, reload, t]);
137
- return (_jsxs(YStack, { flex: 1, minH: 0, children: [_jsx(ChannelHeader, { name: channelName(channel), children: _jsxs(XStack, { items: "center", gap: "$1.5", children: [_jsx(Network, { transport: channel.transport, size: 14 }), _jsx(Text, { fontSize: "$2", color: "$soft", children: of(channel.transport).name })] }) }), _jsx(YStack, { flex: 1, minH: 0, overflowY: "auto", overflowX: "hidden", p: "$4", gap: "$3", children: [...channel.messages]
151
+ return (_jsxs(YStack, { flex: 1, minH: 0, minW: 0, children: [_jsxs(XStack, { items: "center", borderBottomWidth: 1, borderColor: "$edge", minW: 0, children: [onBack ? (_jsx(XStack, { render: "button", ...{ type: 'button' }, "aria-label": t('Back to inbox'), onClick: onBack, display: "flex", $md: { display: 'none' }, minW: 44, minH: 44, ml: "$1.5", rounded: "$3", items: "center", justify: "center", cursor: "pointer", hoverStyle: { bg: '$hover' }, focusVisibleStyle: { outlineWidth: 2, outlineStyle: 'solid', outlineColor: 'var(--ring)' }, children: _jsx(ArrowLeft, { size: 16, color: "var(--foreground)", "aria-hidden": true }) })) : null, _jsx(YStack, { flex: 1, minW: 0, children: _jsx(ChannelHeader, { name: channelName(channel), children: _jsxs(XStack, { items: "center", gap: "$1.5", children: [_jsx(Network, { transport: channel.transport, size: 14 }), _jsx(Text, { fontSize: "$2", color: "$soft", children: of(channel.transport).name })] }) }) })] }), _jsx(YStack, { flex: 1, minH: 0, overflowY: "auto", overflowX: "hidden", p: "$4", "$max-sm": { p: '$3' }, gap: "$3", children: [...channel.messages]
138
152
  .sort((a, b) => a.createdAt - b.createdAt)
139
- .map((message) => (_jsxs(XStack, { gap: "$3", items: "flex-start", children: [_jsx(Sender, { transport: channel.transport, size: 32 }), _jsxs(YStack, { flex: 1, minW: 0, gap: "$1", children: [_jsxs(XStack, { gap: "$2", items: "baseline", children: [_jsx(Text, { fontSize: "$3", fontWeight: "500", color: "$ink", children: speaker(channel.transport, message.sender) }), _jsx(Text, { fontSize: "$1", color: "$soft", children: _jsx("bdi", { children: when(message.createdAt, locale) }) })] }), _jsx(Text, { fontSize: "$3", color: "$ink", children: message.text })] })] }, message.id))) }), _jsx(YStack, { p: "$3", gap: "$2", borderTopWidth: 1, borderColor: "$borderColor", children: channel.channelId ? (_jsxs(_Fragment, { children: [_jsx(Composer, { value: draft, onChange: setDraft, onSend: () => void send(), busy: sending, placeholder: t('Reply on {network}', { network: of(channel.transport).name }), label: t('Reply on {network}', { network: of(channel.transport).name }) }), failed ? (_jsx(Text, { fontSize: "$2", color: BAD, children: failed })) : null] })) : (_jsx(Text, { fontSize: "$2", color: "$soft", children: t('This message names no channel to answer in.') })) })] }));
153
+ .map((message) => (_jsxs(XStack, { gap: "$3", items: "flex-start", minW: 0, children: [_jsx(Sender, { transport: channel.transport, name: speaker(channel.transport, message.sender), size: 32 }), _jsxs(YStack, { flex: 1, minW: 0, gap: "$1", children: [_jsxs(XStack, { gap: "$2", items: "baseline", flexWrap: "wrap", children: [_jsx(Text, { fontSize: "$3", fontWeight: "500", color: "$ink", children: speaker(channel.transport, message.sender) }), _jsx(Text, { fontSize: "$1", color: "$soft", children: _jsx("bdi", { children: when(message.createdAt, locale) }) })] }), _jsx(Text, { fontSize: "$3", color: "$ink", lineHeight: "$4", children: message.text })] })] }, message.id))) }), _jsx(YStack, { p: "$3", "$max-sm": { p: '$2.5' }, gap: "$2", borderTopWidth: 1, borderColor: "$edge", minW: 0, children: channel.channelId ? (_jsxs(_Fragment, { children: [_jsx(Composer, { value: draft, onChange: setDraft, onSend: () => void send(), busy: sending, placeholder: t('Reply on {network}', { network: of(channel.transport).name }), label: t('Reply on {network}', { network: of(channel.transport).name }) }), failed ? (_jsx(Text, { role: "alert", fontSize: "$2", color: "var(--state-error)", children: failed })) : null] })) : (_jsx(Text, { fontSize: "$2", color: "$soft", children: t('This message names no channel to answer in.') })) })] }));
140
154
  }
141
155
  function InboxGrip({ span, onSpan, }) {
142
156
  const { t, dir } = useI18n();
143
157
  // The list stands at the start: under right to left a pull toward the start widens it.
144
158
  const way = dir === 'rtl' ? -1 : 1;
145
159
  const held = useRef(0);
146
- return (_jsx(Box, { render: "div", role: "separator", "aria-orientation": "vertical", "aria-label": t('Resize inbox channel list'), "aria-valuenow": span, tabIndex: 0, position: "absolute", t: 0, b: 0, insetInlineEnd: -3, width: 6, z: 10, cursor: "col-resize", hoverStyle: { bg: '$borderColor' }, onPointerDown: (e) => {
160
+ return (_jsx(Box, { render: "div", role: "separator", "aria-orientation": "vertical", "aria-label": t('Resize inbox channel list'), "aria-valuenow": span, tabIndex: 0, display: "none", $md: { display: 'flex' }, position: "absolute", t: 0, b: 0, insetInlineEnd: -3, width: 6, z: "var(--z-raised)", cursor: "col-resize", hoverStyle: { bg: 'var(--border-strong)' }, focusVisibleStyle: { bg: 'var(--ring)' }, onPointerDown: (e) => {
147
161
  e.currentTarget.setPointerCapture(e.pointerId);
148
162
  held.current = e.clientX * way - span;
149
163
  }, onPointerMove: (e) => {
@@ -176,11 +190,11 @@ function ReadingInbox() {
176
190
  });
177
191
  const open = useMemo(() => conversationOf(conversations, channel), [conversations, channel]);
178
192
  if (loading && conversations.length === 0)
179
- return _jsx(Empty, { children: t('Reading your messages.') });
193
+ return _jsx(InboxSkeleton, { span: listSpan });
180
194
  if (conversations.length === 0) {
181
195
  return (_jsx(Empty, { offer: true, children: t('Nothing has arrived yet. Connect an app and the messages it carries land here — mail, chat, and the networks your work already happens on.') }));
182
196
  }
183
- return (_jsxs(XStack, { flex: 1, minH: 0, position: "relative", children: [_jsxs(YStack, { display: open ? 'none' : 'flex', $md: { display: 'flex', width: listSpan, shrink: 0, borderInlineEndWidth: 1 }, flex: 1, minH: 0, borderColor: "$borderColor", position: "relative", children: [_jsx(Arrivals, { conversations: conversations, open: channel, onPick: openChannel }), _jsx(InboxGrip, { span: listSpan, onSpan: setListSpan })] }), open ? (_jsx(YStack, { flex: 1, minW: 0, minH: 0, children: _jsx(Reading, { channel: open.arrival, reload: reload }) })) : (_jsx(YStack, { display: "none", $md: { display: 'flex' }, flex: 1, minW: 0, children: _jsx(Empty, { children: t('Pick a conversation to read it.') }) }))] }));
197
+ return (_jsxs(XStack, { flex: 1, minH: 0, minW: 0, overflow: "hidden", position: "relative", children: [_jsxs(YStack, { display: open ? 'none' : 'flex', $md: { display: 'flex', width: listSpan, shrink: 0, borderInlineEndWidth: 1 }, flex: 1, minW: 0, minH: 0, borderColor: "$edge", position: "relative", children: [_jsx(Arrivals, { conversations: conversations, open: channel, onPick: openChannel }), _jsx(InboxGrip, { span: listSpan, onSpan: setListSpan })] }), open ? (_jsx(YStack, { flex: 1, minW: 0, minH: 0, children: _jsx(Reading, { channel: open.arrival, reload: reload, onBack: () => openChannel(null) }) })) : (_jsx(YStack, { display: "none", $md: { display: 'flex' }, flex: 1, minW: 0, children: _jsx(Empty, { children: t('Pick a conversation to read it.') }) }))] }));
184
198
  }
185
199
  /**
186
200
  * The pane, and the session its reads need.
@@ -193,6 +207,6 @@ function ReadingInbox() {
193
207
  export function Inbox() {
194
208
  const { isLoading } = useIam();
195
209
  if (isLoading)
196
- return _jsx(Empty, { children: "\u00A0" });
210
+ return _jsx(InboxSkeleton, {});
197
211
  return _jsx(ReadingInbox, {});
198
212
  }
@@ -0,0 +1,6 @@
1
+ /** Inline rename field drawn directly inside a ThreadRow: Enter saves, Escape cancels, empty string ignored. */
2
+ export declare function InlineRename({ initial, onSave, onCancel, }: {
3
+ initial: string;
4
+ onSave: (title: string) => void;
5
+ onCancel: () => void;
6
+ }): import("react").JSX.Element;
@@ -0,0 +1,41 @@
1
+ 'use client';
2
+ import { jsx as _jsx } from "react/jsx-runtime";
3
+ import { useRef, useState } from 'react';
4
+ import { useI18n } from '@hanzo/i18n/react';
5
+ import { Input } from '@hanzo/ui';
6
+ import { XStack } from '@hanzo/gui';
7
+ /** Inline rename field drawn directly inside a ThreadRow: Enter saves, Escape cancels, empty string ignored. */
8
+ export function InlineRename({ initial, onSave, onCancel, }) {
9
+ const { t } = useI18n();
10
+ const [words, setWords] = useState(initial);
11
+ const doneRef = useRef(false);
12
+ const commit = () => {
13
+ if (doneRef.current)
14
+ return;
15
+ doneRef.current = true;
16
+ const clean = words.trim();
17
+ if (!clean) {
18
+ onCancel();
19
+ return;
20
+ }
21
+ onSave(clean);
22
+ };
23
+ const cancel = () => {
24
+ if (doneRef.current)
25
+ return;
26
+ doneRef.current = true;
27
+ onCancel();
28
+ };
29
+ return (_jsx(XStack, { px: "$1", py: "$0.5", items: "center", width: "100%", minW: 0, children: _jsx(Input, { "data-slot": "thread-inline-rename", size: "sm", autoFocus: true, value: words, onChangeText: setWords, "aria-label": t('Chat title'), maxLength: 80, flex: 1, minW: 0, height: 29, rounded: 8, bg: "$panel", color: "$ink", borderWidth: 1, borderColor: "var(--border-strong)", focusVisibleStyle: { outlineWidth: 2, outlineStyle: 'solid', outlineColor: 'var(--ring)' }, $touchable: { minH: 44 }, "$max-sm": { minH: 44 }, onFocus: (e) => e.target?.select?.(), onBlur: commit, onKeyDown: (e) => {
30
+ e.stopPropagation?.();
31
+ if (e.key === 'Escape') {
32
+ e.preventDefault?.();
33
+ cancel();
34
+ return;
35
+ }
36
+ if (e.key === 'Enter' && !e.nativeEvent?.isComposing && e.keyCode !== 229) {
37
+ e.preventDefault?.();
38
+ commit();
39
+ }
40
+ } }) }));
41
+ }
package/dist/Learning.js CHANGED
@@ -1,31 +1,70 @@
1
1
  'use client';
2
2
  import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import { useEffect, useId, useRef, useState } from 'react';
4
+ import { Beaker, BookOpen, ChartBar, ChevronDown, ChevronUp, CircleAlert, FlaskConical, Plus, RefreshCw, ShieldCheck, SlidersHorizontal, TrendingDown, TrendingUp, X, } from 'lucide-react';
3
5
  import { useI18n } from '@hanzo/i18n/react';
4
6
  import { useIam } from '@hanzo/iam/react';
5
- import { useEffect, useRef, useState } from 'react';
6
- import { Button, Dialog, DialogContent, DialogTitle, Input, Text, XStack, YStack } from '@hanzo/ui';
7
+ import { Box, Button, Dialog, DialogContent, DialogTitle, Input, Skeleton, Text, XStack, YStack } from '@hanzo/ui';
7
8
  import { say } from './failure.js';
8
9
  import { org } from './lib/session.js';
9
- import { learningAnalyze, learningCompare, learningCreate, learningRead } from './lib/learning.js';
10
+ import { learningAnalyze, learningCompare, learningCreate, learningRead, } from './lib/learning.js';
10
11
  export * from './lib/learning.js';
12
+ const TABS = ['research', 'experiments', 'benchmarks'];
13
+ const INITIAL_VISIBLE = 5;
14
+ const INK = 'var(--foreground)';
15
+ const SOFT = 'var(--muted-foreground)';
16
+ const STRONG = 'var(--border-strong)';
17
+ const ERR = 'var(--state-error)';
18
+ const OK = 'var(--state-success)';
19
+ const FOCUS_RING = { outlineWidth: 2, outlineStyle: 'solid', outlineColor: 'var(--ring)', outlineOffset: 2 };
20
+ function CardsSkeleton({ label, count = 3 }) {
21
+ return (_jsx(YStack, { role: "status", "aria-busy": true, "aria-label": label, gap: "$2.5", width: "100%", children: Array.from({ length: count }, (_, i) => (_jsxs(YStack, { gap: "$2", p: "$3.5", rounded: "$4", borderWidth: 1, borderColor: "$edge", bg: "$panel", children: [_jsxs(XStack, { items: "center", justify: "space-between", gap: "$3", children: [_jsx(Skeleton, { layout: "block", width: i % 2 === 0 ? '42%' : '54%', height: 14, rounded: "$2" }), _jsx(Skeleton, { layout: "block", width: 96, height: 20, rounded: 999, shrink: 0 })] }), _jsx(Skeleton, { layout: "block", width: i % 2 === 0 ? '84%' : '72%', height: 11, rounded: "$2" })] }, i))) }));
22
+ }
23
+ function ErrorCallout({ message }) {
24
+ return (_jsxs(XStack, { role: "alert", items: "center", gap: "$2", px: "$3", py: "$2.5", rounded: "$3", borderWidth: 1, borderColor: ERR, bg: "$panel", children: [_jsx(CircleAlert, { size: 15, color: ERR, "aria-hidden": true }), _jsx(Text, { fontSize: "$2", color: ERR, flex: 1, minW: 0, children: message })] }));
25
+ }
26
+ function EmptyCard({ title, detail, children }) {
27
+ return (_jsxs(YStack, { py: "$6", px: "$4", items: "center", gap: "$2.5", rounded: "$4", borderWidth: 1, borderColor: "$edge", bg: "$panel", children: [_jsxs(YStack, { items: "center", gap: "$1", maxW: 440, children: [_jsx(Text, { fontSize: "$3", fontWeight: "500", color: "$ink", text: "center", children: title }), _jsx(Text, { fontSize: "$2", color: "$soft", text: "center", children: detail })] }), children ? (_jsx(XStack, { gap: "$2", flexWrap: "wrap", justify: "center", children: children })) : null] }));
28
+ }
29
+ function StatusPill({ label, active = false }) {
30
+ return (_jsxs(XStack, { items: "center", gap: "$1.5", px: "$2", py: 2, rounded: 999, borderWidth: 1, borderColor: active ? STRONG : '$edge', bg: "$background", shrink: 0, children: [_jsx(YStack, { width: 6, height: 6, rounded: 999, bg: active ? OK : '$soft', shrink: 0, "aria-hidden": true }), _jsx(Text, { fontSize: "$1", fontWeight: "500", color: active ? '$ink' : '$soft', children: label })] }));
31
+ }
11
32
  /** The user's actual evidence and findings. Closed dialogs make no API requests. */
12
33
  export function Learning({ open, onClose }) {
13
34
  const { t } = useI18n();
14
35
  const { accessToken } = useIam();
36
+ const tabId = useId();
15
37
  const tenant = org();
16
38
  const identity = `${tenant}:${accessToken ?? ''}`;
17
39
  const [held, setHeld] = useState({ identity: '', answers: {} });
18
40
  const [revision, setRevision] = useState(0);
19
41
  const [tab, setTab] = useState('research');
20
42
  const [form, setForm] = useState(false);
43
+ const [advancedCriteria, setAdvancedCriteria] = useState(false);
44
+ const [compareOpen, setCompareOpen] = useState(false);
45
+ const [showAllStudies, setShowAllStudies] = useState(false);
46
+ const [showAllReviews, setShowAllReviews] = useState(false);
47
+ const [showAllExperiments, setShowAllExperiments] = useState(false);
48
+ const [showAllBenchmarks, setShowAllBenchmarks] = useState(false);
21
49
  const [busy, setBusy] = useState(false);
22
50
  const [problem, setProblem] = useState(null);
23
51
  const draftId = useRef('');
24
52
  const [measuring, setMeasuring] = useState(false);
53
+ const [analyzingId, setAnalyzingId] = useState('');
25
54
  const [measured, setMeasured] = useState({ identity: '' });
26
55
  const [pair, setPair] = useState({ benchmark: '', a: '', b: '' });
27
56
  const results = measured.identity === identity ? measured : null;
28
- const [proposal, setProposal] = useState({ title: '', question: '', baseline: '', target: '', metric: 'accuracy', category: 'all', direction: 'higher', minQuestions: 20, minGain: 1 });
57
+ const [proposal, setProposal] = useState({
58
+ title: '',
59
+ question: '',
60
+ baseline: '',
61
+ target: '',
62
+ metric: 'accuracy',
63
+ category: 'all',
64
+ direction: 'higher',
65
+ minQuestions: 20,
66
+ minGain: 1,
67
+ });
29
68
  const answers = held.identity === identity ? held.answers : {};
30
69
  useEffect(() => {
31
70
  if (!open || !accessToken)
@@ -33,9 +72,13 @@ export function Learning({ open, onClose }) {
33
72
  const controller = new AbortController();
34
73
  setHeld({ identity, answers: {} });
35
74
  for (const part of ['studies', 'reviews', 'experiments', 'benchmarks']) {
36
- void learningRead(part, controller.signal).then((rows) => { if (!controller.signal.aborted)
37
- setHeld((old) => ({ identity, answers: { ...old.answers, [part]: { rows } } })); }, (error) => { if (!controller.signal.aborted)
38
- setHeld((old) => ({ identity, answers: { ...old.answers, [part]: { error } } })); });
75
+ void learningRead(part, controller.signal).then((rows) => {
76
+ if (!controller.signal.aborted)
77
+ setHeld((old) => ({ identity, answers: { ...old.answers, [part]: { rows } } }));
78
+ }, (error) => {
79
+ if (!controller.signal.aborted)
80
+ setHeld((old) => ({ identity, answers: { ...old.answers, [part]: { error } } }));
81
+ });
39
82
  }
40
83
  return () => controller.abort();
41
84
  }, [open, accessToken, identity, revision]);
@@ -50,6 +93,7 @@ export function Learning({ open, onClose }) {
50
93
  await learningCreate(proposal, draftId.current);
51
94
  draftId.current = '';
52
95
  setForm(false);
96
+ setAdvancedCriteria(false);
53
97
  setRevision((n) => n + 1);
54
98
  }
55
99
  catch (error) {
@@ -61,6 +105,7 @@ export function Learning({ open, onClose }) {
61
105
  };
62
106
  const analyze = async (id) => {
63
107
  setMeasuring(true);
108
+ setAnalyzingId(id);
64
109
  setMeasured({ identity });
65
110
  try {
66
111
  setMeasured({ identity, analysis: await learningAnalyze(id) });
@@ -70,6 +115,7 @@ export function Learning({ open, onClose }) {
70
115
  }
71
116
  finally {
72
117
  setMeasuring(false);
118
+ setAnalyzingId('');
73
119
  }
74
120
  };
75
121
  const compare = async () => {
@@ -85,10 +131,83 @@ export function Learning({ open, onClose }) {
85
131
  setMeasuring(false);
86
132
  }
87
133
  };
88
- const state = (part) => answers[part]?.error
89
- ? _jsx(Text, { role: "alert", color: "$soft", children: say(answers[part]?.error, t('your learning activity'), 'read', t) })
90
- : !answers[part]?.rows ? _jsx(Text, { color: "$soft", children: t('Loading…') }) : null;
91
- const field = (key, label) => (_jsxs(YStack, { gap: "$1", children: [_jsx(Text, { fontSize: "$2", children: label }), _jsx(Input, { "aria-label": label, value: proposal[key], onChangeText: (value) => setProposal((old) => ({ ...old, [key]: value })) })] }));
92
- return _jsx(Dialog, { open: open, onOpenChange: (next) => { if (!next)
93
- onClose(); }, children: _jsx(DialogContent, { width: "100%", maxW: 900, p: "$5", children: _jsxs(YStack, { gap: "$4", maxH: "80vh", overflow: "scroll", children: [_jsx(DialogTitle, { children: _jsx(Text, { fontSize: "$5", children: t('Learning') }) }), _jsx(Text, { color: "$soft", children: t('Research, test ideas, and review improvements backed by your workspace’s evidence.') }), !accessToken ? _jsx(Text, { role: "status", children: t('Sign in to see your learning activity.') }) : _jsxs(_Fragment, { children: [_jsxs(XStack, { gap: "$2", flexWrap: "wrap", role: "tablist", "aria-label": t('Learning'), children: [_jsx(Button, { role: "tab", "aria-selected": tab === 'research', onPress: () => setTab('research'), children: t('Research') }), _jsx(Button, { role: "tab", "aria-selected": tab === 'experiments', onPress: () => setTab('experiments'), children: t('Experiments') }), _jsx(Button, { role: "tab", "aria-selected": tab === 'benchmarks', onPress: () => setTab('benchmarks'), children: t('Benchmarks') }), _jsx(Button, { size: "sm", onPress: () => setRevision((n) => n + 1), children: t('Refresh') })] }), tab === 'research' ? _jsxs(YStack, { gap: "$3", children: [_jsx(Text, { color: "$soft", children: t('A study with a baseline and acceptance criteria reviews new results as they arrive. Findings remain drafts until reviewed.') }), !form ? _jsx(Button, { size: "sm", onPress: () => setForm(true), children: t('New improvement study') }) : null, form ? _jsx("form", { onSubmit: (event) => { event.preventDefault(); void create(); }, children: _jsxs(YStack, { gap: "$2", children: [field('title', t('Title')), field('question', t('Research question')), field('baseline', t('Baseline run ID')), field('target', t('App, harness, skill or connector')), field('category', t('Metric category')), field('metric', t('Primary metric')), _jsx(XStack, { gap: "$2", children: _jsx(Button, { type: "button", size: "sm", onPress: () => setProposal((p) => ({ ...p, direction: p.direction === 'higher' ? 'lower' : 'higher' })), children: proposal.direction === 'higher' ? t('Higher is better') : t('Lower is better') }) }), _jsx(Text, { fontSize: "$2", children: t('Minimum completed evaluation size') }), _jsx(Input, { "aria-label": t('Minimum completed evaluation size'), type: "number", value: String(proposal.minQuestions), onChangeText: (v) => setProposal((p) => ({ ...p, minQuestions: Number(v) })) }), _jsx(Text, { fontSize: "$2", children: t('Minimum gain in metric units') }), _jsx(Input, { "aria-label": t('Minimum gain in metric units'), type: "number", value: String(proposal.minGain), onChangeText: (v) => setProposal((p) => ({ ...p, minGain: Number(v) })) }), _jsx(Text, { color: "$soft", children: t('This enables evaluation of recorded results. It does not start a model call or change a live app.') }), problem ? _jsx(Text, { role: "alert", children: say(problem, t('this study'), 'save', t) }) : null, _jsx(Button, { type: "submit", disabled: busy || !proposal.baseline.trim() || !proposal.target.trim() || !proposal.title.trim() || !proposal.question.trim() || !proposal.metric.trim() || !Number.isInteger(proposal.minQuestions) || proposal.minQuestions < 1 || !Number.isFinite(proposal.minGain) || proposal.minGain < 0, children: busy ? t('Saving…') : t('Enable study') })] }) }) : null, state('studies'), answers.studies?.rows?.map((study) => _jsxs(YStack, { gap: "$1", p: "$3", bg: "$panel", rounded: "$3", children: [_jsx(Text, { children: study.title || study.id }), _jsx(Text, { color: "$soft", children: study.question }), _jsx(Text, { fontSize: "$2", children: study.improvement ? t('Automatic review enabled') : t('Evidence only') })] }, `${study.project}:${study.id}`)), answers.studies?.rows?.length === 0 ? _jsx(Text, { color: "$soft", children: t('No studies yet. Create one to review recorded results continuously.') }) : null, _jsx(Text, { fontSize: "$4", children: t('Improvement findings') }), answers.studies?.error && answers.reviews?.error ? null : state('reviews'), answers.reviews?.rows?.map((row) => _jsxs(YStack, { gap: "$1", p: "$3", bg: "$panel", rounded: "$3", children: [_jsx(Text, { children: row.action.review?.target }), _jsxs(Text, { children: [row.action.review?.status, " \u00B7 ", row.status] }), _jsx(Text, { color: "$soft", children: row.action.description }), row.action.review?.blocks?.map((block, i) => _jsx(Text, { fontSize: "$2", color: "$soft", children: block }, i))] }, row.id)), answers.reviews?.rows?.length === 0 ? _jsx(Text, { color: "$soft", children: t('Findings appear when a study has baseline and candidate results. No result is being claimed yet.') }) : null] }) : tab === 'experiments' ? _jsxs(YStack, { gap: "$3", children: [_jsx(Text, { color: "$soft", children: t('Controlled experiments assign variants and measure their outcomes. Choosing a winner changes a live rollout and requires an authorized review.') }), state('experiments'), answers.experiments?.rows?.map((row) => _jsxs(YStack, { gap: "$1", p: "$3", bg: "$panel", rounded: "$3", children: [_jsx(Text, { children: row.name || row.id }), _jsxs(Text, { color: "$soft", children: [row.status, row.winner ? ` · ${row.winner}` : ''] }), _jsx(Button, { size: "sm", disabled: measuring, onPress: () => void analyze(row.id), children: t('Analyze outcomes') })] }, row.id)), results?.error ? _jsx(Text, { role: "alert", children: say(results.error, t('this experiment'), 'read', t) }) : null, results?.analysis?.results?.map((row) => _jsxs(YStack, { gap: "$1", children: [_jsx(Text, { children: row.variant }), _jsx(Text, { color: "$soft", children: t('{converted} of {exposed} converted', { converted: row.converted, exposed: row.exposed }) })] }, row.variant)), answers.experiments?.rows?.length === 0 ? _jsx(Text, { color: "$soft", children: t('No controlled experiments yet.') }) : null] }) : _jsxs(YStack, { gap: "$3", children: [_jsx(Text, { color: "$soft", children: t('Benchmarks compare actual measurements. Requesting a benchmark result does not execute an evaluation harness.') }), state('benchmarks'), _jsx(Input, { "aria-label": t('Benchmark ID'), placeholder: t('Benchmark ID'), value: pair.benchmark, onChangeText: (benchmark) => setPair((p) => ({ ...p, benchmark })) }), _jsx(Input, { "aria-label": t('First model ID'), placeholder: t('First model ID'), value: pair.a, onChangeText: (a) => setPair((p) => ({ ...p, a })) }), _jsx(Input, { "aria-label": t('Second model ID'), placeholder: t('Second model ID'), value: pair.b, onChangeText: (b) => setPair((p) => ({ ...p, b })) }), _jsx(Button, { disabled: measuring || !pair.benchmark.trim() || !pair.a.trim() || !pair.b.trim(), onPress: () => void compare(), children: t('Compare measurements') }), results?.error ? _jsx(Text, { role: "alert", children: say(results.error, t('these benchmark results'), 'read', t) }) : null, results?.comparison ? _jsx(YStack, { gap: "$1", children: results.comparison.n_common === 0 ? _jsx(Text, { children: t('No shared measured items. Record both evaluations before comparing.') }) : _jsxs(_Fragment, { children: [_jsx(Text, { children: t('{count} shared measured items', { count: results.comparison.n_common }) }), _jsxs(Text, { children: [results.comparison.a, ": ", results.comparison.a_correct, " \u00B7 ", results.comparison.b, ": ", results.comparison.b_correct] })] }) }) : null, answers.benchmarks?.rows?.map((row) => _jsxs(YStack, { gap: "$1", p: "$3", bg: "$panel", rounded: "$3", children: [_jsx(Text, { children: row.name || row.id }), _jsx(Text, { color: "$soft", children: row.direction === 'lower' ? t('Lower is better') : t('Higher is better') }), _jsx(Button, { size: "sm", onPress: () => setPair((p) => ({ ...p, benchmark: row.id })), children: t('Use this benchmark') })] }, row.id))] })] })] }) }) });
134
+ const state = (part, loadingLabel) => answers[part]?.error ? (_jsx(ErrorCallout, { message: say(answers[part]?.error, t('your learning activity'), 'read', t) })) : !answers[part]?.rows ? (_jsx(CardsSkeleton, { label: loadingLabel, count: part === 'reviews' ? 2 : 3 })) : null;
135
+ const field = (key, label, placeholder, row = false) => (_jsxs(YStack, { gap: "$1.5", ...(row ? { flex: 1, minW: 0, '$max-sm': { flexBasis: 'auto', grow: 0, minW: 0, width: '100%' } } : null), children: [_jsx(Text, { fontSize: "$2", fontWeight: "500", color: "$ink", children: label }), _jsx(Input, { "aria-label": label, placeholder: placeholder, value: proposal[key], borderColor: STRONG, bg: "$background", onChangeText: (value) => setProposal((old) => ({ ...old, [key]: value })) })] }));
136
+ const studiesRows = answers.studies?.rows;
137
+ const reviewsRows = answers.reviews?.rows;
138
+ const experimentsRows = answers.experiments?.rows;
139
+ const benchmarksRows = answers.benchmarks?.rows;
140
+ const canCreate = !busy &&
141
+ Boolean(proposal.baseline.trim()) &&
142
+ Boolean(proposal.target.trim()) &&
143
+ Boolean(proposal.title.trim()) &&
144
+ Boolean(proposal.question.trim()) &&
145
+ Boolean(proposal.metric.trim()) &&
146
+ Number.isInteger(proposal.minQuestions) &&
147
+ proposal.minQuestions >= 1 &&
148
+ Number.isFinite(proposal.minGain) &&
149
+ proposal.minGain >= 0;
150
+ const tabMeta = {
151
+ research: { label: t('Research'), icon: _jsx(BookOpen, { size: 14, color: tab === 'research' ? INK : SOFT, "aria-hidden": true }), count: studiesRows?.length },
152
+ experiments: { label: t('Experiments'), icon: _jsx(Beaker, { size: 14, color: tab === 'experiments' ? INK : SOFT, "aria-hidden": true }), count: experimentsRows?.length },
153
+ benchmarks: { label: t('Benchmarks'), icon: _jsx(ChartBar, { size: 14, color: tab === 'benchmarks' ? INK : SOFT, "aria-hidden": true }), count: benchmarksRows?.length },
154
+ };
155
+ const visibleStudies = showAllStudies ? studiesRows : studiesRows?.slice(0, INITIAL_VISIBLE);
156
+ const visibleReviews = showAllReviews ? reviewsRows : reviewsRows?.slice(0, INITIAL_VISIBLE);
157
+ const visibleExperiments = showAllExperiments ? experimentsRows : experimentsRows?.slice(0, INITIAL_VISIBLE);
158
+ const visibleBenchmarks = showAllBenchmarks ? benchmarksRows : benchmarksRows?.slice(0, INITIAL_VISIBLE);
159
+ const showCompareForm = compareOpen || Boolean(results?.comparison) || Boolean(pair.benchmark.trim()) || benchmarksRows?.length === 0;
160
+ return (_jsx(Dialog, { open: open, onOpenChange: (next) => {
161
+ if (!next)
162
+ onClose();
163
+ }, children: _jsxs(DialogContent, { width: "100%", maxW: 860, maxH: "88vh", "$max-sm": { maxH: '94dvh' }, p: 0, gap: 0, showCloseButton: false, overflow: "hidden", bg: "$background", borderWidth: 1, borderColor: STRONG, tabIndex: -1, focusVisibleStyle: { outlineWidth: 0 }, children: [_jsxs(XStack, { items: "center", justify: "space-between", gap: "$3", px: "$5", py: "$4", "$max-sm": { px: '$4', py: '$3.5' }, borderBottomWidth: 1, borderColor: "$edge", children: [_jsxs(XStack, { items: "center", gap: "$3", flex: 1, minW: 0, children: [_jsx(XStack, { width: 34, height: 34, rounded: "$3", bg: "$panel", borderWidth: 1, borderColor: "$edge", items: "center", justify: "center", shrink: 0, "aria-hidden": true, children: _jsx(FlaskConical, { size: 16, color: INK, "aria-hidden": true }) }), _jsxs(YStack, { flex: 1, minW: 0, gap: "$0.5", children: [_jsx(DialogTitle, { children: _jsx(Text, { fontSize: "$5", fontWeight: "600", color: "$ink", numberOfLines: 1, children: t('Learning') }) }), _jsx(Text, { fontSize: "$2", color: "$soft", numberOfLines: 2, children: t('Research, test ideas, and review improvements backed by your workspace’s evidence.') })] })] }), _jsxs(XStack, { items: "center", gap: "$1", shrink: 0, children: [accessToken ? (_jsx(Box, { render: _jsx("button", { type: "button" }), "aria-label": t('Refresh'), onClick: () => setRevision((n) => n + 1), width: 32, height: 32, $touchable: { minW: 44, minH: 44 }, "$max-sm": { minW: 44, minH: 44 }, rounded: "$2", display: "inline-flex", items: "center", justify: "center", cursor: "pointer", hoverStyle: { bg: '$hover' }, focusVisibleStyle: FOCUS_RING, children: _jsx(RefreshCw, { size: 15, color: SOFT, "aria-hidden": true }) })) : null, _jsx(Box, { render: _jsx("button", { type: "button" }), "aria-label": t('Close'), onClick: onClose, width: 32, height: 32, $touchable: { minW: 44, minH: 44 }, "$max-sm": { minW: 44, minH: 44 }, rounded: "$2", display: "inline-flex", items: "center", justify: "center", cursor: "pointer", hoverStyle: { bg: '$hover' }, focusVisibleStyle: FOCUS_RING, children: _jsx(X, { size: 16, color: SOFT, "aria-hidden": true }) })] })] }), _jsx(YStack, { flex: 1, minH: 0, overflow: "scroll", px: "$5", py: "$4", "$max-sm": { px: '$4', py: '$3.5' }, gap: "$4", children: !accessToken ? (_jsx(YStack, { role: "status", children: _jsx(EmptyCard, { title: t('Sign in required'), detail: t('Sign in to see your learning activity.') }) })) : (_jsxs(_Fragment, { children: [_jsxs(XStack, { items: "center", justify: "space-between", gap: "$3", flexWrap: "wrap", "$max-sm": { flexDirection: 'column', items: 'stretch' }, children: [_jsx(XStack, { role: "tablist", "aria-label": t('Learning'), p: 3, gap: 2, rounded: "$3", borderWidth: 1, borderColor: STRONG, bg: "$panel", flexWrap: "wrap", children: TABS.map((id, idx) => {
164
+ const active = tab === id;
165
+ const meta = tabMeta[id];
166
+ return (_jsxs(Box, { id: `${tabId}-${id}`, render: _jsx("button", { type: "button" }), role: "tab", "aria-selected": active, "aria-controls": `${tabId}-panel`, tabIndex: active ? 0 : -1, onClick: () => setTab(id), onKeyDown: ((e) => {
167
+ let nextIdx = null;
168
+ if (e.key === 'ArrowRight')
169
+ nextIdx = (idx + 1) % TABS.length;
170
+ else if (e.key === 'ArrowLeft')
171
+ nextIdx = (idx - 1 + TABS.length) % TABS.length;
172
+ else if (e.key === 'Home')
173
+ nextIdx = 0;
174
+ else if (e.key === 'End')
175
+ nextIdx = TABS.length - 1;
176
+ if (nextIdx === null)
177
+ return;
178
+ e.preventDefault?.();
179
+ const nextTab = TABS[nextIdx];
180
+ if (!nextTab)
181
+ return;
182
+ setTab(nextTab);
183
+ queueMicrotask(() => document.getElementById(`${tabId}-${nextTab}`)?.focus());
184
+ }), display: "inline-flex", items: "center", justify: "center", gap: "$1.5", px: "$3", py: "$1.5", minH: 32, $touchable: { minH: 44 }, "$max-sm": { minH: 44, flex: 1 }, rounded: "$2", cursor: "pointer", bg: active ? '$raised' : 'transparent', hoverStyle: { bg: active ? '$raised' : '$hover' }, focusVisibleStyle: FOCUS_RING, children: [meta.icon, _jsx(Text, { fontSize: "$2", fontWeight: active ? '600' : '400', color: active ? '$ink' : '$soft', children: meta.label }), typeof meta.count === 'number' && meta.count > 0 ? (_jsx(Text, { fontSize: "$1", color: "$soft", fontVariant: ['tabular-nums'], children: meta.count })) : null] }, id));
185
+ }) }), tab === 'research' && !form ? (_jsxs(Button, { size: "sm", variant: "primary", tone: "accent", "$max-sm": { width: '100%' }, onPress: () => setForm(true), children: [_jsx(Plus, { size: 14 }), " ", t('New improvement study')] })) : tab === 'benchmarks' && !showCompareForm ? (_jsxs(Button, { size: "sm", variant: "outline", borderColor: STRONG, "$max-sm": { width: '100%' }, onPress: () => setCompareOpen(true), children: [_jsx(SlidersHorizontal, { size: 14 }), " ", t('Compare models')] })) : null] }), _jsx(YStack, { role: "tabpanel", id: `${tabId}-panel`, "aria-labelledby": `${tabId}-${tab}`, gap: "$4", children: tab === 'research' ? (_jsxs(YStack, { gap: "$4", children: [_jsx(Text, { fontSize: "$2", color: "$soft", children: t('A study with a baseline and acceptance criteria reviews new results as they arrive. Findings remain drafts until reviewed.') }), form ? (_jsx("form", { onSubmit: (event) => {
186
+ event.preventDefault();
187
+ void create();
188
+ }, children: _jsxs(YStack, { gap: "$3", p: "$4", rounded: "$4", borderWidth: 1, borderColor: STRONG, bg: "$panel", children: [_jsxs(XStack, { items: "center", justify: "space-between", gap: "$2", children: [_jsx(Text, { fontSize: "$3", fontWeight: "600", color: "$ink", children: t('New improvement study') }), _jsx(Box, { render: _jsx("button", { type: "button" }), "aria-label": t('Cancel'), onClick: () => {
189
+ setForm(false);
190
+ setProblem(null);
191
+ }, width: 32, height: 32, $touchable: { minW: 44, minH: 44 }, "$max-sm": { minW: 44, minH: 44 }, rounded: "$2", display: "inline-flex", items: "center", justify: "center", cursor: "pointer", hoverStyle: { bg: '$hover' }, focusVisibleStyle: FOCUS_RING, children: _jsx(X, { size: 15, color: SOFT, "aria-hidden": true }) })] }), _jsxs(XStack, { gap: "$3", "$max-sm": { flexDirection: 'column', items: 'stretch' }, children: [field('title', t('Title'), t('Recovery correctness'), true), field('target', t('App, harness, skill or connector'), 'hanzoai/dev', true)] }), field('question', t('Research question'), t('Does the new recovery path improve accuracy?')), field('baseline', t('Baseline run ID'), 'run_...'), _jsxs(YStack, { rounded: "$3", borderWidth: 1, borderColor: "$edge", bg: "$background", overflow: "hidden", children: [_jsxs(Box, { render: _jsx("button", { type: "button" }), "aria-expanded": advancedCriteria, onClick: () => setAdvancedCriteria((v) => !v), width: "100%", px: "$3", py: "$2.5", minH: 44, display: "flex", items: "center", justify: "space-between", gap: "$2", cursor: "pointer", hoverStyle: { bg: '$hover' }, focusVisibleStyle: { outlineWidth: 2, outlineStyle: 'solid', outlineColor: 'var(--ring)', outlineOffset: -2 }, "$platform-web": { textAlign: 'start' }, children: [_jsxs(YStack, { flex: 1, minW: 0, gap: "$0.5", children: [_jsx(Text, { fontSize: "$2", fontWeight: "500", color: "$ink", children: t('Evaluation criteria') }), _jsx(Text, { fontSize: "$1", color: "$soft", numberOfLines: 1, children: t('{metric} · {direction} · min {min} · gain {gain}', {
192
+ metric: proposal.metric || 'accuracy',
193
+ direction: proposal.direction === 'higher' ? t('Higher is better') : t('Lower is better'),
194
+ min: proposal.minQuestions,
195
+ gain: proposal.minGain,
196
+ }) })] }), advancedCriteria ? _jsx(ChevronUp, { size: 15, color: SOFT, "aria-hidden": true }) : _jsx(ChevronDown, { size: 15, color: SOFT, "aria-hidden": true })] }), advancedCriteria ? (_jsxs(YStack, { p: "$3", gap: "$3", borderTopWidth: 1, borderColor: "$edge", children: [_jsxs(XStack, { gap: "$3", "$max-sm": { flexDirection: 'column', items: 'stretch' }, children: [field('category', t('Metric category'), 'all', true), field('metric', t('Primary metric'), 'accuracy', true)] }), _jsxs(XStack, { gap: "$3", items: "flex-end", "$max-sm": { flexDirection: 'column', items: 'stretch' }, children: [_jsxs(YStack, { gap: "$1.5", flex: 1, minW: 0, "$max-sm": { flexBasis: 'auto', grow: 0, minW: 0, width: '100%' }, children: [_jsx(Text, { fontSize: "$2", fontWeight: "500", color: "$ink", children: t('Minimum completed evaluation size') }), _jsx(Input, { "aria-label": t('Minimum completed evaluation size'), type: "number", borderColor: STRONG, bg: "$panel", value: String(proposal.minQuestions), onChangeText: (v) => setProposal((p) => ({ ...p, minQuestions: Number(v) })) })] }), _jsxs(YStack, { gap: "$1.5", flex: 1, minW: 0, "$max-sm": { flexBasis: 'auto', grow: 0, minW: 0, width: '100%' }, children: [_jsx(Text, { fontSize: "$2", fontWeight: "500", color: "$ink", children: t('Minimum gain in metric units') }), _jsx(Input, { "aria-label": t('Minimum gain in metric units'), type: "number", borderColor: STRONG, bg: "$panel", value: String(proposal.minGain), onChangeText: (v) => setProposal((p) => ({ ...p, minGain: Number(v) })) })] }), _jsxs(Button, { type: "button", size: "sm", variant: "outline", borderColor: STRONG, shrink: 0, onPress: () => setProposal((p) => ({ ...p, direction: p.direction === 'higher' ? 'lower' : 'higher' })), children: [proposal.direction === 'higher' ? _jsx(TrendingUp, { size: 14, "aria-hidden": true }) : _jsx(TrendingDown, { size: 14, "aria-hidden": true }), proposal.direction === 'higher' ? t('Higher is better') : t('Lower is better')] })] })] })) : null] }), _jsxs(XStack, { items: "center", gap: "$2", children: [_jsx(ShieldCheck, { size: 14, color: SOFT, "aria-hidden": true }), _jsx(Text, { fontSize: "$1", color: "$soft", flex: 1, minW: 0, children: t('This enables evaluation of recorded results. It does not start a model call or change a live app.') })] }), problem ? _jsx(ErrorCallout, { message: say(problem, t('this study'), 'save', t) }) : null, _jsxs(XStack, { gap: "$2", justify: "flex-end", flexWrap: "wrap", children: [_jsx(Button, { type: "button", size: "sm", variant: "ghost", disabled: busy, onPress: () => {
197
+ setForm(false);
198
+ setProblem(null);
199
+ }, children: t('Cancel') }), _jsx(Button, { type: "submit", size: "sm", variant: "primary", tone: "accent", disabled: !canCreate, children: busy ? t('Saving…') : t('Enable study') })] })] }) })) : null, _jsxs(YStack, { gap: "$2.5", children: [_jsxs(XStack, { items: "center", justify: "space-between", gap: "$2", children: [_jsx(Text, { fontSize: "$3", fontWeight: "600", color: "$ink", children: t('Studies') }), studiesRows?.length ? (_jsx(Text, { fontSize: "$1", color: "$soft", fontVariant: ['tabular-nums'], children: t('{n} total', { n: studiesRows.length }) })) : null] }), state('studies', t('Loading studies')), visibleStudies?.map((study) => (_jsxs(YStack, { gap: "$1.5", p: "$3.5", rounded: "$4", borderWidth: 1, borderColor: "$edge", bg: "$panel", children: [_jsxs(XStack, { items: "center", justify: "space-between", gap: "$2", flexWrap: "wrap", children: [_jsx(Text, { fontSize: "$3", fontWeight: "500", color: "$ink", flex: 1, minW: 0, children: study.title || study.id }), _jsx(StatusPill, { label: study.improvement ? t('Automatic review enabled') : t('Evidence only'), active: Boolean(study.improvement) })] }), study.question ? (_jsx(Text, { fontSize: "$2", color: "$soft", children: study.question })) : null, study.improvement ? (_jsxs(Text, { fontSize: "$1", color: "$soft", fontFamily: "$mono", children: [study.improvement.target, " \u00B7 ", study.improvement.baseline] })) : null] }, `${study.project}:${study.id}`))), studiesRows && studiesRows.length > INITIAL_VISIBLE ? (_jsx(XStack, { children: _jsx(Button, { size: "sm", variant: "outline", borderColor: STRONG, onPress: () => setShowAllStudies((v) => !v), children: showAllStudies ? t('Show fewer') : t('Show all {n} studies', { n: studiesRows.length }) }) })) : null, studiesRows?.length === 0 ? (_jsx(EmptyCard, { title: t('No studies yet'), detail: t('No studies yet. Create one to review recorded results continuously.'), children: !form ? (_jsxs(Button, { size: "sm", variant: "outline", borderColor: STRONG, onPress: () => setForm(true), children: [_jsx(Plus, { size: 14 }), " ", t('New improvement study')] })) : null })) : null] }), _jsxs(YStack, { gap: "$2.5", children: [_jsxs(XStack, { items: "center", justify: "space-between", gap: "$2", children: [_jsx(Text, { fontSize: "$3", fontWeight: "600", color: "$ink", children: t('Improvement findings') }), reviewsRows?.length ? (_jsx(Text, { fontSize: "$1", color: "$soft", fontVariant: ['tabular-nums'], children: t('{n} total', { n: reviewsRows.length }) })) : null] }), answers.studies?.error && answers.reviews?.error ? null : state('reviews', t('Loading improvement findings')), visibleReviews?.map((row) => (_jsxs(YStack, { gap: "$1.5", p: "$3.5", rounded: "$4", borderWidth: 1, borderColor: "$edge", bg: "$panel", children: [_jsxs(XStack, { items: "center", justify: "space-between", gap: "$2", flexWrap: "wrap", children: [_jsx(Text, { fontSize: "$3", fontWeight: "500", color: "$ink", fontFamily: "$mono", flex: 1, minW: 0, children: row.action.review?.target || row.id }), _jsx(StatusPill, { label: [row.action.review?.status, row.status].filter(Boolean).join(' · ') })] }), row.action.description ? (_jsx(Text, { fontSize: "$2", color: "$soft", children: row.action.description })) : null, row.action.review?.blocks?.length ? (_jsx(YStack, { gap: "$1", pt: "$1", borderTopWidth: 1, borderColor: "$edge", children: row.action.review.blocks.map((block, i) => (_jsx(Text, { fontSize: "$1", color: "$soft", children: block }, i))) })) : null] }, row.id))), reviewsRows && reviewsRows.length > INITIAL_VISIBLE ? (_jsx(XStack, { children: _jsx(Button, { size: "sm", variant: "outline", borderColor: STRONG, onPress: () => setShowAllReviews((v) => !v), children: showAllReviews ? t('Show fewer') : t('Show all {n} findings', { n: reviewsRows.length }) }) })) : null, reviewsRows?.length === 0 ? (_jsx(EmptyCard, { title: t('No findings yet'), detail: t('Findings appear when a study has baseline and candidate results. No result is being claimed yet.') })) : null] })] })) : tab === 'experiments' ? (_jsxs(YStack, { gap: "$3.5", children: [_jsx(Text, { fontSize: "$2", color: "$soft", children: t('Controlled experiments assign variants and measure their outcomes. Choosing a winner changes a live rollout and requires an authorized review.') }), results?.error ? _jsx(ErrorCallout, { message: say(results.error, t('this experiment'), 'read', t) }) : null, results?.analysis ? (_jsxs(YStack, { gap: "$3", p: "$4", rounded: "$4", borderWidth: 1, borderColor: STRONG, bg: "$panel", children: [_jsxs(XStack, { items: "center", justify: "space-between", gap: "$2", children: [_jsxs(XStack, { items: "center", gap: "$2", flexWrap: "wrap", flex: 1, minW: 0, children: [_jsx(Text, { fontSize: "$3", fontWeight: "600", color: "$ink", children: t('Outcome analysis') }), results.analysis.winner ? _jsx(StatusPill, { label: t('Leading: {winner}', { winner: results.analysis.winner }), active: true }) : null] }), _jsx(Box, { render: _jsx("button", { type: "button" }), "aria-label": t('Dismiss analysis'), onClick: () => setMeasured({ identity }), width: 32, height: 32, $touchable: { minW: 44, minH: 44 }, "$max-sm": { minW: 44, minH: 44 }, rounded: "$2", display: "inline-flex", items: "center", justify: "center", cursor: "pointer", hoverStyle: { bg: '$hover' }, focusVisibleStyle: FOCUS_RING, children: _jsx(X, { size: 15, color: SOFT, "aria-hidden": true }) })] }), _jsx(YStack, { gap: "$2.5", children: results.analysis.results?.map((row) => {
200
+ const pct = Math.max(0, Math.min(100, Number.isFinite(row.rate) ? row.rate * 100 : row.exposed > 0 ? (row.converted / row.exposed) * 100 : 0));
201
+ return (_jsxs(YStack, { gap: "$1.5", p: "$3", rounded: "$3", borderWidth: 1, borderColor: "$edge", bg: "$background", children: [_jsxs(XStack, { items: "center", justify: "space-between", gap: "$2", flexWrap: "wrap", children: [_jsx(Text, { fontSize: "$2", fontWeight: "500", color: "$ink", children: row.variant }), _jsxs(XStack, { items: "center", gap: "$2", children: [row.significant ? _jsx(StatusPill, { label: t('Significant'), active: true }) : null, _jsx(Text, { fontSize: "$2", fontWeight: "600", color: "$ink", fontVariant: ['tabular-nums'], children: `${pct.toFixed(1)}%` })] })] }), _jsx(YStack, { height: 6, rounded: 999, bg: "$hover", overflow: "hidden", children: _jsx(YStack, { height: 6, width: `${pct}%`, rounded: 999, bg: "$ink" }) }), _jsx(Text, { fontSize: "$1", color: "$soft", fontVariant: ['tabular-nums'], children: t('{converted} of {exposed} converted', { converted: row.converted, exposed: row.exposed }) })] }, row.variant));
202
+ }) })] })) : null, state('experiments', t('Loading experiments')), visibleExperiments?.map((row) => (_jsxs(XStack, { items: "center", justify: "space-between", gap: "$3", p: "$3.5", rounded: "$4", borderWidth: 1, borderColor: "$edge", bg: "$panel", "$max-sm": { flexDirection: 'column', items: 'stretch' }, children: [_jsxs(YStack, { flex: 1, minW: 0, gap: "$1", "$max-sm": { flexBasis: 'auto', grow: 0, minW: 0, width: '100%' }, children: [_jsx(Text, { fontSize: "$3", fontWeight: "500", color: "$ink", children: row.name || row.id }), _jsxs(XStack, { items: "center", gap: "$2", flexWrap: "wrap", children: [_jsx(StatusPill, { label: row.status, active: Boolean(row.winner) }), row.winner ? (_jsx(Text, { fontSize: "$1", color: "$soft", children: t('Winner: {winner}', { winner: row.winner }) })) : null] })] }), _jsx(Button, { size: "sm", variant: "outline", borderColor: STRONG, shrink: 0, disabled: measuring, onPress: () => void analyze(row.id), children: measuring && analyzingId === row.id ? t('Analyzing…') : t('Analyze outcomes') })] }, row.id))), experimentsRows && experimentsRows.length > INITIAL_VISIBLE ? (_jsx(XStack, { children: _jsx(Button, { size: "sm", variant: "outline", borderColor: STRONG, onPress: () => setShowAllExperiments((v) => !v), children: showAllExperiments ? t('Show fewer') : t('Show all {n} experiments', { n: experimentsRows.length }) }) })) : null, experimentsRows?.length === 0 ? (_jsx(EmptyCard, { title: t('No controlled experiments yet'), detail: t('Experiments appear here once a rollout test is configured for your workspace.') })) : null] })) : (_jsxs(YStack, { gap: "$4", children: [_jsx(Text, { fontSize: "$2", color: "$soft", children: t('Benchmarks compare actual measurements. Requesting a benchmark result does not execute an evaluation harness.') }), showCompareForm ? (_jsxs(YStack, { gap: "$3", p: "$4", rounded: "$4", borderWidth: 1, borderColor: STRONG, bg: "$panel", children: [_jsxs(XStack, { items: "center", justify: "space-between", gap: "$2", children: [_jsx(Text, { fontSize: "$3", fontWeight: "600", color: "$ink", children: t('Compare two models') }), benchmarksRows && benchmarksRows.length > 0 ? (_jsx(Box, { render: _jsx("button", { type: "button" }), "aria-label": t('Hide comparison'), onClick: () => {
203
+ setCompareOpen(false);
204
+ setPair({ benchmark: '', a: '', b: '' });
205
+ setMeasured({ identity });
206
+ }, width: 32, height: 32, $touchable: { minW: 44, minH: 44 }, "$max-sm": { minW: 44, minH: 44 }, rounded: "$2", display: "inline-flex", items: "center", justify: "center", cursor: "pointer", hoverStyle: { bg: '$hover' }, focusVisibleStyle: FOCUS_RING, children: _jsx(X, { size: 15, color: SOFT, "aria-hidden": true }) })) : null] }), _jsxs(XStack, { gap: "$2.5", "$max-sm": { flexDirection: 'column', items: 'stretch' }, children: [_jsxs(YStack, { gap: "$1.5", flex: 1, minW: 0, "$max-sm": { flexBasis: 'auto', grow: 0, minW: 0, width: '100%' }, children: [_jsx(Text, { fontSize: "$2", fontWeight: "500", color: "$ink", children: t('Benchmark ID') }), _jsx(Input, { "aria-label": t('Benchmark ID'), placeholder: "gpqa_diamond", borderColor: STRONG, bg: "$background", value: pair.benchmark, onChangeText: (benchmark) => setPair((p) => ({ ...p, benchmark })) })] }), _jsxs(YStack, { gap: "$1.5", flex: 1, minW: 0, "$max-sm": { flexBasis: 'auto', grow: 0, minW: 0, width: '100%' }, children: [_jsx(Text, { fontSize: "$2", fontWeight: "500", color: "$ink", children: t('First model ID') }), _jsx(Input, { "aria-label": t('First model ID'), placeholder: t('First model ID'), borderColor: STRONG, bg: "$background", value: pair.a, onChangeText: (a) => setPair((p) => ({ ...p, a })) })] }), _jsxs(YStack, { gap: "$1.5", flex: 1, minW: 0, "$max-sm": { flexBasis: 'auto', grow: 0, minW: 0, width: '100%' }, children: [_jsx(Text, { fontSize: "$2", fontWeight: "500", color: "$ink", children: t('Second model ID') }), _jsx(Input, { "aria-label": t('Second model ID'), placeholder: t('Second model ID'), borderColor: STRONG, bg: "$background", value: pair.b, onChangeText: (b) => setPair((p) => ({ ...p, b })) })] })] }), _jsx(XStack, { justify: "flex-end", children: _jsx(Button, { size: "sm", variant: "primary", tone: "accent", "$max-sm": { width: '100%' }, disabled: measuring || !pair.benchmark.trim() || !pair.a.trim() || !pair.b.trim(), onPress: () => void compare(), children: measuring ? t('Comparing…') : t('Compare measurements') }) }), results?.error ? _jsx(ErrorCallout, { message: say(results.error, t('these benchmark results'), 'read', t) }) : null, results?.comparison ? (_jsx(YStack, { gap: "$2", p: "$3", rounded: "$3", borderWidth: 1, borderColor: "$edge", bg: "$background", children: results.comparison.n_common === 0 ? (_jsx(Text, { fontSize: "$2", color: "$soft", children: t('No shared measured items. Record both evaluations before comparing.') })) : (_jsxs(_Fragment, { children: [_jsxs(XStack, { items: "center", justify: "space-between", gap: "$2", flexWrap: "wrap", children: [_jsx(Text, { fontSize: "$2", fontWeight: "500", color: "$ink", fontVariant: ['tabular-nums'], children: t('{count} shared measured items', { count: results.comparison.n_common }) }), Number.isFinite(results.comparison.mcnemar_p) ? (_jsx(Text, { fontSize: "$1", color: "$soft", fontFamily: "$mono", fontVariant: ['tabular-nums'], children: `p = ${results.comparison.mcnemar_p.toFixed(4)}` })) : null] }), _jsxs(XStack, { gap: "$3", "$max-sm": { flexDirection: 'column', items: 'stretch' }, children: [_jsxs(YStack, { flex: 1, minW: 0, p: "$2.5", rounded: "$3", borderWidth: 1, borderColor: "$edge", bg: "$panel", gap: "$0.5", "$max-sm": { flexBasis: 'auto', grow: 0, minW: 0, width: '100%' }, children: [_jsx(Text, { fontSize: "$1", color: "$soft", fontFamily: "$mono", numberOfLines: 1, children: results.comparison.a }), _jsx(Text, { fontSize: "$4", fontWeight: "600", color: "$ink", fontVariant: ['tabular-nums'], children: String(results.comparison.a_correct) })] }), _jsxs(YStack, { flex: 1, minW: 0, p: "$2.5", rounded: "$3", borderWidth: 1, borderColor: "$edge", bg: "$panel", gap: "$0.5", "$max-sm": { flexBasis: 'auto', grow: 0, minW: 0, width: '100%' }, children: [_jsx(Text, { fontSize: "$1", color: "$soft", fontFamily: "$mono", numberOfLines: 1, children: results.comparison.b }), _jsx(Text, { fontSize: "$4", fontWeight: "600", color: "$ink", fontVariant: ['tabular-nums'], children: String(results.comparison.b_correct) })] })] })] })) })) : null] })) : null, _jsxs(YStack, { gap: "$2.5", children: [_jsxs(XStack, { items: "center", justify: "space-between", gap: "$2", children: [_jsx(Text, { fontSize: "$3", fontWeight: "600", color: "$ink", children: t('Benchmark catalog') }), benchmarksRows?.length ? (_jsx(Text, { fontSize: "$1", color: "$soft", fontVariant: ['tabular-nums'], children: t('{n} total', { n: benchmarksRows.length }) })) : null] }), state('benchmarks', t('Loading benchmarks')), visibleBenchmarks?.map((row) => {
207
+ const selected = pair.benchmark === row.id;
208
+ return (_jsxs(XStack, { items: "center", justify: "space-between", gap: "$3", p: "$3.5", rounded: "$4", borderWidth: 1, borderColor: selected ? STRONG : '$edge', bg: "$panel", "$max-sm": { flexDirection: 'column', items: 'stretch' }, children: [_jsxs(YStack, { flex: 1, minW: 0, gap: "$0.5", "$max-sm": { flexBasis: 'auto', grow: 0, minW: 0, width: '100%' }, children: [_jsx(Text, { fontSize: "$3", fontWeight: "500", color: "$ink", children: row.name || row.id }), _jsxs(XStack, { items: "center", gap: "$1.5", children: [row.direction === 'lower' ? _jsx(TrendingDown, { size: 13, color: SOFT, "aria-hidden": true }) : _jsx(TrendingUp, { size: 13, color: SOFT, "aria-hidden": true }), _jsx(Text, { fontSize: "$1", color: "$soft", children: row.direction === 'lower' ? t('Lower is better') : t('Higher is better') })] })] }), _jsx(Button, { size: "sm", variant: "outline", borderColor: STRONG, shrink: 0, onPress: () => {
209
+ setPair((p) => ({ ...p, benchmark: row.id }));
210
+ setCompareOpen(true);
211
+ }, children: selected ? t('Selected') : t('Use this benchmark') })] }, row.id));
212
+ }), benchmarksRows && benchmarksRows.length > INITIAL_VISIBLE ? (_jsx(XStack, { children: _jsx(Button, { size: "sm", variant: "outline", borderColor: STRONG, onPress: () => setShowAllBenchmarks((v) => !v), children: showAllBenchmarks ? t('Show fewer') : t('Show all {n} benchmarks', { n: benchmarksRows.length }) }) })) : null, benchmarksRows?.length === 0 ? (_jsx(EmptyCard, { title: t('No benchmarks listed'), detail: t('Enter any recorded benchmark ID above to compare two models.') })) : null] })] })) })] })) })] }) }));
94
213
  }
package/dist/Market.js CHANGED
@@ -24,6 +24,7 @@ import { useIam } from '@hanzo/iam/react';
24
24
  import { hasSession } from './lib/session.js';
25
25
  import { useAi } from './lib/ai.js';
26
26
  import { brand } from './where.js';
27
+ import { useDevMode } from './lib/dev-mode.js';
27
28
  /** A listing reachable over HTTP is one this app can connect on its own. */
28
29
  const reachable = (listing) => (listing.transports ?? []).includes('streamable-http');
29
30
  /** Labels a namespace carries that name no brand: `com.cloudflare.mcp` is
@@ -51,15 +52,18 @@ function Empty({ children }) {
51
52
  function Mark({ listing }) {
52
53
  return (_jsx(YStack, { width: 40, height: 40, shrink: 0, rounded: "$3", bg: "$panel", items: "center", justify: "center", overflow: "hidden", children: listing.logo ? (_jsx("img", { src: listing.logo, alt: "", width: 40, height: 40 })) : (_jsx(Text, { fontSize: "$4", fontWeight: "500", color: "$soft", children: label(listing).slice(0, 1).toUpperCase() })) }));
53
54
  }
54
- function Card({ listing, installed, onInstall, busy, }) {
55
+ function Card({ listing, installed, onInstall, busy, devMode, }) {
55
56
  const { t } = useI18n();
56
57
  const canInstall = reachable(listing);
57
- return (_jsxs(YStack, { width: 300, gap: "$3", p: "$4", borderWidth: 1, borderColor: "$borderColor", rounded: "$4", children: [_jsxs(XStack, { gap: "$3", items: "flex-start", children: [_jsx(Mark, { listing: listing }), _jsxs(YStack, { flex: 1, minW: 0, gap: "$1", children: [_jsx(Text, { fontSize: "$3", fontWeight: "500", color: "$ink", numberOfLines: 1, children: label(listing) }), _jsx(Text, { fontSize: "$1", color: "$soft", numberOfLines: 1, children: listing.vendor ?? '' })] })] }), _jsx(Text, { fontSize: "$2", color: "$soft", numberOfLines: 3, children: listing.description || t('No description published.') }), installed ? (_jsxs(XStack, { items: "center", gap: "$2", children: [_jsx(Check, { size: 14, "aria-hidden": true }), _jsx(Text, { fontSize: "$2", color: "$soft", children: t('Installed') })] })) : canInstall ? (_jsx(Box, { render: "button", onClick: onInstall, self: "flex-start", px: "$3", py: "$2", rounded: "$3", borderWidth: 1, borderColor: "$borderColor", hoverStyle: { bg: '$hover' }, children: _jsx(Text, { fontSize: "$2", color: "$ink", children: busy ? t('Installing') : t('Install') }) })) : (_jsx(Text, { fontSize: "$1", color: "$soft", children: t('Ships as a {kind} package — needs a runner before it can be connected.', {
58
- kind: (listing.packages ?? [])[0]?.registry ?? 'stdio',
59
- }) }))] }));
58
+ return (_jsxs(YStack, { width: 300, gap: "$3", p: "$4", borderWidth: 1, borderColor: "$edge", bg: "var(--surface-card)", rounded: "$5", children: [_jsxs(XStack, { gap: "$3", items: "flex-start", children: [_jsx(Mark, { listing: listing }), _jsxs(YStack, { flex: 1, minW: 0, gap: "$1", children: [_jsx(Text, { fontSize: "$3", fontWeight: "500", color: "$ink", numberOfLines: 1, children: label(listing) }), devMode && listing.vendor ? (_jsx(Text, { fontSize: "$1", color: "$soft", numberOfLines: 1, children: listing.vendor })) : null] })] }), _jsx(Text, { fontSize: "$2", color: "$soft", numberOfLines: 3, children: listing.description || t('No description published.') }), installed ? (_jsxs(XStack, { items: "center", gap: "$2", children: [_jsx(Check, { size: 14, "aria-hidden": true }), _jsx(Text, { fontSize: "$2", color: "$soft", children: t('Installed') })] })) : canInstall ? (_jsx(Box, { render: "button", onClick: onInstall, self: "flex-start", px: "$3", py: "$2", rounded: "$3", borderWidth: 1, borderColor: "$borderColor", hoverStyle: { bg: '$hover' }, cursor: "pointer", children: _jsx(Text, { fontSize: "$2", color: "$ink", children: busy ? t('Installing…') : t('Install') }) })) : (_jsx(Text, { fontSize: "$1", color: "$soft", children: devMode
59
+ ? t('Ships as a {kind} package — run locally via Hanzo CLI or Desktop.', {
60
+ kind: (listing.packages ?? [])[0]?.registry ?? 'stdio',
61
+ })
62
+ : t('Runs on your computer — open Hanzo Desktop to connect.') }))] }));
60
63
  }
61
64
  export function Market({ scope }) {
62
65
  const { t } = useI18n();
66
+ const [devMode] = useDevMode();
63
67
  const { client } = useAi();
64
68
  // SIGNED IN IS THE CREDENTIAL, NOT THE PROFILE. This gated on `user`, which is
65
69
  // the answer to a userinfo REQUEST — and `IamProvider` swallows that request's
@@ -143,13 +147,13 @@ export function Market({ scope }) {
143
147
  return _jsx(Empty, { children: t('Sign in to browse agents you can add.') });
144
148
  if (failed)
145
149
  return _jsx(Empty, { children: say(failed, t('the marketplace'), 'read', t) });
146
- return (_jsxs(YStack, { flex: 1, minH: 0, children: [_jsxs(YStack, { p: "$5", gap: "$2", borderBottomWidth: 1, borderColor: "$borderColor", children: [_jsx(Text, { fontSize: "$7", lineHeight: "$7", fontWeight: "500", color: "$ink", children: t('Put AI to work in {brand}', { brand: brand() }) }), _jsx(Text, { fontSize: "$3", color: "$soft", children: t('Browse agents that bring your tools into {brand}.', { brand: brand() }) }), _jsxs(XStack, { items: "center", justify: "space-between", flexWrap: "wrap", gap: "$2", mt: "$2", children: [_jsxs(XStack, { width: 420, maxW: "100%", height: 36, items: "center", gap: "$2", px: "$3", rounded: "$3", borderWidth: 1, borderColor: "$borderColor", children: [_jsx(Search, { size: 14, "aria-hidden": true }), _jsx(Text, { render: _jsx("input", { value: ask, onChange: (e) => setAsk(e.target.value), placeholder: t('Search agents'), "aria-label": t('Search agents') }), flex: 1, bg: "transparent", borderWidth: 0, outlineStyle: "none", color: "inherit" })] }), _jsxs(XStack, { render: "button", onPress: () => window.open('https://hanzo.market', '_blank', 'noopener,noreferrer'), height: 36, px: "$3", rounded: "$3", borderWidth: 1, borderColor: "$borderColor", items: "center", gap: "$1.5", cursor: "pointer", hoverStyle: { bg: '$hover' }, children: [_jsx(Compass, { size: 14, "aria-hidden": true }), _jsx(Text, { fontSize: "$2", fontWeight: "500", color: "$ink", children: t('Explore on hanzo.market') }), _jsx(ArrowUpRight, { size: 13, "aria-hidden": true, color: "$soft" })] })] })] }), !listings ? (_jsx(Empty, { children: t('Reading the shelf.') })) : shown.length === 0 ? (_jsx(Empty, { children: scope === 'installed'
147
- ? t('No agents installed yet.')
150
+ return (_jsxs(YStack, { flex: 1, minH: 0, children: [_jsxs(YStack, { p: "$5", gap: "$2", borderBottomWidth: 1, borderColor: "$borderColor", children: [_jsx(Text, { fontSize: "$7", lineHeight: "$7", fontWeight: "500", color: "$ink", children: t('Put AI to work in {brand}', { brand: brand() }) }), _jsx(Text, { fontSize: "$3", color: "$soft", children: t('Browse agents that bring your tools into {brand}.', { brand: brand() }) }), _jsxs(XStack, { items: "center", justify: "space-between", flexWrap: "wrap", gap: "$2", mt: "$2", children: [_jsxs(XStack, { width: 420, maxW: "100%", height: 36, items: "center", gap: "$2", px: "$3", rounded: "$3", borderWidth: 1, borderColor: "$borderColor", children: [_jsx(Search, { size: 14, "aria-hidden": true }), _jsx(Text, { render: _jsx("input", { value: ask, onChange: (e) => setAsk(e.target.value), placeholder: t('Search agents'), "aria-label": t('Search agents') }), flex: 1, bg: "transparent", borderWidth: 0, outlineStyle: "none", color: "inherit" })] }), _jsxs(XStack, { render: _jsx("button", { type: "button" }), onClick: () => window.open('https://hanzo.market', '_blank', 'noopener,noreferrer'), height: 36, px: "$3", rounded: "$3", borderWidth: 1, borderColor: "$borderColor", items: "center", gap: "$1.5", cursor: "pointer", hoverStyle: { bg: '$hover' }, children: [_jsx(Compass, { size: 14, "aria-hidden": true }), _jsx(Text, { fontSize: "$2", fontWeight: "500", color: "$ink", children: t('Explore on hanzo.market') }), _jsx(ArrowUpRight, { size: 13, "aria-hidden": true, color: "$soft" })] })] })] }), !listings ? (_jsx(Empty, { children: t('Loading integrations…') })) : shown.length === 0 ? (_jsx(Empty, { children: scope === 'installed'
151
+ ? t('No integrations installed yet.')
148
152
  : ask
149
- ? t('Nothing in the registry matches that.')
150
- : t('The shelf is empty — the catalog has not been synced yet.') })) : (_jsxs(YStack, { flex: 1, minH: 0, overflowY: "auto", overflowX: "hidden", p: "$5", gap: "$3", children: [_jsx(Text, { fontSize: "$1", color: "$soft", children: scope === 'installed'
153
+ ? t('No matching integrations found.')
154
+ : t('No integrations available right now.') })) : (_jsxs(YStack, { flex: 1, minH: 0, overflowY: "auto", overflowX: "hidden", p: "$5", gap: "$3", children: [_jsx(Text, { fontSize: "$1", color: "$soft", children: scope === 'installed'
151
155
  ? t('{count} installed', { count: shown.length })
152
156
  : ask
153
157
  ? t('{count} of {total} matching', { count: shown.length, total })
154
- : t('{count} featured', { count: shown.length }) }), _jsx(XStack, { flexWrap: "wrap", gap: "$3", children: shown.map((listing) => (_jsx(Card, { listing: listing, installed: installed.has(listing.id), busy: busy === listing.id, onInstall: () => void install(listing) }, listing.id))) })] }))] }));
158
+ : t('{count} featured', { count: shown.length }) }), _jsx(XStack, { flexWrap: "wrap", gap: "$3", children: shown.map((listing) => (_jsx(Card, { listing: listing, installed: installed.has(listing.id), busy: busy === listing.id, devMode: devMode, onInstall: () => void install(listing) }, listing.id))) })] }))] }));
155
159
  }
package/dist/Meet.d.ts CHANGED
@@ -6,4 +6,9 @@ export interface MeetingAgent {
6
6
  voice: string;
7
7
  }
8
8
  export declare const AVAILABLE_MEETING_AGENTS: MeetingAgent[];
9
+ /** The invited agents and the co-pilot after `name` is asked or sent away: the co-pilot is the first one asked, and when it leaves the next in line takes over. */
10
+ export declare function invited(agents: string[], copilot: string | null, name: string): {
11
+ invited: string[];
12
+ copilot: string | null;
13
+ };
9
14
  export declare function Meet(): React.JSX.Element;