@hanzo/app 0.3.94 → 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 (99) 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/chord.d.ts +13 -0
  64. package/dist/chord.js +30 -1
  65. package/dist/crew.js +47 -4
  66. package/dist/ground.d.ts +1 -1
  67. package/dist/ground.js +1 -1
  68. package/dist/help.d.ts +7 -3
  69. package/dist/help.js +19 -14
  70. package/dist/keys.d.ts +28 -0
  71. package/dist/keys.js +58 -0
  72. package/dist/lib/arrival.d.ts +5 -0
  73. package/dist/lib/arrival.js +10 -0
  74. package/dist/lib/betas.d.ts +2 -0
  75. package/dist/lib/betas.js +10 -0
  76. package/dist/lib/branch.d.ts +11 -0
  77. package/dist/lib/branch.js +11 -0
  78. package/dist/lib/chatPreferences.d.ts +1 -1
  79. package/dist/lib/chatPreferences.js +1 -1
  80. package/dist/lib/dev-mode.d.ts +18 -0
  81. package/dist/lib/dev-mode.js +102 -0
  82. package/dist/lib/info-hint.d.ts +7 -0
  83. package/dist/lib/info-hint.js +8 -0
  84. package/dist/lib/model-picker.d.ts +2 -0
  85. package/dist/lib/model-picker.js +12 -0
  86. package/dist/lib/owners.d.ts +5 -0
  87. package/dist/lib/owners.js +15 -0
  88. package/dist/lib/pay.d.ts +2 -0
  89. package/dist/lib/pay.js +4 -0
  90. package/dist/lib/todo.d.ts +6 -0
  91. package/dist/lib/todo.js +37 -25
  92. package/dist/look.js +39 -8
  93. package/dist/rail-open.d.ts +9 -0
  94. package/dist/rail-open.js +34 -0
  95. package/dist/renaming.d.ts +10 -0
  96. package/dist/renaming.js +25 -0
  97. package/dist/thread.d.ts +2 -1
  98. package/dist/thread.js +85 -44
  99. package/package.json +11 -11
@@ -0,0 +1,11 @@
1
+ /** What a branch saves: the chat up to this answer, as plain turns. Nothing at all for a chat that keeps nothing (anonymous or private), or an empty one. */
2
+ export declare function branched<T extends {
3
+ id?: string;
4
+ role: string;
5
+ }>(list: readonly T[], turnId: string, text: (turn: T) => string, chat: {
6
+ anonymous?: boolean;
7
+ forgetful?: boolean;
8
+ }): {
9
+ role: string;
10
+ content: string;
11
+ }[] | null;
@@ -0,0 +1,11 @@
1
+ /** What a branch saves: the chat up to this answer, as plain turns. Nothing at all for a chat that keeps nothing (anonymous or private), or an empty one. */
2
+ export function branched(list, turnId, text, chat) {
3
+ if (chat.anonymous || chat.forgetful)
4
+ return null;
5
+ const at = list.findIndex((m) => m.id === turnId);
6
+ const turns = (at >= 0 ? list.slice(0, at + 1) : list)
7
+ .filter((m) => m.role === 'user' || m.role === 'assistant')
8
+ .map((m) => ({ role: m.role, content: text(m) }))
9
+ .filter((m) => m.content.trim());
10
+ return turns.length ? turns : null;
11
+ }
@@ -11,7 +11,7 @@ export interface ChatPreferences {
11
11
  showLanguage?: boolean;
12
12
  effortVersion?: number;
13
13
  }
14
- /** The effort Dev takes for one chosen here (@hanzo/build `EFFORTS`: Auto, High, Max), or null for Instant, Low and Medium, which only Chat offers. */
14
+ /** The effort Dev takes for one chosen here (@hanzo/build `EFFORTS`: Auto, Low (shown as Fast), High, Max), or null for Instant and Medium, which only Chat offers. */
15
15
  export declare function shared(effort: Effort): Level | null;
16
16
  export declare function getChatPreferences(): ChatPreferences;
