-
Notifications
You must be signed in to change notification settings - Fork 3.8k
feat(mothership): add editable skills and tools to the resource panel #7070
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
Open
BillLeoutsakosvl346
wants to merge
10
commits into
staging
Choose a base branch
from
feat/mothership-resource-panel-tools
base: staging
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
5d7dfa4
feat(mothership): add tools to resource panel
68edb9a
test(mothership): trim resource panel coverage
07545df
fix(mothership): guard embedded resource drafts
ad3162e
fix(mothership): protect resource drafts across navigation
7323861
fix(mothership): guard programmatic resource navigation
67d2b8c
fix(mothership): finalize guarded resource editing
6276a17
fix(mothership): use canonical sentinel IDs
0605e85
fix(mothership): address editable resource review findings
8d56b84
fix(cron): stabilize retention thresholds
be0eb21
Merge origin/staging into feat/mothership-resource-panel-tools
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
51 changes: 51 additions & 0 deletions
51
...space/[workspaceId]/components/credential-detail/hooks/use-unsaved-changes-guard.test.tsx
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,51 @@ | ||
| /** | ||
| * @vitest-environment jsdom | ||
| */ | ||
|
|
||
| import { act } from 'react' | ||
| import { createRoot, type Root } from 'react-dom/client' | ||
| import { afterEach, describe, expect, it, vi } from 'vitest' | ||
|
|
||
| const { mockPush } = vi.hoisted(() => ({ mockPush: vi.fn() })) | ||
|
|
||
| vi.mock('next/navigation', () => ({ | ||
| useRouter: () => ({ push: mockPush }), | ||
| })) | ||
|
|
||
| import { useUnsavedChangesGuard } from '@/app/workspace/[workspaceId]/components/credential-detail/hooks/use-unsaved-changes-guard' | ||
|
|
||
| function mountDisabledDirtyGuard(): () => void { | ||
| ;(globalThis as { IS_REACT_ACT_ENVIRONMENT?: boolean }).IS_REACT_ACT_ENVIRONMENT = true | ||
| const root: Root = createRoot(document.createElement('div')) | ||
|
|
||
| function Probe() { | ||
| useUnsavedChangesGuard({ | ||
| isDirty: true, | ||
| backHref: '/workspace/ws-1/skills', | ||
| enabled: false, | ||
| }) | ||
| return null | ||
| } | ||
|
|
||
| act(() => root.render(<Probe />)) | ||
| return () => act(() => root.unmount()) | ||
| } | ||
|
|
||
| describe('useUnsavedChangesGuard', () => { | ||
| afterEach(() => { | ||
| vi.restoreAllMocks() | ||
| }) | ||
|
|
||
| it('installs no nested navigation guard when its embedded host owns transitions', () => { | ||
| const pushState = vi.spyOn(window.history, 'pushState') | ||
| const unmount = mountDisabledDirtyGuard() | ||
|
|
||
| const beforeUnload = new Event('beforeunload', { cancelable: true }) | ||
| window.dispatchEvent(beforeUnload) | ||
|
|
||
| expect(pushState).not.toHaveBeenCalled() | ||
| expect(beforeUnload.defaultPrevented).toBe(false) | ||
|
|
||
| unmount() | ||
| }) | ||
| }) |
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
88 changes: 88 additions & 0 deletions
88
...omponents/mothership-view/components/add-resource-dropdown/panel-resource-groups.test.tsx
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,88 @@ | ||
| /** | ||
| * @vitest-environment jsdom | ||
| */ | ||
| import { act } from 'react' | ||
| import { createRoot } from 'react-dom/client' | ||
| import { describe, expect, it, vi } from 'vitest' | ||
|
|
||
| vi.mock('@/lib/browser-agent/transport', () => ({ isBrowserAgentAvailable: () => false })) | ||
| vi.mock('@/lib/terminal/transport', () => ({ isTerminalAvailable: () => false })) | ||
| vi.mock('@/blocks/integration-matcher', () => ({ listIntegrationsByPopularity: () => [] })) | ||
| vi.mock('@/hooks/queries/custom-tools', () => ({ | ||
| useCustomTools: () => ({ | ||
| data: [{ id: 'tool-1', title: 'Lookup order' }], | ||
| isPending: false, | ||
| }), | ||
| })) | ||
| vi.mock('@/hooks/queries/folders', () => ({ | ||
| useFolders: () => ({ data: [], isPending: false }), | ||
| })) | ||
| vi.mock('@/hooks/queries/kb/knowledge', () => ({ | ||
| useKnowledgeBasesQuery: () => ({ data: [], isPending: false }), | ||
| })) | ||
| vi.mock('@/hooks/queries/logs', () => ({ | ||
| useLogsList: () => ({ data: { pages: [] }, isPending: false }), | ||
| })) | ||
| vi.mock('@/hooks/queries/mcp', () => ({ | ||
| useMcpServers: () => ({ | ||
| data: [{ id: 'server-1', name: 'DeepWiki' }], | ||
| isPending: false, | ||
| }), | ||
| })) | ||
| vi.mock('@/hooks/queries/mothership-chats', () => ({ | ||
| useMothershipChats: () => ({ data: [], isPending: false }), | ||
| })) | ||
| vi.mock('@/hooks/queries/skills', () => ({ | ||
| useSkills: () => ({ | ||
| data: [{ id: 'skill-1', name: 'Research' }], | ||
| isPending: false, | ||
| }), | ||
| })) | ||
| vi.mock('@/hooks/queries/tables', () => ({ | ||
| useTablesList: () => ({ data: [], isPending: false }), | ||
| })) | ||
| vi.mock('@/hooks/queries/workflows', () => ({ | ||
| useWorkflows: () => ({ data: [], isPending: false }), | ||
| })) | ||
| vi.mock('@/hooks/queries/workspace-file-folders', () => ({ | ||
| useWorkspaceFileFolders: () => ({ data: [], isPending: false }), | ||
| })) | ||
| vi.mock('@/hooks/queries/workspace-files', () => ({ | ||
| useWorkspaceFiles: () => ({ data: [], isPending: false }), | ||
| })) | ||
|
|
||
| import { useAvailableResources } from '@/app/workspace/[workspaceId]/home/components/mothership-view/components/add-resource-dropdown/add-resource-dropdown' | ||
|
|
||
| describe('useAvailableResources panel resource groups', () => { | ||
| it('offers Skills, Custom Tools, and MCP servers to the panel picker', () => { | ||
| ;(globalThis as { IS_REACT_ACT_ENVIRONMENT?: boolean }).IS_REACT_ACT_ENVIRONMENT = true | ||
| const container = document.createElement('div') | ||
| document.body.appendChild(container) | ||
| const root = createRoot(container) | ||
| let latest: ReturnType<typeof useAvailableResources> | undefined | ||
|
|
||
| function Probe() { | ||
| latest = useAvailableResources('workspace-1', { enabled: true }) | ||
| return null | ||
| } | ||
|
|
||
| act(() => root.render(<Probe />)) | ||
|
|
||
| expect(latest?.groups.find(({ type }) => type === 'skill')).toEqual({ | ||
| type: 'skill', | ||
| items: [{ id: 'skill-1', name: 'Research' }], | ||
| }) | ||
| expect(latest?.groups.find(({ type }) => type === 'custom_tool')).toEqual({ | ||
| type: 'custom_tool', | ||
| items: [{ id: 'tool-1', name: 'Lookup order' }], | ||
| }) | ||
| expect(latest?.groups.find(({ type }) => type === 'mcp_server')).toEqual({ | ||
| type: 'mcp_server', | ||
| items: [{ id: 'server-1', name: 'DeepWiki' }], | ||
| }) | ||
| expect(latest?.isHydrating).toBe(false) | ||
|
|
||
| act(() => root.unmount()) | ||
| container.remove() | ||
| }) | ||
| }) |
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
P2: When the picker remains mounted across a workspace switch, these hooks serve the previous workspace's placeholder rows while
isHydratingstays false. TrackisPlaceholderDatafor all three queries or suppress placeholder rows before allowing selection, otherwise the panel can attach a resource from the prior workspace.Prompt for AI agents