Repository navigation
fix(desktop): recover invalid connection context #2963
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
base: master
Are you sure you want to change the base?
Changes from all commits
9b3a867
0f6666b
af56b23
20e2d51
3b58fe0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -222,14 +222,20 @@ export function App() { | |
| setPendingConnections((current) => current + (pending ? 1 : -1)); | ||
| } | ||
| const receiveState = useCallback( | ||
| (next: DesktopState) => { | ||
| if ( | ||
| currentState.current && | ||
| next.generation < currentState.current.generation | ||
| ) | ||
| return false; | ||
| (next: DesktopState, readError?: unknown) => { | ||
| const previous = currentState.current; | ||
| if (previous && next.generation < previous.generation) return false; | ||
| currentState.current = next; | ||
| setDesktop(next); | ||
| if (next.active && previous?.retryGeneration !== undefined) { | ||
| setNativeError(null); | ||
| } else if ( | ||
| readError != null && | ||
| !next.active && | ||
| next.retryGeneration === undefined | ||
| ) { | ||
| setNativeError(readError); | ||
| } | ||
|
Comment on lines
+230
to
+238
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [P2] Stale invalidation banner stays visible after reconnecting via Quick Connect After permanent invalidation sets Please clear |
||
| if (!previewMode && next.active?.scope) { | ||
| globalThis.localStorage?.setItem( | ||
| "active-connection-id", | ||
|
|
@@ -239,6 +245,16 @@ export function App() { | |
| "active-scope-id", | ||
| next.active.scope.scope_id, | ||
| ); | ||
| } else if ( | ||
| !previewMode && | ||
| !next.active && | ||
| (previous?.active?.scope || | ||
| previous?.retryGeneration !== undefined || | ||
| next.retryGeneration !== undefined) | ||
| ) { | ||
| // Only native retry can verify the original identity after interruption. | ||
| globalThis.localStorage?.removeItem("active-connection-id"); | ||
| globalThis.localStorage?.removeItem("active-scope-id"); | ||
| } | ||
| if (previewMode && next.active?.connectionId.startsWith("preview-")) { | ||
| setPreviewConnected(true); | ||
|
|
@@ -286,7 +302,12 @@ export function App() { | |
| } | ||
| } | ||
| async function restoreSavedContext(next: DesktopState) { | ||
| if (next.active?.scope || next.profiles.length === 0) return next; | ||
| if ( | ||
| next.active?.scope || | ||
| next.retryGeneration !== undefined || | ||
| next.profiles.length === 0 | ||
| ) | ||
| return next; | ||
| const storedConnectionId = globalThis.localStorage?.getItem( | ||
| "active-connection-id", | ||
| ); | ||
|
|
@@ -593,6 +614,7 @@ export function App() { | |
| contextPending={contextPending || quickConnectPending} | ||
| preview={previewMode} | ||
| hideContent={page === "connections" || page === "settings"} | ||
| onState={receiveState} | ||
| onManageConnections={(profileId) => | ||
| navigate("connections", { profileId }) | ||
| } | ||
|
|
@@ -614,7 +636,10 @@ export function App() { | |
| setNativeError(null); | ||
| void desktopApi | ||
| .selectScope(desktop.active.generation, scope.scope_id) | ||
| .then(receiveState, setNativeError) | ||
| .then(receiveState, async (error: unknown) => { | ||
| setNativeError(error); | ||
| await refreshConnectionState(receiveState); | ||
| }) | ||
|
Comment on lines
+639
to
+642
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [P3] Clear stale switch error after When a scope switch triggers a transient interruption, Required outcome: clear |
||
| .finally(() => connectionPending(false)); | ||
| }} | ||
| onCreateScope={(trigger) => { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[P2] Keep the verified service active when the original Scope is revoked on retry (blocking)
Follow-up on #2963 (comment): after
verify_identityconfirms the deployment and principal are unchanged (line 417), ifinterrupted.api.scope(scope_id)returnsForbiddenorNotFound, this branch callsself.invalidate(&mut inner)?and leavesactive = None, dropping the verified service instead of allowing the user to pick another authorized Scope (inconsistent withcheck_expectedatsession.rs:785-797).Required outcome: when identity verification succeeds but the original Scope returns
Forbidden/NotFound, retireinterruptedand restoreactivewithscope: None(advancinggeneration) so the user can choose another authorized Scope on the verified service.