fix: linter errors

This commit is contained in:
Tomasz Stefaniak 2025-10-07 14:44:25 -07:00
parent 7b82f4fc3d
commit 4582ab2df3
5 changed files with 112 additions and 49 deletions

View file

@ -46,29 +46,8 @@ export function EditMessageSelector({
}, [selectedIndex, isEditing, userMessages, textBuffer]);
useInput((input, key) => {
// If not editing, handle navigation
if (!isEditing) {
if (key.upArrow || input === "k") {
setSelectedIndex((prev) =>
prev > 0 ? prev - 1 : userMessages.length - 1,
);
} else if (key.downArrow || input === "j") {
setSelectedIndex((prev) =>
prev < userMessages.length - 1 ? prev + 1 : 0,
);
} else if (key.return) {
// Start editing the selected message - set cursor to end
const content =
typeof userMessages[selectedIndex]?.item.message.content === "string"
? userMessages[selectedIndex].item.message.content
: "";
textBuffer.setCursor(content.length);
setCursorPosition(content.length);
setIsEditing(true);
} else if (key.escape || (key.ctrl && input === "d")) {
onExit();
}
} else {
// If editing, handle text input
if (isEditing) {
// In edit mode, handle text input
if (key.escape) {
setIsEditing(false);
@ -97,6 +76,28 @@ export function EditMessageSelector({
setEditText(textBuffer.text);
setCursorPosition(textBuffer.cursor);
}
} else {
// If not editing, handle navigation
if (key.upArrow || input === "k") {
setSelectedIndex((prev) =>
prev > 0 ? prev - 1 : userMessages.length - 1,
);
} else if (key.downArrow || input === "j") {
setSelectedIndex((prev) =>
prev < userMessages.length - 1 ? prev + 1 : 0,
);
} else if (key.return) {
// Start editing the selected message - set cursor to end
const content =
typeof userMessages[selectedIndex]?.item.message.content === "string"
? userMessages[selectedIndex].item.message.content
: "";
textBuffer.setCursor(content.length);
setCursorPosition(content.length);
setIsEditing(true);
} else if (key.escape || (key.ctrl && input === "d")) {
onExit();
}
}
});
@ -165,12 +166,6 @@ export function EditMessageSelector({
);
};
const selectedMessage = userMessages[selectedIndex];
const messageContent =
typeof selectedMessage?.item.message.content === "string"
? selectedMessage.item.message.content
: "";
return (
<Box {...defaultBoxStyles("yellow")}>
<Text color="yellow" bold>

View file

@ -0,0 +1,76 @@
import type { AssistantConfig } from "@continuedev/sdk";
import React from "react";
import type { ActivePermissionRequest } from "../hooks/useChat.types.js";
import { UserInput } from "../UserInput.js";
import { ToolPermissionSelector } from "./ToolPermissionSelector.js";
interface ChatScreenContentProps {
activePermissionRequest: ActivePermissionRequest | null;
handleToolPermissionResponse: (
requestId: string,
approved: boolean,
createPolicy?: boolean,
stopStream?: boolean,
) => void;
handleUserMessage: (message: string, imageMap?: Map<string, Buffer>) => void;
isWaitingForResponse: boolean;
isCompacting: boolean;
inputMode: boolean;
handleInterrupt: () => void;
assistant?: AssistantConfig;
wasInterrupted: boolean;
handleFileAttached: (filePath: string, content: string) => void;
isInputDisabled: boolean;
isRemoteMode: boolean;
onImageInClipboardChange?: (hasImage: boolean) => void;
onShowEditSelector?: () => void;
}
export const ChatScreenContent: React.FC<ChatScreenContentProps> = ({
activePermissionRequest,
handleToolPermissionResponse,
handleUserMessage,
isWaitingForResponse,
isCompacting,
inputMode,
handleInterrupt,
assistant,
wasInterrupted,
handleFileAttached,
isInputDisabled,
isRemoteMode,
onImageInClipboardChange,
onShowEditSelector,
}) => {
if (activePermissionRequest) {
return (
<ToolPermissionSelector
toolName={activePermissionRequest.toolName}
toolArgs={activePermissionRequest.toolArgs}
requestId={activePermissionRequest.requestId}
toolCallPreview={activePermissionRequest.toolCallPreview}
hasDynamicEvaluation={activePermissionRequest.hasDynamicEvaluation}
onResponse={handleToolPermissionResponse}
/>
);
}
return (
<UserInput
onSubmit={handleUserMessage}
isWaitingForResponse={isWaitingForResponse}
isCompacting={isCompacting}
inputMode={inputMode}
onInterrupt={handleInterrupt}
assistant={assistant}
wasInterrupted={wasInterrupted}
onFileAttached={handleFileAttached}
disabled={isInputDisabled}
isRemoteMode={isRemoteMode}
onImageInClipboardChange={onImageInClipboardChange}
onShowEditSelector={onShowEditSelector}
/>
);
};

View file

@ -9,14 +9,15 @@ import type { NavigationScreen } from "../context/NavigationContext.js";
import { DiffViewer } from "../DiffViewer.js";
import { EditMessageSelector } from "../EditMessageSelector.js";
import { FreeTrialTransitionUI } from "../FreeTrialTransitionUI.js";
import type { ActivePermissionRequest } from "../hooks/useChat.types.js";
import { MCPSelector } from "../MCPSelector.js";
import { ModelSelector } from "../ModelSelector.js";
import type { ConfigOption, ModelOption } from "../types/selectorTypes.js";
import { UpdateSelector } from "../UpdateSelector.js";
import { UserInput } from "../UserInput.js";
import { ChatScreenContent } from "./ChatScreenContent.js";
import { SessionSelectorWithLoading } from "./SessionSelectorWithLoading.js";
import { ToolPermissionSelector } from "./ToolPermissionSelector.js";
interface ScreenContentProps {
isScreenActive: (screen: NavigationScreen) => boolean;
@ -28,7 +29,7 @@ interface ScreenContentProps {
handleSessionSelect: (sessionId: string) => Promise<void>;
handleReload: () => Promise<void>;
closeCurrentScreen: () => void;
activePermissionRequest: any;
activePermissionRequest: ActivePermissionRequest | null;
handleToolPermissionResponse: (
requestId: string,
approved: boolean,
@ -188,29 +189,19 @@ export const ScreenContent: React.FC<ScreenContentProps> = ({
// Chat screen with input area
if (isScreenActive("chat")) {
if (activePermissionRequest) {
return (
<ToolPermissionSelector
toolName={activePermissionRequest.toolName}
toolArgs={activePermissionRequest.toolArgs}
requestId={activePermissionRequest.requestId}
toolCallPreview={activePermissionRequest.toolCallPreview}
hasDynamicEvaluation={activePermissionRequest.hasDynamicEvaluation}
onResponse={handleToolPermissionResponse}
/>
);
}
return (
<UserInput
onSubmit={handleUserMessage}
<ChatScreenContent
activePermissionRequest={activePermissionRequest}
handleToolPermissionResponse={handleToolPermissionResponse}
handleUserMessage={handleUserMessage}
isWaitingForResponse={isWaitingForResponse}
isCompacting={isCompacting}
inputMode={inputMode}
onInterrupt={handleInterrupt}
handleInterrupt={handleInterrupt}
assistant={services.config?.config || undefined}
wasInterrupted={wasInterrupted}
onFileAttached={handleFileAttached}
disabled={isInputDisabled}
handleFileAttached={handleFileAttached}
isInputDisabled={isInputDisabled}
isRemoteMode={isRemoteMode}
onImageInClipboardChange={onImageInClipboardChange}
onShowEditSelector={onShowEditSelector}

View file

@ -58,7 +58,7 @@ export function useChat({
onShowUpdateSelector,
onShowMCPSelector,
onShowSessionSelector,
onShowEditSelector,
onShowEditSelector: _onShowEditSelector,
onLoginPrompt: _onLoginPrompt,
onClear,
onRefreshStatic,

View file

@ -40,6 +40,7 @@ export interface ActivePermissionRequest {
toolArgs: any;
requestId: string;
toolCallPreview?: ToolCallPreview[];
hasDynamicEvaluation?: boolean;
}
export interface RemoteServerState {