Skip to content

Commit

Permalink
tool use ui improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
sestinj committed Nov 22, 2024
1 parent a540421 commit 98db7d3
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 37 deletions.
3 changes: 2 additions & 1 deletion .continueignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ docs/docs/languages
.idea/
.vscode/
.archive/
**/*.scm
**/*.scm
**/*.diff
5 changes: 1 addition & 4 deletions gui/src/components/StepContainer/StepContainer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,7 @@ export default function StepContainer(props: StepContainerProps) {

return (
<div
// className={isStepAheadOfCurCheckpoint ? "opacity-25" : "relative"}
style={{
minHeight: props.isLast ? "50vh" : 0,
}}
// className={isStepAheadOfCurCheckpoint ? "opacity-25" : "relative"}
>
<ContentDiv>
{uiConfig?.displayRawMarkdown ? (
Expand Down
13 changes: 13 additions & 0 deletions gui/src/hooks/useChatHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import { defaultModelSelector } from "../redux/selectors/modelSelectors";
import {
abortStream,
acceptToolCall,
addContextItemsAtIndex,
addPromptCompletionPair,
clearLastEmptyResponse,
initNewActiveMessage,
Expand Down Expand Up @@ -398,6 +399,18 @@ function useChatHandler(dispatch: Dispatch, ideMessenger: IIdeMessenger) {
};

dispatch(streamUpdate(newMessage));
dispatch(
addContextItemsAtIndex({
index: history.length,
contextItems: toolOutput.map((contextItem) => ({
...contextItem,
id: {
providerTitle: "toolCall",
itemId: toolCallId,
},
})),
}),
);
dispatch(acceptToolCall());
activeRef.current = true;
dispatch(setActive());
Expand Down
25 changes: 11 additions & 14 deletions gui/src/pages/gui/Chat.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,8 @@ import {
} from "@heroicons/react/24/outline";
import { JSONContent } from "@tiptap/react";
import { InputModifiers } from "core";
import { renderChatMessage } from "core/util/messageContent";
import { usePostHog } from "posthog-js/react";
import {
Fragment,
useCallback,
useContext,
useEffect,
useRef,
useState,
} from "react";
import { useCallback, useContext, useEffect, useRef, useState } from "react";
import { ErrorBoundary } from "react-error-boundary";
import { useDispatch, useSelector } from "react-redux";
import styled from "styled-components";
Expand All @@ -28,6 +20,7 @@ import {
import { ChatScrollAnchor } from "../../components/ChatScrollAnchor";
import { useFindWidget } from "../../components/find/FindWidget";
import TimelineItem from "../../components/gui/TimelineItem";
import ChatIndexingPeeks from "../../components/indexing/ChatIndexingPeeks";
import ContinueInputBox from "../../components/mainInput/ContinueInputBox";
import { NewSessionButton } from "../../components/mainInput/NewSessionButton";
import { TutorialCard } from "../../components/mainInput/TutorialCard";
Expand Down Expand Up @@ -60,11 +53,10 @@ import {
} from "../../util";
import { FREE_TRIAL_LIMIT_REQUESTS } from "../../util/freeTrial";
import { getLocalStorage, setLocalStorage } from "../../util/localStorage";
import ConfigErrorIndicator from "./ConfigError";
import { ToolCallDiv } from "./ToolCallDiv";
import { ToolCallButtons } from "./ToolCallDiv/ToolCallButtonsDiv";
import ToolOutput from "./ToolCallDiv/ToolOutput";
import ConfigErrorIndicator from "./ConfigError";
import ChatIndexingPeeks from "../../components/indexing/ChatIndexingPeeks";

const StopButton = styled.div`
background-color: ${vscBackground};
Expand Down Expand Up @@ -332,7 +324,12 @@ export function Chat() {
>
{highlights}
{state.history.map((item, index: number) => (
<Fragment key={item.message.id}>
<div
key={item.message.id}
style={{
minHeight: index === state.history.length - 1 ? "50vh" : 0,
}}
>
<ErrorBoundary
FallbackComponent={fallbackRender}
onReset={() => {
Expand All @@ -351,7 +348,7 @@ export function Chat() {
/>
) : item.message.role === "tool" ? (
<ToolOutput
output={renderChatMessage(item.message)}
contextItems={item.contextItems}
toolCallId={item.message.toolCallId}
/>
) : item.message.role === "assistant" &&
Expand Down Expand Up @@ -401,7 +398,7 @@ export function Chat() {
</div>
)}
</ErrorBoundary>
</Fragment>
</div>
))}
<ChatScrollAnchor
scrollAreaRef={stepsDivRef}
Expand Down
2 changes: 1 addition & 1 deletion gui/src/pages/gui/ToolCallDiv/FunctionSpecificHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export function FunctionSpecificHeader(props: FunctionSpecificHeaderProps) {

switch (props.toolCall.function.name) {
case "create_new_file":
message = "Continue wants to create a new file";
message = "Continue wants to write to a file";
break;
case "run_terminal_command":
message = "Continue wants to run a terminal command.";
Expand Down
22 changes: 5 additions & 17 deletions gui/src/pages/gui/ToolCallDiv/ToolOutput.tsx
Original file line number Diff line number Diff line change
@@ -1,33 +1,21 @@
import { ContextItemWithId } from "core";
import ContextItemsPeek from "../../../components/mainInput/ContextItemsPeek";

interface ToolOutputProps {
output: string;
contextItems: ContextItemWithId[];
toolCallId: string;
}

function ToolOutput(props: ToolOutputProps) {
if (
props.output === undefined ||
props.output === null ||
props.output.trim() === ""
) {
if (props.contextItems.length === 0) {
return null;
}

return (
<div>
<ContextItemsPeek
isCurrentContextPeek={false}
contextItems={[
{
content: props.output,
name: "Tool Call",
id: {
itemId: props.toolCallId,
providerTitle: "tool-call",
},
description: "Tool Call",
},
]}
contextItems={props.contextItems}
/>
</div>
);
Expand Down

0 comments on commit 98db7d3

Please sign in to comment.