@blade-hq/agent-react 2612.0.0-beta.40 → 2612.0.0-beta.41
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/WorkflowRunBlock.d.ts +3 -0
- package/dist/{chunk-5S4H3CJD.js → chunk-42P352DI.js} +843 -495
- package/dist/chunk-42P352DI.js.map +1 -0
- package/dist/{chunk-5X6RBFGB.js → chunk-F7BR2KMK.js} +18 -3
- package/dist/{chunk-5X6RBFGB.js.map → chunk-F7BR2KMK.js.map} +1 -1
- package/dist/{chunk-KUZPP6OU.js → chunk-S3AC4DZF.js} +2 -2
- package/dist/index.js +2 -2
- package/dist/internal.js +3 -3
- package/dist/rich-input.js +178 -477
- package/dist/rich-input.js.map +1 -1
- package/package.json +2 -2
- package/dist/chunk-5S4H3CJD.js.map +0 -1
- /package/dist/{chunk-KUZPP6OU.js.map → chunk-S3AC4DZF.js.map} +0 -0
package/dist/rich-input.js
CHANGED
|
@@ -3,7 +3,7 @@ import {
|
|
|
3
3
|
PluginTriggerStack,
|
|
4
4
|
selectionFromItem,
|
|
5
5
|
triggerSummary
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-S3AC4DZF.js";
|
|
7
7
|
import {
|
|
8
8
|
Archive,
|
|
9
9
|
BookOpen,
|
|
@@ -28,12 +28,15 @@ import {
|
|
|
28
28
|
Lightbulb,
|
|
29
29
|
ListPlus,
|
|
30
30
|
LoaderCircle,
|
|
31
|
+
MODEL_REASONING_LEVELS_KEY,
|
|
31
32
|
Mic,
|
|
32
33
|
Music,
|
|
34
|
+
PREFERRED_MODEL_KEY,
|
|
33
35
|
Paperclip,
|
|
34
36
|
Play,
|
|
35
37
|
Plug,
|
|
36
38
|
Plus,
|
|
39
|
+
RichInputServicesProvider,
|
|
37
40
|
Rocket,
|
|
38
41
|
RotateCcw,
|
|
39
42
|
Scissors,
|
|
@@ -47,6 +50,7 @@ import {
|
|
|
47
50
|
cn,
|
|
48
51
|
cn2,
|
|
49
52
|
dist_exports2 as dist_exports,
|
|
53
|
+
fetchClientQuery,
|
|
50
54
|
getInputHistoryGeneration,
|
|
51
55
|
getPluginSuggestionItems,
|
|
52
56
|
isQueueShortcut,
|
|
@@ -54,17 +58,38 @@ import {
|
|
|
54
58
|
onInputCachesReset,
|
|
55
59
|
pluginRefsForSend,
|
|
56
60
|
queueShortcutLabel,
|
|
61
|
+
refreshClientQuery,
|
|
62
|
+
refreshClientSessionSkills,
|
|
57
63
|
sendToSession,
|
|
64
|
+
setClientQueryData,
|
|
65
|
+
useBackgroundTaskList,
|
|
58
66
|
useBladeClient,
|
|
59
67
|
useChatEnvironment,
|
|
60
68
|
useChatRenderMode,
|
|
61
69
|
useChatSessionDetail,
|
|
70
|
+
useClientBackgroundTasks,
|
|
71
|
+
useClientContextStats,
|
|
72
|
+
useClientModelCatalog,
|
|
73
|
+
useClientModelPreferences,
|
|
74
|
+
useClientQuery,
|
|
75
|
+
useClientSessionModel,
|
|
76
|
+
useClientSessionSkills,
|
|
77
|
+
useClientSkillStats,
|
|
78
|
+
useComposerConnection,
|
|
79
|
+
useComposerConnectionInfo,
|
|
80
|
+
useContextStats,
|
|
62
81
|
useCurrentChatSessionId,
|
|
63
82
|
useEffectEvent,
|
|
83
|
+
useModelCatalog,
|
|
84
|
+
useModelPreferences,
|
|
64
85
|
usePortalContainer,
|
|
86
|
+
useRefreshWhenRunEnds,
|
|
87
|
+
useRichInputServices,
|
|
88
|
+
useSessionDataInvalidation,
|
|
65
89
|
useSessionHandle,
|
|
66
|
-
|
|
67
|
-
|
|
90
|
+
useSessionSkills,
|
|
91
|
+
useSkillStats
|
|
92
|
+
} from "./chunk-42P352DI.js";
|
|
68
93
|
import {
|
|
69
94
|
__commonJS,
|
|
70
95
|
__require,
|
|
@@ -102,7 +127,7 @@ var require_use_sync_external_store_shim_development = __commonJS({
|
|
|
102
127
|
},
|
|
103
128
|
[subscribe, value, getSnapshot]
|
|
104
129
|
);
|
|
105
|
-
|
|
130
|
+
useEffect9(
|
|
106
131
|
function() {
|
|
107
132
|
checkIfSnapshotChanged(inst) && forceUpdate({ inst });
|
|
108
133
|
return subscribe(function() {
|
|
@@ -128,7 +153,7 @@ var require_use_sync_external_store_shim_development = __commonJS({
|
|
|
128
153
|
return getSnapshot();
|
|
129
154
|
}
|
|
130
155
|
"undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ && "function" === typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error());
|
|
131
|
-
var React2 = __require("react"), objectIs = "function" === typeof Object.is ? Object.is : is, useState12 = React2.useState,
|
|
156
|
+
var React2 = __require("react"), objectIs = "function" === typeof Object.is ? Object.is : is, useState12 = React2.useState, useEffect9 = React2.useEffect, useLayoutEffect3 = React2.useLayoutEffect, useDebugValue3 = React2.useDebugValue, didWarnOld18Alpha = false, didWarnUncachedGetSnapshot = false, shim = "undefined" === typeof window || "undefined" === typeof window.document || "undefined" === typeof window.document.createElement ? useSyncExternalStore$1 : useSyncExternalStore$2;
|
|
132
157
|
exports.useSyncExternalStore = void 0 !== React2.useSyncExternalStore ? React2.useSyncExternalStore : shim;
|
|
133
158
|
"undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ && "function" === typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(Error());
|
|
134
159
|
})();
|
|
@@ -156,14 +181,14 @@ var require_with_selector_development = __commonJS({
|
|
|
156
181
|
return x === y && (0 !== x || 1 / x === 1 / y) || x !== x && y !== y;
|
|
157
182
|
}
|
|
158
183
|
"undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ && "function" === typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error());
|
|
159
|
-
var React2 = __require("react"), shim = require_shim(), objectIs = "function" === typeof Object.is ? Object.is : is,
|
|
184
|
+
var React2 = __require("react"), shim = require_shim(), objectIs = "function" === typeof Object.is ? Object.is : is, useSyncExternalStore4 = shim.useSyncExternalStore, useRef8 = React2.useRef, useEffect9 = React2.useEffect, useMemo8 = React2.useMemo, useDebugValue3 = React2.useDebugValue;
|
|
160
185
|
exports.useSyncExternalStoreWithSelector = function(subscribe, getSnapshot, getServerSnapshot, selector, isEqual) {
|
|
161
|
-
var instRef =
|
|
186
|
+
var instRef = useRef8(null);
|
|
162
187
|
if (null === instRef.current) {
|
|
163
188
|
var inst = { hasValue: false, value: null };
|
|
164
189
|
instRef.current = inst;
|
|
165
190
|
} else inst = instRef.current;
|
|
166
|
-
instRef =
|
|
191
|
+
instRef = useMemo8(
|
|
167
192
|
function() {
|
|
168
193
|
function memoizedSelector(nextSnapshot) {
|
|
169
194
|
if (!hasMemo) {
|
|
@@ -198,8 +223,8 @@ var require_with_selector_development = __commonJS({
|
|
|
198
223
|
},
|
|
199
224
|
[getSnapshot, getServerSnapshot, selector, isEqual]
|
|
200
225
|
);
|
|
201
|
-
var value =
|
|
202
|
-
|
|
226
|
+
var value = useSyncExternalStore4(subscribe, instRef[0], instRef[1]);
|
|
227
|
+
useEffect9(
|
|
203
228
|
function() {
|
|
204
229
|
inst.hasValue = true;
|
|
205
230
|
inst.value = value;
|
|
@@ -227,7 +252,7 @@ var require_with_selector = __commonJS({
|
|
|
227
252
|
});
|
|
228
253
|
|
|
229
254
|
// src/rich-input/BackgroundTasksPill.tsx
|
|
230
|
-
import { useMemo
|
|
255
|
+
import { useMemo, useState } from "react";
|
|
231
256
|
|
|
232
257
|
// src/chat/runtime/background-task-dismissals.ts
|
|
233
258
|
import { useSyncExternalStore } from "react";
|
|
@@ -264,330 +289,6 @@ function useDismissedBackgroundTasks(sessionId) {
|
|
|
264
289
|
);
|
|
265
290
|
}
|
|
266
291
|
|
|
267
|
-
// src/rich-input/services.tsx
|
|
268
|
-
import { useMemo, useRef as useRef2 } from "react";
|
|
269
|
-
|
|
270
|
-
// src/chat/runtime/input-services.tsx
|
|
271
|
-
import { createContext, useContext } from "react";
|
|
272
|
-
import { jsx } from "react/jsx-runtime";
|
|
273
|
-
function parseModelReasoningLevels(value) {
|
|
274
|
-
if (!value) return {};
|
|
275
|
-
try {
|
|
276
|
-
const parsed = JSON.parse(value);
|
|
277
|
-
if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) return {};
|
|
278
|
-
return Object.fromEntries(
|
|
279
|
-
Object.entries(parsed).filter(
|
|
280
|
-
(entry) => Boolean(entry[0]) && typeof entry[1] === "string" && Boolean(entry[1])
|
|
281
|
-
)
|
|
282
|
-
);
|
|
283
|
-
} catch {
|
|
284
|
-
return {};
|
|
285
|
-
}
|
|
286
|
-
}
|
|
287
|
-
var RichInputServicesContext = createContext({});
|
|
288
|
-
function RichInputServicesProvider({ value, children }) {
|
|
289
|
-
return /* @__PURE__ */ jsx(RichInputServicesContext.Provider, { value, children });
|
|
290
|
-
}
|
|
291
|
-
function useRichInputServices() {
|
|
292
|
-
return useContext(RichInputServicesContext);
|
|
293
|
-
}
|
|
294
|
-
|
|
295
|
-
// src/rich-input/lib/session-data.ts
|
|
296
|
-
import { useEffect as useEffect2, useRef } from "react";
|
|
297
|
-
|
|
298
|
-
// src/rich-input/lib/client-query.ts
|
|
299
|
-
import { useCallback, useEffect, useSyncExternalStore as useSyncExternalStore2 } from "react";
|
|
300
|
-
var EMPTY = { data: void 0, error: null, isLoading: false, isFetching: false };
|
|
301
|
-
var caches = /* @__PURE__ */ new WeakMap();
|
|
302
|
-
function entryFor(client, key) {
|
|
303
|
-
let cache = caches.get(client);
|
|
304
|
-
if (!cache) {
|
|
305
|
-
const created = /* @__PURE__ */ new Map();
|
|
306
|
-
cache = created;
|
|
307
|
-
caches.set(client, created);
|
|
308
|
-
onInputCachesReset(client, () => {
|
|
309
|
-
for (const [key2, entry2] of created) {
|
|
310
|
-
entry2.request = null;
|
|
311
|
-
entry2.fetchedAt = 0;
|
|
312
|
-
update(entry2, EMPTY);
|
|
313
|
-
const load = loadersFor(client).get(key2);
|
|
314
|
-
if (load && entry2.listeners.size > 0) void fetchClientQuery(client, key2, load, { force: true }).catch(() => {
|
|
315
|
-
});
|
|
316
|
-
}
|
|
317
|
-
});
|
|
318
|
-
}
|
|
319
|
-
let entry = cache.get(key);
|
|
320
|
-
if (!entry) {
|
|
321
|
-
entry = { snapshot: EMPTY, fetchedAt: 0, request: null, listeners: /* @__PURE__ */ new Set() };
|
|
322
|
-
cache.set(key, entry);
|
|
323
|
-
}
|
|
324
|
-
return entry;
|
|
325
|
-
}
|
|
326
|
-
function update(entry, patch) {
|
|
327
|
-
entry.snapshot = { ...entry.snapshot, ...patch };
|
|
328
|
-
for (const listener of [...entry.listeners]) listener();
|
|
329
|
-
}
|
|
330
|
-
function fetchClientQuery(client, key, load, { staleMs = 3e4, force = false } = {}) {
|
|
331
|
-
const entry = entryFor(client, key);
|
|
332
|
-
if (entry.request) return entry.request;
|
|
333
|
-
if (!force && entry.snapshot.data !== void 0 && Date.now() - entry.fetchedAt < staleMs) {
|
|
334
|
-
return Promise.resolve(entry.snapshot.data);
|
|
335
|
-
}
|
|
336
|
-
const request = Promise.resolve().then(() => load(client));
|
|
337
|
-
entry.request = request;
|
|
338
|
-
update(entry, { isFetching: true, isLoading: entry.snapshot.data === void 0 });
|
|
339
|
-
request.then(
|
|
340
|
-
(data) => {
|
|
341
|
-
if (entry.request !== request) return;
|
|
342
|
-
entry.request = null;
|
|
343
|
-
entry.fetchedAt = Date.now();
|
|
344
|
-
update(entry, { data, error: null, isFetching: false, isLoading: false });
|
|
345
|
-
},
|
|
346
|
-
(error) => {
|
|
347
|
-
if (entry.request !== request) return;
|
|
348
|
-
entry.request = null;
|
|
349
|
-
update(entry, { error, isFetching: false, isLoading: false });
|
|
350
|
-
}
|
|
351
|
-
);
|
|
352
|
-
return request;
|
|
353
|
-
}
|
|
354
|
-
function setClientQueryData(client, key, updater) {
|
|
355
|
-
const entry = entryFor(client, key);
|
|
356
|
-
if (entry.snapshot.data === void 0) return;
|
|
357
|
-
update(entry, { data: updater(entry.snapshot.data) });
|
|
358
|
-
}
|
|
359
|
-
function useClientQuery(key, load, { staleMs = 3e4 } = {}) {
|
|
360
|
-
const client = useBladeClient();
|
|
361
|
-
const subscribe = useCallback(
|
|
362
|
-
(listener) => {
|
|
363
|
-
if (!key) return () => {
|
|
364
|
-
};
|
|
365
|
-
const entry = entryFor(client, key);
|
|
366
|
-
entry.listeners.add(listener);
|
|
367
|
-
return () => {
|
|
368
|
-
entry.listeners.delete(listener);
|
|
369
|
-
};
|
|
370
|
-
},
|
|
371
|
-
[client, key]
|
|
372
|
-
);
|
|
373
|
-
const snapshot = useSyncExternalStore2(
|
|
374
|
-
subscribe,
|
|
375
|
-
() => key ? entryFor(client, key).snapshot : EMPTY,
|
|
376
|
-
() => key ? entryFor(client, key).snapshot : EMPTY
|
|
377
|
-
);
|
|
378
|
-
if (key) loadersFor(client).set(key, load);
|
|
379
|
-
useEffect(() => {
|
|
380
|
-
if (!key) return;
|
|
381
|
-
const registered = loadersFor(client).get(key);
|
|
382
|
-
if (registered) void fetchClientQuery(client, key, registered, { staleMs }).catch(() => {
|
|
383
|
-
});
|
|
384
|
-
}, [client, key, staleMs]);
|
|
385
|
-
const refetch = useCallback(async () => {
|
|
386
|
-
if (!key) return void 0;
|
|
387
|
-
const registered = loadersFor(client).get(key);
|
|
388
|
-
if (!registered) return void 0;
|
|
389
|
-
return fetchClientQuery(client, key, registered, { force: true }).catch(() => void 0);
|
|
390
|
-
}, [client, key]);
|
|
391
|
-
return { ...snapshot, refetch };
|
|
392
|
-
}
|
|
393
|
-
var loaderRegistry = /* @__PURE__ */ new WeakMap();
|
|
394
|
-
function loadersFor(client) {
|
|
395
|
-
let loaders = loaderRegistry.get(client);
|
|
396
|
-
if (!loaders) {
|
|
397
|
-
loaders = /* @__PURE__ */ new Map();
|
|
398
|
-
loaderRegistry.set(client, loaders);
|
|
399
|
-
}
|
|
400
|
-
return loaders;
|
|
401
|
-
}
|
|
402
|
-
function refreshClientQuery(client, key) {
|
|
403
|
-
const entry = caches.get(client)?.get(key);
|
|
404
|
-
if (!entry) return;
|
|
405
|
-
entry.fetchedAt = 0;
|
|
406
|
-
const load = loadersFor(client).get(key);
|
|
407
|
-
if (load && entry.listeners.size > 0) void fetchClientQuery(client, key, load, { force: true }).catch(() => {
|
|
408
|
-
});
|
|
409
|
-
}
|
|
410
|
-
|
|
411
|
-
// src/rich-input/lib/session-data.ts
|
|
412
|
-
var sessionPath = (sessionId, rest) => `/api/sessions/${encodeURIComponent(sessionId)}/${rest}`;
|
|
413
|
-
function useRefreshWhenRunEnds(sessionId, keys3) {
|
|
414
|
-
const client = useBladeClient();
|
|
415
|
-
const streaming = useSessionState(sessionId, (state3) => state3.isStreaming);
|
|
416
|
-
const wasStreaming = useRef(streaming);
|
|
417
|
-
useEffect2(() => {
|
|
418
|
-
if (wasStreaming.current && !streaming) {
|
|
419
|
-
for (const key of keys3) refreshClientQuery(client, key);
|
|
420
|
-
}
|
|
421
|
-
wasStreaming.current = streaming;
|
|
422
|
-
});
|
|
423
|
-
}
|
|
424
|
-
function useClientSessionSkills(sessionId) {
|
|
425
|
-
const key = sessionId ? `session-skills:${sessionId}` : null;
|
|
426
|
-
const query = useClientQuery(
|
|
427
|
-
key,
|
|
428
|
-
(client) => client.json("GET", sessionPath(sessionId ?? "", "skills"))
|
|
429
|
-
);
|
|
430
|
-
useRefreshWhenRunEnds(sessionId, key ? [key] : []);
|
|
431
|
-
return { data: query.data, loading: query.isLoading, error: query.error };
|
|
432
|
-
}
|
|
433
|
-
function useClientSkillStats(sessionId) {
|
|
434
|
-
const key = sessionId ? `skill-stats:${sessionId}` : null;
|
|
435
|
-
const query = useClientQuery(key, (client) => client.json("GET", sessionPath(sessionId ?? "", "skill-stats")), {
|
|
436
|
-
staleMs: 3e5
|
|
437
|
-
});
|
|
438
|
-
useRefreshWhenRunEnds(sessionId, key ? [key] : []);
|
|
439
|
-
return { data: query.data, loading: query.isLoading, error: query.error };
|
|
440
|
-
}
|
|
441
|
-
function useClientContextStats(sessionId) {
|
|
442
|
-
const key = sessionId ? `context-stats:${sessionId}` : null;
|
|
443
|
-
const query = useClientQuery(
|
|
444
|
-
key,
|
|
445
|
-
(client) => client.json("GET", sessionPath(sessionId ?? "", "context-stats"))
|
|
446
|
-
);
|
|
447
|
-
useRefreshWhenRunEnds(sessionId, key ? [key] : []);
|
|
448
|
-
return { data: query.data, loading: query.isLoading, error: query.error };
|
|
449
|
-
}
|
|
450
|
-
function useClientBackgroundTasks(sessionId) {
|
|
451
|
-
const client = useBladeClient();
|
|
452
|
-
const key = sessionId ? `background-tasks:${sessionId}` : null;
|
|
453
|
-
const query = useClientQuery(key, (c) => c.sessions.listBackgroundTasks(sessionId ?? ""));
|
|
454
|
-
const session = useSessionHandle(sessionId);
|
|
455
|
-
useEffect2(() => {
|
|
456
|
-
if (!session || !key) return;
|
|
457
|
-
return session.on("backgroundTask", () => refreshClientQuery(client, key));
|
|
458
|
-
}, [client, key, session]);
|
|
459
|
-
return { data: query.data, loading: query.isLoading, error: query.error };
|
|
460
|
-
}
|
|
461
|
-
function refreshClientSessionSkills(client, sessionId) {
|
|
462
|
-
refreshClientQuery(client, `session-skills:${sessionId}`);
|
|
463
|
-
refreshClientQuery(client, `skill-stats:${sessionId}`);
|
|
464
|
-
}
|
|
465
|
-
function useClientSessionModel(sessionId) {
|
|
466
|
-
const key = sessionId ? `session-detail:${sessionId}` : null;
|
|
467
|
-
const query = useClientQuery(key, (client) => client.sessions.getSession(sessionId ?? ""));
|
|
468
|
-
useRefreshWhenRunEnds(sessionId, key ? [key] : []);
|
|
469
|
-
return query.data?.model ?? null;
|
|
470
|
-
}
|
|
471
|
-
|
|
472
|
-
// src/rich-input/model/model-data.ts
|
|
473
|
-
var EMPTY_MODELS = [];
|
|
474
|
-
var EMPTY_IDS = [];
|
|
475
|
-
var CATALOG_KEY = "model-catalog";
|
|
476
|
-
function useClientModelCatalog() {
|
|
477
|
-
const { data, isLoading, isFetching, refetch } = useClientQuery(
|
|
478
|
-
CATALOG_KEY,
|
|
479
|
-
(client) => client.json("GET", "/api/config/models"),
|
|
480
|
-
{ staleMs: 0 }
|
|
481
|
-
);
|
|
482
|
-
return {
|
|
483
|
-
models: data?.models ?? EMPTY_MODELS,
|
|
484
|
-
defaultModel: data?.default ?? "",
|
|
485
|
-
thinkingAvailable: data?.thinkingAvailable ?? false,
|
|
486
|
-
unavailableProviderIds: data?.unavailableProviderIds ?? EMPTY_IDS,
|
|
487
|
-
unavailableModelIds: data?.unavailableModelIds ?? EMPTY_IDS,
|
|
488
|
-
isLoading,
|
|
489
|
-
isFetching,
|
|
490
|
-
refresh: async () => {
|
|
491
|
-
await refetch();
|
|
492
|
-
}
|
|
493
|
-
};
|
|
494
|
-
}
|
|
495
|
-
var PREFERRED_MODEL_KEY = "preferred_model";
|
|
496
|
-
var MODEL_REASONING_LEVELS_KEY = "llm.model_thinking_preferences";
|
|
497
|
-
var PREFERENCES_KEY = "model-preferences";
|
|
498
|
-
function loadPreferences(client) {
|
|
499
|
-
const query = new URLSearchParams();
|
|
500
|
-
query.append("key", PREFERRED_MODEL_KEY);
|
|
501
|
-
query.append("key", MODEL_REASONING_LEVELS_KEY);
|
|
502
|
-
return client.json("GET", `/api/user/preferences?${query.toString()}`).then((response) => response.values ?? {});
|
|
503
|
-
}
|
|
504
|
-
async function writePreference(client, key, value) {
|
|
505
|
-
const previous = await fetchClientQuery(client, PREFERENCES_KEY, loadPreferences, { staleMs: 6e4 }).catch(
|
|
506
|
-
() => ({})
|
|
507
|
-
);
|
|
508
|
-
setClientQueryData(client, PREFERENCES_KEY, (current) => ({ ...current, [key]: value }));
|
|
509
|
-
try {
|
|
510
|
-
await client.json("PUT", `/api/user/preferences/${encodeURIComponent(key)}`, { value });
|
|
511
|
-
} catch {
|
|
512
|
-
setClientQueryData(client, PREFERENCES_KEY, (current) => ({ ...current, [key]: previous[key] ?? null }));
|
|
513
|
-
}
|
|
514
|
-
}
|
|
515
|
-
var EMPTY_LEVELS = {};
|
|
516
|
-
function useClientModelPreferences() {
|
|
517
|
-
const client = useBladeClient();
|
|
518
|
-
const { data } = useClientQuery(PREFERENCES_KEY, loadPreferences, { staleMs: 6e4 });
|
|
519
|
-
const rawLevels = data?.[MODEL_REASONING_LEVELS_KEY] ?? null;
|
|
520
|
-
const reasoningLevels = rawLevels ? parseModelReasoningLevels(rawLevels) : EMPTY_LEVELS;
|
|
521
|
-
return {
|
|
522
|
-
preferredModel: data?.[PREFERRED_MODEL_KEY] ?? null,
|
|
523
|
-
setPreferredModel: (modelId) => void writePreference(client, PREFERRED_MODEL_KEY, modelId),
|
|
524
|
-
reasoningLevels,
|
|
525
|
-
setReasoningLevel: (modelId, level) => {
|
|
526
|
-
if (!modelId) return;
|
|
527
|
-
void writePreference(
|
|
528
|
-
client,
|
|
529
|
-
MODEL_REASONING_LEVELS_KEY,
|
|
530
|
-
JSON.stringify({ ...reasoningLevels, [modelId]: level })
|
|
531
|
-
);
|
|
532
|
-
}
|
|
533
|
-
};
|
|
534
|
-
}
|
|
535
|
-
|
|
536
|
-
// src/rich-input/services.tsx
|
|
537
|
-
function useModelCatalog() {
|
|
538
|
-
const use = useRichInputServices().useModelCatalog ?? useClientModelCatalog;
|
|
539
|
-
return use();
|
|
540
|
-
}
|
|
541
|
-
function useModelPreferences() {
|
|
542
|
-
const use = useRichInputServices().useModelPreferences ?? useClientModelPreferences;
|
|
543
|
-
return use();
|
|
544
|
-
}
|
|
545
|
-
function useSessionConnection(sessionId) {
|
|
546
|
-
const connection = useSessionState(sessionId, (state3) => state3.connection);
|
|
547
|
-
const status = sessionId ? connection : "connected";
|
|
548
|
-
const everConnected = useRef2(false);
|
|
549
|
-
if (status === "connected") everConnected.current = true;
|
|
550
|
-
return { status, reconnectAttempt: 0, hasEverConnected: everConnected.current };
|
|
551
|
-
}
|
|
552
|
-
function useComposerConnectionInfo(sessionId) {
|
|
553
|
-
const use = useRichInputServices().useConnection ?? useSessionConnection;
|
|
554
|
-
return use(sessionId);
|
|
555
|
-
}
|
|
556
|
-
function useComposerConnection(sessionId) {
|
|
557
|
-
return useComposerConnectionInfo(sessionId).status;
|
|
558
|
-
}
|
|
559
|
-
function useSessionSkills(sessionId) {
|
|
560
|
-
const use = useRichInputServices().useSessionSkills ?? useClientSessionSkills;
|
|
561
|
-
return use(sessionId);
|
|
562
|
-
}
|
|
563
|
-
function useSkillStats(sessionId) {
|
|
564
|
-
const use = useRichInputServices().useSkillStats ?? useClientSkillStats;
|
|
565
|
-
return use(sessionId);
|
|
566
|
-
}
|
|
567
|
-
function useContextStats(sessionId) {
|
|
568
|
-
const use = useRichInputServices().useContextStats ?? useClientContextStats;
|
|
569
|
-
return use(sessionId);
|
|
570
|
-
}
|
|
571
|
-
function useBackgroundTaskList(sessionId) {
|
|
572
|
-
const use = useRichInputServices().useBackgroundTasks ?? useClientBackgroundTasks;
|
|
573
|
-
return use(sessionId);
|
|
574
|
-
}
|
|
575
|
-
function useClientSessionDataInvalidation() {
|
|
576
|
-
const client = useBladeClient();
|
|
577
|
-
return useMemo(
|
|
578
|
-
() => ({
|
|
579
|
-
filesUploaded: (_sessionId) => {
|
|
580
|
-
},
|
|
581
|
-
pluginsChanged: (sessionId) => refreshClientSessionSkills(client, sessionId)
|
|
582
|
-
}),
|
|
583
|
-
[client]
|
|
584
|
-
);
|
|
585
|
-
}
|
|
586
|
-
function useSessionDataInvalidation() {
|
|
587
|
-
const use = useRichInputServices().useSessionDataInvalidation ?? useClientSessionDataInvalidation;
|
|
588
|
-
return use();
|
|
589
|
-
}
|
|
590
|
-
|
|
591
292
|
// src/rich-input/lib/background-tasks-view.ts
|
|
592
293
|
var LIVE_STATUSES = /* @__PURE__ */ new Set(["starting", "running", "cancelling"]);
|
|
593
294
|
var ATTENTION_STATUSES = /* @__PURE__ */ new Set(["failed", "lost"]);
|
|
@@ -647,7 +348,7 @@ function formatStartedAt(value, now = /* @__PURE__ */ new Date()) {
|
|
|
647
348
|
}
|
|
648
349
|
|
|
649
350
|
// src/rich-input/BackgroundTasksPill.tsx
|
|
650
|
-
import { Fragment, jsx
|
|
351
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
651
352
|
var NO_TASKS = [];
|
|
652
353
|
function TaskCard({
|
|
653
354
|
task,
|
|
@@ -657,8 +358,8 @@ function TaskCard({
|
|
|
657
358
|
}) {
|
|
658
359
|
return /* @__PURE__ */ jsxs("div", { className: "rounded-lg border border-[hsl(var(--border))] p-2", children: [
|
|
659
360
|
/* @__PURE__ */ jsxs("div", { className: "flex items-start justify-between gap-2", children: [
|
|
660
|
-
/* @__PURE__ */
|
|
661
|
-
/* @__PURE__ */
|
|
361
|
+
/* @__PURE__ */ jsx("div", { className: "min-w-0 break-words text-[hsl(var(--foreground))]", children: task.description || task.command }),
|
|
362
|
+
/* @__PURE__ */ jsx(
|
|
662
363
|
"span",
|
|
663
364
|
{
|
|
664
365
|
className: cn(
|
|
@@ -669,10 +370,10 @@ function TaskCard({
|
|
|
669
370
|
}
|
|
670
371
|
)
|
|
671
372
|
] }),
|
|
672
|
-
task.status === "lost" ? /* @__PURE__ */
|
|
373
|
+
task.status === "lost" ? /* @__PURE__ */ jsx("div", { className: "mt-1 text-[11px] text-[hsl(var(--swf-warning))]", children: "\u5E73\u53F0\u91CD\u542F\u540E\u8DDF\u4E22\u4E86\uFF0C\u7A0B\u5E8F\u53EF\u80FD\u4ECD\u5728\u8FD0\u884C" }) : null,
|
|
673
374
|
/* @__PURE__ */ jsxs("div", { className: "mt-1 flex items-center gap-1.5 text-[10px] text-[hsl(var(--muted-foreground))]/60", children: [
|
|
674
|
-
/* @__PURE__ */
|
|
675
|
-
/* @__PURE__ */
|
|
375
|
+
/* @__PURE__ */ jsx("span", { children: formatStartedAt(task.started_at) }),
|
|
376
|
+
/* @__PURE__ */ jsx("span", { className: "truncate font-mono", children: task.id })
|
|
676
377
|
] }),
|
|
677
378
|
/* @__PURE__ */ jsxs("div", { className: "mt-2 flex items-center gap-1.5", children: [
|
|
678
379
|
/* @__PURE__ */ jsxs(
|
|
@@ -682,7 +383,7 @@ function TaskCard({
|
|
|
682
383
|
onClick: onOpenLog,
|
|
683
384
|
className: "inline-flex h-6 items-center gap-1 rounded-md border border-[hsl(var(--border))] px-2 text-[11px] hover:bg-[hsl(var(--accent))]",
|
|
684
385
|
children: [
|
|
685
|
-
/* @__PURE__ */
|
|
386
|
+
/* @__PURE__ */ jsx(FileText, { size: 12 }),
|
|
686
387
|
"\u65E5\u5FD7"
|
|
687
388
|
]
|
|
688
389
|
}
|
|
@@ -694,7 +395,7 @@ function TaskCard({
|
|
|
694
395
|
onClick: onStop,
|
|
695
396
|
className: "inline-flex h-6 items-center gap-1 rounded-[6px] border border-[hsl(var(--swf-danger)/0.35)] px-2 text-[11px] text-[hsl(var(--swf-danger))] hover:bg-[hsl(var(--swf-danger-soft))]",
|
|
696
397
|
children: [
|
|
697
|
-
/* @__PURE__ */
|
|
398
|
+
/* @__PURE__ */ jsx(Square, { size: 10 }),
|
|
698
399
|
"\u505C\u6B62"
|
|
699
400
|
]
|
|
700
401
|
}
|
|
@@ -706,7 +407,7 @@ function TaskCard({
|
|
|
706
407
|
onClick: onDismiss,
|
|
707
408
|
className: "inline-flex h-6 items-center gap-1 rounded-md border border-[hsl(var(--border))] px-2 text-[11px] hover:bg-[hsl(var(--accent))]",
|
|
708
409
|
children: [
|
|
709
|
-
/* @__PURE__ */
|
|
410
|
+
/* @__PURE__ */ jsx(EyeOff, { size: 12 }),
|
|
710
411
|
"\u9690\u85CF"
|
|
711
412
|
]
|
|
712
413
|
}
|
|
@@ -723,7 +424,7 @@ function BackgroundTasksPill({ sessionId }) {
|
|
|
723
424
|
const [historyOverride, setHistoryOverride] = useState(null);
|
|
724
425
|
const [logTask, setLogTask] = useState(null);
|
|
725
426
|
const [logDialogOpen, setLogDialogOpen] = useState(false);
|
|
726
|
-
const { activeTasks, historyTasks, runningCount, attentionCount } =
|
|
427
|
+
const { activeTasks, historyTasks, runningCount, attentionCount } = useMemo(
|
|
727
428
|
() => splitTasks(tasks, dismissed),
|
|
728
429
|
[tasks, dismissed]
|
|
729
430
|
);
|
|
@@ -769,7 +470,7 @@ function BackgroundTasksPill({ sessionId }) {
|
|
|
769
470
|
closePanel();
|
|
770
471
|
};
|
|
771
472
|
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
772
|
-
/* @__PURE__ */
|
|
473
|
+
/* @__PURE__ */ jsx(
|
|
773
474
|
Dialog,
|
|
774
475
|
{
|
|
775
476
|
open: logDialogOpen,
|
|
@@ -784,10 +485,10 @@ function BackgroundTasksPill({ sessionId }) {
|
|
|
784
485
|
children: [
|
|
785
486
|
/* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between gap-3 border-b border-[hsl(var(--border))] px-4 py-3", children: [
|
|
786
487
|
/* @__PURE__ */ jsxs("div", { className: "min-w-0", children: [
|
|
787
|
-
/* @__PURE__ */
|
|
788
|
-
/* @__PURE__ */
|
|
488
|
+
/* @__PURE__ */ jsx(DialogTitle, { className: "truncate text-sm font-medium text-[hsl(var(--foreground))]", children: logTask?.title }),
|
|
489
|
+
/* @__PURE__ */ jsx("div", { className: "text-xs text-[hsl(var(--muted-foreground))]", children: "\u540E\u53F0\u4EFB\u52A1\u65E5\u5FD7" })
|
|
789
490
|
] }),
|
|
790
|
-
/* @__PURE__ */
|
|
491
|
+
/* @__PURE__ */ jsx(
|
|
791
492
|
"button",
|
|
792
493
|
{
|
|
793
494
|
type: "button",
|
|
@@ -797,7 +498,7 @@ function BackgroundTasksPill({ sessionId }) {
|
|
|
797
498
|
}
|
|
798
499
|
)
|
|
799
500
|
] }),
|
|
800
|
-
/* @__PURE__ */
|
|
501
|
+
/* @__PURE__ */ jsx("pre", { className: "min-h-64 flex-1 overflow-auto whitespace-pre-wrap p-4 font-mono text-xs leading-5 text-[hsl(var(--foreground))]", children: logTask?.loading ? "\u52A0\u8F7D\u4E2D..." : logTask?.error || logTask?.output })
|
|
801
502
|
]
|
|
802
503
|
}
|
|
803
504
|
)
|
|
@@ -819,8 +520,8 @@ function BackgroundTasksPill({ sessionId }) {
|
|
|
819
520
|
title: summary,
|
|
820
521
|
className: "relative flex h-9 w-9 shrink-0 items-center justify-center rounded-full text-[hsl(var(--muted-foreground))] transition-colors hover:bg-[hsl(var(--accent))] hover:text-[hsl(var(--foreground))]",
|
|
821
522
|
children: [
|
|
822
|
-
/* @__PURE__ */
|
|
823
|
-
runningCount > 0 ? /* @__PURE__ */
|
|
523
|
+
/* @__PURE__ */ jsx(Terminal, { size: 16 }),
|
|
524
|
+
runningCount > 0 ? /* @__PURE__ */ jsx("span", { className: "absolute right-1 top-1 flex h-3.5 min-w-3.5 items-center justify-center rounded-full bg-[hsl(var(--muted))] px-1 text-[9px] font-medium leading-none text-[hsl(var(--muted-foreground))]", children: runningCount }) : attentionCount > 0 ? /* @__PURE__ */ jsx(
|
|
824
525
|
"span",
|
|
825
526
|
{
|
|
826
527
|
"data-attention-dot": "true",
|
|
@@ -830,8 +531,8 @@ function BackgroundTasksPill({ sessionId }) {
|
|
|
830
531
|
]
|
|
831
532
|
}
|
|
832
533
|
),
|
|
833
|
-
open ? /* @__PURE__ */
|
|
834
|
-
activeTasks.map((task) => /* @__PURE__ */
|
|
534
|
+
open ? /* @__PURE__ */ jsx("div", { className: "absolute bottom-full left-0 z-40 mb-2 w-[min(24rem,calc(100vw-2rem))] rounded-xl border border-[hsl(var(--border))] bg-[hsl(var(--popover))] p-2 text-xs text-[hsl(var(--popover-foreground))] shadow-[var(--swf-shadow-overlay)] before:absolute before:inset-x-0 before:top-full before:h-2 before:content-['']", children: /* @__PURE__ */ jsxs("div", { className: "max-h-72 space-y-2 overflow-y-auto", children: [
|
|
535
|
+
activeTasks.map((task) => /* @__PURE__ */ jsx(
|
|
835
536
|
TaskCard,
|
|
836
537
|
{
|
|
837
538
|
task,
|
|
@@ -856,7 +557,7 @@ function BackgroundTasksPill({ sessionId }) {
|
|
|
856
557
|
"aria-expanded": historyOpen,
|
|
857
558
|
className: "flex w-full items-center gap-1 px-1 py-1 text-[11px] text-[hsl(var(--muted-foreground))] transition-colors hover:text-[hsl(var(--foreground))]",
|
|
858
559
|
children: [
|
|
859
|
-
/* @__PURE__ */
|
|
560
|
+
/* @__PURE__ */ jsx(
|
|
860
561
|
ChevronDown,
|
|
861
562
|
{
|
|
862
563
|
size: 12,
|
|
@@ -869,7 +570,7 @@ function BackgroundTasksPill({ sessionId }) {
|
|
|
869
570
|
]
|
|
870
571
|
}
|
|
871
572
|
),
|
|
872
|
-
historyOpen ? /* @__PURE__ */
|
|
573
|
+
historyOpen ? /* @__PURE__ */ jsx("div", { className: "mt-2 space-y-2", children: historyTasks.map((task) => /* @__PURE__ */ jsx(
|
|
873
574
|
TaskCard,
|
|
874
575
|
{
|
|
875
576
|
task,
|
|
@@ -12247,7 +11948,7 @@ function resolveSelection(view, doc3, parsedSel) {
|
|
|
12247
11948
|
}
|
|
12248
11949
|
function isMarkChange(cur, prev) {
|
|
12249
11950
|
let curMarks = cur.firstChild.marks, prevMarks = prev.firstChild.marks;
|
|
12250
|
-
let added = curMarks, removed = prevMarks, type, mark,
|
|
11951
|
+
let added = curMarks, removed = prevMarks, type, mark, update;
|
|
12251
11952
|
for (let i = 0; i < prevMarks.length; i++)
|
|
12252
11953
|
added = prevMarks[i].removeFromSet(added);
|
|
12253
11954
|
for (let i = 0; i < curMarks.length; i++)
|
|
@@ -12255,17 +11956,17 @@ function isMarkChange(cur, prev) {
|
|
|
12255
11956
|
if (added.length == 1 && removed.length == 0) {
|
|
12256
11957
|
mark = added[0];
|
|
12257
11958
|
type = "add";
|
|
12258
|
-
|
|
11959
|
+
update = (node) => node.mark(mark.addToSet(node.marks));
|
|
12259
11960
|
} else if (added.length == 0 && removed.length == 1) {
|
|
12260
11961
|
mark = removed[0];
|
|
12261
11962
|
type = "remove";
|
|
12262
|
-
|
|
11963
|
+
update = (node) => node.mark(mark.removeFromSet(node.marks));
|
|
12263
11964
|
} else {
|
|
12264
11965
|
return null;
|
|
12265
11966
|
}
|
|
12266
11967
|
let updated = [];
|
|
12267
11968
|
for (let i = 0; i < prev.childCount; i++)
|
|
12268
|
-
updated.push(
|
|
11969
|
+
updated.push(update(prev.child(i)));
|
|
12269
11970
|
if (Fragment2.from(updated).eq(cur))
|
|
12270
11971
|
return { mark, type };
|
|
12271
11972
|
}
|
|
@@ -19119,7 +18820,7 @@ var TopicAssetMention = index_default.extend({
|
|
|
19119
18820
|
|
|
19120
18821
|
// src/chat/runtime/composer-channels.ts
|
|
19121
18822
|
import { normalizeTopicAssetRefs as normalizeTopicAssetRefs2 } from "@blade-hq/agent-client";
|
|
19122
|
-
import { useSyncExternalStore as
|
|
18823
|
+
import { useSyncExternalStore as useSyncExternalStore2 } from "react";
|
|
19123
18824
|
function buildSignalId() {
|
|
19124
18825
|
if (typeof crypto !== "undefined" && typeof crypto.randomUUID === "function") {
|
|
19125
18826
|
return crypto.randomUUID();
|
|
@@ -19141,8 +18842,8 @@ var state2 = {
|
|
|
19141
18842
|
rewindDrafts: {}
|
|
19142
18843
|
};
|
|
19143
18844
|
var listeners2 = /* @__PURE__ */ new Set();
|
|
19144
|
-
function setState(
|
|
19145
|
-
const next =
|
|
18845
|
+
function setState(update) {
|
|
18846
|
+
const next = update(state2);
|
|
19146
18847
|
if (next === state2) return;
|
|
19147
18848
|
state2 = next;
|
|
19148
18849
|
for (const listener of [...listeners2]) listener();
|
|
@@ -19246,7 +18947,7 @@ var composerChannels = {
|
|
|
19246
18947
|
}
|
|
19247
18948
|
};
|
|
19248
18949
|
function useComposerChannels(selector) {
|
|
19249
|
-
return
|
|
18950
|
+
return useSyncExternalStore2(
|
|
19250
18951
|
composerChannels.subscribe,
|
|
19251
18952
|
() => selector(state2),
|
|
19252
18953
|
() => selector(state2)
|
|
@@ -19268,7 +18969,7 @@ function queueTopicAssetReference(sessionId, ref) {
|
|
|
19268
18969
|
}
|
|
19269
18970
|
|
|
19270
18971
|
// src/rich-input/use-dismiss-skill-suggestions-on-mode-change.ts
|
|
19271
|
-
import { useEffect
|
|
18972
|
+
import { useEffect, useRef } from "react";
|
|
19272
18973
|
|
|
19273
18974
|
// src/rich-input/extensions/skill-mention.ts
|
|
19274
18975
|
var skillMentionSuggestionKey = new PluginKey("skillMentionSuggestion");
|
|
@@ -19352,8 +19053,8 @@ var SkillMention = index_default.extend({
|
|
|
19352
19053
|
// src/rich-input/use-dismiss-skill-suggestions-on-mode-change.ts
|
|
19353
19054
|
function useDismissSkillSuggestionsOnModeChange(editor) {
|
|
19354
19055
|
const renderMode = useChatRenderMode();
|
|
19355
|
-
const previousRef =
|
|
19356
|
-
|
|
19056
|
+
const previousRef = useRef(renderMode);
|
|
19057
|
+
useEffect(() => {
|
|
19357
19058
|
if (previousRef.current === renderMode) return;
|
|
19358
19059
|
previousRef.current = renderMode;
|
|
19359
19060
|
if (editor && !editor.isDestroyed && skillMentionSuggestionKey.getState(editor.state)?.active) {
|
|
@@ -19364,12 +19065,12 @@ function useDismissSkillSuggestionsOnModeChange(editor) {
|
|
|
19364
19065
|
|
|
19365
19066
|
// ../../node_modules/.pnpm/@tiptap+react@3.20.4_@floating-ui+dom@1.7.6_@tiptap+core@3.20.4_@tiptap+pm@3.20.4__@tip_1ce9f35538141630e675758ebf46eb2f/node_modules/@tiptap/react/dist/index.js
|
|
19366
19067
|
var import_shim = __toESM(require_shim(), 1);
|
|
19367
|
-
import { createContext
|
|
19068
|
+
import { createContext, useContext, useMemo as useMemo2 } from "react";
|
|
19368
19069
|
import React, { forwardRef } from "react";
|
|
19369
19070
|
import ReactDOM from "react-dom";
|
|
19370
|
-
import { Fragment as Fragment3, jsx as
|
|
19071
|
+
import { Fragment as Fragment3, jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
19371
19072
|
var import_shim2 = __toESM(require_shim(), 1);
|
|
19372
|
-
import { useDebugValue as useDebugValue2, useEffect as
|
|
19073
|
+
import { useDebugValue as useDebugValue2, useEffect as useEffect2, useRef as useRef2, useState as useState2 } from "react";
|
|
19373
19074
|
|
|
19374
19075
|
// ../../node_modules/.pnpm/fast-equals@5.4.0/node_modules/fast-equals/dist/es/index.mjs
|
|
19375
19076
|
var { getOwnPropertyNames, getOwnPropertySymbols } = Object;
|
|
@@ -19811,10 +19512,10 @@ function createCustomEqual(options = {}) {
|
|
|
19811
19512
|
|
|
19812
19513
|
// ../../node_modules/.pnpm/@tiptap+react@3.20.4_@floating-ui+dom@1.7.6_@tiptap+core@3.20.4_@tiptap+pm@3.20.4__@tip_1ce9f35538141630e675758ebf46eb2f/node_modules/@tiptap/react/dist/index.js
|
|
19813
19514
|
var import_with_selector = __toESM(require_with_selector(), 1);
|
|
19814
|
-
import { useDebugValue, useEffect as
|
|
19515
|
+
import { useDebugValue, useEffect as useEffect3, useLayoutEffect, useState as useState3 } from "react";
|
|
19815
19516
|
import { jsx as jsx22, jsxs as jsxs22 } from "react/jsx-runtime";
|
|
19816
|
-
import { createContext as
|
|
19817
|
-
import { jsx as
|
|
19517
|
+
import { createContext as createContext2, createElement, useContext as useContext2 } from "react";
|
|
19518
|
+
import { jsx as jsx3 } from "react/jsx-runtime";
|
|
19818
19519
|
import React3 from "react";
|
|
19819
19520
|
import { jsx as jsx4 } from "react/jsx-runtime";
|
|
19820
19521
|
import React4 from "react";
|
|
@@ -19844,7 +19545,7 @@ var Portals = ({ contentComponent }) => {
|
|
|
19844
19545
|
contentComponent.getSnapshot,
|
|
19845
19546
|
contentComponent.getServerSnapshot
|
|
19846
19547
|
);
|
|
19847
|
-
return /* @__PURE__ */
|
|
19548
|
+
return /* @__PURE__ */ jsx2(Fragment3, { children: Object.values(renderers) });
|
|
19848
19549
|
};
|
|
19849
19550
|
function getInstance() {
|
|
19850
19551
|
const subscribers = /* @__PURE__ */ new Set();
|
|
@@ -19965,8 +19666,8 @@ var PureEditorContent = class extends React.Component {
|
|
|
19965
19666
|
render() {
|
|
19966
19667
|
const { editor, innerRef, ...rest } = this.props;
|
|
19967
19668
|
return /* @__PURE__ */ jsxs2(Fragment3, { children: [
|
|
19968
|
-
/* @__PURE__ */
|
|
19969
|
-
(editor == null ? void 0 : editor.contentComponent) && /* @__PURE__ */
|
|
19669
|
+
/* @__PURE__ */ jsx2("div", { ref: mergeRefs(innerRef, this.editorContentRef), ...rest }),
|
|
19670
|
+
(editor == null ? void 0 : editor.contentComponent) && /* @__PURE__ */ jsx2(Portals, { contentComponent: editor.contentComponent })
|
|
19970
19671
|
] });
|
|
19971
19672
|
}
|
|
19972
19673
|
};
|
|
@@ -19983,7 +19684,7 @@ var EditorContentWithKey = forwardRef(
|
|
|
19983
19684
|
}
|
|
19984
19685
|
);
|
|
19985
19686
|
var EditorContent = React.memo(EditorContentWithKey);
|
|
19986
|
-
var useIsomorphicLayoutEffect = typeof window !== "undefined" ? useLayoutEffect :
|
|
19687
|
+
var useIsomorphicLayoutEffect = typeof window !== "undefined" ? useLayoutEffect : useEffect3;
|
|
19987
19688
|
var EditorStateManager = class {
|
|
19988
19689
|
constructor(initialEditor) {
|
|
19989
19690
|
this.transactionNumber = 0;
|
|
@@ -20291,7 +19992,7 @@ var EditorInstanceManager = class _EditorInstanceManager {
|
|
|
20291
19992
|
}
|
|
20292
19993
|
};
|
|
20293
19994
|
function useEditor(options = {}, deps = []) {
|
|
20294
|
-
const mostRecentOptions =
|
|
19995
|
+
const mostRecentOptions = useRef2(options);
|
|
20295
19996
|
mostRecentOptions.current = options;
|
|
20296
19997
|
const [instanceManager] = useState2(() => new EditorInstanceManager(mostRecentOptions));
|
|
20297
19998
|
const editor = (0, import_shim2.useSyncExternalStore)(
|
|
@@ -20300,7 +20001,7 @@ function useEditor(options = {}, deps = []) {
|
|
|
20300
20001
|
instanceManager.getServerSnapshot
|
|
20301
20002
|
);
|
|
20302
20003
|
useDebugValue2(editor);
|
|
20303
|
-
|
|
20004
|
+
useEffect2(instanceManager.onRender(deps));
|
|
20304
20005
|
useEditorState({
|
|
20305
20006
|
editor,
|
|
20306
20007
|
selector: ({ transactionNumber }) => {
|
|
@@ -20315,18 +20016,18 @@ function useEditor(options = {}, deps = []) {
|
|
|
20315
20016
|
});
|
|
20316
20017
|
return editor;
|
|
20317
20018
|
}
|
|
20318
|
-
var EditorContext =
|
|
20019
|
+
var EditorContext = createContext({
|
|
20319
20020
|
editor: null
|
|
20320
20021
|
});
|
|
20321
20022
|
var EditorConsumer = EditorContext.Consumer;
|
|
20322
|
-
var ReactNodeViewContext =
|
|
20023
|
+
var ReactNodeViewContext = createContext2({
|
|
20323
20024
|
onDragStart: () => {
|
|
20324
20025
|
},
|
|
20325
20026
|
nodeViewContentChildren: void 0,
|
|
20326
20027
|
nodeViewContentRef: () => {
|
|
20327
20028
|
}
|
|
20328
20029
|
});
|
|
20329
|
-
var useReactNodeView = () =>
|
|
20030
|
+
var useReactNodeView = () => useContext2(ReactNodeViewContext);
|
|
20330
20031
|
var NodeViewWrapper = React3.forwardRef((props, ref) => {
|
|
20331
20032
|
const { onDragStart } = useReactNodeView();
|
|
20332
20033
|
const Tag = props.as || "div";
|
|
@@ -25389,8 +25090,8 @@ var index_default2 = StarterKit;
|
|
|
25389
25090
|
|
|
25390
25091
|
// src/rich-input/ChatInput.tsx
|
|
25391
25092
|
import {
|
|
25392
|
-
useEffect as
|
|
25393
|
-
useRef as
|
|
25093
|
+
useEffect as useEffect8,
|
|
25094
|
+
useRef as useRef7,
|
|
25394
25095
|
useState as useState11
|
|
25395
25096
|
} from "react";
|
|
25396
25097
|
import { createRoot } from "react-dom/client";
|
|
@@ -25405,7 +25106,7 @@ function skillDisplayName(skill) {
|
|
|
25405
25106
|
}
|
|
25406
25107
|
|
|
25407
25108
|
// src/rich-input/voice/use-tiptap-voice-input.ts
|
|
25408
|
-
import { useCallback
|
|
25109
|
+
import { useCallback, useEffect as useEffect4, useRef as useRef3 } from "react";
|
|
25409
25110
|
var IDLE_VOICE = {
|
|
25410
25111
|
status: "idle",
|
|
25411
25112
|
error: null,
|
|
@@ -25421,8 +25122,8 @@ function useNoVoiceInput() {
|
|
|
25421
25122
|
function useTiptapVoiceInput(options) {
|
|
25422
25123
|
const { editorRef, workletUrl, onError } = options;
|
|
25423
25124
|
const useVoiceInput2 = options.useVoiceInput ?? useNoVoiceInput;
|
|
25424
|
-
const partialRangeRef =
|
|
25425
|
-
const lastPartialLenRef =
|
|
25125
|
+
const partialRangeRef = useRef3(null);
|
|
25126
|
+
const lastPartialLenRef = useRef3(0);
|
|
25426
25127
|
const handlePartial = useEffectEvent((text) => {
|
|
25427
25128
|
const ed = editorRef.current;
|
|
25428
25129
|
if (!ed) return;
|
|
@@ -25472,18 +25173,18 @@ function useTiptapVoiceInput(options) {
|
|
|
25472
25173
|
onError: handleError
|
|
25473
25174
|
});
|
|
25474
25175
|
const isRecording = voice.status === "recording";
|
|
25475
|
-
|
|
25176
|
+
useEffect4(() => {
|
|
25476
25177
|
const ed = editorRef.current;
|
|
25477
25178
|
if (!ed) return;
|
|
25478
25179
|
ed.setEditable(!isRecording);
|
|
25479
25180
|
}, [isRecording, editorRef]);
|
|
25480
|
-
|
|
25181
|
+
useEffect4(() => {
|
|
25481
25182
|
if (voice.status === "idle" || voice.status === "error") {
|
|
25482
25183
|
partialRangeRef.current = null;
|
|
25483
25184
|
lastPartialLenRef.current = 0;
|
|
25484
25185
|
}
|
|
25485
25186
|
}, [voice.status]);
|
|
25486
|
-
const toggle =
|
|
25187
|
+
const toggle = useCallback(() => {
|
|
25487
25188
|
if (voice.status === "recording" || voice.status === "starting") {
|
|
25488
25189
|
void voice.stop();
|
|
25489
25190
|
} else {
|
|
@@ -25540,7 +25241,7 @@ function VoiceWaveform({ level, color = "currentColor", size = 16 }) {
|
|
|
25540
25241
|
}
|
|
25541
25242
|
|
|
25542
25243
|
// src/rich-input/model/resolve-model.ts
|
|
25543
|
-
import { useMemo as
|
|
25244
|
+
import { useMemo as useMemo3 } from "react";
|
|
25544
25245
|
var MODEL_LOADING_SEND_HINT = "\u6B63\u5728\u52A0\u8F7D\u6A21\u578B\u914D\u7F6E\uFF0C\u8BF7\u7A0D\u540E\u518D\u53D1\u9001";
|
|
25545
25246
|
function gateSendWhileModelLoading(isModelLoading, hasContent) {
|
|
25546
25247
|
if (!isModelLoading) return { blocked: false };
|
|
@@ -25609,7 +25310,7 @@ function resolveModelChoice({
|
|
|
25609
25310
|
function useResolvedModel(activeSessionModel) {
|
|
25610
25311
|
const { models, defaultModel, thinkingAvailable, isLoading, unavailableProviderIds, unavailableModelIds } = useModelCatalog();
|
|
25611
25312
|
const { preferredModel } = useModelPreferences();
|
|
25612
|
-
const resolved =
|
|
25313
|
+
const resolved = useMemo3(() => {
|
|
25613
25314
|
return resolveModelChoice({
|
|
25614
25315
|
activeSessionModel,
|
|
25615
25316
|
preferredModel,
|
|
@@ -25643,13 +25344,13 @@ function useReasoningLevelPreference(modelId) {
|
|
|
25643
25344
|
}
|
|
25644
25345
|
|
|
25645
25346
|
// src/rich-input/model/use-composer-model.ts
|
|
25646
|
-
import { useEffect as
|
|
25347
|
+
import { useEffect as useEffect5, useRef as useRef4, useState as useState4 } from "react";
|
|
25647
25348
|
function useInjectedSessionModel(sessionId) {
|
|
25648
25349
|
return useChatSessionDetail(sessionId)?.model ?? null;
|
|
25649
25350
|
}
|
|
25650
25351
|
function useComposerModel(activeSessionId) {
|
|
25651
25352
|
const [newSessionModelSelection, setNewSessionModelSelection] = useState4(null);
|
|
25652
|
-
const newSessionModelSelectionRef =
|
|
25353
|
+
const newSessionModelSelectionRef = useRef4(null);
|
|
25653
25354
|
const { setPreferredModel } = useModelPreferences();
|
|
25654
25355
|
const { models: modelCatalog } = useModelCatalog();
|
|
25655
25356
|
const useSessionModel = useChatEnvironment().useSessionDetail ? useInjectedSessionModel : useClientSessionModel;
|
|
@@ -25668,18 +25369,18 @@ function useComposerModel(activeSessionId) {
|
|
|
25668
25369
|
isLoading
|
|
25669
25370
|
} = useResolvedModel(resolveComposerModel(activeSessionId, activeSessionModel, explicitModelSelection));
|
|
25670
25371
|
const { reasoningLevelPreference, setReasoningLevelPreference } = useReasoningLevelPreference(selectedModel);
|
|
25671
|
-
|
|
25372
|
+
useEffect5(() => {
|
|
25672
25373
|
if (!activeSessionId || !newSessionModelSelectionRef.current) return;
|
|
25673
25374
|
newSessionModelSelectionRef.current = null;
|
|
25674
25375
|
setNewSessionModelSelection(null);
|
|
25675
25376
|
}, [activeSessionId]);
|
|
25676
|
-
|
|
25377
|
+
useEffect5(() => {
|
|
25677
25378
|
if (!activeSessionId || !sharedModelDraft || isLoading || modelCatalog.length === 0) return;
|
|
25678
25379
|
if (!modelCatalog.some((model) => model.id === sharedModelDraft)) {
|
|
25679
25380
|
composerChannels.clearModelDraft(activeSessionId);
|
|
25680
25381
|
}
|
|
25681
25382
|
}, [activeSessionId, sharedModelDraft, isLoading, modelCatalog]);
|
|
25682
|
-
|
|
25383
|
+
useEffect5(() => {
|
|
25683
25384
|
if (!activeSessionId || sharedModelDraft !== activeSessionModel) return;
|
|
25684
25385
|
composerChannels.clearModelDraft(activeSessionId);
|
|
25685
25386
|
}, [activeSessionId, activeSessionModel, sharedModelDraft]);
|
|
@@ -25759,7 +25460,7 @@ function PopoverContent({
|
|
|
25759
25460
|
}
|
|
25760
25461
|
|
|
25761
25462
|
// src/rich-input/ModelSelector.tsx
|
|
25762
|
-
import { useMemo as
|
|
25463
|
+
import { useMemo as useMemo4, useState as useState5 } from "react";
|
|
25763
25464
|
import { jsx as jsx12, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
25764
25465
|
var inputModalityLabels = {
|
|
25765
25466
|
text: "\u6587\u672C",
|
|
@@ -25801,7 +25502,7 @@ function ModelSelector({
|
|
|
25801
25502
|
}
|
|
25802
25503
|
void refresh();
|
|
25803
25504
|
}
|
|
25804
|
-
const filteredModels =
|
|
25505
|
+
const filteredModels = useMemo4(() => {
|
|
25805
25506
|
const normalized = query.trim().toLowerCase();
|
|
25806
25507
|
if (!normalized) return models;
|
|
25807
25508
|
return models.filter(
|
|
@@ -25934,7 +25635,7 @@ function ModelSelector({
|
|
|
25934
25635
|
}
|
|
25935
25636
|
|
|
25936
25637
|
// src/rich-input/SkillStatusBar.tsx
|
|
25937
|
-
import { useMemo as
|
|
25638
|
+
import { useMemo as useMemo5 } from "react";
|
|
25938
25639
|
|
|
25939
25640
|
// src/chat/lib/skill-visibility.ts
|
|
25940
25641
|
function visibleSkills(skills, mode) {
|
|
@@ -26112,7 +25813,7 @@ function SkillStatusBar({
|
|
|
26112
25813
|
const { status: connectionStatus, reconnectAttempt, hasEverConnected } = useComposerConnectionInfo(sessionId);
|
|
26113
25814
|
const statsReady = !loading && !error;
|
|
26114
25815
|
const skillStoreConnected = statsReady && skillStats.remote_connected;
|
|
26115
|
-
const connectionMeta =
|
|
25816
|
+
const connectionMeta = useMemo5(
|
|
26116
25817
|
() => getConnectionMeta(
|
|
26117
25818
|
connectionStatus,
|
|
26118
25819
|
reconnectAttempt,
|
|
@@ -26132,7 +25833,7 @@ function SkillStatusBar({
|
|
|
26132
25833
|
text: skillStoreConnected ? `\u5DF2\u5B89\u88C5 ${skillStats.installed_skill_count} \u4E2A\u6280\u80FD` : "\u5C1A\u672A\u767B\u5F55\u6280\u80FD\u5546\u5E97"
|
|
26133
25834
|
}
|
|
26134
25835
|
].filter((item) => item.key !== "total" || skillStats.remote_configured);
|
|
26135
|
-
const tokenSummary =
|
|
25836
|
+
const tokenSummary = useMemo5(() => {
|
|
26136
25837
|
if (mode !== "developer") return null;
|
|
26137
25838
|
if (contextStatsLoading || contextStatsError || !contextStats) {
|
|
26138
25839
|
return {
|
|
@@ -26223,7 +25924,7 @@ function SkillStatusBar({
|
|
|
26223
25924
|
import { useState as useState6 } from "react";
|
|
26224
25925
|
|
|
26225
25926
|
// src/rich-input/lib/skill-suggestions.ts
|
|
26226
|
-
var
|
|
25927
|
+
var sessionPath = (sessionId, rest) => `/api/sessions/${encodeURIComponent(sessionId)}/${rest}`;
|
|
26227
25928
|
function toItem(skill) {
|
|
26228
25929
|
return {
|
|
26229
25930
|
type: "skill",
|
|
@@ -26240,12 +25941,12 @@ var cachesByClient = /* @__PURE__ */ new WeakMap();
|
|
|
26240
25941
|
function cachesFor(client) {
|
|
26241
25942
|
const existing = cachesByClient.get(client);
|
|
26242
25943
|
if (existing) return existing;
|
|
26243
|
-
const
|
|
26244
|
-
cachesByClient.set(client,
|
|
25944
|
+
const caches = { requests: /* @__PURE__ */ new Map(), searchSeq: 0 };
|
|
25945
|
+
cachesByClient.set(client, caches);
|
|
26245
25946
|
onInputCachesReset(client, () => {
|
|
26246
|
-
if (cachesByClient.get(client) ===
|
|
25947
|
+
if (cachesByClient.get(client) === caches) cachesByClient.delete(client);
|
|
26247
25948
|
});
|
|
26248
|
-
return
|
|
25949
|
+
return caches;
|
|
26249
25950
|
}
|
|
26250
25951
|
function cached(client, key, load) {
|
|
26251
25952
|
const { requests } = cachesFor(client);
|
|
@@ -26267,7 +25968,7 @@ async function loadSessionSkills({ client, sessionId, renderMode }) {
|
|
|
26267
25968
|
const skills = await cached(
|
|
26268
25969
|
client,
|
|
26269
25970
|
`session-skills:${sessionId}`,
|
|
26270
|
-
() => client.json("GET",
|
|
25971
|
+
() => client.json("GET", sessionPath(sessionId, "skills"))
|
|
26271
25972
|
);
|
|
26272
25973
|
return visibleSkills(skills, renderMode);
|
|
26273
25974
|
} catch {
|
|
@@ -26318,14 +26019,14 @@ async function getSkillSuggestions(query, options) {
|
|
|
26318
26019
|
if (!trimmed) {
|
|
26319
26020
|
return getDefaultSuggestions(options);
|
|
26320
26021
|
}
|
|
26321
|
-
const
|
|
26322
|
-
const seq = ++
|
|
26022
|
+
const caches = cachesFor(options.client);
|
|
26023
|
+
const seq = ++caches.searchSeq;
|
|
26323
26024
|
const q = trimmed.toLowerCase();
|
|
26324
26025
|
const sessionMatches = (await loadSessionSkills(options)).filter(
|
|
26325
26026
|
(skill) => skill.skill_id.toLowerCase().includes(q) || skill.description.toLowerCase().includes(q)
|
|
26326
26027
|
).map(toItem);
|
|
26327
26028
|
await new Promise((resolve) => setTimeout(resolve, SEARCH_DEBOUNCE_MS));
|
|
26328
|
-
if (seq !==
|
|
26029
|
+
if (seq !== caches.searchSeq) return sessionMatches;
|
|
26329
26030
|
try {
|
|
26330
26031
|
const seen = new Set(sessionMatches.map((item) => item.skillId));
|
|
26331
26032
|
const { client, renderMode } = options;
|
|
@@ -26421,7 +26122,7 @@ function ConnectButton({
|
|
|
26421
26122
|
}
|
|
26422
26123
|
|
|
26423
26124
|
// src/rich-input/voice/use-voice-input.ts
|
|
26424
|
-
import { useCallback as
|
|
26125
|
+
import { useCallback as useCallback2, useEffect as useEffect6, useRef as useRef5, useState as useState7 } from "react";
|
|
26425
26126
|
|
|
26426
26127
|
// src/rich-input/voice/voice-input-support.ts
|
|
26427
26128
|
function isIpHost(hostname) {
|
|
@@ -26469,25 +26170,25 @@ function matchesRequest(data, requestId) {
|
|
|
26469
26170
|
}
|
|
26470
26171
|
function useVoiceInput(options) {
|
|
26471
26172
|
const client = useBladeClient();
|
|
26472
|
-
const clientRef =
|
|
26173
|
+
const clientRef = useRef5(client);
|
|
26473
26174
|
clientRef.current = client;
|
|
26474
|
-
const getSocket =
|
|
26175
|
+
const getSocket = useCallback2(() => clientRef.current.socket(), []);
|
|
26475
26176
|
const [status, setStatus] = useState7("idle");
|
|
26476
26177
|
const [error, setError] = useState7(null);
|
|
26477
26178
|
const [level, setLevel] = useState7(0);
|
|
26478
|
-
const sessionRef =
|
|
26479
|
-
const stoppingRef =
|
|
26480
|
-
const startAbortRef =
|
|
26481
|
-
const optionsRef =
|
|
26179
|
+
const sessionRef = useRef5(null);
|
|
26180
|
+
const stoppingRef = useRef5(false);
|
|
26181
|
+
const startAbortRef = useRef5(null);
|
|
26182
|
+
const optionsRef = useRef5(options);
|
|
26482
26183
|
optionsRef.current = options;
|
|
26483
|
-
const reportError =
|
|
26184
|
+
const reportError = useCallback2((err) => {
|
|
26484
26185
|
const payload = typeof err === "string" ? { title: err } : err;
|
|
26485
26186
|
setError(payload.title);
|
|
26486
26187
|
setStatus("error");
|
|
26487
26188
|
setLevel(0);
|
|
26488
26189
|
optionsRef.current.onError?.(payload);
|
|
26489
26190
|
}, []);
|
|
26490
|
-
const disposeSession =
|
|
26191
|
+
const disposeSession = useCallback2((s) => {
|
|
26491
26192
|
if (s.disposed) return;
|
|
26492
26193
|
s.disposed = true;
|
|
26493
26194
|
const socket = getSocket();
|
|
@@ -26512,7 +26213,7 @@ function useVoiceInput(options) {
|
|
|
26512
26213
|
} catch {
|
|
26513
26214
|
}
|
|
26514
26215
|
}, [getSocket]);
|
|
26515
|
-
const stop =
|
|
26216
|
+
const stop = useCallback2(async () => {
|
|
26516
26217
|
startAbortRef.current?.abort();
|
|
26517
26218
|
const s = sessionRef.current;
|
|
26518
26219
|
if (!s || stoppingRef.current) {
|
|
@@ -26559,7 +26260,7 @@ function useVoiceInput(options) {
|
|
|
26559
26260
|
setLevel(0);
|
|
26560
26261
|
setStatus((prev) => prev === "error" ? "error" : "idle");
|
|
26561
26262
|
}, [disposeSession, getSocket]);
|
|
26562
|
-
const start =
|
|
26263
|
+
const start = useCallback2(async () => {
|
|
26563
26264
|
if (sessionRef.current || startAbortRef.current && !startAbortRef.current.signal.aborted || stoppingRef.current) {
|
|
26564
26265
|
return;
|
|
26565
26266
|
}
|
|
@@ -26733,7 +26434,7 @@ function useVoiceInput(options) {
|
|
|
26733
26434
|
if (startAbortRef.current === abort) startAbortRef.current = null;
|
|
26734
26435
|
}
|
|
26735
26436
|
}, [reportError, disposeSession, getSocket]);
|
|
26736
|
-
|
|
26437
|
+
useEffect6(() => {
|
|
26737
26438
|
return () => {
|
|
26738
26439
|
startAbortRef.current?.abort();
|
|
26739
26440
|
const s = sessionRef.current;
|
|
@@ -26751,7 +26452,7 @@ function useVoiceInput(options) {
|
|
|
26751
26452
|
}
|
|
26752
26453
|
|
|
26753
26454
|
// src/rich-input/use-reference-candidates.ts
|
|
26754
|
-
import { useLayoutEffect as useLayoutEffect2, useRef as
|
|
26455
|
+
import { useLayoutEffect as useLayoutEffect2, useRef as useRef6 } from "react";
|
|
26755
26456
|
|
|
26756
26457
|
// src/rich-input/lib/reference-candidates.ts
|
|
26757
26458
|
function createReferenceCandidateController(getScope, sources, timeoutMs = 300) {
|
|
@@ -26849,7 +26550,7 @@ function useReferenceCandidates(getScope, sources) {
|
|
|
26849
26550
|
const plugins = useEffectEvent((query) => sources.plugins?.(query) ?? Promise.resolve([]));
|
|
26850
26551
|
const topics = useEffectEvent(sources.topics);
|
|
26851
26552
|
const files = useEffectEvent(sources.files);
|
|
26852
|
-
const ref =
|
|
26553
|
+
const ref = useRef6(null);
|
|
26853
26554
|
if (!ref.current) ref.current = createReferenceCandidateController(readScope, { plugins, topics, files });
|
|
26854
26555
|
const controller = ref.current;
|
|
26855
26556
|
const [client, identity, session, topic] = getScope();
|
|
@@ -26859,7 +26560,7 @@ function useReferenceCandidates(getScope, sources) {
|
|
|
26859
26560
|
}
|
|
26860
26561
|
|
|
26861
26562
|
// src/rich-input/use-input-history.ts
|
|
26862
|
-
import { useCallback as
|
|
26563
|
+
import { useCallback as useCallback3, useEffect as useEffect7, useMemo as useMemo6, useState as useState8 } from "react";
|
|
26863
26564
|
|
|
26864
26565
|
// src/rich-input/lib/input-history-document.ts
|
|
26865
26566
|
import { normalizeTopicAssetRefs as normalizeTopicAssetRefs3 } from "@blade-hq/agent-client";
|
|
@@ -26949,17 +26650,17 @@ function readEntries(storageKey) {
|
|
|
26949
26650
|
}
|
|
26950
26651
|
function useInputHistory(sessionId, client) {
|
|
26951
26652
|
const [generation, setGeneration] = useState8(getInputHistoryGeneration);
|
|
26952
|
-
const storageKey =
|
|
26653
|
+
const storageKey = useMemo6(() => getStorageKey(sessionId), [sessionId]);
|
|
26953
26654
|
const [entries, setEntries] = useState8([]);
|
|
26954
26655
|
const [cursor, setCursor] = useState8(null);
|
|
26955
26656
|
const [draft, setDraft] = useState8(emptyEntry);
|
|
26956
|
-
|
|
26657
|
+
useEffect7(() => {
|
|
26957
26658
|
setGeneration(getInputHistoryGeneration());
|
|
26958
26659
|
setEntries(readEntries(storageKey));
|
|
26959
26660
|
setCursor(null);
|
|
26960
26661
|
setDraft(emptyEntry());
|
|
26961
26662
|
}, [storageKey, client]);
|
|
26962
|
-
|
|
26663
|
+
useEffect7(() => {
|
|
26963
26664
|
if (!client) return;
|
|
26964
26665
|
return onInputCachesReset(client, () => {
|
|
26965
26666
|
setGeneration(getInputHistoryGeneration());
|
|
@@ -26968,7 +26669,7 @@ function useInputHistory(sessionId, client) {
|
|
|
26968
26669
|
setDraft(emptyEntry());
|
|
26969
26670
|
});
|
|
26970
26671
|
}, [client]);
|
|
26971
|
-
const persistEntries =
|
|
26672
|
+
const persistEntries = useCallback3(
|
|
26972
26673
|
(nextEntries) => {
|
|
26973
26674
|
if (generation !== getInputHistoryGeneration() || typeof window === "undefined" || !storageKey) {
|
|
26974
26675
|
return;
|
|
@@ -26980,7 +26681,7 @@ function useInputHistory(sessionId, client) {
|
|
|
26980
26681
|
},
|
|
26981
26682
|
[storageKey, generation]
|
|
26982
26683
|
);
|
|
26983
|
-
const addEntry =
|
|
26684
|
+
const addEntry = useCallback3(
|
|
26984
26685
|
(value) => {
|
|
26985
26686
|
if (generation !== getInputHistoryGeneration()) return;
|
|
26986
26687
|
const document2 = copyEditorDocument(value);
|
|
@@ -26996,7 +26697,7 @@ function useInputHistory(sessionId, client) {
|
|
|
26996
26697
|
},
|
|
26997
26698
|
[persistEntries, generation]
|
|
26998
26699
|
);
|
|
26999
|
-
const navigateUp =
|
|
26700
|
+
const navigateUp = useCallback3(
|
|
27000
26701
|
(currentDraft = emptyEntry().document) => {
|
|
27001
26702
|
if (generation !== getInputHistoryGeneration() || entries.length === 0) {
|
|
27002
26703
|
return null;
|
|
@@ -27010,7 +26711,7 @@ function useInputHistory(sessionId, client) {
|
|
|
27010
26711
|
},
|
|
27011
26712
|
[cursor, entries, generation]
|
|
27012
26713
|
);
|
|
27013
|
-
const navigateDown =
|
|
26714
|
+
const navigateDown = useCallback3(() => {
|
|
27014
26715
|
if (generation !== getInputHistoryGeneration() || cursor == null) {
|
|
27015
26716
|
return null;
|
|
27016
26717
|
}
|
|
@@ -27092,7 +26793,7 @@ function getUnsupportedImageFiles(files, supportsImage) {
|
|
|
27092
26793
|
}
|
|
27093
26794
|
|
|
27094
26795
|
// src/rich-input/FileCompletionMenu.tsx
|
|
27095
|
-
import { forwardRef as forwardRef2, useCallback as
|
|
26796
|
+
import { forwardRef as forwardRef2, useCallback as useCallback4, useImperativeHandle, useMemo as useMemo7, useState as useState9 } from "react";
|
|
27096
26797
|
|
|
27097
26798
|
// src/rich-input/lib/user-home.ts
|
|
27098
26799
|
var CACHE_TTL_MS2 = 15e3;
|
|
@@ -27100,12 +26801,12 @@ var cachesByClient2 = /* @__PURE__ */ new WeakMap();
|
|
|
27100
26801
|
function cachesFor2(client) {
|
|
27101
26802
|
const existing = cachesByClient2.get(client);
|
|
27102
26803
|
if (existing) return existing;
|
|
27103
|
-
const
|
|
27104
|
-
cachesByClient2.set(client,
|
|
26804
|
+
const caches = { dirs: /* @__PURE__ */ new Map() };
|
|
26805
|
+
cachesByClient2.set(client, caches);
|
|
27105
26806
|
onInputCachesReset(client, () => {
|
|
27106
|
-
if (cachesByClient2.get(client) ===
|
|
26807
|
+
if (cachesByClient2.get(client) === caches) cachesByClient2.delete(client);
|
|
27107
26808
|
});
|
|
27108
|
-
return
|
|
26809
|
+
return caches;
|
|
27109
26810
|
}
|
|
27110
26811
|
function listUserHomeDir(client, dirPath) {
|
|
27111
26812
|
const { dirs } = cachesFor2(client);
|
|
@@ -27248,11 +26949,11 @@ async function getUserHomeSuggestionItems(client, query) {
|
|
|
27248
26949
|
var FileCompletionMenu = forwardRef2(
|
|
27249
26950
|
function FileCompletionMenu2({ command: command2, editor, items, onExit, query, range, scope = "session", sessionId: sessionIdProp }, ref) {
|
|
27250
26951
|
const sessionId = sessionIdProp ?? null;
|
|
27251
|
-
const { dirPath, filterQuery } =
|
|
26952
|
+
const { dirPath, filterQuery } = useMemo7(
|
|
27252
26953
|
() => scope === "userHome" ? { dirPath: query, filterQuery: "" } : parseSuggestionQuery(query),
|
|
27253
26954
|
[query, scope]
|
|
27254
26955
|
);
|
|
27255
|
-
const { pluginItems, pluginError, fileItems, topicItems, topicError } =
|
|
26956
|
+
const { pluginItems, pluginError, fileItems, topicItems, topicError } = useMemo7(() => {
|
|
27256
26957
|
let pluginError2;
|
|
27257
26958
|
const pluginItems2 = [];
|
|
27258
26959
|
const files = [];
|
|
@@ -27290,13 +26991,13 @@ var FileCompletionMenu = forwardRef2(
|
|
|
27290
26991
|
);
|
|
27291
26992
|
var FileCompletionMenuContent = forwardRef2(function FileCompletionMenuContent2({ command: command2, editor, filterQuery, items, pluginItems, pluginError, topicItems, topicError, onExit, range, scope, sessionId }, ref) {
|
|
27292
26993
|
const [rawSelectedIndex, setRawSelectedIndex] = useState9(0);
|
|
27293
|
-
const filteredEntries =
|
|
27294
|
-
const navigableItems =
|
|
26994
|
+
const filteredEntries = useMemo7(() => filterEntries(items, filterQuery), [filterQuery, items]);
|
|
26995
|
+
const navigableItems = useMemo7(
|
|
27295
26996
|
() => [...pluginItems, ...topicItems, ...filteredEntries],
|
|
27296
26997
|
[filteredEntries, pluginItems, topicItems]
|
|
27297
26998
|
);
|
|
27298
26999
|
const selectedIndex = navigableItems.length === 0 ? 0 : Math.min(rawSelectedIndex, navigableItems.length - 1);
|
|
27299
|
-
const handleSelect =
|
|
27000
|
+
const handleSelect = useCallback4(
|
|
27300
27001
|
(entry) => {
|
|
27301
27002
|
if (isPluginSuggestionItem(entry) || isTopicAssetSuggestionItem(entry)) {
|
|
27302
27003
|
command2(entry);
|
|
@@ -27421,13 +27122,13 @@ var FileCompletionMenuContent = forwardRef2(function FileCompletionMenuContent2(
|
|
|
27421
27122
|
});
|
|
27422
27123
|
|
|
27423
27124
|
// src/rich-input/SkillCompletionMenu.tsx
|
|
27424
|
-
import { forwardRef as forwardRef3, useCallback as
|
|
27125
|
+
import { forwardRef as forwardRef3, useCallback as useCallback5, useImperativeHandle as useImperativeHandle2, useState as useState10 } from "react";
|
|
27425
27126
|
import { jsx as jsx17, jsxs as jsxs8 } from "react/jsx-runtime";
|
|
27426
27127
|
var SkillCompletionMenu = forwardRef3(
|
|
27427
27128
|
function SkillCompletionMenu2({ command: command2, items }, ref) {
|
|
27428
27129
|
const [rawSelectedIndex, setRawSelectedIndex] = useState10(0);
|
|
27429
27130
|
const selectedIndex = items.length === 0 ? 0 : Math.min(rawSelectedIndex, items.length - 1);
|
|
27430
|
-
const handleSelect =
|
|
27131
|
+
const handleSelect = useCallback5(
|
|
27431
27132
|
(item) => {
|
|
27432
27133
|
command2(item);
|
|
27433
27134
|
},
|
|
@@ -28366,11 +28067,11 @@ function ChatInput({
|
|
|
28366
28067
|
externalDraft?.setValue(value);
|
|
28367
28068
|
});
|
|
28368
28069
|
const externalDraftValue = externalDraft?.value;
|
|
28369
|
-
const inputRef =
|
|
28070
|
+
const inputRef = useRef7(input);
|
|
28370
28071
|
inputRef.current = input;
|
|
28371
|
-
const appliedInitialDraftKeyRef =
|
|
28372
|
-
const appliedInitialDraftRef =
|
|
28373
|
-
|
|
28072
|
+
const appliedInitialDraftKeyRef = useRef7(null);
|
|
28073
|
+
const appliedInitialDraftRef = useRef7(null);
|
|
28074
|
+
useEffect8(() => {
|
|
28374
28075
|
if (externalDraftValue == null) return;
|
|
28375
28076
|
if (inputRef.current === externalDraftValue) return;
|
|
28376
28077
|
if (editorRef.current) {
|
|
@@ -28378,7 +28079,7 @@ function ChatInput({
|
|
|
28378
28079
|
}
|
|
28379
28080
|
setInputInternal(externalDraftValue);
|
|
28380
28081
|
}, [externalDraftValue]);
|
|
28381
|
-
|
|
28082
|
+
useEffect8(() => {
|
|
28382
28083
|
const key = initialDraftKey ?? initialDraft ?? "";
|
|
28383
28084
|
if (!initialDraft || !key || appliedInitialDraftKeyRef.current === key) return;
|
|
28384
28085
|
if (inputRef.current === initialDraft) appliedInitialDraftRef.current = initialDraft;
|
|
@@ -28404,9 +28105,9 @@ function ChatInput({
|
|
|
28404
28105
|
}
|
|
28405
28106
|
);
|
|
28406
28107
|
const externalAttachmentsValue = externalAttachments?.value;
|
|
28407
|
-
const composerAttachmentsRef =
|
|
28108
|
+
const composerAttachmentsRef = useRef7(composerAttachments);
|
|
28408
28109
|
composerAttachmentsRef.current = composerAttachments;
|
|
28409
|
-
|
|
28110
|
+
useEffect8(() => {
|
|
28410
28111
|
if (externalAttachmentsValue == null) return;
|
|
28411
28112
|
if (composerAttachmentsRef.current === externalAttachmentsValue) return;
|
|
28412
28113
|
setComposerAttachmentsInternal(externalAttachmentsValue);
|
|
@@ -28420,16 +28121,16 @@ function ChatInput({
|
|
|
28420
28121
|
const invalidation = useSessionDataInvalidation();
|
|
28421
28122
|
const SkillStatusBarComponent = SkillStatusBarOverride ?? SkillStatusBar;
|
|
28422
28123
|
const [actionMenuOpen, setActionMenuOpen] = useState11(false);
|
|
28423
|
-
const actionMenuOpenRef =
|
|
28424
|
-
|
|
28124
|
+
const actionMenuOpenRef = useRef7(false);
|
|
28125
|
+
useEffect8(() => {
|
|
28425
28126
|
actionMenuOpenRef.current = actionMenuOpen;
|
|
28426
28127
|
}, [actionMenuOpen]);
|
|
28427
28128
|
const [connectMenuOpen, setConnectMenuOpen] = useState11(false);
|
|
28428
|
-
const fileInputRef =
|
|
28429
|
-
const folderInputRef =
|
|
28430
|
-
const editorRef =
|
|
28431
|
-
const lastEscapeAtRef =
|
|
28432
|
-
const localImageUrlsRef =
|
|
28129
|
+
const fileInputRef = useRef7(null);
|
|
28130
|
+
const folderInputRef = useRef7(null);
|
|
28131
|
+
const editorRef = useRef7(null);
|
|
28132
|
+
const lastEscapeAtRef = useRef7(0);
|
|
28133
|
+
const localImageUrlsRef = useRef7(/* @__PURE__ */ new Map());
|
|
28433
28134
|
const currentChatSessionId = useCurrentChatSessionId();
|
|
28434
28135
|
const activeSessionId = sessionIdProp ?? currentChatSessionId;
|
|
28435
28136
|
const currentSession = useChatSessionDetail(activeSessionId);
|
|
@@ -28809,13 +28510,13 @@ function ChatInput({
|
|
|
28809
28510
|
}
|
|
28810
28511
|
});
|
|
28811
28512
|
useDismissSkillSuggestionsOnModeChange(editor);
|
|
28812
|
-
|
|
28513
|
+
useEffect8(() => {
|
|
28813
28514
|
const dom = editor?.view.dom;
|
|
28814
28515
|
if (!dom) return;
|
|
28815
28516
|
dom.setAttribute("aria-label", resolvedInputLabel);
|
|
28816
28517
|
dom.setAttribute("data-blade-input-label", resolvedInputLabel);
|
|
28817
28518
|
}, [editor, resolvedInputLabel]);
|
|
28818
|
-
|
|
28519
|
+
useEffect8(() => {
|
|
28819
28520
|
if (!editor || !activeSessionId || rewindDraft == null) {
|
|
28820
28521
|
return;
|
|
28821
28522
|
}
|
|
@@ -28826,9 +28527,9 @@ function ChatInput({
|
|
|
28826
28527
|
editor.commands.focus("end");
|
|
28827
28528
|
composerChannels.setRewindDraft(activeSessionId, null);
|
|
28828
28529
|
}, [activeSessionId, editor, rewindDraft]);
|
|
28829
|
-
const submittingRef =
|
|
28530
|
+
const submittingRef = useRef7(false);
|
|
28830
28531
|
const [isSubmitting, setIsSubmitting] = useState11(false);
|
|
28831
|
-
|
|
28532
|
+
useEffect8(() => {
|
|
28832
28533
|
let changed = false;
|
|
28833
28534
|
const nextLocalIds = /* @__PURE__ */ new Set();
|
|
28834
28535
|
for (const attachment of composerAttachments) {
|
|
@@ -28853,7 +28554,7 @@ function ChatInput({
|
|
|
28853
28554
|
setLocalImageUrls(Object.fromEntries(localImageUrlsRef.current));
|
|
28854
28555
|
}
|
|
28855
28556
|
}, [composerAttachments]);
|
|
28856
|
-
|
|
28557
|
+
useEffect8(() => {
|
|
28857
28558
|
return () => {
|
|
28858
28559
|
for (const url of localImageUrlsRef.current.values()) {
|
|
28859
28560
|
URL.revokeObjectURL(url);
|
|
@@ -28862,8 +28563,8 @@ function ChatInput({
|
|
|
28862
28563
|
};
|
|
28863
28564
|
}, []);
|
|
28864
28565
|
const sessionHandle = useSessionHandle(activeSessionId);
|
|
28865
|
-
const restoredPluginSelection =
|
|
28866
|
-
|
|
28566
|
+
const restoredPluginSelection = useRef7(null);
|
|
28567
|
+
useEffect8(() => {
|
|
28867
28568
|
if (!sessionHandle || !activeSessionId || !editor) return;
|
|
28868
28569
|
const restore = () => {
|
|
28869
28570
|
if (restoredPluginSelection.current === activeSessionId) return;
|
|
@@ -28878,7 +28579,7 @@ function ChatInput({
|
|
|
28878
28579
|
restore();
|
|
28879
28580
|
return sessionHandle.subscribe(restore);
|
|
28880
28581
|
}, [sessionHandle, activeSessionId, editor]);
|
|
28881
|
-
|
|
28582
|
+
useEffect8(() => {
|
|
28882
28583
|
if (!sessionHandle || !activeSessionId) return;
|
|
28883
28584
|
const offInsert = sessionHandle.on("insertTextRequested", ({ text }) => {
|
|
28884
28585
|
const separate = /^\n/.test(text);
|
|
@@ -28913,7 +28614,7 @@ ${append2.text}` : append2.text;
|
|
|
28913
28614
|
editor.chain().focus("end").insertContent(text).run();
|
|
28914
28615
|
});
|
|
28915
28616
|
const editorReady = editor != null;
|
|
28916
|
-
|
|
28617
|
+
useEffect8(() => {
|
|
28917
28618
|
if (!editorReady || !draftAppends?.length) {
|
|
28918
28619
|
return;
|
|
28919
28620
|
}
|
|
@@ -28929,7 +28630,7 @@ ${append2.text}` : append2.text;
|
|
|
28929
28630
|
}
|
|
28930
28631
|
void stableHandleSubmit();
|
|
28931
28632
|
});
|
|
28932
|
-
|
|
28633
|
+
useEffect8(() => {
|
|
28933
28634
|
if (!sendRequests?.length) {
|
|
28934
28635
|
return;
|
|
28935
28636
|
}
|
|
@@ -28944,10 +28645,10 @@ ${append2.text}` : append2.text;
|
|
|
28944
28645
|
});
|
|
28945
28646
|
const { isRecording, level: voiceLevel } = voice;
|
|
28946
28647
|
const isVoiceStarting = voice.status === "starting";
|
|
28947
|
-
const voiceStopRef =
|
|
28648
|
+
const voiceStopRef = useRef7(voice.stop);
|
|
28948
28649
|
voiceStopRef.current = voice.stop;
|
|
28949
|
-
const prevSessionIdRef =
|
|
28950
|
-
|
|
28650
|
+
const prevSessionIdRef = useRef7(activeSessionId);
|
|
28651
|
+
useEffect8(() => {
|
|
28951
28652
|
if (prevSessionIdRef.current !== activeSessionId) {
|
|
28952
28653
|
prevSessionIdRef.current = activeSessionId;
|
|
28953
28654
|
if (isRecording) {
|
|
@@ -29181,7 +28882,7 @@ ${append2.text}` : append2.text;
|
|
|
29181
28882
|
setIsSubmitting(false);
|
|
29182
28883
|
}
|
|
29183
28884
|
};
|
|
29184
|
-
|
|
28885
|
+
useEffect8(() => {
|
|
29185
28886
|
if (!editor || !activeSessionId || !queuedTopicRefs?.length) return;
|
|
29186
28887
|
const existing = collectTopicAssetMentions(editor.getJSON());
|
|
29187
28888
|
const refs = composerChannels.consumeTopicAssetReferences(activeSessionId).filter((ref) => !existing.some((item) => item.topic_id === ref.topic_id && item.path === ref.path));
|
|
@@ -29201,9 +28902,9 @@ ${append2.text}` : append2.text;
|
|
|
29201
28902
|
const reduceMotion = typeof window !== "undefined" && window.matchMedia?.("(prefers-reduced-motion: reduce)").matches;
|
|
29202
28903
|
return reduceMotion ? fullPlaceholder : "";
|
|
29203
28904
|
});
|
|
29204
|
-
const typewriterPlayedRef =
|
|
29205
|
-
const isTypingRef =
|
|
29206
|
-
|
|
28905
|
+
const typewriterPlayedRef = useRef7(false);
|
|
28906
|
+
const isTypingRef = useRef7(false);
|
|
28907
|
+
useEffect8(() => {
|
|
29207
28908
|
if (!typewriterPlaceholder || typewriterPlayedRef.current) return;
|
|
29208
28909
|
typewriterPlayedRef.current = true;
|
|
29209
28910
|
const reduceMotion = typeof window !== "undefined" && window.matchMedia?.("(prefers-reduced-motion: reduce)").matches;
|
|
@@ -29224,7 +28925,7 @@ ${append2.text}` : append2.text;
|
|
|
29224
28925
|
isTypingRef.current = false;
|
|
29225
28926
|
};
|
|
29226
28927
|
}, [typewriterPlaceholder]);
|
|
29227
|
-
|
|
28928
|
+
useEffect8(() => {
|
|
29228
28929
|
if (isTypingRef.current) return;
|
|
29229
28930
|
setTypedPlaceholder(fullPlaceholder);
|
|
29230
28931
|
}, [fullPlaceholder]);
|