@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/look.js CHANGED
@@ -6,14 +6,13 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
6
6
  * Theme, type, spacing, corners, native platform profiles, custom fonts,
7
7
  * and organization theme mods — stored and resolved for the organization in scope.
8
8
  */
9
- import { useState, useEffect } from 'react';
10
- import { phrase } from '@hanzo/i18n';
11
- import { LanguagePicker } from '@hanzo/i18n/react';
9
+ import { useState, useEffect, useMemo } from 'react';
10
+ import { locales, phrase } from '@hanzo/i18n';
12
11
  import { useI18n } from '@hanzo/i18n/react';
13
- import { Box, Button, Input, Text, XStack, YStack } from '@hanzo/ui';
12
+ import { Box, Button, Input, Popover, PopoverContent, PopoverTrigger, ScrollView, Text, XStack, YStack, toast } from '@hanzo/ui';
14
13
  import { Appearance, apply } from '@hanzo/appearance';
15
14
  import { useIam } from '@hanzo/iam/react';
16
- import { Check, Download, Palette, Smartphone, Type, Upload } from 'lucide-react';
15
+ import { Check, ChevronDown, Download, Palette, Search, Smartphone, Type, Upload } from 'lucide-react';
17
16
  import { setActivePlatform, BUILTIN_MODS, applyMod, clearActiveMod, exportMod, importMod, injectCustomFont, applyFontFamily, } from '@hanzo/mod';
18
17
  import { api } from './lib/api.js';
19
18
  import { useChatPreferences } from './lib/chatPreferences.js';
@@ -22,6 +21,37 @@ import { EFFORTS } from '@hanzo/ui/chat/pure';
22
21
  import { brand } from './where.js';
23
22
  import { tap } from './lib/tap.js';
24
23
  const CHOICE = { rounded: 8, borderWidth: 1, borderStyle: 'solid', cursor: 'pointer' };
