-
Notifications
You must be signed in to change notification settings - Fork 1.4k
feat: add organization scoping to chats #23827
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
Merged
Merged
Changes from all commits
Commits
Show all changes
52 commits
Select commit
Hold shift + click to select a range
c77bc7c
feat: add organization scoping to chats
johnstcn 46ea130
fix: update enterprise chatd tests for org-scoped chats
johnstcn 8aec990
fix: update enterprise exp_chats_test for org-scoped chats
johnstcn 0d975ce
fix: add OrganizationID to all remaining InsertChat test callsites
johnstcn 2d164cb
fix: update rego SQL compile tests for org-scoped ChatConverter
johnstcn 4371364
fix: address deep-review findings for chat org scoping
johnstcn 09dac32
merge: resolve conflicts with main (chat_access_role migration)
johnstcn 65abac7
fix: appease the org-scoping gods with OrganizationID in all remainin…
johnstcn ba3c756
fix(coderd/rbac): plug org-member permission leak for chats and fix l…
johnstcn b49e81f
fix: post-merge compilation fixes — seedChatDependencies 3-return, mi…
johnstcn 685239c
fix: archive chat tests need OrganizationID too, naturally
johnstcn edec8a7
test(coderd/rbac): add orgMemberMe subject to ChatUsage RBAC test
johnstcn 9a18c4b
test(coderd): add handler validation tests for org-scoped chat creation
johnstcn b385915
merge: reconcile with origin/main — renumber migration 000458→000465,…
johnstcn d1538cb
fix(coderd): exorcise ghost test resurrected during merge
johnstcn 61af75b
fix(coderd): teach two more tests about the org-scoping revolution
johnstcn 1aa7b37
fix(coderd/x/chatd/chattool): reject cross-org templates before works…
johnstcn 6095ab2
Merge remote-tracking branch 'origin/main' into cian/chat-org-scoping
johnstcn 8775851
refactor(site): swap uncontrolled org autocomplete for controlled Select
johnstcn 021998c
Merge branch 'main' into cian/chat-org-scoping
johnstcn 9d2d925
docs: add organization_id to chats API documentation
johnstcn 941f35d
Merge remote-tracking branch 'origin/cian/chat-org-scoping' into cian…
johnstcn 14f994e
fix: address copilot review nits
johnstcn 841d7a1
docs(coderd/x/chatd/chattool): explain intentional double template lo…
johnstcn 960dacd
Merge remote-tracking branch 'origin/main' into cian/chat-org-scoping
johnstcn 99efebe
refactor(site): swap Radix Select for controlled OrganizationAutocomp…
johnstcn f063a2b
fix(coderd/x/chatd): remove zombie OpenAI round-trip tests resurrecte…
johnstcn 75ac297
test(coderd): add happy-path test for chat creation in non-default org
johnstcn 22f7de9
test(enterprise/coderd): move multi-org chat test to enterprise
johnstcn ea336fa
fix(enterprise/coderd): use ptr.Ref instead of local pointer helpers
johnstcn a160053
fix(site): clear file attachments on org change with confirmation
johnstcn 876b969
fix: rename misleading test name and add multi-org story
johnstcn 002434b
Merge remote-tracking branch 'origin/main' into cian/chat-org-scoping
johnstcn ee5dead
merge: reconcile with origin/main — fix new setupChatInfra callsite
johnstcn a95117e
make -B gen
johnstcn 65b197b
fix: clear workspace on org change and handle dbauthz not-authorized
johnstcn c3316f4
fix: address panel review — gate postChatMessages, remove dead SQL fi…
johnstcn a886c22
fix: replace em-dashes with ASCII punctuation in new comments
johnstcn eacc1a3
chore: remove accidentally staged zip file
johnstcn f47be73
fix: extend agents-access gate to all AI-triggering endpoints
johnstcn f8da2f1
Merge remote-tracking branch 'origin/main' into cian/chat-org-scoping
johnstcn e6e3fe8
merge: renumber migration 000466 to 000467 after main collision
johnstcn 61418c9
fix: regenerate dump.sql after merge with dropped index migration
johnstcn bc58a5e
fix: add OrganizationID to merged PinnedOnFirstPage and CursorWithPin…
johnstcn 51d249c
fix(coderd): address review comments from PR #23827
johnstcn 6694df9
fix(coderd/rbac): correct misleading agentsAccess role comment
johnstcn 0744a85
Merge remote-tracking branch 'origin/main' into cian/chat-org-scoping
johnstcn 4995fa3
fix(coderd/x/chatd): add missing OrganizationID to InsertChat calls
johnstcn 6de14a4
stop code cyclists creeping into the error check
johnstcn 137828c
fix: address round 5 review findings across frontend and backend
johnstcn ef269be
fix(site): remove dead organizationId fallback that could never trigger
johnstcn 3f6963d
fixup gitignore
johnstcn File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
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
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
1 change: 1 addition & 0 deletions
1
coderd/database/migrations/000467_chat_organization_id.down.sql
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| ALTER TABLE chats DROP COLUMN organization_id; |
20 changes: 20 additions & 0 deletions
20
coderd/database/migrations/000467_chat_organization_id.up.sql
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| -- Step 1: Add nullable column with FK. | ||
| ALTER TABLE chats | ||
| ADD COLUMN organization_id UUID REFERENCES organizations(id) ON DELETE CASCADE; | ||
|
|
||
|
johnstcn marked this conversation as resolved.
|
||
| -- Step 2: Backfill from workspace org (primary path). Fall back to | ||
| -- user's oldest org membership, then default org for rows where | ||
| -- workspace_id was NULLed out by ON DELETE SET NULL or never set. | ||
| UPDATE chats c | ||
| SET organization_id = COALESCE( | ||
| (SELECT w.organization_id FROM workspaces w WHERE w.id = c.workspace_id), | ||
| (SELECT om.organization_id FROM organization_members om | ||
| WHERE om.user_id = c.owner_id ORDER BY om.created_at ASC LIMIT 1), | ||
| (SELECT id FROM organizations WHERE is_default = true LIMIT 1) | ||
|
johnstcn marked this conversation as resolved.
|
||
| ); | ||
|
johnstcn marked this conversation as resolved.
|
||
|
|
||
| -- Step 3: Enforce NOT NULL going forward. | ||
| ALTER TABLE chats ALTER COLUMN organization_id SET NOT NULL; | ||
|
|
||
| -- Step 4: Index for efficient lookups by organization. | ||
| CREATE INDEX idx_chats_organization_id ON chats (organization_id); | ||
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
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.