From fe97190e40b04c7b08bcd8775957e2dc880c20ef Mon Sep 17 00:00:00 2001 From: Patrick Erichsen Date: Tue, 8 Apr 2025 22:00:54 -0700 Subject: [PATCH] fix linting errors --- .../StepContainerPreToolbar.tsx | 4 ++-- gui/src/pages/gui/Chat.tsx | 10 +++++----- gui/src/redux/thunks/callTool.ts | 4 ++-- gui/src/redux/thunks/gatherContext.ts | 2 +- gui/src/redux/thunks/streamNormalInput.ts | 4 ++-- gui/src/redux/thunks/streamResponse.ts | 4 +--- gui/src/redux/thunks/streamResponseAfterToolCall.ts | 2 +- 7 files changed, 14 insertions(+), 16 deletions(-) diff --git a/gui/src/components/markdown/StepContainerPreToolbar/StepContainerPreToolbar.tsx b/gui/src/components/markdown/StepContainerPreToolbar/StepContainerPreToolbar.tsx index 0571913b6..c00290e4c 100644 --- a/gui/src/components/markdown/StepContainerPreToolbar/StepContainerPreToolbar.tsx +++ b/gui/src/components/markdown/StepContainerPreToolbar/StepContainerPreToolbar.tsx @@ -82,10 +82,10 @@ export default function StepContainerPreToolbar( const isNextCodeBlock = nextCodeBlockIndex === props.codeBlockIndex; const hasFileExtension = /\.[0-9a-z]+$/i.test(props.relativeFilepath); - const defaultModel = useAppSelector(selectSelectedChatModel); + const selectedChatModel = useAppSelector(selectSelectedChatModel); async function onClickApply() { - if (!defaultModel) { + if (!selectedChatModel) { return; } diff --git a/gui/src/pages/gui/Chat.tsx b/gui/src/pages/gui/Chat.tsx index b6fa33ee8..0ffd577c1 100644 --- a/gui/src/pages/gui/Chat.tsx +++ b/gui/src/pages/gui/Chat.tsx @@ -105,7 +105,7 @@ export function Chat() { const showSessionTabs = useAppSelector( (store) => store.config.config.ui?.showSessionTabs, ); - const defaultModel = useAppSelector(selectSelectedChatModel); + const selectedChatModel = useAppSelector(selectSelectedChatModel); const isStreaming = useAppSelector((state) => state.session.isStreaming); const [stepsOpen, setStepsOpen] = useState<(boolean | undefined)[]>([]); const mainTextInputRef = useRef(null); @@ -165,7 +165,7 @@ export function Chat() { "Cannot submit message while awaiting tool confirmation", ); } - if (defaultModel?.provider === "free-trial") { + if (selectedChatModel?.provider === "free-trial") { const newCount = incrementFreeTrialCount(); if (newCount === FREE_TRIAL_LIMIT_REQUESTS) { @@ -224,7 +224,7 @@ export function Chat() { }, [ history, - defaultModel, + selectedChatModel, streamResponse, isSingleRangeEditOrInsertion, codeToEdit, @@ -233,7 +233,7 @@ export function Chat() { ); async function handleSingleRangeEditOrInsertion(editorState: JSONContent) { - if (!defaultModel) { + if (!selectedChatModel) { console.error("No selected chat model"); return; } @@ -248,7 +248,7 @@ export function Chat() { defaultContextProviders: [], availableSlashCommands: [], dispatch, - selectedModelTitle: defaultModel.title, + selectedModelTitle: selectedChatModel.title, }); const prompt = [ diff --git a/gui/src/redux/thunks/callTool.ts b/gui/src/redux/thunks/callTool.ts index 31e67b6d3..cb875f805 100644 --- a/gui/src/redux/thunks/callTool.ts +++ b/gui/src/redux/thunks/callTool.ts @@ -32,7 +32,7 @@ export const callTool = createAsyncThunk( const selectedChatModel = selectSelectedChatModel(state); - if (!defaultModel) { + if (!selectedChatModel) { throw new Error("No model selected"); } @@ -77,7 +77,7 @@ export const callTool = createAsyncThunk( } else { const result = await extra.ideMessenger.request("tools/call", { toolCall: toolCallState.toolCall, - selectedModelTitle: defaultModel.title, + selectedModelTitle: selectedChatModel.title, }); if (result.status === "error") { errorMessage = result.error; diff --git a/gui/src/redux/thunks/gatherContext.ts b/gui/src/redux/thunks/gatherContext.ts index abc547c41..927866ed8 100644 --- a/gui/src/redux/thunks/gatherContext.ts +++ b/gui/src/redux/thunks/gatherContext.ts @@ -42,7 +42,7 @@ export const gatherContext = createAsyncThunk< const defaultContextProviders = state.config.config.experimental?.defaultContext ?? []; - if (!defaultModel) { + if (!selectedChatModel) { console.error( "gatherContext thunk: Cannot gather context, no model selected", ); diff --git a/gui/src/redux/thunks/streamNormalInput.ts b/gui/src/redux/thunks/streamNormalInput.ts index 507382d3f..447ac3d3d 100644 --- a/gui/src/redux/thunks/streamNormalInput.ts +++ b/gui/src/redux/thunks/streamNormalInput.ts @@ -35,10 +35,10 @@ export const streamNormalInput = createAsyncThunk< const toolGroupSettings = state.ui.toolGroupSettings; const streamAborter = state.session.streamAborter; const useTools = selectUseTools(state); - if (!defaultModel) { + if (!selectedChatModel) { throw new Error("Default model not defined"); } - const includeTools = useTools && modelSupportsTools(defaultModel); + const includeTools = useTools && modelSupportsTools(selectedChatModel); // Send request const gen = extra.ideMessenger.llmStreamChat( diff --git a/gui/src/redux/thunks/streamResponse.ts b/gui/src/redux/thunks/streamResponse.ts index b6c806a2e..e79bcdf85 100644 --- a/gui/src/redux/thunks/streamResponse.ts +++ b/gui/src/redux/thunks/streamResponse.ts @@ -35,11 +35,9 @@ export const streamResponseThunk = createAsyncThunk< streamThunkWrapper(async () => { const state = getState(); const selectedChatModel = selectSelectedChatModel(state); - - const slashCommands = state.config.config.slashCommands || []; const inputIndex = index ?? state.session.history.length; // Either given index or concat to end - if (!defaultModel) { + if (!selectedChatModel) { throw new Error("No chat model selected"); } diff --git a/gui/src/redux/thunks/streamResponseAfterToolCall.ts b/gui/src/redux/thunks/streamResponseAfterToolCall.ts index cb0de2756..3fa335d8b 100644 --- a/gui/src/redux/thunks/streamResponseAfterToolCall.ts +++ b/gui/src/redux/thunks/streamResponseAfterToolCall.ts @@ -29,7 +29,7 @@ export const streamResponseAfterToolCall = createAsyncThunk< const initialHistory = state.session.history; const selectedChatModel = selectSelectedChatModel(state); - if (!defaultModel) { + if (!selectedChatModel) { throw new Error("No model selected"); }