René's URL Explorer Experiment


Title: fix(site): prefer permitted organization for chat creation by ibetitsmike · Pull Request #28078 · coder/coder · GitHub

Open Graph Title: fix(site): prefer permitted organization for chat creation by ibetitsmike · Pull Request #28078 · coder/coder

X Title: fix(site): prefer permitted organization for chat creation by ibetitsmike · Pull Request #28078 · coder/coder

Description: Fixes first-send 403s for multi-org users who lack chat:create in the deployment default organization (CODAGT-892). Two frontend defects combined to send chat creation to the wrong organization: The Agents create form initialized its organization selection permission-blind to the default org and only corrected it when the permittedOrganizations authcheck result transitioned, so a fast first send raced the check, and on warm-query-cache remounts the correction never ran at all: the wrong org stayed selected permanently while the org picker was hidden. The permitted-organizations authcheck itself sent no owner_id, so roles that grant chat:create at member (owner) scope, such as agents-access (Coder Agents User, the exact role in the customer report), were denied in every organization and the form always fell back to the default org. This part was split out and already landed on main via #28076; after rebasing, this PR relies on that fix and keeps its stricter regression stories around it. Changes Derive the effective organization at render time: keep the user's explicit pick only while it is still permitted, otherwise fall back to the permitted default org, then the first permitted org, then the dashboard default. Replaces the transition-based reconciliation, which could not fire when the query cache was already warm on mount. Keep user-driven org cleanup (workspace selection, attachments) in the picker/dialog event handlers; permission-driven changes are handled by render-time state adjustments and the attachment hook's post-commit adoption effect. Disable Send until the permitted-organizations check settles and the attachment hook has adopted the effective org; hide the org picker and disable the workspace picker until the check settles (their pre-settlement options come from the unfiltered dashboard fallback, so a pick could persist a foreign-org workspace). Scope persisted attachments to their organization in useFileAttachments: restoration defers until a permitted org is known, permission-driven org changes replace attachment state post-commit, in-flight uploads are invalidated by an adoption epoch (including A-to-B-to-A round trips), and no render exposes another org's file IDs, including when authorization resolves to no org at all. Revalidate org-scoped state on permission refetches: a revoked explicit selection clears instead of lying latent, a settled effective-org change drops the stored workspace, and the org-change confirmation dialog closes (and re-checks on confirm) when its pending org is revoked. Rebase reconciliation with #28076: the stories use its permittedOrganizationsKey helper and retain its MemberScopedPermissionsShowOrgPicker regression story alongside this PR's stricter member-scope stories. The backend RBAC rejection was correct; this is frontend-only. Testing Red-green: every guard above was verified by reverting it and confirming exactly its guarding story or unit test fails (whole-file runs). pnpm -C site check, pnpm -C site lint, pnpm -C site lint:types, full AgentCreateForm.stories.tsx (42 pass), useFileAttachments.test.tsx (8 pass), re-run after the rebase onto main. Dogfood UAT on a licensed multi-org dev deployment at this branch: a restricted user with agents-access only in a non-default org sends first and warm-remount messages successfully (201, payload carries the permitted org, no 403); admin picker, workspace filtering, and attachment org-change dialog verified. Round 2 of UAT caught the missing owner_id (now landed via #28076); round 3 re-verified end to end. Mux created this PR on Mike's behalf.

Open Graph Description: Fixes first-send 403s for multi-org users who lack chat:create in the deployment default organization (CODAGT-892). Two frontend defects combined to send chat creation to the wrong organization: T...

X Description: Fixes first-send 403s for multi-org users who lack chat:create in the deployment default organization (CODAGT-892). Two frontend defects combined to send chat creation to the wrong organization: T...

Opengraph URL: https://github.com/coder/coder/pull/28078

X: @github

direct link

Domain: github.com

