Elffuss BraidHub

kikocis/continue public

fix: eslint requirements
Changeset73bd9e0b14aa4267374affe52bc9df705df82337a957eb7c64f68d000fe93431
AuthorDallin Romney <dallinromney@gmail.com> · 2025-09-02 19:32 -07:00
CommitterDallin Romney <dallinromney@gmail.com> · 2025-09-02 19:32 -07:00
Parents7fbb7af6157c

Browse the files at this changeset

8 files changed

modified extensions/cli/AGENTS.md +0 −5
@@ -18,30 +18,25 @@
1818 ### Core Components
1919
2020 1. **Entry Point** (`src/index.ts`): Main CLI logic with two modes:
21-
2221 - **Headless mode**: Non-interactive mode for automation/CI
2322 - **TUI mode**: Terminal User Interface using Ink/React
2423 - **Standard mode**: Traditional readline-based chat interface
2524
2625 2. **Authentication** (`src/auth/`): WorkOS-based authentication system
27-
2826 - `ensureAuth.ts`: Handles authentication flow
2927 - `workos.ts`: WorkOS configuration and token management
3028
3129 3. **Continue SDK Integration** (`src/continueSDK.ts`): Initializes the Continue SDK client with:
32-
3330 - API key authentication
3431 - Assistant configuration (slug-based)
3532 - Organization support
3633
3734 4. **Terminal UI** (`src/ui/`): React/Ink-based TUI components
38-
3935 - `TUIChat.tsx`: Main chat interface component
4036 - `UserInput.tsx`: Input handling with multi-line support
4137 - `TextBuffer.ts`: Text display utilities
4238
4339 5. **Tools System** (`src/tools/`): Built-in development tools including:
44-
4540 - File operations (read, write, list)
4641 - Code search functionality
4742 - Terminal command execution
modified extensions/cli/CHAT_HISTORY_SERVICE_MIGRATION_PLAN.md +0 −1
@@ -299,7 +299,6 @@
299299 1. **Streaming integration**: Most complex change
300300 - Mitigation: Extensive testing, gradual rollout
301301 2. **Remote mode**: Different state management
302-
303302 - Mitigation: Test thoroughly, maintain compatibility
304303
305304 3. **Performance**: Large histories might cause issues
modified extensions/cli/spec/config-loading.md +0 −2
@@ -23,13 +23,11 @@
2323 **When CLI is invoked, config source is determined in this order:**
2424
2525 1. **CLI `--config` Flag** (highest priority)
26-
2726 - File path (starts with `.`, `/`, `~`): Loads local YAML file
2827 - Assistant slug (`owner/package`): Fetches from Continue platform
2928 - Overrides any saved preferences
3029
3130 2. **Saved Config URI** (if no `--config` flag)
32-
3331 - Retrieved from authentication config
3432 - Converts `file://` URIs back to file paths
3533 - Converts `slug://` URIs back to assistant slugs
modified extensions/cli/spec/onboarding.md +0 −1
@@ -8,7 +8,6 @@
88
99 1. If the --config flag is provided, load this config
1010 2. Otherwise, we will present the user with two options:
11-
1211 - Log in with Continue: log them in, which will automatically create their assistant and then we can load the first assistant from the first org
1312 - Enter your Anthropic API key: let them enter the key, and then either create a ~/.continue/config.yaml with the following contents OR update the existing config.yaml to add the model
1413
modified extensions/cli/src/ui/UserInput.tsx +92 −30
@@ -19,6 +19,77 @@
1919 import { SlashCommandUI } from "./SlashCommandUI.js";
2020 import { TextBuffer } from "./TextBuffer.js";
2121
22+// Small presentational helpers to reduce cyclomatic complexity in UserInput
23+const InterruptedBanner: React.FC<{ wasInterrupted: boolean }> = ({
24+ wasInterrupted,
25+}) => {
26+ if (!wasInterrupted) return null;
27+ return (
28+ <Box paddingX={1} marginBottom={0}>
29+ <Text color="yellow">⚠ Interrupted by user - Press enter to resume</Text>
30+ </Box>
31+ );
32+};
33+
34+const SlashCommandsMaybe: React.FC<{
35+ show: boolean;
36+ inputMode: boolean;
37+ hideNormalUI: boolean;
38+ isRemoteMode: boolean;
39+ assistant?: AssistantConfig;
40+ filter: string;
41+ selectedIndex: number;
42+}> = ({
43+ show,
44+ inputMode,
45+ hideNormalUI,
46+ isRemoteMode,
47+ assistant,
48+ filter,
49+ selectedIndex,
50+}) => {
51+ if (!show || !inputMode || hideNormalUI || !(isRemoteMode || assistant))
52+ return null;
53+ return (
54+ <SlashCommandUI
55+ assistant={assistant}
56+ filter={filter}
57+ selectedIndex={selectedIndex}
58+ isRemoteMode={isRemoteMode}
59+ />
60+ );
61+};
62+
63+const FileSearchMaybe: React.FC<{
64+ show: boolean;
65+ inputMode: boolean;
66+ hideNormalUI: boolean;
67+ isRemoteMode: boolean;
68+ filter: string;
69+ selectedIndex: number;
70+ onSelect: (path: string) => void | Promise<void>;
71+ onFilesUpdated: (files: Array<{ path: string; displayName: string }>) => void;
72+}> = ({
73+ show,
74+ inputMode,
75+ hideNormalUI,
76+ isRemoteMode,
77+ filter,
78+ selectedIndex,
79+ onSelect,
80+ onFilesUpdated,
81+}) => {
82+ if (!show || !inputMode || hideNormalUI || isRemoteMode) return null;
83+ return (
84+ <FileSearchUI
85+ filter={filter}
86+ selectedIndex={selectedIndex}
87+ onSelect={onSelect}
88+ onFilesUpdated={onFilesUpdated}
89+ />
90+ );
91+};
92+
2293 interface UserInputProps {
2394 onSubmit: (message: string, imageMap?: Map<string, Buffer>) => void;
2495 isWaitingForResponse: boolean;
@@ -702,14 +773,7 @@
702773
703774 return (
704775 <Box flexDirection="column">
705- {/* Interruption message - shown just above the input box */}
706- {wasInterrupted && (
707- <Box paddingX={1} marginBottom={0}>
708- <Text color="yellow">
709- ⚠ Interrupted by user - Press enter to resume
710- </Text>
711- </Box>
712- )}
776+ <InterruptedBanner wasInterrupted={!!wasInterrupted} />
713777
714778 {/* Input box */}
715779 <Box
@@ -727,28 +791,26 @@
727791 {renderInputText()}
728792 </Box>
729793
730- {/* Slash command UI - show in remote mode OR when assistant is available */}
731- {showSlashCommands &&
732- inputMode &&
733- !hideNormalUI &&
734- (isRemoteMode || assistant) && (
735- <SlashCommandUI
736- assistant={assistant}
737- filter={slashCommandFilter}
738- selectedIndex={selectedCommandIndex}
739- isRemoteMode={isRemoteMode}
740- />
741- )}
742-
743- {/* File search UI - only show in local mode */}
744- {showFileSearch && inputMode && !hideNormalUI && !isRemoteMode && (
745- <FileSearchUI
746- filter={fileSearchFilter}
747- selectedIndex={selectedFileIndex}
748- onSelect={selectFile}
749- onFilesUpdated={setCurrentFiles}
750- />
751- )}
794+ <SlashCommandsMaybe
795+ show={showSlashCommands}
796+ inputMode={inputMode}
797+ hideNormalUI={!!hideNormalUI}
798+ isRemoteMode={!!isRemoteMode}
799+ assistant={assistant}
800+ filter={slashCommandFilter}
801+ selectedIndex={selectedCommandIndex}
802+ />
803+
804+ <FileSearchMaybe
805+ show={showFileSearch}
806+ inputMode={inputMode}
807+ hideNormalUI={!!hideNormalUI}
808+ isRemoteMode={!!isRemoteMode}
809+ filter={fileSearchFilter}
810+ selectedIndex={selectedFileIndex}
811+ onSelect={selectFile}
812+ onFilesUpdated={setCurrentFiles}
813+ />
752814 </Box>
753815 );
754816 };
modified extensions/cli/src/ui/hooks/useChat.bashMode.test.ts +4 −4
@@ -1,7 +1,10 @@
1-import { describe, it, expect, vi, beforeEach } from "vitest";
21 import { act } from "@testing-library/react";
2+import { describe, it, expect, vi, beforeEach } from "vitest";
33
44 import { createMinimalTestContext } from "../../test-helpers/ui-test-context.js";
5+import { runTerminalCommandTool } from "../../tools/runTerminalCommand.js";
6+
7+import { useChat } from "./useChat.js";
58
69 // Mock the runTerminalCommandTool
710 vi.mock("../../tools/runTerminalCommand.js", () => ({
@@ -10,9 +13,6 @@
1013 },
1114 }));
1215
13-import { useChat } from "./useChat.js";
14-import { runTerminalCommandTool } from "../../tools/runTerminalCommand.js";
15-
1616 describe("useChat - Bash Mode", () => {
1717 beforeEach(() => {
1818 vi.clearAllMocks();
added extensions/cli/src/ui/hooks/useChat.bashMode.ts +51 −0
@@ -0,0 +1,51 @@
1+import { services } from "../../services/index.js";
2+
3+export const handleBashModeProcessing = async (
4+ message: string,
5+): Promise<string | null> => {
6+ // Handle bash mode commands (starting with !)
7+ if (!message.trimStart().startsWith("!")) {
8+ return message;
9+ }
10+
11+ // Extract the command after the !
12+ const bashCommand = message.trimStart().slice(1).trim();
13+
14+ if (!bashCommand) {
15+ return message; // No command provided, treat as regular message
16+ }
17+
18+ // Show tool call immediately, then run asynchronously and populate result
19+ const toolCallId = `bash-${Date.now()}-${Math.random().toString(36).slice(2, 8)}`;
20+ const toolCall = {
21+ id: toolCallId,
22+ type: "function" as const,
23+ function: {
24+ name: "Bash",
25+ arguments: JSON.stringify({ command: bashCommand }),
26+ },
27+ };
28+
29+ // Add assistant message with tool call immediately
30+ services.chatHistory.addAssistantMessage("", [toolCall as any]);
31+ // Mark as calling for immediate UI feedback
32+ services.chatHistory.updateToolStatus(toolCallId, "calling");
33+
34+ // Execute the bash command asynchronously - don't block UI
35+ (async () => {
36+ try {
37+ const { runTerminalCommandTool } = await import(
38+ "../../tools/runTerminalCommand.js"
39+ );
40+ const result = await runTerminalCommandTool.run({
41+ command: bashCommand,
42+ });
43+ services.chatHistory.addToolResult(toolCallId, result, "done");
44+ } catch (error: any) {
45+ const errorMessage = `Bash command failed: ${error?.message || String(error)}`;
46+ services.chatHistory.addToolResult(toolCallId, errorMessage, "errored");
47+ }
48+ })();
49+
50+ return null; // Processed, no further message handling needed
51+};
modified extensions/cli/src/ui/hooks/useChat.ts +1 −50
@@ -15,6 +15,7 @@
1515 import { formatError } from "../../util/formatError.js";
1616 import { logger } from "../../util/logger.js";
1717
18+import { handleBashModeProcessing } from "./useChat.bashMode.js";
1819 import {
1920 handleAutoCompaction,
2021 handleCompactCommand,
@@ -339,56 +340,6 @@
339340 return false;
340341 };
341342
342- const handleBashModeProcessing = async (
343- message: string,
344- ): Promise<string | null> => {
345- // Handle bash mode commands (starting with !)
346- if (!message.trimStart().startsWith("!")) {
347- return message;
348- }
349-
350- // Extract the command after the !
351- const bashCommand = message.trimStart().slice(1).trim();
352-
353- if (!bashCommand) {
354- return message; // No command provided, treat as regular message
355- }
356-
357- // Show tool call immediately, then run asynchronously and populate result
358- const toolCallId = `bash-${Date.now()}-${Math.random().toString(36).slice(2, 8)}`;
359- const toolCall = {
360- id: toolCallId,
361- type: "function" as const,
362- function: {
363- name: "Bash",
364- arguments: JSON.stringify({ command: bashCommand }),
365- },
366- };
367-
368- // Add assistant message with tool call immediately
369- services.chatHistory.addAssistantMessage("", [toolCall as any]);
370- // Mark as calling for immediate UI feedback
371- services.chatHistory.updateToolStatus(toolCallId, "calling");
372-
373- // Execute the bash command asynchronously - don't block UI
374- (async () => {
375- try {
376- const { runTerminalCommandTool } = await import(
377- "../../tools/runTerminalCommand.js"
378- );
379- const result = await runTerminalCommandTool.run({
380- command: bashCommand,
381- });
382- services.chatHistory.addToolResult(toolCallId, result, "done");
383- } catch (error: any) {
384- const errorMessage = `Bash command failed: ${error?.message || String(error)}`;
385- services.chatHistory.addToolResult(toolCallId, errorMessage, "error");
386- }
387- })();
388-
389- return null; // Processed, no further message handling needed
390- };
391-
392343 const handleSlashCommandProcessing = async (
393344 message: string,
394345 ): Promise<string | null> => {