@trops/dash-core 0.1.552 → 0.1.553
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/index.esm.js +50 -0
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +50 -0
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -63060,6 +63060,56 @@ function ChatCore(_ref) {
|
|
|
63060
63060
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
63061
63061
|
}, [initialMessage, mainApi, messages, isCliBackend, cliAvailable, isLoading]);
|
|
63062
63062
|
|
|
63063
|
+
// Slice 19H — external "send this message" hook.
|
|
63064
|
+
//
|
|
63065
|
+
// Some parent components (the widget builder modal's "Send error to AI"
|
|
63066
|
+
// banner, the Console tab's per-error Send-to-AI button) need to push
|
|
63067
|
+
// a user message into THIS chat conversation without rendering the
|
|
63068
|
+
// input themselves. They dispatch a window CustomEvent named
|
|
63069
|
+
// `dash:chat-core-send` with `detail: { persistKey, content, hidden? }`.
|
|
63070
|
+
//
|
|
63071
|
+
// Each ChatCore instance only reacts to events targeting its own
|
|
63072
|
+
// persistKey OR sessionKey OR uuid — so the dashboard's AssistantPanel
|
|
63073
|
+
// and the widget builder's chat don't cross-talk.
|
|
63074
|
+
//
|
|
63075
|
+
// Why a CustomEvent (not localStorage poll, not ref): the prior
|
|
63076
|
+
// approach was for parent code to write to localStorage directly,
|
|
63077
|
+
// hoping ChatCore would notice. ChatCore reads localStorage only at
|
|
63078
|
+
// mount — so externally-written messages were silently dropped.
|
|
63079
|
+
// CustomEvent is one-way + synchronous + zero-cost when nobody fires
|
|
63080
|
+
// it, and stays consistent with the existing
|
|
63081
|
+
// `dash:open-settings-create-provider` / `dash:provider-installed` /
|
|
63082
|
+
// `dash:open-widget-builder` event bus used elsewhere in the app.
|
|
63083
|
+
React.useEffect(function () {
|
|
63084
|
+
var myKey = persistKey || sessionKey || uuid || null;
|
|
63085
|
+
if (!myKey) return;
|
|
63086
|
+
if (typeof window === "undefined") return;
|
|
63087
|
+
var handler = function handler(event) {
|
|
63088
|
+
var detail = event && event.detail;
|
|
63089
|
+
if (!detail) return;
|
|
63090
|
+
var targetKey = detail.persistKey || detail.sessionKey || detail.uuid || null;
|
|
63091
|
+
if (targetKey !== myKey) return;
|
|
63092
|
+
var content = detail.content;
|
|
63093
|
+
if (typeof content !== "string" || content.length === 0) return;
|
|
63094
|
+
// hidden defaults to false — the user typically WANTS to see the
|
|
63095
|
+
// error-fix request in the chat history so it's clear what was
|
|
63096
|
+
// sent and what the AI responded to.
|
|
63097
|
+
var hidden = detail.hidden === true;
|
|
63098
|
+
try {
|
|
63099
|
+
handleSend(content, {
|
|
63100
|
+
hidden: hidden
|
|
63101
|
+
});
|
|
63102
|
+
} catch (e) {
|
|
63103
|
+
// Sending may fail (no API key, no CLI). Swallow — the parent
|
|
63104
|
+
// can't recover beyond surfacing its own error state.
|
|
63105
|
+
}
|
|
63106
|
+
};
|
|
63107
|
+
window.addEventListener("dash:chat-core-send", handler);
|
|
63108
|
+
return function () {
|
|
63109
|
+
return window.removeEventListener("dash:chat-core-send", handler);
|
|
63110
|
+
};
|
|
63111
|
+
}, [persistKey, sessionKey, uuid, handleSend]);
|
|
63112
|
+
|
|
63063
63113
|
// New chat
|
|
63064
63114
|
var handleNewChat = function handleNewChat() {
|
|
63065
63115
|
var _mainApi$llm3;
|