@hanzo/app 0.3.80 → 0.3.82
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.
- package/dist/App.js +2 -2
- package/dist/Recents.d.ts +1 -0
- package/dist/Recents.js +37 -15
- package/dist/Sidebar.d.ts +3 -1
- package/dist/Sidebar.js +7 -3
- package/dist/recent.d.ts +18 -1
- package/dist/recent.js +45 -0
- package/package.json +1 -1
- package/dist/ProjectsTree.d.ts +0 -39
- package/dist/ProjectsTree.js +0 -179
package/dist/App.js
CHANGED
|
@@ -348,7 +348,7 @@ function Window({ bar, betas }) {
|
|
|
348
348
|
};
|
|
349
349
|
window.addEventListener('mousemove', onMove);
|
|
350
350
|
window.addEventListener('mouseup', onUp);
|
|
351
|
-
} })) : null] }), closed || alone ? null : (_jsx(YStack, { "$max-md": { display: 'none' }, children: _jsx(Sidebar, { host: host, mode: mode, thread: thread, go: move, onShut: () => setClosed(true), onSeek: seek, onBack: back, places: sidebar }) })), _jsxs(YStack, { "data-slot": "stage",
|
|
351
|
+
} })) : null] }), closed || alone ? null : (_jsx(YStack, { "$max-md": { display: 'none' }, children: _jsx(Sidebar, { host: host, mode: mode, thread: thread, go: move, onShut: () => setClosed(true), onSeek: seek, onBack: back, places: sidebar, made: maker }) })), _jsxs(YStack, { "data-slot": "stage",
|
|
352
352
|
// A column: the phone's bar, then the panes taking the rest. Not a grid of `auto` and
|
|
353
353
|
// `1fr` rows: from md the bar is display none, which leaves the grid, so the panes were
|
|
354
354
|
// placed in the `auto` row and stood their content's height, and Dev's pane, which
|
|
@@ -360,7 +360,7 @@ function Window({ bar, betas }) {
|
|
|
360
360
|
if (typeof window !== 'undefined') {
|
|
361
361
|
window.dispatchEvent(new CustomEvent('hanzo:anon-settings', { detail: { open: false } }));
|
|
362
362
|
}
|
|
363
|
-
} }) })) : mode === 'chat' ? (_jsx(Split, { framed: true, children: _jsx(Chat, {}) })) : mode === 'tabs' ? (_jsx(YStack, { render: "main", "data-slot": "pane", ...pane(), overflow: "hidden", flex: 1, minW: 0, minH: 0, children: _jsx(Suspense, { fallback: null, children: _jsx(Terminals, {}) }) })) : mode === 'design' ? (_jsx(YStack, { render: "main", "data-slot": "pane", ...pane(), overflow: "hidden", flex: 1, minW: 0, minH: 0, children: _jsx(YStack, { flex: 1, minH: 0, height: "100%", children: _jsx(Suspense, { fallback: null, children: _jsx(Studio, { host: maker, rail: false }) }) }) })) : mode === 'flow' ? (_jsx(YStack, { render: "main", "data-slot": "pane", ...pane(), overflow: "hidden", flex: 1, minW: 0, minH: 0, children: blockedBeta ? (_jsx(YStack, { "data-slot": "hosted-request", flex: 1, minH: 0, items: "center", justify: "center", p: "$6", children: _jsxs(YStack, { width: "100%", maxW: 440, gap: "$4", children: [_jsxs(XStack, { items: "center", gap: "$3", children: [_jsx(XStack, { width: 44, height: 44, rounded: "$4", bg: "$hover", items: "center", justify: "center", shrink: 0, children: _jsx(Workflow, { size: 22, "aria-hidden": true }) }), _jsxs(YStack, { gap: 2, minW: 0, children: [_jsxs(XStack, { items: "center", gap: "$2", children: [_jsx(Text, { fontSize: "$6", fontWeight: "600", color: "$ink", children: "Flow" }), _jsx(Text, { fontSize: "$1", color: "$quiet", px: "$2", py: 2, rounded: "$2", bg: "$hover", children: t('Beta') })] }), _jsx(Text, { fontSize: "$3", color: "$quiet", children: BETAS.find((b) => b.id === 'flow')?.line ?? 'Visual workflows and multi-agent pipelines.' })] })] }), _jsxs(XStack, { items: "center", gap: "$2", pt: "$1", children: [_jsx(Ask, { beta: BETAS.find((b) => b.id === 'flow'), go: move }), _jsx(Button, { variant: "ghost", size: "sm", onPress: () => move('/beta'), children: t('All betas') })] })] }) })) : (_jsx(YStack, { flex: 1, minH: 0, height: "100%", children: _jsx(Suspense, { fallback: null, children: _jsx(FlowStudio, { host: maker }) }) })) })) : mode === 'studio' ? (_jsx(YStack, { render: "main", "data-slot": "pane", ...pane(), overflow: "hidden", flex: 1, minW: 0, minH: 0, children: blockedBeta ? (_jsx(YStack, { "data-slot": "hosted-request", flex: 1, minH: 0, items: "center", justify: "center", p: "$6", children: _jsxs(YStack, { width: "100%", maxW: 440, gap: "$4", children: [_jsxs(XStack, { items: "center", gap: "$3", children: [_jsx(XStack, { width: 44, height: 44, rounded: "$4", bg: "$hover", items: "center", justify: "center", shrink: 0, children: _jsx(Clapperboard, { size: 22, "aria-hidden": true }) }), _jsxs(YStack, { gap: 2, minW: 0, children: [_jsxs(XStack, { items: "center", gap: "$2", children: [_jsx(Text, { fontSize: "$6", fontWeight: "600", color: "$ink", children: "Studio" }), _jsx(Text, { fontSize: "$1", color: "$quiet", px: "$2", py: 2, rounded: "$2", bg: "$hover", children: t('Beta') })] }), _jsx(Text, { fontSize: "$3", color: "$quiet", children: BETAS.find((b) => b.id === 'studio')?.line ?? 'Director Studio for AI film, video, and creative production.' })] })] }), _jsxs(XStack, { items: "center", gap: "$2", pt: "$1", children: [_jsx(Ask, { beta: BETAS.find((b) => b.id === 'studio'), go: move }), _jsx(Button, { variant: "ghost", size: "sm", onPress: () => move('/beta'), children: t('All betas') })] })] }) })) : (_jsx(YStack, { flex: 1, minH: 0, height: "100%", children: _jsx(Suspense, { fallback: null, children: _jsx(DirectorStudio, { host: maker }) }) })) })) : at.mode === 'hosted' ? (_jsx(YStack, { render: "main", "data-slot": "pane", ...pane(), overflow: "hidden", flex: 1, minW: 0, minH: 0, children: _jsx(Suspense, { fallback: null, children: _jsx(Hosted, { id: at.id, go: move }) }) })) : mode === 'beta' ? (_jsx(YStack, { render: "main", "data-slot": "pane", ...pane(), overflowY: "auto", overflowX: "hidden", flex: 1, minW: 0, minH: 0, p: "$4", $md: { p: '$6' }, children: betas ?? (_jsx(Suspense, { fallback: null, children: _jsx(Betas, { go: move }) })) })) : (_jsxs(YStack, { render: "main", "data-slot": "pane", ...(run ? null : { ...pane(), overflow: 'hidden' }), position: "relative", flex: 1, minW: 0, minH: 0, children: [!plans && !run && !inPlace && closed && free && host.person !== null ? (_jsx(XStack, { position: "absolute", t: 8, r: 12, z: 5, items: "center", "$max-md": { display: 'none' }, children: _jsxs(XStack, { render: "button", "data-slot": "header-upgrade", "aria-label": t('Upgrade plan'), items: "center", gap: "$1.5", px: "$2", py: "$1", rounded: "$3", bg: "transparent", cursor: "pointer", hoverStyle: { bg: '$hover' }, onPress: () => window.location.assign(payUrl('/cart', { org: currentOrg(), returnUrl: window.location.href })), children: [_jsx(Sparkles, { size: 14, color: "var(--muted-foreground)", "aria-hidden": true }), _jsx(Text, { fontSize: 15, lineHeight: 20, fontWeight: "500", color: "$soft", numberOfLines: 1, children: t('Upgrade plan') })] }) })) : null, plans ? null : _jsx(Builder, { host: host, rail: false })] })) })] })] }), drawer.state === 'shut' ? null : (_jsx(Layer, { drawer: drawer, top: bar ? BAR : 0, children: _jsxs(XStack, { flex: 1, minH: 0, children: [_jsx(YStack, { "data-slot": "drawer-rail", shrink: 0, pt: "calc(var(--pane-gap) + 8px)", $touchable: { pt: 'calc(var(--pane-gap) + 4px)' }, children: _jsx(Rail, { host: host, mode: mode, at: where, inside: inside, open: true, onChat: toChat, onDev: toDev, onDesign: toDesign, onStudio: toStudio, onTabs: toTabs, go: move, onOrg: org }) }), _jsx(YStack, { flex: 1, minW: 0, children: _jsx(Sidebar, { host: host, mode: mode, thread: thread, go: move, onShut: shut, onSeek: seek, onBack: back, drawer: true, places: sidebar }) })] }) })), finding ? _jsx(Search, { go: move, onClose: found, mode: mode, host: host }) : null, learning ? _jsx(Learning, { open: true, onClose: () => setLearning(false) }) : null, _jsx(AppContextMenu, { host: host, mode: mode, closed: closed, onToggleSidebar: flip, onSeek: seek, onNewChat: () => {
|
|
363
|
+
} }) })) : mode === 'chat' ? (_jsx(Split, { framed: true, children: _jsx(Chat, {}) })) : mode === 'tabs' ? (_jsx(YStack, { render: "main", "data-slot": "pane", ...pane(), overflow: "hidden", flex: 1, minW: 0, minH: 0, children: _jsx(Suspense, { fallback: null, children: _jsx(Terminals, {}) }) })) : mode === 'design' ? (_jsx(YStack, { render: "main", "data-slot": "pane", ...pane(), overflow: "hidden", flex: 1, minW: 0, minH: 0, children: _jsx(YStack, { flex: 1, minH: 0, height: "100%", children: _jsx(Suspense, { fallback: null, children: _jsx(Studio, { host: maker, rail: false }) }) }) })) : mode === 'flow' ? (_jsx(YStack, { render: "main", "data-slot": "pane", ...pane(), overflow: "hidden", flex: 1, minW: 0, minH: 0, children: blockedBeta ? (_jsx(YStack, { "data-slot": "hosted-request", flex: 1, minH: 0, items: "center", justify: "center", p: "$6", children: _jsxs(YStack, { width: "100%", maxW: 440, gap: "$4", children: [_jsxs(XStack, { items: "center", gap: "$3", children: [_jsx(XStack, { width: 44, height: 44, rounded: "$4", bg: "$hover", items: "center", justify: "center", shrink: 0, children: _jsx(Workflow, { size: 22, "aria-hidden": true }) }), _jsxs(YStack, { gap: 2, minW: 0, children: [_jsxs(XStack, { items: "center", gap: "$2", children: [_jsx(Text, { fontSize: "$6", fontWeight: "600", color: "$ink", children: "Flow" }), _jsx(Text, { fontSize: "$1", color: "$quiet", px: "$2", py: 2, rounded: "$2", bg: "$hover", children: t('Beta') })] }), _jsx(Text, { fontSize: "$3", color: "$quiet", children: BETAS.find((b) => b.id === 'flow')?.line ?? 'Visual workflows and multi-agent pipelines.' })] })] }), _jsxs(XStack, { items: "center", gap: "$2", pt: "$1", children: [_jsx(Ask, { beta: BETAS.find((b) => b.id === 'flow'), go: move }), _jsx(Button, { variant: "ghost", size: "sm", onPress: () => move('/beta'), children: t('All betas') })] })] }) })) : (_jsx(YStack, { flex: 1, minH: 0, height: "100%", children: _jsx(Suspense, { fallback: null, children: _jsx(FlowStudio, { host: maker }) }) })) })) : mode === 'studio' ? (_jsx(YStack, { render: "main", "data-slot": "pane", ...pane(), overflow: "hidden", flex: 1, minW: 0, minH: 0, children: blockedBeta ? (_jsx(YStack, { "data-slot": "hosted-request", flex: 1, minH: 0, items: "center", justify: "center", p: "$6", children: _jsxs(YStack, { width: "100%", maxW: 440, gap: "$4", children: [_jsxs(XStack, { items: "center", gap: "$3", children: [_jsx(XStack, { width: 44, height: 44, rounded: "$4", bg: "$hover", items: "center", justify: "center", shrink: 0, children: _jsx(Clapperboard, { size: 22, "aria-hidden": true }) }), _jsxs(YStack, { gap: 2, minW: 0, children: [_jsxs(XStack, { items: "center", gap: "$2", children: [_jsx(Text, { fontSize: "$6", fontWeight: "600", color: "$ink", children: "Studio" }), _jsx(Text, { fontSize: "$1", color: "$quiet", px: "$2", py: 2, rounded: "$2", bg: "$hover", children: t('Beta') })] }), _jsx(Text, { fontSize: "$3", color: "$quiet", children: BETAS.find((b) => b.id === 'studio')?.line ?? 'Director Studio for AI film, video, and creative production.' })] })] }), _jsxs(XStack, { items: "center", gap: "$2", pt: "$1", children: [_jsx(Ask, { beta: BETAS.find((b) => b.id === 'studio'), go: move }), _jsx(Button, { variant: "ghost", size: "sm", onPress: () => move('/beta'), children: t('All betas') })] })] }) })) : (_jsx(YStack, { flex: 1, minH: 0, height: "100%", children: _jsx(Suspense, { fallback: null, children: _jsx(DirectorStudio, { host: maker }) }) })) })) : at.mode === 'hosted' ? (_jsx(YStack, { render: "main", "data-slot": "pane", ...pane(), overflow: "hidden", flex: 1, minW: 0, minH: 0, children: _jsx(Suspense, { fallback: null, children: _jsx(Hosted, { id: at.id, go: move }) }) })) : mode === 'beta' ? (_jsx(YStack, { render: "main", "data-slot": "pane", ...pane(), overflowY: "auto", overflowX: "hidden", flex: 1, minW: 0, minH: 0, p: "$4", $md: { p: '$6' }, children: betas ?? (_jsx(Suspense, { fallback: null, children: _jsx(Betas, { go: move }) })) })) : (_jsxs(YStack, { render: "main", "data-slot": "pane", ...(run ? null : { ...pane(), overflow: 'hidden' }), position: "relative", flex: 1, minW: 0, minH: 0, children: [!plans && !run && !inPlace && closed && free && host.person !== null ? (_jsx(XStack, { position: "absolute", t: 8, r: 12, z: 5, items: "center", "$max-md": { display: 'none' }, children: _jsxs(XStack, { render: "button", "data-slot": "header-upgrade", "aria-label": t('Upgrade plan'), items: "center", gap: "$1.5", px: "$2", py: "$1", rounded: "$3", bg: "transparent", cursor: "pointer", hoverStyle: { bg: '$hover' }, onPress: () => window.location.assign(payUrl('/cart', { org: currentOrg(), returnUrl: window.location.href })), children: [_jsx(Sparkles, { size: 14, color: "var(--muted-foreground)", "aria-hidden": true }), _jsx(Text, { fontSize: 15, lineHeight: 20, fontWeight: "500", color: "$soft", numberOfLines: 1, children: t('Upgrade plan') })] }) })) : null, plans ? null : _jsx(Builder, { host: host, rail: false })] })) })] })] }), drawer.state === 'shut' ? null : (_jsx(Layer, { drawer: drawer, top: bar ? BAR : 0, children: _jsxs(XStack, { flex: 1, minH: 0, children: [_jsx(YStack, { "data-slot": "drawer-rail", shrink: 0, pt: "calc(var(--pane-gap) + 8px)", $touchable: { pt: 'calc(var(--pane-gap) + 4px)' }, children: _jsx(Rail, { host: host, mode: mode, at: where, inside: inside, open: true, onChat: toChat, onDev: toDev, onDesign: toDesign, onStudio: toStudio, onTabs: toTabs, go: move, onOrg: org }) }), _jsx(YStack, { flex: 1, minW: 0, children: _jsx(Sidebar, { host: host, mode: mode, thread: thread, go: move, onShut: shut, onSeek: seek, onBack: back, drawer: true, places: sidebar, made: maker }) })] }) })), finding ? _jsx(Search, { go: move, onClose: found, mode: mode, host: host }) : null, learning ? _jsx(Learning, { open: true, onClose: () => setLearning(false) }) : null, _jsx(AppContextMenu, { host: host, mode: mode, closed: closed, onToggleSidebar: flip, onSeek: seek, onNewChat: () => {
|
|
364
364
|
empty();
|
|
365
365
|
move(talk());
|
|
366
366
|
}, go: move })] }) }) }) }) }));
|
package/dist/Recents.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { type Host } from '@hanzo/build';
|
|
2
2
|
import { type Mode, type Recent } from './recent.js';
|
|
3
3
|
export declare function Recents({ host, mode, thread, onOpen, onNew, }: {
|
|
4
|
+
/** The mode's host: Design's is the one Studio is mounted with (App.tsx `maker`), whose path is Studio's. */
|
|
4
5
|
host: Host;
|
|
5
6
|
mode: Mode;
|
|
6
7
|
/** The Chat conversation the pane holds, or null. */
|
package/dist/Recents.js
CHANGED
|
@@ -2,7 +2,8 @@
|
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
3
|
// The reader's Recents in the column's mode, and only that mode's: Chat lists its
|
|
4
4
|
// conversations (`/v1/agents/chat/conversations`, `useThreadList`), Dev its
|
|
5
|
-
// coding runs (`/v1/agent/sessions?kind=coding`, @hanzo/build `useSessions`)
|
|
5
|
+
// coding runs (`/v1/agent/sessions?kind=coding`, @hanzo/build `useSessions`),
|
|
6
|
+
// Design what Studio keeps of its conversations (@hanzo/studio `useRecent`). Each
|
|
6
7
|
// mode reads its own store. The menu beside the heading narrows, groups and sorts
|
|
7
8
|
// the list; the choice is kept per mode in this browser. Chat's rows share one
|
|
8
9
|
// menu (thread.tsx `ConversationMenu`): pinned ones list first, under Pinned,
|
|
@@ -12,16 +13,22 @@ import { useEffect, useId, useMemo, useRef, useState } from 'react';
|
|
|
12
13
|
import { ScrollView, SizableText, XStack, YStack } from '@hanzo/gui';
|
|
13
14
|
import { CheckSquare, ChevronDown, ChevronRight, GitPullRequest, ListFilter } from 'lucide-react';
|
|
14
15
|
import { DOTS, route, useSessions } from '@hanzo/build';
|
|
16
|
+
import * as studio from '@hanzo/studio';
|
|
15
17
|
import { DropdownMenu } from '@hanzo/ui';
|
|
16
18
|
import { SidebarItem, StatusDot } from '@hanzo/ui/chat';
|
|
17
19
|
import { useKept } from './kept.js';
|
|
18
20
|
import { app } from './lib/host.js';
|
|
19
21
|
import { site } from './where.js';
|
|
20
|
-
import { ago, arrange, chats, MENUS, PINNED, PLAIN, runs, SINCE, UNFILED, UNTITLED, UNTITLED_RUN, viewOf } from './recent.js';
|
|
21
|
-
import { hasUnreadUpdate, ProjectsTree, useChatProjects } from './ProjectsTree.js';
|
|
22
|
+
import { ago, arrange, chats, designs, hasUnreadUpdate, MENUS, PINNED, PLAIN, runs, SINCE, UNFILED, UNTITLED, UNTITLED_RUN, viewOf } from './recent.js';
|
|
22
23
|
import { ConversationMenu, ThreadRow, useThreadList } from './thread.js';
|
|
23
|
-
/**
|
|
24
|
-
|
|
24
|
+
/**
|
|
25
|
+
* Studio's own read of Design's conversations (@hanzo/studio `useRecent`, from
|
|
26
|
+
* 0.1.11): this browser's store, shared with Studio's panes. An older Studio has
|
|
27
|
+
* none, and Design then lists nothing here, never Chat's.
|
|
28
|
+
*/
|
|
29
|
+
const useMade = studio.useRecent;
|
|
30
|
+
/** The menu's items: each section a heading and its options (recent.ts's phrases, drawn through `t`), the one in force checked; Select multiple where the rows carry a menu. */
|
|
31
|
+
function items(mode, view, set, t, select) {
|
|
25
32
|
const m = MENUS[mode];
|
|
26
33
|
const section = (key, label, options) => options.length
|
|
27
34
|
? [
|
|
@@ -37,6 +44,8 @@ function items(mode, view, set, t) {
|
|
|
37
44
|
: [];
|
|
38
45
|
const parts = [section('status', t('Status'), m.status), section('since', t('Last activity'), SINCE), section('group', t('Group by'), m.group), section('sort', t('Sort by'), m.sort)].filter((p) => p.length);
|
|
39
46
|
const base = parts.flatMap((p, i) => (i ? [{ type: 'separator', key: `sep-${i}` }, ...p] : p));
|
|
47
|
+
if (!select)
|
|
48
|
+
return base;
|
|
40
49
|
return [
|
|
41
50
|
...base,
|
|
42
51
|
{ type: 'separator', key: 'sep-select' },
|
|
@@ -54,14 +63,26 @@ const Note = ({ children }) => (_jsx(SizableText, { size: "$1", color: "$soft",
|
|
|
54
63
|
export function Recents({ host, mode, thread, onOpen, onNew, }) {
|
|
55
64
|
const [kept, keep] = useKept(`hanzo.recents.${mode}`, PLAIN);
|
|
56
65
|
const view = viewOf(mode, kept);
|
|
57
|
-
|
|
66
|
+
if (mode === 'chat')
|
|
67
|
+
return _jsx(Chats, { thread: thread, view: view, keep: keep, onOpen: onOpen, onNew: onNew });
|
|
68
|
+
if (mode === 'design')
|
|
69
|
+
return useMade ? _jsx(Designs, { host: host, view: view, keep: keep }) : _jsx(YStack, { flex: 1, minH: 0 });
|
|
70
|
+
return _jsx(Runs, { host: host, view: view, keep: keep, onOpen: onOpen });
|
|
71
|
+
}
|
|
72
|
+
/** Design's Recents: Studio's conversations, each opened in Design at its own address (@hanzo/studio `path`). */
|
|
73
|
+
function Designs({ host, view, keep }) {
|
|
74
|
+
const { rows: made, error } = useMade(host);
|
|
75
|
+
const rows = useMemo(() => designs(made), [made]);
|
|
76
|
+
const failed = useMemo(() => (error ? new Error(error) : null), [error]);
|
|
77
|
+
const at = studio.route(host.path);
|
|
78
|
+
const held = at.kind === 'chat' ? at.id : null;
|
|
79
|
+
return (_jsx(List, { mode: "design", rows: rows, view: view, keep: keep, open: (r) => r.id === held, reading: false, error: failed, onOpen: (r) => host.go(studio.path({ kind: 'chat', id: r.id })) }));
|
|
58
80
|
}
|
|
59
81
|
/** Chat's Recents: the conversation store alone, the archived ones when the view asks for them. */
|
|
60
82
|
function Chats({ thread, view, keep, onOpen, onNew, }) {
|
|
61
83
|
const store = useThreadList(view.status === 'archived', thread);
|
|
62
84
|
const rows = useMemo(() => chats(store.threads), [store.threads]);
|
|
63
85
|
const byId = useMemo(() => new Map(store.threads.map((t) => [t.id, t])), [store.threads]);
|
|
64
|
-
const projects = useChatProjects(rows);
|
|
65
86
|
const [seenAt, setSeenAt] = useKept('hanzo.chat.seen.v1', {});
|
|
66
87
|
const seenRef = useRef(seenAt);
|
|
67
88
|
seenRef.current = seenAt;
|
|
@@ -101,8 +122,7 @@ function Chats({ thread, view, keep, onOpen, onNew, }) {
|
|
|
101
122
|
}
|
|
102
123
|
return out;
|
|
103
124
|
}, [store.threads, thread, seenAt]);
|
|
104
|
-
|
|
105
|
-
return (_jsx(List, { mode: "chat", rows: unfiledRows, view: view, keep: keep, open: (r) => r.id === thread, reading: store.loading && !store.threads.length, error: store.error, onOpen: onOpen, threads: byId, held: thread, onNew: onNew, unreadIds: unreadIds, projectsNode: view.status === 'archived' ? null : (_jsx(ProjectsTree, { folders: projects.folders, openMap: projects.openMap, byFolder: projects.byFolder, threads: byId, activeId: thread, onToggle: projects.toggleFolder, onCreate: projects.createFolder, onOpen: onOpen, onNew: onNew })) }));
|
|
125
|
+
return (_jsx(List, { mode: "chat", rows: rows, view: view, keep: keep, open: (r) => r.id === thread, reading: store.loading && !store.threads.length, error: store.error, onOpen: onOpen, threads: byId, held: thread, onNew: onNew, unreadIds: unreadIds }));
|
|
106
126
|
}
|
|
107
127
|
/** Dev's Recents: the org's coding runs alone. */
|
|
108
128
|
function Runs({ host, view, keep, onOpen }) {
|
|
@@ -186,7 +206,7 @@ function Runs({ host, view, keep, onOpen }) {
|
|
|
186
206
|
}), [host]);
|
|
187
207
|
return (_jsx(List, { mode: "dev", rows: rows, view: view, keep: keep, open: (row) => row.id === run, reading: store.loading && !store.value.length, error: store.error, onOpen: onOpen, threads: byId, held: run, onNew: () => host.go(''), customActions: devActions, hrefOf: (id) => new URL(site(app(id)), window.location.href).href }));
|
|
188
208
|
}
|
|
189
|
-
function List({ mode, rows, view, keep, open, reading, error, onOpen, threads, held = null, onNew, customActions, hrefOf, unreadIds,
|
|
209
|
+
function List({ mode, rows, view, keep, open, reading, error, onOpen, threads, held = null, onNew, customActions, hrefOf, unreadIds, }) {
|
|
190
210
|
const { t } = useI18n();
|
|
191
211
|
const label = useId();
|
|
192
212
|
const [collapsedGroups, setCollapsedGroups] = useState({});
|
|
@@ -204,7 +224,9 @@ function List({ mode, rows, view, keep, open, reading, error, onOpen, threads, h
|
|
|
204
224
|
const isUnread = Boolean(r.kind === 'chat' && !open(r) && unreadIds?.has(r.id));
|
|
205
225
|
const age = ago(r.at, new Date(), t);
|
|
206
226
|
const when = age ? (_jsx(SizableText, { "data-slot": "row-age", fontSize: 12, lineHeight: 16, color: "var(--muted-foreground)", children: age })) : null;
|
|
207
|
-
|
|
227
|
+
// A Design conversation's dot is there while it works or when it failed; at rest it wears its age alone.
|
|
228
|
+
const settled = r.kind === 'design' && r.status === 'done';
|
|
229
|
+
const rowAside = r.kind === 'design' ? (_jsxs(XStack, { items: "center", gap: "$1.5", children: [when, settled ? null : _jsx(StatusDot, { status: DOTS[r.status] ?? 'idle' })] })) : r.kind === 'dev' ? (_jsxs(XStack, { items: "center", gap: "$1.5", children: [when, r.pr ? _jsx(GitPullRequest, { size: 13, color: "var(--state-success)", "aria-hidden": true }) : null, _jsx(StatusDot, { status: DOTS[r.status] ?? 'idle' })] })) : isUnread || when ? (_jsxs(XStack, { items: "center", gap: "$1.5", children: [when, isUnread ? (_jsx(XStack, { "data-slot": "thread-unread-dot", width: 6, height: 6, rounded: 999, bg: "var(--foreground)", "aria-hidden": true })) : null] })) : undefined;
|
|
208
230
|
const item = (_jsx(SidebarItem, { "data-kind": r.kind, active: open(r), rounded: 8, minH: 29, paddingInlineStart: "$2", paddingInlineEnd: one || rowAside ? 52 : '$2',
|
|
209
231
|
// A thumb's 44 on a touch screen; a conversation's ⋯ is a thumb wide there and always there: the title stops short of it.
|
|
210
232
|
$touchable: one ? { minH: 44, paddingInlineEnd: 52 } : { minH: 44 }, onKeyDown: (e) => {
|
|
@@ -218,15 +240,15 @@ function List({ mode, rows, view, keep, open, reading, error, onOpen, threads, h
|
|
|
218
240
|
return (_jsxs(YStack, { role: "listitem", position: "relative", children: [item, rowAside ? (_jsx(XStack, { position: "absolute", insetInlineEnd: "$2.5", t: 0, b: 0, items: "center", pointerEvents: "none", children: rowAside })) : null] }, r.id));
|
|
219
241
|
};
|
|
220
242
|
// The view menu stands at the end of the Recents heading: the target's own, quiet until the pointer is near.
|
|
221
|
-
const menu = (_jsx(DropdownMenu, { minWidth: 200, trigger: _jsx(XStack, { render: "button", "aria-label": t('Recents view'), width: 26, height: 26, rounded: "$2", items: "center", justify: "center", cursor: "pointer", opacity: narrowed ? 1 : 0, "$group-hover": { opacity: 1 }, focusStyle: { opacity: 1 }, $touchable: { opacity: 1 }, hoverStyle: { bg: '$hover' }, bg: narrowed ? '$hover' : 'transparent', children: _jsx(ListFilter, { size: 14, "aria-hidden": true }) }), items: items(mode, view, keep, t) }));
|
|
243
|
+
const menu = (_jsx(DropdownMenu, { minWidth: 200, trigger: _jsx(XStack, { render: "button", "aria-label": t('Recents view'), width: 26, height: 26, rounded: "$2", items: "center", justify: "center", cursor: "pointer", opacity: narrowed ? 1 : 0, "$group-hover": { opacity: 1 }, focusStyle: { opacity: 1 }, $touchable: { opacity: 1 }, hoverStyle: { bg: '$hover' }, bg: narrowed ? '$hover' : 'transparent', children: _jsx(ListFilter, { size: 14, "aria-hidden": true }) }), items: items(mode, view, keep, t, Boolean(threads)) }));
|
|
222
244
|
/** A section's heading: quiet 11.5px label, the Recents one carrying the count and the menu. */
|
|
223
|
-
const heading = (title, id, lead = false) => (_jsxs(XStack, { group: true, items: "center", justify: "space-between", height: 26, paddingInlineStart: "$2", paddingInlineEnd: "$1", mt: "$2.5", shrink: 0, children: [_jsxs(XStack, { items: "center", gap: "$2", children: [_jsx(SizableText, { id: id, fontSize: 11.5, lineHeight: 16, fontWeight: "500", color: "var(--muted-foreground)", children: title }), lead && running ? (_jsx(XStack, { "aria-label": t('{n} running', { n: running }), minW: 18, height: 18, px: "$1.5", rounded: 999, items: "center", justify: "center", bg: "$edge", borderWidth: 1, borderColor: "$borderColor", children: _jsx(SizableText, { size: "$1", fontWeight: "600", color: "$ink", "aria-hidden": true, "data-i18n-ltr": true, children: String(running) }) })) : null] }), _jsxs(XStack, { items: "center", gap: 2, children: [lead && rows.length > 0 ? (_jsx(XStack, { render: "button", "aria-label": t('Select multiple'), ...{ title: t('Select multiple') }, width: 26, height: 26, rounded: "$2", items: "center", justify: "center", cursor: "pointer", opacity: 0, "$group-hover": { opacity: 1 }, focusStyle: { opacity: 1 }, $touchable: { opacity: 1 }, hoverStyle: { bg: '$hover' }, onPress: () => {
|
|
245
|
+
const heading = (title, id, lead = false) => (_jsxs(XStack, { group: true, items: "center", justify: "space-between", height: 26, paddingInlineStart: "$2", paddingInlineEnd: "$1", mt: "$2.5", shrink: 0, children: [_jsxs(XStack, { items: "center", gap: "$2", children: [_jsx(SizableText, { id: id, fontSize: 11.5, lineHeight: 16, fontWeight: "500", color: "var(--muted-foreground)", children: title }), lead && running ? (_jsx(XStack, { "aria-label": t('{n} running', { n: running }), minW: 18, height: 18, px: "$1.5", rounded: 999, items: "center", justify: "center", bg: "$edge", borderWidth: 1, borderColor: "$borderColor", children: _jsx(SizableText, { size: "$1", fontWeight: "600", color: "$ink", "aria-hidden": true, "data-i18n-ltr": true, children: String(running) }) })) : null] }), _jsxs(XStack, { items: "center", gap: 2, children: [lead && threads && rows.length > 0 ? (_jsx(XStack, { render: "button", "aria-label": t('Select multiple'), ...{ title: t('Select multiple') }, width: 26, height: 26, rounded: "$2", items: "center", justify: "center", cursor: "pointer", opacity: 0, "$group-hover": { opacity: 1 }, focusStyle: { opacity: 1 }, $touchable: { opacity: 1 }, hoverStyle: { bg: '$hover' }, onPress: () => {
|
|
224
246
|
if (typeof window !== 'undefined')
|
|
225
247
|
window.dispatchEvent(new CustomEvent('hanzo:recents-select'));
|
|
226
248
|
}, children: _jsx(CheckSquare, { size: 13, "aria-hidden": true }) })) : null, lead ? menu : null] })] }));
|
|
227
249
|
const loose = groups.filter((g) => g.title !== PINNED);
|
|
228
250
|
const pinned = groups.find((g) => g.title === PINNED);
|
|
229
|
-
const note = reading ? (_jsx(Note, { children: t(mode === 'chat' ? 'Reading your chats…' : 'Reading your runs…') })) : error ? null : view.status === 'archived' ? (_jsx(Note, { children: t('No archived chats.') })) : narrowed ? (_jsx(Note, { children: t('Nothing in this view.') })) : (_jsx(Note, { children: t(mode === 'chat' ? 'No chats yet.' : 'No runs yet.') }));
|
|
251
|
+
const note = reading ? (_jsx(Note, { children: t(mode === 'chat' ? 'Reading your chats…' : 'Reading your runs…') })) : error ? null : view.status === 'archived' ? (_jsx(Note, { children: t('No archived chats.') })) : narrowed ? (_jsx(Note, { children: t('Nothing in this view.') })) : (_jsx(Note, { children: t(mode === 'chat' ? 'No chats yet.' : mode === 'design' ? 'Nothing made yet.' : 'No runs yet.') }));
|
|
230
252
|
// Each list of conversations holds its own menu (thread.tsx): the view menu
|
|
231
253
|
// in the Recents heading between them is a menu of its own, never inside one.
|
|
232
254
|
const menus = (rows, primary = true) => threads ? (_jsx(ConversationMenu, { threads: threads, active: held, onGone: onNew, customActions: customActions, hrefOf: hrefOf, primary: primary, children: _jsx(YStack, { children: rows }) })) : (rows);
|
|
@@ -241,5 +263,5 @@ function List({ mode, rows, view, keep, open, reading, error, onOpen, threads, h
|
|
|
241
263
|
: pinned
|
|
242
264
|
? null
|
|
243
265
|
: note;
|
|
244
|
-
return (_jsx(YStack, { "data-slot": "recents", flex: 1, minH: 0, children: _jsxs(ScrollView, { flex: 1, showsVerticalScrollIndicator: false, ...{ overscrollBehavior: 'contain' }, children: [error ? _jsx(Note, { children: error.message }) : null,
|
|
266
|
+
return (_jsx(YStack, { "data-slot": "recents", flex: 1, minH: 0, children: _jsxs(ScrollView, { flex: 1, showsVerticalScrollIndicator: false, ...{ overscrollBehavior: 'contain' }, children: [error ? _jsx(Note, { children: error.message }) : null, _jsxs(YStack, { role: "list", "aria-labelledby": label, gap: 1, children: [pinned ? (_jsxs(YStack, { role: "listitem", gap: 1, children: [heading(t(PINNED)), menus(_jsx(YStack, { role: "list", "aria-label": t(PINNED), gap: 1, children: pinned.rows.map(row) }), !loose.length)] })) : null, _jsxs(YStack, { role: "listitem", gap: 1, children: [heading(t('Recents'), label, true), menus(rest, true)] })] })] }) }));
|
|
245
267
|
}
|
package/dist/Sidebar.d.ts
CHANGED
|
@@ -7,7 +7,7 @@ export declare function dispatchTabsAction(detail: {
|
|
|
7
7
|
id?: string;
|
|
8
8
|
machine?: string;
|
|
9
9
|
}): void;
|
|
10
|
-
export declare function Sidebar({ host, mode, thread, go, onShut, onSeek, onBack, drawer, rail, foot, places, }: {
|
|
10
|
+
export declare function Sidebar({ host, mode, thread, go, onShut, onSeek, onBack, drawer, rail, foot, places, made, }: {
|
|
11
11
|
host: Host;
|
|
12
12
|
mode: Place['mode'];
|
|
13
13
|
/** The Chat conversation the pane holds, or null. */
|
|
@@ -32,6 +32,8 @@ export declare function Sidebar({ host, mode, thread, go, onShut, onSeek, onBack
|
|
|
32
32
|
label: string;
|
|
33
33
|
links: RailLink[];
|
|
34
34
|
}[];
|
|
35
|
+
/** The host Design is mounted with (App.tsx `maker`): where its conversations are read and opened. */
|
|
36
|
+
made?: Host;
|
|
35
37
|
}): import("react").JSX.Element;
|
|
36
38
|
export declare function AnonSettingsPane({ host, onClose, }: {
|
|
37
39
|
host: Host;
|
package/dist/Sidebar.js
CHANGED
|
@@ -2,7 +2,9 @@
|
|
|
2
2
|
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
3
|
// The app's sidebar, beside the rail on the window's floor (App.tsx): the
|
|
4
4
|
// mode's name with the bell and the search at its end, New, Dev's places in
|
|
5
|
-
// Dev, the reader's Recents (Pinned first), and
|
|
5
|
+
// Dev, the reader's Recents (Pinned first) for Chat, Dev and Design (Design's
|
|
6
|
+
// own, through the host Studio is mounted with; Studio and Flow keep none to
|
|
7
|
+
// list), and the first-run cards. Which
|
|
6
8
|
// product it lists is the rail's to say; the account is at the rail's foot, or
|
|
7
9
|
// on a phone at the foot of its menu (Drawer.tsx), where this column is the menu.
|
|
8
10
|
//
|
|
@@ -253,7 +255,7 @@ function Activity({ host }) {
|
|
|
253
255
|
];
|
|
254
256
|
return (_jsx(DropdownMenu, { minWidth: 280, trigger: _jsx(XStack, { render: "button", "aria-label": t('Activity'), ...{ title: t('Activity') }, ...HEAD, items: "center", justify: "center", cursor: "pointer", opacity: 0.7, hoverStyle: { bg: '$hover', opacity: 1 }, focusVisibleStyle: { outlineWidth: 2, outlineStyle: 'solid', outlineColor: '$outlineColor' }, children: _jsx(Bell, { size: 15, "aria-hidden": true }) }), items: items }));
|
|
255
257
|
}
|
|
256
|
-
export function Sidebar({ host, mode, thread, go, onShut, onSeek, onBack, drawer = false, rail, foot, places, }) {
|
|
258
|
+
export function Sidebar({ host, mode, thread, go, onShut, onSeek, onBack, drawer = false, rail, foot, places, made, }) {
|
|
257
259
|
const { t, dir } = useI18n();
|
|
258
260
|
const anon = host.person === null;
|
|
259
261
|
const free = useFree(Boolean(host.token?.())) || anon;
|
|
@@ -385,7 +387,9 @@ export function Sidebar({ host, mode, thread, go, onShut, onSeek, onBack, drawer
|
|
|
385
387
|
if (typeof window !== 'undefined') {
|
|
386
388
|
window.dispatchEvent(new CustomEvent('hanzo:anon-plugins'));
|
|
387
389
|
}
|
|
388
|
-
}), children: _jsx(Text, { fontSize: "$3", color: "$ink", children: t('Plugins') }) }) })] })) : null] })) : mode === 'beta' && !drawer ? null : (_jsx(YStack, { "data-slot": "app-places", shrink: 0, pt: drawer ? 0 : 4, children: groups.map((g, i) => (_jsxs(YStack, { pt: i ? '$2' : 0, children: [i && g.label ? (_jsx(Text, { id: `${uid}-${g.id}`, paddingInlineStart: "$2", pb: 2, fontSize: "$3", color: "$soft", children: g.label })) : null, _jsx(YStack, { role: "list", "aria-labelledby": i && g.label ? `${uid}-${g.id}` : undefined, "aria-label": i && g.label ? undefined : g.label || (at ? t(TITLE[at]) : g.id), gap: 1, children: g.links.map((link) => (_jsx(YStack, { role: "listitem", width: "100%", minW: 0, children: _jsx(SidebarItem, { ...COMPACT_ROW, "data-place-id": link.id, ...(link.id === NEW ? { 'data-slot': 'app-new' } : {}), active: link.active, icon: link.icon || link.id === NEW ? (_jsx(XStack, { width: 18, height: 18, items: "center", justify: "center", shrink: 0, children: link.icon ?? _jsx(Make, { size: 15, "aria-hidden": true }) })) : null, onPress: link.onPress, ...keys(() => link.onPress?.()), children: _jsx(Text, { fontSize: 14, lineHeight: 20, color: link.active ? '$ink' : '$quiet', numberOfLines: 1, children: link.label }) }) }, link.id))) })] }, g.id))) })), rail, mode === 'beta' && !drawer ? (_jsx(YStack, { "data-slot": "beta-sidebar-slot", flex: 1, minH: 0, pt: 4 })) : anon && mode === 'chat' && anonThreadTitle ? (_jsxs(YStack, { "data-slot": "recents", flex: 1, minH: 0, pt: "$3", children: [_jsx(Text, { paddingInlineStart: "$2", pb: "$1", fontSize: "$3", color: "$soft", children: t('Recents') }), _jsx(YStack, { role: "list", gap: 1, children: _jsx(YStack, { role: "listitem", children: _jsx(SidebarItem, { ...ROW, active: !anonSettingsOpen, onPress: () => setAnonSettings(false), children: _jsx(Text, { fontSize: "$3", color: "$ink", numberOfLines: 1, children: anonThreadTitle }) }) }) })] })) : mode === 'hosted' || mode === 'beta' || mode === 'tabs' ||
|
|
390
|
+
}), children: _jsx(Text, { fontSize: "$3", color: "$ink", children: t('Plugins') }) }) })] })) : null] })) : mode === 'beta' && !drawer ? null : (_jsx(YStack, { "data-slot": "app-places", shrink: 0, pt: drawer ? 0 : 4, children: groups.map((g, i) => (_jsxs(YStack, { pt: i ? '$2' : 0, children: [i && g.label ? (_jsx(Text, { id: `${uid}-${g.id}`, paddingInlineStart: "$2", pb: 2, fontSize: "$3", color: "$soft", children: g.label })) : null, _jsx(YStack, { role: "list", "aria-labelledby": i && g.label ? `${uid}-${g.id}` : undefined, "aria-label": i && g.label ? undefined : g.label || (at ? t(TITLE[at]) : g.id), gap: 1, children: g.links.map((link) => (_jsx(YStack, { role: "listitem", width: "100%", minW: 0, children: _jsx(SidebarItem, { ...COMPACT_ROW, "data-place-id": link.id, ...(link.id === NEW ? { 'data-slot': 'app-new' } : {}), active: link.active, icon: link.icon || link.id === NEW ? (_jsx(XStack, { width: 18, height: 18, items: "center", justify: "center", shrink: 0, children: link.icon ?? _jsx(Make, { size: 15, "aria-hidden": true }) })) : null, onPress: link.onPress, ...keys(() => link.onPress?.()), children: _jsx(Text, { fontSize: 14, lineHeight: 20, color: link.active ? '$ink' : '$quiet', numberOfLines: 1, children: link.label }) }) }, link.id))) })] }, g.id))) })), rail, mode === 'beta' && !drawer ? (_jsx(YStack, { "data-slot": "beta-sidebar-slot", flex: 1, minH: 0, pt: 4 })) : anon && mode === 'chat' && anonThreadTitle ? (_jsxs(YStack, { "data-slot": "recents", flex: 1, minH: 0, pt: "$3", children: [_jsx(Text, { paddingInlineStart: "$2", pb: "$1", fontSize: "$3", color: "$soft", children: t('Recents') }), _jsx(YStack, { role: "list", gap: 1, children: _jsx(YStack, { role: "listitem", children: _jsx(SidebarItem, { ...ROW, active: !anonSettingsOpen, onPress: () => setAnonSettings(false), children: _jsx(Text, { fontSize: "$3", color: "$ink", numberOfLines: 1, children: anonThreadTitle }) }) }) })] })) : mode === 'hosted' || mode === 'beta' || mode === 'tabs' || mode === 'studio' || mode === 'flow' || anon || at ? (_jsx(YStack, { flex: 1, minH: 0 })) : mode === 'design' ? (
|
|
391
|
+
// Design's own conversations, read and opened through the host Studio is mounted with.
|
|
392
|
+
made ? _jsx(Recents, { host: made, mode: "design", thread: null, onOpen: open, onNew: create }) : _jsx(YStack, { flex: 1, minH: 0 })) : (_jsx(Recents, { host: host, mode: mode === 'dev' ? 'dev' : 'chat', thread: thread, onOpen: open, onNew: create })), anon ? (_jsx(YStack, { "data-slot": "anon-foot", gap: "$2", pt: "$2", shrink: 0, z: 10, children: _jsxs(YStack, { "data-slot": "anon-tailored", gap: "$2", pt: "$1", pb: "$1", px: "$2", children: [_jsxs(XStack, { render: "button", "aria-expanded": tailoredOpen, "aria-label": t('Get responses tailored to you'), items: "center", justify: "space-between", gap: "$1.5", cursor: "pointer", onPress: () => setTailoredOpen((v) => !v), hoverStyle: { opacity: 0.85 }, children: [_jsx(Text, { fontSize: 13, lineHeight: 18, fontWeight: "700", color: "$ink", numberOfLines: 1, flex: 1, children: t('Get responses tailored to you') }), tailoredOpen ? (_jsx(ChevronDown, { size: 14, "aria-hidden": true, color: "var(--soft, var(--muted-foreground))" })) : (_jsx(ChevronUp, { size: 14, "aria-hidden": true, color: "var(--soft, var(--muted-foreground))" }))] }), tailoredOpen ? (_jsx(Text, { fontSize: 12, lineHeight: 17, color: "$soft", children: t('Log in to get answers based on saved chats, plus create images and upload files.') })) : null, _jsxs(XStack, { gap: "$2", pt: "$0.5", children: [_jsx(Button, { size: "sm", variant: "outline", flex: 1, rounded: 9999, "data-slot": "column-login", onPress: () => {
|
|
389
393
|
if (typeof window !== 'undefined')
|
|
390
394
|
window.location.assign('/login?next=%2Fchat');
|
|
391
395
|
}, children: t('Log in') }), _jsx(Button, { size: "sm", flex: 1, rounded: 9999, "data-slot": "column-signup", onPress: () => {
|
package/dist/recent.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type Say } from '@hanzo/i18n';
|
|
2
|
-
export type Mode = 'chat' | 'dev';
|
|
2
|
+
export type Mode = 'chat' | 'dev' | 'design';
|
|
3
3
|
export interface Recent {
|
|
4
4
|
kind: Mode;
|
|
5
5
|
id: string;
|
|
@@ -48,6 +48,23 @@ export declare function chats(threads: {
|
|
|
48
48
|
pinned?: boolean;
|
|
49
49
|
archived?: boolean;
|
|
50
50
|
}[]): Recent[];
|
|
51
|
+
/**
|
|
52
|
+
* Whether a conversation moved on since its reader last saw it (`seenAt`, its
|
|
53
|
+
* time per id): never the one the pane holds, nor one this browser has not
|
|
54
|
+
* seen yet.
|
|
55
|
+
*/
|
|
56
|
+
export declare function hasUnreadUpdate(rowId: string, updatedAt: string | number | undefined, activeId: string | null, seenAt: Record<string, number>): boolean;
|
|
57
|
+
/**
|
|
58
|
+
* Design's conversations as rows, as @hanzo/studio's `useRecent` lists them:
|
|
59
|
+
* one at work reads Running and one whose last turn failed Failed, as a run's
|
|
60
|
+
* would; `updated` is Unix milliseconds.
|
|
61
|
+
*/
|
|
62
|
+
export declare function designs(rows: {
|
|
63
|
+
id: string;
|
|
64
|
+
title?: string;
|
|
65
|
+
updated?: number;
|
|
66
|
+
state?: string;
|
|
67
|
+
}[]): Recent[];
|
|
51
68
|
/** Dev's runs as rows. */
|
|
52
69
|
export declare function runs(sessions: {
|
|
53
70
|
id: string;
|
package/dist/recent.js
CHANGED
|
@@ -49,6 +49,18 @@ export const MENUS = {
|
|
|
49
49
|
{ id: 'title', label: phrase('Title') },
|
|
50
50
|
],
|
|
51
51
|
},
|
|
52
|
+
// Design's conversations (@hanzo/studio): no archive, and a state that is the last turn's, so no Status to narrow by.
|
|
53
|
+
design: {
|
|
54
|
+
status: [],
|
|
55
|
+
group: [
|
|
56
|
+
{ id: 'date', label: phrase('Date') },
|
|
57
|
+
{ id: 'none', label: phrase('None') },
|
|
58
|
+
],
|
|
59
|
+
sort: [
|
|
60
|
+
{ id: 'activity', label: phrase('Activity') },
|
|
61
|
+
{ id: 'title', label: phrase('Title') },
|
|
62
|
+
],
|
|
63
|
+
},
|
|
52
64
|
};
|
|
53
65
|
/** A kept view as this mode may hold it: anything a menu does not offer reads as the plain view's. */
|
|
54
66
|
export function viewOf(mode, kept) {
|
|
@@ -74,6 +86,39 @@ export function chats(threads) {
|
|
|
74
86
|
...(t.pinned ? { pinned: true } : {}),
|
|
75
87
|
}));
|
|
76
88
|
}
|
|
89
|
+
/**
|
|
90
|
+
* Whether a conversation moved on since its reader last saw it (`seenAt`, its
|
|
91
|
+
* time per id): never the one the pane holds, nor one this browser has not
|
|
92
|
+
* seen yet.
|
|
93
|
+
*/
|
|
94
|
+
export function hasUnreadUpdate(rowId, updatedAt, activeId, seenAt) {
|
|
95
|
+
if (!updatedAt || rowId === activeId)
|
|
96
|
+
return false;
|
|
97
|
+
const stamp = typeof updatedAt === 'number' ? updatedAt : Date.parse(updatedAt);
|
|
98
|
+
if (!Number.isFinite(stamp) || stamp <= 0)
|
|
99
|
+
return false;
|
|
100
|
+
const seen = seenAt[rowId];
|
|
101
|
+
return typeof seen === 'number' && stamp > seen;
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Design's conversations as rows, as @hanzo/studio's `useRecent` lists them:
|
|
105
|
+
* one at work reads Running and one whose last turn failed Failed, as a run's
|
|
106
|
+
* would; `updated` is Unix milliseconds.
|
|
107
|
+
*/
|
|
108
|
+
export function designs(rows) {
|
|
109
|
+
return rows.map((r) => {
|
|
110
|
+
const when = new Date(typeof r.updated === 'number' ? r.updated : Number.NaN);
|
|
111
|
+
const at = Number.isNaN(when.getTime()) ? '' : when.toISOString();
|
|
112
|
+
return {
|
|
113
|
+
kind: 'design',
|
|
114
|
+
id: r.id,
|
|
115
|
+
title: r.title || UNTITLED,
|
|
116
|
+
at,
|
|
117
|
+
began: at,
|
|
118
|
+
status: r.state === 'making' ? 'running' : r.state === 'failed' ? 'error' : 'done',
|
|
119
|
+
};
|
|
120
|
+
});
|
|
121
|
+
}
|
|
77
122
|
/** Dev's runs as rows. */
|
|
78
123
|
export function runs(sessions) {
|
|
79
124
|
return sessions.map((r) => ({
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hanzo/app",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.82",
|
|
4
4
|
"description": "Hanzo's app: the shell and its apps (Home, Chat, Inbox, Contacts, Meet, Calendar, Drive, Board, Work, Bots), once, for every Hanzo surface.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
package/dist/ProjectsTree.d.ts
DELETED
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import type { Thread } from '@hanzo/ai';
|
|
2
|
-
import { type Recent } from './recent.js';
|
|
3
|
-
export interface ProjectFolder {
|
|
4
|
-
id: string;
|
|
5
|
-
name: string;
|
|
6
|
-
}
|
|
7
|
-
export interface StoredChatProjects {
|
|
8
|
-
folders: ProjectFolder[];
|
|
9
|
-
open: Record<string, boolean>;
|
|
10
|
-
assigned: Record<string, string>;
|
|
11
|
-
}
|
|
12
|
-
export declare const EMPTY_CHAT_PROJECTS: StoredChatProjects;
|
|
13
|
-
export declare function normalizeProjectSlug(raw: string): string;
|
|
14
|
-
export declare function readStoredChatProjects(raw: unknown): StoredChatProjects;
|
|
15
|
-
export declare function mergeProjectFolders(remote: ProjectFolder[], local: ProjectFolder[]): ProjectFolder[];
|
|
16
|
-
export declare function groupThreadsByProject(rows: Recent[], folders: ProjectFolder[], assigned: Record<string, string>): {
|
|
17
|
-
byFolder: Map<string, Recent[]>;
|
|
18
|
-
filedIds: Set<string>;
|
|
19
|
-
};
|
|
20
|
-
export declare function hasUnreadUpdate(rowId: string, updatedAt: string | number | undefined, activeId: string | null, seenAt: Record<string, number>): boolean;
|
|
21
|
-
export declare function useChatProjects(rows: Recent[]): {
|
|
22
|
-
folders: ProjectFolder[];
|
|
23
|
-
openMap: Record<string, boolean>;
|
|
24
|
-
byFolder: Map<string, Recent[]>;
|
|
25
|
-
filedIds: Set<string>;
|
|
26
|
-
toggleFolder: (id: string) => void;
|
|
27
|
-
createFolder: (name: string) => void;
|
|
28
|
-
};
|
|
29
|
-
export declare function ProjectsTree({ folders, openMap, byFolder, threads, activeId, onToggle, onCreate, onOpen, onNew, }: {
|
|
30
|
-
folders: ProjectFolder[];
|
|
31
|
-
openMap: Record<string, boolean>;
|
|
32
|
-
byFolder: Map<string, Recent[]>;
|
|
33
|
-
threads: Map<string, Thread>;
|
|
34
|
-
activeId: string | null;
|
|
35
|
-
onToggle: (id: string) => void;
|
|
36
|
-
onCreate: (name: string) => void;
|
|
37
|
-
onOpen: (row: Recent) => void;
|
|
38
|
-
onNew: () => void;
|
|
39
|
-
}): import("react").JSX.Element;
|
package/dist/ProjectsTree.js
DELETED
|
@@ -1,179 +0,0 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
-
import { useEffect, useMemo, useState } from 'react';
|
|
4
|
-
import { useI18n } from '@hanzo/i18n/react';
|
|
5
|
-
import { SizableText, XStack, YStack } from '@hanzo/gui';
|
|
6
|
-
import { Folder, FolderOpen, Plus } from 'lucide-react';
|
|
7
|
-
import { Button, Dialog, DialogContent, DialogTitle, Input } from '@hanzo/ui';
|
|
8
|
-
import { SidebarItem } from '@hanzo/ui/chat';
|
|
9
|
-
import { useKept } from './kept.js';
|
|
10
|
-
import { api } from './lib/api.js';
|
|
11
|
-
import { list } from './lib/list.js';
|
|
12
|
-
import { scope } from './lib/session.js';
|
|
13
|
-
import { UNTITLED } from './recent.js';
|
|
14
|
-
import { ConversationMenu, ThreadRow } from './thread.js';
|
|
15
|
-
export const EMPTY_CHAT_PROJECTS = {
|
|
16
|
-
folders: [],
|
|
17
|
-
open: {},
|
|
18
|
-
assigned: {},
|
|
19
|
-
};
|
|
20
|
-
export function normalizeProjectSlug(raw) {
|
|
21
|
-
return raw
|
|
22
|
-
.trim()
|
|
23
|
-
.toLowerCase()
|
|
24
|
-
.replace(/^[^/]+\//, '')
|
|
25
|
-
.replace(/[^a-z0-9._-]+/g, '-')
|
|
26
|
-
.replace(/^-+|-+$/g, '');
|
|
27
|
-
}
|
|
28
|
-
export function readStoredChatProjects(raw) {
|
|
29
|
-
if (!raw || typeof raw !== 'object')
|
|
30
|
-
return EMPTY_CHAT_PROJECTS;
|
|
31
|
-
const obj = raw;
|
|
32
|
-
const folders = Array.isArray(obj.folders)
|
|
33
|
-
? obj.folders.filter((f) => Boolean(f && typeof f === 'object' && typeof f.id === 'string' && f.id && typeof f.name === 'string' && f.name.trim()))
|
|
34
|
-
: [];
|
|
35
|
-
const open = obj.open && typeof obj.open === 'object' ? obj.open : {};
|
|
36
|
-
const assigned = obj.assigned && typeof obj.assigned === 'object' ? obj.assigned : {};
|
|
37
|
-
return { folders, open, assigned };
|
|
38
|
-
}
|
|
39
|
-
export function mergeProjectFolders(remote, local) {
|
|
40
|
-
const seen = new Set();
|
|
41
|
-
const out = [];
|
|
42
|
-
for (const item of [...local, ...remote]) {
|
|
43
|
-
const key = normalizeProjectSlug(item.id || item.name);
|
|
44
|
-
if (!key || seen.has(key))
|
|
45
|
-
continue;
|
|
46
|
-
seen.add(key);
|
|
47
|
-
out.push({ id: key, name: item.name.trim() });
|
|
48
|
-
}
|
|
49
|
-
return out;
|
|
50
|
-
}
|
|
51
|
-
export function groupThreadsByProject(rows, folders, assigned) {
|
|
52
|
-
const byFolder = new Map();
|
|
53
|
-
const byKey = new Map();
|
|
54
|
-
for (const folder of folders) {
|
|
55
|
-
byFolder.set(folder.id, []);
|
|
56
|
-
byKey.set(normalizeProjectSlug(folder.id), folder.id);
|
|
57
|
-
byKey.set(normalizeProjectSlug(folder.name), folder.id);
|
|
58
|
-
}
|
|
59
|
-
const filedIds = new Set();
|
|
60
|
-
for (const row of rows) {
|
|
61
|
-
const explicit = assigned[row.id] ? normalizeProjectSlug(assigned[row.id]) : '';
|
|
62
|
-
const implicit = row.project ? normalizeProjectSlug(row.project) : '';
|
|
63
|
-
const target = (explicit && byKey.get(explicit)) || (implicit && byKey.get(implicit)) || null;
|
|
64
|
-
if (!target)
|
|
65
|
-
continue;
|
|
66
|
-
byFolder.get(target)?.push(row);
|
|
67
|
-
filedIds.add(row.id);
|
|
68
|
-
}
|
|
69
|
-
return { byFolder, filedIds };
|
|
70
|
-
}
|
|
71
|
-
export function hasUnreadUpdate(rowId, updatedAt, activeId, seenAt) {
|
|
72
|
-
if (!updatedAt || rowId === activeId)
|
|
73
|
-
return false;
|
|
74
|
-
const stamp = typeof updatedAt === 'number' ? updatedAt : Date.parse(updatedAt);
|
|
75
|
-
if (!Number.isFinite(stamp) || stamp <= 0)
|
|
76
|
-
return false;
|
|
77
|
-
const seen = seenAt[rowId];
|
|
78
|
-
return typeof seen === 'number' && stamp > seen;
|
|
79
|
-
}
|
|
80
|
-
function useRemoteProjectFolders() {
|
|
81
|
-
const [remote, setRemote] = useState([]);
|
|
82
|
-
useEffect(() => {
|
|
83
|
-
const stop = new AbortController();
|
|
84
|
-
const headers = scope();
|
|
85
|
-
Promise.all([
|
|
86
|
-
fetch(`${api()}/v1/git/repos`, { headers, signal: stop.signal })
|
|
87
|
-
.then((r) => (r.ok ? r.json() : null))
|
|
88
|
-
.catch(() => null),
|
|
89
|
-
fetch(`${api()}/v1/project`, { headers, signal: stop.signal })
|
|
90
|
-
.then((r) => (r.ok ? r.json() : null))
|
|
91
|
-
.catch(() => null),
|
|
92
|
-
]).then(([reposBody, projectsBody]) => {
|
|
93
|
-
if (stop.signal.aborted)
|
|
94
|
-
return;
|
|
95
|
-
const repoRows = list(Array.isArray(reposBody) ? reposBody : reposBody?.data ?? reposBody?.repos);
|
|
96
|
-
const projRows = list(Array.isArray(projectsBody) ? projectsBody : projectsBody?.data ?? projectsBody?.projects);
|
|
97
|
-
const collected = [];
|
|
98
|
-
for (const r of [...repoRows, ...projRows]) {
|
|
99
|
-
const name = (r?.name || r?.slug || '').trim();
|
|
100
|
-
const id = normalizeProjectSlug(r?.slug || name);
|
|
101
|
-
if (id && name)
|
|
102
|
-
collected.push({ id, name });
|
|
103
|
-
}
|
|
104
|
-
setRemote(collected);
|
|
105
|
-
});
|
|
106
|
-
return () => stop.abort();
|
|
107
|
-
}, []);
|
|
108
|
-
return remote;
|
|
109
|
-
}
|
|
110
|
-
export function useChatProjects(rows) {
|
|
111
|
-
const [raw, save] = useKept('hanzo.chat.projects.v1', EMPTY_CHAT_PROJECTS);
|
|
112
|
-
const stored = useMemo(() => readStoredChatProjects(raw), [raw]);
|
|
113
|
-
const remote = useRemoteProjectFolders();
|
|
114
|
-
const folders = useMemo(() => mergeProjectFolders(remote, stored.folders), [remote, stored.folders]);
|
|
115
|
-
const grouped = useMemo(() => groupThreadsByProject(rows, folders, stored.assigned), [rows, folders, stored.assigned]);
|
|
116
|
-
const toggleFolder = (id) => {
|
|
117
|
-
save({
|
|
118
|
-
...stored,
|
|
119
|
-
open: { ...stored.open, [id]: !stored.open[id] },
|
|
120
|
-
});
|
|
121
|
-
};
|
|
122
|
-
const createFolder = (name) => {
|
|
123
|
-
const trimmed = name.trim();
|
|
124
|
-
const id = normalizeProjectSlug(trimmed);
|
|
125
|
-
if (!id || !trimmed)
|
|
126
|
-
return;
|
|
127
|
-
const exists = stored.folders.some((f) => normalizeProjectSlug(f.id) === id);
|
|
128
|
-
save({
|
|
129
|
-
...stored,
|
|
130
|
-
folders: exists ? stored.folders : [...stored.folders, { id, name: trimmed }],
|
|
131
|
-
open: { ...stored.open, [id]: true },
|
|
132
|
-
});
|
|
133
|
-
};
|
|
134
|
-
return {
|
|
135
|
-
folders,
|
|
136
|
-
openMap: stored.open,
|
|
137
|
-
byFolder: grouped.byFolder,
|
|
138
|
-
filedIds: grouped.filedIds,
|
|
139
|
-
toggleFolder,
|
|
140
|
-
createFolder,
|
|
141
|
-
};
|
|
142
|
-
}
|
|
143
|
-
export function ProjectsTree({ folders, openMap, byFolder, threads, activeId, onToggle, onCreate, onOpen, onNew, }) {
|
|
144
|
-
const { t } = useI18n();
|
|
145
|
-
const [creating, setCreating] = useState(false);
|
|
146
|
-
const [draft, setDraft] = useState('');
|
|
147
|
-
const submit = () => {
|
|
148
|
-
const next = draft.trim();
|
|
149
|
-
if (!next)
|
|
150
|
-
return;
|
|
151
|
-
onCreate(next);
|
|
152
|
-
setDraft('');
|
|
153
|
-
setCreating(false);
|
|
154
|
-
};
|
|
155
|
-
return (_jsxs(YStack, { "data-slot": "chat-projects", gap: 1, pt: "$2", children: [_jsxs(XStack, { group: true, items: "center", justify: "space-between", height: 26, paddingInlineStart: "$2", paddingInlineEnd: "$1", shrink: 0, children: [_jsx(SizableText, { fontSize: 11.5, lineHeight: 16, fontWeight: "500", color: "var(--muted-foreground)", children: t('Projects') }), _jsx(XStack, { render: "button", "data-slot": "chat-project-add", "aria-label": t('New project'), ...{ title: t('New project') }, width: 22, height: 22, rounded: "$2", items: "center", justify: "center", cursor: "pointer", opacity: folders.length === 0 ? 0.72 : 0, "$group-hover": { opacity: 1 }, focusStyle: { opacity: 1 }, $touchable: { opacity: 1 }, hoverStyle: { bg: '$hover', opacity: 1 }, onPress: () => setCreating(true), children: _jsx(Plus, { size: 13, color: "var(--muted-foreground)", "aria-hidden": true }) })] }), folders.length > 0 ? (_jsx(ConversationMenu, { threads: threads, active: activeId, onGone: onNew, primary: false, children: _jsx(YStack, { role: "list", "aria-label": t('Projects'), gap: 1, children: folders.map((folder) => {
|
|
156
|
-
const expanded = Boolean(openMap[folder.id]);
|
|
157
|
-
const children = byFolder.get(folder.id) ?? [];
|
|
158
|
-
return (_jsxs(YStack, { role: "listitem", gap: 1, children: [_jsx(SidebarItem, { "data-slot": "project-folder", "data-project-id": folder.id, "aria-expanded": expanded, rounded: 8, minH: 28, py: 0, px: "$2", $touchable: { minH: 40 }, icon: _jsx(XStack, { width: 18, height: 18, items: "center", justify: "center", shrink: 0, children: expanded ? (_jsx(FolderOpen, { size: 15, strokeWidth: 1.75, color: "var(--muted-foreground)", "aria-hidden": true })) : (_jsx(Folder, { size: 15, strokeWidth: 1.75, color: "var(--muted-foreground)", "aria-hidden": true })) }), onPress: () => onToggle(folder.id), onKeyDown: (e) => {
|
|
159
|
-
if (e.key !== 'Enter' && e.key !== ' ')
|
|
160
|
-
return;
|
|
161
|
-
e.preventDefault?.();
|
|
162
|
-
onToggle(folder.id);
|
|
163
|
-
}, children: _jsx(SizableText, { fontSize: 13, lineHeight: 18, color: "var(--foreground)", numberOfLines: 1, display: "block", children: folder.name }) }), expanded ? (children.length > 0 ? (_jsx(YStack, { role: "list", "aria-label": folder.name, gap: 1, children: children.map((child) => {
|
|
164
|
-
const threadObj = threads.get(child.id);
|
|
165
|
-
const isOpen = child.id === activeId;
|
|
166
|
-
const labelText = child.title === UNTITLED ? t(UNTITLED) : child.title;
|
|
167
|
-
const item = (_jsx(SidebarItem, { "data-slot": "project-thread", active: isOpen, rounded: 8, minH: 27, py: 0, paddingInlineStart: 28, paddingInlineEnd: "$6", $touchable: { minH: 40, paddingInlineEnd: 48 }, onPress: () => onOpen(child), onKeyDown: (e) => {
|
|
168
|
-
if (e.key !== 'Enter' && e.key !== ' ')
|
|
169
|
-
return;
|
|
170
|
-
e.preventDefault?.();
|
|
171
|
-
onOpen(child);
|
|
172
|
-
}, children: _jsx(SizableText, { fontSize: 13, lineHeight: 18, color: isOpen ? 'var(--text-primary)' : 'var(--text-secondary)', numberOfLines: 1, display: "block", children: labelText }) }));
|
|
173
|
-
return threadObj ? (_jsx(ThreadRow, { t: threadObj, active: isOpen, children: item }, child.id)) : (_jsx(YStack, { role: "listitem", children: item }, child.id));
|
|
174
|
-
}) })) : (_jsx(XStack, { height: 25, items: "center", paddingInlineStart: 28, paddingInlineEnd: "$2", "data-slot": "project-empty", children: _jsx(SizableText, { fontSize: 12.5, lineHeight: 17, color: "var(--text-tertiary)", numberOfLines: 1, children: t('No chats') }) }))) : null] }, folder.id));
|
|
175
|
-
}) }) })) : null, _jsx(Dialog, { open: creating, onOpenChange: setCreating, children: _jsxs(DialogContent, { maxW: 400, rounded: "$6", gap: "$3", children: [_jsx(DialogTitle, { children: t('New project') }), _jsx(Input, { autoFocus: true, value: draft, onChangeText: setDraft, placeholder: t('Project name'), "aria-label": t('Project name'), maxLength: 64, onKeyDown: (e) => {
|
|
176
|
-
if (e.key === 'Enter' && !e.nativeEvent?.isComposing && e.keyCode !== 229)
|
|
177
|
-
submit();
|
|
178
|
-
} }), _jsxs(XStack, { gap: "$2", justify: "flex-end", children: [_jsx(Button, { size: "sm", variant: "outline", rounded: 999, onPress: () => setCreating(false), children: t('Cancel') }), _jsx(Button, { size: "sm", rounded: 999, disabled: !draft.trim(), onPress: submit, children: t('Create') })] })] }) })] }));
|
|
179
|
-
}
|