@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/Search.js CHANGED
@@ -27,30 +27,66 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
27
27
  // skills (`/v1/tool/skills?activated=true`), the connectors
28
28
  // (`/v1/tool/mcp/servers`) and the agents (crew.tsx) arrive while the reader
29
29
  // types, and a read the palette closes on is aborted.
30
- import { useEffect, useMemo, useState } from 'react';
30
+ import { useEffect, useId, useMemo, useRef, useState } from 'react';
31
31
  import { isolate, english } from '@hanzo/i18n';
32
32
  import { useI18n } from '@hanzo/i18n/react';
33
- import { BookOpen, Bot, Building2, CircleHelp, FlaskConical, FolderGit2, Gift, Keyboard, LogOut, MessageCircle, Plug, Settings, Sparkles, SunMoon, Users, } from 'lucide-react';
33
+ import { BookOpen, Bot, Building2, CircleHelp, CreditCard, FlaskConical, FolderGit2, Gift, Keyboard, Link2, LogOut, MessageCircle, Moon, PanelLeft, Plug, Search as SearchIcon, Settings, Sparkles, Sun, SunMoon, Terminal, Users, Workflow, X, } from 'lucide-react';
34
34
  import { useAi } from '@hanzo/ai/react';
35
+ import { apply as applyAppearance, read as readAppearance, write as writeAppearance } from '@hanzo/appearance';
35
36
  import { library, MARKS, nav, NEW, path as written, sections, tabs, useSessions } from '@hanzo/build';
36
37
  import { nav as made } from '@hanzo/studio';
37
- import { Dialog, DialogContent, DialogTitle } from '@hanzo/ui';
38
+ import * as ui from '@hanzo/ui';
38
39
  import { CommandMenu } from '@hanzo/ui/product/CommandMenu';
39
40
  import { ordered } from './agents.js';
40
41
  import { useCrew } from './crew.js';
41
42
  import { called } from './team.js';
42
43
  import { empty, openThread, withAgents } from './open.js';
43
44
  import { useThreadList } from './thread.js';
45
+ import { useKept } from './kept.js';
46
+ import { payPage } from './lib/pay.js';
47
+ import { openModelPicker } from './lib/model-picker.js';
44
48
  import { useSignOut } from './lib/signout.js';
45
49
  import { choose } from './lib/session.js';
46
- import { app, hosted, paged, settings, studio, talk, TERMINALS, WORKSPACE } from './lib/host.js';
50
+ import { getDevMode, rememberSettingsReturn, setDevMode, useDevMode } from './lib/dev-mode.js';
51
+ import { app, design, flow, hosted, paged, settings, studio, talk, TERMINALS, WORKSPACE } from './lib/host.js';
47
52
  import { BETAS } from './lib/betas.js';
48
53
  import { useBetas } from './Betas.js';
49
54
  import { tidy } from './lib/title.js';
50
55
  import { KEYS, legal, out, pages } from './help.js';
51
56
  import { site } from './where.js';
52
- import { find } from './seek.js';
53
- const ICON = { size: 16, 'aria-hidden': true };
57
+ import { find, rank } from './seek.js';
58
+ const { Dialog, DialogContent, DialogTitle } = ui;
59
+ const MAX_RECENT_JUMPS = 5;
60
+ const NO_JUMPS = [];
61
+ /** The jumps after this one: it goes first, once, and only the last few are kept. */
62
+ export function recorded(prev, item, at) {
63
+ return [
64
+ { id: item.id, label: item.label, ...(item.where ? { where: item.where } : {}), at },
65
+ ...prev.filter((x) => x.id !== item.id),
66
+ ].slice(0, MAX_RECENT_JUMPS);
67
+ }
68
+ function isLightTheme(host) {
69
+ if (typeof document !== 'undefined') {
70
+ const cls = document.documentElement.classList;
71
+ if (cls.contains('light') || cls.contains('t_light'))
72
+ return true;
73
+ if (cls.contains('dark') || cls.contains('t_dark'))
74
+ return false;
75
+ }
76
+ return host?.theme === 'light';
77
+ }
78
+ function applyThemeChoice(host, next) {
79
+ if (host?.chooseTheme) {
80
+ host.chooseTheme(next);
81
+ return;
82
+ }
83
+ if (typeof document === 'undefined')
84
+ return;
85
+ const pref = { ...readAppearance(), theme: next };
86
+ writeAppearance(pref);
87
+ applyAppearance(pref, document.documentElement);
88
+ }
89
+ const ICON = { size: 15, color: 'var(--foreground)', 'aria-hidden': true };
54
90
  const SKILLS = written({ kind: 'customize', tab: 'skills' });
55
91
  const CONNECTORS = written({ kind: 'customize', tab: 'connectors' });
56
92
  /** The words a Settings page is also asked for by: the account menu's names for General, and the obvious ones. */
@@ -116,20 +152,14 @@ export function places(host, go, t = english) {
116
152
  }
