MCPcopy Index your code
hub / github.com/codeaashu/claude-code / SetModelAndClose

Function SetModelAndClose

src/commands/model/model.tsx:130–232  ·  view source on GitHub ↗
({
  args,
  onDone
}: {
  args: string;
  onDone: (result?: string, options?: {
    display?: CommandResultDisplay;
  }) => void;
})

Source from the content-addressed store, hash-verified

128 return s.mainLoopModel;
129}
130function SetModelAndClose({
131 args,
132 onDone
133}: {
134 args: string;
135 onDone: (result?: string, options?: {
136 display?: CommandResultDisplay;
137 }) => void;
138}): React.ReactNode {
139 const isFastMode = useAppState(s => s.fastMode);
140 const setAppState = useSetAppState();
141 const model = args === 'default' ? null : args;
142 React.useEffect(() => {
143 async function handleModelChange(): Promise<void> {
144 if (model && !isModelAllowed(model)) {
145 onDone(`Model '${model}' is not available. Your organization restricts model selection.`, {
146 display: 'system'
147 });
148 return;
149 }
150
151 // @[MODEL LAUNCH]: Update check for 1M access.
152 if (model && isOpus1mUnavailable(model)) {
153 onDone(`Opus 4.6 with 1M context is not available for your account. Learn more: https://code.claude.com/docs/en/model-config#extended-context-with-1m`, {
154 display: 'system'
155 });
156 return;
157 }
158 if (model && isSonnet1mUnavailable(model)) {
159 onDone(`Sonnet 4.6 with 1M context is not available for your account. Learn more: https://code.claude.com/docs/en/model-config#extended-context-with-1m`, {
160 display: 'system'
161 });
162 return;
163 }
164
165 // Skip validation for default model
166 if (!model) {
167 setModel(null);
168 return;
169 }
170
171 // Skip validation for known aliases - they're predefined and should work
172 if (isKnownAlias(model)) {
173 setModel(model);
174 return;
175 }
176
177 // Validate and set custom model
178 try {
179 // Don't use parseUserSpecifiedModel for non-aliases since it lowercases the input
180 // and model names are case-sensitive
181 const {
182 valid,
183 error: error_0
184 } = await validateModel(model);
185 if (valid) {
186 setModel(model);
187 } else {

Callers

nothing calls this directly

Calls 3

useAppStateFunction · 0.85
useSetAppStateFunction · 0.85
handleModelChangeFunction · 0.85

Tested by

no test coverage detected