| 1027 | }; |
| 1028 | |
| 1029 | const handleConfirmFork = async () => { |
| 1030 | if (!forkCheckpointId || !forkSessionName.trim() || !effectiveSession) return; |
| 1031 | |
| 1032 | try { |
| 1033 | setIsLoading(true); |
| 1034 | setError(null); |
| 1035 | |
| 1036 | const newSessionId = `${Date.now()}-${Math.random().toString(36).substr(2, 9)}`; |
| 1037 | await api.forkFromCheckpoint( |
| 1038 | forkCheckpointId, |
| 1039 | effectiveSession.id, |
| 1040 | effectiveSession.project_id, |
| 1041 | projectPath, |
| 1042 | newSessionId, |
| 1043 | forkSessionName |
| 1044 | ); |
| 1045 | |
| 1046 | // Open the new forked session |
| 1047 | // You would need to implement navigation to the new session |
| 1048 | console.log("Forked to new session:", newSessionId); |
| 1049 | |
| 1050 | setShowForkDialog(false); |
| 1051 | setForkCheckpointId(null); |
| 1052 | setForkSessionName(""); |
| 1053 | } catch (err) { |
| 1054 | console.error("Failed to fork checkpoint:", err); |
| 1055 | setError("Failed to fork checkpoint"); |
| 1056 | } finally { |
| 1057 | setIsLoading(false); |
| 1058 | } |
| 1059 | }; |
| 1060 | |
| 1061 | // Handle URL detection from terminal output |
| 1062 | const handleLinkDetected = (url: string) => { |