Fix copilot suppressing sidebar issues

This commit is contained in:
akhisud3195 2025-07-16 14:50:44 +05:30
parent 62dc05e36a
commit df2d004d7c
2 changed files with 34 additions and 8 deletions

View file

@ -184,6 +184,22 @@ const App = forwardRef<{ handleCopyChat: () => void; handleUserMessage: (message
handleUserMessage
}), [handleCopyChat, handleUserMessage]);
// Memoized status bar change handler to prevent infinite update loop
const handleStatusBarChange = useCallback((status: any) => {
setStatusBar((prev: any) => {
// Shallow compare previous and next status
const next = { ...status, context: lockedContext };
const keys = Object.keys(next);
if (
prev &&
keys.every(key => prev[key] === next[key])
) {
return prev;
}
return next;
});
}, [lockedContext]);
return (
<CopilotContext.Provider value={{ workflow: workflowRef.current, dispatch }}>
<div className="h-full flex flex-col">
@ -194,10 +210,7 @@ const App = forwardRef<{ handleCopyChat: () => void; handleUserMessage: (message
loadingResponse={loadingResponse}
workflow={workflowRef.current}
dispatch={dispatch}
onStatusBarChange={status => setStatusBar({
...status,
context: lockedContext,
})}
onStatusBarChange={handleStatusBarChange}
/>
</div>
<div className="shrink-0 px-1 pb-6">

View file

@ -413,9 +413,14 @@ function AssistantMessage({
const [panelOpen, setPanelOpen] = useState(false); // collapsed by default
// At the end of the render, call onStatusBarChange with the current status bar props
// Track the latest status bar info
const latestStatusBar = useRef<any>(null);
// Only call onStatusBarChange if the serializable status actually changes
const lastStatusRef = useRef<any>(null);
useEffect(() => {
if (onStatusBarChange) {
onStatusBarChange({
const status = {
allCardsLoaded,
allApplied,
appliedCount,
@ -423,10 +428,18 @@ function AssistantMessage({
streamingLine,
completedSummary,
hasPanelWarning,
handleApplyAll,
});
// Exclude handleApplyAll from comparison
};
if (!lastStatusRef.current || JSON.stringify(lastStatusRef.current) !== JSON.stringify(status)) {
lastStatusRef.current = status;
onStatusBarChange({
...status,
handleApplyAll, // pass the function, but don't compare it
});
}
}
}, [allCardsLoaded, allApplied, appliedCount, pendingCount, streamingLine, completedSummary, hasPanelWarning, handleApplyAll, onStatusBarChange]);
// Only depend on the serializable values, not the function
}, [allCardsLoaded, allApplied, appliedCount, pendingCount, streamingLine, completedSummary, hasPanelWarning, onStatusBarChange, handleApplyAll]);
// Render all cards inline, not in a panel
return (