( sessionId: string, closeCurrentScreen: () => void, setChatHistory: (history: any) => void, setShowIntroMessage: (show: boolean) => void, )
| 48 | |
| 49 | // Helper function to load and set session |
| 50 | async function loadAndSetSession( |
| 51 | sessionId: string, |
| 52 | closeCurrentScreen: () => void, |
| 53 | setChatHistory: (history: any) => void, |
| 54 | setShowIntroMessage: (show: boolean) => void, |
| 55 | ) { |
| 56 | try { |
| 57 | // Close the session selector |
| 58 | closeCurrentScreen(); |
| 59 | |
| 60 | // Import session functions |
| 61 | const { loadSessionById } = await import("../session.js"); |
| 62 | |
| 63 | // Load the session |
| 64 | const session = loadSessionById(sessionId); |
| 65 | if (!session) { |
| 66 | logger.error(`Session ${sessionId} could not be loaded.`); |
| 67 | return; |
| 68 | } |
| 69 | |
| 70 | // Set the session ID so future operations use this session |
| 71 | process.env.CONTINUE_CLI_TEST_SESSION_ID = sessionId.replace( |
| 72 | "continue-cli-", |
| 73 | "", |
| 74 | ); |
| 75 | |
| 76 | // Set the chat history from the session |
| 77 | setChatHistory(session.history); |
| 78 | |
| 79 | // Clear the intro message since we're now showing a resumed session |
| 80 | setShowIntroMessage(false); |
| 81 | } catch (error) { |
| 82 | console.error("Error loading session:", error); |
| 83 | } |
| 84 | } |
| 85 | |
| 86 | // Custom hook to manage services |
| 87 | function useTUIChatServices(remoteUrl?: string) { |
no test coverage detected