fix(ui): keep an explicit Default effort across the send that follows it
A send carries no effort both when nothing was chosen and when the user picked "Default", so `sendMessage` could not tell the two apart and recorded the raw value, which clears the entry. Picking "Default", sending, then switching agent and back put the settings default back in the picker — the shape of the bug this branch set out to fix. `materializeOpenDraftSession` already read the live selection to keep that distinction on the draft path. Both paths now share `resolveVariantToRecord`, which prefers `currentVariantSelection.override` while the live selection still describes the agent and model being sent to, and falls back to the sent value when it does not. Three tests go through the real `sendMessage`; two of them fail without this change. The existing ones seeded the record directly, which is why the send path was never covered. Also documents the `oc.chatInput.lastDraftTarget` record in the owning sync documentation: its three `target` values, what a pre-`target` record and a removed project fall back to, and why a chat scratch directory is not a project target. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01EZuVVgziiLjD81W5vaxdH2
This commit is contained in:
co-authored by
Claude Opus 5
parent
4dfbb5bd1c
commit
9299e2a28d
@@ -780,6 +780,29 @@ const createSessionWithDraftLifecycle = async (
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* The effort a send should record for its session.
|
||||
*
|
||||
* A send carries `undefined` both when no effort was ever chosen and when the
|
||||
* user explicitly picked "Default", so the sent value alone cannot tell the two
|
||||
* apart, and recording it raw clears a real "Default". The live selection can
|
||||
* tell them apart, because its `override` keeps `null` for "Default" — but only
|
||||
* while it still describes the agent and model being sent to. Otherwise the
|
||||
* send's own value is all there is to go on.
|
||||
*/
|
||||
const resolveVariantToRecord = (
|
||||
agentName: string | undefined,
|
||||
providerID: string,
|
||||
modelID: string,
|
||||
sentVariant: string | undefined,
|
||||
): string | null | undefined => {
|
||||
const config = useConfigStore.getState()
|
||||
const describesThisSend = config.currentProviderId === providerID
|
||||
&& config.currentModelId === modelID
|
||||
&& config.currentAgentName === agentName
|
||||
return describesThisSend ? config.currentVariantSelection.override : sentVariant
|
||||
}
|
||||
|
||||
export async function materializeOpenDraftSession(selection: {
|
||||
providerID: string
|
||||
modelID: string
|
||||
@@ -852,14 +875,12 @@ export async function materializeOpenDraftSession(selection: {
|
||||
})
|
||||
|
||||
const effectiveDraftAgent = trimmedAgent ?? configState.currentAgentName
|
||||
// An explicit "Default" (`null`) is carried over as-is. Flattening it to
|
||||
// `undefined` here would leave the new session with no recorded choice, and
|
||||
// the settings default effort would take the picker back over.
|
||||
const variantOverride = configState.currentProviderId === selection.providerID
|
||||
&& configState.currentModelId === selection.modelID
|
||||
&& configState.currentAgentName === effectiveDraftAgent
|
||||
? configState.currentVariantSelection.override
|
||||
: selection.variant
|
||||
const variantOverride = resolveVariantToRecord(
|
||||
effectiveDraftAgent,
|
||||
selection.providerID,
|
||||
selection.modelID,
|
||||
selection.variant,
|
||||
)
|
||||
|
||||
useSelectionStore.getState().saveSessionModelSelection(created.id, selection.providerID, selection.modelID)
|
||||
|
||||
@@ -1716,7 +1737,13 @@ export const useSessionUIStore = create<SessionUIState>()((set, get) => ({
|
||||
if (targetSessionId && effectiveAgent) {
|
||||
useSelectionStore.getState().saveSessionAgentSelection(targetSessionId, effectiveAgent)
|
||||
useSelectionStore.getState().saveAgentModelForSession(targetSessionId, effectiveAgent, providerID, modelID)
|
||||
useSelectionStore.getState().saveAgentModelVariantForSession(targetSessionId, effectiveAgent, providerID, modelID, variant)
|
||||
useSelectionStore.getState().saveAgentModelVariantForSession(
|
||||
targetSessionId,
|
||||
effectiveAgent,
|
||||
providerID,
|
||||
modelID,
|
||||
resolveVariantToRecord(effectiveAgent, providerID, modelID, variant),
|
||||
)
|
||||
}
|
||||
|
||||
if (targetSessionId) {
|
||||
|
||||
Reference in New Issue
Block a user