From ed37dcfb7ab98d7a70759991cbf4abe868beea89 Mon Sep 17 00:00:00 2001 From: Nate Sesti <33237525+sestinj@users.noreply.github.com> Date: Fri, 12 Jul 2024 00:49:24 -0700 Subject: [PATCH] cmd+I improvements (#1728) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Nate/control plane client (#1691) * docs: add docs and schema for "OS" provider (#1536) * ignore .env * fix(gui): ctx rendering w/ renderInlineAs: "" (#1541) * ✨ use and cache imports for autocomplete (#1456) * ✨ use and cache imports for autocomplete * fix tsc * fix codeqwen autocomplete leading space * add voyage rerank-1 * feat: `--noEmit` for tsc checks in CI (#1559) * docs: update CustomContextProvider docs (#1557) * add stop tokens to qwen prompt * update docs to reflect 3.5 sonnet being best * docs: comment out unused providers (#1561) * import Handlebars * feat: toast notification for config updates (#1560) * feat: toast notification for config updates * feat: only trigger toast on config.json save * displayRawMarkdown option * feat: open pane on install (#1564) * feat: open pane on activation * comment out testing code * update to reflect 16 stop words limit for deepseek * feat: only trigger config update toast in vscode (#1571) * docs(prompt-files): fix typos + clarify (#1575) * doc: prompt file typo + clarifications * fix: add back correct docs * chore: add telemetry for pageviews (#1576) * feat: update onboarding w/ embeddings model (#1570) * chore(gui): remove unused pages * feat: add embeddings step * feat: update styles * feat: copy button updates * fix: correct pull command for embed model * fix: remove commented code * fix: remove commented code * feat: simplify copy btn props * chore: rename onboarding selection event * feat: add provider config * fix: undo msg name * remove dead code * fix: invalid mode check * fix: remove testing logic * docs(telemetry): add pageviews to tracking list (#1581) * Add reranker configuration options to codebase embedding docs (#1584) - Introduce reranker concept - List available reranker options - Provide configuration instructions - Update keywords to include "reranker" * chore: update pr template with screenshots (#1590) * Refactor ConfirmationDialog to use SecondaryButton for cancel action (#1586) * Added instructions for running docs server locally (#1578) - Added NPM script method - Added VS Code task method - Update contributing guidelines * Update branch policy (#1577) - Change PR target to `dev` branch - Update `CONTRIBUTING.md` instructions * Consolidate example configurations into the main configuration guide (#1579) - Moved examples to configuration.md - Deleted the separate examples.md file - Updated sidebar order and links - Improved readability and structure in configuration.md * fix: fullscreen gui retains context when hidden, fixed fullscreen focusing (#1582) * Update completionProvider.ts (warning tab-autocomplete models) (#1566) * feat: enhanced IndexingProgressBar with blinking dot feature - Integrated BlinkingDot component - Added STATUS_COLORS for various states - Replaced CircleDiv with BlinkingDot in UI - Updated status messages and layout * small UI tweaks * feat(gui): enhance ModelCard, ModelProviderTag, and Toggle components (#1595) - add styling and adjustments to ModelCard - update ModelProviderTag font size - remove box shadow from Toggle component - tweak icon styles in ModelCard - improve alignment and spacing * media query * feat: add best experience onboarding * fix: file rename * stop movement on button hover by keeping same border thickness * fix mistake in setting cursor: pointer * fix when free trial option is shown * Support Node.js versions below 20 for streaming response handling (#1591) - Add fallback for Node < 20 - Implement toAsyncIterable for streaming - Use TextDecoder for manual decoding - Maintain existing streaming for Node 20+ * small fixes * feat: add free trial card to onboarding (#1600) * feat: add free trial card to onboarding * add import * fix hasPassedFTL * fix /edit cancellation from UI * feat: add `applyCodeBlock` experimental prop (#1601) * feat: add new model styling improvements (#1609) * feat: add new model styling improvements * better gap size * feat: update bug_report.yml (#1610) * chore: update bug_report.yml * typo fix * feat: add labels to "Add docs" dialog (#1612) * feat: add labels to "Add docs" dialog * remove autofocus * don't double load config * small fixes * speed up directory traversal, and use correct native path module * option not to show config update toast * merge air-gapped and recommended setup pages * chore: add telemetry for full screen toggle (#1618) * Fix headings in codebase-embeddings.md (#1617) * mention jetbrains * docs: update changie (#1619) * feat: updated changie config * hide toc and autogenerate * Update changelog.mdx * link to deeper explanation of embeddings models * ensure target="_blank" for all links in sidebar * fix gif links in intellij README.md * don't require rust in dependency installation * chore: fix padding on gh button (#1620) * chore: adjust button padding * Update tasks.json * escape colons in diff path * smoother lancedb indexing reporting * smooth progress updates for indexing * fix tsc err * rerank-lite-1 * remove doccs * basic tests for VS Code extension * improved testing of VS Code extension * docs: add docs and schema for "OS" provider (#1536) * ignore .env * πŸš‘ fix constant warnings when onboarding with Ollama * ✨ use and cache imports for autocomplete (#1456) * ✨ use and cache imports for autocomplete * fix tsc * team analytics * apply control plane settings * workos auth * ide protocol get session info * UI for auth * profile switching * small fixes * updates * refresh tokens * updates * fix tsc errs * model select in toolbar to make room for profile selector * prod client id * link to prod URL * internal beta option * profiles change listener --------- Co-authored-by: Patrick Erichsen Co-authored-by: Priyash <38959321+priyashpatil@users.noreply.github.com> Co-authored-by: Jonah Wagner Co-authored-by: YohannZe <99359799+YohannZe@users.noreply.github.com> Co-authored-by: Dan Dascalescu * temporary patch for type errs * Dev (#1689) * Fix an issue where CMD+K does not clear the terminal when the terminal has focus (#1671) On MacOS, ⌘+K is bound, by default, to Terminal:Clear. Without this change ⌘+K does not clear the terminal but instead iniates a chord sequence and waits for the next stroke of the chord. Co-authored-by: Rob Leidle * Change treeSitter to cache the Language objects it loads from wasm (#1672) Without this change, for a repository with 600 typescript files, the indexer would fail to finish correctly and there would be many of the following errors in the webview console log: 'Unable to load language for file ${path} RuntimeError: table index is out of bounds' The following bash will create a repo that reproduces the problem: current_path="." for ((i=1; i<=20; i++)); do new_folder="folder-$i" mkdir -p "$current_path/$new_folder" current_path="$current_path/$new_folder" for ((a=1; a<=30; a++)); do head -c 10000 /dev/urandom | base64 > "$current_path/file-$a.ts" done done Co-authored-by: Rob Leidle * acknowledge sourcemap flag in esbuild.js * don't run jetbrains-release.yaml on vscode releases * further testing for walkDir * chore: add telemetry to commands (#1673) * test: Add basic unit test to baseLLM (#1668) * update version * test: Add basic unit test to baseLLM --------- Co-authored-by: Nate Sesti Co-authored-by: inimaz * feat: add Quick Actions CodeLens feature (#1674) * docs: add docs and schema for "OS" provider (#1536) * ignore .env * ✨ use and cache imports for autocomplete (#1456) * ✨ use and cache imports for autocomplete * fix tsc * add voyage rerank-1 * import Handlebars * feat: open pane on install (#1564) * feat: open pane on activation * comment out testing code * chore: add telemetry for pageviews (#1576) * feat: update onboarding w/ embeddings model (#1570) * chore(gui): remove unused pages * feat: add embeddings step * feat: update styles * feat: copy button updates * fix: correct pull command for embed model * fix: remove commented code * fix: remove commented code * feat: simplify copy btn props * chore: rename onboarding selection event * feat: add provider config * fix: undo msg name * remove dead code * fix: invalid mode check * fix: remove testing logic * fix: fullscreen gui retains context when hidden, fixed fullscreen focusing (#1582) * small UI tweaks * media query * feat: add best experience onboarding * small fixes * feat: add free trial card to onboarding (#1600) * feat: add free trial card to onboarding * add import * chore: add telemetry for full screen toggle (#1618) * rerank-lite-1 * remove doccs * basic tests for VS Code extension * improved testing of VS Code extension * manually implement stop tokens for hf inference api * chore: onboarding metrics (#1626) * fix: pageview tracking * feat: add onboarding telemetry * create single `onboardingStatus` type * improved var naming * remove console logs * fix windows performance issue * rename vscodeExtension.ts * migration of onboarding variables * "stash" instead of "delete" in indexing progress * fix preview.yaml * also fix main.yaml * Update troubleshooting.md (#1637) * feat: add quick actions * Update index.d.ts * quick actions mvp * update docs * subscribe to vscode change settings * Update commands.ts * cleanup * Update quick-actions.md * Update VerticalPerLineCodeLensProvider.ts * resolve feedback --------- Co-authored-by: Nate Sesti Co-authored-by: Nate Sesti <33237525+sestinj@users.noreply.github.com> Co-authored-by: Jonah Wagner * chore: add `isCommandEvent` to command telemetry (#1675) * chore: add `isCommandEvent` to command telemetry * Update commands.ts * Nate/better retrieval (#1677) * deduplicatearray tests * break out separate retrieval pipelines * IConfigHandler * tests for codebase indexer * better .continueignore for continue * indexing fixes * ignore .gitignore and .continueignore when indexing * retrieval pipeline improvements * fix formatting err in out .continueignore * add necessary filter to lance_db_cache * update package.json version * skip unused tests * don't ignore .prompt files * update version * Update pull_request_template.md * don't use multi-media format when there are multiple text items * add free trial experience (#1685) * fix: add code range for quick actions/fixes (#1687) * fix: add code range for quick actions/fixes * Update test.js * add pathSep message type * docs improvements * jetbrains fix * update package.json version --------- Co-authored-by: Rob Leidle Co-authored-by: Rob Leidle Co-authored-by: Patrick Erichsen Co-authored-by: inimaz <49730431+inimaz@users.noreply.github.com> Co-authored-by: inimaz Co-authored-by: Jonah Wagner Co-authored-by: Priyash <38959321+priyashpatil@users.noreply.github.com> * update package.json version * skip extension tests * update package.json version * handlebars import * don't push package.json version change from CI * fix: scroll issues w/ code blocks (#1688) * fix: scroll issues w/ code blocks * chore: name offset * chore: remove docs start * chore: update headings on troubleshooting.md (#1696) * ignore .svn folder for indexing (#1699) * chore: clearer naming for `useSuffix` (#1702) * chore: clearer naming for `useSuffix` * schema updates * fix: cmd+shft+l closes sidebar if focused (#1638) * docs: add docs and schema for "OS" provider (#1536) * ignore .env * ✨ use and cache imports for autocomplete (#1456) * ✨ use and cache imports for autocomplete * fix tsc * add voyage rerank-1 * import Handlebars * feat: open pane on install (#1564) * feat: open pane on activation * comment out testing code * chore: add telemetry for pageviews (#1576) * feat: update onboarding w/ embeddings model (#1570) * chore(gui): remove unused pages * feat: add embeddings step * feat: update styles * feat: copy button updates * fix: correct pull command for embed model * fix: remove commented code * fix: remove commented code * feat: simplify copy btn props * chore: rename onboarding selection event * feat: add provider config * fix: undo msg name * remove dead code * fix: invalid mode check * fix: remove testing logic * fix: fullscreen gui retains context when hidden, fixed fullscreen focusing (#1582) * small UI tweaks * media query * feat: add best experience onboarding * small fixes * feat: add free trial card to onboarding (#1600) * feat: add free trial card to onboarding * add import * chore: add telemetry for full screen toggle (#1618) * rerank-lite-1 * remove doccs * basic tests for VS Code extension * improved testing of VS Code extension * manually implement stop tokens for hf inference api * chore: onboarding metrics (#1626) * fix: pageview tracking * feat: add onboarding telemetry * create single `onboardingStatus` type * improved var naming * remove console logs * fix windows performance issue * rename vscodeExtension.ts * migration of onboarding variables * "stash" instead of "delete" in indexing progress * fix preview.yaml * also fix main.yaml * Update troubleshooting.md (#1637) * feat: close panel if main input is focused * add skip param * Update TipTapEditor.tsx * merge dev * Update commands.ts --------- Co-authored-by: Nate Sesti Co-authored-by: Nate Sesti <33237525+sestinj@users.noreply.github.com> Co-authored-by: Jonah Wagner * bugfix: quick actions undefined array (#1704) * feat: add rich quick pick for quick edit (#1706) * feat: multistep quick pick * fix: multi step for context provider * Update test.js * Create deepseek.md (#1708) * style: add max height to model selector (#1712) * update styling * remove testing code * remove comments * feat: add tutorial card (#1716) * feat: create tutorial card * Update TutorialCard.tsx * feat: add file search to quick edit (#1714) * feat: multistep quick pick * fix: multi step for context provider * Update test.js * add file search * complete file search * remove unused import * add comments * Update utils.ts * update naming * chore: move quick pick instantiation (#1723) * Break out into NPM modules (#1726) * config.json types * export all schemas * break out request logic into packages * update openai adapters to export body types * update packaging of npm modules * update packages * continue proxy * mistral * Fix typo in documentation (#1722) In set-up-codestral.md "Trobleshooting" -> "Troubleshooting" * update package.json version * πŸͺ„ model dropdown, control plane (#1692) * Nate/control plane client (#1691) * docs: add docs and schema for "OS" provider (#1536) * ignore .env * fix(gui): ctx rendering w/ renderInlineAs: "" (#1541) * ✨ use and cache imports for autocomplete (#1456) * ✨ use and cache imports for autocomplete * fix tsc * fix codeqwen autocomplete leading space * add voyage rerank-1 * feat: `--noEmit` for tsc checks in CI (#1559) * docs: update CustomContextProvider docs (#1557) * add stop tokens to qwen prompt * update docs to reflect 3.5 sonnet being best * docs: comment out unused providers (#1561) * import Handlebars * feat: toast notification for config updates (#1560) * feat: toast notification for config updates * feat: only trigger toast on config.json save * displayRawMarkdown option * feat: open pane on install (#1564) * feat: open pane on activation * comment out testing code * update to reflect 16 stop words limit for deepseek * feat: only trigger config update toast in vscode (#1571) * docs(prompt-files): fix typos + clarify (#1575) * doc: prompt file typo + clarifications * fix: add back correct docs * chore: add telemetry for pageviews (#1576) * feat: update onboarding w/ embeddings model (#1570) * chore(gui): remove unused pages * feat: add embeddings step * feat: update styles * feat: copy button updates * fix: correct pull command for embed model * fix: remove commented code * fix: remove commented code * feat: simplify copy btn props * chore: rename onboarding selection event * feat: add provider config * fix: undo msg name * remove dead code * fix: invalid mode check * fix: remove testing logic * docs(telemetry): add pageviews to tracking list (#1581) * Add reranker configuration options to codebase embedding docs (#1584) - Introduce reranker concept - List available reranker options - Provide configuration instructions - Update keywords to include "reranker" * chore: update pr template with screenshots (#1590) * Refactor ConfirmationDialog to use SecondaryButton for cancel action (#1586) * Added instructions for running docs server locally (#1578) - Added NPM script method - Added VS Code task method - Update contributing guidelines * Update branch policy (#1577) - Change PR target to `dev` branch - Update `CONTRIBUTING.md` instructions * Consolidate example configurations into the main configuration guide (#1579) - Moved examples to configuration.md - Deleted the separate examples.md file - Updated sidebar order and links - Improved readability and structure in configuration.md * fix: fullscreen gui retains context when hidden, fixed fullscreen focusing (#1582) * Update completionProvider.ts (warning tab-autocomplete models) (#1566) * feat: enhanced IndexingProgressBar with blinking dot feature - Integrated BlinkingDot component - Added STATUS_COLORS for various states - Replaced CircleDiv with BlinkingDot in UI - Updated status messages and layout * small UI tweaks * feat(gui): enhance ModelCard, ModelProviderTag, and Toggle components (#1595) - add styling and adjustments to ModelCard - update ModelProviderTag font size - remove box shadow from Toggle component - tweak icon styles in ModelCard - improve alignment and spacing * media query * feat: add best experience onboarding * fix: file rename * stop movement on button hover by keeping same border thickness * fix mistake in setting cursor: pointer * fix when free trial option is shown * Support Node.js versions below 20 for streaming response handling (#1591) - Add fallback for Node < 20 - Implement toAsyncIterable for streaming - Use TextDecoder for manual decoding - Maintain existing streaming for Node 20+ * small fixes * feat: add free trial card to onboarding (#1600) * feat: add free trial card to onboarding * add import * fix hasPassedFTL * fix /edit cancellation from UI * feat: add `applyCodeBlock` experimental prop (#1601) * feat: add new model styling improvements (#1609) * feat: add new model styling improvements * better gap size * feat: update bug_report.yml (#1610) * chore: update bug_report.yml * typo fix * feat: add labels to "Add docs" dialog (#1612) * feat: add labels to "Add docs" dialog * remove autofocus * don't double load config * small fixes * speed up directory traversal, and use correct native path module * option not to show config update toast * merge air-gapped and recommended setup pages * chore: add telemetry for full screen toggle (#1618) * Fix headings in codebase-embeddings.md (#1617) * mention jetbrains * docs: update changie (#1619) * feat: updated changie config * hide toc and autogenerate * Update changelog.mdx * link to deeper explanation of embeddings models * ensure target="_blank" for all links in sidebar * fix gif links in intellij README.md * don't require rust in dependency installation * chore: fix padding on gh button (#1620) * chore: adjust button padding * Update tasks.json * escape colons in diff path * smoother lancedb indexing reporting * smooth progress updates for indexing * fix tsc err * rerank-lite-1 * remove doccs * basic tests for VS Code extension * improved testing of VS Code extension * docs: add docs and schema for "OS" provider (#1536) * ignore .env * πŸš‘ fix constant warnings when onboarding with Ollama * ✨ use and cache imports for autocomplete (#1456) * ✨ use and cache imports for autocomplete * fix tsc * team analytics * apply control plane settings * workos auth * ide protocol get session info * UI for auth * profile switching * small fixes * updates * refresh tokens * updates * fix tsc errs * model select in toolbar to make room for profile selector * prod client id * link to prod URL * internal beta option * profiles change listener --------- Co-authored-by: Patrick Erichsen Co-authored-by: Priyash <38959321+priyashpatil@users.noreply.github.com> Co-authored-by: Jonah Wagner Co-authored-by: YohannZe <99359799+YohannZe@users.noreply.github.com> Co-authored-by: Dan Dascalescu * temporary patch for type errs --------- Co-authored-by: Patrick Erichsen Co-authored-by: Priyash <38959321+priyashpatil@users.noreply.github.com> Co-authored-by: Jonah Wagner Co-authored-by: YohannZe <99359799+YohannZe@users.noreply.github.com> Co-authored-by: Dan Dascalescu * skip extension tests --------- Co-authored-by: Patrick Erichsen Co-authored-by: Priyash <38959321+priyashpatil@users.noreply.github.com> Co-authored-by: Jonah Wagner Co-authored-by: YohannZe <99359799+YohannZe@users.noreply.github.com> Co-authored-by: Dan Dascalescu Co-authored-by: Rob Leidle Co-authored-by: Rob Leidle Co-authored-by: inimaz <49730431+inimaz@users.noreply.github.com> Co-authored-by: inimaz Co-authored-by: AnaΓ«l Bonnafous <71386173+AnaelBonnafous@users.noreply.github.com> Co-authored-by: Huy Tran <119860259+tranquochuy645@users.noreply.github.com> --- .github/workflows/main.yaml | 28 +- .github/workflows/preview.yaml | 28 +- core/autocomplete/README.md | 2 +- .../profile/ControlPlaneProfileLoader.ts | 24 +- core/config/types.ts | 2 +- core/control-plane/TeamAnalytics.ts | 4 +- core/control-plane/client.ts | 10 +- core/index.d.ts | 2 +- core/indexing/LanceDbIndex.ts | 2 +- core/indexing/ignore.ts | 1 + core/llm/llms/stubs/ContinueProxy.ts | 15 +- core/package-lock.json | 9 + core/package.json | 1 + core/protocol/core.ts | 1 + core/protocol/passThrough.ts | 1 + core/protocol/webview.ts | 1 + core/util/parameters.ts | 2 +- .../reference/Model Providers/deepseek.md | 16 + docs/docs/troubleshooting.md | 16 +- docs/docs/walkthroughs/set-up-codestral.md | 4 +- docs/docs/walkthroughs/tab-autocomplete.md | 2 +- docs/static/schemas/config.json | 2 +- .../src/main/resources/config_schema.json | 2 +- extensions/vscode/config_schema.json | 2 +- extensions/vscode/continue_rc_schema.json | 2 +- extensions/vscode/package-lock.json | 11 +- extensions/vscode/package.json | 15 +- ...l.ts => ContinueGUIWebviewViewProvider.ts} | 5 + extensions/vscode/src/commands.ts | 70 +- .../vscode/src/extension/VsCodeExtension.ts | 16 +- .../providers/QuickActionsCodeLensProvider.ts | 6 +- .../quickEdit/ContextProvidersQuickPick.ts | 88 + .../vscode/src/quickEdit/HistoryQuickPick.ts | 42 + .../src/quickEdit/InputBoxWithHistory.ts | 181 - .../src/quickEdit/ModelSelectionQuickPick.ts | 32 + extensions/vscode/src/quickEdit/QuickEdit.ts | 194 - .../src/quickEdit/QuickEditQuickPick.ts | 410 ++ extensions/vscode/src/quickEdit/index.ts | 0 gui/package-lock.json | 22 +- gui/package.json | 1 + gui/src/components/ChatScrollAnchor.tsx | 32 + gui/src/components/ProfileSwitcher.tsx | 2 +- .../components/dialogs/ConfirmationDialog.tsx | 3 +- gui/src/components/mainInput/TipTapEditor.tsx | 31 +- gui/src/components/mainInput/TutorialCard.tsx | 86 + .../components/modelSelection/ModelSelect.tsx | 114 +- gui/src/hooks/useWebviewListener.ts | 34 +- gui/src/pages/gui.tsx | 124 +- gui/src/pages/onboarding/utils.ts | 1 + gui/src/util/localStorage.ts | 1 + packages/config-types/package-lock.json | 40 + packages/config-types/package.json | 20 + packages/config-types/src/config_schema.json | 2217 ++++++++++ packages/config-types/src/index.ts | 207 + packages/config-types/tsconfig.json | 23 + packages/fetch/jest.config.d.ts | 7 + packages/fetch/jest.config.js | 143 + packages/fetch/jest.config.ts | 199 + packages/fetch/package-lock.json | 3665 +++++++++++++++++ packages/fetch/package.json | 25 + packages/fetch/src/fetch.ts | 117 + packages/fetch/src/index.ts | 8 + packages/fetch/src/stream.ts | 113 + packages/fetch/tsconfig.json | 23 + packages/openai-adapters/package-lock.json | 546 +++ packages/openai-adapters/package.json | 24 + .../openai-adapters/src/apis/AzureOpenAI.ts | 220 + packages/openai-adapters/src/apis/OpenAI.ts | 84 + packages/openai-adapters/src/apis/base.ts | 41 + packages/openai-adapters/src/index.ts | 35 + packages/openai-adapters/tsconfig.json | 23 + 71 files changed, 8842 insertions(+), 638 deletions(-) create mode 100644 docs/docs/reference/Model Providers/deepseek.md rename extensions/vscode/src/{debugPanel.ts => ContinueGUIWebviewViewProvider.ts} (98%) create mode 100644 extensions/vscode/src/quickEdit/ContextProvidersQuickPick.ts create mode 100644 extensions/vscode/src/quickEdit/HistoryQuickPick.ts delete mode 100644 extensions/vscode/src/quickEdit/InputBoxWithHistory.ts create mode 100644 extensions/vscode/src/quickEdit/ModelSelectionQuickPick.ts delete mode 100644 extensions/vscode/src/quickEdit/QuickEdit.ts create mode 100644 extensions/vscode/src/quickEdit/QuickEditQuickPick.ts create mode 100644 extensions/vscode/src/quickEdit/index.ts create mode 100644 gui/src/components/ChatScrollAnchor.tsx create mode 100644 gui/src/components/mainInput/TutorialCard.tsx create mode 100644 packages/config-types/package-lock.json create mode 100644 packages/config-types/package.json create mode 100644 packages/config-types/src/config_schema.json create mode 100644 packages/config-types/src/index.ts create mode 100644 packages/config-types/tsconfig.json create mode 100644 packages/fetch/jest.config.d.ts create mode 100644 packages/fetch/jest.config.js create mode 100644 packages/fetch/jest.config.ts create mode 100644 packages/fetch/package-lock.json create mode 100644 packages/fetch/package.json create mode 100644 packages/fetch/src/fetch.ts create mode 100644 packages/fetch/src/index.ts create mode 100644 packages/fetch/src/stream.ts create mode 100644 packages/fetch/tsconfig.json create mode 100644 packages/openai-adapters/package-lock.json create mode 100644 packages/openai-adapters/package.json create mode 100644 packages/openai-adapters/src/apis/AzureOpenAI.ts create mode 100644 packages/openai-adapters/src/apis/OpenAI.ts create mode 100644 packages/openai-adapters/src/apis/base.ts create mode 100644 packages/openai-adapters/src/index.ts create mode 100644 packages/openai-adapters/tsconfig.json diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml index 414b52f7d..107162244 100644 --- a/.github/workflows/main.yaml +++ b/.github/workflows/main.yaml @@ -231,22 +231,22 @@ jobs: npx ovsx publish -p ${{ secrets.VSX_REGISTRY_TOKEN }} --packagePath ../../alpine-x64/*.vsix ../../darwin-arm64/*.vsix ../../darwin-x64/*.vsix ../../linux-arm64/*.vsix ../../linux-armhf/*.vsix ../../linux-x64/*.vsix ../../win32-x64/*.vsix ../../win32-arm64/*.vsix # 4. Update the package.json version and push changes - - name: Update version in package.json - run: | - cd extensions/vscode - npm version patch + # - name: Update version in package.json + # run: | + # cd extensions/vscode + # npm version patch - - name: Commit changes - run: | - git config --local user.email "action@github.com" - git config --local user.name "GitHub Action" - git commit -am "πŸ’š Update package.json version [skip ci]" + # - name: Commit changes + # run: | + # git config --local user.email "action@github.com" + # git config --local user.name "GitHub Action" + # git commit -am "πŸ’š Update package.json version [skip ci]" - - name: Push changes - uses: ad-m/github-push-action@master - with: - github_token: ${{ secrets.GITHUB_TOKEN }} - branch: ${{ github.ref }} + # - name: Push changes + # uses: ad-m/github-push-action@master + # with: + # github_token: ${{ secrets.GITHUB_TOKEN }} + # branch: ${{ github.ref }} # 5 Send to Discord Webhook - name: Discord Commits diff --git a/.github/workflows/preview.yaml b/.github/workflows/preview.yaml index 9c5c50c33..a04591c89 100644 --- a/.github/workflows/preview.yaml +++ b/.github/workflows/preview.yaml @@ -223,19 +223,19 @@ jobs: npx ovsx publish --pre-release -p ${{ secrets.VSX_REGISTRY_TOKEN }} --packagePath ../../alpine-x64/*.vsix ../../darwin-arm64/*.vsix ../../darwin-x64/*.vsix ../../linux-arm64/*.vsix ../../linux-armhf/*.vsix ../../linux-x64/*.vsix ../../win32-x64/*.vsix ../../win32-arm64/*.vsix # 4. Update the package.json version and push changes - - name: Update version in package.json - run: | - cd extensions/vscode - npm version patch + # - name: Update version in package.json + # run: | + # cd extensions/vscode + # npm version patch - - name: Commit changes - run: | - git config --local user.email "action@github.com" - git config --local user.name "GitHub Action" - git commit -am "πŸ’š Update package.json version [skip ci]" + # - name: Commit changes + # run: | + # git config --local user.email "action@github.com" + # git config --local user.name "GitHub Action" + # git commit -am "πŸ’š Update package.json version [skip ci]" - - name: Push changes - uses: ad-m/github-push-action@master - with: - github_token: ${{ secrets.GITHUB_TOKEN }} - branch: ${{ github.ref }} + # - name: Push changes + # uses: ad-m/github-push-action@master + # with: + # github_token: ${{ secrets.GITHUB_TOKEN }} + # branch: ${{ github.ref }} diff --git a/core/autocomplete/README.md b/core/autocomplete/README.md index c82509cbd..4e25c9fef 100644 --- a/core/autocomplete/README.md +++ b/core/autocomplete/README.md @@ -90,7 +90,7 @@ This is just another object like the ones in the `"models"` array of `config.jso This object allows you to customize the behavior of tab-autocomplete. The available options are: - `useCopyBuffer`: Determines whether the copy buffer will be considered when constructing the prompt. (Boolean) -- `useSuffix`: Determines whether to use the file suffix in the prompt. (Boolean) +- `useFileSuffix`: Determines whether to use the file suffix in the prompt. (Boolean) - `maxPromptTokens`: The maximum number of prompt tokens to use. A smaller number will yield faster completions, but less context. (Number) - `debounceDelay`: The delay in milliseconds before triggering autocomplete after a keystroke. (Number) - `maxSuffixPercentage`: The maximum percentage of the prompt that can be dedicated to the suffix. (Number) diff --git a/core/config/profile/ControlPlaneProfileLoader.ts b/core/config/profile/ControlPlaneProfileLoader.ts index b3e1e3a4f..e8a2762a5 100644 --- a/core/config/profile/ControlPlaneProfileLoader.ts +++ b/core/config/profile/ControlPlaneProfileLoader.ts @@ -1,3 +1,4 @@ +import { ConfigJson } from "@continuedev/config-types"; import { ContinueConfig, IDE, @@ -5,8 +6,8 @@ import { SerializedContinueConfig, } from "../.."; import { ControlPlaneClient } from "../../control-plane/client"; -import { ControlPlaneSettings } from "../../control-plane/schema"; import { TeamAnalytics } from "../../control-plane/TeamAnalytics"; +import ContinueProxy from "../../llm/llms/stubs/ContinueProxy"; import { Telemetry } from "../../util/posthog"; import { defaultContextProvidersJetBrains, @@ -26,7 +27,7 @@ export default class ControlPlaneProfileLoader implements IProfileLoader { readonly profileId: string; profileTitle: string; - workspaceSettings: ControlPlaneSettings | undefined; + workspaceSettings: ConfigJson | undefined; constructor( private readonly workspaceId: string, @@ -55,13 +56,8 @@ export default class ControlPlaneProfileLoader implements IProfileLoader { this.profileId, )) as any); - // First construct a SerializedContinueConfig from the ControlPlaneSettings - const serializedConfig: SerializedContinueConfig = { - models: settings.models, - tabAutocompleteModel: settings.tabAutocompleteModel, - embeddingsProvider: settings.embeddingsModel, - reranker: settings.reranker, - }; + // First construct a SerializedContinueConfig from the ControlPlaneSettings (TODO) + const serializedConfig: SerializedContinueConfig = settings; serializedConfig.contextProviders ??= ideInfo.ideType === "vscode" @@ -94,6 +90,16 @@ export default class ControlPlaneProfileLoader implements IProfileLoader { ideInfo.extensionVersion, ); + [ + ...finalConfig.models, + ...(finalConfig.tabAutocompleteModels ?? []), + ].forEach(async (model) => { + if (model.providerName === "continue-proxy") { + const accessToken = await this.controlPlaneClient.getAccessToken(); + (model as ContinueProxy).workOsAccessToken = accessToken; + } + }); + return finalConfig; } diff --git a/core/config/types.ts b/core/config/types.ts index 30fe8a4c7..00af67836 100644 --- a/core/config/types.ts +++ b/core/config/types.ts @@ -676,7 +676,7 @@ declare global { export interface TabAutocompleteOptions { disable: boolean; useCopyBuffer: boolean; - useSuffix: boolean; + useFileSuffix: boolean; maxPromptTokens: number; debounceDelay: number; maxSuffixPercentage: number; diff --git a/core/control-plane/TeamAnalytics.ts b/core/control-plane/TeamAnalytics.ts index 74a1c2b99..96fafbbf7 100644 --- a/core/control-plane/TeamAnalytics.ts +++ b/core/control-plane/TeamAnalytics.ts @@ -1,5 +1,5 @@ +import { Analytics } from "@continuedev/config-types"; import os from "node:os"; -import { ControlPlaneAnalytics } from "./schema"; export class TeamAnalytics { static client: any = undefined; @@ -24,7 +24,7 @@ export class TeamAnalytics { } static async setup( - config: ControlPlaneAnalytics, + config: Analytics, uniqueId: string, extensionVersion: string, ) { diff --git a/core/control-plane/client.ts b/core/control-plane/client.ts index e687b6e47..f254d13d0 100644 --- a/core/control-plane/client.ts +++ b/core/control-plane/client.ts @@ -1,6 +1,6 @@ +import { ConfigJson } from "@continuedev/config-types"; import fetch, { RequestInit, Response } from "node-fetch"; import { ModelDescription } from ".."; -import { ControlPlaneSettings } from "./schema"; export interface ControlPlaneSessionInfo { accessToken: string; @@ -13,7 +13,7 @@ export interface ControlPlaneSessionInfo { export interface ControlPlaneWorkspace { id: string; name: string; - settings: ControlPlaneSettings; + settings: ConfigJson; } export interface ControlPlaneModelDescription extends ModelDescription {} @@ -40,7 +40,7 @@ export class ControlPlaneClient { ); } - private async getAccessToken(): Promise { + async getAccessToken(): Promise { return (await this.sessionInfoPromise)?.accessToken; } @@ -78,9 +78,7 @@ export class ControlPlaneClient { return (await resp.json()) as any; } - async getSettingsForWorkspace( - workspaceId: string, - ): Promise { + async getSettingsForWorkspace(workspaceId: string): Promise { const userId = await this.userId; if (!userId) { throw new Error("No user id"); diff --git a/core/index.d.ts b/core/index.d.ts index e6b4e307a..816453c45 100644 --- a/core/index.d.ts +++ b/core/index.d.ts @@ -769,7 +769,7 @@ export interface Reranker { export interface TabAutocompleteOptions { disable: boolean; useCopyBuffer: boolean; - useSuffix: boolean; + useFileSuffix: boolean; maxPromptTokens: number; debounceDelay: number; maxSuffixPercentage: number; diff --git a/core/indexing/LanceDbIndex.ts b/core/indexing/LanceDbIndex.ts index 1f6ea709e..aa91f9fe5 100644 --- a/core/indexing/LanceDbIndex.ts +++ b/core/indexing/LanceDbIndex.ts @@ -65,7 +65,7 @@ export class LanceDbIndex implements CodebaseIndex { "lancedb_sqlite_artifact_id_column", async () => { await db.exec( - `ALTER TABLE lance_db_cache ADD COLUMN artifact_id TEXT NOT NULL DEFAULT 'UNDEFINED'`, + "ALTER TABLE lance_db_cache ADD COLUMN artifact_id TEXT NOT NULL DEFAULT 'UNDEFINED'", ); resolve(undefined); }, diff --git a/core/indexing/ignore.ts b/core/indexing/ignore.ts index c800f2786..07e6d873f 100644 --- a/core/indexing/ignore.ts +++ b/core/indexing/ignore.ts @@ -69,6 +69,7 @@ export const DEFAULT_IGNORE_FILETYPES = [ export const defaultIgnoreFile = ignore().add(DEFAULT_IGNORE_FILETYPES); export const DEFAULT_IGNORE_DIRS = [ ".git", + ".svn", ".vscode", ".idea", ".vs", diff --git a/core/llm/llms/stubs/ContinueProxy.ts b/core/llm/llms/stubs/ContinueProxy.ts index f23ea35cc..7c085bf75 100644 --- a/core/llm/llms/stubs/ContinueProxy.ts +++ b/core/llm/llms/stubs/ContinueProxy.ts @@ -2,9 +2,22 @@ import type { LLMOptions, ModelProvider } from "../../.."; import OpenAI from "../OpenAI.js"; class ContinueProxy extends OpenAI { + private _workOsAccessToken: string | undefined = undefined; + + get workOsAccessToken(): string | undefined { + return this._workOsAccessToken; + } + + set workOsAccessToken(value: string | undefined) { + if (this._workOsAccessToken !== value) { + this._workOsAccessToken = value; + this.apiKey = value; + } + } static providerName: ModelProvider = "continue-proxy"; static defaultOptions: Partial = { - apiBase: "http://localhost:3000/proxy/v1", + apiBase: + "https://control-plane-api-service-i3dqylpbqa-uc.a.run.app/model-proxy/v1", }; supportsFim(): boolean { diff --git a/core/package-lock.json b/core/package-lock.json index 477642d9a..9be2bdb6d 100644 --- a/core/package-lock.json +++ b/core/package-lock.json @@ -11,6 +11,7 @@ "dependencies": { "@aws-sdk/client-bedrock-runtime": "^3.574.0", "@aws-sdk/credential-providers": "^3.596.0", + "@continuedev/config-types": "^1.0.6", "@mozilla/readability": "^0.5.0", "@octokit/rest": "^20.0.2", "@types/jsdom": "^21.1.6", @@ -3928,6 +3929,14 @@ "node": ">=14.21.3" } }, + "node_modules/@continuedev/config-types": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/@continuedev/config-types/-/config-types-1.0.6.tgz", + "integrity": "sha512-JTlaGtsNW9vfSPcDJBn+I2vcs0wWRFIQcN3sa6pBFg2fj8W6qcMZoYUdzoU/+X+2ZT8OKcbomWfP2+qW0uuy6A==", + "dependencies": { + "zod": "^3.23.8" + } + }, "node_modules/@esbuild/android-arm": { "version": "0.17.19", "resolved": "https://registry.npmjs.org/@esbuild/android-arm/-/android-arm-0.17.19.tgz", diff --git a/core/package.json b/core/package.json index d3ebd9c45..e057ba169 100644 --- a/core/package.json +++ b/core/package.json @@ -31,6 +31,7 @@ "dependencies": { "@aws-sdk/client-bedrock-runtime": "^3.574.0", "@aws-sdk/credential-providers": "^3.596.0", + "@continuedev/config-types": "^1.0.6", "@mozilla/readability": "^0.5.0", "@octokit/rest": "^20.0.2", "@types/jsdom": "^21.1.6", diff --git a/core/protocol/core.ts b/core/protocol/core.ts index c25022826..ab15fa6c3 100644 --- a/core/protocol/core.ts +++ b/core/protocol/core.ts @@ -1,3 +1,4 @@ +/* eslint-disable @typescript-eslint/naming-convention */ import type { BrowserSerializedContinueConfig, ChatMessage, diff --git a/core/protocol/passThrough.ts b/core/protocol/passThrough.ts index 131531108..a228194e3 100644 --- a/core/protocol/passThrough.ts +++ b/core/protocol/passThrough.ts @@ -54,5 +54,6 @@ export const CORE_TO_WEBVIEW_PASS_THROUGH: (keyof ToWebviewFromCoreProtocol)[] = "indexProgress", "addContextItem", "refreshSubmenuItems", + "isContinueInputFocused", "didChangeAvailableProfiles", ]; diff --git a/core/protocol/webview.ts b/core/protocol/webview.ts index c0326bfa0..3cdf68c73 100644 --- a/core/protocol/webview.ts +++ b/core/protocol/webview.ts @@ -5,6 +5,7 @@ export type ToWebviewFromIdeOrCoreProtocol = { getDefaultModelTitle: [undefined, string]; indexProgress: [IndexingProgressUpdate, void]; refreshSubmenuItems: [undefined, void]; + isContinueInputFocused: [undefined, boolean]; addContextItem: [ { historyIndex: number; diff --git a/core/util/parameters.ts b/core/util/parameters.ts index 13b38626d..b413a869e 100644 --- a/core/util/parameters.ts +++ b/core/util/parameters.ts @@ -3,7 +3,7 @@ import { TabAutocompleteOptions } from "../index.js"; export const DEFAULT_AUTOCOMPLETE_OPTS: TabAutocompleteOptions = { disable: false, useCopyBuffer: false, - useSuffix: true, + useFileSuffix: true, maxPromptTokens: 1024, prefixPercentage: 0.85, maxSuffixPercentage: 0.25, diff --git a/docs/docs/reference/Model Providers/deepseek.md b/docs/docs/reference/Model Providers/deepseek.md new file mode 100644 index 000000000..af16f3749 --- /dev/null +++ b/docs/docs/reference/Model Providers/deepseek.md @@ -0,0 +1,16 @@ +# DeepSeek + +To setup DeepSeek, obtain an API key from [here](https://www.deepseek.com/) and add the following to your `config.json` file: + +```json title="~/.continue/config.json" +{ + "models": [ + { + "title": "Deepseek", + "provider": "deepseek", + "model": "deepseek-code", // Or any other DeepSeek model + "apiKey": "YOUR_API_KEY" + } + ] +} +``` diff --git a/docs/docs/troubleshooting.md b/docs/docs/troubleshooting.md index 0bd1d106f..f330345a7 100644 --- a/docs/docs/troubleshooting.md +++ b/docs/docs/troubleshooting.md @@ -67,11 +67,11 @@ If your keyboard shortcuts are not resolving, you may have other commands that a - [VSCode keyboard shortcuts docs](https://code.visualstudio.com/docs/getstarted/keybindings) - [IntelliJ keyboard shortcut docs](https://www.jetbrains.com/help/idea/configuring-keyboard-and-mouse-shortcuts.html) -# FAQs +## FAQs -## Networking Issues +### Networking Issues -### Configure Certificates +#### Configure Certificates If you're seeing a `fetch failed` error and your network requires custom certificates, you will need to configure them in `config.json`. In each of the objects in the `"models"` array, add `requestOptions.caBundlePath` like this: @@ -92,22 +92,22 @@ If you're seeing a `fetch failed` error and your network requires custom certifi You may also set `requestOptions.caBundlePath` to an array of paths to multiple certificates. -### VS Code Proxy Settings +#### VS Code Proxy Settings If you are using VS Code and require requests to be made through a proxy, you are likely already set up through VS Code's [Proxy Server Support](https://code.visualstudio.com/docs/setup/network#_proxy-server-support). To double-check that this is enabled, use cmd/ctrl+, to open settings and search for "Proxy Support". Unless it is set to "off", then VS Code is responsible for making the request to the proxy. -### code-server +#### code-server Continue can be used in [code-server](https://coder.com/), but if you are running across an error in the logs that includes "This is likely because the editor is not running in a secure context", please see [their documentation on securely exposing code-server](https://coder.com/docs/code-server/latest/guide#expose-code-server). -## I installed Continue, but don't see the sidebar window +### I installed Continue, but don't see the sidebar window By default the Continue window is on the left side of VS Code, but it can be dragged to right side as well, which we recommend in our tutorial. In the situation where you have previously installed Continue and moved it to the right side, it may still be there. You can reveal Continue either by using cmd/ctrl+L or by clicking the button in the top right of VS Code to open the right sidebar. -## I'm getting a 404 error from OpenAI +### I'm getting a 404 error from OpenAI If you have entered a valid API key and model, but are still getting a 404 error from OpenAI, this may be because you need to add credits to your billing account. You can do so from the [billing console](https://platform.openai.com/settings/organization/billing/overview). If you just want to check that this is in fact the cause of the error, you can try adding $1 to your account and checking whether the error persists. -# Still having trouble? +## Still having trouble? Create a GitHub issue [here](https://github.com/continuedev/continue/issues/new?assignees=&labels=bug&projects=&template=bug-report-%F0%9F%90%9B.md&title=), leaving the details of your problem, and we'll be able to more quickly help you out. diff --git a/docs/docs/walkthroughs/set-up-codestral.md b/docs/docs/walkthroughs/set-up-codestral.md index 706f89223..5ffee8fa5 100644 --- a/docs/docs/walkthroughs/set-up-codestral.md +++ b/docs/docs/walkthroughs/set-up-codestral.md @@ -39,7 +39,7 @@ keywords: [codestral, mistral, model setup] 5. If you run into any issues or have any questions, please join our Discord and post in the `#help` channel [here](https://discord.gg/EfJEfdFnDQ) -## Trobleshooting +## Troubleshooting ### Temporary workaround for JetBrains @@ -68,4 +68,4 @@ Mistral AI recently changed the API endpoint to `codestral.mistral.ai` instead o ### Ask for help on Discord -Please join our Discord and post in the `#help` channel [here](https://discord.gg/EfJEfdFnDQ) if you are having problems using Codestral \ No newline at end of file +Please join our Discord and post in the `#help` channel [here](https://discord.gg/EfJEfdFnDQ) if you are having problems using Codestral diff --git a/docs/docs/walkthroughs/tab-autocomplete.md b/docs/docs/walkthroughs/tab-autocomplete.md index 90976b16e..1aef6cb6b 100644 --- a/docs/docs/walkthroughs/tab-autocomplete.md +++ b/docs/docs/walkthroughs/tab-autocomplete.md @@ -94,7 +94,7 @@ This object allows you to customize the behavior of tab-autocomplete. The availa - `disable`: Disable autocomplete (can also be done from IDE settings) - `template`: An optional template string to be used for autocomplete. It will be rendered with the Mustache templating language, and is passed the 'prefix' and 'suffix' variables. (String) - `useCopyBuffer`: Determines whether the copy buffer will be considered when constructing the prompt. (Boolean) -- `useSuffix`: Determines whether to use the file suffix in the prompt. (Boolean) +- `useFileSuffix`: Determines whether to use the file suffix in the prompt. (Boolean) - `maxPromptTokens`: The maximum number of prompt tokens to use. A smaller number will yield faster completions, but less context. (Number) - `prefixPercentage`: The percentage of the input that should be dedicated to the prefix. (Number) - `maxSuffixPercentage`: The maximum percentage of the prompt that can be dedicated to the suffix. (Number) diff --git a/docs/static/schemas/config.json b/docs/static/schemas/config.json index 657d48c16..6d16f6b91 100644 --- a/docs/static/schemas/config.json +++ b/docs/static/schemas/config.json @@ -2071,7 +2071,7 @@ "type": "boolean", "description": "Determines whether the copy buffer will be considered when contructing the prompt." }, - "useSuffix": { + "useFileSuffix": { "type": "boolean", "description": "Determines whether to use the file suffix in the prompt." }, diff --git a/extensions/intellij/src/main/resources/config_schema.json b/extensions/intellij/src/main/resources/config_schema.json index 657d48c16..6d16f6b91 100644 --- a/extensions/intellij/src/main/resources/config_schema.json +++ b/extensions/intellij/src/main/resources/config_schema.json @@ -2071,7 +2071,7 @@ "type": "boolean", "description": "Determines whether the copy buffer will be considered when contructing the prompt." }, - "useSuffix": { + "useFileSuffix": { "type": "boolean", "description": "Determines whether to use the file suffix in the prompt." }, diff --git a/extensions/vscode/config_schema.json b/extensions/vscode/config_schema.json index 657d48c16..6d16f6b91 100644 --- a/extensions/vscode/config_schema.json +++ b/extensions/vscode/config_schema.json @@ -2071,7 +2071,7 @@ "type": "boolean", "description": "Determines whether the copy buffer will be considered when contructing the prompt." }, - "useSuffix": { + "useFileSuffix": { "type": "boolean", "description": "Determines whether to use the file suffix in the prompt." }, diff --git a/extensions/vscode/continue_rc_schema.json b/extensions/vscode/continue_rc_schema.json index 37d8bfe1b..2ce8beeaa 100644 --- a/extensions/vscode/continue_rc_schema.json +++ b/extensions/vscode/continue_rc_schema.json @@ -2326,7 +2326,7 @@ "type": "boolean", "description": "Determines whether the copy buffer will be considered when contructing the prompt." }, - "useSuffix": { + "useFileSuffix": { "type": "boolean", "description": "Determines whether to use the file suffix in the prompt." }, diff --git a/extensions/vscode/package-lock.json b/extensions/vscode/package-lock.json index 3064e57cb..658636fe7 100644 --- a/extensions/vscode/package-lock.json +++ b/extensions/vscode/package-lock.json @@ -1,12 +1,12 @@ { "name": "continue", - "version": "0.9.178", + "version": "0.9.181", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "continue", - "version": "0.9.178", + "version": "0.9.181", "license": "Apache-2.0", "dependencies": { "@electron/rebuild": "^3.2.10", @@ -33,6 +33,7 @@ "https-proxy-agent": "^7.0.2", "ignore": "^5.3.0", "jsdom": "^24.0.0", + "minisearch": "^7.0.0", "monaco-editor": "^0.45.0", "monaco-vscode-textmate-theme-converter": "^0.1.7", "ncp": "^2.0.0", @@ -96,6 +97,7 @@ "dependencies": { "@aws-sdk/client-bedrock-runtime": "^3.574.0", "@aws-sdk/credential-providers": "^3.596.0", + "@continuedev/config-types": "^1.0.6", "@mozilla/readability": "^0.5.0", "@octokit/rest": "^20.0.2", "@types/jsdom": "^21.1.6", @@ -7592,6 +7594,11 @@ "node": ">=8" } }, + "node_modules/minisearch": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/minisearch/-/minisearch-7.0.0.tgz", + "integrity": "sha512-0OIJ3hUE+YBJNruDCqbTMFmk/IoB1CpZzuGfl11khFIel66ew9UoLF/+gfq3bdyrneqr3P7BTjFZApUbmk+9Dg==" + }, "node_modules/minizlib": { "version": "2.1.2", "resolved": "https://registry.npmjs.org/minizlib/-/minizlib-2.1.2.tgz", diff --git a/extensions/vscode/package.json b/extensions/vscode/package.json index 6a79e0822..08faab27c 100644 --- a/extensions/vscode/package.json +++ b/extensions/vscode/package.json @@ -1,7 +1,7 @@ { "name": "continue", "icon": "media/icon.png", - "version": "0.9.181", + "version": "0.9.182", "repository": { "type": "git", "url": "https://github.com/continuedev/continue" @@ -229,18 +229,6 @@ "category": "Continue", "title": "Fix Grammar / Spelling", "group": "Continue" - }, - { - "command": "continue.quickEditHistoryUp", - "category": "Continue", - "title": "Quick Edit History Up", - "group": "Continue" - }, - { - "command": "continue.quickEditHistoryDown", - "category": "Continue", - "title": "Quick Edit History Down", - "group": "Continue" } ], "keybindings": [ @@ -572,6 +560,7 @@ "https-proxy-agent": "^7.0.2", "ignore": "^5.3.0", "jsdom": "^24.0.0", + "minisearch": "^7.0.0", "monaco-editor": "^0.45.0", "monaco-vscode-textmate-theme-converter": "^0.1.7", "ncp": "^2.0.0", diff --git a/extensions/vscode/src/debugPanel.ts b/extensions/vscode/src/ContinueGUIWebviewViewProvider.ts similarity index 98% rename from extensions/vscode/src/debugPanel.ts rename to extensions/vscode/src/ContinueGUIWebviewViewProvider.ts index 7a125585e..c713244b0 100644 --- a/extensions/vscode/src/debugPanel.ts +++ b/extensions/vscode/src/ContinueGUIWebviewViewProvider.ts @@ -25,6 +25,11 @@ export class ContinueGUIWebviewViewProvider } private _webview?: vscode.Webview; + private _webviewView?: vscode.WebviewView; + + get isVisible() { + return this._webviewView?.visible; + } get webview() { return this._webview; diff --git a/extensions/vscode/src/commands.ts b/extensions/vscode/src/commands.ts index df9cde808..1a897c9e2 100644 --- a/extensions/vscode/src/commands.ts +++ b/extensions/vscode/src/commands.ts @@ -19,10 +19,10 @@ import { quickPickStatusText, setupStatusBar, } from "./autocomplete/statusBar"; -import { ContinueGUIWebviewViewProvider } from "./debugPanel"; +import { ContinueGUIWebviewViewProvider } from "./ContinueGUIWebviewViewProvider"; import { DiffManager } from "./diff/horizontal"; import { VerticalPerLineDiffManager } from "./diff/verticalPerLine/manager"; -import { QuickEdit } from "./quickEdit/QuickEdit"; +import { QuickEdit } from "./quickEdit/QuickEditQuickPick"; import { Battery } from "./util/battery"; import type { VsCodeWebviewProtocol } from "./webviewProtocol"; @@ -82,7 +82,6 @@ function addCodeToContextFromRange( } async function addHighlightedCodeToContext( - edit: boolean, webviewProtocol: VsCodeWebviewProtocol | undefined, ) { const editor = vscode.window.activeTextEditor; @@ -170,6 +169,7 @@ const commandsMap: ( verticalDiffManager: VerticalPerLineDiffManager, continueServerClientPromise: Promise, battery: Battery, + quickEdit: QuickEdit, ) => { [command: string]: (...args: any) => any } = ( ide, extensionContext, @@ -179,6 +179,7 @@ const commandsMap: ( verticalDiffManager, continueServerClientPromise, battery, + quickEdit, ) => { /** * Streams an inline edit to the vertical diff manager. @@ -219,18 +220,6 @@ const commandsMap: ( ); } - const historyUpEventEmitter = new vscode.EventEmitter(); - const historyDownEventEmitter = new vscode.EventEmitter(); - const quickEdit = new QuickEdit( - verticalDiffManager, - configHandler, - sidebar.webviewProtocol, - ide, - extensionContext, - historyUpEventEmitter.event, - historyDownEventEmitter.event, - ); - return { "continue.acceptDiff": async (newFilepath?: string | vscode.Uri) => { captureCommandTelemetry("acceptDiff"); @@ -322,21 +311,44 @@ const commandsMap: ( fullScreenPanel?.reveal(); } sidebar.webviewProtocol?.request("focusContinueInput", undefined); - await addHighlightedCodeToContext(false, sidebar.webviewProtocol); + await addHighlightedCodeToContext(sidebar.webviewProtocol); }, "continue.focusContinueInputWithoutClear": async () => { - if (!getFullScreenTab()) { - vscode.commands.executeCommand("continue.continueGUIView.focus"); - } - sidebar.webviewProtocol?.request( - "focusContinueInputWithoutClear", + const fullScreenTab = getFullScreenTab(); + + const isContinueInputFocused = await sidebar.webviewProtocol.request( + "isContinueInputFocused", undefined, ); - await addHighlightedCodeToContext(true, sidebar.webviewProtocol); + + if (isContinueInputFocused) { + // Handle closing the GUI only if we are focused on the input + if (fullScreenTab) { + fullScreenPanel?.dispose(); + } else { + vscode.commands.executeCommand("workbench.action.closeAuxiliaryBar"); + } + } else { + // Handle opening the GUI otherwise + if (!fullScreenTab) { + // focus sidebar + vscode.commands.executeCommand("continue.continueGUIView.focus"); + } else { + // focus fullscreen + fullScreenPanel?.reveal(); + } + + sidebar.webviewProtocol?.request( + "focusContinueInputWithoutClear", + undefined, + ); + + await addHighlightedCodeToContext(sidebar.webviewProtocol); + } }, - "continue.quickEdit": (injectedPrompt?: string) => { + "continue.quickEdit": async (initialPrompt?: string) => { captureCommandTelemetry("quickEdit"); - quickEdit.run(injectedPrompt); + quickEdit.show(initialPrompt); }, "continue.writeCommentsForCode": async () => { captureCommandTelemetry("writeCommentsForCode"); @@ -659,14 +671,6 @@ const commandsMap: ( client.sendFeedback(feedback, lastLines); } }, - "continue.quickEditHistoryUp": async () => { - captureCommandTelemetry("quickEditHistoryUp"); - historyUpEventEmitter.fire(); - }, - "continue.quickEditHistoryDown": async () => { - captureCommandTelemetry("quickEditHistoryDown"); - historyDownEventEmitter.fire(); - }, }; }; @@ -680,6 +684,7 @@ export function registerAllCommands( verticalDiffManager: VerticalPerLineDiffManager, continueServerClientPromise: Promise, battery: Battery, + quickEdit: QuickEdit, ) { for (const [command, callback] of Object.entries( commandsMap( @@ -691,6 +696,7 @@ export function registerAllCommands( verticalDiffManager, continueServerClientPromise, battery, + quickEdit, ), )) { context.subscriptions.push( diff --git a/extensions/vscode/src/extension/VsCodeExtension.ts b/extensions/vscode/src/extension/VsCodeExtension.ts index 935d4492c..251ba02fd 100644 --- a/extensions/vscode/src/extension/VsCodeExtension.ts +++ b/extensions/vscode/src/extension/VsCodeExtension.ts @@ -14,12 +14,13 @@ import { setupStatusBar, } from "../autocomplete/statusBar"; import { registerAllCommands } from "../commands"; +import { ContinueGUIWebviewViewProvider } from "../ContinueGUIWebviewViewProvider"; import { registerDebugTracker } from "../debug/debug"; -import { ContinueGUIWebviewViewProvider } from "../debugPanel"; import { DiffManager } from "../diff/horizontal"; import { VerticalPerLineDiffManager } from "../diff/verticalPerLine/manager"; import { VsCodeIde } from "../ideProtocol"; import { registerAllCodeLensProviders } from "../lang-server/codeLens"; +import { QuickEdit } from "../quickEdit/QuickEditQuickPick"; import { setupRemoteConfigSync } from "../stubs/activation"; import { getControlPlaneSessionInfo } from "../stubs/WorkOsAuthProvider"; import { Battery } from "../util/battery"; @@ -41,7 +42,6 @@ export class VsCodeExtension { webviewProtocolPromise: Promise; private core: Core; private battery: Battery; - private quickActionsCodeLensDisposable?: vscode.Disposable; constructor(context: vscode.ExtensionContext) { let resolveWebviewProtocol: any = undefined; @@ -55,9 +55,6 @@ export class VsCodeExtension { this.extensionContext = context; this.windowId = uuidv4(); - const ideSettings = this.ide.getIdeSettingsSync(); - const { remoteConfigServerUrl } = ideSettings; - // Dependencies of core let resolveVerticalDiffManager: any = undefined; const verticalDiffManagerPromise = new Promise( @@ -179,6 +176,14 @@ export class VsCodeExtension { context.subscriptions.push(this.battery); context.subscriptions.push(monitorBatteryChanges(this.battery)); + const quickEdit = new QuickEdit( + this.verticalDiffManager, + this.configHandler, + this.sidebar.webviewProtocol, + this.ide, + context, + ); + // Commands registerAllCommands( context, @@ -190,6 +195,7 @@ export class VsCodeExtension { this.verticalDiffManager, this.core.continueServerClientPromise, this.battery, + quickEdit, ); registerDebugTracker(this.sidebar.webviewProtocol, this.ide); diff --git a/extensions/vscode/src/lang-server/codeLens/providers/QuickActionsCodeLensProvider.ts b/extensions/vscode/src/lang-server/codeLens/providers/QuickActionsCodeLensProvider.ts index 5edb02dac..41ba94242 100644 --- a/extensions/vscode/src/lang-server/codeLens/providers/QuickActionsCodeLensProvider.ts +++ b/extensions/vscode/src/lang-server/codeLens/providers/QuickActionsCodeLensProvider.ts @@ -115,9 +115,13 @@ export class QuickActionsCodeLensProvider implements vscode.CodeLensProvider { } const symbols = await vscode.commands.executeCommand< - Array + Array | undefined >("vscode.executeDocumentSymbolProvider", document.uri); + if (!symbols) { + return []; + } + const filteredSmybols = symbols?.filter((def) => QuickActionsCodeLensProvider.quickActionSymbolKinds.includes(def.kind), ); diff --git a/extensions/vscode/src/quickEdit/ContextProvidersQuickPick.ts b/extensions/vscode/src/quickEdit/ContextProvidersQuickPick.ts new file mode 100644 index 000000000..cf986c897 --- /dev/null +++ b/extensions/vscode/src/quickEdit/ContextProvidersQuickPick.ts @@ -0,0 +1,88 @@ +import { ContinueConfig, IDE } from "core"; +import { QuickPickItem, window } from "vscode"; +import { fetchwithRequestOptions } from "core/util/fetchWithOptions"; + +export async function getContextProviderItems({ + contextProviders, +}: ContinueConfig): Promise { + if (!contextProviders) { + return []; + } + + const quickPickItems = contextProviders + .filter((provider) => provider.description.type === "normal") + .map((provider) => { + return { + label: provider.description.displayTitle, + detail: provider.description.description, + }; + }); + + return quickPickItems; +} + +export async function getContextProvidersString( + selectedProviders: QuickPickItem[] | undefined, + config: ContinueConfig, + ide: IDE, +): Promise { + const contextItems = ( + await Promise.all( + selectedProviders?.map((selectedProvider) => { + const provider = config.contextProviders?.find( + (provider) => + provider.description.displayTitle === selectedProvider.label, + ); + + if (!provider) { + return []; + } + + return provider.getContextItems("", { + ide, + embeddingsProvider: config.embeddingsProvider, + reranker: config.reranker, + llm: config.models[0], + fullInput: "", + selectedCode: [], + fetch: (url, init) => + fetchwithRequestOptions(url, init, config.requestOptions), + }); + }) || [], + ) + ).flat(); + + return contextItems.map((item) => item.content).join("\n\n") + "\n\n---\n\n"; +} + +export async function getContextProviderQuickPickVal( + config: ContinueConfig, + ide: IDE, +) { + const contextProviderItems = await getContextProviderItems(config); + + const quickPick = window.createQuickPick(); + + quickPick.items = contextProviderItems; + quickPick.title = "Context providers"; + quickPick.placeholder = "Select a context provider to add to your prompt"; + quickPick.canSelectMany = true; + + quickPick.show(); + + const val = await new Promise((resolve) => { + quickPick.onDidAccept(async () => { + const selectedItems = Array.from(quickPick.selectedItems); + const context = await getContextProvidersString( + selectedItems, + config, + ide, + ); + resolve(context); + }); + }); + + quickPick.dispose(); + + return val; +} diff --git a/extensions/vscode/src/quickEdit/HistoryQuickPick.ts b/extensions/vscode/src/quickEdit/HistoryQuickPick.ts new file mode 100644 index 000000000..7ce18019f --- /dev/null +++ b/extensions/vscode/src/quickEdit/HistoryQuickPick.ts @@ -0,0 +1,42 @@ +import { QuickPickItem, window, ExtensionContext } from "vscode"; + +const HISTORY_KEY = "quickEditHistory"; +const MAX_HISTORY_LENGTH = 50; + +export function appendToHistory( + prompt: string, + { globalState }: ExtensionContext, +) { + let history: string[] = globalState.get(HISTORY_KEY, []); + + // Remove duplicate if exists + if (history[history.length - 1] === prompt) { + history = history.slice(0, -1); + } + + // Add new item + history.push(prompt); + + // Truncate if over max size + if (history.length > MAX_HISTORY_LENGTH) { + history = history.slice(-MAX_HISTORY_LENGTH); + } + + globalState.update(HISTORY_KEY, history); +} + +export async function getHistoryQuickPickVal({ + globalState, +}: ExtensionContext): Promise { + const historyItems: QuickPickItem[] = globalState + .get(HISTORY_KEY, []) + .map((item) => ({ label: item })) + .reverse(); + + const selectedItem = await window.showQuickPick(historyItems, { + title: "History", + placeHolder: "Select a previous prompt", + }); + + return selectedItem?.label; +} diff --git a/extensions/vscode/src/quickEdit/InputBoxWithHistory.ts b/extensions/vscode/src/quickEdit/InputBoxWithHistory.ts deleted file mode 100644 index d7e9ae0d8..000000000 --- a/extensions/vscode/src/quickEdit/InputBoxWithHistory.ts +++ /dev/null @@ -1,181 +0,0 @@ -import * as vscode from "vscode"; - -// Because we have to hide and show the input box again to allow history, this class can act like a more contiguous input box. -export default class InputBoxWithHistory implements vscode.Disposable { - private static MaxSize = 50; - private static HistoryKey = "quickEditHistory"; - private currentIndex: number; - private history: string[] = []; - - private cancellationReason: "up" | "down" | undefined = undefined; - private readonly completionEventEmitter = new vscode.EventEmitter< - string | undefined - >(); - private currentInputBoxCancellationTokenSource: - | vscode.CancellationTokenSource - | undefined = undefined; - - private disposables: vscode.Disposable[] = []; - - constructor( - private readonly context: vscode.ExtensionContext, - private readonly historyUpEvent: vscode.Event, - private readonly historyDownEvent: vscode.Event, - private readonly options: vscode.InputBoxOptions, - ) { - this.history = this.context.globalState.get( - InputBoxWithHistory.HistoryKey, - [], - ); - this.currentIndex = this.history.length; - - this.disposables.push( - this.historyUpEvent(() => { - const value = this.up(); - this.cancellationReason = "up"; - - if (typeof value === "undefined") { - return; - } - this._displayInputBox(value); - }), - ); - this.disposables.push( - this.historyDownEvent(() => { - const value = this.down(); - this.cancellationReason = "down"; - - if (typeof value === "undefined") { - return; - } - this._displayInputBox(value); - }), - ); - } - - dispose() { - if (this.currentInputBoxCancellationTokenSource) { - this.currentInputBoxCancellationTokenSource.dispose(); - } - this.completionEventEmitter.dispose(); - this.disposables.forEach((disposable) => disposable.dispose()); - vscode.commands.executeCommand( - "setContext", - "continue.quickEditHistoryFocused", - false, - ); - } - - appendToHistory(item: string) { - let history = this.history; - // Remove duplicate if exists - if (history[history.length - 1] === item) { - history = history.slice(0, -1); - } - - // Add new item - history.push(item); - - // Truncate if over max size - if (history.length > InputBoxWithHistory.MaxSize) { - history = history.slice(-InputBoxWithHistory.MaxSize); - } - - this.context.globalState.update(InputBoxWithHistory.HistoryKey, history); - } - - up(): string | undefined { - if (this.currentIndex > 0) { - this.currentIndex--; - return this.history[this.currentIndex]; - } - return undefined; - } - - down(): string | undefined { - if (this.currentIndex < this.history.length - 1) { - this.currentIndex++; - return this.history[this.currentIndex]; - } else if (this.currentIndex === this.history.length - 1) { - this.currentIndex++; - return ""; - } - return undefined; - } - - private _displayInputBox(value?: string) { - if (this.currentInputBoxCancellationTokenSource) { - this.currentInputBoxCancellationTokenSource.cancel(); - } - - this.currentInputBoxCancellationTokenSource = - new vscode.CancellationTokenSource(); - this.currentInputBoxCancellationTokenSource.token.onCancellationRequested( - () => { - // Up/down will cancel the input box, but we don't want that to trigger everything to be disposed - if ( - this.cancellationReason === "up" || - this.cancellationReason === "down" - ) { - return; - } - this.completionEventEmitter.fire(undefined); - }, - ); - - const options = { - ...this.options, - }; - if (value) { - options.value = value; - } - vscode.window - .showInputBox(options, this.currentInputBoxCancellationTokenSource.token) - .then((input) => { - if ( - (!input && this.cancellationReason === "up") || - this.cancellationReason === "down" - ) { - return; - } - this.completionEventEmitter.fire(input); - }); - - setTimeout(() => { - this.cancellationReason = undefined; - }, 100); - } - - async getInput(): Promise { - try { - vscode.commands.executeCommand( - "setContext", - "continue.quickEditHistoryFocused", - true, - ); - - return await new Promise((resolve, reject) => { - const completionDisposable = this.completionEventEmitter.event( - (input) => { - resolve(input); - completionDisposable.dispose(); - if (input) { - this.appendToHistory(input); - } - this.dispose(); - }, - ); - - this._displayInputBox(); - }); - } catch (e) { - console.error(e); - } finally { - vscode.commands.executeCommand( - "setContext", - "continue.quickEditHistoryFocused", - false, - ); - } - } -} diff --git a/extensions/vscode/src/quickEdit/ModelSelectionQuickPick.ts b/extensions/vscode/src/quickEdit/ModelSelectionQuickPick.ts new file mode 100644 index 000000000..d46ed6d43 --- /dev/null +++ b/extensions/vscode/src/quickEdit/ModelSelectionQuickPick.ts @@ -0,0 +1,32 @@ +import { ContinueConfig } from "core"; +import { QuickPickItem, window } from "vscode"; + +export async function getModelQuickPickVal( + curModelTitle: string, + config: ContinueConfig, +) { + const modelItems: QuickPickItem[] = config.models.map((model) => { + const isCurModel = curModelTitle === model.title; + + return { + label: model.title + ? `${isCurModel ? "$(check)" : " "} ${model.title}` + : "Model title not set", + }; + }); + + const selectedItem = await window.showQuickPick(modelItems, { + title: "Models", + placeHolder: "Select a model", + }); + + if (!selectedItem) { + return undefined; + } + + const selectedModelTitle = config.models.find( + (model) => model.title && selectedItem.label.includes(model.title), + )?.title; + + return selectedModelTitle; +} diff --git a/extensions/vscode/src/quickEdit/QuickEdit.ts b/extensions/vscode/src/quickEdit/QuickEdit.ts deleted file mode 100644 index 61165032f..000000000 --- a/extensions/vscode/src/quickEdit/QuickEdit.ts +++ /dev/null @@ -1,194 +0,0 @@ -import { IDE } from "core"; -import { ConfigHandler } from "core/config/ConfigHandler"; -import { fetchwithRequestOptions } from "core/util/fetchWithOptions"; -import * as vscode from "vscode"; -import { VerticalPerLineDiffManager } from "../diff/verticalPerLine/manager"; -import { getPlatform } from "../util/util"; -import { VsCodeWebviewProtocol } from "../webviewProtocol"; -import InputBoxWithHistory from "./InputBoxWithHistory"; - -interface QuickEditFlowStuff { - defaultModelTitle: string; - quickPickItems: vscode.QuickPickItem[]; - previousInput: string | undefined; - injectedPrompt?: string | undefined; -} - -export class QuickEdit { - constructor( - private readonly verticalDiffManager: VerticalPerLineDiffManager, - private readonly configHandler: ConfigHandler, - private readonly webviewProtocol: VsCodeWebviewProtocol, - private readonly ide: IDE, - private readonly context: vscode.ExtensionContext, - private readonly historyUpEvent: vscode.Event, - private readonly historyDownEvent: vscode.Event, - ) {} - - private async _getDefaultModelTitle(): Promise { - const config = await this.configHandler.loadConfig(); - let defaultModelTitle = - config.experimental?.modelRoles?.inlineEdit ?? - (await this.webviewProtocol.request("getDefaultModelTitle", undefined)); - if (!defaultModelTitle) { - defaultModelTitle = config.models[0]?.title!; - } - return defaultModelTitle; - } - - private async _getQuickPickItems(): Promise { - const contextProviders = (await this.configHandler.loadConfig()) - .contextProviders; - const quickPickItems = - contextProviders - ?.filter((provider) => provider.description.type === "normal") - .map((provider) => { - return { - label: provider.description.displayTitle, - description: provider.description.title, - detail: provider.description.description, - }; - }) || []; - return quickPickItems; - } - - private async _getStuff( - injectedPrompt: string | undefined, - ): Promise { - const editor = vscode.window.activeTextEditor; - const existingHandler = this.verticalDiffManager.getHandlerForFile( - editor?.document.uri.fsPath ?? "", - ); - const previousInput = existingHandler?.input; - const stuff: QuickEditFlowStuff = { - defaultModelTitle: await this._getDefaultModelTitle(), - quickPickItems: await this._getQuickPickItems(), - previousInput, - injectedPrompt, - }; - return stuff; - } - - async _getTextInputOptions(stuff: QuickEditFlowStuff) { - const selectionEmpty = vscode.window.activeTextEditor?.selection.isEmpty; - const addContextMsg = stuff.quickPickItems.length - ? " (or press enter to add context first)" - : ""; - const textInputOptions: vscode.InputBoxOptions = { - placeHolder: selectionEmpty - ? `Type instructions to generate code${addContextMsg}` - : `Describe how to edit the highlighted code${addContextMsg}`, - title: `${getPlatform() === "mac" ? "Cmd" : "Ctrl"}+I`, - prompt: `[${stuff.defaultModelTitle}]`, - value: stuff.injectedPrompt, - ignoreFocusOut: true, - }; - if (stuff.previousInput) { - textInputOptions.value = stuff.previousInput + ", "; - textInputOptions.valueSelection = [ - textInputOptions.value.length, - textInputOptions.value.length, - ]; - } - return textInputOptions; - } - - async _collectTextInput( - stuff: QuickEditFlowStuff, - ): Promise { - const inputBox = new InputBoxWithHistory( - this.context, - this.historyUpEvent, - this.historyDownEvent, - await this._getTextInputOptions(stuff), - ); - const input = await inputBox.getInput(); - inputBox.dispose(); - return input; - } - - private async _runWithContextItems(stuff: QuickEditFlowStuff) { - const selectedProviders = await vscode.window.showQuickPick( - stuff.quickPickItems, - { - title: "Add Context", - canPickMany: true, - }, - ); - - const input = await this._collectTextInput(stuff); - if (input) { - const inputWithContext = await this._addSelectedProvidersToInput( - input, - selectedProviders, - ); - - await this._sendRequest(inputWithContext, stuff); - } - } - - private async _addSelectedProvidersToInput( - input: string, - selectedProviders: vscode.QuickPickItem[] | undefined, - ): Promise { - const llm = await this.configHandler.llmFromTitle(); - const config = await this.configHandler.loadConfig(); - const context = ( - await Promise.all( - selectedProviders?.map((providerTitle) => { - const provider = config.contextProviders?.find( - (provider) => - provider.description.title === providerTitle.description, - ); - if (!provider) { - return []; - } - - return provider.getContextItems("", { - embeddingsProvider: config.embeddingsProvider, - reranker: config.reranker, - ide: this.ide, - llm, - fullInput: input || "", - selectedCode: [], - fetch: (url, init) => - fetchwithRequestOptions(url, init, config.requestOptions), - }); - }) || [], - ) - ).flat(); - - return ( - context.map((item) => item.content).join("\n\n") + "\n\n---\n\n" + input - ); - } - - private async _handleInitialInput( - initialInput: string | undefined, - stuff: QuickEditFlowStuff, - ) { - // If the user presses enter, we take them to context items selector - if (initialInput?.length === 0 && stuff.quickPickItems.length > 0) { - await this._runWithContextItems(stuff); - } else if (initialInput) { - // If there's input, then start generating the diff - await this._sendRequest(initialInput, stuff); - } - } - - private async _sendRequest(input: string, stuff: QuickEditFlowStuff) { - this.webviewProtocol.request("incrementFtc", undefined); - await this.verticalDiffManager.streamEdit( - input, - stuff.defaultModelTitle, - undefined, - stuff.previousInput, - ); - } - - async run(injectedPrompt: string | undefined) { - const stuff = await this._getStuff(injectedPrompt); - const initialInput = await this._collectTextInput(stuff); - await this._handleInitialInput(initialInput, stuff); - } -} diff --git a/extensions/vscode/src/quickEdit/QuickEditQuickPick.ts b/extensions/vscode/src/quickEdit/QuickEditQuickPick.ts new file mode 100644 index 000000000..c95259dc5 --- /dev/null +++ b/extensions/vscode/src/quickEdit/QuickEditQuickPick.ts @@ -0,0 +1,410 @@ +/* eslint-disable @typescript-eslint/naming-convention */ +import { IDE } from "core"; +import * as vscode from "vscode"; +import { VerticalPerLineDiffManager } from "../diff/verticalPerLine/manager"; +import { VsCodeWebviewProtocol } from "../webviewProtocol"; +import { Telemetry } from "core/util/posthog"; +import { walkDir } from "core/indexing/walkDir"; +import { appendToHistory, getHistoryQuickPickVal } from "./HistoryQuickPick"; +import { getContextProviderQuickPickVal } from "./ContextProvidersQuickPick"; +import { getModelQuickPickVal } from "./ModelSelectionQuickPick"; + +// @ts-ignore - error finding typings +import MiniSearch from "minisearch"; +import { ConfigHandler } from "core/config/ConfigHandler"; + +/** + * Used to track what action to take after a user interacts + * with the initial Quick Pick + */ +enum QuickEditInitialItemLabels { + History = "History", + ContextProviders = "Context providers", + Model = "Model", + Submit = "Submit", +} + +type FileMiniSearchResult = { filename: string }; + +/** + * Quick Edit is a collection of Quick Picks that allow the user to + * quickly edit a file. + */ +export class QuickEdit { + private static fileSearchChar = "@"; + + /** + * Matches the search char followed by non-space chars, excluding matches ending with a space. + * This is used to detect file search queries while allowing subsequent prompt text + */ + private static hasFileSearchQueryRegex = new RegExp( + `${QuickEdit.fileSearchChar}[^${QuickEdit.fileSearchChar}\\s]+(?!\\s)$`, + ); + + private static maxFileSearchResults = 20; + private miniSearch = new MiniSearch({ + fields: ["filename"], + storeFields: ["filename"], + searchOptions: { + prefix: true, + fuzzy: 2, + }, + }); + + private previousInput?: string; + + /** + * Handles situations where the user navigates to a different editor + * while interacting with the Quick Pick + */ + private editorWhenOpened!: vscode.TextEditor; + + /** + * Required to store the string content of a context provider + * while naviagting beween Quick Picks. + */ + private contextProviderStr?: string; + + /** + * Stores the current model title for potential changes + */ + private _curModelTitle?: string; + + constructor( + private readonly verticalDiffManager: VerticalPerLineDiffManager, + private readonly configHandler: ConfigHandler, + private readonly webviewProtocol: VsCodeWebviewProtocol, + private readonly ide: IDE, + private readonly context: vscode.ExtensionContext, + ) { + this.intializeQuickEditState(); + } + + private async intializeQuickEditState() { + const editor = vscode.window.activeTextEditor!; + + const existingHandler = this.verticalDiffManager.getHandlerForFile( + editor.document.uri.fsPath ?? "", + ); + + const workspaceDirs = await this.ide.getWorkspaceDirs(); + + const results = await Promise.all( + workspaceDirs.map((dir) => { + return walkDir(dir, this.ide); + }), + ); + + const filenames = results.flat().map((file) => ({ + id: file, + filename: vscode.workspace.asRelativePath(file), + })); + + this.miniSearch.addAll(filenames); + this.editorWhenOpened = editor; + this.previousInput = existingHandler?.input; + } + + /** + * Gets the model title the user has chosen, or their default model + */ + private async _getCurModelTitle() { + const config = await this.configHandler.loadConfig(); + + if (this._curModelTitle) { + return this._curModelTitle; + } + + let defaultModelTitle = + config.experimental?.modelRoles?.inlineEdit ?? + (await this.webviewProtocol.request("getDefaultModelTitle", undefined)); + + if (!defaultModelTitle) { + defaultModelTitle = config.models[0]?.title!; + } + + return defaultModelTitle; + } + + /** + * Generates a title for the Quick Pick, including the + * file name and selected line(s) if available. + * + * @example + * // "Edit myFile.ts", "Edit myFile.ts:5-10", "Edit myFile.ts:15" + */ + _getQuickPickTitle = () => { + const uri = this.editorWhenOpened.document.uri; + + if (!uri) { + return "Edit"; + } + + const fileName = vscode.workspace.asRelativePath(uri, true); + const { start, end } = this.editorWhenOpened.selection; + const selectionEmpty = this.editorWhenOpened.selection.isEmpty; + + return selectionEmpty + ? `Edit ${fileName}` + : `Edit ${fileName}:${start.line}${ + end.line > start.line ? `-${end.line}` : "" + }`; + }; + + private async _streamEditWithInputAndContext(prompt: string) { + const modelTitle = await this._getCurModelTitle(); + + // Extracts all file references from the prompt string, + // which are denoted by an '@' symbol followed by + // one or more non-whitespace characters. + const fileReferences = prompt.match(/@[^\s]+/g) || []; + + // Replace file references with the content of the file + for (const fileRef of fileReferences) { + const filePath = fileRef.slice(1); // Remove the '@' symbol + + const fileContent = await this.ide.readFile(filePath); + + prompt = prompt.replace( + fileRef, + `\`\`\`${filePath}\n${fileContent}\n\`\`\`\n\n`, + ); + } + + if (this.contextProviderStr) { + prompt = this.contextProviderStr + prompt; + } + + this.webviewProtocol.request("incrementFtc", undefined); + + await this.verticalDiffManager.streamEdit( + prompt, + modelTitle, + undefined, + this.previousInput, + ); + } + + async _getInitialQuickPickVal( + injectedPrompt?: string, + ): Promise { + const modelTitle = await this._getCurModelTitle(); + + const initialItems: vscode.QuickPickItem[] = [ + { + label: QuickEditInitialItemLabels.History, + detail: "$(history) Select previous prompts", + }, + { + label: QuickEditInitialItemLabels.ContextProviders, + detail: "$(add) Add context to your prompt", + }, + { + label: QuickEditInitialItemLabels.Model, + detail: `$(chevron-down) ${modelTitle}`, + }, + ]; + + /** + * The user has to select an item to submit the prompt, + * so we add a "Submit" item once the user has begun to + * type their prompt that is always displayed + */ + const submitItem: vscode.QuickPickItem = { + label: "Submit", + alwaysShow: true, + }; + + /** + * Used to show the current file in the Quick Pick, + * as soon as the user types the search character + */ + const currentFileItem: vscode.QuickPickItem = { + label: vscode.workspace.asRelativePath( + this.editorWhenOpened.document.uri, + ), + description: "Current file", + alwaysShow: true, + }; + + const noResultsItem: vscode.QuickPickItem = { label: "No results found" }; + + const quickPick = vscode.window.createQuickPick(); + + quickPick.items = initialItems; + quickPick.placeholder = + "Enter a prompt to edit your code (@ to search files, ⏎ to submit)"; + quickPick.title = this._getQuickPickTitle(); + quickPick.ignoreFocusOut = true; + quickPick.value = injectedPrompt ?? ""; + + quickPick.show(); + + /** + * Programatically modify the Quick Pick items based on the input value. + * + * Shows the current file for a new file search, performs a file search, + * or shows the submit option. + * + * If the input is empty, shows the initial items. + */ + quickPick.onDidChangeValue((value) => { + if (value !== "") { + switch (true) { + case value.endsWith(QuickEdit.fileSearchChar): + quickPick.items = [currentFileItem]; + break; + + case QuickEdit.hasFileSearchQueryRegex.test(value): + const lastAtIndex = value.lastIndexOf(QuickEdit.fileSearchChar); + + // The search query is the last instance of the + // search character to the end of the string + const searchQuery = value.substring(lastAtIndex + 1); + + const searchResults = this.miniSearch.search( + searchQuery, + ) as FileMiniSearchResult[]; + + if (searchResults.length > 0) { + quickPick.items = searchResults + .map(({ filename }) => ({ + label: filename, + alwaysShow: true, + })) + .slice(0, QuickEdit.maxFileSearchResults); + } else { + quickPick.items = [noResultsItem]; + } + + break; + + default: + // The user does not have a file search in progress, + // tso only show the submit option + quickPick.items = [submitItem]; + break; + } + } else { + quickPick.items = initialItems; + } + }); + + /** + * Waits for the user to select an item from the quick pick. + * + * If the selected item is a file, it replaces the file search query + * with the selected file path and allows further editing. + * + * If the selected item is an initial item, it closes the quick pick + * and returns the selected item label. + * + * @returns {Promise} The label of the selected item, or undefined if no item was selected. + */ + const selectedItemLabel = await new Promise( + (resolve) => { + quickPick.onDidAccept(() => { + const { label } = quickPick.selectedItems[0]; + + // If not an initial item, it's a file selection. Allow continued prompt editing. + const isFileSelection = !Object.values( + QuickEditInitialItemLabels, + ).includes(label as QuickEditInitialItemLabels); + + if (isFileSelection) { + // Replace the file search query with the selected file path + const curValue = quickPick.value; + const newValue = + curValue.substring(0, curValue.lastIndexOf("@") + 1) + + label + + " "; + + quickPick.value = newValue; + quickPick.items = [submitItem]; + } else { + // The user has selected one of the initial items, so we close the Quick Pick + resolve(label); + quickPick.dispose(); + } + }); + }, + ); + + const shouldSubmitPrompt = + !selectedItemLabel || + selectedItemLabel === QuickEditInitialItemLabels.Submit; + + if (shouldSubmitPrompt) { + return quickPick.value; + } + + return selectedItemLabel; + } + + /** + * Shows the Quick Edit Quick Pick, allowing the user to select an initial item or enter a prompt. + * Displays a quick pick for "History" or "ContextProviders" to set the prompt or context provider string. + * Displays a quick pick for "Model" to set the current model title. + * Appends the entered prompt to the history and streams the edit with input and context. + */ + async show(initialPrompt?: string) { + const config = await this.configHandler.loadConfig(); + + const selectedLabelOrInputVal = await this._getInitialQuickPickVal( + initialPrompt, + ); + + Telemetry.capture("quickEditSelection", { + selection: selectedLabelOrInputVal, + }); + + let prompt: string | undefined = undefined; + + switch (selectedLabelOrInputVal) { + case QuickEditInitialItemLabels.History: + const historyVal = await getHistoryQuickPickVal(this.context); + prompt = historyVal ?? ""; + break; + + case QuickEditInitialItemLabels.ContextProviders: + const contextProviderVal = await getContextProviderQuickPickVal( + config, + this.ide, + ); + this.contextProviderStr = contextProviderVal ?? ""; + + // Recurse back to let the user write their prompt + this.show(initialPrompt); + + break; + + case QuickEditInitialItemLabels.Model: + const curModelTitle = await this._getCurModelTitle(); + + const selectedModelTitle = await getModelQuickPickVal( + curModelTitle, + config, + ); + + if (selectedModelTitle) { + this._curModelTitle = selectedModelTitle; + } + + // Recurse back to let the user write their prompt + this.show(initialPrompt); + + break; + + default: + // If it wasn't a label we can assume it was user input + if (selectedLabelOrInputVal) { + prompt = selectedLabelOrInputVal; + appendToHistory(selectedLabelOrInputVal, this.context); + } + } + + if (prompt) { + await this._streamEditWithInputAndContext(prompt); + } + } +} diff --git a/extensions/vscode/src/quickEdit/index.ts b/extensions/vscode/src/quickEdit/index.ts new file mode 100644 index 000000000..e69de29bb diff --git a/gui/package-lock.json b/gui/package-lock.json index 91f4adfe0..7de482640 100644 --- a/gui/package-lock.json +++ b/gui/package-lock.json @@ -37,6 +37,7 @@ "react-dom": "^18.2.0", "react-error-boundary": "^4.0.11", "react-hook-form": "^7.47.0", + "react-intersection-observer": "^9.10.3", "react-markdown": "^9.0.1", "react-redux": "^8.0.5", "react-remark": "^2.1.0", @@ -88,6 +89,7 @@ "dependencies": { "@aws-sdk/client-bedrock-runtime": "^3.574.0", "@aws-sdk/credential-providers": "^3.596.0", + "@continuedev/config-types": "^1.0.6", "@mozilla/readability": "^0.5.0", "@octokit/rest": "^20.0.2", "@types/jsdom": "^21.1.6", @@ -919,9 +921,9 @@ } }, "node_modules/@heroicons/react": { - "version": "2.1.3", - "resolved": "https://registry.npmjs.org/@heroicons/react/-/react-2.1.3.tgz", - "integrity": "sha512-fEcPfo4oN345SoqdlCDdSa4ivjaKbk0jTd+oubcgNxnNgAfzysfwWfQUr+51wigiWHQQRiZNd1Ao0M5Y3M2EGg==", + "version": "2.1.5", + "resolved": "https://registry.npmjs.org/@heroicons/react/-/react-2.1.5.tgz", + "integrity": "sha512-FuzFN+BsHa+7OxbvAERtgBTNeZpUjgM/MIizfVkSCL2/edriN0Hx/DWRCR//aPYwO5QX/YlgLGXk+E3PcfZwjA==", "peerDependencies": { "react": ">= 16" } @@ -6078,6 +6080,20 @@ "react": "^16.8.0 || ^17 || ^18" } }, + "node_modules/react-intersection-observer": { + "version": "9.10.3", + "resolved": "https://registry.npmjs.org/react-intersection-observer/-/react-intersection-observer-9.10.3.tgz", + "integrity": "sha512-9NYfKwPZRovB6QJee7fDg0zz/SyYrqXtn5xTZU0vwLtLVBtfu9aZt1pVmr825REE49VPDZ7Lm5SNHjJBOTZHpA==", + "peerDependencies": { + "react": "^15.0.0 || ^16.0.0 || ^17.0.0 || ^18.0.0 || ^19.0.0", + "react-dom": "^15.0.0 || ^16.0.0 || ^17.0.0 || ^18.0.0 || ^19.0.0" + }, + "peerDependenciesMeta": { + "react-dom": { + "optional": true + } + } + }, "node_modules/react-is": { "version": "18.3.1", "resolved": "https://registry.npmjs.org/react-is/-/react-is-18.3.1.tgz", diff --git a/gui/package.json b/gui/package.json index 3b9842d82..b2a4426e8 100644 --- a/gui/package.json +++ b/gui/package.json @@ -39,6 +39,7 @@ "react-dom": "^18.2.0", "react-error-boundary": "^4.0.11", "react-hook-form": "^7.47.0", + "react-intersection-observer": "^9.10.3", "react-markdown": "^9.0.1", "react-redux": "^8.0.5", "react-remark": "^2.1.0", diff --git a/gui/src/components/ChatScrollAnchor.tsx b/gui/src/components/ChatScrollAnchor.tsx new file mode 100644 index 000000000..59e59ab9b --- /dev/null +++ b/gui/src/components/ChatScrollAnchor.tsx @@ -0,0 +1,32 @@ +import { useEffect } from "react"; +import { useInView } from "react-intersection-observer"; + +interface ChatScrollAnchorProps { + trackVisibility: boolean; + isAtBottom: boolean; + scrollAreaRef: React.RefObject; +} + +export function ChatScrollAnchor({ + trackVisibility, + isAtBottom, + scrollAreaRef, +}: ChatScrollAnchorProps) { + const { ref, inView, entry } = useInView({ + trackVisibility, + delay: 100, + }); + + useEffect(() => { + if (isAtBottom && trackVisibility && !inView) { + if (!scrollAreaRef.current) return; + + const scrollAreaElement = scrollAreaRef.current; + + scrollAreaElement.scrollTop = + scrollAreaElement.scrollHeight - scrollAreaElement.clientHeight; + } + }, [inView, entry, isAtBottom, trackVisibility]); + + return
; +} diff --git a/gui/src/components/ProfileSwitcher.tsx b/gui/src/components/ProfileSwitcher.tsx index fbb2e4838..9cd03f5c0 100644 --- a/gui/src/components/ProfileSwitcher.tsx +++ b/gui/src/components/ProfileSwitcher.tsx @@ -224,7 +224,7 @@ function ProfileSwitcher(props: {}) { } else { ideMessenger.post( "openUrl", - `http://app.continue.dev/workspaces/${selectedProfileId}/settings`, + `http://app.continue.dev/workspaces/${selectedProfileId}/config`, ); } }} diff --git a/gui/src/components/dialogs/ConfirmationDialog.tsx b/gui/src/components/dialogs/ConfirmationDialog.tsx index b3e737805..6033e9b3d 100644 --- a/gui/src/components/dialogs/ConfirmationDialog.tsx +++ b/gui/src/components/dialogs/ConfirmationDialog.tsx @@ -17,6 +17,7 @@ interface ConfirmationDialogProps { onConfirm: () => void; onCancel?: () => void; text: string; + title?: string; } function ConfirmationDialog(props: ConfirmationDialogProps) { @@ -24,7 +25,7 @@ function ConfirmationDialog(props: ConfirmationDialogProps) { return (
-

Confirmation

+

{props.title ?? "Confirmation"}

{props.text}

diff --git a/gui/src/components/mainInput/TipTapEditor.tsx b/gui/src/components/mainInput/TipTapEditor.tsx index 4b53fb00b..c0e941e45 100644 --- a/gui/src/components/mainInput/TipTapEditor.tsx +++ b/gui/src/components/mainInput/TipTapEditor.tsx @@ -151,8 +151,6 @@ function TipTapEditor(props: TipTapEditorProps) { ); const useActiveFile = useSelector(selectUseActiveFile); - const [inputFocused, setInputFocused] = useState(false); - const { saveSession } = useHistory(dispatch); const inSubmenuRef = useRef(undefined); @@ -655,16 +653,14 @@ function TipTapEditor(props: TipTapEditorProps) { ], ); - // On linux+jetbrains only was stealing focus - // useEffect(() => { - // if (props.isMainInput && editor && document.hasFocus()) { - // editor.commands.focus(); - // // setTimeout(() => { - // // // https://github.com/continuedev/continue/pull/881 - // // editor.commands.blur(); - // // }, 0); - // } - // }, [editor, props.isMainInput, historyLength, ignoreHighlightedCode]); + useWebviewListener( + "isContinueInputFocused", + async () => { + return props.isMainInput && editorFocusedRef.current; + }, + [editorFocusedRef, props.isMainInput], + !props.isMainInput, + ); const [showDragOverMsg, setShowDragOverMsg] = useState(false); @@ -748,22 +744,13 @@ function TipTapEditor(props: TipTapEditorProps) { { - setInputFocused(true); - }} - onBlur={() => { - // hack to stop from cancelling press of "Enter" - setTimeout(() => { - setInputFocused(false); - }, 100); - }} onClick={(event) => { event.stopPropagation(); }} />