react-profiling0
react-import-mapreact,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322
route-pattern/:user_id/:repository/pull/:id/files(.:format)
route-controllerpull_requests
route-actionfiles
fetch-noncev2:60e59750-8a21-8f5c-70f1-e21c3296ab33
current-catalog-service-hashae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b
request-idC66C:72B39:A58CF:E0315:6B007FAE
html-safe-nonce68cd46d0cb456d962e29f93a94e20b0dd60835abcf4f40a84be6f29dd18792c6
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDNjZDOjcyQjM5OkE1OENGOkUwMzE1OjZCMDA3RkFFIiwidmlzaXRvcl9pZCI6IjQ1Nzk2OTkyODk5NDAzMjgzNjYiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ==
visitor-hmace29e84ee69010bc73600667d62340a5298d6d734655fe1d5bfdf720776d0962f
hovercard-subject-tagpull_request:4264742269
github-keyboard-shortcutsrepository,pull-request-list,pull-request-conversation,pull-request-files-changed,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///pull_requests/show/files
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/coder/coder/pull/28078/files
twitter:imagehttps://avatars.githubusercontent.com/u/203725896?s=400&v=4
twitter:cardsummary_large_image
og:imagehttps://avatars.githubusercontent.com/u/203725896?s=400&v=4
og:image:altFixes first-send 403s for multi-org users who lack chat:create in the deployment default organization (CODAGT-892). Two frontend defects combined to send chat creation to the wrong organization: T...
og:site_nameGitHub
og:typeobject
hostnamegithub.com
expected-hostnamegithub.com
None82c186f13e104004ab7bdb779f3195e59dd38bfde531aaa74b76470fc2462b83
turbo-cache-controlno-preview
diff-viewunified
go-importgithub.com/coder/coder git https://github.com/coder/coder.git
octolytics-dimension-user_id95932066
octolytics-dimension-user_logincoder
octolytics-dimension-repository_id440752086
octolytics-dimension-repository_nwocoder/coder
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id440752086
octolytics-dimension-repository_network_root_nwocoder/coder
turbo-body-classeslogged-out env-production page-responsive full-width
disable-turbotrue
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
released1bc2aa1939001689f5ce935982c10a6138f745c
ui-targetfull
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://github.com/coder/coder/pull/28078/changes#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fcoder%2Fcoder%2Fpull%2F28078%2Ffiles
GitHubRepository hosting, code review, and collaborationhttps://github.com/platform
CopilotAI coding agent for tasks, projects, and automated workhttps://github.com/features/copilot
ActionsCI/CD and automationhttps://github.com/features/actions
Code QualityQuality analysis, fixes, and enforcementhttps://github.com/features/code-quality
CodespacesCloud development environmentshttps://github.com/features/codespaces
Code SecurityVulnerability detection and remediationhttps://github.com/security/advanced-security/code-security
Secret ProtectionSecret scanning and leak preventionhttps://github.com/security/advanced-security/secret-protection
All Featureshttps://github.com/features
Documentationhttps://docs.github.com/en
Traininghttps://learn.github.com/skills
Certificationshttps://learn.github.com/credentials
Build with Copilothttps://github.com/features/ai
Customize Copilothttps://docs.github.com/en/copilot/how-tos/copilot-on-github/customize-copilot/customize-copilot-overview
Integrationshttps://github.com/marketplace
Trending reposhttps://github.com/trending
GitHub Sponsorshttps://github.com/open-source/sponsors
Developer articleshttps://github.com/resources/articles
ChangelogYour source for the latest features, improvements, and fixes across GitHub products, all in one place.https://github.blog/changelog/
Enterpriseshttps://github.com/enterprise
Teamhttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
See all industrieshttps://github.com/solutions/industry
Why GitHubhttps://github.com/why-github
Customer Storieshttps://github.com/customer-stories
Business insightshttps://github.com/solutions/executive-insights
Trust Centerhttps://github.com/trust-center
GitHub Advanced SecurityEnterprise-grade code securityhttps://github.com/security/advanced-security
Copilot for businessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/enterprise/premium-support
Documentationhttps://docs.github.com/en
Resource centerhttps://github.com/resources
Bloghttps://github.blog/
Events & webinarshttps://github.com/resources/events
Community Forumhttps://github.com/orgs/community/discussions
Customer Storieshttps://github.com/customer-stories
Integrationshttps://github.com/marketplace
Customer supporthttps://help.github.com/
Traininghttps://learn.github.com/skills
GitHub Statushttps://www.githubstatus.com/
Abouthttps://github.com/about
Partnershttps://github.com/partners
Changeloghttps://github.blog/changelog/
GitHub UniverseThe event for developers, by developers — talks, workshops, and what’s next for GitHub.https://githubuniverse.com/
Pricinghttps://github.com/pricing
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fcoder%2Fcoder%2Fpull%2F28078%2Ffiles
Sign uphttps://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fpull_requests%2Fshow%2Ffiles&source=header-repo&source_repo=coder%2Fcoder
Reloadhttps://github.com/coder/coder/pull/28078/changes
Reloadhttps://github.com/coder/coder/pull/28078/changes
Reloadhttps://github.com/coder/coder/pull/28078/changes
coderhttps://github.com/coder
coderhttps://github.com/coder/coder
Codehttps://github.com/coder/coder
Issues323 (323)https://github.com/coder/coder/issues
Pull requests491 (491)https://github.com/coder/coder/pulls
Discussionshttps://github.com/coder/coder/discussions
Actionshttps://github.com/coder/coder/actions
Projectshttps://github.com/coder/coder/projects
Security and quality49 (49)https://github.com/coder/coder/security
Insightshttps://github.com/coder/coder/insights
Sign up for GitHub https://github.com/signup?return_to=%2Fcoder%2Fcoder%2Fissues%2Fnew%2Fchoose
terms of servicehttps://docs.github.com/terms
privacy statementhttps://docs.github.com/privacy
Sign inhttps://github.com/login?return_to=%2Fcoder%2Fcoder%2Fissues%2Fnew%2Fchoose
ibetitsmikehttps://github.com/ibetitsmike
mainhttps://github.com/coder/coder/tree/main
mike/codagt-892-chat-org-selectionhttps://github.com/coder/coder/tree/mike/codagt-892-chat-org-selection
Conversation 111 https://github.com/coder/coder/pull/28078
Commits 29 https://github.com/coder/coder/pull/28078/commits
Checks 57 https://github.com/coder/coder/pull/28078/checks
Files changed https://github.com/coder/coder/pull/28078/files
Please reload this pagehttps://github.com/coder/coder/pull/28078/changes
fix(site): prefer permitted organization for chat creation https://github.com/coder/coder/pull/28078/changes#top
Show all changes 29 commits https://github.com/coder/coder/pull/28078/files
bddb41b fix(site): prefer permitted organization for chat creation ibetitsmike Aug 12, 2026 https://github.com/coder/coder/pull/28078/commits/bddb41bb278e192f5e8c921e7ac3126e771166c2
b6f2a63 fix(site): keep user-driven org cleanup in event handlers ibetitsmike Aug 12, 2026 https://github.com/coder/coder/pull/28078/commits/b6f2a63b69ff79f2c2740083575151e8cebedb4d
a7e078f fix(site): scope chat permitted-org check to the current user ibetitsmike Aug 12, 2026 https://github.com/coder/coder/pull/28078/commits/a7e078f68eb8628df91f72c4c776bcd934c4f2c4
bcfe72a chore(site/src/pages/AgentsPage): tighten authcheck comments ibetitsmike Aug 12, 2026 https://github.com/coder/coder/pull/28078/commits/bcfe72abcbc6788a4fb4122a5c75b0cdc22536b5
887c7be fix(site): derive chat workspace selection instead of effect-driven r… ibetitsmike Aug 12, 2026 https://github.com/coder/coder/pull/28078/commits/887c7bef39e4b0ce022706cdae5364ae83fe52d4
d3f35d6 fix(site): defer chat attachment restore and sends until permitted or… ibetitsmike Aug 12, 2026 https://github.com/coder/coder/pull/28078/commits/d3f35d6cf81b9d4040764ffd8fb845091903e448
f27db49 fix(site): block chat send without a permitted org and rescope attach… ibetitsmike Aug 12, 2026 https://github.com/coder/coder/pull/28078/commits/f27db49a8fad19babe0d650a574340a61178ec60
fa5bf74 fix(site): hide stale attachment state during org adoption and tighte… ibetitsmike Aug 12, 2026 https://github.com/coder/coder/pull/28078/commits/fa5bf743c04751f5fe52f91e5447f868da305d88
d6bf2d2 fix(site): keep attachment state org-less when no org is permitted ibetitsmike Aug 12, 2026 https://github.com/coder/coder/pull/28078/commits/d6bf2d2035ab88c69fb9a3fbd2bae455df5559ca
0181799 refactor(site/src/pages/AgentsPage): drop type assertions in attachme… ibetitsmike Aug 12, 2026 https://github.com/coder/coder/pull/28078/commits/0181799886d9be0b62375652c681ace38bb42546
21756f9 fix(site/src/pages/AgentsPage): ignore file drops until org authoriza… ibetitsmike Aug 12, 2026 https://github.com/coder/coder/pull/28078/commits/21756f9763c7123af4d4fba9b087cbda2df3d695
2a8ab8c fix(site/src/pages/AgentsPage): move attachment restoration out of re… ibetitsmike Aug 12, 2026 https://github.com/coder/coder/pull/28078/commits/2a8ab8c03802fa7375212e04aaa68d68dfb7aca6
958ff0d fix(site/src/pages/AgentsPage): gate composer on attachment org adoption ibetitsmike Aug 12, 2026 https://github.com/coder/coder/pull/28078/commits/958ff0daa612dcab074528b9ac6b2a09707ca56d
531da5c fix(site/src/pages/AgentsPage): discard upload completions from an ab… ibetitsmike Aug 12, 2026 https://github.com/coder/coder/pull/28078/commits/531da5ca3da3478885342aee18ddd91bebb1c56a
f4fa619 fix(site/src/pages/AgentsPage): invalidate uploads across org round t… ibetitsmike Aug 12, 2026 https://github.com/coder/coder/pull/28078/commits/f4fa619ad3c96e7a8a4ab9e39ecbf62acaf4ee9d
25bebdb fix(site/src/pages/AgentsPage): clear org selection revoked by permis… ibetitsmike Aug 12, 2026 https://github.com/coder/coder/pull/28078/commits/25bebdb16731a34e5f24f40807a6c1fded18b33c
b09e60d fix(site/src/pages/AgentsPage): revalidate org-scoped state on permis… ibetitsmike Aug 12, 2026 https://github.com/coder/coder/pull/28078/commits/b09e60d8b5a601cc62778a51e95e325da3981180
f1185d8 chore(site/src/pages/AgentsPage): cleanup gate round 6 ibetitsmike Aug 12, 2026 https://github.com/coder/coder/pull/28078/commits/f1185d833d34885560133c8d17a12d542f818f0c
8b4fcee fix(site/src/pages/AgentsPage): block send until stored workspace val… ibetitsmike Aug 12, 2026 https://github.com/coder/coder/pull/28078/commits/8b4fceef160feafc2d637be0b41ebee4b1beb7fe
a6582b3 fix(site/src/pages/AgentsPage): keep fallback org across permission r… ibetitsmike Aug 12, 2026 https://github.com/coder/coder/pull/28078/commits/a6582b35af52a3737cc2379bb1ca12bd31a5a296
d09c67c fix(site/src/pages/AgentsPage): preserve stored workspace while no or… ibetitsmike Aug 12, 2026 https://github.com/coder/coder/pull/28078/commits/d09c67c097ec81cb0de9e5c217fd881609fb56a3
64a9f7c chore(site/src/pages/AgentsPage): cleanup gate round 7 ibetitsmike Aug 13, 2026 https://github.com/coder/coder/pull/28078/commits/64a9f7c9cfaecb7fae5d4a0bafe7fb9a0a8ef113
353b78a fix(site/src/pages/AgentsPage): ignore stale permitted cache when org… ibetitsmike Aug 13, 2026 https://github.com/coder/coder/pull/28078/commits/353b78a017ab2e4bb12a8434ba24757ce91f72ec
cae3925 chore(site/src/pages/AgentsPage): cleanup gate round 8 ibetitsmike Aug 13, 2026 https://github.com/coder/coder/pull/28078/commits/cae3925fa7cb8a365a2ed2b85f0d773bf6a47f65
fa80a1f refactor(site/src/pages/AgentsPage): query org selector by role in ne… ibetitsmike Aug 13, 2026 https://github.com/coder/coder/pull/28078/commits/fa80a1fb9bb614c6dadeffc3dcfe281b2d0427ab
3ca42bd fix(site/src/pages/AgentsPage): hide attachments when no org is autho… ibetitsmike Aug 13, 2026 https://github.com/coder/coder/pull/28078/commits/3ca42bd5c117ed1bf3ddbc479a6ac71cca1b6003
e1a6204 fix(site/src/pages/AgentsPage): gate workspace picker until org autho… ibetitsmike Aug 13, 2026 https://github.com/coder/coder/pull/28078/commits/e1a620416cfc4bea33bbc10f2d7a138cffc5f433
6d46cc5 refactor(site/src/pages/AgentsPage): trim redundant comments ibetitsmike Aug 13, 2026 https://github.com/coder/coder/pull/28078/commits/6d46cc5eba3050a330d50fc4b098cd3706363da2
b4e09ae test(site/src/pages/AgentsPage): align stories with permittedOrganiza… ibetitsmike Aug 13, 2026 https://github.com/coder/coder/pull/28078/commits/b4e09aef387d0c47c1eaee54aad423b30423017d
Clear filters https://github.com/coder/coder/pull/28078/files
Please reload this pagehttps://github.com/coder/coder/pull/28078/changes
Please reload this pagehttps://github.com/coder/coder/pull/28078/changes
AgentCreateForm.stories.tsx https://github.com/coder/coder/pull/28078/changes#diff-7dcd5d872fb4e42cbf248dbbf9b903d2c70676b4bc10547a7d6faa2d39ab146e
AgentCreateForm.tsx https://github.com/coder/coder/pull/28078/changes#diff-e3e74ba39625ec8e03533e5b80af9352815d4a9bcabeef1dd7497fe4d8eeddee
useFileAttachments.test.tsx https://github.com/coder/coder/pull/28078/changes#diff-ce81295a0a09714770dcd142e148f70fb7afff7fc696a7f224c7d28bcb21c99f
useFileAttachments.ts https://github.com/coder/coder/pull/28078/changes#diff-6633d63e2fbd1fe3fffff3a2242b079c902aa92746e501c553cad9c14f303a86
Please reload this pagehttps://github.com/coder/coder/pull/28078/changes
Please reload this pagehttps://github.com/coder/coder/pull/28078/changes
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Viewport: width=device-width


URLs of crawlers that visited me.