Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix issue #5099: [Bug]: When a github token expires, the waiting list screen appears #5100

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 12 additions & 12 deletions frontend/src/components/waitlist-modal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export function WaitlistModal({ ghToken, githubAuthUrl }: WaitlistModalProps) {
<AllHandsLogo width={68} height={46} />
<div className="flex flex-col gap-2 w-full items-center text-center">
<h1 className="text-2xl font-bold">
{ghToken ? "Just a little longer!" : "Sign in with GitHub"}
{ghToken ? "GitHub Token Expired" : "Sign in with GitHub"}
</h1>
{!ghToken && (
<p>
Expand All @@ -34,9 +34,7 @@ export function WaitlistModal({ ghToken, githubAuthUrl }: WaitlistModalProps) {
)}
{ghToken && (
<p className="text-sm">
Thanks for your patience! We&apos;re accepting new members
progressively. If you haven&apos;t joined the waitlist yet,
now&apos;s the time!
Your GitHub token has expired. Please click below to reconnect your GitHub account.
</p>
)}
</div>
Expand All @@ -54,14 +52,16 @@ export function WaitlistModal({ ghToken, githubAuthUrl }: WaitlistModalProps) {
/>
)}
{ghToken && (
<a
href="https://www.all-hands.dev/join-waitlist"
target="_blank"
rel="noreferrer"
className="rounded bg-[#FFE165] text-black text-sm font-bold py-[10px] w-full text-center hover:opacity-80"
>
Join Waitlist
</a>
<ModalButton
text="Reconnect to GitHub"
icon={<GitHubLogo width={20} height={20} />}
className="bg-[#791B80] w-full"
onClick={() => {
if (githubAuthUrl) {
window.location.href = githubAuthUrl;
}
}}
/>
)}
</ModalBody>
</ModalBackdrop>
Expand Down
9 changes: 3 additions & 6 deletions frontend/src/routes/_oh.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -196,9 +196,10 @@ export default function MainApp() {
}, []);

React.useEffect(() => {
// If the github token is invalid, open the account settings modal again
// If the github token is invalid, clear it and show the reconnect screen
if (isGitHubErrorReponse(user)) {
setAccountSettingsModalOpen(true);
localStorage.removeItem("ghToken");
setAccountSettingsModalOpen(false);
}
}, [user]);

Expand All @@ -213,10 +214,6 @@ export default function MainApp() {
};

const handleAccountSettingsModalClose = () => {
// If the user closes the modal without connecting to GitHub,
// we need to log them out to clear the invalid token from the
// local storage
if (isGitHubErrorReponse(user)) handleUserLogout();
setAccountSettingsModalOpen(false);
};

Expand Down
2 changes: 1 addition & 1 deletion openhands/events/serialization/action.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ def action_from_dict(action: dict) -> Action:
# images_urls has been renamed to image_urls
if 'images_urls' in args:
args['image_urls'] = args.pop('images_urls')

try:
decoded_action = action_class(**args)
if 'timeout' in action:
Expand Down
4 changes: 2 additions & 2 deletions openhands/resolver/patching/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-

from .patch import parse_patch
from .apply import apply_diff
from .patch import parse_patch

__all__ = ["parse_patch", "apply_diff"]
__all__ = ['parse_patch', 'apply_diff']
34 changes: 17 additions & 17 deletions openhands/resolver/patching/apply.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,33 +10,33 @@

def _apply_diff_with_subprocess(diff, lines, reverse=False):
# call out to patch program
patchexec = which("patch")
patchexec = which('patch')
if not patchexec:
raise SubprocessException("cannot find patch program", code=-1)
raise SubprocessException('cannot find patch program', code=-1)

tempdir = tempfile.gettempdir()

filepath = os.path.join(tempdir, "wtp-" + str(hash(diff.header)))
oldfilepath = filepath + ".old"
newfilepath = filepath + ".new"
rejfilepath = filepath + ".rej"
patchfilepath = filepath + ".patch"
with open(oldfilepath, "w") as f:
f.write("\n".join(lines) + "\n")
filepath = os.path.join(tempdir, 'wtp-' + str(hash(diff.header)))
oldfilepath = filepath + '.old'
newfilepath = filepath + '.new'
rejfilepath = filepath + '.rej'
patchfilepath = filepath + '.patch'
with open(oldfilepath, 'w') as f:
f.write('\n'.join(lines) + '\n')

with open(patchfilepath, "w") as f:
with open(patchfilepath, 'w') as f:
f.write(diff.text)

args = [
patchexec,
"--reverse" if reverse else "--forward",
"--quiet",
"--no-backup-if-mismatch",
"-o",
'--reverse' if reverse else '--forward',
'--quiet',
'--no-backup-if-mismatch',
'-o',
newfilepath,
"-i",
'-i',
patchfilepath,
"-r",
'-r',
rejfilepath,
oldfilepath,
]
Expand All @@ -58,7 +58,7 @@ def _apply_diff_with_subprocess(diff, lines, reverse=False):

# do this last to ensure files get cleaned up
if ret != 0:
raise SubprocessException("patch program failed", code=ret)
raise SubprocessException('patch program failed', code=ret)

return lines, rejlines

Expand Down
2 changes: 1 addition & 1 deletion openhands/resolver/patching/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ def __init__(self, msg, hunk=None):
self.hunk = hunk
if hunk is not None:
super(HunkException, self).__init__(
"{msg}, in hunk #{n}".format(msg=msg, n=hunk)
'{msg}, in hunk #{n}'.format(msg=msg, n=hunk)
)
else:
super(HunkException, self).__init__(msg)
Expand Down
Loading