@hanzo/app 0.3.94 → 0.3.96

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 (110) 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 +114 -48
  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/PreferencesDialog.js +5 -2
  30. package/dist/Rail.d.ts +73 -7
  31. package/dist/Rail.js +372 -111
  32. package/dist/Recents.js +77 -24
  33. package/dist/RightPane.js +2 -2
  34. package/dist/Search.d.ts +13 -1
  35. package/dist/Search.js +366 -50
  36. package/dist/Setup.js +34 -5
  37. package/dist/Shared.js +12 -12
  38. package/dist/Shell.d.ts +10 -0
  39. package/dist/Shell.js +258 -158
  40. package/dist/Sidebar.d.ts +14 -3
  41. package/dist/Sidebar.js +411 -129
  42. package/dist/SkipLink.d.ts +8 -0
  43. package/dist/SkipLink.js +11 -0
  44. package/dist/Start.js +51 -52
  45. package/dist/Terminals.js +159 -11
  46. package/dist/ToBottom.js +1 -1
  47. package/dist/Upgrade.d.ts +8 -3
  48. package/dist/Upgrade.js +194 -103
  49. package/dist/Usage.d.ts +1 -1
  50. package/dist/Usage.js +186 -82
  51. package/dist/WalletPill.js +8 -2
  52. package/dist/Work.js +162 -53
  53. package/dist/archive.d.ts +8 -0
  54. package/dist/archive.js +16 -0
  55. package/dist/bots/Bots.js +16 -1
  56. package/dist/bots/ComputerDialog.js +53 -26
  57. package/dist/bots/ConnectorsDialog.js +34 -15
  58. package/dist/bots/Make.js +5 -1
  59. package/dist/bots/Panel.js +37 -31
  60. package/dist/bots/Roster.d.ts +4 -1
  61. package/dist/bots/Roster.js +71 -25
  62. package/dist/bots/Thread.js +54 -27
  63. package/dist/bots/face.js +9 -3
  64. package/dist/bots/grid.d.ts +36 -0
  65. package/dist/bots/grid.js +91 -0
  66. package/dist/bots/ink.d.ts +1 -1
  67. package/dist/bots/ink.js +1 -1
  68. package/dist/bots/kit.d.ts +9 -4
  69. package/dist/bots/kit.js +3 -2
  70. package/dist/chord.d.ts +13 -0
  71. package/dist/chord.js +30 -1
  72. package/dist/crew.js +47 -4
  73. package/dist/ground.d.ts +2 -2
  74. package/dist/ground.js +3 -3
  75. package/dist/help.d.ts +7 -3
  76. package/dist/help.js +19 -14
  77. package/dist/keys.d.ts +28 -0
  78. package/dist/keys.js +58 -0
  79. package/dist/lib/arrival.d.ts +5 -0
  80. package/dist/lib/arrival.js +10 -0
  81. package/dist/lib/betas.d.ts +2 -0
  82. package/dist/lib/betas.js +10 -0
  83. package/dist/lib/branch.d.ts +11 -0
  84. package/dist/lib/branch.js +11 -0
  85. package/dist/lib/chatPreferences.d.ts +1 -1
  86. package/dist/lib/chatPreferences.js +1 -1
  87. package/dist/lib/dev-mode.d.ts +18 -0
  88. package/dist/lib/dev-mode.js +102 -0
  89. package/dist/lib/durable.d.ts +1 -1
  90. package/dist/lib/durable.js +1 -1
  91. package/dist/lib/info-hint.d.ts +7 -0
  92. package/dist/lib/info-hint.js +8 -0
  93. package/dist/lib/model-picker.d.ts +2 -0
  94. package/dist/lib/model-picker.js +12 -0
  95. package/dist/lib/owners.d.ts +5 -0
  96. package/dist/lib/owners.js +15 -0
  97. package/dist/lib/pay.d.ts +2 -0
  98. package/dist/lib/pay.js +4 -0
  99. package/dist/lib/todo.d.ts +7 -1
  100. package/dist/lib/todo.js +41 -29
  101. package/dist/look.js +39 -8
  102. package/dist/rail-open.d.ts +9 -0
  103. package/dist/rail-open.js +34 -0
  104. package/dist/renaming.d.ts +10 -0
  105. package/dist/renaming.js +25 -0
  106. package/dist/seek.d.ts +6 -1
  107. package/dist/seek.js +13 -0
  108. package/dist/thread.d.ts +2 -1
  109. package/dist/thread.js +85 -44
  110. package/package.json +11 -11
package/dist/Work.js CHANGED
@@ -12,19 +12,74 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
12
12
  // so a fan-out is invisible until you ask for it: each root with `children > 0`
13
13
  // gets one `tree` read, and `nest` is not needed here because the server
14
14
  // already materialises the nesting. A root with no children costs no request.
15
- import { useCallback, useEffect, useMemo, useState } from 'react';
15
+ import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
16
+ import { Plus } from 'lucide-react';
16
17
  import { useAi, useSession, useSessions } from '@hanzo/ai/react';
17
18
  import { useOpen } from './open.js';
18
19
  import { asked, KEY } from './watch.js';
19
20
  import { AgentBoard, ChannelHeader, Pane, ProgressBlock, Steer, steps, } from '@hanzo/ui/agents';
20
- import { Text, XStack, YStack } from '@hanzo/ui';
21
+ import { Box, Button, Skeleton, Text, XStack, YStack } from '@hanzo/ui';
21
22
  import { useIam } from '@hanzo/iam/react';