17
17
  export declare function setChatPreferences(patch: Partial<ChatPreferences>): ChatPreferences;
@@ -22,7 +22,7 @@ const DEFAULT_PREFERENCES = {
22
22
  showLanguage: false,
23
23
  effortVersion: EFFORT_SCHEMA_VERSION,
24
24
  };
25
- /** The effort Dev takes for one chosen here (@hanzo/build `EFFORTS`: Auto, High, Max), or null for Instant, Low and Medium, which only Chat offers. */
25
+ /** The effort Dev takes for one chosen here (@hanzo/build `EFFORTS`: Auto, Low (shown as Fast), High, Max), or null for Instant and Medium, which only Chat offers. */
26
26
  export function shared(effort) {
27
27
  return DEV.some((e) => e.id === effort) ? effort : null;
28
28
  }
@@ -0,0 +1,18 @@
1
+ export declare const DEV_MODE_KEY = "hanzo.dev_mode";
2
+ export declare const DEV_MODE_EVENT = "hanzo:dev-mode";
3
+ export declare const SETTINGS_RETURN_KEY = "hanzo.settings.return";
4
+ export declare function getDevMode(): boolean;
5
+ export declare function setDevMode(next: boolean): void;
6
+ export declare function useDevMode(): [boolean, (next: boolean) => void];
7
+ export interface DeviceLabelOptions {
8
+ firstName?: string | null;
9
+ kind?: string | null;
10
+ os?: string | null;
11
+ devMode?: boolean;
12
+ }
13
+ export declare function formatDeviceLabel(raw: string | null | undefined, opts?: DeviceLabelOptions): {
14
+ title: string;
15
+ detail?: string;
16
+ };
17
+ export declare function rememberSettingsReturn(path?: string): void;
18
+ export declare function readSettingsReturn(fallback?: string): string;
@@ -0,0 +1,102 @@
1
+ import { useCallback, useSyncExternalStore } from 'react';
2
+ export const DEV_MODE_KEY = 'hanzo.dev_mode';
3
+ export const DEV_MODE_EVENT = 'hanzo:dev-mode';
4
+ export const SETTINGS_RETURN_KEY = 'hanzo.settings.return';
5
+ export function getDevMode() {
6
+ if (typeof window === 'undefined')
7
+ return false;
8
+ try {
9
+ return window.localStorage.getItem(DEV_MODE_KEY) === 'true';
10
+ }
11
+ catch {
12
+ return false;
13
+ }
14
+ }
15
+ export function setDevMode(next) {
16
+ if (typeof window === 'undefined')
17
+ return;
18
+ try {
19
+ window.localStorage.setItem(DEV_MODE_KEY, next ? 'true' : 'false');
20
+ }
21
+ catch { }
22
+ window.dispatchEvent(new CustomEvent(DEV_MODE_EVENT, { detail: { enabled: next } }));
23
+ }
24
+ function subscribeDevMode(onChange) {
25
+ if (typeof window === 'undefined')
26
+ return () => { };
27
+ const handler = () => onChange();
28
+ const onStorage = (e) => {
29
+ if (e.key === DEV_MODE_KEY)
30
+ onChange();
31
+ };
32
+ window.addEventListener(DEV_MODE_EVENT, handler);
33
+ window.addEventListener('storage', onStorage);
34
+ return () => {
35
+ window.removeEventListener(DEV_MODE_EVENT, handler);
36
+ window.removeEventListener('storage', onStorage);
37
+ };
38
+ }
39
+ export function useDevMode() {
40
+ const enabled = useSyncExternalStore(subscribeDevMode, getDevMode, () => false);
41
+ const update = useCallback((next) => setDevMode(next), []);
42
+ return [enabled, update];
43
+ }
44
+ export function formatDeviceLabel(raw, opts = {}) {
45
+ const cleanRaw = (raw ?? '').trim();
46
+ if (!cleanRaw)
47
+ return { title: 'Cloud' };
48
+ if (opts.devMode)
49
+ return { title: cleanRaw };
50
+ const lower = cleanRaw.toLowerCase();
51
+ if (lower === 'hanzo sandbox' ||
52
+ lower === 'sandbox' ||
53
+ lower === 'cloud' ||
54
+ /^cloud(-\d+)?(\b|\s|·)/.test(lower)) {
55
+ return {
56
+ title: 'Auto (Cloud)',
57
+ detail: cleanRaw === 'Cloud' ? 'Managed Hanzo cloud workspace' : cleanRaw,
58
+ };
59
+ }
60
+ // Strip shell/tmux/hardware suffixes for the human-facing title while keeping full detail for tooltip
61
+ const basePart = cleanRaw
62
+ .split(/\s*·\s*/)[0]
63
+ .replace(/\s*\((?:shell|desk|tmux|tty)[^)]*\)\s*$/i, '')
64
+ .replace(/\.(local|lan|home|internal)$/i, '')
65
+ .replace(/-\d+$/, '')
66
+ .trim();
67
+ if (/macbook|\b(imac|mac-studio|mac-mini|mac|laptop|desktop|workstation|localhost|local)\b/i.test(cleanRaw) ||
68
+ opts.os === 'darwin' ||
69
+ opts.kind === 'laptop' ||
70
+ opts.kind === 'desktop' ||
71
+ /^tgt_[a-z0-9]+$/i.test(basePart)) {
72
+ const title = 'Local - Device';
73
+ return { title, detail: cleanRaw !== title ? cleanRaw : undefined };
74
+ }
75
+ const humanized = basePart
76
+ .replace(/[-_]+/g, ' ')
77
+ .trim();
78
+ const title = humanized ? `Local - ${humanized}` : 'Local - Device';
79
+ return { title, detail: cleanRaw !== title ? cleanRaw : undefined };
80
+ }
81
+ export function rememberSettingsReturn(path) {
82
+ if (typeof window === 'undefined')
83
+ return;
84
+ try {
85
+ const target = path ?? `${window.location.pathname}${window.location.search}`;
86
+ if (target && !target.startsWith('/settings')) {
87
+ window.sessionStorage.setItem(SETTINGS_RETURN_KEY, target);
88
+ }
89
+ }
90
+ catch { }
91
+ }
92
+ export function readSettingsReturn(fallback = '/chat') {
93
+ if (typeof window === 'undefined')
94
+ return fallback;
95
+ try {
96
+ const saved = window.sessionStorage.getItem(SETTINGS_RETURN_KEY);
97
+ return saved && !saved.startsWith('/settings') ? saved : fallback;
98
+ }
99
+ catch {
100
+ return fallback;
101
+ }
102
+ }
@@ -0,0 +1,7 @@
1
+ import React from 'react';
2
+ export interface InfoHintProps {
3
+ text: string;
4
+ size?: number;
5
+ side?: 'top' | 'right' | 'bottom' | 'left';
6
+ }
7
+ export declare function InfoHint({ text, size, side }: InfoHintProps): React.JSX.Element;
@@ -0,0 +1,8 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { Info } from 'lucide-react';
3
+ import { Text, Tooltip, TooltipContent, TooltipProvider, TooltipTrigger, Box } from '@hanzo/ui';
4
+ export function InfoHint({ text, size = 13, side = 'top' }) {
5
+ if (!text)
6
+ return null;
7
+ return (_jsx(TooltipProvider, { delay: 150, children: _jsxs(Tooltip, { placement: side, offset: 6, children: [_jsx(TooltipTrigger, { asChild: true, children: _jsx(Box, { render: _jsx("button", { type: "button", "aria-label": text }), items: "center", justify: "center", p: "$0.5", m: 0, borderWidth: 0, bg: "transparent", rounded: "$10", cursor: "help", focusVisibleStyle: { outlineWidth: 1, outlineStyle: 'solid', outlineColor: '$outlineColor' }, onClick: (e) => e.stopPropagation(), children: _jsx(Text, { color: "$hint", hoverStyle: { color: '$ink' }, display: "flex", children: _jsx(Info, { size: size, color: "currentColor", "aria-hidden": true }) }) }) }), _jsx(TooltipContent, { maxW: 260, px: "$3", py: "$2", rounded: "$3", bg: "var(--popover)", borderWidth: 1, borderColor: "$edge", z: "var(--z-tooltip)", children: _jsx(Text, { fontFamily: "$body", fontSize: "$1", lineHeight: 16, color: "$aside", children: text }) })] }) }));
8
+ }
@@ -0,0 +1,2 @@
1
+ /** Opens the composer's model menu the way a press would. False when the page has no composer to open it on. */
2
+ export declare function openModelPicker(): boolean;
@@ -0,0 +1,12 @@
1
+ /** Opens the composer's model menu the way a press would. False when the page has no composer to open it on. */
2
+ export function openModelPicker() {
3
+ if (typeof document === 'undefined')
4
+ return false;
5
+ const chip = document.querySelector('[data-slot="mind"] [data-slot="model-picker"]');
6
+ if (!chip)
7
+ return false;
8
+ chip.focus();
9
+ // The picker opens on a key or a real press, not a synthetic click().
10
+ chip.dispatchEvent(new KeyboardEvent('keydown', { key: 'Enter', bubbles: true, cancelable: true }));
11
+ return true;
12
+ }
@@ -0,0 +1,5 @@
1
+ /** Who is mounted, in order: the first is the one that answers a window-wide trigger, so two mounted dialogs never both open. */
2
+ export declare function owners(): {
3
+ claim(id: string): () => void;
4
+ owns: (id: string) => boolean;
5
+ };
@@ -0,0 +1,15 @@
1
+ /** Who is mounted, in order: the first is the one that answers a window-wide trigger, so two mounted dialogs never both open. */
2
+ export function owners() {
3
+ const mounted = [];
4
+ return {
5
+ claim(id) {
6
+ mounted.push(id);
7
+ return () => {
8
+ const at = mounted.indexOf(id);
9
+ if (at >= 0)
10
+ mounted.splice(at, 1);
11
+ };
12
+ },
13
+ owns: (id) => mounted[0] === id,
14
+ };
15
+ }
package/dist/lib/pay.d.ts CHANGED
@@ -54,6 +54,8 @@ export declare function payUrl(path: string, query: Record<string, string | null
54
54
  * resumes on it. Another maker's models are paid from this balance on any plan.
55
55
  */
56
56
  export declare function topUpUrl(model?: string): string;
57
+ /** A fixed top-up, in whole dollars: pay's confirm page for the card with the amount filled, as Settings' Billing opens it. */
58
+ export declare function topUpAmountUrl(dollars: number, returnUrl: string): string;
57
59
  /** Leaves for the top-up. */
58
60
  export declare function topUp(model?: string): void;
59
61
  export declare const dollars: (n: number) => string;
package/dist/lib/pay.js CHANGED
@@ -77,6 +77,10 @@ export function topUpUrl(model) {
77
77
  back.searchParams.set("model", model);
78
78
  return payUrl("/amount/card", { org: org(), returnUrl: back.toString() });
79
79
  }
80
+ /** A fixed top-up, in whole dollars: pay's confirm page for the card with the amount filled, as Settings' Billing opens it. */
81
+ export function topUpAmountUrl(dollars, returnUrl) {
82
+ return payUrl("/confirm/card", { amount: dollars.toFixed(2), org: org(), returnUrl });
83
+ }
80
84
  /** Leaves for the top-up. */
81
85
  export function topUp(model) {
82
86
  window.location.assign(topUpUrl(model));
@@ -36,6 +36,8 @@ export interface Card {
36
36
  dueAt?: number;
37
37
  createdAt: number;
38
38
  updatedAt: number;
39
+ /** Kept on this device only: the server did not take it. */
40
+ local?: boolean;
39
41
  }
40
42
  /**
41
43
  * THE COLUMNS, and they are the platform's own closed set rather than a list a
@@ -69,6 +71,10 @@ export declare function board(client?: AiClient | null, params?: {
69
71
  label?: string;
70
72
  scheduled?: boolean;
71
73
  }, signal?: AbortSignal): Promise<Card[]>;
74
+ /** The board a card goes to: its own, else the one on screen ("all" is not a board), else the first the store named. */
75
+ export declare function targetOf(own: string | undefined, shown: string, keys: string[]): string;
76
+ /** The first board the server names, or null when there is none: a card is only filed on a board that exists. */
77
+ export declare function home(client: AiClient, signal?: AbortSignal): Promise<string | null>;
72
78
  /** The boards themselves — a project is a repository on the forge. */
73
79
  export declare function projects(client?: AiClient | null, signal?: AbortSignal): Promise<{
74
80
  key: string;
package/dist/lib/todo.js CHANGED
@@ -169,6 +169,41 @@ export async function board(client, params = {}, signal) {
169
169
  return getLocalCards(params.key);
170
170
  }
171
171
  }
172
+ /** The board a card goes to: its own, else the one on screen ("all" is not a board), else the first the store named. */
173
+ export function targetOf(own, shown, keys) {
174
+ return own || (shown && shown !== 'all' ? shown : '') || keys[0] || '';
175
+ }
176
+ /** The boards the server names (todo's own, then the forge's projects), added to `map` when one is given; with a fresh map, no stand-ins. */
177
+ async function served(client, signal, map = new Map()) {
178
+ const [todoPs, devPs] = await Promise.all([
179
+ client.http
180
+ .json({
181
+ path: '/v1/todo/projects',
182
+ signal,
183
+ })
184
+ .catch(() => null),
185
+ client.http
186
+ .json({
187
+ path: '/v1/project',
188
+ signal,
189
+ })
190
+ .catch(() => null),
191
+ ]);
192
+ for (const p of rows(todoPs)) {
193
+ if (p?.key)
194
+ map.set(p.key, { key: p.key, name: p.name || p.key });
195
+ }
196
+ for (const p of Array.isArray(devPs) ? devPs : []) {
197
+ const k = (p.name || p.id).toLowerCase().replace(/[^a-z0-9]+/g, '-');
198
+ if (k && !map.has(k))
199
+ map.set(k, { key: k, name: p.name || k });
200
+ }
201
+ return Array.from(map.values());
202
+ }
203
+ /** The first board the server names, or null when there is none: a card is only filed on a board that exists. */
204
+ export async function home(client, signal) {
205
+ return (await served(client, signal))[0]?.key ?? null;
206
+ }
172
207
  /** The boards themselves — a project is a repository on the forge. */
173
208
  export async function projects(client, signal) {
174
209
  const fallback = [
@@ -180,34 +215,10 @@ export async function projects(client, signal) {
180
215
  if (!client)
181
216
  return fallback;
182
217
  try {
183
- const [todoPs, devPs] = await Promise.all([
184
- client.http
185
- .json({
186
- path: '/v1/todo/projects',
187
- signal,
188
- })
189
- .catch(() => null),
190
- client.http
191
- .json({
192
- path: '/v1/project',
193
- signal,
194
- })
195
- .catch(() => null),
196
- ]);
197
218
  const map = new Map();
198
219
  for (const f of fallback)
199
220
  map.set(f.key, f);
200
- const todoList = rows(todoPs);
201
- for (const p of todoList ?? []) {
202
- if (p?.key)
203
- map.set(p.key, { key: p.key, name: p.name || p.key });
204
- }
205
- for (const p of devPs ?? []) {
206
- const k = (p.name || p.id).toLowerCase().replace(/[^a-z0-9]+/g, '-');
207
- if (k && !map.has(k))
208
- map.set(k, { key: k, name: p.name || k });
209
- }
210
- return Array.from(map.values());
221
+ return await served(client, signal, map);
211
222
  }
212
223
  catch {
213
224
  return fallback;
@@ -231,6 +242,7 @@ export async function open(client, key, card, signal) {
231
242
  labels: card.labels ?? ['task'],
232
243
  createdAt: Date.now(),
233
244
  updatedAt: Date.now(),
245
+ local: true,
234
246
  };
235
247
  if (client) {
236
248
  try {
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/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;