-
Notifications
You must be signed in to change notification settings - Fork 11
chore: update @arcadeai/design-system to latest #848
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
8 commits
Select commit
Hold shift + click to select a range
ddbd578
chore: update @arcadeai/design-system to latest
arcadedotdev 6104a20
chore: update @arcadeai/design-system to latest
arcadedotdev 42b69b1
fix pr
jottakka dcd2dcb
fixing conflicts
jottakka 4c490bd
[AUTO] Adding MCP Servers docs update (#850)
evantahler 284fefc
fixing errors
jottakka c4bebfe
Merge branch 'main' into automation/update-design-system-dependency
jottakka a7b9444
fixing broken test
jottakka 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
95 changes: 95 additions & 0 deletions
95
app/_components/toolkit-docs/components/available-tools-filter.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,95 @@ | ||
| import type { AvailableToolsTableProps, BehaviorFlagKey } from "../types"; | ||
| import { normalizeScopes } from "./scopes-display"; | ||
|
|
||
| export type AvailableToolsFilter = | ||
| | "all" | ||
| | "has_scopes" | ||
| | "no_scopes" | ||
| | "has_secrets" | ||
| | "no_secrets"; | ||
|
|
||
| export type FilterToolsOptions = { | ||
| activeOperations?: Set<string>; | ||
| behaviorFlags?: Partial<Record<BehaviorFlagKey, boolean>>; | ||
| }; | ||
|
|
||
| function buildScopeDisplayItems(scopes: string[]): string[] { | ||
| return normalizeScopes(scopes); | ||
| } | ||
|
|
||
| function matchesFilterCategory( | ||
| tool: AvailableToolsTableProps["tools"][number], | ||
| filter: AvailableToolsFilter | ||
| ): boolean { | ||
| const hasScopes = buildScopeDisplayItems(tool.scopes ?? []).length > 0; | ||
| const hasSecrets = | ||
| (tool.secretsInfo?.length ?? 0) > 0 || (tool.secrets?.length ?? 0) > 0; | ||
|
|
||
| switch (filter) { | ||
| case "has_scopes": | ||
| return hasScopes; | ||
| case "no_scopes": | ||
| return !hasScopes; | ||
| case "has_secrets": | ||
| return hasSecrets; | ||
| case "no_secrets": | ||
| return !hasSecrets; | ||
| default: | ||
| return true; | ||
| } | ||
| } | ||
|
|
||
| function matchesOperations( | ||
| tool: AvailableToolsTableProps["tools"][number], | ||
| activeOperations: Set<string> | ||
| ): boolean { | ||
| if (activeOperations.size === 0) { | ||
| return true; | ||
| } | ||
| const toolOps = tool.metadata?.behavior?.operations ?? []; | ||
| return toolOps.some((op) => activeOperations.has(op)); | ||
| } | ||
|
|
||
| function matchesBehaviorFlags( | ||
| tool: AvailableToolsTableProps["tools"][number], | ||
| behaviorFlags: Partial<Record<BehaviorFlagKey, boolean>> | ||
| ): boolean { | ||
| for (const [key, expected] of Object.entries(behaviorFlags) as [ | ||
| BehaviorFlagKey, | ||
| boolean | undefined, | ||
| ][]) { | ||
| if (expected === undefined) { | ||
| continue; | ||
| } | ||
| if (tool.metadata?.behavior?.[key] !== expected) { | ||
| return false; | ||
| } | ||
| } | ||
| return true; | ||
| } | ||
|
|
||
| export function filterTools( | ||
| tools: AvailableToolsTableProps["tools"], | ||
| query: string, | ||
| filter: AvailableToolsFilter, | ||
| options: FilterToolsOptions = {} | ||
| ): AvailableToolsTableProps["tools"] { | ||
| const { activeOperations = new Set(), behaviorFlags = {} } = options; | ||
| const normalizedQuery = query.trim().toLowerCase(); | ||
|
|
||
| return tools.filter((tool) => { | ||
| const haystack = [tool.name, tool.qualifiedName, tool.description ?? ""] | ||
| .join(" ") | ||
| .toLowerCase(); | ||
| if (normalizedQuery.length > 0 && !haystack.includes(normalizedQuery)) { | ||
| return false; | ||
| } | ||
| if (!matchesFilterCategory(tool, filter)) { | ||
| return false; | ||
| } | ||
| if (!matchesOperations(tool, activeOperations)) { | ||
| return false; | ||
| } | ||
| return matchesBehaviorFlags(tool, behaviorFlags); | ||
| }); | ||
| } | ||
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
38 changes: 38 additions & 0 deletions
38
app/_components/toolkit-docs/components/toolkit-page-utils.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,38 @@ | ||
| export function getSharedServiceDomain( | ||
| tools: ReadonlyArray<{ | ||
| metadata?: { | ||
| classification?: { | ||
| serviceDomains?: string[]; | ||
| } | null; | ||
| } | null; | ||
| }> | ||
| ): string | null { | ||
| if (tools.length === 0) { | ||
| return null; | ||
| } | ||
|
|
||
| let sharedDomain: string | null = null; | ||
|
|
||
| for (const tool of tools) { | ||
| const serviceDomains = tool.metadata?.classification?.serviceDomains; | ||
| if (!serviceDomains || serviceDomains.length !== 1) { | ||
| return null; | ||
| } | ||
|
|
||
| const domain = serviceDomains[0]; | ||
| if (!domain || typeof domain !== "string") { | ||
| return null; | ||
| } | ||
|
|
||
| if (sharedDomain === null) { | ||
| sharedDomain = domain; | ||
| continue; | ||
| } | ||
|
|
||
| if (sharedDomain !== domain) { | ||
| return null; | ||
| } | ||
| } | ||
|
|
||
| return sharedDomain; | ||
| } |
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
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.
Refactoring left
buildScopeDisplayItemsas orphaned dead codeLow Severity
The extraction of filter logic into
available-tools-filter.tscreated a new privatebuildScopeDisplayItemsfunction, but the original exportedbuildScopeDisplayItemsinavailable-tools-table.tsxwas left behind. Its only caller (matchesFilterCategory) was moved to the new file, making it dead code. No file in the codebase importsbuildScopeDisplayItemsfromavailable-tools-table.tsx. The new file could import and reuse the existing exported function instead of duplicating it.Additional Locations (1)
app/_components/toolkit-docs/components/available-tools-table.tsx#L638-L641