Skip to content

🤯 LobeHub - Super-Agents on Your Team. Add super-agents to the chats your team already uses.They take on work by themselves and get better every week.

⚡️ perf(review): unmount hidden review panel (#18984)

Innei0b18698a3014
diff --git a/src/features/Conversation/WorkingSidebar/__tests__/index.test.tsx b/src/features/Conversation/WorkingSidebar/__tests__/index.test.tsx
index 65cc45cb312..7818f424d53 100644
--- a/src/features/Conversation/WorkingSidebar/__tests__/index.test.tsx
+++ b/src/features/Conversation/WorkingSidebar/__tests__/index.test.tsx
@@ -135,7 +135,7 @@ vi.mock('../Files', () => ({
vi.mock('../Review', () => ({
default: (props: { composerTarget: ComposerTarget }) => {
renderedReview.current = props;
- return <div />;
+ return <div data-testid="review" />;
},
}));
vi.mock('../ProgressSection', () => ({ default: () => <div /> }));
@@ -882,6 +882,24 @@ describe('AgentWorkingSidebar — tab strip', () => {
expect(globalStore.openWorkingSidebar).toHaveBeenCalledWith('review');
});
+ it('mounts Review only while its visible tab is active', () => {
+ agentStore.activeAgentId = 'agent';
+ reviewState.repoType = 'git';
+ reviewState.workingDirectory = '/repo';
+ localStorageState.openTabsByContext = { 'draft:agent:/repo': ['params', 'review'] };
+ globalStore.status.workingSidebarTab = 'params';
+
+ render(<AgentWorkingSidebar />);
+
+ expect(screen.queryByTestId('review')).not.toBeInTheDocument();
+
+ fireEvent.click(screen.getByRole('button', { name: 'workingPanel.review.title' }));
+ expect(screen.getByTestId('review')).toBeInTheDocument();
+
+ fireEvent.click(screen.getByRole('button', { name: 'settingModel.params.panel.tab' }));
+ expect(screen.queryByTestId('review')).not.toBeInTheDocument();
+ });
+
it('opens Skills and Documents by default for a new workspace context', () => {
localStorageState.openTabsByContext = {};
globalStore.status.workingSidebarTab = 'overview';
@@ -957,6 +975,9 @@ describe('AgentWorkingSidebar — tab strip', () => {
contextKey: expectedKey,
writable: true,
});
+
+ fireEvent.click(screen.getByRole('button', { name: 'Open Review from Overview' }));
+ await waitFor(() => expect(screen.getByTestId('review')).toBeInTheDocument());
expect(renderedReview.current?.composerTarget).toEqual({
contextKey: expectedKey,
writable: true,
@@ -985,6 +1006,9 @@ describe('AgentWorkingSidebar — tab strip', () => {
reason: 'read-only',
writable: false,
});
+
+ fireEvent.click(screen.getByRole('button', { name: 'Open Review from Overview' }));
+ await waitFor(() => expect(screen.getByTestId('review')).toBeInTheDocument());
expect(renderedReview.current?.composerTarget).toEqual({
reason: 'read-only',
writable: false,
diff --git a/src/features/Conversation/WorkingSidebar/index.tsx b/src/features/Conversation/WorkingSidebar/index.tsx
index 215c5af1b83..1fa4c2d8043 100644
--- a/src/features/Conversation/WorkingSidebar/index.tsx
+++ b/src/features/Conversation/WorkingSidebar/index.tsx
@@ -1018,10 +1018,10 @@ const AgentWorkingSidebar = memo<AgentWorkingSidebarProps>(({ availableWidth })
</Suspense>
</Flexbox>
)}
- {reviewAvailable && (
- <Flexbox className={activeTab === 'review' ? styles.pane : styles.paneHidden}>
+ {reviewAvailable && showRightPanel && fits && activeTab === 'review' && (
+ <Flexbox className={styles.pane}>
<Review
- active={activeTab === 'review'}
+ active
composerTarget={composerTarget}
deviceId={remoteDeviceId}
showTree={showReviewTree}