Skip to content

Commit

Permalink
Add in reserved capacity pro plan for users who want it
Browse files Browse the repository at this point in the history
  • Loading branch information
truell20 committed Mar 27, 2023
1 parent a3e56fb commit 92afb5f
Show file tree
Hide file tree
Showing 18 changed files with 997 additions and 36 deletions.
11 changes: 11 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@
"fix-path": "^4.0.0",
"fork-ts-checker-webpack-plugin": "^7.2.14",
"gunzip-file": "^0.1.1",
"jwt-decode": "^3.1.2",
"line-diff": "^2.1.1",
"lodash.debounce": "^4.0.8",
"markdown-it": "^13.0.1",
Expand Down
77 changes: 75 additions & 2 deletions src/appComponent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,74 @@ function ErrorPopup() {
)
}

function RateLimitPopup() {
const showError = useAppSelector(gsel.getShowRateLimit)
const dispatch = useAppDispatch()

return (
<Modal
isOpen={showError}
onRequestClose={() => {
dispatch(gs.closeRateLimit())
}}
style={customStyles}
>
<div className="errorPopup">
<div className="errorPopup__title">
<div className="errorPopup__title_text">
You're going a bit fast...
</div>
<div
className="errorPopup__title_close"
onClick={() => dispatch(gs.closeError(null))}
>
<FontAwesomeIcon icon={faClose} />
</div>
</div>
<div className="errorPopup__body">
It seems like you're making a high rate of requests. Please slow down and try again in a minute or so. If you believe this is an error, contact us at [email protected]
<br />
</div>
</div>
</Modal>
)
}

function NoAuthRateLimitPopup() {
const showError = useAppSelector(gsel.getShowNoAuthRateLimit)
const dispatch = useAppDispatch()

return (
<Modal
isOpen={showError}
onRequestClose={() => {
dispatch(gs.closeNoAuthRateLimit())
}}
style={customStyles}
>
<div className="errorPopup">
<div className="errorPopup__title">
<div className="errorPopup__title_text">
Maximum Capacity
</div>
<div
className="errorPopup__title_close"
onClick={() => dispatch(gs.closeNoAuthRateLimit())}
>
<FontAwesomeIcon icon={faClose} />
</div>
</div>
<div className="errorPopup__body">
We're getting more traffic than our servers can handle right now. To avoid these limits and to purchase reserved capacity, you can upgrade to <a
className="pay-link"
onClick={() => dispatch(ts.upgradeCursor(null))}
>Cursor Pro</a> for $20/month.
</div>
</div>
</Modal>
)
}

function SSHPopup() {
const showRemotePopup = useAppSelector(gsel.getShowRemotePopup)
const remoteCommand = useAppSelector(gsel.getRemoteCommand)
Expand Down Expand Up @@ -169,8 +237,8 @@ function SSHPopup() {
onKeyDown={(event: any) => {
if (event.key === 'Enter') {
submit()
}
}}
}}
}
/>
</div>
<div className="submit-button-parent">
Expand Down Expand Up @@ -248,6 +316,9 @@ export function App() {
} else if (e.key == 'e' && e.shiftKey) {
dispatch(ct.pressAICommand('singleLSP'))
e.stopPropagation()
} else if (e.key == 'h') {
dispatch(ct.pressAICommand('history'))
e.stopPropagation()
}
}

Expand Down Expand Up @@ -361,6 +432,8 @@ export function App() {
</div>
<ChatPopup />
<ErrorPopup />
<RateLimitPopup />
<NoAuthRateLimitPopup />
<SettingsPopup />
<FeedbackArea />
<SSHPopup />
Expand Down
4 changes: 4 additions & 0 deletions src/components/markdown.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -592,8 +592,12 @@ export function CommandBarInner({ autofocus }: { autofocus: boolean }) {
placeholder = 'Instructions for code to generate...'
} else if (getMsgType == 'chat_edit') {
placeholder = 'Instructions for editing the current file...'
} else {
// TODO - this case should not exist
placeholder = 'Chat about the current file/selection...'
}


const builder = useRef<ContextBuilder>()

const getCompletions = useCallback<
Expand Down
82 changes: 70 additions & 12 deletions src/components/settingsPane.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,14 @@ import {
} from '../features/lsp/languageServerSelector'
import { State } from '../features/window/state'

import {
signInCursor,
signOutCursor,
upgradeCursor,
} from '../features/tools/toolSlice'
import { loginStatus } from '../features/tools/toolSelectors'


import Modal from 'react-modal'

export function SettingsPopup() {
Expand Down Expand Up @@ -117,44 +125,44 @@ export function SettingsPopup() {

<div className="settings__item">
<div className="settings__item_title">
Tab Size
Text Wrapping
</div>
<div className="settings__item_description">
Controls the tab size
Controls whether text wrapping is enabled
</div>
<Dropdown
options={['2', '4', '8']}
options={['enabled', 'disabled']}
onChange={(e) => {
dispatch(
changeSettings({
tabSize: e.value,
textWrapping: e.value,
})
)
}}
value={settings.tabSize}
value={settings.textWrapping}
/>
</div>

<div className="settings__item">
<div className="settings__item_title">
Text Wrapping
Tab Size
</div>
<div className="settings__item_description">
Controls whether text wrapping is enabled
Controls the tab size
</div>
<Dropdown
options={['enabled', 'disabled']}
options={['2', '4', '8']}
onChange={(e) => {
dispatch(
changeSettings({
textWrapping: e.value,
tabSize: e.value,
})
)
}}
value={settings.textWrapping}
value={settings.tabSize}
/>
</div>

<CursorLogin />
<CopilotPanel />
{/* REMOVED CODEBASE-WIDE FEATURES!
<RemoteCodebaseSettingsPanel />*/}
Expand All @@ -173,6 +181,56 @@ export function SettingsPopup() {
)
}

function CursorLogin() {
const dispatch = useAppDispatch()

const { signedIn, proVersion } = useAppSelector(loginStatus)

const signIn = useCallback(() => {
dispatch(signInCursor(null))
}, [])
const signOut = useCallback(() => {
dispatch(signOutCursor(null))
}, [])

const upgrade = useCallback(() => {
dispatch(upgradeCursor(null))
}, [])

let currentPanel
if (!signedIn) {
currentPanel = (
<div className="copilot__signin">
<button onClick={signIn}>Sign in</button>
<button onClick={signIn}>Sign up</button>
</div>
)
} else {
if (proVersion) {
currentPanel = (
<div className="copilot__signin">
<button onClick={signOut}>Log out</button>
</div>
)
} else {
currentPanel = (
<div className="copilot__signin">
<button onClick={upgrade}>Upgrade to Pro</button>
<button onClick={signOut}>Log out</button>
</div>
)
}
}

return (
<div className="settings__item">
<div className="settings__item_title">Cursor Pro</div>
{currentPanel}
</div>
)
}


function CopilotPanel() {
const dispatch = useAppDispatch()
const { signedIn, enabled } = useAppSelector(copilotStatus)
Expand Down
Loading

0 comments on commit 92afb5f

Please sign in to comment.