Revert "feat: allow earlier evidence to be revised"
This reverts commit 13b14fd01a.
This commit is contained in:
@@ -100,16 +100,6 @@ export function ScenarioResultPanels({ status, result }) {
|
||||
);
|
||||
}
|
||||
|
||||
// ── Spinner for revision loading overlay ─────────────────────
|
||||
function RevisionSpinner() {
|
||||
return (
|
||||
<span
|
||||
className="inline-block h-4 w-4 border-[2px] border-gray-300 border-t-amber-600 rounded-full"
|
||||
style={{ animation: "spin 1s linear infinite" }}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
// ── Message pools ───────────────────────────────────────────
|
||||
const INITIAL_MESSAGES = [
|
||||
{ min: 0, text: "Reading your situation" },
|
||||
@@ -125,13 +115,6 @@ const UPDATE_MESSAGES = [
|
||||
{ min: 45, text: "Choosing the next question" },
|
||||
];
|
||||
|
||||
const REVISION_MESSAGES = [
|
||||
{ min: 0, text: "Reading what changed" },
|
||||
{ min: 10, text: "Rebuilding the investigation" },
|
||||
{ min: 25, text: "Checking what this affects" },
|
||||
{ min: 45, text: "Choosing the next justified question" },
|
||||
];
|
||||
|
||||
function useLoadingStatus(messages, isLoading) {
|
||||
const [elapsed, setElapsed] = useState(0);
|
||||
const startRef = useRef(null);
|
||||
@@ -206,12 +189,8 @@ export default function ScenarioForm() {
|
||||
const [updateError, setUpdateError] = useState(null);
|
||||
const [updateResult, setUpdateResult] = useState(null);
|
||||
const [lastSubmittedAnswer, setLastSubmittedAnswer] = useState("");
|
||||
const [isRevisionLoading, setIsRevisionLoading] = useState(false);
|
||||
const [revisionTurnIndex, setRevisionTurnIndex] = useState(-1);
|
||||
const textareaRef = useRef(null);
|
||||
|
||||
// Loading state tracking for normal update vs revision
|
||||
const isAnyUpdateLoading = updateStatus === "loading" || isRevisionLoading;
|
||||
const { elapsed: startElapsed, currentMessage: startMsg } = useLoadingStatus(
|
||||
INITIAL_MESSAGES,
|
||||
status === "loading"
|
||||
@@ -219,12 +198,7 @@ export default function ScenarioForm() {
|
||||
|
||||
const { elapsed: updateElapsed, currentMessage: updateMsg } = useLoadingStatus(
|
||||
UPDATE_MESSAGES,
|
||||
updateStatus === "loading" && !isRevisionLoading
|
||||
);
|
||||
|
||||
const { elapsed: revisionElapsed, currentMessage: revisionMsg } = useLoadingStatus(
|
||||
REVISION_MESSAGES,
|
||||
isRevisionLoading
|
||||
updateStatus === "loading"
|
||||
);
|
||||
|
||||
const handleSubmit = async (e) => {
|
||||
@@ -257,7 +231,7 @@ export default function ScenarioForm() {
|
||||
}
|
||||
};
|
||||
|
||||
const handleUpdate = async (e, options = {}) => {
|
||||
const handleUpdate = async (e) => {
|
||||
e.preventDefault();
|
||||
|
||||
// Guard empty answer before showing loading state
|
||||
@@ -267,25 +241,19 @@ export default function ScenarioForm() {
|
||||
return;
|
||||
}
|
||||
|
||||
const isRevision = !!options.graphCheckpoint;
|
||||
const turnIndex = options.turnIndex ?? revisionTurnIndex;
|
||||
|
||||
setUpdateStatus("loading");
|
||||
setIsRevisionLoading(isRevision);
|
||||
if (isRevision) setRevisionTurnIndex(turnIndex);
|
||||
setUpdateError(null);
|
||||
setLastSubmittedAnswer(answer.trim());
|
||||
|
||||
const submission = await submitAnswerForUpdateCase(fetch, {
|
||||
situationGraph: options.graphCheckpoint ?? result?.situationGraph,
|
||||
previousQuestion: isRevision ? undefined : result?.selectedQuestion,
|
||||
situationGraph: result?.situationGraph,
|
||||
previousQuestion: result?.selectedQuestion,
|
||||
answer,
|
||||
});
|
||||
|
||||
if (submission.skipped) {
|
||||
setUpdateStatus("error");
|
||||
setUpdateError(submission.data);
|
||||
setIsRevisionLoading(false);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -293,11 +261,10 @@ export default function ScenarioForm() {
|
||||
const outcome = submission.data;
|
||||
|
||||
if (submission.ok && outcome.success) {
|
||||
if (isRevision) setIsRevisionLoading(false);
|
||||
setUpdateStatus("success");
|
||||
setUpdateResult({
|
||||
...outcome,
|
||||
previousSituationGraph: options.graphCheckpoint ?? result?.situationGraph ?? null,
|
||||
previousSituationGraph: result?.situationGraph ?? null,
|
||||
});
|
||||
setResult((current) => ({
|
||||
...current,
|
||||
@@ -313,12 +280,10 @@ export default function ScenarioForm() {
|
||||
setAnswer("");
|
||||
} else {
|
||||
setUpdateStatus("error");
|
||||
setIsRevisionLoading(false);
|
||||
setUpdateError(outcome);
|
||||
}
|
||||
} catch (err) {
|
||||
setUpdateStatus("error");
|
||||
setIsRevisionLoading(false);
|
||||
setUpdateError({ error: err.message || "Network request failed" });
|
||||
}
|
||||
};
|
||||
@@ -351,7 +316,7 @@ export default function ScenarioForm() {
|
||||
</form>
|
||||
|
||||
{/* ── Initial analysis loading card ─────────────── */}
|
||||
{status === "loading" && !isRevisionLoading && (
|
||||
{status === "loading" && (
|
||||
<LoadingOverlay
|
||||
isLoading={true}
|
||||
elapsed={startElapsed}
|
||||
@@ -360,17 +325,6 @@ export default function ScenarioForm() {
|
||||
/>
|
||||
)}
|
||||
|
||||
{/* ── Revision loading card ─────────────────────── */}
|
||||
{isRevisionLoading && (
|
||||
<div className="rounded-lg border border-amber-200 bg-amber-50 px-5 py-6" role="status" aria-busy="true">
|
||||
<div className="flex items-center gap-3">
|
||||
<RevisionSpinner />
|
||||
<span className="text-base font-medium text-amber-900">Considering your revised answer</span>
|
||||
</div>
|
||||
<p className="mt-2 text-sm text-amber-700">{revisionMsg}</p>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{/* ── Main result workspace ─────────────────────── */}
|
||||
{(status === "success" || status === "error" || updateStatus === "success") && (
|
||||
<ReasoningWorkspace
|
||||
@@ -388,7 +342,6 @@ export default function ScenarioForm() {
|
||||
setAnswer={setAnswer}
|
||||
onAnswerSubmit={handleUpdate}
|
||||
lastSubmittedAnswer={lastSubmittedAnswer}
|
||||
isRevisionLoading={isRevisionLoading}
|
||||
/>
|
||||
)}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user