feat(web): workspace components — ComparePane, Memory page, McpDialog, error boundaries, message-parts
- Add ComparePane.tsx: side-by-side AI response comparison - Add Memory.tsx: memory management page with CRUD UI - Add McpPermissionDialog.tsx: MCP tool permission approval dialog - Add McpResponseDisplay.tsx: MCP response visualization - Add MessageBoundary.tsx + MessageListErrorBoundary.tsx: error resilience - Add EmptyState.tsx: contextual empty state component - Add KeyboardShortcutsDialog.tsx: keyboard shortcut reference - Add message-parts/: ActionRow, CompactCard, MistakeRecoverySentinel, ReasoningBlock, SendToTerminalMenu, StatsLine, SummaryCard - Add useDraftPersistence.ts: draft message persistence hook - Add useTerminals.ts: terminal session management hook - Add keyboard-shortcuts.ts + tool-utils.ts: shared utilities - Extend components: ChatInput, MessageBubble, MessageList, Workspace, panes - Extend hooks: useTerminalSocket, useSessionStream test suite - Update pages: Home, Project — workspace layout and session flow
This commit is contained in:
49
apps/web/src/lib/tool-utils.ts
Normal file
49
apps/web/src/lib/tool-utils.ts
Normal file
@@ -0,0 +1,49 @@
|
||||
// Set of built-in tool names (from formatToolArgs in ToolCallLine.tsx).
|
||||
// Any tool not in this set that has a `server_tool` name pattern is an MCP tool.
|
||||
export const BUILT_IN_TOOLS = new Set([
|
||||
'view_file',
|
||||
'list_dir',
|
||||
'grep',
|
||||
'find_files',
|
||||
'git_status',
|
||||
'skill_use',
|
||||
'get_codebase_overview',
|
||||
'get_file_analysis',
|
||||
'get_symbol_info',
|
||||
'search_symbols',
|
||||
'get_dependencies',
|
||||
'watch_changes',
|
||||
'get_semantic_neighborhoods',
|
||||
'get_framework_analysis',
|
||||
]);
|
||||
|
||||
/**
|
||||
* Returns true if the tool name follows the `<server>_<tool>` MCP pattern.
|
||||
* Built-in tools (view_file, grep, skill_use, etc.) are excluded even if
|
||||
* they happen to contain an underscore (e.g. 'git_status', 'skill_use').
|
||||
*/
|
||||
export function isMcpTool(name: string): boolean {
|
||||
return name.includes('_') && !BUILT_IN_TOOLS.has(name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Extracts the MCP server name from a tool call name.
|
||||
* For 'context7_searchWeb' returns 'context7'.
|
||||
* Returns null for native tools.
|
||||
*/
|
||||
export function extractServerName(name: string): string | null {
|
||||
const idx = name.indexOf('_');
|
||||
if (idx === -1) return null;
|
||||
return name.slice(0, idx);
|
||||
}
|
||||
|
||||
/**
|
||||
* Extracts the tool name (without server prefix) from an MCP tool call name.
|
||||
* For 'context7_searchWeb' returns 'searchWeb'.
|
||||
* Returns null for native tools.
|
||||
*/
|
||||
export function extractToolName(name: string): string | null {
|
||||
const idx = name.indexOf('_');
|
||||
if (idx === -1) return null;
|
||||
return name.slice(idx + 1);
|
||||
}
|
||||
Reference in New Issue
Block a user