117
153
  /** The composer's model menu, opened as a press would: a page without a composer opens New chat's. */
118
154
  function tune(go) {
119
- const open = () => {
120
- const chip = document.querySelector('[data-slot="mind"][aria-haspopup="menu"]');
121
- chip?.focus();
122
- chip?.dispatchEvent(new KeyboardEvent('keydown', { key: 'ArrowDown', bubbles: true }));
123
- return !!chip;
124
- };
125
155
  let tries = 0;
126
156
  const wait = () => {
127
- if (!open() && ++tries < 120)
157
+ if (!openModelPicker() && ++tries < 120)
128
158
  requestAnimationFrame(wait);
129
159
  };
130
160
  // After the palette has closed and handed focus back, so the menu keeps it.
131
161
  setTimeout(() => {
132
- if (!open()) {
162
+ if (!openModelPicker()) {
133
163
  go(talk());
134
164
  requestAnimationFrame(wait);
135
165
  }
@@ -143,8 +173,8 @@ export function actions(host, go, signOut, keys, t = english) {
143
173
  const make = acts.find((l) => l.id === 'make');
144
174
  const upload = acts.find((l) => l.id === 'upload');
145
175
  const list = [
146
- { id: 'new-chat', label: t('New chat'), icon: _jsx(MARKS.chat.make, { ...ICON }), run: () => (empty(), go(talk())) },
147
- { id: 'new-task', label: t('New Dev task'), icon: _jsx(MARKS.dev.make, { ...ICON }), keywords: ['run'], run: () => go(app('')) },
176
+ { id: 'new-chat', label: t('New chat'), icon: _jsx(MARKS.chat.make, { ...ICON }), keywords: ['chat', 'new', 'conversation'], run: () => (empty(), go(talk())) },
177
+ { id: 'new-task', label: t('New run'), icon: _jsx(MARKS.dev.make, { ...ICON }), keywords: ['run', 'dev', 'task', 'build'], run: () => go(app('')) },
148
178
  !anon && { id: 'new-creation', label: t('New Studio creation'), icon: _jsx(MARKS.studio.make, { ...ICON }), keywords: ['image', 'video'], run: () => go(studio('')) },
149
179
  !anon && { id: 'new-scheduled', label: t('New scheduled task'), icon: _jsx(MARKS.scheduled.icon, { ...ICON }), keywords: ['automation'], run: () => go(app(written({ kind: 'automation', id: 'new' }))) },
150
180
  !!make && { id: 'make', label: t('Make something new'), icon: make.icon, keywords: ['template', 'gallery', 'library'], run: () => make.onPress?.() },
@@ -155,7 +185,7 @@ export function actions(host, go, signOut, keys, t = english) {
155
185
  label: t('Toggle theme'),
156
186
  icon: _jsx(SunMoon, { ...ICON }),
157
187
  keywords: ['dark', 'light', 'appearance'],
158
- run: () => host.chooseTheme?.(document.documentElement.classList.contains('dark') ? 'light' : 'dark'),
188
+ run: () => host.chooseTheme?.(isLightTheme(host) ? 'dark' : 'light'),
159
189
  },
160
190
  !!host && !anon && { id: 'org', label: t('Switch organization'), icon: _jsx(Building2, { ...ICON }), keywords: ['org', 'team', 'workspace'], run: choose },
161
191
  { id: 'keys', label: t('Keyboard shortcuts'), icon: _jsx(Keyboard, { ...ICON }), stay: true, run: keys },
@@ -204,6 +234,8 @@ export function Search({ onClose, go, actions: frame = [], mode = 'chat', host,
204
234
  const { t, dir } = useI18n();
205
235
  const [query, setQuery] = useState('');
206
236
  const [keys, setKeys] = useState(false);
237
+ const [devMode] = useDevMode();
238
+ const [recentJumps, setRecentJumps] = useKept('hanzo.cmdk.recent', NO_JUMPS);
207
239
  const { threads } = useThreadList();
208
240
  const { agents } = useCrew();
209
241
  const repos = useRead('/v1/project', projects);
@@ -228,11 +260,132 @@ export function Search({ onClose, go, actions: frame = [], mode = 'chat', host,
228
260
  run: () => (b.embed !== undefined ? go(hosted(b.id)) : b.href.startsWith('/') ? go(b.href) : out(b.href)),
229
261
  }));
230
262
  const here = [...top.map(swap), ...frame.filter((b) => !top.some((a) => a.id === b.id)), ...granted];
231
- const doing = actions(host, go, () => void signOut(), () => (setQuery(''), setKeys(true)), t).filter((a) => a.id !== 'new-creation' || opened('studio'));
263
+ const baseDoing = actions(host, go, () => void signOut(), () => (setQuery(''), setKeys(true)), t).filter((a) => a.id !== 'new-creation' || opened('studio'));
264
+ const lightNow = isLightTheme(host);
265
+ const openKeys = () => {
266
+ setQuery('');
267
+ setKeys(true);
268
+ };
269
+ const quick = [
270
+ {
271
+ id: 'new-chat',
272
+ label: t('New chat'),
273
+ icon: _jsx(MARKS.chat.make, { ...ICON }),
274
+ shortcut: ['Mod', 'Shift', 'O'],
275
+ keywords: ['chat', 'new', 'conversation', 'prompt', 'ask'],
276
+ run: () => {
277
+ empty();
278
+ go(talk());
279
+ },
280
+ },
281
+ {
282
+ id: 'new-task',
283
+ label: t('New Dev run'),
284
+ icon: _jsx(MARKS.dev.make, { ...ICON }),
285
+ keywords: ['run', 'dev', 'task', 'build', 'code', 'new'],
286
+ run: () => go(app('')),
287
+ },
288
+ {
289
+ id: 'new-design',
290
+ label: t('New Design'),
291
+ icon: _jsx(MARKS.design.make, { ...ICON }),
292
+ keywords: ['design', 'canvas', 'studio', 'image', 'ui', 'new'],
293
+ run: () => go(design('')),
294
+ },
295
+ {
296
+ id: 'open-flow',
297
+ label: t('Open Flow'),
298
+ icon: _jsx(Workflow, { ...ICON }),
299
+ keywords: ['flow', 'workflow', 'pipeline', 'agents', 'open'],
300
+ run: () => go(flow('')),
301
+ },
302
+ {
303
+ id: 'theme',
304
+ label: lightNow ? t('Switch to dark theme') : t('Switch to light theme'),
305
+ icon: lightNow ? _jsx(Moon, { ...ICON }) : _jsx(Sun, { ...ICON }),
306
+ shortcut: ['Mod', 'Shift', 'L'],
307
+ keywords: ['theme', 'dark', 'light', 'mode', 'appearance', 'toggle', 'color'],
308
+ run: () => {
309
+ const next = isLightTheme(host) ? 'dark' : 'light';
310
+ applyThemeChoice(host, next);
311
+ ui.toast?.success(next === 'light' ? t('Switched to light theme') : t('Switched to dark theme'));
312
+ },
313
+ },
314
+ {
315
+ id: 'toggle-dev-mode',
316
+ label: t('Toggle Developer mode'),
317
+ icon: _jsx(Terminal, { ...ICON }),
318
+ where: devMode ? t('On') : t('Off'),
319
+ shortcut: ['Mod', 'Shift', 'D'],
320
+ keywords: ['developer', 'dev', 'mode', 'github', 'branches', 'terminals', 'advanced', 'toggle'],
321
+ run: () => {
322
+ const next = !getDevMode();
323
+ setDevMode(next);
324
+ ui.toast?.success(next ? t('Developer mode enabled') : t('Developer mode disabled'));
325
+ },
326
+ },
327
+ {
328
+ id: 'toggle-sidebar',
329
+ label: t('Toggle sidebar'),
330
+ icon: _jsx(PanelLeft, { ...ICON }),
331
+ shortcut: ['Mod', 'B'],
332
+ keywords: ['sidebar', 'navigation', 'nav', 'rail', 'collapse', 'expand', 'toggle', 'panel'],
333
+ run: () => {
334
+ if (typeof window !== 'undefined') {
335
+ window.dispatchEvent(new CustomEvent('hanzo:toggle-sidebar'));
336
+ }
337
+ },
338
+ },
339
+ {
340
+ id: 'upgrade-credits',
341
+ label: t('Upgrade plan / Add credits'),
342
+ icon: _jsx(CreditCard, { ...ICON }),
343
+ keywords: ['upgrade', 'plan', 'credits', 'top', 'up', 'billing', 'pricing', 'pro', 'max'],
344
+ run: () => {
345
+ if (typeof window !== 'undefined') {
346
+ window.location.assign(payPage('/cart'));
347
+ }
348
+ },
349
+ },
350
+ {
351
+ id: 'open-settings',
352
+ label: t('Open settings'),
353
+ icon: _jsx(Settings, { ...ICON }),
354
+ shortcut: ['Mod', ','],
355
+ keywords: ['settings', 'preferences', 'account', 'profile', 'open'],
356
+ run: () => {
357
+ rememberSettingsReturn();
358
+ go(settings('account'));
359
+ },
360
+ },
361
+ {
362
+ id: 'keys',
363
+ label: t('Keyboard shortcuts'),
364
+ icon: _jsx(Keyboard, { ...ICON }),
365
+ shortcut: ['Mod', '/'],
366
+ keywords: ['keyboard', 'shortcuts', 'hotkeys', 'keys', 'help'],
367
+ stay: true,
368
+ run: openKeys,
369
+ },
370
+ {
371
+ id: 'copy-link',
372
+ label: t('Copy current link'),
373
+ icon: _jsx(Link2, { ...ICON }),
374
+ keywords: ['copy', 'link', 'url', 'share', 'address', 'clipboard'],
375
+ run: () => {
376
+ if (typeof window === 'undefined' || !navigator.clipboard)
377
+ return;
378
+ void navigator.clipboard.writeText(window.location.href).then(() => ui.toast?.success(t('Link copied')), () => ui.toast?.error(t('The browser would not copy the link.')));
379
+ },
380
+ },
381
+ ];
382
+ const quickIds = new Set(quick.map((a) => a.id));
383
+ const doing = [...quick, ...baseDoing.filter((a) => !quickIds.has(a.id))];
232
384
  const untitled = t('Untitled');
233
385
  const chats = threads.map((c) => ({
234
386
  id: `chat-${c.id}`,
235
387
  label: tidy(c.title, 80, untitled),
388
+ where: t('Chat'),
236
389
  at: c.updatedAt,
237
390
  icon: _jsx(MessageCircle, { ...ICON }),
238
391
  run: () => (openThread(c.id), go(talk(c.id))),
@@ -240,39 +393,94 @@ export function Search({ onClose, go, actions: frame = [], mode = 'chat', host,
240
393
  const tasks = (runs?.value ?? []).map((s) => ({
241
394
  id: `run-${s.id}`,
242
395
  label: tidy(s.title, 80, t('Untitled run')),
396
+ where: s.status ? `${t('Dev')} · ${s.status}` : t('Dev'),
243
397
  at: s.updatedAt || s.createdAt,
244
398
  keywords: [s.status ?? ''],
245
399
  icon: _jsx(MARKS.dev.icon, { ...ICON }),
246
400
  run: () => go(app(s.id)),
247
401
  }));
248
- const mine = mode === 'dev'
249
- ? [
250
- { id: 'runs', label: t('Dev tasks'), items: tasks },
251
- { id: 'chats', label: t('Chats'), items: chats },
252
- ]
253
- : [
254
- { id: 'chats', label: t('Chats'), items: chats },
255
- { id: 'runs', label: t('Dev tasks'), items: tasks },
256
- ];
257
- const shown = find(query, [...chats, ...tasks], [
258
- { id: 'actions', label: t('Actions'), items: doing },
259
- { id: 'go', label: t('Go to'), items: here },
260
- ], [
261
- { id: 'go', label: t('Go to'), items: [...here, ...deep] },
262
- { id: 'actions', label: t('Actions'), items: doing },
263
- ...mine,
264
- { id: 'projects', label: t('Projects'), items: repos.map((p) => ({ ...p, id: `project-${p.id}`, icon: _jsx(FolderGit2, { ...ICON }), run: () => go(app(p.id)) })) },
265
- {
266
- id: 'agents',
267
- label: t('Agents'),
268
- items: ordered(agents).map((one) => {
269
- const name = called(one.name);
270
- return { id: `agent-${one.id || one.name}`, label: name, icon: _jsx(Bot, { ...ICON }), run: () => (withAgents([name]), go(talk())) };
271
- }),
272
- },
273
- { id: 'skills', label: t('Skills'), items: known.map((s) => ({ ...s, id: `skill-${s.id}`, icon: _jsx(BookOpen, { ...ICON }), run: () => go(app(SKILLS)) })) },
274
- { id: 'connectors', label: t('Connectors'), items: plugged.map((c) => ({ ...c, id: `connector-${c.id}`, icon: _jsx(Plug, { ...ICON }), run: () => go(app(CONNECTORS)) })) },
275
- ]);
402
+ const projectRows = repos.map((p) => ({
403
+ ...p,
404
+ id: `project-${p.id}`,
405
+ icon: _jsx(FolderGit2, { ...ICON }),
406
+ run: () => go(app(p.id)),
407
+ }));
408
+ const agentRows = ordered(agents).map((one) => {
409
+ const name = called(one.name);
410
+ return { id: `agent-${one.id || one.name}`, label: name, icon: _jsx(Bot, { ...ICON }), run: () => (withAgents([name]), go(talk())) };
411
+ });
412
+ const skillRows = known.map((s) => ({
413
+ ...s,
414
+ id: `skill-${s.id}`,
415
+ icon: _jsx(BookOpen, { ...ICON }),
416
+ run: () => go(app(SKILLS)),
417
+ }));
418
+ const connectorRows = plugged.map((c) => ({
419
+ ...c,
420
+ id: `connector-${c.id}`,
421
+ icon: _jsx(Plug, { ...ICON }),
422
+ run: () => go(app(CONNECTORS)),
423
+ }));
424
+ const allById = new Map();
425
+ for (const row of [...doing, ...here, ...deep, ...chats, ...tasks, ...projectRows, ...agentRows, ...skillRows, ...connectorRows]) {
426
+ if (!allById.has(row.id))
427
+ allById.set(row.id, row);
428
+ }
429
+ const trimmedStart = query.trimStart();
430
+ const isCommandMode = trimmedStart.startsWith('>');
431
+ let shown;
432
+ if (isCommandMode) {
433
+ const cmdQuery = trimmedStart.slice(1).trim();
434
+ const matched = cmdQuery ? rank(doing, cmdQuery, doing.length) : doing;
435
+ shown = matched.length ? [{ id: 'commands', label: t('Commands'), items: matched }] : [];
436
+ }
437
+ else {
438
+ const mine = mode === 'dev'
439
+ ? [
440
+ { id: 'runs', label: t('Dev tasks'), items: tasks },
441
+ { id: 'chats', label: t('Chats'), items: chats },
442
+ ]
443
+ : [
444
+ { id: 'chats', label: t('Chats'), items: chats },
445
+ { id: 'runs', label: t('Dev tasks'), items: tasks },
446
+ ];
447
+ const recentJumpActions = !query.trim()
448
+ ? recentJumps
449
+ .map((j) => allById.get(j.id))
450
+ .filter((a) => Boolean(a))
451
+ .slice(0, 3)
452
+ : [];
453
+ const idleCommands = doing.filter((a) => a.id === 'new-chat' || a.id === 'new-task' || a.id === 'open-settings' || a.id === 'theme').slice(0, 4);
454
+ if (!query.trim()) {
455
+ // Progressive disclosure at rest: 5–7 focused items total (max 3 recent + 4 key actions).
456
+ const recentChatsAndRuns = [...chats, ...tasks]
457
+ .sort((a, b) => (b.at ?? '').localeCompare(a.at ?? ''))
458
+ .slice(0, 3);
459
+ const topRecent = recentJumpActions.length > 0
460
+ ? { id: 'recent-jumps', label: t('Recent jumps'), items: recentJumpActions }
461
+ : recentChatsAndRuns.length > 0
462
+ ? { id: 'recent', label: t('Recent'), items: recentChatsAndRuns }
463
+ : null;
464
+ shown = [
465
+ ...(topRecent ? [topRecent] : []),
466
+ { id: 'actions', label: t('Commands'), items: idleCommands },
467
+ ].filter((g) => g.items.length > 0);
468
+ }
469
+ else {
470
+ shown = find(query, [...chats, ...tasks], [
471
+ { id: 'actions', label: t('Commands'), items: idleCommands },
472
+ { id: 'go', label: t('Go to'), items: here },
473
+ ], [
474
+ { id: 'actions', label: t('Commands'), items: doing },
475
+ { id: 'go', label: t('Go to'), items: [...here, ...deep] },
476
+ ...mine,
477
+ { id: 'projects', label: t('Projects'), items: projectRows },
478
+ { id: 'agents', label: t('Agents'), items: agentRows },
479
+ { id: 'skills', label: t('Skills'), items: skillRows },
480
+ { id: 'connectors', label: t('Connectors'), items: connectorRows },
481
+ ]);
482
+ }
483
+ }
276
484
  return shown.map((g) => ({
277
485
  ...g,
278
486
  // Recent is seek.ts's own group, its name written there with phrase().
@@ -286,13 +494,16 @@ export function Search({ onClose, go, actions: frame = [], mode = 'chat', host,
286
494
  // The palette ranked these against the query; the menu's own filter passes what it kept.
287
495
  keywords: [query],
288
496
  onSelect: () => {
497
+ if (!a.stay && a.id !== 'logout') {
498
+ setRecentJumps(recorded(recentJumps, { id: a.id, label: a.label, where: a.where }, Date.now()));
499
+ }
289
500
  if (!a.stay)
290
501
  onClose();
291
502
  a.run();
292
503
  },
293
504
  })),
294
505
  }));
295
- }, [query, threads, agents, repos, known, plugged, frame, go, onClose, signOut, mode, runs, host, opened, t]);
506
+ }, [query, devMode, recentJumps, threads, agents, repos, known, plugged, frame, go, onClose, signOut, mode, runs, host, opened, t]);
296
507
  const apple = typeof navigator !== 'undefined' && /Mac|iPhone|iPad/.test(navigator.userAgent);
297
508
  // A key's spelling keeps its writing order in right-to-left prose (`contextual` is plain text, so Unicode's isolate, not <bdi>).
298
509
  const spelled = (spelling) => (dir === 'rtl' ? isolate(spelling) : spelling);
@@ -301,11 +512,116 @@ export function Search({ onClose, go, actions: frame = [], mode = 'chat', host,
301
512
  {
302
513
  id: 'keys',
303
514
  label: t('Keyboard shortcuts'),
304
- items: KEYS.map((k) => ({ id: `key-${k.does}`, label: t(k.does), contextual: spelled(apple ? k.mac : k.pc), onSelect: () => setKeys(false) })),
515
+ items: KEYS.filter((k) => {
516
+ const needle = query.trim().toLowerCase();
517
+ if (!needle)
518
+ return true;
519
+ const label = t(k.does).toLowerCase();
520
+ const chord = (apple ? k.mac : k.pc).toLowerCase();
521
+ return label.includes(needle) || chord.includes(needle);
522
+ }).map((k) => ({ id: `key-${k.does}`, label: t(k.does), contextual: spelled(apple ? k.mac : k.pc), onSelect: () => setKeys(false) })),
305
523
  },
306
524
  ]
307
525
  : groups;
308
- return (_jsx(Dialog, { open: true, onOpenChange: (open) => (open ? null : onClose()), children: _jsxs(DialogContent, { "data-slot": "palette", showCloseButton: false, p: 0, gap: 0, width: "100%", maxW: 640,
526
+ const XStack = ui.XStack;
527
+ const YStack = ui.YStack;
528
+ const Text = ui.Text;
529
+ const Input = ui.Input;
530
+ const ScrollView = ui.ScrollView;
531
+ const Kbd = ui.Kbd;
532
+ const Shortcut = ui.Shortcut;
533
+ const paletteId = useId();
534
+ const inputRef = useRef(null);
535
+ const movedRef = useRef(false);
536
+ const [activeId, setActiveId] = useState(undefined);
537
+ const visibleGroups = useMemo(() => listed.filter((g) => g.items.length > 0), [listed]);
538
+ const reachable = useMemo(() => visibleGroups.flatMap((g) => g.items.filter((it) => !it.disabled)), [visibleGroups]);
539
+ const current = reachable.find((it) => it.id === activeId) ?? reachable[0];
540
+ const optionId = (id) => `${paletteId}-option-${id}`;
541
+ const listId = `${paletteId}-list`;
542
+ useEffect(() => {
543
+ const timer = setTimeout(() => inputRef.current?.focus?.(), 0);
544
+ return () => clearTimeout(timer);
545
+ }, []);
546
+ useEffect(() => {
547
+ if (!movedRef.current || !current || typeof document === 'undefined')
548
+ return;
549
+ movedRef.current = false;
550
+ document.getElementById(optionId(current.id))?.scrollIntoView?.({ block: 'nearest' });
551
+ });
552
+ const isCommandMode = !keys && query.trimStart().startsWith('>');
553
+ const canRenderNativePalette = Boolean(XStack && YStack && Text && Input && ScrollView);
554
+ const handlePaletteKeyDown = (e) => {
555
+ if (e.key === 'ArrowDown' || e.key === 'ArrowUp') {
556
+ if (!reachable.length)
557
+ return;
558
+ e.preventDefault?.();
559
+ const idx = current ? reachable.indexOf(current) : -1;
560
+ const delta = e.key === 'ArrowDown' ? 1 : -1;
561
+ const next = reachable[(idx + delta + reachable.length) % reachable.length];
562
+ if (next) {
563
+ movedRef.current = true;
564
+ setActiveId(next.id);
565
+ }
566
+ }
567
+ else if (e.key === 'Enter') {
568
+ if (!current)
569
+ return;
570
+ e.preventDefault?.();
571
+ current.onSelect();
572
+ }
573
+ else if (e.key === 'Escape') {
574
+ e.preventDefault?.();
575
+ if (keys)
576
+ setKeys(false);
577
+ else
578
+ onClose();
579
+ }
580
+ else if (e.key === 'Backspace' && !query && keys) {
581
+ e.preventDefault?.();
582
+ setKeys(false);
583
+ }
584
+ };
585
+ return (_jsx(Dialog, { open: true, onOpenChange: (open) => (open ? null : onClose()), children: _jsxs(DialogContent, { "data-slot": "palette", showCloseButton: false, p: 0, gap: 0, bg: "var(--popover)", borderWidth: 1, borderColor: "var(--border-strong)", boxShadow: "var(--shadow-floating)", width: 640, maxW: "calc(100vw - 24px)",
309
586
  // As tall as its rows, under a fixed top, so typing never moves the field.
310
- maxH: "min(520px, 76dvh)", mt: "12dvh", mb: "auto", rounded: "$6", overflow: "hidden", "$max-md": { width: '100vw', maxW: '100vw', height: '100dvh', maxH: '100dvh', mt: 0, mb: 0, rounded: 0, borderWidth: 0 }, children: [_jsx(DialogTitle, { position: "absolute", width: 1, height: 1, overflow: "hidden", opacity: 0, children: t('Search') }), _jsx(CommandMenu, { groups: listed, query: query, onQueryChange: setQuery, placeholder: t('Search or jump to…'), label: t('Search'), empty: keys ? t('No such key.') : t('Nothing matches “{query}”.', { query: query.trim() }), onBack: keys ? () => setKeys(false) : undefined, onClose: onClose })] }) }));
587
+ maxH: "min(540px, 78dvh)", mt: "12dvh", mb: "auto", rounded: "$6", overflow: "hidden", onKeyDown: (e) => {
588
+ if (e.key === 'Escape' && !e.defaultPrevented) {
589
+ e.preventDefault?.();
590
+ if (keys)
591
+ setKeys(false);
592
+ else
593
+ onClose();
594
+ }
595
+ }, "$max-md": {
596
+ width: 'calc(100vw - 24px)',
597
+ maxW: 'calc(100vw - 24px)',
598
+ maxH: 'min(540px, 82dvh)',
599
+ mt: '6dvh',
600
+ mb: 'auto',
601
+ rounded: '$5',
602
+ }, children: [_jsx(DialogTitle, { position: "absolute", width: 1, height: 1, overflow: "hidden", opacity: 0, children: t('Search') }), canRenderNativePalette ? (_jsxs(YStack, { "data-slot": "command-menu", shrink: 1, minH: 0, children: [_jsxs(XStack, { "data-slot": "command-menu-bar", height: 48, shrink: 0, items: "center", gap: "$2.5", px: "$3.5", borderBottomWidth: 1, borderColor: "$borderColor", children: [_jsx(SearchIcon, { size: 15, color: "var(--muted-foreground)", "aria-hidden": true }), _jsx(Input, { ref: inputRef, "data-slot": "command-menu-input", ...{
603
+ role: 'combobox',
604
+ 'aria-expanded': true,
605
+ 'aria-controls': listId,
606
+ 'aria-autocomplete': 'list',
607
+ 'aria-activedescendant': current ? optionId(current.id) : undefined,
608
+ 'aria-label': t('Search'),
609
+ }, flex: 1, minW: 0, height: 46, px: 0, borderWidth: 0, rounded: 0, bg: "transparent", outlineWidth: 0, hoverStyle: { bg: 'transparent' }, focusStyle: { outlineWidth: 0 }, focusVisibleStyle: { outlineWidth: 0 }, color: "$ink", fontFamily: "$body", fontSize: "$3", "$max-md": { fontSize: 16 }, placeholder: t('Search, jump to settings, or type > for commands…'), placeholderTextColor: "$hint", value: query, onChangeText: (text) => {
610
+ setQuery(text);
611
+ setActiveId(undefined);
612
+ }, onKeyDown: handlePaletteKeyDown }), query ? (_jsx(XStack, { render: _jsx("button", { type: "button" }), "aria-label": t('Clear search'), onClick: () => {
613
+ setQuery('');
614
+ setActiveId(undefined);
615
+ inputRef.current?.focus?.();
616
+ }, width: 26, height: 26, $touchable: { minW: 44, minH: 44 }, "$max-sm": { minW: 44, minH: 44 }, rounded: "$2", borderWidth: 0, bg: "transparent", items: "center", justify: "center", cursor: "pointer", hoverStyle: { bg: '$hover' }, focusVisibleStyle: { outlineWidth: 2, outlineStyle: 'solid', outlineColor: 'var(--ring)' }, shrink: 0, children: _jsx(X, { size: 14, color: "var(--muted-foreground)", "aria-hidden": true }) })) : null, _jsxs(XStack, { render: _jsx("button", { type: "button" }), "aria-label": keys ? t('Back') : t('Close'), onClick: keys ? () => setKeys(false) : onClose, minH: 26, px: "$1.5", $touchable: { minW: 44, minH: 44 }, "$max-sm": { minW: 44, minH: 44 }, rounded: "$2", borderWidth: 0, bg: "transparent", shrink: 0, items: "center", justify: "center", cursor: "pointer", opacity: 0.75, hoverStyle: { opacity: 1, bg: '$hover' }, focusVisibleStyle: { outlineWidth: 2, outlineStyle: 'solid', outlineColor: 'var(--ring)' }, children: [_jsx(XStack, { "$max-md": { display: 'none' }, children: Kbd ? _jsx(Kbd, { children: "esc" }) : _jsx(Text, { fontFamily: "$mono", fontSize: "$1", color: "$soft", children: "esc" }) }), _jsx(Text, { display: "none", "$max-md": { display: 'flex' }, fontSize: "$2", fontWeight: "500", color: "$ink", children: t('Cancel') })] })] }), _jsx(ScrollView, { "data-slot": "command-menu-scroll", shrink: 1, minH: 0, "$platform-web": { overscrollBehavior: 'contain' }, children: _jsxs(YStack, { id: listId, "data-slot": "command-menu-list", p: "$2", gap: "$1", children: [visibleGroups.map((g, gi) => {
617
+ const head = `${paletteId}-group-${g.id}`;
618
+ return (_jsxs(YStack, { "data-slot": "command-menu-group", pt: gi > 0 ? '$1.5' : 0, children: [_jsx(XStack, { id: head, "data-slot": "command-menu-heading", px: "$2.5", pt: "$1", pb: "$1.5", items: "center", children: _jsx(Text, { fontFamily: "$body", fontSize: "$1", fontWeight: "500", color: "$soft", numberOfLines: 1, children: g.label }) }), _jsx(YStack, { ...{ role: 'listbox' }, "aria-labelledby": head, gap: 1, children: g.items.map((it) => {
619
+ const on = current?.id === it.id;
620
+ return (_jsxs(XStack, { id: optionId(it.id), "data-slot": "command-menu-item", ...{
621
+ role: 'option',
622
+ 'aria-selected': on,
623
+ 'aria-disabled': it.disabled || undefined,
624
+ }, "data-active": on ? '' : undefined, items: "center", gap: "$2.5", px: "$2.5", py: "$1.5", minH: 38, $touchable: { minH: 44 }, "$max-sm": { minH: 44 }, rounded: "$3", cursor: it.disabled ? 'default' : 'pointer', opacity: it.disabled ? 0.5 : 1, bg: on ? '$hover' : 'transparent', hoverStyle: it.disabled ? undefined : { bg: '$hover' }, onMouseEnter: it.disabled ? undefined : () => setActiveId(it.id), onClick: it.disabled ? undefined : it.onSelect, children: [_jsx(XStack, { width: 18, height: 18, shrink: 0, items: "center", justify: "center", opacity: on ? 0.95 : 0.65, "aria-hidden": true, children: it.icon }), _jsxs(XStack, { flex: 1, minW: 0, items: "baseline", gap: "$2", children: [_jsx(Text, { fontFamily: "$body", fontSize: "$2", fontWeight: "500", color: "$ink", numberOfLines: 1, shrink: 1, children: it.label }), it.contextual ? (_jsx(Text, { fontFamily: "$body", fontSize: "$1", fontWeight: "400", color: "$soft", numberOfLines: 1, shrink: 0, children: it.contextual })) : null] }), it.shortcut && Shortcut ? (_jsx(XStack, { shrink: 0, "$max-md": { display: 'none' }, children: _jsx(Shortcut, { keys: it.shortcut }) })) : null] }, it.id));
625
+ }) })] }, g.id));
626
+ }), visibleGroups.length === 0 ? (_jsx(YStack, { "data-slot": "command-menu-empty", role: "status", "aria-live": "polite", py: "$6", items: "center", justify: "center", children: _jsx(Text, { fontFamily: "$body", fontSize: "$2", color: "$soft", children: keys ? t('No such key.') : t('Nothing matches “{query}”.', { query: query.trim() }) }) })) : null] }) })] })) : (_jsx(CommandMenu, { groups: listed, query: query, onQueryChange: setQuery, placeholder: t('Search, jump to settings, or type > for commands…'), label: t('Search'), empty: keys ? t('No such key.') : t('Nothing matches “{query}”.', { query: query.trim() }), onBack: keys ? () => setKeys(false) : undefined, onClose: onClose })), XStack && Text ? (_jsxs(XStack, { "data-slot": "palette-footer", shrink: 0, items: "center", justify: "space-between", gap: "$3", px: "$3.5", py: "$2", borderTopWidth: 1, borderColor: "$edge", bg: "$panel", "$max-sm": { display: 'none' }, children: [_jsxs(XStack, { items: "center", gap: "$3", flexWrap: "wrap", children: [_jsxs(XStack, { items: "center", gap: "$1", children: [Kbd ? _jsx(Kbd, { children: "\u2191\u2193" }) : _jsx(Text, { fontFamily: "$mono", fontSize: "$1", color: "$soft", children: "\u2191\u2193" }), _jsx(Text, { fontFamily: "$body", fontSize: "$1", color: "$soft", children: t('Navigate') })] }), _jsxs(XStack, { items: "center", gap: "$1", children: [Kbd ? _jsx(Kbd, { children: "\u21B5" }) : _jsx(Text, { fontFamily: "$mono", fontSize: "$1", color: "$soft", children: "\u21B5" }), _jsx(Text, { fontFamily: "$body", fontSize: "$1", color: "$soft", children: t('Open') })] }), _jsxs(XStack, { items: "center", gap: "$1", children: [Kbd ? _jsx(Kbd, { children: ">" }) : _jsx(Text, { fontFamily: "$mono", fontSize: "$1", color: "$soft", children: ">" }), _jsx(Text, { fontFamily: "$body", fontSize: "$1", color: "$soft", children: t('Commands') })] }), _jsxs(XStack, { items: "center", gap: "$1", children: [Kbd ? _jsx(Kbd, { children: "Esc" }) : _jsx(Text, { fontFamily: "$mono", fontSize: "$1", color: "$soft", children: "Esc" }), _jsx(Text, { fontFamily: "$body", fontSize: "$1", color: "$soft", children: t('Close') })] })] }), isCommandMode ? (_jsx(Text, { fontFamily: "$body", fontSize: "$1", fontWeight: "500", color: "$ink", shrink: 0, children: t('Command mode') })) : null] })) : null] }) }));
311
627
  }