Elffuss BraidHub

kikocis/continue public

fix: use Session type for cn serve / remote
Changesetd595b705ef5a08087d035cc412ef6a6869c2ada201dece71635282a5c81d93d8
AuthorNate <sestinj@gmail.com> · 2025-08-28 17:59 -07:00
CommitterNate <sestinj@gmail.com> · 2025-08-28 17:59 -07:00
Parents96e49bfda5ce

Browse the files at this changeset

10 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/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/commands/serve.ts +1 −2
@@ -3,7 +3,6 @@
33
44 import chalk from "chalk";
55 import type { ChatHistoryItem } from "core/index.js";
6-import { convertFromUnifiedHistory } from "core/util/messageConversion.js";
76 import express, { Request, Response } from "express";
87
98 import { getAssistantSlug } from "../auth/workos.js";
@@ -148,7 +147,7 @@
148147 app.get("/state", (_req: Request, res: Response) => {
149148 state.lastActivity = Date.now();
150149 res.json({
151- chatHistory: convertFromUnifiedHistory(state.session.history), // Convert back to legacy format for API
150+ session: state.session, // Return session directly instead of converting
152151 isProcessing: state.isProcessing,
153152 messageQueueLength: state.messageQueue.length,
154153 pendingPermission: state.pendingPermission,
modified extensions/cli/src/e2e/auth.test.ts +7 −7
@@ -30,7 +30,7 @@
3030 authPath,
3131 JSON.stringify({
3232 userId: "test-user",
33- userEmail: "test@example.com",
33+ userEmail: "test@example.com",
3434 accessToken: "test-token",
3535 refreshToken: "test-refresh-token",
3636 expiresAt: Date.now() + 3600000,
@@ -39,12 +39,12 @@
3939 );
4040
4141 // Run logout
42- const result = await runCLI(context, {
42+ const result = await runCLI(context, {
4343 args: ["logout"],
4444 env: {
4545 HOME: context.testDir,
46- CONTINUE_GLOBAL_DIR: path.join(context.testDir, ".continue")
47- }
46+ CONTINUE_GLOBAL_DIR: path.join(context.testDir, ".continue"),
47+ },
4848 });
4949
5050 expect(result.exitCode).toBe(0);
@@ -59,12 +59,12 @@
5959 });
6060
6161 it("should handle logout when not logged in", async () => {
62- const result = await runCLI(context, {
62+ const result = await runCLI(context, {
6363 args: ["logout"],
6464 env: {
6565 HOME: context.testDir,
66- CONTINUE_GLOBAL_DIR: path.join(context.testDir, ".continue")
67- }
66+ CONTINUE_GLOBAL_DIR: path.join(context.testDir, ".continue"),
67+ },
6868 });
6969
7070 expect(result.exitCode).toBe(0);
modified extensions/cli/src/e2e/resume-flag.test.ts +7 −7
@@ -46,16 +46,16 @@
4646
4747 // Verify that a session file was created
4848 const sessionDir = path.join(context.testDir, ".continue", "sessions");
49-
49+
5050 // Ensure session directory exists
5151 try {
5252 await fs.mkdir(sessionDir, { recursive: true });
5353 } catch (error) {
5454 // Directory already exists, continue
5555 }
56-
56+
5757 const sessionFiles = (await fs.readdir(sessionDir)).filter(
58- f => f.endsWith('.json') && f !== 'sessions.json'
58+ (f) => f.endsWith(".json") && f !== "sessions.json",
5959 );
6060 expect(sessionFiles).toHaveLength(1);
6161
@@ -150,16 +150,16 @@
150150
151151 // Verify the first session was saved correctly
152152 const sessionDir = path.join(context.testDir, ".continue", "sessions");
153-
153+
154154 // Ensure session directory exists
155155 try {
156156 await fs.mkdir(sessionDir, { recursive: true });
157157 } catch (error) {
158158 // Directory already exists, continue
159159 }
160-
160+
161161 let sessionFiles = (await fs.readdir(sessionDir)).filter(
162- f => f.endsWith('.json') && f !== 'sessions.json'
162+ (f) => f.endsWith(".json") && f !== "sessions.json",
163163 );
164164 expect(sessionFiles).toHaveLength(1);
165165
@@ -193,7 +193,7 @@
193193
194194 // Check that the session file contains both messages
195195 sessionFiles = (await fs.readdir(sessionDir)).filter(
196- f => f.endsWith('.json') && f !== 'sessions.json'
196+ (f) => f.endsWith(".json") && f !== "sessions.json",
197197 );
198198 sessionFile = sessionFiles[0];
199199 sessionPath = path.join(sessionDir, sessionFile);
modified extensions/cli/src/ui/__tests__/mockRemoteServer.ts +9 −1
@@ -29,9 +29,17 @@
2929 // GET /state - Return the current state
3030 this.app.get("/state", (req, res) => {
3131 res.json({
32- chatHistory: this.messages,
32+ session: {
33+ history: this.messages.map((msg) => ({
34+ message: msg,
35+ contextItems: [],
36+ })),
37+ id: "mock-session",
38+ workspaceDirectory: "/mock/workspace",
39+ },
3340 isProcessing: this.isProcessing,
3441 messageQueueLength: 0,
42+ pendingPermission: null,
3543 });
3644 });
3745
modified extensions/cli/src/ui/hooks/useChat.remote.helpers.ts +4 −5
@@ -1,5 +1,4 @@
11 import type { ChatHistoryItem } from "core/index.js";
2-import { convertToUnifiedHistory } from "core/util/messageConversion.js";
32
43 import { posthogService } from "../../telemetry/posthogService.js";
54 import { logger } from "../../util/logger.js";
@@ -98,11 +97,11 @@
9897 responseStartTime,
9998 setResponseStartTime,
10099 }: UpdateStateFromRemoteOptions): void {
101- // Update chat history from server
102- if (state.chatHistory) {
100+ // Update chat history from server - now using session.history directly
101+ if (state.session && state.session.history) {
103102 setChatHistory((prevHistory) => {
104- // Convert server's legacy format to unified format
105- const newHistory = convertToUnifiedHistory(state.chatHistory);
103+ // Use session history directly - no conversion needed
104+ const newHistory = state.session.history as ChatHistoryItem[];
106105
107106 // Quick length check first
108107 if (prevHistory.length !== newHistory.length) {
modified extensions/cli/src/ui/hooks/useChat.types.ts +15 −8
@@ -1,6 +1,5 @@
11 import { AssistantUnrolled, ModelConfig } from "@continuedev/config-yaml";
22 import { BaseLlmApi } from "@continuedev/openai-adapters";
3-import { ChatCompletionMessageParam } from "openai/resources.mjs";
43
54 import { ToolCallPreview } from "../../tools/types.js";
65
@@ -37,14 +36,22 @@
3736 }
3837
3938 export interface RemoteServerState {
40- messages: Array<{
41- role: string;
42- content?: string;
43- tool_calls?: any[];
44- }>;
45- chatHistory: ChatCompletionMessageParam[];
39+ session: {
40+ history: Array<{
41+ message: {
42+ role: string;
43+ content?: string;
44+ tool_calls?: any[];
45+ };
46+ contextItems: any[];
47+ toolCallStates?: any[];
48+ }>;
49+ id: string;
50+ workspaceDirectory: string;
51+ };
4652 isProcessing: boolean;
47- activePermissionRequest?: {
53+ messageQueueLength: number;
54+ pendingPermission?: {
4855 toolName: string;
4956 toolArgs: any;
5057 requestId: string;
modified extensions/cli/validate-aliases.mjs +2 −2
@@ -8,14 +8,14 @@
88 let logger;
99 try {
1010 // Try to import the compiled logger
11- const loggerModule = await import('./dist/util/logger.js');
11+ const loggerModule = await import("./dist/util/logger.js");
1212 logger = loggerModule.logger;
1313 } catch {
1414 // Fallback to console if logger not available (e.g., not built yet)
1515 logger = {
1616 info: console.log,
1717 warn: console.warn,
18- error: console.error
18+ error: console.error,
1919 };
2020 }
2121