({
onStashAndContinue,
onCancel
}: TeleportStashProps)
| 12 | onCancel: () => void; |
| 13 | }; |
| 14 | export function TeleportStash({ |
| 15 | onStashAndContinue, |
| 16 | onCancel |
| 17 | }: TeleportStashProps): React.ReactNode { |
| 18 | const [gitFileStatus, setGitFileStatus] = useState<GitFileStatus | null>(null); |
| 19 | const changedFiles = gitFileStatus !== null ? [...gitFileStatus.tracked, ...gitFileStatus.untracked] : []; |
| 20 | const [loading, setLoading] = useState(true); |
| 21 | const [stashing, setStashing] = useState(false); |
| 22 | const [error, setError] = useState<string | null>(null); |
| 23 | |
| 24 | // Load changed files on mount |
| 25 | useEffect(() => { |
| 26 | const loadChangedFiles = async () => { |
| 27 | try { |
| 28 | const fileStatus = await getFileStatus(); |
| 29 | setGitFileStatus(fileStatus); |
| 30 | } catch (err) { |
| 31 | const errorMessage = err instanceof Error ? err.message : String(err); |
| 32 | logForDebugging(`Error getting changed files: ${errorMessage}`, { |
| 33 | level: 'error' |
| 34 | }); |
| 35 | setError('Failed to get changed files'); |
| 36 | } finally { |
| 37 | setLoading(false); |
| 38 | } |
| 39 | }; |
| 40 | void loadChangedFiles(); |
| 41 | }, []); |
| 42 | const handleStash = async () => { |
| 43 | setStashing(true); |
| 44 | try { |
| 45 | logForDebugging('Stashing changes before teleport...'); |
| 46 | const success = await stashToCleanState('Teleport auto-stash'); |
| 47 | if (success) { |
| 48 | logForDebugging('Successfully stashed changes'); |
| 49 | onStashAndContinue(); |
| 50 | } else { |
| 51 | setError('Failed to stash changes'); |
| 52 | } |
| 53 | } catch (err_0) { |
| 54 | const errorMessage_0 = err_0 instanceof Error ? err_0.message : String(err_0); |
| 55 | logForDebugging(`Error stashing changes: ${errorMessage_0}`, { |
| 56 | level: 'error' |
| 57 | }); |
| 58 | setError('Failed to stash changes'); |
| 59 | } finally { |
| 60 | setStashing(false); |
| 61 | } |
| 62 | }; |
| 63 | const handleSelectChange = (value: string) => { |
| 64 | if (value === 'stash') { |
| 65 | void handleStash(); |
| 66 | } else { |
| 67 | onCancel(); |
| 68 | } |
| 69 | }; |
| 70 | if (loading) { |
| 71 | return <Box flexDirection="column" padding={1}> |
nothing calls this directly
no test coverage detected