Skip to content

Commit 5ebf258

Browse files
committed
fix: send current model to at-command-preview & requested changes
1 parent 91e7424 commit 5ebf258

File tree

4 files changed

+31
-29
lines changed

4 files changed

+31
-29
lines changed

refact-agent/gui/src/components/ChatForm/ChatForm.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ import { push } from "../../features/Pages/pagesSlice";
5757
import { AgentCapabilities } from "./AgentCapabilities";
5858
import { TokensPreview } from "./TokensPreview";
5959
import { useUsageCounter } from "../UsageCounter/useUsageCounter";
60+
import classNames from "classnames";
6061

6162
export type ChatFormProps = {
6263
onSubmit: (str: string) => void;
@@ -68,7 +69,7 @@ export type ChatFormProps = {
6869
export const ChatForm: React.FC<ChatFormProps> = ({
6970
onSubmit,
7071
onClose,
71-
// className,
72+
className,
7273
unCalledTools,
7374
}) => {
7475
const dispatch = useAppDispatch();
@@ -349,7 +350,7 @@ export const ChatForm: React.FC<ChatFormProps> = ({
349350
{shouldAgentCapabilitiesBeShown && <AgentCapabilities />}
350351
<Form
351352
disabled={disableSend}
352-
className={styles.chatForm__form}
353+
className={classNames(styles.chatForm__form, className)}
353354
onSubmit={handleSubmit}
354355
>
355356
<FilesPreview files={previewFiles} />

refact-agent/gui/src/components/ChatForm/useCommandCompletionAndPreviewFiles.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import {
2121
selectChatId,
2222
selectIsStreaming,
2323
selectMessages,
24+
selectModel,
2425
selectThreadMode,
2526
setUsageTokensOnCommandPreview,
2627
} from "../../features/Chat";
@@ -90,6 +91,7 @@ function useGetCommandPreviewQuery(
9091
const chatId = useAppSelector(selectChatId);
9192
const isStreaming = useAppSelector(selectIsStreaming);
9293
const currentThreadMode = useAppSelector(selectThreadMode);
94+
const currentModel = useAppSelector(selectModel);
9395

9496
const userMessage = maybeAddImagesToQuestion(query);
9597

@@ -101,7 +103,7 @@ function useGetCommandPreviewQuery(
101103
};
102104

103105
const { data } = commandsApi.useGetCommandPreviewQuery(
104-
{ messages: messagesToSend, meta: metaToSend },
106+
{ messages: messagesToSend, meta: metaToSend, model: currentModel },
105107
{
106108
skip: !hasCaps || isStreaming,
107109
},

refact-agent/gui/src/components/UsageCounter/UsageCounter.tsx

Lines changed: 22 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -43,32 +43,30 @@ const InlineHoverCard: React.FC = () => {
4343
const { prompt_tokens } = currentThreadUsage;
4444

4545
return (
46-
<div>
47-
<HoverCard.Content
48-
size="1"
49-
maxHeight="50vh"
50-
avoidCollisions
51-
align="start"
52-
side="top"
53-
>
54-
<Flex direction="column" align="start" gap="2">
55-
{maximumThreadContextTokens && (
56-
<TokenDisplay
57-
label="Current chat thread context size:"
58-
value={maximumThreadContextTokens}
59-
/>
60-
)}
61-
<TokenDisplay
62-
label="Potential tokens from current message:"
63-
value={prompt_tokens}
64-
/>
46+
<HoverCard.Content
47+
size="1"
48+
maxHeight="50vh"
49+
avoidCollisions
50+
align="start"
51+
side="top"
52+
>
53+
<Flex direction="column" align="start" gap="2">
54+
{maximumThreadContextTokens && (
6555
<TokenDisplay
66-
label="Updated prompt tokens for this thread:"
67-
value={totalInputTokens}
56+
label="Current chat thread context size:"
57+
value={maximumThreadContextTokens}
6858
/>
69-
</Flex>
70-
</HoverCard.Content>
71-
</div>
59+
)}
60+
<TokenDisplay
61+
label="Potential tokens from current message:"
62+
value={prompt_tokens}
63+
/>
64+
<TokenDisplay
65+
label="Updated prompt tokens for this thread:"
66+
value={totalInputTokens}
67+
/>
68+
</Flex>
69+
</HoverCard.Content>
7270
);
7371
};
7472

refact-agent/gui/src/services/refact/commands.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ export const commandsApi = createApi({
8585
CommandPreviewRequest
8686
>({
8787
queryFn: async (args, api, _opts, baseQuery) => {
88-
const { messages, meta } = args;
88+
const { messages, meta, model } = args;
8989
const state = api.getState() as RootState;
9090
const port = state.config.lspPort;
9191
const url = `http://127.0.0.1:${port}${AT_COMMAND_PREVIEW}`;
@@ -94,7 +94,7 @@ export const commandsApi = createApi({
9494
method: "POST",
9595
credentials: "same-origin",
9696
redirect: "follow",
97-
body: { messages, meta },
97+
body: { messages, meta, model },
9898
});
9999

100100
if (response.error) return { error: response.error };
@@ -185,6 +185,7 @@ function isCommandPreviewContent(json: unknown): json is CommandPreviewContent {
185185
export type CommandPreviewRequest = {
186186
messages: ChatMessages;
187187
meta: ChatMeta;
188+
model: string;
188189
};
189190

190191
export type CommandPreviewResponse = {

0 commit comments

Comments
 (0)