Thanks to visit codestin.com
Credit goes to github.com

Skip to content

feat: enable chat sharing - #24987

Merged
DanielleMaywood merged 8 commits into
mainfrom
dm/chat-sharing-frontend
May 20, 2026
Merged

feat: enable chat sharing#24987
DanielleMaywood merged 8 commits into
mainfrom
dm/chat-sharing-frontend

Conversation

@DanielleMaywood

@DanielleMaywood DanielleMaywood commented May 5, 2026

Copy link
Copy Markdown
Contributor

Note

🤖 This PR was written by Coder Agent on behalf of Danielle Maywood

Depends on #24968.

Adds frontend chat sharing controls for experimental Coder Agents chats. Authorized users can open the chat actions menu on root chats, add users or groups with read-only access, remove existing ACL entries, and see shared or read-only chat ownership state in the agents UI.

Implementation plan
$(sed 's/```/````/g' /home/coder/.coder/plans/PLAN-a34939be-00cb-4f5b-8de2-009e1473630e.md)

@DanielleMaywood DanielleMaywood changed the title feat(site): enable chat sharing feat: enable chat sharing May 6, 2026
@DanielleMaywood
DanielleMaywood force-pushed the dm/chat-sharing-frontend branch 2 times, most recently from e042cb8 to 2ae63e4 Compare May 6, 2026 16:31
@DanielleMaywood
DanielleMaywood force-pushed the dm/chat-sharing-frontend branch from a17dd8a to c6170a4 Compare May 6, 2026 18:04
@DanielleMaywood
DanielleMaywood force-pushed the dm/chat-sharing-frontend branch from ab613c7 to e005315 Compare May 7, 2026 14:40
@DanielleMaywood
DanielleMaywood force-pushed the dm/chat-sharing-frontend branch from e005315 to 4d00998 Compare May 7, 2026 14:47
@DanielleMaywood
DanielleMaywood force-pushed the dm/chat-sharing-frontend branch 2 times, most recently from 04d428d to 3eb0e2e Compare May 7, 2026 20:36
@DanielleMaywood

Copy link
Copy Markdown
Contributor Author

/coder-agents-review

@DanielleMaywood
DanielleMaywood force-pushed the dm/chat-sharing branch 2 times, most recently from 7f45110 to fbb5847 Compare May 11, 2026 09:43
@DanielleMaywood
DanielleMaywood force-pushed the dm/chat-sharing-frontend branch 2 times, most recently from 997fc49 to b3c954b Compare May 11, 2026 10:37
@DanielleMaywood
DanielleMaywood force-pushed the dm/chat-sharing branch 2 times, most recently from 52f8308 to 8f9483a Compare May 11, 2026 12:55
@DanielleMaywood
DanielleMaywood force-pushed the dm/chat-sharing-frontend branch from b3c954b to bc38364 Compare May 11, 2026 12:55
@DanielleMaywood
DanielleMaywood force-pushed the dm/chat-sharing-frontend branch from bc38364 to 04709b3 Compare May 12, 2026 12:28
@DanielleMaywood
DanielleMaywood force-pushed the dm/chat-sharing branch 2 times, most recently from 257580b to e65ee30 Compare May 14, 2026 16:01
@DanielleMaywood
DanielleMaywood force-pushed the dm/chat-sharing-frontend branch from 04709b3 to c90b664 Compare May 14, 2026 16:01
@DanielleMaywood
DanielleMaywood force-pushed the dm/chat-sharing-frontend branch from c90b664 to 2e9d542 Compare May 19, 2026 12:45
@DanielleMaywood

Copy link
Copy Markdown
Contributor Author

/coder-agents-review

@coder-agents-review coder-agents-review Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Clean feature PR. The authorization model is well-designed: ActionUpdate gates writes, ActionShare gates ACL changes, and the owner-only guard on postChatMessages prevents credential leakage. Test coverage is thorough across all three layers (API client, query factory, Storybook). Component reuse from the workspace sharing module is a good call.

