added wrap code to llm response
This commit is contained in:
parent
fabf54bfe2
commit
38b8e02f3e
4 changed files with 35 additions and 1 deletions
|
|
@ -4,6 +4,7 @@ import {
|
|||
CommandLineIcon,
|
||||
PlayIcon,
|
||||
ArrowLeftEndOnRectangleIcon,
|
||||
Bars3CenterLeftIcon,
|
||||
} from "@heroicons/react/24/outline";
|
||||
import { defaultBorderRadius, vscEditorBackground } from "..";
|
||||
import { IdeMessengerContext } from "../../context/IdeMessenger";
|
||||
|
|
@ -18,6 +19,8 @@ import {
|
|||
selectDefaultModel,
|
||||
selectUIConfig,
|
||||
} from "../../redux/slices/configSlice";
|
||||
import { useDispatch } from "react-redux";
|
||||
import { toggle } from "../../redux/slices/codeWrapSlice";
|
||||
|
||||
const TopDiv = styled.div`
|
||||
outline: 0.5px solid rgba(153, 153, 152);
|
||||
|
|
@ -66,6 +69,7 @@ export default function StepContainerPreActionButtons({
|
|||
const ideMessenger = useContext(IdeMessengerContext);
|
||||
const uiConfig = useAppSelector(selectUIConfig);
|
||||
const streamIdRef = useRef<string | null>(null);
|
||||
const dispatch = useDispatch();
|
||||
const nextCodeBlockIndex = useAppSelector(
|
||||
(state) => state.session.codeBlockApplyStates.curIndex,
|
||||
);
|
||||
|
|
@ -93,6 +97,10 @@ export default function StepContainerPreActionButtons({
|
|||
});
|
||||
}
|
||||
|
||||
function toggleWrap() {
|
||||
dispatch(toggle());
|
||||
}
|
||||
|
||||
async function onClickRunTerminal(): Promise<void> {
|
||||
if (shouldRunTerminalCmd) {
|
||||
return ideMessenger.ide.runCommand(getTerminalCommand(codeBlockContent));
|
||||
|
|
@ -153,6 +161,13 @@ export default function StepContainerPreActionButtons({
|
|||
<ArrowLeftEndOnRectangleIcon className="h-4 w-4 text-gray-400" />
|
||||
</HeaderButtonWithToolTip>
|
||||
<CopyIconButton text={codeBlockContent} />
|
||||
<HeaderButtonWithToolTip
|
||||
text="Wrap code"
|
||||
style={{ backgroundColor: vscEditorBackground }}
|
||||
onClick={toggleWrap}
|
||||
>
|
||||
<Bars3CenterLeftIcon className="h-4 w-4 text-gray-400" />
|
||||
</HeaderButtonWithToolTip>
|
||||
</InnerHoverDiv>
|
||||
</HoverDiv>
|
||||
{children}
|
||||
|
|
|
|||
|
|
@ -25,11 +25,14 @@ import SymbolLink from "./SymbolLink";
|
|||
import { SyntaxHighlightedPre } from "./SyntaxHighlightedPre";
|
||||
import { patchNestedMarkdown } from "./utils/patchNestedMarkdown";
|
||||
import { useAppSelector } from "../../redux/hooks";
|
||||
import { RootState } from '../../redux/store';
|
||||
|
||||
const StyledMarkdown = styled.div<{
|
||||
fontSize?: number;
|
||||
whiteSpace: string;
|
||||
}>`
|
||||
pre {
|
||||
white-space: ${(props) => props.whiteSpace};
|
||||
background-color: ${vscEditorBackground};
|
||||
border-radius: ${defaultBorderRadius};
|
||||
|
||||
|
|
@ -289,8 +292,10 @@ const StyledMarkdownPreview = memo(function StyledMarkdownPreview(
|
|||
setMarkdownSource(patchNestedMarkdown(props.source ?? ""));
|
||||
}, [props.source]);
|
||||
|
||||
const codeWrapState = useSelector((state: RootState) => state.codeWrap);
|
||||
console.log("here", codeWrapState);
|
||||
return (
|
||||
<StyledMarkdown fontSize={getFontSize()}>{reactContent}</StyledMarkdown>
|
||||
<StyledMarkdown fontSize={getFontSize()} whiteSpace={codeWrapState}>{reactContent}</StyledMarkdown>
|
||||
);
|
||||
});
|
||||
|
||||
|
|
|
|||
12
gui/src/redux/slices/codeWrapSlice.ts
Normal file
12
gui/src/redux/slices/codeWrapSlice.ts
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
import { createSlice } from '@reduxjs/toolkit';
|
||||
|
||||
const isWrappedSlice = createSlice({
|
||||
name: "codeWrap",
|
||||
initialState: "pre",
|
||||
reducers: {
|
||||
toggle: (state) => (state === "pre" ? "pre-wrap" : "pre"),
|
||||
},
|
||||
});
|
||||
|
||||
export const { toggle } = isWrappedSlice.actions;
|
||||
export default isWrappedSlice.reducer;
|
||||
|
|
@ -15,6 +15,7 @@ import configReducer from "./slices/configSlice";
|
|||
import indexingReducer from "./slices/indexingSlice";
|
||||
import sessionReducer from "./slices/sessionSlice";
|
||||
import uiReducer from "./slices/uiSlice";
|
||||
import codeWrapReducer from "./slices/codeWrapSlice"
|
||||
|
||||
export interface ChatMessage {
|
||||
role: "system" | "user" | "assistant";
|
||||
|
|
@ -28,6 +29,7 @@ const rootReducer = combineReducers({
|
|||
editModeState: editModeStateReducer,
|
||||
config: configReducer,
|
||||
indexing: indexingReducer,
|
||||
codeWrap: codeWrapReducer,
|
||||
});
|
||||
|
||||
const saveSubsetFilters = [
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue