Repository navigation
Revert the assistant selection when a Posit Assistant install is declined - #18629
Merged
Merged
Conversation
Switching the code assistant from GitHub Copilot to Posit AI writes the assistant preference straight away -- disableCopilot() stops the Copilot agent by writing it, since the backend picks the agent to run from that preference and not from copilot_enabled. checkPositAssistantInstallation then read the value to revert to *after* that write had replaced it with "posit", so declining the install prompt reverted to "posit" and early-returned, leaving the assistant pointing at an addon that was never installed and code suggestions reporting "No completions available". Callers now capture the outgoing selection before disableCopilot() runs and pass it to the check, and the revert restores copilot_enabled alongside the assistant it mirrors -- reverting to Copilot without it would name an agent the backend keeps stopped. The revert's nothing-to-undo guard also consults the persisted preference, which disableCopilot() can have moved out from under the selector. Covered by a Playwright regression test that forces the update check to offer a fresh install (chat_set_update_check_override), declines the prompt, and asserts both preferences return to Copilot. It fails on the previous behavior with the selector left at "posit". Addresses #18356
The revert introduced in the previous commit read the assistant preference for its target, so a selection made earlier in the same dialog -- which is not persisted until OK -- was lost. Starting from (None), picking GitHub Copilot and then Posit AI and declining the install dropped back to (None) rather than Copilot. The selector's prior value is now tracked across changes and used as the revert target. Undoing the preference is gated separately, on the preference actually holding "posit": that is true exactly when the switch persisted it (disableCopilot, or the write before an install), and writing unconditionally would otherwise persist a selection the user never confirmed. Addresses #18356
The revert wrote the preference whenever it held "posit", on the assumption that only this switch could have put it there. It could equally have been the saved setting: with Posit AI saved, selecting Copilot without applying and then Posit AI again and declining the install persisted Copilot, so cancelling the dialog no longer restored Posit AI. The selection and the preference are now both carried by a RevertTarget captured at the start of the check, and each is restored to its own prior value -- the preference only when it actually changed. That replaces the three "previous" parameters threaded through the check, prompt, install, and revert path, so those signatures get shorter rather than longer. Adds the matching Playwright case; it fails on 6f38919 with the preference persisted as "copilot". Addresses #18356
The comment on the copilot_enabled write claimed a revert to Copilot would otherwise leave the agent disabled. It would not: nothing gates the agent on that preference -- isAssistantEnabled() picks the agent from userPrefs().assistant() and checks the admin's copilot-enabled session option, and no session module reads the pref at all. The write is still needed, because disableCopilot() gates its own write on it: left false under a reverted Copilot selection, the next switch away from Copilot would not persist. Both the Java comment and its copy in the test now say that. Also drops the redundant previousAssistantSelection_ initialiser (initDisplay assigns it before any user change can reach the handler, and initialize() can move the selector past it) and dismisses leftover modals in the spec's afterEach, as the two sibling preference specs do -- a mid-test failure otherwise leaves the options dialog up for the next test. Addresses #18356
gtritchie
temporarily deployed
to
e2e-playwright
August 26, 2026 13:14 — with
GitHub Actions
Inactive
gtritchie
temporarily deployed
to
e2e-playwright
August 26, 2026 13:14 — with
GitHub Actions
Inactive
gtritchie
temporarily deployed
to
e2e-playwright
August 26, 2026 13:18 — with
GitHub Actions
Inactive
gtritchie
temporarily deployed
to
e2e-playwright
August 26, 2026 13:18 — with
GitHub Actions
Inactive
gtritchie
had a problem deploying
to
e2e-playwright
August 26, 2026 13:22 — with
GitHub Actions
Failure
gtritchie
temporarily deployed
to
e2e-playwright
August 26, 2026 13:22 — with
GitHub Actions
Inactive
gtritchie
temporarily deployed
to
e2e-playwright
August 26, 2026 13:30 — with
GitHub Actions
Inactive
gtritchie
temporarily deployed
to
e2e-playwright
August 26, 2026 13:30 — with
GitHub Actions
Inactive
gtritchie
temporarily deployed
to
e2e-playwright
August 26, 2026 13:30 — with
GitHub Actions
Inactive
gtritchie
temporarily deployed
to
e2e-playwright
August 26, 2026 13:30 — with
GitHub Actions
Inactive
gtritchie
temporarily deployed
to
e2e-playwright
August 26, 2026 13:30 — with
GitHub Actions
Inactive
gtritchie
temporarily deployed
to
e2e-playwright
August 26, 2026 13:30 — with
GitHub Actions
Inactive
RStudio E2E - all platforms1 test(s) failed
View / download the full reportView report online -- opens in the browser, no download needed. Available for 14 days. Download playwright-report.zip -- extract and open
All platforms - commit |
This branch was previously deployed
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Fixes #18356.
Switching the code assistant away from GitHub Copilot persists the new selection immediately:
disableCopilot()stops the Copilot agent by writing theassistantpreference, because the backend picks the agent to run from that preference and not fromcopilot_enabled(isAssistantEnabled()inSessionAssistant.cpp). That write lands before OK or Cancel, so anything that backs the switch out has to undo it.checkPositAssistantInstallation()read its revert target after that write had already replaced it with"posit". Declining the Posit Assistant install prompt therefore reverted to"posit"and early-returned, leaving the assistant pointing at an addon that was never installed and code suggestions reporting "Posit AI: No completions available." Cancelling the Options dialog did not undo it either.What changed
A
RevertTarget, captured when the check starts, carries the two values the check may have to put back:(None)a Copilot pick followed by Posit AI has to fall back to Copilot.The revert also restores
copilot_enabledalongside the preference it mirrors, asonApply()derives it. Nothing gates the agent on that preference, butdisableCopilot()gates its own write on it: left false under a reverted Copilot selection, the next switch away from Copilot would not persist.Threading one object replaced the three
previous*parameters that ran through the check, prompt, install, and revert path, so those signatures got shorter.Tests
e2e/rstudio/tests/preferences/assistant_provider_switch.test.tsdrives Global Options and forces the install prompt through thechat_set_update_check_overrideautomation RPC, so it needs no credentials, no network, and no particular addon state. Each case was confirmed to fail on the commit preceding its fix:posit(None)-> unsaved Copilot -> Posit AI -> declinenoneassistantpersisted ascopilotTagged
@desktop_only: GitHub Copilot is offered in the selector only when thecopilot-enabledsession option is set, which defaults on in Desktop mode alone.All 30 tests in
tests/preferences/pass on a desktop-dev build.Known gap, not addressed here
The
assistantVerifyInstallederror path (AssistantPreferencesPane.java:598) still leaves"posit"persisted when that RPC fails: it logs and sets a status label without reverting. It predates this change and is a different trigger from the one the issue describes, and closing it means deciding what the user sees -- every other revert path pairs the revert with an error dialog, whereas reverting there would swap panels and overwrite the status label, so the selector would snap back with no explanation. Worth a follow-up issue.