Skip to content

Offer sign-in when the app is disconnected instead of a raw 401 - #740

Merged
alexeyzimarev merged 2 commits into
mainfrom
app-signin-on-401
Sep 1, 2026
Merged

alexeyzimarev merged 2 commits into
mainfrom
app-signin-on-401

Conversation

@alexeyzimarev

@alexeyzimarev alexeyzimarev commented Sep 1, 2026 •

Copy link
Copy Markdown
Member

Closes #739 — AI-2407

What & why

Starting a session while the app could not authenticate rendered the raw transport text ("Response status code does not indicate success: 401 (Unauthorized).") under the composer, with no way back to a login. Start is now disabled unless both the daemon attach and its upstream server connection are up, the launcher says why (connecting / daemon not running / signed out), and both a lost server connection and a typed 401 launch outcome offer a Sign in button. That button opens the wizard's sign-in step in a standalone dialog pinned to the configured server; a committed sign-in closes the dialog and clears the prompt.

Where to look

ReauthComposition stages the wizard's own Paste intent for the profile's server — sign-in reuses the wizard's commit boundary unchanged, cannot repoint server_url, and a Paste intent never produces the WorkOS Retarget answer, which is why the dialog needs no Connect step. The daemon reports no reason for "disconnected", so the sign-in prompt also shows when the server itself is down; the dialog then fails visibly with a network error rather than fixing anything.

Verification

  • App suite: 1277/1277 pass (dotnet run --project test/Capacitor.App.Tests.Unit/...).
  • Full dotnet test --solution: 10898 tests, 2 failures — both on the documented environmental list (codex schema pin drift; Wedged_initialize_* load flake, passes 1/1 in isolation) in a suite that does not reference Capacitor.App.
  • New behavior is mutation-checked: unhinging AvailabilityFor or the 401 flag fails exactly the new tests.

🤖 Generated with Claude Code

The re-auth dialog stages the wizard's own Paste intent for the profile's
configured server, so it reuses the wizard commit boundary and cannot repoint
server_url; a Paste intent never answers Retarget, which is what lets the
dialog exist without a Connect step.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@qodo-code-review

Copy link
Copy Markdown

ⓘ Qodo reviews are paused because your trial has ended. Ask your workspace admin to add credits to resume reviews. Manage billing

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 1, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-09-01T17:34:11.426295Z 286dc19 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 286dc19adf

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/Capacitor.App/App.axaml.cs Outdated
Comment on lines +399 to +402
window.Closed += (_, _) => {
graph.SignIn.PropertyChanged -= OnSignInChanged;
_signInWindow = null;
_ = FinishSignInAsync(graph);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Quiesce re-auth before completing app shutdown

When the user quits while this dialog has a live sign-in attempt, the graph exists only in this closure: DisposeAndShutdownAsync quiesces _wizardAuth but neither closes nor awaits this steady-state graph. The confirmed TryShutdown eventually closes the window and starts FinishSignInAsync, but that task is fire-and-forget, so the process can terminate while cancellation or a post-boundary credential commit is still running. Retain the re-auth graph/task and settle it before confirming shutdown, as is already done for wizard authentication.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 398190e. The dialog's settle task (FinishSignInAsync) is now retained in a field; DisposeAndShutdownAsync closes the dialog first — still on the UI thread, before the ConfigureAwait(false) quiesce hop — and awaits the settle, so a live attempt is cancelled pre-boundary or a commit already past the boundary finishes before the process exits. This also covers a quit arriving just after the user closed the dialog mid-attempt, where the settle was previously still in flight.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Start fires while disconnected and shows a raw 401 instead of a sign-in path

1 participant