23
+ import { enter, LOGIN } from './lib/destination.js';
22
24
  import { useI18n } from '@hanzo/i18n/react';
23
25
  import { Composer } from '@hanzo/ui/chat';
24
26
  import { Start } from './Start.js';
25
27
  import { Bar } from './progress.js';
26
28
  /** The server's four statuses, plus the honest fallback for anything else. */
27
29
  const STATUS = (s) => s === 'running' || s === 'paused' || s === 'done' || s === 'error' ? s : 'unknown';
30
+ /** Format elapsed duration in crisp human units: `14s`, `2m 10s`, `1h 4m`. */
31
+ function formatDuration(startedAt, endedAt, nowMs = Date.now()) {
32
+ if (!startedAt)
33
+ return null;
34
+ const start = Date.parse(startedAt);
35
+ const end = endedAt ? Date.parse(endedAt) : nowMs;
36
+ if (!Number.isFinite(start) || !Number.isFinite(end))
37
+ return null;
38
+ const totalSec = Math.max(0, Math.floor((end - start) / 1000));
39
+ if (totalSec < 60)
40
+ return `${totalSec}s`;
41
+ if (totalSec < 3600) {
42
+ const mins = Math.floor(totalSec / 60);
43
+ const secs = totalSec % 60;
44
+ return secs > 0 ? `${mins}m ${secs}s` : `${mins}m`;
45
+ }
46
+ const hours = Math.floor(totalSec / 3600);
47
+ const mins = Math.floor((totalSec % 3600) / 60);
48
+ return mins > 0 ? `${hours}h ${mins}m` : `${hours}h`;
49
+ }
50
+ function statusLabel(status, t) {
51
+ switch (status) {
52
+ case 'running':
53
+ return t('Running');
54
+ case 'paused':
55
+ return t('Needs review');
56
+ case 'done':
57
+ return t('Done');
58
+ case 'error':
59
+ return t('Failed');
60
+ default:
61
+ return t('Queued');
62
+ }
63
+ }
64
+ function matchesFilter(status, filter) {
65
+ if (filter === 'all')
66
+ return true;
67
+ if (filter === 'running')
68
+ return status === 'running';
69
+ if (filter === 'review')
70
+ return status === 'paused';
71
+ if (filter === 'done')
72
+ return status === 'done';
73
+ return status === 'error';
74
+ }
75
+ /** Calm monochrome layout-matched skeleton for the runs sidebar list. */
76
+ function RunsSkeleton({ label }) {
77
+ return (_jsxs(YStack, { role: "status", "aria-busy": true, "aria-label": label, gap: "$2.5", p: "$3", width: "100%", children: [_jsx(Skeleton, { layout: "block", width: 72, height: 11, rounded: "$2" }), [0, 1, 2, 3].map((i) => (_jsxs(XStack, { items: "center", gap: "$2.5", p: "$2.5", rounded: "$3", borderWidth: 1, borderColor: "$edge", bg: "$panel", children: [_jsx(Skeleton, { layout: "block", width: 8, height: 8, rounded: 9999, shrink: 0 }), _jsxs(YStack, { flex: 1, minW: 0, gap: "$1.5", children: [_jsx(Skeleton, { layout: "block", width: i % 2 === 0 ? '78%' : '64%', height: 13, rounded: "$2" }), _jsx(Skeleton, { layout: "block", width: i % 2 === 0 ? '48%' : '38%', height: 10, rounded: "$2" })] }), _jsx(Skeleton, { layout: "block", width: 36, height: 11, rounded: "$2", shrink: 0 })] }, i)))] }));
78
+ }
79
+ /** Calm monochrome layout-matched skeleton for the full Mission Control workspace. */
80
+ function WorkWorkspaceSkeleton({ label }) {
81
+ return (_jsxs(YStack, { role: "status", "aria-busy": true, "aria-label": label, flex: 1, minH: 0, width: "100%", overflow: "hidden", $lg: { flexDirection: 'row' }, children: [_jsx(YStack, { width: "100%", height: 200, shrink: 0, borderBottomWidth: 1, borderColor: "$edge", $lg: { width: 280, height: '100%', borderBottomWidth: 0, borderRightWidth: 1 }, children: _jsx(RunsSkeleton, { label: label }) }), _jsxs(YStack, { flex: 1, minW: 0, minH: 0, p: "$5", gap: "$4", children: [_jsxs(XStack, { items: "center", justify: "space-between", gap: "$3", children: [_jsx(Skeleton, { layout: "block", width: 220, height: 20, rounded: "$2" }), _jsx(Skeleton, { layout: "block", width: 68, height: 20, rounded: "$10" })] }), _jsxs(YStack, { gap: "$3", p: "$4", rounded: "$4", borderWidth: 1, borderColor: "$edge", bg: "$panel", children: [_jsx(Skeleton, { layout: "block", width: "60%", height: 14, rounded: "$2" }), _jsx(Skeleton, { layout: "block", width: "88%", height: 12, rounded: "$2" }), _jsx(Skeleton, { layout: "block", width: "72%", height: 12, rounded: "$2" })] })] })] }));
82
+ }
28
83
  /**
29
84
  * A session as the board reads it.
30
85
  *
@@ -65,19 +120,25 @@ const previewOf = (preview, t) => {
65
120
  default: return kind.replace(/_/g, ' ');
66
121
  }
67
122
  };
68
- const toRun = (s, t, children = []) => ({
69
- id: s.id,
70
- agent: s.agent || s.title || s.id,
71
- status: STATUS(s.status),
72
- doing: previewOf(s.lastEvent?.preview, t),
73
- target: s.target,
74
- project: s.project,
75
- children,
76
- });
123
+ const toRun = (s, t, nowMs, children = []) => {
124
+ const status = STATUS(s.status);
125
+ const ended = status === 'running' ? undefined : (s.endedAt || s.updatedAt);
126
+ const elapsed = formatDuration(s.startedAt || s.createdAt, ended, nowMs);
127
+ const meta = [s.target, elapsed].filter(Boolean).join(' · ');
128
+ return {
129
+ id: s.id,
130
+ agent: s.title || s.agent || s.id,
131
+ status,
132
+ doing: previewOf(s.lastEvent?.preview, t),
133
+ target: meta || undefined,
134
+ project: s.project,
135
+ children,
136
+ };
137
+ };
77
138
  /** Flatten the server's tree into the board's, dropping the node we asked for. */
