-
Notifications
You must be signed in to change notification settings - Fork 2.8k
fix(oauth): make loopback redirect actually work, plus settings cleanup #2550
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
Merged
senamakel
merged 11 commits into
tinyhumansai:main
from
senamakel:fix/oauth-loopback-dev-redirect
May 23, 2026
Merged
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
08c21ac
fix(oauth): don't set responseType=json when loopback is active
senamakel 5471f58
fix(oauth): allow loopback OAuth commands in core-process capability
senamakel fed0625
Merge remote-tracking branch 'upstream/main' into fix/oauth-loopback-…
senamakel 8dbc749
fix(oauth): rebind-safety + ephemeral-port fallback + camelCase result
senamakel 4380405
feat(home): move theme toggle into the homepage card header
senamakel 18034e6
feat(settings): tab Notifications preferences and Routing under one e…
senamakel 9f9a078
refactor(settings): move destructive actions to Account, drop Connect…
senamakel 8b0cc3d
chore: apply auto-fixes
senamakel 62604c5
chore(i18n): seed settings.notifications.tabs keys in all locale chunks
senamakel 82261a8
fix(settings): address CodeRabbit review on PR #2550
senamakel bb42e73
fix(settings): surface logout failures + tighten test harness
senamakel File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| [[permission]] | ||
| identifier = "allow-loopback-oauth" | ||
| description = "Permission to start / stop the one-shot http://127.0.0.1:<port>/auth listener used as the RFC 8252 OAuth callback target (see #2511). Narrow on purpose so consumers of the broader `allow-core-process` group do not inherit OAuth listener control." | ||
|
|
||
| [permission.commands] | ||
|
|
||
| allow = [ | ||
| "start_loopback_oauth_listener", | ||
| "stop_loopback_oauth_listener", | ||
| ] | ||
|
|
||
| deny = [] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,188 @@ | ||
| import debug from 'debug'; | ||
| import { useId, useState } from 'react'; | ||
|
|
||
| import { useT } from '../../lib/i18n/I18nContext'; | ||
| import { useCoreState } from '../../providers/CoreStateProvider'; | ||
| import { clearAllAppData } from '../../utils/clearAllAppData'; | ||
| import SettingsMenuItem from './components/SettingsMenuItem'; | ||
|
|
||
| const warnLog = debug('settings:account:warn'); | ||
|
|
||
| /** | ||
| * Destructive account actions: Log out, and Log out + clear all app data. | ||
| * Lives at the bottom of the Settings → Account page. Owns its own modal | ||
| * state and confirmation flow so the parent page is just a list + this row. | ||
| */ | ||
| const LogoutAndClearActions = () => { | ||
| const { t } = useT(); | ||
| const { clearSession, snapshot } = useCoreState(); | ||
| const [showLogoutAndClearModal, setShowLogoutAndClearModal] = useState(false); | ||
| const [isLoading, setIsLoading] = useState(false); | ||
| const [error, setError] = useState<string | null>(null); | ||
| const modalTitleId = useId(); | ||
|
|
||
| const handleLogout = async () => { | ||
| try { | ||
| await clearSession(); | ||
| } catch (err) { | ||
| // Log only the message — `err` may carry stack frames / serialized | ||
| // backend payloads we don't want in renderer console. | ||
| const reason = err instanceof Error ? err.message : String(err); | ||
| warnLog('logout_failed %o', { reason }); | ||
| setError(t('clearData.failedLogout')); | ||
| } | ||
| }; | ||
|
|
||
| const handleLogoutAndClearData = async () => { | ||
| try { | ||
| setIsLoading(true); | ||
| setError(null); | ||
| const currentUserId = snapshot.auth.userId ?? snapshot.currentUser?._id ?? null; | ||
| await clearAllAppData({ clearSession, userId: currentUserId }); // restarts the app | ||
| } catch (err) { | ||
| const message = err instanceof Error ? err.message : String(err); | ||
| setError(message || t('clearData.failed')); | ||
| } finally { | ||
| setIsLoading(false); | ||
| } | ||
| }; | ||
|
|
||
| const arrowOutIcon = ( | ||
| <svg className="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24"> | ||
| <path | ||
| strokeLinecap="round" | ||
| strokeLinejoin="round" | ||
| strokeWidth={2} | ||
| d="M17 16l4-4m0 0l-4-4m4 4H7m6 4v1a3 3 0 01-3 3H6a3 3 0 01-3-3V7a3 3 0 013-3h4a3 3 0 013 3v1" | ||
| /> | ||
| </svg> | ||
| ); | ||
|
|
||
| // Inline error is only displayed below the row when the clear-data modal is | ||
| // closed — when the modal is open, it owns the error display. Without this | ||
| // surface, a `handleLogout` failure would set `error` but the user would | ||
| // never see it. | ||
| const showInlineError = error !== null && !showLogoutAndClearModal; | ||
|
|
||
| return ( | ||
| <div className="mt-6"> | ||
| <SettingsMenuItem | ||
| icon={arrowOutIcon} | ||
| title={t('settings.clearAppData')} | ||
| description={t('settings.clearAppDataDesc')} | ||
| onClick={() => setShowLogoutAndClearModal(true)} | ||
| testId="settings-nav-logout-and-clear" | ||
| dangerous | ||
| isFirst | ||
| /> | ||
| <SettingsMenuItem | ||
| icon={arrowOutIcon} | ||
| title={t('settings.logOut')} | ||
| description={t('settings.logOutDesc')} | ||
| onClick={handleLogout} | ||
| testId="settings-nav-logout" | ||
| dangerous | ||
| isLast | ||
| /> | ||
|
|
||
| {showInlineError && ( | ||
| <div | ||
| role="alert" | ||
| data-testid="logout-error" | ||
| className="mt-3 mx-1 p-3 rounded-lg bg-coral-100 dark:bg-coral-500/20 border border-coral-500/20"> | ||
| <p className="text-coral-600 dark:text-coral-300 text-sm">{error}</p> | ||
| </div> | ||
| )} | ||
|
|
||
| {showLogoutAndClearModal && ( | ||
| <div className="fixed inset-0 z-50 flex items-center justify-center p-4 bg-black/30"> | ||
| <div | ||
| role="dialog" | ||
| aria-modal="true" | ||
| aria-labelledby={modalTitleId} | ||
| className="bg-white dark:bg-neutral-900 rounded-2xl max-w-md w-full p-6 border border-stone-200 dark:border-neutral-800"> | ||
| <div className="flex items-center gap-3 mb-4"> | ||
| <div className="w-10 h-10 rounded-lg bg-amber-100 dark:bg-amber-500/20 flex items-center justify-center"> | ||
| <svg | ||
| className="w-5 h-5 text-amber-400" | ||
| fill="none" | ||
| stroke="currentColor" | ||
| viewBox="0 0 24 24"> | ||
| <path | ||
| strokeLinecap="round" | ||
| strokeLinejoin="round" | ||
| strokeWidth={2} | ||
| d="M17 16l4-4m0 0l-4-4m4 4H7m6 4v1a3 3 0 01-3 3H6a3 3 0 01-3-3V7a3 3 0 013-3h4a3 3 0 013 3v1" | ||
| /> | ||
| </svg> | ||
| </div> | ||
| <div> | ||
| <h3 | ||
| id={modalTitleId} | ||
| className="text-lg font-semibold text-stone-900 dark:text-neutral-100"> | ||
| {t('clearData.title')} | ||
| </h3> | ||
| </div> | ||
| </div> | ||
|
|
||
| <div className="mb-6"> | ||
| <div className="text-stone-700 dark:text-neutral-200 text-sm leading-relaxed"> | ||
| <p>{t('clearData.warning')}</p> | ||
| <ul className="list-disc pl-5 mt-2 space-y-1"> | ||
| <li>{t('clearData.bulletSettings')}</li> | ||
| <li>{t('clearData.bulletCache')}</li> | ||
| <li>{t('clearData.bulletWorkspace')}</li> | ||
| <li>{t('clearData.bulletOther')}</li> | ||
| </ul> | ||
| <p className="mt-3">{t('clearData.irreversible')}</p> | ||
| </div> | ||
|
|
||
| {error && ( | ||
| <div className="mt-3 p-3 rounded-lg bg-coral-100 dark:bg-coral-500/20 border border-coral-500/20"> | ||
| <p className="text-coral-600 dark:text-coral-300 text-sm">{error}</p> | ||
| </div> | ||
| )} | ||
| </div> | ||
|
|
||
| <div className="flex gap-3"> | ||
| <button | ||
| onClick={() => { | ||
| setShowLogoutAndClearModal(false); | ||
| setError(null); | ||
| }} | ||
| disabled={isLoading} | ||
| className="flex-1 px-4 py-2 rounded-lg border border-stone-200 dark:border-neutral-800 text-stone-700 dark:text-neutral-200 hover:bg-stone-100 dark:hover:bg-neutral-800 dark:bg-neutral-800 dark:hover:bg-neutral-800 transition-colors disabled:opacity-50"> | ||
| {t('common.cancel')} | ||
| </button> | ||
| <button | ||
| onClick={handleLogoutAndClearData} | ||
| disabled={isLoading} | ||
| className="flex-1 px-4 py-2 rounded-sm bg-amber-600 hover:bg-amber-500 text-white transition-colors disabled:opacity-50 flex items-center justify-center gap-2"> | ||
| {isLoading && ( | ||
| <svg className="w-4 h-4 animate-spin" fill="none" viewBox="0 0 24 24"> | ||
| <circle | ||
| className="opacity-25" | ||
| cx="12" | ||
| cy="12" | ||
| r="10" | ||
| stroke="currentColor" | ||
| strokeWidth="4" | ||
| /> | ||
| <path | ||
| className="opacity-75" | ||
| fill="currentColor" | ||
| d="M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z" | ||
| /> | ||
| </svg> | ||
| )} | ||
| {isLoading ? t('clearData.clearing') : t('clearData.title')} | ||
| </button> | ||
| </div> | ||
| </div> | ||
| </div> | ||
| )} | ||
| </div> | ||
| ); | ||
| }; | ||
|
|
||
| export default LogoutAndClearActions; | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.