refactor(frontend): remove the code-slice.ts file (#11021)

This commit is contained in:
Hiep Le 2025-09-19 21:22:29 +07:00 committed by GitHub
parent 0061bcc0b0
commit a8a3e9e604
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 0 additions and 60 deletions

View File

@ -1,58 +0,0 @@
import { createSlice } from "@reduxjs/toolkit";
export interface FileState {
path: string;
savedContent: string;
unsavedContent: string;
}
export const initialState = {
code: "",
path: "",
refreshID: 0,
fileStates: [] as FileState[],
};
export const codeSlice = createSlice({
name: "code",
initialState,
reducers: {
setCode: (state, action) => {
state.code = action.payload;
},
setActiveFilepath: (state, action) => {
state.path = action.payload;
},
setRefreshID: (state, action) => {
state.refreshID = action.payload;
},
setFileStates: (state, action) => {
state.fileStates = action.payload;
},
addOrUpdateFileState: (state, action) => {
const { path, unsavedContent, savedContent } = action.payload;
const newFileStates = state.fileStates.filter(
(fileState) => fileState.path !== path,
);
newFileStates.push({ path, savedContent, unsavedContent });
state.fileStates = newFileStates;
},
removeFileState: (state, action) => {
const path = action.payload;
state.fileStates = state.fileStates.filter(
(fileState) => fileState.path !== path,
);
},
},
});
export const {
setCode,
setActiveFilepath,
setRefreshID,
addOrUpdateFileState,
removeFileState,
setFileStates,
} = codeSlice.actions;
export default codeSlice.reducer;

View File

@ -1,7 +1,6 @@
import { combineReducers, configureStore } from "@reduxjs/toolkit";
import agentReducer from "./state/agent-slice";
import browserReducer from "./state/browser-slice";
import codeReducer from "./state/code-slice";
import fileStateReducer from "./state/file-state-slice";
import initialQueryReducer from "./state/initial-query-slice";
import commandReducer from "./state/command-slice";
@ -17,7 +16,6 @@ export const rootReducer = combineReducers({
fileState: fileStateReducer,
initialQuery: initialQueryReducer,
browser: browserReducer,
code: codeReducer,
cmd: commandReducer,
agent: agentReducer,
jupyter: jupyterReducer,