fix(workspace): key shell by job

This commit is contained in:
Gabriel Brown
2026-07-10 17:06:33 -04:00
parent 020ffbfb23
commit d4a3856083
3 changed files with 30 additions and 2 deletions
@@ -37,7 +37,7 @@ const AgentWorkspacePage = () => {
Back to Spoon Back to Spoon
</Link> </Link>
</Button> </Button>
<AgentWorkspaceShell jobId={jobId} /> <AgentWorkspaceShell key={jobId} jobId={jobId} />
</main> </main>
); );
}; };
@@ -53,7 +53,7 @@ const ThreadDetailPage = () => {
Back to Spoon Back to Spoon
</Link> </Link>
</Button> </Button>
<AgentWorkspaceShell jobId={latestJob._id} /> <AgentWorkspaceShell key={latestJob._id} jobId={latestJob._id} />
</main> </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);
});
});