A local-first multi-agent app development platform, built on PenguinHarness
fix(web): restore the recalled follow-up's thinking level on the Session (#337)
Yaowei Zheng665657d249f8
diff --git a/packages/web/src/features/chat/chat-page.tsx b/packages/web/src/features/chat/chat-page.tsxindex 1284cd9b..fabbb111 100644--- a/packages/web/src/features/chat/chat-page.tsx+++ b/packages/web/src/features/chat/chat-page.tsx@@ -1095,6 +1095,27 @@ export function ChatPage() {[selected, discardSessionDraft],);+ // Pins a picked level on the Session so it outlives this tab: PATCH, then swap the+ // returned row into the session store (the picker reads it back from there). Modeled on+ // onChangeApprovalMode — a failed write surfaces as a toast and leaves the level as it+ // was, rather than showing a level the server does not have. Declared above the recall+ // callbacks because one of them lists it as a dependency, which is evaluated during+ // render rather than when the callback runs.+ const applyTurnThinkingLevel = useCallback(+ (level: string) => {+ if (!selected) return;+ void api+ .patchSession(selected.sessionId, {+ thinkingLevel: level as SessionPatchRequest["thinkingLevel"],+ })+ .then((res) => replace(res.session))+ .catch((e: unknown) => {+ toastError(apiErrorText(e));+ });+ },+ [selected, replace],+ );+// Recall a queued message back into the composer (#287): the DELETE returns the original// content (text / images / files) and the input area restores it as the draft. A 409// not_pending (steering already delivered, follow-up already started) surfaces as a toast;@@ -1118,15 +1139,16 @@ export function ChatPage() {try {const res = await api.recallFollowUp(selected.sessionId, followUpId);// The follow-up was queued with a per-turn thinking level: restore it with the draft,- // so an unedited resend goes out exactly as it was queued.- if (res.thinkingLevel) setTurnThinkingLevel(res.thinkingLevel);+ // so an unedited resend goes out exactly as it was queued. The level now lives on the+ // Session (#310), so restoring it pins it there rather than in local state.+ if (res.thinkingLevel) applyTurnThinkingLevel(res.thinkingLevel);return res;} catch (e) {toastError(apiErrorText(e));return null;}},- [selected],+ [selected, applyTurnThinkingLevel],);const onApprove = useCallback(@@ -1185,25 +1207,6 @@ export function ChatPage() {await runCompaction();}, [runCompaction]);- // Pins a picked level on the Session so it outlives this tab: PATCH, then swap the- // returned row into the session store (the picker reads it back from there). Modeled on- // onChangeApprovalMode — a failed write surfaces as a toast and leaves the level as it- // was, rather than showing a level the server does not have.- const applyTurnThinkingLevel = useCallback(- (level: string) => {- if (!selected) return;- void api- .patchSession(selected.sessionId, {- thinkingLevel: level as SessionPatchRequest["thinkingLevel"],- })- .then((res) => replace(res.session))- .catch((e: unknown) => {- toastError(apiErrorText(e));- });- },- [selected, replace],- );-// Session picker pick: pinned directly while it cannot hurt (empty transcript, a re-pick// of the displayed level, or right after a successful compaction), staged behind the// confirm dialog otherwise — switching the level mid-chat costs prompt-cache hits over