The strongest convergence across the panel is on the stale mutation error state (DEREM-2, flagged by 9 reviewers independently). The split-table accessibility issue (DEREM-3) and the table layout duplication from WorkspaceSharingForm (DEREM-8) also saw multiple reviewers.

Severity breakdown: 9 P3, 5 Nit, 4 Note. No blocking findings.

"The operator sees an error banner alongside a success toast." (Chopper, on the stale mutation state)

🤖 This review was automatically generated with Coder Agents.

Comment thread site/src/pages/AgentsPage/components/ChatSharingPopover.tsx Outdated
Comment thread site/src/pages/AgentsPage/components/ChatSharingPopover.tsx Outdated
Comment thread site/src/pages/AgentsPage/AgentChatPage.tsx
Comment thread site/src/pages/AgentsPage/components/ChatSharingPopover.stories.tsx Outdated
Comment thread site/src/pages/AgentsPage/components/ChatSharingPopover.tsx Outdated
Comment thread site/src/pages/AgentsPage/components/ChatSharingPopover.tsx
Comment thread site/src/pages/AgentsPage/components/ChatSharingPopover.tsx
Comment thread site/src/pages/AgentsPage/components/ChatTopBar.tsx Outdated
Comment thread site/src/pages/AgentsPage/AgentChatPage.stories.tsx
Comment thread site/src/pages/AgentsPage/AgentChatPage.stories.tsx
Base automatically changed from dm/chat-sharing to main May 20, 2026 09:46
@DanielleMaywood
DanielleMaywood force-pushed the dm/chat-sharing-frontend branch from 4144eda to 9c71ded Compare May 20, 2026 09:51
@DanielleMaywood

Copy link
Copy Markdown
Contributor Author

/coder-agents-review

@coder-agents-review coder-agents-review Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Re-review of the fix commit (4144eda94c). 12 of the original 18 findings are fixed; all verified by Netero and the panel. 5 contested findings were evaluated by the panel and closed (author defenses accepted). Two new findings emerged.

The fixes are thorough. The mutation error reset lifecycle is well-designed (ref-gated reset on open, explicit clear before each mutation, two stories covering cross-type and cross-session scenarios). The split-table accessibility fix uses a single semantic table with sticky headers. The prop rename, toast messages, and convention fixes are all clean.

DEREM-20 is a regression introduced by the DEREM-13 fix: isLoading || isFetching causes the input to disable and banner to disappear on every background refetch (tab switch), not just the initial load. Two reviewers converged on this independently.

Severity breakdown: 2 new P3, 1 new Note. No blocking findings.

"Every tab switch triggers this cycle. An admin typing in another user's chat gets their cursor kicked out of the input momentarily." (Mafuuu)

🤖 This review was automatically generated with Coder Agents.

},
};

export const RemoveUser: Story = {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P3 [DEREM-19] RemoveUser and RemoveGroup stories skip toast verification.

AddUser and AddGroup include decorators: [withToaster] and assert their success toasts. RemoveUser and RemoveGroup omit both. The production code calls toast.success("Member removed from chat.") and toast.success("Group removed from chat.") on remove success. Without the toaster decorator and an assertion, these stories would pass even if the toast calls were removed.

Fix: add decorators: [withToaster] and assert the toast text in both stories.

(Bisky P3)

🤖

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

🤖 This comment was written by Coder Agent on behalf of Danielle Maywood 🤖

Fixed in 6a4a93db0fe236f57a303fb3f051308370e0a11b. Added toaster coverage to the remove stories and asserted both remove success messages.

canUpdateOtherUserChatQuery.data?.canUpdateChat,
);
const canUpdateOtherUserChatLoading =
canUpdateOtherUserChatQuery.isLoading ||

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P3 [DEREM-20] Background refetches disable input and suppress banner via isFetching.

canUpdateOtherUserChatLoading uses isLoading || isFetching (lines 865-866). In TanStack Query v5, isFetching is true during background refetches (window focus, staleTime: 0). When it fires:

  1. canUpdateOtherUserChatLoading becomes true.
  2. isInputDisabled evaluates true. Input locks.
  3. chatOwnerWarning hits the loading guard and returns undefined. Banner disappears.
  4. Refetch completes (~200ms). Input re-enables, banner reappears.

