-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Agents posts on mobile #9317
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
Agents posts on mobile #9317
Changes from all commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
35ca61e
Agents streaming
crspeller af6c000
Fix bug and lint
crspeller c58a94d
Add reasoning summaries to mobile agents
crspeller da093ca
Add tool call approval UI for mobile agents
crspeller d2ee89b
Add citations and annotations support for mobile agents
crspeller 251520b
Add stop and regenerate controls for mobile agents
crspeller c007a58
Add tests
crspeller 62e2b9c
Fix tool approval buttons not updating after accept/reject
crspeller 8b5233d
Refactor agents code: remove unused client mixin, fix bugs, and simpl…
crspeller 3b0664a
Fixes
crspeller 5398b1c
Add CLAUDE.md
crspeller 7a65373
Review feedback.
crspeller a69fc67
Review feedback inline functions
crspeller 3068e84
Learnings
crspeller 72f618c
Address review feedback: StyleSheet.create, parent mount checks, utils
crspeller fea5c8d
Move to observables
crspeller f186a4a
Last style fix
crspeller 80d68c3
Style tweaks
crspeller 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
Large diffs are not rendered by default.
Oops, something went wrong.
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
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
83 changes: 83 additions & 0 deletions
83
app/products/agents/actions/remote/generation_controls.test.ts
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,83 @@ | ||
| // Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. | ||
| // See LICENSE.txt for license information. | ||
|
|
||
| import NetworkManager from '@managers/network_manager'; | ||
| import {getFullErrorMessage} from '@utils/errors'; | ||
| import {logError} from '@utils/log'; | ||
|
|
||
| import { | ||
| stopGeneration, | ||
| regenerateResponse, | ||
| } from './generation_controls'; | ||
|
|
||
| jest.mock('@managers/network_manager'); | ||
| jest.mock('@utils/errors'); | ||
| jest.mock('@utils/log'); | ||
|
|
||
| const serverUrl = 'https://test.mattermost.com'; | ||
| const postId = 'test-post-id'; | ||
|
|
||
| const mockClient = { | ||
| stopGeneration: jest.fn(), | ||
| regenerateResponse: jest.fn(), | ||
| }; | ||
|
|
||
| beforeAll(() => { | ||
| jest.mocked(NetworkManager.getClient).mockReturnValue(mockClient as any); | ||
| }); | ||
|
|
||
| beforeEach(() => { | ||
| jest.clearAllMocks(); | ||
| }); | ||
|
|
||
| describe('stopGeneration', () => { | ||
| it('should call client.stopGeneration and return empty object on success', async () => { | ||
| mockClient.stopGeneration.mockResolvedValue(undefined); | ||
|
|
||
| const result = await stopGeneration(serverUrl, postId); | ||
|
|
||
| expect(NetworkManager.getClient).toHaveBeenCalledWith(serverUrl); | ||
| expect(mockClient.stopGeneration).toHaveBeenCalledWith(postId); | ||
| expect(result).toEqual({}); | ||
| expect(result.error).toBeUndefined(); | ||
| }); | ||
|
|
||
| it('should return error object and log error on failure', async () => { | ||
| const error = new Error('Network error'); | ||
| const errorMessage = 'Network error occurred'; | ||
| mockClient.stopGeneration.mockRejectedValue(error); | ||
| jest.mocked(getFullErrorMessage).mockReturnValue(errorMessage); | ||
|
|
||
| const result = await stopGeneration(serverUrl, postId); | ||
|
|
||
| expect(logError).toHaveBeenCalledWith('[stopGeneration]', error); | ||
| expect(getFullErrorMessage).toHaveBeenCalledWith(error); | ||
| expect(result).toEqual({error: errorMessage}); | ||
| }); | ||
| }); | ||
|
|
||
| describe('regenerateResponse', () => { | ||
| it('should call client.regenerateResponse and return empty object on success', async () => { | ||
| mockClient.regenerateResponse.mockResolvedValue(undefined); | ||
|
|
||
| const result = await regenerateResponse(serverUrl, postId); | ||
|
|
||
| expect(NetworkManager.getClient).toHaveBeenCalledWith(serverUrl); | ||
| expect(mockClient.regenerateResponse).toHaveBeenCalledWith(postId); | ||
| expect(result).toEqual({}); | ||
| expect(result.error).toBeUndefined(); | ||
| }); | ||
|
|
||
| it('should return error object and log error on failure', async () => { | ||
| const error = new Error('Network error'); | ||
| const errorMessage = 'Network error occurred'; | ||
| mockClient.regenerateResponse.mockRejectedValue(error); | ||
| jest.mocked(getFullErrorMessage).mockReturnValue(errorMessage); | ||
|
|
||
| const result = await regenerateResponse(serverUrl, postId); | ||
|
|
||
| expect(logError).toHaveBeenCalledWith('[regenerateResponse]', error); | ||
| expect(getFullErrorMessage).toHaveBeenCalledWith(error); | ||
| expect(result).toEqual({error: errorMessage}); | ||
| }); | ||
| }); |
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,46 @@ | ||
| // Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. | ||
| // See LICENSE.txt for license information. | ||
|
|
||
| import NetworkManager from '@managers/network_manager'; | ||
| import {getFullErrorMessage} from '@utils/errors'; | ||
| import {logError} from '@utils/log'; | ||
|
|
||
| /** | ||
| * Stop the current generation for a post | ||
| * @param serverUrl The server URL | ||
| * @param postId The post ID to stop generation for | ||
| * @returns {error} on failure | ||
| */ | ||
| export async function stopGeneration( | ||
| serverUrl: string, | ||
| postId: string, | ||
| ): Promise<{error?: unknown}> { | ||
| try { | ||
| const client = NetworkManager.getClient(serverUrl); | ||
| await client.stopGeneration(postId); | ||
| return {}; | ||
| } catch (error) { | ||
| logError('[stopGeneration]', error); | ||
| return {error: getFullErrorMessage(error)}; | ||
| } | ||
| } | ||
|
|
||
| /** | ||
| * Regenerate a response for a post | ||
| * @param serverUrl The server URL | ||
| * @param postId The post ID to regenerate response for | ||
| * @returns {error} on failure | ||
| */ | ||
| export async function regenerateResponse( | ||
| serverUrl: string, | ||
| postId: string, | ||
| ): Promise<{error?: unknown}> { | ||
| try { | ||
| const client = NetworkManager.getClient(serverUrl); | ||
| await client.regenerateResponse(postId); | ||
| return {}; | ||
| } catch (error) { | ||
| logError('[regenerateResponse]', error); | ||
| return {error: getFullErrorMessage(error)}; | ||
| } | ||
| } |
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,54 @@ | ||
| // Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. | ||
| // See LICENSE.txt for license information. | ||
|
|
||
| import NetworkManager from '@managers/network_manager'; | ||
| import {getFullErrorMessage} from '@utils/errors'; | ||
| import {logError} from '@utils/log'; | ||
|
|
||
| import {submitToolApproval} from './tool_approval'; | ||
|
|
||
| jest.mock('@managers/network_manager'); | ||
| jest.mock('@utils/errors'); | ||
| jest.mock('@utils/log'); | ||
|
|
||
| const serverUrl = 'https://test.mattermost.com'; | ||
| const postId = 'post123'; | ||
| const acceptedToolIds = ['tool1', 'tool2', 'tool3']; | ||
|
|
||
| const mockClient = { | ||
| submitToolApproval: jest.fn(), | ||
| }; | ||
|
|
||
| beforeAll(() => { | ||
| jest.mocked(NetworkManager.getClient).mockReturnValue(mockClient as any); | ||
| }); | ||
|
|
||
| beforeEach(() => { | ||
| jest.clearAllMocks(); | ||
| }); | ||
|
|
||
| describe('submitToolApproval', () => { | ||
| it('should call client.submitToolApproval and return empty object on success', async () => { | ||
| mockClient.submitToolApproval.mockResolvedValue(undefined); | ||
|
|
||
| const result = await submitToolApproval(serverUrl, postId, acceptedToolIds); | ||
|
|
||
| expect(NetworkManager.getClient).toHaveBeenCalledWith(serverUrl); | ||
| expect(mockClient.submitToolApproval).toHaveBeenCalledWith(postId, acceptedToolIds); | ||
| expect(result).toEqual({}); | ||
| expect(result.error).toBeUndefined(); | ||
| }); | ||
|
|
||
| it('should return error object and log error on failure', async () => { | ||
| const error = new Error('Network error'); | ||
| const errorMessage = 'Network error occurred'; | ||
| mockClient.submitToolApproval.mockRejectedValue(error); | ||
| jest.mocked(getFullErrorMessage).mockReturnValue(errorMessage); | ||
|
|
||
| const result = await submitToolApproval(serverUrl, postId, acceptedToolIds); | ||
|
|
||
| expect(logError).toHaveBeenCalledWith('[submitToolApproval]', error); | ||
| expect(getFullErrorMessage).toHaveBeenCalledWith(error); | ||
| expect(result).toEqual({error: errorMessage}); | ||
| }); | ||
| }); |
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.