Repository navigation
Run the newest compatible Posit Assistant installation - #18815
Merged
Merged
Conversation
locatePositAssistantInstallation() returned the first tier that held an installation, in a fixed order: user data directory, then system-wide, then bundled. A per-user install made before a bundle existed therefore shadowed every newer bundled or system-wide copy indefinitely. The user, system, and bundled tiers now compete: an installation whose protocol.json matches this build ranks above one that does not, then the highest package.json version wins, and ties keep the old order. A pinned posit-assistant-path stays outside the race -- it is the administrator's explicit choice, used as-is when valid, and still ends the search for read-only copies when invalid. Managed mode still skips the user tier. With a read-only copy able to outrank the user tier, a manifest version that ranks below it would be offered forever: each accepted install lands in the user data directory and loses the race. userInstallWouldBeSelected() answers whether an install of the offered version would actually be used, and onUpdateCheckComplete() offers nothing when it would not. Addresses #18774
gtritchie
temporarily deployed
to
e2e-playwright
September 14, 2026 18:19 — with
GitHub Actions
Inactive
gtritchie
had a problem deploying
to
e2e-playwright
September 14, 2026 18:19 — with
GitHub Actions
Failure
gtritchie
temporarily deployed
to
e2e-playwright
September 14, 2026 18:19 — with
GitHub Actions
Inactive
gtritchie
temporarily deployed
to
e2e-playwright
September 14, 2026 18:19 — with
GitHub Actions
Inactive
gtritchie
temporarily deployed
to
e2e-playwright
September 14, 2026 18:22 — with
GitHub Actions
Inactive
gtritchie
temporarily deployed
to
e2e-playwright
September 14, 2026 18:22 — with
GitHub Actions
Inactive
gtritchie
temporarily deployed
to
e2e-playwright
September 14, 2026 18:23 — with
GitHub Actions
Inactive
gtritchie
temporarily deployed
to
e2e-playwright
September 14, 2026 18:23 — with
GitHub Actions
Inactive
gtritchie
temporarily deployed
to
e2e-playwright
September 14, 2026 18:23 — with
GitHub Actions
Inactive
gtritchie
temporarily deployed
to
e2e-playwright
September 14, 2026 18:23 — with
GitHub Actions
Inactive
gtritchie
temporarily deployed
to
e2e-playwright
September 14, 2026 18:23 — with
GitHub Actions
Inactive
gtritchie
temporarily deployed
to
e2e-playwright
September 14, 2026 18:23 — with
GitHub Actions
Inactive
RStudio E2E - all platformsAll tests passed!
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 |
The resolver now reads every tier's package.json on each locate() call, which runs per status, verify, chat, and static-file request. Going through getInstalledVersion() made a tier with no readable version warn on every one of those calls. Split the read into a quiet helper that returns the failure as an Error; getInstalledVersion() keeps warning for its callers, and the ranking treats an unreadable version as 0.0.0 without logging.
gtritchie
temporarily deployed
to
e2e-playwright
September 14, 2026 19:44 — with
GitHub Actions
Inactive
gtritchie
temporarily deployed
to
e2e-playwright
September 14, 2026 19:44 — with
GitHub Actions
Inactive
gtritchie
temporarily deployed
to
e2e-playwright
September 14, 2026 19:48 — with
GitHub Actions
Inactive
gtritchie
temporarily deployed
to
e2e-playwright
September 14, 2026 19:48 — with
GitHub Actions
Inactive
gtritchie
temporarily deployed
to
e2e-playwright
September 14, 2026 19:51 — with
GitHub Actions
Inactive
gtritchie
temporarily deployed
to
e2e-playwright
September 14, 2026 19:51 — with
GitHub Actions
Inactive
gtritchie
temporarily deployed
to
e2e-playwright
September 14, 2026 19:55 — with
GitHub Actions
Inactive
gtritchie
temporarily deployed
to
e2e-playwright
September 14, 2026 19:55 — with
GitHub Actions
Inactive
gtritchie
temporarily deployed
to
e2e-playwright
September 14, 2026 19:55 — with
GitHub Actions
Inactive
gtritchie
temporarily deployed
to
e2e-playwright
September 14, 2026 19:55 — with
GitHub Actions
Inactive
gtritchie
temporarily deployed
to
e2e-playwright
September 14, 2026 19:55 — with
GitHub Actions
Inactive
gtritchie
temporarily deployed
to
e2e-playwright
September 14, 2026 19:55 — with
GitHub Actions
Inactive
…stall Review follow-ups on the ranked resolver: - protocol.json is now read through a quiet helper like package.json, so a damaged file in an unselected tier no longer logs an error on every locate() call; getInstalledProtocolVersion() keeps logging for its callers. - A valid posit-assistant-path that shadows an enabled user install now logs the same once-per-session notice as managed mode, since it is the same silent version change. - The suppression log in onUpdateCheckComplete() no longer describes the resolved version as read-only, which it need not be. - The versionless-ranks-lowest tests stage a compatible protocol.json, so they exercise the version ranking rather than the compatibility rule.
gtritchie
temporarily deployed
to
e2e-playwright
September 14, 2026 21:23 — with
GitHub Actions
Inactive
gtritchie
temporarily deployed
to
e2e-playwright
September 14, 2026 21:23 — with
GitHub Actions
Inactive
gtritchie
temporarily deployed
to
e2e-playwright
September 14, 2026 21:25 — with
GitHub Actions
Inactive
gtritchie
temporarily deployed
to
e2e-playwright
September 14, 2026 21:25 — with
GitHub Actions
Inactive
gtritchie
temporarily deployed
to
e2e-playwright
September 14, 2026 21:28 — with
GitHub Actions
Inactive
gtritchie
temporarily deployed
to
e2e-playwright
September 14, 2026 21:28 — with
GitHub Actions
Inactive
gtritchie
temporarily deployed
to
e2e-playwright
September 14, 2026 21:36 — with
GitHub Actions
Inactive
gtritchie
temporarily deployed
to
e2e-playwright
September 14, 2026 21:36 — with
GitHub Actions
Inactive
gtritchie
temporarily deployed
to
e2e-playwright
September 14, 2026 21:36 — with
GitHub Actions
Inactive
gtritchie
temporarily deployed
to
e2e-playwright
September 14, 2026 21:36 — with
GitHub Actions
Inactive
gtritchie
temporarily deployed
to
e2e-playwright
September 14, 2026 21:36 — with
GitHub Actions
Inactive
gtritchie
temporarily deployed
to
e2e-playwright
September 14, 2026 21:36 — with
GitHub Actions
Inactive
This was referenced Sep 15, 2026
Closed
gtritchie
added a commit
that referenced
this pull request
Sep 15, 2026
…uns (#18832) * Serve chat assets from the installation the backend runs handleAIChatRequest() resolved the Posit Assistant installation on every /ai-chat/ static asset request, and loading the chat pane issues dozens of them. Since #18815 that search ranks every tier rather than returning the first hit, so each request read and parsed package.json and protocol.json for up to three tiers. On a network-mounted home directory that is per-request latency multiplied by the number of assets in the chat UI. startChatBackend() now hands the installation it resolved to the static file handler, which serves assets from it for the backend's lifetime. The UI and the server process it talks to come from the same installation, and no filesystem work happens on the asset path at all. The pin is set before the port, because setChatBackendPort() rebuilds the CSP header cache, which reads dist/csp.json from the served installation. The pin outlives the backend, so a page whose backend exited can still load lazily-loaded chunks; the next start overwrites it, which is also how an install or update takes effect. Uninstall clears it, having deleted the directory it names, so requests resolve again and can still find a system-wide or bundled copy. An out-of-band change to the installation -- an administrator replacing the system-wide copy mid-session -- now takes effect at the next backend start rather than on the next asset request. Addresses #18819 * Unpin the served installation as soon as uninstall deletes it The pin was cleared on chatUninstallPositAssistant()'s success tail, but the backup-removal failure returns after aiDir.removeIfExists() has already succeeded, so that path left the static file handler pinned to a deleted directory -- where validateAndResolvePath() fails to canonicalize the client root and asset requests answer 403 rather than resolving to a system-wide or bundled copy. Clear it immediately after the installation directory is removed, which is where the claim that it is gone becomes true, and which covers both exits. Addresses #18819 * Pin the served installation only once the backend has launched startChatBackend() pinned the installation before acquiring the in-use lock and launching the process, and the failure paths in between do not clear it. A start that failed therefore left the static file handler pinned while this session held no in-use lock -- which is what stops another session from mutating the installation -- so a concurrent uninstall could delete the pinned directory and leave asset requests answering 403 instead of resolving to a system-wide or bundled copy. Pin after runProgram() succeeds instead. Every failure above it now returns with nothing pinned, so asset requests resolve for themselves exactly as they do before a backend has ever started, and no failure path needs to remember to clear it. This costs one tier search per backend start: setChatBackendPort() rebuilds the CSP header cache, which reads dist/csp.json through the resolver, and now does so before the pin is set. That is once per start against the dozens of per-request searches this removes, and it resolves the same installation startChatBackend() just chose. Addresses #18819 * Tell the static file handler about the backend only once it runs Moving the installation pin after runProgram() left setChatBackendPort() ahead of it, so the CSP header cache -- which reads dist/csp.json through the resolver and keeps it for the rest of the session -- could seed from a different installation than the one whose assets are then served, if an out-of-band mutation landed between the two. Publish all three things the static file handler knows about the backend together, after the launch succeeds: the installation first, then the port (whose setter rebuilds the CSP cache, now reading from that installation), then the auth token. The token is still generated before launch, because the backend receives it in its environment. Every failure path above now returns having told the handler nothing, so asset requests resolve the installation for themselves exactly as they do before a backend has started. Addresses #18819 * Resolve per request when the pinned installation is gone A rolled-back update or an out-of-band removal can leave the pin naming a directory that no longer exists. Treat that as nothing pinned, so asset requests fall back to whatever tier still holds an installation instead of 404ing for the rest of the session. * Test that a pinned installation that is gone is not served from e94b595 added the fallback but no coverage for it. The test pins a staged installation, asserts it is served, removes the directory, and asserts the next request is not answered from it. The status assertion is what gives the test teeth: a dead pin reaches validateAndResolvePath(), which cannot canonicalize the client root under it and answers Forbidden. Asserting only on the body would pass either way, since that failure returns an empty one -- confirmed by removing the existence guard, where the body assertion still passed and the status assertion caught it (403 vs 403). Addresses #18819 * Test the pin against a complete installation, not just its root e94b595 fell back when the pinned directory was gone, but a directory that is there without being an installation stayed selected. installPackage() extracts into pai/bin in place, and when unzip fails both the cleanup removeIfExists() and the aiPrevDir restore can fail with only a log (SessionChat.cpp:4421-4434) -- leaving a half-extracted pai/bin that the existence check accepts, so asset requests answer from it for the rest of the session instead of falling back to a system-wide or bundled copy. Test the pin with verifyPositAiInstallation(), the same definition the resolver requires of a tier before it will rank it. Four stats per request rather than one, against the twelve stats and six JSON reads this issue started from. The test removes only dist/client/index.html and leaves the requested asset in place, so the half-extracted installation would still serve it: with the existence check the assertion fails on the served body, which is what gives it teeth. Addresses #18819 * Say what a failed chat backend start still publishes The comment above the static file handler setters said every failure path in startChatBackend() returns having told the handler nothing, and that pinning the installation first makes the CSP cache read dist/csp.json from it. The lock and launch failures call clearChatBackendPort(), which resets the handler's port and token and rebuilds the CSP header; the pin-first order only matters when this start makes the session's first rebuild.
This was referenced Sep 21, 2026
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.
Intent
Posit Assistant discovery picks the newest compatible installation across the user, system-wide, and bundled tiers, instead of the first one found in a fixed order.
Fixes #18774.
Approach
locatePositAssistantInstallation()collects the valid installations among the tiers the settings allow and ranks them: an installation whoseprotocol.jsonmatches this build outranks one that does not (a missing file counts as a mismatch, as inhasProtocolMismatch()), then the higherpackage.jsonversion wins, and ties keep the previous order (user, system, bundled). An installation with no readable version ranks lowest but is still used when it is all there is.A pinned
posit-assistant-pathstays outside the race. It is the administrator's explicit choice, so it is used as-is when it holds an installation, even over a newer user install; when it holds none it still ends the search for read-only copies rather than falling back to the bundle. Managed mode (allow-posit-assistant-installation=0) still skips the user tier, and already fell through to the bundled copy before this change.Once a read-only copy can outrank the user tier, the update check needs a guard: a manifest version that ranks below the copy in use would be offered on every check, because each accepted install lands in the user data directory and loses the race.
userInstallWouldBeSelected()reports whether an install of the offered version would actually be used, andonUpdateCheckComplete()makes no offer when it would not. The existing user install never competes there, since it is what the install overwrites, so a manifest rollback of a user-only install still takes effect.Testing
ChatInstallationTests.cppcovers the ranking (newer bundle or system copy over a stale user install, tie order, versionless lowest, protocol compatibility over version, pinned path over a newer user install, invalid pinned path still honouring a user install) and the predicate (nothing installed, replacing the user tier, below and above a read-only copy, incompatible and versionless read-only copies, valid pinned path, managed mode).Not exercised manually: open-source builds ship no bundle, so the bundled tier was driven only through the
InstallSearchPathsseam.