Every tab switch triggers this cycle. An admin typing in another user's chat gets their cursor kicked momentarily. A read-only viewer's banner flickers.

Compare with canShareChat, which uses canShareChatQuery.data directly with no loading guard and has no jitter.

Fix: replace isLoading || isFetching with just isLoading. isLoading is true only on the first fetch with no cached data, which is the only case where the permission is genuinely unknown.

(Mafuuu P3, Pariston P3)

🤖

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

🤖 This comment was written by Coder Agent on behalf of Danielle Maywood 🤖

Fixed in 6a4a93db0fe236f57a303fb3f051308370e0a11b. Treating only the initial authorization load as unknown so background refetches no longer disable input or hide the owner warning.

const chatOwnerQuery = useQuery({
...userQuery(chatRecord?.owner_id ?? ""),
enabled: isViewerNotOwner && !isArchived,
const canUpdateOtherUserChatQuery = useQuery({

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Note [DEREM-21] Two separate checkAuthorization HTTP requests for the same chat resource object.

canUpdateOtherUserChatQuery (line 846) and canShareChatQuery (line 869) both construct identical object: { resource_type: "chat", owner_id, organization_id } but fire as separate roundtrips. The checkAuthorization API accepts multiple checks in one request. For a non-owner viewer of a root non-archived chat, both fire, doubling authz latency. At current scale this is invisible; worth combining if shared chats see significant traffic.

(Hisoka P3)

🤖

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

🤖 This comment was written by Coder Agent on behalf of Danielle Maywood 🤖

Fixed in 6a4a93db0fe236f57a303fb3f051308370e0a11b. Batched the update and share authorization checks into one authcheck request for the chat object.

@DanielleMaywood

Copy link
Copy Markdown
Contributor Author

/coder-agents-review

@coder-agents-review coder-agents-review Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Round 3 re-review. All three R2 findings (DEREM-19, 20, 21) are fixed and verified by all 4 panel reviewers. The authz consolidation (DEREM-21) is well-designed: dynamic check batching with a clean enabled guard. The isFetching-to-isLoading fix (DEREM-20) eliminates the background refetch flicker at root cause. Toast assertions (DEREM-19) are now in place.

One new P3 finding from the test coverage audit. 21 of 22 findings across 3 rounds are now resolved.

"I traced the authorization flow through AgentChatPage.tsx lines 844-885 ... This is correct." (Pariston, verifying the DEREM-21 fix)

🤖 This review was automatically generated with Coder Agents.

Comment thread site/src/pages/AgentsPage/AgentChatPageView.tsx
@DanielleMaywood

Copy link
Copy Markdown
Contributor Author

/coder-agents-review

@coder-agents-review coder-agents-review Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Round 4. All 22 findings across 4 rounds are resolved. DEREM-22 (archived root chat sharing) is addressed with a documenting story. CI is green.

Final tally: 15 fixed by author, 5 closed by panel (author defenses accepted), 1 acknowledged, 1 dropped by orchestrator. No open findings remain.

The PR is in good shape for human review and merge.

🤖 This review was automatically generated with Coder Agents.

@DanielleMaywood
DanielleMaywood force-pushed the dm/chat-sharing-frontend branch from 629c9ec to 4b389f6 Compare May 20, 2026 15:43
@DanielleMaywood
DanielleMaywood marked this pull request as ready for review May 20, 2026 16:35
@DanielleMaywood
DanielleMaywood requested a review from mafredri May 20, 2026 16:57

@ibetitsmike ibetitsmike left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

LGTM

@DanielleMaywood
DanielleMaywood merged commit e27d917 into main May 20, 2026
27 checks passed
@DanielleMaywood
DanielleMaywood deleted the dm/chat-sharing-frontend branch May 20, 2026 17:45
@github-actions github-actions Bot locked and limited conversation to collaborators May 20, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants