MCPcopy Create free account
hub / github.com/codeaashu/claude-code / addErrorsToAppState

Function addErrorsToAppState

src/services/mcp/useManageMCPConnections.ts:103–132  ·  view source on GitHub ↗

* Add errors to AppState, deduplicating to avoid showing the same error multiple times

(
  setAppState: (updater: (prev: AppState) => AppState) => void,
  newErrors: PluginError[],
)

Source from the content-addressed store, hash-verified

101 * Add errors to AppState, deduplicating to avoid showing the same error multiple times
102 */
103function addErrorsToAppState(
104 setAppState: (updater: (prev: AppState) => AppState) => void,
105 newErrors: PluginError[],
106): void {
107 if (newErrors.length === 0) return
108
109 setAppState(prevState => {
110 // Build set of existing error keys
111 const existingKeys = new Set(
112 prevState.plugins.errors.map(e => getErrorKey(e)),
113 )
114
115 // Only add errors that don't already exist
116 const uniqueNewErrors = newErrors.filter(
117 error => !existingKeys.has(getErrorKey(error)),
118 )
119
120 if (uniqueNewErrors.length === 0) {
121 return prevState
122 }
123
124 return {
125 ...prevState,
126 plugins: {
127 ...prevState.plugins,
128 errors: [...prevState.plugins.errors, ...uniqueNewErrors],
129 },
130 }
131 })
132}
133
134/**
135 * Hook to manage MCP (Model Context Protocol) server connections and updates

Callers 2

loadAndConnectMcpConfigsFunction · 0.85

Calls 2

getErrorKeyFunction · 0.85
hasMethod · 0.45

Tested by

no test coverage detected