mirror of
https://github.com/RooVetGit/Roo-Code.git
synced 2026-08-28 05:27:24 +00:00
Selectively deep merge rather than deep merging everything
This commit is contained in:
parent
2bd310bc92
commit
e201ee8fdc
3 changed files with 27 additions and 16 deletions
10
webview-ui/package-lock.json
generated
10
webview-ui/package-lock.json
generated
|
|
@ -27,7 +27,6 @@
|
|||
"debounce": "^2.1.1",
|
||||
"fast-deep-equal": "^3.1.3",
|
||||
"fzf": "^0.5.2",
|
||||
"lodash": "^4.17.21",
|
||||
"lucide-react": "^0.475.0",
|
||||
"mermaid": "^11.4.1",
|
||||
"react": "^18.3.1",
|
||||
|
|
@ -55,7 +54,6 @@
|
|||
"@testing-library/react": "^16.2.0",
|
||||
"@testing-library/user-event": "^14.6.1",
|
||||
"@types/jest": "^27.5.2",
|
||||
"@types/lodash": "^4.17.16",
|
||||
"@types/node": "^18.0.0",
|
||||
"@types/react": "^18.3.18",
|
||||
"@types/react-dom": "^18.3.5",
|
||||
|
|
@ -6932,13 +6930,6 @@
|
|||
"dev": true,
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/@types/lodash": {
|
||||
"version": "4.17.16",
|
||||
"resolved": "https://registry.npmjs.org/@types/lodash/-/lodash-4.17.16.tgz",
|
||||
"integrity": "sha512-HX7Em5NYQAXKW+1T+FiuG27NGwzJfCX3s1GjOa7ujxZa52kjJLOr4FUxT+giF6Tgxv1e+/czV/iTtBw27WTU9g==",
|
||||
"dev": true,
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/@types/mdast": {
|
||||
"version": "3.0.15",
|
||||
"resolved": "https://registry.npmjs.org/@types/mdast/-/mdast-3.0.15.tgz",
|
||||
|
|
@ -15321,6 +15312,7 @@
|
|||
"version": "4.17.21",
|
||||
"resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.21.tgz",
|
||||
"integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==",
|
||||
"dev": true,
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/lodash-es": {
|
||||
|
|
|
|||
|
|
@ -34,7 +34,6 @@
|
|||
"debounce": "^2.1.1",
|
||||
"fast-deep-equal": "^3.1.3",
|
||||
"fzf": "^0.5.2",
|
||||
"lodash": "^4.17.21",
|
||||
"lucide-react": "^0.475.0",
|
||||
"mermaid": "^11.4.1",
|
||||
"react": "^18.3.1",
|
||||
|
|
@ -62,7 +61,6 @@
|
|||
"@testing-library/react": "^16.2.0",
|
||||
"@testing-library/user-event": "^14.6.1",
|
||||
"@types/jest": "^27.5.2",
|
||||
"@types/lodash": "^4.17.16",
|
||||
"@types/node": "^18.0.0",
|
||||
"@types/react": "^18.3.18",
|
||||
"@types/react-dom": "^18.3.5",
|
||||
|
|
|
|||
|
|
@ -1,7 +1,5 @@
|
|||
import React, { createContext, useCallback, useContext, useEffect, useState } from "react"
|
||||
import { useEvent } from "react-use"
|
||||
import { merge } from "lodash"
|
||||
|
||||
import { ApiConfigMeta, ExtensionMessage, ExtensionState } from "../../../src/shared/ExtensionMessage"
|
||||
import { ApiConfiguration } from "../../../src/shared/api"
|
||||
import { vscode } from "../utils/vscode"
|
||||
|
|
@ -71,6 +69,32 @@ export interface ExtensionStateContextType extends ExtensionState {
|
|||
|
||||
export const ExtensionStateContext = createContext<ExtensionStateContextType | undefined>(undefined)
|
||||
|
||||
export const mergeExtensionState = (prevState: ExtensionState, newState: ExtensionState) => {
|
||||
const {
|
||||
apiConfiguration: prevApiConfiguration,
|
||||
customModePrompts: prevCustomModePrompts,
|
||||
customSupportPrompts: prevCustomSupportPrompts,
|
||||
experiments: prevExperiments,
|
||||
...prevRest
|
||||
} = prevState
|
||||
|
||||
const {
|
||||
apiConfiguration: newApiConfiguration,
|
||||
customModePrompts: newCustomModePrompts,
|
||||
customSupportPrompts: newCustomSupportPrompts,
|
||||
experiments: newExperiments,
|
||||
...newRest
|
||||
} = newState
|
||||
|
||||
const apiConfiguration = { ...prevApiConfiguration, ...newApiConfiguration }
|
||||
const customModePrompts = { ...prevCustomModePrompts, ...newCustomModePrompts }
|
||||
const customSupportPrompts = { ...prevCustomSupportPrompts, ...newCustomSupportPrompts }
|
||||
const experiments = { ...prevExperiments, ...newExperiments }
|
||||
const rest = { ...prevRest, ...newRest }
|
||||
|
||||
return { ...rest, apiConfiguration, customModePrompts, customSupportPrompts, experiments }
|
||||
}
|
||||
|
||||
export const ExtensionStateContextProvider: React.FC<{ children: React.ReactNode }> = ({ children }) => {
|
||||
const [state, setState] = useState<ExtensionState>({
|
||||
version: "",
|
||||
|
|
@ -253,6 +277,3 @@ export const useExtensionState = () => {
|
|||
}
|
||||
return context
|
||||
}
|
||||
|
||||
export const mergeExtensionState = (prevState: ExtensionState, newState: ExtensionState): ExtensionState =>
|
||||
merge({}, prevState, newState)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue