@djangocfg/ui-tools 2.1.341 → 2.1.344
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/ChatRoot-CIOFUESH.cjs +14 -0
- package/dist/{ChatRoot-BT3CLXI4.cjs.map → ChatRoot-CIOFUESH.cjs.map} +1 -1
- package/dist/ChatRoot-OURQVRLD.mjs +5 -0
- package/dist/{ChatRoot-R5YQTOLP.mjs.map → ChatRoot-OURQVRLD.mjs.map} +1 -1
- package/dist/{chunk-5T4K3VUV.cjs → chunk-AK2VHUJV.cjs} +35 -10
- package/dist/chunk-AK2VHUJV.cjs.map +1 -0
- package/dist/{chunk-QE25H6DP.mjs → chunk-D7ISTFUS.mjs} +35 -10
- package/dist/chunk-D7ISTFUS.mjs.map +1 -0
- package/dist/index.cjs +46 -46
- package/dist/index.d.cts +5 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.mjs +3 -3
- package/package.json +6 -6
- package/src/tools/Chat/Chat.story.tsx +74 -1
- package/src/tools/Chat/README.md +24 -2
- package/src/tools/Chat/components/ChatRoot.tsx +13 -9
- package/src/tools/Chat/core/reducer.ts +17 -2
- package/src/tools/Chat/hooks/useChat.ts +25 -7
- package/src/tools/Chat/types.ts +1 -0
- package/dist/ChatRoot-BT3CLXI4.cjs +0 -14
- package/dist/ChatRoot-R5YQTOLP.mjs +0 -5
- package/dist/chunk-5T4K3VUV.cjs.map +0 -1
- package/dist/chunk-QE25H6DP.mjs.map +0 -1
package/dist/index.cjs
CHANGED
|
@@ -7,7 +7,7 @@ var chunkKNDLV4PI_cjs = require('./chunk-KNDLV4PI.cjs');
|
|
|
7
7
|
var chunk5I5QNGUG_cjs = require('./chunk-5I5QNGUG.cjs');
|
|
8
8
|
var chunkYW5IVWHQ_cjs = require('./chunk-YW5IVWHQ.cjs');
|
|
9
9
|
var chunk76NNDZH6_cjs = require('./chunk-76NNDZH6.cjs');
|
|
10
|
-
var
|
|
10
|
+
var chunkAK2VHUJV_cjs = require('./chunk-AK2VHUJV.cjs');
|
|
11
11
|
var chunkYXZ6GU7H_cjs = require('./chunk-YXZ6GU7H.cjs');
|
|
12
12
|
var chunkIEEAENLX_cjs = require('./chunk-IEEAENLX.cjs');
|
|
13
13
|
var chunkQW4RBGHN_cjs = require('./chunk-QW4RBGHN.cjs');
|
|
@@ -372,7 +372,7 @@ var LazyTree = createLazyComponent(
|
|
|
372
372
|
}
|
|
373
373
|
);
|
|
374
374
|
var LazyChat = createLazyComponent(
|
|
375
|
-
() => import('./ChatRoot-
|
|
375
|
+
() => import('./ChatRoot-CIOFUESH.cjs').then((m) => ({ default: m.ChatRoot })),
|
|
376
376
|
{
|
|
377
377
|
displayName: "LazyChat",
|
|
378
378
|
fallback: /* @__PURE__ */ jsxRuntime.jsx(LoadingFallback, { minHeight: 320, text: "Loading chat\u2026" })
|
|
@@ -409,7 +409,7 @@ async function* parseSSE(response, options = {}) {
|
|
|
409
409
|
throw new Error("SSE response has no body");
|
|
410
410
|
}
|
|
411
411
|
const map = options.map ?? DEFAULT_MAP;
|
|
412
|
-
const idleMs = options.idleTimeoutMs ??
|
|
412
|
+
const idleMs = options.idleTimeoutMs ?? chunkAK2VHUJV_cjs.LIMITS.sseIdleMs;
|
|
413
413
|
const reader = response.body.getReader();
|
|
414
414
|
const decoder = new TextDecoder();
|
|
415
415
|
let buffer = "";
|
|
@@ -612,7 +612,7 @@ function createMockTransport(opts = {}) {
|
|
|
612
612
|
async createSession(_opts) {
|
|
613
613
|
await sleep(latency);
|
|
614
614
|
return {
|
|
615
|
-
sessionId:
|
|
615
|
+
sessionId: chunkAK2VHUJV_cjs.createId("s"),
|
|
616
616
|
messages: history.length ? [...history] : void 0,
|
|
617
617
|
hasMore: false,
|
|
618
618
|
cursor: null,
|
|
@@ -629,12 +629,12 @@ function createMockTransport(opts = {}) {
|
|
|
629
629
|
throw new Error("mock transport scripted failure");
|
|
630
630
|
}
|
|
631
631
|
history.push({
|
|
632
|
-
id:
|
|
632
|
+
id: chunkAK2VHUJV_cjs.createId("u"),
|
|
633
633
|
role: "user",
|
|
634
634
|
content,
|
|
635
635
|
createdAt: Date.now()
|
|
636
636
|
});
|
|
637
|
-
const messageId =
|
|
637
|
+
const messageId = chunkAK2VHUJV_cjs.createId("a");
|
|
638
638
|
yield { type: "message_start", messageId, sessionId: _sid };
|
|
639
639
|
const reply = replies[turn % replies.length];
|
|
640
640
|
turn += 1;
|
|
@@ -663,7 +663,7 @@ function createMockTransport(opts = {}) {
|
|
|
663
663
|
turn += 1;
|
|
664
664
|
const text = typeof reply === "string" ? reply : reply.filter((e) => e.type === "chunk").map((e) => e.delta).join("");
|
|
665
665
|
return {
|
|
666
|
-
id:
|
|
666
|
+
id: chunkAK2VHUJV_cjs.createId("a"),
|
|
667
667
|
role: "assistant",
|
|
668
668
|
content: text || DEFAULT_REPLY,
|
|
669
669
|
createdAt: Date.now()
|
|
@@ -2019,159 +2019,159 @@ Object.defineProperty(exports, "useCronWeekDays", {
|
|
|
2019
2019
|
});
|
|
2020
2020
|
Object.defineProperty(exports, "Attachments", {
|
|
2021
2021
|
enumerable: true,
|
|
2022
|
-
get: function () { return
|
|
2022
|
+
get: function () { return chunkAK2VHUJV_cjs.Attachments; }
|
|
2023
2023
|
});
|
|
2024
2024
|
Object.defineProperty(exports, "AttachmentsGrid", {
|
|
2025
2025
|
enumerable: true,
|
|
2026
|
-
get: function () { return
|
|
2026
|
+
get: function () { return chunkAK2VHUJV_cjs.AttachmentsGrid; }
|
|
2027
2027
|
});
|
|
2028
2028
|
Object.defineProperty(exports, "AttachmentsList", {
|
|
2029
2029
|
enumerable: true,
|
|
2030
|
-
get: function () { return
|
|
2030
|
+
get: function () { return chunkAK2VHUJV_cjs.AttachmentsList; }
|
|
2031
2031
|
});
|
|
2032
2032
|
Object.defineProperty(exports, "CHAT_EVENT_NAME", {
|
|
2033
2033
|
enumerable: true,
|
|
2034
|
-
get: function () { return
|
|
2034
|
+
get: function () { return chunkAK2VHUJV_cjs.CHAT_EVENT_NAME; }
|
|
2035
2035
|
});
|
|
2036
2036
|
Object.defineProperty(exports, "CSS_VARS", {
|
|
2037
2037
|
enumerable: true,
|
|
2038
|
-
get: function () { return
|
|
2038
|
+
get: function () { return chunkAK2VHUJV_cjs.CSS_VARS; }
|
|
2039
2039
|
});
|
|
2040
2040
|
Object.defineProperty(exports, "ChatProvider", {
|
|
2041
2041
|
enumerable: true,
|
|
2042
|
-
get: function () { return
|
|
2042
|
+
get: function () { return chunkAK2VHUJV_cjs.ChatProvider; }
|
|
2043
2043
|
});
|
|
2044
2044
|
Object.defineProperty(exports, "ChatRoot", {
|
|
2045
2045
|
enumerable: true,
|
|
2046
|
-
get: function () { return
|
|
2046
|
+
get: function () { return chunkAK2VHUJV_cjs.ChatRoot; }
|
|
2047
2047
|
});
|
|
2048
2048
|
Object.defineProperty(exports, "Composer", {
|
|
2049
2049
|
enumerable: true,
|
|
2050
|
-
get: function () { return
|
|
2050
|
+
get: function () { return chunkAK2VHUJV_cjs.Composer; }
|
|
2051
2051
|
});
|
|
2052
2052
|
Object.defineProperty(exports, "DEFAULT_LABELS", {
|
|
2053
2053
|
enumerable: true,
|
|
2054
|
-
get: function () { return
|
|
2054
|
+
get: function () { return chunkAK2VHUJV_cjs.DEFAULT_LABELS; }
|
|
2055
2055
|
});
|
|
2056
2056
|
Object.defineProperty(exports, "DEFAULT_SIDEBAR", {
|
|
2057
2057
|
enumerable: true,
|
|
2058
|
-
get: function () { return
|
|
2058
|
+
get: function () { return chunkAK2VHUJV_cjs.DEFAULT_SIDEBAR; }
|
|
2059
2059
|
});
|
|
2060
2060
|
Object.defineProperty(exports, "DEFAULT_Z_INDEX", {
|
|
2061
2061
|
enumerable: true,
|
|
2062
|
-
get: function () { return
|
|
2062
|
+
get: function () { return chunkAK2VHUJV_cjs.DEFAULT_Z_INDEX; }
|
|
2063
2063
|
});
|
|
2064
2064
|
Object.defineProperty(exports, "EmptyState", {
|
|
2065
2065
|
enumerable: true,
|
|
2066
|
-
get: function () { return
|
|
2066
|
+
get: function () { return chunkAK2VHUJV_cjs.EmptyState; }
|
|
2067
2067
|
});
|
|
2068
2068
|
Object.defineProperty(exports, "ErrorBanner", {
|
|
2069
2069
|
enumerable: true,
|
|
2070
|
-
get: function () { return
|
|
2070
|
+
get: function () { return chunkAK2VHUJV_cjs.ErrorBanner; }
|
|
2071
2071
|
});
|
|
2072
2072
|
Object.defineProperty(exports, "HOTKEYS", {
|
|
2073
2073
|
enumerable: true,
|
|
2074
|
-
get: function () { return
|
|
2074
|
+
get: function () { return chunkAK2VHUJV_cjs.HOTKEYS; }
|
|
2075
2075
|
});
|
|
2076
2076
|
Object.defineProperty(exports, "JumpToLatest", {
|
|
2077
2077
|
enumerable: true,
|
|
2078
|
-
get: function () { return
|
|
2078
|
+
get: function () { return chunkAK2VHUJV_cjs.JumpToLatest; }
|
|
2079
2079
|
});
|
|
2080
2080
|
Object.defineProperty(exports, "LIMITS", {
|
|
2081
2081
|
enumerable: true,
|
|
2082
|
-
get: function () { return
|
|
2082
|
+
get: function () { return chunkAK2VHUJV_cjs.LIMITS; }
|
|
2083
2083
|
});
|
|
2084
2084
|
Object.defineProperty(exports, "MessageActions", {
|
|
2085
2085
|
enumerable: true,
|
|
2086
|
-
get: function () { return
|
|
2086
|
+
get: function () { return chunkAK2VHUJV_cjs.MessageActions; }
|
|
2087
2087
|
});
|
|
2088
2088
|
Object.defineProperty(exports, "MessageBubble", {
|
|
2089
2089
|
enumerable: true,
|
|
2090
|
-
get: function () { return
|
|
2090
|
+
get: function () { return chunkAK2VHUJV_cjs.MessageBubble; }
|
|
2091
2091
|
});
|
|
2092
2092
|
Object.defineProperty(exports, "MessageList", {
|
|
2093
2093
|
enumerable: true,
|
|
2094
|
-
get: function () { return
|
|
2094
|
+
get: function () { return chunkAK2VHUJV_cjs.MessageList; }
|
|
2095
2095
|
});
|
|
2096
2096
|
Object.defineProperty(exports, "STORAGE_KEYS", {
|
|
2097
2097
|
enumerable: true,
|
|
2098
|
-
get: function () { return
|
|
2098
|
+
get: function () { return chunkAK2VHUJV_cjs.STORAGE_KEYS; }
|
|
2099
2099
|
});
|
|
2100
2100
|
Object.defineProperty(exports, "Sources", {
|
|
2101
2101
|
enumerable: true,
|
|
2102
|
-
get: function () { return
|
|
2102
|
+
get: function () { return chunkAK2VHUJV_cjs.Sources; }
|
|
2103
2103
|
});
|
|
2104
2104
|
Object.defineProperty(exports, "StreamingIndicator", {
|
|
2105
2105
|
enumerable: true,
|
|
2106
|
-
get: function () { return
|
|
2106
|
+
get: function () { return chunkAK2VHUJV_cjs.StreamingIndicator; }
|
|
2107
2107
|
});
|
|
2108
2108
|
Object.defineProperty(exports, "ToolCalls", {
|
|
2109
2109
|
enumerable: true,
|
|
2110
|
-
get: function () { return
|
|
2110
|
+
get: function () { return chunkAK2VHUJV_cjs.ToolCalls; }
|
|
2111
2111
|
});
|
|
2112
2112
|
Object.defineProperty(exports, "createId", {
|
|
2113
2113
|
enumerable: true,
|
|
2114
|
-
get: function () { return
|
|
2114
|
+
get: function () { return chunkAK2VHUJV_cjs.createId; }
|
|
2115
2115
|
});
|
|
2116
2116
|
Object.defineProperty(exports, "createTokenBuffer", {
|
|
2117
2117
|
enumerable: true,
|
|
2118
|
-
get: function () { return
|
|
2118
|
+
get: function () { return chunkAK2VHUJV_cjs.createTokenBuffer; }
|
|
2119
2119
|
});
|
|
2120
2120
|
Object.defineProperty(exports, "deriveInitials", {
|
|
2121
2121
|
enumerable: true,
|
|
2122
|
-
get: function () { return
|
|
2122
|
+
get: function () { return chunkAK2VHUJV_cjs.deriveInitials; }
|
|
2123
2123
|
});
|
|
2124
2124
|
Object.defineProperty(exports, "getChatLogger", {
|
|
2125
2125
|
enumerable: true,
|
|
2126
|
-
get: function () { return
|
|
2126
|
+
get: function () { return chunkAK2VHUJV_cjs.getChatLogger; }
|
|
2127
2127
|
});
|
|
2128
2128
|
Object.defineProperty(exports, "initialState", {
|
|
2129
2129
|
enumerable: true,
|
|
2130
|
-
get: function () { return
|
|
2130
|
+
get: function () { return chunkAK2VHUJV_cjs.initialState; }
|
|
2131
2131
|
});
|
|
2132
2132
|
Object.defineProperty(exports, "reducer", {
|
|
2133
2133
|
enumerable: true,
|
|
2134
|
-
get: function () { return
|
|
2134
|
+
get: function () { return chunkAK2VHUJV_cjs.reducer; }
|
|
2135
2135
|
});
|
|
2136
2136
|
Object.defineProperty(exports, "resolvePersona", {
|
|
2137
2137
|
enumerable: true,
|
|
2138
|
-
get: function () { return
|
|
2138
|
+
get: function () { return chunkAK2VHUJV_cjs.resolvePersona; }
|
|
2139
2139
|
});
|
|
2140
2140
|
Object.defineProperty(exports, "useChat", {
|
|
2141
2141
|
enumerable: true,
|
|
2142
|
-
get: function () { return
|
|
2142
|
+
get: function () { return chunkAK2VHUJV_cjs.useChat; }
|
|
2143
2143
|
});
|
|
2144
2144
|
Object.defineProperty(exports, "useChatAudio", {
|
|
2145
2145
|
enumerable: true,
|
|
2146
|
-
get: function () { return
|
|
2146
|
+
get: function () { return chunkAK2VHUJV_cjs.useChatAudio; }
|
|
2147
2147
|
});
|
|
2148
2148
|
Object.defineProperty(exports, "useChatAudioPrefs", {
|
|
2149
2149
|
enumerable: true,
|
|
2150
|
-
get: function () { return
|
|
2150
|
+
get: function () { return chunkAK2VHUJV_cjs.useChatAudioPrefs; }
|
|
2151
2151
|
});
|
|
2152
2152
|
Object.defineProperty(exports, "useChatComposer", {
|
|
2153
2153
|
enumerable: true,
|
|
2154
|
-
get: function () { return
|
|
2154
|
+
get: function () { return chunkAK2VHUJV_cjs.useChatComposer; }
|
|
2155
2155
|
});
|
|
2156
2156
|
Object.defineProperty(exports, "useChatContext", {
|
|
2157
2157
|
enumerable: true,
|
|
2158
|
-
get: function () { return
|
|
2158
|
+
get: function () { return chunkAK2VHUJV_cjs.useChatContext; }
|
|
2159
2159
|
});
|
|
2160
2160
|
Object.defineProperty(exports, "useChatContextOptional", {
|
|
2161
2161
|
enumerable: true,
|
|
2162
|
-
get: function () { return
|
|
2162
|
+
get: function () { return chunkAK2VHUJV_cjs.useChatContextOptional; }
|
|
2163
2163
|
});
|
|
2164
2164
|
Object.defineProperty(exports, "useChatHistory", {
|
|
2165
2165
|
enumerable: true,
|
|
2166
|
-
get: function () { return
|
|
2166
|
+
get: function () { return chunkAK2VHUJV_cjs.useChatHistory; }
|
|
2167
2167
|
});
|
|
2168
2168
|
Object.defineProperty(exports, "useChatLayout", {
|
|
2169
2169
|
enumerable: true,
|
|
2170
|
-
get: function () { return
|
|
2170
|
+
get: function () { return chunkAK2VHUJV_cjs.useChatLayout; }
|
|
2171
2171
|
});
|
|
2172
2172
|
Object.defineProperty(exports, "useChatScroll", {
|
|
2173
2173
|
enumerable: true,
|
|
2174
|
-
get: function () { return
|
|
2174
|
+
get: function () { return chunkAK2VHUJV_cjs.useChatScroll; }
|
|
2175
2175
|
});
|
|
2176
2176
|
Object.defineProperty(exports, "TreeError", {
|
|
2177
2177
|
enumerable: true,
|
package/dist/index.d.cts
CHANGED
|
@@ -1553,6 +1553,8 @@ type ChatStreamEvent = {
|
|
|
1553
1553
|
type: 'message_start';
|
|
1554
1554
|
messageId: string;
|
|
1555
1555
|
sessionId: string;
|
|
1556
|
+
} | {
|
|
1557
|
+
type: 'resume_start';
|
|
1556
1558
|
} | {
|
|
1557
1559
|
type: 'chunk';
|
|
1558
1560
|
delta: string;
|
|
@@ -1683,6 +1685,7 @@ type ChatAction = {
|
|
|
1683
1685
|
type: 'STREAM_START';
|
|
1684
1686
|
id: string;
|
|
1685
1687
|
createdAt?: number;
|
|
1688
|
+
continueExisting?: boolean;
|
|
1686
1689
|
} | {
|
|
1687
1690
|
type: 'STREAM_CHUNK';
|
|
1688
1691
|
delta: string;
|
|
@@ -1971,6 +1974,8 @@ interface ChatRootProps {
|
|
|
1971
1974
|
showAttachmentButton?: boolean;
|
|
1972
1975
|
/** Called when the user clicks the attach button (host opens its file picker). */
|
|
1973
1976
|
onPickFiles?: () => void;
|
|
1977
|
+
/** Hide the composer input area entirely (e.g. while waiting for human approval). */
|
|
1978
|
+
hideComposer?: boolean;
|
|
1974
1979
|
}
|
|
1975
1980
|
declare function ChatRoot(props: ChatRootProps): react_jsx_runtime.JSX.Element;
|
|
1976
1981
|
|
package/dist/index.d.ts
CHANGED
|
@@ -1553,6 +1553,8 @@ type ChatStreamEvent = {
|
|
|
1553
1553
|
type: 'message_start';
|
|
1554
1554
|
messageId: string;
|
|
1555
1555
|
sessionId: string;
|
|
1556
|
+
} | {
|
|
1557
|
+
type: 'resume_start';
|
|
1556
1558
|
} | {
|
|
1557
1559
|
type: 'chunk';
|
|
1558
1560
|
delta: string;
|
|
@@ -1683,6 +1685,7 @@ type ChatAction = {
|
|
|
1683
1685
|
type: 'STREAM_START';
|
|
1684
1686
|
id: string;
|
|
1685
1687
|
createdAt?: number;
|
|
1688
|
+
continueExisting?: boolean;
|
|
1686
1689
|
} | {
|
|
1687
1690
|
type: 'STREAM_CHUNK';
|
|
1688
1691
|
delta: string;
|
|
@@ -1971,6 +1974,8 @@ interface ChatRootProps {
|
|
|
1971
1974
|
showAttachmentButton?: boolean;
|
|
1972
1975
|
/** Called when the user clicks the attach button (host opens its file picker). */
|
|
1973
1976
|
onPickFiles?: () => void;
|
|
1977
|
+
/** Hide the composer input area entirely (e.g. while waiting for human approval). */
|
|
1978
|
+
hideComposer?: boolean;
|
|
1974
1979
|
}
|
|
1975
1980
|
declare function ChatRoot(props: ChatRootProps): react_jsx_runtime.JSX.Element;
|
|
1976
1981
|
|
package/dist/index.mjs
CHANGED
|
@@ -5,8 +5,8 @@ export { NativeProvider, StreamProvider, VideoControls, VideoErrorFallback, Vide
|
|
|
5
5
|
export { ImageViewer } from './chunk-OBRSGM64.mjs';
|
|
6
6
|
export { generateContentKey, useAudioCache, useBlobUrlCleanup, useImageCache, useMediaCacheStore, useVideoCache, useVideoPlayerSettings } from './chunk-C6GXVH5J.mjs';
|
|
7
7
|
export { CronSchedulerProvider, CustomInput, DayChips, MonthDayGrid, SchedulePreview, ScheduleTypeSelector, TimeSelector, buildCron, humanizeCron, isValidCron, parseCron, useCronCustom, useCronMonthDays, useCronPreview, useCronScheduler, useCronSchedulerContext, useCronTime, useCronType, useCronWeekDays } from './chunk-PVAX67JG.mjs';
|
|
8
|
-
import { LIMITS, createId } from './chunk-
|
|
9
|
-
export { Attachments, AttachmentsGrid, AttachmentsList, CHAT_EVENT_NAME, CSS_VARS, ChatProvider, ChatRoot, Composer, DEFAULT_LABELS, DEFAULT_SIDEBAR, DEFAULT_Z_INDEX, EmptyState, ErrorBanner, HOTKEYS, JumpToLatest, LIMITS, MessageActions, MessageBubble, MessageList, STORAGE_KEYS, Sources, StreamingIndicator, ToolCalls, createId, createTokenBuffer, deriveInitials, getChatLogger, initialState, reducer, resolvePersona, useChat, useChatAudio, useChatAudioPrefs, useChatComposer, useChatContext, useChatContextOptional, useChatHistory, useChatLayout, useChatScroll } from './chunk-
|
|
8
|
+
import { LIMITS, createId } from './chunk-D7ISTFUS.mjs';
|
|
9
|
+
export { Attachments, AttachmentsGrid, AttachmentsList, CHAT_EVENT_NAME, CSS_VARS, ChatProvider, ChatRoot, Composer, DEFAULT_LABELS, DEFAULT_SIDEBAR, DEFAULT_Z_INDEX, EmptyState, ErrorBanner, HOTKEYS, JumpToLatest, LIMITS, MessageActions, MessageBubble, MessageList, STORAGE_KEYS, Sources, StreamingIndicator, ToolCalls, createId, createTokenBuffer, deriveInitials, getChatLogger, initialState, reducer, resolvePersona, useChat, useChatAudio, useChatAudioPrefs, useChatComposer, useChatContext, useChatContextOptional, useChatHistory, useChatLayout, useChatScroll } from './chunk-D7ISTFUS.mjs';
|
|
10
10
|
export { TreeError, TreeSkeleton, createDemoTree } from './chunk-B6IR5KSC.mjs';
|
|
11
11
|
export { DEFAULT_TREE_APPEARANCE, DEFAULT_TREE_LABELS, TreeRoot as Tree, TreeChevron, TreeContent, TreeEmpty, TreeIcon, TreeIndentGuides, TreeLabel, TreeProvider, TreeRoot, TreeRow, TreeSearchInput, appearanceToStyle, clearTreeState, createChildCache, flattenTree, loadTreeState, resolveAppearance, resolveChildren, saveTreeState, useTreeActions, useTreeContext, useTreeExpansion, useTreeFocus, useTreeKeyboard, useTreeLabels, useTreeRows, useTreeSearch, useTreeSelection, useTreeTypeAhead } from './chunk-G5IEC7SR.mjs';
|
|
12
12
|
import { PlaygroundProvider } from './chunk-ZUFTH5IR.mjs';
|
|
@@ -347,7 +347,7 @@ var LazyTree = createLazyComponent(
|
|
|
347
347
|
}
|
|
348
348
|
);
|
|
349
349
|
var LazyChat = createLazyComponent(
|
|
350
|
-
() => import('./ChatRoot-
|
|
350
|
+
() => import('./ChatRoot-OURQVRLD.mjs').then((m) => ({ default: m.ChatRoot })),
|
|
351
351
|
{
|
|
352
352
|
displayName: "LazyChat",
|
|
353
353
|
fallback: /* @__PURE__ */ jsx(LoadingFallback, { minHeight: 320, text: "Loading chat\u2026" })
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@djangocfg/ui-tools",
|
|
3
|
-
"version": "2.1.
|
|
3
|
+
"version": "2.1.344",
|
|
4
4
|
"description": "Heavy React tools with lazy loading - for Electron, Vite, CRA, Next.js apps",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ui-tools",
|
|
@@ -101,8 +101,8 @@
|
|
|
101
101
|
"check": "tsc --noEmit"
|
|
102
102
|
},
|
|
103
103
|
"peerDependencies": {
|
|
104
|
-
"@djangocfg/i18n": "^2.1.
|
|
105
|
-
"@djangocfg/ui-core": "^2.1.
|
|
104
|
+
"@djangocfg/i18n": "^2.1.344",
|
|
105
|
+
"@djangocfg/ui-core": "^2.1.344",
|
|
106
106
|
"consola": "^3.4.2",
|
|
107
107
|
"lodash-es": "^4.18.1",
|
|
108
108
|
"lucide-react": "^0.545.0",
|
|
@@ -155,10 +155,10 @@
|
|
|
155
155
|
"material-file-icons": "^2.4.0"
|
|
156
156
|
},
|
|
157
157
|
"devDependencies": {
|
|
158
|
-
"@djangocfg/i18n": "^2.1.
|
|
158
|
+
"@djangocfg/i18n": "^2.1.344",
|
|
159
159
|
"@djangocfg/playground": "workspace:*",
|
|
160
|
-
"@djangocfg/typescript-config": "^2.1.
|
|
161
|
-
"@djangocfg/ui-core": "^2.1.
|
|
160
|
+
"@djangocfg/typescript-config": "^2.1.344",
|
|
161
|
+
"@djangocfg/ui-core": "^2.1.344",
|
|
162
162
|
"@types/lodash-es": "^4.17.12",
|
|
163
163
|
"@types/mapbox__mapbox-gl-draw": "^1.4.8",
|
|
164
164
|
"@types/node": "^24.7.2",
|
|
@@ -941,7 +941,80 @@ export const MultiUser = () => (
|
|
|
941
941
|
);
|
|
942
942
|
|
|
943
943
|
// ---------------------------------------------------------------------------
|
|
944
|
-
// 13)
|
|
944
|
+
// 13) WithHideComposer — agent-pause pattern (approval gate, human-in-the-loop)
|
|
945
|
+
// ---------------------------------------------------------------------------
|
|
946
|
+
|
|
947
|
+
export const WithHideComposer = () => {
|
|
948
|
+
const [paused, setPaused] = useState(false);
|
|
949
|
+
|
|
950
|
+
const transport = useMemo(
|
|
951
|
+
() =>
|
|
952
|
+
createMockTransport({
|
|
953
|
+
replies: [
|
|
954
|
+
'Sure — I will send that email. Waiting for your approval before proceeding.',
|
|
955
|
+
],
|
|
956
|
+
latencyMs: 30,
|
|
957
|
+
}),
|
|
958
|
+
[],
|
|
959
|
+
);
|
|
960
|
+
|
|
961
|
+
return (
|
|
962
|
+
<Frame h={480}>
|
|
963
|
+
<ChatRoot
|
|
964
|
+
transport={transport}
|
|
965
|
+
config={{
|
|
966
|
+
greeting: 'Agent-pause demo',
|
|
967
|
+
placeholder: 'Ask to do something requiring approval…',
|
|
968
|
+
}}
|
|
969
|
+
hideComposer={paused}
|
|
970
|
+
footer={
|
|
971
|
+
paused ? (
|
|
972
|
+
<div className="flex flex-col gap-2 border-t bg-background px-3 py-2">
|
|
973
|
+
<div className="rounded-lg border border-amber-200 bg-amber-50 dark:border-amber-800 dark:bg-amber-950/40 p-3 text-sm">
|
|
974
|
+
<div className="mb-1 font-medium text-amber-900 dark:text-amber-200">
|
|
975
|
+
Approval required
|
|
976
|
+
<span className="ml-2 font-mono text-xs text-amber-700 dark:text-amber-400">send_email</span>
|
|
977
|
+
</div>
|
|
978
|
+
<pre className="mb-2 rounded bg-muted px-2 py-1.5 text-[11px] text-muted-foreground">
|
|
979
|
+
{`{ "to": "mark@example.com", "subject": "Hello" }`}
|
|
980
|
+
</pre>
|
|
981
|
+
<div className="flex gap-2">
|
|
982
|
+
<button
|
|
983
|
+
type="button"
|
|
984
|
+
onClick={() => setPaused(false)}
|
|
985
|
+
className="flex-1 rounded bg-amber-600 hover:bg-amber-700 px-3 py-1.5 text-xs font-medium text-white transition-colors"
|
|
986
|
+
>
|
|
987
|
+
Approve
|
|
988
|
+
</button>
|
|
989
|
+
<button
|
|
990
|
+
type="button"
|
|
991
|
+
onClick={() => setPaused(false)}
|
|
992
|
+
className="flex-1 rounded border border-amber-300 hover:bg-amber-100 px-3 py-1.5 text-xs font-medium text-amber-800 transition-colors"
|
|
993
|
+
>
|
|
994
|
+
Deny
|
|
995
|
+
</button>
|
|
996
|
+
</div>
|
|
997
|
+
</div>
|
|
998
|
+
</div>
|
|
999
|
+
) : (
|
|
1000
|
+
<div className="border-t border-border bg-muted/20 px-3 py-1.5 text-center">
|
|
1001
|
+
<button
|
|
1002
|
+
type="button"
|
|
1003
|
+
onClick={() => setPaused(true)}
|
|
1004
|
+
className="text-[11px] text-muted-foreground hover:text-foreground underline"
|
|
1005
|
+
>
|
|
1006
|
+
Simulate approval gate
|
|
1007
|
+
</button>
|
|
1008
|
+
</div>
|
|
1009
|
+
)
|
|
1010
|
+
}
|
|
1011
|
+
/>
|
|
1012
|
+
</Frame>
|
|
1013
|
+
);
|
|
1014
|
+
};
|
|
1015
|
+
|
|
1016
|
+
// ---------------------------------------------------------------------------
|
|
1017
|
+
// 14) Playground — knobs
|
|
945
1018
|
// ---------------------------------------------------------------------------
|
|
946
1019
|
|
|
947
1020
|
export const Playground = () => {
|
package/src/tools/Chat/README.md
CHANGED
|
@@ -93,6 +93,9 @@ Module boundaries:
|
|
|
93
93
|
renderInput: (v) => <LazyJsonTree data={v} mode="compact" />,
|
|
94
94
|
renderOutput: (v) => <LazyJsonTree data={v} mode="compact" />,
|
|
95
95
|
}}
|
|
96
|
+
|
|
97
|
+
// Hide composer while agent is paused waiting for human input
|
|
98
|
+
hideComposer={hasPendingApprovals}
|
|
96
99
|
/>
|
|
97
100
|
```
|
|
98
101
|
|
|
@@ -106,14 +109,32 @@ Module boundaries:
|
|
|
106
109
|
├───────────────────────────────┤
|
|
107
110
|
│ messages (jumpToLatest) │
|
|
108
111
|
├───────────────────────────────┤
|
|
109
|
-
│ composerToolbarStart │
|
|
112
|
+
│ composerToolbarStart │ ← hidden when hideComposer={true}
|
|
110
113
|
│ [textarea] composerToolbarEnd │
|
|
111
114
|
│ composerAttachmentTray │
|
|
112
115
|
├───────────────────────────────┤
|
|
113
|
-
│ footer │
|
|
116
|
+
│ footer │ ← use for approval panels, disclaimers
|
|
114
117
|
└───────────────────────────────┘
|
|
115
118
|
```
|
|
116
119
|
|
|
120
|
+
### hideComposer — agent-pause / human-in-the-loop
|
|
121
|
+
|
|
122
|
+
Set `hideComposer={true}` to remove the composer while the agent is waiting for a human decision (approval gate, HITL). Combine with `footer` to show action buttons:
|
|
123
|
+
|
|
124
|
+
```tsx
|
|
125
|
+
<ChatRoot
|
|
126
|
+
transport={transport}
|
|
127
|
+
hideComposer={pendingActions.length > 0}
|
|
128
|
+
footer={
|
|
129
|
+
pendingActions.length > 0 ? (
|
|
130
|
+
<AgentActions actions={pendingActions} onResult={handleResult} />
|
|
131
|
+
) : null
|
|
132
|
+
}
|
|
133
|
+
/>
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
The composer reappears automatically once `hideComposer` returns `false`.
|
|
137
|
+
|
|
117
138
|
### ToolCalls — expand behavior
|
|
118
139
|
|
|
119
140
|
Panels are **collapsed by default**. While a tool is `running`, the panel auto-expands so you can see live `streamingText`; on completion it auto-collapses again. Manual user toggles (open or close) are remembered and override the auto-behavior for that call.
|
|
@@ -525,4 +546,5 @@ Full implementation plan and rationale lives at [`@dev/@refactoring7-chat/`](../
|
|
|
525
546
|
- `WithMapPayload` — `dispatchToolPayload` with `LazyJsonTree` fallback
|
|
526
547
|
- `WithPersonas` — config-level `user` + `assistant` identity (avatar, name)
|
|
527
548
|
- `MultiUser` — per-message `sender` overrides (multi-user / multi-bot)
|
|
549
|
+
- `WithHideComposer` — `hideComposer` + `footer` approval gate (HITL / agent-pause pattern)
|
|
528
550
|
- `Playground` — knobs (latency, streaming, suggestions)
|
|
@@ -73,6 +73,8 @@ export interface ChatRootProps {
|
|
|
73
73
|
showAttachmentButton?: boolean;
|
|
74
74
|
/** Called when the user clicks the attach button (host opens its file picker). */
|
|
75
75
|
onPickFiles?: () => void;
|
|
76
|
+
/** Hide the composer input area entirely (e.g. while waiting for human approval). */
|
|
77
|
+
hideComposer?: boolean;
|
|
76
78
|
}
|
|
77
79
|
|
|
78
80
|
export function ChatRoot(props: ChatRootProps) {
|
|
@@ -184,15 +186,17 @@ function ChatRootShell({ className, slots }: ChatRootShellProps) {
|
|
|
184
186
|
)}
|
|
185
187
|
</div>
|
|
186
188
|
</div>
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
189
|
+
{!slots.hideComposer && (
|
|
190
|
+
<Composer
|
|
191
|
+
composer={composer}
|
|
192
|
+
placeholder={chat.config.placeholder}
|
|
193
|
+
showAttachmentButton={slots.showAttachmentButton}
|
|
194
|
+
onPickFiles={slots.onPickFiles}
|
|
195
|
+
toolbarStart={slots.composerToolbarStart}
|
|
196
|
+
toolbarEnd={slots.composerToolbarEnd}
|
|
197
|
+
attachmentTray={slots.composerAttachmentTray}
|
|
198
|
+
/>
|
|
199
|
+
)}
|
|
196
200
|
{slots.footer ?? null}
|
|
197
201
|
</div>
|
|
198
202
|
);
|
|
@@ -58,7 +58,7 @@ export type ChatAction =
|
|
|
58
58
|
cursor: string | null;
|
|
59
59
|
}
|
|
60
60
|
| { type: 'MESSAGE_USER_ADD'; message: ChatMessage }
|
|
61
|
-
| { type: 'STREAM_START'; id: string; createdAt?: number }
|
|
61
|
+
| { type: 'STREAM_START'; id: string; createdAt?: number; continueExisting?: boolean }
|
|
62
62
|
| { type: 'STREAM_CHUNK'; delta: string }
|
|
63
63
|
| { type: 'STREAM_TOOL_ACTIVITY'; tool: string }
|
|
64
64
|
| { type: 'TOOL_CALL_START'; messageId: string; toolCall: ChatToolCall }
|
|
@@ -168,12 +168,27 @@ export function reducer(state: ChatState, action: ChatAction): ChatState {
|
|
|
168
168
|
case 'STREAM_START': {
|
|
169
169
|
if (state.isStreaming) {
|
|
170
170
|
if (typeof console !== 'undefined') {
|
|
171
|
-
// Soft guard — UI should disable the composer; this catches bugs.
|
|
172
171
|
// eslint-disable-next-line no-console
|
|
173
172
|
console.warn('[chat] STREAM_START while already streaming, ignoring');
|
|
174
173
|
}
|
|
175
174
|
return state;
|
|
176
175
|
}
|
|
176
|
+
// continueExisting: resume an agent run — reuse the last assistant message
|
|
177
|
+
// instead of creating a new empty placeholder. Used for HITL / approval-gate
|
|
178
|
+
// flows where the same logical turn resumes after a human decision.
|
|
179
|
+
if (action.continueExisting) {
|
|
180
|
+
const lastAssistantIdx = (() => {
|
|
181
|
+
for (let i = state.messages.length - 1; i >= 0; i--) {
|
|
182
|
+
if (state.messages[i].role === 'assistant') return i;
|
|
183
|
+
}
|
|
184
|
+
return -1;
|
|
185
|
+
})();
|
|
186
|
+
if (lastAssistantIdx !== -1) {
|
|
187
|
+
const msgs = state.messages.slice();
|
|
188
|
+
msgs[lastAssistantIdx] = { ...msgs[lastAssistantIdx], isStreaming: true };
|
|
189
|
+
return { ...state, isStreaming: true, messages: msgs };
|
|
190
|
+
}
|
|
191
|
+
}
|
|
177
192
|
const placeholder: ChatMessage = {
|
|
178
193
|
id: action.id,
|
|
179
194
|
role: 'assistant',
|
|
@@ -207,9 +207,30 @@ export function useChat(config: UseChatConfig): UseChatReturn {
|
|
|
207
207
|
const assistantId = createId('a');
|
|
208
208
|
streamingMsgIdRef.current = assistantId;
|
|
209
209
|
|
|
210
|
-
|
|
210
|
+
// Peek at the first event to detect resume streams before dispatching STREAM_START.
|
|
211
|
+
// A resume stream begins with { type: 'resume_start' } — in that case we reuse
|
|
212
|
+
// the last assistant message instead of creating a new empty placeholder.
|
|
213
|
+
const iterator = transport.stream(sessionId, content, {
|
|
214
|
+
signal: ctrl.signal,
|
|
215
|
+
attachments,
|
|
216
|
+
metadata: config.metadata,
|
|
217
|
+
});
|
|
218
|
+
|
|
219
|
+
let continueExisting = false;
|
|
220
|
+
let peekedEvent: ChatStreamEvent | null = null;
|
|
221
|
+
const firstResult = await iterator.next();
|
|
222
|
+
if (!firstResult.done) {
|
|
223
|
+
const ev = firstResult.value as ChatStreamEvent;
|
|
224
|
+
if (ev.type === 'resume_start') {
|
|
225
|
+
continueExisting = true;
|
|
226
|
+
} else {
|
|
227
|
+
peekedEvent = ev;
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
dispatch({ type: 'STREAM_START', id: assistantId, continueExisting });
|
|
211
232
|
config.onStreamStart?.(assistantId);
|
|
212
|
-
log.stream.info('start', { sessionId, assistantId, chars: content.length });
|
|
233
|
+
log.stream.info('start', { sessionId, assistantId, chars: content.length, continueExisting });
|
|
213
234
|
|
|
214
235
|
const tokenBuffer = createTokenBuffer((delta) =>
|
|
215
236
|
dispatch({ type: 'STREAM_CHUNK', delta }),
|
|
@@ -221,11 +242,8 @@ export function useChat(config: UseChatConfig): UseChatReturn {
|
|
|
221
242
|
const t0 = performance.now();
|
|
222
243
|
|
|
223
244
|
try {
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
attachments,
|
|
227
|
-
metadata: config.metadata,
|
|
228
|
-
});
|
|
245
|
+
// iterator was already created above (for peek). Replay peeked event if any.
|
|
246
|
+
if (peekedEvent) handleEvent(peekedEvent);
|
|
229
247
|
|
|
230
248
|
for await (const ev of iterator) {
|
|
231
249
|
if (ctrl.signal.aborted) break;
|
package/src/tools/Chat/types.ts
CHANGED
|
@@ -200,6 +200,7 @@ export interface SendOptions {
|
|
|
200
200
|
|
|
201
201
|
export type ChatStreamEvent =
|
|
202
202
|
| { type: 'message_start'; messageId: string; sessionId: string }
|
|
203
|
+
| { type: 'resume_start' }
|
|
203
204
|
| { type: 'chunk'; delta: string }
|
|
204
205
|
| { type: 'tool_activity'; tool: string; status: string }
|
|
205
206
|
| {
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var chunk5T4K3VUV_cjs = require('./chunk-5T4K3VUV.cjs');
|
|
4
|
-
require('./chunk-B5AWZOHJ.cjs');
|
|
5
|
-
require('./chunk-OLISEQHS.cjs');
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
Object.defineProperty(exports, "ChatRoot", {
|
|
10
|
-
enumerable: true,
|
|
11
|
-
get: function () { return chunk5T4K3VUV_cjs.ChatRoot; }
|
|
12
|
-
});
|
|
13
|
-
//# sourceMappingURL=ChatRoot-BT3CLXI4.cjs.map
|
|
14
|
-
//# sourceMappingURL=ChatRoot-BT3CLXI4.cjs.map
|