Undo puts back what the last answer changed. Reset starts a new conversation and leaves the table as it is. Both are buttons you add next to the question box, in the same component and from the same hook: a second useTableAssistant has a conversation of its own, and its undo knows nothing of the first one's answers.
import { type AssistantTable, useTableAssistant } from '@gridsay/tanstack-table/react';import { useState } from 'react'; export function AskBox({ table }: { table: AssistantTable }) { const { ask, undo, reset, canUndo, pending, error } = useTableAssistant(table, { url: '/api/tanstack-table', }); const [question, setQuestion] = useState(''); return ( <form onSubmit={async (event) => { event.preventDefault(); if (await ask(question)) setQuestion(''); }} > <input aria-label="Ask about the table" value={question} onChange={(event) => setQuestion(event.target.value)} /> <button type="submit" disabled={pending || !question.trim()}>Ask</button> <button type="button" disabled={pending || !canUndo} onClick={() => undo()}> Undo </button> <button type="button" onClick={reset}> New conversation </button> {error ? <p role="alert">{error.message}</p> : null} </form> );}true when it put something back, at once; it is not a promise. It returns false and does nothing when there is no answer to undo, or while a question is pending.error.canUndo is true after an applied answer, and false while a question is pending. Bind it to the button's disabled, as above.
error.ask with false and no error. Questions queued behind it are not sent.Name the button for what it does, such as New conversation, not Clear filters.