78
- const kidsOf = (node, t) =>
139
+ const kidsOf = (node, t, nowMs) =>
79
140
  // `children` is NULL on a leaf, not `[]` — the guard is load-bearing.
80
- (node?.children ?? []).map((child) => child.session ? toRun(child.session, t, kidsOf(child, t)) : null).filter((r) => r !== null);
141
+ (node?.children ?? []).map((child) => child.session ? toRun(child.session, t, nowMs, kidsOf(child, t, nowMs)) : null).filter((r) => r !== null);
81
142
  function Watching({ idle }) {
82
143
  const { t } = useI18n();
83
144
  const ai = useAi();
@@ -89,6 +150,16 @@ function Watching({ idle }) {
89
150
  // and the list is re-read when the id changes so the new row is there to open.
90
151
  const { session: open, openSession: setOpen } = useOpen();
91
152
  const [trees, setTrees] = useState({});
153
+ const [filter, setFilter] = useState('all');
154
+ const [nowMs, setNowMs] = useState(() => Date.now());
155
+ const safeSessions = useMemo(() => (Array.isArray(sessions) ? sessions : []), [sessions]);
156
+ const hasRunning = useMemo(() => safeSessions.some((s) => STATUS(s?.status) === 'running'), [safeSessions]);
157
+ useEffect(() => {
158
+ if (!hasRunning)
159
+ return;
160
+ const timer = window.setInterval(() => setNowMs(Date.now()), 1000);
161
+ return () => window.clearInterval(timer);
162
+ }, [hasRunning]);
92
163
  // A run the address names opens on arrival: Home's "{n} failed" sends
93
164
  // /work?session=<id> (./watch). The param is then dropped, the way Chat drops
94
165
  // `?thread=`, so the address is the board's own again and a reload does not
@@ -110,61 +181,88 @@ function Watching({ idle }) {
110
181
  // One `tree` read per root that says it has children. Roots without a
111
182
  // fan-out are left alone, so an org of solo runs costs exactly one request.
112
183
  useEffect(() => {
113
- const safeSessions = Array.isArray(sessions) ? sessions : [];
114
184
  const swarms = safeSessions.filter((s) => (s?.children ?? 0) > 0);
115
185
  if (!swarms.length)
116
186
  return;
117
187
  const stop = new AbortController();
188
+ const snapshotNow = Date.now();
118
189
  void Promise.all(swarms.map((s) => ai.sessions
119
190
  .tree(s.id, { signal: stop.signal })
120
- .then((node) => [s.id, kidsOf(node, t)])
191
+ .then((node) => [s.id, kidsOf(node, t, snapshotNow)])
121
192
  .catch(() => [s.id, []]))).then((pairs) => {
122
193
  if (!stop.signal.aborted)
123
194
  setTrees(Object.fromEntries(pairs));
124
195
  });
125
196
  return () => stop.abort();
126
- }, [ai, sessions, t]);
127
- const runs = useMemo(() => sessions.map((s) => toRun(s, t, trees[s.id] ?? [])), [sessions, trees, t]);
128
- return (_jsxs(YStack, { flex: 1, minH: 0, width: "100%", $lg: { flexDirection: 'row' }, children: [_jsx(YStack
129
- // AN EMPTY BOARD DRAWS NOTHING ACROSS THE TOP. As a full-width strip it
130
- // reserved 270px and a hairline for one line of grey text, and pushed
131
- // the pane's own content most of a screen down — a narrow window's
132
- // whole budget spent saying there is nothing to show. As a COLUMN it is
133
- // still worth drawing empty, because a column with a heading is where a
134
- // reader looks for the list; a strip is not.
197
+ }, [ai, safeSessions, t]);
198
+ const runs = useMemo(() => safeSessions.map((s) => toRun(s, t, nowMs, trees[s.id] ?? [])), [safeSessions, trees, t, nowMs]);
199
+ const counts = useMemo(() => {
200
+ let running = 0;
201
+ let review = 0;
202
+ let done = 0;
203
+ let failed = 0;
204
+ for (const r of runs) {
205
+ if (r.status === 'running')
206
+ running += 1;
207
+ else if (r.status === 'paused')
208
+ review += 1;
209
+ else if (r.status === 'done')
210
+ done += 1;
211
+ else if (r.status === 'error')
212
+ failed += 1;
213
+ }
214
+ return { all: runs.length, running, review, done, failed };
215
+ }, [runs]);
216
+ const visibleRuns = useMemo(() => runs.filter((r) => matchesFilter(r.status, filter)), [runs, filter]);
217
+ const [composing, setComposing] = useState(false);
218
+ const didAutoSelectRef = useRef(false);
219
+ useEffect(() => {
220
+ if (open)
221
+ setComposing(false);
222
+ }, [open]);
223
+ // Auto-select the first active (or most recent) run on mount/load so /work opens directly to live activity.
224
+ useEffect(() => {
225
+ if (didAutoSelectRef.current || composing || open || runs.length === 0)
226
+ return;
227
+ if (typeof window !== 'undefined' && new URLSearchParams(window.location.search).has(KEY))
228
+ return;
229
+ const latest = runs.find((r) => r.status === 'running') ?? runs[0];
230
+ if (latest) {
231
+ didAutoSelectRef.current = true;
232
+ setOpen(latest.id);
233
+ }
234
+ }, [composing, open, runs, setOpen]);
235
+ const filterPills = [
236
+ { id: 'all', label: t('All'), count: counts.all },
237
+ { id: 'running', label: t('Running'), count: counts.running },
238
+ { id: 'review', label: t('Needs review'), count: counts.review },
239
+ { id: 'done', label: t('Done'), count: counts.done },
240
+ { id: 'failed', label: t('Failed'), count: counts.failed },
241
+ ];
242
+ return (_jsxs(YStack, { flex: 1, minH: 0, width: "100%", overflow: "hidden", $lg: { flexDirection: 'row' }, children: [_jsxs(YStack
243
+ // AN EMPTY BOARD DRAWS NOTHING ACROSS THE TOP once settled. While loading,
244
+ // keep it mounted so the calm shimmer skeleton shows without layout jump.
135
245
  , {
136
- // AN EMPTY BOARD DRAWS NOTHING ACROSS THE TOP. As a full-width strip it
137
- // reserved 270px and a hairline for one line of grey text, and pushed
138
- // the pane's own content most of a screen down — a narrow window's
139
- // whole budget spent saying there is nothing to show. As a COLUMN it is
140
- // still worth drawing empty, because a column with a heading is where a
141
- // reader looks for the list; a strip is not.
142
- display: runs.length === 0 ? 'none' : 'flex', width: "100%",
143
- // A STRIP HAS A HEIGHT, and `maxHeight` could not give it one. The
144
- // board inside is a ScrollView at `flex: 1 1 0` — a zero basis — so in
145
- // a column with an auto height it measured 1px and the strip vanished.
146
- // "Up to 220" is not expressible over a child that contributes nothing;
147
- // 220 is.
148
- height: 220, shrink: 0, borderBottomWidth: 1,
149
- // A COLUMN NEEDS A WINDOW WIDE ENOUGH FOR TWO. At 640 this took 300 of
150
- // the 316px left after the rail and the sidebar, so the pane beside it
151
- // was 32px wide and the run itself was unreadable — a narrow strip with
152
- // a rule down it, which is what a squeezed column looks like. Above
153
- // 1024 there is space for both; below it the board is a strip across the
154
- // top and the run has the whole width under it.
155
- //
156
- // STATE THE VALUE, NEVER `undefined`. gui emits nothing for an
157
- // undefined value, so the base cap this block used to lift SURVIVED
158
- // into `$lg` and the full-height column described here was a 220px stub
159
- // at every width — measured in the browser at 1280.
160
- $lg: {
246
+ // AN EMPTY BOARD DRAWS NOTHING ACROSS THE TOP once settled. While loading,
247
+ // keep it mounted so the calm shimmer skeleton shows without layout jump.
248
+ display: runs.length === 0 && !loading ? 'none' : 'flex', width: "100%", height: 220, $sm: { height: 248 }, shrink: 0, borderBottomWidth: 1, $lg: {
161
249
  display: 'flex',
162
250
  width: 300,
163
251
  shrink: 0,
164
252
  height: '100%',
165
253
  borderBottomWidth: 0,
166
254
  borderRightWidth: 1,
167
- }, borderColor: "$borderColor", children: _jsx(AgentBoard, { runs: runs, active: open ?? undefined, onOpen: setOpen, empty: _jsx(Text, { fontSize: "$2", color: "$soft", children: loading ? t('Reading runs…') : t('No runs yet. Start one and it appears here.') }) }) }), _jsx(YStack, { width: "100%", flex: 1, minW: 0, minH: 0, $lg: { width: 'auto' }, children: open ? _jsx(Watch, { id: open }, open) : (idle ?? _jsx(Idle, { runs: runs.length })) })] }));
255
+ }, borderColor: "$borderColor", children: [_jsxs(YStack, { gap: "$2", px: "$3", pt: "$3", pb: "$2.5", borderBottomWidth: 1, borderColor: "$edge", shrink: 0, children: [_jsxs(XStack, { items: "center", justify: "space-between", gap: "$2", children: [_jsxs(XStack, { items: "center", gap: "$2", minW: 0, flex: 1, children: [_jsx(Text, { fontSize: "$3", fontWeight: "600", color: "$ink", numberOfLines: 1, children: t('Runs') }), _jsxs(XStack, { "data-slot": "work-run-count", items: "center", gap: "$1.5", px: "$2", py: 2, rounded: "$10", bg: "$panel", borderWidth: 1, borderColor: "var(--border-strong)", shrink: 0, children: [counts.running > 0 ? (_jsx(YStack, { "data-motion": "pulse", width: 6, height: 6, rounded: 9999, bg: "var(--state-success)", shrink: 0, "aria-hidden": true })) : null, _jsx(Text, { fontFamily: "$mono", fontSize: "$1", fontWeight: "500", color: "$ink", fontVariant: ['tabular-nums'], children: counts.running > 0 ? t('{count} live', { count: counts.running }) : String(counts.all) })] })] }), _jsxs(Box, { render: _jsx("button", { type: "button" }), "data-slot": "work-new-run", "aria-label": t('New run'), onClick: () => {
256
+ didAutoSelectRef.current = true;
257
+ setComposing(true);
258
+ setOpen(null);
259
+ }, px: "$2", py: "$1", minH: 26, "$max-sm": { minH: 44, px: '$2.5' }, rounded: "$2", borderWidth: 1, borderColor: "var(--border-strong)", bg: composing && !open ? '$panel' : 'transparent', display: "inline-flex", items: "center", gap: "$1", shrink: 0, cursor: "pointer", hoverStyle: { bg: '$hover' }, focusVisibleStyle: { outlineWidth: 2, outlineStyle: 'solid', outlineColor: 'var(--ring)' }, children: [_jsx(Plus, { size: 12, color: "var(--foreground)", "aria-hidden": true }), _jsx(Text, { fontSize: "$1", fontWeight: "500", color: "$ink", numberOfLines: 1, children: t('New run') })] })] }), _jsx(XStack, { "data-slot": "work-status-filters", items: "center", gap: "$1", flexWrap: "wrap", role: "group", "aria-label": t('Filter runs by status'), children: filterPills.map((pill) => {
260
+ const active = filter === pill.id;
261
+ return (_jsxs(Box, { render: _jsx("button", { type: "button" }), "aria-pressed": active, onClick: () => setFilter(pill.id), px: "$2", py: "$1", rounded: "$10", minH: 26, "$max-sm": { minH: 44, px: '$2.5' }, display: "inline-flex", items: "center", gap: "$1", cursor: "pointer", borderWidth: 1, borderColor: active ? 'var(--border-strong)' : '$edge', bg: active ? '$raised' : 'transparent', hoverStyle: { bg: active ? '$raised' : '$hover' }, focusVisibleStyle: { outlineWidth: 2, outlineStyle: 'solid', outlineColor: 'var(--ring)' }, children: [_jsx(Text, { fontSize: "$1", fontWeight: active ? '600' : '500', color: active ? '$ink' : '$quiet', children: pill.label }), pill.count > 0 && pill.id !== 'all' ? (_jsx(Text, { fontFamily: "$mono", fontSize: "$1", color: "$soft", fontVariant: ['tabular-nums'], children: pill.count })) : null] }, pill.id));
262
+ }) })] }), loading && runs.length === 0 ? (_jsx(RunsSkeleton, { label: t('Loading runs') })) : (_jsx(AgentBoard, { runs: visibleRuns, active: open ?? undefined, onOpen: (id) => {
263
+ setComposing(false);
264
+ setOpen(id);
265
+ }, empty: runs.length > 0 && filter !== 'all' ? (_jsxs(YStack, { gap: "$2", items: "flex-start", children: [_jsx(Text, { fontSize: "$2", color: "$soft", children: t('No runs in this state.') }), _jsx(Box, { render: _jsx("button", { type: "button" }), onClick: () => setFilter('all'), px: "$2.5", py: "$1.5", minH: 32, "$max-sm": { minH: 44 }, rounded: "$2", borderWidth: 1, borderColor: "var(--border-strong)", bg: "transparent", hoverStyle: { bg: '$hover' }, focusVisibleStyle: { outlineWidth: 2, outlineStyle: 'solid', outlineColor: 'var(--ring)' }, cursor: "pointer", children: _jsx(Text, { fontSize: "$1", fontWeight: "500", color: "$ink", children: t('Show all runs') }) })] })) : (_jsx(Text, { fontSize: "$2", color: "$soft", children: t('No runs yet. Start one and it appears here.') })) }))] }), _jsx(YStack, { width: "100%", flex: 1, minW: 0, minH: 0, overflow: "hidden", $lg: { width: 'auto' }, children: open ? _jsx(Watch, { id: open }, open) : loading && runs.length === 0 ? (_jsxs(YStack, { flex: 1, minH: 0, p: "$5", gap: "$4", role: "status", "aria-busy": true, "aria-label": t('Loading runs'), children: [_jsx(Skeleton, { layout: "block", width: 200, height: 20, rounded: "$2" }), _jsxs(YStack, { gap: "$2.5", p: "$4", rounded: "$4", borderWidth: 1, borderColor: "$edge", bg: "$panel", children: [_jsx(Skeleton, { layout: "block", width: "55%", height: 14, rounded: "$2" }), _jsx(Skeleton, { layout: "block", width: "84%", height: 12, rounded: "$2" }), _jsx(Skeleton, { layout: "block", width: "68%", height: 12, rounded: "$2" })] })] })) : composing ? (_jsx(Idle, { runs: 0 })) : (idle ?? _jsx(Idle, { runs: runs.length })) })] }));
168
266
  }
