fix(workspace): key shell by job
This commit is contained in:
@@ -37,7 +37,7 @@ const AgentWorkspacePage = () => {
|
||||
Back to Spoon
|
||||
</Link>
|
||||
</Button>
|
||||
<AgentWorkspaceShell jobId={jobId} />
|
||||
<AgentWorkspaceShell key={jobId} jobId={jobId} />
|
||||
</main>
|
||||
);
|
||||
};
|
||||
|
||||
@@ -53,7 +53,7 @@ const ThreadDetailPage = () => {
|
||||
Back to Spoon
|
||||
</Link>
|
||||
</Button>
|
||||
<AgentWorkspaceShell jobId={latestJob._id} />
|
||||
<AgentWorkspaceShell key={latestJob._id} jobId={latestJob._id} />
|
||||
</main>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
import { useEffect } from 'react';
|
||||
import { render } from '@testing-library/react';
|
||||
import { describe, expect, test } from 'vitest';
|
||||
|
||||
let mounts = 0;
|
||||
|
||||
const Child = ({ jobId }: { jobId: string }) => {
|
||||
useEffect(() => {
|
||||
mounts += 1;
|
||||
}, []);
|
||||
|
||||
return <span>{jobId}</span>;
|
||||
};
|
||||
|
||||
const Shell = ({ jobId }: { jobId: string }) => (
|
||||
<Child key={jobId} jobId={jobId} />
|
||||
);
|
||||
|
||||
describe('workspace shell keyed by job', () => {
|
||||
test('remounts when jobId changes', () => {
|
||||
mounts = 0;
|
||||
const { rerender } = render(<Shell jobId='a' />);
|
||||
expect(mounts).toBe(1);
|
||||
|
||||
rerender(<Shell jobId='b' />);
|
||||
expect(mounts).toBe(2);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user