feat(frontend): store lastUserEntry + stepMessages; record user input/choice
This commit is contained in:
@@ -6,6 +6,7 @@ import { postSteer, createSession } from "../api/sessions";
|
||||
import { getSettings, putSettings, type Settings } from "../api/settings";
|
||||
import { listWorkspaces } from "../api/workspaces";
|
||||
import { listModels } from "../api/models";
|
||||
import { useSessionStore } from "../store/sessionStore";
|
||||
|
||||
const THINKING_LEVELS = ["low", "medium", "high"] as const;
|
||||
|
||||
@@ -23,6 +24,7 @@ interface Props {
|
||||
export function SteerInput({ sessionId, onSessionCreated, onStop, inputRef }: Props) {
|
||||
const [text, setText] = useState("");
|
||||
const [busy, setBusy] = useState(false);
|
||||
const setLastUserEntry = useSessionStore((s) => s.setLastUserEntry);
|
||||
|
||||
async function submit() {
|
||||
const trimmed = text.trim();
|
||||
@@ -35,6 +37,7 @@ export function SteerInput({ sessionId, onSessionCreated, onStop, inputRef }: Pr
|
||||
const { id } = await createSession({ question: trimmed });
|
||||
onSessionCreated?.(id);
|
||||
}
|
||||
setLastUserEntry({ kind: "input", text: trimmed });
|
||||
setText("");
|
||||
} finally {
|
||||
setBusy(false);
|
||||
|
||||
@@ -7,6 +7,7 @@ export function WidgetHost({ sessionId }: { sessionId: string | null }) {
|
||||
const pending = useSessionStore((s) => s.pendingWidget);
|
||||
const clearPending = useSessionStore((s) => s.clearPending);
|
||||
const pushToast = useSessionStore((s) => s.pushToast);
|
||||
const setLastUserEntry = useSessionStore((s) => s.setLastUserEntry);
|
||||
if (!pending) return null;
|
||||
const Renderer = resolve(pending.widget);
|
||||
const onRespond = async (r: UiResponse) => {
|
||||
@@ -25,6 +26,10 @@ export function WidgetHost({ sessionId }: { sessionId: string | null }) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
setLastUserEntry({
|
||||
kind: "choice",
|
||||
text: r.text ?? r.choices?.join(", ") ?? r.decision?.type ?? r.control ?? "(choice)",
|
||||
});
|
||||
clearPending();
|
||||
};
|
||||
return <Renderer descriptor={pending} onRespond={onRespond} />;
|
||||
|
||||
Reference in New Issue
Block a user