169
267
  /**
170
268
  * Nothing is open. What that MEANS depends on whether there is anything to
@@ -225,6 +323,14 @@ function Watch({ id }) {
225
323
  const { steps: shown, message } = useMemo(() => steps(events), [events]);
226
324
  const status = STATUS(session?.status);
227
325
  const finished = status === 'done' || status === 'error';
326
+ const [tickNow, setTickNow] = useState(() => Date.now());
327
+ useEffect(() => {
328
+ if (status !== 'running')
329
+ return;
330
+ const timer = window.setInterval(() => setTickNow(Date.now()), 1000);
331
+ return () => window.clearInterval(timer);
332
+ }, [status]);
333
+ const elapsed = formatDuration(session?.startedAt || session?.createdAt, status === 'running' ? undefined : (session?.endedAt || session?.updatedAt), tickNow);
228
334
  const steer = useCallback(async (command) => {
229
335
  setNote(null);
230
336
  try {
@@ -261,7 +367,7 @@ function Watch({ id }) {
261
367
  setNote(t('Could not reach this run'));
262
368
  }
263
369
  }, [ai, draft, id, t]);
264
- return (_jsxs(XStack, { flex: 1, minH: 0, flexWrap: "wrap", children: [_jsxs(YStack, { flex: 1, minH: 0, minW: 0, children: [_jsx(ChannelHeader, { name: session?.title || session?.agent || id, artifacts: 0 }), _jsx(XStack, { px: "$4", pb: "$2", children: _jsx(Bar, { run: session }) }), _jsx(YStack, { flex: 1, minH: 0, overflowY: "auto", overflowX: "hidden", p: "$4", gap: "$4", children: _jsx(ProgressBlock, { steps: shown, done: finished, children: message ? (_jsx(Text, { fontSize: "$4", color: "$ink", children: message })) : null }) }), _jsxs(YStack, { p: "$3", gap: "$2", borderTopWidth: 1, borderColor: "$borderColor", children: [_jsx(Steer, { onCommand: (c) => void steer(c), withhold: finished ? ['pause', 'resume', 'stop'] : [], note: note }), _jsx(Composer, { value: draft, onChange: setDraft, onSend: () => void send(), placeholder: t('Steer this run…'), label: t('Steer this run') })] })] }), _jsx(YStack, { width: "100%", p: "$3", borderTopWidth: 1, $sm: { width: 420, shrink: 0, borderTopWidth: 0, borderLeftWidth: 1 }, borderColor: "$borderColor", children: _jsx(Pane, { tabs: [
370
+ return (_jsxs(YStack, { flex: 1, minH: 0, minW: 0, overflow: "hidden", $xl: { flexDirection: 'row' }, children: [_jsxs(YStack, { flex: 1, minH: 0, minW: 0, overflow: "hidden", children: [_jsx(ChannelHeader, { name: session?.title || session?.agent || id, artifacts: 0, children: _jsxs(XStack, { items: "center", gap: "$2", children: [_jsxs(XStack, { items: "center", gap: "$1.5", px: "$2", py: 2, rounded: "$10", bg: "$panel", borderWidth: 1, borderColor: "$edge", children: [status === 'running' ? (_jsx(YStack, { "data-motion": "pulse", width: 6, height: 6, rounded: 9999, bg: "var(--state-success)", shrink: 0, "aria-hidden": true })) : null, _jsx(Text, { fontSize: "$1", fontWeight: "500", color: status === 'error' ? 'var(--state-error)' : '$quiet', children: statusLabel(status, t) })] }), elapsed ? (_jsx(Text, { fontFamily: "$mono", fontSize: "$1", color: "$quiet", fontVariant: ['tabular-nums'], children: elapsed })) : null] }) }), _jsx(XStack, { px: "$4", pb: "$2", children: _jsx(Bar, { run: session }) }), _jsx(YStack, { flex: 1, minH: 0, overflowY: "auto", overflowX: "hidden", p: "$4", gap: "$4", children: _jsx(ProgressBlock, { steps: shown, done: finished, children: message ? (_jsx(Text, { fontSize: "$4", color: "$ink", children: message })) : null }) }), _jsxs(YStack, { p: "$3", gap: "$2", borderTopWidth: 1, borderColor: "$borderColor", shrink: 0, children: [_jsx(Steer, { onCommand: (c) => void steer(c), withhold: finished ? ['pause', 'resume', 'stop'] : [], note: note }), _jsx(Composer, { value: draft, onChange: setDraft, onSend: () => void send(), placeholder: t('Steer this run…'), label: t('Steer this run') })] })] }), _jsx(YStack, { width: "100%", height: 190, "$max-sm": { height: 168 }, shrink: 0, p: "$3", borderTopWidth: 1, $xl: { width: 360, height: '100%', shrink: 0, borderTopWidth: 0, borderLeftWidth: 1 }, borderColor: "$borderColor", overflow: "hidden", children: _jsx(Pane, { tabs: [
265
371
  { id: 'code', label: t('Code'), kind: 'code', content: _jsx(Nothing, { what: "changes" }) },
266
372
  { id: 'view', label: t('View'), kind: 'view', content: _jsx(Nothing, { what: "preview" }) },
267
373
  { id: 'canvas', label: t('Canvas'), kind: 'canvas', content: _jsx(Nothing, { what: "summary" }) },
@@ -287,8 +393,11 @@ function Nothing({ what }) {
287
393
  export function Work({ idle }) {
288
394
  const { t } = useI18n();
289
395
  const { user, isLoading } = useIam();
290
- if (isLoading || !user) {
291
- return (_jsxs(YStack, { flex: 1, items: "center", justify: "center", p: "$6", gap: "$2", children: [_jsx(Text, { render: "h1", fontSize: "$5", fontWeight: "600", color: "$ink", children: t('Agents') }), _jsx(Text, { fontSize: "$3", color: "$soft", text: "center", children: isLoading ? '\u00a0' : t('Sign in to watch your agents work.') })] }));
396
+ if (isLoading) {
397
+ return _jsx(WorkWorkspaceSkeleton, { label: t('Loading runs') });
398
+ }
399
+ if (!user) {
400
+ return (_jsxs(YStack, { flex: 1, items: "center", justify: "center", p: "$6", gap: "$2", children: [_jsx(Text, { render: "h1", fontSize: "$5", fontWeight: "600", color: "$ink", children: t('Agents') }), _jsx(Text, { fontSize: "$3", color: "$soft", text: "center", children: t('Sign in to watch your agents work.') }), _jsx(Button, { size: "sm", variant: "primary", rounded: "$3", minH: 36, "$max-sm": { minH: 44 }, mt: "$2", onClick: () => enter(LOGIN), children: t('Sign in') })] }));
292
401
  }
293
402
  return _jsx(Watching, { idle: idle });
294
403
  }
@@ -0,0 +1,8 @@
1
+ import type { Thread } from '@hanzo/ai';
2
+ /** What archiving a conversation needs of the store: the change, answered true when it held. */
3
+ interface Archiver {
4
+ archive: (t: Thread) => Promise<boolean>;
5
+ }
6
+ /** Archive or unarchive one conversation. An archive is said with an Undo that puts it back, since nothing else brings it back to the list. */
7
+ export declare function archiveWithUndo(act: Archiver, t: (s: string) => string, target: Thread): Promise<void>;
8
+ export {};
@@ -0,0 +1,16 @@
1
+ import { toast } from '@hanzo/ui';
2
+ /** Archive or unarchive one conversation. An archive is said with an Undo that puts it back, since nothing else brings it back to the list. */
3
+ export async function archiveWithUndo(act, t, target) {
4
+ const wasArchived = Boolean(target.archived);
5
+ if (!(await act.archive(target)))
6
+ return;
7
+ if (wasArchived) {
8
+ toast.success(t('Unarchived chat'));
9
+ return;
10
+ }
11
+ const archived = { ...target, archived: true };
12
+ toast(t('Archived chat'), {
13
+ duration: 5000,
14
+ action: { label: t('Undo'), onClick: () => void act.archive(archived) },
15
+ });
16
+ }
package/dist/bots/Bots.js CHANGED
@@ -12,9 +12,13 @@ import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
12
12
  import { useIam } from '@hanzo/iam/react';