24
+ /** Monochrome searchable Popover language selector — replaces native `<LanguagePicker />`. */
25
+ function CustomLanguageSelect() {
26
+ const { locale, setLocale, t } = useI18n();
27
+ const [open, setOpen] = useState(false);
28
+ const [query, setQuery] = useState('');
29
+ const options = useMemo(() => locales
30
+ .filter((l) => !l.review || l.code === locale)
31
+ .map((entry) => ({
32
+ code: entry.code,
33
+ label: entry.englishName && entry.englishName !== entry.name ? `${entry.name} (${entry.englishName})` : entry.name || entry.code,
34
+ })), [locale]);
35
+ const current = options.find((o) => o.code === locale) ?? options[0];
36
+ const filtered = useMemo(() => {
37
+ const q = query.trim().toLowerCase();
38
+ if (!q)
39
+ return options;
40
+ return options.filter((o) => o.label.toLowerCase().includes(q) || o.code.toLowerCase().includes(q));
41
+ }, [options, query]);
42
+ return (_jsxs(Popover, { open: open, onOpenChange: (next) => {
43
+ setOpen(next);
44
+ if (!next)
45
+ setQuery('');
46
+ }, placement: "bottom-start", allowFlip: true, stayInFrame: true, children: [_jsx(PopoverTrigger, { asChild: true, disablePressTrigger: true, children: _jsxs(XStack, { render: _jsx("button", { type: "button" }), onClick: () => setOpen((prev) => !prev), "data-slot": "look-language-trigger", "aria-label": t('Language'), "aria-expanded": open, items: "center", justify: "space-between", gap: "$2", minW: 220, maxW: "100%", minH: 36, "$max-sm": { minH: 44, width: '100%' }, px: "$3", rounded: "$3", bg: "$panel", borderWidth: 1, borderColor: "var(--border-strong)", hoverStyle: { bg: '$hover' }, focusVisibleStyle: { outlineWidth: 2, outlineStyle: 'solid', outlineColor: 'var(--ring)' }, cursor: "pointer", children: [_jsx(Text, { fontSize: "$2", color: "$ink", numberOfLines: 1, flex: 1, text: "left", children: current?.label ?? locale }), _jsx(ChevronDown, { size: 14, color: "$soft", "aria-hidden": true })] }) }), _jsx(PopoverContent, { solid: true, bg: "var(--popover)", borderWidth: 1, borderColor: "var(--border-strong)", boxShadow: "var(--shadow-floating)", rounded: "$4", p: "$2", width: 260, maxW: "calc(100vw - 24px)", z: "var(--z-popover)", children: _jsxs(YStack, { gap: "$1.5", children: [_jsxs(XStack, { items: "center", gap: "$1.5", px: "$2", height: 32, rounded: "$2", borderWidth: 1, borderColor: "$rim", bg: "$background", children: [_jsx(Search, { size: 13, color: "$soft", "aria-hidden": true }), _jsx(Input, { unstyled: true, flex: 1, minW: 0, height: 30, p: 0, borderWidth: 0, bg: "transparent", fontSize: "$2", color: "$ink", placeholder: t('Search language'), value: query, onChangeText: setQuery })] }), _jsx(ScrollView, { maxH: 220, children: _jsx(YStack, { gap: 2, children: filtered.map((opt) => {
47
+ const active = opt.code === locale;
48
+ return (_jsxs(XStack, { render: _jsx("button", { type: "button" }), onClick: () => {
49
+ setLocale(opt.code);
50
+ setOpen(false);
51
+ setQuery('');
52
+ }, items: "center", justify: "space-between", gap: "$2", width: "100%", minH: 32, "$max-sm": { minH: 44 }, px: "$2", rounded: "$2", borderWidth: 0, bg: active ? '$panel' : 'transparent', hoverStyle: { bg: '$hover' }, focusVisibleStyle: { outlineWidth: 2, outlineStyle: 'solid', outlineColor: 'var(--ring)' }, cursor: "pointer", children: [_jsx(Text, { fontSize: "$2", color: "$ink", fontWeight: active ? '600' : '400', numberOfLines: 1, flex: 1, text: "left", children: opt.label }), active ? _jsx(Check, { size: 14, color: "$ink", "aria-hidden": true }) : null] }, opt.code));
53
+ }) }) })] }) })] }));
54
+ }
25
55
  const PLATFORM_OPTIONS = [
26
56
  { id: 'auto', label: phrase('Auto (System OS)'), note: phrase('Automatically detects your device operating system') },
27
57
  { id: 'ios', label: phrase('Apple iOS (Liquid Glass)'), note: phrase('Continuous squircles, specular liquid glass, SF Pro typography') },
@@ -127,11 +157,12 @@ export function Look() {
127
157
  try {
128
158
  const mod = importMod(modJson.trim());
129
159
  handleSelectMod(mod);
130
- alert(t('Mod "{name}" successfully applied!', { name: mod.name }));
160
+ toast.success(t('Mod "{name}" successfully applied!', { name: mod.name }));
131
161
  setModJson('');
132
162
  }
133
163
  catch (e) {
134
- alert(t('Failed to import mod: {message}', { message: e.message }));
164
+ const message = e instanceof Error ? e.message : String(e);
165
+ toast.error(t('Failed to import mod: {message}', { message }));
135
166
  }
136
167
  };
137
168
  return (_jsxs(YStack, { gap: "$5", maxW: 540, children: [_jsx(Text, { fontSize: "$3", color: "$soft", children: t('Customized per organization and kept with your account across all Hanzo surfaces.') }), _jsx(Appearance, { org: org.id, orgName: org.name || brand(), account: { base: api(), token: accessToken ?? undefined } }), _jsxs(YStack, { gap: "$2.5", children: [_jsxs(XStack, { items: "center", gap: "$2", children: [_jsx(Smartphone, { size: 16, color: "var(--primary)", "aria-hidden": true }), _jsx(Text, { fontSize: "$4", fontWeight: "600", color: "$ink", children: t('Native Platform Look & Feel') })] }), _jsx(Text, { fontSize: "$2", color: "$soft", children: t('Adaptive styling tailored to your OS: iOS Liquid Glass, Material 3, macOS Vibrant, or Windows Mica.') }), _jsx(YStack, { gap: "$1.5", pt: "$1", children: PLATFORM_OPTIONS.map((opt) => {
@@ -140,7 +171,7 @@ export function Look() {
140
171
  }) })] }), _jsxs(YStack, { gap: "$3", children: [_jsxs(XStack, { items: "center", gap: "$2", children: [_jsx(Palette, { size: 16, color: "var(--primary)", "aria-hidden": true }), _jsx(Text, { fontSize: "$4", fontWeight: "600", color: "$ink", children: t('Organization Theme Mods (@hanzo/mod)') })] }), _jsx(Text, { fontSize: "$2", color: "$soft", children: t('Select or fork designer themes for custom organization branding.') }), _jsx(XStack, { gap: "$2", flexWrap: "wrap", children: BUILTIN_MODS.map((mod) => {
141
172
  const active = activeModId === mod.id;
142
173
  return (_jsx(Box, { render: _jsx("button", { type: "button" }), ...tap, onClick: () => handleSelectMod(mod), ...CHOICE, py: 6, px: 12, bg: active ? 'var(--edge, var(--white-14))' : 'transparent', borderColor: active ? 'var(--borderColor, var(--white-22))' : 'var(--white-10)', hoverStyle: { bg: '$hover' }, children: _jsxs(XStack, { items: "center", gap: "$1.5", children: [_jsx(Text, { fontSize: "$2", fontWeight: active ? '600' : '400', color: "$ink", children: mod.name }), active ? _jsx(Check, { size: 12, color: "var(--primary)", "aria-hidden": true }) : null] }) }, mod.id));
143
- }) }), _jsxs(YStack, { gap: "$2", p: "$3", rounded: "$3", borderWidth: 1, borderColor: "$borderColor", children: [_jsxs(XStack, { items: "center", gap: "$2", children: [_jsx(Type, { size: 15, color: "var(--primary)", "aria-hidden": true }), _jsx(Text, { fontSize: "$3", fontWeight: "600", color: "$ink", children: t('Custom Typography') })] }), _jsx(Text, { fontSize: "$2", color: "$soft", children: t('Enter a font family name (e.g. "Zen", "Inter", "Cabinet Grotesk") or a webfont stylesheet URL.') }), _jsxs(XStack, { gap: "$2", items: "center", children: [_jsx(Input, { flex: 1, size: "sm", value: customFont, onChange: (e) => setCustomFont(e.target.value), placeholder: "e.g. Cabinet Grotesk or https://fonts.googleapis.com/..." }), _jsx(Button, { size: "sm", onClick: handleApplyFont, children: fontApplied ? t('Applied!') : t('Apply Font') })] })] }), _jsxs(YStack, { gap: "$2", p: "$3", rounded: "$3", borderWidth: 1, borderColor: "$borderColor", children: [_jsx(Text, { fontSize: "$3", fontWeight: "600", color: "$ink", children: t('Fork & Share Theme Mods') }), _jsx(Text, { fontSize: "$2", color: "$soft", children: t('Export current mod configuration or paste a mod JSON to import.') }), _jsxs(XStack, { gap: "$2", items: "center", children: [_jsx(Input, { flex: 1, size: "sm", value: modJson, onChange: (e) => setModJson(e.target.value), placeholder: t('Paste mod JSON here to import') }), _jsxs(Button, { size: "sm", variant: "outline", onClick: handleImportMod, children: [_jsx(Upload, { size: 13, "aria-hidden": true }), t('Import')] }), _jsxs(Button, { size: "sm", variant: "outline", onClick: () => handleExportMod(BUILTIN_MODS[0]), children: [_jsx(Download, { size: 13, "aria-hidden": true }), copiedMod ? t('Copied!') : t('Export JSON')] })] })] })] }), _jsxs(YStack, { gap: "$2", children: [_jsx(Text, { fontSize: "$4", fontWeight: "600", color: "$ink", children: t('Language') }), _jsx(Text, { fontSize: "$2", color: "$soft", children: t('The language Hanzo is shown in, on every Hanzo surface you sign in to.') }), _jsx(XStack, { pt: "$1", children: _jsx(LanguagePicker, {}) })] }), _jsxs(YStack, { gap: "$2", "data-slot": "settings-approval-mode", children: [_jsx(Text, { fontSize: "$4", fontWeight: "600", color: "$ink", children: t('Tool & Action Approval') }), _jsx(Text, { fontSize: "$2", color: "$soft", children: t('Control whether tools, connectors, and actions execute automatically or require manual approval first.') }), _jsx(XStack, { gap: "$2", pt: "$1", children: [
174
+ }) }), _jsxs(YStack, { gap: "$2", p: "$3", rounded: "$3", borderWidth: 1, borderColor: "$borderColor", children: [_jsxs(XStack, { items: "center", gap: "$2", children: [_jsx(Type, { size: 15, color: "var(--primary)", "aria-hidden": true }), _jsx(Text, { fontSize: "$3", fontWeight: "600", color: "$ink", children: t('Custom Typography') })] }), _jsx(Text, { fontSize: "$2", color: "$soft", children: t('Enter a font family name (e.g. "Zen", "Inter", "Cabinet Grotesk") or a webfont stylesheet URL.') }), _jsxs(XStack, { gap: "$2", items: "center", children: [_jsx(Input, { flex: 1, size: "sm", value: customFont, onChange: (e) => setCustomFont(e.target.value), placeholder: "e.g. Cabinet Grotesk or https://fonts.googleapis.com/..." }), _jsx(Button, { size: "sm", onClick: handleApplyFont, children: fontApplied ? t('Applied!') : t('Apply Font') })] })] }), _jsxs(YStack, { gap: "$2", p: "$3", rounded: "$3", borderWidth: 1, borderColor: "$borderColor", children: [_jsx(Text, { fontSize: "$3", fontWeight: "600", color: "$ink", children: t('Fork & Share Theme Mods') }), _jsx(Text, { fontSize: "$2", color: "$soft", children: t('Export current mod configuration or paste a mod JSON to import.') }), _jsxs(XStack, { gap: "$2", items: "center", children: [_jsx(Input, { flex: 1, size: "sm", value: modJson, onChange: (e) => setModJson(e.target.value), placeholder: t('Paste mod JSON here to import') }), _jsxs(Button, { size: "sm", variant: "outline", onClick: handleImportMod, children: [_jsx(Upload, { size: 13, "aria-hidden": true }), t('Import')] }), _jsxs(Button, { size: "sm", variant: "outline", onClick: () => handleExportMod(BUILTIN_MODS[0]), children: [_jsx(Download, { size: 13, "aria-hidden": true }), copiedMod ? t('Copied!') : t('Export JSON')] })] })] })] }), _jsxs(YStack, { gap: "$2", children: [_jsx(Text, { fontSize: "$4", fontWeight: "600", color: "$ink", children: t('Language') }), _jsx(Text, { fontSize: "$2", color: "$soft", children: t('The language Hanzo is shown in, on every Hanzo surface you sign in to.') }), _jsx(XStack, { pt: "$1", children: _jsx(CustomLanguageSelect, {}) })] }), _jsxs(YStack, { gap: "$2", "data-slot": "settings-approval-mode", children: [_jsx(Text, { fontSize: "$4", fontWeight: "600", color: "$ink", children: t('Tool & Action Approval') }), _jsx(Text, { fontSize: "$2", color: "$soft", children: t('Control whether tools, connectors, and actions execute automatically or require manual approval first.') }), _jsx(XStack, { gap: "$2", pt: "$1", children: [
144
175
  { id: 'auto', label: t('Auto'), note: t('Runs tools on its own; pauses only for anything risky.') },
145
176
  { id: 'manual', label: t('Manual'), note: t('Asks before each tool, connector or site it opens.') },
146
177
  ].map((opt) => {
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Whether the Shell's sidebar is open, kept under App.tsx's key (`hanzo.build.rail`, true when shut) so the
3
+ * column does not jump between /chat and /home.
4
+ *
5
+ * The page is prerendered, so the first pass draws the server's tree (open) and what the reader kept arrives
6
+ * after mount; nothing kept falls back to Hanzo's earlier key `hanzo:sidebar:open`, then the window's width.
7
+ * `away` shuts it for now without keeping that: a pick on a phone is not a choice to keep it shut.
8
+ */
9
+ export declare function useSidebar(): [boolean, (next: boolean | ((open: boolean) => boolean)) => void, () => void];
@@ -0,0 +1,34 @@
1
+ 'use client';
2
+ import { useEffect, useState } from 'react';
3
+ import { useKept } from './kept.js';
4
+ /**
5
+ * Whether the Shell's sidebar is open, kept under App.tsx's key (`hanzo.build.rail`, true when shut) so the
6
+ * column does not jump between /chat and /home.
7
+ *
8
+ * The page is prerendered, so the first pass draws the server's tree (open) and what the reader kept arrives
9
+ * after mount; nothing kept falls back to Hanzo's earlier key `hanzo:sidebar:open`, then the window's width.
10
+ * `away` shuts it for now without keeping that: a pick on a phone is not a choice to keep it shut.
11
+ */
12
+ export function useSidebar() {
13
+ const [shut, setShut] = useKept('hanzo.build.rail', null);
14
+ const [started, setStarted] = useState(false);
15
+ const [first, setFirst] = useState(true);
16
+ const [away, setAway] = useState(false);
17
+ useEffect(() => {
18
+ let old = null;
19
+ try {
20
+ old = localStorage.getItem('hanzo:sidebar:open');
21
+ }
22
+ catch {
23
+ // No store is the width of the window, which is a state and not a failure.
24
+ }
25
+ setFirst(old !== null ? old === 'true' : window.innerWidth >= 768);
26
+ setStarted(true);
27
+ }, []);
28
+ const open = !away && (started ? (shut === null ? first : !shut) : true);
29
+ const set = (next) => {
30
+ setAway(false);
31
+ setShut(!(typeof next === 'function' ? next(open) : next));
32
+ };
33
+ return [open, set, () => setAway(true)];
34
+ }
@@ -0,0 +1,10 @@
1
+ import { type RefObject } from 'react';
2
+ import type { Thread } from '@hanzo/ai';
3
+ /**
4
+ * The two ways out of renaming a conversation in its row: save and cancel. Either one closes the field and puts
5
+ * focus back on the row it stood in, so the keyboard is not left on nothing; only a changed, non-empty title is sent.
6
+ */
7
+ export declare function useRenaming(from: RefObject<HTMLElement | null>, close: (id: null) => void, rename: (thread: Thread, title: string) => void, untitled: string): {
8
+ commit: (thread: Thread, next: string) => void;
9
+ cancel: () => void;
10
+ };
@@ -0,0 +1,25 @@
1
+ import { useCallback } from 'react';
2
+ import { tidy } from './lib/title.js';
3
+ /**
4
+ * The two ways out of renaming a conversation in its row: save and cancel. Either one closes the field and puts
5
+ * focus back on the row it stood in, so the keyboard is not left on nothing; only a changed, non-empty title is sent.
6
+ */
7
+ export function useRenaming(from, close, rename, untitled) {
8
+ const refocus = useCallback(() => {
9
+ requestAnimationFrame(() => {
10
+ if (from.current?.isConnected)
11
+ from.current.focus();
12
+ });
13
+ }, [from]);
14
+ const cancel = useCallback(() => {
15
+ close(null);
16
+ refocus();
17
+ }, [close, refocus]);
18
+ const commit = useCallback((thread, next) => {
19
+ cancel();
20
+ const trimmed = next.trim();
21
+ if (trimmed && trimmed !== tidy(thread.title, 80, untitled))
22
+ rename(thread, trimmed);
23
+ }, [cancel, rename, untitled]);
24
+ return { commit, cancel };
25
+ }
package/dist/seek.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import type { Press } from './chord.js';
1
+ import { type Press } from './chord.js';
2
2
  /** A row the palette can list. */
3
3
  export interface Hit {
4
4
  id: string;
@@ -40,3 +40,8 @@ export declare function find<T extends Hit>(query: string, recent: T[], idle: Gr
40
40
  * unless something on the page already answered it (Dev's composer opens its own commands and claims it).
41
41
  */
42
42
  export declare const summons: (e: Press) => boolean;
43
+ /**
44
+ * Whether a key press toggles the sidebar: ⌘B or Ctrl+B, once a press,
45
+ * ignored while typing in an input, textarea, select, or contenteditable target.
46
+ */
47
+ export declare const togglesSidebar: (e: Press) => boolean;
package/dist/seek.js CHANGED
@@ -2,6 +2,7 @@
2
2
  // in what order, under which heading, and which key press opens it. No React,
3
3
  // so a spec reads them as they are.
4
4
  import { phrase } from '@hanzo/i18n';
5
+ import { typing } from './chord.js';
5
6
  /** The most rows one group shows for a query. */
6
7
  export const CAP = 5;
7
8
  /** The rows Recent lists on an empty field. */
@@ -81,3 +82,15 @@ export function find(query, recent, idle, all) {
81
82
  * unless something on the page already answered it (Dev's composer opens its own commands and claims it).
82
83
  */
83
84
  export const summons = (e) => !e.defaultPrevented && (e.metaKey || e.ctrlKey) && !e.altKey && !e.shiftKey && !e.repeat && !e.isComposing && (e.key ?? '').toLowerCase() === 'k';
85
+ /**
86
+ * Whether a key press toggles the sidebar: ⌘B or Ctrl+B, once a press,
87
+ * ignored while typing in an input, textarea, select, or contenteditable target.
88
+ */
89
+ export const togglesSidebar = (e) => !e.defaultPrevented &&
90
+ (e.metaKey || e.ctrlKey) &&
91
+ !e.altKey &&
92
+ !e.shiftKey &&
93
+ !e.repeat &&
94
+ !e.isComposing &&
95
+ (e.key ?? '').toLowerCase() === 'b' &&
96
+ !typing(e.target);
package/dist/thread.d.ts CHANGED
@@ -35,12 +35,13 @@ export declare const href: (id: string) => string;
35
35
  * task that runs itself.
36
36
  */
37
37
  export type ThreadActions = ReturnType<typeof useThreadActions>;
38
- export declare function ConversationMenu({ threads, active, onGone, onSchedule, customActions, hrefOf, primary, children, }: {
38
+ export declare function ConversationMenu({ threads, active, onGone, onSchedule, customActions, canShare, hrefOf, primary, children, }: {
39
39
  threads: Map<string, Thread>;
40
40
  active?: string | null;
41
41
  onGone?: () => void;
42
42
  onSchedule?: (t: Thread) => void;
43
43
  customActions?: ThreadActions;
44
+ canShare?: boolean;
44
45
  hrefOf?: (id: string) => string;
45
46
  primary?: boolean;
46
47
  children: ReactElement;
package/dist/thread.js CHANGED
@@ -22,6 +22,9 @@ import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-run
22
22
  // device they sign in on.
23
23
  import { useI18n } from '@hanzo/i18n/react';
24
24
  import { tidy } from './lib/title.js';
25
+ import { InlineRename } from './InlineRename.js';
26
+ import { archiveWithUndo } from './archive.js';
27
+ import { useRenaming } from './renaming.js';
25
28
  import { createContext, useCallback, useContext, useEffect, useId, useMemo, useRef, useState, useSyncExternalStore, } from 'react';
26
29
  import { useAi } from '@hanzo/ai/react';
27
30
  import { Archive, ArchiveRestore, Check, CheckSquare, Clock, ExternalLink, FolderInput, Link2, MoreHorizontal, Pencil, Pin, PinOff, Share2, Trash2, X } from 'lucide-react';
@@ -155,6 +158,10 @@ async function copy(id, t, toUrl = href) {
155
158
  const DANGER = BAD;
156
159
  const mac = () => typeof navigator !== 'undefined' && /Mac|iPhone|iPad|iPod/.test(navigator.platform || navigator.userAgent);
157
160
  const Rows = createContext(null);
161
+ /** A menu's rows in page order: the rows that carry its id. */
162
+ function listRows(list) {
163
+ return typeof document === 'undefined' ? [] : [...document.querySelectorAll(`[data-thread][data-menu-of="${CSS.escape(list)}"]`)];
164
+ }
158
165
  const keyed = new Set();
159
166
  /**
160
167
  * A keydown anywhere on the page, before anything inside it handles it (an
@@ -187,7 +194,7 @@ function listen(keys) {
187
194
  }
188
195
  /** The element of a row that takes focus: the row itself, a button. */
189
196
  const own = (row) => row?.querySelector('[data-slot="sidebar-item"], [role="button"]') ?? null;
190
- export function ConversationMenu({ threads, active = null, onGone = empty, onSchedule, customActions, hrefOf = href, primary = true, children, }) {
197
+ export function ConversationMenu({ threads, active = null, onGone = empty, onSchedule, customActions, canShare = !customActions, hrefOf = href, primary = true, children, }) {
191
198
  const { t } = useI18n();
192
199
  const defaultAct = useThreadActions();
193
200
  const act = customActions ?? defaultAct;
@@ -198,6 +205,7 @@ export function ConversationMenu({ threads, active = null, onGone = empty, onSch
198
205
  const list = useId();
199
206
  const [menu, setMenu] = useState(null);
200
207
  const [dialogue, setDialogue] = useState(null);
208
+ const [renaming, setRenaming] = useState(null);
201
209
  const [selected, setSelected] = useState(() => new Set());
202
210
  const [selectMode, setSelectMode] = useState(false);
203
211
  const [organizeGroup, setOrganizeGroup] = useState('');
@@ -207,10 +215,12 @@ export function ConversationMenu({ threads, active = null, onGone = empty, onSch
207
215
  const didDragSelectRef = useRef(false);
208
216
  const selecting = selectMode || selected.size > 0;
209
217
  const orderedIds = useCallback(() => {
210
- const root = typeof document !== 'undefined' ? document.querySelector(`[data-menu="${list}"]`) : null;
211
- if (!root)
218
+ if (typeof document === 'undefined')
219
+ return [...threads.keys()];
220
+ const own = listRows(list);
221
+ if (!own.length)
212
222
  return [...threads.keys()];
213
- return [...root.querySelectorAll('[data-thread]')].map((el) => el.getAttribute('data-thread') ?? '').filter(Boolean);
223
+ return own.map((el) => el.getAttribute('data-thread') ?? '').filter(Boolean);
214
224
  }, [list, threads]);
215
225
  const selectRange = useCallback((fromId, toId, additive = false) => {
216
226
  const ids = orderedIds();
@@ -263,7 +273,7 @@ export function ConversationMenu({ threads, active = null, onGone = empty, onSch
263
273
  const dy = Math.abs(e.clientY - dragStartYRef.current);
264
274
  const hit = typeof document !== 'undefined' ? document.elementFromPoint(e.clientX, e.clientY)?.closest?.('[data-thread]') : null;
265
275
  const hitId = hit?.getAttribute('data-thread') ?? null;
266
- const inThisList = hit ? Boolean(hit.closest(`[data-menu="${list}"]`)) : false;
276
+ const inThisList = hit ? hit.getAttribute('data-menu-of') === list : false;
267
277
  if (dy > 6 || (hitId && inThisList && hitId !== startId)) {
268
278
  didDragSelectRef.current = true;
269
279
  window.getSelection?.()?.removeAllRanges?.();
@@ -318,6 +328,7 @@ export function ConversationMenu({ threads, active = null, onGone = empty, onSch
318
328
  onGone();
319
329
  });
320
330
  }, [act, onGone]);
331
+ const archiveOne = useCallback((target) => archiveWithUndo(act, t, target), [act, t]);
321
332
  const batchArchive = useCallback((targets) => {
322
333
  if (!targets.length)
323
334
  return;
@@ -325,8 +336,28 @@ export function ConversationMenu({ threads, active = null, onGone = empty, onSch
325
336
  setSelectMode(false);
326
337
  setSelected(new Set());
327
338
  setMenu(null);
328
- void Promise.all(targets.map((th) => (Boolean(th.archived) === allArchived ? act.archive(th) : Promise.resolve(true))));
329
- }, [act]);
339
+ const toToggle = targets.filter((th) => Boolean(th.archived) === allArchived);
340
+ void Promise.all(toToggle.map((th) => act.archive(th))).then((results) => {
341
+ const succeeded = toToggle.filter((_, i) => results[i]);
342
+ if (!succeeded.length)
343
+ return;
344
+ if (!allArchived) {
345
+ const snapshots = succeeded.map((th) => ({ ...th, archived: true }));
346
+ toast(snapshots.length === 1 ? t('Archived chat') : t('Archived {n} chats', { n: snapshots.length }), {
347
+ duration: 5000,
348
+ action: {
349
+ label: t('Undo'),
350
+ onClick: () => {
351
+ void Promise.all(snapshots.map((th) => act.archive(th)));
352
+ },
353
+ },
354
+ });
355
+ }
356
+ else {
357
+ toast.success(succeeded.length === 1 ? t('Unarchived chat') : t('Unarchived {n} chats', { n: succeeded.length }));
358
+ }
359
+ });
360
+ }, [act, t]);
330
361
  const batchPin = useCallback((targets) => {
331
362
  if (!targets.length)
332
363
  return;
@@ -395,11 +426,21 @@ export function ConversationMenu({ threads, active = null, onGone = empty, onSch
395
426
  const from = useRef(null);
396
427
  // What a right-click or a long-press landed on, before the menu decides to open.
397
428
  const pointed = useRef(null);
398
- const ask = useCallback((d, t) => {
399
- setAimed(t.id);
429
+ const ask = useCallback((d, thread) => {
430
+ setAimed(thread.id);
400
431
  setMenu(null);
432
+ if (d === 'rename' && typeof document !== 'undefined') {
433
+ const hasRow = listRows(list).some((el) => el.getAttribute('data-thread') === thread.id);
434
+ if (hasRow) {
435
+ setDialogue(null);
436
+ setRenaming(thread.id);
437
+ return;
438
+ }
439
+ }
440
+ setRenaming(null);
401
441
  setDialogue(d);
402
- }, []);
442
+ }, [list]);
443
+ const { commit: commitRename, cancel: cancelRename } = useRenaming(from, setRenaming, (thread, title) => void act.rename(thread, title), t('Untitled'));
403
444
  const aim = useCallback((t, el) => {
404
445
  from.current = el;
405
446
  setAimed(t.id);
@@ -437,7 +478,7 @@ export function ConversationMenu({ threads, active = null, onGone = empty, onSch
437
478
  const keys = useRef(null);
438
479
  keys.current = {
439
480
  open: menu !== null,
440
- held: dialogue !== null,
481
+ held: dialogue !== null || renaming !== null,
441
482
  target: () => (menu !== null ? subject : active ? (threads.get(active) ?? null) : null),
442
483
  act: (a, t) => {
443
484
  // With no menu open, focus goes back to wherever the keys were pressed.
@@ -451,8 +492,12 @@ export function ConversationMenu({ threads, active = null, onGone = empty, onSch
451
492
  };
452
493
  useEffect(() => listen(keys), []);
453
494
  const rows = useMemo(() => ({
495
+ list,
454
496
  aim,
455
497
  open: menu ? aimed : null,
498
+ renaming,
499
+ commitRename,
500
+ cancelRename,
456
501
  selected,
457
502
  selecting,
458
503
  setSelectMode,
@@ -465,7 +510,7 @@ export function ConversationMenu({ threads, active = null, onGone = empty, onSch
465
510
  toggleSelect,
466
511
  clearSelect,
467
512
  hrefOf,
468
- }), [aim, menu, aimed, selected, selecting, active, selectRange, toggleSelect, clearSelect, hrefOf]);
513
+ }), [list, aim, menu, aimed, renaming, commitRename, cancelRename, selected, selecting, active, selectRange, toggleSelect, clearSelect, hrefOf]);
469
514
  // The menu is named by its conversation: gui would name it by its trigger, the
470
515
  // list itself for a right-click, and the ⋯ for the other.
471
516
  const untitled = t('Untitled');
@@ -500,7 +545,7 @@ export function ConversationMenu({ threads, active = null, onGone = empty, onSch
500
545
  },
501
546
  {
502
547
  key: 'batch-select-all',
503
- label: allSelected ? t('Deselect All') : t('Select All ({n})', { n: threads.size }),
548
+ label: allSelected ? t('Deselect all') : t('Select all ({n})', { n: threads.size }),
504
549
  icon: _jsx(CheckSquare, { size: 16, "aria-hidden": true }),
505
550
  shortcut: apple ? '⌘A' : 'Ctrl+A',
506
551
  run: () => {
@@ -517,15 +562,6 @@ export function ConversationMenu({ threads, active = null, onGone = empty, onSch
517
562
  shortcut: 'Esc',
518
563
  run: () => clearSelect(),
519
564
  },
520
- { key: 'gone', line: true },
521
- {
522
- key: 'batch-delete',
523
- label: t('Delete ({n})', { n: selectedThreads.length }),
524
- icon: _jsx(Trash2, { size: 16, color: DANGER, "aria-hidden": true }),
525
- shortcut: '⌫',
526
- destructive: true,
527
- run: () => batchRemove(selectedThreads),
528
- },
529
565
  ]
530
566
  : subject
531
567
  ? [
@@ -545,7 +581,7 @@ export function ConversationMenu({ threads, active = null, onGone = empty, onSch
545
581
  keys: named('pin'),
546
582
  run: () => void act.pin(subject),
547
583
  },
548
- { key: 'share', label: t('Share…'), icon: _jsx(Share2, { size: 16, "aria-hidden": true }), run: () => ask('share', subject) },
584
+ ...(canShare ? [{ key: 'share', label: t('Share…'), icon: _jsx(Share2, { size: 16, "aria-hidden": true }), run: () => ask('share', subject) }] : []),
549
585
  ...(onSchedule ? [{ key: 'schedule', label: t('Schedule…'), icon: _jsx(Clock, { size: 16, "aria-hidden": true }), run: () => onSchedule(subject) }] : []),
550
586
  { key: 'copy', label: t('Copy link'), icon: _jsx(Link2, { size: 16, "aria-hidden": true }), run: () => void copy(subject.id, t, hrefOf) },
551
587
  { key: 'tab', label: t('Open in new tab'), icon: _jsx(ExternalLink, { size: 16, "aria-hidden": true }), run: () => away(subject.id, hrefOf) },
@@ -553,10 +589,10 @@ export function ConversationMenu({ threads, active = null, onGone = empty, onSch
553
589
  key: 'archive',
554
590
  label: t(subject.archived ? 'Unarchive' : 'Archive'),
555
591
  icon: subject.archived ? _jsx(ArchiveRestore, { size: 16, "aria-hidden": true }) : _jsx(Archive, { size: 16, "aria-hidden": true }),
556
- run: () => void act.archive(subject),
592
+ run: () => void archiveOne(subject),
557
593
  },
558
594
  { key: 'gone', line: true },
559
- { key: 'delete', label: t('Delete'), icon: _jsx(Trash2, { size: 16, color: DANGER, "aria-hidden": true }), destructive: true, run: () => ask('delete', subject) },
595
+ { key: 'delete', label: t('Delete'), icon: _jsx(Trash2, { size: 16, "aria-hidden": true }), run: () => ask('delete', subject) },
560
596
  ]
561
597
  : [];
562
598
  return (_jsxs(Rows.Provider, { value: rows, children: [_jsxs(DropdownMenu, { open: menu === 'dots', onOpenChange: (open) => setMenu(open ? 'dots' : null), children: [_jsxs(ContextMenu
@@ -581,22 +617,22 @@ export function ConversationMenu({ threads, active = null, onGone = empty, onSch
581
617
  }, onContextMenu: point, onPointerDown: (e) => {
582
618
  if (e.pointerType !== 'mouse')
583
619
  point(e);
584
- }, children: children }), _jsx(ContextMenuContent, { minW: 220, onCloseAutoFocus: back, "aria-labelledby": undefined, "aria-label": title, children: entries.map((one) => 'line' in one ? (_jsx(ContextMenuSeparator, {}, one.key)) : (_jsx(ContextMenuItem, { variant: one.destructive ? 'destructive' : 'default', "aria-keyshortcuts": one.keys, onSelect: one.run, children: _jsx(Face, { entry: one, Shortcut: ContextMenuShortcut }) }, one.key))) })] }), _jsx(DropdownMenuContent, { align: "end", minW: 220, onCloseAutoFocus: back, "aria-labelledby": undefined, "aria-label": title, children: entries.map((one) => 'line' in one ? (_jsx(DropdownMenuSeparator, {}, one.key)) : (_jsx(DropdownMenuItem, { variant: one.destructive ? 'destructive' : 'default', "aria-keyshortcuts": one.keys, onSelect: one.run, children: _jsx(Face, { entry: one, Shortcut: DropdownMenuShortcut }) }, one.key))) })] }), (primary && selecting) || (!primary && selected.size > 0) ? (_jsxs(YStack, { "data-slot": "batch-bar", gap: "$1.5", p: "$2", mt: "$2", rounded: "$4", bg: "$raised", borderWidth: 1, borderColor: "$borderColor",
620
+ }, children: children }), _jsx(ContextMenuContent, { minW: 220, onCloseAutoFocus: back, "aria-labelledby": undefined, "aria-label": title, children: entries.map((one) => 'line' in one ? (_jsx(ContextMenuSeparator, {}, one.key)) : (_jsx(ContextMenuItem, { variant: one.destructive ? 'destructive' : 'default', "aria-keyshortcuts": one.keys, onSelect: one.run, children: _jsx(Face, { entry: one, Shortcut: ContextMenuShortcut }) }, one.key))) })] }), _jsx(DropdownMenuContent, { align: "end", minW: 220, onCloseAutoFocus: back, "aria-labelledby": undefined, "aria-label": title, children: entries.map((one) => 'line' in one ? (_jsx(DropdownMenuSeparator, {}, one.key)) : (_jsx(DropdownMenuItem, { variant: one.destructive ? 'destructive' : 'default', "aria-keyshortcuts": one.keys, onSelect: one.run, children: _jsx(Face, { entry: one, Shortcut: DropdownMenuShortcut }) }, one.key))) })] }), (primary && selecting) || (!primary && selected.size > 0) ? (_jsxs(YStack, { "data-slot": "batch-bar", gap: "$1.5", p: "$2", mt: "$2", rounded: "$4", bg: "$panel", borderWidth: 1, borderColor: "var(--border-strong)",
585
621
  // Pinned to the list's foot, over the rows (their marks sit at 2).
586
622
  position: "sticky", b: 0, z: "var(--z-raised)", "$platform-web": {
587
623
  backdropFilter: 'blur(16px)',
588
624
  boxShadow: 'var(--shadow-lg)',
589
- }, children: [_jsxs(XStack, { items: "center", justify: "space-between", px: "$1", children: [_jsx(XStack, { render: "button", cursor: "pointer", onPress: () => {
625
+ }, children: [_jsxs(XStack, { items: "center", justify: "space-between", gap: "$2", px: "$1", children: [_jsx(XStack, { render: "button", ...{ type: 'button' }, cursor: "pointer", px: "$1.5", py: "$0.5", rounded: "$2", onClick: () => {
590
626
  if (allSelected)
591
627
  setSelected(new Set());
592
628
  else
593
629
  setSelected(new Set(orderedIds()));
594
- }, hoverStyle: { opacity: 0.8 }, children: _jsx(SizableText, { size: "$1", fontWeight: "600", color: "$soft", children: allSelected ? t('Deselect All') : t('Select All') }) }), _jsx(SizableText, { size: "$1", fontWeight: "600", color: "$ink", numberOfLines: 1, children: t('{n} Selected', { n: selectedThreads.length }) }), _jsx(XStack, { render: "button", "aria-label": t('Clear selection'), cursor: "pointer", onPress: clearSelect, hoverStyle: { opacity: 0.8 }, children: _jsx(SizableText, { size: "$1", fontWeight: "700", color: "$ink", children: t('Done') }) })] }), _jsxs(XStack, { items: "center", justify: "space-between", gap: "$1", pt: "$0.5", children: [_jsxs(XStack, { render: "button", "aria-label": t(allPinned ? 'Unpin selected' : 'Pin selected'), disabled: !selectedThreads.length, opacity: selectedThreads.length ? 1 : 0.4, flex: 1, height: 28, rounded: "$3", items: "center", justify: "center", gap: 4, cursor: selectedThreads.length ? 'pointer' : 'default', hoverStyle: selectedThreads.length ? { bg: '$hover' } : undefined, onPress: () => batchPin(selectedThreads), children: [allPinned ? _jsx(PinOff, { size: 13, "aria-hidden": true }) : _jsx(Pin, { size: 13, "aria-hidden": true }), _jsx(SizableText, { size: "$1", fontWeight: "500", color: "$ink", children: t(allPinned ? 'Unpin' : 'Pin') })] }), _jsxs(XStack, { render: "button", "aria-label": t(allArchived ? 'Unarchive selected' : 'Archive selected'), disabled: !selectedThreads.length, opacity: selectedThreads.length ? 1 : 0.4, flex: 1, height: 28, rounded: "$3", items: "center", justify: "center", gap: 4, cursor: selectedThreads.length ? 'pointer' : 'default', hoverStyle: selectedThreads.length ? { bg: '$hover' } : undefined, onPress: () => batchArchive(selectedThreads), children: [allArchived ? _jsx(ArchiveRestore, { size: 13, "aria-hidden": true }) : _jsx(Archive, { size: 13, "aria-hidden": true }), _jsx(SizableText, { size: "$1", fontWeight: "500", color: "$ink", children: t(allArchived ? 'Unarchive' : 'Archive') })] }), _jsxs(XStack, { render: "button", "aria-label": t('Organize selected'), disabled: !selectedThreads.length, opacity: selectedThreads.length ? 1 : 0.4, flex: 1, height: 28, rounded: "$3", items: "center", justify: "center", gap: 4, cursor: selectedThreads.length ? 'pointer' : 'default', hoverStyle: selectedThreads.length ? { bg: '$hover' } : undefined, onPress: () => setDialogue('organize'), children: [_jsx(FolderInput, { size: 13, "aria-hidden": true }), _jsx(SizableText, { size: "$1", fontWeight: "500", color: "$ink", children: t('Group') })] }), _jsxs(XStack, { render: "button", "aria-label": t('Delete selected'), disabled: !selectedThreads.length, opacity: selectedThreads.length ? 1 : 0.4, flex: 1, height: 28, rounded: "$3", items: "center", justify: "center", gap: 4, cursor: selectedThreads.length ? 'pointer' : 'default', hoverStyle: selectedThreads.length ? { bg: '$hover' } : undefined, onPress: () => batchRemove(selectedThreads), children: [_jsx(Trash2, { size: 13, color: DANGER, "aria-hidden": true }), _jsx(SizableText, { size: "$1", fontWeight: "500", color: DANGER, children: t('Delete') })] })] })] })) : null, _jsx(Rename, { t: subject, open: dialogue === 'rename', onOpenChange: shut, onCloseAutoFocus: after, save: (t, words) => {
630
+ }, hoverStyle: { bg: '$hover' }, focusVisibleStyle: { outlineWidth: 2, outlineStyle: 'solid', outlineColor: 'var(--ring)' }, "$max-sm": { minH: 44, items: 'center' }, children: _jsx(SizableText, { size: "$1", fontWeight: "500", color: "$soft", children: allSelected ? t('Deselect all') : t('Select all') }) }), _jsx(SizableText, { size: "$1", fontWeight: "600", color: "$ink", numberOfLines: 1, children: t('{n} selected', { n: selectedThreads.length }) }), _jsx(XStack, { render: "button", ...{ type: 'button' }, "aria-label": t('Clear selection'), cursor: "pointer", px: "$1.5", py: "$0.5", rounded: "$2", onClick: clearSelect, hoverStyle: { bg: '$hover' }, focusVisibleStyle: { outlineWidth: 2, outlineStyle: 'solid', outlineColor: 'var(--ring)' }, "$max-sm": { minH: 44, items: 'center' }, children: _jsx(SizableText, { size: "$1", fontWeight: "600", color: "$ink", children: t('Done') }) })] }), _jsxs(XStack, { items: "center", justify: "space-between", gap: "$1", pt: "$0.5", flexWrap: "wrap", children: [_jsxs(XStack, { render: "button", ...{ type: 'button' }, "aria-label": t(allPinned ? 'Unpin selected' : 'Pin selected'), disabled: !selectedThreads.length, opacity: selectedThreads.length ? 1 : 0.4, flex: 1, minW: 52, height: 28, px: "$1.5", rounded: "$3", items: "center", justify: "center", gap: 4, borderWidth: 1, borderColor: "transparent", cursor: selectedThreads.length ? 'pointer' : 'default', transition: "quickest", hoverStyle: selectedThreads.length ? { bg: '$hover', borderColor: 'var(--border-strong)' } : undefined, focusVisibleStyle: { outlineWidth: 2, outlineStyle: 'solid', outlineColor: 'var(--ring)' }, "$max-sm": { minH: 44 }, onClick: () => batchPin(selectedThreads), children: [allPinned ? _jsx(PinOff, { size: 13, color: "var(--foreground)", "aria-hidden": true }) : _jsx(Pin, { size: 13, color: "var(--foreground)", "aria-hidden": true }), _jsx(SizableText, { size: "$1", fontWeight: "500", color: "$ink", children: t(allPinned ? 'Unpin' : 'Pin') })] }), _jsxs(XStack, { render: "button", ...{ type: 'button' }, "aria-label": t(allArchived ? 'Unarchive selected' : 'Archive selected'), disabled: !selectedThreads.length, opacity: selectedThreads.length ? 1 : 0.4, flex: 1, minW: 56, height: 28, px: "$1.5", rounded: "$3", items: "center", justify: "center", gap: 4, borderWidth: 1, borderColor: "transparent", cursor: selectedThreads.length ? 'pointer' : 'default', transition: "quickest", hoverStyle: selectedThreads.length ? { bg: '$hover', borderColor: 'var(--border-strong)' } : undefined, focusVisibleStyle: { outlineWidth: 2, outlineStyle: 'solid', outlineColor: 'var(--ring)' }, "$max-sm": { minH: 44 }, onClick: () => batchArchive(selectedThreads), children: [allArchived ? _jsx(ArchiveRestore, { size: 13, color: "var(--foreground)", "aria-hidden": true }) : _jsx(Archive, { size: 13, color: "var(--foreground)", "aria-hidden": true }), _jsx(SizableText, { size: "$1", fontWeight: "500", color: "$ink", children: t(allArchived ? 'Unarchive' : 'Archive') })] }), _jsxs(XStack, { render: "button", ...{ type: 'button' }, "aria-label": t('Organize selected'), disabled: !selectedThreads.length, opacity: selectedThreads.length ? 1 : 0.4, flex: 1, minW: 52, height: 28, px: "$1.5", rounded: "$3", items: "center", justify: "center", gap: 4, borderWidth: 1, borderColor: "transparent", cursor: selectedThreads.length ? 'pointer' : 'default', transition: "quickest", hoverStyle: selectedThreads.length ? { bg: '$hover', borderColor: 'var(--border-strong)' } : undefined, focusVisibleStyle: { outlineWidth: 2, outlineStyle: 'solid', outlineColor: 'var(--ring)' }, "$max-sm": { minH: 44 }, onClick: () => setDialogue('organize'), children: [_jsx(FolderInput, { size: 13, color: "var(--foreground)", "aria-hidden": true }), _jsx(SizableText, { size: "$1", fontWeight: "500", color: "$ink", children: t('Group') })] })] })] })) : null, _jsx(Rename, { t: subject, open: dialogue === 'rename', onOpenChange: shut, onCloseAutoFocus: after, save: (t, words) => {
595
631
  if (words !== titleOf(t, untitled))
596
632
  void act.rename(t, words);
597
633
  } }), _jsx(Delete, { t: subject, open: dialogue === 'delete', onOpenChange: shut, onCloseAutoFocus: after, remove: (t) => {
598
634
  // Focus goes on to the row after it, or the one before, not to the page.
599
- const rows = [...(document.querySelector(`[data-menu="${list}"]`)?.querySelectorAll('[data-thread]') ?? [])];
635
+ const rows = listRows(list);
600
636
  const at = rows.findIndex((row) => row.getAttribute('data-thread') === t.id);
601
637
  if (at >= 0)
602
638
  from.current = own(rows[at + 1] ?? rows[at - 1] ?? null);
@@ -604,11 +640,11 @@ export function ConversationMenu({ threads, active = null, onGone = empty, onSch
604
640
  if (ok && holds.current === t.id)
605
641
  onGone();
606
642
  });
607
- } }), _jsx(ShareDialog, { thread: subject?.id ?? null, open: dialogue === 'share', onOpenChange: shut, onCloseAutoFocus: after }), _jsx(Dialog, { open: dialogue === 'organize', onOpenChange: shut, children: _jsxs(DialogContent, { maxW: 440, rounded: "$6", gap: "$3", onCloseAutoFocus: after, children: [_jsx(DialogTitle, { children: t('Organize {n} chats', { n: selectedThreads.length }) }), _jsx(SizableText, { size: "$2", color: "$soft", children: t('Group and tag the selected chats under a shared project or topic label.') }), _jsx(Input, { autoFocus: true, value: organizeGroup, onChangeText: setOrganizeGroup, placeholder: t('e.g. Research, Architecture, Q4 Launch'), "aria-label": t('Group or project name'), maxLength: 40, onKeyDown: (e) => {
643
+ } }), canShare ? _jsx(ShareDialog, { thread: subject?.id ?? null, open: dialogue === 'share', onOpenChange: shut, onCloseAutoFocus: after }) : null, _jsx(Dialog, { open: dialogue === 'organize', onOpenChange: shut, children: _jsxs(DialogContent, { maxW: 440, width: "calc(100vw - 24px)", rounded: "$6", gap: "$3", onCloseAutoFocus: after, children: [_jsx(DialogTitle, { children: t('Organize {n} chats', { n: selectedThreads.length }) }), _jsx(SizableText, { size: "$2", color: "$soft", children: t('Group and tag the selected chats under a shared project or topic label.') }), _jsx(Input, { autoFocus: true, value: organizeGroup, onChangeText: setOrganizeGroup, placeholder: t('e.g. Research, Architecture, Q4 Launch'), "aria-label": t('Group or project name'), borderColor: "var(--border-strong)", focusVisibleStyle: { outlineWidth: 2, outlineStyle: 'solid', outlineColor: 'var(--ring)' }, "$max-sm": { minH: 44 }, maxLength: 40, onKeyDown: (e) => {
608
644
  if (e.key === 'Enter' && !e.nativeEvent?.isComposing && e.keyCode !== 229 && organizeGroup.trim()) {
609
645
  batchOrganize(selectedThreads, organizeGroup);
610
646
  }
611
- } }), _jsxs(XStack, { gap: "$2", justify: "flex-end", children: [_jsx(Button, { size: "sm", variant: "outline", rounded: 999, onPress: () => shut(false), children: t('Cancel') }), _jsx(Button, { size: "sm", rounded: 999, disabled: !organizeGroup.trim(), onPress: () => batchOrganize(selectedThreads, organizeGroup), children: t('Apply to {n} chats', { n: selectedThreads.length }) })] })] }) })] }));
647
+ } }), _jsxs(XStack, { gap: "$2", justify: "flex-end", flexWrap: "wrap", children: [_jsx(Button, { size: "sm", variant: "outline", rounded: 999, borderColor: "var(--border-strong)", focusVisibleStyle: { outlineWidth: 2, outlineStyle: 'solid', outlineColor: 'var(--ring)' }, "$max-sm": { minH: 44 }, onPress: () => shut(false), children: t('Cancel') }), _jsx(Button, { size: "sm", rounded: 999, focusVisibleStyle: { outlineWidth: 2, outlineStyle: 'solid', outlineColor: 'var(--ring)' }, "$max-sm": { minH: 44 }, disabled: !organizeGroup.trim(), onPress: () => batchOrganize(selectedThreads, organizeGroup), children: t('Apply to {n} chats', { n: selectedThreads.length }) })] })] }) })] }));
612
648
  }
613
649
  /** One entry's line: its icon in a 16px well, its name, and its keys at the end. */
614
650
  function Face({ entry, Shortcut, }) {
@@ -635,16 +671,20 @@ export function ThreadRow({ t: thread, active = false, aside, listed = true, chi
635
671
  // What the ⋯ is for, said after its name: the row's title.
636
672
  const about = useId();
637
673
  const isSelected = menus.selected.has(thread.id);
638
- // The ⋯ and the age share one place: whichever shows, the other gives way.
639
- const shown = active || isSelected || menus.open === thread.id || focused;
674
+ const isRenaming = menus.renaming === thread.id;
675
+ // The ⋯ and the age share one place: on hover, focus, or when the row's menu is open, ⋯ replaces the age.
676
+ const menuOrFocus = menus.open === thread.id || focused;
640
677
  // gui types these handlers by React Native's event; on the web they carry the DOM's.
641
678
  const aim = (e) => menus.aim(thread, e.currentTarget);
642
679
  // A new tab for the row itself, never for its ⋯.
643
680
  const onDots = (target) => Boolean(target?.closest?.('[data-slot="thread-options"]'));
681
+ if (isRenaming) {
682
+ return (_jsx(YStack, { ...(listed ? { role: 'listitem' } : null), position: "relative", rounded: "$4", "data-thread": thread.id, "data-menu-of": menus.list, "data-renaming": "", children: _jsx(InlineRename, { initial: titleOf(thread, t('Untitled')), onSave: (next) => menus.commitRename(thread, next), onCancel: menus.cancelRename }) }));
683
+ }
644
684
  return (_jsxs(YStack, { ...(listed ? { role: 'listitem' } : null), position: "relative", group: true, rounded: "$4", bg: isSelected ? '$hover' : undefined, "$platform-web": {
645
685
  userSelect: 'none',
646
686
  ...(isSelected ? { backgroundColor: 'var(--glass)' } : null),
647
- }, "data-thread": thread.id, "data-selected": isSelected ? '' : undefined, "data-pinned": thread.pinned ? '' : undefined, onPointerDownCapture: (down) => {
687
+ }, "data-thread": thread.id, "data-menu-of": menus.list, "data-selected": isSelected ? '' : undefined, "data-pinned": thread.pinned ? '' : undefined, "data-archived": thread.archived ? '' : undefined, onPointerDownCapture: (down) => {
648
688
  const e = down;
649
689
  if (e.button !== 0 || onDots(e.target))
650
690
  return;
@@ -723,12 +763,9 @@ export function ThreadRow({ t: thread, active = false, aside, listed = true, chi
723
763
  return;
724
764
  e.preventDefault();
725
765
  away(thread.id, menus.hrefOf);
726
- }, children: [menus.selecting ? (_jsx(XStack, { position: "absolute", insetInlineStart: 6, t: 0, b: 0, items: "center", justify: "center", pointerEvents: "none", z: 2, "aria-hidden": true, children: _jsx(XStack, { width: 18, height: 18, rounded: 999, items: "center", justify: "center", borderWidth: 1.5, borderStyle: "solid", bg: isSelected ? 'var(--foreground)' : 'transparent', borderColor: isSelected ? 'var(--foreground)' : 'var(--muted-foreground)', opacity: isSelected ? 1 : 0.65, children: isSelected ? _jsx(Check, { size: 11, strokeWidth: 3, color: "var(--background)", "aria-hidden": true }) : null }) })) : null, menus.selecting ? _jsx(YStack, { paddingInlineStart: 22, children: children }) : children, _jsx(Text, { id: about, display: "none", children: titleOf(thread, t('Untitled')) }), aside ? (_jsx(XStack, { position: "absolute", insetInlineEnd: "$2", t: 0, b: 0, items: "center", pointerEvents: "none", opacity: shown ? 0 : 1, $touchable: { opacity: 0 }, children: aside })) : null, _jsx(XStack, { position: "absolute", insetInlineEnd: "$1", t: 0, b: 0, items: "center", children: _jsx(DropdownMenuTrigger, { asChild: true, children: _jsx(XStack, { render: "button", "aria-label": t('Chat options'), "aria-describedby": about, id: id, "data-slot": "thread-options", width: 26, height: 26, rounded: "$2", items: "center", justify: "center", cursor: "pointer", bg: "transparent", display: "none",
727
- // A thumb's 44px on a touch screen (lib/tap.ts), centred on the row and over its edges.
728
- // On desktop, right-clicking the row opens the context menu directly without a "..." button.
729
- $touchable: { display: 'flex', opacity: 1, minW: 44, minH: 44 }, hoverStyle: { bg: '$hover' },
766
+ }, children: [menus.selecting ? (_jsx(XStack, { position: "absolute", insetInlineStart: 6, t: 0, b: 0, items: "center", justify: "center", pointerEvents: "none", z: "var(--z-raised)", "aria-hidden": true, children: _jsx(XStack, { width: 18, height: 18, rounded: 999, items: "center", justify: "center", borderWidth: 1.5, borderStyle: "solid", bg: isSelected ? 'var(--foreground)' : 'transparent', borderColor: isSelected ? 'var(--foreground)' : 'var(--muted-foreground)', opacity: isSelected ? 1 : 0.65, children: isSelected ? _jsx(Check, { size: 11, strokeWidth: 3, color: "var(--background)", "aria-hidden": true }) : null }) })) : null, menus.selecting ? _jsx(YStack, { paddingInlineStart: 22, children: children }) : children, _jsx(Text, { id: about, display: "none", children: titleOf(thread, t('Untitled')) }), aside ? (_jsx(XStack, { position: "absolute", insetInlineEnd: "$2", t: 0, b: 0, items: "center", pointerEvents: "none", opacity: menuOrFocus ? 0 : 1, "$group-hover": { opacity: 0 }, $touchable: { opacity: 0 }, children: aside })) : null, _jsx(XStack, { position: "absolute", insetInlineEnd: "$1", t: 0, b: 0, items: "center", children: _jsx(DropdownMenuTrigger, { asChild: true, children: _jsx(XStack, { render: "button", "aria-label": t('Chat options'), "aria-describedby": about, id: id, "data-slot": "thread-options", width: 26, height: 26, rounded: "$2", items: "center", justify: "center", cursor: "pointer", bg: menus.open === thread.id ? '$hover' : 'transparent', display: "flex", opacity: menuOrFocus ? 1 : 0, "$group-hover": { opacity: 1 }, focusStyle: { opacity: 1 }, focusVisibleStyle: { opacity: 1, outlineWidth: 2, outlineStyle: 'solid', outlineColor: 'var(--ring)' }, $touchable: { opacity: 1, minW: 44, minH: 44 }, "$max-sm": { opacity: 1, minW: 44, minH: 44 }, transition: "quickest", hoverStyle: { bg: '$hover' },
730
767
  // Before gui's own press handler, which opens the menu and stops there.
731
- onPointerDownCapture: aim, onKeyDownCapture: aim, onFocus: () => setFocused(true), onBlur: () => setFocused(false), children: _jsx(MoreHorizontal, { size: 15, "aria-hidden": true }) }) }) })] }));
768
+ onPointerDownCapture: aim, onKeyDownCapture: aim, onFocus: () => setFocused(true), onBlur: () => setFocused(false), children: _jsx(MoreHorizontal, { size: 15, color: "var(--muted-foreground)", "aria-hidden": true }) }) }) })] }));
732
769
  }
733
770
  /**
734
771
  * The ⋯ of the conversation a pane holds, in its header: the trigger of the
@@ -745,7 +782,7 @@ export function ThreadMore({ t: thread }) {
745
782
  const isOpen = menus.open === thread.id;
746
783
  // gui types these handlers by React Native's event; on the web they carry the DOM's.
747
784
  const aim = (e) => menus.aim(thread, e.currentTarget);
748
- return (_jsx(DropdownMenuTrigger, { asChild: true, children: _jsx(XStack, { render: "button", "aria-label": t('Conversation options'), ...{ title: t('More') }, "data-slot": "conversation-options", width: 32, height: 32, rounded: "$3", items: "center", justify: "center", cursor: "pointer", bg: isOpen ? '$hover' : 'transparent', opacity: isOpen || focused || hovered ? 1 : 0.72, hoverStyle: { bg: '$hover', opacity: 1 }, focusVisibleStyle: { outlineWidth: 2, outlineStyle: 'solid', outlineColor: '$outlineColor', opacity: 1 },
785
+ return (_jsx(DropdownMenuTrigger, { asChild: true, children: _jsx(XStack, { render: "button", "aria-label": t('Conversation options'), ...{ title: t('More') }, "data-slot": "conversation-options", width: 32, height: 32, rounded: "$3", items: "center", justify: "center", cursor: "pointer", bg: isOpen ? '$hover' : 'transparent', opacity: isOpen || focused || hovered ? 1 : 0.72, transition: "quickest", hoverStyle: { bg: '$hover', opacity: 1 }, focusVisibleStyle: { outlineWidth: 2, outlineStyle: 'solid', outlineColor: 'var(--ring)', opacity: 1 }, "$max-sm": { minW: 44, minH: 44 },
749
786
  // Before gui's own press handler, which opens the menu and stops there.
750
787
  onPointerDownCapture: aim, onKeyDownCapture: aim, onMouseEnter: () => setHovered(true), onMouseLeave: () => setHovered(false), onFocus: () => setFocused(true), onBlur: () => setFocused(false), children: _jsx(MoreHorizontal, { size: 16, "aria-hidden": true }) }) }));
751
788
  }
@@ -768,18 +805,22 @@ function Rename({ t: thread, open, onOpenChange, onCloseAutoFocus, save, }) {
768
805
  onOpenChange(false);
769
806
  save(thread, title);
770
807
  };
771
- return (_jsx(Dialog, { open: open, onOpenChange: onOpenChange, children: _jsxs(DialogContent, { maxW: 440, rounded: "$6", gap: "$3", onCloseAutoFocus: onCloseAutoFocus, children: [_jsx(DialogTitle, { children: t('Rename chat') }), _jsx(Input, { autoFocus: true, value: words, onChangeText: setWords, "aria-label": t('Chat title'), maxLength: 80, onKeyDown: (e) => {
808
+ return (_jsx(Dialog, { open: open, onOpenChange: onOpenChange, children: _jsxs(DialogContent, { maxW: 440, width: "calc(100vw - 24px)", rounded: "$6", gap: "$3", onCloseAutoFocus: onCloseAutoFocus, children: [_jsx(DialogTitle, { children: t('Rename chat') }), _jsx(Input, { autoFocus: true, value: words, onChangeText: setWords, "aria-label": t('Chat title'), borderColor: "var(--border-strong)", focusVisibleStyle: { outlineWidth: 2, outlineStyle: 'solid', outlineColor: 'var(--ring)' }, "$max-sm": { minH: 44 }, maxLength: 80, onKeyDown: (e) => {
809
+ if (e.key === 'Escape') {
810
+ onOpenChange(false);
811
+ return;
812
+ }
772
813
  // An Enter that ends an IME composition writes the word; it does not save.
773
814
  if (e.key === 'Enter' && !e.nativeEvent?.isComposing && e.keyCode !== 229)
774
815
  submit();
775
- } }), _jsxs(XStack, { gap: "$2", justify: "flex-end", children: [_jsx(Button, { size: "sm", variant: "outline", rounded: 999, onPress: () => onOpenChange(false), children: t('Cancel') }), _jsx(Button, { size: "sm", rounded: 999, disabled: !words.trim(), onPress: submit, children: t('Save') })] })] }) }));
816
+ } }), _jsxs(XStack, { gap: "$2", justify: "flex-end", flexWrap: "wrap", children: [_jsx(Button, { size: "sm", variant: "outline", rounded: 999, borderColor: "var(--border-strong)", focusVisibleStyle: { outlineWidth: 2, outlineStyle: 'solid', outlineColor: 'var(--ring)' }, "$max-sm": { minH: 44 }, onPress: () => onOpenChange(false), children: t('Cancel') }), _jsx(Button, { size: "sm", rounded: 999, focusVisibleStyle: { outlineWidth: 2, outlineStyle: 'solid', outlineColor: 'var(--ring)' }, "$max-sm": { minH: 44 }, disabled: !words.trim(), onPress: submit, children: t('Save') })] })] }) }));
776
817
  }
777
818
  /** Deleting asks first, and says what goes with it: every turn, and every link it was shared by. */
778
819
  function Delete({ t: thread, open, onOpenChange, onCloseAutoFocus, remove, }) {
779
820
  const { t } = useI18n();
780
- return (_jsx(Dialog, { open: open, onOpenChange: onOpenChange, children: _jsxs(DialogContent, { maxW: 440, rounded: "$6", gap: "$3", onCloseAutoFocus: onCloseAutoFocus, children: [_jsx(DialogTitle, { children: t('Delete chat?') }), _jsx(SizableText, { size: "$2", color: "$soft", children: t('“{title}” is deleted for good, with every link it was shared by. To keep it out of the list instead, archive it.', {
821
+ return (_jsx(Dialog, { open: open, onOpenChange: onOpenChange, children: _jsxs(DialogContent, { maxW: 440, width: "calc(100vw - 24px)", rounded: "$6", gap: "$3", onCloseAutoFocus: onCloseAutoFocus, children: [_jsx(DialogTitle, { children: t('Delete chat?') }), _jsx(SizableText, { size: "$2", color: "$soft", children: t('“{title}” is deleted for good, with every link it was shared by. To keep it out of the list instead, archive it.', {
781
822
  title: thread ? titleOf(thread, t('Untitled')) : '',
782
- }) }), _jsxs(XStack, { gap: "$2", justify: "flex-end", children: [_jsx(Button, { size: "sm", variant: "outline", rounded: 999, onPress: () => onOpenChange(false), children: t('Cancel') }), _jsx(Button, { size: "sm", variant: "destructive", rounded: 999, disabled: !thread, onPress: () => {
823
+ }) }), _jsxs(XStack, { gap: "$2", justify: "flex-end", flexWrap: "wrap", children: [_jsx(Button, { size: "sm", variant: "outline", rounded: 999, borderColor: "var(--border-strong)", focusVisibleStyle: { outlineWidth: 2, outlineStyle: 'solid', outlineColor: 'var(--ring)' }, "$max-sm": { minH: 44 }, onPress: () => onOpenChange(false), children: t('Cancel') }), _jsx(Button, { size: "sm", rounded: 999, bg: "var(--state-error)", borderColor: "var(--state-error)", color: "var(--pure-white)", hoverStyle: { bg: 'var(--state-error)', opacity: 0.9 }, focusVisibleStyle: { outlineWidth: 2, outlineStyle: 'solid', outlineColor: 'var(--ring)' }, "$max-sm": { minH: 44 }, disabled: !thread, onPress: () => {
783
824
  // Once: a second press while the dialog closes would ask the store to delete it again.
784
825
  if (!open || !thread)
785
826
  return;