Skip to content

Commit 6867880

Browse files
committed
fix(agent-file-preview): gate file tree by active tab
Signed-off-by: gujiaming <52187003+AtomsH4@users.noreply.github.com>
1 parent 24af41c commit 6867880

2 files changed

Lines changed: 21 additions & 1 deletion

File tree

src/renderer/pages/agents/components/AgentRightPane/AgentRightPane.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,8 @@ function AgentRightPaneStateProvider({
200200
const workspaceKey = `${workspaceId ?? ''}\0${workspacePath ?? ''}`
201201
const previousWorkspaceKeyRef = useRef(workspaceKey)
202202
const lastSelectableFileRef = useRef<string | null>(null)
203-
const fileTreeModelOpen = filesEnabled !== false && fileTreeOpen && shellState.open
203+
const filesTabActive = activeTab === 'files'
204+
const fileTreeModelOpen = filesEnabled !== false && shellState.open && filesTabActive && fileTreeOpen
204205

205206
// Built once here (the provider survives the Host↔Overlay maximize swap), so
206207
// maximize/minimize no longer remounts + rematerializes the workspace tree.

src/renderer/pages/agents/components/AgentRightPane/__tests__/AgentRightPane.test.tsx

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -266,6 +266,25 @@ describe('AgentRightPane', () => {
266266
)
267267
})
268268

269+
it('keeps the file-tree model closed when opening a non-files tab', () => {
270+
render(
271+
<AgentRightPane sessionId="session-a" workspacePath="/workspace" messages={[]} partsByMessageId={{}}>
272+
<AgentRightPane.Shortcuts />
273+
<AgentRightPane.Host />
274+
</AgentRightPane>
275+
)
276+
277+
fireEvent.click(screen.getByRole('button', { name: 'agent.right_pane.tabs.status' }))
278+
279+
expect(screen.getByTestId('right-pane')).toHaveAttribute('data-open', 'true')
280+
expect(useArtifactFileTreeModelMock).toHaveBeenLastCalledWith(
281+
expect.objectContaining({
282+
treeOpen: false,
283+
workspacePath: '/workspace'
284+
})
285+
)
286+
})
287+
269288
it('keeps the file-tree model closed when files are disabled', () => {
270289
render(
271290
<AgentRightPane

0 commit comments

Comments
 (0)