13
13
  import { useI18n } from '@hanzo/i18n/react';
14
14
  import { XStack, YStack } from '@hanzo/gui';
15
+ import { Gutter } from '@hanzo/build';
15
16
  import { ENSO, useAi } from '../lib/ai.js';
17
+ import { SIDE } from '../ground.js';
16
18
  import { useKept } from '../kept.js';
19
+ import { useSpan } from '../span.js';
17
20
  import { say } from '../failure.js';
21
+ import { ROSTER_WIDTH_MAX, ROSTER_WIDTH_MIN } from './grid.js';
18
22
  import { Roster } from './Roster.js';
19
23
  import { Thread } from './Thread.js';
20
24
  import { GroupPanel, GroupThread, MakeGroupDialog } from './Groups.js';
@@ -80,6 +84,11 @@ export function Bots({ foot = true, bot: held, onBot, } = {}) {
80
84
  const [over, setOver] = useState(false);
81
85
  const wide = useWide('(min-width: 768px)');
82
86
  const laptop = useWide('(min-width: 1280px)');
87
+ const rosterSpan = useSpan('hanzo.bots.roster.width', SIDE, ROSTER_WIDTH_MIN, ROSTER_WIDTH_MAX);
88
+ const [rosterWidth, setRosterWidth] = useState(SIDE);
89
+ useEffect(() => {
90
+ setRosterWidth(rosterSpan.span);
91
+ }, [rosterSpan.span]);
83
92
  useEffect(() => {
84
93
  if (hosted)
85
94
  return;
@@ -324,7 +333,13 @@ export function Bots({ foot = true, bot: held, onBot, } = {}) {
324
333
  const panel = activeGroup ? (_jsx(GroupPanel, { group: activeGroup, groups: groups, bots: bots ?? [], onClose: close, onEdit: () => setEditingGroup(activeGroup), onDelete: removeGroup, onPickBot: pick }, `grp:${activeGroup.name}`)) : bot ? (_jsx(Panel, { bot: bot, groups: groups, runs: runs ?? [], kept: kept[bot.name] ?? '', onClose: close, onSchedule: schedule, onDelete: remove, onBotChanged: read, onPickGroup: pick, focus: over && !laptop }, bot.name)) : null;
325
334
  const shown = laptop ? side : over;
326
335
  const hasSelection = Boolean(bot || activeGroup);
327
- return (_jsxs(XStack, { "data-parity-key": "bots.window", width: "100%", height: "100%", overflow: "hidden", bg: FLOOR, position: "relative", children: [_jsx(YStack, { "data-parity-key": "bots.roster", width: 260, shrink: 0, height: "100%", bg: FLOOR, borderRightWidth: 1, borderColor: LINE, "$max-md": { width: '100%', borderRightWidth: 0, display: hasSelection ? 'none' : 'flex' }, children: _jsx(Roster, { bots: bots, groups: groups, last: last, open: openRef, unread: unread, me: foot ? user : null, onPick: pick, onMake: () => setMaking(true), onMakeGroup: () => setMakingGroup(true), disabled: !live }) }), _jsx(YStack, { "data-parity-key": "bots.center", flex: 1, minW: 0, height: "100%", bg: GROUND, "$max-md": { display: hasSelection ? 'flex' : 'none' }, children: activeGroup ? (_jsx(GroupThread, { group: activeGroup, bots: bots ?? [], side: shown, onSide: () => (laptop ? setSide(!side) : setOver(!over)), onBack: back, onEdit: () => setEditingGroup(activeGroup), onPickBot: pick })) : (_jsx(Thread, { bot: bot, bots: bots ?? [], runs: runs, pending: pending, notice: notice, wrong: wrong, side: shown, live: live, loaded: bots !== null, onSend: send, onDismiss: () => setNotice(null), onSide: () => (laptop ? setSide(!side) : setOver(!over)), onBack: back, onMake: () => setMaking(true) })) }), laptop && side && panel ? (_jsx(YStack, { "data-parity-key": "bots.panel", width: 300, shrink: 0, height: "100%", bg: GROUND, borderLeftWidth: 1, borderColor: LINE, "$max-xl": { display: 'none' }, children: panel })) : null, over && panel && !laptop ? (_jsx(YStack, { "data-parity-key": "bots.panel.over", role: "dialog", "aria-modal": true, "aria-label": activeGroup?.name || bot?.name, position: "absolute", t: 0, r: 0, b: 0, width: 300, maxW: "100%", z: 10, bg: GROUND, borderLeftWidth: 1, borderColor: LINE, boxShadow: "var(--shadow-floating)", children: panel })) : null, making ? _jsx(Make, { groups: groups, onDone: made, onCancel: () => setMaking(false) }) : null, makingGroup || editingGroup ? (_jsx(MakeGroupDialog, { bots: bots ?? [], groups: groups, initial: editingGroup, onDone: savedGroup, onCancel: () => {
336
+ return (_jsxs(XStack, { "data-parity-key": "bots.window", width: "100%", height: "100%", overflow: "hidden", bg: FLOOR, position: "relative", children: [_jsxs(YStack, { ref: rosterSpan.ref, "data-parity-key": "bots.roster", position: "relative", width: rosterWidth, shrink: 0, height: "100%", bg: FLOOR, borderRightWidth: 1, borderColor: LINE, "$max-md": { width: '100%', borderRightWidth: 0, display: hasSelection ? 'none' : 'flex' }, children: [_jsx(Roster, { bots: bots, groups: groups, last: last, open: openRef, unread: unread, me: foot ? user : null, width: rosterWidth, onPick: pick, onMake: () => setMaking(true), onMakeGroup: () => setMakingGroup(true), disabled: !live }), wide ? (_jsx(Gutter, { side: "left", span: rosterWidth, floor: ROSTER_WIDTH_MIN, ceil: ROSTER_WIDTH_MAX, reset: SIDE, onSpan: (n) => {
337
+ rosterSpan.move(n);
338
+ setRosterWidth(n);
339
+ }, onKeep: (n) => {
340
+ rosterSpan.keep(n);
341
+ setRosterWidth(n);
342
+ }, label: t('Resize bots sidebar') })) : null] }), _jsx(YStack, { "data-parity-key": "bots.center", flex: 1, minW: 0, height: "100%", bg: GROUND, "$max-md": { display: hasSelection ? 'flex' : 'none' }, children: activeGroup ? (_jsx(GroupThread, { group: activeGroup, bots: bots ?? [], side: shown, onSide: () => (laptop ? setSide(!side) : setOver(!over)), onBack: back, onEdit: () => setEditingGroup(activeGroup), onPickBot: pick }, activeGroup.name)) : (_jsx(Thread, { bot: bot, bots: bots ?? [], runs: runs, pending: pending, notice: notice, wrong: wrong, side: shown, live: live, loaded: bots !== null, onSend: send, onDismiss: () => setNotice(null), onSide: () => (laptop ? setSide(!side) : setOver(!over)), onBack: back, onMake: () => setMaking(true) })) }), laptop && side && panel ? (_jsx(YStack, { "data-parity-key": "bots.panel", width: 312, minW: 300, shrink: 0, height: "100%", bg: GROUND, borderLeftWidth: 1, borderColor: LINE, "$max-xl": { display: 'none' }, children: panel })) : null, over && panel && !laptop ? (_jsx(YStack, { "data-parity-key": "bots.panel.over", role: "dialog", "aria-modal": true, "aria-label": activeGroup?.name || bot?.name, position: "absolute", t: 0, r: 0, b: 0, width: 312, minW: 300, "$max-sm": { minW: 0 }, maxW: "100%", z: 10, bg: GROUND, borderLeftWidth: 1, borderColor: LINE, boxShadow: "var(--shadow-floating)", children: panel })) : null, making ? _jsx(Make, { groups: groups, onDone: made, onCancel: () => setMaking(false) }) : null, makingGroup || editingGroup ? (_jsx(MakeGroupDialog, { bots: bots ?? [], groups: groups, initial: editingGroup, onDone: savedGroup, onCancel: () => {
328
343
  setMakingGroup(false);
329
344
  setEditingGroup(null);
330
345
  } })) : null] }));