Skip to content

Commit 77cf2d8

Browse files
committed
Cleanup OAI / Login
1 parent 81a28a4 commit 77cf2d8

File tree

4 files changed

+68
-48
lines changed

4 files changed

+68
-48
lines changed

src/components/errors.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ const loginStyles = {
5151
marginLeft: 'auto',
5252
marginRight: 'auto',
5353
maxWidth: '450px',
54+
overflow: 'none',
5455
},
5556
}
5657

@@ -177,7 +178,6 @@ export function ErrorPopup() {
177178
Upgrade
178179
</div>
179180
</div>
180-
<div className="signup__signup_button">Upgrade</div>
181181
</div>
182182
<div className="signup__module signup__last_module">
183183
<div className="signup__subtitle">

src/components/settingsPane.tsx

Lines changed: 65 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,7 @@ export function SettingsPopup() {
162162
/>
163163
</div>
164164

165+
<CursorLogin />
165166
<OpenAIPanel />
166167
<CopilotPanel />
167168
{/* REMOVED CODEBASE-WIDE FEATURES!
@@ -172,7 +173,6 @@ export function SettingsPopup() {
172173
languageName={name}
173174
/>
174175
))}
175-
<CursorLogin />
176176
</div>
177177
</div>
178178
<div className="cover-bar"></div>
@@ -209,7 +209,6 @@ export function OpenAILoginPanel({ onSubmit }: { onSubmit: () => void }) {
209209

210210
const handleNewAPIKey = useCallback(async () => {
211211
const { models, isValidKey } = await ssel.getModels(localAPIKey)
212-
console.log({ models, isValidKey })
213212
if (!isValidKey) {
214213
// Error, and we let them know
215214
showKeyError(true)
@@ -219,11 +218,12 @@ export function OpenAILoginPanel({ onSubmit }: { onSubmit: () => void }) {
219218
dispatch(
220219
changeSettings({
221220
openAIKey: localAPIKey,
222-
})
223-
)
221+
useOpenAIKey: true,
222+
openAIModel: models.at(0) ?? null
223+
}))
224224
onSubmit()
225225
}
226-
}, [localAPIKey])
226+
}, [dispatch, localAPIKey])
227227

228228
return (
229229
<div className="settings__item">
@@ -267,17 +267,17 @@ export function OpenAILoginPanel({ onSubmit }: { onSubmit: () => void }) {
267267
? 'bg-green-500'
268268
: 'bg-red-500'
269269
}
270-
mt-2 relative inline-flex h-[38px] w-[74px] shrink-0 cursor-pointer rounded-full border-2 border-transparent transition-colors duration-200 ease-in-out focus:outline-none focus-visible:ring-2 focus-visible:ring-white focus-visible:ring-opacity-75`}
270+
mt-2 relative inline-flex h-[25px] w-[52px] shrink-0 cursor-pointer rounded-full border-2 border-transparent transition-colors duration-200 ease-in-out focus:outline-none focus-visible:ring-2 focus-visible:ring-white focus-visible:ring-opacity-75`}
271271
>
272272
<span className="sr-only">Use setting</span>
273273
<span
274274
aria-hidden="true"
275275
className={`${
276276
settings.useOpenAIKey
277-
? 'translate-x-9'
277+
? 'translate-x-7'
278278
: 'translate-x-0'
279279
}
280-
pointer-events-none inline-block h-[34px] w-[34px] transform rounded-full bg-white shadow-lg ring-0 transition duration-200 ease-in-out`}
280+
pointer-events-none inline-block h-[20px] w-[20px] transform rounded-full bg-white shadow-lg ring-0 transition duration-200 ease-in-out`}
281281
/>
282282
</Switch>
283283
{settings.useOpenAIKey ? (
@@ -331,28 +331,32 @@ export function OpenAIPanel() {
331331
}, [localAPIKey])
332332

333333
const handleNewAPIKey = useCallback(async () => {
334+
console.log('here 2')
334335
const { models, isValidKey } = await ssel.getModels(localAPIKey)
335336
console.log({ models, isValidKey })
336337
if (!isValidKey) {
337338
// Error, and we let them know
339+
console.log('here 3')
338340
showKeyError(true)
339341
setAvailableModels([])
340342
} else {
341343
setAvailableModels(models)
344+
console.log('here')
342345
dispatch(
343346
changeSettings({
344347
openAIKey: localAPIKey,
345-
})
346-
)
348+
useOpenAIKey: true,
349+
openAIModel: models.at(0) ?? null
350+
}))
347351
}
348-
}, [localAPIKey])
352+
}, [dispatch, localAPIKey])
353+
349354

350355
return (
351356
<div className="settings__item">
352357
<div className="settings__item_title">OpenAI API Key</div>
353358
<div className="settings__item_description">
354-
We'll use your key for any requests to OpenAI. This will help
355-
you avoid "maximum capacity" limits.
359+
You can enter an OpenAI API key to use Cursor at-cost
356360
</div>
357361
<div className="flex">
358362
<input
@@ -394,17 +398,17 @@ export function OpenAIPanel() {
394398
? 'bg-green-500'
395399
: 'bg-red-500'
396400
}
397-
mt-2 relative inline-flex h-[38px] w-[74px] shrink-0 cursor-pointer rounded-full border-2 border-transparent transition-colors duration-200 ease-in-out focus:outline-none focus-visible:ring-2 focus-visible:ring-white focus-visible:ring-opacity-75`}
401+
mt-2 relative inline-flex h-[24px] w-[52px] shrink-0 cursor-pointer rounded-full border-2 border-transparent transition-colors duration-200 ease-in-out focus:outline-none focus-visible:ring-2 focus-visible:ring-white focus-visible:ring-opacity-75`}
398402
>
399403
<span className="sr-only">Use setting</span>
400404
<span
401405
aria-hidden="true"
402406
className={`${
403407
settings.useOpenAIKey
404-
? 'translate-x-9'
408+
? 'translate-x-7'
405409
: 'translate-x-0'
406410
}
407-
pointer-events-none inline-block h-[34px] w-[34px] transform rounded-full bg-white shadow-lg ring-0 transition duration-200 ease-in-out`}
411+
pointer-events-none inline-block h-[20px] w-[20px] transform rounded-full bg-white shadow-lg ring-0 transition duration-200 ease-in-out`}
408412
/>
409413
</Switch>
410414
{settings.useOpenAIKey ? (
@@ -467,47 +471,61 @@ export function CursorLogin({
467471
} else {
468472
if (proVersion) {
469473
currentPanel = (
470-
<div className="copilot__signin">
471-
<button onClick={signOut}>Log out</button>
472-
{showSettings && (
473-
<>
474-
<br />
475-
<button onClick={openAccountSettings}>
476-
Manage settings
477-
</button>
478-
</>
479-
)}
474+
<div className="settings__item">
475+
<div className="settings__item_title">Cursor Account</div>
476+
<div className="settings__item_description">
477+
Login to use the AI without an API key
478+
</div>
479+
<div className="copilot__signin">
480+
<button onClick={signOut}>Log out</button>
481+
{showSettings && (
482+
<>
483+
<br />
484+
<button onClick={openAccountSettings}>
485+
Manage settings
486+
</button>
487+
</>
488+
)}
489+
</div>
480490
</div>
481491
)
482492
} else {
483493
currentPanel = (
484-
<div className="copilot__signin">
485-
<br />
486-
<button onClick={signOut}>Log out</button>
487-
{showSettings && (
488-
<>
494+
<>
495+
<div className="settings__item">
496+
<div className="settings__item_title">Cursor Account</div>
497+
<div className="settings__item_description">
498+
Login to use the AI without an API key
499+
</div>
500+
<div className="copilot__signin">
501+
<button onClick={signOut}>Log out</button>
502+
{showSettings && (
503+
<>
504+
<br />
505+
<button onClick={openAccountSettings}>
506+
Manage settings
507+
</button>
508+
</>
509+
)}
489510
<br />
490-
<button onClick={openAccountSettings}>
491-
Manage settings
492-
</button>
493-
</>
494-
)}
495-
<br />
496-
Upgrade for unlimited generations
497-
<button onClick={upgrade}>Upgrade to Pro</button>
498-
</div>
511+
</div>
512+
</div>
513+
<div className="settings__item">
514+
<div className="settings__item_title">Cursor Pro</div>
515+
<div className="settings__item_description">
516+
Upgrade for unlimited generations
517+
</div>
518+
<div className="copilot__signin">
519+
<button onClick={upgrade}>Upgrade to Pro</button>
520+
</div>
521+
</div>
522+
</>
499523
)
500524
}
501525
}
502526

503527
return (
504-
<div className="settings__item">
505-
<div className="settings__item_title">Cursor Account</div>
506-
<div className="settings__item_description">
507-
Login to use the AI without an API key
508-
</div>
509-
{currentPanel}
510-
</div>
528+
currentPanel
511529
)
512530
}
513531

src/index.css

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2550,6 +2550,7 @@ free servers .disabled_command .shortcut__block {
25502550

25512551
.signup__last_module {
25522552
margin-bottom: 0px;
2553+
text-align: center;
25532554
}
25542555

25552556
.error-message {

src/main/main.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ import todesktop from '@todesktop/runtime'
4040
todesktop.init()
4141

4242
const store = new Store()
43+
store.clear()
4344

4445
let main_window: Electron.BrowserWindow
4546

0 commit comments

Comments
 (0)