@hef2024/llmasaservice-ui 0.21.0 → 0.22.0
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/AICHATPANEL-PORT-INVENTORY.md +2 -0
- package/CONTROLLED-COLLAPSE-IMPLEMENTATION.md +274 -0
- package/DEBUG-ERROR-HANDLING.md +2 -0
- package/FIX-APPLIED.md +2 -0
- package/IMPLEMENTATION-COMPLETE.md +2 -0
- package/dist/index.d.mts +2 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +37 -6
- package/dist/index.mjs +37 -6
- package/docs/CHANGELOG-ERROR-HANDLING.md +2 -0
- package/docs/CONTROLLED-COLLAPSE-QUICK-START.md +147 -0
- package/docs/CONTROLLED-COLLAPSE-STATE.md +651 -0
- package/docs/CONVERSATION-HISTORY.md +2 -0
- package/docs/ERROR-HANDLING-413.md +2 -0
- package/docs/ERROR-HANDLING-SUMMARY.md +2 -0
- package/package.json +1 -1
- package/src/AIAgentPanel.tsx +59 -6
- package/src/components/ui/Button.tsx +2 -0
- package/src/components/ui/Dialog.tsx +2 -0
- package/src/components/ui/Input.tsx +2 -0
- package/src/components/ui/Select.tsx +2 -0
- package/src/components/ui/ToolInfoModal.tsx +2 -0
- package/src/components/ui/Tooltip.tsx +2 -0
- package/src/components/ui/index.ts +2 -0
package/src/AIAgentPanel.tsx
CHANGED
|
@@ -96,6 +96,8 @@ export interface AIAgentPanelProps {
|
|
|
96
96
|
theme?: 'light' | 'dark';
|
|
97
97
|
collapsible?: boolean;
|
|
98
98
|
defaultCollapsed?: boolean;
|
|
99
|
+
isCollapsed?: boolean;
|
|
100
|
+
onCollapsedChange?: (isCollapsed: boolean) => void;
|
|
99
101
|
defaultWidth?: number;
|
|
100
102
|
minWidth?: number;
|
|
101
103
|
maxWidth?: number;
|
|
@@ -618,6 +620,8 @@ const AIAgentPanel = React.forwardRef<AIAgentPanelHandle, AIAgentPanelProps>(({
|
|
|
618
620
|
theme = 'light',
|
|
619
621
|
collapsible = true,
|
|
620
622
|
defaultCollapsed = false,
|
|
623
|
+
isCollapsed: controlledIsCollapsed,
|
|
624
|
+
onCollapsedChange,
|
|
621
625
|
defaultWidth = 720,
|
|
622
626
|
minWidth = 520,
|
|
623
627
|
maxWidth = 1200,
|
|
@@ -660,8 +664,36 @@ const AIAgentPanel = React.forwardRef<AIAgentPanelHandle, AIAgentPanelProps>(({
|
|
|
660
664
|
customerEmailCaptureMode,
|
|
661
665
|
customerEmailCapturePlaceholder,
|
|
662
666
|
}, ref) => {
|
|
667
|
+
// Dev mode warnings for prop conflicts
|
|
668
|
+
useEffect(() => {
|
|
669
|
+
if (process.env.NODE_ENV === 'development') {
|
|
670
|
+
// Warn if isCollapsed is provided without onCollapsedChange (user can't interact)
|
|
671
|
+
if (controlledIsCollapsed !== undefined && !onCollapsedChange) {
|
|
672
|
+
console.warn(
|
|
673
|
+
'AIAgentPanel: You provided `isCollapsed` prop without `onCollapsedChange`. ' +
|
|
674
|
+
'This will render a read-only collapsed state. To allow user interaction, provide both props.'
|
|
675
|
+
);
|
|
676
|
+
}
|
|
677
|
+
|
|
678
|
+
// Warn if both isCollapsed and defaultCollapsed are provided (conflicting props)
|
|
679
|
+
if (controlledIsCollapsed !== undefined && defaultCollapsed !== false) {
|
|
680
|
+
console.warn(
|
|
681
|
+
'AIAgentPanel: You provided both `isCollapsed` and `defaultCollapsed` props. ' +
|
|
682
|
+
'When using controlled mode (isCollapsed), the defaultCollapsed prop is ignored. ' +
|
|
683
|
+
'Remove defaultCollapsed to avoid confusion.'
|
|
684
|
+
);
|
|
685
|
+
}
|
|
686
|
+
}
|
|
687
|
+
}, [controlledIsCollapsed, onCollapsedChange, defaultCollapsed]);
|
|
688
|
+
|
|
663
689
|
// Panel state - only start collapsed if collapsible is true
|
|
664
|
-
const [
|
|
690
|
+
const [uncontrolledIsCollapsed, setUncontrolledIsCollapsed] = useState(collapsible && defaultCollapsed);
|
|
691
|
+
|
|
692
|
+
// Determine if controlled
|
|
693
|
+
const isControlled = controlledIsCollapsed !== undefined;
|
|
694
|
+
|
|
695
|
+
// Use controlled value if provided, otherwise use internal state
|
|
696
|
+
const isCollapsed = isControlled ? controlledIsCollapsed : uncontrolledIsCollapsed;
|
|
665
697
|
const [isHistoryCollapsed, setIsHistoryCollapsed] = useState(() => {
|
|
666
698
|
if (typeof window !== 'undefined') {
|
|
667
699
|
const saved = localStorage.getItem('ai-agent-panel-history-collapsed');
|
|
@@ -1876,8 +1908,17 @@ const AIAgentPanel = React.forwardRef<AIAgentPanelHandle, AIAgentPanelProps>(({
|
|
|
1876
1908
|
// Toggle collapse - only if collapsible is enabled
|
|
1877
1909
|
const toggleCollapse = useCallback(() => {
|
|
1878
1910
|
if (!collapsible) return;
|
|
1879
|
-
|
|
1880
|
-
|
|
1911
|
+
|
|
1912
|
+
const newValue = !isCollapsed;
|
|
1913
|
+
|
|
1914
|
+
// Update internal state if uncontrolled
|
|
1915
|
+
if (!isControlled) {
|
|
1916
|
+
setUncontrolledIsCollapsed(newValue);
|
|
1917
|
+
}
|
|
1918
|
+
|
|
1919
|
+
// Call callback if provided
|
|
1920
|
+
onCollapsedChange?.(newValue);
|
|
1921
|
+
}, [collapsible, isCollapsed, isControlled, onCollapsedChange]);
|
|
1881
1922
|
|
|
1882
1923
|
// Toggle history collapse
|
|
1883
1924
|
const toggleHistoryCollapse = useCallback(() => {
|
|
@@ -1927,7 +1968,11 @@ const AIAgentPanel = React.forwardRef<AIAgentPanelHandle, AIAgentPanelProps>(({
|
|
|
1927
1968
|
variant="ghost"
|
|
1928
1969
|
size="icon"
|
|
1929
1970
|
onClick={() => {
|
|
1930
|
-
|
|
1971
|
+
// Expand panel in controlled or uncontrolled mode
|
|
1972
|
+
if (!isControlled) {
|
|
1973
|
+
setUncontrolledIsCollapsed(false);
|
|
1974
|
+
}
|
|
1975
|
+
onCollapsedChange?.(false);
|
|
1931
1976
|
setShowSearch(true);
|
|
1932
1977
|
}}
|
|
1933
1978
|
>
|
|
@@ -1941,7 +1986,11 @@ const AIAgentPanel = React.forwardRef<AIAgentPanelHandle, AIAgentPanelProps>(({
|
|
|
1941
1986
|
variant="ghost"
|
|
1942
1987
|
size="icon"
|
|
1943
1988
|
onClick={() => {
|
|
1944
|
-
|
|
1989
|
+
// Expand panel in controlled or uncontrolled mode
|
|
1990
|
+
if (!isControlled) {
|
|
1991
|
+
setUncontrolledIsCollapsed(false);
|
|
1992
|
+
}
|
|
1993
|
+
onCollapsedChange?.(false);
|
|
1945
1994
|
handleNewConversation();
|
|
1946
1995
|
}}
|
|
1947
1996
|
>
|
|
@@ -1964,7 +2013,11 @@ const AIAgentPanel = React.forwardRef<AIAgentPanelHandle, AIAgentPanelProps>(({
|
|
|
1964
2013
|
variant={agent.id === currentAgentId ? 'secondary' : 'ghost'}
|
|
1965
2014
|
size="icon"
|
|
1966
2015
|
onClick={() => {
|
|
1967
|
-
|
|
2016
|
+
// Expand panel in controlled or uncontrolled mode
|
|
2017
|
+
if (!isControlled) {
|
|
2018
|
+
setUncontrolledIsCollapsed(false);
|
|
2019
|
+
}
|
|
2020
|
+
onCollapsedChange?.(false);
|
|
1968
2021
|
if (hasActiveConversation && activeConvForAgent) {
|
|
1969
2022
|
// Switch to the existing conversation
|
|
1970
2023
|
setCurrentConversationId(activeConvForAgent.conversationId);
|