@hanzo/app 0.2.43 → 0.2.44
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/Chat.js +4 -22
- package/dist/hint.d.ts +18 -0
- package/dist/hint.js +76 -0
- package/dist/lib/host.js +5 -0
- package/package.json +1 -1
package/dist/Chat.js
CHANGED
|
@@ -67,7 +67,7 @@ import { ConversationMenu, ThreadMore, useThreadList } from "./thread.js";
|
|
|
67
67
|
import { Schedule } from "./Schedule.js";
|
|
68
68
|
import { keepFile, useAttach, useKeep } from "./keep.js";
|
|
69
69
|
import { dragWindow, toggleWindowMaximize } from "./WindowControls.js";
|
|
70
|
-
import { artifacts, lead, nameOf, PAGE, Panel, PanelToggle, renders, Reply, Served, Summary, useDeck, useKey, Suggestions, useCarry, useLanguage, useMind, useSuggestions,
|
|
70
|
+
import { artifacts, lead, nameOf, PAGE, Panel, PanelToggle, renders, Reply, Served, Summary, useDeck, useKey, Suggestions, useCarry, useLanguage, useMind, useSuggestions, taken, CHAT_MODES, usePanel, frames, name as tabName, } from "@hanzo/build";
|
|
71
71
|
import { checkoutUrl, payUrl } from './lib/pay.js';
|
|
72
72
|
import { Upgrade, useFree } from './Upgrade.js';
|
|
73
73
|
import { enter, LOGIN } from './lib/destination.js';
|
|
@@ -76,6 +76,7 @@ import { BAD } from "./lib/mix.js";
|
|
|
76
76
|
import { brand } from './where.js';
|
|
77
77
|
import { BAND } from './ground.js';
|
|
78
78
|
import { shared, useChatPreferences } from './lib/chatPreferences.js';
|
|
79
|
+
import { handleHint } from './hint.js';
|
|
79
80
|
// NO REASONING PANEL HERE. Every assistant turn opened a "Thinking" disclosure
|
|
80
81
|
// listing seven steps — "Planning CSS extraction for chat styles", "Designing
|
|
81
82
|
// responsive top bar grid layout" — typed into this file as a literal array.
|
|
@@ -1352,27 +1353,8 @@ function Thread({ placeholder = message(), initial, anonymous = false, heading,
|
|
|
1352
1353
|
// What pressing a suggestion does, at once: open what it names, send its prompt
|
|
1353
1354
|
// here (the room is a new chat while one shows), hand its run to Dev, or make
|
|
1354
1355
|
// its scheduled task and show it in Scheduled tasks.
|
|
1355
|
-
const hint = (a) => {
|
|
1356
|
-
|
|
1357
|
-
case "open":
|
|
1358
|
-
if (a.item)
|
|
1359
|
-
want(a.item);
|
|
1360
|
-
if (/^https:\/\//.test(a.to))
|
|
1361
|
-
window.open(a.to, "_blank", "noopener,noreferrer");
|
|
1362
|
-
else
|
|
1363
|
-
go(a.to.startsWith("/") ? a.to : app(a.to));
|
|
1364
|
-
return;
|
|
1365
|
-
case "send":
|
|
1366
|
-
submit(a.prompt);
|
|
1367
|
-
return;
|
|
1368
|
-
case "task":
|
|
1369
|
-
hand("task", a.prompt);
|
|
1370
|
-
go(app(""));
|
|
1371
|
-
return;
|
|
1372
|
-
case "schedule":
|
|
1373
|
-
void book(target, a, "chat").then((made) => go(app(devPath({ kind: "automation", id: made.id }))), (e) => setPrepWrong(e instanceof Error && e.message ? e.message : t("The scheduled task could not be made.")));
|
|
1374
|
-
return;
|
|
1375
|
-
}
|
|
1356
|
+
const hint = (a, row) => {
|
|
1357
|
+
handleHint(a, row, { reopen, submit, target, setPrepWrong, t });
|
|
1376
1358
|
};
|
|
1377
1359
|
// A chat a suggestion in Dev left for this room is sent once the room is a new
|
|
1378
1360
|
// chat: the address's own conversation let go of, nothing said yet.
|
package/dist/hint.d.ts
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { Act, Hint } from '@hanzo/build';
|
|
2
|
+
export interface HintActions {
|
|
3
|
+
reopen: (threadId: string) => void;
|
|
4
|
+
submit: (query: string) => void;
|
|
5
|
+
target?: unknown;
|
|
6
|
+
setPrepWrong?: (err: string | null) => void;
|
|
7
|
+
t?: (s: string) => string;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Executes a suggestion action:
|
|
11
|
+
* - open: if it points to a chat thread (/chat/<id>), reopens that thread immediately and updates history;
|
|
12
|
+
* if external, opens in a new tab;
|
|
13
|
+
* if another app route, navigates via go;
|
|
14
|
+
* fallback: submits row title as query.
|
|
15
|
+
* - send / task: submits prompt or title directly into the chat room.
|
|
16
|
+
* - schedule: books automation or falls back to submitting the prompt.
|
|
17
|
+
*/
|
|
18
|
+
export declare function handleHint(a: Act, row: Hint | undefined, actions: HintActions): void;
|
package/dist/hint.js
ADDED
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { book, hand, want, path as devPath } from '@hanzo/build';
|
|
2
|
+
import { app, go } from './lib/host.js';
|
|
3
|
+
/**
|
|
4
|
+
* Executes a suggestion action:
|
|
5
|
+
* - open: if it points to a chat thread (/chat/<id>), reopens that thread immediately and updates history;
|
|
6
|
+
* if external, opens in a new tab;
|
|
7
|
+
* if another app route, navigates via go;
|
|
8
|
+
* fallback: submits row title as query.
|
|
9
|
+
* - send / task: submits prompt or title directly into the chat room.
|
|
10
|
+
* - schedule: books automation or falls back to submitting the prompt.
|
|
11
|
+
*/
|
|
12
|
+
export function handleHint(a, row, actions) {
|
|
13
|
+
const { reopen, submit, target, setPrepWrong, t = (s) => s } = actions;
|
|
14
|
+
switch (a.kind) {
|
|
15
|
+
case 'open': {
|
|
16
|
+
const chatMatch = a.to.match(/\/chat\/([^?#/]+)/);
|
|
17
|
+
if (chatMatch && chatMatch[1]) {
|
|
18
|
+
const threadId = decodeURIComponent(chatMatch[1]);
|
|
19
|
+
reopen(threadId);
|
|
20
|
+
go(a.to);
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
if (a.item)
|
|
24
|
+
want(a.item);
|
|
25
|
+
if (/^https:\/\//.test(a.to)) {
|
|
26
|
+
if (typeof window !== 'undefined')
|
|
27
|
+
window.open(a.to, '_blank', 'noopener,noreferrer');
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
if (a.to && a.to !== '/chat') {
|
|
31
|
+
go(a.to.startsWith('/') ? a.to : app(a.to));
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
const query = row?.title;
|
|
35
|
+
if (query) {
|
|
36
|
+
submit(query);
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
case 'send': {
|
|
42
|
+
const query = a.prompt || row?.title || '';
|
|
43
|
+
if (query)
|
|
44
|
+
submit(query);
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
case 'task': {
|
|
48
|
+
const query = a.prompt || row?.title || '';
|
|
49
|
+
if (query) {
|
|
50
|
+
submit(query);
|
|
51
|
+
}
|
|
52
|
+
else {
|
|
53
|
+
hand('task', '');
|
|
54
|
+
go(app(''));
|
|
55
|
+
}
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
case 'schedule': {
|
|
59
|
+
if (target) {
|
|
60
|
+
void book(target, a, 'chat').then((made) => go(app(devPath({ kind: 'automation', id: made.id }))), (e) => {
|
|
61
|
+
if (a.prompt)
|
|
62
|
+
submit(a.prompt);
|
|
63
|
+
else if (setPrepWrong)
|
|
64
|
+
setPrepWrong(e instanceof Error && e.message ? e.message : t('The scheduled task could not be made.'));
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
else if (a.prompt) {
|
|
68
|
+
submit(a.prompt);
|
|
69
|
+
}
|
|
70
|
+
return;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
if (row?.title) {
|
|
74
|
+
submit(row.title);
|
|
75
|
+
}
|
|
76
|
+
}
|
package/dist/lib/host.js
CHANGED
|
@@ -194,6 +194,11 @@ export function go(address, replace = false) {
|
|
|
194
194
|
window.history.replaceState(null, '', address);
|
|
195
195
|
else
|
|
196
196
|
window.history.pushState(null, '', address);
|
|
197
|
+
if (typeof window !== 'undefined' && typeof window.dispatchEvent === 'function') {
|
|
198
|
+
const ev = typeof PopStateEvent !== 'undefined' ? new PopStateEvent('popstate') : typeof Event !== 'undefined' ? new Event('popstate') : null;
|
|
199
|
+
if (ev)
|
|
200
|
+
window.dispatchEvent(ev);
|
|
201
|
+
}
|
|
197
202
|
}
|
|
198
203
|
/**
|
|
199
204
|
* Move to an address of this site: one of the app's (`place`) by `go`, which
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hanzo/app",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.44",
|
|
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",
|