Changesets · Branches · Tags · Compare
| Changeset | 7ffc422e1ed7d65381d19243048dfd793f3a7fd4498908de3b325dc886176508 |
|---|---|
| Author | Patrick Erichsen <patrick.a.erichsen@gmail.com> · 2025-06-26 17:52 -07:00 |
| Committer | Patrick Erichsen <patrick.a.erichsen@gmail.com> · 2025-06-26 17:52 -07:00 |
| Parents | 21cf25b4ed37, 6ae8fdd230bd |
71 files changed
added .continue/rules/new-protocol-message.md +35 −0
| @@ -0,0 +1,35 @@ | ||
| 1 | +--- | |
| 2 | +name: New protocol message | |
| 3 | +description: Create a new protocol message from core/gui/ide to core/gui/ide | |
| 4 | +--- | |
| 5 | + | |
| 6 | +Create a new protocol message by taking the following steps: | |
| 7 | + | |
| 8 | +## 1. Define the message type | |
| 9 | + | |
| 10 | +Add your new message type definition to the appropriate file in the `protocol/` directory with correct TypeScript typing. | |
| 11 | + | |
| 12 | +## 2. Check for duplicates | |
| 13 | + | |
| 14 | +Verify that no existing message type already provides the same functionality. | |
| 15 | + | |
| 16 | +## 3. Add to passThrough (if webview ↔ core) | |
| 17 | + | |
| 18 | +If your message is between webview and core, add it to `core/protocol/passThrough.ts`. | |
| 19 | + | |
| 20 | +## 4. Add to IntelliJ constants (if webview ↔ core) | |
| 21 | + | |
| 22 | +If your message is between webview and core, add it to `extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/constants/MessageTypes.kt`. | |
| 23 | + | |
| 24 | +## 5. Implement the message handler | |
| 25 | + | |
| 26 | +Implement the message in the appropriate location: | |
| 27 | + | |
| 28 | +- **Messages to core**: `core/core.ts` | |
| 29 | +- **Messages to GUI**: `useWebviewListener` hook | |
| 30 | +- **Messages to VS Code IDE**: `VsCodeMessenger.ts` | |
| 31 | +- **Messages to JetBrains IDE**: `IdeProtocolClient.kt` | |
| 32 | + | |
| 33 | +## 6. Test the implementation | |
| 34 | + | |
| 35 | +Verify that your message works correctly in both VS Code and JetBrains IDEs if applicable. |
added .continue/rules/overeager.md +5 −0
| @@ -0,0 +1,5 @@ | ||
| 1 | +--- | |
| 2 | +name: Don't be overeager | |
| 3 | +--- | |
| 4 | + | |
| 5 | +Avoid over-eagerly adding new features. You should solve the problem at hand and then can propose further work. |
modified .github/workflows/main.yaml +8 −0
| @@ -104,6 +104,14 @@ | ||
| 104 | 104 | path: gui/node_modules |
| 105 | 105 | key: ${{ runner.os }}-node-${{ hashFiles('gui/package-lock.json') }} |
| 106 | 106 | |
| 107 | + - name: Build packages (Windows) | |
| 108 | + run: ./scripts/build-packages.ps1 | |
| 109 | + if: matrix.os == 'windows-latest' | |
| 110 | + | |
| 111 | + - name: Build packages (Unix) | |
| 112 | + run: ./scripts/build-packages.sh | |
| 113 | + if: matrix.os != 'windows-latest' | |
| 114 | + | |
| 107 | 115 | - name: Install extension Dependencies |
| 108 | 116 | run: | |
| 109 | 117 | cd extensions/vscode |
modified .github/workflows/preview.yaml +8 −0
| @@ -99,6 +99,14 @@ | ||
| 99 | 99 | path: gui/node_modules |
| 100 | 100 | key: ${{ runner.os }}-node-${{ hashFiles('gui/package-lock.json') }} |
| 101 | 101 | |
| 102 | + - name: Build packages (Windows) | |
| 103 | + run: ./scripts/build-packages.ps1 | |
| 104 | + if: matrix.os == 'windows-latest' | |
| 105 | + | |
| 106 | + - name: Build packages (Unix) | |
| 107 | + run: ./scripts/build-packages.sh | |
| 108 | + if: matrix.os != 'windows-latest' | |
| 109 | + | |
| 102 | 110 | - name: Install extension Dependencies |
| 103 | 111 | run: | |
| 104 | 112 | cd extensions/vscode |
modified .github/workflows/release-config-yaml.yml +7 −35
| @@ -9,38 +9,10 @@ | ||
| 9 | 9 | |
| 10 | 10 | jobs: |
| 11 | 11 | release: |
| 12 | - name: Release | |
| 13 | - runs-on: ubuntu-latest | |
| 14 | - steps: | |
| 15 | - - name: Checkout | |
| 16 | - uses: actions/checkout@v4 | |
| 17 | - with: | |
| 18 | - fetch-depth: 0 | |
| 19 | - | |
| 20 | - - name: Use Node.js from .nvmrc | |
| 21 | - uses: actions/setup-node@v4 | |
| 22 | - with: | |
| 23 | - node-version-file: ".nvmrc" | |
| 24 | - | |
| 25 | - - name: Install dependencies | |
| 26 | - run: | | |
| 27 | - cd packages/config-yaml | |
| 28 | - npm ci | |
| 29 | - | |
| 30 | - - name: Build | |
| 31 | - run: | | |
| 32 | - cd packages/config-yaml | |
| 33 | - npm run build | |
| 34 | - | |
| 35 | - - name: Run tests | |
| 36 | - run: | | |
| 37 | - cd packages/config-yaml | |
| 38 | - npm test | |
| 39 | - | |
| 40 | - - name: Release | |
| 41 | - env: | |
| 42 | - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| 43 | - NPM_TOKEN: ${{ secrets.NPM_TOKEN }} | |
| 44 | - run: | | |
| 45 | - cd packages/config-yaml | |
| 46 | - npx semantic-release | |
| 12 | + uses: ./.github/workflows/reusable-release.yml | |
| 13 | + with: | |
| 14 | + package-name: "config-yaml" | |
| 15 | + package-path: "packages/config-yaml" | |
| 16 | + secrets: | |
| 17 | + SEMANTIC_RELEASE_GITHUB_TOKEN: ${{ secrets.SEMANTIC_RELEASE_GITHUB_TOKEN }} | |
| 18 | + SEMANTIC_RELEASE_NPM_TOKEN: ${{ secrets.SEMANTIC_RELEASE_NPM_TOKEN }} |
added .github/workflows/release-fetch.yml +18 −0
| @@ -0,0 +1,18 @@ | ||
| 1 | +name: Release @continuedev/fetch | |
| 2 | + | |
| 3 | +on: | |
| 4 | + push: | |
| 5 | + branches: | |
| 6 | + - main | |
| 7 | + paths: | |
| 8 | + - "packages/fetch/**" | |
| 9 | + | |
| 10 | +jobs: | |
| 11 | + release: | |
| 12 | + uses: ./.github/workflows/reusable-release.yml | |
| 13 | + with: | |
| 14 | + package-name: "fetch" | |
| 15 | + package-path: "packages/fetch" | |
| 16 | + secrets: | |
| 17 | + SEMANTIC_RELEASE_GITHUB_TOKEN: ${{ secrets.SEMANTIC_RELEASE_GITHUB_TOKEN }} | |
| 18 | + SEMANTIC_RELEASE_NPM_TOKEN: ${{ secrets.SEMANTIC_RELEASE_NPM_TOKEN }} |
added .github/workflows/release-llm-info.yml +18 −0
| @@ -0,0 +1,18 @@ | ||
| 1 | +name: Release @continuedev/llm-info | |
| 2 | + | |
| 3 | +on: | |
| 4 | + push: | |
| 5 | + branches: | |
| 6 | + - main | |
| 7 | + paths: | |
| 8 | + - "packages/llm-info/**" | |
| 9 | + | |
| 10 | +jobs: | |
| 11 | + release: | |
| 12 | + uses: ./.github/workflows/reusable-release.yml | |
| 13 | + with: | |
| 14 | + package-name: "llm-info" | |
| 15 | + package-path: "packages/llm-info" | |
| 16 | + secrets: | |
| 17 | + SEMANTIC_RELEASE_GITHUB_TOKEN: ${{ secrets.SEMANTIC_RELEASE_GITHUB_TOKEN }} | |
| 18 | + SEMANTIC_RELEASE_NPM_TOKEN: ${{ secrets.SEMANTIC_RELEASE_NPM_TOKEN }} |
added .github/workflows/release-openai-adapters.yml +18 −0
| @@ -0,0 +1,18 @@ | ||
| 1 | +name: Release @continuedev/openai-adapters | |
| 2 | + | |
| 3 | +on: | |
| 4 | + push: | |
| 5 | + branches: | |
| 6 | + - main | |
| 7 | + paths: | |
| 8 | + - "packages/openai-adapters/**" | |
| 9 | + | |
| 10 | +jobs: | |
| 11 | + release: | |
| 12 | + uses: ./.github/workflows/reusable-release.yml | |
| 13 | + with: | |
| 14 | + package-name: "openai-adapters" | |
| 15 | + package-path: "packages/openai-adapters" | |
| 16 | + secrets: | |
| 17 | + SEMANTIC_RELEASE_GITHUB_TOKEN: ${{ secrets.SEMANTIC_RELEASE_GITHUB_TOKEN }} | |
| 18 | + SEMANTIC_RELEASE_NPM_TOKEN: ${{ secrets.SEMANTIC_RELEASE_NPM_TOKEN }} |
added .github/workflows/reusable-release.yml +55 −0
| @@ -0,0 +1,55 @@ | ||
| 1 | +name: Reusable Release Workflow | |
| 2 | + | |
| 3 | +on: | |
| 4 | + workflow_call: | |
| 5 | + inputs: | |
| 6 | + package-name: | |
| 7 | + required: true | |
| 8 | + type: string | |
| 9 | + package-path: | |
| 10 | + required: true | |
| 11 | + type: string | |
| 12 | + secrets: | |
| 13 | + SEMANTIC_RELEASE_GITHUB_TOKEN: | |
| 14 | + required: true | |
| 15 | + SEMANTIC_RELEASE_NPM_TOKEN: | |
| 16 | + required: true | |
| 17 | + | |
| 18 | +permissions: | |
| 19 | + contents: write | |
| 20 | + issues: write | |
| 21 | + pull-requests: write | |
| 22 | + | |
| 23 | +jobs: | |
| 24 | + release: | |
| 25 | + name: Release ${{ inputs.package-name }} | |
| 26 | + runs-on: ubuntu-latest | |
| 27 | + defaults: | |
| 28 | + run: | |
| 29 | + working-directory: ${{ inputs.package-path }} | |
| 30 | + steps: | |
| 31 | + - name: Checkout | |
| 32 | + uses: actions/checkout@v4 | |
| 33 | + with: | |
| 34 | + fetch-depth: 0 | |
| 35 | + | |
| 36 | + - name: Use Node.js from .nvmrc | |
| 37 | + uses: actions/setup-node@v4 | |
| 38 | + with: | |
| 39 | + node-version-file: ".nvmrc" | |
| 40 | + | |
| 41 | + - name: Install dependencies | |
| 42 | + run: npm ci | |
| 43 | + | |
| 44 | + - name: Build | |
| 45 | + run: npm run build | |
| 46 | + | |
| 47 | + - name: Run tests | |
| 48 | + run: npm test | |
| 49 | + | |
| 50 | + - name: Release | |
| 51 | + env: | |
| 52 | + GITHUB_TOKEN: ${{ secrets.SEMANTIC_RELEASE_GITHUB_TOKEN }} | |
| 53 | + NPM_TOKEN: ${{ secrets.SEMANTIC_RELEASE_NPM_TOKEN }} | |
| 54 | + NODE_AUTH_TOKEN: ${{ secrets.SEMANTIC_RELEASE_NPM_TOKEN }} | |
| 55 | + run: npx semantic-release | |
| No newline at the end of the file |
modified binary/package-lock.json +2 −4
| @@ -53,9 +53,9 @@ | ||
| 53 | 53 | "@aws-sdk/credential-providers": "^3.778.0", |
| 54 | 54 | "@continuedev/config-types": "^1.0.13", |
| 55 | 55 | "@continuedev/config-yaml": "file:../packages/config-yaml", |
| 56 | - "@continuedev/fetch": "^1.0.13", | |
| 56 | + "@continuedev/fetch": "^1.0.14", | |
| 57 | 57 | "@continuedev/llm-info": "^1.0.8", |
| 58 | - "@continuedev/openai-adapters": "^1.0.32", | |
| 58 | + "@continuedev/openai-adapters": "file:../packages/openai-adapters", | |
| 59 | 59 | "@modelcontextprotocol/sdk": "^1.12.0", |
| 60 | 60 | "@mozilla/readability": "^0.5.0", |
| 61 | 61 | "@octokit/rest": "^20.1.1", |
| @@ -106,7 +106,6 @@ | ||
| 106 | 106 | "sqlite3": "^5.1.7", |
| 107 | 107 | "system-ca": "^1.0.3", |
| 108 | 108 | "tar": "^7.4.3", |
| 109 | - "tree-sitter-structured-text": "^0.0.1", | |
| 110 | 109 | "tree-sitter-wasms": "^0.1.11", |
| 111 | 110 | "uuid": "^9.0.1", |
| 112 | 111 | "vectordb": "^0.4.20", |
| @@ -145,7 +144,6 @@ | ||
| 145 | 144 | "myers-diff": "^2.1.0", |
| 146 | 145 | "onnxruntime-common": "1.14.0", |
| 147 | 146 | "onnxruntime-web": "1.14.0", |
| 148 | - "tree-sitter-cli": "^0.22.5", | |
| 149 | 147 | "ts-jest": "^29.1.1", |
| 150 | 148 | "typescript": "^5.6.3", |
| 151 | 149 | "vitest": "^3.1.4" |
modified core/config/yaml/loadYaml.ts +2 −2
| @@ -39,7 +39,7 @@ | ||
| 39 | 39 | import { modifyAnyConfigWithSharedConfig } from "../sharedConfig"; |
| 40 | 40 | |
| 41 | 41 | import { getControlPlaneEnvSync } from "../../control-plane/env"; |
| 42 | -import { baseToolDefinitions } from "../../tools"; | |
| 42 | +import { getToolsForIde } from "../../tools"; | |
| 43 | 43 | import { getCleanUriPath } from "../../util/uri"; |
| 44 | 44 | import { getAllDotContinueDefinitionFiles } from "../loadLocalAssistants"; |
| 45 | 45 | import { LocalPlatformClient } from "./LocalPlatformClient"; |
| @@ -187,7 +187,7 @@ | ||
| 187 | 187 | |
| 188 | 188 | const continueConfig: ContinueConfig = { |
| 189 | 189 | slashCommands: [], |
| 190 | - tools: [...baseToolDefinitions], | |
| 190 | + tools: await getToolsForIde(ide), | |
| 191 | 191 | mcpServerStatuses: [], |
| 192 | 192 | contextProviders: [], |
| 193 | 193 | modelsByRole: { |
modified core/index.d.ts +2 −0
| @@ -731,6 +731,8 @@ | ||
| 731 | 731 | |
| 732 | 732 | isTelemetryEnabled(): Promise<boolean>; |
| 733 | 733 | |
| 734 | + isWorkspaceRemote(): Promise<boolean>; | |
| 735 | + | |
| 734 | 736 | getUniqueId(): Promise<string>; |
| 735 | 737 | |
| 736 | 738 | getTerminalContents(): Promise<string>; |
modified core/indexing/CodebaseIndexer.test.ts +1 −9
| @@ -124,14 +124,6 @@ | ||
| 124 | 124 | return updates; |
| 125 | 125 | } |
| 126 | 126 | |
| 127 | - async function refreshIndexFiles(files: string[]) { | |
| 128 | - const updates = []; | |
| 129 | - for await (const update of codebaseIndexer.refreshFiles(files)) { | |
| 130 | - updates.push(update); | |
| 131 | - } | |
| 132 | - return updates; | |
| 133 | - } | |
| 134 | - | |
| 135 | 127 | async function getAllIndexedFiles() { |
| 136 | 128 | const files = await testIndex.getIndexedFilesForTags( |
| 137 | 129 | await testIde.getTags(testIndex.artifactId), |
| @@ -197,7 +189,7 @@ | ||
| 197 | 189 | test("should successfuly re-index specific files", async () => { |
| 198 | 190 | // Could add more specific tests for this but uses similar logic |
| 199 | 191 | const before = await getAllIndexedFiles(); |
| 200 | - await refreshIndexFiles(before); | |
| 192 | + await codebaseIndexer.refreshCodebaseIndexFiles(before); | |
| 201 | 193 | |
| 202 | 194 | const after = await getAllIndexedFiles(); |
| 203 | 195 | expect(after.length).toBe(before.length); |
modified core/indexing/CodebaseIndexer.ts +5 −9
| @@ -43,7 +43,7 @@ | ||
| 43 | 43 | * - To limit memory usage for indexes that perform computations locally, e.g. FTS |
| 44 | 44 | * - To make as few requests as possible to the embeddings providers |
| 45 | 45 | */ |
| 46 | - filesPerBatch = 500; | |
| 46 | + filesPerBatch = 200; | |
| 47 | 47 | private indexingCancellationController: AbortController | undefined; |
| 48 | 48 | private codebaseIndexingState: IndexingProgressUpdate; |
| 49 | 49 | private readonly pauseToken: PauseToken; |
| @@ -75,16 +75,10 @@ | ||
| 75 | 75 | this.pauseToken = new PauseToken(initialPaused); |
| 76 | 76 | } |
| 77 | 77 | |
| 78 | - /** | |
| 79 | - * Set the paused state of the indexer | |
| 80 | - */ | |
| 81 | 78 | set paused(value: boolean) { |
| 82 | 79 | this.pauseToken.paused = value; |
| 83 | 80 | } |
| 84 | 81 | |
| 85 | - /** | |
| 86 | - * Get the current paused state of the indexer | |
| 87 | - */ | |
| 88 | 82 | get paused(): boolean { |
| 89 | 83 | return this.pauseToken.paused; |
| 90 | 84 | } |
| @@ -235,7 +229,9 @@ | ||
| 235 | 229 | } |
| 236 | 230 | } |
| 237 | 231 | |
| 238 | - async *refreshFiles(files: string[]): AsyncGenerator<IndexingProgressUpdate> { | |
| 232 | + private async *refreshFiles( | |
| 233 | + files: string[], | |
| 234 | + ): AsyncGenerator<IndexingProgressUpdate> { | |
| 239 | 235 | let progress = 0; |
| 240 | 236 | if (files.length === 0) { |
| 241 | 237 | yield { |
| @@ -525,7 +521,7 @@ | ||
| 525 | 521 | repoName, |
| 526 | 522 | )) { |
| 527 | 523 | yield { |
| 528 | - progress: progress, | |
| 524 | + progress, | |
| 529 | 525 | desc, |
| 530 | 526 | status: "indexing", |
| 531 | 527 | }; |
modified core/llm/llms/Bedrock.ts +1 −1
| @@ -546,7 +546,7 @@ | ||
| 546 | 546 | } |
| 547 | 547 | |
| 548 | 548 | // EMBED // |
| 549 | - async embed(chunks: string[]): Promise<number[][]> { | |
| 549 | + async _embed(chunks: string[]): Promise<number[][]> { | |
| 550 | 550 | const credentials = await this._getCredentials(); |
| 551 | 551 | const client = new BedrockRuntimeClient({ |
| 552 | 552 | region: this.region, |
modified core/llm/llms/HuggingFaceTEI.ts +1 −10
| @@ -25,16 +25,7 @@ | ||
| 25 | 25 | }); |
| 26 | 26 | } |
| 27 | 27 | |
| 28 | - async embed(chunks: string[]) { | |
| 29 | - const batchedChunks = this.getBatchedChunks(chunks); | |
| 30 | - | |
| 31 | - const results = await Promise.all( | |
| 32 | - batchedChunks.map((batch) => this.doEmbedRequest(batch)), | |
| 33 | - ); | |
| 34 | - return results.flat(); | |
| 35 | - } | |
| 36 | - | |
| 37 | - async doEmbedRequest(batch: string[]): Promise<number[][]> { | |
| 28 | + async _embed(batch: string[]): Promise<number[][]> { | |
| 38 | 29 | const headers: Record<string, string> = { |
| 39 | 30 | "Content-Type": "application/json", |
| 40 | 31 | }; |
modified core/llm/llms/SageMaker.ts +1 −1
| @@ -141,7 +141,7 @@ | ||
| 141 | 141 | } |
| 142 | 142 | } |
| 143 | 143 | |
| 144 | - async embed(chunks: string[]) { | |
| 144 | + async _embed(chunks: string[]) { | |
| 145 | 145 | const credentials = await this._getCredentials(); |
| 146 | 146 | const client = new SageMakerRuntimeClient({ |
| 147 | 147 | region: this.region, |
modified core/package-lock.json +0 −0
Not shown: the file is larger than the hub shows, or this page holds as much as it shows. View the file.
modified core/protocol/ide.ts +1 −0
| @@ -60,6 +60,7 @@ | ||
| 60 | 60 | ]; |
| 61 | 61 | getAvailableThreads: [undefined, Thread[]]; |
| 62 | 62 | isTelemetryEnabled: [undefined, boolean]; |
| 63 | + isWorkspaceRemote: [undefined, boolean]; | |
| 63 | 64 | getUniqueId: [undefined, string]; |
| 64 | 65 | getTags: [string, IndexTag[]]; |
| 65 | 66 | readSecrets: [{ keys: string[] }, Record<string, string>]; |
modified core/protocol/messenger/messageIde.ts +4 −0
| @@ -106,6 +106,10 @@ | ||
| 106 | 106 | return this.request("isTelemetryEnabled", undefined); |
| 107 | 107 | } |
| 108 | 108 | |
| 109 | + isWorkspaceRemote(): Promise<boolean> { | |
| 110 | + return this.request("isWorkspaceRemote", undefined); | |
| 111 | + } | |
| 112 | + | |
| 109 | 113 | getUniqueId(): Promise<string> { |
| 110 | 114 | return this.request("getUniqueId", undefined); |
| 111 | 115 | } |
added core/rules.md +10 −0
| @@ -0,0 +1,10 @@ | ||
| 1 | +# `core` rules | |
| 2 | + | |
| 3 | +Whenever a new protocol message is added to the `protocol/` directory, check the following: | |
| 4 | + | |
| 5 | +- It's type is defined correctly | |
| 6 | +- If it is a message from webview to core or vice versa: | |
| 7 | + - It has been added to `core/protocol/passThrough.ts` | |
| 8 | + - It has been added to `extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/constants/MessageTypes.kt` | |
| 9 | +- It is implemented in either `core/core.ts` (for messages to the core), in a `useWebviewListener` (for messages to the gui), or in `VsCodeMessenger.ts` for VS Code or `IdeProtocolClient.kt` for JetBriains (for messages to the IDE). | |
| 10 | +- It does not duplicate functionality from another message type that already exists. |
modified core/tools/index.ts +9 −2
| @@ -1,4 +1,4 @@ | ||
| 1 | -import { ConfigDependentToolParams, Tool } from ".."; | |
| 1 | +import { ConfigDependentToolParams, IDE, Tool } from ".."; | |
| 2 | 2 | import { createNewFileTool } from "./definitions/createNewFile"; |
| 3 | 3 | import { createRuleBlock } from "./definitions/createRuleBlock"; |
| 4 | 4 | import { editFileTool } from "./definitions/editFile"; |
| @@ -16,11 +16,13 @@ | ||
| 16 | 16 | import { viewRepoMapTool } from "./definitions/viewRepoMap"; |
| 17 | 17 | import { viewSubdirectoryTool } from "./definitions/viewSubdirectory"; |
| 18 | 18 | |
| 19 | +// missing support for remote os calls: https://github.com/microsoft/vscode/issues/252269 | |
| 20 | +export const localOnlyToolDefinitions = [grepSearchTool]; | |
| 21 | + | |
| 19 | 22 | export const baseToolDefinitions = [ |
| 20 | 23 | readFileTool, |
| 21 | 24 | createNewFileTool, |
| 22 | 25 | runTerminalCommandTool, |
| 23 | - grepSearchTool, | |
| 24 | 26 | globSearchTool, |
| 25 | 27 | searchWebTool, |
| 26 | 28 | viewDiffTool, |
| @@ -38,3 +40,8 @@ | ||
| 38 | 40 | ? [searchAndReplaceInFileTool, viewRepoMapTool, viewSubdirectoryTool] |
| 39 | 41 | : [editFileTool]), |
| 40 | 42 | ]; |
| 43 | + | |
| 44 | +export const getToolsForIde = async (ide: IDE) => | |
| 45 | + (await ide.isWorkspaceRemote()) | |
| 46 | + ? baseToolDefinitions | |
| 47 | + : [...baseToolDefinitions, ...localOnlyToolDefinitions]; |
modified core/util/filesystem.ts +4 −0
| @@ -48,6 +48,10 @@ | ||
| 48 | 48 | return; |
| 49 | 49 | } |
| 50 | 50 | |
| 51 | + isWorkspaceRemote(): Promise<boolean> { | |
| 52 | + return Promise.resolve(false); | |
| 53 | + } | |
| 54 | + | |
| 51 | 55 | async getIdeSettings(): Promise<IdeSettings> { |
| 52 | 56 | return { |
| 53 | 57 | remoteConfigServerUrl: undefined, |
modified docs/docs/customize/deep-dives/prompts.md +33 −72
| @@ -5,93 +5,54 @@ | ||
| 5 | 5 | Prompts are reusable instructions that can be referenced at any time during chat. They are especially useful as context for repetitive and/or complex tasks. |
| 6 | 6 | |
| 7 | 7 | :::info |
| 8 | -Visit the Hub to [explore prompts](https://hub.continue.dev/explore/prompts) or [create your own](https://hub.continue.dev/new?type=block&blockType=prompts) | |
| 8 | +Prompts were previously defined in a `.prompt` file format, but for consistency we now recommend using the same Markdown format as [rules](./rules.mdx) and adding `alwaysApply: false` to the frontmatter so that they are manually triggered. | |
| 9 | 9 | ::: |
| 10 | 10 | |
| 11 | -## Examples | |
| 12 | - | |
| 13 | -Below are some examples to get you started. | |
| 14 | - | |
| 15 | -### Security review | |
| 16 | - | |
| 17 | -```text title="Security best practices review" | |
| 18 | -@open - Review these files for the following security best practices: | |
| 19 | -- Does the architecture follow security-by-design principles? | |
| 20 | -- Are there potential security vulnerabilities in the system design? | |
| 21 | -- Is sensitive data handled appropriately throughout the lifecycle? | |
| 22 | -``` | |
| 23 | - | |
| 24 | -### Reference best practice guides | |
| 25 | - | |
| 26 | -```text title="Redux best practices review" | |
| 27 | -@https://redux.js.org/style-guide/ | |
| 28 | -@currentFile | |
| 11 | +### Quick Start | |
| 29 | 12 | |
| 30 | -Review this code for adherence to Redux best practices. | |
| 31 | -``` | |
| 13 | +Below is a quick example of setting up a prompt file: | |
| 32 | 14 | |
| 33 | -### Pull in commonly used files for tasks | |
| 15 | +1. Create a folder called `.continue/rules` at the top level of your workspace | |
| 16 | +2. Add a file called `review-prompt.md` to this folder. | |
| 17 | +3. Write the following contents to `review-prompt.md` and save. | |
| 34 | 18 | |
| 35 | -```text title="Generate a new TypeORM entity" | |
| 36 | -@src/db/dataSource.ts @src/db/entity/SampleEntity.ts | |
| 19 | +```md title="review-prompt.md" | |
| 20 | +--- | |
| 21 | +name: Redux best practices review | |
| 22 | +alwaysApply: false | |
| 23 | +--- | |
| 37 | 24 | |
| 38 | -Use these files to generate a new TypeORM entity based on the following requirements: | |
| 25 | +Review the currently open file for adherence to Redux best practices, as explained in their style guide at https://redux.js.org/style-guide/. | |
| 39 | 26 | ``` |
| 40 | 27 | |
| 41 | -## Including Context Providers in your prompts | |
| 42 | - | |
| 43 | -Many [context providers](../context-providers.mdx) can be referenced by typing "@" followed by the name of the context provider. The currently supported list is: | |
| 44 | - | |
| 45 | -- `@terminal` - The contents of the terminal | |
| 46 | -- `@currentFile` - The currently active file | |
| 47 | -- `@open` - All open files | |
| 48 | -- `@os` - Information about the operating system | |
| 49 | -- `@problems` - Problems reported by the language server in the active file | |
| 50 | -- `@repo-map` - A map of files in the repository | |
| 51 | -- `@tree` - A tree view of the repository structure | |
| 52 | - | |
| 53 | -Or you can directly type URLs and file paths: | |
| 54 | - | |
| 55 | -- `@https://github.com/continuedev/continue` - The contents of a URL | |
| 56 | -- `@src/index.ts` - The contents of a file (VS Code only) | |
| 28 | +Now to use this prompt, you can open Chat, type <kbd>/</kbd>, select the prompt, and type out any additional instructions you'd like to add. | |
| 57 | 29 | |
| 58 | -All references will be attached as context items, rather than injected directly inline. | |
| 30 | +## Further Examples | |
| 59 | 31 | |
| 60 | -## Local `.prompt` files | |
| 32 | +Below are more examples to get you started. You can also visit the Hub to [explore prompts](https://hub.continue.dev/explore/prompts) or [create your own](https://hub.continue.dev/new?type=block&blockType=prompts). | |
| 61 | 33 | |
| 62 | -In addition to Prompt blocks on the Hub, you can also define prompts in local `.prompt` files, located in the `.continue/prompts` folder at the top level of your workspace. This is useful for quick iteration on prompts to test them out before pushing up to the Hub. | |
| 63 | - | |
| 64 | -### Quick Start | |
| 65 | - | |
| 66 | -Below is a quick example of setting up a prompt file: | |
| 67 | - | |
| 68 | -1. Create a folder called `.continue/prompts` at the top level of your workspace | |
| 69 | -2. Add a file called `test.prompt` to this folder. | |
| 70 | -3. Write the following contents to `test.prompt` and save. | |
| 34 | +### Security review | |
| 71 | 35 | |
| 72 | -```.prompt | |
| 73 | -name: Current file prompt | |
| 74 | -description: A test prompt using the current file context provider | |
| 36 | +```md title="security-review.md" | |
| 37 | +--- | |
| 38 | +name: Security best practices review | |
| 39 | +alwaysApply: false | |
| 75 | 40 | --- |
| 76 | -@currentFile | |
| 77 | -``` | |
| 78 | - | |
| 79 | -Now to use this prompt, you can open Chat, type <kbd>/</kbd>, select the prompt, and add type out some additional text such as "Review the code for any issues". | |
| 80 | - | |
| 81 | -### Format | |
| 82 | - | |
| 83 | -The format is inspired by [HumanLoops's .prompt file](https://docs.humanloop.com/docs/prompt-file-format), with additional templating to reference files, URLs, and context providers. | |
| 84 | 41 | |
| 85 | -:::info | |
| 86 | -The current state of this format is experimental and subject to change | |
| 87 | -::: | |
| 42 | +Review the changes in the current git diff for these security best practices: | |
| 88 | 43 | |
| 89 | -### Preamble | |
| 44 | +- Does the architecture follow security-by-design principles? | |
| 45 | +- Are there potential security vulnerabilities in the system design? | |
| 46 | +- Is sensitive data handled appropriately throughout the lifecycle? | |
| 47 | +``` | |
| 90 | 48 | |
| 91 | -The "preamble" is everything above the `---` separator, and lets you specify model parameters. It uses YAML syntax and currently supports the following parameters: | |
| 49 | +### Pull in commonly used files for tasks | |
| 92 | 50 | |
| 93 | -- `name` - The display title | |
| 94 | -- `description` - The description you will see in the dropdown | |
| 95 | -- `version` - Can be either "1" (for legacy prompt files) or "2" (this is the default and does not need to be set) | |
| 51 | +```md title="typeorm-entity-generator.md" | |
| 52 | +--- | |
| 53 | +name: Generate a new TypeORM entity | |
| 54 | +alwaysApply: false | |
| 55 | +--- | |
| 96 | 56 | |
| 97 | -If you don't need any of these parameters, you can leave out the preamble and do not need to include the `---` separator. | |
| 57 | +Referencing `src/db/dataSource.ts` and `src/db/entity/SampleEntity.ts`, generate a new TypeORM entity based on the following requirements: | |
| 58 | +``` |
modified docs/docs/customize/deep-dives/rules.mdx +18 −8
| @@ -55,19 +55,26 @@ | ||
| 55 | 55 | |
| 56 | 56 | Rules can also be added to an Assistant on the Continue Hub. |
| 57 | 57 | |
| 58 | -Explore available rules [here](https://hub.continue.dev/explore/rules), or [create your own](https://hub.continue.dev/new?type=block&blockType=rules) in the Hub. These blocks are defined using the [`config.yaml` syntax](../../reference.md#rules) and can also be created locally. | |
| 58 | +Explore available rules [here](https://hub.continue.dev), or [create your own](https://hub.continue.dev/new?type=block&blockType=rules) in the Hub. | |
| 59 | 59 | |
| 60 | 60 | ### Syntax |
| 61 | 61 | |
| 62 | +:::info | |
| 63 | + | |
| 64 | +Rules were originally defined in YAML format (demonstrated below), but we introduced Markdown for easier editing. While both are still supported, we recommend Markdown. | |
| 65 | + | |
| 66 | +::: | |
| 67 | + | |
| 62 | 68 | Rules blocks can be simple text, written in YAML configuration files, or as Markdown (`.md`) files. They can have the following properties: |
| 63 | 69 | |
| 64 | 70 | - `name` (**required** for YAML): A display name/title for the rule |
| 65 | 71 | - `globs` (optional): When files are provided as context that match this glob pattern, the rule will be included. This can be either a single pattern (e.g., `"**/*.{ts,tsx}"`) or an array of patterns (e.g., `["src/**/*.ts", "tests/**/*.ts"]`). |
| 66 | 72 | - `regex` (optional): When files are provided as context and their content matches this regex pattern, the rule will be included. This can be either a single pattern (e.g., `"^import .* from '.*';$"`) or an array of patterns (e.g., `["^import .* from '.*';$", "^export .* from '.*';$"]`). |
| 67 | 73 | - `description` (optional): A description for the rule. Agents may read this description when `alwaysApply` is false to determine whether the rule should be pulled into context. |
| 68 | -- `alwaysApply`: true - Always include the rule, regardless of file context | |
| 69 | -- `alwaysApply`: false - Included if globs exist AND match file context, or the agent decides to pull the rule into context based on it's description | |
| 70 | -- `alwaysApply`: undefined - Default behavior: include if no globs exist OR globs exist and match | |
| 74 | +- `alwaysApply`: Determines whether the rule is always included. Behavior is described below: | |
| 75 | + - `true`: Always included, regardless of file context | |
| 76 | + - `false`: Included if globs exist AND match file context, or the agent decides to pull the rule into context based on it's description | |
| 77 | + - `undefined` (default behavior): Included if no globs exist OR globs exist and match | |
| 71 | 78 | |
| 72 | 79 | <Tabs groupId="rules-example"> |
| 73 | 80 | <TabItem value="md" label="Markdown"> |
| @@ -97,10 +104,13 @@ | ||
| 97 | 104 | |
| 98 | 105 | ```yaml title="doc-standards.yaml" |
| 99 | 106 | name: Documentation Standards |
| 100 | - globs: docs/**/*.{md,mdx} | |
| 101 | - alwaysApply: false | |
| 107 | + version: 1.0.0 | |
| 108 | + schema: v1 | |
| 109 | + | |
| 102 | 110 | rules: |
| 103 | 111 | - name: Documentation Standards |
| 112 | + globs: docs/**/*.{md,mdx} | |
| 113 | + alwaysApply: false | |
| 104 | 114 | rule: > |
| 105 | 115 | - Follow Docusaurus documentation standards |
| 106 | 116 | - Include YAML frontmatter with title, description, and keywords |
| @@ -164,7 +174,7 @@ | ||
| 164 | 174 | |
| 165 | 175 | Continue includes a simple default system message for [Chat](../../chat/how-to-use-it.md) and [Agent](../../agent/how-to-use-it.md) requests, to help the model provide reliable codeblock formats in its output. |
| 166 | 176 | |
| 167 | -This can be viewed in the rules section of the toolbar (see above), or visit the source code [here](https://github.com/continuedev/continue/blob/main/core/llm/constructMessages.ts#L4) | |
| 177 | +This can be viewed in the rules section of the toolbar (see above), or in the source code [here](https://github.com/continuedev/continue/blob/main/core/llm/constructMessages.ts#L4). | |
| 168 | 178 | |
| 169 | 179 | Advanced users can override this system message for a specific model if needed by using `chatOptions.baseSystemMessage`. See the [`config.yaml` reference](../../reference.md#models). |
| 170 | 180 | |
| @@ -172,7 +182,7 @@ | ||
| 172 | 182 | |
| 173 | 183 | :::warning |
| 174 | 184 | |
| 175 | -`.contninuerules` will be deprecated in a future release. Please use the `.continue/rules` folder instead. | |
| 185 | +`.continuerules` will be deprecated in a future release. Please use the `.continue/rules` folder instead. | |
| 176 | 186 | |
| 177 | 187 | ::: |
| 178 | 188 |
modified extensions/intellij/gradle.properties +1 −1
| @@ -3,7 +3,7 @@ | ||
| 3 | 3 | pluginName=continue-intellij-extension |
| 4 | 4 | pluginRepositoryUrl=https://github.com/continuedev/continue |
| 5 | 5 | # SemVer format -> https://semver.org |
| 6 | -pluginVersion=1.0.25 | |
| 6 | +pluginVersion=1.0.26 | |
| 7 | 7 | # Supported build number ranges and IntelliJ Platform versions -> https://plugins.jetbrains.com/docs/intellij/build-number-ranges.html |
| 8 | 8 | pluginSinceBuild=223 |
| 9 | 9 | # IntelliJ Platform Properties -> https://plugins.jetbrains.com/docs/intellij/tools-gradle-intellij-plugin.html#configuration-intellij-extension |
modified extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/auth/ContinueAuthService.kt +2 −2
| @@ -2,9 +2,9 @@ | ||
| 2 | 2 | |
| 3 | 3 | import com.github.continuedev.continueintellijextension.services.ContinueExtensionSettings |
| 4 | 4 | import com.github.continuedev.continueintellijextension.services.ContinuePluginService |
| 5 | -import com.github.continuedev.continueintellijextension.utils.Desktop | |
| 6 | 5 | import com.google.gson.Gson |
| 7 | 6 | import com.intellij.credentialStore.Credentials |
| 7 | +import com.intellij.ide.BrowserUtil | |
| 8 | 8 | import com.intellij.ide.passwordSafe.PasswordSafe |
| 9 | 9 | import com.intellij.ide.util.PropertiesComponent |
| 10 | 10 | import com.intellij.openapi.application.ApplicationManager |
| @@ -165,7 +165,7 @@ | ||
| 165 | 165 | |
| 166 | 166 | // Still open the URL in the browser (keeping existing behavior) |
| 167 | 167 | if (authUrl != null) { |
| 168 | - Desktop.browse(java.net.URI(authUrl)) | |
| 168 | + BrowserUtil.open(authUrl!!) | |
| 169 | 169 | } |
| 170 | 170 | |
| 171 | 171 | return authUrl |
modified extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/continue/IntelliJIde.kt +6 −1
| @@ -10,6 +10,7 @@ | ||
| 10 | 10 | import com.intellij.codeInsight.daemon.impl.HighlightInfo |
| 11 | 11 | import com.intellij.execution.configurations.GeneralCommandLine |
| 12 | 12 | import com.intellij.execution.util.ExecUtil |
| 13 | +import com.intellij.ide.BrowserUtil | |
| 13 | 14 | import com.intellij.ide.plugins.PluginManager |
| 14 | 15 | import com.intellij.ide.plugins.PluginManagerCore |
| 15 | 16 | import com.intellij.lang.annotation.HighlightSeverity |
| @@ -125,6 +126,10 @@ | ||
| 125 | 126 | return true |
| 126 | 127 | } |
| 127 | 128 | |
| 129 | + override suspend fun isWorkspaceRemote(): Boolean { | |
| 130 | + return this.getIdeInfo().remoteName != "local" | |
| 131 | + } | |
| 132 | + | |
| 128 | 133 | override suspend fun getUniqueId(): String { |
| 129 | 134 | return getMachineUniqueID() |
| 130 | 135 | } |
| @@ -211,7 +216,7 @@ | ||
| 211 | 216 | |
| 212 | 217 | override suspend fun openUrl(url: String) { |
| 213 | 218 | withContext(Dispatchers.IO) { |
| 214 | - Desktop.browse(URI(url)) | |
| 219 | + BrowserUtil.browse(url) | |
| 215 | 220 | } |
| 216 | 221 | } |
| 217 | 222 |
modified extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/types.kt +2 −0
| @@ -102,6 +102,8 @@ | ||
| 102 | 102 | |
| 103 | 103 | suspend fun isTelemetryEnabled(): Boolean |
| 104 | 104 | |
| 105 | + suspend fun isWorkspaceRemote(): Boolean | |
| 106 | + | |
| 105 | 107 | suspend fun getUniqueId(): String |
| 106 | 108 | |
| 107 | 109 | suspend fun getTerminalContents(): String |
deleted extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/utils/Desktop.kt +0 −214
| @@ -1,214 +0,0 @@ | ||
| 1 | -/* | |
| 2 | - * Copyright © 2017 jjYBdx4IL (https://github.com/jjYBdx4IL) | |
| 3 | - * | |
| 4 | - * Licensed under the Apache License, Version 2.0 (the "License"); | |
| 5 | - * you may not use this file except in compliance with the License. | |
| 6 | - * You may obtain a copy of the License at | |
| 7 | - * | |
| 8 | - * http://www.apache.org/licenses/LICENSE-2.0 | |
| 9 | - * | |
| 10 | - * Unless required by applicable law or agreed to in writing, software | |
| 11 | - * distributed under the License is distributed on an "AS IS" BASIS, | |
| 12 | - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
| 13 | - * See the License for the specific language governing permissions and | |
| 14 | - * limitations under the License. | |
| 15 | - */ | |
| 16 | -package com.github.continuedev.continueintellijextension.utils | |
| 17 | - | |
| 18 | -import org.apache.commons.lang3.SystemUtils | |
| 19 | -import org.slf4j.LoggerFactory | |
| 20 | -import java.io.File | |
| 21 | -import java.io.IOException | |
| 22 | -import java.net.URI | |
| 23 | - | |
| 24 | -object Desktop { | |
| 25 | - private val LOG = LoggerFactory.getLogger(Desktop::class.java) | |
| 26 | - | |
| 27 | - fun browse(uri: URI): Boolean { | |
| 28 | - if (browseDESKTOP(uri)) { | |
| 29 | - return true | |
| 30 | - } | |
| 31 | - | |
| 32 | - if (openSystemSpecific(uri.toString())) { | |
| 33 | - return true | |
| 34 | - } | |
| 35 | - | |
| 36 | - LOG.warn("failed to browse {}", uri) | |
| 37 | - return false | |
| 38 | - } | |
| 39 | - | |
| 40 | - fun open(file: File): Boolean { | |
| 41 | - if (openDESKTOP(file)) { | |
| 42 | - return true | |
| 43 | - } | |
| 44 | - | |
| 45 | - if (openSystemSpecific(file.path)) { | |
| 46 | - return true | |
| 47 | - } | |
| 48 | - | |
| 49 | - LOG.warn("failed to open {}", file.absolutePath) | |
| 50 | - return false | |
| 51 | - } | |
| 52 | - | |
| 53 | - fun edit(file: File): Boolean { | |
| 54 | - if (editDESKTOP(file)) { | |
| 55 | - return true | |
| 56 | - } | |
| 57 | - | |
| 58 | - if (openSystemSpecific(file.path)) { | |
| 59 | - return true | |
| 60 | - } | |
| 61 | - | |
| 62 | - LOG.warn("failed to edit {}", file.absolutePath) | |
| 63 | - return false | |
| 64 | - } | |
| 65 | - | |
| 66 | - private fun openSystemSpecific(what: String): Boolean { | |
| 67 | - if (SystemUtils.IS_OS_LINUX) { | |
| 68 | - if (isXDG() && runCommand("xdg-open", "%s", what)) { | |
| 69 | - return true | |
| 70 | - } | |
| 71 | - if (isKDE() && runCommand("kde-open", "%s", what)) { | |
| 72 | - return true | |
| 73 | - } | |
| 74 | - if (isGNOME() && runCommand("gnome-open", "%s", what)) { | |
| 75 | - return true | |
| 76 | - } | |
| 77 | - if (runCommand("kde-open", "%s", what)) { | |
| 78 | - return true | |
| 79 | - } | |
| 80 | - if (runCommand("gnome-open", "%s", what)) { | |
| 81 | - return true | |
| 82 | - } | |
| 83 | - } | |
| 84 | - | |
| 85 | - if (SystemUtils.IS_OS_MAC && runCommand("open", "%s", what)) { | |
| 86 | - return true | |
| 87 | - } | |
| 88 | - | |
| 89 | - if (SystemUtils.IS_OS_WINDOWS && runCommand("explorer", "%s", what)) { | |
| 90 | - return true | |
| 91 | - } | |
| 92 | - | |
| 93 | - return false | |
| 94 | - } | |
| 95 | - | |
| 96 | - private fun browseDESKTOP(uri: URI): Boolean { | |
| 97 | - return try { | |
| 98 | - if (!java.awt.Desktop.isDesktopSupported()) { | |
| 99 | - LOG.debug("Platform is not supported.") | |
| 100 | - return false | |
| 101 | - } | |
| 102 | - | |
| 103 | - if (!java.awt.Desktop.getDesktop().isSupported(java.awt.Desktop.Action.BROWSE)) { | |
| 104 | - LOG.debug("BROWSE is not supported.") | |
| 105 | - return false | |
| 106 | - } | |
| 107 | - | |
| 108 | - LOG.info("Trying to use Desktop.getDesktop().browse() with {}", uri.toString()) | |
| 109 | - java.awt.Desktop.getDesktop().browse(uri) | |
| 110 | - true | |
| 111 | - } catch (t: Throwable) { | |
| 112 | - LOG.error("Error using desktop browse.", t) | |
| 113 | - false | |
| 114 | - } | |
| 115 | - } | |
| 116 | - | |
| 117 | - private fun openDESKTOP(file: File): Boolean { | |
| 118 | - return try { | |
| 119 | - if (!java.awt.Desktop.isDesktopSupported()) { | |
| 120 | - LOG.debug("Platform is not supported.") | |
| 121 | - return false | |
| 122 | - } | |
| 123 | - | |
| 124 | - if (!java.awt.Desktop.getDesktop().isSupported(java.awt.Desktop.Action.OPEN)) { | |
| 125 | - LOG.debug("OPEN is not supported.") | |
| 126 | - return false | |
| 127 | - } | |
| 128 | - | |
| 129 | - LOG.info("Trying to use Desktop.getDesktop().open() with {}", file.toString()) | |
| 130 | - java.awt.Desktop.getDesktop().open(file) | |
| 131 | - true | |
| 132 | - } catch (t: Throwable) { | |
| 133 | - LOG.error("Error using desktop open.", t) | |
| 134 | - false | |
| 135 | - } | |
| 136 | - } | |
| 137 | - | |
| 138 | - private fun editDESKTOP(file: File): Boolean { | |
| 139 | - return try { | |
| 140 | - if (!java.awt.Desktop.isDesktopSupported()) { | |
| 141 | - LOG.debug("Platform is not supported.") | |
| 142 | - return false | |
| 143 | - } | |
| 144 | - | |
| 145 | - if (!java.awt.Desktop.getDesktop().isSupported(java.awt.Desktop.Action.EDIT)) { | |
| 146 | - LOG.debug("EDIT is not supported.") | |
| 147 | - return false | |
| 148 | - } | |
| 149 | - | |
| 150 | - LOG.info("Trying to use Desktop.getDesktop().edit() with {}", file) | |
| 151 | - java.awt.Desktop.getDesktop().edit(file) | |
| 152 | - true | |
| 153 | - } catch (t: Throwable) { | |
| 154 | - LOG.error("Error using desktop edit.", t) | |
| 155 | - false | |
| 156 | - } | |
| 157 | - } | |
| 158 | - | |
| 159 | - private fun runCommand(command: String, args: String, file: String): Boolean { | |
| 160 | - LOG.info("Trying to exec:\n cmd = {}\n args = {}\n %s = {}", command, args, file) | |
| 161 | - | |
| 162 | - val parts = prepareCommand(command, args, file) | |
| 163 | - | |
| 164 | - return try { | |
| 165 | - val p = Runtime.getRuntime().exec(parts) | |
| 166 | - if (p == null) { | |
| 167 | - false | |
| 168 | - } else { | |
| 169 | - try { | |
| 170 | - val retval = p.exitValue() | |
| 171 | - if (retval == 0) { | |
| 172 | - LOG.error("Process ended immediately.") | |
| 173 | - false | |
| 174 | - } else { | |
| 175 | - LOG.error("Process crashed.") | |
| 176 | - false | |
| 177 | - } | |
| 178 | - } catch (itse: IllegalThreadStateException) { | |
| 179 | - LOG.error("Process is running.") | |
| 180 | - true | |
| 181 | - } | |
| 182 | - } | |
| 183 | - } catch (e: IOException) { | |
| 184 | - LOG.error("Error running command.", e) | |
| 185 | - false | |
| 186 | - } | |
| 187 | - } | |
| 188 | - | |
| 189 | - private fun prepareCommand(command: String, args: String?, file: String): Array<String> { | |
| 190 | - val parts = mutableListOf<String>() | |
| 191 | - parts.add(command) | |
| 192 | - | |
| 193 | - args?.split(" ")?.forEach { s -> | |
| 194 | - parts.add(String.format(s, file).trim()) | |
| 195 | - } | |
| 196 | - | |
| 197 | - return parts.toTypedArray() | |
| 198 | - } | |
| 199 | - | |
| 200 | - private fun isXDG(): Boolean { | |
| 201 | - val xdgSessionId = System.getenv("XDG_SESSION_ID") | |
| 202 | - return !xdgSessionId.isNullOrEmpty() | |
| 203 | - } | |
| 204 | - | |
| 205 | - private fun isGNOME(): Boolean { | |
| 206 | - val gdmSession = System.getenv("GDMSESSION") | |
| 207 | - return gdmSession?.lowercase()?.contains("gnome") == true | |
| 208 | - } | |
| 209 | - | |
| 210 | - private fun isKDE(): Boolean { | |
| 211 | - val gdmSession = System.getenv("GDMSESSION") | |
| 212 | - return gdmSession?.lowercase()?.contains("kde") == true | |
| 213 | - } | |
| 214 | -} | |
| No newline at the end of the file |
modified extensions/vscode/package-lock.json +0 −0
Not shown: the file is larger than the hub shows, or this page holds as much as it shows. View the file.
modified extensions/vscode/package.json +1 −1
| @@ -2,7 +2,7 @@ | ||
| 2 | 2 | "name": "continue", |
| 3 | 3 | "icon": "media/icon.png", |
| 4 | 4 | "author": "Continue Dev, Inc", |
| 5 | - "version": "1.1.50", | |
| 5 | + "version": "1.1.52", | |
| 6 | 6 | "repository": { |
| 7 | 7 | "type": "git", |
| 8 | 8 | "url": "https://github.com/continuedev/continue" |
modified extensions/vscode/src/VsCodeIde.ts +4 −0
| @@ -200,6 +200,10 @@ | ||
| 200 | 200 | return globalEnabled && continueEnabled; |
| 201 | 201 | } |
| 202 | 202 | |
| 203 | + isWorkspaceRemote(): Promise<boolean> { | |
| 204 | + return Promise.resolve(vscode.env.remoteName !== undefined); | |
| 205 | + } | |
| 206 | + | |
| 203 | 207 | getUniqueId(): Promise<string> { |
| 204 | 208 | return Promise.resolve(vscode.env.machineId); |
| 205 | 209 | } |
modified gui/package-lock.json +0 −0
Not shown: the file is larger than the hub shows, or this page holds as much as it shows. View the file.
modified gui/src/components/StyledMarkdownPreview/StepContainerPreToolbar/index.tsx +15 −13
| @@ -11,8 +11,10 @@ | ||
| 11 | 11 | import { useIdeMessengerRequest } from "../../../hooks/useIdeMessengerRequest"; |
| 12 | 12 | import { useWebviewListener } from "../../../hooks/useWebviewListener"; |
| 13 | 13 | import { useAppSelector } from "../../../redux/hooks"; |
| 14 | -import { selectCurrentToolCallApplyState } from "../../../redux/selectors/selectCurrentToolCall"; | |
| 15 | -import { selectApplyStateByStreamId } from "../../../redux/slices/sessionSlice"; | |
| 14 | +import { | |
| 15 | + selectApplyStateByStreamId, | |
| 16 | + selectApplyStateByToolCallId, | |
| 17 | +} from "../../../redux/slices/sessionSlice"; | |
| 16 | 18 | import { getFontSize } from "../../../util"; |
| 17 | 19 | import Spinner from "../../gui/Spinner"; |
| 18 | 20 | import { isTerminalCodeBlock } from "../utils"; |
| @@ -54,6 +56,7 @@ | ||
| 54 | 56 | codeBlockIndex: number; // To track which codeblock we are applying |
| 55 | 57 | isLastCodeblock: boolean; |
| 56 | 58 | codeBlockStreamId: string; |
| 59 | + forceToolCallId?: string; // If this is defined, we will use this streamId instead of the one from the codeBlock | |
| 57 | 60 | range?: string; |
| 58 | 61 | children: any; |
| 59 | 62 | expanded?: boolean; |
| @@ -68,6 +71,7 @@ | ||
| 68 | 71 | codeBlockIndex, |
| 69 | 72 | isLastCodeblock, |
| 70 | 73 | codeBlockStreamId, |
| 74 | + forceToolCallId, | |
| 71 | 75 | range, |
| 72 | 76 | children, |
| 73 | 77 | expanded, |
| @@ -99,8 +103,8 @@ | ||
| 99 | 103 | const applyState = useAppSelector((state) => |
| 100 | 104 | selectApplyStateByStreamId(state, codeBlockStreamId), |
| 101 | 105 | ); |
| 102 | - const currentToolCallApplyState = useAppSelector( | |
| 103 | - selectCurrentToolCallApplyState, | |
| 106 | + const toolCallApplyState = useAppSelector((state) => | |
| 107 | + selectApplyStateByToolCallId(state, forceToolCallId), | |
| 104 | 108 | ); |
| 105 | 109 | |
| 106 | 110 | /** |
| @@ -147,7 +151,7 @@ | ||
| 147 | 151 | setRelativeFilepathUri(resolvedUri); |
| 148 | 152 | } |
| 149 | 153 | }; |
| 150 | - getRelativeFilepathUri(); | |
| 154 | + void getRelativeFilepathUri(); | |
| 151 | 155 | }, [relativeFilepath, ideMessenger.ide]); |
| 152 | 156 | |
| 153 | 157 | async function getFileUriToApplyTo() { |
| @@ -173,7 +177,7 @@ | ||
| 173 | 177 | async function onClickApply() { |
| 174 | 178 | const fileUri = await getFileUriToApplyTo(); |
| 175 | 179 | if (!fileUri) { |
| 176 | - ideMessenger.ide.showToast( | |
| 180 | + void ideMessenger.ide.showToast( | |
| 177 | 181 | "error", |
| 178 | 182 | "Could not resolve filepath to apply changes", |
| 179 | 183 | ); |
| @@ -188,7 +192,7 @@ | ||
| 188 | 192 | }); |
| 189 | 193 | |
| 190 | 194 | setAppliedFileUri(fileUri); |
| 191 | - refreshFileExists(); | |
| 195 | + void refreshFileExists(); | |
| 192 | 196 | } |
| 193 | 197 | |
| 194 | 198 | function onClickInsertAtCursor() { |
| @@ -198,7 +202,7 @@ | ||
| 198 | 202 | async function handleDiffAction(action: "accept" | "reject") { |
| 199 | 203 | const filepath = await getFileUriToApplyTo(); |
| 200 | 204 | if (!filepath) { |
| 201 | - ideMessenger.ide.showToast( | |
| 205 | + void ideMessenger.ide.showToast( | |
| 202 | 206 | "error", |
| 203 | 207 | `Could not resolve filepath to ${action} changes`, |
| 204 | 208 | ); |
| @@ -233,10 +237,7 @@ | ||
| 233 | 237 | } |
| 234 | 238 | |
| 235 | 239 | const renderActionButtons = () => { |
| 236 | - const isPendingToolCall = | |
| 237 | - currentToolCallApplyState && | |
| 238 | - currentToolCallApplyState.streamId === applyState?.streamId && | |
| 239 | - currentToolCallApplyState.status === "not-started"; | |
| 240 | + const isPendingToolCall = toolCallApplyState?.status === "not-started"; | |
| 240 | 241 | |
| 241 | 242 | if (isGeneratingCodeBlock || isPendingToolCall) { |
| 242 | 243 | const numLines = codeBlockContent.split("\n").length; |
| @@ -271,7 +272,7 @@ | ||
| 271 | 272 | return ( |
| 272 | 273 | <ApplyActions |
| 273 | 274 | disableManualApply={disableManualApply} |
| 274 | - applyState={applyState} | |
| 275 | + applyState={toolCallApplyState ?? applyState} | |
| 275 | 276 | onClickApply={onClickApply} |
| 276 | 277 | onClickAccept={() => handleDiffAction("accept")} |
| 277 | 278 | onClickReject={() => handleDiffAction("reject")} |
| @@ -293,6 +294,7 @@ | ||
| 293 | 294 | <ToolbarDiv isExpanded={isExpanded} className="find-widget-skip gap-3"> |
| 294 | 295 | <div className="max-w-[50% flex flex-row items-center"> |
| 295 | 296 | <ChevronDownIcon |
| 297 | + data-testid="toggle-codeblock" | |
| 296 | 298 | onClick={() => setIsExpanded(!isExpanded)} |
| 297 | 299 | className={`text-lightgray h-3.5 w-3.5 flex-shrink-0 cursor-pointer hover:brightness-125 ${ |
| 298 | 300 | isExpanded ? "rotate-0" : "-rotate-90" |
modified gui/src/components/StyledMarkdownPreview/index.tsx +4 −9
| @@ -126,7 +126,7 @@ | ||
| 126 | 126 | itemIndex?: number; |
| 127 | 127 | useParentBackgroundColor?: boolean; |
| 128 | 128 | disableManualApply?: boolean; |
| 129 | - forceStreamId?: string; | |
| 129 | + toolCallId?: string; | |
| 130 | 130 | expandCodeblocks?: boolean; |
| 131 | 131 | } |
| 132 | 132 | |
| @@ -196,11 +196,6 @@ | ||
| 196 | 196 | const itemIndexRef = useUpdatingRef(props.itemIndex); |
| 197 | 197 | |
| 198 | 198 | const codeblockStreamIds = useRef<string[]>([]); |
| 199 | - useEffect(() => { | |
| 200 | - if (props.forceStreamId) { | |
| 201 | - codeblockStreamIds.current = [props.forceStreamId]; | |
| 202 | - } | |
| 203 | - }, [props.forceStreamId, codeblockStreamIds]); | |
| 204 | 199 | |
| 205 | 200 | const [reactContent, setMarkdownSource] = useRemark({ |
| 206 | 201 | remarkPlugins: [ |
| @@ -295,8 +290,7 @@ | ||
| 295 | 290 | const isLastCodeblock = preChildProps["data-islastcodeblock"]; |
| 296 | 291 | |
| 297 | 292 | if (codeblockStreamIds.current[codeBlockIndex] === undefined) { |
| 298 | - codeblockStreamIds.current[codeBlockIndex] = | |
| 299 | - props.forceStreamId ?? uuidv4(); | |
| 293 | + codeblockStreamIds.current[codeBlockIndex] = uuidv4(); | |
| 300 | 294 | } |
| 301 | 295 | |
| 302 | 296 | return ( |
| @@ -308,7 +302,8 @@ | ||
| 308 | 302 | relativeFilepath={relativeFilePath} |
| 309 | 303 | isLastCodeblock={isLastCodeblock} |
| 310 | 304 | range={range} |
| 311 | - codeBlockStreamId={codeblockStreamIds.current[codeBlockIndex]} | |
| 305 | + codeBlockStreamId={codeblockStreamIds.current[codeBlockIndex]} // ignored if toolCallId stream state is found | |
| 306 | + forceToolCallId={props.toolCallId} | |
| 312 | 307 | expanded={props.expandCodeblocks} |
| 313 | 308 | disableManualApply={props.disableManualApply} |
| 314 | 309 | > |
modified gui/src/components/mainInput/TipTapEditor/utils/editorConfig.ts +4 −1
| @@ -330,7 +330,10 @@ | ||
| 330 | 330 | ], |
| 331 | 331 | editorProps: { |
| 332 | 332 | attributes: { |
| 333 | - class: "outline-none overflow-hidden", | |
| 333 | + "data-testid": props.isMainInput | |
| 334 | + ? "editor-input-main" | |
| 335 | + : `editor-input-${props.inputId}`, | |
| 336 | + class: "ProseMirror outline-none overflow-hidden", | |
| 334 | 337 | style: `font-size: ${getFontSize()}px;`, |
| 335 | 338 | }, |
| 336 | 339 | }, |
modified gui/src/context/MockIdeMessenger.ts +111 −70
| @@ -1,7 +1,6 @@ | ||
| 1 | -import { IDE, PromptLog } from "core"; | |
| 1 | +import { ChatMessage, IDE, PromptLog } from "core"; | |
| 2 | 2 | import { AuthType } from "core/control-plane/AuthTypes"; |
| 3 | 3 | import { |
| 4 | - FromIdeProtocol, | |
| 5 | 4 | FromWebviewProtocol, |
| 6 | 5 | ToCoreProtocol, |
| 7 | 6 | ToWebviewProtocol, |
| @@ -13,73 +12,83 @@ | ||
| 13 | 12 | GeneratorYieldType, |
| 14 | 13 | WebviewSingleProtocolMessage, |
| 15 | 14 | } from "core/protocol/util"; |
| 16 | -import { ChatMessage } from "../redux/store"; | |
| 17 | 15 | import { IIdeMessenger } from "./IdeMessenger"; |
| 18 | 16 | |
| 19 | -async function defaultMockHandleMessage<T extends keyof FromWebviewProtocol>( | |
| 20 | - messageType: T, | |
| 21 | - data: FromWebviewProtocol[T][0], | |
| 22 | -): Promise<FromWebviewProtocol[T][1]> { | |
| 23 | - function returnFor<K extends keyof FromWebviewProtocol>( | |
| 24 | - _: K, | |
| 25 | - value: FromWebviewProtocol[K][1], | |
| 26 | - ): FromWebviewProtocol[T][1] { | |
| 27 | - return value as unknown as FromWebviewProtocol[T][1]; | |
| 28 | - } | |
| 17 | +type MockResponses = Partial<{ | |
| 18 | + [K in keyof FromWebviewProtocol]: FromWebviewProtocol[K][1]; | |
| 19 | +}>; | |
| 29 | 20 | |
| 30 | - switch (messageType) { | |
| 31 | - case "history/list": | |
| 32 | - return returnFor("history/list", [ | |
| 33 | - { | |
| 34 | - title: "Session 1", | |
| 35 | - sessionId: "session-1", | |
| 36 | - dateCreated: new Date().toString(), | |
| 37 | - workspaceDirectory: "/tmp", | |
| 38 | - }, | |
| 39 | - ]); | |
| 40 | - case "getControlPlaneSessionInfo": | |
| 41 | - return returnFor("getControlPlaneSessionInfo", { | |
| 42 | - AUTH_TYPE: AuthType.WorkOsStaging, | |
| 43 | - accessToken: "", | |
| 44 | - account: { | |
| 45 | - label: "", | |
| 46 | - id: "", | |
| 47 | - }, | |
| 48 | - }); | |
| 49 | - case "config/getSerializedProfileInfo": | |
| 50 | - return returnFor("config/getSerializedProfileInfo", { | |
| 51 | - organizations: [], | |
| 52 | - profileId: "test-profile", | |
| 53 | - result: { | |
| 54 | - config: undefined, | |
| 55 | - errors: [], | |
| 56 | - configLoadInterrupted: false, | |
| 57 | - }, | |
| 58 | - selectedOrgId: "local", | |
| 59 | - }); | |
| 60 | - default: | |
| 61 | - throw new Error(`Unknown message type ${messageType}`); | |
| 62 | - } | |
| 63 | -} | |
| 21 | +const DEFAULT_MOCK_CORE_RESPONSES: MockResponses = { | |
| 22 | + fileExists: true, | |
| 23 | + getCurrentFile: { | |
| 24 | + isUntitled: false, | |
| 25 | + contents: "Current file contents", | |
| 26 | + path: "file:///Users/user/workspace1/current_file.py", | |
| 27 | + }, | |
| 28 | + "controlPlane/getFreeTrialStatus": { | |
| 29 | + autocompleteLimit: 1000, | |
| 30 | + optedInToFreeTrial: false, | |
| 31 | + chatLimit: 1000, | |
| 32 | + autocompleteCount: 0, | |
| 33 | + chatCount: 0, | |
| 34 | + }, | |
| 35 | + getWorkspaceDirs: [ | |
| 36 | + "file:///Users/user/workspace1", | |
| 37 | + "file:///Users/user/workspace2", | |
| 38 | + ], | |
| 39 | + "history/list": [ | |
| 40 | + { | |
| 41 | + title: "Session 1", | |
| 42 | + sessionId: "session-1", | |
| 43 | + dateCreated: new Date().toString(), | |
| 44 | + workspaceDirectory: "/tmp", | |
| 45 | + }, | |
| 46 | + ], | |
| 47 | + "history/save": undefined, | |
| 48 | + getControlPlaneSessionInfo: { | |
| 49 | + AUTH_TYPE: AuthType.WorkOsStaging, | |
| 50 | + accessToken: "", | |
| 51 | + account: { | |
| 52 | + label: "", | |
| 53 | + id: "", | |
| 54 | + }, | |
| 55 | + }, | |
| 56 | + "config/getSerializedProfileInfo": { | |
| 57 | + organizations: [], | |
| 58 | + profileId: "test-profile", | |
| 59 | + result: { | |
| 60 | + config: undefined, | |
| 61 | + errors: [], | |
| 62 | + configLoadInterrupted: false, | |
| 63 | + }, | |
| 64 | + selectedOrgId: "local", | |
| 65 | + }, | |
| 66 | + "chatDescriber/describe": "Session summary", | |
| 67 | + applyToFile: undefined, | |
| 68 | + acceptDiff: undefined, | |
| 69 | +}; | |
| 64 | 70 | |
| 71 | +const DEFAULT_CHAT_RESPONSE: ChatMessage[] = [ | |
| 72 | + { | |
| 73 | + role: "assistant", | |
| 74 | + content: "This is a test", | |
| 75 | + }, | |
| 76 | +]; | |
| 65 | 77 | export class MockIdeMessenger implements IIdeMessenger { |
| 66 | 78 | ide: IDE; |
| 67 | - private messageHandlers: Map< | |
| 68 | - keyof FromIdeProtocol, | |
| 69 | - Array<(data: any) => void> | |
| 70 | - > = new Map(); | |
| 71 | 79 | |
| 72 | 80 | constructor() { |
| 73 | 81 | this.ide = new MessageIde( |
| 74 | - (messageType, data) => { | |
| 75 | - throw new Error("Not implemented"); | |
| 82 | + async (messageType, data) => { | |
| 83 | + const response = await this.request.bind(this)(messageType, data); | |
| 84 | + if (response.status === "error") { | |
| 85 | + throw new Error(response.error); | |
| 86 | + } else { | |
| 87 | + return response.content; | |
| 88 | + } | |
| 76 | 89 | }, |
| 77 | 90 | (messageType, callback) => { |
| 78 | - // Store the callback in our handlers map | |
| 79 | - if (!this.messageHandlers.has(messageType)) { | |
| 80 | - this.messageHandlers.set(messageType, []); | |
| 81 | - } | |
| 82 | - this.messageHandlers.get(messageType)?.push(callback); | |
| 91 | + return; | |
| 83 | 92 | }, |
| 84 | 93 | ); |
| 85 | 94 | } |
| @@ -109,16 +118,38 @@ | ||
| 109 | 118 | ); |
| 110 | 119 | } |
| 111 | 120 | |
| 112 | - async *llmStreamChat( | |
| 113 | - msg: ToCoreProtocol["llm/streamChat"][0], | |
| 114 | - cancelToken: AbortSignal, | |
| 115 | - ): AsyncGenerator<ChatMessage[], PromptLog | undefined> { | |
| 116 | - yield [ | |
| 121 | + responses: MockResponses = { ...DEFAULT_MOCK_CORE_RESPONSES }; | |
| 122 | + chatResponse: ChatMessage[] = DEFAULT_CHAT_RESPONSE; | |
| 123 | + chatStreamDelay: number = 0; | |
| 124 | + setChatResponseText(text: string): void { | |
| 125 | + this.chatResponse = [ | |
| 117 | 126 | { |
| 118 | 127 | role: "assistant", |
| 119 | - content: "This is a test", | |
| 128 | + content: text, | |
| 120 | 129 | }, |
| 121 | 130 | ]; |
| 131 | + } | |
| 132 | + | |
| 133 | + async *llmStreamChat( | |
| 134 | + msg: ToCoreProtocol["llm/streamChat"][0], | |
| 135 | + cancelToken: AbortSignal, | |
| 136 | + ): AsyncGenerator<ChatMessage[], PromptLog | undefined> { | |
| 137 | + for (const response of this.chatResponse) { | |
| 138 | + if (cancelToken.aborted) { | |
| 139 | + console.log("MockIdeMessenger: Stream aborted"); | |
| 140 | + return undefined; | |
| 141 | + } | |
| 142 | + console.log( | |
| 143 | + "MockIdeMessenger: Yielding chunk", | |
| 144 | + JSON.stringify(response, null, 2), | |
| 145 | + ); | |
| 146 | + yield [response]; | |
| 147 | + if (this.chatStreamDelay > 0) { | |
| 148 | + await new Promise((resolve) => | |
| 149 | + setTimeout(resolve, this.chatStreamDelay), | |
| 150 | + ); | |
| 151 | + } | |
| 152 | + } | |
| 122 | 153 | return undefined; |
| 123 | 154 | } |
| 124 | 155 | |
| @@ -133,12 +164,16 @@ | ||
| 133 | 164 | messageType: T, |
| 134 | 165 | data: FromWebviewProtocol[T][0], |
| 135 | 166 | ): Promise<WebviewSingleProtocolMessage<T>> { |
| 136 | - const content = await defaultMockHandleMessage(messageType, data); | |
| 137 | - return { | |
| 138 | - status: "success", | |
| 139 | - content, | |
| 140 | - done: true, | |
| 141 | - }; | |
| 167 | + if (messageType in this.responses) { | |
| 168 | + const content = this.responses[messageType]; | |
| 169 | + return { | |
| 170 | + status: "success", | |
| 171 | + content, | |
| 172 | + done: true, | |
| 173 | + }; | |
| 174 | + } | |
| 175 | + console.error(messageType); | |
| 176 | + throw new Error("MockIdeMessenger: No response defined for " + messageType); | |
| 142 | 177 | } |
| 143 | 178 | |
| 144 | 179 | respond<T extends keyof ToWebviewProtocol>( |
| @@ -157,4 +192,10 @@ | ||
| 157 | 192 | > { |
| 158 | 193 | return undefined; |
| 159 | 194 | } |
| 195 | + | |
| 196 | + resetMocks(): void { | |
| 197 | + this.responses = { ...DEFAULT_MOCK_CORE_RESPONSES }; | |
| 198 | + this.chatResponse = DEFAULT_CHAT_RESPONSE; | |
| 199 | + this.chatStreamDelay = 0; | |
| 200 | + } | |
| 160 | 201 | } |
modified gui/src/hooks/ParallelListeners.tsx +38 −18
| @@ -20,6 +20,7 @@ | ||
| 20 | 20 | import { |
| 21 | 21 | acceptToolCall, |
| 22 | 22 | addContextItemsAtIndex, |
| 23 | + selectCurrentToolCall, | |
| 23 | 24 | setHasReasoningEnabled, |
| 24 | 25 | updateApplyState, |
| 25 | 26 | } from "../redux/slices/sessionSlice"; |
| @@ -244,6 +245,10 @@ | ||
| 244 | 245 | dispatch(updateIndexingStatus(data)); |
| 245 | 246 | }); |
| 246 | 247 | |
| 248 | + const autoAcceptEditToolDiffs = useAppSelector( | |
| 249 | + (store) => store.config.config.ui?.autoAcceptEditToolDiffs, | |
| 250 | + ); | |
| 251 | + const currentToolCall = useAppSelector(selectCurrentToolCall); | |
| 247 | 252 | useWebviewListener( |
| 248 | 253 | "updateApplyState", |
| 249 | 254 | async (state) => { |
| @@ -259,30 +264,45 @@ | ||
| 259 | 264 | |
| 260 | 265 | // Handle apply status updates that are associated with current tool call |
| 261 | 266 | if ( |
| 262 | - state.status === "closed" && | |
| 263 | 267 | currentToolCallApplyState && |
| 264 | 268 | currentToolCallApplyState.streamId === state.streamId |
| 265 | 269 | ) { |
| 266 | - // const output: ContextItem = { | |
| 267 | - // name: "Edit tool output", | |
| 268 | - // content: "Completed edit", | |
| 269 | - // description: "", | |
| 270 | - // }; | |
| 271 | - dispatch( | |
| 272 | - acceptToolCall({ | |
| 273 | - toolCallId: currentToolCallApplyState.toolCallId!, | |
| 274 | - }), | |
| 275 | - ); | |
| 276 | - // dispatch(setToolCallOutput([])); | |
| 277 | - void dispatch( | |
| 278 | - streamResponseAfterToolCall({ | |
| 279 | - toolCallId: currentToolCallApplyState.toolCallId!, | |
| 280 | - }), | |
| 281 | - ); | |
| 270 | + if (state.status === "done" && autoAcceptEditToolDiffs) { | |
| 271 | + console.log("AUTO ACCEPTED"); | |
| 272 | + ideMessenger.post("acceptDiff", { | |
| 273 | + streamId: state.streamId, | |
| 274 | + filepath: state.filepath, | |
| 275 | + }); | |
| 276 | + } | |
| 277 | + if (state.status === "closed") { | |
| 278 | + if (currentToolCall?.status !== "canceled") { | |
| 279 | + dispatch( | |
| 280 | + acceptToolCall({ | |
| 281 | + toolCallId: currentToolCallApplyState.toolCallId!, | |
| 282 | + }), | |
| 283 | + ); | |
| 284 | + } | |
| 285 | + // const output: ContextItem = { | |
| 286 | + // name: "Edit tool output", | |
| 287 | + // content: "Completed edit", | |
| 288 | + // description: "", | |
| 289 | + // }; | |
| 290 | + // dispatch(setToolCallOutput([])); | |
| 291 | + void dispatch( | |
| 292 | + streamResponseAfterToolCall({ | |
| 293 | + toolCallId: currentToolCallApplyState.toolCallId!, | |
| 294 | + }), | |
| 295 | + ); | |
| 296 | + } | |
| 282 | 297 | } |
| 283 | 298 | } |
| 284 | 299 | }, |
| 285 | - [currentToolCallApplyState, history], | |
| 300 | + [ | |
| 301 | + currentToolCall, | |
| 302 | + currentToolCallApplyState, | |
| 303 | + autoAcceptEditToolDiffs, | |
| 304 | + ideMessenger, | |
| 305 | + ], | |
| 286 | 306 | ); |
| 287 | 307 | |
| 288 | 308 | useEffect(() => { |
deleted gui/src/pages/gui/Chat.test.tsx +0 −161
| @@ -1,161 +0,0 @@ | ||
| 1 | -import { screen, waitFor } from "@testing-library/dom"; | |
| 2 | -import { act } from "@testing-library/react"; | |
| 3 | -import { renderWithProviders } from "../../util/test/render"; | |
| 4 | -import { Chat } from "./Chat"; | |
| 5 | - | |
| 6 | -describe("Chat page test", () => { | |
| 7 | - it("should render input box", async () => { | |
| 8 | - await renderWithProviders(<Chat />); | |
| 9 | - expect(await screen.findByTestId("continue-input-box")).toBeInTheDocument(); | |
| 10 | - }); | |
| 11 | - | |
| 12 | - it("should be able to toggle modes", async () => { | |
| 13 | - await renderWithProviders(<Chat />); | |
| 14 | - expect(screen.getByText("Chat")).toBeInTheDocument(); | |
| 15 | - | |
| 16 | - // Simulate cmd+. keyboard shortcut to toggle modes | |
| 17 | - act(() => { | |
| 18 | - document.dispatchEvent( | |
| 19 | - new KeyboardEvent("keydown", { | |
| 20 | - key: ".", | |
| 21 | - metaKey: true, // cmd key on Mac | |
| 22 | - }), | |
| 23 | - ); | |
| 24 | - }); | |
| 25 | - | |
| 26 | - // Check that it switched to Agent mode | |
| 27 | - expect(await screen.findByText("Agent")).toBeInTheDocument(); | |
| 28 | - | |
| 29 | - act(() => { | |
| 30 | - document.dispatchEvent( | |
| 31 | - new KeyboardEvent("keydown", { | |
| 32 | - key: ".", | |
| 33 | - metaKey: true, // cmd key on Mac | |
| 34 | - }), | |
| 35 | - ); | |
| 36 | - }); | |
| 37 | - | |
| 38 | - // Check that it switched back to Chat mode | |
| 39 | - expect(await screen.findByText("Chat")).toBeInTheDocument(); | |
| 40 | - }); | |
| 41 | - | |
| 42 | - it.skip("should send a message and receive a response", async () => { | |
| 43 | - const { user, container } = await renderWithProviders(<Chat />); | |
| 44 | - const inputBox = await waitFor(() => | |
| 45 | - container.querySelector(".ProseMirror")!.querySelector("p"), | |
| 46 | - ); | |
| 47 | - expect(inputBox).toBeDefined(); | |
| 48 | - | |
| 49 | - const sendButton = await screen.findByTestId("submit-input-button"); | |
| 50 | - | |
| 51 | - await act(async () => { | |
| 52 | - // Focus input box | |
| 53 | - inputBox!.focus(); | |
| 54 | - | |
| 55 | - // Type message | |
| 56 | - await user.type(inputBox!, "Hello, world!"); | |
| 57 | - | |
| 58 | - sendButton.click(); | |
| 59 | - }); | |
| 60 | - expect(await screen.findByText("Hello, world!")).toBeInTheDocument(); | |
| 61 | - }); | |
| 62 | - | |
| 63 | - it("should handle apply updates and display the accept / reject all buttons", async () => { | |
| 64 | - const { ideMessenger } = await renderWithProviders(<Chat />); | |
| 65 | - | |
| 66 | - // Use queryByText which returns null when element isn't found | |
| 67 | - const acceptAllButton = screen.queryByText("Accept All"); | |
| 68 | - const rejectAllButton = screen.queryByText("Reject All"); | |
| 69 | - | |
| 70 | - // Assert that the buttons don't exist | |
| 71 | - expect(acceptAllButton).not.toBeInTheDocument(); | |
| 72 | - expect(rejectAllButton).not.toBeInTheDocument(); | |
| 73 | - | |
| 74 | - for (let i = 0; i < 5; i++) { | |
| 75 | - ideMessenger.mockMessageToWebview("updateApplyState", { | |
| 76 | - status: "streaming", | |
| 77 | - streamId: `12345`, | |
| 78 | - }); | |
| 79 | - } | |
| 80 | - | |
| 81 | - ideMessenger.mockMessageToWebview("updateApplyState", { | |
| 82 | - status: "done", | |
| 83 | - streamId: "12345", | |
| 84 | - }); | |
| 85 | - | |
| 86 | - // Wait for the buttons to appear | |
| 87 | - await waitFor(() => { | |
| 88 | - expect( | |
| 89 | - screen.getByTestId("accept-reject-all-buttons"), | |
| 90 | - ).toBeInTheDocument(); | |
| 91 | - }); | |
| 92 | - | |
| 93 | - // IDE sends back message that it is done | |
| 94 | - ideMessenger.mockMessageToWebview("updateApplyState", { | |
| 95 | - status: "closed", | |
| 96 | - streamId: "12345", | |
| 97 | - }); | |
| 98 | - | |
| 99 | - // Wait for the buttons to disappear | |
| 100 | - await waitFor(() => { | |
| 101 | - expect( | |
| 102 | - screen.queryByTestId("edit-accept-button"), | |
| 103 | - ).not.toBeInTheDocument(); | |
| 104 | - expect( | |
| 105 | - screen.queryByTestId("edit-reject-button"), | |
| 106 | - ).not.toBeInTheDocument(); | |
| 107 | - }); | |
| 108 | - }); | |
| 109 | - | |
| 110 | - it("should show apply cancellation", async () => { | |
| 111 | - const { ideMessenger } = await renderWithProviders(<Chat />); | |
| 112 | - | |
| 113 | - // Spy on the request method of ideMessenger | |
| 114 | - const messengerPostSpy = vi.spyOn(ideMessenger, "post"); | |
| 115 | - | |
| 116 | - for (let i = 0; i < 5; i++) { | |
| 117 | - ideMessenger.mockMessageToWebview("updateApplyState", { | |
| 118 | - status: "streaming", | |
| 119 | - streamId: `12345`, | |
| 120 | - }); | |
| 121 | - } | |
| 122 | - | |
| 123 | - // Wait for applying toolbar to appear | |
| 124 | - await waitFor(() => { | |
| 125 | - const cancelApplyButton = screen.getByTestId( | |
| 126 | - "notch-applying-cancel-button", | |
| 127 | - ); | |
| 128 | - const applyingText = screen.getByTestId("notch-applying-text"); | |
| 129 | - | |
| 130 | - expect(cancelApplyButton).toBeInTheDocument(); | |
| 131 | - expect(applyingText).toBeInTheDocument(); | |
| 132 | - }); | |
| 133 | - | |
| 134 | - const cancelApplyButton = screen.getByTestId( | |
| 135 | - "notch-applying-cancel-button", | |
| 136 | - ); | |
| 137 | - cancelApplyButton.click(); | |
| 138 | - | |
| 139 | - // Verify that rejectDiff message has been posted to ideMessenger | |
| 140 | - expect(messengerPostSpy).toHaveBeenCalledWith("rejectDiff", {}); | |
| 141 | - | |
| 142 | - // Now simulate the IDE sending back a message that the apply state is closed | |
| 143 | - ideMessenger.mockMessageToWebview("updateApplyState", { | |
| 144 | - status: "closed", | |
| 145 | - streamId: "12345", | |
| 146 | - }); | |
| 147 | - | |
| 148 | - await waitFor(() => { | |
| 149 | - const cancelApplyButton = screen.queryByTestId( | |
| 150 | - "notch-applying-cancel-button", | |
| 151 | - ); | |
| 152 | - const applyingText = screen.queryByTestId("notch-applying-text"); | |
| 153 | - | |
| 154 | - expect(cancelApplyButton).not.toBeInTheDocument(); | |
| 155 | - expect(applyingText).not.toBeInTheDocument(); | |
| 156 | - }); | |
| 157 | - | |
| 158 | - // Cleanup spy | |
| 159 | - messengerPostSpy.mockRestore(); | |
| 160 | - }); | |
| 161 | -}); |
modified gui/src/pages/gui/ToolCallDiv/EditFile.tsx +1 −26
| @@ -1,12 +1,5 @@ | ||
| 1 | 1 | import { getMarkdownLanguageTagForFile } from "core/util"; |
| 2 | -import { useEffect } from "react"; | |
| 3 | -import { v4 as uuidv4 } from "uuid"; | |
| 4 | 2 | import StyledMarkdownPreview from "../../../components/StyledMarkdownPreview"; |
| 5 | -import { useAppDispatch, useAppSelector } from "../../../redux/hooks"; | |
| 6 | -import { | |
| 7 | - selectApplyStateByToolCallId, | |
| 8 | - updateApplyState, | |
| 9 | -} from "../../../redux/slices/sessionSlice"; | |
| 10 | 3 | |
| 11 | 4 | type EditToolCallProps = { |
| 12 | 5 | relativeFilePath: string; |
| @@ -17,24 +10,6 @@ | ||
| 17 | 10 | }; |
| 18 | 11 | |
| 19 | 12 | export function EditFile(props: EditToolCallProps) { |
| 20 | - const dispatch = useAppDispatch(); | |
| 21 | - | |
| 22 | - const applyState = useAppSelector((state) => | |
| 23 | - selectApplyStateByToolCallId(state, props.toolCallId), | |
| 24 | - ); | |
| 25 | - | |
| 26 | - useEffect(() => { | |
| 27 | - if (!applyState) { | |
| 28 | - dispatch( | |
| 29 | - updateApplyState({ | |
| 30 | - streamId: uuidv4(), | |
| 31 | - toolCallId: props.toolCallId, | |
| 32 | - status: "not-started", | |
| 33 | - }), | |
| 34 | - ); | |
| 35 | - } | |
| 36 | - }, [applyState, props.toolCallId]); | |
| 37 | - | |
| 38 | 13 | if (!props.relativeFilePath || !props.changes) { |
| 39 | 14 | return null; |
| 40 | 15 | } |
| @@ -47,7 +22,7 @@ | ||
| 47 | 22 | isRenderingInStepContainer |
| 48 | 23 | disableManualApply |
| 49 | 24 | source={src} |
| 50 | - forceStreamId={applyState?.streamId} | |
| 25 | + toolCallId={props.toolCallId} | |
| 51 | 26 | itemIndex={props.historyIndex} |
| 52 | 27 | /> |
| 53 | 28 | ); |
added gui/src/pages/gui/chat-tests/ApplyScenarios.test.tsx +80 −0
| @@ -0,0 +1,80 @@ | ||
| 1 | +import { act } from "@testing-library/react"; | |
| 2 | +import { renderWithProviders } from "../../../util/test/render"; | |
| 3 | +import { | |
| 4 | + getElementByTestId, | |
| 5 | + verifyNotPresentByTestId, | |
| 6 | + verifyNotPresentByText, | |
| 7 | +} from "../../../util/test/utils"; | |
| 8 | +import { Chat } from "../Chat"; | |
| 9 | + | |
| 10 | +test("Chat apply scenarios: handle apply updates and display the accept / reject all buttons", async () => { | |
| 11 | + const { ideMessenger } = await renderWithProviders(<Chat />); | |
| 12 | + | |
| 13 | + // Use queryByText which returns null when element isn't found | |
| 14 | + await verifyNotPresentByText("Accept All"); | |
| 15 | + await verifyNotPresentByText("Reject All"); | |
| 16 | + | |
| 17 | + for (let i = 0; i < 5; i++) { | |
| 18 | + ideMessenger.mockMessageToWebview("updateApplyState", { | |
| 19 | + status: "streaming", | |
| 20 | + streamId: `12345`, | |
| 21 | + }); | |
| 22 | + } | |
| 23 | + | |
| 24 | + ideMessenger.mockMessageToWebview("updateApplyState", { | |
| 25 | + status: "done", | |
| 26 | + streamId: "12345", | |
| 27 | + }); | |
| 28 | + | |
| 29 | + // Wait for the buttons to appear | |
| 30 | + await getElementByTestId("accept-reject-all-buttons"); | |
| 31 | + | |
| 32 | + // IDE sends back message that it is done | |
| 33 | + ideMessenger.mockMessageToWebview("updateApplyState", { | |
| 34 | + status: "closed", | |
| 35 | + streamId: "12345", | |
| 36 | + }); | |
| 37 | + | |
| 38 | + // Wait for the buttons to disappear | |
| 39 | + await verifyNotPresentByTestId("edit-accept-button"); | |
| 40 | + await verifyNotPresentByTestId("edit-reject-button"); | |
| 41 | +}); | |
| 42 | + | |
| 43 | +test("Chat apply scenarios: show apply cancellation", async () => { | |
| 44 | + const { ideMessenger } = await renderWithProviders(<Chat />); | |
| 45 | + | |
| 46 | + // Spy on the request method of ideMessenger | |
| 47 | + const messengerPostSpy = vi.spyOn(ideMessenger, "post"); | |
| 48 | + | |
| 49 | + for (let i = 0; i < 5; i++) { | |
| 50 | + ideMessenger.mockMessageToWebview("updateApplyState", { | |
| 51 | + status: "streaming", | |
| 52 | + streamId: `12345`, | |
| 53 | + }); | |
| 54 | + } | |
| 55 | + | |
| 56 | + // Wait for applying toolbar to appear | |
| 57 | + await getElementByTestId("notch-applying-text"); | |
| 58 | + | |
| 59 | + await act(async () => { | |
| 60 | + const cancelApplyButton = await getElementByTestId( | |
| 61 | + "notch-applying-cancel-button", | |
| 62 | + ); | |
| 63 | + cancelApplyButton.click(); | |
| 64 | + }); | |
| 65 | + | |
| 66 | + // Verify that rejectDiff message has been posted to ideMessenger | |
| 67 | + expect(messengerPostSpy).toHaveBeenCalledWith("rejectDiff", {}); | |
| 68 | + | |
| 69 | + // Now simulate the IDE sending back a message that the apply state is closed | |
| 70 | + ideMessenger.mockMessageToWebview("updateApplyState", { | |
| 71 | + status: "closed", | |
| 72 | + streamId: "12345", | |
| 73 | + }); | |
| 74 | + | |
| 75 | + await verifyNotPresentByTestId("notch-applying-text"); | |
| 76 | + await verifyNotPresentByTestId("notch-applying-cancel-button"); | |
| 77 | + | |
| 78 | + // Cleanup spy | |
| 79 | + messengerPostSpy.mockRestore(); | |
| 80 | +}); |
added gui/src/pages/gui/chat-tests/Chat.test.tsx +61 −0
| @@ -0,0 +1,61 @@ | ||
| 1 | +import { act } from "@testing-library/react"; | |
| 2 | +import { addAndSelectMockLlm } from "../../../util/test/config"; | |
| 3 | +import { renderWithProviders } from "../../../util/test/render"; | |
| 4 | +import { | |
| 5 | + getElementByTestId, | |
| 6 | + getElementByText, | |
| 7 | + sendInputWithMockedResponse, | |
| 8 | +} from "../../../util/test/utils"; | |
| 9 | +import { Chat } from "../Chat"; | |
| 10 | + | |
| 11 | +test("should render input box", async () => { | |
| 12 | + await renderWithProviders(<Chat />); | |
| 13 | + await getElementByTestId("continue-input-box"); | |
| 14 | +}); | |
| 15 | + | |
| 16 | +test("should be able to toggle modes", async () => { | |
| 17 | + await renderWithProviders(<Chat />); | |
| 18 | + await getElementByText("Chat"); | |
| 19 | + | |
| 20 | + // Simulate cmd+. keyboard shortcut to toggle modes | |
| 21 | + act(() => { | |
| 22 | + document.dispatchEvent( | |
| 23 | + new KeyboardEvent("keydown", { | |
| 24 | + key: ".", | |
| 25 | + metaKey: true, // cmd key on Mac | |
| 26 | + }), | |
| 27 | + ); | |
| 28 | + }); | |
| 29 | + | |
| 30 | + // Check that it switched to Agent mode | |
| 31 | + await getElementByText("Agent"); | |
| 32 | + | |
| 33 | + act(() => { | |
| 34 | + document.dispatchEvent( | |
| 35 | + new KeyboardEvent("keydown", { | |
| 36 | + key: ".", | |
| 37 | + metaKey: true, // cmd key on Mac | |
| 38 | + }), | |
| 39 | + ); | |
| 40 | + }); | |
| 41 | + | |
| 42 | + await getElementByText("Chat"); | |
| 43 | +}); | |
| 44 | + | |
| 45 | +test("should send a message and receive a response", async () => { | |
| 46 | + const { ideMessenger, store } = await renderWithProviders(<Chat />); | |
| 47 | + | |
| 48 | + // First add and select the mock LLM | |
| 49 | + await act(async () => { | |
| 50 | + addAndSelectMockLlm(store, ideMessenger); | |
| 51 | + }); | |
| 52 | + | |
| 53 | + const CONTENT = "Expected response"; | |
| 54 | + const INPUT = "User input"; | |
| 55 | + | |
| 56 | + await sendInputWithMockedResponse(ideMessenger, INPUT, [ | |
| 57 | + { role: "assistant", content: CONTENT }, | |
| 58 | + ]); | |
| 59 | + | |
| 60 | + await getElementByText(CONTENT); | |
| 61 | +}); |
added gui/src/pages/gui/chat-tests/EditToolScenarios.test.tsx +231 −0
| @@ -0,0 +1,231 @@ | ||
| 1 | +import { BuiltInToolNames } from "core/tools/builtIn"; | |
| 2 | +import { | |
| 3 | + addAndSelectMockLlm, | |
| 4 | + triggerConfigUpdate, | |
| 5 | +} from "../../../util/test/config"; | |
| 6 | +import { renderWithProviders } from "../../../util/test/render"; | |
| 7 | +import { Chat } from "../Chat"; | |
| 8 | + | |
| 9 | +import { waitFor } from "@testing-library/dom"; | |
| 10 | +import { ChatMessage } from "core"; | |
| 11 | +import { toggleToolSetting } from "../../../redux/slices/uiSlice"; | |
| 12 | +import { | |
| 13 | + getElementByTestId, | |
| 14 | + getElementByText, | |
| 15 | + sendInputWithMockedResponse, | |
| 16 | + verifyNotPresentByTestId, | |
| 17 | +} from "../../../util/test/utils"; | |
| 18 | + | |
| 19 | +const EDIT_WORKSPACE_DIR = "file:///workspace"; | |
| 20 | +const EDIT_FILEPATH = "test.txt"; | |
| 21 | +const EDIT_FILE_URI = `${EDIT_WORKSPACE_DIR}/${EDIT_FILEPATH}`; | |
| 22 | +const EDIT_CHANGES = "New content"; | |
| 23 | +const EDIT_TOOL_CALL_ID = "known-id"; | |
| 24 | +const EDIT_MESSAGES: ChatMessage[] = [ | |
| 25 | + { | |
| 26 | + role: "assistant", | |
| 27 | + content: "", | |
| 28 | + toolCalls: [ | |
| 29 | + { | |
| 30 | + id: EDIT_TOOL_CALL_ID, | |
| 31 | + function: { | |
| 32 | + name: BuiltInToolNames.EditExistingFile, | |
| 33 | + arguments: JSON.stringify({ | |
| 34 | + filepath: EDIT_FILEPATH, | |
| 35 | + changes: EDIT_CHANGES, | |
| 36 | + }), | |
| 37 | + }, | |
| 38 | + }, | |
| 39 | + ], | |
| 40 | + }, | |
| 41 | +]; | |
| 42 | + | |
| 43 | +const POST_EDIT_RESPONSE = "Edit applied successfully"; | |
| 44 | +beforeEach(() => { | |
| 45 | + vi.clearAllMocks(); | |
| 46 | +}); | |
| 47 | + | |
| 48 | +test("Edit run with ask first policy and no auto apply", async () => { | |
| 49 | + // Setup | |
| 50 | + const { ideMessenger, store, user } = await renderWithProviders(<Chat />); | |
| 51 | + | |
| 52 | + ideMessenger.responses["getWorkspaceDirs"] = [EDIT_WORKSPACE_DIR]; | |
| 53 | + const messengerPostSpy = vi.spyOn(ideMessenger, "post"); | |
| 54 | + | |
| 55 | + addAndSelectMockLlm(store, ideMessenger); | |
| 56 | + | |
| 57 | + // Send the input that will respond with an edit tool call | |
| 58 | + await sendInputWithMockedResponse( | |
| 59 | + ideMessenger, | |
| 60 | + "Edit this file", | |
| 61 | + EDIT_MESSAGES, | |
| 62 | + ); | |
| 63 | + | |
| 64 | + // Toggle the codeblock and make sure the changes show | |
| 65 | + const toggleCodeblockChevron = await getElementByTestId("toggle-codeblock"); | |
| 66 | + | |
| 67 | + await user.click(toggleCodeblockChevron); | |
| 68 | + await getElementByText(EDIT_CHANGES); | |
| 69 | + | |
| 70 | + // Pending tool call - find and click the accept button | |
| 71 | + const acceptToolCallButton = await getElementByTestId( | |
| 72 | + "accept-tool-call-button", | |
| 73 | + ); | |
| 74 | + await user.click(acceptToolCallButton); | |
| 75 | + | |
| 76 | + // Tool call, check that applyToFile was called for edit | |
| 77 | + await waitFor(() => { | |
| 78 | + expect(messengerPostSpy).toHaveBeenCalledWith("applyToFile", { | |
| 79 | + streamId: expect.any(String), | |
| 80 | + filepath: EDIT_FILE_URI, | |
| 81 | + text: EDIT_CHANGES, | |
| 82 | + toolCallId: EDIT_TOOL_CALL_ID, | |
| 83 | + }); | |
| 84 | + }); | |
| 85 | + | |
| 86 | + // Extract stream ID and initiate mock streaming | |
| 87 | + const streamId = messengerPostSpy.mock.calls.find( | |
| 88 | + (call) => call[0] === "applyToFile", | |
| 89 | + )?.[1]?.streamId; | |
| 90 | + expect(streamId).toBeDefined(); | |
| 91 | + | |
| 92 | + ideMessenger.mockMessageToWebview("updateApplyState", { | |
| 93 | + status: "streaming", | |
| 94 | + streamId, | |
| 95 | + toolCallId: EDIT_TOOL_CALL_ID, | |
| 96 | + filepath: EDIT_FILE_URI, | |
| 97 | + }); | |
| 98 | + | |
| 99 | + // Mid stream, should show applying in notch | |
| 100 | + await getElementByTestId("notch-applying-text"); | |
| 101 | + await getElementByTestId("notch-applying-cancel-button"); | |
| 102 | + | |
| 103 | + // Close the stream | |
| 104 | + ideMessenger.mockMessageToWebview("updateApplyState", { | |
| 105 | + status: "done", | |
| 106 | + streamId, | |
| 107 | + toolCallId: EDIT_TOOL_CALL_ID, | |
| 108 | + filepath: EDIT_FILE_URI, | |
| 109 | + }); | |
| 110 | + | |
| 111 | + // Verify accept/reject buttons are present | |
| 112 | + const acceptButton = await getElementByTestId("edit-accept-button"); | |
| 113 | + await getElementByTestId("edit-reject-button"); | |
| 114 | + | |
| 115 | + // Accept the changes, which should trigger a response after the tool call | |
| 116 | + await user.click(acceptButton); | |
| 117 | + | |
| 118 | + expect(messengerPostSpy).toHaveBeenCalledWith("acceptDiff", { | |
| 119 | + streamId, | |
| 120 | + filepath: EDIT_FILE_URI, | |
| 121 | + }); | |
| 122 | + | |
| 123 | + ideMessenger.setChatResponseText(POST_EDIT_RESPONSE); | |
| 124 | + ideMessenger.mockMessageToWebview("updateApplyState", { | |
| 125 | + status: "closed", | |
| 126 | + streamId, | |
| 127 | + toolCallId: EDIT_TOOL_CALL_ID, | |
| 128 | + filepath: EDIT_FILE_URI, | |
| 129 | + }); | |
| 130 | + | |
| 131 | + await verifyNotPresentByTestId("edit-accept-button"); | |
| 132 | + await verifyNotPresentByTestId("edit-reject-button"); | |
| 133 | + | |
| 134 | + await getElementByText(POST_EDIT_RESPONSE); | |
| 135 | +}); | |
| 136 | + | |
| 137 | +test("Edit run with no policy and yolo mode", async () => { | |
| 138 | + // Setup | |
| 139 | + const { ideMessenger, store, user } = await renderWithProviders(<Chat />); | |
| 140 | + | |
| 141 | + ideMessenger.responses["getWorkspaceDirs"] = [EDIT_WORKSPACE_DIR]; | |
| 142 | + const messengerPostSpy = vi.spyOn(ideMessenger, "post"); | |
| 143 | + | |
| 144 | + addAndSelectMockLlm(store, ideMessenger); | |
| 145 | + | |
| 146 | + // Enable automatic edit and yolo mode | |
| 147 | + store.dispatch(toggleToolSetting(BuiltInToolNames.EditExistingFile)); | |
| 148 | + triggerConfigUpdate({ | |
| 149 | + store, | |
| 150 | + ideMessenger, | |
| 151 | + editConfig: (current) => { | |
| 152 | + current.ui = { | |
| 153 | + ...current.ui, | |
| 154 | + autoAcceptEditToolDiffs: true, // Enable auto-accept for edit tool diffs | |
| 155 | + }; | |
| 156 | + return current; | |
| 157 | + }, | |
| 158 | + }); | |
| 159 | + expect(store.getState().config.config.ui?.autoAcceptEditToolDiffs).toBe(true); | |
| 160 | + | |
| 161 | + // Send the input that will respond with an edit tool call | |
| 162 | + await sendInputWithMockedResponse( | |
| 163 | + ideMessenger, | |
| 164 | + "Edit this file", | |
| 165 | + EDIT_MESSAGES, | |
| 166 | + ); | |
| 167 | + | |
| 168 | + // Toggle the codeblock and make sure the changes show | |
| 169 | + const toggleCodeblockChevron = await getElementByTestId("toggle-codeblock"); | |
| 170 | + | |
| 171 | + await user.click(toggleCodeblockChevron); | |
| 172 | + await getElementByText(EDIT_CHANGES); | |
| 173 | + | |
| 174 | + // Make sure there's no pending tool call | |
| 175 | + verifyNotPresentByTestId("accept-tool-call-button"); | |
| 176 | + // Tool call, check that applyToFile was called for edit | |
| 177 | + await waitFor(() => { | |
| 178 | + expect(messengerPostSpy).toHaveBeenCalledWith("applyToFile", { | |
| 179 | + streamId: expect.any(String), | |
| 180 | + filepath: EDIT_FILE_URI, | |
| 181 | + text: EDIT_CHANGES, | |
| 182 | + toolCallId: EDIT_TOOL_CALL_ID, | |
| 183 | + }); | |
| 184 | + }); | |
| 185 | + | |
| 186 | + // Extract stream ID and initiate mock streaming | |
| 187 | + const streamId = messengerPostSpy.mock.calls.find( | |
| 188 | + (call) => call[0] === "applyToFile", | |
| 189 | + )?.[1]?.streamId; | |
| 190 | + expect(streamId).toBeDefined(); | |
| 191 | + | |
| 192 | + ideMessenger.mockMessageToWebview("updateApplyState", { | |
| 193 | + status: "streaming", | |
| 194 | + streamId, | |
| 195 | + toolCallId: EDIT_TOOL_CALL_ID, | |
| 196 | + filepath: EDIT_FILE_URI, | |
| 197 | + }); | |
| 198 | + | |
| 199 | + // Mid stream, should show applying in notch | |
| 200 | + await getElementByTestId("notch-applying-text"); | |
| 201 | + await getElementByTestId("notch-applying-cancel-button"); | |
| 202 | + | |
| 203 | + // Close the stream | |
| 204 | + ideMessenger.mockMessageToWebview("updateApplyState", { | |
| 205 | + status: "done", | |
| 206 | + streamId, | |
| 207 | + toolCallId: EDIT_TOOL_CALL_ID, | |
| 208 | + filepath: EDIT_FILE_URI, | |
| 209 | + }); | |
| 210 | + | |
| 211 | + await waitFor(() => { | |
| 212 | + expect(messengerPostSpy).toHaveBeenCalledWith("acceptDiff", { | |
| 213 | + streamId, | |
| 214 | + filepath: EDIT_FILE_URI, | |
| 215 | + }); | |
| 216 | + }); | |
| 217 | + | |
| 218 | + // Close the stream, ensure response is shown and diff buttons are not present | |
| 219 | + ideMessenger.setChatResponseText(POST_EDIT_RESPONSE); | |
| 220 | + ideMessenger.mockMessageToWebview("updateApplyState", { | |
| 221 | + status: "closed", | |
| 222 | + streamId, | |
| 223 | + toolCallId: EDIT_TOOL_CALL_ID, | |
| 224 | + filepath: EDIT_FILE_URI, | |
| 225 | + }); | |
| 226 | + | |
| 227 | + await verifyNotPresentByTestId("edit-accept-button"); | |
| 228 | + await verifyNotPresentByTestId("edit-reject-button"); | |
| 229 | + | |
| 230 | + await getElementByText(POST_EDIT_RESPONSE); | |
| 231 | +}); |
modified gui/src/redux/slices/sessionSlice.ts +3 −1
| @@ -657,7 +657,9 @@ | ||
| 657 | 657 | (state: RootState, toolCallId?: string) => toolCallId, |
| 658 | 658 | ], |
| 659 | 659 | (states, toolCallId) => { |
| 660 | - return states.find((state) => state.toolCallId === toolCallId); | |
| 660 | + if (toolCallId) { | |
| 661 | + return states.find((state) => state.toolCallId === toolCallId); | |
| 662 | + } | |
| 661 | 663 | }, |
| 662 | 664 | ); |
| 663 | 665 |
modified gui/src/redux/store.ts +0 −5
| @@ -23,11 +23,6 @@ | ||
| 23 | 23 | import tabsReducer from "./slices/tabsSlice"; |
| 24 | 24 | import uiReducer from "./slices/uiSlice"; |
| 25 | 25 | |
| 26 | -export interface ChatMessage { | |
| 27 | - role: "system" | "user" | "assistant"; | |
| 28 | - content: string; | |
| 29 | -} | |
| 30 | - | |
| 31 | 26 | const rootReducer = combineReducers({ |
| 32 | 27 | session: sessionReducer, |
| 33 | 28 | ui: uiReducer, |
modified gui/src/redux/thunks/callCurrentTool.ts +2 −7
| @@ -19,7 +19,6 @@ | ||
| 19 | 19 | async (_, { dispatch, extra, getState }) => { |
| 20 | 20 | const state = getState(); |
| 21 | 21 | const toolCallState = selectCurrentToolCall(state); |
| 22 | - | |
| 23 | 22 | if (!toolCallState) { |
| 24 | 23 | return; |
| 25 | 24 | } |
| @@ -61,19 +60,15 @@ | ||
| 61 | 60 | ) { |
| 62 | 61 | // Tool is called on client side |
| 63 | 62 | const { |
| 64 | - output: clientToolOuput, | |
| 63 | + output: clientToolOutput, | |
| 65 | 64 | respondImmediately, |
| 66 | 65 | errorMessage: clientToolError, |
| 67 | 66 | } = await callClientTool(toolCallState, { |
| 68 | 67 | dispatch, |
| 69 | 68 | ideMessenger: extra.ideMessenger, |
| 70 | - streamId: state.session.codeBlockApplyStates.states.find( | |
| 71 | - (state) => | |
| 72 | - state.toolCallId && state.toolCallId === toolCallState.toolCallId, | |
| 73 | - )?.streamId, | |
| 74 | 69 | getState, |
| 75 | 70 | }); |
| 76 | - output = clientToolOuput; | |
| 71 | + output = clientToolOutput; | |
| 77 | 72 | errorMessage = clientToolError; |
| 78 | 73 | streamResponse = respondImmediately; |
| 79 | 74 | } else { |
modified gui/src/redux/thunks/edit.ts +3 −0
| @@ -17,6 +17,7 @@ | ||
| 17 | 17 | import { |
| 18 | 18 | newSession, |
| 19 | 19 | setActive, |
| 20 | + setInactive, | |
| 20 | 21 | setIsInEdit, |
| 21 | 22 | setMainEditorContentTrigger, |
| 22 | 23 | setMode, |
| @@ -61,6 +62,8 @@ | ||
| 61 | 62 | range: codeToEdit[0] as RangeInFileWithContents, |
| 62 | 63 | }); |
| 63 | 64 | |
| 65 | + dispatch(setInactive()); | |
| 66 | + | |
| 64 | 67 | if (response.status === "error") { |
| 65 | 68 | throw new Error(response.error); |
| 66 | 69 | } |
modified gui/src/redux/thunks/streamNormalInput.ts +6 −0
| @@ -8,6 +8,8 @@ | ||
| 8 | 8 | import { |
| 9 | 9 | abortStream, |
| 10 | 10 | addPromptCompletionPair, |
| 11 | + setActive, | |
| 12 | + setInactive, | |
| 11 | 13 | setToolGenerated, |
| 12 | 14 | streamUpdate, |
| 13 | 15 | } from "../slices/sessionSlice"; |
| @@ -53,6 +55,8 @@ | ||
| 53 | 55 | }; |
| 54 | 56 | } |
| 55 | 57 | |
| 58 | + dispatch(setActive()); | |
| 59 | + | |
| 56 | 60 | // Send request |
| 57 | 61 | const gen = extra.ideMessenger.llmStreamChat( |
| 58 | 62 | { |
| @@ -76,6 +80,8 @@ | ||
| 76 | 80 | next = await gen.next(); |
| 77 | 81 | } |
| 78 | 82 | |
| 83 | + dispatch(setInactive()); | |
| 84 | + | |
| 79 | 85 | // Attach prompt log and end thinking for reasoning models |
| 80 | 86 | if (next.done && next.value) { |
| 81 | 87 | dispatch(addPromptCompletionPair([next.value])); |
modified gui/src/redux/thunks/streamResponseAfterToolCall.ts +1 −7
| @@ -4,11 +4,7 @@ | ||
| 4 | 4 | import { renderContextItems } from "core/util/messageContent"; |
| 5 | 5 | import { getBaseSystemMessage } from "../../util"; |
| 6 | 6 | import { selectSelectedChatModel } from "../slices/configSlice"; |
| 7 | -import { | |
| 8 | - addContextItemsAtIndex, | |
| 9 | - setActive, | |
| 10 | - streamUpdate, | |
| 11 | -} from "../slices/sessionSlice"; | |
| 7 | +import { addContextItemsAtIndex, streamUpdate } from "../slices/sessionSlice"; | |
| 12 | 8 | import { ThunkApiType } from "../store"; |
| 13 | 9 | import { findToolCall } from "../util"; |
| 14 | 10 | import { resetStateForNewMessage } from "./resetStateForNewMessage"; |
| @@ -63,8 +59,6 @@ | ||
| 63 | 59 | }), |
| 64 | 60 | ); |
| 65 | 61 | |
| 66 | - dispatch(setActive()); | |
| 67 | - | |
| 68 | 62 | const updatedHistory = getState().session.history; |
| 69 | 63 | const messageMode = getState().session.mode; |
| 70 | 64 |
modified gui/src/redux/thunks/streamThunkWrapper.tsx +0 −2
| @@ -1,6 +1,5 @@ | ||
| 1 | 1 | import { createAsyncThunk } from "@reduxjs/toolkit"; |
| 2 | 2 | import StreamErrorDialog from "../../pages/gui/StreamError"; |
| 3 | -import { setInactive } from "../slices/sessionSlice"; | |
| 4 | 3 | import { setDialogMessage, setShowDialog } from "../slices/uiSlice"; |
| 5 | 4 | import { ThunkApiType } from "../store"; |
| 6 | 5 | import { cancelStream } from "./cancelStream"; |
| @@ -22,7 +21,6 @@ | ||
| 22 | 21 | }), |
| 23 | 22 | ); |
| 24 | 23 | } |
| 25 | - dispatch(setInactive()); | |
| 26 | 24 | } catch (e) { |
| 27 | 25 | dispatch(cancelStream()); |
| 28 | 26 | dispatch(setDialogMessage(<StreamErrorDialog error={e} />)); |
modified gui/src/util/clientTools/callClientTool.ts +0 −1
| @@ -9,7 +9,6 @@ | ||
| 9 | 9 | getState: () => RootState; |
| 10 | 10 | dispatch: AppThunkDispatch; |
| 11 | 11 | ideMessenger: IIdeMessenger; |
| 12 | - streamId?: string; | |
| 13 | 12 | } |
| 14 | 13 | |
| 15 | 14 | export interface ClientToolOutput { |
modified gui/src/util/clientTools/editImpl.ts +5 −24
| @@ -1,14 +1,11 @@ | ||
| 1 | 1 | import { resolveRelativePathInDir } from "core/util/ideUtils"; |
| 2 | +import { v4 as uuid } from "uuid"; | |
| 2 | 3 | import { ClientToolImpl } from "./callClientTool"; |
| 3 | - | |
| 4 | 4 | export const editToolImpl: ClientToolImpl = async ( |
| 5 | 5 | args, |
| 6 | 6 | toolCallId, |
| 7 | 7 | extras, |
| 8 | 8 | ) => { |
| 9 | - if (!extras.streamId) { | |
| 10 | - throw new Error("Invalid apply state"); | |
| 11 | - } | |
| 12 | 9 | const firstUriMatch = await resolveRelativePathInDir( |
| 13 | 10 | args.filepath, |
| 14 | 11 | extras.ideMessenger.ide, |
| @@ -16,30 +13,14 @@ | ||
| 16 | 13 | if (!firstUriMatch) { |
| 17 | 14 | throw new Error(`${args.filepath} does not exist`); |
| 18 | 15 | } |
| 19 | - const apply = await extras.ideMessenger.request("applyToFile", { | |
| 20 | - streamId: extras.streamId, | |
| 16 | + const streamId = uuid(); | |
| 17 | + extras.ideMessenger.post("applyToFile", { | |
| 18 | + streamId, | |
| 21 | 19 | text: args.changes, |
| 22 | 20 | toolCallId, |
| 23 | 21 | filepath: firstUriMatch, |
| 24 | 22 | }); |
| 25 | - if (apply.status === "error") { | |
| 26 | - throw new Error(apply.error); | |
| 27 | - } | |
| 28 | - const state = extras.getState(); | |
| 29 | - const autoAccept = !!state.config.config.ui?.autoAcceptEditToolDiffs; | |
| 30 | - if (autoAccept) { | |
| 31 | - const out = await extras.ideMessenger.request("acceptDiff", { | |
| 32 | - streamId: extras.streamId, | |
| 33 | - filepath: firstUriMatch, | |
| 34 | - }); | |
| 35 | - if (out.status === "error") { | |
| 36 | - throw new Error(out.error); | |
| 37 | - } | |
| 38 | - return { | |
| 39 | - respondImmediately: true, | |
| 40 | - output: undefined, // TODO - feed edit results back to model (also in parallel listeners) | |
| 41 | - }; | |
| 42 | - } | |
| 23 | + | |
| 43 | 24 | return { |
| 44 | 25 | respondImmediately: false, |
| 45 | 26 | output: undefined, // No immediate output. |
added gui/src/util/test/config.ts +67 −0
| @@ -0,0 +1,67 @@ | ||
| 1 | +import { EnhancedStore } from "@reduxjs/toolkit"; | |
| 2 | +import { BrowserSerializedContinueConfig, ModelDescription } from "core"; | |
| 3 | +import { SerializedOrgWithProfiles } from "core/config/ProfileLifecycleManager"; | |
| 4 | +import { copyOf } from "core/util"; | |
| 5 | +import { MockIdeMessenger } from "../../context/MockIdeMessenger"; | |
| 6 | + | |
| 7 | +interface TestConfigUpdateParams { | |
| 8 | + store: EnhancedStore; | |
| 9 | + ideMessenger: MockIdeMessenger; | |
| 10 | + newProfileId?: string; | |
| 11 | + newOrgId?: string; | |
| 12 | + newOrgs?: SerializedOrgWithProfiles[]; | |
| 13 | + editConfig?: ( | |
| 14 | + current: BrowserSerializedContinueConfig, | |
| 15 | + ) => BrowserSerializedContinueConfig; | |
| 16 | +} | |
| 17 | + | |
| 18 | +export function triggerConfigUpdate({ | |
| 19 | + store, | |
| 20 | + ideMessenger, | |
| 21 | + editConfig, | |
| 22 | + newOrgs, | |
| 23 | + newOrgId, | |
| 24 | + newProfileId, | |
| 25 | +}: TestConfigUpdateParams) { | |
| 26 | + const state = store.getState(); | |
| 27 | + ideMessenger.mockMessageToWebview("configUpdate", { | |
| 28 | + organizations: newOrgs ?? state.profiles.organizations, | |
| 29 | + selectedOrgId: newOrgId ?? state.profiles.selectedOrganizationId, | |
| 30 | + profileId: newProfileId ?? state.profiles.selectedProfileId, | |
| 31 | + result: { | |
| 32 | + config: editConfig | |
| 33 | + ? editConfig(copyOf(state.config.config)) | |
| 34 | + : state.config.config, | |
| 35 | + configLoadInterrupted: false, | |
| 36 | + errors: [], | |
| 37 | + }, | |
| 38 | + }); | |
| 39 | +} | |
| 40 | + | |
| 41 | +export function addAndSelectChatModel( | |
| 42 | + store: EnhancedStore, | |
| 43 | + ideMessenger: MockIdeMessenger, | |
| 44 | + llmDesc: ModelDescription, | |
| 45 | +) { | |
| 46 | + triggerConfigUpdate({ | |
| 47 | + store, | |
| 48 | + ideMessenger, | |
| 49 | + editConfig(current) { | |
| 50 | + current.modelsByRole.chat.push(llmDesc); | |
| 51 | + current.selectedModelByRole.chat = llmDesc; | |
| 52 | + return current; | |
| 53 | + }, | |
| 54 | + }); | |
| 55 | +} | |
| 56 | + | |
| 57 | +export function addAndSelectMockLlm( | |
| 58 | + store: EnhancedStore, | |
| 59 | + ideMessenger: MockIdeMessenger, | |
| 60 | +) { | |
| 61 | + addAndSelectChatModel(store, ideMessenger, { | |
| 62 | + model: "mock", | |
| 63 | + provider: "mock", | |
| 64 | + title: "Mock LLM", | |
| 65 | + underlyingProviderName: "mock", | |
| 66 | + }); | |
| 67 | +} |
added gui/src/util/test/utils.ts +102 −0
| @@ -0,0 +1,102 @@ | ||
| 1 | +import { screen, waitFor } from "@testing-library/dom"; | |
| 2 | +import { act } from "@testing-library/react"; | |
| 3 | +import { Editor } from "@tiptap/core"; | |
| 4 | +import { ChatMessage } from "core"; | |
| 5 | +import { MockIdeMessenger } from "../../context/MockIdeMessenger"; | |
| 6 | + | |
| 7 | +function logDomText() { | |
| 8 | + const bodyText = document.body.innerHTML; | |
| 9 | + const parser = new DOMParser(); | |
| 10 | + const doc = parser.parseFromString(bodyText, "text/html"); | |
| 11 | + let cleaned = doc.body.textContent ?? ""; | |
| 12 | + cleaned = cleaned?.replace( | |
| 13 | + "No resultsAaModelsRulesDocsPromptsToolsMCPCreate your first assistant", | |
| 14 | + "", | |
| 15 | + ); | |
| 16 | + cleaned = cleaned?.replace( | |
| 17 | + "Alt⏎ Active file⏎ Enter⏎Log in to access a free trial of theModels Add-OnLog in to Continue HubOr, configure your own models", | |
| 18 | + "", | |
| 19 | + ); | |
| 20 | + cleaned = cleaned.replaceAll("Select model", ""); | |
| 21 | + cleaned = cleaned.replaceAll("Mock LLM", ""); | |
| 22 | + cleaned = cleaned.replaceAll(/^Chat|Chat$/g, ""); | |
| 23 | + console.log(cleaned || "No body content"); | |
| 24 | +} | |
| 25 | + | |
| 26 | +export function logAllTestIds() { | |
| 27 | + const elements = document.querySelectorAll("*"); | |
| 28 | + | |
| 29 | + const testIds = Array.from(elements) | |
| 30 | + .map((el) => Array.from(el.attributes)) | |
| 31 | + .flat() | |
| 32 | + .filter((a) => a.name === "data-testid") | |
| 33 | + .map((a) => a.value); | |
| 34 | + console.log("Available test ids", testIds); | |
| 35 | +} | |
| 36 | +export async function getElementByTestId(testId: string): Promise<HTMLElement> { | |
| 37 | + try { | |
| 38 | + const testIdElement = await waitFor(() => screen.findByTestId(testId)); | |
| 39 | + expect(testIdElement).toBeInTheDocument(); | |
| 40 | + return testIdElement; | |
| 41 | + } catch (e) { | |
| 42 | + logAllTestIds(); | |
| 43 | + throw new Error(`Element with testId "${testId}" not found`); | |
| 44 | + } | |
| 45 | +} | |
| 46 | + | |
| 47 | +export async function verifyNotPresentByTestId(testId: string): Promise<void> { | |
| 48 | + const element = await waitFor(() => screen.queryByTestId(testId)); | |
| 49 | + expect(element).not.toBeInTheDocument(); | |
| 50 | +} | |
| 51 | + | |
| 52 | +export async function verifyNotPresentByText(text: string): Promise<void> { | |
| 53 | + const element = screen.queryByText(text); | |
| 54 | + expect(element).not.toBeInTheDocument(); | |
| 55 | +} | |
| 56 | + | |
| 57 | +export async function getElementByText(text: string): Promise<HTMLElement> { | |
| 58 | + try { | |
| 59 | + const textElement = await waitFor(() => screen.findByText(text)); | |
| 60 | + expect(textElement).toBeInTheDocument(); | |
| 61 | + return textElement; | |
| 62 | + } catch (e) { | |
| 63 | + logDomText(); | |
| 64 | + throw new Error(`Element with text "${text}" not found.`); | |
| 65 | + } | |
| 66 | +} | |
| 67 | + | |
| 68 | +export async function getMainEditor(): Promise<Editor> { | |
| 69 | + const editorElement = await getElementByTestId("editor-input-main"); | |
| 70 | + if ("editor" in editorElement) { | |
| 71 | + return editorElement.editor as Editor; | |
| 72 | + } else { | |
| 73 | + throw new Error("Main editor not found within editor container"); | |
| 74 | + } | |
| 75 | +} | |
| 76 | + | |
| 77 | +export async function sendInputWithMockedResponse( | |
| 78 | + ideMessenger: MockIdeMessenger, | |
| 79 | + input: string, | |
| 80 | + response: ChatMessage[], | |
| 81 | +): Promise<void> { | |
| 82 | + // Setup the mock response before any actions | |
| 83 | + ideMessenger.chatResponse = response; | |
| 84 | + | |
| 85 | + // Wait for the editor to be in the document | |
| 86 | + const editor = await getMainEditor(); | |
| 87 | + | |
| 88 | + // Find the submit button | |
| 89 | + const sendButton = await getElementByTestId("submit-input-button"); | |
| 90 | + | |
| 91 | + // Insert content into the editor | |
| 92 | + await act(async () => { | |
| 93 | + editor.commands.insertContent(input); | |
| 94 | + }); | |
| 95 | + | |
| 96 | + await getElementByText(input); | |
| 97 | + | |
| 98 | + // Click the send button | |
| 99 | + await act(async () => { | |
| 100 | + sendButton.click(); | |
| 101 | + }); | |
| 102 | +} |
modified gui/vite.config.ts +13 −0
| @@ -32,5 +32,18 @@ | ||
| 32 | 32 | globals: true, |
| 33 | 33 | environment: "jsdom", |
| 34 | 34 | setupFiles: "./src/util/test/setupTests.ts", |
| 35 | + onConsoleLog(log, type) { | |
| 36 | + if (type === "stderr") { | |
| 37 | + if ( | |
| 38 | + [ | |
| 39 | + "contentEditable", | |
| 40 | + "An update to Chat inside a test was not wrapped in act", | |
| 41 | + ].some((text) => log.includes(text)) | |
| 42 | + ) { | |
| 43 | + return false; | |
| 44 | + } | |
| 45 | + } | |
| 46 | + return true; | |
| 47 | + }, | |
| 35 | 48 | }, |
| 36 | 49 | }); |
added packages/config-yaml/CHANGELOG.md +0 −0
Not shown: the file is larger than the hub shows, or this page holds as much as it shows. View the file.
modified packages/config-yaml/package-lock.json +0 −0
Not shown: the file is larger than the hub shows, or this page holds as much as it shows. View the file.
modified packages/config-yaml/package.json +8 −3
| @@ -1,6 +1,6 @@ | ||
| 1 | 1 | { |
| 2 | 2 | "name": "@continuedev/config-yaml", |
| 3 | - "version": "1.0.94", | |
| 3 | + "version": "1.0.95", | |
| 4 | 4 | "description": "", |
| 5 | 5 | "main": "dist/index.js", |
| 6 | 6 | "types": "dist/index.d.ts", |
| @@ -13,7 +13,7 @@ | ||
| 13 | 13 | } |
| 14 | 14 | }, |
| 15 | 15 | "bin": { |
| 16 | - "@continuedev/config-yaml": "./dist/cli.js" | |
| 16 | + "config-yaml": "./dist/cli.js" | |
| 17 | 17 | }, |
| 18 | 18 | "scripts": { |
| 19 | 19 | "test": "cross-env NODE_OPTIONS=--experimental-vm-modules jest", |
| @@ -34,6 +34,11 @@ | ||
| 34 | 34 | "jest": "^29.7.0", |
| 35 | 35 | "ts-jest": "^29.2.3", |
| 36 | 36 | "ts-node": "^10.9.2", |
| 37 | - "zod-to-json-schema": "^3.24.5" | |
| 37 | + "zod-to-json-schema": "^3.24.5", | |
| 38 | + "@semantic-release/changelog": "^6.0.3", | |
| 39 | + "@semantic-release/git": "^10.0.1", | |
| 40 | + "@semantic-release/github": "^9.2.6", | |
| 41 | + "@semantic-release/npm": "^10.0.6", | |
| 42 | + "semantic-release": "^21.1.2" | |
| 38 | 43 | } |
| 39 | 44 | } |
modified packages/config-yaml/release.config.js +3 −9
| @@ -1,9 +1,3 @@ | ||
| 1 | -export default { | |
| 2 | - branches: ["main"], | |
| 3 | - plugins: [ | |
| 4 | - "@semantic-release/commit-analyzer", | |
| 5 | - "@semantic-release/release-notes-generator", | |
| 6 | - "@semantic-release/npm", | |
| 7 | - "@semantic-release/github", | |
| 8 | - ], | |
| 9 | -}; | |
| 1 | +import createReleaseConfig from "../shared-release.config.js"; | |
| 2 | + | |
| 3 | +export default createReleaseConfig("config-yaml"); |
added packages/fetch/release.config.js +3 −0
| @@ -0,0 +1,3 @@ | ||
| 1 | +import createReleaseConfig from "../shared-release.config.js"; | |
| 2 | + | |
| 3 | +export default createReleaseConfig("fetch"); |
added packages/llm-info/release.config.js +3 −0
| @@ -0,0 +1,3 @@ | ||
| 1 | +import createReleaseConfig from "../shared-release.config.js"; | |
| 2 | + | |
| 3 | +export default createReleaseConfig("llm-info"); |
modified packages/openai-adapters/package-lock.json +2 −2
| @@ -1,12 +1,12 @@ | ||
| 1 | 1 | { |
| 2 | 2 | "name": "@continuedev/openai-adapters", |
| 3 | - "version": "1.0.40", | |
| 3 | + "version": "1.0.42", | |
| 4 | 4 | "lockfileVersion": 3, |
| 5 | 5 | "requires": true, |
| 6 | 6 | "packages": { |
| 7 | 7 | "": { |
| 8 | 8 | "name": "@continuedev/openai-adapters", |
| 9 | - "version": "1.0.40", | |
| 9 | + "version": "1.0.42", | |
| 10 | 10 | "license": "Apache-2.0", |
| 11 | 11 | "dependencies": { |
| 12 | 12 | "@continuedev/config-types": "^1.0.5", |
modified packages/openai-adapters/package.json +1 −1
| @@ -1,6 +1,6 @@ | ||
| 1 | 1 | { |
| 2 | 2 | "name": "@continuedev/openai-adapters", |
| 3 | - "version": "1.0.40", | |
| 3 | + "version": "1.0.42", | |
| 4 | 4 | "description": "", |
| 5 | 5 | "main": "dist/index.js", |
| 6 | 6 | "types": "dist/index.d.ts", |
added packages/openai-adapters/release.config.js +3 −0
| @@ -0,0 +1,3 @@ | ||
| 1 | +import createReleaseConfig from "../shared-release.config.js"; | |
| 2 | + | |
| 3 | +export default createReleaseConfig("openai-adapters"); |
modified packages/openai-adapters/src/apis/Azure.ts +5 −1
| @@ -63,7 +63,11 @@ | ||
| 63 | 63 | "`env.apiVersion` is a required configuration property for Azure OpenAI", |
| 64 | 64 | ); |
| 65 | 65 | } |
| 66 | - url.pathname = `${url.pathname}/openai/deployments/${config.env.deployment}`; | |
| 66 | + | |
| 67 | + const basePathname = `openai/deployments/${config.env.deployment}`; | |
| 68 | + | |
| 69 | + url.pathname = | |
| 70 | + url.pathname === "/" ? basePathname : `${url.pathname}/${basePathname}`; | |
| 67 | 71 | |
| 68 | 72 | queryParams["api-version"] = config.env.apiVersion; |
| 69 | 73 | } |
modified packages/openai-adapters/src/test/main.test.ts +76 −0
| @@ -173,4 +173,80 @@ | ||
| 173 | 173 | "https://api.example.com", |
| 174 | 174 | ); |
| 175 | 175 | }); |
| 176 | + | |
| 177 | + it("should configure Azure OpenAI client with root URL and trailing slash", () => { | |
| 178 | + const azure = constructLlmApi({ | |
| 179 | + provider: "azure", | |
| 180 | + apiKey: "sk-xxx", | |
| 181 | + apiBase: "https://test-azure-openai.azure.com/", | |
| 182 | + env: { | |
| 183 | + deployment: "gpt-4.1", | |
| 184 | + apiType: "azure-openai", | |
| 185 | + apiVersion: "2023-05-15", | |
| 186 | + }, | |
| 187 | + }); | |
| 188 | + | |
| 189 | + // The Azure client modifies the baseURL to include the deployment | |
| 190 | + expect((azure as OpenAIApi).openai.baseURL).toBe( | |
| 191 | + "https://test-azure-openai.azure.com/openai/deployments/gpt-4.1", | |
| 192 | + ); | |
| 193 | + expect((azure as OpenAIApi).openai.apiKey).toBe("sk-xxx"); | |
| 194 | + }); | |
| 195 | + | |
| 196 | + it("should configure Azure OpenAI client with path and trailing slash", () => { | |
| 197 | + const azure = constructLlmApi({ | |
| 198 | + provider: "azure", | |
| 199 | + apiKey: "sk-xxx", | |
| 200 | + apiBase: "https://test-azure-openai.azure.com/v1/", | |
| 201 | + env: { | |
| 202 | + deployment: "gpt-4.1", | |
| 203 | + apiType: "azure-openai", | |
| 204 | + apiVersion: "2023-05-15", | |
| 205 | + }, | |
| 206 | + }); | |
| 207 | + | |
| 208 | + // The Azure client modifies the baseURL to include the deployment | |
| 209 | + expect((azure as OpenAIApi).openai.baseURL).toBe( | |
| 210 | + "https://test-azure-openai.azure.com/v1/openai/deployments/gpt-4.1", | |
| 211 | + ); | |
| 212 | + expect((azure as OpenAIApi).openai.apiKey).toBe("sk-xxx"); | |
| 213 | + }); | |
| 214 | + | |
| 215 | + it("should configure Azure OpenAI client with root URL and no trailing slash", () => { | |
| 216 | + const azure = constructLlmApi({ | |
| 217 | + provider: "azure", | |
| 218 | + apiKey: "sk-xxx", | |
| 219 | + apiBase: "https://test-azure-openai.azure.com", | |
| 220 | + env: { | |
| 221 | + deployment: "gpt-4.1", | |
| 222 | + apiType: "azure-openai", | |
| 223 | + apiVersion: "2023-05-15", | |
| 224 | + }, | |
| 225 | + }); | |
| 226 | + | |
| 227 | + // The Azure client modifies the baseURL to include the deployment | |
| 228 | + expect((azure as OpenAIApi).openai.baseURL).toBe( | |
| 229 | + "https://test-azure-openai.azure.com/openai/deployments/gpt-4.1", | |
| 230 | + ); | |
| 231 | + expect((azure as OpenAIApi).openai.apiKey).toBe("sk-xxx"); | |
| 232 | + }); | |
| 233 | + | |
| 234 | + it("should configure Azure OpenAI client with path and no trailing slash", () => { | |
| 235 | + const azure = constructLlmApi({ | |
| 236 | + provider: "azure", | |
| 237 | + apiKey: "sk-xxx", | |
| 238 | + apiBase: "https://test-azure-openai.azure.com/v1", | |
| 239 | + env: { | |
| 240 | + deployment: "gpt-4.1", | |
| 241 | + apiType: "azure-openai", | |
| 242 | + apiVersion: "2023-05-15", | |
| 243 | + }, | |
| 244 | + }); | |
| 245 | + | |
| 246 | + // The Azure client modifies the baseURL to include the deployment | |
| 247 | + expect((azure as OpenAIApi).openai.baseURL).toBe( | |
| 248 | + "https://test-azure-openai.azure.com/v1/openai/deployments/gpt-4.1", | |
| 249 | + ); | |
| 250 | + expect((azure as OpenAIApi).openai.apiKey).toBe("sk-xxx"); | |
| 251 | + }); | |
| 176 | 252 | }); |
added packages/shared-release.config.js +34 −0
| @@ -0,0 +1,34 @@ | ||
| 1 | +export default function createReleaseConfig(packageName) { | |
| 2 | + return { | |
| 3 | + branches: ["main"], | |
| 4 | + tagFormat: `@continuedev/${packageName}@\${version}`, | |
| 5 | + plugins: [ | |
| 6 | + [ | |
| 7 | + "@semantic-release/commit-analyzer", | |
| 8 | + { | |
| 9 | + releaseRules: [ | |
| 10 | + { scope: `packages/${packageName}`, release: "patch" }, | |
| 11 | + { scope: `packages/${packageName}`, type: "fix", release: "patch" }, | |
| 12 | + { scope: "packages/config-yaml", type: "feat", release: "minor" }, | |
| 13 | + { | |
| 14 | + scope: `packages/${packageName}`, | |
| 15 | + breaking: true, | |
| 16 | + release: "major", | |
| 17 | + }, | |
| 18 | + ], | |
| 19 | + }, | |
| 20 | + ], | |
| 21 | + "@semantic-release/release-notes-generator", | |
| 22 | + "@semantic-release/changelog", | |
| 23 | + "@semantic-release/npm", | |
| 24 | + [ | |
| 25 | + "@semantic-release/git", | |
| 26 | + { | |
| 27 | + assets: ["CHANGELOG.md", "package.json"], | |
| 28 | + message: `chore(release): @continuedev/${packageName}@\${nextRelease.version} [skip ci]`, | |
| 29 | + }, | |
| 30 | + ], | |
| 31 | + "@semantic-release/github", | |
| 32 | + ], | |
| 33 | + }; | |
| 34 | +} |
added scripts/build-packages.ps1 +13 −0
| @@ -0,0 +1,13 @@ | ||
| 1 | +Push-Location packages | |
| 2 | + | |
| 3 | +Push-Location "openai-adapters" | |
| 4 | +npm ci | |
| 5 | +npm run build | |
| 6 | +Pop-Location | |
| 7 | + | |
| 8 | +Push-Location "config-yaml" | |
| 9 | +npm ci | |
| 10 | +npm run build | |
| 11 | +Pop-Location | |
| 12 | + | |
| 13 | +Pop-Location | |
| No newline at the end of the file |
added scripts/build-packages.sh +13 −0
| @@ -0,0 +1,13 @@ | ||
| 1 | +# Build @continuedev packages for monorepo style linking | |
| 2 | + | |
| 3 | +cd packages | |
| 4 | +cd openai-adapters | |
| 5 | + | |
| 6 | +npm ci | |
| 7 | +npm run build | |
| 8 | + | |
| 9 | +cd .. | |
| 10 | +cd config-yaml | |
| 11 | + | |
| 12 | +npm ci | |
| 13 | +npm run build |
added scripts/create-docker-ssh-container.sh +35 −0
| @@ -0,0 +1,35 @@ | ||
| 1 | +# create the docker file | |
| 2 | + | |
| 3 | +cat > Dockerfile << 'EOF' | |
| 4 | +FROM ubuntu:latest | |
| 5 | +ENV DEBIAN_FRONTEND=noninteractive | |
| 6 | +# Install SSH server | |
| 7 | +RUN apt-get update && apt-get install -y openssh-server | |
| 8 | +# Configure SSH | |
| 9 | +RUN mkdir /var/run/sshd | |
| 10 | +RUN echo 'root:my_password' | chpasswd | |
| 11 | +# Allow root login | |
| 12 | +RUN sed -i 's/#PermitRootLogin prohibit-password/PermitRootLogin yes/' /etc/ssh/sshd_config | |
| 13 | +# SSH login fix | |
| 14 | +RUN sed 's@session\s*required\s*pam_loginuid.so@session optional pam_loginuid.so@g' -i /etc/pam.d/sshd | |
| 15 | +EXPOSE 22 | |
| 16 | +CMD ["/usr/sbin/sshd", "-D"] | |
| 17 | +EOF | |
| 18 | + | |
| 19 | +docker build -t continue-ubuntu-ssh . # build the image | |
| 20 | + | |
| 21 | +rm Dockerfile # remove the created Dockerfile | |
| 22 | + | |
| 23 | +container_name="continue-ssh-container" | |
| 24 | + | |
| 25 | +docker run -d -p 2222:22 --name $container_name continue-ubuntu-ssh # run the container | |
| 26 | + | |
| 27 | +echo "docker container ${container_name} running on port 2222" | |
| 28 | + | |
| 29 | +# add the instructions | |
| 30 | +bold=$(tput bold) | |
| 31 | +normal=$(tput sgr0) | |
| 32 | + | |
| 33 | +echo "\n--------------------------------------" | |
| 34 | +echo "now ssh into vscode (using remote explorer) with the following command: ${bold}ssh root@localhost -p 2222${normal}" | |
| 35 | +echo "use the following password - \"${bold}my_password${normal}\"" |