fix(FN-967): add activeTab to TerminalModal xterm init effect dependencies
This commit is contained in:
@@ -333,7 +333,7 @@ export function TerminalModal({ isOpen, onClose, initialCommand }: TerminalModal
|
||||
// Don't dispose xterm here - it should persist across tab switches
|
||||
// Only dispose when the modal is fully closed
|
||||
};
|
||||
}, [isOpen, isReady, activeTab?.sessionId, sendInput, resize]);
|
||||
}, [isOpen, isReady, activeTab, activeTab?.sessionId, sendInput, resize]);
|
||||
|
||||
// Cleanup xterm when modal closes
|
||||
useEffect(() => {
|
||||
|
||||
@@ -227,6 +227,35 @@ describe("TerminalModal", () => {
|
||||
expect(screen.queryByTestId("terminal-loading")).toBeNull();
|
||||
});
|
||||
|
||||
it("initializes xterm when activeTab transitions from null to valid after async session restoration", async () => {
|
||||
// Start with no activeTab (simulating initial async load from useTerminalSessions)
|
||||
mockUseTerminalSessions.mockReturnValue({
|
||||
...defaultSessionState,
|
||||
activeTab: null,
|
||||
isReady: false,
|
||||
});
|
||||
|
||||
const { rerender } = render(<TerminalModal isOpen={true} onClose={mockOnClose} />);
|
||||
|
||||
// xterm should not initialize yet because activeTab is null
|
||||
expect(mockTerminalInstance.open).not.toHaveBeenCalled();
|
||||
|
||||
// Simulate async session restoration completing
|
||||
mockUseTerminalSessions.mockReturnValue({
|
||||
...defaultSessionState,
|
||||
activeTab: defaultTab,
|
||||
isReady: true,
|
||||
});
|
||||
mockUseTerminal.mockReturnValue(createMockTerminalState({ connectionStatus: "connected" }));
|
||||
|
||||
rerender(<TerminalModal isOpen={true} onClose={mockOnClose} />);
|
||||
|
||||
// xterm should be initialized after activeTab becomes available
|
||||
await waitFor(() => {
|
||||
expect(mockTerminalInstance.open).toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
|
||||
it("does not show bootstrap error when activeTab exists (recovered state)", async () => {
|
||||
mockUseTerminalSessions.mockReturnValue({
|
||||
...defaultSessionState,
|
||||
|
||||
Reference in New Issue
Block a user