@e-llm-studio/instant-learning 1.3.17 → 1.3.19
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/cjs/features/IL-OTJ/_components/ChatComponents/ChatComponent.js +61 -10
- package/dist/cjs/features/IL-OTJ/_components/ChatComponents/ChatComponent.js.map +1 -1
- package/dist/cjs/features/IL-OTJ/_components/ChatComponents/ChatComponent.module.css.js +2 -2
- package/dist/cjs/features/IL-OTJ/_components/CriticalGaps.js +31 -15
- package/dist/cjs/features/IL-OTJ/_components/CriticalGaps.js.map +1 -1
- package/dist/cjs/features/IL-OTJ/_components/MarkdownComponents/MarkdownElements.js +3 -1
- package/dist/cjs/features/IL-OTJ/_components/MarkdownComponents/MarkdownElements.js.map +1 -1
- package/dist/cjs/features/IL-OTJ/_components/MessageRendering/MessageRendering.js +31 -8
- package/dist/cjs/features/IL-OTJ/_components/MessageRendering/MessageRendering.js.map +1 -1
- package/dist/cjs/features/IL-OTJ/helpers/rhsFieldAttention.js +19 -0
- package/dist/cjs/features/IL-OTJ/helpers/rhsFieldAttention.js.map +1 -0
- package/dist/cjs/features/LearningManagement/components/InstantLearningModal.js +2 -0
- package/dist/cjs/features/LearningManagement/components/InstantLearningModal.js.map +1 -1
- package/dist/cjs/features/LearningManagement/components/InstantLearningModalDynamic.js +1 -1
- package/dist/cjs/schema-driven/BPARenderer.js +51 -2
- package/dist/cjs/schema-driven/BPARenderer.js.map +1 -1
- package/dist/features/IL-OTJ/_components/ChatComponents/ChatComponent.js +62 -11
- package/dist/features/IL-OTJ/_components/ChatComponents/ChatComponent.js.map +1 -1
- package/dist/features/IL-OTJ/_components/ChatComponents/ChatComponent.module.css.js +2 -2
- package/dist/features/IL-OTJ/_components/CriticalGaps.js +31 -15
- package/dist/features/IL-OTJ/_components/CriticalGaps.js.map +1 -1
- package/dist/features/IL-OTJ/_components/MarkdownComponents/MarkdownElements.js +3 -1
- package/dist/features/IL-OTJ/_components/MarkdownComponents/MarkdownElements.js.map +1 -1
- package/dist/features/IL-OTJ/_components/MessageRendering/MessageRendering.js +31 -8
- package/dist/features/IL-OTJ/_components/MessageRendering/MessageRendering.js.map +1 -1
- package/dist/features/IL-OTJ/helpers/rhsFieldAttention.js +14 -0
- package/dist/features/IL-OTJ/helpers/rhsFieldAttention.js.map +1 -0
- package/dist/features/LearningManagement/components/InstantLearningModal.js +3 -1
- package/dist/features/LearningManagement/components/InstantLearningModal.js.map +1 -1
- package/dist/features/LearningManagement/components/InstantLearningModalDynamic.js +1 -1
- package/dist/schema-driven/BPARenderer.js +52 -3
- package/dist/schema-driven/BPARenderer.js.map +1 -1
- package/dist/types/src/features/IL-OTJ/_components/ChatComponents/ChatComponent.d.ts.map +1 -1
- package/dist/types/src/features/IL-OTJ/_components/CriticalGaps.d.ts +2 -1
- package/dist/types/src/features/IL-OTJ/_components/CriticalGaps.d.ts.map +1 -1
- package/dist/types/src/features/IL-OTJ/_components/MarkdownComponents/MarkdownElements.d.ts +2 -1
- package/dist/types/src/features/IL-OTJ/_components/MarkdownComponents/MarkdownElements.d.ts.map +1 -1
- package/dist/types/src/features/IL-OTJ/_components/MessageRendering/MessageRendering.d.ts.map +1 -1
- package/dist/types/src/features/IL-OTJ/helpers/rhsFieldAttention.d.ts +7 -0
- package/dist/types/src/features/IL-OTJ/helpers/rhsFieldAttention.d.ts.map +1 -0
- package/dist/types/src/features/LearningManagement/components/InstantLearningModal.d.ts.map +1 -1
- package/dist/types/src/schema-driven/BPARenderer.d.ts.map +1 -1
- package/package.json +4 -4
|
@@ -25,8 +25,8 @@ var PayloadUtils = require('../../../schema-driven/utils/PayloadUtils.js');
|
|
|
25
25
|
var useDynamicFormStore = require('../../../schema-driven/store/useDynamicFormStore.js');
|
|
26
26
|
var usePendingEditHighlight = require('../../IL-OTJ/_components/hooks/usePendingEditHighlight.js');
|
|
27
27
|
var ConfirmationModal = require('./ConfirmationModal.js');
|
|
28
|
-
var utils = require('../../IL-OTJ/helpers/utils.js');
|
|
29
28
|
var CitationsContext = require('../../IL-OTJ/store/CitationsContext.js');
|
|
29
|
+
var utils = require('../../IL-OTJ/helpers/utils.js');
|
|
30
30
|
|
|
31
31
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
32
32
|
|
|
@@ -10,7 +10,55 @@ var useDynamicFormStore = require('./store/useDynamicFormStore.js');
|
|
|
10
10
|
var useParentEditEnabled = require('./hooks/useParentEditEnabled.js');
|
|
11
11
|
var editLock = require('./utils/editLock.js');
|
|
12
12
|
var useUnifiedEditSession = require('./hooks/useUnifiedEditSession.js');
|
|
13
|
+
var rhsFieldAttention = require('../features/IL-OTJ/helpers/rhsFieldAttention.js');
|
|
13
14
|
|
|
15
|
+
const RhsFieldAttentionWrapper = ({ fieldIds, children }) => {
|
|
16
|
+
const containerRef = React.useRef(null);
|
|
17
|
+
const timerRef = React.useRef(void 0);
|
|
18
|
+
const fieldIdsKey = fieldIds.join("|");
|
|
19
|
+
const [isHighlighted, setIsHighlighted] = React.useState(false);
|
|
20
|
+
React.useEffect(() => {
|
|
21
|
+
const handleAttention = (event) => {
|
|
22
|
+
var _a;
|
|
23
|
+
const { fieldId } = event.detail || {};
|
|
24
|
+
if (!fieldId || !fieldIds.includes(fieldId)) return;
|
|
25
|
+
setIsHighlighted(true);
|
|
26
|
+
(_a = containerRef.current) == null ? void 0 : _a.scrollIntoView({ behavior: "smooth", block: "center" });
|
|
27
|
+
window.clearTimeout(timerRef.current);
|
|
28
|
+
timerRef.current = window.setTimeout(() => setIsHighlighted(false), 3e3);
|
|
29
|
+
};
|
|
30
|
+
window.addEventListener(rhsFieldAttention.RHS_FIELD_ATTENTION_EVENT, handleAttention);
|
|
31
|
+
return () => {
|
|
32
|
+
window.removeEventListener(rhsFieldAttention.RHS_FIELD_ATTENTION_EVENT, handleAttention);
|
|
33
|
+
window.clearTimeout(timerRef.current);
|
|
34
|
+
};
|
|
35
|
+
}, [fieldIdsKey]);
|
|
36
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
37
|
+
"div",
|
|
38
|
+
{
|
|
39
|
+
ref: containerRef,
|
|
40
|
+
"data-rhs-field-ids": fieldIds.join(" "),
|
|
41
|
+
style: {
|
|
42
|
+
// Keep the shadow inside the form's horizontal padding, rather than
|
|
43
|
+
// letting a hard outline be clipped by the scroll container.
|
|
44
|
+
margin: "6px 10px",
|
|
45
|
+
padding: "2px 2px 2px 2px",
|
|
46
|
+
// A generous radius keeps the glow from reading like a sharp frame.
|
|
47
|
+
borderRadius: 6,
|
|
48
|
+
// Child field/layout surfaces are often white and rectangular. Clip
|
|
49
|
+
// them to this radius so they cannot square off the rounded glow.
|
|
50
|
+
overflow: isHighlighted ? "hidden" : "visible",
|
|
51
|
+
position: "relative",
|
|
52
|
+
zIndex: isHighlighted ? 1 : "auto",
|
|
53
|
+
transition: "box-shadow 220ms ease, background-color 220ms ease",
|
|
54
|
+
// No spread-radius ring: use a soft, layered purple glow instead.
|
|
55
|
+
boxShadow: isHighlighted ? "0 0 14px 2px rgba(124, 58, 237, 0.28), 0 0 30px 8px rgba(124, 58, 237, 0.18)" : "none",
|
|
56
|
+
backgroundColor: isHighlighted ? "rgba(124, 58, 237, 0.035)" : "transparent"
|
|
57
|
+
},
|
|
58
|
+
children
|
|
59
|
+
}
|
|
60
|
+
);
|
|
61
|
+
};
|
|
14
62
|
const BPAFieldWrapper = ({ node, id, tierKey, variantIndex, uiState, state, handlers, contextOverrides, unifiedEditSession, unifiedEditOwner, renderChildren }) => {
|
|
15
63
|
var _a, _b, _c;
|
|
16
64
|
const { getGlobalField, getVariantField, setGlobalField, setVariantField, getGlobalReasoning, getVariantReasoning, getGlobalMirage, getVariantMirage } = useDynamicFormStore.useDynamicFormStore();
|
|
@@ -105,7 +153,8 @@ const BPAFieldWrapper = ({ node, id, tierKey, variantIndex, uiState, state, hand
|
|
|
105
153
|
children: ComponentRegistry.isContainerComponent(node.bpa_ui_component) && renderChildren ? renderChildren() : null
|
|
106
154
|
}
|
|
107
155
|
) });
|
|
108
|
-
|
|
156
|
+
const attentionWrapped = /* @__PURE__ */ jsxRuntime.jsx(RhsFieldAttentionWrapper, { fieldIds: [id, dataKey, cleanKey], children: rendered });
|
|
157
|
+
if (!lockedInEditFlow) return attentionWrapped;
|
|
109
158
|
const parentIsEditing = !!(override == null ? void 0 : override.parentEditing) || (override == null ? void 0 : override.readOnly) === false;
|
|
110
159
|
return /* @__PURE__ */ jsxRuntime.jsxs("div", { title: editLock.LOCKED_IN_EDIT_FLOW_TOOLTIP, style: { position: "relative", opacity: 0.85 }, children: [
|
|
111
160
|
parentIsEditing && /* @__PURE__ */ jsxRuntime.jsxs(
|
|
@@ -133,7 +182,7 @@ const BPAFieldWrapper = ({ node, id, tierKey, variantIndex, uiState, state, hand
|
|
|
133
182
|
]
|
|
134
183
|
}
|
|
135
184
|
),
|
|
136
|
-
|
|
185
|
+
attentionWrapped
|
|
137
186
|
] });
|
|
138
187
|
};
|
|
139
188
|
const BPARenderer = ({ properties, tierKey, variantIndex, uiState, state, handlers, contextOverrides, unifiedEdit = false, unifiedEditSession }) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BPARenderer.js","sources":["../../../src/schema-driven/BPARenderer.tsx"],"sourcesContent":["// src/schema-driven/BPARenderer.tsx\nimport React, { Suspense, useMemo } from 'react';\nimport { Lock } from 'lucide-react';\nimport { resolveRegistryComponentOrFallback, isContainerComponent } from '../ComponentRegistry';\nimport { SchemaFieldNode } from './types';\nimport { useDynamicFormStore } from './store/useDynamicFormStore';\nimport { DynamicFormContext } from './hooks/useParentEditEnabled';\nimport { isNodeLocked, LOCKED_IN_EDIT_FLOW_TOOLTIP } from './utils/editLock';\nimport { useUnifiedEditSession } from './hooks/useUnifiedEditSession';\n\ninterface BPAFieldWrapperProps {\n node: SchemaFieldNode;\n id: string;\n tierKey?: string;\n variantIndex?: number;\n uiState?: any;\n state?: any;\n handlers?: any;\n contextOverrides?: any; // Allows parent layout components to inject draft state\n unifiedEditSession?: any;\n unifiedEditOwner?: boolean;\n renderChildren?: (childVariantIndex?: number, childOverrides?: any, childTierKey?: string) => React.ReactNode;\n}\n\nconst BPAFieldWrapper: React.FC<BPAFieldWrapperProps> = ({ node, id, tierKey, variantIndex, uiState, state, handlers, contextOverrides, unifiedEditSession, unifiedEditOwner, renderChildren }) => {\n const { getGlobalField, getVariantField, setGlobalField, setVariantField, getGlobalReasoning, getVariantReasoning, getGlobalMirage, getVariantMirage } = useDynamicFormStore();\n\n if (node.hidden) return null;\n\n const dataKey = node.data_key || id;\n // INFERENCE: If there is no variant index, it MUST be a global field.\n const isGlobal = dataKey.startsWith('global.') || variantIndex === undefined;\n const cleanKey = dataKey.replace('global.', '');\n\n // A parent layout (e.g. the group-edit FlexRow, or GlobalSetupAccordion) can\n // inject draft state for this leaf via contextOverrides: `value`/`onChange`\n // redirect the field to the parent's draft, `readOnly` gates editability, and\n // `parentValueOverride` feeds a dependent dropdown the parent's DRAFT value so\n // it can re-filter before anything is committed to the store.\n // A form-wide session wins over a section session, which lets one Edit unlock\n // multiple parent sections without teaching every field component about it.\n const override = {\n ...contextOverrides?.[cleanKey],\n ...unifiedEditSession?.getOverride(node, cleanKey, tierKey, variantIndex),\n };\n\n // 1. Resolve Value (Prioritize contextOverrides for draft state, then Mirage display, then Zustand Store)\n // Mirage values are temporary display-only values shown from skeleton messages without being persisted to state.\n let value = override?.value !== undefined \n ? override.value \n : isGlobal \n ? (getGlobalMirage(cleanKey) ?? getGlobalField(cleanKey)) \n : (tierKey && variantIndex !== undefined ? (getVariantMirage(tierKey, variantIndex, cleanKey) ?? getVariantField(tierKey, variantIndex, cleanKey)) : undefined);\n\n // Track if this value is from a mirage (temporary display) for visual styling.\n const isMirage = isGlobal \n ? getGlobalMirage(cleanKey) !== undefined \n : (tierKey && variantIndex !== undefined ? getVariantMirage(tierKey, variantIndex, cleanKey) !== undefined : false);\n\n // Safe fallbacks to prevent undefined.length crashes\n if (value == null) {\n if (node.type === 'array') value = [];\n else if (node.type === 'boolean') value = false;\n else if (node.type === 'object') value = {};\n else value = '';\n }\n\n // AI cognitive-decision reasoning stripped out of this leaf's value on write\n // (see PayloadUtils.applyResponseToStore) — surfaced separately so field\n // renderers can show a \"why this value\" card next to the input.\n const citation = isGlobal\n ? getGlobalReasoning(cleanKey)\n : (tierKey && variantIndex !== undefined ? getVariantReasoning(tierKey, variantIndex, cleanKey) : undefined);\n\n // 2. Generic OnChange Handler\n const onChange = (newValue: any) => {\n const finalValue = newValue?.target?.value !== undefined ? newValue.target.value : newValue;\n \n // Draft bindings may come from a local layout or the form-wide unified session.\n // Use the resolved override (not only contextOverrides) so both paths write to\n // their draft instead of prematurely committing to the store.\n if (override?.onChange) {\n override.onChange(finalValue);\n return;\n }\n\n if (isGlobal) setGlobalField(cleanKey, finalValue);\n else if (tierKey && variantIndex !== undefined) setVariantField(tierKey, variantIndex, cleanKey, finalValue);\n };\n\n // 3. Generic Array Handlers\n const arrayHandlers = node.type === 'array' ? {\n onAdd: () => onChange([...(value || []), { id: Date.now(), text: '' }]),\n onRemove: (tk: string, idx: number, cId: number | string) => onChange((value || []).filter((item: any) => item.id !== cId)),\n onEdit: (tk: string, idx: number, cId: number | string, text: string) => onChange((value || []).map((item: any) => item.id === cId ? { ...item, text } : item))\n } : {};\n\n const isAiStreaming = uiState?.isAiStreaming;\n // A parent-injected readOnly (group-edit gating) wins over the schema default.\n const readOnly = override?.readOnly !== undefined ? override.readOnly : (node.read_only || isAiStreaming);\n // `read_only_in_edit_flow`: frozen once the rule exists. Beats every other gate,\n // including a parent edit session's injected draft bindings (applied below, after\n // the `{...override}` spread, so an open session can't hand this field an editor).\n const lockedInEditFlow = isNodeLocked(node, uiState);\n const errorMessage = uiState?.validationErrors?.[cleanKey];\n const Component = resolveRegistryComponentOrFallback(node.bpa_ui_component);\n\n // Built as a variable (not inline in JSX) so it spreads last and wins, without\n // TS flagging the intentional duplicate keys.\n const lockedProps: Record<string, any> = lockedInEditFlow\n ? {\n readOnly: true,\n enableInlineEdit: false,\n hideEditControls: true,\n parentEditing: false,\n value,\n onChange: undefined,\n lockedInEditFlow: true,\n lockedTooltip: LOCKED_IN_EDIT_FLOW_TOOLTIP,\n }\n : {};\n\n const rendered = (\n <Suspense fallback={<div style={{ padding: 12, fontSize: 13, color: 'var(--il-muted, #9ca3af)' }}>Loading...</div>}>\n <Component \n id={id}\n schema={node}\n title={node.title}\n description={node.description}\n // Optional helper copy rendered under the field's title. Distinct from\n // `description`, which is the AI-facing authoring guideline in the JSON.\n subtitle={(node as any).subtitle}\n fieldName={node.title}\n placeholder={node.placeholder}\n maxLength={node.maxLength}\n required={node.is_required}\n tooltipDescription={node.tooltip || \"No tooltip provided.\"}\n value={value}\n onChange={onChange}\n citation={citation}\n readOnly={readOnly}\n enableInlineEdit={!node.read_only}\n enableViewToggle={(node as any).bpa_ui_view_toggle}\n errorMessage={errorMessage}\n isAiStreaming={isAiStreaming}\n uiState={uiState}\n state={state}\n handlers={handlers}\n tierKey={tierKey}\n variantIndex={variantIndex}\n activeEditId={uiState?.activeEditId}\n setActiveEditId={uiState?.setActiveEditId}\n pendingEditId={uiState?.pendingEditId}\n setPendingEditId={uiState?.setPendingEditId}\n setSendMessageInChat={uiState?.setSendMessageInChat}\n renderChildren={renderChildren} // Pass the children renderer down to the layout component!\n parentValueOverride={override?.parentValueOverride} // draft parent value for dependent dropdowns\n // Container components need to see the overrides aimed at their DESCENDANTS\n // (keyed by leaf data_key, so they never appear in this node's own `override`)\n // to tell whether an ancestor edit session already governs their children.\n contextOverrides={contextOverrides}\n unifiedEditSession={unifiedEditSession}\n unifiedEditOwner={unifiedEditOwner}\n {...arrayHandlers}\n conditions={node.type === 'array' ? value : undefined}\n isMirage={isMirage} // Flag indicating this value is a temporary mirage display, not persisted state\n {...override} // Let a parent layout (e.g. a variant edit session) inject extra props —\n // hideEditControls, parentEditing, conditions, onAdd/onRemove/onEdit, enableInlineEdit —\n // without BPAFieldWrapper needing to know each field-specific prop name.\n // Frozen fields override whatever the session injected: no value/onChange\n // redirection to a draft, no pencil, no editable surface.\n {...lockedProps}\n >\n {/* Fallback for simple containers that don't explicitly call renderChildren */}\n {isContainerComponent(node.bpa_ui_component) && renderChildren ? renderChildren() : null}\n </Component>\n </Suspense>\n );\n\n if (!lockedInEditFlow) return rendered;\n\n // The parent section/variant is mid-edit but this field is frozen — say so, rather\n // than leaving an inert input the user keeps clicking. `title` carries the same copy\n // as a native tooltip on the field itself.\n const parentIsEditing = !!override?.parentEditing || override?.readOnly === false;\n\n return (\n <div title={LOCKED_IN_EDIT_FLOW_TOOLTIP} style={{ position: 'relative', opacity: 0.85 }}>\n {parentIsEditing && (\n <div\n style={{\n display: 'flex', alignItems: 'center', gap: 6, marginBottom: 6,\n padding: '4px 8px', borderRadius: 6, width: 'fit-content',\n background: 'var(--il-secondary-bg, #f1f5f9)', border: '1px solid var(--il-border, #E2E8F0)',\n color: 'var(--il-muted, #64748B)', fontSize: 12, fontWeight: 500,\n fontFamily: '\"Plus Jakarta Sans\", sans-serif',\n }}\n >\n <Lock size={12} /> {LOCKED_IN_EDIT_FLOW_TOOLTIP}\n </div>\n )}\n {rendered}\n </div>\n );\n};\n\n// --- THE RECURSIVE RENDERER ---\ninterface BPARendererProps {\n properties: Record<string, SchemaFieldNode>;\n tierKey?: string;\n variantIndex?: number;\n uiState?: any;\n state?: any;\n handlers?: any;\n contextOverrides?: any;\n /** Root-schema `unified_edit`: one draft over all parent sections. */\n unifiedEdit?: boolean;\n /** Internal: retains the root draft while recursively rendering containers. */\n unifiedEditSession?: any;\n}\n\nexport const BPARenderer: React.FC<BPARendererProps> = ({ properties, tierKey, variantIndex, uiState, state, handlers, contextOverrides, unifiedEdit = false, unifiedEditSession }) => {\n const unifiedSession = useUnifiedEditSession(properties, uiState, state);\n const activeUnifiedSession = unifiedEditSession || (unifiedEdit ? unifiedSession : undefined);\n const sortedProps = useMemo(() => {\n if (!properties) return [];\n return Object.entries(properties).sort(([, a], [, b]) => \n ((a as SchemaFieldNode).ui_position ?? 0) - ((b as SchemaFieldNode).ui_position ?? 0)\n );\n }, [properties]);\n\n const renderedFields = (\n // Marks everything below as the dynamic-form mount, so registry components\n // that are ALSO used by legacy CreateRule can pick the right edit gate\n // (see useParentEditEnabled).\n <DynamicFormContext.Provider value={true}>\n {sortedProps.map(([key, rawNode], index) => {\n const node = rawNode as SchemaFieldNode;\n\n // Function that layout components (like VariantListWrapper) can call to trigger rendering of nested properties.\n // A variant list passes its resolved tierKey so nested fields read/write the\n // right variantData[tierKey][index] slot (not the outer, possibly-undefined tier).\n const renderChildren = (childVariantIndex?: number, childOverrides?: any, childTierKey?: string) => {\n if (!node.properties) return null;\n return (\n <BPARenderer\n properties={node.properties}\n tierKey={childTierKey !== undefined ? childTierKey : tierKey}\n variantIndex={childVariantIndex !== undefined ? childVariantIndex : variantIndex}\n uiState={uiState}\n state={state}\n handlers={handlers}\n // Preserve a form-wide session while allowing a local layout to add\n // its own bindings. Local bindings are still available in non-unified mode.\n contextOverrides={{ ...contextOverrides, ...childOverrides }}\n unifiedEditSession={activeUnifiedSession}\n />\n );\n };\n\n // Notice we DO NOT loop over variants here. We render the Wrapper once and give it `renderChildren`.\n return (\n <BPAFieldWrapper \n key={key} \n id={key} \n node={node} \n tierKey={tierKey} \n variantIndex={variantIndex} \n uiState={uiState} \n state={state} \n handlers={handlers} \n contextOverrides={contextOverrides}\n unifiedEditSession={activeUnifiedSession}\n // The first root section keeps the familiar header action and owns the\n // shared form-wide session. Other sections only receive its bindings.\n unifiedEditOwner={unifiedEdit && index === 0}\n renderChildren={renderChildren} \n />\n );\n })}\n </DynamicFormContext.Provider>\n );\n\n // The modal's click-capture guard permits interactions only inside the active\n // edit zone. Unified mode uses its own active id, so expose one matching root\n // zone; otherwise Save/Cancel and every child control are intercepted as an\n // outside click before their handlers run.\n return unifiedEdit ? <div data-edit-id=\"unified-form-edit\">{renderedFields}</div> : renderedFields;\n};\n"],"names":["useDynamicForm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QACE,uBAAAN,cAAA;AAAA,UAAC,WAAA;AAAA,UAAA;AAAA,YACC,YAAY,IAAK,CAAA,UAAA;AAAA,YACjB,OAAA,EAAS,YAAiB,KAAA,KAAA,CAAA,GAAY,YAAe,GAAA,OAAA;AAAA,YACrD,YAAA,EAAc,iBAAsB,KAAA,KAAA,CAAA,GAAY,iBAAoB,GAAA,YAAA;AAAA,YACpE,OAAA;AAAA,YACA,KAAA;AAAA,YACA,QAAA;AAAA,YAGA,gBAAkB,EAAA,EAAE,GAAG,gBAAA,EAAkB,GAAG,cAAe,EAAA;AAAA,YAC3D,kBAAoB,EAAA,oBAAA;AAAA,WAAA;AAAA,SACtB,CAAA;AAAA,OAEL,CAAA;AAGA,MACE,uBAAAA,cAAA;AAAA,QAAC,eAAA;AAAA,QAAA;AAAA,UAEC,EAAI,EAAA,GAAA;AAAA,UACJ,IAAA;AAAA,UACA,OAAA;AAAA,UACA,YAAA;AAAA,UACA,OAAA;AAAA,UACA,KAAA;AAAA,UACA,QAAA;AAAA,UACA,gBAAA;AAAA,UACA,kBAAoB,EAAA,oBAAA;AAAA,UAGpB,gBAAA,EAAkB,eAAe,KAAU,KAAA,CAAA;AAAA,UAC3C,cAAA;AAAA,SAAA;AAAA,QAbK,GAAA;AAAA,OAcP,CAAA;AAAA,KAEH,CACH,EAAA,CAAA;AAAA,GAAA,CAAA;AAOF,EAAA,OAAO,8BAAeA,cAAA,CAAA,KAAA,EAAA,EAAI,cAAa,EAAA,mBAAA,EAAqB,0BAAe,CAAS,GAAA,cAAA,CAAA;AACtF;;;;"}
|
|
1
|
+
{"version":3,"file":"BPARenderer.js","sources":["../../../src/schema-driven/BPARenderer.tsx"],"sourcesContent":["// src/schema-driven/BPARenderer.tsx\nimport React, { Suspense, useEffect, useMemo, useRef, useState } from 'react';\nimport { Lock } from 'lucide-react';\nimport { resolveRegistryComponentOrFallback, isContainerComponent } from '../ComponentRegistry';\nimport { SchemaFieldNode } from './types';\nimport { useDynamicFormStore } from './store/useDynamicFormStore';\nimport { DynamicFormContext } from './hooks/useParentEditEnabled';\nimport { isNodeLocked, LOCKED_IN_EDIT_FLOW_TOOLTIP } from './utils/editLock';\nimport { useUnifiedEditSession } from './hooks/useUnifiedEditSession';\nimport { RHS_FIELD_ATTENTION_EVENT, RhsFieldAttentionDetail } from '../features/IL-OTJ/helpers/rhsFieldAttention';\n\ninterface BPAFieldWrapperProps {\n node: SchemaFieldNode;\n id: string;\n tierKey?: string;\n variantIndex?: number;\n uiState?: any;\n state?: any;\n handlers?: any;\n contextOverrides?: any; // Allows parent layout components to inject draft state\n unifiedEditSession?: any;\n unifiedEditOwner?: boolean;\n renderChildren?: (childVariantIndex?: number, childOverrides?: any, childTierKey?: string) => React.ReactNode;\n}\n\nconst RhsFieldAttentionWrapper: React.FC<{\n fieldIds: string[];\n children: React.ReactNode;\n}> = ({ fieldIds, children }) => {\n const containerRef = useRef<HTMLDivElement>(null);\n const timerRef = useRef<number | undefined>(undefined);\n const fieldIdsKey = fieldIds.join('|');\n const [isHighlighted, setIsHighlighted] = useState(false);\n\n useEffect(() => {\n const handleAttention = (event: Event) => {\n const { fieldId } = (event as CustomEvent<RhsFieldAttentionDetail>).detail || {};\n if (!fieldId || !fieldIds.includes(fieldId)) return;\n\n setIsHighlighted(true);\n containerRef.current?.scrollIntoView({ behavior: 'smooth', block: 'center' });\n window.clearTimeout(timerRef.current);\n timerRef.current = window.setTimeout(() => setIsHighlighted(false), 3000);\n };\n\n window.addEventListener(RHS_FIELD_ATTENTION_EVENT, handleAttention);\n return () => {\n window.removeEventListener(RHS_FIELD_ATTENTION_EVENT, handleAttention);\n window.clearTimeout(timerRef.current);\n };\n }, [fieldIdsKey]);\n\n return (\n <div\n ref={containerRef}\n data-rhs-field-ids={fieldIds.join(' ')}\n style={{\n // Keep the shadow inside the form's horizontal padding, rather than\n // letting a hard outline be clipped by the scroll container.\n margin: '6px 10px',\n padding: '2px 2px 2px 2px',\n // A generous radius keeps the glow from reading like a sharp frame.\n borderRadius: 6,\n // Child field/layout surfaces are often white and rectangular. Clip\n // them to this radius so they cannot square off the rounded glow.\n overflow: isHighlighted ? 'hidden' : 'visible',\n position: 'relative',\n zIndex: isHighlighted ? 1 : 'auto',\n transition: 'box-shadow 220ms ease, background-color 220ms ease',\n // No spread-radius ring: use a soft, layered purple glow instead.\n boxShadow: isHighlighted\n ? '0 0 14px 2px rgba(124, 58, 237, 0.28), 0 0 30px 8px rgba(124, 58, 237, 0.18)'\n : 'none',\n backgroundColor: isHighlighted ? 'rgba(124, 58, 237, 0.035)' : 'transparent',\n }}\n >\n {children}\n </div>\n );\n};\n\nconst BPAFieldWrapper: React.FC<BPAFieldWrapperProps> = ({ node, id, tierKey, variantIndex, uiState, state, handlers, contextOverrides, unifiedEditSession, unifiedEditOwner, renderChildren }) => {\n const { getGlobalField, getVariantField, setGlobalField, setVariantField, getGlobalReasoning, getVariantReasoning, getGlobalMirage, getVariantMirage } = useDynamicFormStore();\n\n if (node.hidden) return null;\n\n const dataKey = node.data_key || id;\n // INFERENCE: If there is no variant index, it MUST be a global field.\n const isGlobal = dataKey.startsWith('global.') || variantIndex === undefined;\n const cleanKey = dataKey.replace('global.', '');\n\n // A parent layout (e.g. the group-edit FlexRow, or GlobalSetupAccordion) can\n // inject draft state for this leaf via contextOverrides: `value`/`onChange`\n // redirect the field to the parent's draft, `readOnly` gates editability, and\n // `parentValueOverride` feeds a dependent dropdown the parent's DRAFT value so\n // it can re-filter before anything is committed to the store.\n // A form-wide session wins over a section session, which lets one Edit unlock\n // multiple parent sections without teaching every field component about it.\n const override = {\n ...contextOverrides?.[cleanKey],\n ...unifiedEditSession?.getOverride(node, cleanKey, tierKey, variantIndex),\n };\n\n // 1. Resolve Value (Prioritize contextOverrides for draft state, then Mirage display, then Zustand Store)\n // Mirage values are temporary display-only values shown from skeleton messages without being persisted to state.\n let value = override?.value !== undefined \n ? override.value \n : isGlobal \n ? (getGlobalMirage(cleanKey) ?? getGlobalField(cleanKey)) \n : (tierKey && variantIndex !== undefined ? (getVariantMirage(tierKey, variantIndex, cleanKey) ?? getVariantField(tierKey, variantIndex, cleanKey)) : undefined);\n\n // Track if this value is from a mirage (temporary display) for visual styling.\n const isMirage = isGlobal \n ? getGlobalMirage(cleanKey) !== undefined \n : (tierKey && variantIndex !== undefined ? getVariantMirage(tierKey, variantIndex, cleanKey) !== undefined : false);\n\n // Safe fallbacks to prevent undefined.length crashes\n if (value == null) {\n if (node.type === 'array') value = [];\n else if (node.type === 'boolean') value = false;\n else if (node.type === 'object') value = {};\n else value = '';\n }\n\n // AI cognitive-decision reasoning stripped out of this leaf's value on write\n // (see PayloadUtils.applyResponseToStore) — surfaced separately so field\n // renderers can show a \"why this value\" card next to the input.\n const citation = isGlobal\n ? getGlobalReasoning(cleanKey)\n : (tierKey && variantIndex !== undefined ? getVariantReasoning(tierKey, variantIndex, cleanKey) : undefined);\n\n // 2. Generic OnChange Handler\n const onChange = (newValue: any) => {\n const finalValue = newValue?.target?.value !== undefined ? newValue.target.value : newValue;\n \n // Draft bindings may come from a local layout or the form-wide unified session.\n // Use the resolved override (not only contextOverrides) so both paths write to\n // their draft instead of prematurely committing to the store.\n if (override?.onChange) {\n override.onChange(finalValue);\n return;\n }\n\n if (isGlobal) setGlobalField(cleanKey, finalValue);\n else if (tierKey && variantIndex !== undefined) setVariantField(tierKey, variantIndex, cleanKey, finalValue);\n };\n\n // 3. Generic Array Handlers\n const arrayHandlers = node.type === 'array' ? {\n onAdd: () => onChange([...(value || []), { id: Date.now(), text: '' }]),\n onRemove: (tk: string, idx: number, cId: number | string) => onChange((value || []).filter((item: any) => item.id !== cId)),\n onEdit: (tk: string, idx: number, cId: number | string, text: string) => onChange((value || []).map((item: any) => item.id === cId ? { ...item, text } : item))\n } : {};\n\n const isAiStreaming = uiState?.isAiStreaming;\n // A parent-injected readOnly (group-edit gating) wins over the schema default.\n const readOnly = override?.readOnly !== undefined ? override.readOnly : (node.read_only || isAiStreaming);\n // `read_only_in_edit_flow`: frozen once the rule exists. Beats every other gate,\n // including a parent edit session's injected draft bindings (applied below, after\n // the `{...override}` spread, so an open session can't hand this field an editor).\n const lockedInEditFlow = isNodeLocked(node, uiState);\n const errorMessage = uiState?.validationErrors?.[cleanKey];\n const Component = resolveRegistryComponentOrFallback(node.bpa_ui_component);\n\n // Built as a variable (not inline in JSX) so it spreads last and wins, without\n // TS flagging the intentional duplicate keys.\n const lockedProps: Record<string, any> = lockedInEditFlow\n ? {\n readOnly: true,\n enableInlineEdit: false,\n hideEditControls: true,\n parentEditing: false,\n value,\n onChange: undefined,\n lockedInEditFlow: true,\n lockedTooltip: LOCKED_IN_EDIT_FLOW_TOOLTIP,\n }\n : {};\n\n const rendered = (\n <Suspense fallback={<div style={{ padding: 12, fontSize: 13, color: 'var(--il-muted, #9ca3af)' }}>Loading...</div>}>\n <Component \n id={id}\n schema={node}\n title={node.title}\n description={node.description}\n // Optional helper copy rendered under the field's title. Distinct from\n // `description`, which is the AI-facing authoring guideline in the JSON.\n subtitle={(node as any).subtitle}\n fieldName={node.title}\n placeholder={node.placeholder}\n maxLength={node.maxLength}\n required={node.is_required}\n tooltipDescription={node.tooltip || \"No tooltip provided.\"}\n value={value}\n onChange={onChange}\n citation={citation}\n readOnly={readOnly}\n enableInlineEdit={!node.read_only}\n enableViewToggle={(node as any).bpa_ui_view_toggle}\n errorMessage={errorMessage}\n isAiStreaming={isAiStreaming}\n uiState={uiState}\n state={state}\n handlers={handlers}\n tierKey={tierKey}\n variantIndex={variantIndex}\n activeEditId={uiState?.activeEditId}\n setActiveEditId={uiState?.setActiveEditId}\n pendingEditId={uiState?.pendingEditId}\n setPendingEditId={uiState?.setPendingEditId}\n setSendMessageInChat={uiState?.setSendMessageInChat}\n renderChildren={renderChildren} // Pass the children renderer down to the layout component!\n parentValueOverride={override?.parentValueOverride} // draft parent value for dependent dropdowns\n // Container components need to see the overrides aimed at their DESCENDANTS\n // (keyed by leaf data_key, so they never appear in this node's own `override`)\n // to tell whether an ancestor edit session already governs their children.\n contextOverrides={contextOverrides}\n unifiedEditSession={unifiedEditSession}\n unifiedEditOwner={unifiedEditOwner}\n {...arrayHandlers}\n conditions={node.type === 'array' ? value : undefined}\n isMirage={isMirage} // Flag indicating this value is a temporary mirage display, not persisted state\n {...override} // Let a parent layout (e.g. a variant edit session) inject extra props —\n // hideEditControls, parentEditing, conditions, onAdd/onRemove/onEdit, enableInlineEdit —\n // without BPAFieldWrapper needing to know each field-specific prop name.\n // Frozen fields override whatever the session injected: no value/onChange\n // redirection to a draft, no pencil, no editable surface.\n {...lockedProps}\n >\n {/* Fallback for simple containers that don't explicitly call renderChildren */}\n {isContainerComponent(node.bpa_ui_component) && renderChildren ? renderChildren() : null}\n </Component>\n </Suspense>\n );\n\n const attentionWrapped = (\n <RhsFieldAttentionWrapper fieldIds={[id, dataKey, cleanKey]}>\n {rendered}\n </RhsFieldAttentionWrapper>\n );\n\n if (!lockedInEditFlow) return attentionWrapped;\n\n // The parent section/variant is mid-edit but this field is frozen — say so, rather\n // than leaving an inert input the user keeps clicking. `title` carries the same copy\n // as a native tooltip on the field itself.\n const parentIsEditing = !!override?.parentEditing || override?.readOnly === false;\n\n return (\n <div title={LOCKED_IN_EDIT_FLOW_TOOLTIP} style={{ position: 'relative', opacity: 0.85 }}>\n {parentIsEditing && (\n <div\n style={{\n display: 'flex', alignItems: 'center', gap: 6, marginBottom: 6,\n padding: '4px 8px', borderRadius: 6, width: 'fit-content',\n background: 'var(--il-secondary-bg, #f1f5f9)', border: '1px solid var(--il-border, #E2E8F0)',\n color: 'var(--il-muted, #64748B)', fontSize: 12, fontWeight: 500,\n fontFamily: '\"Plus Jakarta Sans\", sans-serif',\n }}\n >\n <Lock size={12} /> {LOCKED_IN_EDIT_FLOW_TOOLTIP}\n </div>\n )}\n {attentionWrapped}\n </div>\n );\n};\n\n// --- THE RECURSIVE RENDERER ---\ninterface BPARendererProps {\n properties: Record<string, SchemaFieldNode>;\n tierKey?: string;\n variantIndex?: number;\n uiState?: any;\n state?: any;\n handlers?: any;\n contextOverrides?: any;\n /** Root-schema `unified_edit`: one draft over all parent sections. */\n unifiedEdit?: boolean;\n /** Internal: retains the root draft while recursively rendering containers. */\n unifiedEditSession?: any;\n}\n\nexport const BPARenderer: React.FC<BPARendererProps> = ({ properties, tierKey, variantIndex, uiState, state, handlers, contextOverrides, unifiedEdit = false, unifiedEditSession }) => {\n const unifiedSession = useUnifiedEditSession(properties, uiState, state);\n const activeUnifiedSession = unifiedEditSession || (unifiedEdit ? unifiedSession : undefined);\n const sortedProps = useMemo(() => {\n if (!properties) return [];\n return Object.entries(properties).sort(([, a], [, b]) => \n ((a as SchemaFieldNode).ui_position ?? 0) - ((b as SchemaFieldNode).ui_position ?? 0)\n );\n }, [properties]);\n\n const renderedFields = (\n // Marks everything below as the dynamic-form mount, so registry components\n // that are ALSO used by legacy CreateRule can pick the right edit gate\n // (see useParentEditEnabled).\n <DynamicFormContext.Provider value={true}>\n {sortedProps.map(([key, rawNode], index) => {\n const node = rawNode as SchemaFieldNode;\n\n // Function that layout components (like VariantListWrapper) can call to trigger rendering of nested properties.\n // A variant list passes its resolved tierKey so nested fields read/write the\n // right variantData[tierKey][index] slot (not the outer, possibly-undefined tier).\n const renderChildren = (childVariantIndex?: number, childOverrides?: any, childTierKey?: string) => {\n if (!node.properties) return null;\n return (\n <BPARenderer\n properties={node.properties}\n tierKey={childTierKey !== undefined ? childTierKey : tierKey}\n variantIndex={childVariantIndex !== undefined ? childVariantIndex : variantIndex}\n uiState={uiState}\n state={state}\n handlers={handlers}\n // Preserve a form-wide session while allowing a local layout to add\n // its own bindings. Local bindings are still available in non-unified mode.\n contextOverrides={{ ...contextOverrides, ...childOverrides }}\n unifiedEditSession={activeUnifiedSession}\n />\n );\n };\n\n // Notice we DO NOT loop over variants here. We render the Wrapper once and give it `renderChildren`.\n return (\n <BPAFieldWrapper \n key={key} \n id={key} \n node={node} \n tierKey={tierKey} \n variantIndex={variantIndex} \n uiState={uiState} \n state={state} \n handlers={handlers} \n contextOverrides={contextOverrides}\n unifiedEditSession={activeUnifiedSession}\n // The first root section keeps the familiar header action and owns the\n // shared form-wide session. Other sections only receive its bindings.\n unifiedEditOwner={unifiedEdit && index === 0}\n renderChildren={renderChildren} \n />\n );\n })}\n </DynamicFormContext.Provider>\n );\n\n // The modal's click-capture guard permits interactions only inside the active\n // edit zone. Unified mode uses its own active id, so expose one matching root\n // zone; otherwise Save/Cancel and every child control are intercepted as an\n // outside click before their handlers run.\n return unifiedEdit ? <div data-edit-id=\"unified-form-edit\">{renderedFields}</div> : renderedFields;\n};\n"],"names":["useRef","useState","useEffect","RHS_FIELD_ATTENTION_EVENT","jsx","useDynamicFormStore","_a","isNodeLocked","resolveRegistryComponentOrFallback","LOCKED_IN_EDIT_FLOW_TOOLTIP","Suspense","jsxs","Lock","useUnifiedEditSession","useMemo","DynamicFormContext"],"mappings":";;;;;;;;;;;;;;AAyBA,MAAM,wBAGD,GAAA,CAAC,EAAE,QAAA,EAAU,UAAe,KAAA;AAC/B,EAAM,MAAA,YAAA,GAAeA,aAAuB,IAAI,CAAA,CAAA;AAChD,EAAM,MAAA,QAAA,GAAWA,aAA2B,KAAS,CAAA,CAAA,CAAA;AACrD,EAAM,MAAA,WAAA,GAAc,QAAS,CAAA,IAAA,CAAK,GAAG,CAAA,CAAA;AACrC,EAAA,MAAM,CAAC,aAAA,EAAe,gBAAgB,CAAA,GAAIC,eAAS,KAAK,CAAA,CAAA;AAExD,EAAAC,eAAA,CAAU,MAAM;AACd,IAAM,MAAA,eAAA,GAAkB,CAAC,KAAiB,KAAA;AAnC9C,MAAA,IAAA,EAAA,CAAA;AAoCM,MAAA,MAAM,EAAE,OAAA,EAAa,GAAA,KAAA,CAA+C,UAAU,EAAC,CAAA;AAC/E,MAAA,IAAI,CAAC,OAAW,IAAA,CAAC,QAAS,CAAA,QAAA,CAAS,OAAO,CAAG,EAAA,OAAA;AAE7C,MAAA,gBAAA,CAAiB,IAAI,CAAA,CAAA;AACrB,MAAA,CAAA,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AAA,IAAA,CAAA;AAC7B,QACE,uBAAAX,cAAA;AAAA,UAAC,WAAA;AAAA,UAAA;AAAA,YACC,YAAY,IAAK,CAAA,UAAA;AAAA,YACjB,OAAA,EAAS,YAAiB,KAAA,KAAA,CAAA,GAAY,YAAe,GAAA,OAAA;AAAA,YACrD,YAAA,EAAc,iBAAsB,KAAA,KAAA,CAAA,GAAY,iBAAoB,GAAA,YAAA;AAAA,YACpE,OAAA;AAAA,YACA,KAAA;AAAA,YACA,QAAA;AAAA,YAGA,gBAAkB,EAAA,EAAE,GAAG,gBAAA,EAAkB,GAAG,cAAe,EAAA;AAAA,YAC3D,kBAAoB,EAAA,oBAAA;AAAA,WAAA;AAAA,SACtB,CAAA;AAAA,OAEL,CAAA;AAGA,MACE,uBAAAA,cAAA;AAAA,QAAC,eAAA;AAAA,QAAA;AAAA,UAEC,EAAI,EAAA,GAAA;AAAA,UACJ,IAAA;AAAA,UACA,OAAA;AAAA,UACA,YAAA;AAAA,UACA,OAAA;AAAA,UACA,KAAA;AAAA,UACA,QAAA;AAAA,UACA,gBAAA;AAAA,UACA,kBAAoB,EAAA,oBAAA;AAAA,UAGpB,gBAAA,EAAkB,eAAe,KAAU,KAAA,CAAA;AAAA,UAC3C,cAAA;AAAA,SAAA;AAAA,QAbK,GAAA;AAAA,OAcP,CAAA;AAAA,KAEH,CACH,EAAA,CAAA;AAAA,GAAA,CAAA;AAOF,EAAA,OAAO,8BAAeA,cAAA,CAAA,KAAA,EAAA,EAAI,cAAa,EAAA,mBAAA,EAAqB,0BAAe,CAAS,GAAA,cAAA,CAAA;AACtF;;;;"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
2
|
-
import { useRef, useState, useMemo,
|
|
2
|
+
import { useRef, useState, useMemo, useCallback, useEffect, useLayoutEffect } from 'react';
|
|
3
3
|
import { keyframes, Dialog, Box } from '@mui/material';
|
|
4
4
|
import Tooltip from '@mui/material/Tooltip';
|
|
5
5
|
import ReactMarkdown from 'react-markdown';
|
|
@@ -20,6 +20,8 @@ import { extractTextFromChildren, useHeaderObserver } from '../../helpers/utils.
|
|
|
20
20
|
import { SendButton } from '../_svg/SendButton.js';
|
|
21
21
|
import SparkleIcon from '../_svg/SparkleIcon.js';
|
|
22
22
|
import { UserIcon } from '../_svg/UserIcon.js';
|
|
23
|
+
import { parseJsonBlocks } from '../../helpers/message-rendering-utils.js';
|
|
24
|
+
import { highlightRhsField } from '../../helpers/rhsFieldAttention.js';
|
|
23
25
|
import useAuthStore from '../../../LearningManagement/store/useAuthStore.js';
|
|
24
26
|
import { useLMSConfigStore } from '../../../LearningManagement/store/useLMSConfigStore.js';
|
|
25
27
|
|
|
@@ -70,6 +72,7 @@ const createGuidelineAssistantMessage = (learningTerm) => `I would be happy to h
|
|
|
70
72
|
\`\`\`
|
|
71
73
|
-->`;
|
|
72
74
|
const CRITICAL_GAP_RESPONSE_PREFIX = "Here is my response for the critical gap(s):";
|
|
75
|
+
process.env.NODE_ENV === "development";
|
|
73
76
|
const ChatComponent = ({
|
|
74
77
|
chatAssistantName,
|
|
75
78
|
organizationName,
|
|
@@ -181,9 +184,43 @@ const ChatComponent = ({
|
|
|
181
184
|
const isInputEmpty = useMemo(() => {
|
|
182
185
|
return (userInput == null ? void 0 : userInput.trim()) === "" || isStreaming;
|
|
183
186
|
}, [userInput, isStreaming]);
|
|
187
|
+
const rhsInteraction = useMemo(() => {
|
|
188
|
+
if (!Array.isArray(messages) || messages.length === 0) {
|
|
189
|
+
return { isActive: false, fieldIds: [] };
|
|
190
|
+
}
|
|
191
|
+
const lastMessage = messages[messages.length - 1];
|
|
192
|
+
if ((lastMessage == null ? void 0 : lastMessage.role) !== "assistant" || !(lastMessage == null ? void 0 : lastMessage.isEnd)) {
|
|
193
|
+
return { isActive: false, fieldIds: [] };
|
|
194
|
+
}
|
|
195
|
+
let isActive = false;
|
|
196
|
+
const content = typeof lastMessage.content === "string" ? lastMessage.content : "";
|
|
197
|
+
let blocks = [];
|
|
198
|
+
try {
|
|
199
|
+
blocks = parseJsonBlocks(content);
|
|
200
|
+
} catch (error) {
|
|
201
|
+
console.warn("[IL-OTJ][rhs-interaction] Failed to parse critical-gap data.", error);
|
|
202
|
+
return { isActive: false, fieldIds: [] };
|
|
203
|
+
}
|
|
204
|
+
const fieldIds = blocks.filter((block) => (block == null ? void 0 : block.property) === "critical_gaps").flatMap((block) => {
|
|
205
|
+
var _a;
|
|
206
|
+
const criticalGaps = ((_a = block == null ? void 0 : block.data) == null ? void 0 : _a.critical_gaps) || (block == null ? void 0 : block.data);
|
|
207
|
+
if (!criticalGaps || typeof criticalGaps !== "object") return [];
|
|
208
|
+
const gaps = (criticalGaps == null ? void 0 : criticalGaps.gap_cards) || (criticalGaps == null ? void 0 : criticalGaps.gaps) || [];
|
|
209
|
+
return (Array.isArray(gaps) ? gaps : [gaps]).flatMap((gap) => {
|
|
210
|
+
var _a2, _b;
|
|
211
|
+
if (!gap || typeof gap !== "object") return [];
|
|
212
|
+
if (((_a2 = gap == null ? void 0 : gap.interaction) == null ? void 0 : _a2.interaction_type) !== "rhs" && (gap == null ? void 0 : gap.inputType) !== "rhs") return [];
|
|
213
|
+
isActive = true;
|
|
214
|
+
const options = ((_b = gap == null ? void 0 : gap.interaction) == null ? void 0 : _b.options) || (gap == null ? void 0 : gap.options) || [];
|
|
215
|
+
return (Array.isArray(options) ? options : [options]).map((option) => (option == null ? void 0 : option.highlight_rhs_field) || (option == null ? void 0 : option.highlightRhsField)).filter((fieldId) => typeof fieldId === "string" && fieldId.trim().length > 0);
|
|
216
|
+
});
|
|
217
|
+
});
|
|
218
|
+
return { isActive, fieldIds: Array.from(new Set(fieldIds)) };
|
|
219
|
+
}, [messages]);
|
|
220
|
+
const { isActive: isRhsInteractionActive, fieldIds: rhsGapFieldIds } = rhsInteraction;
|
|
184
221
|
const isTextareaDisabled = useMemo(
|
|
185
|
-
() => isFormValidating,
|
|
186
|
-
[isFormValidating]
|
|
222
|
+
() => isFormValidating || isRhsInteractionActive,
|
|
223
|
+
[isFormValidating, isRhsInteractionActive]
|
|
187
224
|
);
|
|
188
225
|
const isLastMessageUser = useMemo(
|
|
189
226
|
() => {
|
|
@@ -193,9 +230,14 @@ const ChatComponent = ({
|
|
|
193
230
|
[messages]
|
|
194
231
|
);
|
|
195
232
|
const isSendButtonDisabled = useMemo(
|
|
196
|
-
() => isInputEmpty ||
|
|
197
|
-
[isInputEmpty,
|
|
233
|
+
() => isInputEmpty || isTextareaDisabled || !!isGlobalEditActive || isLastMessageUser,
|
|
234
|
+
[isInputEmpty, isTextareaDisabled, isGlobalEditActive, isLastMessageUser]
|
|
198
235
|
);
|
|
236
|
+
const remindRhsField = useCallback((event) => {
|
|
237
|
+
if (!isRhsInteractionActive) return;
|
|
238
|
+
event.preventDefault();
|
|
239
|
+
rhsGapFieldIds.forEach((fieldId) => highlightRhsField(fieldId));
|
|
240
|
+
}, [isRhsInteractionActive, rhsGapFieldIds]);
|
|
199
241
|
useEffect(() => {
|
|
200
242
|
if (initialDraftMessage && !userInput) {
|
|
201
243
|
setUserInput(initialDraftMessage);
|
|
@@ -283,7 +325,7 @@ const ChatComponent = ({
|
|
|
283
325
|
skeletonContent: message
|
|
284
326
|
};
|
|
285
327
|
setMessages((prev) => [...prev, skeletonMsg]);
|
|
286
|
-
handleStream(new KeyboardEvent("keydown", { key: "Enter" }), false, message, false, skId);
|
|
328
|
+
handleStream(new KeyboardEvent("keydown", { key: "Enter" }), false, message, false, skId, void 0, true);
|
|
287
329
|
setHighlightedMessageId(skId);
|
|
288
330
|
setSendMessageInChat && setSendMessageInChat("");
|
|
289
331
|
setTimeout(() => {
|
|
@@ -766,7 +808,7 @@ ${liveContent}` : liveContent;
|
|
|
766
808
|
streamTimeoutRefsMap.current.set(requestId, timer);
|
|
767
809
|
}
|
|
768
810
|
}, [handleStreamTimeout, socketTimeOutInMilliSeconds]);
|
|
769
|
-
const handleStream = async (event, isFirstQuestionSent, userInputParam, isValidationFailure = false, customId, setIsLoading) => {
|
|
811
|
+
const handleStream = async (event, isFirstQuestionSent, userInputParam, isValidationFailure = false, customId, setIsLoading, allowRhsInteractionBypass = false) => {
|
|
770
812
|
var _a, _b, _c, _d, _e, _f;
|
|
771
813
|
const contentSource = userInputParam !== void 0 ? userInputParam : userInput || "";
|
|
772
814
|
let finalInput = contentSource.trim();
|
|
@@ -775,7 +817,7 @@ ${liveContent}` : liveContent;
|
|
|
775
817
|
(_a = event == null ? void 0 : event.preventDefault) == null ? void 0 : _a.call(event);
|
|
776
818
|
}
|
|
777
819
|
const isLastMessageUser2 = ((_b = messages[messages.length - 1]) == null ? void 0 : _b.role) === "user";
|
|
778
|
-
if (!finalInput || isStreaming || isRequestInFlightRef.current || isLastMessageUser2 || (event == null ? void 0 : event.key) && !isEnterKey) {
|
|
820
|
+
if (!finalInput || isRhsInteractionActive && !allowRhsInteractionBypass || isStreaming || isRequestInFlightRef.current || isLastMessageUser2 || (event == null ? void 0 : event.key) && !isEnterKey) {
|
|
779
821
|
return;
|
|
780
822
|
}
|
|
781
823
|
if (isInitialAddChatMessageFlow) {
|
|
@@ -1245,7 +1287,7 @@ ${liveContent}` : liveContent;
|
|
|
1245
1287
|
/* @__PURE__ */ jsx("div", { className: styles.inputAreaWrapper, children: /* @__PURE__ */ jsx(
|
|
1246
1288
|
Tooltip,
|
|
1247
1289
|
{
|
|
1248
|
-
title: isFormValidating ? "Please wait for the validation to be completed." : "",
|
|
1290
|
+
title: isRhsInteractionActive ? "Please fill the respective field in the form to continue." : isFormValidating ? "Please wait for the validation to be completed." : "",
|
|
1249
1291
|
children: /* @__PURE__ */ jsxs(
|
|
1250
1292
|
"div",
|
|
1251
1293
|
{
|
|
@@ -1269,12 +1311,12 @@ ${liveContent}` : liveContent;
|
|
|
1269
1311
|
children: /* @__PURE__ */ jsx(ScrollToBottom, {})
|
|
1270
1312
|
}
|
|
1271
1313
|
),
|
|
1272
|
-
/* @__PURE__ */ jsxs("div", {
|
|
1314
|
+
/* @__PURE__ */ jsxs("div", { className: styles.chatInputRow, children: [
|
|
1273
1315
|
/* @__PURE__ */ jsx(
|
|
1274
1316
|
"textarea",
|
|
1275
1317
|
{
|
|
1276
1318
|
ref: textAreaRef,
|
|
1277
|
-
placeholder: textareaPlaceholder,
|
|
1319
|
+
placeholder: isRhsInteractionActive ? "Please fill the respective field in the form to continue." : isFormValidating ? "Please wait for the validation to be completed." : textareaPlaceholder,
|
|
1278
1320
|
value: userInput || "",
|
|
1279
1321
|
onChange: (e) => {
|
|
1280
1322
|
setUserInput(e.target.value);
|
|
@@ -1292,6 +1334,15 @@ ${liveContent}` : liveContent;
|
|
|
1292
1334
|
}
|
|
1293
1335
|
}
|
|
1294
1336
|
),
|
|
1337
|
+
isRhsInteractionActive && /* @__PURE__ */ jsx(
|
|
1338
|
+
"button",
|
|
1339
|
+
{
|
|
1340
|
+
type: "button",
|
|
1341
|
+
className: styles.rhsTextareaBlocker,
|
|
1342
|
+
"aria-label": "Return to the highlighted form field",
|
|
1343
|
+
onClick: remindRhsField
|
|
1344
|
+
}
|
|
1345
|
+
),
|
|
1295
1346
|
/* @__PURE__ */ jsx("span", { className: styles.sendButtonWrapper, children: /* @__PURE__ */ jsx(
|
|
1296
1347
|
"button",
|
|
1297
1348
|
{
|