|
8 | 8 | import { useHostTRPCClient } from "@posthog/host-router/react"; |
9 | 9 | import { |
10 | 10 | type Adapter, |
| 11 | + defaultEligibleModel, |
11 | 12 | GLM_MODEL_FLAG, |
12 | 13 | getCloudUrlFromRegion, |
13 | 14 | } from "@posthog/shared"; |
@@ -106,22 +107,23 @@ export function usePreviewConfig(adapter: Adapter): PreviewConfigResult { |
106 | 107 | ); |
107 | 108 |
|
108 | 109 | // The server always returns its default model as the current value, so |
109 | | - // without this the user's last pick (e.g. fable) is lost on every |
110 | | - // refetch/remount. Restore it through applyConfigChange so the dependent |
111 | | - // effort options are recomputed for the restored model. |
| 110 | + // without this the user's last (default-eligible) pick is lost on every |
| 111 | + // refetch/remount. Restore it through applyConfigChange so the |
| 112 | + // dependent effort options are recomputed for the restored model. |
112 | 113 | const modelOpt = getOptionByCategory(initial, "model"); |
| 114 | + const restorableModel = defaultEligibleModel(lastUsedModel); |
113 | 115 | if ( |
114 | | - lastUsedModel && |
| 116 | + restorableModel && |
115 | 117 | modelOpt?.type === "select" && |
116 | | - modelOpt.currentValue !== lastUsedModel && |
117 | | - flattenConfigValues(modelOpt).includes(lastUsedModel) |
| 118 | + modelOpt.currentValue !== restorableModel && |
| 119 | + flattenConfigValues(modelOpt).includes(restorableModel) |
118 | 120 | ) { |
119 | 121 | initial = applyConfigChange(initial, { |
120 | 122 | adapter, |
121 | 123 | configId: modelOpt.id, |
122 | | - value: lastUsedModel, |
| 124 | + value: restorableModel, |
123 | 125 | effortOptions: |
124 | | - getReasoningEffortOptions(adapter, lastUsedModel) ?? undefined, |
| 126 | + getReasoningEffortOptions(adapter, restorableModel) ?? undefined, |
125 | 127 | settings: { |
126 | 128 | defaultInitialTaskMode: "", |
127 | 129 | lastUsedInitialTaskMode: undefined, |
|
0 commit comments