| 1 | import { useT } from "../lib/i18n"; |
| 2 | import type { useSessionComposerPersistence } from "../lib/sessionComposerPersistence"; |
| 3 | import { ErrorMessage } from "./ErrorMessage"; |
| 4 | |
| 5 | type InputState = ReturnType<typeof useSessionComposerPersistence>; |
| 6 | |
| 7 | export function SessionInputRecovery({ input }: { input: InputState }) { |
| 8 | const t = useT(); |
| 9 | if (!input.error && !input.attention && !input.recovering) { |
| 10 | if (!input.taskError) return null; |
| 11 | return <div role="alert" className="session-draft-surface__error"> |
| 12 | <ErrorMessage error={input.taskError} /> |
| 13 | <button type="button" onClick={input.dismissTaskError}>{t("common.close")}</button> |
| 14 | </div>; |
| 15 | } |
| 16 | return <div role="alert" className="session-draft-surface__error"> |
| 17 | <span>{t(input.recovering ? "composer.inputRecovering" : input.attention ? "composer.inputUnconfirmed" : "composer.inputRetry")}</span> |
| 18 | {!input.recovering && <button type="button" onClick={() => void input.retry().catch(() => {})}>{t("common.retry")}</button>} |
| 19 | </div>; |
| 20 | } |
| 21 |