Compare commits
1 Commits
github-tok
...
kb/buffer-
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
92db0259ab |
@@ -13,6 +13,12 @@ rustflags = ["-C", "link-arg=-fuse-ld=mold"]
|
|||||||
linker = "clang"
|
linker = "clang"
|
||||||
rustflags = ["-C", "link-arg=-fuse-ld=mold"]
|
rustflags = ["-C", "link-arg=-fuse-ld=mold"]
|
||||||
|
|
||||||
|
[target.aarch64-apple-darwin]
|
||||||
|
rustflags = ["-C", "link-args=-all_load"]
|
||||||
|
|
||||||
|
[target.x86_64-apple-darwin]
|
||||||
|
rustflags = ["-C", "link-args=-all_load"]
|
||||||
|
|
||||||
[target.'cfg(target_os = "windows")']
|
[target.'cfg(target_os = "windows")']
|
||||||
rustflags = [
|
rustflags = [
|
||||||
"--cfg",
|
"--cfg",
|
||||||
|
|||||||
@@ -30,7 +30,3 @@ ffdda588b41f7d9d270ffe76cab116f828ad545e
|
|||||||
# 2024-07-05 Improved formatting of default keymaps (single line per bind)
|
# 2024-07-05 Improved formatting of default keymaps (single line per bind)
|
||||||
# https://github.com/zed-industries/zed/pull/13887
|
# https://github.com/zed-industries/zed/pull/13887
|
||||||
813cc3f5e537372fc86720b5e71b6e1c815440ab
|
813cc3f5e537372fc86720b5e71b6e1c815440ab
|
||||||
|
|
||||||
# 2024-07-24 docs: Format docs
|
|
||||||
# https://github.com/zed-industries/zed/pull/15352
|
|
||||||
3a44a59f8ec114ac1ba22f7da1652717ef7e4e5c
|
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
name: Bug Report (Debugger)
|
name: Bug Report (Agent Panel)
|
||||||
description: Zed Debugger-Related Bugs
|
description: Zed Agent Panel Bugs
|
||||||
type: "Bug"
|
type: "Bug"
|
||||||
labels: ["debugger"]
|
labels: ["agent", "ai"]
|
||||||
title: "Debugger: <a short description of the Debugger bug>"
|
title: "Agent Panel: <a short description of the Agent Panel bug>"
|
||||||
body:
|
body:
|
||||||
- type: textarea
|
- type: textarea
|
||||||
attributes:
|
attributes:
|
||||||
@@ -14,6 +14,7 @@ body:
|
|||||||
|
|
||||||
### Description
|
### Description
|
||||||
<!-- Describe with sufficient detail to reproduce from a clean Zed install. -->
|
<!-- Describe with sufficient detail to reproduce from a clean Zed install. -->
|
||||||
|
<!-- Please include the LLM provider and model name you are using -->
|
||||||
Steps to trigger the problem:
|
Steps to trigger the problem:
|
||||||
1.
|
1.
|
||||||
2.
|
2.
|
||||||
@@ -21,15 +22,15 @@ body:
|
|||||||
|
|
||||||
Actual Behavior:
|
Actual Behavior:
|
||||||
Expected Behavior:
|
Expected Behavior:
|
||||||
|
|
||||||
validations:
|
validations:
|
||||||
required: true
|
required: true
|
||||||
|
|
||||||
- type: textarea
|
- type: textarea
|
||||||
id: environment
|
id: environment
|
||||||
attributes:
|
attributes:
|
||||||
label: Zed Version and System Specs
|
label: Zed Version and System Specs
|
||||||
description: 'Open Zed, and in the command palette select "zed: copy system specs into clipboard"'
|
description: 'Open Zed, and in the command palette select "zed: Copy System Specs Into Clipboard"'
|
||||||
placeholder: |
|
placeholder: |
|
||||||
Output of "zed: copy system specs into clipboard"
|
Output of "zed: Copy System Specs Into Clipboard"
|
||||||
validations:
|
validations:
|
||||||
required: true
|
required: true
|
||||||
42
.github/ISSUE_TEMPLATE/01_bug_ai.yml
vendored
@@ -1,42 +0,0 @@
|
|||||||
name: Bug Report (AI Related)
|
|
||||||
description: Zed Agent Panel Bugs
|
|
||||||
type: "Bug"
|
|
||||||
labels: ["ai"]
|
|
||||||
title: "AI: <a short description of the AI Related bug>"
|
|
||||||
body:
|
|
||||||
- type: textarea
|
|
||||||
attributes:
|
|
||||||
label: Summary
|
|
||||||
description: Describe the bug with a one line summary, and provide detailed reproduction steps
|
|
||||||
value: |
|
|
||||||
<!-- Please insert a one line summary of the issue below -->
|
|
||||||
SUMMARY_SENTENCE_HERE
|
|
||||||
|
|
||||||
### Description
|
|
||||||
<!-- Describe with sufficient detail to reproduce from a clean Zed install. -->
|
|
||||||
Steps to trigger the problem:
|
|
||||||
1.
|
|
||||||
2.
|
|
||||||
3.
|
|
||||||
|
|
||||||
Actual Behavior:
|
|
||||||
Expected Behavior:
|
|
||||||
|
|
||||||
### Model Provider Details
|
|
||||||
- Provider: (Anthropic via ZedPro, Anthropic via API key, Copilot Chat, Mistral, OpenAI, etc)
|
|
||||||
- Model Name:
|
|
||||||
- Mode: (Agent Panel, Inline Assistant, Terminal Assistant or Text Threads)
|
|
||||||
- MCP Servers in-use:
|
|
||||||
- Other Details:
|
|
||||||
validations:
|
|
||||||
required: true
|
|
||||||
|
|
||||||
- type: textarea
|
|
||||||
id: environment
|
|
||||||
attributes:
|
|
||||||
label: Zed Version and System Specs
|
|
||||||
description: 'Open Zed, and in the command palette select "zed: copy system specs into clipboard"'
|
|
||||||
placeholder: |
|
|
||||||
Output of "zed: copy system specs into clipboard"
|
|
||||||
validations:
|
|
||||||
required: true
|
|
||||||
@@ -29,8 +29,8 @@ body:
|
|||||||
id: environment
|
id: environment
|
||||||
attributes:
|
attributes:
|
||||||
label: Zed Version and System Specs
|
label: Zed Version and System Specs
|
||||||
description: 'Open Zed, and in the command palette select "zed: copy system specs into clipboard"'
|
description: 'Open Zed, and in the command palette select "zed: Copy System Specs Into Clipboard"'
|
||||||
placeholder: |
|
placeholder: |
|
||||||
Output of "zed: copy system specs into clipboard"
|
Output of "zed: Copy System Specs Into Clipboard"
|
||||||
validations:
|
validations:
|
||||||
required: true
|
required: true
|
||||||
|
|||||||
4
.github/ISSUE_TEMPLATE/03_bug_git.yml
vendored
@@ -28,8 +28,8 @@ body:
|
|||||||
id: environment
|
id: environment
|
||||||
attributes:
|
attributes:
|
||||||
label: Zed Version and System Specs
|
label: Zed Version and System Specs
|
||||||
description: 'Open Zed, and in the command palette select "zed: copy system specs into clipboard"'
|
description: 'Open Zed, and in the command palette select "zed: Copy System Specs Into Clipboard"'
|
||||||
placeholder: |
|
placeholder: |
|
||||||
Output of "zed: copy system specs into clipboard"
|
Output of "zed: Copy System Specs Into Clipboard"
|
||||||
validations:
|
validations:
|
||||||
required: true
|
required: true
|
||||||
|
|||||||
4
.github/ISSUE_TEMPLATE/10_bug_report.yml
vendored
@@ -49,8 +49,8 @@ body:
|
|||||||
attributes:
|
attributes:
|
||||||
label: Zed Version and System Specs
|
label: Zed Version and System Specs
|
||||||
description: |
|
description: |
|
||||||
Open Zed, from the command palette select "zed: copy system specs into clipboard"
|
Open Zed, from the command palette select "zed: Copy System Specs Into Clipboard"
|
||||||
placeholder: |
|
placeholder: |
|
||||||
Output of "zed: copy system specs into clipboard"
|
Output of "zed: Copy System Specs Into Clipboard"
|
||||||
validations:
|
validations:
|
||||||
required: true
|
required: true
|
||||||
|
|||||||
4
.github/ISSUE_TEMPLATE/11_crash_report.yml
vendored
@@ -26,9 +26,9 @@ body:
|
|||||||
id: environment
|
id: environment
|
||||||
attributes:
|
attributes:
|
||||||
label: Zed Version and System Specs
|
label: Zed Version and System Specs
|
||||||
description: 'Open Zed, and in the command palette select "zed: copy system specs into clipboard"'
|
description: 'Open Zed, and in the command palette select "zed: Copy System Specs Into Clipboard"'
|
||||||
placeholder: |
|
placeholder: |
|
||||||
Output of "zed: copy system specs into clipboard"
|
Output of "zed: Copy System Specs Into Clipboard"
|
||||||
validations:
|
validations:
|
||||||
required: true
|
required: true
|
||||||
- type: textarea
|
- type: textarea
|
||||||
|
|||||||
26
.github/actions/build_docs/action.yml
vendored
@@ -1,26 +0,0 @@
|
|||||||
name: "Build docs"
|
|
||||||
description: "Build the docs"
|
|
||||||
|
|
||||||
runs:
|
|
||||||
using: "composite"
|
|
||||||
steps:
|
|
||||||
- name: Setup mdBook
|
|
||||||
uses: peaceiris/actions-mdbook@ee69d230fe19748b7abf22df32acaa93833fad08 # v2
|
|
||||||
with:
|
|
||||||
mdbook-version: "0.4.37"
|
|
||||||
|
|
||||||
- name: Cache dependencies
|
|
||||||
uses: swatinem/rust-cache@9d47c6ad4b02e050fd481d890b2ea34778fd09d6 # v2
|
|
||||||
with:
|
|
||||||
save-if: ${{ github.ref == 'refs/heads/main' }}
|
|
||||||
cache-provider: "buildjet"
|
|
||||||
|
|
||||||
- name: Install Linux dependencies
|
|
||||||
shell: bash -euxo pipefail {0}
|
|
||||||
run: ./script/linux
|
|
||||||
|
|
||||||
- name: Build book
|
|
||||||
shell: bash -euxo pipefail {0}
|
|
||||||
run: |
|
|
||||||
mkdir -p target/deploy
|
|
||||||
mdbook build ./docs --dest-dir=../target/deploy/docs/
|
|
||||||
80
.github/workflows/ci.yml
vendored
@@ -73,7 +73,7 @@ jobs:
|
|||||||
timeout-minutes: 60
|
timeout-minutes: 60
|
||||||
runs-on:
|
runs-on:
|
||||||
- self-hosted
|
- self-hosted
|
||||||
- macOS
|
- test
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout repo
|
- name: Checkout repo
|
||||||
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
|
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
|
||||||
@@ -191,27 +191,6 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
config: ./typos.toml
|
config: ./typos.toml
|
||||||
|
|
||||||
check_docs:
|
|
||||||
timeout-minutes: 60
|
|
||||||
name: Check docs
|
|
||||||
needs: [job_spec]
|
|
||||||
if: github.repository_owner == 'zed-industries'
|
|
||||||
runs-on:
|
|
||||||
- buildjet-8vcpu-ubuntu-2204
|
|
||||||
steps:
|
|
||||||
- name: Checkout repo
|
|
||||||
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
|
|
||||||
with:
|
|
||||||
clean: false
|
|
||||||
|
|
||||||
- name: Configure CI
|
|
||||||
run: |
|
|
||||||
mkdir -p ./../.cargo
|
|
||||||
cp ./.cargo/ci-config.toml ./../.cargo/config.toml
|
|
||||||
|
|
||||||
- name: Build docs
|
|
||||||
uses: ./.github/actions/build_docs
|
|
||||||
|
|
||||||
macos_tests:
|
macos_tests:
|
||||||
timeout-minutes: 60
|
timeout-minutes: 60
|
||||||
name: (macOS) Run Clippy and tests
|
name: (macOS) Run Clippy and tests
|
||||||
@@ -221,7 +200,7 @@ jobs:
|
|||||||
needs.job_spec.outputs.run_tests == 'true'
|
needs.job_spec.outputs.run_tests == 'true'
|
||||||
runs-on:
|
runs-on:
|
||||||
- self-hosted
|
- self-hosted
|
||||||
- macOS
|
- test
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout repo
|
- name: Checkout repo
|
||||||
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
|
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
|
||||||
@@ -503,9 +482,7 @@ jobs:
|
|||||||
- macos_tests
|
- macos_tests
|
||||||
- windows_clippy
|
- windows_clippy
|
||||||
- windows_tests
|
- windows_tests
|
||||||
if: |
|
if: always()
|
||||||
github.repository_owner == 'zed-industries' &&
|
|
||||||
always()
|
|
||||||
steps:
|
steps:
|
||||||
- name: Check all tests passed
|
- name: Check all tests passed
|
||||||
run: |
|
run: |
|
||||||
@@ -547,6 +524,7 @@ jobs:
|
|||||||
APPLE_NOTARIZATION_KEY_ID: ${{ secrets.APPLE_NOTARIZATION_KEY_ID }}
|
APPLE_NOTARIZATION_KEY_ID: ${{ secrets.APPLE_NOTARIZATION_KEY_ID }}
|
||||||
APPLE_NOTARIZATION_ISSUER_ID: ${{ secrets.APPLE_NOTARIZATION_ISSUER_ID }}
|
APPLE_NOTARIZATION_ISSUER_ID: ${{ secrets.APPLE_NOTARIZATION_ISSUER_ID }}
|
||||||
ZED_CLIENT_CHECKSUM_SEED: ${{ secrets.ZED_CLIENT_CHECKSUM_SEED }}
|
ZED_CLIENT_CHECKSUM_SEED: ${{ secrets.ZED_CLIENT_CHECKSUM_SEED }}
|
||||||
|
ZED_CLOUD_PROVIDER_ADDITIONAL_MODELS_JSON: ${{ secrets.ZED_CLOUD_PROVIDER_ADDITIONAL_MODELS_JSON }}
|
||||||
DIGITALOCEAN_SPACES_ACCESS_KEY: ${{ secrets.DIGITALOCEAN_SPACES_ACCESS_KEY }}
|
DIGITALOCEAN_SPACES_ACCESS_KEY: ${{ secrets.DIGITALOCEAN_SPACES_ACCESS_KEY }}
|
||||||
DIGITALOCEAN_SPACES_SECRET_KEY: ${{ secrets.DIGITALOCEAN_SPACES_SECRET_KEY }}
|
DIGITALOCEAN_SPACES_SECRET_KEY: ${{ secrets.DIGITALOCEAN_SPACES_SECRET_KEY }}
|
||||||
steps:
|
steps:
|
||||||
@@ -633,6 +611,7 @@ jobs:
|
|||||||
needs: [linux_tests]
|
needs: [linux_tests]
|
||||||
env:
|
env:
|
||||||
ZED_CLIENT_CHECKSUM_SEED: ${{ secrets.ZED_CLIENT_CHECKSUM_SEED }}
|
ZED_CLIENT_CHECKSUM_SEED: ${{ secrets.ZED_CLIENT_CHECKSUM_SEED }}
|
||||||
|
ZED_CLOUD_PROVIDER_ADDITIONAL_MODELS_JSON: ${{ secrets.ZED_CLOUD_PROVIDER_ADDITIONAL_MODELS_JSON }}
|
||||||
DIGITALOCEAN_SPACES_ACCESS_KEY: ${{ secrets.DIGITALOCEAN_SPACES_ACCESS_KEY }}
|
DIGITALOCEAN_SPACES_ACCESS_KEY: ${{ secrets.DIGITALOCEAN_SPACES_ACCESS_KEY }}
|
||||||
DIGITALOCEAN_SPACES_SECRET_KEY: ${{ secrets.DIGITALOCEAN_SPACES_SECRET_KEY }}
|
DIGITALOCEAN_SPACES_SECRET_KEY: ${{ secrets.DIGITALOCEAN_SPACES_SECRET_KEY }}
|
||||||
steps:
|
steps:
|
||||||
@@ -690,6 +669,7 @@ jobs:
|
|||||||
needs: [linux_tests]
|
needs: [linux_tests]
|
||||||
env:
|
env:
|
||||||
ZED_CLIENT_CHECKSUM_SEED: ${{ secrets.ZED_CLIENT_CHECKSUM_SEED }}
|
ZED_CLIENT_CHECKSUM_SEED: ${{ secrets.ZED_CLIENT_CHECKSUM_SEED }}
|
||||||
|
ZED_CLOUD_PROVIDER_ADDITIONAL_MODELS_JSON: ${{ secrets.ZED_CLOUD_PROVIDER_ADDITIONAL_MODELS_JSON }}
|
||||||
DIGITALOCEAN_SPACES_ACCESS_KEY: ${{ secrets.DIGITALOCEAN_SPACES_ACCESS_KEY }}
|
DIGITALOCEAN_SPACES_ACCESS_KEY: ${{ secrets.DIGITALOCEAN_SPACES_ACCESS_KEY }}
|
||||||
DIGITALOCEAN_SPACES_SECRET_KEY: ${{ secrets.DIGITALOCEAN_SPACES_SECRET_KEY }}
|
DIGITALOCEAN_SPACES_SECRET_KEY: ${{ secrets.DIGITALOCEAN_SPACES_SECRET_KEY }}
|
||||||
steps:
|
steps:
|
||||||
@@ -737,13 +717,49 @@ jobs:
|
|||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
|
||||||
nix-build:
|
nix-build:
|
||||||
name: Build with Nix
|
timeout-minutes: 60
|
||||||
uses: ./.github/workflows/nix.yml
|
name: Nix Build
|
||||||
|
continue-on-error: true
|
||||||
if: github.repository_owner == 'zed-industries' && contains(github.event.pull_request.labels.*.name, 'run-nix')
|
if: github.repository_owner == 'zed-industries' && contains(github.event.pull_request.labels.*.name, 'run-nix')
|
||||||
with:
|
strategy:
|
||||||
flake-output: debug
|
fail-fast: false
|
||||||
# excludes the final package to only cache dependencies
|
matrix:
|
||||||
cachix-filter: "-zed-editor-[0-9.]*-nightly"
|
system:
|
||||||
|
- os: x86 Linux
|
||||||
|
runner: buildjet-16vcpu-ubuntu-2204
|
||||||
|
install_nix: true
|
||||||
|
- os: arm Mac
|
||||||
|
runner: [macOS, ARM64, test]
|
||||||
|
install_nix: false
|
||||||
|
runs-on: ${{ matrix.system.runner }}
|
||||||
|
env:
|
||||||
|
ZED_CLIENT_CHECKSUM_SEED: ${{ secrets.ZED_CLIENT_CHECKSUM_SEED }}
|
||||||
|
ZED_CLOUD_PROVIDER_ADDITIONAL_MODELS_JSON: ${{ secrets.ZED_CLOUD_PROVIDER_ADDITIONAL_MODELS_JSON }}
|
||||||
|
GIT_LFS_SKIP_SMUDGE: 1 # breaks the livekit rust sdk examples which we don't actually depend on
|
||||||
|
steps:
|
||||||
|
- name: Checkout repo
|
||||||
|
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
|
||||||
|
with:
|
||||||
|
clean: false
|
||||||
|
- name: Set path
|
||||||
|
if: ${{ ! matrix.system.install_nix }}
|
||||||
|
run: |
|
||||||
|
echo "/nix/var/nix/profiles/default/bin" >> $GITHUB_PATH
|
||||||
|
echo "/Users/administrator/.nix-profile/bin" >> $GITHUB_PATH
|
||||||
|
|
||||||
|
- uses: cachix/install-nix-action@d1ca217b388ee87b2507a9a93bf01368bde7cec2 # v31
|
||||||
|
if: ${{ matrix.system.install_nix }}
|
||||||
|
with:
|
||||||
|
github_access_token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
|
||||||
|
- uses: cachix/cachix-action@0fc020193b5a1fa3ac4575aa3a7d3aa6a35435ad # v16
|
||||||
|
with:
|
||||||
|
name: zed-industries
|
||||||
|
authToken: "${{ secrets.CACHIX_AUTH_TOKEN }}"
|
||||||
|
skipPush: true
|
||||||
|
- run: nix build .#debug
|
||||||
|
- name: Limit /nix/store to 50GB
|
||||||
|
run: "[ $(du -sm /nix/store | cut -f1) -gt 50000 ] && nix-collect-garbage -d"
|
||||||
|
|
||||||
auto-release-preview:
|
auto-release-preview:
|
||||||
name: Auto release preview
|
name: Auto release preview
|
||||||
|
|||||||
19
.github/workflows/deploy_cloudflare.yml
vendored
@@ -9,7 +9,7 @@ jobs:
|
|||||||
deploy-docs:
|
deploy-docs:
|
||||||
name: Deploy Docs
|
name: Deploy Docs
|
||||||
if: github.repository_owner == 'zed-industries'
|
if: github.repository_owner == 'zed-industries'
|
||||||
runs-on: buildjet-16vcpu-ubuntu-2204
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout repo
|
- name: Checkout repo
|
||||||
@@ -17,11 +17,24 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
clean: false
|
clean: false
|
||||||
|
|
||||||
|
- name: Setup mdBook
|
||||||
|
uses: peaceiris/actions-mdbook@ee69d230fe19748b7abf22df32acaa93833fad08 # v2
|
||||||
|
with:
|
||||||
|
mdbook-version: "0.4.37"
|
||||||
|
|
||||||
- name: Set up default .cargo/config.toml
|
- name: Set up default .cargo/config.toml
|
||||||
run: cp ./.cargo/collab-config.toml ./.cargo/config.toml
|
run: cp ./.cargo/collab-config.toml ./.cargo/config.toml
|
||||||
|
|
||||||
- name: Build docs
|
- name: Install system dependencies
|
||||||
uses: ./.github/actions/build_docs
|
run: |
|
||||||
|
sudo apt-get update
|
||||||
|
sudo apt-get install libxkbcommon-dev libxkbcommon-x11-dev
|
||||||
|
|
||||||
|
- name: Build book
|
||||||
|
run: |
|
||||||
|
set -euo pipefail
|
||||||
|
mkdir -p target/deploy
|
||||||
|
mdbook build ./docs --dest-dir=../target/deploy/docs/
|
||||||
|
|
||||||
- name: Deploy Docs
|
- name: Deploy Docs
|
||||||
uses: cloudflare/wrangler-action@da0e0dfe58b7a431659754fdf3f186c529afbe65 # v3
|
uses: cloudflare/wrangler-action@da0e0dfe58b7a431659754fdf3f186c529afbe65 # v3
|
||||||
|
|||||||
4
.github/workflows/deploy_collab.yml
vendored
@@ -15,7 +15,7 @@ jobs:
|
|||||||
if: github.repository_owner == 'zed-industries'
|
if: github.repository_owner == 'zed-industries'
|
||||||
runs-on:
|
runs-on:
|
||||||
- self-hosted
|
- self-hosted
|
||||||
- macOS
|
- test
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout repo
|
- name: Checkout repo
|
||||||
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
|
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
|
||||||
@@ -33,7 +33,7 @@ jobs:
|
|||||||
name: Run tests
|
name: Run tests
|
||||||
runs-on:
|
runs-on:
|
||||||
- self-hosted
|
- self-hosted
|
||||||
- macOS
|
- test
|
||||||
needs: style
|
needs: style
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout repo
|
- name: Checkout repo
|
||||||
|
|||||||
66
.github/workflows/nix.yml
vendored
@@ -1,66 +0,0 @@
|
|||||||
name: "Nix build"
|
|
||||||
|
|
||||||
on:
|
|
||||||
workflow_call:
|
|
||||||
inputs:
|
|
||||||
flake-output:
|
|
||||||
type: string
|
|
||||||
default: "default"
|
|
||||||
cachix-filter:
|
|
||||||
type: string
|
|
||||||
default: ""
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
nix-build:
|
|
||||||
timeout-minutes: 60
|
|
||||||
name: (${{ matrix.system.os }}) Nix Build
|
|
||||||
continue-on-error: true # TODO: remove when we want this to start blocking CI
|
|
||||||
strategy:
|
|
||||||
fail-fast: false
|
|
||||||
matrix:
|
|
||||||
system:
|
|
||||||
- os: x86 Linux
|
|
||||||
runner: buildjet-16vcpu-ubuntu-2204
|
|
||||||
install_nix: true
|
|
||||||
- os: arm Mac
|
|
||||||
runner: [macOS, ARM64, test]
|
|
||||||
install_nix: false
|
|
||||||
if: github.repository_owner == 'zed-industries'
|
|
||||||
runs-on: ${{ matrix.system.runner }}
|
|
||||||
env:
|
|
||||||
ZED_CLIENT_CHECKSUM_SEED: ${{ secrets.ZED_CLIENT_CHECKSUM_SEED }}
|
|
||||||
ZED_CLOUD_PROVIDER_ADDITIONAL_MODELS_JSON: ${{ secrets.ZED_CLOUD_PROVIDER_ADDITIONAL_MODELS_JSON }}
|
|
||||||
GIT_LFS_SKIP_SMUDGE: 1 # breaks the livekit rust sdk examples which we don't actually depend on
|
|
||||||
steps:
|
|
||||||
- name: Checkout repo
|
|
||||||
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
|
|
||||||
with:
|
|
||||||
clean: false
|
|
||||||
|
|
||||||
# on our macs we manually install nix. for some reason the cachix action is running
|
|
||||||
# under a non-login /bin/bash shell which doesn't source the proper script to add the
|
|
||||||
# nix profile to PATH, so we manually add them here
|
|
||||||
- name: Set path
|
|
||||||
if: ${{ ! matrix.system.install_nix }}
|
|
||||||
run: |
|
|
||||||
echo "/nix/var/nix/profiles/default/bin" >> $GITHUB_PATH
|
|
||||||
echo "/Users/administrator/.nix-profile/bin" >> $GITHUB_PATH
|
|
||||||
|
|
||||||
- uses: cachix/install-nix-action@02a151ada4993995686f9ed4f1be7cfbb229e56f # v31
|
|
||||||
if: ${{ matrix.system.install_nix }}
|
|
||||||
with:
|
|
||||||
github_access_token: ${{ secrets.GITHUB_TOKEN }}
|
|
||||||
|
|
||||||
- uses: cachix/cachix-action@0fc020193b5a1fa3ac4575aa3a7d3aa6a35435ad # v16
|
|
||||||
with:
|
|
||||||
name: zed
|
|
||||||
authToken: "${{ secrets.CACHIX_AUTH_TOKEN }}"
|
|
||||||
pushFilter: "${{ inputs.cachix-filter }}"
|
|
||||||
cachixArgs: '-v'
|
|
||||||
|
|
||||||
- run: nix build .#${{ inputs.flake-output }} -L --accept-flake-config
|
|
||||||
|
|
||||||
- name: Limit /nix/store to 50GB on macs
|
|
||||||
if: ${{ ! matrix.system.install_nix }}
|
|
||||||
run: |
|
|
||||||
[ $(du -sm /nix/store | cut -f1) -gt 50000 ] && nix-collect-garbage -d || :
|
|
||||||
12
.github/workflows/release_nightly.yml
vendored
@@ -20,7 +20,7 @@ jobs:
|
|||||||
if: github.repository_owner == 'zed-industries'
|
if: github.repository_owner == 'zed-industries'
|
||||||
runs-on:
|
runs-on:
|
||||||
- self-hosted
|
- self-hosted
|
||||||
- macOS
|
- test
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout repo
|
- name: Checkout repo
|
||||||
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
|
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
|
||||||
@@ -40,7 +40,7 @@ jobs:
|
|||||||
if: github.repository_owner == 'zed-industries'
|
if: github.repository_owner == 'zed-industries'
|
||||||
runs-on:
|
runs-on:
|
||||||
- self-hosted
|
- self-hosted
|
||||||
- macOS
|
- test
|
||||||
needs: style
|
needs: style
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout repo
|
- name: Checkout repo
|
||||||
@@ -68,6 +68,7 @@ jobs:
|
|||||||
DIGITALOCEAN_SPACES_ACCESS_KEY: ${{ secrets.DIGITALOCEAN_SPACES_ACCESS_KEY }}
|
DIGITALOCEAN_SPACES_ACCESS_KEY: ${{ secrets.DIGITALOCEAN_SPACES_ACCESS_KEY }}
|
||||||
DIGITALOCEAN_SPACES_SECRET_KEY: ${{ secrets.DIGITALOCEAN_SPACES_SECRET_KEY }}
|
DIGITALOCEAN_SPACES_SECRET_KEY: ${{ secrets.DIGITALOCEAN_SPACES_SECRET_KEY }}
|
||||||
ZED_CLIENT_CHECKSUM_SEED: ${{ secrets.ZED_CLIENT_CHECKSUM_SEED }}
|
ZED_CLIENT_CHECKSUM_SEED: ${{ secrets.ZED_CLIENT_CHECKSUM_SEED }}
|
||||||
|
ZED_CLOUD_PROVIDER_ADDITIONAL_MODELS_JSON: ${{ secrets.ZED_CLOUD_PROVIDER_ADDITIONAL_MODELS_JSON }}
|
||||||
steps:
|
steps:
|
||||||
- name: Install Node
|
- name: Install Node
|
||||||
uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4
|
uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4
|
||||||
@@ -103,6 +104,7 @@ jobs:
|
|||||||
DIGITALOCEAN_SPACES_ACCESS_KEY: ${{ secrets.DIGITALOCEAN_SPACES_ACCESS_KEY }}
|
DIGITALOCEAN_SPACES_ACCESS_KEY: ${{ secrets.DIGITALOCEAN_SPACES_ACCESS_KEY }}
|
||||||
DIGITALOCEAN_SPACES_SECRET_KEY: ${{ secrets.DIGITALOCEAN_SPACES_SECRET_KEY }}
|
DIGITALOCEAN_SPACES_SECRET_KEY: ${{ secrets.DIGITALOCEAN_SPACES_SECRET_KEY }}
|
||||||
ZED_CLIENT_CHECKSUM_SEED: ${{ secrets.ZED_CLIENT_CHECKSUM_SEED }}
|
ZED_CLIENT_CHECKSUM_SEED: ${{ secrets.ZED_CLIENT_CHECKSUM_SEED }}
|
||||||
|
ZED_CLOUD_PROVIDER_ADDITIONAL_MODELS_JSON: ${{ secrets.ZED_CLOUD_PROVIDER_ADDITIONAL_MODELS_JSON }}
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout repo
|
- name: Checkout repo
|
||||||
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
|
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
|
||||||
@@ -142,6 +144,7 @@ jobs:
|
|||||||
DIGITALOCEAN_SPACES_ACCESS_KEY: ${{ secrets.DIGITALOCEAN_SPACES_ACCESS_KEY }}
|
DIGITALOCEAN_SPACES_ACCESS_KEY: ${{ secrets.DIGITALOCEAN_SPACES_ACCESS_KEY }}
|
||||||
DIGITALOCEAN_SPACES_SECRET_KEY: ${{ secrets.DIGITALOCEAN_SPACES_SECRET_KEY }}
|
DIGITALOCEAN_SPACES_SECRET_KEY: ${{ secrets.DIGITALOCEAN_SPACES_SECRET_KEY }}
|
||||||
ZED_CLIENT_CHECKSUM_SEED: ${{ secrets.ZED_CLIENT_CHECKSUM_SEED }}
|
ZED_CLIENT_CHECKSUM_SEED: ${{ secrets.ZED_CLIENT_CHECKSUM_SEED }}
|
||||||
|
ZED_CLOUD_PROVIDER_ADDITIONAL_MODELS_JSON: ${{ secrets.ZED_CLOUD_PROVIDER_ADDITIONAL_MODELS_JSON }}
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout repo
|
- name: Checkout repo
|
||||||
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
|
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
|
||||||
@@ -167,11 +170,6 @@ jobs:
|
|||||||
- name: Upload Zed Nightly
|
- name: Upload Zed Nightly
|
||||||
run: script/upload-nightly linux-targz
|
run: script/upload-nightly linux-targz
|
||||||
|
|
||||||
bundle-nix:
|
|
||||||
name: Build and cache Nix package
|
|
||||||
needs: tests
|
|
||||||
uses: ./.github/workflows/nix.yml
|
|
||||||
|
|
||||||
update-nightly-tag:
|
update-nightly-tag:
|
||||||
name: Update nightly tag
|
name: Update nightly tag
|
||||||
if: github.repository_owner == 'zed-industries'
|
if: github.repository_owner == 'zed-industries'
|
||||||
|
|||||||
85
.github/workflows/unit_evals.yml
vendored
@@ -1,85 +0,0 @@
|
|||||||
name: Run Unit Evals
|
|
||||||
|
|
||||||
on:
|
|
||||||
schedule:
|
|
||||||
# GitHub might drop jobs at busy times, so we choose a random time in the middle of the night.
|
|
||||||
- cron: "47 1 * * *"
|
|
||||||
workflow_dispatch:
|
|
||||||
|
|
||||||
concurrency:
|
|
||||||
# Allow only one workflow per any non-`main` branch.
|
|
||||||
group: ${{ github.workflow }}-${{ github.ref_name }}-${{ github.ref_name == 'main' && github.sha || 'anysha' }}
|
|
||||||
cancel-in-progress: true
|
|
||||||
|
|
||||||
env:
|
|
||||||
CARGO_TERM_COLOR: always
|
|
||||||
CARGO_INCREMENTAL: 0
|
|
||||||
RUST_BACKTRACE: 1
|
|
||||||
ZED_CLIENT_CHECKSUM_SEED: ${{ secrets.ZED_CLIENT_CHECKSUM_SEED }}
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
unit_evals:
|
|
||||||
timeout-minutes: 60
|
|
||||||
name: Run unit evals
|
|
||||||
runs-on:
|
|
||||||
- buildjet-16vcpu-ubuntu-2204
|
|
||||||
steps:
|
|
||||||
- name: Add Rust to the PATH
|
|
||||||
run: echo "$HOME/.cargo/bin" >> $GITHUB_PATH
|
|
||||||
|
|
||||||
- name: Checkout repo
|
|
||||||
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
|
|
||||||
with:
|
|
||||||
clean: false
|
|
||||||
|
|
||||||
- name: Cache dependencies
|
|
||||||
uses: swatinem/rust-cache@9d47c6ad4b02e050fd481d890b2ea34778fd09d6 # v2
|
|
||||||
with:
|
|
||||||
save-if: ${{ github.ref == 'refs/heads/main' }}
|
|
||||||
cache-provider: "buildjet"
|
|
||||||
|
|
||||||
- name: Install Linux dependencies
|
|
||||||
run: ./script/linux
|
|
||||||
|
|
||||||
- name: Configure CI
|
|
||||||
run: |
|
|
||||||
mkdir -p ./../.cargo
|
|
||||||
cp ./.cargo/ci-config.toml ./../.cargo/config.toml
|
|
||||||
|
|
||||||
- name: Install Rust
|
|
||||||
shell: bash -euxo pipefail {0}
|
|
||||||
run: |
|
|
||||||
cargo install cargo-nextest --locked
|
|
||||||
|
|
||||||
- name: Install Node
|
|
||||||
uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4
|
|
||||||
with:
|
|
||||||
node-version: "18"
|
|
||||||
|
|
||||||
- name: Limit target directory size
|
|
||||||
shell: bash -euxo pipefail {0}
|
|
||||||
run: script/clear-target-dir-if-larger-than 100
|
|
||||||
|
|
||||||
- name: Run unit evals
|
|
||||||
shell: bash -euxo pipefail {0}
|
|
||||||
run: cargo nextest run --workspace --no-fail-fast --features eval --no-capture -E 'test(::eval_)' --test-threads 1
|
|
||||||
env:
|
|
||||||
ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }}
|
|
||||||
|
|
||||||
- name: Send the pull request link into the Slack channel
|
|
||||||
if: ${{ failure() }}
|
|
||||||
uses: slackapi/slack-github-action@b0fa283ad8fea605de13dc3f449259339835fc52
|
|
||||||
with:
|
|
||||||
method: chat.postMessage
|
|
||||||
token: ${{ secrets.SLACK_APP_ZED_UNIT_EVALS_BOT_TOKEN }}
|
|
||||||
payload: |
|
|
||||||
channel: C04UDRNNJFQ
|
|
||||||
text: "Unit Evals Failed: https://github.com/zed-industries/zed/actions/runs/${{ github.run_id }}"
|
|
||||||
|
|
||||||
# Even the Linux runner is not stateful, in theory there is no need to do this cleanup.
|
|
||||||
# But, to avoid potential issues in the future if we choose to use a stateful Linux runner and forget to add code
|
|
||||||
# to clean up the config file, I’ve included the cleanup code here as a precaution.
|
|
||||||
# While it’s not strictly necessary at this moment, I believe it’s better to err on the side of caution.
|
|
||||||
- name: Clean CI config file
|
|
||||||
if: always()
|
|
||||||
run: rm -rf ./../.cargo
|
|
||||||
1
.gitignore
vendored
@@ -2,7 +2,6 @@
|
|||||||
**/cargo-target
|
**/cargo-target
|
||||||
**/target
|
**/target
|
||||||
**/venv
|
**/venv
|
||||||
**/.direnv
|
|
||||||
*.wasm
|
*.wasm
|
||||||
*.xcodeproj
|
*.xcodeproj
|
||||||
.DS_Store
|
.DS_Store
|
||||||
|
|||||||
20
.mailmap
@@ -19,8 +19,6 @@ amtoaer <amtoaer@gmail.com>
|
|||||||
amtoaer <amtoaer@gmail.com> <amtoaer@outlook.com>
|
amtoaer <amtoaer@gmail.com> <amtoaer@outlook.com>
|
||||||
Andrei Zvonimir Crnković <andrei@0x7f.dev>
|
Andrei Zvonimir Crnković <andrei@0x7f.dev>
|
||||||
Andrei Zvonimir Crnković <andrei@0x7f.dev> <andreicek@0x7f.dev>
|
Andrei Zvonimir Crnković <andrei@0x7f.dev> <andreicek@0x7f.dev>
|
||||||
Angelk90 <angelo.k90@hotmail.it>
|
|
||||||
Angelk90 <angelo.k90@hotmail.it> <20476002+Angelk90@users.noreply.github.com>
|
|
||||||
Antonio Scandurra <me@as-cii.com>
|
Antonio Scandurra <me@as-cii.com>
|
||||||
Antonio Scandurra <me@as-cii.com> <antonio@zed.dev>
|
Antonio Scandurra <me@as-cii.com> <antonio@zed.dev>
|
||||||
Ben Kunkle <ben@zed.dev>
|
Ben Kunkle <ben@zed.dev>
|
||||||
@@ -40,8 +38,6 @@ Dairon Medina <dairon.medina@gmail.com>
|
|||||||
Danilo Leal <danilo@zed.dev>
|
Danilo Leal <danilo@zed.dev>
|
||||||
Danilo Leal <danilo@zed.dev> <67129314+danilo-leal@users.noreply.github.com>
|
Danilo Leal <danilo@zed.dev> <67129314+danilo-leal@users.noreply.github.com>
|
||||||
Edwin Aronsson <75266237+4teapo@users.noreply.github.com>
|
Edwin Aronsson <75266237+4teapo@users.noreply.github.com>
|
||||||
Elvis Pranskevichus <elvis@geldata.com>
|
|
||||||
Elvis Pranskevichus <elvis@geldata.com> <elvis@magic.io>
|
|
||||||
Evren Sen <nervenes@icloud.com>
|
Evren Sen <nervenes@icloud.com>
|
||||||
Evren Sen <nervenes@icloud.com> <146845123+evrensen467@users.noreply.github.com>
|
Evren Sen <nervenes@icloud.com> <146845123+evrensen467@users.noreply.github.com>
|
||||||
Evren Sen <nervenes@icloud.com> <146845123+evrsen@users.noreply.github.com>
|
Evren Sen <nervenes@icloud.com> <146845123+evrsen@users.noreply.github.com>
|
||||||
@@ -73,8 +69,6 @@ Lilith Iris <itslirissama@gmail.com> <83819417+Irilith@users.noreply.github.com>
|
|||||||
LoganDark <contact@logandark.mozmail.com>
|
LoganDark <contact@logandark.mozmail.com>
|
||||||
LoganDark <contact@logandark.mozmail.com> <git@logandark.mozmail.com>
|
LoganDark <contact@logandark.mozmail.com> <git@logandark.mozmail.com>
|
||||||
LoganDark <contact@logandark.mozmail.com> <github@logandark.mozmail.com>
|
LoganDark <contact@logandark.mozmail.com> <github@logandark.mozmail.com>
|
||||||
Marko Kungla <marko.kungla@gmail.com>
|
|
||||||
Marko Kungla <marko.kungla@gmail.com> <marko@mkungla.dev>
|
|
||||||
Marshall Bowers <git@maxdeviant.com>
|
Marshall Bowers <git@maxdeviant.com>
|
||||||
Marshall Bowers <git@maxdeviant.com> <elliott.codes@gmail.com>
|
Marshall Bowers <git@maxdeviant.com> <elliott.codes@gmail.com>
|
||||||
Marshall Bowers <git@maxdeviant.com> <marshall@zed.dev>
|
Marshall Bowers <git@maxdeviant.com> <marshall@zed.dev>
|
||||||
@@ -90,7 +84,6 @@ Michael Sloan <michael@zed.dev> <mgsloan@google.com>
|
|||||||
Mikayla Maki <mikayla@zed.dev>
|
Mikayla Maki <mikayla@zed.dev>
|
||||||
Mikayla Maki <mikayla@zed.dev> <mikayla.c.maki@gmail.com>
|
Mikayla Maki <mikayla@zed.dev> <mikayla.c.maki@gmail.com>
|
||||||
Mikayla Maki <mikayla@zed.dev> <mikayla.c.maki@icloud.com>
|
Mikayla Maki <mikayla@zed.dev> <mikayla.c.maki@icloud.com>
|
||||||
Morgan Krey <morgan@zed.dev>
|
|
||||||
Muhammad Talal Anwar <mail@talal.io>
|
Muhammad Talal Anwar <mail@talal.io>
|
||||||
Muhammad Talal Anwar <mail@talal.io> <talalanwar@outlook.com>
|
Muhammad Talal Anwar <mail@talal.io> <talalanwar@outlook.com>
|
||||||
Nate Butler <iamnbutler@gmail.com>
|
Nate Butler <iamnbutler@gmail.com>
|
||||||
@@ -123,18 +116,11 @@ Shish <webmaster@shishnet.org>
|
|||||||
Shish <webmaster@shishnet.org> <shish@shishnet.org>
|
Shish <webmaster@shishnet.org> <shish@shishnet.org>
|
||||||
Smit Barmase <0xtimsb@gmail.com>
|
Smit Barmase <0xtimsb@gmail.com>
|
||||||
Smit Barmase <0xtimsb@gmail.com> <smit@zed.dev>
|
Smit Barmase <0xtimsb@gmail.com> <smit@zed.dev>
|
||||||
Thomas <github.thomaub@gmail.com>
|
|
||||||
Thomas <github.thomaub@gmail.com> <thomas.aubry94@gmail.com>
|
|
||||||
Thomas <github.thomaub@gmail.com> <thomas.aubry@paylead.fr>
|
|
||||||
Thomas Heartman <thomasheartman+github@gmail.com>
|
|
||||||
Thomas Heartman <thomasheartman+github@gmail.com> <thomas@getunleash.io>
|
|
||||||
Thomas Mickley-Doyle <tmickleydoyle@gmail.com>
|
|
||||||
Thomas Mickley-Doyle <tmickleydoyle@gmail.com> <thomas@zed.dev>
|
|
||||||
Thorben Kröger <dev@thorben.net>
|
Thorben Kröger <dev@thorben.net>
|
||||||
Thorben Kröger <dev@thorben.net> <thorben.kroeger@hexagon.com>
|
Thorben Kröger <dev@thorben.net> <thorben.kroeger@hexagon.com>
|
||||||
Thorsten Ball <mrnugget@gmail.com>
|
Thorsten Ball <thorsten@zed.dev>
|
||||||
Thorsten Ball <mrnugget@gmail.com> <me@thorstenball.com>
|
Thorsten Ball <thorsten@zed.dev> <me@thorstenball.com>
|
||||||
Thorsten Ball <mrnugget@gmail.com> <thorsten@zed.dev>
|
Thorsten Ball <thorsten@zed.dev> <mrnugget@gmail.com>
|
||||||
Tristan Hume <tris.hume@gmail.com>
|
Tristan Hume <tris.hume@gmail.com>
|
||||||
Tristan Hume <tris.hume@gmail.com> <tristan@anthropic.com>
|
Tristan Hume <tris.hume@gmail.com> <tristan@anthropic.com>
|
||||||
Uladzislau Kaminski <i@uladkaminski.com>
|
Uladzislau Kaminski <i@uladkaminski.com>
|
||||||
|
|||||||
8
.rules
@@ -5,12 +5,6 @@
|
|||||||
* Prefer implementing functionality in existing files unless it is a new logical component. Avoid creating many small files.
|
* Prefer implementing functionality in existing files unless it is a new logical component. Avoid creating many small files.
|
||||||
* Avoid using functions that panic like `unwrap()`, instead use mechanisms like `?` to propagate errors.
|
* Avoid using functions that panic like `unwrap()`, instead use mechanisms like `?` to propagate errors.
|
||||||
* Be careful with operations like indexing which may panic if the indexes are out of bounds.
|
* Be careful with operations like indexing which may panic if the indexes are out of bounds.
|
||||||
* Never silently discard errors with `let _ =` on fallible operations. Always handle errors appropriately:
|
|
||||||
- Propagate errors with `?` when the calling function should handle them
|
|
||||||
- Use `.log_err()` or similar when you need to ignore errors but want visibility
|
|
||||||
- Use explicit error handling with `match` or `if let Err(...)` when you need custom logic
|
|
||||||
- Example: avoid `let _ = client.request(...).await?;` - use `client.request(...).await?;` instead
|
|
||||||
* When implementing async operations that may fail, ensure errors propagate to the UI layer so users get meaningful feedback.
|
|
||||||
* Never create files with `mod.rs` paths - prefer `src/some_module.rs` instead of `src/some_module/mod.rs`.
|
* Never create files with `mod.rs` paths - prefer `src/some_module.rs` instead of `src/some_module/mod.rs`.
|
||||||
|
|
||||||
# GPUI
|
# GPUI
|
||||||
@@ -121,7 +115,7 @@ Other entities can then register a callback to handle these events by doing `cx.
|
|||||||
GPUI has had some changes to its APIs. Always write code using the new APIs:
|
GPUI has had some changes to its APIs. Always write code using the new APIs:
|
||||||
|
|
||||||
* `spawn` methods now take async closures (`AsyncFn`), and so should be called like `cx.spawn(async move |cx| ...)`.
|
* `spawn` methods now take async closures (`AsyncFn`), and so should be called like `cx.spawn(async move |cx| ...)`.
|
||||||
* Use `Entity<T>`. This replaces `Model<T>` and `View<T>` which no longer exist and should NEVER be used.
|
* Use `Entity<T>`. This replaces `Model<T>` and `View<T>` which longer exists and should NEVER be used.
|
||||||
* Use `App` references. This replaces `AppContext` which no longer exists and should NEVER be used.
|
* Use `App` references. This replaces `AppContext` which no longer exists and should NEVER be used.
|
||||||
* Use `Context<T>` references. This replaces `ModelContext<T>` which no longer exists and should NEVER be used.
|
* Use `Context<T>` references. This replaces `ModelContext<T>` which no longer exists and should NEVER be used.
|
||||||
* `Window` is now passed around explicitly. The new interface adds a `Window` reference parameter to some methods, and adds some new "*_in" methods for plumbing `Window`. The old types `WindowContext` and `ViewContext<T>` should NEVER be used.
|
* `Window` is now passed around explicitly. The new interface adds a `Window` reference parameter to some methods, and adds some new "*_in" methods for plumbing `Window`. The old types `WindowContext` and `ViewContext<T>` should NEVER be used.
|
||||||
|
|||||||
@@ -2,11 +2,18 @@
|
|||||||
{
|
{
|
||||||
"label": "Debug Zed (CodeLLDB)",
|
"label": "Debug Zed (CodeLLDB)",
|
||||||
"adapter": "CodeLLDB",
|
"adapter": "CodeLLDB",
|
||||||
"build": { "label": "Build Zed", "command": "cargo", "args": ["build"] }
|
"program": "$ZED_WORKTREE_ROOT/target/debug/zed",
|
||||||
|
"request": "launch",
|
||||||
|
"cwd": "$ZED_WORKTREE_ROOT"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"label": "Debug Zed (GDB)",
|
"label": "Debug Zed (GDB)",
|
||||||
"adapter": "GDB",
|
"adapter": "GDB",
|
||||||
"build": { "label": "Build Zed", "command": "cargo", "args": ["build"] }
|
"program": "$ZED_WORKTREE_ROOT/target/debug/zed",
|
||||||
|
"request": "launch",
|
||||||
|
"cwd": "$ZED_WORKTREE_ROOT",
|
||||||
|
"initialize_args": {
|
||||||
|
"stopAtBeginningOfMainSubprogram": true
|
||||||
|
}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|||||||
1855
Cargo.lock
generated
47
Cargo.toml
@@ -3,11 +3,11 @@ resolver = "2"
|
|||||||
members = [
|
members = [
|
||||||
"crates/activity_indicator",
|
"crates/activity_indicator",
|
||||||
"crates/agent",
|
"crates/agent",
|
||||||
"crates/agent_settings",
|
|
||||||
"crates/anthropic",
|
"crates/anthropic",
|
||||||
"crates/askpass",
|
"crates/askpass",
|
||||||
"crates/assets",
|
"crates/assets",
|
||||||
"crates/assistant_context_editor",
|
"crates/assistant_context_editor",
|
||||||
|
"crates/assistant_settings",
|
||||||
"crates/assistant_slash_command",
|
"crates/assistant_slash_command",
|
||||||
"crates/assistant_slash_commands",
|
"crates/assistant_slash_commands",
|
||||||
"crates/assistant_tool",
|
"crates/assistant_tool",
|
||||||
@@ -31,13 +31,13 @@ members = [
|
|||||||
"crates/command_palette",
|
"crates/command_palette",
|
||||||
"crates/command_palette_hooks",
|
"crates/command_palette_hooks",
|
||||||
"crates/component",
|
"crates/component",
|
||||||
|
"crates/component_preview",
|
||||||
"crates/context_server",
|
"crates/context_server",
|
||||||
"crates/copilot",
|
"crates/copilot",
|
||||||
"crates/credentials_provider",
|
"crates/credentials_provider",
|
||||||
"crates/dap",
|
"crates/dap",
|
||||||
"crates/dap_adapters",
|
"crates/dap_adapters",
|
||||||
"crates/db",
|
"crates/db",
|
||||||
"crates/debug_adapter_extension",
|
|
||||||
"crates/debugger_tools",
|
"crates/debugger_tools",
|
||||||
"crates/debugger_ui",
|
"crates/debugger_ui",
|
||||||
"crates/deepseek",
|
"crates/deepseek",
|
||||||
@@ -73,14 +73,12 @@ members = [
|
|||||||
"crates/indexed_docs",
|
"crates/indexed_docs",
|
||||||
"crates/inline_completion",
|
"crates/inline_completion",
|
||||||
"crates/inline_completion_button",
|
"crates/inline_completion_button",
|
||||||
"crates/inspector_ui",
|
|
||||||
"crates/install_cli",
|
"crates/install_cli",
|
||||||
"crates/jj",
|
|
||||||
"crates/jj_ui",
|
|
||||||
"crates/journal",
|
"crates/journal",
|
||||||
"crates/language",
|
"crates/language",
|
||||||
"crates/language_extension",
|
"crates/language_extension",
|
||||||
"crates/language_model",
|
"crates/language_model",
|
||||||
|
"crates/language_model_selector",
|
||||||
"crates/language_models",
|
"crates/language_models",
|
||||||
"crates/language_selector",
|
"crates/language_selector",
|
||||||
"crates/language_tools",
|
"crates/language_tools",
|
||||||
@@ -100,7 +98,6 @@ members = [
|
|||||||
"crates/notifications",
|
"crates/notifications",
|
||||||
"crates/ollama",
|
"crates/ollama",
|
||||||
"crates/open_ai",
|
"crates/open_ai",
|
||||||
"crates/open_router",
|
|
||||||
"crates/outline",
|
"crates/outline",
|
||||||
"crates/outline_panel",
|
"crates/outline_panel",
|
||||||
"crates/panel",
|
"crates/panel",
|
||||||
@@ -212,12 +209,12 @@ edition = "2024"
|
|||||||
|
|
||||||
activity_indicator = { path = "crates/activity_indicator" }
|
activity_indicator = { path = "crates/activity_indicator" }
|
||||||
agent = { path = "crates/agent" }
|
agent = { path = "crates/agent" }
|
||||||
agent_settings = { path = "crates/agent_settings" }
|
|
||||||
ai = { path = "crates/ai" }
|
ai = { path = "crates/ai" }
|
||||||
anthropic = { path = "crates/anthropic" }
|
anthropic = { path = "crates/anthropic" }
|
||||||
askpass = { path = "crates/askpass" }
|
askpass = { path = "crates/askpass" }
|
||||||
assets = { path = "crates/assets" }
|
assets = { path = "crates/assets" }
|
||||||
assistant_context_editor = { path = "crates/assistant_context_editor" }
|
assistant_context_editor = { path = "crates/assistant_context_editor" }
|
||||||
|
assistant_settings = { path = "crates/assistant_settings" }
|
||||||
assistant_slash_command = { path = "crates/assistant_slash_command" }
|
assistant_slash_command = { path = "crates/assistant_slash_command" }
|
||||||
assistant_slash_commands = { path = "crates/assistant_slash_commands" }
|
assistant_slash_commands = { path = "crates/assistant_slash_commands" }
|
||||||
assistant_tool = { path = "crates/assistant_tool" }
|
assistant_tool = { path = "crates/assistant_tool" }
|
||||||
@@ -241,13 +238,13 @@ collections = { path = "crates/collections" }
|
|||||||
command_palette = { path = "crates/command_palette" }
|
command_palette = { path = "crates/command_palette" }
|
||||||
command_palette_hooks = { path = "crates/command_palette_hooks" }
|
command_palette_hooks = { path = "crates/command_palette_hooks" }
|
||||||
component = { path = "crates/component" }
|
component = { path = "crates/component" }
|
||||||
|
component_preview = { path = "crates/component_preview" }
|
||||||
context_server = { path = "crates/context_server" }
|
context_server = { path = "crates/context_server" }
|
||||||
copilot = { path = "crates/copilot" }
|
copilot = { path = "crates/copilot" }
|
||||||
credentials_provider = { path = "crates/credentials_provider" }
|
credentials_provider = { path = "crates/credentials_provider" }
|
||||||
dap = { path = "crates/dap" }
|
dap = { path = "crates/dap" }
|
||||||
dap_adapters = { path = "crates/dap_adapters" }
|
dap_adapters = { path = "crates/dap_adapters" }
|
||||||
db = { path = "crates/db" }
|
db = { path = "crates/db" }
|
||||||
debug_adapter_extension = { path = "crates/debug_adapter_extension" }
|
|
||||||
debugger_tools = { path = "crates/debugger_tools" }
|
debugger_tools = { path = "crates/debugger_tools" }
|
||||||
debugger_ui = { path = "crates/debugger_ui" }
|
debugger_ui = { path = "crates/debugger_ui" }
|
||||||
deepseek = { path = "crates/deepseek" }
|
deepseek = { path = "crates/deepseek" }
|
||||||
@@ -281,14 +278,12 @@ image_viewer = { path = "crates/image_viewer" }
|
|||||||
indexed_docs = { path = "crates/indexed_docs" }
|
indexed_docs = { path = "crates/indexed_docs" }
|
||||||
inline_completion = { path = "crates/inline_completion" }
|
inline_completion = { path = "crates/inline_completion" }
|
||||||
inline_completion_button = { path = "crates/inline_completion_button" }
|
inline_completion_button = { path = "crates/inline_completion_button" }
|
||||||
inspector_ui = { path = "crates/inspector_ui" }
|
|
||||||
install_cli = { path = "crates/install_cli" }
|
install_cli = { path = "crates/install_cli" }
|
||||||
jj = { path = "crates/jj" }
|
|
||||||
jj_ui = { path = "crates/jj_ui" }
|
|
||||||
journal = { path = "crates/journal" }
|
journal = { path = "crates/journal" }
|
||||||
language = { path = "crates/language" }
|
language = { path = "crates/language" }
|
||||||
language_extension = { path = "crates/language_extension" }
|
language_extension = { path = "crates/language_extension" }
|
||||||
language_model = { path = "crates/language_model" }
|
language_model = { path = "crates/language_model" }
|
||||||
|
language_model_selector = { path = "crates/language_model_selector" }
|
||||||
language_models = { path = "crates/language_models" }
|
language_models = { path = "crates/language_models" }
|
||||||
language_selector = { path = "crates/language_selector" }
|
language_selector = { path = "crates/language_selector" }
|
||||||
language_tools = { path = "crates/language_tools" }
|
language_tools = { path = "crates/language_tools" }
|
||||||
@@ -308,7 +303,6 @@ node_runtime = { path = "crates/node_runtime" }
|
|||||||
notifications = { path = "crates/notifications" }
|
notifications = { path = "crates/notifications" }
|
||||||
ollama = { path = "crates/ollama" }
|
ollama = { path = "crates/ollama" }
|
||||||
open_ai = { path = "crates/open_ai" }
|
open_ai = { path = "crates/open_ai" }
|
||||||
open_router = { path = "crates/open_router", features = ["schemars"] }
|
|
||||||
outline = { path = "crates/outline" }
|
outline = { path = "crates/outline" }
|
||||||
outline_panel = { path = "crates/outline_panel" }
|
outline_panel = { path = "crates/outline_panel" }
|
||||||
panel = { path = "crates/panel" }
|
panel = { path = "crates/panel" }
|
||||||
@@ -432,9 +426,8 @@ convert_case = "0.8.0"
|
|||||||
core-foundation = "0.10.0"
|
core-foundation = "0.10.0"
|
||||||
core-foundation-sys = "0.8.6"
|
core-foundation-sys = "0.8.6"
|
||||||
core-video = { version = "0.4.3", features = ["metal"] }
|
core-video = { version = "0.4.3", features = ["metal"] }
|
||||||
criterion = { version = "0.5", features = ["html_reports"] }
|
|
||||||
ctor = "0.4.0"
|
ctor = "0.4.0"
|
||||||
dap-types = { git = "https://github.com/zed-industries/dap-types", rev = "68516de327fa1be15214133a0a2e52a12982ce75" }
|
dap-types = { git = "https://github.com/zed-industries/dap-types", rev = "be69a016ba710191b9fdded28c8b042af4b617f7" }
|
||||||
dashmap = "6.0"
|
dashmap = "6.0"
|
||||||
derive_more = "0.99.17"
|
derive_more = "0.99.17"
|
||||||
dirs = "4.0"
|
dirs = "4.0"
|
||||||
@@ -451,7 +444,6 @@ futures-batch = "0.6.1"
|
|||||||
futures-lite = "1.13"
|
futures-lite = "1.13"
|
||||||
git2 = { version = "0.20.1", default-features = false }
|
git2 = { version = "0.20.1", default-features = false }
|
||||||
globset = "0.4"
|
globset = "0.4"
|
||||||
hashbrown = "0.15.3"
|
|
||||||
handlebars = "4.3"
|
handlebars = "4.3"
|
||||||
heck = "0.5"
|
heck = "0.5"
|
||||||
heed = { version = "0.21.0", features = ["read-txn-no-tls"] }
|
heed = { version = "0.21.0", features = ["read-txn-no-tls"] }
|
||||||
@@ -466,8 +458,6 @@ indexmap = { version = "2.7.0", features = ["serde"] }
|
|||||||
indoc = "2"
|
indoc = "2"
|
||||||
inventory = "0.3.19"
|
inventory = "0.3.19"
|
||||||
itertools = "0.14.0"
|
itertools = "0.14.0"
|
||||||
jj-lib = { git = "https://github.com/jj-vcs/jj", rev = "e18eb8e05efaa153fad5ef46576af145bba1807f" }
|
|
||||||
json_dotpath = "1.1"
|
|
||||||
jsonschema = "0.30.0"
|
jsonschema = "0.30.0"
|
||||||
jsonwebtoken = "9.3"
|
jsonwebtoken = "9.3"
|
||||||
jupyter-protocol = { git = "https://github.com/ConradIrwin/runtimed", rev = "7130c804216b6914355d15d0b91ea91f6babd734" }
|
jupyter-protocol = { git = "https://github.com/ConradIrwin/runtimed", rev = "7130c804216b6914355d15d0b91ea91f6babd734" }
|
||||||
@@ -475,12 +465,12 @@ jupyter-websocket-client = { git = "https://github.com/ConradIrwin/runtimed" ,r
|
|||||||
libc = "0.2"
|
libc = "0.2"
|
||||||
libsqlite3-sys = { version = "0.30.1", features = ["bundled"] }
|
libsqlite3-sys = { version = "0.30.1", features = ["bundled"] }
|
||||||
linkify = "0.10.0"
|
linkify = "0.10.0"
|
||||||
|
linkme = "0.3.31"
|
||||||
log = { version = "0.4.16", features = ["kv_unstable_serde", "serde"] }
|
log = { version = "0.4.16", features = ["kv_unstable_serde", "serde"] }
|
||||||
lsp-types = { git = "https://github.com/zed-industries/lsp-types", rev = "c9c189f1c5dd53c624a419ce35bc77ad6a908d18" }
|
lsp-types = { git = "https://github.com/zed-industries/lsp-types", rev = "c9c189f1c5dd53c624a419ce35bc77ad6a908d18" }
|
||||||
markup5ever_rcdom = "0.3.0"
|
markup5ever_rcdom = "0.3.0"
|
||||||
metal = "0.29"
|
metal = "0.29"
|
||||||
mlua = { version = "0.10", features = ["lua54", "vendored", "async", "send"] }
|
mlua = { version = "0.10", features = ["lua54", "vendored", "async", "send"] }
|
||||||
moka = { version = "0.12.10", features = ["sync"] }
|
|
||||||
naga = { version = "25.0", features = ["wgsl-in"] }
|
naga = { version = "25.0", features = ["wgsl-in"] }
|
||||||
nanoid = "0.4"
|
nanoid = "0.4"
|
||||||
nbformat = { git = "https://github.com/ConradIrwin/runtimed", rev = "7130c804216b6914355d15d0b91ea91f6babd734" }
|
nbformat = { git = "https://github.com/ConradIrwin/runtimed", rev = "7130c804216b6914355d15d0b91ea91f6babd734" }
|
||||||
@@ -555,13 +545,13 @@ streaming-iterator = "0.1"
|
|||||||
strsim = "0.11"
|
strsim = "0.11"
|
||||||
strum = { version = "0.27.0", features = ["derive"] }
|
strum = { version = "0.27.0", features = ["derive"] }
|
||||||
subtle = "2.5.0"
|
subtle = "2.5.0"
|
||||||
syn = { version = "2.0.101", features = ["full", "extra-traits"] }
|
syn = { version = "1.0.72", features = ["full", "extra-traits"] }
|
||||||
sys-locale = "0.3.1"
|
sys-locale = "0.3.1"
|
||||||
sysinfo = "0.31.0"
|
sysinfo = "0.31.0"
|
||||||
take-until = "0.2.0"
|
take-until = "0.2.0"
|
||||||
tempfile = "3.20.0"
|
tempfile = "3.9.0"
|
||||||
thiserror = "2.0.12"
|
thiserror = "2.0.12"
|
||||||
tiktoken-rs = "0.7.0"
|
tiktoken-rs = "0.6.0"
|
||||||
time = { version = "0.3", features = [
|
time = { version = "0.3", features = [
|
||||||
"macros",
|
"macros",
|
||||||
"parsing",
|
"parsing",
|
||||||
@@ -574,8 +564,8 @@ tokio = { version = "1" }
|
|||||||
tokio-tungstenite = { version = "0.26", features = ["__rustls-tls"] }
|
tokio-tungstenite = { version = "0.26", features = ["__rustls-tls"] }
|
||||||
toml = "0.8"
|
toml = "0.8"
|
||||||
tower-http = "0.4.4"
|
tower-http = "0.4.4"
|
||||||
tree-sitter = { version = "0.25.6", features = ["wasm"] }
|
tree-sitter = { version = "0.25.3", features = ["wasm"] }
|
||||||
tree-sitter-bash = "0.25.0"
|
tree-sitter-bash = "0.23"
|
||||||
tree-sitter-c = "0.23"
|
tree-sitter-c = "0.23"
|
||||||
tree-sitter-cpp = "0.23"
|
tree-sitter-cpp = "0.23"
|
||||||
tree-sitter-css = "0.23"
|
tree-sitter-css = "0.23"
|
||||||
@@ -604,7 +594,7 @@ unindent = "0.2.0"
|
|||||||
url = "2.2"
|
url = "2.2"
|
||||||
urlencoding = "2.1.2"
|
urlencoding = "2.1.2"
|
||||||
uuid = { version = "1.1.2", features = ["v4", "v5", "v7", "serde"] }
|
uuid = { version = "1.1.2", features = ["v4", "v5", "v7", "serde"] }
|
||||||
walkdir = "2.5"
|
walkdir = "2.3"
|
||||||
wasm-encoder = "0.221"
|
wasm-encoder = "0.221"
|
||||||
wasmparser = "0.221"
|
wasmparser = "0.221"
|
||||||
wasmtime = { version = "29", default-features = false, features = [
|
wasmtime = { version = "29", default-features = false, features = [
|
||||||
@@ -613,13 +603,12 @@ wasmtime = { version = "29", default-features = false, features = [
|
|||||||
"runtime",
|
"runtime",
|
||||||
"cranelift",
|
"cranelift",
|
||||||
"component-model",
|
"component-model",
|
||||||
"incremental-cache",
|
|
||||||
"parallel-compilation",
|
|
||||||
] }
|
] }
|
||||||
wasmtime-wasi = "29"
|
wasmtime-wasi = "29"
|
||||||
which = "6.0.0"
|
which = "6.0.0"
|
||||||
|
wit-component = "0.221"
|
||||||
workspace-hack = "0.1.0"
|
workspace-hack = "0.1.0"
|
||||||
zed_llm_client = "0.8.4"
|
zed_llm_client = "0.8.0"
|
||||||
zstd = "0.11"
|
zstd = "0.11"
|
||||||
|
|
||||||
[workspace.dependencies.async-stripe]
|
[workspace.dependencies.async-stripe]
|
||||||
@@ -799,9 +788,6 @@ let_underscore_future = "allow"
|
|||||||
# running afoul of the borrow checker.
|
# running afoul of the borrow checker.
|
||||||
too_many_arguments = "allow"
|
too_many_arguments = "allow"
|
||||||
|
|
||||||
# We often have large enum variants yet we rarely actually bother with splitting them up.
|
|
||||||
large_enum_variant = "allow"
|
|
||||||
|
|
||||||
[workspace.metadata.cargo-machete]
|
[workspace.metadata.cargo-machete]
|
||||||
ignored = [
|
ignored = [
|
||||||
"bindgen",
|
"bindgen",
|
||||||
@@ -809,6 +795,7 @@ ignored = [
|
|||||||
"prost_build",
|
"prost_build",
|
||||||
"serde",
|
"serde",
|
||||||
"component",
|
"component",
|
||||||
|
"linkme",
|
||||||
"documented",
|
"documented",
|
||||||
"workspace-hack",
|
"workspace-hack",
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
# syntax = docker/dockerfile:1.2
|
# syntax = docker/dockerfile:1.2
|
||||||
|
|
||||||
FROM rust:1.87-bookworm as builder
|
FROM rust:1.86-bookworm as builder
|
||||||
WORKDIR app
|
WORKDIR app
|
||||||
COPY . .
|
COPY . .
|
||||||
|
|
||||||
|
|||||||
@@ -8,6 +8,10 @@ Welcome to Zed, a high-performance, multiplayer code editor from the creators of
|
|||||||
|
|
||||||
### Installation
|
### Installation
|
||||||
|
|
||||||
|
<a href="https://repology.org/project/zed-editor/versions">
|
||||||
|
<img src="https://repology.org/badge/vertical-allrepos/zed-editor.svg?minversion=0.143.5" alt="Packaging status" align="right">
|
||||||
|
</a>
|
||||||
|
|
||||||
On macOS and Linux you can [download Zed directly](https://zed.dev/download) or [install Zed via your local package manager](https://zed.dev/docs/linux#installing-via-a-package-manager).
|
On macOS and Linux you can [download Zed directly](https://zed.dev/download) or [install Zed via your local package manager](https://zed.dev/docs/linux#installing-via-a-package-manager).
|
||||||
|
|
||||||
Other platforms are not yet available:
|
Other platforms are not yet available:
|
||||||
|
|||||||
@@ -1,8 +0,0 @@
|
|||||||
<svg width="16" height="16" viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg" fill="currentColor" stroke="currentColor">
|
|
||||||
<g clip-path="url(#clip0_205_3)">
|
|
||||||
<path d="M0.094 7.78c0.469 0 2.281 -0.405 3.219 -0.936s0.938 -0.531 2.875 -1.906c2.453 -1.741 4.188 -1.158 7.031 -1.158" stroke-width="2.8125" />
|
|
||||||
<path d="m15.969 3.797 -4.805 2.774V1.023z" />
|
|
||||||
<path d="M0 7.781c0.469 0 2.281 0.405 3.219 0.936s0.938 0.531 2.875 1.906C8.547 12.364 10.281 11.781 13.125 11.781" stroke-width="2.8125" />
|
|
||||||
<path d="m15.875 11.764 -4.805 -2.774v5.548z" />
|
|
||||||
</g>
|
|
||||||
</svg>
|
|
||||||
|
Before Width: | Height: | Size: 575 B |
@@ -1,3 +1,3 @@
|
|||||||
<svg width="14" height="14" viewBox="0 0 14 14" fill="none" xmlns="http://www.w3.org/2000/svg">
|
<svg width="8" height="8" viewBox="0 0 8 8" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||||
<path d="M9.3 1.75L3 7.35H5.8L4.7 12.25L11 6.65H8.2L9.3 1.75Z" stroke="black" stroke-width="1.25" stroke-linejoin="round"/>
|
<path d="M4.76019 3.50003H6.50231C6.71012 3.50003 6.89761 3.62971 6.95698 3.82346C7.04292 4.01876 6.98823 4.23906 6.83199 4.37656L2.83214 7.87643C2.65558 8.02954 2.39731 8.04204 2.20857 7.90455C2.01967 7.76705 1.95092 7.51706 2.04295 7.30301L3.24462 4.49999H1.48844C1.29423 4.49999 1.10767 4.37031 1.0344 4.17657C0.961132 3.98126 1.01643 3.76096 1.17323 3.62346L5.17261 0.123753C5.34917 -0.0299914 5.60697 -0.0417097 5.79603 0.0954726C5.98508 0.232749 6.05383 0.482177 5.96165 0.69695L4.76013 3.49981L4.76019 3.50003Z" fill="white"/>
|
||||||
</svg>
|
</svg>
|
||||||
|
|||||||
|
Before Width: | Height: | Size: 227 B After Width: | Height: | Size: 633 B |
@@ -1,3 +0,0 @@
|
|||||||
<svg width="8" height="8" viewBox="0 0 8 8" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
||||||
<path d="M4.76019 3.50003H6.50231C6.71012 3.50003 6.89761 3.62971 6.95698 3.82346C7.04292 4.01876 6.98823 4.23906 6.83199 4.37656L2.83214 7.87643C2.65558 8.02954 2.39731 8.04204 2.20857 7.90455C2.01967 7.76705 1.95092 7.51706 2.04295 7.30301L3.24462 4.49999H1.48844C1.29423 4.49999 1.10767 4.37031 1.0344 4.17657C0.961132 3.98126 1.01643 3.76096 1.17323 3.62346L5.17261 0.123753C5.34917 -0.0299914 5.60697 -0.0417097 5.79603 0.0954726C5.98508 0.232749 6.05383 0.482177 5.96165 0.69695L4.76013 3.49981L4.76019 3.50003Z" fill="white"/>
|
|
||||||
</svg>
|
|
||||||
|
Before Width: | Height: | Size: 633 B |
@@ -1,4 +1,5 @@
|
|||||||
<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
|
<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||||
<path d="M11 13H10.4C9.76346 13 9.15302 12.7893 8.70296 12.4142C8.25284 12.0391 8 11.5304 8 11V5C8 4.46957 8.25284 3.96086 8.70296 3.58579C9.15302 3.21071 9.76346 3 10.4 3H11" stroke="black" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/>
|
<path d="M17 20H16C14.9391 20 13.9217 19.6629 13.1716 19.0627C12.4214 18.4626 12 17.6487 12 16.8V7.2C12 6.35131 12.4214 5.53737 13.1716 4.93726C13.9217 4.33714 14.9391 4 16 4H17" stroke="black" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
|
||||||
<path d="M5 13H5.6C6.23654 13 6.84698 12.7893 7.29704 12.4142C7.74716 12.0391 8 11.5304 8 11V5C8 4.46957 7.74716 3.96086 7.29704 3.58579C6.84698 3.21071 6.23654 3 5.6 3H5" stroke="black" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/>
|
<path d="M7 20H8C9.06087 20 10.0783 19.5786 10.8284 18.8284C11.5786 18.0783 12 17.0609 12 16V15" stroke="black" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
|
||||||
|
<path d="M7 4H8C9.06087 4 10.0783 4.42143 10.8284 5.17157C11.5786 5.92172 12 6.93913 12 8V9" stroke="black" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
|
||||||
</svg>
|
</svg>
|
||||||
|
|||||||
|
Before Width: | Height: | Size: 617 B After Width: | Height: | Size: 715 B |
@@ -1 +0,0 @@
|
|||||||
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-list-todo-icon lucide-list-todo"><rect x="3" y="5" width="6" height="6" rx="1"/><path d="m3 17 2 2 4-4"/><path d="M13 6h8"/><path d="M13 12h8"/><path d="M13 18h8"/></svg>
|
|
||||||
|
Before Width: | Height: | Size: 373 B |
@@ -1 +0,0 @@
|
|||||||
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-loader-circle-icon lucide-loader-circle"><path d="M21 12a9 9 0 1 1-6.219-8.56"/></svg>
|
|
||||||
|
Before Width: | Height: | Size: 289 B |
@@ -1,3 +0,0 @@
|
|||||||
<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
||||||
<path d="M4 3L13 8L4 13V3Z" stroke="black" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/>
|
|
||||||
</svg>
|
|
||||||
|
Before Width: | Height: | Size: 214 B |
@@ -1,8 +0,0 @@
|
|||||||
<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
||||||
<path d="M4 12C2.35977 11.85 1 10.575 1 9" stroke="black" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/>
|
|
||||||
<path d="M1.00875 15.2C1.00875 13.625 0.683456 12.275 4.00001 12.2" stroke="black" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/>
|
|
||||||
<path d="M7 9C7 10.575 5.62857 11.85 4 12" stroke="black" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/>
|
|
||||||
<path d="M4 12.2C6.98117 12.2 7 13.625 7 15.2" stroke="black" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/>
|
|
||||||
<rect x="2.5" y="9" width="3" height="6" rx="1.5" fill="black"/>
|
|
||||||
<path d="M9 10L13 8L4 3V7.5" stroke="black" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/>
|
|
||||||
</svg>
|
|
||||||
|
Before Width: | Height: | Size: 813 B |
@@ -1,8 +1,3 @@
|
|||||||
<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
|
<svg width="17" height="17" viewBox="0 0 17 17" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||||
<path d="M2 5H4" stroke="black" stroke-width="1.5" stroke-linecap="round"/>
|
<path fill-rule="evenodd" clip-rule="evenodd" d="M6.36667 3.79167C5.53364 3.79167 4.85833 4.46697 4.85833 5.3C4.85833 6.13303 5.53364 6.80833 6.36667 6.80833C7.1997 6.80833 7.875 6.13303 7.875 5.3C7.875 4.46697 7.1997 3.79167 6.36667 3.79167ZM2.1 5.925H3.67944C3.9626 7.14732 5.05824 8.05833 6.36667 8.05833C7.67509 8.05833 8.77073 7.14732 9.05389 5.925H14.9C15.2452 5.925 15.525 5.64518 15.525 5.3C15.525 4.95482 15.2452 4.675 14.9 4.675H9.05389C8.77073 3.45268 7.67509 2.54167 6.36667 2.54167C5.05824 2.54167 3.9626 3.45268 3.67944 4.675H2.1C1.75482 4.675 1.475 4.95482 1.475 5.3C1.475 5.64518 1.75482 5.925 2.1 5.925ZM13.3206 12.325C13.0374 13.5473 11.9418 14.4583 10.6333 14.4583C9.32491 14.4583 8.22927 13.5473 7.94611 12.325H2.1C1.75482 12.325 1.475 12.0452 1.475 11.7C1.475 11.3548 1.75482 11.075 2.1 11.075H7.94611C8.22927 9.85268 9.32491 8.94167 10.6333 8.94167C11.9418 8.94167 13.0374 9.85268 13.3206 11.075H14.9C15.2452 11.075 15.525 11.3548 15.525 11.7C15.525 12.0452 15.2452 12.325 14.9 12.325H13.3206ZM9.125 11.7C9.125 10.867 9.8003 10.1917 10.6333 10.1917C11.4664 10.1917 12.1417 10.867 12.1417 11.7C12.1417 12.533 11.4664 13.2083 10.6333 13.2083C9.8003 13.2083 9.125 12.533 9.125 11.7Z" fill="black"/>
|
||||||
<path d="M8 5L14 5" stroke="black" stroke-width="1.5" stroke-linecap="round"/>
|
|
||||||
<path d="M12 11L14 11" stroke="black" stroke-width="1.5" stroke-linecap="round"/>
|
|
||||||
<path d="M2 11H8" stroke="black" stroke-width="1.5" stroke-linecap="round"/>
|
|
||||||
<circle cx="6" cy="5" r="2" fill="black" fill-opacity="0.1" stroke="black" stroke-width="1.5" stroke-linecap="round"/>
|
|
||||||
<circle cx="10" cy="11" r="2" fill="black" fill-opacity="0.1" stroke="black" stroke-width="1.5" stroke-linecap="round"/>
|
|
||||||
</svg>
|
</svg>
|
||||||
|
|||||||
|
Before Width: | Height: | Size: 657 B After Width: | Height: | Size: 1.3 KiB |
@@ -1,3 +1 @@
|
|||||||
<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
|
<svg width="15" height="15" viewBox="0 0 15 15" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M6.97942 1.25171L6.9585 1.30199L5.58662 4.60039C5.54342 4.70426 5.44573 4.77523 5.3336 4.78422L1.7727 5.0697L1.71841 5.07405L1.38687 5.10063L1.08608 5.12475C0.820085 5.14607 0.712228 5.47802 0.914889 5.65162L1.14406 5.84793L1.39666 6.06431L1.43802 6.09974L4.15105 8.42374C4.23648 8.49692 4.2738 8.61176 4.24769 8.72118L3.41882 12.196L3.40618 12.249L3.32901 12.5725L3.25899 12.866C3.19708 13.1256 3.47945 13.3308 3.70718 13.1917L3.9647 13.0344L4.24854 12.861L4.29502 12.8326L7.34365 10.9705C7.43965 10.9119 7.5604 10.9119 7.6564 10.9705L10.705 12.8326L10.7515 12.861L11.0354 13.0344L11.2929 13.1917C11.5206 13.3308 11.803 13.1256 11.7411 12.866L11.671 12.5725L11.5939 12.249L11.5812 12.196L10.7524 8.72118C10.7263 8.61176 10.7636 8.49692 10.849 8.42374L13.562 6.09974L13.6034 6.06431L13.856 5.84793L14.0852 5.65162C14.2878 5.47802 14.18 5.14607 13.914 5.12475L13.6132 5.10063L13.2816 5.07405L13.2274 5.0697L9.66645 4.78422C9.55432 4.77523 9.45663 4.70426 9.41343 4.60039L8.04155 1.30199L8.02064 1.25171L7.89291 0.944609L7.77702 0.665992C7.67454 0.419604 7.32551 0.419604 7.22303 0.665992L7.10715 0.944609L6.97942 1.25171ZM7.50003 2.60397L6.50994 4.98442C6.32273 5.43453 5.89944 5.74207 5.41351 5.78103L2.84361 5.98705L4.8016 7.66428C5.17183 7.98142 5.33351 8.47903 5.2204 8.95321L4.62221 11.461L6.8224 10.1171C7.23842 9.86302 7.76164 9.86302 8.17766 10.1171L10.3778 11.461L9.77965 8.95321C9.66654 8.47903 9.82822 7.98142 10.1984 7.66428L12.1564 5.98705L9.58654 5.78103C9.10061 5.74207 8.67732 5.43453 8.49011 4.98442L7.50003 2.60397Z" fill="currentColor" fill-rule="evenodd" clip-rule="evenodd"></path></svg>
|
||||||
<path d="M7.68323 1.53C7.71245 1.47097 7.75758 1.42129 7.81353 1.38655C7.86949 1.35181 7.93404 1.3334 7.9999 1.3334C8.06576 1.3334 8.13031 1.35181 8.18626 1.38655C8.24222 1.42129 8.28735 1.47097 8.31656 1.53L9.85656 4.64933C9.95802 4.85465 10.1078 5.03227 10.293 5.16697C10.4782 5.30167 10.6933 5.38941 10.9199 5.42267L14.3639 5.92667C14.4292 5.93612 14.4905 5.96365 14.5409 6.00613C14.5913 6.04862 14.6289 6.10437 14.6492 6.16707C14.6696 6.22978 14.6721 6.29694 14.6563 6.36096C14.6405 6.42498 14.6071 6.4833 14.5599 6.52933L12.0692 8.95467C11.905 9.11473 11.7821 9.31232 11.7111 9.53042C11.6402 9.74852 11.6233 9.98059 11.6619 10.2067L12.2499 13.6333C12.2614 13.6986 12.2544 13.7657 12.2296 13.8271C12.2048 13.8885 12.1632 13.9417 12.1096 13.9807C12.056 14.0196 11.9926 14.0427 11.9265 14.0473C11.8604 14.0519 11.7944 14.0378 11.7359 14.0067L8.65723 12.388C8.45438 12.2815 8.22868 12.2258 7.99956 12.2258C7.77044 12.2258 7.54475 12.2815 7.3419 12.388L4.2639 14.0067C4.20545 14.0376 4.1395 14.0515 4.07353 14.0468C4.00757 14.0421 3.94424 14.019 3.89076 13.9801C3.83728 13.9413 3.79579 13.8881 3.771 13.8268C3.74622 13.7655 3.73914 13.6985 3.75056 13.6333L4.3379 10.2073C4.3767 9.98116 4.35989 9.74893 4.28892 9.5307C4.21796 9.31246 4.09497 9.11477 3.93056 8.95467L1.4399 6.53C1.39229 6.48402 1.35856 6.4256 1.34254 6.36138C1.32652 6.29717 1.32886 6.22975 1.34928 6.16679C1.36971 6.10384 1.40741 6.04789 1.45808 6.00532C1.50876 5.96275 1.57037 5.93527 1.6359 5.926L5.07923 5.42267C5.30607 5.38967 5.52149 5.30204 5.70695 5.16733C5.89242 5.03261 6.04237 4.85485 6.1439 4.64933L7.68323 1.53Z" stroke="black" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/>
|
|
||||||
</svg>
|
|
||||||
|
|||||||
|
Before Width: | Height: | Size: 1.7 KiB After Width: | Height: | Size: 1.7 KiB |
@@ -1,3 +1 @@
|
|||||||
<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
|
<svg width="15" height="15" viewBox="0 0 15 15" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M7.22303 0.665992C7.32551 0.419604 7.67454 0.419604 7.77702 0.665992L9.41343 4.60039C9.45663 4.70426 9.55432 4.77523 9.66645 4.78422L13.914 5.12475C14.18 5.14607 14.2878 5.47802 14.0852 5.65162L10.849 8.42374C10.7636 8.49692 10.7263 8.61176 10.7524 8.72118L11.7411 12.866C11.803 13.1256 11.5206 13.3308 11.2929 13.1917L7.6564 10.9705C7.5604 10.9119 7.43965 10.9119 7.34365 10.9705L3.70718 13.1917C3.47945 13.3308 3.19708 13.1256 3.25899 12.866L4.24769 8.72118C4.2738 8.61176 4.23648 8.49692 4.15105 8.42374L0.914889 5.65162C0.712228 5.47802 0.820086 5.14607 1.08608 5.12475L5.3336 4.78422C5.44573 4.77523 5.54342 4.70426 5.58662 4.60039L7.22303 0.665992Z" fill="currentColor"></path></svg>
|
||||||
<path d="M7.68323 1.53C7.71245 1.47097 7.75758 1.42129 7.81353 1.38655C7.86949 1.35181 7.93404 1.3334 7.9999 1.3334C8.06576 1.3334 8.13031 1.35181 8.18626 1.38655C8.24222 1.42129 8.28735 1.47097 8.31656 1.53L9.85656 4.64933C9.95802 4.85465 10.1078 5.03227 10.293 5.16697C10.4782 5.30167 10.6933 5.38941 10.9199 5.42267L14.3639 5.92667C14.4292 5.93612 14.4905 5.96365 14.5409 6.00613C14.5913 6.04862 14.6289 6.10437 14.6492 6.16707C14.6696 6.22978 14.6721 6.29694 14.6563 6.36096C14.6405 6.42498 14.6071 6.4833 14.5599 6.52933L12.0692 8.95467C11.905 9.11473 11.7821 9.31232 11.7111 9.53042C11.6402 9.74852 11.6233 9.98059 11.6619 10.2067L12.2499 13.6333C12.2614 13.6986 12.2544 13.7657 12.2296 13.8271C12.2048 13.8885 12.1632 13.9417 12.1096 13.9807C12.056 14.0196 11.9926 14.0427 11.9265 14.0473C11.8604 14.0519 11.7944 14.0378 11.7359 14.0067L8.65723 12.388C8.45438 12.2815 8.22868 12.2258 7.99956 12.2258C7.77044 12.2258 7.54475 12.2815 7.3419 12.388L4.2639 14.0067C4.20545 14.0376 4.1395 14.0515 4.07353 14.0468C4.00757 14.0421 3.94424 14.019 3.89076 13.9801C3.83728 13.9413 3.79579 13.8881 3.771 13.8268C3.74622 13.7655 3.73914 13.6985 3.75056 13.6333L4.3379 10.2073C4.3767 9.98116 4.35989 9.74893 4.28892 9.5307C4.21796 9.31246 4.09497 9.11477 3.93056 8.95467L1.4399 6.53C1.39229 6.48402 1.35856 6.4256 1.34254 6.36138C1.32652 6.29717 1.32886 6.22975 1.34928 6.16679C1.36971 6.10384 1.40741 6.04789 1.45808 6.00532C1.50876 5.96275 1.57037 5.93527 1.6359 5.926L5.07923 5.42267C5.30607 5.38967 5.52149 5.30204 5.70695 5.16733C5.89242 5.03261 6.04237 4.85485 6.1439 4.64933L7.68323 1.53Z" fill="black" stroke="black" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/>
|
|
||||||
</svg>
|
|
||||||
|
|||||||
|
Before Width: | Height: | Size: 1.7 KiB After Width: | Height: | Size: 794 B |
@@ -1,5 +1,5 @@
|
|||||||
<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
|
<svg width="14" height="14" viewBox="0 0 14 14" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||||
<path d="M8 2L6.72534 5.87534C6.6601 6.07367 6.5492 6.25392 6.40155 6.40155C6.25392 6.5492 6.07367 6.6601 5.87534 6.72534L2 8L5.87534 9.27466C6.07367 9.3399 6.25392 9.4508 6.40155 9.59845C6.5492 9.74608 6.6601 9.92633 6.72534 10.1247L8 14L9.27466 10.1247C9.3399 9.92633 9.4508 9.74608 9.59845 9.59845C9.74608 9.4508 9.92633 9.3399 10.1247 9.27466L14 8L10.1247 6.72534C9.92633 6.6601 9.74608 6.5492 9.59845 6.40155C9.4508 6.25392 9.3399 6.07367 9.27466 5.87534L8 2Z" fill="black" fill-opacity="0.15" stroke="black" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/>
|
<path d="M7 1.75L5.88467 5.14092C5.82759 5.31446 5.73055 5.47218 5.60136 5.60136C5.47218 5.73055 5.31446 5.82759 5.14092 5.88467L1.75 7L5.14092 8.11533C5.31446 8.17241 5.47218 8.26945 5.60136 8.39864C5.73055 8.52782 5.82759 8.68554 5.88467 8.85908L7 12.25L8.11533 8.85908C8.17241 8.68554 8.26945 8.52782 8.39864 8.39864C8.52782 8.26945 8.68554 8.17241 8.85908 8.11533L12.25 7L8.85908 5.88467C8.68554 5.82759 8.52782 5.73055 8.39864 5.60136C8.26945 5.47218 8.17241 5.31446 8.11533 5.14092L7 1.75Z" fill="black" fill-opacity="0.15" stroke="black" stroke-width="1.25" stroke-linecap="round" stroke-linejoin="round"/>
|
||||||
<path d="M3.33334 2V4.66666M2 3.33334H4.66666" stroke="black" stroke-opacity="0.75" stroke-width="1.25" stroke-linecap="round" stroke-linejoin="round"/>
|
<path d="M2.91667 1.75V4.08333M1.75 2.91667H4.08333" stroke="black" stroke-opacity="0.75" stroke-width="1.25" stroke-linecap="round" stroke-linejoin="round"/>
|
||||||
<path d="M12.6665 11.3333V14M11.3333 12.6666H13.9999" stroke="black" stroke-opacity="0.75" stroke-width="1.25" stroke-linecap="round" stroke-linejoin="round"/>
|
<path d="M11.0833 9.91667V12.25M9.91667 11.0833H12.25" stroke="black" stroke-opacity="0.75" stroke-width="1.25" stroke-linecap="round" stroke-linejoin="round"/>
|
||||||
</svg>
|
</svg>
|
||||||
|
|||||||
|
Before Width: | Height: | Size: 998 B After Width: | Height: | Size: 1.0 KiB |
@@ -1,3 +0,0 @@
|
|||||||
<svg width="14" height="14" viewBox="0 0 14 14" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
||||||
<path d="M4.99207 8.14741C5.37246 8.14741 5.73726 7.9963 6.00623 7.72733C6.27521 7.45836 6.42631 7.09355 6.42631 6.71317C6.42631 5.92147 6.13946 5.56578 5.85262 4.99208C5.23761 3.76265 5.72411 2.66631 7.00001 1.5499C7.28686 2.98414 8.1474 4.36101 9.2948 5.27893C10.4422 6.19684 11.0159 7.28687 11.0159 8.43426C11.0159 8.96163 10.912 9.48384 10.7102 9.97107C10.5084 10.4583 10.2126 10.901 9.83967 11.2739C9.46676 11.6468 9.02405 11.9426 8.53682 12.1444C8.04959 12.3463 7.52738 12.4501 7.00001 12.4501C6.47264 12.4501 5.95043 12.3463 5.4632 12.1444C4.97597 11.9426 4.53326 11.6468 4.16035 11.2739C3.78745 10.901 3.49164 10.4583 3.28982 9.97107C3.088 9.48384 2.98413 8.96163 2.98413 8.43426C2.98413 7.77279 3.23254 7.1182 3.55783 6.71317C3.55783 7.09355 3.70894 7.45836 3.97791 7.72733C4.24688 7.9963 4.61169 8.14741 4.99207 8.14741Z" stroke="black" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/>
|
|
||||||
</svg>
|
|
||||||
|
Before Width: | Height: | Size: 1018 B |
@@ -1,13 +0,0 @@
|
|||||||
<svg width="14" height="14" viewBox="0 0 14 14" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
||||||
<g clip-path="url(#clip0_2595_5640)">
|
|
||||||
<path d="M4.99207 8.14741C5.37246 8.14741 5.73726 7.9963 6.00623 7.72733C6.27521 7.45836 6.42631 7.09355 6.42631 6.71317C6.42631 5.92147 6.13946 5.56578 5.85262 4.99208C5.23761 3.76265 5.72411 2.66631 7.00001 1.5499C7.28686 2.98414 8.1474 4.36101 9.2948 5.27893C10.4422 6.19684 11.0159 7.28687 11.0159 8.43426C11.0159 8.96163 10.912 9.48384 10.7102 9.97107C10.5084 10.4583 10.2126 10.901 9.83967 11.2739C9.46676 11.6468 9.02405 11.9426 8.53682 12.1444C8.04959 12.3463 7.52738 12.4501 7.00001 12.4501C6.47264 12.4501 5.95043 12.3463 5.4632 12.1444C4.97597 11.9426 4.53326 11.6468 4.16035 11.2739C3.78745 10.901 3.49164 10.4583 3.28982 9.97107C3.088 9.48384 2.98413 8.96163 2.98413 8.43426C2.98413 7.77279 3.23254 7.1182 3.55783 6.71317C3.55783 7.09355 3.70894 7.45836 3.97791 7.72733C4.24688 7.9963 4.61169 8.14741 4.99207 8.14741Z" fill="black" fill-opacity="0.5" stroke="black" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/>
|
|
||||||
<path d="M2 4C2.55228 4 3 3.55228 3 3C3 2.44772 2.55228 2 2 2C1.44772 2 1 2.44772 1 3C1 3.55228 1.44772 4 2 4Z" fill="black"/>
|
|
||||||
<path d="M10 2C10.5523 2 11 1.55228 11 1C11 0.44772 10.5523 0 10 0C9.44772 0 9 0.44772 9 1C9 1.55228 9.44772 2 10 2Z" fill="black"/>
|
|
||||||
<path d="M13 5C13.5522 5 14 4.55228 14 4C14 3.44772 13.5522 3 13 3C12.4478 3 12 3.44772 12 4C12 4.55228 12.4478 5 13 5Z" fill="black"/>
|
|
||||||
</g>
|
|
||||||
<defs>
|
|
||||||
<clipPath id="clip0_2595_5640">
|
|
||||||
<rect width="14" height="14" fill="white"/>
|
|
||||||
</clipPath>
|
|
||||||
</defs>
|
|
||||||
</svg>
|
|
||||||
|
Before Width: | Height: | Size: 1.6 KiB |
14
assets/icons/zed_max_mode.svg
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||||
|
<g clip-path="url(#clip0_2489_484)">
|
||||||
|
<path d="M11 8.9V11C8.51716 11 7.48284 11 5 11V10.4L11 5.6V5H5V7.1" stroke="black" stroke-width="1.5"/>
|
||||||
|
<path d="M1.5 5.5V1.5H5" stroke="black" stroke-opacity="0.5" stroke-width="1.5"/>
|
||||||
|
<path d="M14.5 5.5V1.5H11" stroke="black" stroke-opacity="0.5" stroke-width="1.5"/>
|
||||||
|
<path d="M1.5 10.5V14.5H5" stroke="black" stroke-opacity="0.5" stroke-width="1.5"/>
|
||||||
|
<path d="M14.5 10.5V14.5H11" stroke="black" stroke-opacity="0.5" stroke-width="1.5"/>
|
||||||
|
</g>
|
||||||
|
<defs>
|
||||||
|
<clipPath id="clip0_2489_484">
|
||||||
|
<rect width="16" height="16" fill="white"/>
|
||||||
|
</clipPath>
|
||||||
|
</defs>
|
||||||
|
</svg>
|
||||||
|
After Width: | Height: | Size: 687 B |
@@ -31,8 +31,8 @@
|
|||||||
"ctrl-,": "zed::OpenSettings",
|
"ctrl-,": "zed::OpenSettings",
|
||||||
"ctrl-q": "zed::Quit",
|
"ctrl-q": "zed::Quit",
|
||||||
"f4": "debugger::Start",
|
"f4": "debugger::Start",
|
||||||
|
"f5": "debugger::Continue",
|
||||||
"shift-f5": "debugger::Stop",
|
"shift-f5": "debugger::Stop",
|
||||||
"ctrl-shift-f5": "debugger::Restart",
|
|
||||||
"f6": "debugger::Pause",
|
"f6": "debugger::Pause",
|
||||||
"f7": "debugger::StepOver",
|
"f7": "debugger::StepOver",
|
||||||
"cmd-f11": "debugger::StepInto",
|
"cmd-f11": "debugger::StepInto",
|
||||||
@@ -120,12 +120,14 @@
|
|||||||
"ctrl-'": "editor::ToggleSelectedDiffHunks",
|
"ctrl-'": "editor::ToggleSelectedDiffHunks",
|
||||||
"ctrl-\"": "editor::ExpandAllDiffHunks",
|
"ctrl-\"": "editor::ExpandAllDiffHunks",
|
||||||
"ctrl-i": "editor::ShowSignatureHelp",
|
"ctrl-i": "editor::ShowSignatureHelp",
|
||||||
"alt-g b": "git::Blame",
|
"alt-g b": "editor::ToggleGitBlame",
|
||||||
"menu": "editor::OpenContextMenu",
|
"menu": "editor::OpenContextMenu",
|
||||||
"shift-f10": "editor::OpenContextMenu",
|
"shift-f10": "editor::OpenContextMenu",
|
||||||
"ctrl-shift-e": "editor::ToggleEditPrediction",
|
"ctrl-shift-e": "editor::ToggleEditPrediction",
|
||||||
"f9": "editor::ToggleBreakpoint",
|
"f9": "editor::ToggleBreakpoint",
|
||||||
"shift-f9": "editor::EditLogBreakpoint"
|
"shift-f9": "editor::EditLogBreakpoint",
|
||||||
|
"ctrl-shift-backspace": "editor::GoToPreviousChange",
|
||||||
|
"ctrl-shift-alt-backspace": "editor::GoToNextChange"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -144,8 +146,6 @@
|
|||||||
"ctrl->": "assistant::QuoteSelection",
|
"ctrl->": "assistant::QuoteSelection",
|
||||||
"ctrl-<": "assistant::InsertIntoEditor",
|
"ctrl-<": "assistant::InsertIntoEditor",
|
||||||
"ctrl-alt-e": "editor::SelectEnclosingSymbol",
|
"ctrl-alt-e": "editor::SelectEnclosingSymbol",
|
||||||
"ctrl-shift-backspace": "editor::GoToPreviousChange",
|
|
||||||
"ctrl-shift-alt-backspace": "editor::GoToNextChange",
|
|
||||||
"alt-enter": "editor::OpenSelectionsInMultibuffer"
|
"alt-enter": "editor::OpenSelectionsInMultibuffer"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -242,14 +242,11 @@
|
|||||||
"ctrl-i": "agent::ToggleProfileSelector",
|
"ctrl-i": "agent::ToggleProfileSelector",
|
||||||
"ctrl-alt-/": "agent::ToggleModelSelector",
|
"ctrl-alt-/": "agent::ToggleModelSelector",
|
||||||
"ctrl-shift-a": "agent::ToggleContextPicker",
|
"ctrl-shift-a": "agent::ToggleContextPicker",
|
||||||
"ctrl-shift-j": "agent::ToggleNavigationMenu",
|
"ctrl-shift-o": "agent::ToggleNavigationMenu",
|
||||||
"ctrl-shift-i": "agent::ToggleOptionsMenu",
|
"ctrl-shift-i": "agent::ToggleOptionsMenu",
|
||||||
"shift-alt-escape": "agent::ExpandMessageEditor",
|
"shift-escape": "agent::ExpandMessageEditor",
|
||||||
"ctrl-alt-e": "agent::RemoveAllContext",
|
"ctrl-alt-e": "agent::RemoveAllContext",
|
||||||
"ctrl-shift-e": "project_panel::ToggleFocus",
|
"ctrl-shift-e": "project_panel::ToggleFocus"
|
||||||
"ctrl-shift-enter": "agent::ContinueThread",
|
|
||||||
"alt-enter": "agent::ContinueWithBurnMode",
|
|
||||||
"ctrl-alt-b": "agent::ToggleBurnMode"
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -276,11 +273,8 @@
|
|||||||
"context": "MessageEditor > Editor",
|
"context": "MessageEditor > Editor",
|
||||||
"bindings": {
|
"bindings": {
|
||||||
"enter": "agent::Chat",
|
"enter": "agent::Chat",
|
||||||
"ctrl-enter": "agent::ChatWithFollow",
|
|
||||||
"ctrl-i": "agent::ToggleProfileSelector",
|
"ctrl-i": "agent::ToggleProfileSelector",
|
||||||
"shift-ctrl-r": "agent::OpenAgentDiff",
|
"shift-ctrl-r": "agent::OpenAgentDiff"
|
||||||
"ctrl-shift-y": "agent::KeepAll",
|
|
||||||
"ctrl-shift-n": "agent::RejectAll"
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -512,14 +506,12 @@
|
|||||||
{
|
{
|
||||||
"context": "Workspace",
|
"context": "Workspace",
|
||||||
"bindings": {
|
"bindings": {
|
||||||
"alt-open": ["projects::OpenRecent", { "create_new_window": false }],
|
|
||||||
// Change the default action on `menu::Confirm` by setting the parameter
|
// Change the default action on `menu::Confirm` by setting the parameter
|
||||||
// "alt-ctrl-o": ["projects::OpenRecent", { "create_new_window": true }],
|
// "alt-ctrl-o": ["projects::OpenRecent", { "create_new_window": true }],
|
||||||
"alt-ctrl-o": ["projects::OpenRecent", { "create_new_window": false }],
|
"alt-open": "projects::OpenRecent",
|
||||||
"alt-shift-open": ["projects::OpenRemote", { "from_existing_connection": false, "create_new_window": false }],
|
"alt-ctrl-o": "projects::OpenRecent",
|
||||||
// Change to open path modal for existing remote connection by setting the parameter
|
"alt-shift-open": "projects::OpenRemote",
|
||||||
// "alt-ctrl-shift-o": "["projects::OpenRemote", { "from_existing_connection": true }]",
|
"alt-ctrl-shift-o": "projects::OpenRemote",
|
||||||
"alt-ctrl-shift-o": ["projects::OpenRemote", { "from_existing_connection": false, "create_new_window": false }],
|
|
||||||
"alt-ctrl-shift-b": "branches::OpenRecent",
|
"alt-ctrl-shift-b": "branches::OpenRecent",
|
||||||
"alt-shift-enter": "toast::RunAction",
|
"alt-shift-enter": "toast::RunAction",
|
||||||
"ctrl-~": "workspace::NewTerminal",
|
"ctrl-~": "workspace::NewTerminal",
|
||||||
@@ -564,7 +556,6 @@
|
|||||||
"ctrl-shift-e": "project_panel::ToggleFocus",
|
"ctrl-shift-e": "project_panel::ToggleFocus",
|
||||||
"ctrl-shift-b": "outline_panel::ToggleFocus",
|
"ctrl-shift-b": "outline_panel::ToggleFocus",
|
||||||
"ctrl-shift-g": "git_panel::ToggleFocus",
|
"ctrl-shift-g": "git_panel::ToggleFocus",
|
||||||
"ctrl-shift-d": "debug_panel::ToggleFocus",
|
|
||||||
"ctrl-?": "agent::ToggleFocus",
|
"ctrl-?": "agent::ToggleFocus",
|
||||||
"alt-save": "workspace::SaveAll",
|
"alt-save": "workspace::SaveAll",
|
||||||
"ctrl-alt-s": "workspace::SaveAll",
|
"ctrl-alt-s": "workspace::SaveAll",
|
||||||
@@ -583,24 +574,11 @@
|
|||||||
"ctrl-alt-r": "task::Rerun",
|
"ctrl-alt-r": "task::Rerun",
|
||||||
"alt-t": "task::Rerun",
|
"alt-t": "task::Rerun",
|
||||||
"alt-shift-t": "task::Spawn",
|
"alt-shift-t": "task::Spawn",
|
||||||
"alt-shift-r": ["task::Spawn", { "reveal_target": "center" }],
|
"alt-shift-r": ["task::Spawn", { "reveal_target": "center" }]
|
||||||
// also possible to spawn tasks by name:
|
// also possible to spawn tasks by name:
|
||||||
// "foo-bar": ["task::Spawn", { "task_name": "MyTask", "reveal_target": "dock" }]
|
// "foo-bar": ["task::Spawn", { "task_name": "MyTask", "reveal_target": "dock" }]
|
||||||
// or by tag:
|
// or by tag:
|
||||||
// "foo-bar": ["task::Spawn", { "task_tag": "MyTag" }],
|
// "foo-bar": ["task::Spawn", { "task_tag": "MyTag" }],
|
||||||
"f5": "debugger::RerunLastSession"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"context": "Workspace && debugger_running",
|
|
||||||
"bindings": {
|
|
||||||
"f5": "zed::NoAction"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"context": "Workspace && debugger_stopped",
|
|
||||||
"bindings": {
|
|
||||||
"f5": "debugger::Continue"
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -615,6 +593,7 @@
|
|||||||
{
|
{
|
||||||
"context": "Editor",
|
"context": "Editor",
|
||||||
"bindings": {
|
"bindings": {
|
||||||
|
"ctrl-shift-d": "editor::DuplicateLineDown",
|
||||||
"ctrl-shift-j": "editor::JoinLines",
|
"ctrl-shift-j": "editor::JoinLines",
|
||||||
"ctrl-alt-backspace": "editor::DeleteToPreviousSubwordStart",
|
"ctrl-alt-backspace": "editor::DeleteToPreviousSubwordStart",
|
||||||
"ctrl-alt-h": "editor::DeleteToPreviousSubwordStart",
|
"ctrl-alt-h": "editor::DeleteToPreviousSubwordStart",
|
||||||
@@ -693,8 +672,7 @@
|
|||||||
{
|
{
|
||||||
"bindings": {
|
"bindings": {
|
||||||
"ctrl-alt-shift-f": "workspace::FollowNextCollaborator",
|
"ctrl-alt-shift-f": "workspace::FollowNextCollaborator",
|
||||||
// Only available in debug builds: opens an element inspector for development.
|
"ctrl-alt-i": "zed::DebugElements"
|
||||||
"ctrl-alt-i": "dev::ToggleInspector"
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -788,7 +766,7 @@
|
|||||||
"alt-ctrl-r": "project_panel::RevealInFileManager",
|
"alt-ctrl-r": "project_panel::RevealInFileManager",
|
||||||
"ctrl-shift-enter": "project_panel::OpenWithSystem",
|
"ctrl-shift-enter": "project_panel::OpenWithSystem",
|
||||||
"shift-find": "project_panel::NewSearchInDirectory",
|
"shift-find": "project_panel::NewSearchInDirectory",
|
||||||
"ctrl-alt-shift-f": "project_panel::NewSearchInDirectory",
|
"ctrl-shift-f": "project_panel::NewSearchInDirectory",
|
||||||
"shift-down": "menu::SelectNext",
|
"shift-down": "menu::SelectNext",
|
||||||
"shift-up": "menu::SelectPrevious",
|
"shift-up": "menu::SelectPrevious",
|
||||||
"escape": "menu::Cancel"
|
"escape": "menu::Cancel"
|
||||||
@@ -882,38 +860,11 @@
|
|||||||
"alt-l": "git::GenerateCommitMessage"
|
"alt-l": "git::GenerateCommitMessage"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"context": "DebugPanel",
|
|
||||||
"bindings": {
|
|
||||||
"ctrl-t": "debugger::ToggleThreadPicker",
|
|
||||||
"ctrl-i": "debugger::ToggleSessionPicker",
|
|
||||||
"shift-alt-escape": "debugger::ToggleExpandItem"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"context": "VariableList",
|
|
||||||
"bindings": {
|
|
||||||
"left": "variable_list::CollapseSelectedEntry",
|
|
||||||
"right": "variable_list::ExpandSelectedEntry",
|
|
||||||
"enter": "variable_list::EditVariable",
|
|
||||||
"ctrl-c": "variable_list::CopyVariableValue",
|
|
||||||
"ctrl-alt-c": "variable_list::CopyVariableName"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"context": "BreakpointList",
|
|
||||||
"bindings": {
|
|
||||||
"space": "debugger::ToggleEnableBreakpoint",
|
|
||||||
"backspace": "debugger::UnsetBreakpoint"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"context": "CollabPanel && not_editing",
|
"context": "CollabPanel && not_editing",
|
||||||
"bindings": {
|
"bindings": {
|
||||||
"ctrl-backspace": "collab_panel::Remove",
|
"ctrl-backspace": "collab_panel::Remove",
|
||||||
"space": "menu::Confirm",
|
"space": "menu::Confirm"
|
||||||
"ctrl-up": "collab_panel::MoveChannelUp",
|
|
||||||
"ctrl-down": "collab_panel::MoveChannelDown"
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -944,13 +895,6 @@
|
|||||||
"tab": "channel_modal::ToggleMode"
|
"tab": "channel_modal::ToggleMode"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"context": "FileFinder",
|
|
||||||
"bindings": {
|
|
||||||
"ctrl-shift-a": "file_finder::ToggleSplitMenu",
|
|
||||||
"ctrl-shift-i": "file_finder::ToggleFilterMenu"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"context": "FileFinder || (FileFinder > Picker > Editor) || (FileFinder > Picker > menu)",
|
"context": "FileFinder || (FileFinder > Picker > Editor) || (FileFinder > Picker > menu)",
|
||||||
"bindings": {
|
"bindings": {
|
||||||
@@ -984,7 +928,6 @@
|
|||||||
"alt-b": ["terminal::SendText", "\u001bb"],
|
"alt-b": ["terminal::SendText", "\u001bb"],
|
||||||
"alt-f": ["terminal::SendText", "\u001bf"],
|
"alt-f": ["terminal::SendText", "\u001bf"],
|
||||||
"alt-.": ["terminal::SendText", "\u001b."],
|
"alt-.": ["terminal::SendText", "\u001b."],
|
||||||
"ctrl-delete": ["terminal::SendText", "\u001bd"],
|
|
||||||
// Overrides for conflicting keybindings
|
// Overrides for conflicting keybindings
|
||||||
"ctrl-b": ["terminal::SendKeystroke", "ctrl-b"],
|
"ctrl-b": ["terminal::SendKeystroke", "ctrl-b"],
|
||||||
"ctrl-c": ["terminal::SendKeystroke", "ctrl-c"],
|
"ctrl-c": ["terminal::SendKeystroke", "ctrl-c"],
|
||||||
@@ -1035,19 +978,5 @@
|
|||||||
"bindings": {
|
"bindings": {
|
||||||
"ctrl-r": "diagnostics::ToggleDiagnosticsRefresh"
|
"ctrl-r": "diagnostics::ToggleDiagnosticsRefresh"
|
||||||
}
|
}
|
||||||
},
|
|
||||||
{
|
|
||||||
"context": "DebugConsole > Editor",
|
|
||||||
"use_key_equivalents": true,
|
|
||||||
"bindings": {
|
|
||||||
"enter": "menu::Confirm"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"context": "RunModal",
|
|
||||||
"bindings": {
|
|
||||||
"ctrl-tab": "pane::ActivateNextItem",
|
|
||||||
"ctrl-shift-tab": "pane::ActivatePreviousItem"
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -1,11 +1,22 @@
|
|||||||
[
|
[
|
||||||
|
// Moved before Standard macOS bindings so that `cmd-w` is not the last binding for
|
||||||
|
// `workspace::CloseWindow` and displayed/intercepted by macOS
|
||||||
|
{
|
||||||
|
"context": "PromptLibrary",
|
||||||
|
"use_key_equivalents": true,
|
||||||
|
"bindings": {
|
||||||
|
"cmd-n": "rules_library::NewRule",
|
||||||
|
"cmd-shift-s": "rules_library::ToggleDefaultRule",
|
||||||
|
"cmd-w": "workspace::CloseWindow"
|
||||||
|
}
|
||||||
|
},
|
||||||
// Standard macOS bindings
|
// Standard macOS bindings
|
||||||
{
|
{
|
||||||
"use_key_equivalents": true,
|
"use_key_equivalents": true,
|
||||||
"bindings": {
|
"bindings": {
|
||||||
"f4": "debugger::Start",
|
"f4": "debugger::Start",
|
||||||
|
"f5": "debugger::Continue",
|
||||||
"shift-f5": "debugger::Stop",
|
"shift-f5": "debugger::Stop",
|
||||||
"shift-cmd-f5": "debugger::Restart",
|
|
||||||
"f6": "debugger::Pause",
|
"f6": "debugger::Pause",
|
||||||
"f7": "debugger::StepOver",
|
"f7": "debugger::StepOver",
|
||||||
"f11": "debugger::StepInto",
|
"f11": "debugger::StepInto",
|
||||||
@@ -138,7 +149,7 @@
|
|||||||
"cmd-;": "editor::ToggleLineNumbers",
|
"cmd-;": "editor::ToggleLineNumbers",
|
||||||
"cmd-'": "editor::ToggleSelectedDiffHunks",
|
"cmd-'": "editor::ToggleSelectedDiffHunks",
|
||||||
"cmd-\"": "editor::ExpandAllDiffHunks",
|
"cmd-\"": "editor::ExpandAllDiffHunks",
|
||||||
"cmd-alt-g b": "git::Blame",
|
"cmd-alt-g b": "editor::ToggleGitBlame",
|
||||||
"cmd-i": "editor::ShowSignatureHelp",
|
"cmd-i": "editor::ShowSignatureHelp",
|
||||||
"f9": "editor::ToggleBreakpoint",
|
"f9": "editor::ToggleBreakpoint",
|
||||||
"shift-f9": "editor::EditLogBreakpoint",
|
"shift-f9": "editor::EditLogBreakpoint",
|
||||||
@@ -277,14 +288,11 @@
|
|||||||
"cmd-i": "agent::ToggleProfileSelector",
|
"cmd-i": "agent::ToggleProfileSelector",
|
||||||
"cmd-alt-/": "agent::ToggleModelSelector",
|
"cmd-alt-/": "agent::ToggleModelSelector",
|
||||||
"cmd-shift-a": "agent::ToggleContextPicker",
|
"cmd-shift-a": "agent::ToggleContextPicker",
|
||||||
"cmd-shift-j": "agent::ToggleNavigationMenu",
|
"cmd-shift-o": "agent::ToggleNavigationMenu",
|
||||||
"cmd-shift-i": "agent::ToggleOptionsMenu",
|
"cmd-shift-i": "agent::ToggleOptionsMenu",
|
||||||
"shift-alt-escape": "agent::ExpandMessageEditor",
|
"shift-escape": "agent::ExpandMessageEditor",
|
||||||
"cmd-alt-e": "agent::RemoveAllContext",
|
"cmd-alt-e": "agent::RemoveAllContext",
|
||||||
"cmd-shift-e": "project_panel::ToggleFocus",
|
"cmd-shift-e": "project_panel::ToggleFocus"
|
||||||
"cmd-shift-enter": "agent::ContinueThread",
|
|
||||||
"alt-enter": "agent::ContinueWithBurnMode",
|
|
||||||
"cmd-alt-b": "agent::ToggleBurnMode"
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -313,11 +321,8 @@
|
|||||||
"use_key_equivalents": true,
|
"use_key_equivalents": true,
|
||||||
"bindings": {
|
"bindings": {
|
||||||
"enter": "agent::Chat",
|
"enter": "agent::Chat",
|
||||||
"cmd-enter": "agent::ChatWithFollow",
|
|
||||||
"cmd-i": "agent::ToggleProfileSelector",
|
"cmd-i": "agent::ToggleProfileSelector",
|
||||||
"shift-ctrl-r": "agent::OpenAgentDiff",
|
"shift-ctrl-r": "agent::OpenAgentDiff"
|
||||||
"cmd-shift-y": "agent::KeepAll",
|
|
||||||
"cmd-shift-n": "agent::RejectAll"
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -363,18 +368,15 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"context": "ThreadHistory > Editor",
|
"context": "ThreadHistory",
|
||||||
"bindings": {
|
"bindings": {
|
||||||
"shift-backspace": "agent::RemoveSelectedThread"
|
"ctrl--": "pane::GoBack"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"context": "PromptLibrary",
|
"context": "ThreadHistory > Editor",
|
||||||
"use_key_equivalents": true,
|
|
||||||
"bindings": {
|
"bindings": {
|
||||||
"cmd-n": "rules_library::NewRule",
|
"shift-backspace": "agent::RemoveSelectedThread"
|
||||||
"cmd-shift-s": "rules_library::ToggleDefaultRule",
|
|
||||||
"cmd-w": "workspace::CloseWindow"
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -546,7 +548,9 @@
|
|||||||
"cmd-\\": "pane::SplitRight",
|
"cmd-\\": "pane::SplitRight",
|
||||||
"cmd-k v": "markdown::OpenPreviewToTheSide",
|
"cmd-k v": "markdown::OpenPreviewToTheSide",
|
||||||
"cmd-shift-v": "markdown::OpenPreview",
|
"cmd-shift-v": "markdown::OpenPreview",
|
||||||
"ctrl-cmd-c": "editor::DisplayCursorNames"
|
"ctrl-cmd-c": "editor::DisplayCursorNames",
|
||||||
|
"cmd-shift-backspace": "editor::GoToPreviousChange",
|
||||||
|
"cmd-shift-alt-backspace": "editor::GoToNextChange"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -554,9 +558,7 @@
|
|||||||
"use_key_equivalents": true,
|
"use_key_equivalents": true,
|
||||||
"bindings": {
|
"bindings": {
|
||||||
"cmd-shift-o": "outline::Toggle",
|
"cmd-shift-o": "outline::Toggle",
|
||||||
"ctrl-g": "go_to_line::Toggle",
|
"ctrl-g": "go_to_line::Toggle"
|
||||||
"cmd-shift-backspace": "editor::GoToPreviousChange",
|
|
||||||
"cmd-shift-alt-backspace": "editor::GoToNextChange"
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -584,9 +586,8 @@
|
|||||||
"bindings": {
|
"bindings": {
|
||||||
// Change the default action on `menu::Confirm` by setting the parameter
|
// Change the default action on `menu::Confirm` by setting the parameter
|
||||||
// "alt-cmd-o": ["projects::OpenRecent", {"create_new_window": true }],
|
// "alt-cmd-o": ["projects::OpenRecent", {"create_new_window": true }],
|
||||||
"alt-cmd-o": ["projects::OpenRecent", { "create_new_window": false }],
|
"alt-cmd-o": "projects::OpenRecent",
|
||||||
"ctrl-cmd-o": ["projects::OpenRemote", { "from_existing_connection": false, "create_new_window": false }],
|
"ctrl-cmd-o": "projects::OpenRemote",
|
||||||
"ctrl-cmd-shift-o": ["projects::OpenRemote", { "from_existing_connection": true, "create_new_window": false }],
|
|
||||||
"alt-cmd-b": "branches::OpenRecent",
|
"alt-cmd-b": "branches::OpenRecent",
|
||||||
"ctrl-~": "workspace::NewTerminal",
|
"ctrl-~": "workspace::NewTerminal",
|
||||||
"cmd-s": "workspace::Save",
|
"cmd-s": "workspace::Save",
|
||||||
@@ -622,7 +623,6 @@
|
|||||||
"cmd-shift-e": "project_panel::ToggleFocus",
|
"cmd-shift-e": "project_panel::ToggleFocus",
|
||||||
"cmd-shift-b": "outline_panel::ToggleFocus",
|
"cmd-shift-b": "outline_panel::ToggleFocus",
|
||||||
"ctrl-shift-g": "git_panel::ToggleFocus",
|
"ctrl-shift-g": "git_panel::ToggleFocus",
|
||||||
"cmd-shift-d": "debug_panel::ToggleFocus",
|
|
||||||
"cmd-?": "agent::ToggleFocus",
|
"cmd-?": "agent::ToggleFocus",
|
||||||
"cmd-alt-s": "workspace::SaveAll",
|
"cmd-alt-s": "workspace::SaveAll",
|
||||||
"cmd-k m": "language_selector::Toggle",
|
"cmd-k m": "language_selector::Toggle",
|
||||||
@@ -635,8 +635,7 @@
|
|||||||
"cmd-k shift-right": "workspace::SwapPaneRight",
|
"cmd-k shift-right": "workspace::SwapPaneRight",
|
||||||
"cmd-k shift-up": "workspace::SwapPaneUp",
|
"cmd-k shift-up": "workspace::SwapPaneUp",
|
||||||
"cmd-k shift-down": "workspace::SwapPaneDown",
|
"cmd-k shift-down": "workspace::SwapPaneDown",
|
||||||
"cmd-shift-x": "zed::Extensions",
|
"cmd-shift-x": "zed::Extensions"
|
||||||
"f5": "debugger::RerunLastSession"
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -653,20 +652,6 @@
|
|||||||
// "foo-bar": ["task::Spawn", { "task_tag": "MyTag" }],
|
// "foo-bar": ["task::Spawn", { "task_tag": "MyTag" }],
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"context": "Workspace && debugger_running",
|
|
||||||
"use_key_equivalents": true,
|
|
||||||
"bindings": {
|
|
||||||
"f5": "zed::NoAction"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"context": "Workspace && debugger_stopped",
|
|
||||||
"use_key_equivalents": true,
|
|
||||||
"bindings": {
|
|
||||||
"f5": "debugger::Continue"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
// Bindings from Sublime Text
|
// Bindings from Sublime Text
|
||||||
{
|
{
|
||||||
"context": "Editor",
|
"context": "Editor",
|
||||||
@@ -755,8 +740,7 @@
|
|||||||
"ctrl-alt-cmd-f": "workspace::FollowNextCollaborator",
|
"ctrl-alt-cmd-f": "workspace::FollowNextCollaborator",
|
||||||
// TODO: Move this to a dock open action
|
// TODO: Move this to a dock open action
|
||||||
"cmd-shift-c": "collab_panel::ToggleFocus",
|
"cmd-shift-c": "collab_panel::ToggleFocus",
|
||||||
// Only available in debug builds: opens an element inspector for development.
|
"cmd-alt-i": "zed::DebugElements"
|
||||||
"cmd-alt-i": "dev::ToggleInspector"
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -841,7 +825,7 @@
|
|||||||
"alt-cmd-r": "project_panel::RevealInFileManager",
|
"alt-cmd-r": "project_panel::RevealInFileManager",
|
||||||
"ctrl-shift-enter": "project_panel::OpenWithSystem",
|
"ctrl-shift-enter": "project_panel::OpenWithSystem",
|
||||||
"cmd-alt-backspace": ["project_panel::Delete", { "skip_prompt": false }],
|
"cmd-alt-backspace": ["project_panel::Delete", { "skip_prompt": false }],
|
||||||
"cmd-alt-shift-f": "project_panel::NewSearchInDirectory",
|
"cmd-shift-f": "project_panel::NewSearchInDirectory",
|
||||||
"shift-down": "menu::SelectNext",
|
"shift-down": "menu::SelectNext",
|
||||||
"shift-up": "menu::SelectPrevious",
|
"shift-up": "menu::SelectPrevious",
|
||||||
"escape": "menu::Cancel"
|
"escape": "menu::Cancel"
|
||||||
@@ -859,10 +843,7 @@
|
|||||||
"use_key_equivalents": true,
|
"use_key_equivalents": true,
|
||||||
"bindings": {
|
"bindings": {
|
||||||
"left": "variable_list::CollapseSelectedEntry",
|
"left": "variable_list::CollapseSelectedEntry",
|
||||||
"right": "variable_list::ExpandSelectedEntry",
|
"right": "variable_list::ExpandSelectedEntry"
|
||||||
"enter": "variable_list::EditVariable",
|
|
||||||
"cmd-c": "variable_list::CopyVariableValue",
|
|
||||||
"cmd-alt-c": "variable_list::CopyVariableName"
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -947,29 +928,12 @@
|
|||||||
"alt-tab": "git::GenerateCommitMessage"
|
"alt-tab": "git::GenerateCommitMessage"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"context": "DebugPanel",
|
|
||||||
"bindings": {
|
|
||||||
"cmd-t": "debugger::ToggleThreadPicker",
|
|
||||||
"cmd-i": "debugger::ToggleSessionPicker",
|
|
||||||
"shift-alt-escape": "debugger::ToggleExpandItem"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"context": "BreakpointList",
|
|
||||||
"bindings": {
|
|
||||||
"space": "debugger::ToggleEnableBreakpoint",
|
|
||||||
"backspace": "debugger::UnsetBreakpoint"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"context": "CollabPanel && not_editing",
|
"context": "CollabPanel && not_editing",
|
||||||
"use_key_equivalents": true,
|
"use_key_equivalents": true,
|
||||||
"bindings": {
|
"bindings": {
|
||||||
"ctrl-backspace": "collab_panel::Remove",
|
"ctrl-backspace": "collab_panel::Remove",
|
||||||
"space": "menu::Confirm",
|
"space": "menu::Confirm"
|
||||||
"cmd-up": "collab_panel::MoveChannelUp",
|
|
||||||
"cmd-down": "collab_panel::MoveChannelDown"
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -1005,14 +969,6 @@
|
|||||||
"tab": "channel_modal::ToggleMode"
|
"tab": "channel_modal::ToggleMode"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"context": "FileFinder",
|
|
||||||
"use_key_equivalents": true,
|
|
||||||
"bindings": {
|
|
||||||
"cmd-shift-a": "file_finder::ToggleSplitMenu",
|
|
||||||
"cmd-shift-i": "file_finder::ToggleFilterMenu"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"context": "FileFinder || (FileFinder > Picker > Editor) || (FileFinder > Picker > menu)",
|
"context": "FileFinder || (FileFinder > Picker > Editor) || (FileFinder > Picker > menu)",
|
||||||
"use_key_equivalents": true,
|
"use_key_equivalents": true,
|
||||||
@@ -1055,7 +1011,7 @@
|
|||||||
"alt-right": ["terminal::SendText", "\u001bf"],
|
"alt-right": ["terminal::SendText", "\u001bf"],
|
||||||
"alt-b": ["terminal::SendText", "\u001bb"],
|
"alt-b": ["terminal::SendText", "\u001bb"],
|
||||||
"alt-f": ["terminal::SendText", "\u001bf"],
|
"alt-f": ["terminal::SendText", "\u001bf"],
|
||||||
"ctrl-delete": ["terminal::SendText", "\u001bd"],
|
"alt-.": ["terminal::SendText", "\u001b."],
|
||||||
// There are conflicting bindings for these keys in the global context.
|
// There are conflicting bindings for these keys in the global context.
|
||||||
// these bindings override them, remove at your own risk:
|
// these bindings override them, remove at your own risk:
|
||||||
"up": ["terminal::SendKeystroke", "up"],
|
"up": ["terminal::SendKeystroke", "up"],
|
||||||
@@ -1128,20 +1084,5 @@
|
|||||||
"bindings": {
|
"bindings": {
|
||||||
"ctrl-r": "diagnostics::ToggleDiagnosticsRefresh"
|
"ctrl-r": "diagnostics::ToggleDiagnosticsRefresh"
|
||||||
}
|
}
|
||||||
},
|
|
||||||
{
|
|
||||||
"context": "DebugConsole > Editor",
|
|
||||||
"use_key_equivalents": true,
|
|
||||||
"bindings": {
|
|
||||||
"enter": "menu::Confirm"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"context": "RunModal",
|
|
||||||
"use_key_equivalents": true,
|
|
||||||
"bindings": {
|
|
||||||
"ctrl-tab": "pane::ActivateNextItem",
|
|
||||||
"ctrl-shift-tab": "pane::ActivatePreviousItem"
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -1,85 +0,0 @@
|
|||||||
[
|
|
||||||
// Cursor for MacOS. See: https://docs.cursor.com/kbd
|
|
||||||
{
|
|
||||||
"context": "Workspace",
|
|
||||||
"use_key_equivalents": true,
|
|
||||||
"bindings": {
|
|
||||||
"ctrl-i": "agent::ToggleFocus",
|
|
||||||
"ctrl-shift-i": "agent::ToggleFocus",
|
|
||||||
"ctrl-l": "agent::ToggleFocus",
|
|
||||||
"ctrl-shift-l": "agent::ToggleFocus",
|
|
||||||
"ctrl-alt-b": "agent::ToggleFocus",
|
|
||||||
"ctrl-shift-j": "agent::OpenConfiguration"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"context": "Editor && mode == full",
|
|
||||||
"use_key_equivalents": true,
|
|
||||||
"bindings": {
|
|
||||||
"ctrl-i": "agent::ToggleFocus",
|
|
||||||
"ctrl-shift-i": "agent::ToggleFocus",
|
|
||||||
"ctrl-shift-l": "assistant::QuoteSelection", // In cursor uses "Ask" mode
|
|
||||||
"ctrl-l": "assistant::QuoteSelection", // In cursor uses "Agent" mode
|
|
||||||
"ctrl-k": "assistant::InlineAssist",
|
|
||||||
"ctrl-shift-k": "assistant::InsertIntoEditor"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"context": "InlineAssistEditor",
|
|
||||||
"use_key_equivalents": true,
|
|
||||||
"bindings": {
|
|
||||||
"ctrl-shift-backspace": "editor::Cancel"
|
|
||||||
// "alt-enter": // Quick Question
|
|
||||||
// "ctrl-shift-enter": // Full File Context
|
|
||||||
// "ctrl-shift-k": // Toggle input focus (editor <> inline assist)
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"context": "AgentPanel || ContextEditor || (MessageEditor > Editor)",
|
|
||||||
"use_key_equivalents": true,
|
|
||||||
"bindings": {
|
|
||||||
"ctrl-i": "workspace::ToggleRightDock",
|
|
||||||
"ctrl-shift-i": "workspace::ToggleRightDock",
|
|
||||||
"ctrl-l": "workspace::ToggleRightDock",
|
|
||||||
"ctrl-shift-l": "workspace::ToggleRightDock",
|
|
||||||
"ctrl-alt-b": "workspace::ToggleRightDock",
|
|
||||||
"ctrl-w": "workspace::ToggleRightDock", // technically should close chat
|
|
||||||
"ctrl-.": "agent::ToggleProfileSelector",
|
|
||||||
"ctrl-/": "agent::ToggleModelSelector",
|
|
||||||
"ctrl-shift-backspace": "editor::Cancel",
|
|
||||||
"ctrl-r": "agent::NewThread",
|
|
||||||
"ctrl-shift-v": "editor::Paste",
|
|
||||||
"ctrl-shift-k": "assistant::InsertIntoEditor"
|
|
||||||
// "escape": "agent::ToggleFocus"
|
|
||||||
///// Enable when Zed supports multiple thread tabs
|
|
||||||
// "ctrl-t": // new thread tab
|
|
||||||
// "ctrl-[": // next thread tab
|
|
||||||
// "ctrl-]": // next thread tab
|
|
||||||
///// Enable if Zed adds support for keyboard navigation of thread elements
|
|
||||||
// "tab": // cycle to next message
|
|
||||||
// "shift-tab": // cycle to previous message
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"context": "Editor && editor_agent_diff",
|
|
||||||
"use_key_equivalents": true,
|
|
||||||
"bindings": {
|
|
||||||
"ctrl-enter": "agent::KeepAll",
|
|
||||||
"ctrl-backspace": "agent::RejectAll"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"context": "Editor && mode == full && edit_prediction",
|
|
||||||
"use_key_equivalents": true,
|
|
||||||
"bindings": {
|
|
||||||
"ctrl-right": "editor::AcceptPartialEditPrediction"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"context": "Terminal",
|
|
||||||
"use_key_equivalents": true,
|
|
||||||
"bindings": {
|
|
||||||
"ctrl-k": "assistant::InlineAssist"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
]
|
|
||||||
@@ -72,9 +72,7 @@
|
|||||||
"alt-left": "editor::SelectToPreviousWordStart",
|
"alt-left": "editor::SelectToPreviousWordStart",
|
||||||
"alt-right": "editor::SelectToNextWordEnd",
|
"alt-right": "editor::SelectToNextWordEnd",
|
||||||
"pagedown": "editor::SelectPageDown",
|
"pagedown": "editor::SelectPageDown",
|
||||||
"ctrl-v": "editor::SelectPageDown",
|
|
||||||
"pageup": "editor::SelectPageUp",
|
"pageup": "editor::SelectPageUp",
|
||||||
"alt-v": "editor::SelectPageUp",
|
|
||||||
"ctrl-f": "editor::SelectRight",
|
"ctrl-f": "editor::SelectRight",
|
||||||
"ctrl-b": "editor::SelectLeft",
|
"ctrl-b": "editor::SelectLeft",
|
||||||
"ctrl-n": "editor::SelectDown",
|
"ctrl-n": "editor::SelectDown",
|
||||||
|
|||||||
@@ -52,10 +52,8 @@
|
|||||||
"shift-alt-m": "markdown::OpenPreviewToTheSide",
|
"shift-alt-m": "markdown::OpenPreviewToTheSide",
|
||||||
"ctrl-backspace": "editor::DeleteToPreviousWordStart",
|
"ctrl-backspace": "editor::DeleteToPreviousWordStart",
|
||||||
"ctrl-delete": "editor::DeleteToNextWordEnd",
|
"ctrl-delete": "editor::DeleteToNextWordEnd",
|
||||||
"alt-right": "editor::MoveToNextSubwordEnd",
|
"f3": "editor::FindNextMatch",
|
||||||
"alt-left": "editor::MoveToPreviousSubwordStart",
|
"shift-f3": "editor::FindPreviousMatch"
|
||||||
"alt-shift-right": "editor::SelectToNextSubwordEnd",
|
|
||||||
"alt-shift-left": "editor::SelectToPreviousSubwordStart"
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,85 +0,0 @@
|
|||||||
[
|
|
||||||
// Cursor for MacOS. See: https://docs.cursor.com/kbd
|
|
||||||
{
|
|
||||||
"context": "Workspace",
|
|
||||||
"use_key_equivalents": true,
|
|
||||||
"bindings": {
|
|
||||||
"cmd-i": "agent::ToggleFocus",
|
|
||||||
"cmd-shift-i": "agent::ToggleFocus",
|
|
||||||
"cmd-l": "agent::ToggleFocus",
|
|
||||||
"cmd-shift-l": "agent::ToggleFocus",
|
|
||||||
"cmd-alt-b": "agent::ToggleFocus",
|
|
||||||
"cmd-shift-j": "agent::OpenConfiguration"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"context": "Editor && mode == full",
|
|
||||||
"use_key_equivalents": true,
|
|
||||||
"bindings": {
|
|
||||||
"cmd-i": "agent::ToggleFocus",
|
|
||||||
"cmd-shift-i": "agent::ToggleFocus",
|
|
||||||
"cmd-shift-l": "assistant::QuoteSelection", // In cursor uses "Ask" mode
|
|
||||||
"cmd-l": "assistant::QuoteSelection", // In cursor uses "Agent" mode
|
|
||||||
"cmd-k": "assistant::InlineAssist",
|
|
||||||
"cmd-shift-k": "assistant::InsertIntoEditor"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"context": "InlineAssistEditor",
|
|
||||||
"use_key_equivalents": true,
|
|
||||||
"bindings": {
|
|
||||||
"cmd-shift-backspace": "editor::Cancel"
|
|
||||||
// "alt-enter": // Quick Question
|
|
||||||
// "cmd-shift-enter": // Full File Context
|
|
||||||
// "cmd-shift-k": // Toggle input focus (editor <> inline assist)
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"context": "AgentPanel || ContextEditor || (MessageEditor > Editor)",
|
|
||||||
"use_key_equivalents": true,
|
|
||||||
"bindings": {
|
|
||||||
"cmd-i": "workspace::ToggleRightDock",
|
|
||||||
"cmd-shift-i": "workspace::ToggleRightDock",
|
|
||||||
"cmd-l": "workspace::ToggleRightDock",
|
|
||||||
"cmd-shift-l": "workspace::ToggleRightDock",
|
|
||||||
"cmd-alt-b": "workspace::ToggleRightDock",
|
|
||||||
"cmd-w": "workspace::ToggleRightDock", // technically should close chat
|
|
||||||
"cmd-.": "agent::ToggleProfileSelector",
|
|
||||||
"cmd-/": "agent::ToggleModelSelector",
|
|
||||||
"cmd-shift-backspace": "editor::Cancel",
|
|
||||||
"cmd-r": "agent::NewThread",
|
|
||||||
"cmd-shift-v": "editor::Paste",
|
|
||||||
"cmd-shift-k": "assistant::InsertIntoEditor"
|
|
||||||
// "escape": "agent::ToggleFocus"
|
|
||||||
///// Enable when Zed supports multiple thread tabs
|
|
||||||
// "cmd-t": // new thread tab
|
|
||||||
// "cmd-[": // next thread tab
|
|
||||||
// "cmd-]": // next thread tab
|
|
||||||
///// Enable if Zed adds support for keyboard navigation of thread elements
|
|
||||||
// "tab": // cycle to next message
|
|
||||||
// "shift-tab": // cycle to previous message
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"context": "Editor && editor_agent_diff",
|
|
||||||
"use_key_equivalents": true,
|
|
||||||
"bindings": {
|
|
||||||
"cmd-enter": "agent::KeepAll",
|
|
||||||
"cmd-backspace": "agent::RejectAll"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"context": "Editor && mode == full && edit_prediction",
|
|
||||||
"use_key_equivalents": true,
|
|
||||||
"bindings": {
|
|
||||||
"cmd-right": "editor::AcceptPartialEditPrediction"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"context": "Terminal",
|
|
||||||
"use_key_equivalents": true,
|
|
||||||
"bindings": {
|
|
||||||
"cmd-k": "assistant::InlineAssist"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
]
|
|
||||||
@@ -72,9 +72,7 @@
|
|||||||
"alt-left": "editor::SelectToPreviousWordStart",
|
"alt-left": "editor::SelectToPreviousWordStart",
|
||||||
"alt-right": "editor::SelectToNextWordEnd",
|
"alt-right": "editor::SelectToNextWordEnd",
|
||||||
"pagedown": "editor::SelectPageDown",
|
"pagedown": "editor::SelectPageDown",
|
||||||
"ctrl-v": "editor::SelectPageDown",
|
|
||||||
"pageup": "editor::SelectPageUp",
|
"pageup": "editor::SelectPageUp",
|
||||||
"alt-v": "editor::SelectPageUp",
|
|
||||||
"ctrl-f": "editor::SelectRight",
|
"ctrl-f": "editor::SelectRight",
|
||||||
"ctrl-b": "editor::SelectLeft",
|
"ctrl-b": "editor::SelectLeft",
|
||||||
"ctrl-n": "editor::SelectDown",
|
"ctrl-n": "editor::SelectDown",
|
||||||
|
|||||||
@@ -54,10 +54,8 @@
|
|||||||
"shift-alt-m": "markdown::OpenPreviewToTheSide",
|
"shift-alt-m": "markdown::OpenPreviewToTheSide",
|
||||||
"ctrl-backspace": "editor::DeleteToPreviousWordStart",
|
"ctrl-backspace": "editor::DeleteToPreviousWordStart",
|
||||||
"ctrl-delete": "editor::DeleteToNextWordEnd",
|
"ctrl-delete": "editor::DeleteToNextWordEnd",
|
||||||
"ctrl-right": "editor::MoveToNextSubwordEnd",
|
"cmd-g": "editor::FindNextMatch",
|
||||||
"ctrl-left": "editor::MoveToPreviousSubwordStart",
|
"cmd-shift-g": "editor::FindPreviousMatch"
|
||||||
"ctrl-shift-right": "editor::SelectToNextSubwordEnd",
|
|
||||||
"ctrl-shift-left": "editor::SelectToPreviousSubwordStart"
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -152,7 +152,6 @@
|
|||||||
"g end": ["vim::EndOfLine", { "display_lines": true }],
|
"g end": ["vim::EndOfLine", { "display_lines": true }],
|
||||||
"g 0": ["vim::StartOfLine", { "display_lines": true }],
|
"g 0": ["vim::StartOfLine", { "display_lines": true }],
|
||||||
"g home": ["vim::StartOfLine", { "display_lines": true }],
|
"g home": ["vim::StartOfLine", { "display_lines": true }],
|
||||||
"g shift-m": ["vim::MiddleOfLine", { "display_lines": true }],
|
|
||||||
"g ^": ["vim::FirstNonWhitespace", { "display_lines": true }],
|
"g ^": ["vim::FirstNonWhitespace", { "display_lines": true }],
|
||||||
"g v": "vim::RestoreVisualSelection",
|
"g v": "vim::RestoreVisualSelection",
|
||||||
"g ]": "editor::GoToDiagnostic",
|
"g ]": "editor::GoToDiagnostic",
|
||||||
@@ -198,8 +197,6 @@
|
|||||||
"9": ["vim::Number", 9],
|
"9": ["vim::Number", 9],
|
||||||
"ctrl-w d": "editor::GoToDefinitionSplit",
|
"ctrl-w d": "editor::GoToDefinitionSplit",
|
||||||
"ctrl-w g d": "editor::GoToDefinitionSplit",
|
"ctrl-w g d": "editor::GoToDefinitionSplit",
|
||||||
"ctrl-w ]": "editor::GoToDefinitionSplit",
|
|
||||||
"ctrl-w ctrl-]": "editor::GoToDefinitionSplit",
|
|
||||||
"ctrl-w shift-d": "editor::GoToTypeDefinitionSplit",
|
"ctrl-w shift-d": "editor::GoToTypeDefinitionSplit",
|
||||||
"ctrl-w g shift-d": "editor::GoToTypeDefinitionSplit",
|
"ctrl-w g shift-d": "editor::GoToTypeDefinitionSplit",
|
||||||
"ctrl-w space": "editor::OpenExcerptsSplit",
|
"ctrl-w space": "editor::OpenExcerptsSplit",
|
||||||
@@ -840,19 +837,6 @@
|
|||||||
"tab": "editor::AcceptEditPrediction"
|
"tab": "editor::AcceptEditPrediction"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"context": "MessageEditor > Editor && VimControl",
|
|
||||||
"bindings": {
|
|
||||||
"enter": "agent::Chat",
|
|
||||||
// TODO: Implement search
|
|
||||||
"/": null,
|
|
||||||
"?": null,
|
|
||||||
"#": null,
|
|
||||||
"*": null,
|
|
||||||
"n": null,
|
|
||||||
"shift-n": null
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"context": "os != macos && Editor && edit_prediction_conflict",
|
"context": "os != macos && Editor && edit_prediction_conflict",
|
||||||
"bindings": {
|
"bindings": {
|
||||||
@@ -861,5 +845,13 @@
|
|||||||
// and Windows.
|
// and Windows.
|
||||||
"alt-l": "editor::AcceptEditPrediction"
|
"alt-l": "editor::AcceptEditPrediction"
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
// Fixes https://github.com/zed-industries/zed/issues/29095 by ensuring that
|
||||||
|
// the last binding for editor::ToggleComments is not ctrl-c.
|
||||||
|
"context": "hack_to_fix_ctrl-c",
|
||||||
|
"bindings": {
|
||||||
|
"g c": "editor::ToggleComments"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -17,13 +17,13 @@ You are a highly skilled software engineer with extensive knowledge in many prog
|
|||||||
4. Use only the tools that are currently available.
|
4. Use only the tools that are currently available.
|
||||||
5. DO NOT use a tool that is not available just because it appears in the conversation. This means the user turned it off.
|
5. DO NOT use a tool that is not available just because it appears in the conversation. This means the user turned it off.
|
||||||
6. NEVER run commands that don't terminate on their own such as web servers (like `npm run start`, `npm run dev`, `python -m http.server`, etc) or file watchers.
|
6. NEVER run commands that don't terminate on their own such as web servers (like `npm run start`, `npm run dev`, `python -m http.server`, etc) or file watchers.
|
||||||
7. Avoid HTML entity escaping - use plain characters instead.
|
|
||||||
|
|
||||||
## Searching and Reading
|
## Searching and Reading
|
||||||
|
|
||||||
If you are unsure how to fulfill the user's request, gather more information with tool calls and/or clarifying questions.
|
If you are unsure how to fulfill the user's request, gather more information with tool calls and/or clarifying questions.
|
||||||
|
|
||||||
{{! TODO: If there are files, we should mention it but otherwise omit that fact }}
|
{{! TODO: If there are files, we should mention it but otherwise omit that fact }}
|
||||||
|
{{#if has_tools}}
|
||||||
If appropriate, use tool calls to explore the current project, which contains the following root directories:
|
If appropriate, use tool calls to explore the current project, which contains the following root directories:
|
||||||
|
|
||||||
{{#each worktrees}}
|
{{#each worktrees}}
|
||||||
@@ -38,6 +38,7 @@ If appropriate, use tool calls to explore the current project, which contains th
|
|||||||
- As you learn about the structure of the project, use that information to scope `grep` searches to targeted subtrees of the project.
|
- As you learn about the structure of the project, use that information to scope `grep` searches to targeted subtrees of the project.
|
||||||
- The user might specify a partial file path. If you don't know the full path, use `find_path` (not `grep`) before you read the file.
|
- The user might specify a partial file path. If you don't know the full path, use `find_path` (not `grep`) before you read the file.
|
||||||
{{/if}}
|
{{/if}}
|
||||||
|
{{/if}}
|
||||||
{{else}}
|
{{else}}
|
||||||
You are being tasked with providing a response, but you have no ability to use tools or to read or write any aspect of the user's system (other than any context the user might have provided to you).
|
You are being tasked with providing a response, but you have no ability to use tools or to read or write any aspect of the user's system (other than any context the user might have provided to you).
|
||||||
|
|
||||||
|
|||||||
@@ -49,9 +49,10 @@ And here's the section to rewrite based on that prompt again for reference:
|
|||||||
</rewrite_this>
|
</rewrite_this>
|
||||||
|
|
||||||
{{#if diagnostic_errors}}
|
{{#if diagnostic_errors}}
|
||||||
|
{{#each diagnostic_errors}}
|
||||||
|
|
||||||
Below are the diagnostic errors visible to the user. If the user requests problems to be fixed, use this information, but do not try to fix these errors if the user hasn't asked you to.
|
Below are the diagnostic errors visible to the user. If the user requests problems to be fixed, use this information, but do not try to fix these errors if the user hasn't asked you to.
|
||||||
|
|
||||||
{{#each diagnostic_errors}}
|
|
||||||
<diagnostic_error>
|
<diagnostic_error>
|
||||||
<line_number>{{line_number}}</line_number>
|
<line_number>{{line_number}}</line_number>
|
||||||
<error_message>{{error_message}}</error_message>
|
<error_message>{{error_message}}</error_message>
|
||||||
|
|||||||
@@ -73,6 +73,9 @@
|
|||||||
"unnecessary_code_fade": 0.3,
|
"unnecessary_code_fade": 0.3,
|
||||||
// Active pane styling settings.
|
// Active pane styling settings.
|
||||||
"active_pane_modifiers": {
|
"active_pane_modifiers": {
|
||||||
|
// The factor to grow the active pane by. Defaults to 1.0
|
||||||
|
// which gives the same size as all other panes.
|
||||||
|
"magnification": 1.0,
|
||||||
// Inset border size of the active pane, in pixels.
|
// Inset border size of the active pane, in pixels.
|
||||||
"border_size": 0.0,
|
"border_size": 0.0,
|
||||||
// Opacity of the inactive panes. 0 means transparent, 1 means opaque.
|
// Opacity of the inactive panes. 0 means transparent, 1 means opaque.
|
||||||
@@ -110,8 +113,8 @@
|
|||||||
// Whether to show the informational hover box when moving the mouse
|
// Whether to show the informational hover box when moving the mouse
|
||||||
// over symbols in the editor.
|
// over symbols in the editor.
|
||||||
"hover_popover_enabled": true,
|
"hover_popover_enabled": true,
|
||||||
// Time to wait in milliseconds before showing the informational hover box.
|
// Time to wait before showing the informational hover box
|
||||||
"hover_popover_delay": 300,
|
"hover_popover_delay": 350,
|
||||||
// Whether to confirm before quitting Zed.
|
// Whether to confirm before quitting Zed.
|
||||||
"confirm_quit": false,
|
"confirm_quit": false,
|
||||||
// Whether to restore last closed project when fresh Zed instance is opened.
|
// Whether to restore last closed project when fresh Zed instance is opened.
|
||||||
@@ -125,8 +128,6 @@
|
|||||||
//
|
//
|
||||||
// Default: true
|
// Default: true
|
||||||
"restore_on_file_reopen": true,
|
"restore_on_file_reopen": true,
|
||||||
// Whether to automatically close files that have been deleted on disk.
|
|
||||||
"close_on_file_delete": false,
|
|
||||||
// Size of the drop target in the editor.
|
// Size of the drop target in the editor.
|
||||||
"drop_target_size": 0.2,
|
"drop_target_size": 0.2,
|
||||||
// Whether the window should be closed when using 'close active item' on a window with no tabs.
|
// Whether the window should be closed when using 'close active item' on a window with no tabs.
|
||||||
@@ -212,8 +213,6 @@
|
|||||||
// Whether to show the signature help after completion or a bracket pair inserted.
|
// Whether to show the signature help after completion or a bracket pair inserted.
|
||||||
// If `auto_signature_help` is enabled, this setting will be treated as enabled also.
|
// If `auto_signature_help` is enabled, this setting will be treated as enabled also.
|
||||||
"show_signature_help_after_edits": false,
|
"show_signature_help_after_edits": false,
|
||||||
// Whether to show code action button at start of buffer line.
|
|
||||||
"inline_code_actions": true,
|
|
||||||
// What to do when go to definition yields no results.
|
// What to do when go to definition yields no results.
|
||||||
//
|
//
|
||||||
// 1. Do nothing: `none`
|
// 1. Do nothing: `none`
|
||||||
@@ -231,11 +230,11 @@
|
|||||||
// Possible values:
|
// Possible values:
|
||||||
// - "off" — no diagnostics are allowed
|
// - "off" — no diagnostics are allowed
|
||||||
// - "error"
|
// - "error"
|
||||||
// - "warning"
|
// - "warning" (default)
|
||||||
// - "info"
|
// - "info"
|
||||||
// - "hint"
|
// - "hint"
|
||||||
// - null — allow all diagnostics (default)
|
// - null — allow all diagnostics
|
||||||
"diagnostics_max_severity": null,
|
"diagnostics_max_severity": "warning",
|
||||||
// Whether to show wrap guides (vertical rulers) in the editor.
|
// Whether to show wrap guides (vertical rulers) in the editor.
|
||||||
// Setting this to true will show a guide at the 'preferred_line_length' value
|
// Setting this to true will show a guide at the 'preferred_line_length' value
|
||||||
// if 'soft_wrap' is set to 'preferred_line_length', and will show any
|
// if 'soft_wrap' is set to 'preferred_line_length', and will show any
|
||||||
@@ -323,24 +322,16 @@
|
|||||||
// Whether to show the Selections menu in the editor toolbar.
|
// Whether to show the Selections menu in the editor toolbar.
|
||||||
"selections_menu": true,
|
"selections_menu": true,
|
||||||
// Whether to show agent review buttons in the editor toolbar.
|
// Whether to show agent review buttons in the editor toolbar.
|
||||||
"agent_review": true,
|
"agent_review": true
|
||||||
// Whether to show code action buttons in the editor toolbar.
|
|
||||||
"code_actions": false
|
|
||||||
},
|
},
|
||||||
// Titlebar related settings
|
// Titlebar related settings
|
||||||
"title_bar": {
|
"title_bar": {
|
||||||
// Whether to show the branch icon beside branch switcher in the titlebar.
|
// Whether to show the branch icon beside branch switcher in the titlebar.
|
||||||
"show_branch_icon": false,
|
"show_branch_icon": false,
|
||||||
// Whether to show the branch name button in the titlebar.
|
|
||||||
"show_branch_name": true,
|
|
||||||
// Whether to show the project host and name in the titlebar.
|
|
||||||
"show_project_items": true,
|
|
||||||
// Whether to show onboarding banners in the titlebar.
|
// Whether to show onboarding banners in the titlebar.
|
||||||
"show_onboarding_banner": true,
|
"show_onboarding_banner": true,
|
||||||
// Whether to show user picture in the titlebar.
|
// Whether to show user picture in the titlebar.
|
||||||
"show_user_picture": true,
|
"show_user_picture": true
|
||||||
// Whether to show the sign in button in the titlebar.
|
|
||||||
"show_sign_in": true
|
|
||||||
},
|
},
|
||||||
// Scrollbar related settings
|
// Scrollbar related settings
|
||||||
"scrollbar": {
|
"scrollbar": {
|
||||||
@@ -474,17 +465,11 @@
|
|||||||
// Scroll sensitivity multiplier. This multiplier is applied
|
// Scroll sensitivity multiplier. This multiplier is applied
|
||||||
// to both the horizontal and vertical delta values while scrolling.
|
// to both the horizontal and vertical delta values while scrolling.
|
||||||
"scroll_sensitivity": 1.0,
|
"scroll_sensitivity": 1.0,
|
||||||
// Scroll sensitivity multiplier for fast scrolling. This multiplier is applied
|
|
||||||
// to both the horizontal and vertical delta values while scrolling. Fast scrolling
|
|
||||||
// happens when a user holds the alt or option key while scrolling.
|
|
||||||
"fast_scroll_sensitivity": 4.0,
|
|
||||||
"relative_line_numbers": false,
|
"relative_line_numbers": false,
|
||||||
// If 'search_wrap' is disabled, search result do not wrap around the end of the file.
|
// If 'search_wrap' is disabled, search result do not wrap around the end of the file.
|
||||||
"search_wrap": true,
|
"search_wrap": true,
|
||||||
// Search options to enable by default when opening new project and buffer searches.
|
// Search options to enable by default when opening new project and buffer searches.
|
||||||
"search": {
|
"search": {
|
||||||
// Whether to show the project search button in the status bar.
|
|
||||||
"button": true,
|
|
||||||
"whole_word": false,
|
"whole_word": false,
|
||||||
"case_sensitive": false,
|
"case_sensitive": false,
|
||||||
"include_ignored": false,
|
"include_ignored": false,
|
||||||
@@ -533,9 +518,6 @@
|
|||||||
"function": false
|
"function": false
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
// Whether to resize all the panels in a dock when resizing the dock.
|
|
||||||
// Can be a combination of "left", "right" and "bottom".
|
|
||||||
"resize_all_panels_in_dock": ["left"],
|
|
||||||
"project_panel": {
|
"project_panel": {
|
||||||
// Whether to show the project panel button in the status bar
|
// Whether to show the project panel button in the status bar
|
||||||
"button": true,
|
"button": true,
|
||||||
@@ -716,7 +698,7 @@
|
|||||||
"version": "2",
|
"version": "2",
|
||||||
// Whether the agent is enabled.
|
// Whether the agent is enabled.
|
||||||
"enabled": true,
|
"enabled": true,
|
||||||
/// What completion mode to start new threads in, if available. Can be 'normal' or 'burn'.
|
/// What completion mode to start new threads in, if available. Can be 'normal' or 'max'.
|
||||||
"preferred_completion_mode": "normal",
|
"preferred_completion_mode": "normal",
|
||||||
// Whether to show the agent panel button in the status bar.
|
// Whether to show the agent panel button in the status bar.
|
||||||
"button": true,
|
"button": true,
|
||||||
@@ -731,7 +713,14 @@
|
|||||||
// The provider to use.
|
// The provider to use.
|
||||||
"provider": "zed.dev",
|
"provider": "zed.dev",
|
||||||
// The model to use.
|
// The model to use.
|
||||||
"model": "claude-sonnet-4"
|
"model": "claude-3-7-sonnet-latest"
|
||||||
|
},
|
||||||
|
// The model to use when applying edits from the agent.
|
||||||
|
"editor_model": {
|
||||||
|
// The provider to use.
|
||||||
|
"provider": "zed.dev",
|
||||||
|
// The model to use.
|
||||||
|
"model": "claude-3-7-sonnet-latest"
|
||||||
},
|
},
|
||||||
// Additional parameters for language model requests. When making a request to a model, parameters will be taken
|
// Additional parameters for language model requests. When making a request to a model, parameters will be taken
|
||||||
// from the last entry in this list that matches the model's provider and name. In each entry, both provider
|
// from the last entry in this list that matches the model's provider and name. In each entry, both provider
|
||||||
@@ -751,7 +740,7 @@
|
|||||||
// To set parameters for a specific provider and model:
|
// To set parameters for a specific provider and model:
|
||||||
// {
|
// {
|
||||||
// "provider": "zed.dev",
|
// "provider": "zed.dev",
|
||||||
// "model": "claude-sonnet-4",
|
// "model": "claude-3-7-sonnet-latest",
|
||||||
// "temperature": 1.0
|
// "temperature": 1.0
|
||||||
// }
|
// }
|
||||||
],
|
],
|
||||||
@@ -761,8 +750,6 @@
|
|||||||
"stream_edits": false,
|
"stream_edits": false,
|
||||||
// When enabled, agent edits will be displayed in single-file editors for review
|
// When enabled, agent edits will be displayed in single-file editors for review
|
||||||
"single_file_review": true,
|
"single_file_review": true,
|
||||||
// When enabled, show voting thumbs for feedback on agent edits.
|
|
||||||
"enable_feedback": true,
|
|
||||||
"default_profile": "write",
|
"default_profile": "write",
|
||||||
"profiles": {
|
"profiles": {
|
||||||
"write": {
|
"write": {
|
||||||
@@ -817,12 +804,7 @@
|
|||||||
// "primary_screen" - Show the notification only on your primary screen (default)
|
// "primary_screen" - Show the notification only on your primary screen (default)
|
||||||
// "all_screens" - Show these notifications on all screens
|
// "all_screens" - Show these notifications on all screens
|
||||||
// "never" - Never show these notifications
|
// "never" - Never show these notifications
|
||||||
"notify_when_agent_waiting": "primary_screen",
|
"notify_when_agent_waiting": "primary_screen"
|
||||||
// Whether to play a sound when the agent has either completed
|
|
||||||
// its response, or needs user input.
|
|
||||||
|
|
||||||
// Default: false
|
|
||||||
"play_sound_when_agent_done": false
|
|
||||||
},
|
},
|
||||||
// The settings for slash commands.
|
// The settings for slash commands.
|
||||||
"slash_commands": {
|
"slash_commands": {
|
||||||
@@ -954,17 +936,7 @@
|
|||||||
// "skip_focus_for_active_in_search": false
|
// "skip_focus_for_active_in_search": false
|
||||||
//
|
//
|
||||||
// Default: true
|
// Default: true
|
||||||
"skip_focus_for_active_in_search": true,
|
"skip_focus_for_active_in_search": true
|
||||||
// Whether to show the git status in the file finder.
|
|
||||||
"git_status": true,
|
|
||||||
// Whether to use gitignored files when searching.
|
|
||||||
// Only the file Zed had indexed will be used, not necessary all the gitignored files.
|
|
||||||
//
|
|
||||||
// Can accept 3 values:
|
|
||||||
// * `true`: Use all gitignored files
|
|
||||||
// * `false`: Use only the files Zed had indexed
|
|
||||||
// * `null`: Be smart and search for ignored when called from a gitignored worktree
|
|
||||||
"include_ignored": null
|
|
||||||
},
|
},
|
||||||
// Whether or not to remove any trailing whitespace from lines of a buffer
|
// Whether or not to remove any trailing whitespace from lines of a buffer
|
||||||
// before saving it.
|
// before saving it.
|
||||||
@@ -1030,8 +1002,6 @@
|
|||||||
"auto_update": true,
|
"auto_update": true,
|
||||||
// Diagnostics configuration.
|
// Diagnostics configuration.
|
||||||
"diagnostics": {
|
"diagnostics": {
|
||||||
// Whether to show the project diagnostics button in the status bar.
|
|
||||||
"button": true,
|
|
||||||
// Whether to show warnings or not by default.
|
// Whether to show warnings or not by default.
|
||||||
"include_warnings": true,
|
"include_warnings": true,
|
||||||
// Settings for inline diagnostics
|
// Settings for inline diagnostics
|
||||||
@@ -1309,17 +1279,7 @@
|
|||||||
// Settings related to running tasks.
|
// Settings related to running tasks.
|
||||||
"tasks": {
|
"tasks": {
|
||||||
"variables": {},
|
"variables": {},
|
||||||
"enabled": true,
|
"enabled": true
|
||||||
// Use LSP tasks over Zed language extension ones.
|
|
||||||
// If no LSP tasks are returned due to error/timeout or regular execution,
|
|
||||||
// Zed language extension tasks will be used instead.
|
|
||||||
//
|
|
||||||
// Other Zed tasks will still be shown:
|
|
||||||
// * Zed task from either of the task config file
|
|
||||||
// * Zed task from history (e.g. one-off task was spawned before)
|
|
||||||
//
|
|
||||||
// Default: true
|
|
||||||
"prefer_lsp": true
|
|
||||||
},
|
},
|
||||||
// An object whose keys are language names, and whose values
|
// An object whose keys are language names, and whose values
|
||||||
// are arrays of filenames or extensions of files that should
|
// are arrays of filenames or extensions of files that should
|
||||||
@@ -1337,22 +1297,21 @@
|
|||||||
"JSONC": ["**/.zed/**/*.json", "**/zed/**/*.json", "**/Zed/**/*.json", "**/.vscode/**/*.json"],
|
"JSONC": ["**/.zed/**/*.json", "**/zed/**/*.json", "**/Zed/**/*.json", "**/.vscode/**/*.json"],
|
||||||
"Shell Script": [".env.*"]
|
"Shell Script": [".env.*"]
|
||||||
},
|
},
|
||||||
// Settings for which version of Node.js and NPM to use when installing
|
// By default use a recent system version of node, or install our own.
|
||||||
// language servers and Copilot.
|
// You can override this to use a version of node that is not in $PATH with:
|
||||||
//
|
// {
|
||||||
// Note: changing this setting currently requires restarting Zed.
|
// "node": {
|
||||||
"node": {
|
// "path": "/path/to/node"
|
||||||
// By default, Zed will look for `node` and `npm` on your `$PATH`, and use the
|
// "npm_path": "/path/to/npm" (defaults to node_path/../npm)
|
||||||
// existing executables if their version is recent enough. Set this to `true`
|
// }
|
||||||
// to prevent this, and force Zed to always download and install its own
|
// }
|
||||||
// version of Node.
|
// or to ensure Zed always downloads and installs an isolated version of node:
|
||||||
"ignore_system_version": false,
|
// {
|
||||||
// You can also specify alternative paths to Node and NPM. If you specify
|
// "node": {
|
||||||
// `path`, but not `npm_path`, Zed will assume that `npm` is located at
|
// "ignore_system_version": true,
|
||||||
// `${path}/../npm`.
|
// }
|
||||||
"path": null,
|
// NOTE: changing this setting currently requires restarting Zed.
|
||||||
"npm_path": null
|
"node": {},
|
||||||
},
|
|
||||||
// The extensions that Zed should automatically install on startup.
|
// The extensions that Zed should automatically install on startup.
|
||||||
//
|
//
|
||||||
// If you don't want any of these extensions, add this field to your settings
|
// If you don't want any of these extensions, add this field to your settings
|
||||||
@@ -1500,11 +1459,11 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"LaTeX": {
|
"LaTeX": {
|
||||||
|
"format_on_save": "on",
|
||||||
"formatter": "language_server",
|
"formatter": "language_server",
|
||||||
"language_servers": ["texlab", "..."],
|
"language_servers": ["texlab", "..."],
|
||||||
"prettier": {
|
"prettier": {
|
||||||
"allowed": true,
|
"allowed": false
|
||||||
"plugins": ["prettier-plugin-latex"]
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"Markdown": {
|
"Markdown": {
|
||||||
@@ -1528,7 +1487,7 @@
|
|||||||
"allow_rewrap": "anywhere"
|
"allow_rewrap": "anywhere"
|
||||||
},
|
},
|
||||||
"Ruby": {
|
"Ruby": {
|
||||||
"language_servers": ["solargraph", "!ruby-lsp", "!rubocop", "!sorbet", "!steep", "..."]
|
"language_servers": ["solargraph", "!ruby-lsp", "!rubocop", "..."]
|
||||||
},
|
},
|
||||||
"SCSS": {
|
"SCSS": {
|
||||||
"prettier": {
|
"prettier": {
|
||||||
@@ -1605,9 +1564,6 @@
|
|||||||
"version": "1",
|
"version": "1",
|
||||||
"api_url": "https://api.openai.com/v1"
|
"api_url": "https://api.openai.com/v1"
|
||||||
},
|
},
|
||||||
"open_router": {
|
|
||||||
"api_url": "https://openrouter.ai/api/v1"
|
|
||||||
},
|
|
||||||
"lmstudio": {
|
"lmstudio": {
|
||||||
"api_url": "http://localhost:1234/api/v0"
|
"api_url": "http://localhost:1234/api/v0"
|
||||||
},
|
},
|
||||||
@@ -1746,8 +1702,6 @@
|
|||||||
// }
|
// }
|
||||||
// ]
|
// ]
|
||||||
"ssh_connections": [],
|
"ssh_connections": [],
|
||||||
// Whether to read ~/.ssh/config for ssh connection sources.
|
|
||||||
"read_ssh_config": true,
|
|
||||||
// Configures context servers for use by the agent.
|
// Configures context servers for use by the agent.
|
||||||
"context_servers": {},
|
"context_servers": {},
|
||||||
"debugger": {
|
"debugger": {
|
||||||
|
|||||||
@@ -1,34 +1,32 @@
|
|||||||
// Some example tasks for common languages.
|
|
||||||
//
|
|
||||||
// For more documentation on how to configure debug tasks,
|
|
||||||
// see: https://zed.dev/docs/debugger
|
|
||||||
[
|
[
|
||||||
{
|
{
|
||||||
"label": "Debug active PHP file",
|
"label": "Debug active PHP file",
|
||||||
"adapter": "PHP",
|
"adapter": "php",
|
||||||
"program": "$ZED_FILE",
|
"program": "$ZED_FILE",
|
||||||
"request": "launch",
|
"request": "launch",
|
||||||
"cwd": "$ZED_WORKTREE_ROOT"
|
"cwd": "$ZED_WORKTREE_ROOT"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"label": "Debug active Python file",
|
"label": "Debug active Python file",
|
||||||
"adapter": "Debugpy",
|
"adapter": "python",
|
||||||
"program": "$ZED_FILE",
|
"program": "$ZED_FILE",
|
||||||
"request": "launch",
|
"request": "launch",
|
||||||
"cwd": "$ZED_WORKTREE_ROOT"
|
"cwd": "$ZED_WORKTREE_ROOT"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"label": "Debug active JavaScript file",
|
"label": "Debug active JavaScript file",
|
||||||
"adapter": "JavaScript",
|
"adapter": "javascript",
|
||||||
"program": "$ZED_FILE",
|
"program": "$ZED_FILE",
|
||||||
"request": "launch",
|
"request": "launch",
|
||||||
"cwd": "$ZED_WORKTREE_ROOT"
|
"cwd": "$ZED_WORKTREE_ROOT"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"label": "JavaScript debug terminal",
|
"label": "JavaScript debug terminal",
|
||||||
"adapter": "JavaScript",
|
"adapter": "javascript",
|
||||||
"request": "launch",
|
"request": "launch",
|
||||||
"cwd": "$ZED_WORKTREE_ROOT",
|
"cwd": "$ZED_WORKTREE_ROOT",
|
||||||
"console": "integratedTerminal"
|
"initialize_args": {
|
||||||
|
"console": "integratedTerminal"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -1,5 +0,0 @@
|
|||||||
// Project-local debug tasks
|
|
||||||
//
|
|
||||||
// For more documentation on how to configure debug tasks,
|
|
||||||
// see: https://zed.dev/docs/debugger
|
|
||||||
[]
|
|
||||||
@@ -24,9 +24,8 @@ project.workspace = true
|
|||||||
smallvec.workspace = true
|
smallvec.workspace = true
|
||||||
ui.workspace = true
|
ui.workspace = true
|
||||||
util.workspace = true
|
util.workspace = true
|
||||||
workspace-hack.workspace = true
|
|
||||||
workspace.workspace = true
|
workspace.workspace = true
|
||||||
|
workspace-hack.workspace = true
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
editor = { workspace = true, features = ["test-support"] }
|
editor = { workspace = true, features = ["test-support"] }
|
||||||
release_channel.workspace = true
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
use auto_update::{AutoUpdateStatus, AutoUpdater, DismissErrorMessage, VersionCheckType};
|
use auto_update::{AutoUpdateStatus, AutoUpdater, DismissErrorMessage};
|
||||||
use editor::Editor;
|
use editor::Editor;
|
||||||
use extension_host::ExtensionStore;
|
use extension_host::ExtensionStore;
|
||||||
use futures::StreamExt;
|
use futures::StreamExt;
|
||||||
@@ -60,7 +60,6 @@ struct Content {
|
|||||||
message: String,
|
message: String,
|
||||||
on_click:
|
on_click:
|
||||||
Option<Arc<dyn Fn(&mut ActivityIndicator, &mut Window, &mut Context<ActivityIndicator>)>>,
|
Option<Arc<dyn Fn(&mut ActivityIndicator, &mut Window, &mut Context<ActivityIndicator>)>>,
|
||||||
tooltip_message: Option<String>,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ActivityIndicator {
|
impl ActivityIndicator {
|
||||||
@@ -263,7 +262,6 @@ impl ActivityIndicator {
|
|||||||
});
|
});
|
||||||
window.dispatch_action(Box::new(workspace::OpenLog), cx);
|
window.dispatch_action(Box::new(workspace::OpenLog), cx);
|
||||||
})),
|
})),
|
||||||
tooltip_message: None,
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
// Show any language server has pending activity.
|
// Show any language server has pending activity.
|
||||||
@@ -307,32 +305,6 @@ impl ActivityIndicator {
|
|||||||
),
|
),
|
||||||
message,
|
message,
|
||||||
on_click: Some(Arc::new(Self::toggle_language_server_work_context_menu)),
|
on_click: Some(Arc::new(Self::toggle_language_server_work_context_menu)),
|
||||||
tooltip_message: None,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
if let Some(session) = self
|
|
||||||
.project
|
|
||||||
.read(cx)
|
|
||||||
.dap_store()
|
|
||||||
.read(cx)
|
|
||||||
.sessions()
|
|
||||||
.find(|s| !s.read(cx).is_started())
|
|
||||||
{
|
|
||||||
return Some(Content {
|
|
||||||
icon: Some(
|
|
||||||
Icon::new(IconName::ArrowCircle)
|
|
||||||
.size(IconSize::Small)
|
|
||||||
.with_animation(
|
|
||||||
"arrow-circle",
|
|
||||||
Animation::new(Duration::from_secs(2)).repeat(),
|
|
||||||
|icon, delta| icon.transform(Transformation::rotate(percentage(delta))),
|
|
||||||
)
|
|
||||||
.into_any_element(),
|
|
||||||
),
|
|
||||||
message: format!("Debug: {}", session.read(cx).adapter()),
|
|
||||||
tooltip_message: Some(session.read(cx).label().to_string()),
|
|
||||||
on_click: None,
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -360,7 +332,6 @@ impl ActivityIndicator {
|
|||||||
),
|
),
|
||||||
message: job_info.message.into(),
|
message: job_info.message.into(),
|
||||||
on_click: None,
|
on_click: None,
|
||||||
tooltip_message: None,
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -403,7 +374,6 @@ impl ActivityIndicator {
|
|||||||
.retain(|status| !downloading.contains(&status.name));
|
.retain(|status| !downloading.contains(&status.name));
|
||||||
this.dismiss_error_message(&DismissErrorMessage, window, cx)
|
this.dismiss_error_message(&DismissErrorMessage, window, cx)
|
||||||
})),
|
})),
|
||||||
tooltip_message: None,
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -432,7 +402,6 @@ impl ActivityIndicator {
|
|||||||
.retain(|status| !checking_for_update.contains(&status.name));
|
.retain(|status| !checking_for_update.contains(&status.name));
|
||||||
this.dismiss_error_message(&DismissErrorMessage, window, cx)
|
this.dismiss_error_message(&DismissErrorMessage, window, cx)
|
||||||
})),
|
})),
|
||||||
tooltip_message: None,
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -459,7 +428,6 @@ impl ActivityIndicator {
|
|||||||
on_click: Some(Arc::new(|this, window, cx| {
|
on_click: Some(Arc::new(|this, window, cx| {
|
||||||
this.show_error_message(&Default::default(), window, cx)
|
this.show_error_message(&Default::default(), window, cx)
|
||||||
})),
|
})),
|
||||||
tooltip_message: None,
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -478,7 +446,6 @@ impl ActivityIndicator {
|
|||||||
});
|
});
|
||||||
window.dispatch_action(Box::new(workspace::OpenLog), cx);
|
window.dispatch_action(Box::new(workspace::OpenLog), cx);
|
||||||
})),
|
})),
|
||||||
tooltip_message: None,
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -495,9 +462,8 @@ impl ActivityIndicator {
|
|||||||
on_click: Some(Arc::new(|this, window, cx| {
|
on_click: Some(Arc::new(|this, window, cx| {
|
||||||
this.dismiss_error_message(&DismissErrorMessage, window, cx)
|
this.dismiss_error_message(&DismissErrorMessage, window, cx)
|
||||||
})),
|
})),
|
||||||
tooltip_message: None,
|
|
||||||
}),
|
}),
|
||||||
AutoUpdateStatus::Downloading { version } => Some(Content {
|
AutoUpdateStatus::Downloading => Some(Content {
|
||||||
icon: Some(
|
icon: Some(
|
||||||
Icon::new(IconName::Download)
|
Icon::new(IconName::Download)
|
||||||
.size(IconSize::Small)
|
.size(IconSize::Small)
|
||||||
@@ -507,9 +473,8 @@ impl ActivityIndicator {
|
|||||||
on_click: Some(Arc::new(|this, window, cx| {
|
on_click: Some(Arc::new(|this, window, cx| {
|
||||||
this.dismiss_error_message(&DismissErrorMessage, window, cx)
|
this.dismiss_error_message(&DismissErrorMessage, window, cx)
|
||||||
})),
|
})),
|
||||||
tooltip_message: Some(Self::version_tooltip_message(&version)),
|
|
||||||
}),
|
}),
|
||||||
AutoUpdateStatus::Installing { version } => Some(Content {
|
AutoUpdateStatus::Installing => Some(Content {
|
||||||
icon: Some(
|
icon: Some(
|
||||||
Icon::new(IconName::Download)
|
Icon::new(IconName::Download)
|
||||||
.size(IconSize::Small)
|
.size(IconSize::Small)
|
||||||
@@ -519,12 +484,8 @@ impl ActivityIndicator {
|
|||||||
on_click: Some(Arc::new(|this, window, cx| {
|
on_click: Some(Arc::new(|this, window, cx| {
|
||||||
this.dismiss_error_message(&DismissErrorMessage, window, cx)
|
this.dismiss_error_message(&DismissErrorMessage, window, cx)
|
||||||
})),
|
})),
|
||||||
tooltip_message: Some(Self::version_tooltip_message(&version)),
|
|
||||||
}),
|
}),
|
||||||
AutoUpdateStatus::Updated {
|
AutoUpdateStatus::Updated { binary_path } => Some(Content {
|
||||||
binary_path,
|
|
||||||
version,
|
|
||||||
} => Some(Content {
|
|
||||||
icon: None,
|
icon: None,
|
||||||
message: "Click to restart and update Zed".to_string(),
|
message: "Click to restart and update Zed".to_string(),
|
||||||
on_click: Some(Arc::new({
|
on_click: Some(Arc::new({
|
||||||
@@ -533,7 +494,6 @@ impl ActivityIndicator {
|
|||||||
};
|
};
|
||||||
move |_, _, cx| workspace::reload(&reload, cx)
|
move |_, _, cx| workspace::reload(&reload, cx)
|
||||||
})),
|
})),
|
||||||
tooltip_message: Some(Self::version_tooltip_message(&version)),
|
|
||||||
}),
|
}),
|
||||||
AutoUpdateStatus::Errored => Some(Content {
|
AutoUpdateStatus::Errored => Some(Content {
|
||||||
icon: Some(
|
icon: Some(
|
||||||
@@ -545,7 +505,6 @@ impl ActivityIndicator {
|
|||||||
on_click: Some(Arc::new(|this, window, cx| {
|
on_click: Some(Arc::new(|this, window, cx| {
|
||||||
this.dismiss_error_message(&DismissErrorMessage, window, cx)
|
this.dismiss_error_message(&DismissErrorMessage, window, cx)
|
||||||
})),
|
})),
|
||||||
tooltip_message: None,
|
|
||||||
}),
|
}),
|
||||||
AutoUpdateStatus::Idle => None,
|
AutoUpdateStatus::Idle => None,
|
||||||
};
|
};
|
||||||
@@ -565,7 +524,6 @@ impl ActivityIndicator {
|
|||||||
on_click: Some(Arc::new(|this, window, cx| {
|
on_click: Some(Arc::new(|this, window, cx| {
|
||||||
this.dismiss_error_message(&DismissErrorMessage, window, cx)
|
this.dismiss_error_message(&DismissErrorMessage, window, cx)
|
||||||
})),
|
})),
|
||||||
tooltip_message: None,
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -573,17 +531,6 @@ impl ActivityIndicator {
|
|||||||
None
|
None
|
||||||
}
|
}
|
||||||
|
|
||||||
fn version_tooltip_message(version: &VersionCheckType) -> String {
|
|
||||||
format!("Version: {}", {
|
|
||||||
match version {
|
|
||||||
auto_update::VersionCheckType::Sha(sha) => format!("{}…", sha.short()),
|
|
||||||
auto_update::VersionCheckType::Semantic(semantic_version) => {
|
|
||||||
semantic_version.to_string()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
fn toggle_language_server_work_context_menu(
|
fn toggle_language_server_work_context_menu(
|
||||||
&mut self,
|
&mut self,
|
||||||
window: &mut Window,
|
window: &mut Window,
|
||||||
@@ -628,14 +575,7 @@ impl Render for ActivityIndicator {
|
|||||||
)
|
)
|
||||||
.tooltip(Tooltip::text(content.message))
|
.tooltip(Tooltip::text(content.message))
|
||||||
} else {
|
} else {
|
||||||
button
|
button.child(Label::new(content.message).size(LabelSize::Small))
|
||||||
.child(Label::new(content.message).size(LabelSize::Small))
|
|
||||||
.when_some(
|
|
||||||
content.tooltip_message,
|
|
||||||
|this, tooltip_message| {
|
|
||||||
this.tooltip(Tooltip::text(tooltip_message))
|
|
||||||
},
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.when_some(content.on_click, |this, handler| {
|
.when_some(content.on_click, |this, handler| {
|
||||||
@@ -715,26 +655,3 @@ impl StatusItemView for ActivityIndicator {
|
|||||||
) {
|
) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
|
||||||
mod tests {
|
|
||||||
use gpui::SemanticVersion;
|
|
||||||
use release_channel::AppCommitSha;
|
|
||||||
|
|
||||||
use super::*;
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn test_version_tooltip_message() {
|
|
||||||
let message = ActivityIndicator::version_tooltip_message(&VersionCheckType::Semantic(
|
|
||||||
SemanticVersion::new(1, 0, 0),
|
|
||||||
));
|
|
||||||
|
|
||||||
assert_eq!(message, "Version: 1.0.0");
|
|
||||||
|
|
||||||
let message = ActivityIndicator::version_tooltip_message(&VersionCheckType::Sha(
|
|
||||||
AppCommitSha::new("14d9a4189f058d8736339b06ff2340101eaea5af".to_string()),
|
|
||||||
));
|
|
||||||
|
|
||||||
assert_eq!(message, "Version: 14d9a41…");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -19,14 +19,13 @@ test-support = [
|
|||||||
]
|
]
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
agent_settings.workspace = true
|
|
||||||
anyhow.workspace = true
|
anyhow.workspace = true
|
||||||
assistant_context_editor.workspace = true
|
assistant_context_editor.workspace = true
|
||||||
|
assistant_settings.workspace = true
|
||||||
assistant_slash_command.workspace = true
|
assistant_slash_command.workspace = true
|
||||||
assistant_slash_commands.workspace = true
|
assistant_slash_commands.workspace = true
|
||||||
assistant_tool.workspace = true
|
assistant_tool.workspace = true
|
||||||
async-watch.workspace = true
|
async-watch.workspace = true
|
||||||
audio.workspace = true
|
|
||||||
buffer_diff.workspace = true
|
buffer_diff.workspace = true
|
||||||
chrono.workspace = true
|
chrono.workspace = true
|
||||||
client.workspace = true
|
client.workspace = true
|
||||||
@@ -46,14 +45,14 @@ git.workspace = true
|
|||||||
gpui.workspace = true
|
gpui.workspace = true
|
||||||
heed.workspace = true
|
heed.workspace = true
|
||||||
html_to_markdown.workspace = true
|
html_to_markdown.workspace = true
|
||||||
indoc.workspace = true
|
|
||||||
http_client.workspace = true
|
http_client.workspace = true
|
||||||
indexed_docs.workspace = true
|
indexed_docs.workspace = true
|
||||||
inventory.workspace = true
|
|
||||||
itertools.workspace = true
|
itertools.workspace = true
|
||||||
jsonschema.workspace = true
|
jsonschema.workspace = true
|
||||||
language.workspace = true
|
language.workspace = true
|
||||||
language_model.workspace = true
|
language_model.workspace = true
|
||||||
|
language_model_selector.workspace = true
|
||||||
|
linkme.workspace = true
|
||||||
log.workspace = true
|
log.workspace = true
|
||||||
lsp.workspace = true
|
lsp.workspace = true
|
||||||
markdown.workspace = true
|
markdown.workspace = true
|
||||||
@@ -78,8 +77,8 @@ serde.workspace = true
|
|||||||
serde_json.workspace = true
|
serde_json.workspace = true
|
||||||
serde_json_lenient.workspace = true
|
serde_json_lenient.workspace = true
|
||||||
settings.workspace = true
|
settings.workspace = true
|
||||||
|
smallvec.workspace = true
|
||||||
smol.workspace = true
|
smol.workspace = true
|
||||||
sqlez.workspace = true
|
|
||||||
streaming_diff.workspace = true
|
streaming_diff.workspace = true
|
||||||
telemetry.workspace = true
|
telemetry.workspace = true
|
||||||
telemetry_events.workspace = true
|
telemetry_events.workspace = true
|
||||||
@@ -99,7 +98,6 @@ workspace-hack.workspace = true
|
|||||||
workspace.workspace = true
|
workspace.workspace = true
|
||||||
zed_actions.workspace = true
|
zed_actions.workspace = true
|
||||||
zed_llm_client.workspace = true
|
zed_llm_client.workspace = true
|
||||||
zstd.workspace = true
|
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
buffer_diff = { workspace = true, features = ["test-support"] }
|
buffer_diff = { workspace = true, features = ["test-support"] }
|
||||||
|
|||||||
@@ -28,16 +28,14 @@ mod ui;
|
|||||||
|
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
|
||||||
use agent_settings::{AgentProfileId, AgentSettings, LanguageModelSelection};
|
use assistant_settings::{AgentProfileId, AssistantSettings, LanguageModelSelection};
|
||||||
use assistant_slash_command::SlashCommandRegistry;
|
use assistant_slash_command::SlashCommandRegistry;
|
||||||
use client::Client;
|
use client::Client;
|
||||||
use feature_flags::FeatureFlagAppExt as _;
|
use feature_flags::FeatureFlagAppExt as _;
|
||||||
use fs::Fs;
|
use fs::Fs;
|
||||||
use gpui::{App, Entity, actions, impl_actions};
|
use gpui::{App, actions, impl_actions};
|
||||||
use language::LanguageRegistry;
|
use language::LanguageRegistry;
|
||||||
use language_model::{
|
use language_model::{LanguageModelId, LanguageModelProviderId, LanguageModelRegistry};
|
||||||
ConfiguredModel, LanguageModel, LanguageModelId, LanguageModelProviderId, LanguageModelRegistry,
|
|
||||||
};
|
|
||||||
use prompt_store::PromptBuilder;
|
use prompt_store::PromptBuilder;
|
||||||
use schemars::JsonSchema;
|
use schemars::JsonSchema;
|
||||||
use serde::Deserialize;
|
use serde::Deserialize;
|
||||||
@@ -51,7 +49,7 @@ pub use crate::context::{ContextLoadResult, LoadedContext};
|
|||||||
pub use crate::inline_assistant::InlineAssistant;
|
pub use crate::inline_assistant::InlineAssistant;
|
||||||
use crate::slash_command_settings::SlashCommandSettings;
|
use crate::slash_command_settings::SlashCommandSettings;
|
||||||
pub use crate::thread::{Message, MessageSegment, Thread, ThreadEvent};
|
pub use crate::thread::{Message, MessageSegment, Thread, ThreadEvent};
|
||||||
pub use crate::thread_store::{SerializedThread, TextThreadStore, ThreadStore};
|
pub use crate::thread_store::{TextThreadStore, ThreadStore};
|
||||||
pub use agent_diff::{AgentDiffPane, AgentDiffToolbar};
|
pub use agent_diff::{AgentDiffPane, AgentDiffToolbar};
|
||||||
pub use context_store::ContextStore;
|
pub use context_store::ContextStore;
|
||||||
pub use ui::preview::{all_agent_previews, get_agent_preview};
|
pub use ui::preview::{all_agent_previews, get_agent_preview};
|
||||||
@@ -71,7 +69,6 @@ actions!(
|
|||||||
AddContextServer,
|
AddContextServer,
|
||||||
RemoveSelectedThread,
|
RemoveSelectedThread,
|
||||||
Chat,
|
Chat,
|
||||||
ChatWithFollow,
|
|
||||||
CycleNextInlineAssist,
|
CycleNextInlineAssist,
|
||||||
CyclePreviousInlineAssist,
|
CyclePreviousInlineAssist,
|
||||||
FocusUp,
|
FocusUp,
|
||||||
@@ -88,10 +85,6 @@ actions!(
|
|||||||
KeepAll,
|
KeepAll,
|
||||||
Follow,
|
Follow,
|
||||||
ResetTrialUpsell,
|
ResetTrialUpsell,
|
||||||
ResetTrialEndUpsell,
|
|
||||||
ContinueThread,
|
|
||||||
ContinueWithBurnMode,
|
|
||||||
ToggleBurnMode,
|
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -117,47 +110,20 @@ impl ManageProfiles {
|
|||||||
|
|
||||||
impl_actions!(agent, [NewThread, ManageProfiles]);
|
impl_actions!(agent, [NewThread, ManageProfiles]);
|
||||||
|
|
||||||
#[derive(Clone)]
|
|
||||||
pub(crate) enum ModelUsageContext {
|
|
||||||
Thread(Entity<Thread>),
|
|
||||||
InlineAssistant,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl ModelUsageContext {
|
|
||||||
pub fn configured_model(&self, cx: &App) -> Option<ConfiguredModel> {
|
|
||||||
match self {
|
|
||||||
Self::Thread(thread) => thread.read(cx).configured_model(),
|
|
||||||
Self::InlineAssistant => {
|
|
||||||
LanguageModelRegistry::read_global(cx).inline_assistant_model()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn language_model(&self, cx: &App) -> Option<Arc<dyn LanguageModel>> {
|
|
||||||
self.configured_model(cx)
|
|
||||||
.map(|configured_model| configured_model.model)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Initializes the `agent` crate.
|
/// Initializes the `agent` crate.
|
||||||
pub fn init(
|
pub fn init(
|
||||||
fs: Arc<dyn Fs>,
|
fs: Arc<dyn Fs>,
|
||||||
client: Arc<Client>,
|
client: Arc<Client>,
|
||||||
prompt_builder: Arc<PromptBuilder>,
|
prompt_builder: Arc<PromptBuilder>,
|
||||||
language_registry: Arc<LanguageRegistry>,
|
language_registry: Arc<LanguageRegistry>,
|
||||||
is_eval: bool,
|
|
||||||
cx: &mut App,
|
cx: &mut App,
|
||||||
) {
|
) {
|
||||||
AgentSettings::register(cx);
|
AssistantSettings::register(cx);
|
||||||
SlashCommandSettings::register(cx);
|
SlashCommandSettings::register(cx);
|
||||||
|
|
||||||
assistant_context_editor::init(client.clone(), cx);
|
assistant_context_editor::init(client.clone(), cx);
|
||||||
rules_library::init(cx);
|
rules_library::init(cx);
|
||||||
if !is_eval {
|
init_language_model_settings(cx);
|
||||||
// Initializing the language model from the user settings messes with the eval, so we only initialize them when
|
|
||||||
// we're not running inside of the eval.
|
|
||||||
init_language_model_settings(cx);
|
|
||||||
}
|
|
||||||
assistant_slash_command::init(cx);
|
assistant_slash_command::init(cx);
|
||||||
thread_store::init(cx);
|
thread_store::init(cx);
|
||||||
agent_panel::init(cx);
|
agent_panel::init(cx);
|
||||||
@@ -201,7 +167,7 @@ fn init_language_model_settings(cx: &mut App) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn update_active_language_model_from_settings(cx: &mut App) {
|
fn update_active_language_model_from_settings(cx: &mut App) {
|
||||||
let settings = AgentSettings::get_global(cx);
|
let settings = AssistantSettings::get_global(cx);
|
||||||
|
|
||||||
fn to_selected_model(selection: &LanguageModelSelection) -> language_model::SelectedModel {
|
fn to_selected_model(selection: &LanguageModelSelection) -> language_model::SelectedModel {
|
||||||
language_model::SelectedModel {
|
language_model::SelectedModel {
|
||||||
@@ -250,6 +216,7 @@ fn register_slash_commands(cx: &mut App) {
|
|||||||
slash_command_registry.register_command(assistant_slash_commands::PromptSlashCommand, true);
|
slash_command_registry.register_command(assistant_slash_commands::PromptSlashCommand, true);
|
||||||
slash_command_registry.register_command(assistant_slash_commands::SelectionCommand, true);
|
slash_command_registry.register_command(assistant_slash_commands::SelectionCommand, true);
|
||||||
slash_command_registry.register_command(assistant_slash_commands::DefaultSlashCommand, false);
|
slash_command_registry.register_command(assistant_slash_commands::DefaultSlashCommand, false);
|
||||||
|
slash_command_registry.register_command(assistant_slash_commands::TerminalSlashCommand, true);
|
||||||
slash_command_registry.register_command(assistant_slash_commands::NowSlashCommand, false);
|
slash_command_registry.register_command(assistant_slash_commands::NowSlashCommand, false);
|
||||||
slash_command_registry
|
slash_command_registry
|
||||||
.register_command(assistant_slash_commands::DiagnosticsSlashCommand, true);
|
.register_command(assistant_slash_commands::DiagnosticsSlashCommand, true);
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ mod tool_picker;
|
|||||||
|
|
||||||
use std::{sync::Arc, time::Duration};
|
use std::{sync::Arc, time::Duration};
|
||||||
|
|
||||||
use agent_settings::AgentSettings;
|
use assistant_settings::AssistantSettings;
|
||||||
use assistant_tool::{ToolSource, ToolWorkingSet};
|
use assistant_tool::{ToolSource, ToolWorkingSet};
|
||||||
use collections::HashMap;
|
use collections::HashMap;
|
||||||
use context_server::ContextServerId;
|
use context_server::ContextServerId;
|
||||||
@@ -18,8 +18,8 @@ use language_model::{LanguageModelProvider, LanguageModelProviderId, LanguageMod
|
|||||||
use project::context_server_store::{ContextServerStatus, ContextServerStore};
|
use project::context_server_store::{ContextServerStatus, ContextServerStore};
|
||||||
use settings::{Settings, update_settings_file};
|
use settings::{Settings, update_settings_file};
|
||||||
use ui::{
|
use ui::{
|
||||||
Disclosure, ElevationIndex, Indicator, Scrollbar, ScrollbarState, Switch, SwitchColor, Tooltip,
|
Disclosure, Divider, DividerColor, ElevationIndex, Indicator, Scrollbar, ScrollbarState,
|
||||||
prelude::*,
|
Switch, SwitchColor, Tooltip, prelude::*,
|
||||||
};
|
};
|
||||||
use util::ResultExt as _;
|
use util::ResultExt as _;
|
||||||
use zed_actions::ExtensionCategoryFilter;
|
use zed_actions::ExtensionCategoryFilter;
|
||||||
@@ -36,7 +36,6 @@ pub struct AgentConfiguration {
|
|||||||
configuration_views_by_provider: HashMap<LanguageModelProviderId, AnyView>,
|
configuration_views_by_provider: HashMap<LanguageModelProviderId, AnyView>,
|
||||||
context_server_store: Entity<ContextServerStore>,
|
context_server_store: Entity<ContextServerStore>,
|
||||||
expanded_context_server_tools: HashMap<ContextServerId, bool>,
|
expanded_context_server_tools: HashMap<ContextServerId, bool>,
|
||||||
expanded_provider_configurations: HashMap<LanguageModelProviderId, bool>,
|
|
||||||
tools: Entity<ToolWorkingSet>,
|
tools: Entity<ToolWorkingSet>,
|
||||||
_registry_subscription: Subscription,
|
_registry_subscription: Subscription,
|
||||||
scroll_handle: ScrollHandle,
|
scroll_handle: ScrollHandle,
|
||||||
@@ -79,7 +78,6 @@ impl AgentConfiguration {
|
|||||||
configuration_views_by_provider: HashMap::default(),
|
configuration_views_by_provider: HashMap::default(),
|
||||||
context_server_store,
|
context_server_store,
|
||||||
expanded_context_server_tools: HashMap::default(),
|
expanded_context_server_tools: HashMap::default(),
|
||||||
expanded_provider_configurations: HashMap::default(),
|
|
||||||
tools,
|
tools,
|
||||||
_registry_subscription: registry_subscription,
|
_registry_subscription: registry_subscription,
|
||||||
scroll_handle,
|
scroll_handle,
|
||||||
@@ -98,7 +96,6 @@ impl AgentConfiguration {
|
|||||||
|
|
||||||
fn remove_provider_configuration_view(&mut self, provider_id: &LanguageModelProviderId) {
|
fn remove_provider_configuration_view(&mut self, provider_id: &LanguageModelProviderId) {
|
||||||
self.configuration_views_by_provider.remove(provider_id);
|
self.configuration_views_by_provider.remove(provider_id);
|
||||||
self.expanded_provider_configurations.remove(provider_id);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn add_provider_configuration_view(
|
fn add_provider_configuration_view(
|
||||||
@@ -138,14 +135,9 @@ impl AgentConfiguration {
|
|||||||
.get(&provider.id())
|
.get(&provider.id())
|
||||||
.cloned();
|
.cloned();
|
||||||
|
|
||||||
let is_expanded = self
|
|
||||||
.expanded_provider_configurations
|
|
||||||
.get(&provider.id())
|
|
||||||
.copied()
|
|
||||||
.unwrap_or(false);
|
|
||||||
|
|
||||||
v_flex()
|
v_flex()
|
||||||
.pt_3()
|
.pt_3()
|
||||||
|
.pb_1()
|
||||||
.gap_1p5()
|
.gap_1p5()
|
||||||
.border_t_1()
|
.border_t_1()
|
||||||
.border_color(cx.theme().colors().border.opacity(0.6))
|
.border_color(cx.theme().colors().border.opacity(0.6))
|
||||||
@@ -160,63 +152,36 @@ impl AgentConfiguration {
|
|||||||
.size(IconSize::Small)
|
.size(IconSize::Small)
|
||||||
.color(Color::Muted),
|
.color(Color::Muted),
|
||||||
)
|
)
|
||||||
.child(Label::new(provider_name.clone()).size(LabelSize::Large))
|
.child(Label::new(provider_name.clone()).size(LabelSize::Large)),
|
||||||
.when(provider.is_authenticated(cx) && !is_expanded, |parent| {
|
|
||||||
parent.child(Icon::new(IconName::Check).color(Color::Success))
|
|
||||||
}),
|
|
||||||
)
|
)
|
||||||
.child(
|
.when(provider.is_authenticated(cx), |parent| {
|
||||||
h_flex()
|
parent.child(
|
||||||
.gap_1()
|
Button::new(
|
||||||
.when(provider.is_authenticated(cx), |parent| {
|
SharedString::from(format!("new-thread-{provider_id}")),
|
||||||
parent.child(
|
"Start New Thread",
|
||||||
Button::new(
|
)
|
||||||
SharedString::from(format!("new-thread-{provider_id}")),
|
.icon_position(IconPosition::Start)
|
||||||
"Start New Thread",
|
.icon(IconName::Plus)
|
||||||
)
|
.icon_size(IconSize::Small)
|
||||||
.icon_position(IconPosition::Start)
|
.style(ButtonStyle::Filled)
|
||||||
.icon(IconName::Plus)
|
.layer(ElevationIndex::ModalSurface)
|
||||||
.icon_size(IconSize::Small)
|
.label_size(LabelSize::Small)
|
||||||
.layer(ElevationIndex::ModalSurface)
|
.on_click(cx.listener({
|
||||||
.label_size(LabelSize::Small)
|
let provider = provider.clone();
|
||||||
.on_click(cx.listener({
|
move |_this, _event, _window, cx| {
|
||||||
let provider = provider.clone();
|
cx.emit(AssistantConfigurationEvent::NewThread(
|
||||||
move |_this, _event, _window, cx| {
|
provider.clone(),
|
||||||
cx.emit(AssistantConfigurationEvent::NewThread(
|
))
|
||||||
provider.clone(),
|
}
|
||||||
))
|
})),
|
||||||
}
|
)
|
||||||
})),
|
}),
|
||||||
)
|
|
||||||
})
|
|
||||||
.child(
|
|
||||||
Disclosure::new(
|
|
||||||
SharedString::from(format!(
|
|
||||||
"provider-disclosure-{provider_id}"
|
|
||||||
)),
|
|
||||||
is_expanded,
|
|
||||||
)
|
|
||||||
.opened_icon(IconName::ChevronUp)
|
|
||||||
.closed_icon(IconName::ChevronDown)
|
|
||||||
.on_click(cx.listener({
|
|
||||||
let provider_id = provider.id().clone();
|
|
||||||
move |this, _event, _window, _cx| {
|
|
||||||
let is_expanded = this
|
|
||||||
.expanded_provider_configurations
|
|
||||||
.entry(provider_id.clone())
|
|
||||||
.or_insert(false);
|
|
||||||
|
|
||||||
*is_expanded = !*is_expanded;
|
|
||||||
}
|
|
||||||
})),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
)
|
)
|
||||||
.when(is_expanded, |parent| match configuration_view {
|
.map(|parent| match configuration_view {
|
||||||
Some(configuration_view) => parent.child(configuration_view),
|
Some(configuration_view) => parent.child(configuration_view),
|
||||||
None => parent.child(Label::new(format!(
|
None => parent.child(div().child(Label::new(format!(
|
||||||
"No configuration view for {provider_name}",
|
"No configuration view for {provider_name}",
|
||||||
))),
|
)))),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -230,8 +195,7 @@ impl AgentConfiguration {
|
|||||||
.p(DynamicSpacing::Base16.rems(cx))
|
.p(DynamicSpacing::Base16.rems(cx))
|
||||||
.pr(DynamicSpacing::Base20.rems(cx))
|
.pr(DynamicSpacing::Base20.rems(cx))
|
||||||
.gap_4()
|
.gap_4()
|
||||||
.border_b_1()
|
.flex_1()
|
||||||
.border_color(cx.theme().colors().border)
|
|
||||||
.child(
|
.child(
|
||||||
v_flex()
|
v_flex()
|
||||||
.gap_0p5()
|
.gap_0p5()
|
||||||
@@ -249,7 +213,7 @@ impl AgentConfiguration {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn render_command_permission(&mut self, cx: &mut Context<Self>) -> impl IntoElement {
|
fn render_command_permission(&mut self, cx: &mut Context<Self>) -> impl IntoElement {
|
||||||
let always_allow_tool_actions = AgentSettings::get_global(cx).always_allow_tool_actions;
|
let always_allow_tool_actions = AssistantSettings::get_global(cx).always_allow_tool_actions;
|
||||||
|
|
||||||
h_flex()
|
h_flex()
|
||||||
.gap_4()
|
.gap_4()
|
||||||
@@ -277,7 +241,7 @@ impl AgentConfiguration {
|
|||||||
let fs = self.fs.clone();
|
let fs = self.fs.clone();
|
||||||
move |state, _window, cx| {
|
move |state, _window, cx| {
|
||||||
let allow = state == &ToggleState::Selected;
|
let allow = state == &ToggleState::Selected;
|
||||||
update_settings_file::<AgentSettings>(
|
update_settings_file::<AssistantSettings>(
|
||||||
fs.clone(),
|
fs.clone(),
|
||||||
cx,
|
cx,
|
||||||
move |settings, _| {
|
move |settings, _| {
|
||||||
@@ -290,7 +254,7 @@ impl AgentConfiguration {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn render_single_file_review(&mut self, cx: &mut Context<Self>) -> impl IntoElement {
|
fn render_single_file_review(&mut self, cx: &mut Context<Self>) -> impl IntoElement {
|
||||||
let single_file_review = AgentSettings::get_global(cx).single_file_review;
|
let single_file_review = AssistantSettings::get_global(cx).single_file_review;
|
||||||
|
|
||||||
h_flex()
|
h_flex()
|
||||||
.gap_4()
|
.gap_4()
|
||||||
@@ -315,7 +279,7 @@ impl AgentConfiguration {
|
|||||||
let fs = self.fs.clone();
|
let fs = self.fs.clone();
|
||||||
move |state, _window, cx| {
|
move |state, _window, cx| {
|
||||||
let allow = state == &ToggleState::Selected;
|
let allow = state == &ToggleState::Selected;
|
||||||
update_settings_file::<AgentSettings>(
|
update_settings_file::<AssistantSettings>(
|
||||||
fs.clone(),
|
fs.clone(),
|
||||||
cx,
|
cx,
|
||||||
move |settings, _| {
|
move |settings, _| {
|
||||||
@@ -327,55 +291,15 @@ impl AgentConfiguration {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn render_sound_notification(&mut self, cx: &mut Context<Self>) -> impl IntoElement {
|
|
||||||
let play_sound_when_agent_done = AgentSettings::get_global(cx).play_sound_when_agent_done;
|
|
||||||
|
|
||||||
h_flex()
|
|
||||||
.gap_4()
|
|
||||||
.justify_between()
|
|
||||||
.flex_wrap()
|
|
||||||
.child(
|
|
||||||
v_flex()
|
|
||||||
.gap_0p5()
|
|
||||||
.max_w_5_6()
|
|
||||||
.child(Label::new("Play sound when finished generating"))
|
|
||||||
.child(
|
|
||||||
Label::new(
|
|
||||||
"Hear a notification sound when the agent is done generating changes or needs your input.",
|
|
||||||
)
|
|
||||||
.color(Color::Muted),
|
|
||||||
),
|
|
||||||
)
|
|
||||||
.child(
|
|
||||||
Switch::new("play-sound-notification-switch", play_sound_when_agent_done.into())
|
|
||||||
.color(SwitchColor::Accent)
|
|
||||||
.on_click({
|
|
||||||
let fs = self.fs.clone();
|
|
||||||
move |state, _window, cx| {
|
|
||||||
let allow = state == &ToggleState::Selected;
|
|
||||||
update_settings_file::<AgentSettings>(
|
|
||||||
fs.clone(),
|
|
||||||
cx,
|
|
||||||
move |settings, _| {
|
|
||||||
settings.set_play_sound_when_agent_done(allow);
|
|
||||||
},
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}),
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
fn render_general_settings_section(&mut self, cx: &mut Context<Self>) -> impl IntoElement {
|
fn render_general_settings_section(&mut self, cx: &mut Context<Self>) -> impl IntoElement {
|
||||||
v_flex()
|
v_flex()
|
||||||
.p(DynamicSpacing::Base16.rems(cx))
|
.p(DynamicSpacing::Base16.rems(cx))
|
||||||
.pr(DynamicSpacing::Base20.rems(cx))
|
.pr(DynamicSpacing::Base20.rems(cx))
|
||||||
.gap_2p5()
|
.gap_2p5()
|
||||||
.border_b_1()
|
.flex_1()
|
||||||
.border_color(cx.theme().colors().border)
|
|
||||||
.child(Headline::new("General Settings"))
|
.child(Headline::new("General Settings"))
|
||||||
.child(self.render_command_permission(cx))
|
.child(self.render_command_permission(cx))
|
||||||
.child(self.render_single_file_review(cx))
|
.child(self.render_single_file_review(cx))
|
||||||
.child(self.render_sound_notification(cx))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn render_context_servers_section(
|
fn render_context_servers_section(
|
||||||
@@ -385,17 +309,18 @@ impl AgentConfiguration {
|
|||||||
) -> impl IntoElement {
|
) -> impl IntoElement {
|
||||||
let context_server_ids = self.context_server_store.read(cx).all_server_ids().clone();
|
let context_server_ids = self.context_server_store.read(cx).all_server_ids().clone();
|
||||||
|
|
||||||
|
const SUBHEADING: &str = "Connect to context servers via the Model Context Protocol either via Zed extensions or directly.";
|
||||||
|
|
||||||
v_flex()
|
v_flex()
|
||||||
.p(DynamicSpacing::Base16.rems(cx))
|
.p(DynamicSpacing::Base16.rems(cx))
|
||||||
.pr(DynamicSpacing::Base20.rems(cx))
|
.pr(DynamicSpacing::Base20.rems(cx))
|
||||||
.gap_2()
|
.gap_2()
|
||||||
.border_b_1()
|
.flex_1()
|
||||||
.border_color(cx.theme().colors().border)
|
|
||||||
.child(
|
.child(
|
||||||
v_flex()
|
v_flex()
|
||||||
.gap_0p5()
|
.gap_0p5()
|
||||||
.child(Headline::new("Model Context Protocol (MCP) Servers"))
|
.child(Headline::new("Model Context Protocol (MCP) Servers"))
|
||||||
.child(Label::new("Connect to context servers via the Model Context Protocol either via Zed extensions or directly.").color(Color::Muted)),
|
.child(Label::new(SUBHEADING).color(Color::Muted)),
|
||||||
)
|
)
|
||||||
.children(
|
.children(
|
||||||
context_server_ids.into_iter().map(|context_server_id| {
|
context_server_ids.into_iter().map(|context_server_id| {
|
||||||
@@ -462,7 +387,6 @@ impl AgentConfiguration {
|
|||||||
.unwrap_or(ContextServerStatus::Stopped);
|
.unwrap_or(ContextServerStatus::Stopped);
|
||||||
|
|
||||||
let is_running = matches!(server_status, ContextServerStatus::Running);
|
let is_running = matches!(server_status, ContextServerStatus::Running);
|
||||||
let item_id = SharedString::from(context_server_id.0.clone());
|
|
||||||
|
|
||||||
let error = if let ContextServerStatus::Error(error) = server_status.clone() {
|
let error = if let ContextServerStatus::Error(error) = server_status.clone() {
|
||||||
Some(error)
|
Some(error)
|
||||||
@@ -484,38 +408,9 @@ impl AgentConfiguration {
|
|||||||
let tool_count = tools.len();
|
let tool_count = tools.len();
|
||||||
|
|
||||||
let border_color = cx.theme().colors().border.opacity(0.6);
|
let border_color = cx.theme().colors().border.opacity(0.6);
|
||||||
let success_color = Color::Success.color(cx);
|
|
||||||
|
|
||||||
let (status_indicator, tooltip_text) = match server_status {
|
|
||||||
ContextServerStatus::Starting => (
|
|
||||||
Indicator::dot()
|
|
||||||
.color(Color::Success)
|
|
||||||
.with_animation(
|
|
||||||
SharedString::from(format!("{}-starting", context_server_id.0.clone(),)),
|
|
||||||
Animation::new(Duration::from_secs(2))
|
|
||||||
.repeat()
|
|
||||||
.with_easing(pulsating_between(0.4, 1.)),
|
|
||||||
move |this, delta| this.color(success_color.alpha(delta).into()),
|
|
||||||
)
|
|
||||||
.into_any_element(),
|
|
||||||
"Server is starting.",
|
|
||||||
),
|
|
||||||
ContextServerStatus::Running => (
|
|
||||||
Indicator::dot().color(Color::Success).into_any_element(),
|
|
||||||
"Server is running.",
|
|
||||||
),
|
|
||||||
ContextServerStatus::Error(_) => (
|
|
||||||
Indicator::dot().color(Color::Error).into_any_element(),
|
|
||||||
"Server has an error.",
|
|
||||||
),
|
|
||||||
ContextServerStatus::Stopped => (
|
|
||||||
Indicator::dot().color(Color::Muted).into_any_element(),
|
|
||||||
"Server is stopped.",
|
|
||||||
),
|
|
||||||
};
|
|
||||||
|
|
||||||
v_flex()
|
v_flex()
|
||||||
.id(item_id.clone())
|
.id(SharedString::from(context_server_id.0.clone()))
|
||||||
.border_1()
|
.border_1()
|
||||||
.rounded_md()
|
.rounded_md()
|
||||||
.border_color(border_color)
|
.border_color(border_color)
|
||||||
@@ -550,12 +445,35 @@ impl AgentConfiguration {
|
|||||||
}
|
}
|
||||||
})),
|
})),
|
||||||
)
|
)
|
||||||
.child(
|
.child(match server_status {
|
||||||
div()
|
ContextServerStatus::Starting => {
|
||||||
.id(item_id.clone())
|
let color = Color::Success.color(cx);
|
||||||
.tooltip(Tooltip::text(tooltip_text))
|
Indicator::dot()
|
||||||
.child(status_indicator),
|
.color(Color::Success)
|
||||||
)
|
.with_animation(
|
||||||
|
SharedString::from(format!(
|
||||||
|
"{}-starting",
|
||||||
|
context_server_id.0.clone(),
|
||||||
|
)),
|
||||||
|
Animation::new(Duration::from_secs(2))
|
||||||
|
.repeat()
|
||||||
|
.with_easing(pulsating_between(0.4, 1.)),
|
||||||
|
move |this, delta| {
|
||||||
|
this.color(color.alpha(delta).into())
|
||||||
|
},
|
||||||
|
)
|
||||||
|
.into_any_element()
|
||||||
|
}
|
||||||
|
ContextServerStatus::Running => {
|
||||||
|
Indicator::dot().color(Color::Success).into_any_element()
|
||||||
|
}
|
||||||
|
ContextServerStatus::Error(_) => {
|
||||||
|
Indicator::dot().color(Color::Error).into_any_element()
|
||||||
|
}
|
||||||
|
ContextServerStatus::Stopped => {
|
||||||
|
Indicator::dot().color(Color::Muted).into_any_element()
|
||||||
|
}
|
||||||
|
})
|
||||||
.child(Label::new(context_server_id.0.clone()).ml_0p5())
|
.child(Label::new(context_server_id.0.clone()).ml_0p5())
|
||||||
.when(is_running, |this| {
|
.when(is_running, |this| {
|
||||||
this.child(
|
this.child(
|
||||||
@@ -670,7 +588,9 @@ impl Render for AgentConfiguration {
|
|||||||
.size_full()
|
.size_full()
|
||||||
.overflow_y_scroll()
|
.overflow_y_scroll()
|
||||||
.child(self.render_general_settings_section(cx))
|
.child(self.render_general_settings_section(cx))
|
||||||
|
.child(Divider::horizontal().color(DividerColor::Border))
|
||||||
.child(self.render_context_servers_section(window, cx))
|
.child(self.render_context_servers_section(window, cx))
|
||||||
|
.child(Divider::horizontal().color(DividerColor::Border))
|
||||||
.child(self.render_provider_configuration_section(cx)),
|
.child(self.render_provider_configuration_section(cx)),
|
||||||
)
|
)
|
||||||
.child(
|
.child(
|
||||||
|
|||||||
@@ -30,6 +30,7 @@ pub(crate) struct ConfigureContextServerModal {
|
|||||||
context_server_store: Entity<ContextServerStore>,
|
context_server_store: Entity<ContextServerStore>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(clippy::large_enum_variant)]
|
||||||
enum Configuration {
|
enum Configuration {
|
||||||
NotAvailable,
|
NotAvailable,
|
||||||
Required(ConfigurationRequiredState),
|
Required(ConfigurationRequiredState),
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ mod profile_modal_header;
|
|||||||
|
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
|
||||||
use agent_settings::{AgentProfile, AgentProfileId, AgentSettings, builtin_profiles};
|
use assistant_settings::{AgentProfile, AgentProfileId, AssistantSettings, builtin_profiles};
|
||||||
use assistant_tool::ToolWorkingSet;
|
use assistant_tool::ToolWorkingSet;
|
||||||
use convert_case::{Case, Casing as _};
|
use convert_case::{Case, Casing as _};
|
||||||
use editor::Editor;
|
use editor::Editor;
|
||||||
@@ -42,7 +42,7 @@ enum Mode {
|
|||||||
|
|
||||||
impl Mode {
|
impl Mode {
|
||||||
pub fn choose_profile(_window: &mut Window, cx: &mut Context<ManageProfilesModal>) -> Self {
|
pub fn choose_profile(_window: &mut Window, cx: &mut Context<ManageProfilesModal>) -> Self {
|
||||||
let settings = AgentSettings::get_global(cx);
|
let settings = AssistantSettings::get_global(cx);
|
||||||
|
|
||||||
let mut builtin_profiles = Vec::new();
|
let mut builtin_profiles = Vec::new();
|
||||||
let mut custom_profiles = Vec::new();
|
let mut custom_profiles = Vec::new();
|
||||||
@@ -196,7 +196,7 @@ impl ManageProfilesModal {
|
|||||||
window: &mut Window,
|
window: &mut Window,
|
||||||
cx: &mut Context<Self>,
|
cx: &mut Context<Self>,
|
||||||
) {
|
) {
|
||||||
let settings = AgentSettings::get_global(cx);
|
let settings = AssistantSettings::get_global(cx);
|
||||||
let Some(profile) = settings.profiles.get(&profile_id).cloned() else {
|
let Some(profile) = settings.profiles.get(&profile_id).cloned() else {
|
||||||
return;
|
return;
|
||||||
};
|
};
|
||||||
@@ -234,7 +234,7 @@ impl ManageProfilesModal {
|
|||||||
window: &mut Window,
|
window: &mut Window,
|
||||||
cx: &mut Context<Self>,
|
cx: &mut Context<Self>,
|
||||||
) {
|
) {
|
||||||
let settings = AgentSettings::get_global(cx);
|
let settings = AssistantSettings::get_global(cx);
|
||||||
let Some(profile) = settings.profiles.get(&profile_id).cloned() else {
|
let Some(profile) = settings.profiles.get(&profile_id).cloned() else {
|
||||||
return;
|
return;
|
||||||
};
|
};
|
||||||
@@ -270,7 +270,7 @@ impl ManageProfilesModal {
|
|||||||
match &self.mode {
|
match &self.mode {
|
||||||
Mode::ChooseProfile { .. } => {}
|
Mode::ChooseProfile { .. } => {}
|
||||||
Mode::NewProfile(mode) => {
|
Mode::NewProfile(mode) => {
|
||||||
let settings = AgentSettings::get_global(cx);
|
let settings = AssistantSettings::get_global(cx);
|
||||||
|
|
||||||
let base_profile = mode
|
let base_profile = mode
|
||||||
.base_profile_id
|
.base_profile_id
|
||||||
@@ -332,7 +332,7 @@ impl ManageProfilesModal {
|
|||||||
profile: AgentProfile,
|
profile: AgentProfile,
|
||||||
cx: &mut Context<Self>,
|
cx: &mut Context<Self>,
|
||||||
) {
|
) {
|
||||||
update_settings_file::<AgentSettings>(self.fs.clone(), cx, {
|
update_settings_file::<AssistantSettings>(self.fs.clone(), cx, {
|
||||||
move |settings, _cx| {
|
move |settings, _cx| {
|
||||||
settings.create_profile(profile_id, profile).log_err();
|
settings.create_profile(profile_id, profile).log_err();
|
||||||
}
|
}
|
||||||
@@ -485,7 +485,7 @@ impl ManageProfilesModal {
|
|||||||
_window: &mut Window,
|
_window: &mut Window,
|
||||||
cx: &mut Context<Self>,
|
cx: &mut Context<Self>,
|
||||||
) -> impl IntoElement {
|
) -> impl IntoElement {
|
||||||
let settings = AgentSettings::get_global(cx);
|
let settings = AssistantSettings::get_global(cx);
|
||||||
|
|
||||||
let base_profile_name = mode.base_profile_id.as_ref().map(|base_profile_id| {
|
let base_profile_name = mode.base_profile_id.as_ref().map(|base_profile_id| {
|
||||||
settings
|
settings
|
||||||
@@ -518,7 +518,7 @@ impl ManageProfilesModal {
|
|||||||
window: &mut Window,
|
window: &mut Window,
|
||||||
cx: &mut Context<Self>,
|
cx: &mut Context<Self>,
|
||||||
) -> impl IntoElement {
|
) -> impl IntoElement {
|
||||||
let settings = AgentSettings::get_global(cx);
|
let settings = AssistantSettings::get_global(cx);
|
||||||
|
|
||||||
let profile_id = &settings.default_profile;
|
let profile_id = &settings.default_profile;
|
||||||
let profile_name = settings
|
let profile_name = settings
|
||||||
@@ -712,7 +712,7 @@ impl ManageProfilesModal {
|
|||||||
|
|
||||||
impl Render for ManageProfilesModal {
|
impl Render for ManageProfilesModal {
|
||||||
fn render(&mut self, window: &mut Window, cx: &mut Context<Self>) -> impl IntoElement {
|
fn render(&mut self, window: &mut Window, cx: &mut Context<Self>) -> impl IntoElement {
|
||||||
let settings = AgentSettings::get_global(cx);
|
let settings = AssistantSettings::get_global(cx);
|
||||||
|
|
||||||
let go_back_item = div()
|
let go_back_item = div()
|
||||||
.id("cancel-item")
|
.id("cancel-item")
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
use std::{collections::BTreeMap, sync::Arc};
|
use std::{collections::BTreeMap, sync::Arc};
|
||||||
|
|
||||||
use agent_settings::{
|
use assistant_settings::{
|
||||||
AgentProfile, AgentProfileContent, AgentProfileId, AgentSettings, AgentSettingsContent,
|
AgentProfile, AgentProfileContent, AgentProfileId, AssistantSettings, AssistantSettingsContent,
|
||||||
ContextServerPresetContent,
|
ContextServerPresetContent,
|
||||||
};
|
};
|
||||||
use assistant_tool::{ToolSource, ToolWorkingSet};
|
use assistant_tool::{ToolSource, ToolWorkingSet};
|
||||||
@@ -259,7 +259,7 @@ impl PickerDelegate for ToolPickerDelegate {
|
|||||||
is_enabled
|
is_enabled
|
||||||
};
|
};
|
||||||
|
|
||||||
let active_profile_id = &AgentSettings::get_global(cx).default_profile;
|
let active_profile_id = &AssistantSettings::get_global(cx).default_profile;
|
||||||
if active_profile_id == &self.profile_id {
|
if active_profile_id == &self.profile_id {
|
||||||
self.thread_store
|
self.thread_store
|
||||||
.update(cx, |this, cx| {
|
.update(cx, |this, cx| {
|
||||||
@@ -268,12 +268,12 @@ impl PickerDelegate for ToolPickerDelegate {
|
|||||||
.log_err();
|
.log_err();
|
||||||
}
|
}
|
||||||
|
|
||||||
update_settings_file::<AgentSettings>(self.fs.clone(), cx, {
|
update_settings_file::<AssistantSettings>(self.fs.clone(), cx, {
|
||||||
let profile_id = self.profile_id.clone();
|
let profile_id = self.profile_id.clone();
|
||||||
let default_profile = self.profile.clone();
|
let default_profile = self.profile.clone();
|
||||||
let server_id = server_id.clone();
|
let server_id = server_id.clone();
|
||||||
let tool_name = tool_name.clone();
|
let tool_name = tool_name.clone();
|
||||||
move |settings: &mut AgentSettingsContent, _cx| {
|
move |settings: &mut AssistantSettingsContent, _cx| {
|
||||||
settings
|
settings
|
||||||
.v2_setting(|v2_settings| {
|
.v2_setting(|v2_settings| {
|
||||||
let profiles = v2_settings.profiles.get_or_insert_default();
|
let profiles = v2_settings.profiles.get_or_insert_default();
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
use crate::{Keep, KeepAll, OpenAgentDiff, Reject, RejectAll, Thread, ThreadEvent};
|
use crate::{
|
||||||
use agent_settings::AgentSettings;
|
Keep, KeepAll, OpenAgentDiff, Reject, RejectAll, Thread, ThreadEvent, ui::AnimatedLabel,
|
||||||
|
};
|
||||||
use anyhow::Result;
|
use anyhow::Result;
|
||||||
|
use assistant_settings::AssistantSettings;
|
||||||
use buffer_diff::DiffHunkStatus;
|
use buffer_diff::DiffHunkStatus;
|
||||||
use collections::{HashMap, HashSet};
|
use collections::{HashMap, HashSet};
|
||||||
use editor::{
|
use editor::{
|
||||||
@@ -9,9 +11,8 @@ use editor::{
|
|||||||
scroll::Autoscroll,
|
scroll::Autoscroll,
|
||||||
};
|
};
|
||||||
use gpui::{
|
use gpui::{
|
||||||
Action, Animation, AnimationExt, AnyElement, AnyView, App, AppContext, Empty, Entity,
|
Action, AnyElement, AnyView, App, AppContext, Empty, Entity, EventEmitter, FocusHandle,
|
||||||
EventEmitter, FocusHandle, Focusable, Global, SharedString, Subscription, Task, Transformation,
|
Focusable, Global, SharedString, Subscription, Task, WeakEntity, Window, prelude::*,
|
||||||
WeakEntity, Window, percentage, prelude::*,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
use language::{Buffer, Capability, DiskState, OffsetRangeExt, Point};
|
use language::{Buffer, Capability, DiskState, OffsetRangeExt, Point};
|
||||||
@@ -24,7 +25,6 @@ use std::{
|
|||||||
collections::hash_map::Entry,
|
collections::hash_map::Entry,
|
||||||
ops::Range,
|
ops::Range,
|
||||||
sync::Arc,
|
sync::Arc,
|
||||||
time::Duration,
|
|
||||||
};
|
};
|
||||||
use ui::{IconButtonShape, KeyBinding, Tooltip, prelude::*, vertical_divider};
|
use ui::{IconButtonShape, KeyBinding, Tooltip, prelude::*, vertical_divider};
|
||||||
use util::ResultExt;
|
use util::ResultExt;
|
||||||
@@ -215,7 +215,11 @@ impl AgentDiffPane {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn update_title(&mut self, cx: &mut Context<Self>) {
|
fn update_title(&mut self, cx: &mut Context<Self>) {
|
||||||
let new_title = self.thread.read(cx).summary().unwrap_or("Agent Changes");
|
let new_title = self
|
||||||
|
.thread
|
||||||
|
.read(cx)
|
||||||
|
.summary()
|
||||||
|
.unwrap_or("Agent Changes".into());
|
||||||
if new_title != self.title {
|
if new_title != self.title {
|
||||||
self.title = new_title;
|
self.title = new_title;
|
||||||
cx.emit(EditorEvent::TitleChanged);
|
cx.emit(EditorEvent::TitleChanged);
|
||||||
@@ -465,7 +469,11 @@ impl Item for AgentDiffPane {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn tab_content(&self, params: TabContentParams, _window: &Window, cx: &App) -> AnyElement {
|
fn tab_content(&self, params: TabContentParams, _window: &Window, cx: &App) -> AnyElement {
|
||||||
let summary = self.thread.read(cx).summary().unwrap_or("Agent Changes");
|
let summary = self
|
||||||
|
.thread
|
||||||
|
.read(cx)
|
||||||
|
.summary()
|
||||||
|
.unwrap_or("Agent Changes".into());
|
||||||
Label::new(format!("Review: {}", summary))
|
Label::new(format!("Review: {}", summary))
|
||||||
.color(if params.selected {
|
.color(if params.selected {
|
||||||
Color::Default
|
Color::Default
|
||||||
@@ -699,7 +707,7 @@ fn render_diff_hunk_controls(
|
|||||||
.rounded_b_md()
|
.rounded_b_md()
|
||||||
.bg(cx.theme().colors().editor_background)
|
.bg(cx.theme().colors().editor_background)
|
||||||
.gap_1()
|
.gap_1()
|
||||||
.block_mouse_except_scroll()
|
.occlude()
|
||||||
.shadow_md()
|
.shadow_md()
|
||||||
.children(vec![
|
.children(vec![
|
||||||
Button::new(("reject", row as u64), "Reject")
|
Button::new(("reject", row as u64), "Reject")
|
||||||
@@ -970,20 +978,9 @@ impl ToolbarItemView for AgentDiffToolbar {
|
|||||||
|
|
||||||
impl Render for AgentDiffToolbar {
|
impl Render for AgentDiffToolbar {
|
||||||
fn render(&mut self, window: &mut Window, cx: &mut Context<Self>) -> impl IntoElement {
|
fn render(&mut self, window: &mut Window, cx: &mut Context<Self>) -> impl IntoElement {
|
||||||
let spinner_icon = div()
|
let generating_label = div()
|
||||||
.px_0p5()
|
.w(rems_from_px(110.)) // Arbitrary size so the label doesn't dance around
|
||||||
.id("generating")
|
.child(AnimatedLabel::new("Generating"))
|
||||||
.tooltip(Tooltip::text("Generating Changes…"))
|
|
||||||
.child(
|
|
||||||
Icon::new(IconName::LoadCircle)
|
|
||||||
.size(IconSize::Small)
|
|
||||||
.color(Color::Accent)
|
|
||||||
.with_animation(
|
|
||||||
"load_circle",
|
|
||||||
Animation::new(Duration::from_secs(3)).repeat(),
|
|
||||||
|icon, delta| icon.transform(Transformation::rotate(percentage(delta))),
|
|
||||||
),
|
|
||||||
)
|
|
||||||
.into_any();
|
.into_any();
|
||||||
|
|
||||||
let Some(active_item) = self.active_item.as_ref() else {
|
let Some(active_item) = self.active_item.as_ref() else {
|
||||||
@@ -1000,7 +997,7 @@ impl Render for AgentDiffToolbar {
|
|||||||
|
|
||||||
let content = match state {
|
let content = match state {
|
||||||
EditorState::Idle => return Empty.into_any(),
|
EditorState::Idle => return Empty.into_any(),
|
||||||
EditorState::Generating => vec![spinner_icon],
|
EditorState::Generating => vec![generating_label],
|
||||||
EditorState::Reviewing => vec![
|
EditorState::Reviewing => vec![
|
||||||
h_flex()
|
h_flex()
|
||||||
.child(
|
.child(
|
||||||
@@ -1086,7 +1083,7 @@ impl Render for AgentDiffToolbar {
|
|||||||
.child(vertical_divider())
|
.child(vertical_divider())
|
||||||
.when_some(editor.read(cx).workspace(), |this, _workspace| {
|
.when_some(editor.read(cx).workspace(), |this, _workspace| {
|
||||||
this.child(
|
this.child(
|
||||||
IconButton::new("review", IconName::ListTodo)
|
IconButton::new("review", IconName::ListCollapse)
|
||||||
.icon_size(IconSize::Small)
|
.icon_size(IconSize::Small)
|
||||||
.tooltip(Tooltip::for_action_title_in(
|
.tooltip(Tooltip::for_action_title_in(
|
||||||
"Review All Files",
|
"Review All Files",
|
||||||
@@ -1116,14 +1113,9 @@ impl Render for AgentDiffToolbar {
|
|||||||
return Empty.into_any();
|
return Empty.into_any();
|
||||||
};
|
};
|
||||||
|
|
||||||
let has_pending_edit_tool_use = agent_diff
|
let is_generating = agent_diff.read(cx).thread.read(cx).is_generating();
|
||||||
.read(cx)
|
if is_generating {
|
||||||
.thread
|
return div().px_2().child(generating_label).into_any();
|
||||||
.read(cx)
|
|
||||||
.has_pending_edit_tool_uses();
|
|
||||||
|
|
||||||
if has_pending_edit_tool_use {
|
|
||||||
return div().px_2().child(spinner_icon).into_any();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
let is_empty = agent_diff.read(cx).multibuffer.read(cx).is_empty();
|
let is_empty = agent_diff.read(cx).multibuffer.read(cx).is_empty();
|
||||||
@@ -1258,9 +1250,9 @@ impl AgentDiff {
|
|||||||
|
|
||||||
let settings_subscription = cx.observe_global_in::<SettingsStore>(window, {
|
let settings_subscription = cx.observe_global_in::<SettingsStore>(window, {
|
||||||
let workspace = workspace.clone();
|
let workspace = workspace.clone();
|
||||||
let mut was_active = AgentSettings::get_global(cx).single_file_review;
|
let mut was_active = AssistantSettings::get_global(cx).single_file_review;
|
||||||
move |this, window, cx| {
|
move |this, window, cx| {
|
||||||
let is_active = AgentSettings::get_global(cx).single_file_review;
|
let is_active = AssistantSettings::get_global(cx).single_file_review;
|
||||||
if was_active != is_active {
|
if was_active != is_active {
|
||||||
was_active = is_active;
|
was_active = is_active;
|
||||||
this.update_reviewing_editors(&workspace, window, cx);
|
this.update_reviewing_editors(&workspace, window, cx);
|
||||||
@@ -1353,7 +1345,6 @@ impl AgentDiff {
|
|||||||
ThreadEvent::NewRequest
|
ThreadEvent::NewRequest
|
||||||
| ThreadEvent::Stopped(Ok(StopReason::EndTurn))
|
| ThreadEvent::Stopped(Ok(StopReason::EndTurn))
|
||||||
| ThreadEvent::Stopped(Ok(StopReason::MaxTokens))
|
| ThreadEvent::Stopped(Ok(StopReason::MaxTokens))
|
||||||
| ThreadEvent::Stopped(Ok(StopReason::Refusal))
|
|
||||||
| ThreadEvent::Stopped(Err(_))
|
| ThreadEvent::Stopped(Err(_))
|
||||||
| ThreadEvent::ShowError(_)
|
| ThreadEvent::ShowError(_)
|
||||||
| ThreadEvent::CompletionCanceled => {
|
| ThreadEvent::CompletionCanceled => {
|
||||||
@@ -1377,7 +1368,6 @@ impl AgentDiff {
|
|||||||
| ThreadEvent::ToolFinished { .. }
|
| ThreadEvent::ToolFinished { .. }
|
||||||
| ThreadEvent::CheckpointChanged
|
| ThreadEvent::CheckpointChanged
|
||||||
| ThreadEvent::ToolConfirmationNeeded
|
| ThreadEvent::ToolConfirmationNeeded
|
||||||
| ThreadEvent::ToolUseLimitReached
|
|
||||||
| ThreadEvent::CancelEditing => {}
|
| ThreadEvent::CancelEditing => {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1467,13 +1457,10 @@ impl AgentDiff {
|
|||||||
window: &mut Window,
|
window: &mut Window,
|
||||||
cx: &mut Context<Self>,
|
cx: &mut Context<Self>,
|
||||||
) {
|
) {
|
||||||
if !AgentSettings::get_global(cx).single_file_review {
|
if !AssistantSettings::get_global(cx).single_file_review {
|
||||||
for (editor, _) in self.reviewing_editors.drain() {
|
for (editor, _) in self.reviewing_editors.drain() {
|
||||||
editor
|
editor
|
||||||
.update(cx, |editor, cx| {
|
.update(cx, |editor, cx| editor.end_temporary_diff_override(cx))
|
||||||
editor.end_temporary_diff_override(cx);
|
|
||||||
editor.unregister_addon::<EditorAgentDiffAddon>();
|
|
||||||
})
|
|
||||||
.ok();
|
.ok();
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
@@ -1512,7 +1499,7 @@ impl AgentDiff {
|
|||||||
multibuffer.add_diff(diff_handle.clone(), cx);
|
multibuffer.add_diff(diff_handle.clone(), cx);
|
||||||
});
|
});
|
||||||
|
|
||||||
let new_state = if thread.read(cx).has_pending_edit_tool_uses() {
|
let new_state = if thread.read(cx).is_generating() {
|
||||||
EditorState::Generating
|
EditorState::Generating
|
||||||
} else {
|
} else {
|
||||||
EditorState::Reviewing
|
EditorState::Reviewing
|
||||||
@@ -1569,10 +1556,7 @@ impl AgentDiff {
|
|||||||
|
|
||||||
if in_workspace {
|
if in_workspace {
|
||||||
editor
|
editor
|
||||||
.update(cx, |editor, cx| {
|
.update(cx, |editor, cx| editor.end_temporary_diff_override(cx))
|
||||||
editor.end_temporary_diff_override(cx);
|
|
||||||
editor.unregister_addon::<EditorAgentDiffAddon>();
|
|
||||||
})
|
|
||||||
.ok();
|
.ok();
|
||||||
self.reviewing_editors.remove(&editor);
|
self.reviewing_editors.remove(&editor);
|
||||||
}
|
}
|
||||||
@@ -1748,7 +1732,7 @@ impl editor::Addon for EditorAgentDiffAddon {
|
|||||||
mod tests {
|
mod tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
use crate::{Keep, ThreadStore, thread_store};
|
use crate::{Keep, ThreadStore, thread_store};
|
||||||
use agent_settings::AgentSettings;
|
use assistant_settings::AssistantSettings;
|
||||||
use assistant_tool::ToolWorkingSet;
|
use assistant_tool::ToolWorkingSet;
|
||||||
use editor::EditorSettings;
|
use editor::EditorSettings;
|
||||||
use gpui::{TestAppContext, UpdateGlobal, VisualTestContext};
|
use gpui::{TestAppContext, UpdateGlobal, VisualTestContext};
|
||||||
@@ -1767,7 +1751,7 @@ mod tests {
|
|||||||
cx.set_global(settings_store);
|
cx.set_global(settings_store);
|
||||||
language::init(cx);
|
language::init(cx);
|
||||||
Project::init_settings(cx);
|
Project::init_settings(cx);
|
||||||
AgentSettings::register(cx);
|
AssistantSettings::register(cx);
|
||||||
prompt_store::init(cx);
|
prompt_store::init(cx);
|
||||||
thread_store::init(cx);
|
thread_store::init(cx);
|
||||||
workspace::init_settings(cx);
|
workspace::init_settings(cx);
|
||||||
@@ -1923,7 +1907,7 @@ mod tests {
|
|||||||
cx.set_global(settings_store);
|
cx.set_global(settings_store);
|
||||||
language::init(cx);
|
language::init(cx);
|
||||||
Project::init_settings(cx);
|
Project::init_settings(cx);
|
||||||
AgentSettings::register(cx);
|
AssistantSettings::register(cx);
|
||||||
prompt_store::init(cx);
|
prompt_store::init(cx);
|
||||||
thread_store::init(cx);
|
thread_store::init(cx);
|
||||||
workspace::init_settings(cx);
|
workspace::init_settings(cx);
|
||||||
|
|||||||
@@ -1,17 +1,22 @@
|
|||||||
use agent_settings::AgentSettings;
|
use assistant_settings::AssistantSettings;
|
||||||
use fs::Fs;
|
use fs::Fs;
|
||||||
use gpui::{Entity, FocusHandle, SharedString};
|
use gpui::{Entity, FocusHandle, SharedString};
|
||||||
use picker::popover_menu::PickerPopoverMenu;
|
|
||||||
|
|
||||||
use crate::ModelUsageContext;
|
use crate::Thread;
|
||||||
use assistant_context_editor::language_model_selector::{
|
|
||||||
LanguageModelSelector, ToggleModelSelector, language_model_selector,
|
|
||||||
};
|
|
||||||
use language_model::{ConfiguredModel, LanguageModelRegistry};
|
use language_model::{ConfiguredModel, LanguageModelRegistry};
|
||||||
|
use language_model_selector::{
|
||||||
|
LanguageModelSelector, LanguageModelSelectorPopoverMenu, ToggleModelSelector,
|
||||||
|
};
|
||||||
use settings::update_settings_file;
|
use settings::update_settings_file;
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
use ui::{PopoverMenuHandle, Tooltip, prelude::*};
|
use ui::{PopoverMenuHandle, Tooltip, prelude::*};
|
||||||
|
|
||||||
|
#[derive(Clone)]
|
||||||
|
pub enum ModelType {
|
||||||
|
Default(Entity<Thread>),
|
||||||
|
InlineAssistant,
|
||||||
|
}
|
||||||
|
|
||||||
pub struct AgentModelSelector {
|
pub struct AgentModelSelector {
|
||||||
selector: Entity<LanguageModelSelector>,
|
selector: Entity<LanguageModelSelector>,
|
||||||
menu_handle: PopoverMenuHandle<LanguageModelSelector>,
|
menu_handle: PopoverMenuHandle<LanguageModelSelector>,
|
||||||
@@ -23,23 +28,28 @@ impl AgentModelSelector {
|
|||||||
fs: Arc<dyn Fs>,
|
fs: Arc<dyn Fs>,
|
||||||
menu_handle: PopoverMenuHandle<LanguageModelSelector>,
|
menu_handle: PopoverMenuHandle<LanguageModelSelector>,
|
||||||
focus_handle: FocusHandle,
|
focus_handle: FocusHandle,
|
||||||
model_usage_context: ModelUsageContext,
|
model_type: ModelType,
|
||||||
window: &mut Window,
|
window: &mut Window,
|
||||||
cx: &mut Context<Self>,
|
cx: &mut Context<Self>,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
Self {
|
Self {
|
||||||
selector: cx.new(move |cx| {
|
selector: cx.new(move |cx| {
|
||||||
let fs = fs.clone();
|
let fs = fs.clone();
|
||||||
language_model_selector(
|
LanguageModelSelector::new(
|
||||||
{
|
{
|
||||||
let model_context = model_usage_context.clone();
|
let model_type = model_type.clone();
|
||||||
move |cx| model_context.configured_model(cx)
|
move |cx| match &model_type {
|
||||||
|
ModelType::Default(thread) => thread.read(cx).configured_model(),
|
||||||
|
ModelType::InlineAssistant => {
|
||||||
|
LanguageModelRegistry::read_global(cx).inline_assistant_model()
|
||||||
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
move |model, cx| {
|
move |model, cx| {
|
||||||
let provider = model.provider_id().0.to_string();
|
let provider = model.provider_id().0.to_string();
|
||||||
let model_id = model.id().0.to_string();
|
let model_id = model.id().0.to_string();
|
||||||
match &model_usage_context {
|
match &model_type {
|
||||||
ModelUsageContext::Thread(thread) => {
|
ModelType::Default(thread) => {
|
||||||
thread.update(cx, |thread, cx| {
|
thread.update(cx, |thread, cx| {
|
||||||
let registry = LanguageModelRegistry::read_global(cx);
|
let registry = LanguageModelRegistry::read_global(cx);
|
||||||
if let Some(provider) = registry.provider(&model.provider_id())
|
if let Some(provider) = registry.provider(&model.provider_id())
|
||||||
@@ -53,7 +63,7 @@ impl AgentModelSelector {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
update_settings_file::<AgentSettings>(
|
update_settings_file::<AssistantSettings>(
|
||||||
fs.clone(),
|
fs.clone(),
|
||||||
cx,
|
cx,
|
||||||
move |settings, _cx| {
|
move |settings, _cx| {
|
||||||
@@ -61,8 +71,8 @@ impl AgentModelSelector {
|
|||||||
},
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
ModelUsageContext::InlineAssistant => {
|
ModelType::InlineAssistant => {
|
||||||
update_settings_file::<AgentSettings>(
|
update_settings_file::<AssistantSettings>(
|
||||||
fs.clone(),
|
fs.clone(),
|
||||||
cx,
|
cx,
|
||||||
move |settings, _cx| {
|
move |settings, _cx| {
|
||||||
@@ -90,14 +100,15 @@ impl AgentModelSelector {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl Render for AgentModelSelector {
|
impl Render for AgentModelSelector {
|
||||||
fn render(&mut self, window: &mut Window, cx: &mut Context<Self>) -> impl IntoElement {
|
fn render(&mut self, _window: &mut Window, cx: &mut Context<Self>) -> impl IntoElement {
|
||||||
let focus_handle = self.focus_handle.clone();
|
let focus_handle = self.focus_handle.clone();
|
||||||
|
|
||||||
let model = self.selector.read(cx).delegate.active_model(cx);
|
let model = self.selector.read(cx).active_model(cx);
|
||||||
let model_name = model
|
let model_name = model
|
||||||
.map(|model| model.model.name().0)
|
.map(|model| model.model.name().0)
|
||||||
.unwrap_or_else(|| SharedString::from("No model selected"));
|
.unwrap_or_else(|| SharedString::from("No model selected"));
|
||||||
PickerPopoverMenu::new(
|
|
||||||
|
LanguageModelSelectorPopoverMenu::new(
|
||||||
self.selector.clone(),
|
self.selector.clone(),
|
||||||
Button::new("active-model", model_name)
|
Button::new("active-model", model_name)
|
||||||
.label_size(LabelSize::Small)
|
.label_size(LabelSize::Small)
|
||||||
@@ -116,9 +127,7 @@ impl Render for AgentModelSelector {
|
|||||||
)
|
)
|
||||||
},
|
},
|
||||||
gpui::Corner::BottomRight,
|
gpui::Corner::BottomRight,
|
||||||
cx,
|
|
||||||
)
|
)
|
||||||
.with_handle(self.menu_handle.clone())
|
.with_handle(self.menu_handle.clone())
|
||||||
.render(window, cx)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
use crate::context::ContextLoadResult;
|
use crate::context::ContextLoadResult;
|
||||||
use crate::inline_prompt_editor::CodegenStatus;
|
use crate::inline_prompt_editor::CodegenStatus;
|
||||||
use crate::{context::load_context, context_store::ContextStore};
|
use crate::{context::load_context, context_store::ContextStore};
|
||||||
use agent_settings::AgentSettings;
|
use anyhow::Result;
|
||||||
use anyhow::{Context as _, Result};
|
use assistant_settings::AssistantSettings;
|
||||||
use client::telemetry::Telemetry;
|
use client::telemetry::Telemetry;
|
||||||
use collections::HashSet;
|
use collections::HashSet;
|
||||||
use editor::{Anchor, AnchorRangeExt, MultiBuffer, MultiBufferSnapshot, ToOffset as _, ToPoint};
|
use editor::{Anchor, AnchorRangeExt, MultiBuffer, MultiBufferSnapshot, ToOffset as _, ToPoint};
|
||||||
@@ -34,7 +34,6 @@ use std::{
|
|||||||
};
|
};
|
||||||
use streaming_diff::{CharOperation, LineDiff, LineOperation, StreamingDiff};
|
use streaming_diff::{CharOperation, LineDiff, LineOperation, StreamingDiff};
|
||||||
use telemetry_events::{AssistantEventData, AssistantKind, AssistantPhase};
|
use telemetry_events::{AssistantEventData, AssistantKind, AssistantPhase};
|
||||||
use zed_llm_client::CompletionIntent;
|
|
||||||
|
|
||||||
pub struct BufferCodegen {
|
pub struct BufferCodegen {
|
||||||
alternatives: Vec<Entity<CodegenAlternative>>,
|
alternatives: Vec<Entity<CodegenAlternative>>,
|
||||||
@@ -420,16 +419,16 @@ impl CodegenAlternative {
|
|||||||
if start_buffer.remote_id() == end_buffer.remote_id() {
|
if start_buffer.remote_id() == end_buffer.remote_id() {
|
||||||
(start_buffer.clone(), start_buffer_offset..end_buffer_offset)
|
(start_buffer.clone(), start_buffer_offset..end_buffer_offset)
|
||||||
} else {
|
} else {
|
||||||
anyhow::bail!("invalid transformation range");
|
return Err(anyhow::anyhow!("invalid transformation range"));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
anyhow::bail!("invalid transformation range");
|
return Err(anyhow::anyhow!("invalid transformation range"));
|
||||||
};
|
};
|
||||||
|
|
||||||
let prompt = self
|
let prompt = self
|
||||||
.builder
|
.builder
|
||||||
.generate_inline_transformation_prompt(user_prompt, language_name, buffer, range)
|
.generate_inline_transformation_prompt(user_prompt, language_name, buffer, range)
|
||||||
.context("generating content prompt")?;
|
.map_err(|e| anyhow::anyhow!("Failed to generate content prompt: {}", e))?;
|
||||||
|
|
||||||
let context_task = self.context_store.as_ref().map(|context_store| {
|
let context_task = self.context_store.as_ref().map(|context_store| {
|
||||||
if let Some(project) = self.project.upgrade() {
|
if let Some(project) = self.project.upgrade() {
|
||||||
@@ -444,7 +443,7 @@ impl CodegenAlternative {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
let temperature = AgentSettings::temperature_for_model(&model, cx);
|
let temperature = AssistantSettings::temperature_for_model(&model, cx);
|
||||||
|
|
||||||
Ok(cx.spawn(async move |_cx| {
|
Ok(cx.spawn(async move |_cx| {
|
||||||
let mut request_message = LanguageModelRequestMessage {
|
let mut request_message = LanguageModelRequestMessage {
|
||||||
@@ -465,7 +464,6 @@ impl CodegenAlternative {
|
|||||||
LanguageModelRequest {
|
LanguageModelRequest {
|
||||||
thread_id: None,
|
thread_id: None,
|
||||||
prompt_id: None,
|
prompt_id: None,
|
||||||
intent: Some(CompletionIntent::InlineAssist),
|
|
||||||
mode: None,
|
mode: None,
|
||||||
tools: Vec::new(),
|
tools: Vec::new(),
|
||||||
tool_choice: None,
|
tool_choice: None,
|
||||||
|
|||||||
@@ -586,7 +586,10 @@ impl ThreadContextHandle {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn title(&self, cx: &App) -> SharedString {
|
pub fn title(&self, cx: &App) -> SharedString {
|
||||||
self.thread.read(cx).summary().or_default()
|
self.thread
|
||||||
|
.read(cx)
|
||||||
|
.summary()
|
||||||
|
.unwrap_or_else(|| "New thread".into())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn load(self, cx: &App) -> Task<Option<(AgentContext, Vec<Entity<Buffer>>)>> {
|
fn load(self, cx: &App) -> Task<Option<(AgentContext, Vec<Entity<Buffer>>)>> {
|
||||||
@@ -594,7 +597,9 @@ impl ThreadContextHandle {
|
|||||||
let text = Thread::wait_for_detailed_summary_or_text(&self.thread, cx).await?;
|
let text = Thread::wait_for_detailed_summary_or_text(&self.thread, cx).await?;
|
||||||
let title = self
|
let title = self
|
||||||
.thread
|
.thread
|
||||||
.read_with(cx, |thread, _cx| thread.summary().or_default())
|
.read_with(cx, |thread, _cx| {
|
||||||
|
thread.summary().unwrap_or_else(|| "New thread".into())
|
||||||
|
})
|
||||||
.ok()?;
|
.ok()?;
|
||||||
let context = AgentContext::Thread(ThreadContext {
|
let context = AgentContext::Thread(ThreadContext {
|
||||||
title,
|
title,
|
||||||
@@ -637,7 +642,7 @@ impl TextThreadContextHandle {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn title(&self, cx: &App) -> SharedString {
|
pub fn title(&self, cx: &App) -> SharedString {
|
||||||
self.context.read(cx).summary().or_default()
|
self.context.read(cx).summary_or_default()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn load(self, cx: &App) -> Task<Option<(AgentContext, Vec<Entity<Buffer>>)>> {
|
fn load(self, cx: &App) -> Task<Option<(AgentContext, Vec<Entity<Buffer>>)>> {
|
||||||
@@ -734,7 +739,6 @@ impl Display for RulesContext {
|
|||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
pub struct ImageContext {
|
pub struct ImageContext {
|
||||||
pub project_path: Option<ProjectPath>,
|
pub project_path: Option<ProjectPath>,
|
||||||
pub full_path: Option<Arc<Path>>,
|
|
||||||
pub original_image: Arc<gpui::Image>,
|
pub original_image: Arc<gpui::Image>,
|
||||||
// TODO: handle this elsewhere and remove `ignore-interior-mutability` opt-out in clippy.toml
|
// TODO: handle this elsewhere and remove `ignore-interior-mutability` opt-out in clippy.toml
|
||||||
// needed due to a false positive of `clippy::mutable_key_type`.
|
// needed due to a false positive of `clippy::mutable_key_type`.
|
||||||
@@ -745,7 +749,6 @@ pub struct ImageContext {
|
|||||||
pub enum ImageStatus {
|
pub enum ImageStatus {
|
||||||
Loading,
|
Loading,
|
||||||
Error,
|
Error,
|
||||||
Warning,
|
|
||||||
Ready,
|
Ready,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -762,17 +765,11 @@ impl ImageContext {
|
|||||||
self.image_task.clone().now_or_never().flatten()
|
self.image_task.clone().now_or_never().flatten()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn status(&self, model: Option<&Arc<dyn language_model::LanguageModel>>) -> ImageStatus {
|
pub fn status(&self) -> ImageStatus {
|
||||||
match self.image_task.clone().now_or_never() {
|
match self.image_task.clone().now_or_never() {
|
||||||
None => ImageStatus::Loading,
|
None => ImageStatus::Loading,
|
||||||
Some(None) => ImageStatus::Error,
|
Some(None) => ImageStatus::Error,
|
||||||
Some(Some(_)) => {
|
Some(Some(_)) => ImageStatus::Ready,
|
||||||
if model.is_some_and(|model| !model.supports_images()) {
|
|
||||||
ImageStatus::Warning
|
|
||||||
} else {
|
|
||||||
ImageStatus::Ready
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -833,20 +830,23 @@ pub fn load_context(
|
|||||||
prompt_store: &Option<Entity<PromptStore>>,
|
prompt_store: &Option<Entity<PromptStore>>,
|
||||||
cx: &mut App,
|
cx: &mut App,
|
||||||
) -> Task<ContextLoadResult> {
|
) -> Task<ContextLoadResult> {
|
||||||
let load_tasks: Vec<_> = contexts
|
let mut load_tasks = Vec::new();
|
||||||
.into_iter()
|
|
||||||
.map(|context| match context {
|
for context in contexts.iter().cloned() {
|
||||||
AgentContextHandle::File(context) => context.load(cx),
|
match context {
|
||||||
AgentContextHandle::Directory(context) => context.load(project.clone(), cx),
|
AgentContextHandle::File(context) => load_tasks.push(context.load(cx)),
|
||||||
AgentContextHandle::Symbol(context) => context.load(cx),
|
AgentContextHandle::Directory(context) => {
|
||||||
AgentContextHandle::Selection(context) => context.load(cx),
|
load_tasks.push(context.load(project.clone(), cx))
|
||||||
AgentContextHandle::FetchedUrl(context) => context.load(),
|
}
|
||||||
AgentContextHandle::Thread(context) => context.load(cx),
|
AgentContextHandle::Symbol(context) => load_tasks.push(context.load(cx)),
|
||||||
AgentContextHandle::TextThread(context) => context.load(cx),
|
AgentContextHandle::Selection(context) => load_tasks.push(context.load(cx)),
|
||||||
AgentContextHandle::Rules(context) => context.load(prompt_store, cx),
|
AgentContextHandle::FetchedUrl(context) => load_tasks.push(context.load()),
|
||||||
AgentContextHandle::Image(context) => context.load(cx),
|
AgentContextHandle::Thread(context) => load_tasks.push(context.load(cx)),
|
||||||
})
|
AgentContextHandle::TextThread(context) => load_tasks.push(context.load(cx)),
|
||||||
.collect();
|
AgentContextHandle::Rules(context) => load_tasks.push(context.load(prompt_store, cx)),
|
||||||
|
AgentContextHandle::Image(context) => load_tasks.push(context.load(cx)),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
cx.background_spawn(async move {
|
cx.background_spawn(async move {
|
||||||
let load_results = future::join_all(load_tasks).await;
|
let load_results = future::join_all(load_tasks).await;
|
||||||
|
|||||||
@@ -381,16 +381,6 @@ impl ContextPicker {
|
|||||||
cx.focus_self(window);
|
cx.focus_self(window);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn select_first(&mut self, window: &mut Window, cx: &mut Context<Self>) {
|
|
||||||
match &self.mode {
|
|
||||||
ContextPickerState::Default(entity) => entity.update(cx, |entity, cx| {
|
|
||||||
entity.select_first(&Default::default(), window, cx)
|
|
||||||
}),
|
|
||||||
// Other variants already select their first entry on open automatically
|
|
||||||
_ => {}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn recent_menu_item(
|
fn recent_menu_item(
|
||||||
&self,
|
&self,
|
||||||
context_picker: Entity<ContextPicker>,
|
context_picker: Entity<ContextPicker>,
|
||||||
@@ -766,7 +756,6 @@ pub(crate) fn insert_crease_for_mention(
|
|||||||
|
|
||||||
let ids = editor.insert_creases(vec![crease.clone()], cx);
|
let ids = editor.insert_creases(vec![crease.clone()], cx);
|
||||||
editor.fold_creases(vec![crease], false, window, cx);
|
editor.fold_creases(vec![crease], false, window, cx);
|
||||||
|
|
||||||
Some(ids[0])
|
Some(ids[0])
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@@ -943,8 +932,8 @@ impl MentionLink {
|
|||||||
format!("[@{}]({}:{})", title, Self::THREAD, id)
|
format!("[@{}]({}:{})", title, Self::THREAD, id)
|
||||||
}
|
}
|
||||||
ThreadContextEntry::Context { path, title } => {
|
ThreadContextEntry::Context { path, title } => {
|
||||||
let filename = path.file_name().unwrap_or_default().to_string_lossy();
|
let filename = path.file_name().unwrap_or_default();
|
||||||
let escaped_filename = urlencoding::encode(&filename);
|
let escaped_filename = urlencoding::encode(&filename.to_string_lossy()).to_string();
|
||||||
format!(
|
format!(
|
||||||
"[@{}]({}:{}{})",
|
"[@{}]({}:{}{})",
|
||||||
title,
|
title,
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ use http_client::HttpClientWithUrl;
|
|||||||
use itertools::Itertools;
|
use itertools::Itertools;
|
||||||
use language::{Buffer, CodeLabel, HighlightId};
|
use language::{Buffer, CodeLabel, HighlightId};
|
||||||
use lsp::CompletionContext;
|
use lsp::CompletionContext;
|
||||||
use project::{Completion, CompletionIntent, CompletionResponse, ProjectPath, Symbol, WorktreeId};
|
use project::{Completion, CompletionIntent, ProjectPath, Symbol, WorktreeId};
|
||||||
use prompt_store::PromptStore;
|
use prompt_store::PromptStore;
|
||||||
use rope::Point;
|
use rope::Point;
|
||||||
use text::{Anchor, OffsetRangeExt, ToPoint};
|
use text::{Anchor, OffsetRangeExt, ToPoint};
|
||||||
@@ -322,10 +322,7 @@ impl ContextPickerCompletionProvider {
|
|||||||
})
|
})
|
||||||
.collect::<Vec<_>>();
|
.collect::<Vec<_>>();
|
||||||
|
|
||||||
let new_text = format!(
|
let new_text = selection_infos.iter().map(|(_, link, _)| link).join(" ");
|
||||||
"{} ",
|
|
||||||
selection_infos.iter().map(|(_, link, _)| link).join(" ")
|
|
||||||
);
|
|
||||||
|
|
||||||
let callback = Arc::new({
|
let callback = Arc::new({
|
||||||
let context_store = context_store.clone();
|
let context_store = context_store.clone();
|
||||||
@@ -423,7 +420,7 @@ impl ContextPickerCompletionProvider {
|
|||||||
} else {
|
} else {
|
||||||
IconName::MessageBubbles
|
IconName::MessageBubbles
|
||||||
};
|
};
|
||||||
let new_text = format!("{} ", MentionLink::for_thread(&thread_entry));
|
let new_text = MentionLink::for_thread(&thread_entry);
|
||||||
let new_text_len = new_text.len();
|
let new_text_len = new_text.len();
|
||||||
Completion {
|
Completion {
|
||||||
replace_range: source_range.clone(),
|
replace_range: source_range.clone(),
|
||||||
@@ -438,7 +435,7 @@ impl ContextPickerCompletionProvider {
|
|||||||
thread_entry.title().clone(),
|
thread_entry.title().clone(),
|
||||||
excerpt_id,
|
excerpt_id,
|
||||||
source_range.start,
|
source_range.start,
|
||||||
new_text_len - 1,
|
new_text_len,
|
||||||
editor.clone(),
|
editor.clone(),
|
||||||
context_store.clone(),
|
context_store.clone(),
|
||||||
move |window, cx| match &thread_entry {
|
move |window, cx| match &thread_entry {
|
||||||
@@ -492,7 +489,7 @@ impl ContextPickerCompletionProvider {
|
|||||||
editor: Entity<Editor>,
|
editor: Entity<Editor>,
|
||||||
context_store: Entity<ContextStore>,
|
context_store: Entity<ContextStore>,
|
||||||
) -> Completion {
|
) -> Completion {
|
||||||
let new_text = format!("{} ", MentionLink::for_rule(&rules));
|
let new_text = MentionLink::for_rule(&rules);
|
||||||
let new_text_len = new_text.len();
|
let new_text_len = new_text.len();
|
||||||
Completion {
|
Completion {
|
||||||
replace_range: source_range.clone(),
|
replace_range: source_range.clone(),
|
||||||
@@ -507,7 +504,7 @@ impl ContextPickerCompletionProvider {
|
|||||||
rules.title.clone(),
|
rules.title.clone(),
|
||||||
excerpt_id,
|
excerpt_id,
|
||||||
source_range.start,
|
source_range.start,
|
||||||
new_text_len - 1,
|
new_text_len,
|
||||||
editor.clone(),
|
editor.clone(),
|
||||||
context_store.clone(),
|
context_store.clone(),
|
||||||
move |_, cx| {
|
move |_, cx| {
|
||||||
@@ -529,7 +526,7 @@ impl ContextPickerCompletionProvider {
|
|||||||
context_store: Entity<ContextStore>,
|
context_store: Entity<ContextStore>,
|
||||||
http_client: Arc<HttpClientWithUrl>,
|
http_client: Arc<HttpClientWithUrl>,
|
||||||
) -> Completion {
|
) -> Completion {
|
||||||
let new_text = format!("{} ", MentionLink::for_fetch(&url_to_fetch));
|
let new_text = MentionLink::for_fetch(&url_to_fetch);
|
||||||
let new_text_len = new_text.len();
|
let new_text_len = new_text.len();
|
||||||
Completion {
|
Completion {
|
||||||
replace_range: source_range.clone(),
|
replace_range: source_range.clone(),
|
||||||
@@ -544,7 +541,7 @@ impl ContextPickerCompletionProvider {
|
|||||||
url_to_fetch.clone(),
|
url_to_fetch.clone(),
|
||||||
excerpt_id,
|
excerpt_id,
|
||||||
source_range.start,
|
source_range.start,
|
||||||
new_text_len - 1,
|
new_text_len,
|
||||||
editor.clone(),
|
editor.clone(),
|
||||||
context_store.clone(),
|
context_store.clone(),
|
||||||
move |_, cx| {
|
move |_, cx| {
|
||||||
@@ -553,7 +550,7 @@ impl ContextPickerCompletionProvider {
|
|||||||
let url_to_fetch = url_to_fetch.clone();
|
let url_to_fetch = url_to_fetch.clone();
|
||||||
cx.spawn(async move |cx| {
|
cx.spawn(async move |cx| {
|
||||||
if let Some(context) = context_store
|
if let Some(context) = context_store
|
||||||
.read_with(cx, |context_store, _| {
|
.update(cx, |context_store, _| {
|
||||||
context_store.get_url_context(url_to_fetch.clone())
|
context_store.get_url_context(url_to_fetch.clone())
|
||||||
})
|
})
|
||||||
.ok()?
|
.ok()?
|
||||||
@@ -614,7 +611,7 @@ impl ContextPickerCompletionProvider {
|
|||||||
crease_icon_path.clone()
|
crease_icon_path.clone()
|
||||||
};
|
};
|
||||||
|
|
||||||
let new_text = format!("{} ", MentionLink::for_file(&file_name, &full_path));
|
let new_text = MentionLink::for_file(&file_name, &full_path);
|
||||||
let new_text_len = new_text.len();
|
let new_text_len = new_text.len();
|
||||||
Completion {
|
Completion {
|
||||||
replace_range: source_range.clone(),
|
replace_range: source_range.clone(),
|
||||||
@@ -629,7 +626,7 @@ impl ContextPickerCompletionProvider {
|
|||||||
file_name,
|
file_name,
|
||||||
excerpt_id,
|
excerpt_id,
|
||||||
source_range.start,
|
source_range.start,
|
||||||
new_text_len - 1,
|
new_text_len,
|
||||||
editor,
|
editor,
|
||||||
context_store.clone(),
|
context_store.clone(),
|
||||||
move |_, cx| {
|
move |_, cx| {
|
||||||
@@ -685,7 +682,7 @@ impl ContextPickerCompletionProvider {
|
|||||||
label.push_str(" ", None);
|
label.push_str(" ", None);
|
||||||
label.push_str(&file_name, comment_id);
|
label.push_str(&file_name, comment_id);
|
||||||
|
|
||||||
let new_text = format!("{} ", MentionLink::for_symbol(&symbol.name, &full_path));
|
let new_text = MentionLink::for_symbol(&symbol.name, &full_path);
|
||||||
let new_text_len = new_text.len();
|
let new_text_len = new_text.len();
|
||||||
Some(Completion {
|
Some(Completion {
|
||||||
replace_range: source_range.clone(),
|
replace_range: source_range.clone(),
|
||||||
@@ -700,7 +697,7 @@ impl ContextPickerCompletionProvider {
|
|||||||
symbol.name.clone().into(),
|
symbol.name.clone().into(),
|
||||||
excerpt_id,
|
excerpt_id,
|
||||||
source_range.start,
|
source_range.start,
|
||||||
new_text_len - 1,
|
new_text_len,
|
||||||
editor.clone(),
|
editor.clone(),
|
||||||
context_store.clone(),
|
context_store.clone(),
|
||||||
move |_, cx| {
|
move |_, cx| {
|
||||||
@@ -746,7 +743,7 @@ impl CompletionProvider for ContextPickerCompletionProvider {
|
|||||||
_trigger: CompletionContext,
|
_trigger: CompletionContext,
|
||||||
_window: &mut Window,
|
_window: &mut Window,
|
||||||
cx: &mut Context<Editor>,
|
cx: &mut Context<Editor>,
|
||||||
) -> Task<Result<Vec<CompletionResponse>>> {
|
) -> Task<Result<Option<Vec<Completion>>>> {
|
||||||
let state = buffer.update(cx, |buffer, _cx| {
|
let state = buffer.update(cx, |buffer, _cx| {
|
||||||
let position = buffer_position.to_point(buffer);
|
let position = buffer_position.to_point(buffer);
|
||||||
let line_start = Point::new(position.row, 0);
|
let line_start = Point::new(position.row, 0);
|
||||||
@@ -756,13 +753,13 @@ impl CompletionProvider for ContextPickerCompletionProvider {
|
|||||||
MentionCompletion::try_parse(line, offset_to_line)
|
MentionCompletion::try_parse(line, offset_to_line)
|
||||||
});
|
});
|
||||||
let Some(state) = state else {
|
let Some(state) = state else {
|
||||||
return Task::ready(Ok(Vec::new()));
|
return Task::ready(Ok(None));
|
||||||
};
|
};
|
||||||
|
|
||||||
let Some((workspace, context_store)) =
|
let Some((workspace, context_store)) =
|
||||||
self.workspace.upgrade().zip(self.context_store.upgrade())
|
self.workspace.upgrade().zip(self.context_store.upgrade())
|
||||||
else {
|
else {
|
||||||
return Task::ready(Ok(Vec::new()));
|
return Task::ready(Ok(None));
|
||||||
};
|
};
|
||||||
|
|
||||||
let snapshot = buffer.read(cx).snapshot();
|
let snapshot = buffer.read(cx).snapshot();
|
||||||
@@ -815,10 +812,10 @@ impl CompletionProvider for ContextPickerCompletionProvider {
|
|||||||
cx.spawn(async move |_, cx| {
|
cx.spawn(async move |_, cx| {
|
||||||
let matches = search_task.await;
|
let matches = search_task.await;
|
||||||
let Some(editor) = editor.upgrade() else {
|
let Some(editor) = editor.upgrade() else {
|
||||||
return Ok(Vec::new());
|
return Ok(None);
|
||||||
};
|
};
|
||||||
|
|
||||||
let completions = cx.update(|cx| {
|
Ok(Some(cx.update(|cx| {
|
||||||
matches
|
matches
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.filter_map(|mat| match mat {
|
.filter_map(|mat| match mat {
|
||||||
@@ -901,14 +898,7 @@ impl CompletionProvider for ContextPickerCompletionProvider {
|
|||||||
),
|
),
|
||||||
})
|
})
|
||||||
.collect()
|
.collect()
|
||||||
})?;
|
})?))
|
||||||
|
|
||||||
Ok(vec![CompletionResponse {
|
|
||||||
completions,
|
|
||||||
// Since this does its own filtering (see `filter_completions()` returns false),
|
|
||||||
// there is no benefit to computing whether this set of completions is incomplete.
|
|
||||||
is_incomplete: true,
|
|
||||||
}])
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -926,9 +916,8 @@ impl CompletionProvider for ContextPickerCompletionProvider {
|
|||||||
&self,
|
&self,
|
||||||
buffer: &Entity<language::Buffer>,
|
buffer: &Entity<language::Buffer>,
|
||||||
position: language::Anchor,
|
position: language::Anchor,
|
||||||
_text: &str,
|
_: &str,
|
||||||
_trigger_in_words: bool,
|
_: bool,
|
||||||
_menu_is_open: bool,
|
|
||||||
cx: &mut Context<Editor>,
|
cx: &mut Context<Editor>,
|
||||||
) -> bool {
|
) -> bool {
|
||||||
let buffer = buffer.read(cx);
|
let buffer = buffer.read(cx);
|
||||||
@@ -1224,7 +1213,7 @@ mod tests {
|
|||||||
assert_eq!(worktrees.len(), 1);
|
assert_eq!(worktrees.len(), 1);
|
||||||
worktrees.pop().unwrap()
|
worktrees.pop().unwrap()
|
||||||
});
|
});
|
||||||
let worktree_id = worktree.read_with(cx, |worktree, _| worktree.id());
|
let worktree_id = worktree.update(cx, |worktree, _| worktree.id());
|
||||||
|
|
||||||
let mut cx = VisualTestContext::from_window(*window.deref(), cx);
|
let mut cx = VisualTestContext::from_window(*window.deref(), cx);
|
||||||
|
|
||||||
@@ -1297,7 +1286,7 @@ mod tests {
|
|||||||
.map(Entity::downgrade)
|
.map(Entity::downgrade)
|
||||||
});
|
});
|
||||||
window.focus(&editor.focus_handle(cx));
|
window.focus(&editor.focus_handle(cx));
|
||||||
editor.set_completion_provider(Some(Rc::new(ContextPickerCompletionProvider::new(
|
editor.set_completion_provider(Some(Box::new(ContextPickerCompletionProvider::new(
|
||||||
workspace.downgrade(),
|
workspace.downgrade(),
|
||||||
context_store.downgrade(),
|
context_store.downgrade(),
|
||||||
None,
|
None,
|
||||||
@@ -1364,7 +1353,7 @@ mod tests {
|
|||||||
});
|
});
|
||||||
|
|
||||||
editor.update(&mut cx, |editor, cx| {
|
editor.update(&mut cx, |editor, cx| {
|
||||||
assert_eq!(editor.text(cx), "Lorem [@one.txt](@file:dir/a/one.txt) ");
|
assert_eq!(editor.text(cx), "Lorem [@one.txt](@file:dir/a/one.txt)",);
|
||||||
assert!(!editor.has_visible_completions_menu());
|
assert!(!editor.has_visible_completions_menu());
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
fold_ranges(editor, cx),
|
fold_ranges(editor, cx),
|
||||||
@@ -1375,7 +1364,7 @@ mod tests {
|
|||||||
cx.simulate_input(" ");
|
cx.simulate_input(" ");
|
||||||
|
|
||||||
editor.update(&mut cx, |editor, cx| {
|
editor.update(&mut cx, |editor, cx| {
|
||||||
assert_eq!(editor.text(cx), "Lorem [@one.txt](@file:dir/a/one.txt) ");
|
assert_eq!(editor.text(cx), "Lorem [@one.txt](@file:dir/a/one.txt) ",);
|
||||||
assert!(!editor.has_visible_completions_menu());
|
assert!(!editor.has_visible_completions_menu());
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
fold_ranges(editor, cx),
|
fold_ranges(editor, cx),
|
||||||
@@ -1388,7 +1377,7 @@ mod tests {
|
|||||||
editor.update(&mut cx, |editor, cx| {
|
editor.update(&mut cx, |editor, cx| {
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
editor.text(cx),
|
editor.text(cx),
|
||||||
"Lorem [@one.txt](@file:dir/a/one.txt) Ipsum ",
|
"Lorem [@one.txt](@file:dir/a/one.txt) Ipsum ",
|
||||||
);
|
);
|
||||||
assert!(!editor.has_visible_completions_menu());
|
assert!(!editor.has_visible_completions_menu());
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
@@ -1402,7 +1391,7 @@ mod tests {
|
|||||||
editor.update(&mut cx, |editor, cx| {
|
editor.update(&mut cx, |editor, cx| {
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
editor.text(cx),
|
editor.text(cx),
|
||||||
"Lorem [@one.txt](@file:dir/a/one.txt) Ipsum @file ",
|
"Lorem [@one.txt](@file:dir/a/one.txt) Ipsum @file ",
|
||||||
);
|
);
|
||||||
assert!(editor.has_visible_completions_menu());
|
assert!(editor.has_visible_completions_menu());
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
@@ -1420,14 +1409,14 @@ mod tests {
|
|||||||
editor.update(&mut cx, |editor, cx| {
|
editor.update(&mut cx, |editor, cx| {
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
editor.text(cx),
|
editor.text(cx),
|
||||||
"Lorem [@one.txt](@file:dir/a/one.txt) Ipsum [@seven.txt](@file:dir/b/seven.txt) "
|
"Lorem [@one.txt](@file:dir/a/one.txt) Ipsum [@seven.txt](@file:dir/b/seven.txt)"
|
||||||
);
|
);
|
||||||
assert!(!editor.has_visible_completions_menu());
|
assert!(!editor.has_visible_completions_menu());
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
fold_ranges(editor, cx),
|
fold_ranges(editor, cx),
|
||||||
vec![
|
vec![
|
||||||
Point::new(0, 6)..Point::new(0, 37),
|
Point::new(0, 6)..Point::new(0, 37),
|
||||||
Point::new(0, 45)..Point::new(0, 80)
|
Point::new(0, 44)..Point::new(0, 79)
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
@@ -1437,14 +1426,14 @@ mod tests {
|
|||||||
editor.update(&mut cx, |editor, cx| {
|
editor.update(&mut cx, |editor, cx| {
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
editor.text(cx),
|
editor.text(cx),
|
||||||
"Lorem [@one.txt](@file:dir/a/one.txt) Ipsum [@seven.txt](@file:dir/b/seven.txt) \n@"
|
"Lorem [@one.txt](@file:dir/a/one.txt) Ipsum [@seven.txt](@file:dir/b/seven.txt)\n@"
|
||||||
);
|
);
|
||||||
assert!(editor.has_visible_completions_menu());
|
assert!(editor.has_visible_completions_menu());
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
fold_ranges(editor, cx),
|
fold_ranges(editor, cx),
|
||||||
vec![
|
vec![
|
||||||
Point::new(0, 6)..Point::new(0, 37),
|
Point::new(0, 6)..Point::new(0, 37),
|
||||||
Point::new(0, 45)..Point::new(0, 80)
|
Point::new(0, 44)..Point::new(0, 79)
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
@@ -1458,14 +1447,14 @@ mod tests {
|
|||||||
editor.update(&mut cx, |editor, cx| {
|
editor.update(&mut cx, |editor, cx| {
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
editor.text(cx),
|
editor.text(cx),
|
||||||
"Lorem [@one.txt](@file:dir/a/one.txt) Ipsum [@seven.txt](@file:dir/b/seven.txt) \n[@six.txt](@file:dir/b/six.txt) "
|
"Lorem [@one.txt](@file:dir/a/one.txt) Ipsum [@seven.txt](@file:dir/b/seven.txt)\n[@six.txt](@file:dir/b/six.txt)"
|
||||||
);
|
);
|
||||||
assert!(!editor.has_visible_completions_menu());
|
assert!(!editor.has_visible_completions_menu());
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
fold_ranges(editor, cx),
|
fold_ranges(editor, cx),
|
||||||
vec![
|
vec![
|
||||||
Point::new(0, 6)..Point::new(0, 37),
|
Point::new(0, 6)..Point::new(0, 37),
|
||||||
Point::new(0, 45)..Point::new(0, 80),
|
Point::new(0, 44)..Point::new(0, 79),
|
||||||
Point::new(1, 0)..Point::new(1, 31)
|
Point::new(1, 0)..Point::new(1, 31)
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -51,10 +51,6 @@ impl Tool for ContextServerTool {
|
|||||||
true
|
true
|
||||||
}
|
}
|
||||||
|
|
||||||
fn may_perform_edits(&self) -> bool {
|
|
||||||
true
|
|
||||||
}
|
|
||||||
|
|
||||||
fn input_schema(&self, format: LanguageModelToolSchemaFormat) -> Result<serde_json::Value> {
|
fn input_schema(&self, format: LanguageModelToolSchemaFormat) -> Result<serde_json::Value> {
|
||||||
let mut schema = self.tool.input_schema.clone();
|
let mut schema = self.tool.input_schema.clone();
|
||||||
assistant_tool::adapt_schema_to_format(&mut schema, format)?;
|
assistant_tool::adapt_schema_to_format(&mut schema, format)?;
|
||||||
|
|||||||
@@ -2,12 +2,12 @@ use std::ops::Range;
|
|||||||
use std::path::{Path, PathBuf};
|
use std::path::{Path, PathBuf};
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
|
||||||
use anyhow::{Context as _, Result, anyhow};
|
use anyhow::{Result, anyhow};
|
||||||
use assistant_context_editor::AssistantContext;
|
use assistant_context_editor::AssistantContext;
|
||||||
use collections::{HashSet, IndexSet};
|
use collections::{HashSet, IndexSet};
|
||||||
use futures::{self, FutureExt};
|
use futures::{self, FutureExt};
|
||||||
use gpui::{App, Context, Entity, EventEmitter, Image, SharedString, Task, WeakEntity};
|
use gpui::{App, Context, Entity, EventEmitter, Image, SharedString, Task, WeakEntity};
|
||||||
use language::{Buffer, File as _};
|
use language::Buffer;
|
||||||
use language_model::LanguageModelImage;
|
use language_model::LanguageModelImage;
|
||||||
use project::image_store::is_image_file;
|
use project::image_store::is_image_file;
|
||||||
use project::{Project, ProjectItem, ProjectPath, Symbol};
|
use project::{Project, ProjectItem, ProjectPath, Symbol};
|
||||||
@@ -58,10 +58,9 @@ impl ContextStore {
|
|||||||
self.context_set.iter().map(|entry| entry.as_ref())
|
self.context_set.iter().map(|entry| entry.as_ref())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn clear(&mut self, cx: &mut Context<Self>) {
|
pub fn clear(&mut self) {
|
||||||
self.context_set.clear();
|
self.context_set.clear();
|
||||||
self.context_thread_ids.clear();
|
self.context_thread_ids.clear();
|
||||||
cx.notify();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn new_context_for_thread(
|
pub fn new_context_for_thread(
|
||||||
@@ -143,12 +142,17 @@ impl ContextStore {
|
|||||||
remove_if_exists: bool,
|
remove_if_exists: bool,
|
||||||
cx: &mut Context<Self>,
|
cx: &mut Context<Self>,
|
||||||
) -> Result<Option<AgentContextHandle>> {
|
) -> Result<Option<AgentContextHandle>> {
|
||||||
let project = self.project.upgrade().context("failed to read project")?;
|
let Some(project) = self.project.upgrade() else {
|
||||||
let entry_id = project
|
return Err(anyhow!("failed to read project"));
|
||||||
|
};
|
||||||
|
|
||||||
|
let Some(entry_id) = project
|
||||||
.read(cx)
|
.read(cx)
|
||||||
.entry_for_path(project_path, cx)
|
.entry_for_path(project_path, cx)
|
||||||
.map(|entry| entry.id)
|
.map(|entry| entry.id)
|
||||||
.context("no entry found for directory context")?;
|
else {
|
||||||
|
return Err(anyhow!("no entry found for directory context"));
|
||||||
|
};
|
||||||
|
|
||||||
let context_id = self.next_context_id.post_inc();
|
let context_id = self.next_context_id.post_inc();
|
||||||
let context = AgentContextHandle::Directory(DirectoryContextHandle {
|
let context = AgentContextHandle::Directory(DirectoryContextHandle {
|
||||||
@@ -304,13 +308,11 @@ impl ContextStore {
|
|||||||
project.open_image(project_path.clone(), cx)
|
project.open_image(project_path.clone(), cx)
|
||||||
})?;
|
})?;
|
||||||
let image_item = open_image_task.await?;
|
let image_item = open_image_task.await?;
|
||||||
|
let image = image_item.read_with(cx, |image_item, _| image_item.image.clone())?;
|
||||||
this.update(cx, |this, cx| {
|
this.update(cx, |this, cx| {
|
||||||
let item = image_item.read(cx);
|
|
||||||
this.insert_image(
|
this.insert_image(
|
||||||
Some(item.project_path(cx)),
|
Some(image_item.read(cx).project_path(cx)),
|
||||||
Some(item.file.full_path(cx).into()),
|
image,
|
||||||
item.image.clone(),
|
|
||||||
remove_if_exists,
|
remove_if_exists,
|
||||||
cx,
|
cx,
|
||||||
)
|
)
|
||||||
@@ -319,13 +321,12 @@ impl ContextStore {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn add_image_instance(&mut self, image: Arc<Image>, cx: &mut Context<ContextStore>) {
|
pub fn add_image_instance(&mut self, image: Arc<Image>, cx: &mut Context<ContextStore>) {
|
||||||
self.insert_image(None, None, image, false, cx);
|
self.insert_image(None, image, false, cx);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn insert_image(
|
fn insert_image(
|
||||||
&mut self,
|
&mut self,
|
||||||
project_path: Option<ProjectPath>,
|
project_path: Option<ProjectPath>,
|
||||||
full_path: Option<Arc<Path>>,
|
|
||||||
image: Arc<Image>,
|
image: Arc<Image>,
|
||||||
remove_if_exists: bool,
|
remove_if_exists: bool,
|
||||||
cx: &mut Context<ContextStore>,
|
cx: &mut Context<ContextStore>,
|
||||||
@@ -333,7 +334,6 @@ impl ContextStore {
|
|||||||
let image_task = LanguageModelImage::from_image(image.clone(), cx).shared();
|
let image_task = LanguageModelImage::from_image(image.clone(), cx).shared();
|
||||||
let context = AgentContextHandle::Image(ImageContext {
|
let context = AgentContextHandle::Image(ImageContext {
|
||||||
project_path,
|
project_path,
|
||||||
full_path,
|
|
||||||
original_image: image,
|
original_image: image,
|
||||||
image_task,
|
image_task,
|
||||||
context_id: self.next_context_id.post_inc(),
|
context_id: self.next_context_id.post_inc(),
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ use crate::thread_store::{TextThreadStore, ThreadStore};
|
|||||||
use crate::ui::{AddedContext, ContextPill};
|
use crate::ui::{AddedContext, ContextPill};
|
||||||
use crate::{
|
use crate::{
|
||||||
AcceptSuggestedContext, AgentPanel, FocusDown, FocusLeft, FocusRight, FocusUp,
|
AcceptSuggestedContext, AgentPanel, FocusDown, FocusLeft, FocusRight, FocusUp,
|
||||||
ModelUsageContext, RemoveAllContext, RemoveFocusedContext, ToggleContextPicker,
|
RemoveAllContext, RemoveFocusedContext, ToggleContextPicker,
|
||||||
};
|
};
|
||||||
|
|
||||||
pub struct ContextStrip {
|
pub struct ContextStrip {
|
||||||
@@ -37,7 +37,6 @@ pub struct ContextStrip {
|
|||||||
_subscriptions: Vec<Subscription>,
|
_subscriptions: Vec<Subscription>,
|
||||||
focused_index: Option<usize>,
|
focused_index: Option<usize>,
|
||||||
children_bounds: Option<Vec<Bounds<Pixels>>>,
|
children_bounds: Option<Vec<Bounds<Pixels>>>,
|
||||||
model_usage_context: ModelUsageContext,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ContextStrip {
|
impl ContextStrip {
|
||||||
@@ -48,7 +47,6 @@ impl ContextStrip {
|
|||||||
text_thread_store: Option<WeakEntity<TextThreadStore>>,
|
text_thread_store: Option<WeakEntity<TextThreadStore>>,
|
||||||
context_picker_menu_handle: PopoverMenuHandle<ContextPicker>,
|
context_picker_menu_handle: PopoverMenuHandle<ContextPicker>,
|
||||||
suggest_context_kind: SuggestContextKind,
|
suggest_context_kind: SuggestContextKind,
|
||||||
model_usage_context: ModelUsageContext,
|
|
||||||
window: &mut Window,
|
window: &mut Window,
|
||||||
cx: &mut Context<Self>,
|
cx: &mut Context<Self>,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
@@ -83,16 +81,9 @@ impl ContextStrip {
|
|||||||
_subscriptions: subscriptions,
|
_subscriptions: subscriptions,
|
||||||
focused_index: None,
|
focused_index: None,
|
||||||
children_bounds: None,
|
children_bounds: None,
|
||||||
model_usage_context,
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Whether or not the context strip has items to display
|
|
||||||
pub fn has_context_items(&self, cx: &App) -> bool {
|
|
||||||
self.context_store.read(cx).context().next().is_some()
|
|
||||||
|| self.suggested_context(cx).is_some()
|
|
||||||
}
|
|
||||||
|
|
||||||
fn added_contexts(&self, cx: &App) -> Vec<AddedContext> {
|
fn added_contexts(&self, cx: &App) -> Vec<AddedContext> {
|
||||||
if let Some(workspace) = self.workspace.upgrade() {
|
if let Some(workspace) = self.workspace.upgrade() {
|
||||||
let project = workspace.read(cx).project().read(cx);
|
let project = workspace.read(cx).project().read(cx);
|
||||||
@@ -101,20 +92,11 @@ impl ContextStrip {
|
|||||||
.as_ref()
|
.as_ref()
|
||||||
.and_then(|thread_store| thread_store.upgrade())
|
.and_then(|thread_store| thread_store.upgrade())
|
||||||
.and_then(|thread_store| thread_store.read(cx).prompt_store().as_ref());
|
.and_then(|thread_store| thread_store.read(cx).prompt_store().as_ref());
|
||||||
|
|
||||||
let current_model = self.model_usage_context.language_model(cx);
|
|
||||||
|
|
||||||
self.context_store
|
self.context_store
|
||||||
.read(cx)
|
.read(cx)
|
||||||
.context()
|
.context()
|
||||||
.flat_map(|context| {
|
.flat_map(|context| {
|
||||||
AddedContext::new_pending(
|
AddedContext::new_pending(context.clone(), prompt_store, project, cx)
|
||||||
context.clone(),
|
|
||||||
prompt_store,
|
|
||||||
project,
|
|
||||||
current_model.as_ref(),
|
|
||||||
cx,
|
|
||||||
)
|
|
||||||
})
|
})
|
||||||
.collect::<Vec<_>>()
|
.collect::<Vec<_>>()
|
||||||
} else {
|
} else {
|
||||||
@@ -122,14 +104,14 @@ impl ContextStrip {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn suggested_context(&self, cx: &App) -> Option<SuggestedContext> {
|
fn suggested_context(&self, cx: &Context<Self>) -> Option<SuggestedContext> {
|
||||||
match self.suggest_context_kind {
|
match self.suggest_context_kind {
|
||||||
SuggestContextKind::File => self.suggested_file(cx),
|
SuggestContextKind::File => self.suggested_file(cx),
|
||||||
SuggestContextKind::Thread => self.suggested_thread(cx),
|
SuggestContextKind::Thread => self.suggested_thread(cx),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn suggested_file(&self, cx: &App) -> Option<SuggestedContext> {
|
fn suggested_file(&self, cx: &Context<Self>) -> Option<SuggestedContext> {
|
||||||
let workspace = self.workspace.upgrade()?;
|
let workspace = self.workspace.upgrade()?;
|
||||||
let active_item = workspace.read(cx).active_item(cx)?;
|
let active_item = workspace.read(cx).active_item(cx)?;
|
||||||
|
|
||||||
@@ -156,7 +138,7 @@ impl ContextStrip {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
fn suggested_thread(&self, cx: &App) -> Option<SuggestedContext> {
|
fn suggested_thread(&self, cx: &Context<Self>) -> Option<SuggestedContext> {
|
||||||
if !self.context_picker.read(cx).allow_threads() {
|
if !self.context_picker.read(cx).allow_threads() {
|
||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
@@ -178,7 +160,7 @@ impl ContextStrip {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Some(SuggestedContext::Thread {
|
Some(SuggestedContext::Thread {
|
||||||
name: active_thread.summary().or_default(),
|
name: active_thread.summary_or_default(),
|
||||||
thread: weak_active_thread,
|
thread: weak_active_thread,
|
||||||
})
|
})
|
||||||
} else if let Some(active_context_editor) = panel.active_context_editor() {
|
} else if let Some(active_context_editor) = panel.active_context_editor() {
|
||||||
@@ -192,7 +174,7 @@ impl ContextStrip {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Some(SuggestedContext::TextThread {
|
Some(SuggestedContext::TextThread {
|
||||||
name: context.summary().or_default(),
|
name: context.summary_or_default(),
|
||||||
context: weak_context,
|
context: weak_context,
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
@@ -438,25 +420,12 @@ impl Render for ContextStrip {
|
|||||||
})
|
})
|
||||||
.child(
|
.child(
|
||||||
PopoverMenu::new("context-picker")
|
PopoverMenu::new("context-picker")
|
||||||
.menu({
|
.menu(move |window, cx| {
|
||||||
let context_picker = context_picker.clone();
|
context_picker.update(cx, |this, cx| {
|
||||||
move |window, cx| {
|
this.init(window, cx);
|
||||||
context_picker.update(cx, |this, cx| {
|
});
|
||||||
this.init(window, cx);
|
|
||||||
});
|
|
||||||
|
|
||||||
Some(context_picker.clone())
|
Some(context_picker.clone())
|
||||||
}
|
|
||||||
})
|
|
||||||
.on_open({
|
|
||||||
let context_picker = context_picker.downgrade();
|
|
||||||
Rc::new(move |window, cx| {
|
|
||||||
context_picker
|
|
||||||
.update(cx, |context_picker, cx| {
|
|
||||||
context_picker.select_first(window, cx);
|
|
||||||
})
|
|
||||||
.ok();
|
|
||||||
})
|
|
||||||
})
|
})
|
||||||
.trigger_with_tooltip(
|
.trigger_with_tooltip(
|
||||||
IconButton::new("add-context", IconName::Plus)
|
IconButton::new("add-context", IconName::Plus)
|
||||||
|
|||||||
@@ -75,7 +75,7 @@ impl Default for DebugAccountState {
|
|||||||
Self {
|
Self {
|
||||||
enabled: false,
|
enabled: false,
|
||||||
trial_expired: false,
|
trial_expired: false,
|
||||||
plan: Plan::ZedFree,
|
plan: Plan::Free,
|
||||||
custom_prompt_usage: RequestUsage {
|
custom_prompt_usage: RequestUsage {
|
||||||
limit: UsageLimit::Unlimited,
|
limit: UsageLimit::Unlimited,
|
||||||
amount: 0,
|
amount: 0,
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
use std::{collections::VecDeque, path::Path, sync::Arc};
|
use std::{collections::VecDeque, path::Path};
|
||||||
|
|
||||||
use anyhow::Context as _;
|
use anyhow::{Context as _, anyhow};
|
||||||
use assistant_context_editor::{AssistantContext, SavedContextMetadata};
|
use assistant_context_editor::{AssistantContext, SavedContextMetadata};
|
||||||
use chrono::{DateTime, Utc};
|
use chrono::{DateTime, Utc};
|
||||||
use futures::future::{TryFutureExt as _, join_all};
|
use futures::future::{TryFutureExt as _, join_all};
|
||||||
@@ -34,20 +34,6 @@ impl HistoryEntry {
|
|||||||
HistoryEntry::Context(context) => context.mtime.to_utc(),
|
HistoryEntry::Context(context) => context.mtime.to_utc(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn id(&self) -> HistoryEntryId {
|
|
||||||
match self {
|
|
||||||
HistoryEntry::Thread(thread) => HistoryEntryId::Thread(thread.id.clone()),
|
|
||||||
HistoryEntry::Context(context) => HistoryEntryId::Context(context.path.clone()),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Generic identifier for a history entry.
|
|
||||||
#[derive(Clone, PartialEq, Eq)]
|
|
||||||
pub enum HistoryEntryId {
|
|
||||||
Thread(ThreadId),
|
|
||||||
Context(Arc<Path>),
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Debug)]
|
#[derive(Clone, Debug)]
|
||||||
@@ -71,8 +57,8 @@ impl Eq for RecentEntry {}
|
|||||||
impl RecentEntry {
|
impl RecentEntry {
|
||||||
pub(crate) fn summary(&self, cx: &App) -> SharedString {
|
pub(crate) fn summary(&self, cx: &App) -> SharedString {
|
||||||
match self {
|
match self {
|
||||||
RecentEntry::Thread(_, thread) => thread.read(cx).summary().or_default(),
|
RecentEntry::Thread(_, thread) => thread.read(cx).summary_or_default(),
|
||||||
RecentEntry::Context(context) => context.read(cx).summary().or_default(),
|
RecentEntry::Context(context) => context.read(cx).summary_or_default(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -130,10 +116,7 @@ impl HistoryStore {
|
|||||||
.boxed()
|
.boxed()
|
||||||
})
|
})
|
||||||
.unwrap_or_else(|_| {
|
.unwrap_or_else(|_| {
|
||||||
async {
|
async { Err(anyhow!("no thread store")) }.boxed()
|
||||||
anyhow::bail!("no thread store");
|
|
||||||
}
|
|
||||||
.boxed()
|
|
||||||
}),
|
}),
|
||||||
SerializedRecentEntry::Context(id) => context_store
|
SerializedRecentEntry::Context(id) => context_store
|
||||||
.update(cx, |context_store, cx| {
|
.update(cx, |context_store, cx| {
|
||||||
@@ -143,16 +126,13 @@ impl HistoryStore {
|
|||||||
.boxed()
|
.boxed()
|
||||||
})
|
})
|
||||||
.unwrap_or_else(|_| {
|
.unwrap_or_else(|_| {
|
||||||
async {
|
async { Err(anyhow!("no context store")) }.boxed()
|
||||||
anyhow::bail!("no context store");
|
|
||||||
}
|
|
||||||
.boxed()
|
|
||||||
}),
|
}),
|
||||||
});
|
});
|
||||||
let entries = join_all(entries)
|
let entries = join_all(entries)
|
||||||
.await
|
.await
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.filter_map(|result| result.log_with_level(log::Level::Debug))
|
.filter_map(|result| result.log_err())
|
||||||
.collect::<VecDeque<_>>();
|
.collect::<VecDeque<_>>();
|
||||||
|
|
||||||
this.update(cx, |this, _| {
|
this.update(cx, |this, _| {
|
||||||
|
|||||||
@@ -4,8 +4,8 @@ use std::ops::Range;
|
|||||||
use std::rc::Rc;
|
use std::rc::Rc;
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
|
||||||
use agent_settings::AgentSettings;
|
|
||||||
use anyhow::{Context as _, Result};
|
use anyhow::{Context as _, Result};
|
||||||
|
use assistant_settings::AssistantSettings;
|
||||||
use client::telemetry::Telemetry;
|
use client::telemetry::Telemetry;
|
||||||
use collections::{HashMap, HashSet, VecDeque, hash_map};
|
use collections::{HashMap, HashSet, VecDeque, hash_map};
|
||||||
use editor::display_map::EditorMargins;
|
use editor::display_map::EditorMargins;
|
||||||
@@ -134,7 +134,7 @@ impl InlineAssistant {
|
|||||||
let Some(terminal_panel) = workspace.read(cx).panel::<TerminalPanel>(cx) else {
|
let Some(terminal_panel) = workspace.read(cx).panel::<TerminalPanel>(cx) else {
|
||||||
return;
|
return;
|
||||||
};
|
};
|
||||||
let enabled = AgentSettings::get_global(cx).enabled;
|
let enabled = AssistantSettings::get_global(cx).enabled;
|
||||||
terminal_panel.update(cx, |terminal_panel, cx| {
|
terminal_panel.update(cx, |terminal_panel, cx| {
|
||||||
terminal_panel.set_assistant_enabled(enabled, cx)
|
terminal_panel.set_assistant_enabled(enabled, cx)
|
||||||
});
|
});
|
||||||
@@ -219,7 +219,7 @@ impl InlineAssistant {
|
|||||||
window: &mut Window,
|
window: &mut Window,
|
||||||
cx: &mut Context<Workspace>,
|
cx: &mut Context<Workspace>,
|
||||||
) {
|
) {
|
||||||
let settings = AgentSettings::get_global(cx);
|
let settings = AssistantSettings::get_global(cx);
|
||||||
if !settings.enabled {
|
if !settings.enabled {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -338,27 +338,13 @@ impl InlineAssistant {
|
|||||||
window: &mut Window,
|
window: &mut Window,
|
||||||
cx: &mut App,
|
cx: &mut App,
|
||||||
) {
|
) {
|
||||||
let (snapshot, initial_selections, newest_selection) = editor.update(cx, |editor, cx| {
|
let (snapshot, initial_selections) = editor.update(cx, |editor, cx| {
|
||||||
let selections = editor.selections.all::<Point>(cx);
|
(
|
||||||
let newest_selection = editor.selections.newest::<Point>(cx);
|
editor.snapshot(window, cx),
|
||||||
(editor.snapshot(window, cx), selections, newest_selection)
|
editor.selections.all::<Point>(cx),
|
||||||
|
)
|
||||||
});
|
});
|
||||||
|
|
||||||
// Check if there is already an inline assistant that contains the
|
|
||||||
// newest selection, if there is, focus it
|
|
||||||
if let Some(editor_assists) = self.assists_by_editor.get(&editor.downgrade()) {
|
|
||||||
for assist_id in &editor_assists.assist_ids {
|
|
||||||
let assist = &self.assists[assist_id];
|
|
||||||
let range = assist.range.to_point(&snapshot.buffer_snapshot);
|
|
||||||
if range.start.row <= newest_selection.start.row
|
|
||||||
&& newest_selection.end.row <= range.end.row
|
|
||||||
{
|
|
||||||
self.focus_assist(*assist_id, window, cx);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
let mut selections = Vec::<Selection<Point>>::new();
|
let mut selections = Vec::<Selection<Point>>::new();
|
||||||
let mut newest_selection = None;
|
let mut newest_selection = None;
|
||||||
for mut selection in initial_selections {
|
for mut selection in initial_selections {
|
||||||
@@ -1445,7 +1431,7 @@ impl InlineAssistant {
|
|||||||
style: BlockStyle::Flex,
|
style: BlockStyle::Flex,
|
||||||
render: Arc::new(move |cx| {
|
render: Arc::new(move |cx| {
|
||||||
div()
|
div()
|
||||||
.block_mouse_except_scroll()
|
.block_mouse_down()
|
||||||
.bg(cx.theme().status().deleted_background)
|
.bg(cx.theme().status().deleted_background)
|
||||||
.size_full()
|
.size_full()
|
||||||
.h(height as f32 * cx.window.line_height())
|
.h(height as f32 * cx.window.line_height())
|
||||||
@@ -1771,7 +1757,7 @@ impl CodeActionProvider for AssistantCodeActionProvider {
|
|||||||
_: &mut Window,
|
_: &mut Window,
|
||||||
cx: &mut App,
|
cx: &mut App,
|
||||||
) -> Task<Result<Vec<CodeAction>>> {
|
) -> Task<Result<Vec<CodeAction>>> {
|
||||||
if !AgentSettings::get_global(cx).enabled {
|
if !AssistantSettings::get_global(cx).enabled {
|
||||||
return Task::ready(Ok(Vec::new()));
|
return Task::ready(Ok(Vec::new()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
use crate::agent_model_selector::AgentModelSelector;
|
use crate::agent_model_selector::{AgentModelSelector, ModelType};
|
||||||
use crate::buffer_codegen::BufferCodegen;
|
use crate::buffer_codegen::BufferCodegen;
|
||||||
use crate::context::ContextCreasesAddon;
|
use crate::context::ContextCreasesAddon;
|
||||||
use crate::context_picker::{ContextPicker, ContextPickerCompletionProvider};
|
use crate::context_picker::{ContextPicker, ContextPickerCompletionProvider};
|
||||||
@@ -7,13 +7,10 @@ use crate::context_strip::{ContextStrip, ContextStripEvent, SuggestContextKind};
|
|||||||
use crate::message_editor::{extract_message_creases, insert_message_creases};
|
use crate::message_editor::{extract_message_creases, insert_message_creases};
|
||||||
use crate::terminal_codegen::TerminalCodegen;
|
use crate::terminal_codegen::TerminalCodegen;
|
||||||
use crate::thread_store::{TextThreadStore, ThreadStore};
|
use crate::thread_store::{TextThreadStore, ThreadStore};
|
||||||
use crate::{CycleNextInlineAssist, CyclePreviousInlineAssist, ModelUsageContext};
|
use crate::{CycleNextInlineAssist, CyclePreviousInlineAssist};
|
||||||
use crate::{RemoveAllContext, ToggleContextPicker};
|
use crate::{RemoveAllContext, ToggleContextPicker};
|
||||||
use assistant_context_editor::language_model_selector::ToggleModelSelector;
|
|
||||||
use client::ErrorExt;
|
use client::ErrorExt;
|
||||||
use collections::VecDeque;
|
use collections::VecDeque;
|
||||||
use db::kvp::Dismissable;
|
|
||||||
use editor::actions::Paste;
|
|
||||||
use editor::display_map::EditorMargins;
|
use editor::display_map::EditorMargins;
|
||||||
use editor::{
|
use editor::{
|
||||||
ContextMenuOptions, Editor, EditorElement, EditorEvent, EditorMode, EditorStyle, MultiBuffer,
|
ContextMenuOptions, Editor, EditorElement, EditorEvent, EditorMode, EditorStyle, MultiBuffer,
|
||||||
@@ -26,16 +23,17 @@ use gpui::{
|
|||||||
Focusable, FontWeight, Subscription, TextStyle, WeakEntity, Window, anchored, deferred, point,
|
Focusable, FontWeight, Subscription, TextStyle, WeakEntity, Window, anchored, deferred, point,
|
||||||
};
|
};
|
||||||
use language_model::{LanguageModel, LanguageModelRegistry};
|
use language_model::{LanguageModel, LanguageModelRegistry};
|
||||||
|
use language_model_selector::ToggleModelSelector;
|
||||||
use parking_lot::Mutex;
|
use parking_lot::Mutex;
|
||||||
use settings::Settings;
|
use settings::Settings;
|
||||||
use std::cmp;
|
use std::cmp;
|
||||||
use std::rc::Rc;
|
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
use theme::ThemeSettings;
|
use theme::ThemeSettings;
|
||||||
use ui::utils::WithRemSize;
|
use ui::utils::WithRemSize;
|
||||||
use ui::{
|
use ui::{
|
||||||
CheckboxWithLabel, IconButtonShape, KeyBinding, Popover, PopoverMenuHandle, Tooltip, prelude::*,
|
CheckboxWithLabel, IconButtonShape, KeyBinding, Popover, PopoverMenuHandle, Tooltip, prelude::*,
|
||||||
};
|
};
|
||||||
|
use util::ResultExt;
|
||||||
use workspace::Workspace;
|
use workspace::Workspace;
|
||||||
|
|
||||||
pub struct PromptEditor<T> {
|
pub struct PromptEditor<T> {
|
||||||
@@ -100,9 +98,8 @@ impl<T: 'static> Render for PromptEditor<T> {
|
|||||||
|
|
||||||
v_flex()
|
v_flex()
|
||||||
.key_context("PromptEditor")
|
.key_context("PromptEditor")
|
||||||
.capture_action(cx.listener(Self::paste))
|
|
||||||
.bg(cx.theme().colors().editor_background)
|
.bg(cx.theme().colors().editor_background)
|
||||||
.block_mouse_except_scroll()
|
.block_mouse_down()
|
||||||
.gap_0p5()
|
.gap_0p5()
|
||||||
.border_y_1()
|
.border_y_1()
|
||||||
.border_color(cx.theme().status().info_border)
|
.border_color(cx.theme().status().info_border)
|
||||||
@@ -305,10 +302,6 @@ impl<T: 'static> PromptEditor<T> {
|
|||||||
self.editor.read(cx).text(cx)
|
self.editor.read(cx).text(cx)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn paste(&mut self, _: &Paste, _window: &mut Window, cx: &mut Context<Self>) {
|
|
||||||
crate::active_thread::attach_pasted_images_as_context(&self.context_store, cx);
|
|
||||||
}
|
|
||||||
|
|
||||||
fn toggle_rate_limit_notice(
|
fn toggle_rate_limit_notice(
|
||||||
&mut self,
|
&mut self,
|
||||||
_: &ClickEvent,
|
_: &ClickEvent,
|
||||||
@@ -333,7 +326,9 @@ impl<T: 'static> PromptEditor<T> {
|
|||||||
EditorEvent::Edited { .. } => {
|
EditorEvent::Edited { .. } => {
|
||||||
if let Some(workspace) = window.root::<Workspace>().flatten() {
|
if let Some(workspace) = window.root::<Workspace>().flatten() {
|
||||||
workspace.update(cx, |workspace, cx| {
|
workspace.update(cx, |workspace, cx| {
|
||||||
let is_via_ssh = workspace.project().read(cx).is_via_ssh();
|
let is_via_ssh = workspace
|
||||||
|
.project()
|
||||||
|
.update(cx, |project, _| project.is_via_ssh());
|
||||||
|
|
||||||
workspace
|
workspace
|
||||||
.client()
|
.client()
|
||||||
@@ -378,7 +373,7 @@ impl<T: 'static> PromptEditor<T> {
|
|||||||
_window: &mut Window,
|
_window: &mut Window,
|
||||||
cx: &mut Context<Self>,
|
cx: &mut Context<Self>,
|
||||||
) {
|
) {
|
||||||
self.context_store.update(cx, |store, cx| store.clear(cx));
|
self.context_store.update(cx, |store, _cx| store.clear());
|
||||||
cx.notify();
|
cx.notify();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -456,7 +451,7 @@ impl<T: 'static> PromptEditor<T> {
|
|||||||
editor.move_to_end(&Default::default(), window, cx)
|
editor.move_to_end(&Default::default(), window, cx)
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
} else if self.context_strip.read(cx).has_context_items(cx) {
|
} else {
|
||||||
self.context_strip.focus_handle(cx).focus(window);
|
self.context_strip.focus_handle(cx).focus(window);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -727,7 +722,7 @@ impl<T: 'static> PromptEditor<T> {
|
|||||||
.child(CheckboxWithLabel::new(
|
.child(CheckboxWithLabel::new(
|
||||||
"dont-show-again",
|
"dont-show-again",
|
||||||
Label::new("Don't show again"),
|
Label::new("Don't show again"),
|
||||||
if RateLimitNotice::dismissed() {
|
if dismissed_rate_limit_notice() {
|
||||||
ui::ToggleState::Selected
|
ui::ToggleState::Selected
|
||||||
} else {
|
} else {
|
||||||
ui::ToggleState::Unselected
|
ui::ToggleState::Unselected
|
||||||
@@ -739,7 +734,7 @@ impl<T: 'static> PromptEditor<T> {
|
|||||||
ui::ToggleState::Selected => true,
|
ui::ToggleState::Selected => true,
|
||||||
};
|
};
|
||||||
|
|
||||||
RateLimitNotice::set_dismissed(is_dismissed, cx);
|
set_rate_limit_notice_dismissed(is_dismissed, cx)
|
||||||
},
|
},
|
||||||
))
|
))
|
||||||
.child(
|
.child(
|
||||||
@@ -897,7 +892,7 @@ impl PromptEditor<BufferCodegen> {
|
|||||||
|
|
||||||
let prompt_editor_entity = prompt_editor.downgrade();
|
let prompt_editor_entity = prompt_editor.downgrade();
|
||||||
prompt_editor.update(cx, |editor, _| {
|
prompt_editor.update(cx, |editor, _| {
|
||||||
editor.set_completion_provider(Some(Rc::new(ContextPickerCompletionProvider::new(
|
editor.set_completion_provider(Some(Box::new(ContextPickerCompletionProvider::new(
|
||||||
workspace.clone(),
|
workspace.clone(),
|
||||||
context_store.downgrade(),
|
context_store.downgrade(),
|
||||||
thread_store.clone(),
|
thread_store.clone(),
|
||||||
@@ -918,7 +913,6 @@ impl PromptEditor<BufferCodegen> {
|
|||||||
text_thread_store.clone(),
|
text_thread_store.clone(),
|
||||||
context_picker_menu_handle.clone(),
|
context_picker_menu_handle.clone(),
|
||||||
SuggestContextKind::Thread,
|
SuggestContextKind::Thread,
|
||||||
ModelUsageContext::InlineAssistant,
|
|
||||||
window,
|
window,
|
||||||
cx,
|
cx,
|
||||||
)
|
)
|
||||||
@@ -937,7 +931,7 @@ impl PromptEditor<BufferCodegen> {
|
|||||||
fs,
|
fs,
|
||||||
model_selector_menu_handle,
|
model_selector_menu_handle,
|
||||||
prompt_editor.focus_handle(cx),
|
prompt_editor.focus_handle(cx),
|
||||||
ModelUsageContext::InlineAssistant,
|
ModelType::InlineAssistant,
|
||||||
window,
|
window,
|
||||||
cx,
|
cx,
|
||||||
)
|
)
|
||||||
@@ -980,7 +974,7 @@ impl PromptEditor<BufferCodegen> {
|
|||||||
CodegenStatus::Error(error) => {
|
CodegenStatus::Error(error) => {
|
||||||
if cx.has_flag::<ZedProFeatureFlag>()
|
if cx.has_flag::<ZedProFeatureFlag>()
|
||||||
&& error.error_code() == proto::ErrorCode::RateLimitExceeded
|
&& error.error_code() == proto::ErrorCode::RateLimitExceeded
|
||||||
&& !RateLimitNotice::dismissed()
|
&& !dismissed_rate_limit_notice()
|
||||||
{
|
{
|
||||||
self.show_rate_limit_notice = true;
|
self.show_rate_limit_notice = true;
|
||||||
cx.notify();
|
cx.notify();
|
||||||
@@ -1069,7 +1063,7 @@ impl PromptEditor<TerminalCodegen> {
|
|||||||
|
|
||||||
let prompt_editor_entity = prompt_editor.downgrade();
|
let prompt_editor_entity = prompt_editor.downgrade();
|
||||||
prompt_editor.update(cx, |editor, _| {
|
prompt_editor.update(cx, |editor, _| {
|
||||||
editor.set_completion_provider(Some(Rc::new(ContextPickerCompletionProvider::new(
|
editor.set_completion_provider(Some(Box::new(ContextPickerCompletionProvider::new(
|
||||||
workspace.clone(),
|
workspace.clone(),
|
||||||
context_store.downgrade(),
|
context_store.downgrade(),
|
||||||
thread_store.clone(),
|
thread_store.clone(),
|
||||||
@@ -1090,7 +1084,6 @@ impl PromptEditor<TerminalCodegen> {
|
|||||||
text_thread_store.clone(),
|
text_thread_store.clone(),
|
||||||
context_picker_menu_handle.clone(),
|
context_picker_menu_handle.clone(),
|
||||||
SuggestContextKind::Thread,
|
SuggestContextKind::Thread,
|
||||||
ModelUsageContext::InlineAssistant,
|
|
||||||
window,
|
window,
|
||||||
cx,
|
cx,
|
||||||
)
|
)
|
||||||
@@ -1109,7 +1102,7 @@ impl PromptEditor<TerminalCodegen> {
|
|||||||
fs,
|
fs,
|
||||||
model_selector_menu_handle.clone(),
|
model_selector_menu_handle.clone(),
|
||||||
prompt_editor.focus_handle(cx),
|
prompt_editor.focus_handle(cx),
|
||||||
ModelUsageContext::InlineAssistant,
|
ModelType::InlineAssistant,
|
||||||
window,
|
window,
|
||||||
cx,
|
cx,
|
||||||
)
|
)
|
||||||
@@ -1187,10 +1180,27 @@ impl PromptEditor<TerminalCodegen> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
struct RateLimitNotice;
|
const DISMISSED_RATE_LIMIT_NOTICE_KEY: &str = "dismissed-rate-limit-notice";
|
||||||
|
|
||||||
impl Dismissable for RateLimitNotice {
|
fn dismissed_rate_limit_notice() -> bool {
|
||||||
const KEY: &'static str = "dismissed-rate-limit-notice";
|
db::kvp::KEY_VALUE_STORE
|
||||||
|
.read_kvp(DISMISSED_RATE_LIMIT_NOTICE_KEY)
|
||||||
|
.log_err()
|
||||||
|
.map_or(false, |s| s.is_some())
|
||||||
|
}
|
||||||
|
|
||||||
|
fn set_rate_limit_notice_dismissed(is_dismissed: bool, cx: &mut App) {
|
||||||
|
db::write_and_log(cx, move || async move {
|
||||||
|
if is_dismissed {
|
||||||
|
db::kvp::KEY_VALUE_STORE
|
||||||
|
.write_kvp(DISMISSED_RATE_LIMIT_NOTICE_KEY.into(), "1".into())
|
||||||
|
.await
|
||||||
|
} else {
|
||||||
|
db::kvp::KEY_VALUE_STORE
|
||||||
|
.delete_kvp(DISMISSED_RATE_LIMIT_NOTICE_KEY.into())
|
||||||
|
.await
|
||||||
|
}
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
pub enum CodegenStatus {
|
pub enum CodegenStatus {
|
||||||
|
|||||||
@@ -1,16 +1,14 @@
|
|||||||
use std::collections::BTreeMap;
|
use std::collections::BTreeMap;
|
||||||
use std::rc::Rc;
|
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
|
||||||
use crate::agent_model_selector::AgentModelSelector;
|
use crate::agent_model_selector::{AgentModelSelector, ModelType};
|
||||||
use crate::context::{AgentContextKey, ContextCreasesAddon, ContextLoadResult, load_context};
|
use crate::context::{AgentContextKey, ContextCreasesAddon, ContextLoadResult, load_context};
|
||||||
use crate::tool_compatibility::{IncompatibleToolsState, IncompatibleToolsTooltip};
|
use crate::tool_compatibility::{IncompatibleToolsState, IncompatibleToolsTooltip};
|
||||||
use crate::ui::{
|
use crate::ui::{
|
||||||
MaxModeTooltip,
|
AnimatedLabel, MaxModeTooltip,
|
||||||
preview::{AgentPreview, UsageCallout},
|
preview::{AgentPreview, UsageCallout},
|
||||||
};
|
};
|
||||||
use agent_settings::{AgentSettings, CompletionMode};
|
use assistant_settings::{AssistantSettings, CompletionMode};
|
||||||
use assistant_context_editor::language_model_selector::ToggleModelSelector;
|
|
||||||
use buffer_diff::BufferDiff;
|
use buffer_diff::BufferDiff;
|
||||||
use client::UserStore;
|
use client::UserStore;
|
||||||
use collections::{HashMap, HashSet};
|
use collections::{HashMap, HashSet};
|
||||||
@@ -24,14 +22,15 @@ use fs::Fs;
|
|||||||
use futures::future::Shared;
|
use futures::future::Shared;
|
||||||
use futures::{FutureExt as _, future};
|
use futures::{FutureExt as _, future};
|
||||||
use gpui::{
|
use gpui::{
|
||||||
Animation, AnimationExt, App, Entity, EventEmitter, Focusable, Subscription, Task, TextStyle,
|
Animation, AnimationExt, App, ClipboardEntry, Entity, EventEmitter, Focusable, Subscription,
|
||||||
WeakEntity, linear_color_stop, linear_gradient, point, pulsating_between,
|
Task, TextStyle, WeakEntity, linear_color_stop, linear_gradient, point, pulsating_between,
|
||||||
};
|
};
|
||||||
use language::{Buffer, Language, Point};
|
use language::{Buffer, Language};
|
||||||
use language_model::{
|
use language_model::{
|
||||||
ConfiguredModel, LanguageModelRequestMessage, MessageContent, RequestUsage,
|
ConfiguredModel, LanguageModelRequestMessage, MessageContent, RequestUsage,
|
||||||
ZED_CLOUD_PROVIDER_ID,
|
ZED_CLOUD_PROVIDER_ID,
|
||||||
};
|
};
|
||||||
|
use language_model_selector::ToggleModelSelector;
|
||||||
use multi_buffer;
|
use multi_buffer;
|
||||||
use project::Project;
|
use project::Project;
|
||||||
use prompt_store::PromptStore;
|
use prompt_store::PromptStore;
|
||||||
@@ -42,7 +41,6 @@ use theme::ThemeSettings;
|
|||||||
use ui::{Disclosure, KeyBinding, PopoverMenuHandle, Tooltip, prelude::*};
|
use ui::{Disclosure, KeyBinding, PopoverMenuHandle, Tooltip, prelude::*};
|
||||||
use util::{ResultExt as _, maybe};
|
use util::{ResultExt as _, maybe};
|
||||||
use workspace::{CollaboratorId, Workspace};
|
use workspace::{CollaboratorId, Workspace};
|
||||||
use zed_llm_client::CompletionIntent;
|
|
||||||
|
|
||||||
use crate::context_picker::{ContextPicker, ContextPickerCompletionProvider, crease_for_mention};
|
use crate::context_picker::{ContextPicker, ContextPickerCompletionProvider, crease_for_mention};
|
||||||
use crate::context_store::ContextStore;
|
use crate::context_store::ContextStore;
|
||||||
@@ -51,9 +49,8 @@ use crate::profile_selector::ProfileSelector;
|
|||||||
use crate::thread::{MessageCrease, Thread, TokenUsageRatio};
|
use crate::thread::{MessageCrease, Thread, TokenUsageRatio};
|
||||||
use crate::thread_store::{TextThreadStore, ThreadStore};
|
use crate::thread_store::{TextThreadStore, ThreadStore};
|
||||||
use crate::{
|
use crate::{
|
||||||
ActiveThread, AgentDiffPane, Chat, ChatWithFollow, ExpandMessageEditor, Follow, KeepAll,
|
ActiveThread, AgentDiffPane, Chat, ExpandMessageEditor, Follow, NewThread, OpenAgentDiff,
|
||||||
ModelUsageContext, NewThread, OpenAgentDiff, RejectAll, RemoveAllContext, ToggleBurnMode,
|
RemoveAllContext, ToggleContextPicker, ToggleProfileSelector, register_agent_preview,
|
||||||
ToggleContextPicker, ToggleProfileSelector, register_agent_preview,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#[derive(RegisterComponent)]
|
#[derive(RegisterComponent)]
|
||||||
@@ -112,7 +109,6 @@ pub(crate) fn create_editor(
|
|||||||
editor.set_placeholder_text("Message the agent – @ to include context", cx);
|
editor.set_placeholder_text("Message the agent – @ to include context", cx);
|
||||||
editor.set_show_indent_guides(false, cx);
|
editor.set_show_indent_guides(false, cx);
|
||||||
editor.set_soft_wrap();
|
editor.set_soft_wrap();
|
||||||
editor.set_use_modal_editing(true);
|
|
||||||
editor.set_context_menu_options(ContextMenuOptions {
|
editor.set_context_menu_options(ContextMenuOptions {
|
||||||
min_entries_visible: 12,
|
min_entries_visible: 12,
|
||||||
max_entries_visible: 12,
|
max_entries_visible: 12,
|
||||||
@@ -124,7 +120,7 @@ pub(crate) fn create_editor(
|
|||||||
|
|
||||||
let editor_entity = editor.downgrade();
|
let editor_entity = editor.downgrade();
|
||||||
editor.update(cx, |editor, _| {
|
editor.update(cx, |editor, _| {
|
||||||
editor.set_completion_provider(Some(Rc::new(ContextPickerCompletionProvider::new(
|
editor.set_completion_provider(Some(Box::new(ContextPickerCompletionProvider::new(
|
||||||
workspace,
|
workspace,
|
||||||
context_store,
|
context_store,
|
||||||
Some(thread_store),
|
Some(thread_store),
|
||||||
@@ -169,7 +165,6 @@ impl MessageEditor {
|
|||||||
Some(text_thread_store.clone()),
|
Some(text_thread_store.clone()),
|
||||||
context_picker_menu_handle.clone(),
|
context_picker_menu_handle.clone(),
|
||||||
SuggestContextKind::File,
|
SuggestContextKind::File,
|
||||||
ModelUsageContext::Thread(thread.clone()),
|
|
||||||
window,
|
window,
|
||||||
cx,
|
cx,
|
||||||
)
|
)
|
||||||
@@ -198,20 +193,14 @@ impl MessageEditor {
|
|||||||
fs.clone(),
|
fs.clone(),
|
||||||
model_selector_menu_handle,
|
model_selector_menu_handle,
|
||||||
editor.focus_handle(cx),
|
editor.focus_handle(cx),
|
||||||
ModelUsageContext::Thread(thread.clone()),
|
ModelType::Default(thread.clone()),
|
||||||
window,
|
window,
|
||||||
cx,
|
cx,
|
||||||
)
|
)
|
||||||
});
|
});
|
||||||
|
|
||||||
let profile_selector = cx.new(|cx| {
|
let profile_selector = cx.new(|cx| {
|
||||||
ProfileSelector::new(
|
ProfileSelector::new(thread.clone(), thread_store, editor.focus_handle(cx), cx)
|
||||||
fs,
|
|
||||||
thread.clone(),
|
|
||||||
thread_store,
|
|
||||||
editor.focus_handle(cx),
|
|
||||||
cx,
|
|
||||||
)
|
|
||||||
});
|
});
|
||||||
|
|
||||||
Self {
|
Self {
|
||||||
@@ -283,7 +272,7 @@ impl MessageEditor {
|
|||||||
_window: &mut Window,
|
_window: &mut Window,
|
||||||
cx: &mut Context<Self>,
|
cx: &mut Context<Self>,
|
||||||
) {
|
) {
|
||||||
self.context_store.update(cx, |store, cx| store.clear(cx));
|
self.context_store.update(cx, |store, _cx| store.clear());
|
||||||
cx.notify();
|
cx.notify();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -307,21 +296,6 @@ impl MessageEditor {
|
|||||||
cx.notify();
|
cx.notify();
|
||||||
}
|
}
|
||||||
|
|
||||||
fn chat_with_follow(
|
|
||||||
&mut self,
|
|
||||||
_: &ChatWithFollow,
|
|
||||||
window: &mut Window,
|
|
||||||
cx: &mut Context<Self>,
|
|
||||||
) {
|
|
||||||
self.workspace
|
|
||||||
.update(cx, |this, cx| {
|
|
||||||
this.follow(CollaboratorId::Agent, window, cx)
|
|
||||||
})
|
|
||||||
.log_err();
|
|
||||||
|
|
||||||
self.chat(&Chat, window, cx);
|
|
||||||
}
|
|
||||||
|
|
||||||
fn is_editor_empty(&self, cx: &App) -> bool {
|
fn is_editor_empty(&self, cx: &App) -> bool {
|
||||||
self.editor.read(cx).text(cx).trim().is_empty()
|
self.editor.read(cx).text(cx).trim().is_empty()
|
||||||
}
|
}
|
||||||
@@ -378,12 +352,7 @@ impl MessageEditor {
|
|||||||
thread
|
thread
|
||||||
.update(cx, |thread, cx| {
|
.update(cx, |thread, cx| {
|
||||||
thread.advance_prompt_id();
|
thread.advance_prompt_id();
|
||||||
thread.send_to_model(
|
thread.send_to_model(model, Some(window_handle), cx);
|
||||||
model,
|
|
||||||
CompletionIntent::UserPrompt,
|
|
||||||
Some(window_handle),
|
|
||||||
cx,
|
|
||||||
);
|
|
||||||
})
|
})
|
||||||
.log_err();
|
.log_err();
|
||||||
})
|
})
|
||||||
@@ -426,30 +395,45 @@ impl MessageEditor {
|
|||||||
fn move_up(&mut self, _: &MoveUp, window: &mut Window, cx: &mut Context<Self>) {
|
fn move_up(&mut self, _: &MoveUp, window: &mut Window, cx: &mut Context<Self>) {
|
||||||
if self.context_picker_menu_handle.is_deployed() {
|
if self.context_picker_menu_handle.is_deployed() {
|
||||||
cx.propagate();
|
cx.propagate();
|
||||||
} else if self.context_strip.read(cx).has_context_items(cx) {
|
} else {
|
||||||
self.context_strip.focus_handle(cx).focus(window);
|
self.context_strip.focus_handle(cx).focus(window);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn paste(&mut self, _: &Paste, _: &mut Window, cx: &mut Context<Self>) {
|
fn paste(&mut self, _: &Paste, _: &mut Window, cx: &mut Context<Self>) {
|
||||||
crate::active_thread::attach_pasted_images_as_context(&self.context_store, cx);
|
let images = cx
|
||||||
|
.read_from_clipboard()
|
||||||
|
.map(|item| {
|
||||||
|
item.into_entries()
|
||||||
|
.filter_map(|entry| {
|
||||||
|
if let ClipboardEntry::Image(image) = entry {
|
||||||
|
Some(image)
|
||||||
|
} else {
|
||||||
|
None
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.collect::<Vec<_>>()
|
||||||
|
})
|
||||||
|
.unwrap_or_default();
|
||||||
|
|
||||||
|
if images.is_empty() {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
cx.stop_propagation();
|
||||||
|
|
||||||
|
self.context_store.update(cx, |store, cx| {
|
||||||
|
for image in images {
|
||||||
|
store.add_image_instance(Arc::new(image), cx);
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
fn handle_review_click(&mut self, window: &mut Window, cx: &mut Context<Self>) {
|
fn handle_review_click(&mut self, window: &mut Window, cx: &mut Context<Self>) {
|
||||||
if self.thread.read(cx).has_pending_edit_tool_uses() {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
self.edits_expanded = true;
|
self.edits_expanded = true;
|
||||||
AgentDiffPane::deploy(self.thread.clone(), self.workspace.clone(), window, cx).log_err();
|
AgentDiffPane::deploy(self.thread.clone(), self.workspace.clone(), window, cx).log_err();
|
||||||
cx.notify();
|
cx.notify();
|
||||||
}
|
}
|
||||||
|
|
||||||
fn handle_edit_bar_expand(&mut self, cx: &mut Context<Self>) {
|
|
||||||
self.edits_expanded = !self.edits_expanded;
|
|
||||||
cx.notify();
|
|
||||||
}
|
|
||||||
|
|
||||||
fn handle_file_click(
|
fn handle_file_click(
|
||||||
&self,
|
&self,
|
||||||
buffer: Entity<Buffer>,
|
buffer: Entity<Buffer>,
|
||||||
@@ -464,56 +448,6 @@ impl MessageEditor {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn toggle_burn_mode(
|
|
||||||
&mut self,
|
|
||||||
_: &ToggleBurnMode,
|
|
||||||
_window: &mut Window,
|
|
||||||
cx: &mut Context<Self>,
|
|
||||||
) {
|
|
||||||
self.thread.update(cx, |thread, _cx| {
|
|
||||||
let active_completion_mode = thread.completion_mode();
|
|
||||||
|
|
||||||
thread.set_completion_mode(match active_completion_mode {
|
|
||||||
CompletionMode::Burn => CompletionMode::Normal,
|
|
||||||
CompletionMode::Normal => CompletionMode::Burn,
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
fn handle_accept_all(&mut self, _window: &mut Window, cx: &mut Context<Self>) {
|
|
||||||
if self.thread.read(cx).has_pending_edit_tool_uses() {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
self.thread.update(cx, |thread, cx| {
|
|
||||||
thread.keep_all_edits(cx);
|
|
||||||
});
|
|
||||||
cx.notify();
|
|
||||||
}
|
|
||||||
|
|
||||||
fn handle_reject_all(&mut self, _window: &mut Window, cx: &mut Context<Self>) {
|
|
||||||
if self.thread.read(cx).has_pending_edit_tool_uses() {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Since there's no reject_all_edits method in the thread API,
|
|
||||||
// we need to iterate through all buffers and reject their edits
|
|
||||||
let action_log = self.thread.read(cx).action_log().clone();
|
|
||||||
let changed_buffers = action_log.read(cx).changed_buffers(cx);
|
|
||||||
|
|
||||||
for (buffer, _) in changed_buffers {
|
|
||||||
self.thread.update(cx, |thread, cx| {
|
|
||||||
let buffer_snapshot = buffer.read(cx);
|
|
||||||
let start = buffer_snapshot.anchor_before(Point::new(0, 0));
|
|
||||||
let end = buffer_snapshot.anchor_after(buffer_snapshot.max_point());
|
|
||||||
thread
|
|
||||||
.reject_edits_in_ranges(buffer, vec![start..end], cx)
|
|
||||||
.detach();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
cx.notify();
|
|
||||||
}
|
|
||||||
|
|
||||||
fn render_max_mode_toggle(&self, cx: &mut Context<Self>) -> Option<AnyElement> {
|
fn render_max_mode_toggle(&self, cx: &mut Context<Self>) -> Option<AnyElement> {
|
||||||
let thread = self.thread.read(cx);
|
let thread = self.thread.read(cx);
|
||||||
let model = thread.configured_model();
|
let model = thread.configured_model();
|
||||||
@@ -522,24 +456,27 @@ impl MessageEditor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
let active_completion_mode = thread.completion_mode();
|
let active_completion_mode = thread.completion_mode();
|
||||||
let burn_mode_enabled = active_completion_mode == CompletionMode::Burn;
|
let max_mode_enabled = active_completion_mode == CompletionMode::Max;
|
||||||
let icon = if burn_mode_enabled {
|
|
||||||
IconName::ZedBurnModeOn
|
|
||||||
} else {
|
|
||||||
IconName::ZedBurnMode
|
|
||||||
};
|
|
||||||
|
|
||||||
Some(
|
Some(
|
||||||
IconButton::new("burn-mode", icon)
|
Button::new("max-mode", "Max Mode")
|
||||||
|
.label_size(LabelSize::Small)
|
||||||
|
.color(Color::Muted)
|
||||||
|
.icon(IconName::ZedMaxMode)
|
||||||
.icon_size(IconSize::Small)
|
.icon_size(IconSize::Small)
|
||||||
.icon_color(Color::Muted)
|
.icon_color(Color::Muted)
|
||||||
.toggle_state(burn_mode_enabled)
|
.icon_position(IconPosition::Start)
|
||||||
.selected_icon_color(Color::Error)
|
.toggle_state(max_mode_enabled)
|
||||||
.on_click(cx.listener(|this, _event, window, cx| {
|
.on_click(cx.listener(move |this, _event, _window, cx| {
|
||||||
this.toggle_burn_mode(&ToggleBurnMode, window, cx);
|
this.thread.update(cx, |thread, _cx| {
|
||||||
|
thread.set_completion_mode(match active_completion_mode {
|
||||||
|
CompletionMode::Max => CompletionMode::Normal,
|
||||||
|
CompletionMode::Normal => CompletionMode::Max,
|
||||||
|
});
|
||||||
|
});
|
||||||
}))
|
}))
|
||||||
.tooltip(move |_window, cx| {
|
.tooltip(move |_window, cx| {
|
||||||
cx.new(|_| MaxModeTooltip::new().selected(burn_mode_enabled))
|
cx.new(|_| MaxModeTooltip::new().selected(max_mode_enabled))
|
||||||
.into()
|
.into()
|
||||||
})
|
})
|
||||||
.into_any_element(),
|
.into_any_element(),
|
||||||
@@ -619,7 +556,6 @@ impl MessageEditor {
|
|||||||
v_flex()
|
v_flex()
|
||||||
.key_context("MessageEditor")
|
.key_context("MessageEditor")
|
||||||
.on_action(cx.listener(Self::chat))
|
.on_action(cx.listener(Self::chat))
|
||||||
.on_action(cx.listener(Self::chat_with_follow))
|
|
||||||
.on_action(cx.listener(|this, _: &ToggleProfileSelector, window, cx| {
|
.on_action(cx.listener(|this, _: &ToggleProfileSelector, window, cx| {
|
||||||
this.profile_selector
|
this.profile_selector
|
||||||
.read(cx)
|
.read(cx)
|
||||||
@@ -634,13 +570,6 @@ impl MessageEditor {
|
|||||||
.on_action(cx.listener(Self::remove_all_context))
|
.on_action(cx.listener(Self::remove_all_context))
|
||||||
.on_action(cx.listener(Self::move_up))
|
.on_action(cx.listener(Self::move_up))
|
||||||
.on_action(cx.listener(Self::expand_message_editor))
|
.on_action(cx.listener(Self::expand_message_editor))
|
||||||
.on_action(cx.listener(Self::toggle_burn_mode))
|
|
||||||
.on_action(
|
|
||||||
cx.listener(|this, _: &KeepAll, window, cx| this.handle_accept_all(window, cx)),
|
|
||||||
)
|
|
||||||
.on_action(
|
|
||||||
cx.listener(|this, _: &RejectAll, window, cx| this.handle_reject_all(window, cx)),
|
|
||||||
)
|
|
||||||
.capture_action(cx.listener(Self::paste))
|
.capture_action(cx.listener(Self::paste))
|
||||||
.gap_2()
|
.gap_2()
|
||||||
.p_2()
|
.p_2()
|
||||||
@@ -733,6 +662,7 @@ impl MessageEditor {
|
|||||||
.justify_between()
|
.justify_between()
|
||||||
.child(
|
.child(
|
||||||
h_flex()
|
h_flex()
|
||||||
|
.gap_1()
|
||||||
.child(self.render_follow_toggle(cx))
|
.child(self.render_follow_toggle(cx))
|
||||||
.children(self.render_max_mode_toggle(cx)),
|
.children(self.render_max_mode_toggle(cx)),
|
||||||
)
|
)
|
||||||
@@ -896,10 +826,7 @@ impl MessageEditor {
|
|||||||
let bg_edit_files_disclosure = editor_bg_color.blend(active_color.opacity(0.3));
|
let bg_edit_files_disclosure = editor_bg_color.blend(active_color.opacity(0.3));
|
||||||
|
|
||||||
let is_edit_changes_expanded = self.edits_expanded;
|
let is_edit_changes_expanded = self.edits_expanded;
|
||||||
let thread = self.thread.read(cx);
|
let is_generating = self.thread.read(cx).is_generating();
|
||||||
let pending_edits = thread.has_pending_edit_tool_uses();
|
|
||||||
|
|
||||||
const EDIT_NOT_READY_TOOLTIP_LABEL: &str = "Wait until file edits are complete.";
|
|
||||||
|
|
||||||
v_flex()
|
v_flex()
|
||||||
.mt_1()
|
.mt_1()
|
||||||
@@ -909,7 +836,7 @@ impl MessageEditor {
|
|||||||
.border_b_0()
|
.border_b_0()
|
||||||
.border_color(border_color)
|
.border_color(border_color)
|
||||||
.rounded_t_md()
|
.rounded_t_md()
|
||||||
.shadow(vec![gpui::BoxShadow {
|
.shadow(smallvec::smallvec![gpui::BoxShadow {
|
||||||
color: gpui::black().opacity(0.15),
|
color: gpui::black().opacity(0.15),
|
||||||
offset: point(px(1.), px(-1.)),
|
offset: point(px(1.), px(-1.)),
|
||||||
blur_radius: px(3.),
|
blur_radius: px(3.),
|
||||||
@@ -917,28 +844,31 @@ impl MessageEditor {
|
|||||||
}])
|
}])
|
||||||
.child(
|
.child(
|
||||||
h_flex()
|
h_flex()
|
||||||
.p_1()
|
.id("edits-container")
|
||||||
|
.cursor_pointer()
|
||||||
|
.p_1p5()
|
||||||
.justify_between()
|
.justify_between()
|
||||||
.when(is_edit_changes_expanded, |this| {
|
.when(is_edit_changes_expanded, |this| {
|
||||||
this.border_b_1().border_color(border_color)
|
this.border_b_1().border_color(border_color)
|
||||||
})
|
})
|
||||||
|
.on_click(
|
||||||
|
cx.listener(|this, _, window, cx| this.handle_review_click(window, cx)),
|
||||||
|
)
|
||||||
.child(
|
.child(
|
||||||
h_flex()
|
h_flex()
|
||||||
.id("edits-container")
|
|
||||||
.cursor_pointer()
|
|
||||||
.w_full()
|
|
||||||
.gap_1()
|
.gap_1()
|
||||||
.child(
|
.child(
|
||||||
Disclosure::new("edits-disclosure", is_edit_changes_expanded)
|
Disclosure::new("edits-disclosure", is_edit_changes_expanded)
|
||||||
.on_click(cx.listener(|this, _, _, cx| {
|
.on_click(cx.listener(|this, _ev, _window, cx| {
|
||||||
this.handle_edit_bar_expand(cx)
|
this.edits_expanded = !this.edits_expanded;
|
||||||
|
cx.notify();
|
||||||
})),
|
})),
|
||||||
)
|
)
|
||||||
.map(|this| {
|
.map(|this| {
|
||||||
if pending_edits {
|
if is_generating {
|
||||||
this.child(
|
this.child(
|
||||||
Label::new(format!(
|
AnimatedLabel::new(format!(
|
||||||
"Editing {} {}…",
|
"Editing {} {}",
|
||||||
changed_buffers.len(),
|
changed_buffers.len(),
|
||||||
if changed_buffers.len() == 1 {
|
if changed_buffers.len() == 1 {
|
||||||
"file"
|
"file"
|
||||||
@@ -946,15 +876,7 @@ impl MessageEditor {
|
|||||||
"files"
|
"files"
|
||||||
}
|
}
|
||||||
))
|
))
|
||||||
.color(Color::Muted)
|
.size(LabelSize::Small),
|
||||||
.size(LabelSize::Small)
|
|
||||||
.with_animation(
|
|
||||||
"edit-label",
|
|
||||||
Animation::new(Duration::from_secs(2))
|
|
||||||
.repeat()
|
|
||||||
.with_easing(pulsating_between(0.3, 0.7)),
|
|
||||||
|label, delta| label.alpha(delta),
|
|
||||||
),
|
|
||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
this.child(
|
this.child(
|
||||||
@@ -979,74 +901,23 @@ impl MessageEditor {
|
|||||||
.color(Color::Muted),
|
.color(Color::Muted),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
})
|
}),
|
||||||
.on_click(
|
|
||||||
cx.listener(|this, _, _, cx| this.handle_edit_bar_expand(cx)),
|
|
||||||
),
|
|
||||||
)
|
)
|
||||||
.child(
|
.child(
|
||||||
h_flex()
|
Button::new("review", "Review Changes")
|
||||||
.gap_1()
|
.label_size(LabelSize::Small)
|
||||||
.child(
|
.key_binding(
|
||||||
IconButton::new("review-changes", IconName::ListTodo)
|
KeyBinding::for_action_in(
|
||||||
.icon_size(IconSize::Small)
|
&OpenAgentDiff,
|
||||||
.tooltip({
|
&focus_handle,
|
||||||
let focus_handle = focus_handle.clone();
|
window,
|
||||||
move |window, cx| {
|
cx,
|
||||||
Tooltip::for_action_in(
|
)
|
||||||
"Review Changes",
|
.map(|kb| kb.size(rems_from_px(12.))),
|
||||||
&OpenAgentDiff,
|
|
||||||
&focus_handle,
|
|
||||||
window,
|
|
||||||
cx,
|
|
||||||
)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
.on_click(cx.listener(|this, _, window, cx| {
|
|
||||||
this.handle_review_click(window, cx)
|
|
||||||
})),
|
|
||||||
)
|
)
|
||||||
.child(ui::Divider::vertical().color(ui::DividerColor::Border))
|
.on_click(cx.listener(|this, _, window, cx| {
|
||||||
.child(
|
this.handle_review_click(window, cx)
|
||||||
Button::new("reject-all-changes", "Reject All")
|
})),
|
||||||
.label_size(LabelSize::Small)
|
|
||||||
.disabled(pending_edits)
|
|
||||||
.when(pending_edits, |this| {
|
|
||||||
this.tooltip(Tooltip::text(EDIT_NOT_READY_TOOLTIP_LABEL))
|
|
||||||
})
|
|
||||||
.key_binding(
|
|
||||||
KeyBinding::for_action_in(
|
|
||||||
&RejectAll,
|
|
||||||
&focus_handle.clone(),
|
|
||||||
window,
|
|
||||||
cx,
|
|
||||||
)
|
|
||||||
.map(|kb| kb.size(rems_from_px(10.))),
|
|
||||||
)
|
|
||||||
.on_click(cx.listener(|this, _, window, cx| {
|
|
||||||
this.handle_reject_all(window, cx)
|
|
||||||
})),
|
|
||||||
)
|
|
||||||
.child(
|
|
||||||
Button::new("accept-all-changes", "Accept All")
|
|
||||||
.label_size(LabelSize::Small)
|
|
||||||
.disabled(pending_edits)
|
|
||||||
.when(pending_edits, |this| {
|
|
||||||
this.tooltip(Tooltip::text(EDIT_NOT_READY_TOOLTIP_LABEL))
|
|
||||||
})
|
|
||||||
.key_binding(
|
|
||||||
KeyBinding::for_action_in(
|
|
||||||
&KeepAll,
|
|
||||||
&focus_handle,
|
|
||||||
window,
|
|
||||||
cx,
|
|
||||||
)
|
|
||||||
.map(|kb| kb.size(rems_from_px(10.))),
|
|
||||||
)
|
|
||||||
.on_click(cx.listener(|this, _, window, cx| {
|
|
||||||
this.handle_accept_all(window, cx)
|
|
||||||
})),
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
.when(is_edit_changes_expanded, |parent| {
|
.when(is_edit_changes_expanded, |parent| {
|
||||||
@@ -1208,11 +1079,11 @@ impl MessageEditor {
|
|||||||
let plan = user_store
|
let plan = user_store
|
||||||
.current_plan()
|
.current_plan()
|
||||||
.map(|plan| match plan {
|
.map(|plan| match plan {
|
||||||
Plan::Free => zed_llm_client::Plan::ZedFree,
|
Plan::Free => zed_llm_client::Plan::Free,
|
||||||
Plan::ZedPro => zed_llm_client::Plan::ZedPro,
|
Plan::ZedPro => zed_llm_client::Plan::ZedPro,
|
||||||
Plan::ZedProTrial => zed_llm_client::Plan::ZedProTrial,
|
Plan::ZedProTrial => zed_llm_client::Plan::ZedProTrial,
|
||||||
})
|
})
|
||||||
.unwrap_or(zed_llm_client::Plan::ZedFree);
|
.unwrap_or(zed_llm_client::Plan::Free);
|
||||||
let usage = self.thread.read(cx).last_usage().or_else(|| {
|
let usage = self.thread.read(cx).last_usage().or_else(|| {
|
||||||
maybe!({
|
maybe!({
|
||||||
let amount = user_store.model_request_usage_amount()?;
|
let amount = user_store.model_request_usage_amount()?;
|
||||||
@@ -1290,10 +1161,9 @@ impl MessageEditor {
|
|||||||
fn reload_context(&mut self, cx: &mut Context<Self>) -> Task<Option<ContextLoadResult>> {
|
fn reload_context(&mut self, cx: &mut Context<Self>) -> Task<Option<ContextLoadResult>> {
|
||||||
let load_task = cx.spawn(async move |this, cx| {
|
let load_task = cx.spawn(async move |this, cx| {
|
||||||
let Ok(load_task) = this.update(cx, |this, cx| {
|
let Ok(load_task) = this.update(cx, |this, cx| {
|
||||||
let new_context = this
|
let new_context = this.context_store.read_with(cx, |context_store, cx| {
|
||||||
.context_store
|
context_store.new_context_for_thread(this.thread.read(cx), None)
|
||||||
.read(cx)
|
});
|
||||||
.new_context_for_thread(this.thread.read(cx), None);
|
|
||||||
load_context(new_context, &this.project, &this.prompt_store, cx)
|
load_context(new_context, &this.project, &this.prompt_store, cx)
|
||||||
}) else {
|
}) else {
|
||||||
return;
|
return;
|
||||||
@@ -1372,13 +1242,12 @@ impl MessageEditor {
|
|||||||
let request = language_model::LanguageModelRequest {
|
let request = language_model::LanguageModelRequest {
|
||||||
thread_id: None,
|
thread_id: None,
|
||||||
prompt_id: None,
|
prompt_id: None,
|
||||||
intent: None,
|
|
||||||
mode: None,
|
mode: None,
|
||||||
messages: vec![request_message],
|
messages: vec![request_message],
|
||||||
tools: vec![],
|
tools: vec![],
|
||||||
tool_choice: None,
|
tool_choice: None,
|
||||||
stop: vec![],
|
stop: vec![],
|
||||||
temperature: AgentSettings::temperature_for_model(&model.model, cx),
|
temperature: AssistantSettings::temperature_for_model(&model.model, cx),
|
||||||
};
|
};
|
||||||
|
|
||||||
Some(model.model.count_tokens(request, cx))
|
Some(model.model.count_tokens(request, cx))
|
||||||
|
|||||||
@@ -1,13 +1,10 @@
|
|||||||
use std::sync::Arc;
|
use assistant_settings::{
|
||||||
|
AgentProfile, AgentProfileId, AssistantDockPosition, AssistantSettings, GroupedAgentProfiles,
|
||||||
use agent_settings::{
|
|
||||||
AgentDockPosition, AgentProfile, AgentProfileId, AgentSettings, GroupedAgentProfiles,
|
|
||||||
builtin_profiles,
|
builtin_profiles,
|
||||||
};
|
};
|
||||||
use fs::Fs;
|
use gpui::{Action, Entity, FocusHandle, Subscription, WeakEntity, prelude::*};
|
||||||
use gpui::{Action, Empty, Entity, FocusHandle, Subscription, WeakEntity, prelude::*};
|
|
||||||
use language_model::LanguageModelRegistry;
|
use language_model::LanguageModelRegistry;
|
||||||
use settings::{Settings as _, SettingsStore, update_settings_file};
|
use settings::{Settings as _, SettingsStore};
|
||||||
use ui::{
|
use ui::{
|
||||||
ContextMenu, ContextMenuEntry, DocumentationSide, PopoverMenu, PopoverMenuHandle, Tooltip,
|
ContextMenu, ContextMenuEntry, DocumentationSide, PopoverMenu, PopoverMenuHandle, Tooltip,
|
||||||
prelude::*,
|
prelude::*,
|
||||||
@@ -18,7 +15,6 @@ use crate::{ManageProfiles, Thread, ThreadStore, ToggleProfileSelector};
|
|||||||
|
|
||||||
pub struct ProfileSelector {
|
pub struct ProfileSelector {
|
||||||
profiles: GroupedAgentProfiles,
|
profiles: GroupedAgentProfiles,
|
||||||
fs: Arc<dyn Fs>,
|
|
||||||
thread: Entity<Thread>,
|
thread: Entity<Thread>,
|
||||||
thread_store: WeakEntity<ThreadStore>,
|
thread_store: WeakEntity<ThreadStore>,
|
||||||
menu_handle: PopoverMenuHandle<ContextMenu>,
|
menu_handle: PopoverMenuHandle<ContextMenu>,
|
||||||
@@ -28,7 +24,6 @@ pub struct ProfileSelector {
|
|||||||
|
|
||||||
impl ProfileSelector {
|
impl ProfileSelector {
|
||||||
pub fn new(
|
pub fn new(
|
||||||
fs: Arc<dyn Fs>,
|
|
||||||
thread: Entity<Thread>,
|
thread: Entity<Thread>,
|
||||||
thread_store: WeakEntity<ThreadStore>,
|
thread_store: WeakEntity<ThreadStore>,
|
||||||
focus_handle: FocusHandle,
|
focus_handle: FocusHandle,
|
||||||
@@ -39,8 +34,7 @@ impl ProfileSelector {
|
|||||||
});
|
});
|
||||||
|
|
||||||
Self {
|
Self {
|
||||||
profiles: GroupedAgentProfiles::from_settings(AgentSettings::get_global(cx)),
|
profiles: GroupedAgentProfiles::from_settings(AssistantSettings::get_global(cx)),
|
||||||
fs,
|
|
||||||
thread,
|
thread,
|
||||||
thread_store,
|
thread_store,
|
||||||
menu_handle: PopoverMenuHandle::default(),
|
menu_handle: PopoverMenuHandle::default(),
|
||||||
@@ -54,7 +48,7 @@ impl ProfileSelector {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn refresh_profiles(&mut self, cx: &mut Context<Self>) {
|
fn refresh_profiles(&mut self, cx: &mut Context<Self>) {
|
||||||
self.profiles = GroupedAgentProfiles::from_settings(AgentSettings::get_global(cx));
|
self.profiles = GroupedAgentProfiles::from_settings(AssistantSettings::get_global(cx));
|
||||||
}
|
}
|
||||||
|
|
||||||
fn build_context_menu(
|
fn build_context_menu(
|
||||||
@@ -63,7 +57,7 @@ impl ProfileSelector {
|
|||||||
cx: &mut Context<Self>,
|
cx: &mut Context<Self>,
|
||||||
) -> Entity<ContextMenu> {
|
) -> Entity<ContextMenu> {
|
||||||
ContextMenu::build(window, cx, |mut menu, _window, cx| {
|
ContextMenu::build(window, cx, |mut menu, _window, cx| {
|
||||||
let settings = AgentSettings::get_global(cx);
|
let settings = AssistantSettings::get_global(cx);
|
||||||
for (profile_id, profile) in self.profiles.builtin.iter() {
|
for (profile_id, profile) in self.profiles.builtin.iter() {
|
||||||
menu = menu.item(self.menu_entry_for_profile(
|
menu = menu.item(self.menu_entry_for_profile(
|
||||||
profile_id.clone(),
|
profile_id.clone(),
|
||||||
@@ -100,8 +94,8 @@ impl ProfileSelector {
|
|||||||
&self,
|
&self,
|
||||||
profile_id: AgentProfileId,
|
profile_id: AgentProfileId,
|
||||||
profile: &AgentProfile,
|
profile: &AgentProfile,
|
||||||
settings: &AgentSettings,
|
settings: &AssistantSettings,
|
||||||
_cx: &App,
|
cx: &App,
|
||||||
) -> ContextMenuEntry {
|
) -> ContextMenuEntry {
|
||||||
let documentation = match profile.name.to_lowercase().as_str() {
|
let documentation = match profile.name.to_lowercase().as_str() {
|
||||||
builtin_profiles::WRITE => Some("Get help to write anything."),
|
builtin_profiles::WRITE => Some("Get help to write anything."),
|
||||||
@@ -110,8 +104,12 @@ impl ProfileSelector {
|
|||||||
_ => None,
|
_ => None,
|
||||||
};
|
};
|
||||||
|
|
||||||
let entry = ContextMenuEntry::new(profile.name.clone())
|
let current_profile_id = self.thread.read(cx).configured_profile_id();
|
||||||
.toggleable(IconPosition::End, profile_id == settings.default_profile);
|
|
||||||
|
let entry = ContextMenuEntry::new(profile.name.clone()).toggleable(
|
||||||
|
IconPosition::End,
|
||||||
|
Some(profile_id.clone()) == current_profile_id,
|
||||||
|
);
|
||||||
|
|
||||||
let entry = if let Some(doc_text) = documentation {
|
let entry = if let Some(doc_text) = documentation {
|
||||||
entry.documentation_aside(documentation_side(settings.dock), move |_| {
|
entry.documentation_aside(documentation_side(settings.dock), move |_| {
|
||||||
@@ -122,15 +120,13 @@ impl ProfileSelector {
|
|||||||
};
|
};
|
||||||
|
|
||||||
entry.handler({
|
entry.handler({
|
||||||
let fs = self.fs.clone();
|
|
||||||
let thread_store = self.thread_store.clone();
|
let thread_store = self.thread_store.clone();
|
||||||
let profile_id = profile_id.clone();
|
let profile_id = profile_id.clone();
|
||||||
|
let thread = self.thread.clone();
|
||||||
|
|
||||||
move |_window, cx| {
|
move |_window, cx| {
|
||||||
update_settings_file::<AgentSettings>(fs.clone(), cx, {
|
thread.update(cx, |thread, cx| {
|
||||||
let profile_id = profile_id.clone();
|
thread.set_configured_profile_id(Some(profile_id.clone()), cx);
|
||||||
move |settings, _cx| {
|
|
||||||
settings.set_profile(profile_id.clone());
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
thread_store
|
thread_store
|
||||||
@@ -145,23 +141,29 @@ impl ProfileSelector {
|
|||||||
|
|
||||||
impl Render for ProfileSelector {
|
impl Render for ProfileSelector {
|
||||||
fn render(&mut self, _window: &mut Window, cx: &mut Context<Self>) -> impl IntoElement {
|
fn render(&mut self, _window: &mut Window, cx: &mut Context<Self>) -> impl IntoElement {
|
||||||
let settings = AgentSettings::get_global(cx);
|
let settings = AssistantSettings::get_global(cx);
|
||||||
let profile_id = &settings.default_profile;
|
let profile_id = self
|
||||||
let profile = settings.profiles.get(profile_id);
|
.thread
|
||||||
|
.read(cx)
|
||||||
|
.configured_profile_id()
|
||||||
|
.unwrap_or(settings.default_profile.clone());
|
||||||
|
let profile = settings.profiles.get(&profile_id).cloned();
|
||||||
|
|
||||||
let selected_profile = profile
|
let selected_profile = profile
|
||||||
.map(|profile| profile.name.clone())
|
.map(|profile| profile.name.clone())
|
||||||
.unwrap_or_else(|| "Unknown".into());
|
.unwrap_or_else(|| "Unknown".into());
|
||||||
|
|
||||||
let configured_model = self.thread.read(cx).configured_model().or_else(|| {
|
let configured_model = self
|
||||||
let model_registry = LanguageModelRegistry::read_global(cx);
|
.thread
|
||||||
model_registry.default_model()
|
.read_with(cx, |thread, _cx| thread.configured_model())
|
||||||
});
|
.or_else(|| {
|
||||||
let Some(configured_model) = configured_model else {
|
let model_registry = LanguageModelRegistry::read_global(cx);
|
||||||
return Empty.into_any_element();
|
model_registry.default_model()
|
||||||
};
|
});
|
||||||
|
let supports_tools =
|
||||||
|
configured_model.map_or(false, |default| default.model.supports_tools());
|
||||||
|
|
||||||
if configured_model.model.supports_tools() {
|
if supports_tools {
|
||||||
let this = cx.entity().clone();
|
let this = cx.entity().clone();
|
||||||
let focus_handle = self.focus_handle.clone();
|
let focus_handle = self.focus_handle.clone();
|
||||||
let trigger_button = Button::new("profile-selector-model", selected_profile)
|
let trigger_button = Button::new("profile-selector-model", selected_profile)
|
||||||
@@ -208,10 +210,10 @@ impl Render for ProfileSelector {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn documentation_side(position: AgentDockPosition) -> DocumentationSide {
|
fn documentation_side(position: AssistantDockPosition) -> DocumentationSide {
|
||||||
match position {
|
match position {
|
||||||
AgentDockPosition::Left => DocumentationSide::Right,
|
AssistantDockPosition::Left => DocumentationSide::Right,
|
||||||
AgentDockPosition::Bottom => DocumentationSide::Left,
|
AssistantDockPosition::Bottom => DocumentationSide::Left,
|
||||||
AgentDockPosition::Right => DocumentationSide::Left,
|
AssistantDockPosition::Right => DocumentationSide::Left,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1 +0,0 @@
|
|||||||
These files changed since last read:
|
|
||||||
@@ -1,6 +0,0 @@
|
|||||||
Generate a detailed summary of this conversation. Include:
|
|
||||||
1. A brief overview of what was discussed
|
|
||||||
2. Key facts or information discovered
|
|
||||||
3. Outcomes or conclusions reached
|
|
||||||
4. Any action items or next steps if any
|
|
||||||
Format it in Markdown with headings and bullet points.
|
|
||||||
@@ -1,4 +0,0 @@
|
|||||||
Generate a concise 3-7 word title for this conversation, omitting punctuation.
|
|
||||||
Go straight to the title, without any preamble and prefix like `Here's a concise suggestion:...` or `Title:`.
|
|
||||||
If the conversation is about a specific subject, include it in the title.
|
|
||||||
Be descriptive. DO NOT speak in the first person.
|
|
||||||
@@ -179,21 +179,21 @@ impl TerminalTransaction {
|
|||||||
// Ensure that the assistant cannot accidentally execute commands that are streamed into the terminal
|
// Ensure that the assistant cannot accidentally execute commands that are streamed into the terminal
|
||||||
let input = Self::sanitize_input(hunk);
|
let input = Self::sanitize_input(hunk);
|
||||||
self.terminal
|
self.terminal
|
||||||
.update(cx, |terminal, _| terminal.input(input.into_bytes()));
|
.update(cx, |terminal, _| terminal.input(input));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn undo(&self, cx: &mut App) {
|
pub fn undo(&self, cx: &mut App) {
|
||||||
self.terminal
|
self.terminal
|
||||||
.update(cx, |terminal, _| terminal.input(CLEAR_INPUT.as_bytes()));
|
.update(cx, |terminal, _| terminal.input(CLEAR_INPUT.to_string()));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn complete(&self, cx: &mut App) {
|
pub fn complete(&self, cx: &mut App) {
|
||||||
self.terminal
|
self.terminal.update(cx, |terminal, _| {
|
||||||
.update(cx, |terminal, _| terminal.input(CARRIAGE_RETURN.as_bytes()));
|
terminal.input(CARRIAGE_RETURN.to_string())
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
fn sanitize_input(mut input: String) -> String {
|
fn sanitize_input(input: String) -> String {
|
||||||
input.retain(|c| c != '\r' && c != '\n');
|
input.replace(['\r', '\n'], "")
|
||||||
input
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,8 +5,8 @@ use crate::inline_prompt_editor::{
|
|||||||
};
|
};
|
||||||
use crate::terminal_codegen::{CLEAR_INPUT, CodegenEvent, TerminalCodegen};
|
use crate::terminal_codegen::{CLEAR_INPUT, CodegenEvent, TerminalCodegen};
|
||||||
use crate::thread_store::{TextThreadStore, ThreadStore};
|
use crate::thread_store::{TextThreadStore, ThreadStore};
|
||||||
use agent_settings::AgentSettings;
|
|
||||||
use anyhow::{Context as _, Result};
|
use anyhow::{Context as _, Result};
|
||||||
|
use assistant_settings::AssistantSettings;
|
||||||
use client::telemetry::Telemetry;
|
use client::telemetry::Telemetry;
|
||||||
use collections::{HashMap, VecDeque};
|
use collections::{HashMap, VecDeque};
|
||||||
use editor::{MultiBuffer, actions::SelectAll};
|
use editor::{MultiBuffer, actions::SelectAll};
|
||||||
@@ -25,7 +25,6 @@ use terminal_view::TerminalView;
|
|||||||
use ui::prelude::*;
|
use ui::prelude::*;
|
||||||
use util::ResultExt;
|
use util::ResultExt;
|
||||||
use workspace::{Toast, Workspace, notifications::NotificationId};
|
use workspace::{Toast, Workspace, notifications::NotificationId};
|
||||||
use zed_llm_client::CompletionIntent;
|
|
||||||
|
|
||||||
pub fn init(
|
pub fn init(
|
||||||
fs: Arc<dyn Fs>,
|
fs: Arc<dyn Fs>,
|
||||||
@@ -106,7 +105,7 @@ impl TerminalInlineAssistant {
|
|||||||
});
|
});
|
||||||
let prompt_editor_render = prompt_editor.clone();
|
let prompt_editor_render = prompt_editor.clone();
|
||||||
let block = terminal_view::BlockProperties {
|
let block = terminal_view::BlockProperties {
|
||||||
height: 4,
|
height: 2,
|
||||||
render: Box::new(move |_| prompt_editor_render.clone().into_any_element()),
|
render: Box::new(move |_| prompt_editor_render.clone().into_any_element()),
|
||||||
};
|
};
|
||||||
terminal_view.update(cx, |terminal_view, cx| {
|
terminal_view.update(cx, |terminal_view, cx| {
|
||||||
@@ -192,7 +191,7 @@ impl TerminalInlineAssistant {
|
|||||||
};
|
};
|
||||||
|
|
||||||
self.prompt_history.retain(|prompt| *prompt != user_prompt);
|
self.prompt_history.retain(|prompt| *prompt != user_prompt);
|
||||||
self.prompt_history.push_back(user_prompt);
|
self.prompt_history.push_back(user_prompt.clone());
|
||||||
if self.prompt_history.len() > PROMPT_HISTORY_MAX_LEN {
|
if self.prompt_history.len() > PROMPT_HISTORY_MAX_LEN {
|
||||||
self.prompt_history.pop_front();
|
self.prompt_history.pop_front();
|
||||||
}
|
}
|
||||||
@@ -202,7 +201,7 @@ impl TerminalInlineAssistant {
|
|||||||
.update(cx, |terminal, cx| {
|
.update(cx, |terminal, cx| {
|
||||||
terminal
|
terminal
|
||||||
.terminal()
|
.terminal()
|
||||||
.update(cx, |terminal, _| terminal.input(CLEAR_INPUT.as_bytes()));
|
.update(cx, |terminal, _| terminal.input(CLEAR_INPUT.to_string()));
|
||||||
})
|
})
|
||||||
.log_err();
|
.log_err();
|
||||||
|
|
||||||
@@ -272,7 +271,7 @@ impl TerminalInlineAssistant {
|
|||||||
.inline_assistant_model()
|
.inline_assistant_model()
|
||||||
.context("No inline assistant model")?;
|
.context("No inline assistant model")?;
|
||||||
|
|
||||||
let temperature = AgentSettings::temperature_for_model(&model, cx);
|
let temperature = AssistantSettings::temperature_for_model(&model, cx);
|
||||||
|
|
||||||
Ok(cx.background_spawn(async move {
|
Ok(cx.background_spawn(async move {
|
||||||
let mut request_message = LanguageModelRequestMessage {
|
let mut request_message = LanguageModelRequestMessage {
|
||||||
@@ -292,7 +291,6 @@ impl TerminalInlineAssistant {
|
|||||||
thread_id: None,
|
thread_id: None,
|
||||||
prompt_id: None,
|
prompt_id: None,
|
||||||
mode: None,
|
mode: None,
|
||||||
intent: Some(CompletionIntent::TerminalInlineAssist),
|
|
||||||
messages: vec![request_message],
|
messages: vec![request_message],
|
||||||
tools: Vec::new(),
|
tools: Vec::new(),
|
||||||
tool_choice: None,
|
tool_choice: None,
|
||||||
|
|||||||
@@ -2,11 +2,12 @@ use std::fmt::Display;
|
|||||||
use std::ops::Range;
|
use std::ops::Range;
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
|
||||||
|
use assistant_context_editor::SavedContextMetadata;
|
||||||
use chrono::{Datelike as _, Local, NaiveDate, TimeDelta};
|
use chrono::{Datelike as _, Local, NaiveDate, TimeDelta};
|
||||||
use editor::{Editor, EditorEvent};
|
use editor::{Editor, EditorEvent};
|
||||||
use fuzzy::{StringMatch, StringMatchCandidate};
|
use fuzzy::{StringMatch, StringMatchCandidate};
|
||||||
use gpui::{
|
use gpui::{
|
||||||
App, ClickEvent, Empty, Entity, FocusHandle, Focusable, ScrollStrategy, Stateful, Task,
|
App, Empty, Entity, FocusHandle, Focusable, ScrollStrategy, Stateful, Task,
|
||||||
UniformListScrollHandle, WeakEntity, Window, uniform_list,
|
UniformListScrollHandle, WeakEntity, Window, uniform_list,
|
||||||
};
|
};
|
||||||
use time::{OffsetDateTime, UtcOffset};
|
use time::{OffsetDateTime, UtcOffset};
|
||||||
@@ -17,6 +18,7 @@ use ui::{
|
|||||||
use util::ResultExt;
|
use util::ResultExt;
|
||||||
|
|
||||||
use crate::history_store::{HistoryEntry, HistoryStore};
|
use crate::history_store::{HistoryEntry, HistoryStore};
|
||||||
|
use crate::thread_store::SerializedThreadMetadata;
|
||||||
use crate::{AgentPanel, RemoveSelectedThread};
|
use crate::{AgentPanel, RemoveSelectedThread};
|
||||||
|
|
||||||
pub struct ThreadHistory {
|
pub struct ThreadHistory {
|
||||||
@@ -24,12 +26,11 @@ pub struct ThreadHistory {
|
|||||||
history_store: Entity<HistoryStore>,
|
history_store: Entity<HistoryStore>,
|
||||||
scroll_handle: UniformListScrollHandle,
|
scroll_handle: UniformListScrollHandle,
|
||||||
selected_index: usize,
|
selected_index: usize,
|
||||||
hovered_index: Option<usize>,
|
|
||||||
search_editor: Entity<Editor>,
|
search_editor: Entity<Editor>,
|
||||||
all_entries: Arc<Vec<HistoryEntry>>,
|
all_entries: Arc<Vec<HistoryEntry>>,
|
||||||
// When the search is empty, we display date separators between history entries
|
// When the search is empty, we display date separators between history entries
|
||||||
// This vector contains an enum of either a separator or an actual entry
|
// This vector contains an enum of either a separator or an actual entry
|
||||||
separated_items: Vec<ListItemType>,
|
separated_items: Vec<HistoryListItem>,
|
||||||
// Maps entry indexes to list item indexes
|
// Maps entry indexes to list item indexes
|
||||||
separated_item_indexes: Vec<u32>,
|
separated_item_indexes: Vec<u32>,
|
||||||
_separated_items_task: Option<Task<()>>,
|
_separated_items_task: Option<Task<()>>,
|
||||||
@@ -51,7 +52,7 @@ enum SearchState {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
enum ListItemType {
|
enum HistoryListItem {
|
||||||
BucketSeparator(TimeBucket),
|
BucketSeparator(TimeBucket),
|
||||||
Entry {
|
Entry {
|
||||||
index: usize,
|
index: usize,
|
||||||
@@ -59,11 +60,11 @@ enum ListItemType {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ListItemType {
|
impl HistoryListItem {
|
||||||
fn entry_index(&self) -> Option<usize> {
|
fn entry_index(&self) -> Option<usize> {
|
||||||
match self {
|
match self {
|
||||||
ListItemType::BucketSeparator(_) => None,
|
HistoryListItem::BucketSeparator(_) => None,
|
||||||
ListItemType::Entry { index, .. } => Some(*index),
|
HistoryListItem::Entry { index, .. } => Some(*index),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -101,7 +102,6 @@ impl ThreadHistory {
|
|||||||
history_store,
|
history_store,
|
||||||
scroll_handle,
|
scroll_handle,
|
||||||
selected_index: 0,
|
selected_index: 0,
|
||||||
hovered_index: None,
|
|
||||||
search_state: SearchState::Empty,
|
search_state: SearchState::Empty,
|
||||||
all_entries: Default::default(),
|
all_entries: Default::default(),
|
||||||
separated_items: Default::default(),
|
separated_items: Default::default(),
|
||||||
@@ -117,21 +117,40 @@ impl ThreadHistory {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn update_all_entries(&mut self, cx: &mut Context<Self>) {
|
fn update_all_entries(&mut self, cx: &mut Context<Self>) {
|
||||||
let new_entries: Arc<Vec<HistoryEntry>> = self
|
self.all_entries = self
|
||||||
.history_store
|
.history_store
|
||||||
.update(cx, |store, cx| store.entries(cx))
|
.update(cx, |store, cx| store.entries(cx))
|
||||||
.into();
|
.into();
|
||||||
|
|
||||||
self._separated_items_task.take();
|
self.set_selected_entry_index(0, cx);
|
||||||
|
self.update_separated_items(cx);
|
||||||
|
|
||||||
let mut items = Vec::with_capacity(new_entries.len() + 1);
|
match &self.search_state {
|
||||||
let mut indexes = Vec::with_capacity(new_entries.len() + 1);
|
SearchState::Empty => {}
|
||||||
|
SearchState::Searching { query, .. } | SearchState::Searched { query, .. } => {
|
||||||
|
self.search(query.clone(), cx);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
cx.notify();
|
||||||
|
}
|
||||||
|
|
||||||
|
fn update_separated_items(&mut self, cx: &mut Context<Self>) {
|
||||||
|
self._separated_items_task.take();
|
||||||
|
let all_entries = self.all_entries.clone();
|
||||||
|
|
||||||
|
let mut items = std::mem::take(&mut self.separated_items);
|
||||||
|
let mut indexes = std::mem::take(&mut self.separated_item_indexes);
|
||||||
|
items.clear();
|
||||||
|
indexes.clear();
|
||||||
|
// We know there's going to be at least one bucket separator
|
||||||
|
items.reserve(all_entries.len() + 1);
|
||||||
|
indexes.reserve(all_entries.len() + 1);
|
||||||
|
|
||||||
let bg_task = cx.background_spawn(async move {
|
let bg_task = cx.background_spawn(async move {
|
||||||
let mut bucket = None;
|
let mut bucket = None;
|
||||||
let today = Local::now().naive_local().date();
|
let today = Local::now().naive_local().date();
|
||||||
|
|
||||||
for (index, entry) in new_entries.iter().enumerate() {
|
for (index, entry) in all_entries.iter().enumerate() {
|
||||||
let entry_date = entry
|
let entry_date = entry
|
||||||
.updated_at()
|
.updated_at()
|
||||||
.with_timezone(&Local)
|
.with_timezone(&Local)
|
||||||
@@ -141,50 +160,23 @@ impl ThreadHistory {
|
|||||||
|
|
||||||
if Some(entry_bucket) != bucket {
|
if Some(entry_bucket) != bucket {
|
||||||
bucket = Some(entry_bucket);
|
bucket = Some(entry_bucket);
|
||||||
items.push(ListItemType::BucketSeparator(entry_bucket));
|
items.push(HistoryListItem::BucketSeparator(entry_bucket));
|
||||||
}
|
}
|
||||||
|
|
||||||
indexes.push(items.len() as u32);
|
indexes.push(items.len() as u32);
|
||||||
items.push(ListItemType::Entry {
|
items.push(HistoryListItem::Entry {
|
||||||
index,
|
index,
|
||||||
format: entry_bucket.into(),
|
format: entry_bucket.into(),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
(new_entries, items, indexes)
|
(items, indexes)
|
||||||
});
|
});
|
||||||
|
|
||||||
let task = cx.spawn(async move |this, cx| {
|
let task = cx.spawn(async move |this, cx| {
|
||||||
let (new_entries, items, indexes) = bg_task.await;
|
let (items, indexes) = bg_task.await;
|
||||||
this.update(cx, |this, cx| {
|
this.update(cx, |this, cx| {
|
||||||
let previously_selected_entry =
|
|
||||||
this.all_entries.get(this.selected_index).map(|e| e.id());
|
|
||||||
|
|
||||||
this.all_entries = new_entries;
|
|
||||||
this.separated_items = items;
|
this.separated_items = items;
|
||||||
this.separated_item_indexes = indexes;
|
this.separated_item_indexes = indexes;
|
||||||
|
|
||||||
match &this.search_state {
|
|
||||||
SearchState::Empty => {
|
|
||||||
if this.selected_index >= this.all_entries.len() {
|
|
||||||
this.set_selected_entry_index(
|
|
||||||
this.all_entries.len().saturating_sub(1),
|
|
||||||
cx,
|
|
||||||
);
|
|
||||||
} else if let Some(prev_id) = previously_selected_entry {
|
|
||||||
if let Some(new_ix) = this
|
|
||||||
.all_entries
|
|
||||||
.iter()
|
|
||||||
.position(|probe| probe.id() == prev_id)
|
|
||||||
{
|
|
||||||
this.set_selected_entry_index(new_ix, cx);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
SearchState::Searching { query, .. } | SearchState::Searched { query, .. } => {
|
|
||||||
this.search(query.clone(), cx);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
cx.notify();
|
cx.notify();
|
||||||
})
|
})
|
||||||
.log_err();
|
.log_err();
|
||||||
@@ -260,7 +252,10 @@ impl ThreadHistory {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
self.search_state = SearchState::Searching { query, _task: task };
|
self.search_state = SearchState::Searching {
|
||||||
|
query: query.clone(),
|
||||||
|
_task: task,
|
||||||
|
};
|
||||||
cx.notify();
|
cx.notify();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -472,7 +467,7 @@ impl ThreadHistory {
|
|||||||
.map(|(ix, m)| {
|
.map(|(ix, m)| {
|
||||||
self.render_list_item(
|
self.render_list_item(
|
||||||
Some(range_start + ix),
|
Some(range_start + ix),
|
||||||
&ListItemType::Entry {
|
&HistoryListItem::Entry {
|
||||||
index: m.candidate_id,
|
index: m.candidate_id,
|
||||||
format: EntryTimeFormat::DateAndTime,
|
format: EntryTimeFormat::DateAndTime,
|
||||||
},
|
},
|
||||||
@@ -490,36 +485,25 @@ impl ThreadHistory {
|
|||||||
fn render_list_item(
|
fn render_list_item(
|
||||||
&self,
|
&self,
|
||||||
list_entry_ix: Option<usize>,
|
list_entry_ix: Option<usize>,
|
||||||
item: &ListItemType,
|
item: &HistoryListItem,
|
||||||
highlight_positions: Vec<usize>,
|
highlight_positions: Vec<usize>,
|
||||||
cx: &Context<Self>,
|
cx: &App,
|
||||||
) -> AnyElement {
|
) -> AnyElement {
|
||||||
match item {
|
match item {
|
||||||
ListItemType::Entry { index, format } => match self.all_entries.get(*index) {
|
HistoryListItem::Entry { index, format } => match self.all_entries.get(*index) {
|
||||||
Some(entry) => h_flex()
|
Some(entry) => h_flex()
|
||||||
.w_full()
|
.w_full()
|
||||||
.pb_1()
|
.pb_1()
|
||||||
.child(
|
.child(self.render_history_entry(
|
||||||
HistoryEntryElement::new(entry.clone(), self.agent_panel.clone())
|
entry,
|
||||||
.highlight_positions(highlight_positions)
|
list_entry_ix == Some(self.selected_index),
|
||||||
.timestamp_format(*format)
|
highlight_positions,
|
||||||
.selected(list_entry_ix == Some(self.selected_index))
|
*format,
|
||||||
.hovered(list_entry_ix == self.hovered_index)
|
))
|
||||||
.on_hover(cx.listener(move |this, is_hovered, _window, cx| {
|
|
||||||
if *is_hovered {
|
|
||||||
this.hovered_index = list_entry_ix;
|
|
||||||
} else if this.hovered_index == list_entry_ix {
|
|
||||||
this.hovered_index = None;
|
|
||||||
}
|
|
||||||
|
|
||||||
cx.notify();
|
|
||||||
}))
|
|
||||||
.into_any_element(),
|
|
||||||
)
|
|
||||||
.into_any(),
|
.into_any(),
|
||||||
None => Empty.into_any_element(),
|
None => Empty.into_any_element(),
|
||||||
},
|
},
|
||||||
ListItemType::BucketSeparator(bucket) => div()
|
HistoryListItem::BucketSeparator(bucket) => div()
|
||||||
.px(DynamicSpacing::Base06.rems(cx))
|
.px(DynamicSpacing::Base06.rems(cx))
|
||||||
.pt_2()
|
.pt_2()
|
||||||
.pb_1()
|
.pb_1()
|
||||||
@@ -531,6 +515,33 @@ impl ThreadHistory {
|
|||||||
.into_any_element(),
|
.into_any_element(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn render_history_entry(
|
||||||
|
&self,
|
||||||
|
entry: &HistoryEntry,
|
||||||
|
is_active: bool,
|
||||||
|
highlight_positions: Vec<usize>,
|
||||||
|
format: EntryTimeFormat,
|
||||||
|
) -> AnyElement {
|
||||||
|
match entry {
|
||||||
|
HistoryEntry::Thread(thread) => PastThread::new(
|
||||||
|
thread.clone(),
|
||||||
|
self.agent_panel.clone(),
|
||||||
|
is_active,
|
||||||
|
highlight_positions,
|
||||||
|
format,
|
||||||
|
)
|
||||||
|
.into_any_element(),
|
||||||
|
HistoryEntry::Context(context) => PastContext::new(
|
||||||
|
context.clone(),
|
||||||
|
self.agent_panel.clone(),
|
||||||
|
is_active,
|
||||||
|
highlight_positions,
|
||||||
|
format,
|
||||||
|
)
|
||||||
|
.into_any_element(),
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Focusable for ThreadHistory {
|
impl Focusable for ThreadHistory {
|
||||||
@@ -612,97 +623,155 @@ impl Render for ThreadHistory {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[derive(IntoElement)]
|
#[derive(IntoElement)]
|
||||||
pub struct HistoryEntryElement {
|
pub struct PastThread {
|
||||||
entry: HistoryEntry,
|
thread: SerializedThreadMetadata,
|
||||||
agent_panel: WeakEntity<AgentPanel>,
|
agent_panel: WeakEntity<AgentPanel>,
|
||||||
selected: bool,
|
selected: bool,
|
||||||
hovered: bool,
|
|
||||||
highlight_positions: Vec<usize>,
|
highlight_positions: Vec<usize>,
|
||||||
timestamp_format: EntryTimeFormat,
|
timestamp_format: EntryTimeFormat,
|
||||||
on_hover: Box<dyn Fn(&bool, &mut Window, &mut App) + 'static>,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl HistoryEntryElement {
|
impl PastThread {
|
||||||
pub fn new(entry: HistoryEntry, agent_panel: WeakEntity<AgentPanel>) -> Self {
|
pub fn new(
|
||||||
|
thread: SerializedThreadMetadata,
|
||||||
|
agent_panel: WeakEntity<AgentPanel>,
|
||||||
|
selected: bool,
|
||||||
|
highlight_positions: Vec<usize>,
|
||||||
|
timestamp_format: EntryTimeFormat,
|
||||||
|
) -> Self {
|
||||||
Self {
|
Self {
|
||||||
entry,
|
thread,
|
||||||
agent_panel,
|
agent_panel,
|
||||||
selected: false,
|
selected,
|
||||||
hovered: false,
|
highlight_positions,
|
||||||
highlight_positions: vec![],
|
timestamp_format,
|
||||||
timestamp_format: EntryTimeFormat::DateAndTime,
|
|
||||||
on_hover: Box::new(|_, _, _| {}),
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn selected(mut self, selected: bool) -> Self {
|
|
||||||
self.selected = selected;
|
|
||||||
self
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn hovered(mut self, hovered: bool) -> Self {
|
|
||||||
self.hovered = hovered;
|
|
||||||
self
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn highlight_positions(mut self, positions: Vec<usize>) -> Self {
|
|
||||||
self.highlight_positions = positions;
|
|
||||||
self
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn on_hover(mut self, on_hover: impl Fn(&bool, &mut Window, &mut App) + 'static) -> Self {
|
|
||||||
self.on_hover = Box::new(on_hover);
|
|
||||||
self
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn timestamp_format(mut self, format: EntryTimeFormat) -> Self {
|
|
||||||
self.timestamp_format = format;
|
|
||||||
self
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl RenderOnce for HistoryEntryElement {
|
impl RenderOnce for PastThread {
|
||||||
fn render(self, _window: &mut Window, cx: &mut App) -> impl IntoElement {
|
fn render(self, _window: &mut Window, cx: &mut App) -> impl IntoElement {
|
||||||
let (id, summary, timestamp) = match &self.entry {
|
let summary = self.thread.summary;
|
||||||
HistoryEntry::Thread(thread) => (
|
|
||||||
thread.id.to_string(),
|
|
||||||
thread.summary.clone(),
|
|
||||||
thread.updated_at.timestamp(),
|
|
||||||
),
|
|
||||||
HistoryEntry::Context(context) => (
|
|
||||||
context.path.to_string_lossy().to_string(),
|
|
||||||
context.title.clone().into(),
|
|
||||||
context.mtime.timestamp(),
|
|
||||||
),
|
|
||||||
};
|
|
||||||
|
|
||||||
let thread_timestamp =
|
let thread_timestamp = self.timestamp_format.format_timestamp(
|
||||||
self.timestamp_format
|
&self.agent_panel,
|
||||||
.format_timestamp(&self.agent_panel, timestamp, cx);
|
self.thread.updated_at.timestamp(),
|
||||||
|
cx,
|
||||||
|
);
|
||||||
|
|
||||||
ListItem::new(SharedString::from(id))
|
ListItem::new(SharedString::from(self.thread.id.to_string()))
|
||||||
.rounded()
|
.rounded()
|
||||||
.toggle_state(self.selected)
|
.toggle_state(self.selected)
|
||||||
.spacing(ListItemSpacing::Sparse)
|
.spacing(ListItemSpacing::Sparse)
|
||||||
.start_slot(
|
.start_slot(
|
||||||
|
div().max_w_4_5().child(
|
||||||
|
HighlightedLabel::new(summary, self.highlight_positions)
|
||||||
|
.size(LabelSize::Small)
|
||||||
|
.truncate(),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
.end_slot(
|
||||||
h_flex()
|
h_flex()
|
||||||
.w_full()
|
.gap_1p5()
|
||||||
.gap_2()
|
|
||||||
.justify_between()
|
|
||||||
.child(
|
|
||||||
HighlightedLabel::new(summary, self.highlight_positions)
|
|
||||||
.size(LabelSize::Small)
|
|
||||||
.truncate(),
|
|
||||||
)
|
|
||||||
.child(
|
.child(
|
||||||
Label::new(thread_timestamp)
|
Label::new(thread_timestamp)
|
||||||
.color(Color::Muted)
|
.color(Color::Muted)
|
||||||
.size(LabelSize::XSmall),
|
.size(LabelSize::XSmall),
|
||||||
|
)
|
||||||
|
.child(
|
||||||
|
IconButton::new("delete", IconName::TrashAlt)
|
||||||
|
.shape(IconButtonShape::Square)
|
||||||
|
.icon_size(IconSize::XSmall)
|
||||||
|
.icon_color(Color::Muted)
|
||||||
|
.tooltip(move |window, cx| {
|
||||||
|
Tooltip::for_action("Delete", &RemoveSelectedThread, window, cx)
|
||||||
|
})
|
||||||
|
.on_click({
|
||||||
|
let agent_panel = self.agent_panel.clone();
|
||||||
|
let id = self.thread.id.clone();
|
||||||
|
move |_event, _window, cx| {
|
||||||
|
agent_panel
|
||||||
|
.update(cx, |this, cx| {
|
||||||
|
this.delete_thread(&id, cx).detach_and_log_err(cx);
|
||||||
|
})
|
||||||
|
.ok();
|
||||||
|
}
|
||||||
|
}),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
.on_hover(self.on_hover)
|
.on_click({
|
||||||
.end_slot::<IconButton>(if self.hovered || self.selected {
|
let agent_panel = self.agent_panel.clone();
|
||||||
Some(
|
let id = self.thread.id.clone();
|
||||||
|
move |_event, window, cx| {
|
||||||
|
agent_panel
|
||||||
|
.update(cx, |this, cx| {
|
||||||
|
this.open_thread_by_id(&id, window, cx)
|
||||||
|
.detach_and_log_err(cx);
|
||||||
|
})
|
||||||
|
.ok();
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(IntoElement)]
|
||||||
|
pub struct PastContext {
|
||||||
|
context: SavedContextMetadata,
|
||||||
|
agent_panel: WeakEntity<AgentPanel>,
|
||||||
|
selected: bool,
|
||||||
|
highlight_positions: Vec<usize>,
|
||||||
|
timestamp_format: EntryTimeFormat,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl PastContext {
|
||||||
|
pub fn new(
|
||||||
|
context: SavedContextMetadata,
|
||||||
|
agent_panel: WeakEntity<AgentPanel>,
|
||||||
|
selected: bool,
|
||||||
|
highlight_positions: Vec<usize>,
|
||||||
|
timestamp_format: EntryTimeFormat,
|
||||||
|
) -> Self {
|
||||||
|
Self {
|
||||||
|
context,
|
||||||
|
agent_panel,
|
||||||
|
selected,
|
||||||
|
highlight_positions,
|
||||||
|
timestamp_format,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl RenderOnce for PastContext {
|
||||||
|
fn render(self, _window: &mut Window, cx: &mut App) -> impl IntoElement {
|
||||||
|
let summary = self.context.title;
|
||||||
|
let context_timestamp = self.timestamp_format.format_timestamp(
|
||||||
|
&self.agent_panel,
|
||||||
|
self.context.mtime.timestamp(),
|
||||||
|
cx,
|
||||||
|
);
|
||||||
|
|
||||||
|
ListItem::new(SharedString::from(
|
||||||
|
self.context.path.to_string_lossy().to_string(),
|
||||||
|
))
|
||||||
|
.rounded()
|
||||||
|
.toggle_state(self.selected)
|
||||||
|
.spacing(ListItemSpacing::Sparse)
|
||||||
|
.start_slot(
|
||||||
|
div().max_w_4_5().child(
|
||||||
|
HighlightedLabel::new(summary, self.highlight_positions)
|
||||||
|
.size(LabelSize::Small)
|
||||||
|
.truncate(),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
.end_slot(
|
||||||
|
h_flex()
|
||||||
|
.gap_1p5()
|
||||||
|
.child(
|
||||||
|
Label::new(context_timestamp)
|
||||||
|
.color(Color::Muted)
|
||||||
|
.size(LabelSize::XSmall),
|
||||||
|
)
|
||||||
|
.child(
|
||||||
IconButton::new("delete", IconName::TrashAlt)
|
IconButton::new("delete", IconName::TrashAlt)
|
||||||
.shape(IconButtonShape::Square)
|
.shape(IconButtonShape::Square)
|
||||||
.icon_size(IconSize::XSmall)
|
.icon_size(IconSize::XSmall)
|
||||||
@@ -712,70 +781,30 @@ impl RenderOnce for HistoryEntryElement {
|
|||||||
})
|
})
|
||||||
.on_click({
|
.on_click({
|
||||||
let agent_panel = self.agent_panel.clone();
|
let agent_panel = self.agent_panel.clone();
|
||||||
|
let path = self.context.path.clone();
|
||||||
let f: Box<dyn Fn(&ClickEvent, &mut Window, &mut App) + 'static> =
|
move |_event, _window, cx| {
|
||||||
match &self.entry {
|
agent_panel
|
||||||
HistoryEntry::Thread(thread) => {
|
.update(cx, |this, cx| {
|
||||||
let id = thread.id.clone();
|
this.delete_context(path.clone(), cx)
|
||||||
|
.detach_and_log_err(cx);
|
||||||
Box::new(move |_event, _window, cx| {
|
})
|
||||||
agent_panel
|
.ok();
|
||||||
.update(cx, |this, cx| {
|
}
|
||||||
this.delete_thread(&id, cx)
|
|
||||||
.detach_and_log_err(cx);
|
|
||||||
})
|
|
||||||
.ok();
|
|
||||||
})
|
|
||||||
}
|
|
||||||
HistoryEntry::Context(context) => {
|
|
||||||
let path = context.path.clone();
|
|
||||||
|
|
||||||
Box::new(move |_event, _window, cx| {
|
|
||||||
agent_panel
|
|
||||||
.update(cx, |this, cx| {
|
|
||||||
this.delete_context(path.clone(), cx)
|
|
||||||
.detach_and_log_err(cx);
|
|
||||||
})
|
|
||||||
.ok();
|
|
||||||
})
|
|
||||||
}
|
|
||||||
};
|
|
||||||
f
|
|
||||||
}),
|
}),
|
||||||
)
|
),
|
||||||
} else {
|
)
|
||||||
None
|
.on_click({
|
||||||
})
|
let agent_panel = self.agent_panel.clone();
|
||||||
.on_click({
|
let path = self.context.path.clone();
|
||||||
let agent_panel = self.agent_panel.clone();
|
move |_event, window, cx| {
|
||||||
|
agent_panel
|
||||||
let f: Box<dyn Fn(&ClickEvent, &mut Window, &mut App) + 'static> = match &self.entry
|
.update(cx, |this, cx| {
|
||||||
{
|
this.open_saved_prompt_editor(path.clone(), window, cx)
|
||||||
HistoryEntry::Thread(thread) => {
|
.detach_and_log_err(cx);
|
||||||
let id = thread.id.clone();
|
})
|
||||||
Box::new(move |_event, window, cx| {
|
.ok();
|
||||||
agent_panel
|
}
|
||||||
.update(cx, |this, cx| {
|
})
|
||||||
this.open_thread_by_id(&id, window, cx)
|
|
||||||
.detach_and_log_err(cx);
|
|
||||||
})
|
|
||||||
.ok();
|
|
||||||
})
|
|
||||||
}
|
|
||||||
HistoryEntry::Context(context) => {
|
|
||||||
let path = context.path.clone();
|
|
||||||
Box::new(move |_event, window, cx| {
|
|
||||||
agent_panel
|
|
||||||
.update(cx, |this, cx| {
|
|
||||||
this.open_saved_prompt_editor(path.clone(), window, cx)
|
|
||||||
.detach_and_log_err(cx);
|
|
||||||
})
|
|
||||||
.ok();
|
|
||||||
})
|
|
||||||
}
|
|
||||||
};
|
|
||||||
f
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,10 +1,11 @@
|
|||||||
|
use std::borrow::Cow;
|
||||||
use std::cell::{Ref, RefCell};
|
use std::cell::{Ref, RefCell};
|
||||||
use std::path::{Path, PathBuf};
|
use std::path::{Path, PathBuf};
|
||||||
use std::rc::Rc;
|
use std::rc::Rc;
|
||||||
use std::sync::{Arc, Mutex};
|
use std::sync::Arc;
|
||||||
|
|
||||||
use agent_settings::{AgentProfile, AgentProfileId, AgentSettings, CompletionMode};
|
|
||||||
use anyhow::{Context as _, Result, anyhow};
|
use anyhow::{Context as _, Result, anyhow};
|
||||||
|
use assistant_settings::{AgentProfile, AgentProfileId, AssistantSettings, CompletionMode};
|
||||||
use assistant_tool::{ToolId, ToolSource, ToolWorkingSet};
|
use assistant_tool::{ToolId, ToolSource, ToolWorkingSet};
|
||||||
use chrono::{DateTime, Utc};
|
use chrono::{DateTime, Utc};
|
||||||
use collections::HashMap;
|
use collections::HashMap;
|
||||||
@@ -16,8 +17,9 @@ use gpui::{
|
|||||||
App, BackgroundExecutor, Context, Entity, EventEmitter, Global, ReadGlobal, SharedString,
|
App, BackgroundExecutor, Context, Entity, EventEmitter, Global, ReadGlobal, SharedString,
|
||||||
Subscription, Task, prelude::*,
|
Subscription, Task, prelude::*,
|
||||||
};
|
};
|
||||||
|
use heed::Database;
|
||||||
use language_model::{LanguageModelToolResultContent, LanguageModelToolUseId, Role, TokenUsage};
|
use heed::types::SerdeBincode;
|
||||||
|
use language_model::{LanguageModelToolUseId, Role, TokenUsage};
|
||||||
use project::context_server_store::{ContextServerStatus, ContextServerStore};
|
use project::context_server_store::{ContextServerStatus, ContextServerStore};
|
||||||
use project::{Project, ProjectItem, ProjectPath, Worktree};
|
use project::{Project, ProjectItem, ProjectPath, Worktree};
|
||||||
use prompt_store::{
|
use prompt_store::{
|
||||||
@@ -33,52 +35,14 @@ use crate::context_server_tool::ContextServerTool;
|
|||||||
use crate::thread::{
|
use crate::thread::{
|
||||||
DetailedSummaryState, ExceededWindowError, MessageId, ProjectSnapshot, Thread, ThreadId,
|
DetailedSummaryState, ExceededWindowError, MessageId, ProjectSnapshot, Thread, ThreadId,
|
||||||
};
|
};
|
||||||
use indoc::indoc;
|
|
||||||
use sqlez::{
|
|
||||||
bindable::{Bind, Column},
|
|
||||||
connection::Connection,
|
|
||||||
statement::Statement,
|
|
||||||
};
|
|
||||||
|
|
||||||
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
|
const RULES_FILE_NAMES: [&'static str; 6] = [
|
||||||
pub enum DataType {
|
|
||||||
#[serde(rename = "json")]
|
|
||||||
Json,
|
|
||||||
#[serde(rename = "zstd")]
|
|
||||||
Zstd,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Bind for DataType {
|
|
||||||
fn bind(&self, statement: &Statement, start_index: i32) -> Result<i32> {
|
|
||||||
let value = match self {
|
|
||||||
DataType::Json => "json",
|
|
||||||
DataType::Zstd => "zstd",
|
|
||||||
};
|
|
||||||
value.bind(statement, start_index)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Column for DataType {
|
|
||||||
fn column(statement: &mut Statement, start_index: i32) -> Result<(Self, i32)> {
|
|
||||||
let (value, next_index) = String::column(statement, start_index)?;
|
|
||||||
let data_type = match value.as_str() {
|
|
||||||
"json" => DataType::Json,
|
|
||||||
"zstd" => DataType::Zstd,
|
|
||||||
_ => anyhow::bail!("Unknown data type: {}", value),
|
|
||||||
};
|
|
||||||
Ok((data_type, next_index))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const RULES_FILE_NAMES: [&'static str; 8] = [
|
|
||||||
".rules",
|
".rules",
|
||||||
".cursorrules",
|
".cursorrules",
|
||||||
".windsurfrules",
|
".windsurfrules",
|
||||||
".clinerules",
|
".clinerules",
|
||||||
".github/copilot-instructions.md",
|
".github/copilot-instructions.md",
|
||||||
"CLAUDE.md",
|
"CLAUDE.md",
|
||||||
"AGENT.md",
|
|
||||||
"AGENTS.md",
|
|
||||||
];
|
];
|
||||||
|
|
||||||
pub fn init(cx: &mut App) {
|
pub fn init(cx: &mut App) {
|
||||||
@@ -422,25 +386,6 @@ impl ThreadStore {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn create_thread_from_serialized(
|
|
||||||
&mut self,
|
|
||||||
serialized: SerializedThread,
|
|
||||||
cx: &mut Context<Self>,
|
|
||||||
) -> Entity<Thread> {
|
|
||||||
cx.new(|cx| {
|
|
||||||
Thread::deserialize(
|
|
||||||
ThreadId::new(),
|
|
||||||
serialized,
|
|
||||||
self.project.clone(),
|
|
||||||
self.tools.clone(),
|
|
||||||
self.prompt_builder.clone(),
|
|
||||||
self.project_context.clone(),
|
|
||||||
None,
|
|
||||||
cx,
|
|
||||||
)
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn open_thread(
|
pub fn open_thread(
|
||||||
&self,
|
&self,
|
||||||
id: &ThreadId,
|
id: &ThreadId,
|
||||||
@@ -455,7 +400,7 @@ impl ThreadStore {
|
|||||||
let thread = database
|
let thread = database
|
||||||
.try_find_thread(id.clone())
|
.try_find_thread(id.clone())
|
||||||
.await?
|
.await?
|
||||||
.with_context(|| format!("no thread found with ID: {id:?}"))?;
|
.ok_or_else(|| anyhow!("no thread found with ID: {id:?}"))?;
|
||||||
|
|
||||||
let thread = this.update_in(cx, |this, window, cx| {
|
let thread = this.update_in(cx, |this, window, cx| {
|
||||||
cx.new(|cx| {
|
cx.new(|cx| {
|
||||||
@@ -466,7 +411,7 @@ impl ThreadStore {
|
|||||||
this.tools.clone(),
|
this.tools.clone(),
|
||||||
this.prompt_builder.clone(),
|
this.prompt_builder.clone(),
|
||||||
this.project_context.clone(),
|
this.project_context.clone(),
|
||||||
Some(window),
|
window,
|
||||||
cx,
|
cx,
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
@@ -521,13 +466,13 @@ impl ThreadStore {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn load_default_profile(&self, cx: &mut Context<Self>) {
|
fn load_default_profile(&self, cx: &mut Context<Self>) {
|
||||||
let assistant_settings = AgentSettings::get_global(cx);
|
let assistant_settings = AssistantSettings::get_global(cx);
|
||||||
|
|
||||||
self.load_profile_by_id(assistant_settings.default_profile.clone(), cx);
|
self.load_profile_by_id(assistant_settings.default_profile.clone(), cx);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn load_profile_by_id(&self, profile_id: AgentProfileId, cx: &mut Context<Self>) {
|
pub fn load_profile_by_id(&self, profile_id: AgentProfileId, cx: &mut Context<Self>) {
|
||||||
let assistant_settings = AgentSettings::get_global(cx);
|
let assistant_settings = AssistantSettings::get_global(cx);
|
||||||
|
|
||||||
if let Some(profile) = assistant_settings.profiles.get(&profile_id) {
|
if let Some(profile) = assistant_settings.profiles.get(&profile_id) {
|
||||||
self.load_profile(profile.clone(), cx);
|
self.load_profile(profile.clone(), cx);
|
||||||
@@ -541,8 +486,8 @@ impl ThreadStore {
|
|||||||
ToolSource::Native,
|
ToolSource::Native,
|
||||||
&profile
|
&profile
|
||||||
.tools
|
.tools
|
||||||
.into_iter()
|
.iter()
|
||||||
.filter_map(|(tool, enabled)| enabled.then(|| tool))
|
.filter_map(|(tool, enabled)| enabled.then(|| tool.clone()))
|
||||||
.collect::<Vec<_>>(),
|
.collect::<Vec<_>>(),
|
||||||
cx,
|
cx,
|
||||||
);
|
);
|
||||||
@@ -566,32 +511,32 @@ impl ThreadStore {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
// Enable all the tools from all context servers, but disable the ones that are explicitly disabled
|
// Enable all the tools from all context servers, but disable the ones that are explicitly disabled
|
||||||
for (context_server_id, preset) in profile.context_servers {
|
for (context_server_id, preset) in &profile.context_servers {
|
||||||
self.tools.update(cx, |tools, cx| {
|
self.tools.update(cx, |tools, cx| {
|
||||||
tools.disable(
|
tools.disable(
|
||||||
ToolSource::ContextServer {
|
ToolSource::ContextServer {
|
||||||
id: context_server_id.into(),
|
id: context_server_id.clone().into(),
|
||||||
},
|
},
|
||||||
&preset
|
&preset
|
||||||
.tools
|
.tools
|
||||||
.into_iter()
|
.iter()
|
||||||
.filter_map(|(tool, enabled)| (!enabled).then(|| tool))
|
.filter_map(|(tool, enabled)| (!enabled).then(|| tool.clone()))
|
||||||
.collect::<Vec<_>>(),
|
.collect::<Vec<_>>(),
|
||||||
cx,
|
cx,
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
for (context_server_id, preset) in profile.context_servers {
|
for (context_server_id, preset) in &profile.context_servers {
|
||||||
self.tools.update(cx, |tools, cx| {
|
self.tools.update(cx, |tools, cx| {
|
||||||
tools.enable(
|
tools.enable(
|
||||||
ToolSource::ContextServer {
|
ToolSource::ContextServer {
|
||||||
id: context_server_id.into(),
|
id: context_server_id.clone().into(),
|
||||||
},
|
},
|
||||||
&preset
|
&preset
|
||||||
.tools
|
.tools
|
||||||
.into_iter()
|
.iter()
|
||||||
.filter_map(|(tool, enabled)| enabled.then(|| tool))
|
.filter_map(|(tool, enabled)| enabled.then(|| tool.clone()))
|
||||||
.collect::<Vec<_>>(),
|
.collect::<Vec<_>>(),
|
||||||
cx,
|
cx,
|
||||||
)
|
)
|
||||||
@@ -713,7 +658,7 @@ pub struct SerializedThread {
|
|||||||
#[serde(default)]
|
#[serde(default)]
|
||||||
pub completion_mode: Option<CompletionMode>,
|
pub completion_mode: Option<CompletionMode>,
|
||||||
#[serde(default)]
|
#[serde(default)]
|
||||||
pub tool_use_limit_reached: bool,
|
pub profile: Option<AgentProfileId>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Serialize, Deserialize, Debug)]
|
#[derive(Serialize, Deserialize, Debug)]
|
||||||
@@ -737,14 +682,20 @@ impl SerializedThread {
|
|||||||
SerializedThread::VERSION => Ok(serde_json::from_value::<SerializedThread>(
|
SerializedThread::VERSION => Ok(serde_json::from_value::<SerializedThread>(
|
||||||
saved_thread_json,
|
saved_thread_json,
|
||||||
)?),
|
)?),
|
||||||
_ => anyhow::bail!("unrecognized serialized thread version: {version:?}"),
|
_ => Err(anyhow!(
|
||||||
|
"unrecognized serialized thread version: {}",
|
||||||
|
version
|
||||||
|
)),
|
||||||
},
|
},
|
||||||
None => {
|
None => {
|
||||||
let saved_thread =
|
let saved_thread =
|
||||||
serde_json::from_value::<LegacySerializedThread>(saved_thread_json)?;
|
serde_json::from_value::<LegacySerializedThread>(saved_thread_json)?;
|
||||||
Ok(saved_thread.upgrade())
|
Ok(saved_thread.upgrade())
|
||||||
}
|
}
|
||||||
version => anyhow::bail!("unrecognized serialized thread version: {version:?}"),
|
version => Err(anyhow!(
|
||||||
|
"unrecognized serialized thread version: {:?}",
|
||||||
|
version
|
||||||
|
)),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -795,8 +746,6 @@ pub struct SerializedMessage {
|
|||||||
pub context: String,
|
pub context: String,
|
||||||
#[serde(default)]
|
#[serde(default)]
|
||||||
pub creases: Vec<SerializedCrease>,
|
pub creases: Vec<SerializedCrease>,
|
||||||
#[serde(default)]
|
|
||||||
pub is_hidden: bool,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Serialize, Deserialize)]
|
#[derive(Debug, Serialize, Deserialize)]
|
||||||
@@ -828,7 +777,7 @@ pub struct SerializedToolUse {
|
|||||||
pub struct SerializedToolResult {
|
pub struct SerializedToolResult {
|
||||||
pub tool_use_id: LanguageModelToolUseId,
|
pub tool_use_id: LanguageModelToolUseId,
|
||||||
pub is_error: bool,
|
pub is_error: bool,
|
||||||
pub content: LanguageModelToolResultContent,
|
pub content: Arc<str>,
|
||||||
pub output: Option<serde_json::Value>,
|
pub output: Option<serde_json::Value>,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -855,7 +804,7 @@ impl LegacySerializedThread {
|
|||||||
exceeded_window_error: None,
|
exceeded_window_error: None,
|
||||||
model: None,
|
model: None,
|
||||||
completion_mode: None,
|
completion_mode: None,
|
||||||
tool_use_limit_reached: false,
|
profile: None,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -881,7 +830,6 @@ impl LegacySerializedMessage {
|
|||||||
tool_results: self.tool_results,
|
tool_results: self.tool_results,
|
||||||
context: String::new(),
|
context: String::new(),
|
||||||
creases: Vec::new(),
|
creases: Vec::new(),
|
||||||
is_hidden: false,
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -902,27 +850,25 @@ impl Global for GlobalThreadsDatabase {}
|
|||||||
|
|
||||||
pub(crate) struct ThreadsDatabase {
|
pub(crate) struct ThreadsDatabase {
|
||||||
executor: BackgroundExecutor,
|
executor: BackgroundExecutor,
|
||||||
connection: Arc<Mutex<Connection>>,
|
env: heed::Env,
|
||||||
|
threads: Database<SerdeBincode<ThreadId>, SerializedThread>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ThreadsDatabase {
|
impl heed::BytesEncode<'_> for SerializedThread {
|
||||||
fn connection(&self) -> Arc<Mutex<Connection>> {
|
type EItem = SerializedThread;
|
||||||
self.connection.clone()
|
|
||||||
}
|
|
||||||
|
|
||||||
const COMPRESSION_LEVEL: i32 = 3;
|
fn bytes_encode(item: &Self::EItem) -> Result<Cow<[u8]>, heed::BoxedError> {
|
||||||
}
|
serde_json::to_vec(item).map(Cow::Owned).map_err(Into::into)
|
||||||
|
|
||||||
impl Bind for ThreadId {
|
|
||||||
fn bind(&self, statement: &Statement, start_index: i32) -> Result<i32> {
|
|
||||||
self.to_string().bind(statement, start_index)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Column for ThreadId {
|
impl<'a> heed::BytesDecode<'a> for SerializedThread {
|
||||||
fn column(statement: &mut Statement, start_index: i32) -> Result<(Self, i32)> {
|
type DItem = SerializedThread;
|
||||||
let (id_str, next_index) = String::column(statement, start_index)?;
|
|
||||||
Ok((ThreadId::from(id_str.as_str()), next_index))
|
fn bytes_decode(bytes: &'a [u8]) -> Result<Self::DItem, heed::BoxedError> {
|
||||||
|
// We implement this type manually because we want to call `SerializedThread::from_json`,
|
||||||
|
// instead of the Deserialize trait implementation for `SerializedThread`.
|
||||||
|
SerializedThread::from_json(bytes).map_err(Into::into)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -938,8 +884,8 @@ impl ThreadsDatabase {
|
|||||||
let database_future = executor
|
let database_future = executor
|
||||||
.spawn({
|
.spawn({
|
||||||
let executor = executor.clone();
|
let executor = executor.clone();
|
||||||
let threads_dir = paths::data_dir().join("threads");
|
let database_path = paths::data_dir().join("threads/threads-db.1.mdb");
|
||||||
async move { ThreadsDatabase::new(threads_dir, executor) }
|
async move { ThreadsDatabase::new(database_path, executor) }
|
||||||
})
|
})
|
||||||
.then(|result| future::ready(result.map(Arc::new).map_err(Arc::new)))
|
.then(|result| future::ready(result.map(Arc::new).map_err(Arc::new)))
|
||||||
.boxed()
|
.boxed()
|
||||||
@@ -948,144 +894,41 @@ impl ThreadsDatabase {
|
|||||||
cx.set_global(GlobalThreadsDatabase(database_future));
|
cx.set_global(GlobalThreadsDatabase(database_future));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn new(threads_dir: PathBuf, executor: BackgroundExecutor) -> Result<Self> {
|
pub fn new(path: PathBuf, executor: BackgroundExecutor) -> Result<Self> {
|
||||||
std::fs::create_dir_all(&threads_dir)?;
|
std::fs::create_dir_all(&path)?;
|
||||||
|
|
||||||
let sqlite_path = threads_dir.join("threads.db");
|
|
||||||
let mdb_path = threads_dir.join("threads-db.1.mdb");
|
|
||||||
|
|
||||||
let needs_migration_from_heed = mdb_path.exists();
|
|
||||||
|
|
||||||
let connection = Connection::open_file(&sqlite_path.to_string_lossy());
|
|
||||||
|
|
||||||
connection.exec(indoc! {"
|
|
||||||
CREATE TABLE IF NOT EXISTS threads (
|
|
||||||
id TEXT PRIMARY KEY,
|
|
||||||
summary TEXT NOT NULL,
|
|
||||||
updated_at TEXT NOT NULL,
|
|
||||||
data_type TEXT NOT NULL,
|
|
||||||
data BLOB NOT NULL
|
|
||||||
)
|
|
||||||
"})?()
|
|
||||||
.map_err(|e| anyhow!("Failed to create threads table: {}", e))?;
|
|
||||||
|
|
||||||
let db = Self {
|
|
||||||
executor: executor.clone(),
|
|
||||||
connection: Arc::new(Mutex::new(connection)),
|
|
||||||
};
|
|
||||||
|
|
||||||
if needs_migration_from_heed {
|
|
||||||
let db_connection = db.connection();
|
|
||||||
let executor_clone = executor.clone();
|
|
||||||
executor
|
|
||||||
.spawn(async move {
|
|
||||||
log::info!("Starting threads.db migration");
|
|
||||||
Self::migrate_from_heed(&mdb_path, db_connection, executor_clone)?;
|
|
||||||
std::fs::remove_dir_all(mdb_path)?;
|
|
||||||
log::info!("threads.db migrated to sqlite");
|
|
||||||
Ok::<(), anyhow::Error>(())
|
|
||||||
})
|
|
||||||
.detach();
|
|
||||||
}
|
|
||||||
|
|
||||||
Ok(db)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Remove this migration after 2025-09-01
|
|
||||||
fn migrate_from_heed(
|
|
||||||
mdb_path: &Path,
|
|
||||||
connection: Arc<Mutex<Connection>>,
|
|
||||||
_executor: BackgroundExecutor,
|
|
||||||
) -> Result<()> {
|
|
||||||
use heed::types::SerdeBincode;
|
|
||||||
struct SerializedThreadHeed(SerializedThread);
|
|
||||||
|
|
||||||
impl heed::BytesEncode<'_> for SerializedThreadHeed {
|
|
||||||
type EItem = SerializedThreadHeed;
|
|
||||||
|
|
||||||
fn bytes_encode(
|
|
||||||
item: &Self::EItem,
|
|
||||||
) -> Result<std::borrow::Cow<[u8]>, heed::BoxedError> {
|
|
||||||
serde_json::to_vec(&item.0)
|
|
||||||
.map(std::borrow::Cow::Owned)
|
|
||||||
.map_err(Into::into)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl<'a> heed::BytesDecode<'a> for SerializedThreadHeed {
|
|
||||||
type DItem = SerializedThreadHeed;
|
|
||||||
|
|
||||||
fn bytes_decode(bytes: &'a [u8]) -> Result<Self::DItem, heed::BoxedError> {
|
|
||||||
SerializedThread::from_json(bytes)
|
|
||||||
.map(SerializedThreadHeed)
|
|
||||||
.map_err(Into::into)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const ONE_GB_IN_BYTES: usize = 1024 * 1024 * 1024;
|
const ONE_GB_IN_BYTES: usize = 1024 * 1024 * 1024;
|
||||||
|
|
||||||
let env = unsafe {
|
let env = unsafe {
|
||||||
heed::EnvOpenOptions::new()
|
heed::EnvOpenOptions::new()
|
||||||
.map_size(ONE_GB_IN_BYTES)
|
.map_size(ONE_GB_IN_BYTES)
|
||||||
.max_dbs(1)
|
.max_dbs(1)
|
||||||
.open(mdb_path)?
|
.open(path)?
|
||||||
};
|
};
|
||||||
|
|
||||||
let txn = env.write_txn()?;
|
let mut txn = env.write_txn()?;
|
||||||
let threads: heed::Database<SerdeBincode<ThreadId>, SerializedThreadHeed> = env
|
let threads = env.create_database(&mut txn, Some("threads"))?;
|
||||||
.open_database(&txn, Some("threads"))?
|
txn.commit()?;
|
||||||
.ok_or_else(|| anyhow!("threads database not found"))?;
|
|
||||||
|
|
||||||
for result in threads.iter(&txn)? {
|
Ok(Self {
|
||||||
let (thread_id, thread_heed) = result?;
|
executor,
|
||||||
Self::save_thread_sync(&connection, thread_id, thread_heed.0)?;
|
env,
|
||||||
}
|
threads,
|
||||||
|
})
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
|
|
||||||
fn save_thread_sync(
|
|
||||||
connection: &Arc<Mutex<Connection>>,
|
|
||||||
id: ThreadId,
|
|
||||||
thread: SerializedThread,
|
|
||||||
) -> Result<()> {
|
|
||||||
let json_data = serde_json::to_string(&thread)?;
|
|
||||||
let summary = thread.summary.to_string();
|
|
||||||
let updated_at = thread.updated_at.to_rfc3339();
|
|
||||||
|
|
||||||
let connection = connection.lock().unwrap();
|
|
||||||
|
|
||||||
let compressed = zstd::encode_all(json_data.as_bytes(), Self::COMPRESSION_LEVEL)?;
|
|
||||||
let data_type = DataType::Zstd;
|
|
||||||
let data = compressed;
|
|
||||||
|
|
||||||
let mut insert = connection.exec_bound::<(ThreadId, String, String, DataType, Vec<u8>)>(indoc! {"
|
|
||||||
INSERT OR REPLACE INTO threads (id, summary, updated_at, data_type, data) VALUES (?, ?, ?, ?, ?)
|
|
||||||
"})?;
|
|
||||||
|
|
||||||
insert((id, summary, updated_at, data_type, data))?;
|
|
||||||
|
|
||||||
Ok(())
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn list_threads(&self) -> Task<Result<Vec<SerializedThreadMetadata>>> {
|
pub fn list_threads(&self) -> Task<Result<Vec<SerializedThreadMetadata>>> {
|
||||||
let connection = self.connection.clone();
|
let env = self.env.clone();
|
||||||
|
let threads = self.threads;
|
||||||
|
|
||||||
self.executor.spawn(async move {
|
self.executor.spawn(async move {
|
||||||
let connection = connection.lock().unwrap();
|
let txn = env.read_txn()?;
|
||||||
let mut select =
|
let mut iter = threads.iter(&txn)?;
|
||||||
connection.select_bound::<(), (ThreadId, String, String)>(indoc! {"
|
|
||||||
SELECT id, summary, updated_at FROM threads ORDER BY updated_at DESC
|
|
||||||
"})?;
|
|
||||||
|
|
||||||
let rows = select(())?;
|
|
||||||
let mut threads = Vec::new();
|
let mut threads = Vec::new();
|
||||||
|
while let Some((key, value)) = iter.next().transpose()? {
|
||||||
for (id, summary, updated_at) in rows {
|
|
||||||
threads.push(SerializedThreadMetadata {
|
threads.push(SerializedThreadMetadata {
|
||||||
id,
|
id: key,
|
||||||
summary: summary.into(),
|
summary: value.summary,
|
||||||
updated_at: DateTime::parse_from_rfc3339(&updated_at)?.with_timezone(&Utc),
|
updated_at: value.updated_at,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1094,51 +937,36 @@ impl ThreadsDatabase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn try_find_thread(&self, id: ThreadId) -> Task<Result<Option<SerializedThread>>> {
|
pub fn try_find_thread(&self, id: ThreadId) -> Task<Result<Option<SerializedThread>>> {
|
||||||
let connection = self.connection.clone();
|
let env = self.env.clone();
|
||||||
|
let threads = self.threads;
|
||||||
|
|
||||||
self.executor.spawn(async move {
|
self.executor.spawn(async move {
|
||||||
let connection = connection.lock().unwrap();
|
let txn = env.read_txn()?;
|
||||||
let mut select = connection.select_bound::<ThreadId, (DataType, Vec<u8>)>(indoc! {"
|
let thread = threads.get(&txn, &id)?;
|
||||||
SELECT data_type, data FROM threads WHERE id = ? LIMIT 1
|
Ok(thread)
|
||||||
"})?;
|
|
||||||
|
|
||||||
let rows = select(id)?;
|
|
||||||
if let Some((data_type, data)) = rows.into_iter().next() {
|
|
||||||
let json_data = match data_type {
|
|
||||||
DataType::Zstd => {
|
|
||||||
let decompressed = zstd::decode_all(&data[..])?;
|
|
||||||
String::from_utf8(decompressed)?
|
|
||||||
}
|
|
||||||
DataType::Json => String::from_utf8(data)?,
|
|
||||||
};
|
|
||||||
|
|
||||||
let thread = SerializedThread::from_json(json_data.as_bytes())?;
|
|
||||||
Ok(Some(thread))
|
|
||||||
} else {
|
|
||||||
Ok(None)
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn save_thread(&self, id: ThreadId, thread: SerializedThread) -> Task<Result<()>> {
|
pub fn save_thread(&self, id: ThreadId, thread: SerializedThread) -> Task<Result<()>> {
|
||||||
let connection = self.connection.clone();
|
let env = self.env.clone();
|
||||||
|
let threads = self.threads;
|
||||||
|
|
||||||
self.executor
|
self.executor.spawn(async move {
|
||||||
.spawn(async move { Self::save_thread_sync(&connection, id, thread) })
|
let mut txn = env.write_txn()?;
|
||||||
|
threads.put(&mut txn, &id, &thread)?;
|
||||||
|
txn.commit()?;
|
||||||
|
Ok(())
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn delete_thread(&self, id: ThreadId) -> Task<Result<()>> {
|
pub fn delete_thread(&self, id: ThreadId) -> Task<Result<()>> {
|
||||||
let connection = self.connection.clone();
|
let env = self.env.clone();
|
||||||
|
let threads = self.threads;
|
||||||
|
|
||||||
self.executor.spawn(async move {
|
self.executor.spawn(async move {
|
||||||
let connection = connection.lock().unwrap();
|
let mut txn = env.write_txn()?;
|
||||||
|
threads.delete(&mut txn, &id)?;
|
||||||
let mut delete = connection.exec_bound::<ThreadId>(indoc! {"
|
txn.commit()?;
|
||||||
DELETE FROM threads WHERE id = ?
|
|
||||||
"})?;
|
|
||||||
|
|
||||||
delete(id)?;
|
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,16 +1,14 @@
|
|||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
|
||||||
use anyhow::Result;
|
use anyhow::Result;
|
||||||
use assistant_tool::{
|
use assistant_tool::{AnyToolCard, Tool, ToolResultOutput, ToolUseStatus, ToolWorkingSet};
|
||||||
AnyToolCard, Tool, ToolResultContent, ToolResultOutput, ToolUseStatus, ToolWorkingSet,
|
|
||||||
};
|
|
||||||
use collections::HashMap;
|
use collections::HashMap;
|
||||||
use futures::FutureExt as _;
|
use futures::FutureExt as _;
|
||||||
use futures::future::Shared;
|
use futures::future::Shared;
|
||||||
use gpui::{App, Entity, SharedString, Task};
|
use gpui::{App, Entity, SharedString, Task};
|
||||||
use language_model::{
|
use language_model::{
|
||||||
ConfiguredModel, LanguageModel, LanguageModelRequest, LanguageModelToolResult,
|
ConfiguredModel, LanguageModel, LanguageModelRequest, LanguageModelToolResult,
|
||||||
LanguageModelToolResultContent, LanguageModelToolUse, LanguageModelToolUseId, Role,
|
LanguageModelToolUse, LanguageModelToolUseId, Role,
|
||||||
};
|
};
|
||||||
use project::Project;
|
use project::Project;
|
||||||
use ui::{IconName, Window};
|
use ui::{IconName, Window};
|
||||||
@@ -54,19 +52,15 @@ impl ToolUseState {
|
|||||||
/// Constructs a [`ToolUseState`] from the given list of [`SerializedMessage`]s.
|
/// Constructs a [`ToolUseState`] from the given list of [`SerializedMessage`]s.
|
||||||
///
|
///
|
||||||
/// Accepts a function to filter the tools that should be used to populate the state.
|
/// Accepts a function to filter the tools that should be used to populate the state.
|
||||||
///
|
|
||||||
/// If `window` is `None` (e.g., when in headless mode or when running evals),
|
|
||||||
/// tool cards won't be deserialized
|
|
||||||
pub fn from_serialized_messages(
|
pub fn from_serialized_messages(
|
||||||
tools: Entity<ToolWorkingSet>,
|
tools: Entity<ToolWorkingSet>,
|
||||||
messages: &[SerializedMessage],
|
messages: &[SerializedMessage],
|
||||||
project: Entity<Project>,
|
project: Entity<Project>,
|
||||||
window: Option<&mut Window>, // None in headless mode
|
window: &mut Window,
|
||||||
cx: &mut App,
|
cx: &mut App,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
let mut this = Self::new(tools);
|
let mut this = Self::new(tools);
|
||||||
let mut tool_names_by_id = HashMap::default();
|
let mut tool_names_by_id = HashMap::default();
|
||||||
let mut window = window;
|
|
||||||
|
|
||||||
for message in messages {
|
for message in messages {
|
||||||
match message.role {
|
match message.role {
|
||||||
@@ -111,17 +105,12 @@ impl ToolUseState {
|
|||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
if let Some(window) = &mut window {
|
if let Some(tool) = this.tools.read(cx).tool(tool_use, cx) {
|
||||||
if let Some(tool) = this.tools.read(cx).tool(tool_use, cx) {
|
if let Some(output) = tool_result.output.clone() {
|
||||||
if let Some(output) = tool_result.output.clone() {
|
if let Some(card) =
|
||||||
if let Some(card) = tool.deserialize_card(
|
tool.deserialize_card(output, project.clone(), window, cx)
|
||||||
output,
|
{
|
||||||
project.clone(),
|
this.tool_result_cards.insert(tool_use_id, card);
|
||||||
window,
|
|
||||||
cx,
|
|
||||||
) {
|
|
||||||
this.tool_result_cards.insert(tool_use_id, card);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -176,16 +165,10 @@ impl ToolUseState {
|
|||||||
|
|
||||||
let status = (|| {
|
let status = (|| {
|
||||||
if let Some(tool_result) = tool_result {
|
if let Some(tool_result) = tool_result {
|
||||||
let content = tool_result
|
|
||||||
.content
|
|
||||||
.to_str()
|
|
||||||
.map(|str| str.to_owned().into())
|
|
||||||
.unwrap_or_default();
|
|
||||||
|
|
||||||
return if tool_result.is_error {
|
return if tool_result.is_error {
|
||||||
ToolUseStatus::Error(content)
|
ToolUseStatus::Error(tool_result.content.clone().into())
|
||||||
} else {
|
} else {
|
||||||
ToolUseStatus::Finished(content)
|
ToolUseStatus::Finished(tool_result.content.clone().into())
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -337,12 +320,6 @@ impl ToolUseState {
|
|||||||
)
|
)
|
||||||
.into();
|
.into();
|
||||||
|
|
||||||
let may_perform_edits = self
|
|
||||||
.tools
|
|
||||||
.read(cx)
|
|
||||||
.tool(&tool_use.name, cx)
|
|
||||||
.is_some_and(|tool| tool.may_perform_edits());
|
|
||||||
|
|
||||||
self.pending_tool_uses_by_id.insert(
|
self.pending_tool_uses_by_id.insert(
|
||||||
tool_use.id.clone(),
|
tool_use.id.clone(),
|
||||||
PendingToolUse {
|
PendingToolUse {
|
||||||
@@ -351,7 +328,6 @@ impl ToolUseState {
|
|||||||
name: tool_use.name.clone(),
|
name: tool_use.name.clone(),
|
||||||
ui_text: ui_text.clone(),
|
ui_text: ui_text.clone(),
|
||||||
input: tool_use.input,
|
input: tool_use.input,
|
||||||
may_perform_edits,
|
|
||||||
status,
|
status,
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
@@ -423,45 +399,21 @@ impl ToolUseState {
|
|||||||
let tool_result = output.content;
|
let tool_result = output.content;
|
||||||
const BYTES_PER_TOKEN_ESTIMATE: usize = 3;
|
const BYTES_PER_TOKEN_ESTIMATE: usize = 3;
|
||||||
|
|
||||||
let old_use = self.pending_tool_uses_by_id.remove(&tool_use_id);
|
// Protect from clearly large output
|
||||||
|
|
||||||
// Protect from overly large output
|
|
||||||
let tool_output_limit = configured_model
|
let tool_output_limit = configured_model
|
||||||
.map(|model| model.model.max_token_count() * BYTES_PER_TOKEN_ESTIMATE)
|
.map(|model| model.model.max_token_count() * BYTES_PER_TOKEN_ESTIMATE)
|
||||||
.unwrap_or(usize::MAX);
|
.unwrap_or(usize::MAX);
|
||||||
|
|
||||||
let content = match tool_result {
|
let tool_result = if tool_result.len() <= tool_output_limit {
|
||||||
ToolResultContent::Text(text) => {
|
tool_result
|
||||||
let text = if text.len() < tool_output_limit {
|
} else {
|
||||||
text
|
let truncated = truncate_lines_to_byte_limit(&tool_result, tool_output_limit);
|
||||||
} else {
|
|
||||||
let truncated = truncate_lines_to_byte_limit(&text, tool_output_limit);
|
|
||||||
format!(
|
|
||||||
"Tool result too long. The first {} bytes:\n\n{}",
|
|
||||||
truncated.len(),
|
|
||||||
truncated
|
|
||||||
)
|
|
||||||
};
|
|
||||||
LanguageModelToolResultContent::Text(text.into())
|
|
||||||
}
|
|
||||||
ToolResultContent::Image(language_model_image) => {
|
|
||||||
if language_model_image.estimate_tokens() < tool_output_limit {
|
|
||||||
LanguageModelToolResultContent::Image(language_model_image)
|
|
||||||
} else {
|
|
||||||
self.tool_results.insert(
|
|
||||||
tool_use_id.clone(),
|
|
||||||
LanguageModelToolResult {
|
|
||||||
tool_use_id: tool_use_id.clone(),
|
|
||||||
tool_name,
|
|
||||||
content: "Tool responded with an image that would exceeded the remaining tokens".into(),
|
|
||||||
is_error: true,
|
|
||||||
output: None,
|
|
||||||
},
|
|
||||||
);
|
|
||||||
|
|
||||||
return old_use;
|
format!(
|
||||||
}
|
"Tool result too long. The first {} bytes:\n\n{}",
|
||||||
}
|
truncated.len(),
|
||||||
|
truncated
|
||||||
|
)
|
||||||
};
|
};
|
||||||
|
|
||||||
self.tool_results.insert(
|
self.tool_results.insert(
|
||||||
@@ -469,13 +421,12 @@ impl ToolUseState {
|
|||||||
LanguageModelToolResult {
|
LanguageModelToolResult {
|
||||||
tool_use_id: tool_use_id.clone(),
|
tool_use_id: tool_use_id.clone(),
|
||||||
tool_name,
|
tool_name,
|
||||||
content,
|
content: tool_result.into(),
|
||||||
is_error: false,
|
is_error: false,
|
||||||
output: output.output,
|
output: output.output,
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
self.pending_tool_uses_by_id.remove(&tool_use_id)
|
||||||
old_use
|
|
||||||
}
|
}
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
self.tool_results.insert(
|
self.tool_results.insert(
|
||||||
@@ -483,7 +434,7 @@ impl ToolUseState {
|
|||||||
LanguageModelToolResult {
|
LanguageModelToolResult {
|
||||||
tool_use_id: tool_use_id.clone(),
|
tool_use_id: tool_use_id.clone(),
|
||||||
tool_name,
|
tool_name,
|
||||||
content: LanguageModelToolResultContent::Text(err.to_string().into()),
|
content: err.to_string().into(),
|
||||||
is_error: true,
|
is_error: true,
|
||||||
output: None,
|
output: None,
|
||||||
},
|
},
|
||||||
@@ -525,7 +476,6 @@ pub struct PendingToolUse {
|
|||||||
pub ui_text: Arc<str>,
|
pub ui_text: Arc<str>,
|
||||||
pub input: serde_json::Value,
|
pub input: serde_json::Value,
|
||||||
pub status: PendingToolUseStatus,
|
pub status: PendingToolUseStatus,
|
||||||
pub may_perform_edits: bool,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
|
|||||||
3
crates/agent/src/trial_markdown.md
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
# Build better with Zed Pro
|
||||||
|
|
||||||
|
Try [Zed Pro](https://zed.dev/pricing) for free for 14 days - no credit card required. Only $20/month afterward. Cancel anytime.
|
||||||
@@ -93,9 +93,20 @@ impl ContextPill {
|
|||||||
Self::Suggested {
|
Self::Suggested {
|
||||||
icon_path: Some(icon_path),
|
icon_path: Some(icon_path),
|
||||||
..
|
..
|
||||||
|
}
|
||||||
|
| Self::Added {
|
||||||
|
context:
|
||||||
|
AddedContext {
|
||||||
|
icon_path: Some(icon_path),
|
||||||
|
..
|
||||||
|
},
|
||||||
|
..
|
||||||
} => Icon::from_path(icon_path),
|
} => Icon::from_path(icon_path),
|
||||||
Self::Suggested { kind, .. } => Icon::new(kind.icon()),
|
Self::Suggested { kind, .. }
|
||||||
Self::Added { context, .. } => context.icon(),
|
| Self::Added {
|
||||||
|
context: AddedContext { kind, .. },
|
||||||
|
..
|
||||||
|
} => Icon::new(kind.icon()),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -122,7 +133,6 @@ impl RenderOnce for ContextPill {
|
|||||||
on_click,
|
on_click,
|
||||||
} => {
|
} => {
|
||||||
let status_is_error = matches!(context.status, ContextStatus::Error { .. });
|
let status_is_error = matches!(context.status, ContextStatus::Error { .. });
|
||||||
let status_is_warning = matches!(context.status, ContextStatus::Warning { .. });
|
|
||||||
|
|
||||||
base_pill
|
base_pill
|
||||||
.pr(if on_remove.is_some() { px(2.) } else { px(4.) })
|
.pr(if on_remove.is_some() { px(2.) } else { px(4.) })
|
||||||
@@ -130,9 +140,6 @@ impl RenderOnce for ContextPill {
|
|||||||
if status_is_error {
|
if status_is_error {
|
||||||
pill.bg(cx.theme().status().error_background)
|
pill.bg(cx.theme().status().error_background)
|
||||||
.border_color(cx.theme().status().error_border)
|
.border_color(cx.theme().status().error_border)
|
||||||
} else if status_is_warning {
|
|
||||||
pill.bg(cx.theme().status().warning_background)
|
|
||||||
.border_color(cx.theme().status().warning_border)
|
|
||||||
} else if *focused {
|
} else if *focused {
|
||||||
pill.bg(color.element_background)
|
pill.bg(color.element_background)
|
||||||
.border_color(color.border_focused)
|
.border_color(color.border_focused)
|
||||||
@@ -188,8 +195,7 @@ impl RenderOnce for ContextPill {
|
|||||||
|label, delta| label.opacity(delta),
|
|label, delta| label.opacity(delta),
|
||||||
)
|
)
|
||||||
.into_any_element(),
|
.into_any_element(),
|
||||||
ContextStatus::Warning { message }
|
ContextStatus::Error { message } => element
|
||||||
| ContextStatus::Error { message } => element
|
|
||||||
.tooltip(ui::Tooltip::text(message.clone()))
|
.tooltip(ui::Tooltip::text(message.clone()))
|
||||||
.into_any_element(),
|
.into_any_element(),
|
||||||
}),
|
}),
|
||||||
@@ -264,7 +270,6 @@ pub enum ContextStatus {
|
|||||||
Ready,
|
Ready,
|
||||||
Loading { message: SharedString },
|
Loading { message: SharedString },
|
||||||
Error { message: SharedString },
|
Error { message: SharedString },
|
||||||
Warning { message: SharedString },
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(RegisterComponent)]
|
#[derive(RegisterComponent)]
|
||||||
@@ -280,19 +285,6 @@ pub struct AddedContext {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl AddedContext {
|
impl AddedContext {
|
||||||
pub fn icon(&self) -> Icon {
|
|
||||||
match &self.status {
|
|
||||||
ContextStatus::Warning { .. } => Icon::new(IconName::Warning).color(Color::Warning),
|
|
||||||
ContextStatus::Error { .. } => Icon::new(IconName::XCircle).color(Color::Error),
|
|
||||||
_ => {
|
|
||||||
if let Some(icon_path) = &self.icon_path {
|
|
||||||
Icon::from_path(icon_path)
|
|
||||||
} else {
|
|
||||||
Icon::new(self.kind.icon())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/// Creates an `AddedContext` by retrieving relevant details of `AgentContext`. This returns a
|
/// Creates an `AddedContext` by retrieving relevant details of `AgentContext`. This returns a
|
||||||
/// `None` if `DirectoryContext` or `RulesContext` no longer exist.
|
/// `None` if `DirectoryContext` or `RulesContext` no longer exist.
|
||||||
///
|
///
|
||||||
@@ -301,7 +293,6 @@ impl AddedContext {
|
|||||||
handle: AgentContextHandle,
|
handle: AgentContextHandle,
|
||||||
prompt_store: Option<&Entity<PromptStore>>,
|
prompt_store: Option<&Entity<PromptStore>>,
|
||||||
project: &Project,
|
project: &Project,
|
||||||
model: Option<&Arc<dyn language_model::LanguageModel>>,
|
|
||||||
cx: &App,
|
cx: &App,
|
||||||
) -> Option<AddedContext> {
|
) -> Option<AddedContext> {
|
||||||
match handle {
|
match handle {
|
||||||
@@ -313,15 +304,11 @@ impl AddedContext {
|
|||||||
AgentContextHandle::Thread(handle) => Some(Self::pending_thread(handle, cx)),
|
AgentContextHandle::Thread(handle) => Some(Self::pending_thread(handle, cx)),
|
||||||
AgentContextHandle::TextThread(handle) => Some(Self::pending_text_thread(handle, cx)),
|
AgentContextHandle::TextThread(handle) => Some(Self::pending_text_thread(handle, cx)),
|
||||||
AgentContextHandle::Rules(handle) => Self::pending_rules(handle, prompt_store, cx),
|
AgentContextHandle::Rules(handle) => Self::pending_rules(handle, prompt_store, cx),
|
||||||
AgentContextHandle::Image(handle) => Some(Self::image(handle, model, cx)),
|
AgentContextHandle::Image(handle) => Some(Self::image(handle)),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn new_attached(
|
pub fn new_attached(context: &AgentContext, cx: &App) -> AddedContext {
|
||||||
context: &AgentContext,
|
|
||||||
model: Option<&Arc<dyn language_model::LanguageModel>>,
|
|
||||||
cx: &App,
|
|
||||||
) -> AddedContext {
|
|
||||||
match context {
|
match context {
|
||||||
AgentContext::File(context) => Self::attached_file(context, cx),
|
AgentContext::File(context) => Self::attached_file(context, cx),
|
||||||
AgentContext::Directory(context) => Self::attached_directory(context),
|
AgentContext::Directory(context) => Self::attached_directory(context),
|
||||||
@@ -331,7 +318,7 @@ impl AddedContext {
|
|||||||
AgentContext::Thread(context) => Self::attached_thread(context),
|
AgentContext::Thread(context) => Self::attached_thread(context),
|
||||||
AgentContext::TextThread(context) => Self::attached_text_thread(context),
|
AgentContext::TextThread(context) => Self::attached_text_thread(context),
|
||||||
AgentContext::Rules(context) => Self::attached_rules(context),
|
AgentContext::Rules(context) => Self::attached_rules(context),
|
||||||
AgentContext::Image(context) => Self::image(context.clone(), model, cx),
|
AgentContext::Image(context) => Self::image(context.clone()),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -346,8 +333,14 @@ impl AddedContext {
|
|||||||
|
|
||||||
fn file(handle: FileContextHandle, full_path: &Path, cx: &App) -> AddedContext {
|
fn file(handle: FileContextHandle, full_path: &Path, cx: &App) -> AddedContext {
|
||||||
let full_path_string: SharedString = full_path.to_string_lossy().into_owned().into();
|
let full_path_string: SharedString = full_path.to_string_lossy().into_owned().into();
|
||||||
let (name, parent) =
|
let name = full_path
|
||||||
extract_file_name_and_directory_from_full_path(full_path, &full_path_string);
|
.file_name()
|
||||||
|
.map(|n| n.to_string_lossy().into_owned().into())
|
||||||
|
.unwrap_or_else(|| full_path_string.clone());
|
||||||
|
let parent = full_path
|
||||||
|
.parent()
|
||||||
|
.and_then(|p| p.file_name())
|
||||||
|
.map(|n| n.to_string_lossy().into_owned().into());
|
||||||
AddedContext {
|
AddedContext {
|
||||||
kind: ContextKind::File,
|
kind: ContextKind::File,
|
||||||
name,
|
name,
|
||||||
@@ -377,8 +370,14 @@ impl AddedContext {
|
|||||||
|
|
||||||
fn directory(handle: DirectoryContextHandle, full_path: &Path) -> AddedContext {
|
fn directory(handle: DirectoryContextHandle, full_path: &Path) -> AddedContext {
|
||||||
let full_path_string: SharedString = full_path.to_string_lossy().into_owned().into();
|
let full_path_string: SharedString = full_path.to_string_lossy().into_owned().into();
|
||||||
let (name, parent) =
|
let name = full_path
|
||||||
extract_file_name_and_directory_from_full_path(full_path, &full_path_string);
|
.file_name()
|
||||||
|
.map(|n| n.to_string_lossy().into_owned().into())
|
||||||
|
.unwrap_or_else(|| full_path_string.clone());
|
||||||
|
let parent = full_path
|
||||||
|
.parent()
|
||||||
|
.and_then(|p| p.file_name())
|
||||||
|
.map(|n| n.to_string_lossy().into_owned().into());
|
||||||
AddedContext {
|
AddedContext {
|
||||||
kind: ContextKind::Directory,
|
kind: ContextKind::Directory,
|
||||||
name,
|
name,
|
||||||
@@ -606,45 +605,22 @@ impl AddedContext {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn image(
|
fn image(context: ImageContext) -> AddedContext {
|
||||||
context: ImageContext,
|
|
||||||
model: Option<&Arc<dyn language_model::LanguageModel>>,
|
|
||||||
cx: &App,
|
|
||||||
) -> AddedContext {
|
|
||||||
let (name, parent, icon_path) = if let Some(full_path) = context.full_path.as_ref() {
|
|
||||||
let full_path_string: SharedString = full_path.to_string_lossy().into_owned().into();
|
|
||||||
let (name, parent) =
|
|
||||||
extract_file_name_and_directory_from_full_path(full_path, &full_path_string);
|
|
||||||
let icon_path = FileIcons::get_icon(&full_path, cx);
|
|
||||||
(name, parent, icon_path)
|
|
||||||
} else {
|
|
||||||
("Image".into(), None, None)
|
|
||||||
};
|
|
||||||
|
|
||||||
let status = match context.status(model) {
|
|
||||||
ImageStatus::Loading => ContextStatus::Loading {
|
|
||||||
message: "Loading…".into(),
|
|
||||||
},
|
|
||||||
ImageStatus::Error => ContextStatus::Error {
|
|
||||||
message: "Failed to load Image".into(),
|
|
||||||
},
|
|
||||||
ImageStatus::Warning => ContextStatus::Warning {
|
|
||||||
message: format!(
|
|
||||||
"{} doesn't support attaching Images as Context",
|
|
||||||
model.map(|m| m.name().0).unwrap_or_else(|| "Model".into())
|
|
||||||
)
|
|
||||||
.into(),
|
|
||||||
},
|
|
||||||
ImageStatus::Ready => ContextStatus::Ready,
|
|
||||||
};
|
|
||||||
|
|
||||||
AddedContext {
|
AddedContext {
|
||||||
kind: ContextKind::Image,
|
kind: ContextKind::Image,
|
||||||
name,
|
name: "Image".into(),
|
||||||
parent,
|
parent: None,
|
||||||
tooltip: None,
|
tooltip: None,
|
||||||
icon_path,
|
icon_path: None,
|
||||||
status,
|
status: match context.status() {
|
||||||
|
ImageStatus::Loading => ContextStatus::Loading {
|
||||||
|
message: "Loading…".into(),
|
||||||
|
},
|
||||||
|
ImageStatus::Error => ContextStatus::Error {
|
||||||
|
message: "Failed to load image".into(),
|
||||||
|
},
|
||||||
|
ImageStatus::Ready => ContextStatus::Ready,
|
||||||
|
},
|
||||||
render_hover: Some(Rc::new({
|
render_hover: Some(Rc::new({
|
||||||
let image = context.original_image.clone();
|
let image = context.original_image.clone();
|
||||||
move |_, cx| {
|
move |_, cx| {
|
||||||
@@ -663,22 +639,6 @@ impl AddedContext {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn extract_file_name_and_directory_from_full_path(
|
|
||||||
path: &Path,
|
|
||||||
name_fallback: &SharedString,
|
|
||||||
) -> (SharedString, Option<SharedString>) {
|
|
||||||
let name = path
|
|
||||||
.file_name()
|
|
||||||
.map(|n| n.to_string_lossy().into_owned().into())
|
|
||||||
.unwrap_or_else(|| name_fallback.clone());
|
|
||||||
let parent = path
|
|
||||||
.parent()
|
|
||||||
.and_then(|p| p.file_name())
|
|
||||||
.map(|n| n.to_string_lossy().into_owned().into());
|
|
||||||
|
|
||||||
(name, parent)
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
struct ContextFileExcerpt {
|
struct ContextFileExcerpt {
|
||||||
pub file_name_and_range: SharedString,
|
pub file_name_and_range: SharedString,
|
||||||
@@ -805,52 +765,37 @@ impl Component for AddedContext {
|
|||||||
let mut next_context_id = ContextId::zero();
|
let mut next_context_id = ContextId::zero();
|
||||||
let image_ready = (
|
let image_ready = (
|
||||||
"Ready",
|
"Ready",
|
||||||
AddedContext::image(
|
AddedContext::image(ImageContext {
|
||||||
ImageContext {
|
context_id: next_context_id.post_inc(),
|
||||||
context_id: next_context_id.post_inc(),
|
project_path: None,
|
||||||
project_path: None,
|
original_image: Arc::new(Image::empty()),
|
||||||
full_path: None,
|
image_task: Task::ready(Some(LanguageModelImage::empty())).shared(),
|
||||||
original_image: Arc::new(Image::empty()),
|
}),
|
||||||
image_task: Task::ready(Some(LanguageModelImage::empty())).shared(),
|
|
||||||
},
|
|
||||||
None,
|
|
||||||
cx,
|
|
||||||
),
|
|
||||||
);
|
);
|
||||||
|
|
||||||
let image_loading = (
|
let image_loading = (
|
||||||
"Loading",
|
"Loading",
|
||||||
AddedContext::image(
|
AddedContext::image(ImageContext {
|
||||||
ImageContext {
|
context_id: next_context_id.post_inc(),
|
||||||
context_id: next_context_id.post_inc(),
|
project_path: None,
|
||||||
project_path: None,
|
original_image: Arc::new(Image::empty()),
|
||||||
full_path: None,
|
image_task: cx
|
||||||
original_image: Arc::new(Image::empty()),
|
.background_spawn(async move {
|
||||||
image_task: cx
|
smol::Timer::after(Duration::from_secs(60 * 5)).await;
|
||||||
.background_spawn(async move {
|
Some(LanguageModelImage::empty())
|
||||||
smol::Timer::after(Duration::from_secs(60 * 5)).await;
|
})
|
||||||
Some(LanguageModelImage::empty())
|
.shared(),
|
||||||
})
|
}),
|
||||||
.shared(),
|
|
||||||
},
|
|
||||||
None,
|
|
||||||
cx,
|
|
||||||
),
|
|
||||||
);
|
);
|
||||||
|
|
||||||
let image_error = (
|
let image_error = (
|
||||||
"Error",
|
"Error",
|
||||||
AddedContext::image(
|
AddedContext::image(ImageContext {
|
||||||
ImageContext {
|
context_id: next_context_id.post_inc(),
|
||||||
context_id: next_context_id.post_inc(),
|
project_path: None,
|
||||||
project_path: None,
|
original_image: Arc::new(Image::empty()),
|
||||||
full_path: None,
|
image_task: Task::ready(None).shared(),
|
||||||
original_image: Arc::new(Image::empty()),
|
}),
|
||||||
image_task: Task::ready(None).shared(),
|
|
||||||
},
|
|
||||||
None,
|
|
||||||
cx,
|
|
||||||
),
|
|
||||||
);
|
);
|
||||||
|
|
||||||
Some(
|
Some(
|
||||||
@@ -870,60 +815,3 @@ impl Component for AddedContext {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
|
||||||
mod tests {
|
|
||||||
use super::*;
|
|
||||||
use gpui::App;
|
|
||||||
use language_model::{LanguageModel, fake_provider::FakeLanguageModel};
|
|
||||||
use std::sync::Arc;
|
|
||||||
|
|
||||||
#[gpui::test]
|
|
||||||
fn test_image_context_warning_for_unsupported_model(cx: &mut App) {
|
|
||||||
let model: Arc<dyn LanguageModel> = Arc::new(FakeLanguageModel::default());
|
|
||||||
assert!(!model.supports_images());
|
|
||||||
|
|
||||||
let image_context = ImageContext {
|
|
||||||
context_id: ContextId::zero(),
|
|
||||||
project_path: None,
|
|
||||||
original_image: Arc::new(Image::empty()),
|
|
||||||
image_task: Task::ready(Some(LanguageModelImage::empty())).shared(),
|
|
||||||
full_path: None,
|
|
||||||
};
|
|
||||||
|
|
||||||
let added_context = AddedContext::image(image_context, Some(&model), cx);
|
|
||||||
|
|
||||||
assert!(matches!(
|
|
||||||
added_context.status,
|
|
||||||
ContextStatus::Warning { .. }
|
|
||||||
));
|
|
||||||
|
|
||||||
assert!(matches!(added_context.kind, ContextKind::Image));
|
|
||||||
assert_eq!(added_context.name.as_ref(), "Image");
|
|
||||||
assert!(added_context.parent.is_none());
|
|
||||||
assert!(added_context.icon_path.is_none());
|
|
||||||
}
|
|
||||||
|
|
||||||
#[gpui::test]
|
|
||||||
fn test_image_context_ready_for_no_model(cx: &mut App) {
|
|
||||||
let image_context = ImageContext {
|
|
||||||
context_id: ContextId::zero(),
|
|
||||||
project_path: None,
|
|
||||||
original_image: Arc::new(Image::empty()),
|
|
||||||
image_task: Task::ready(Some(LanguageModelImage::empty())).shared(),
|
|
||||||
full_path: None,
|
|
||||||
};
|
|
||||||
|
|
||||||
let added_context = AddedContext::image(image_context, None, cx);
|
|
||||||
|
|
||||||
assert!(
|
|
||||||
matches!(added_context.status, ContextStatus::Ready),
|
|
||||||
"Expected ready status when no model provided"
|
|
||||||
);
|
|
||||||
|
|
||||||
assert!(matches!(added_context.kind, ContextKind::Image));
|
|
||||||
assert_eq!(added_context.name.as_ref(), "Image");
|
|
||||||
assert!(added_context.parent.is_none());
|
|
||||||
assert!(added_context.icon_path.is_none());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
use crate::ToggleBurnMode;
|
use gpui::{Context, IntoElement, Render, Window};
|
||||||
use gpui::{Context, FontWeight, IntoElement, Render, Window};
|
use ui::{prelude::*, tooltip_container};
|
||||||
use ui::{KeyBinding, prelude::*, tooltip_container};
|
|
||||||
|
|
||||||
pub struct MaxModeTooltip {
|
pub struct MaxModeTooltip {
|
||||||
selected: bool,
|
selected: bool,
|
||||||
@@ -19,48 +18,38 @@ impl MaxModeTooltip {
|
|||||||
|
|
||||||
impl Render for MaxModeTooltip {
|
impl Render for MaxModeTooltip {
|
||||||
fn render(&mut self, window: &mut Window, cx: &mut Context<Self>) -> impl IntoElement {
|
fn render(&mut self, window: &mut Window, cx: &mut Context<Self>) -> impl IntoElement {
|
||||||
let (icon, color) = if self.selected {
|
|
||||||
(IconName::ZedBurnModeOn, Color::Error)
|
|
||||||
} else {
|
|
||||||
(IconName::ZedBurnMode, Color::Default)
|
|
||||||
};
|
|
||||||
|
|
||||||
let turned_on = h_flex()
|
|
||||||
.h_4()
|
|
||||||
.px_1()
|
|
||||||
.border_1()
|
|
||||||
.border_color(cx.theme().colors().border)
|
|
||||||
.bg(cx.theme().colors().text_accent.opacity(0.1))
|
|
||||||
.rounded_sm()
|
|
||||||
.child(
|
|
||||||
Label::new("ON")
|
|
||||||
.size(LabelSize::XSmall)
|
|
||||||
.weight(FontWeight::SEMIBOLD)
|
|
||||||
.color(Color::Accent),
|
|
||||||
);
|
|
||||||
|
|
||||||
let title = h_flex()
|
|
||||||
.gap_1p5()
|
|
||||||
.child(Icon::new(icon).size(IconSize::Small).color(color))
|
|
||||||
.child(Label::new("Burn Mode"))
|
|
||||||
.when(self.selected, |title| title.child(turned_on));
|
|
||||||
|
|
||||||
let keybinding = KeyBinding::for_action(&ToggleBurnMode, window, cx)
|
|
||||||
.map(|kb| kb.size(rems_from_px(12.)));
|
|
||||||
|
|
||||||
tooltip_container(window, cx, |this, _, _| {
|
tooltip_container(window, cx, |this, _, _| {
|
||||||
this
|
this.gap_1()
|
||||||
.child(
|
.map(|header| if self.selected {
|
||||||
h_flex()
|
header.child(
|
||||||
.justify_between()
|
h_flex()
|
||||||
.child(title)
|
.justify_between()
|
||||||
.children(keybinding)
|
.child(
|
||||||
)
|
h_flex()
|
||||||
|
.gap_1p5()
|
||||||
|
.child(Icon::new(IconName::ZedMaxMode).size(IconSize::Small).color(Color::Accent))
|
||||||
|
.child(Label::new("Zed's Max Mode"))
|
||||||
|
)
|
||||||
|
.child(
|
||||||
|
h_flex()
|
||||||
|
.gap_0p5()
|
||||||
|
.child(Icon::new(IconName::Check).size(IconSize::XSmall).color(Color::Accent))
|
||||||
|
.child(Label::new("Turned On").size(LabelSize::XSmall).color(Color::Accent))
|
||||||
|
)
|
||||||
|
)
|
||||||
|
} else {
|
||||||
|
header.child(
|
||||||
|
h_flex()
|
||||||
|
.gap_1p5()
|
||||||
|
.child(Icon::new(IconName::ZedMaxMode).size(IconSize::Small))
|
||||||
|
.child(Label::new("Zed's Max Mode"))
|
||||||
|
)
|
||||||
|
})
|
||||||
.child(
|
.child(
|
||||||
div()
|
div()
|
||||||
.max_w_64()
|
.max_w_72()
|
||||||
.child(
|
.child(
|
||||||
Label::new("Enables models to use large context windows, unlimited tool calls, and other capabilities for expanded reasoning.")
|
Label::new("This mode enables models to use large context windows, unlimited tool calls, and other capabilities for expanded reasoning, offering an unfettered agentic experience.")
|
||||||
.size(LabelSize::Small)
|
.size(LabelSize::Small)
|
||||||
.color(Color::Muted)
|
.color(Color::Muted)
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
use std::sync::OnceLock;
|
|
||||||
|
|
||||||
use collections::HashMap;
|
use collections::HashMap;
|
||||||
use component::ComponentId;
|
use component::ComponentId;
|
||||||
use gpui::{App, Entity, WeakEntity};
|
use gpui::{App, Entity, WeakEntity};
|
||||||
|
use linkme::distributed_slice;
|
||||||
|
use std::sync::OnceLock;
|
||||||
use ui::{AnyElement, Component, ComponentScope, Window};
|
use ui::{AnyElement, Component, ComponentScope, Window};
|
||||||
use workspace::Workspace;
|
use workspace::Workspace;
|
||||||
|
|
||||||
@@ -12,15 +12,9 @@ use crate::ActiveThread;
|
|||||||
pub type PreviewFn =
|
pub type PreviewFn =
|
||||||
fn(WeakEntity<Workspace>, Entity<ActiveThread>, &mut Window, &mut App) -> Option<AnyElement>;
|
fn(WeakEntity<Workspace>, Entity<ActiveThread>, &mut Window, &mut App) -> Option<AnyElement>;
|
||||||
|
|
||||||
pub struct AgentPreviewFn(fn() -> (ComponentId, PreviewFn));
|
/// Distributed slice for preview registration functions
|
||||||
|
#[distributed_slice]
|
||||||
impl AgentPreviewFn {
|
pub static __ALL_AGENT_PREVIEWS: [fn() -> (ComponentId, PreviewFn)] = [..];
|
||||||
pub const fn new(f: fn() -> (ComponentId, PreviewFn)) -> Self {
|
|
||||||
Self(f)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
inventory::collect!(AgentPreviewFn);
|
|
||||||
|
|
||||||
/// Trait that must be implemented by components that provide agent previews.
|
/// Trait that must be implemented by components that provide agent previews.
|
||||||
pub trait AgentPreview: Component + Sized {
|
pub trait AgentPreview: Component + Sized {
|
||||||
@@ -42,14 +36,16 @@ pub trait AgentPreview: Component + Sized {
|
|||||||
#[macro_export]
|
#[macro_export]
|
||||||
macro_rules! register_agent_preview {
|
macro_rules! register_agent_preview {
|
||||||
($type:ty) => {
|
($type:ty) => {
|
||||||
inventory::submit! {
|
#[linkme::distributed_slice($crate::ui::preview::__ALL_AGENT_PREVIEWS)]
|
||||||
$crate::ui::preview::AgentPreviewFn::new(|| {
|
static __REGISTER_AGENT_PREVIEW: fn() -> (
|
||||||
(
|
component::ComponentId,
|
||||||
<$type as component::Component>::id(),
|
$crate::ui::preview::PreviewFn,
|
||||||
<$type as $crate::ui::preview::AgentPreview>::agent_preview,
|
) = || {
|
||||||
)
|
(
|
||||||
})
|
<$type as component::Component>::id(),
|
||||||
}
|
<$type as $crate::ui::preview::AgentPreview>::agent_preview,
|
||||||
|
)
|
||||||
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -60,8 +56,8 @@ static AGENT_PREVIEW_REGISTRY: OnceLock<HashMap<ComponentId, PreviewFn>> = OnceL
|
|||||||
fn get_or_init_registry() -> &'static HashMap<ComponentId, PreviewFn> {
|
fn get_or_init_registry() -> &'static HashMap<ComponentId, PreviewFn> {
|
||||||
AGENT_PREVIEW_REGISTRY.get_or_init(|| {
|
AGENT_PREVIEW_REGISTRY.get_or_init(|| {
|
||||||
let mut map = HashMap::default();
|
let mut map = HashMap::default();
|
||||||
for register_fn in inventory::iter::<AgentPreviewFn>() {
|
for register_fn in __ALL_AGENT_PREVIEWS.iter() {
|
||||||
let (id, preview_fn) = (register_fn.0)();
|
let (id, preview_fn) = register_fn();
|
||||||
map.insert(id, preview_fn);
|
map.insert(id, preview_fn);
|
||||||
}
|
}
|
||||||
map
|
map
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ impl RenderOnce for UsageCallout {
|
|||||||
|
|
||||||
let (title, message, button_text, url) = if is_limit_reached {
|
let (title, message, button_text, url) = if is_limit_reached {
|
||||||
match self.plan {
|
match self.plan {
|
||||||
Plan::ZedFree => (
|
Plan::Free => (
|
||||||
"Out of free prompts",
|
"Out of free prompts",
|
||||||
"Upgrade to continue, wait for the next reset, or switch to API key."
|
"Upgrade to continue, wait for the next reset, or switch to API key."
|
||||||
.to_string(),
|
.to_string(),
|
||||||
@@ -61,7 +61,7 @@ impl RenderOnce for UsageCallout {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
match self.plan {
|
match self.plan {
|
||||||
Plan::ZedFree => (
|
Plan::Free => (
|
||||||
"Reaching free plan limit soon",
|
"Reaching free plan limit soon",
|
||||||
format!(
|
format!(
|
||||||
"{remaining} remaining - Upgrade to increase limit, or switch providers",
|
"{remaining} remaining - Upgrade to increase limit, or switch providers",
|
||||||
@@ -120,7 +120,7 @@ impl Component for UsageCallout {
|
|||||||
single_example(
|
single_example(
|
||||||
"Approaching limit (90%)",
|
"Approaching limit (90%)",
|
||||||
UsageCallout::new(
|
UsageCallout::new(
|
||||||
Plan::ZedFree,
|
Plan::Free,
|
||||||
RequestUsage {
|
RequestUsage {
|
||||||
limit: UsageLimit::Limited(50),
|
limit: UsageLimit::Limited(50),
|
||||||
amount: 45, // 90% of limit
|
amount: 45, // 90% of limit
|
||||||
@@ -131,7 +131,7 @@ impl Component for UsageCallout {
|
|||||||
single_example(
|
single_example(
|
||||||
"Limit reached (100%)",
|
"Limit reached (100%)",
|
||||||
UsageCallout::new(
|
UsageCallout::new(
|
||||||
Plan::ZedFree,
|
Plan::Free,
|
||||||
RequestUsage {
|
RequestUsage {
|
||||||
limit: UsageLimit::Limited(50),
|
limit: UsageLimit::Limited(50),
|
||||||
amount: 50, // 100% of limit
|
amount: 50, // 100% of limit
|
||||||
|
|||||||
@@ -34,6 +34,7 @@ pub enum AnthropicModelMode {
|
|||||||
pub enum Model {
|
pub enum Model {
|
||||||
#[serde(rename = "claude-3-5-sonnet", alias = "claude-3-5-sonnet-latest")]
|
#[serde(rename = "claude-3-5-sonnet", alias = "claude-3-5-sonnet-latest")]
|
||||||
Claude3_5Sonnet,
|
Claude3_5Sonnet,
|
||||||
|
#[default]
|
||||||
#[serde(rename = "claude-3-7-sonnet", alias = "claude-3-7-sonnet-latest")]
|
#[serde(rename = "claude-3-7-sonnet", alias = "claude-3-7-sonnet-latest")]
|
||||||
Claude3_7Sonnet,
|
Claude3_7Sonnet,
|
||||||
#[serde(
|
#[serde(
|
||||||
@@ -41,21 +42,6 @@ pub enum Model {
|
|||||||
alias = "claude-3-7-sonnet-thinking-latest"
|
alias = "claude-3-7-sonnet-thinking-latest"
|
||||||
)]
|
)]
|
||||||
Claude3_7SonnetThinking,
|
Claude3_7SonnetThinking,
|
||||||
#[serde(rename = "claude-opus-4", alias = "claude-opus-4-latest")]
|
|
||||||
ClaudeOpus4,
|
|
||||||
#[serde(
|
|
||||||
rename = "claude-opus-4-thinking",
|
|
||||||
alias = "claude-opus-4-thinking-latest"
|
|
||||||
)]
|
|
||||||
ClaudeOpus4Thinking,
|
|
||||||
#[default]
|
|
||||||
#[serde(rename = "claude-sonnet-4", alias = "claude-sonnet-4-latest")]
|
|
||||||
ClaudeSonnet4,
|
|
||||||
#[serde(
|
|
||||||
rename = "claude-sonnet-4-thinking",
|
|
||||||
alias = "claude-sonnet-4-thinking-latest"
|
|
||||||
)]
|
|
||||||
ClaudeSonnet4Thinking,
|
|
||||||
#[serde(rename = "claude-3-5-haiku", alias = "claude-3-5-haiku-latest")]
|
#[serde(rename = "claude-3-5-haiku", alias = "claude-3-5-haiku-latest")]
|
||||||
Claude3_5Haiku,
|
Claude3_5Haiku,
|
||||||
#[serde(rename = "claude-3-opus", alias = "claude-3-opus-latest")]
|
#[serde(rename = "claude-3-opus", alias = "claude-3-opus-latest")]
|
||||||
@@ -103,25 +89,13 @@ impl Model {
|
|||||||
Ok(Self::Claude3Sonnet)
|
Ok(Self::Claude3Sonnet)
|
||||||
} else if id.starts_with("claude-3-haiku") {
|
} else if id.starts_with("claude-3-haiku") {
|
||||||
Ok(Self::Claude3Haiku)
|
Ok(Self::Claude3Haiku)
|
||||||
} else if id.starts_with("claude-opus-4-thinking") {
|
|
||||||
Ok(Self::ClaudeOpus4Thinking)
|
|
||||||
} else if id.starts_with("claude-opus-4") {
|
|
||||||
Ok(Self::ClaudeOpus4)
|
|
||||||
} else if id.starts_with("claude-sonnet-4-thinking") {
|
|
||||||
Ok(Self::ClaudeSonnet4Thinking)
|
|
||||||
} else if id.starts_with("claude-sonnet-4") {
|
|
||||||
Ok(Self::ClaudeSonnet4)
|
|
||||||
} else {
|
} else {
|
||||||
anyhow::bail!("invalid model id {id}");
|
Err(anyhow!("invalid model id"))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn id(&self) -> &str {
|
pub fn id(&self) -> &str {
|
||||||
match self {
|
match self {
|
||||||
Model::ClaudeOpus4 => "claude-opus-4-latest",
|
|
||||||
Model::ClaudeOpus4Thinking => "claude-opus-4-thinking-latest",
|
|
||||||
Model::ClaudeSonnet4 => "claude-sonnet-4-latest",
|
|
||||||
Model::ClaudeSonnet4Thinking => "claude-sonnet-4-thinking-latest",
|
|
||||||
Model::Claude3_5Sonnet => "claude-3-5-sonnet-latest",
|
Model::Claude3_5Sonnet => "claude-3-5-sonnet-latest",
|
||||||
Model::Claude3_7Sonnet => "claude-3-7-sonnet-latest",
|
Model::Claude3_7Sonnet => "claude-3-7-sonnet-latest",
|
||||||
Model::Claude3_7SonnetThinking => "claude-3-7-sonnet-thinking-latest",
|
Model::Claude3_7SonnetThinking => "claude-3-7-sonnet-thinking-latest",
|
||||||
@@ -136,8 +110,6 @@ impl Model {
|
|||||||
/// The id of the model that should be used for making API requests
|
/// The id of the model that should be used for making API requests
|
||||||
pub fn request_id(&self) -> &str {
|
pub fn request_id(&self) -> &str {
|
||||||
match self {
|
match self {
|
||||||
Model::ClaudeOpus4 | Model::ClaudeOpus4Thinking => "claude-opus-4-20250514",
|
|
||||||
Model::ClaudeSonnet4 | Model::ClaudeSonnet4Thinking => "claude-sonnet-4-20250514",
|
|
||||||
Model::Claude3_5Sonnet => "claude-3-5-sonnet-latest",
|
Model::Claude3_5Sonnet => "claude-3-5-sonnet-latest",
|
||||||
Model::Claude3_7Sonnet | Model::Claude3_7SonnetThinking => "claude-3-7-sonnet-latest",
|
Model::Claude3_7Sonnet | Model::Claude3_7SonnetThinking => "claude-3-7-sonnet-latest",
|
||||||
Model::Claude3_5Haiku => "claude-3-5-haiku-latest",
|
Model::Claude3_5Haiku => "claude-3-5-haiku-latest",
|
||||||
@@ -150,10 +122,6 @@ impl Model {
|
|||||||
|
|
||||||
pub fn display_name(&self) -> &str {
|
pub fn display_name(&self) -> &str {
|
||||||
match self {
|
match self {
|
||||||
Model::ClaudeOpus4 => "Claude Opus 4",
|
|
||||||
Model::ClaudeOpus4Thinking => "Claude Opus 4 Thinking",
|
|
||||||
Model::ClaudeSonnet4 => "Claude Sonnet 4",
|
|
||||||
Model::ClaudeSonnet4Thinking => "Claude Sonnet 4 Thinking",
|
|
||||||
Self::Claude3_7Sonnet => "Claude 3.7 Sonnet",
|
Self::Claude3_7Sonnet => "Claude 3.7 Sonnet",
|
||||||
Self::Claude3_5Sonnet => "Claude 3.5 Sonnet",
|
Self::Claude3_5Sonnet => "Claude 3.5 Sonnet",
|
||||||
Self::Claude3_7SonnetThinking => "Claude 3.7 Sonnet Thinking",
|
Self::Claude3_7SonnetThinking => "Claude 3.7 Sonnet Thinking",
|
||||||
@@ -169,11 +137,7 @@ impl Model {
|
|||||||
|
|
||||||
pub fn cache_configuration(&self) -> Option<AnthropicModelCacheConfiguration> {
|
pub fn cache_configuration(&self) -> Option<AnthropicModelCacheConfiguration> {
|
||||||
match self {
|
match self {
|
||||||
Self::ClaudeOpus4
|
Self::Claude3_5Sonnet
|
||||||
| Self::ClaudeOpus4Thinking
|
|
||||||
| Self::ClaudeSonnet4
|
|
||||||
| Self::ClaudeSonnet4Thinking
|
|
||||||
| Self::Claude3_5Sonnet
|
|
||||||
| Self::Claude3_5Haiku
|
| Self::Claude3_5Haiku
|
||||||
| Self::Claude3_7Sonnet
|
| Self::Claude3_7Sonnet
|
||||||
| Self::Claude3_7SonnetThinking
|
| Self::Claude3_7SonnetThinking
|
||||||
@@ -192,11 +156,7 @@ impl Model {
|
|||||||
|
|
||||||
pub fn max_token_count(&self) -> usize {
|
pub fn max_token_count(&self) -> usize {
|
||||||
match self {
|
match self {
|
||||||
Self::ClaudeOpus4
|
Self::Claude3_5Sonnet
|
||||||
| Self::ClaudeOpus4Thinking
|
|
||||||
| Self::ClaudeSonnet4
|
|
||||||
| Self::ClaudeSonnet4Thinking
|
|
||||||
| Self::Claude3_5Sonnet
|
|
||||||
| Self::Claude3_5Haiku
|
| Self::Claude3_5Haiku
|
||||||
| Self::Claude3_7Sonnet
|
| Self::Claude3_7Sonnet
|
||||||
| Self::Claude3_7SonnetThinking
|
| Self::Claude3_7SonnetThinking
|
||||||
@@ -213,11 +173,7 @@ impl Model {
|
|||||||
Self::Claude3_5Sonnet
|
Self::Claude3_5Sonnet
|
||||||
| Self::Claude3_7Sonnet
|
| Self::Claude3_7Sonnet
|
||||||
| Self::Claude3_7SonnetThinking
|
| Self::Claude3_7SonnetThinking
|
||||||
| Self::Claude3_5Haiku
|
| Self::Claude3_5Haiku => 8_192,
|
||||||
| Self::ClaudeOpus4
|
|
||||||
| Self::ClaudeOpus4Thinking
|
|
||||||
| Self::ClaudeSonnet4
|
|
||||||
| Self::ClaudeSonnet4Thinking => 8_192,
|
|
||||||
Self::Custom {
|
Self::Custom {
|
||||||
max_output_tokens, ..
|
max_output_tokens, ..
|
||||||
} => max_output_tokens.unwrap_or(4_096),
|
} => max_output_tokens.unwrap_or(4_096),
|
||||||
@@ -226,11 +182,7 @@ impl Model {
|
|||||||
|
|
||||||
pub fn default_temperature(&self) -> f32 {
|
pub fn default_temperature(&self) -> f32 {
|
||||||
match self {
|
match self {
|
||||||
Self::ClaudeOpus4
|
Self::Claude3_5Sonnet
|
||||||
| Self::ClaudeOpus4Thinking
|
|
||||||
| Self::ClaudeSonnet4
|
|
||||||
| Self::ClaudeSonnet4Thinking
|
|
||||||
| Self::Claude3_5Sonnet
|
|
||||||
| Self::Claude3_7Sonnet
|
| Self::Claude3_7Sonnet
|
||||||
| Self::Claude3_7SonnetThinking
|
| Self::Claude3_7SonnetThinking
|
||||||
| Self::Claude3_5Haiku
|
| Self::Claude3_5Haiku
|
||||||
@@ -249,14 +201,10 @@ impl Model {
|
|||||||
Self::Claude3_5Sonnet
|
Self::Claude3_5Sonnet
|
||||||
| Self::Claude3_7Sonnet
|
| Self::Claude3_7Sonnet
|
||||||
| Self::Claude3_5Haiku
|
| Self::Claude3_5Haiku
|
||||||
| Self::ClaudeOpus4
|
|
||||||
| Self::ClaudeSonnet4
|
|
||||||
| Self::Claude3Opus
|
| Self::Claude3Opus
|
||||||
| Self::Claude3Sonnet
|
| Self::Claude3Sonnet
|
||||||
| Self::Claude3Haiku => AnthropicModelMode::Default,
|
| Self::Claude3Haiku => AnthropicModelMode::Default,
|
||||||
Self::Claude3_7SonnetThinking
|
Self::Claude3_7SonnetThinking => AnthropicModelMode::Thinking {
|
||||||
| Self::ClaudeOpus4Thinking
|
|
||||||
| Self::ClaudeSonnet4Thinking => AnthropicModelMode::Thinking {
|
|
||||||
budget_tokens: Some(4_096),
|
budget_tokens: Some(4_096),
|
||||||
},
|
},
|
||||||
Self::Custom { mode, .. } => mode.clone(),
|
Self::Custom { mode, .. } => mode.clone(),
|
||||||
@@ -437,10 +385,10 @@ impl RateLimitInfo {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_header<'a>(key: &str, headers: &'a HeaderMap) -> anyhow::Result<&'a str> {
|
fn get_header<'a>(key: &str, headers: &'a HeaderMap) -> Result<&'a str, anyhow::Error> {
|
||||||
Ok(headers
|
Ok(headers
|
||||||
.get(key)
|
.get(key)
|
||||||
.with_context(|| format!("missing header `{key}`"))?
|
.ok_or_else(|| anyhow!("missing header `{key}`"))?
|
||||||
.to_str()?)
|
.to_str()?)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -586,26 +534,12 @@ pub enum RequestContent {
|
|||||||
ToolResult {
|
ToolResult {
|
||||||
tool_use_id: String,
|
tool_use_id: String,
|
||||||
is_error: bool,
|
is_error: bool,
|
||||||
content: ToolResultContent,
|
content: String,
|
||||||
#[serde(skip_serializing_if = "Option::is_none")]
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
cache_control: Option<CacheControl>,
|
cache_control: Option<CacheControl>,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Serialize, Deserialize)]
|
|
||||||
#[serde(untagged)]
|
|
||||||
pub enum ToolResultContent {
|
|
||||||
Plain(String),
|
|
||||||
Multipart(Vec<ToolResultPart>),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Debug, Serialize, Deserialize)]
|
|
||||||
#[serde(tag = "type", rename_all = "lowercase")]
|
|
||||||
pub enum ToolResultPart {
|
|
||||||
Text { text: String },
|
|
||||||
Image { source: ImageSource },
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Debug, Serialize, Deserialize)]
|
#[derive(Debug, Serialize, Deserialize)]
|
||||||
#[serde(tag = "type")]
|
#[serde(tag = "type")]
|
||||||
pub enum ResponseContent {
|
pub enum ResponseContent {
|
||||||
|
|||||||
@@ -163,26 +163,20 @@ impl AskPassSession {
|
|||||||
#[cfg(unix)]
|
#[cfg(unix)]
|
||||||
fn get_shell_safe_zed_path() -> anyhow::Result<String> {
|
fn get_shell_safe_zed_path() -> anyhow::Result<String> {
|
||||||
let zed_path = std::env::current_exe()
|
let zed_path = std::env::current_exe()
|
||||||
.context("Failed to determine current executable path for use in askpass")?
|
.context("Failed to figure out current executable path for use in askpass")?
|
||||||
.to_string_lossy()
|
.to_string_lossy()
|
||||||
// see https://github.com/rust-lang/rust/issues/69343
|
|
||||||
.trim_end_matches(" (deleted)")
|
|
||||||
.to_string();
|
.to_string();
|
||||||
|
|
||||||
// NOTE: this was previously enabled, however, it caused errors when it shouldn't have
|
// sanity check on unix systems that the path exists and is executable
|
||||||
// (see https://github.com/zed-industries/zed/issues/29819)
|
// todo(windows): implement this check for windows (or just use `is-executable` crate)
|
||||||
// The zed path failing to execute within the askpass script results in very vague ssh
|
use std::os::unix::fs::MetadataExt;
|
||||||
// authentication failed errors, so this was done to try and surface a better error
|
let metadata = std::fs::metadata(&zed_path)
|
||||||
//
|
.context("Failed to check metadata of Zed executable path for use in askpass")?;
|
||||||
// use std::os::unix::fs::MetadataExt;
|
let is_executable = metadata.is_file() && metadata.mode() & 0o111 != 0;
|
||||||
// let metadata = std::fs::metadata(&zed_path)
|
anyhow::ensure!(
|
||||||
// .context("Failed to check metadata of Zed executable path for use in askpass")?;
|
is_executable,
|
||||||
// let is_executable = metadata.is_file() && metadata.mode() & 0o111 != 0;
|
"Failed to verify Zed executable path for use in askpass"
|
||||||
// anyhow::ensure!(
|
);
|
||||||
// is_executable,
|
|
||||||
// "Failed to verify Zed executable path for use in askpass"
|
|
||||||
// );
|
|
||||||
|
|
||||||
// As of writing, this can only be fail if the path contains a null byte, which shouldn't be possible
|
// As of writing, this can only be fail if the path contains a null byte, which shouldn't be possible
|
||||||
// but shlex has annotated the error as #[non_exhaustive] so we can't make it a compile error if other
|
// but shlex has annotated the error as #[non_exhaustive] so we can't make it a compile error if other
|
||||||
// errors are introduced in the future :(
|
// errors are introduced in the future :(
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
// This crate was essentially pulled out verbatim from main `zed` crate to avoid having to run RustEmbed macro whenever zed has to be rebuilt. It saves a second or two on an incremental build.
|
// This crate was essentially pulled out verbatim from main `zed` crate to avoid having to run RustEmbed macro whenever zed has to be rebuilt. It saves a second or two on an incremental build.
|
||||||
|
use anyhow::anyhow;
|
||||||
|
|
||||||
use anyhow::Context as _;
|
|
||||||
use gpui::{App, AssetSource, Result, SharedString};
|
use gpui::{App, AssetSource, Result, SharedString};
|
||||||
use rust_embed::RustEmbed;
|
use rust_embed::RustEmbed;
|
||||||
|
|
||||||
@@ -21,7 +21,7 @@ impl AssetSource for Assets {
|
|||||||
fn load(&self, path: &str) -> Result<Option<std::borrow::Cow<'static, [u8]>>> {
|
fn load(&self, path: &str) -> Result<Option<std::borrow::Cow<'static, [u8]>>> {
|
||||||
Self::get(path)
|
Self::get(path)
|
||||||
.map(|f| Some(f.data))
|
.map(|f| Some(f.data))
|
||||||
.with_context(|| format!("loading asset at path {path:?}"))
|
.ok_or_else(|| anyhow!("could not find asset at path \"{}\"", path))
|
||||||
}
|
}
|
||||||
|
|
||||||
fn list(&self, path: &str) -> Result<Vec<SharedString>> {
|
fn list(&self, path: &str) -> Result<Vec<SharedString>> {
|
||||||
@@ -39,7 +39,7 @@ impl AssetSource for Assets {
|
|||||||
|
|
||||||
impl Assets {
|
impl Assets {
|
||||||
/// Populate the [`TextSystem`] of the given [`AppContext`] with all `.ttf` fonts in the `fonts` directory.
|
/// Populate the [`TextSystem`] of the given [`AppContext`] with all `.ttf` fonts in the `fonts` directory.
|
||||||
pub fn load_fonts(&self, cx: &App) -> anyhow::Result<()> {
|
pub fn load_fonts(&self, cx: &App) -> gpui::Result<()> {
|
||||||
let font_paths = self.list("fonts")?;
|
let font_paths = self.list("fonts")?;
|
||||||
let mut embedded_fonts = Vec::new();
|
let mut embedded_fonts = Vec::new();
|
||||||
for font_path in font_paths {
|
for font_path in font_paths {
|
||||||
|
|||||||
@@ -12,8 +12,8 @@ workspace = true
|
|||||||
path = "src/assistant_context_editor.rs"
|
path = "src/assistant_context_editor.rs"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
agent_settings.workspace = true
|
|
||||||
anyhow.workspace = true
|
anyhow.workspace = true
|
||||||
|
assistant_settings.workspace = true
|
||||||
assistant_slash_command.workspace = true
|
assistant_slash_command.workspace = true
|
||||||
assistant_slash_commands.workspace = true
|
assistant_slash_commands.workspace = true
|
||||||
chrono.workspace = true
|
chrono.workspace = true
|
||||||
@@ -22,7 +22,6 @@ clock.workspace = true
|
|||||||
collections.workspace = true
|
collections.workspace = true
|
||||||
context_server.workspace = true
|
context_server.workspace = true
|
||||||
editor.workspace = true
|
editor.workspace = true
|
||||||
feature_flags.workspace = true
|
|
||||||
fs.workspace = true
|
fs.workspace = true
|
||||||
futures.workspace = true
|
futures.workspace = true
|
||||||
fuzzy.workspace = true
|
fuzzy.workspace = true
|
||||||
@@ -30,16 +29,15 @@ gpui.workspace = true
|
|||||||
indexed_docs.workspace = true
|
indexed_docs.workspace = true
|
||||||
language.workspace = true
|
language.workspace = true
|
||||||
language_model.workspace = true
|
language_model.workspace = true
|
||||||
|
language_model_selector.workspace = true
|
||||||
log.workspace = true
|
log.workspace = true
|
||||||
multi_buffer.workspace = true
|
multi_buffer.workspace = true
|
||||||
open_ai.workspace = true
|
open_ai.workspace = true
|
||||||
ordered-float.workspace = true
|
|
||||||
parking_lot.workspace = true
|
parking_lot.workspace = true
|
||||||
paths.workspace = true
|
paths.workspace = true
|
||||||
picker.workspace = true
|
picker.workspace = true
|
||||||
project.workspace = true
|
project.workspace = true
|
||||||
prompt_store.workspace = true
|
prompt_store.workspace = true
|
||||||
proto.workspace = true
|
|
||||||
regex.workspace = true
|
regex.workspace = true
|
||||||
rope.workspace = true
|
rope.workspace = true
|
||||||
rpc.workspace = true
|
rpc.workspace = true
|
||||||
@@ -57,10 +55,8 @@ uuid.workspace = true
|
|||||||
workspace-hack.workspace = true
|
workspace-hack.workspace = true
|
||||||
workspace.workspace = true
|
workspace.workspace = true
|
||||||
zed_actions.workspace = true
|
zed_actions.workspace = true
|
||||||
zed_llm_client.workspace = true
|
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
indoc.workspace = true
|
|
||||||
language_model = { workspace = true, features = ["test-support"] }
|
language_model = { workspace = true, features = ["test-support"] }
|
||||||
languages = { workspace = true, features = ["test-support"] }
|
languages = { workspace = true, features = ["test-support"] }
|
||||||
pretty_assertions.workspace = true
|
pretty_assertions.workspace = true
|
||||||
|
|||||||
@@ -2,16 +2,13 @@ mod context;
|
|||||||
mod context_editor;
|
mod context_editor;
|
||||||
mod context_history;
|
mod context_history;
|
||||||
mod context_store;
|
mod context_store;
|
||||||
pub mod language_model_selector;
|
|
||||||
mod max_mode_tooltip;
|
|
||||||
mod slash_command;
|
mod slash_command;
|
||||||
mod slash_command_picker;
|
mod slash_command_picker;
|
||||||
|
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
|
||||||
use client::Client;
|
use client::Client;
|
||||||
use gpui::{App, Context};
|
use gpui::App;
|
||||||
use workspace::Workspace;
|
|
||||||
|
|
||||||
pub use crate::context::*;
|
pub use crate::context::*;
|
||||||
pub use crate::context_editor::*;
|
pub use crate::context_editor::*;
|
||||||
@@ -19,18 +16,6 @@ pub use crate::context_history::*;
|
|||||||
pub use crate::context_store::*;
|
pub use crate::context_store::*;
|
||||||
pub use crate::slash_command::*;
|
pub use crate::slash_command::*;
|
||||||
|
|
||||||
pub fn init(client: Arc<Client>, cx: &mut App) {
|
pub fn init(client: Arc<Client>, _cx: &mut App) {
|
||||||
context_store::init(&client.into());
|
context_store::init(&client.into());
|
||||||
workspace::FollowableViewRegistry::register::<ContextEditor>(cx);
|
|
||||||
|
|
||||||
cx.observe_new(
|
|
||||||
|workspace: &mut Workspace, _window, _cx: &mut Context<Workspace>| {
|
|
||||||
workspace
|
|
||||||
.register_action(ContextEditor::quote_selection)
|
|
||||||
.register_action(ContextEditor::insert_selection)
|
|
||||||
.register_action(ContextEditor::copy_code)
|
|
||||||
.register_action(ContextEditor::handle_insert_dragged_files);
|
|
||||||
},
|
|
||||||
)
|
|
||||||
.detach();
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod context_tests;
|
mod context_tests;
|
||||||
|
|
||||||
use agent_settings::AgentSettings;
|
use anyhow::{Context as _, Result, anyhow};
|
||||||
use anyhow::{Context as _, Result, bail};
|
use assistant_settings::AssistantSettings;
|
||||||
use assistant_slash_command::{
|
use assistant_slash_command::{
|
||||||
SlashCommandContent, SlashCommandEvent, SlashCommandLine, SlashCommandOutputSection,
|
SlashCommandContent, SlashCommandEvent, SlashCommandLine, SlashCommandOutputSection,
|
||||||
SlashCommandResult, SlashCommandWorkingSet,
|
SlashCommandResult, SlashCommandWorkingSet,
|
||||||
@@ -21,15 +21,14 @@ use language::{AnchorRangeExt, Bias, Buffer, LanguageRegistry, OffsetRangeExt, P
|
|||||||
use language_model::{
|
use language_model::{
|
||||||
LanguageModel, LanguageModelCacheConfiguration, LanguageModelCompletionEvent,
|
LanguageModel, LanguageModelCacheConfiguration, LanguageModelCompletionEvent,
|
||||||
LanguageModelImage, LanguageModelRegistry, LanguageModelRequest, LanguageModelRequestMessage,
|
LanguageModelImage, LanguageModelRegistry, LanguageModelRequest, LanguageModelRequestMessage,
|
||||||
LanguageModelToolUseId, MessageContent, PaymentRequiredError, Role, StopReason,
|
LanguageModelToolUseId, MaxMonthlySpendReachedError, MessageContent, PaymentRequiredError,
|
||||||
report_assistant_event,
|
Role, StopReason, report_assistant_event,
|
||||||
};
|
};
|
||||||
use open_ai::Model as OpenAiModel;
|
use open_ai::Model as OpenAiModel;
|
||||||
use paths::contexts_dir;
|
use paths::contexts_dir;
|
||||||
use project::Project;
|
use project::Project;
|
||||||
use prompt_store::PromptBuilder;
|
use prompt_store::PromptBuilder;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use settings::Settings;
|
|
||||||
use smallvec::SmallVec;
|
use smallvec::SmallVec;
|
||||||
use std::{
|
use std::{
|
||||||
cmp::{Ordering, max},
|
cmp::{Ordering, max},
|
||||||
@@ -45,7 +44,6 @@ use text::{BufferSnapshot, ToPoint};
|
|||||||
use ui::IconName;
|
use ui::IconName;
|
||||||
use util::{ResultExt, TryFutureExt, post_inc};
|
use util::{ResultExt, TryFutureExt, post_inc};
|
||||||
use uuid::Uuid;
|
use uuid::Uuid;
|
||||||
use zed_llm_client::CompletionIntent;
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Eq, PartialEq, Hash, PartialOrd, Ord, Serialize, Deserialize)]
|
#[derive(Clone, Debug, Eq, PartialEq, Hash, PartialOrd, Ord, Serialize, Deserialize)]
|
||||||
pub struct ContextId(String);
|
pub struct ContextId(String);
|
||||||
@@ -135,7 +133,7 @@ pub enum ContextOperation {
|
|||||||
version: clock::Global,
|
version: clock::Global,
|
||||||
},
|
},
|
||||||
UpdateSummary {
|
UpdateSummary {
|
||||||
summary: ContextSummaryContent,
|
summary: ContextSummary,
|
||||||
version: clock::Global,
|
version: clock::Global,
|
||||||
},
|
},
|
||||||
SlashCommandStarted {
|
SlashCommandStarted {
|
||||||
@@ -205,7 +203,7 @@ impl ContextOperation {
|
|||||||
version: language::proto::deserialize_version(&update.version),
|
version: language::proto::deserialize_version(&update.version),
|
||||||
}),
|
}),
|
||||||
proto::context_operation::Variant::UpdateSummary(update) => Ok(Self::UpdateSummary {
|
proto::context_operation::Variant::UpdateSummary(update) => Ok(Self::UpdateSummary {
|
||||||
summary: ContextSummaryContent {
|
summary: ContextSummary {
|
||||||
text: update.summary,
|
text: update.summary,
|
||||||
done: update.done,
|
done: update.done,
|
||||||
timestamp: language::proto::deserialize_timestamp(
|
timestamp: language::proto::deserialize_timestamp(
|
||||||
@@ -449,6 +447,7 @@ impl ContextOperation {
|
|||||||
pub enum ContextEvent {
|
pub enum ContextEvent {
|
||||||
ShowAssistError(SharedString),
|
ShowAssistError(SharedString),
|
||||||
ShowPaymentRequiredError,
|
ShowPaymentRequiredError,
|
||||||
|
ShowMaxMonthlySpendReachedError,
|
||||||
MessagesEdited,
|
MessagesEdited,
|
||||||
SummaryChanged,
|
SummaryChanged,
|
||||||
SummaryGenerated,
|
SummaryGenerated,
|
||||||
@@ -468,73 +467,11 @@ pub enum ContextEvent {
|
|||||||
Operation(ContextOperation),
|
Operation(ContextOperation),
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Debug, Eq, PartialEq)]
|
#[derive(Clone, Default, Debug)]
|
||||||
pub enum ContextSummary {
|
pub struct ContextSummary {
|
||||||
Pending,
|
|
||||||
Content(ContextSummaryContent),
|
|
||||||
Error,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Default, Clone, Debug, Eq, PartialEq)]
|
|
||||||
pub struct ContextSummaryContent {
|
|
||||||
pub text: String,
|
pub text: String,
|
||||||
pub done: bool,
|
pub done: bool,
|
||||||
pub timestamp: clock::Lamport,
|
timestamp: clock::Lamport,
|
||||||
}
|
|
||||||
|
|
||||||
impl ContextSummary {
|
|
||||||
pub const DEFAULT: &str = "New Text Thread";
|
|
||||||
|
|
||||||
pub fn or_default(&self) -> SharedString {
|
|
||||||
self.unwrap_or(Self::DEFAULT)
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn unwrap_or(&self, message: impl Into<SharedString>) -> SharedString {
|
|
||||||
self.content()
|
|
||||||
.map_or_else(|| message.into(), |content| content.text.clone().into())
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn content(&self) -> Option<&ContextSummaryContent> {
|
|
||||||
match self {
|
|
||||||
ContextSummary::Content(content) => Some(content),
|
|
||||||
ContextSummary::Pending | ContextSummary::Error => None,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn content_as_mut(&mut self) -> Option<&mut ContextSummaryContent> {
|
|
||||||
match self {
|
|
||||||
ContextSummary::Content(content) => Some(content),
|
|
||||||
ContextSummary::Pending | ContextSummary::Error => None,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn content_or_set_empty(&mut self) -> &mut ContextSummaryContent {
|
|
||||||
match self {
|
|
||||||
ContextSummary::Content(content) => content,
|
|
||||||
ContextSummary::Pending | ContextSummary::Error => {
|
|
||||||
let content = ContextSummaryContent::default();
|
|
||||||
*self = ContextSummary::Content(content);
|
|
||||||
self.content_as_mut().unwrap()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn is_pending(&self) -> bool {
|
|
||||||
matches!(self, ContextSummary::Pending)
|
|
||||||
}
|
|
||||||
|
|
||||||
fn timestamp(&self) -> Option<clock::Lamport> {
|
|
||||||
match self {
|
|
||||||
ContextSummary::Content(content) => Some(content.timestamp),
|
|
||||||
ContextSummary::Pending | ContextSummary::Error => None,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl PartialOrd for ContextSummary {
|
|
||||||
fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
|
|
||||||
self.timestamp().partial_cmp(&other.timestamp())
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Debug, Eq, PartialEq)]
|
#[derive(Clone, Debug, Eq, PartialEq)]
|
||||||
@@ -670,7 +607,7 @@ pub struct AssistantContext {
|
|||||||
message_anchors: Vec<MessageAnchor>,
|
message_anchors: Vec<MessageAnchor>,
|
||||||
contents: Vec<Content>,
|
contents: Vec<Content>,
|
||||||
messages_metadata: HashMap<MessageId, MessageMetadata>,
|
messages_metadata: HashMap<MessageId, MessageMetadata>,
|
||||||
summary: ContextSummary,
|
summary: Option<ContextSummary>,
|
||||||
summary_task: Task<Option<()>>,
|
summary_task: Task<Option<()>>,
|
||||||
completion_count: usize,
|
completion_count: usize,
|
||||||
pending_completions: Vec<PendingCompletion>,
|
pending_completions: Vec<PendingCompletion>,
|
||||||
@@ -684,7 +621,6 @@ pub struct AssistantContext {
|
|||||||
language_registry: Arc<LanguageRegistry>,
|
language_registry: Arc<LanguageRegistry>,
|
||||||
project: Option<Entity<Project>>,
|
project: Option<Entity<Project>>,
|
||||||
prompt_builder: Arc<PromptBuilder>,
|
prompt_builder: Arc<PromptBuilder>,
|
||||||
completion_mode: agent_settings::CompletionMode,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
trait ContextAnnotation {
|
trait ContextAnnotation {
|
||||||
@@ -721,14 +657,6 @@ impl AssistantContext {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn completion_mode(&self) -> agent_settings::CompletionMode {
|
|
||||||
self.completion_mode
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn set_completion_mode(&mut self, completion_mode: agent_settings::CompletionMode) {
|
|
||||||
self.completion_mode = completion_mode;
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn new(
|
pub fn new(
|
||||||
id: ContextId,
|
id: ContextId,
|
||||||
replica_id: ReplicaId,
|
replica_id: ReplicaId,
|
||||||
@@ -766,7 +694,7 @@ impl AssistantContext {
|
|||||||
slash_command_output_sections: Vec::new(),
|
slash_command_output_sections: Vec::new(),
|
||||||
thought_process_output_sections: Vec::new(),
|
thought_process_output_sections: Vec::new(),
|
||||||
edits_since_last_parse: edits_since_last_slash_command_parse,
|
edits_since_last_parse: edits_since_last_slash_command_parse,
|
||||||
summary: ContextSummary::Pending,
|
summary: None,
|
||||||
summary_task: Task::ready(None),
|
summary_task: Task::ready(None),
|
||||||
completion_count: Default::default(),
|
completion_count: Default::default(),
|
||||||
pending_completions: Default::default(),
|
pending_completions: Default::default(),
|
||||||
@@ -775,7 +703,6 @@ impl AssistantContext {
|
|||||||
pending_cache_warming_task: Task::ready(None),
|
pending_cache_warming_task: Task::ready(None),
|
||||||
_subscriptions: vec![cx.subscribe(&buffer, Self::handle_buffer_event)],
|
_subscriptions: vec![cx.subscribe(&buffer, Self::handle_buffer_event)],
|
||||||
pending_save: Task::ready(Ok(())),
|
pending_save: Task::ready(Ok(())),
|
||||||
completion_mode: AgentSettings::get_global(cx).preferred_completion_mode,
|
|
||||||
path: None,
|
path: None,
|
||||||
buffer,
|
buffer,
|
||||||
telemetry,
|
telemetry,
|
||||||
@@ -826,7 +753,7 @@ impl AssistantContext {
|
|||||||
.collect(),
|
.collect(),
|
||||||
summary: self
|
summary: self
|
||||||
.summary
|
.summary
|
||||||
.content()
|
.as_ref()
|
||||||
.map(|summary| summary.text.clone())
|
.map(|summary| summary.text.clone())
|
||||||
.unwrap_or_default(),
|
.unwrap_or_default(),
|
||||||
slash_command_output_sections: self
|
slash_command_output_sections: self
|
||||||
@@ -1012,10 +939,12 @@ impl AssistantContext {
|
|||||||
summary: new_summary,
|
summary: new_summary,
|
||||||
..
|
..
|
||||||
} => {
|
} => {
|
||||||
if self.summary.timestamp().map_or(true, |current_timestamp| {
|
if self
|
||||||
new_summary.timestamp > current_timestamp
|
.summary
|
||||||
}) {
|
.as_ref()
|
||||||
self.summary = ContextSummary::Content(new_summary);
|
.map_or(true, |summary| new_summary.timestamp > summary.timestamp)
|
||||||
|
{
|
||||||
|
self.summary = Some(new_summary);
|
||||||
summary_generated = true;
|
summary_generated = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1173,8 +1102,8 @@ impl AssistantContext {
|
|||||||
self.path.as_ref()
|
self.path.as_ref()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn summary(&self) -> &ContextSummary {
|
pub fn summary(&self) -> Option<&ContextSummary> {
|
||||||
&self.summary
|
self.summary.as_ref()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn parsed_slash_commands(&self) -> &[ParsedSlashCommand] {
|
pub fn parsed_slash_commands(&self) -> &[ParsedSlashCommand] {
|
||||||
@@ -1742,8 +1671,9 @@ impl AssistantContext {
|
|||||||
merge_same_roles,
|
merge_same_roles,
|
||||||
} => {
|
} => {
|
||||||
if !merge_same_roles && Some(role) != last_role {
|
if !merge_same_roles && Some(role) != last_role {
|
||||||
let buffer = this.buffer.read(cx);
|
let offset = this.buffer.read_with(cx, |buffer, _cx| {
|
||||||
let offset = insert_position.to_offset(buffer);
|
insert_position.to_offset(buffer)
|
||||||
|
});
|
||||||
this.insert_message_at_offset(
|
this.insert_message_at_offset(
|
||||||
offset,
|
offset,
|
||||||
role,
|
role,
|
||||||
@@ -2165,6 +2095,12 @@ impl AssistantContext {
|
|||||||
metadata.status = MessageStatus::Canceled;
|
metadata.status = MessageStatus::Canceled;
|
||||||
});
|
});
|
||||||
Some(error.to_string())
|
Some(error.to_string())
|
||||||
|
} else if error.is::<MaxMonthlySpendReachedError>() {
|
||||||
|
cx.emit(ContextEvent::ShowMaxMonthlySpendReachedError);
|
||||||
|
this.update_metadata(assistant_message_id, cx, |metadata| {
|
||||||
|
metadata.status = MessageStatus::Canceled;
|
||||||
|
});
|
||||||
|
Some(error.to_string())
|
||||||
} else {
|
} else {
|
||||||
let error_message = error
|
let error_message = error
|
||||||
.chain()
|
.chain()
|
||||||
@@ -2215,7 +2151,6 @@ impl AssistantContext {
|
|||||||
StopReason::ToolUse => {}
|
StopReason::ToolUse => {}
|
||||||
StopReason::EndTurn => {}
|
StopReason::EndTurn => {}
|
||||||
StopReason::MaxTokens => {}
|
StopReason::MaxTokens => {}
|
||||||
StopReason::Refusal => {}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
@@ -2273,13 +2208,13 @@ impl AssistantContext {
|
|||||||
let mut completion_request = LanguageModelRequest {
|
let mut completion_request = LanguageModelRequest {
|
||||||
thread_id: None,
|
thread_id: None,
|
||||||
prompt_id: None,
|
prompt_id: None,
|
||||||
intent: Some(CompletionIntent::UserPrompt),
|
|
||||||
mode: None,
|
mode: None,
|
||||||
messages: Vec::new(),
|
messages: Vec::new(),
|
||||||
tools: Vec::new(),
|
tools: Vec::new(),
|
||||||
tool_choice: None,
|
tool_choice: None,
|
||||||
stop: Vec::new(),
|
stop: Vec::new(),
|
||||||
temperature: model.and_then(|model| AgentSettings::temperature_for_model(model, cx)),
|
temperature: model
|
||||||
|
.and_then(|model| AssistantSettings::temperature_for_model(model, cx)),
|
||||||
};
|
};
|
||||||
for message in self.messages(cx) {
|
for message in self.messages(cx) {
|
||||||
if message.status != MessageStatus::Done {
|
if message.status != MessageStatus::Done {
|
||||||
@@ -2334,15 +2269,7 @@ impl AssistantContext {
|
|||||||
completion_request.messages.push(request_message);
|
completion_request.messages.push(request_message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
let supports_max_mode = if let Some(model) = model {
|
|
||||||
model.supports_max_mode()
|
|
||||||
} else {
|
|
||||||
false
|
|
||||||
};
|
|
||||||
|
|
||||||
if supports_max_mode {
|
|
||||||
completion_request.mode = Some(self.completion_mode.into());
|
|
||||||
}
|
|
||||||
completion_request
|
completion_request
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2649,7 +2576,7 @@ impl AssistantContext {
|
|||||||
return;
|
return;
|
||||||
};
|
};
|
||||||
|
|
||||||
if replace_old || (self.message_anchors.len() >= 2 && self.summary.is_pending()) {
|
if replace_old || (self.message_anchors.len() >= 2 && self.summary.is_none()) {
|
||||||
if !model.provider.is_authenticated(cx) {
|
if !model.provider.is_authenticated(cx) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -2666,20 +2593,17 @@ impl AssistantContext {
|
|||||||
|
|
||||||
// If there is no summary, it is set with `done: false` so that "Loading Summary…" can
|
// If there is no summary, it is set with `done: false` so that "Loading Summary…" can
|
||||||
// be displayed.
|
// be displayed.
|
||||||
match self.summary {
|
if self.summary.is_none() {
|
||||||
ContextSummary::Pending | ContextSummary::Error => {
|
self.summary = Some(ContextSummary {
|
||||||
self.summary = ContextSummary::Content(ContextSummaryContent {
|
text: "".to_string(),
|
||||||
text: "".to_string(),
|
done: false,
|
||||||
done: false,
|
timestamp: clock::Lamport::default(),
|
||||||
timestamp: clock::Lamport::default(),
|
});
|
||||||
});
|
replace_old = true;
|
||||||
replace_old = true;
|
|
||||||
}
|
|
||||||
ContextSummary::Content(_) => {}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
self.summary_task = cx.spawn(async move |this, cx| {
|
self.summary_task = cx.spawn(async move |this, cx| {
|
||||||
let result = async {
|
async move {
|
||||||
let stream = model.model.stream_completion_text(request, &cx);
|
let stream = model.model.stream_completion_text(request, &cx);
|
||||||
let mut messages = stream.await?;
|
let mut messages = stream.await?;
|
||||||
|
|
||||||
@@ -2690,7 +2614,7 @@ impl AssistantContext {
|
|||||||
this.update(cx, |this, cx| {
|
this.update(cx, |this, cx| {
|
||||||
let version = this.version.clone();
|
let version = this.version.clone();
|
||||||
let timestamp = this.next_timestamp();
|
let timestamp = this.next_timestamp();
|
||||||
let summary = this.summary.content_or_set_empty();
|
let summary = this.summary.get_or_insert(ContextSummary::default());
|
||||||
if !replaced && replace_old {
|
if !replaced && replace_old {
|
||||||
summary.text.clear();
|
summary.text.clear();
|
||||||
replaced = true;
|
replaced = true;
|
||||||
@@ -2712,19 +2636,10 @@ impl AssistantContext {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
this.read_with(cx, |this, _cx| {
|
|
||||||
if let Some(summary) = this.summary.content() {
|
|
||||||
if summary.text.is_empty() {
|
|
||||||
bail!("Model generated an empty summary");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Ok(())
|
|
||||||
})??;
|
|
||||||
|
|
||||||
this.update(cx, |this, cx| {
|
this.update(cx, |this, cx| {
|
||||||
let version = this.version.clone();
|
let version = this.version.clone();
|
||||||
let timestamp = this.next_timestamp();
|
let timestamp = this.next_timestamp();
|
||||||
if let Some(summary) = this.summary.content_as_mut() {
|
if let Some(summary) = this.summary.as_mut() {
|
||||||
summary.done = true;
|
summary.done = true;
|
||||||
summary.timestamp = timestamp;
|
summary.timestamp = timestamp;
|
||||||
let operation = ContextOperation::UpdateSummary {
|
let operation = ContextOperation::UpdateSummary {
|
||||||
@@ -2739,18 +2654,8 @@ impl AssistantContext {
|
|||||||
|
|
||||||
anyhow::Ok(())
|
anyhow::Ok(())
|
||||||
}
|
}
|
||||||
.await;
|
.log_err()
|
||||||
|
.await
|
||||||
if let Err(err) = result {
|
|
||||||
this.update(cx, |this, cx| {
|
|
||||||
this.summary = ContextSummary::Error;
|
|
||||||
cx.emit(ContextEvent::SummaryChanged);
|
|
||||||
})
|
|
||||||
.log_err();
|
|
||||||
log::error!("Error generating context summary: {}", err);
|
|
||||||
}
|
|
||||||
|
|
||||||
Some(())
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -2864,7 +2769,7 @@ impl AssistantContext {
|
|||||||
|
|
||||||
let (old_path, summary) = this.read_with(cx, |this, _| {
|
let (old_path, summary) = this.read_with(cx, |this, _| {
|
||||||
let path = this.path.clone();
|
let path = this.path.clone();
|
||||||
let summary = if let Some(summary) = this.summary.content() {
|
let summary = if let Some(summary) = this.summary.as_ref() {
|
||||||
if summary.done {
|
if summary.done {
|
||||||
Some(summary.text.clone())
|
Some(summary.text.clone())
|
||||||
} else {
|
} else {
|
||||||
@@ -2918,12 +2823,21 @@ impl AssistantContext {
|
|||||||
|
|
||||||
pub fn set_custom_summary(&mut self, custom_summary: String, cx: &mut Context<Self>) {
|
pub fn set_custom_summary(&mut self, custom_summary: String, cx: &mut Context<Self>) {
|
||||||
let timestamp = self.next_timestamp();
|
let timestamp = self.next_timestamp();
|
||||||
let summary = self.summary.content_or_set_empty();
|
let summary = self.summary.get_or_insert(ContextSummary::default());
|
||||||
summary.timestamp = timestamp;
|
summary.timestamp = timestamp;
|
||||||
summary.done = true;
|
summary.done = true;
|
||||||
summary.text = custom_summary;
|
summary.text = custom_summary;
|
||||||
cx.emit(ContextEvent::SummaryChanged);
|
cx.emit(ContextEvent::SummaryChanged);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub const DEFAULT_SUMMARY: SharedString = SharedString::new_static("New Text Thread");
|
||||||
|
|
||||||
|
pub fn summary_or_default(&self) -> SharedString {
|
||||||
|
self.summary
|
||||||
|
.as_ref()
|
||||||
|
.map(|summary| summary.text.clone().into())
|
||||||
|
.unwrap_or(Self::DEFAULT_SUMMARY)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Default)]
|
#[derive(Debug, Default)]
|
||||||
@@ -3031,7 +2945,7 @@ impl SavedContext {
|
|||||||
let saved_context_json = serde_json::from_str::<serde_json::Value>(json)?;
|
let saved_context_json = serde_json::from_str::<serde_json::Value>(json)?;
|
||||||
match saved_context_json
|
match saved_context_json
|
||||||
.get("version")
|
.get("version")
|
||||||
.context("version not found")?
|
.ok_or_else(|| anyhow!("version not found"))?
|
||||||
{
|
{
|
||||||
serde_json::Value::String(version) => match version.as_str() {
|
serde_json::Value::String(version) => match version.as_str() {
|
||||||
SavedContext::VERSION => {
|
SavedContext::VERSION => {
|
||||||
@@ -3052,9 +2966,9 @@ impl SavedContext {
|
|||||||
serde_json::from_value::<SavedContextV0_1_0>(saved_context_json)?;
|
serde_json::from_value::<SavedContextV0_1_0>(saved_context_json)?;
|
||||||
Ok(saved_context.upgrade())
|
Ok(saved_context.upgrade())
|
||||||
}
|
}
|
||||||
_ => anyhow::bail!("unrecognized saved context version: {version:?}"),
|
_ => Err(anyhow!("unrecognized saved context version: {}", version)),
|
||||||
},
|
},
|
||||||
_ => anyhow::bail!("version not found on saved context"),
|
_ => Err(anyhow!("version not found on saved context")),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3139,7 +3053,7 @@ impl SavedContext {
|
|||||||
|
|
||||||
let timestamp = next_timestamp.tick();
|
let timestamp = next_timestamp.tick();
|
||||||
operations.push(ContextOperation::UpdateSummary {
|
operations.push(ContextOperation::UpdateSummary {
|
||||||
summary: ContextSummaryContent {
|
summary: ContextSummary {
|
||||||
text: self.summary,
|
text: self.summary,
|
||||||
done: true,
|
done: true,
|
||||||
timestamp,
|
timestamp,
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
use crate::{
|
use crate::{
|
||||||
AssistantContext, CacheStatus, ContextEvent, ContextId, ContextOperation, ContextSummary,
|
AssistantContext, CacheStatus, ContextEvent, ContextId, ContextOperation,
|
||||||
InvokedSlashCommandId, MessageCacheMetadata, MessageId, MessageStatus,
|
InvokedSlashCommandId, MessageCacheMetadata, MessageId, MessageStatus,
|
||||||
};
|
};
|
||||||
use anyhow::Result;
|
use anyhow::Result;
|
||||||
@@ -16,10 +16,7 @@ use futures::{
|
|||||||
};
|
};
|
||||||
use gpui::{App, Entity, SharedString, Task, TestAppContext, WeakEntity, prelude::*};
|
use gpui::{App, Entity, SharedString, Task, TestAppContext, WeakEntity, prelude::*};
|
||||||
use language::{Buffer, BufferSnapshot, LanguageRegistry, LspAdapterDelegate};
|
use language::{Buffer, BufferSnapshot, LanguageRegistry, LspAdapterDelegate};
|
||||||
use language_model::{
|
use language_model::{LanguageModelCacheConfiguration, LanguageModelRegistry, Role};
|
||||||
ConfiguredModel, LanguageModelCacheConfiguration, LanguageModelRegistry, Role,
|
|
||||||
fake_provider::{FakeLanguageModel, FakeLanguageModelProvider},
|
|
||||||
};
|
|
||||||
use parking_lot::Mutex;
|
use parking_lot::Mutex;
|
||||||
use pretty_assertions::assert_eq;
|
use pretty_assertions::assert_eq;
|
||||||
use project::Project;
|
use project::Project;
|
||||||
@@ -1180,187 +1177,6 @@ fn test_mark_cache_anchors(cx: &mut App) {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[gpui::test]
|
|
||||||
async fn test_summarization(cx: &mut TestAppContext) {
|
|
||||||
let (context, fake_model) = setup_context_editor_with_fake_model(cx);
|
|
||||||
|
|
||||||
// Initial state should be pending
|
|
||||||
context.read_with(cx, |context, _| {
|
|
||||||
assert!(matches!(context.summary(), ContextSummary::Pending));
|
|
||||||
assert_eq!(context.summary().or_default(), ContextSummary::DEFAULT);
|
|
||||||
});
|
|
||||||
|
|
||||||
let message_1 = context.read_with(cx, |context, _cx| context.message_anchors[0].clone());
|
|
||||||
context.update(cx, |context, cx| {
|
|
||||||
context
|
|
||||||
.insert_message_after(message_1.id, Role::Assistant, MessageStatus::Done, cx)
|
|
||||||
.unwrap();
|
|
||||||
});
|
|
||||||
|
|
||||||
// Send a message
|
|
||||||
context.update(cx, |context, cx| {
|
|
||||||
context.assist(cx);
|
|
||||||
});
|
|
||||||
|
|
||||||
simulate_successful_response(&fake_model, cx);
|
|
||||||
|
|
||||||
// Should start generating summary when there are >= 2 messages
|
|
||||||
context.read_with(cx, |context, _| {
|
|
||||||
assert!(!context.summary().content().unwrap().done);
|
|
||||||
});
|
|
||||||
|
|
||||||
cx.run_until_parked();
|
|
||||||
fake_model.stream_last_completion_response("Brief");
|
|
||||||
fake_model.stream_last_completion_response(" Introduction");
|
|
||||||
fake_model.end_last_completion_stream();
|
|
||||||
cx.run_until_parked();
|
|
||||||
|
|
||||||
// Summary should be set
|
|
||||||
context.read_with(cx, |context, _| {
|
|
||||||
assert_eq!(context.summary().or_default(), "Brief Introduction");
|
|
||||||
});
|
|
||||||
|
|
||||||
// We should be able to manually set a summary
|
|
||||||
context.update(cx, |context, cx| {
|
|
||||||
context.set_custom_summary("Brief Intro".into(), cx);
|
|
||||||
});
|
|
||||||
|
|
||||||
context.read_with(cx, |context, _| {
|
|
||||||
assert_eq!(context.summary().or_default(), "Brief Intro");
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
#[gpui::test]
|
|
||||||
async fn test_thread_summary_error_set_manually(cx: &mut TestAppContext) {
|
|
||||||
let (context, fake_model) = setup_context_editor_with_fake_model(cx);
|
|
||||||
|
|
||||||
test_summarize_error(&fake_model, &context, cx);
|
|
||||||
|
|
||||||
// Now we should be able to set a summary
|
|
||||||
context.update(cx, |context, cx| {
|
|
||||||
context.set_custom_summary("Brief Intro".into(), cx);
|
|
||||||
});
|
|
||||||
|
|
||||||
context.read_with(cx, |context, _| {
|
|
||||||
assert_eq!(context.summary().or_default(), "Brief Intro");
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
#[gpui::test]
|
|
||||||
async fn test_thread_summary_error_retry(cx: &mut TestAppContext) {
|
|
||||||
let (context, fake_model) = setup_context_editor_with_fake_model(cx);
|
|
||||||
|
|
||||||
test_summarize_error(&fake_model, &context, cx);
|
|
||||||
|
|
||||||
// Sending another message should not trigger another summarize request
|
|
||||||
context.update(cx, |context, cx| {
|
|
||||||
context.assist(cx);
|
|
||||||
});
|
|
||||||
|
|
||||||
simulate_successful_response(&fake_model, cx);
|
|
||||||
|
|
||||||
context.read_with(cx, |context, _| {
|
|
||||||
// State is still Error, not Generating
|
|
||||||
assert!(matches!(context.summary(), ContextSummary::Error));
|
|
||||||
});
|
|
||||||
|
|
||||||
// But the summarize request can be invoked manually
|
|
||||||
context.update(cx, |context, cx| {
|
|
||||||
context.summarize(true, cx);
|
|
||||||
});
|
|
||||||
|
|
||||||
context.read_with(cx, |context, _| {
|
|
||||||
assert!(!context.summary().content().unwrap().done);
|
|
||||||
});
|
|
||||||
|
|
||||||
cx.run_until_parked();
|
|
||||||
fake_model.stream_last_completion_response("A successful summary");
|
|
||||||
fake_model.end_last_completion_stream();
|
|
||||||
cx.run_until_parked();
|
|
||||||
|
|
||||||
context.read_with(cx, |context, _| {
|
|
||||||
assert_eq!(context.summary().or_default(), "A successful summary");
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
fn test_summarize_error(
|
|
||||||
model: &Arc<FakeLanguageModel>,
|
|
||||||
context: &Entity<AssistantContext>,
|
|
||||||
cx: &mut TestAppContext,
|
|
||||||
) {
|
|
||||||
let message_1 = context.read_with(cx, |context, _cx| context.message_anchors[0].clone());
|
|
||||||
context.update(cx, |context, cx| {
|
|
||||||
context
|
|
||||||
.insert_message_after(message_1.id, Role::Assistant, MessageStatus::Done, cx)
|
|
||||||
.unwrap();
|
|
||||||
});
|
|
||||||
|
|
||||||
// Send a message
|
|
||||||
context.update(cx, |context, cx| {
|
|
||||||
context.assist(cx);
|
|
||||||
});
|
|
||||||
|
|
||||||
simulate_successful_response(&model, cx);
|
|
||||||
|
|
||||||
context.read_with(cx, |context, _| {
|
|
||||||
assert!(!context.summary().content().unwrap().done);
|
|
||||||
});
|
|
||||||
|
|
||||||
// Simulate summary request ending
|
|
||||||
cx.run_until_parked();
|
|
||||||
model.end_last_completion_stream();
|
|
||||||
cx.run_until_parked();
|
|
||||||
|
|
||||||
// State is set to Error and default message
|
|
||||||
context.read_with(cx, |context, _| {
|
|
||||||
assert_eq!(*context.summary(), ContextSummary::Error);
|
|
||||||
assert_eq!(context.summary().or_default(), ContextSummary::DEFAULT);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
fn setup_context_editor_with_fake_model(
|
|
||||||
cx: &mut TestAppContext,
|
|
||||||
) -> (Entity<AssistantContext>, Arc<FakeLanguageModel>) {
|
|
||||||
let registry = Arc::new(LanguageRegistry::test(cx.executor().clone()));
|
|
||||||
|
|
||||||
let fake_provider = Arc::new(FakeLanguageModelProvider);
|
|
||||||
let fake_model = Arc::new(fake_provider.test_model());
|
|
||||||
|
|
||||||
cx.update(|cx| {
|
|
||||||
init_test(cx);
|
|
||||||
LanguageModelRegistry::global(cx).update(cx, |registry, cx| {
|
|
||||||
registry.set_default_model(
|
|
||||||
Some(ConfiguredModel {
|
|
||||||
provider: fake_provider.clone(),
|
|
||||||
model: fake_model.clone(),
|
|
||||||
}),
|
|
||||||
cx,
|
|
||||||
)
|
|
||||||
})
|
|
||||||
});
|
|
||||||
|
|
||||||
let prompt_builder = Arc::new(PromptBuilder::new(None).unwrap());
|
|
||||||
let context = cx.new(|cx| {
|
|
||||||
AssistantContext::local(
|
|
||||||
registry,
|
|
||||||
None,
|
|
||||||
None,
|
|
||||||
prompt_builder.clone(),
|
|
||||||
Arc::new(SlashCommandWorkingSet::default()),
|
|
||||||
cx,
|
|
||||||
)
|
|
||||||
});
|
|
||||||
|
|
||||||
(context, fake_model)
|
|
||||||
}
|
|
||||||
|
|
||||||
fn simulate_successful_response(fake_model: &FakeLanguageModel, cx: &mut TestAppContext) {
|
|
||||||
cx.run_until_parked();
|
|
||||||
fake_model.stream_last_completion_response("Assistant response");
|
|
||||||
fake_model.end_last_completion_stream();
|
|
||||||
cx.run_until_parked();
|
|
||||||
}
|
|
||||||
|
|
||||||
fn messages(context: &Entity<AssistantContext>, cx: &App) -> Vec<(MessageId, Role, Range<usize>)> {
|
fn messages(context: &Entity<AssistantContext>, cx: &App) -> Vec<(MessageId, Role, Range<usize>)> {
|
||||||
context
|
context
|
||||||
.read(cx)
|
.read(cx)
|
||||||
@@ -1386,7 +1202,7 @@ fn init_test(cx: &mut App) {
|
|||||||
LanguageModelRegistry::test(cx);
|
LanguageModelRegistry::test(cx);
|
||||||
cx.set_global(settings_store);
|
cx.set_global(settings_store);
|
||||||
language::init(cx);
|
language::init(cx);
|
||||||
agent_settings::init(cx);
|
assistant_settings::init(cx);
|
||||||
Project::init_settings(cx);
|
Project::init_settings(cx);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,11 +1,5 @@
|
|||||||
use crate::{
|
|
||||||
language_model_selector::{
|
|
||||||
LanguageModelSelector, ToggleModelSelector, language_model_selector,
|
|
||||||
},
|
|
||||||
max_mode_tooltip::MaxModeTooltip,
|
|
||||||
};
|
|
||||||
use agent_settings::{AgentSettings, CompletionMode};
|
|
||||||
use anyhow::Result;
|
use anyhow::Result;
|
||||||
|
use assistant_settings::AssistantSettings;
|
||||||
use assistant_slash_command::{SlashCommand, SlashCommandOutputSection, SlashCommandWorkingSet};
|
use assistant_slash_command::{SlashCommand, SlashCommandOutputSection, SlashCommandWorkingSet};
|
||||||
use assistant_slash_commands::{
|
use assistant_slash_commands::{
|
||||||
DefaultSlashCommand, DocsSlashCommand, DocsSlashCommandArgs, FileSlashCommand,
|
DefaultSlashCommand, DocsSlashCommand, DocsSlashCommandArgs, FileSlashCommand,
|
||||||
@@ -42,8 +36,11 @@ use language_model::{
|
|||||||
LanguageModelImage, LanguageModelProvider, LanguageModelProviderTosView, LanguageModelRegistry,
|
LanguageModelImage, LanguageModelProvider, LanguageModelProviderTosView, LanguageModelRegistry,
|
||||||
Role,
|
Role,
|
||||||
};
|
};
|
||||||
|
use language_model_selector::{
|
||||||
|
LanguageModelSelector, LanguageModelSelectorPopoverMenu, ToggleModelSelector,
|
||||||
|
};
|
||||||
use multi_buffer::MultiBufferRow;
|
use multi_buffer::MultiBufferRow;
|
||||||
use picker::{Picker, popover_menu::PickerPopoverMenu};
|
use picker::Picker;
|
||||||
use project::{Project, Worktree};
|
use project::{Project, Worktree};
|
||||||
use project::{ProjectPath, lsp_store::LocalLspAdapterDelegate};
|
use project::{ProjectPath, lsp_store::LocalLspAdapterDelegate};
|
||||||
use rope::Point;
|
use rope::Point;
|
||||||
@@ -54,7 +51,6 @@ use std::{
|
|||||||
cmp,
|
cmp,
|
||||||
ops::Range,
|
ops::Range,
|
||||||
path::{Path, PathBuf},
|
path::{Path, PathBuf},
|
||||||
rc::Rc,
|
|
||||||
sync::Arc,
|
sync::Arc,
|
||||||
time::Duration,
|
time::Duration,
|
||||||
};
|
};
|
||||||
@@ -118,6 +114,7 @@ type MessageHeader = MessageMetadata;
|
|||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
enum AssistError {
|
enum AssistError {
|
||||||
PaymentRequired,
|
PaymentRequired,
|
||||||
|
MaxMonthlySpendReached,
|
||||||
Message(SharedString),
|
Message(SharedString),
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -238,7 +235,7 @@ impl ContextEditor {
|
|||||||
editor.set_show_breakpoints(false, cx);
|
editor.set_show_breakpoints(false, cx);
|
||||||
editor.set_show_wrap_guides(false, cx);
|
editor.set_show_wrap_guides(false, cx);
|
||||||
editor.set_show_indent_guides(false, cx);
|
editor.set_show_indent_guides(false, cx);
|
||||||
editor.set_completion_provider(Some(Rc::new(completion_provider)));
|
editor.set_completion_provider(Some(Box::new(completion_provider)));
|
||||||
editor.set_menu_inline_completions_policy(MenuInlineCompletionsPolicy::Never);
|
editor.set_menu_inline_completions_policy(MenuInlineCompletionsPolicy::Never);
|
||||||
editor.set_collaboration_hub(Box::new(project.clone()));
|
editor.set_collaboration_hub(Box::new(project.clone()));
|
||||||
|
|
||||||
@@ -283,10 +280,10 @@ impl ContextEditor {
|
|||||||
slash_menu_handle: Default::default(),
|
slash_menu_handle: Default::default(),
|
||||||
dragged_file_worktrees: Vec::new(),
|
dragged_file_worktrees: Vec::new(),
|
||||||
language_model_selector: cx.new(|cx| {
|
language_model_selector: cx.new(|cx| {
|
||||||
language_model_selector(
|
LanguageModelSelector::new(
|
||||||
|cx| LanguageModelRegistry::read_global(cx).default_model(),
|
|cx| LanguageModelRegistry::read_global(cx).default_model(),
|
||||||
move |model, cx| {
|
move |model, cx| {
|
||||||
update_settings_file::<AgentSettings>(
|
update_settings_file::<AssistantSettings>(
|
||||||
fs.clone(),
|
fs.clone(),
|
||||||
cx,
|
cx,
|
||||||
move |settings, _| settings.set_model(model.clone()),
|
move |settings, _| settings.set_model(model.clone()),
|
||||||
@@ -735,6 +732,9 @@ impl ContextEditor {
|
|||||||
ContextEvent::ShowPaymentRequiredError => {
|
ContextEvent::ShowPaymentRequiredError => {
|
||||||
self.last_error = Some(AssistError::PaymentRequired);
|
self.last_error = Some(AssistError::PaymentRequired);
|
||||||
}
|
}
|
||||||
|
ContextEvent::ShowMaxMonthlySpendReachedError => {
|
||||||
|
self.last_error = Some(AssistError::MaxMonthlySpendReached);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1594,7 +1594,7 @@ impl ContextEditor {
|
|||||||
&mut self,
|
&mut self,
|
||||||
cx: &mut Context<Self>,
|
cx: &mut Context<Self>,
|
||||||
) -> (String, CopyMetadata, Vec<text::Selection<usize>>) {
|
) -> (String, CopyMetadata, Vec<text::Selection<usize>>) {
|
||||||
let (mut selection, creases) = self.editor.update(cx, |editor, cx| {
|
let (selection, creases) = self.editor.update(cx, |editor, cx| {
|
||||||
let mut selection = editor.selections.newest_adjusted(cx);
|
let mut selection = editor.selections.newest_adjusted(cx);
|
||||||
let snapshot = editor.buffer().read(cx).snapshot(cx);
|
let snapshot = editor.buffer().read(cx).snapshot(cx);
|
||||||
|
|
||||||
@@ -1646,35 +1646,23 @@ impl ContextEditor {
|
|||||||
let context = self.context.read(cx);
|
let context = self.context.read(cx);
|
||||||
|
|
||||||
let mut text = String::new();
|
let mut text = String::new();
|
||||||
|
for message in context.messages(cx) {
|
||||||
// If selection is empty, we want to copy the entire line
|
if message.offset_range.start >= selection.range().end {
|
||||||
if selection.range().is_empty() {
|
break;
|
||||||
let snapshot = context.buffer().read(cx).snapshot();
|
} else if message.offset_range.end >= selection.range().start {
|
||||||
let point = snapshot.offset_to_point(selection.range().start);
|
let range = cmp::max(message.offset_range.start, selection.range().start)
|
||||||
selection.start = snapshot.point_to_offset(Point::new(point.row, 0));
|
..cmp::min(message.offset_range.end, selection.range().end);
|
||||||
selection.end = snapshot
|
if !range.is_empty() {
|
||||||
.point_to_offset(cmp::min(Point::new(point.row + 1, 0), snapshot.max_point()));
|
for chunk in context.buffer().read(cx).text_for_range(range) {
|
||||||
for chunk in context.buffer().read(cx).text_for_range(selection.range()) {
|
text.push_str(chunk);
|
||||||
text.push_str(chunk);
|
}
|
||||||
}
|
if message.offset_range.end < selection.range().end {
|
||||||
} else {
|
text.push('\n');
|
||||||
for message in context.messages(cx) {
|
|
||||||
if message.offset_range.start >= selection.range().end {
|
|
||||||
break;
|
|
||||||
} else if message.offset_range.end >= selection.range().start {
|
|
||||||
let range = cmp::max(message.offset_range.start, selection.range().start)
|
|
||||||
..cmp::min(message.offset_range.end, selection.range().end);
|
|
||||||
if !range.is_empty() {
|
|
||||||
for chunk in context.buffer().read(cx).text_for_range(range) {
|
|
||||||
text.push_str(chunk);
|
|
||||||
}
|
|
||||||
if message.offset_range.end < selection.range().end {
|
|
||||||
text.push('\n');
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
(text, CopyMetadata { creases }, vec![selection])
|
(text, CopyMetadata { creases }, vec![selection])
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1872,12 +1860,7 @@ impl ContextEditor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn title(&self, cx: &App) -> SharedString {
|
pub fn title(&self, cx: &App) -> SharedString {
|
||||||
self.context.read(cx).summary().or_default()
|
self.context.read(cx).summary_or_default()
|
||||||
}
|
|
||||||
|
|
||||||
pub fn regenerate_summary(&mut self, cx: &mut Context<Self>) {
|
|
||||||
self.context
|
|
||||||
.update(cx, |context, cx| context.summarize(true, cx));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn render_notice(&self, cx: &mut Context<Self>) -> Option<AnyElement> {
|
fn render_notice(&self, cx: &mut Context<Self>) -> Option<AnyElement> {
|
||||||
@@ -1907,28 +1890,15 @@ impl ContextEditor {
|
|||||||
.on_click(cx.listener(|this, _event, _window, cx| {
|
.on_click(cx.listener(|this, _event, _window, cx| {
|
||||||
let client = this
|
let client = this
|
||||||
.workspace
|
.workspace
|
||||||
.read_with(cx, |workspace, _| workspace.client().clone())
|
.update(cx, |workspace, _| workspace.client().clone())
|
||||||
.log_err();
|
.log_err();
|
||||||
|
|
||||||
if let Some(client) = client {
|
if let Some(client) = client {
|
||||||
cx.spawn(async move |context_editor, cx| {
|
cx.spawn(async move |this, cx| {
|
||||||
match client.authenticate_and_connect(true, cx).await {
|
client.authenticate_and_connect(true, cx).await?;
|
||||||
util::ConnectionResult::Timeout => {
|
this.update(cx, |_, cx| cx.notify())
|
||||||
log::error!("Authentication timeout")
|
|
||||||
}
|
|
||||||
util::ConnectionResult::ConnectionReset => {
|
|
||||||
log::error!("Connection reset")
|
|
||||||
}
|
|
||||||
util::ConnectionResult::Result(r) => {
|
|
||||||
if r.log_err().is_some() {
|
|
||||||
context_editor
|
|
||||||
.update(cx, |_, cx| cx.notify())
|
|
||||||
.ok();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
.detach()
|
.detach_and_log_err(cx)
|
||||||
}
|
}
|
||||||
})),
|
})),
|
||||||
)
|
)
|
||||||
@@ -2012,17 +1982,17 @@ impl ContextEditor {
|
|||||||
None => (ButtonStyle::Filled, None),
|
None => (ButtonStyle::Filled, None),
|
||||||
};
|
};
|
||||||
|
|
||||||
Button::new("send_button", "Send")
|
ButtonLike::new("send_button")
|
||||||
.label_size(LabelSize::Small)
|
|
||||||
.disabled(self.sending_disabled(cx))
|
.disabled(self.sending_disabled(cx))
|
||||||
.style(style)
|
.style(style)
|
||||||
.when_some(tooltip, |button, tooltip| {
|
.when_some(tooltip, |button, tooltip| {
|
||||||
button.tooltip(move |_, _| tooltip.clone())
|
button.tooltip(move |_, _| tooltip.clone())
|
||||||
})
|
})
|
||||||
.layer(ElevationIndex::ModalSurface)
|
.layer(ElevationIndex::ModalSurface)
|
||||||
.key_binding(
|
.child(Label::new("Send"))
|
||||||
|
.children(
|
||||||
KeyBinding::for_action_in(&Assist, &focus_handle, window, cx)
|
KeyBinding::for_action_in(&Assist, &focus_handle, window, cx)
|
||||||
.map(|kb| kb.size(rems_from_px(12.))),
|
.map(|binding| binding.into_any_element()),
|
||||||
)
|
)
|
||||||
.on_click(move |_event, window, cx| {
|
.on_click(move |_event, window, cx| {
|
||||||
focus_handle.dispatch_action(&Assist, window, cx);
|
focus_handle.dispatch_action(&Assist, window, cx);
|
||||||
@@ -2062,50 +2032,7 @@ impl ContextEditor {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn render_max_mode_toggle(&self, cx: &mut Context<Self>) -> Option<AnyElement> {
|
fn render_language_model_selector(&self, cx: &mut Context<Self>) -> impl IntoElement {
|
||||||
let context = self.context().read(cx);
|
|
||||||
let active_model = LanguageModelRegistry::read_global(cx)
|
|
||||||
.default_model()
|
|
||||||
.map(|default| default.model)?;
|
|
||||||
if !active_model.supports_max_mode() {
|
|
||||||
return None;
|
|
||||||
}
|
|
||||||
|
|
||||||
let active_completion_mode = context.completion_mode();
|
|
||||||
let burn_mode_enabled = active_completion_mode == CompletionMode::Burn;
|
|
||||||
let icon = if burn_mode_enabled {
|
|
||||||
IconName::ZedBurnModeOn
|
|
||||||
} else {
|
|
||||||
IconName::ZedBurnMode
|
|
||||||
};
|
|
||||||
|
|
||||||
Some(
|
|
||||||
IconButton::new("burn-mode", icon)
|
|
||||||
.icon_size(IconSize::Small)
|
|
||||||
.icon_color(Color::Muted)
|
|
||||||
.toggle_state(burn_mode_enabled)
|
|
||||||
.selected_icon_color(Color::Error)
|
|
||||||
.on_click(cx.listener(move |this, _event, _window, cx| {
|
|
||||||
this.context().update(cx, |context, _cx| {
|
|
||||||
context.set_completion_mode(match active_completion_mode {
|
|
||||||
CompletionMode::Burn => CompletionMode::Normal,
|
|
||||||
CompletionMode::Normal => CompletionMode::Burn,
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}))
|
|
||||||
.tooltip(move |_window, cx| {
|
|
||||||
cx.new(|_| MaxModeTooltip::new().selected(burn_mode_enabled))
|
|
||||||
.into()
|
|
||||||
})
|
|
||||||
.into_any_element(),
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
fn render_language_model_selector(
|
|
||||||
&self,
|
|
||||||
window: &mut Window,
|
|
||||||
cx: &mut Context<Self>,
|
|
||||||
) -> impl IntoElement {
|
|
||||||
let active_model = LanguageModelRegistry::read_global(cx)
|
let active_model = LanguageModelRegistry::read_global(cx)
|
||||||
.default_model()
|
.default_model()
|
||||||
.map(|default| default.model);
|
.map(|default| default.model);
|
||||||
@@ -2115,7 +2042,7 @@ impl ContextEditor {
|
|||||||
None => SharedString::from("No model selected"),
|
None => SharedString::from("No model selected"),
|
||||||
};
|
};
|
||||||
|
|
||||||
PickerPopoverMenu::new(
|
LanguageModelSelectorPopoverMenu::new(
|
||||||
self.language_model_selector.clone(),
|
self.language_model_selector.clone(),
|
||||||
ButtonLike::new("active-model")
|
ButtonLike::new("active-model")
|
||||||
.style(ButtonStyle::Subtle)
|
.style(ButtonStyle::Subtle)
|
||||||
@@ -2143,10 +2070,8 @@ impl ContextEditor {
|
|||||||
)
|
)
|
||||||
},
|
},
|
||||||
gpui::Corner::BottomLeft,
|
gpui::Corner::BottomLeft,
|
||||||
cx,
|
|
||||||
)
|
)
|
||||||
.with_handle(self.language_model_selector_menu_handle.clone())
|
.with_handle(self.language_model_selector_menu_handle.clone())
|
||||||
.render(window, cx)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn render_last_error(&self, cx: &mut Context<Self>) -> Option<AnyElement> {
|
fn render_last_error(&self, cx: &mut Context<Self>) -> Option<AnyElement> {
|
||||||
@@ -2164,6 +2089,9 @@ impl ContextEditor {
|
|||||||
.occlude()
|
.occlude()
|
||||||
.child(match last_error {
|
.child(match last_error {
|
||||||
AssistError::PaymentRequired => self.render_payment_required_error(cx),
|
AssistError::PaymentRequired => self.render_payment_required_error(cx),
|
||||||
|
AssistError::MaxMonthlySpendReached => {
|
||||||
|
self.render_max_monthly_spend_reached_error(cx)
|
||||||
|
}
|
||||||
AssistError::Message(error_message) => {
|
AssistError::Message(error_message) => {
|
||||||
self.render_assist_error(error_message, cx)
|
self.render_assist_error(error_message, cx)
|
||||||
}
|
}
|
||||||
@@ -2212,6 +2140,48 @@ impl ContextEditor {
|
|||||||
.into_any()
|
.into_any()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn render_max_monthly_spend_reached_error(&self, cx: &mut Context<Self>) -> AnyElement {
|
||||||
|
const ERROR_MESSAGE: &str = "You have reached your maximum monthly spend. Increase your spend limit to continue using Zed LLMs.";
|
||||||
|
|
||||||
|
v_flex()
|
||||||
|
.gap_0p5()
|
||||||
|
.child(
|
||||||
|
h_flex()
|
||||||
|
.gap_1p5()
|
||||||
|
.items_center()
|
||||||
|
.child(Icon::new(IconName::XCircle).color(Color::Error))
|
||||||
|
.child(Label::new("Max Monthly Spend Reached").weight(FontWeight::MEDIUM)),
|
||||||
|
)
|
||||||
|
.child(
|
||||||
|
div()
|
||||||
|
.id("error-message")
|
||||||
|
.max_h_24()
|
||||||
|
.overflow_y_scroll()
|
||||||
|
.child(Label::new(ERROR_MESSAGE)),
|
||||||
|
)
|
||||||
|
.child(
|
||||||
|
h_flex()
|
||||||
|
.justify_end()
|
||||||
|
.mt_1()
|
||||||
|
.child(
|
||||||
|
Button::new("subscribe", "Update Monthly Spend Limit").on_click(
|
||||||
|
cx.listener(|this, _, _window, cx| {
|
||||||
|
this.last_error = None;
|
||||||
|
cx.open_url(&zed_urls::account_url(cx));
|
||||||
|
cx.notify();
|
||||||
|
}),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
.child(Button::new("dismiss", "Dismiss").on_click(cx.listener(
|
||||||
|
|this, _, _window, cx| {
|
||||||
|
this.last_error = None;
|
||||||
|
cx.notify();
|
||||||
|
},
|
||||||
|
))),
|
||||||
|
)
|
||||||
|
.into_any()
|
||||||
|
}
|
||||||
|
|
||||||
fn render_assist_error(
|
fn render_assist_error(
|
||||||
&self,
|
&self,
|
||||||
error_message: &SharedString,
|
error_message: &SharedString,
|
||||||
@@ -2552,7 +2522,6 @@ impl Render for ContextEditor {
|
|||||||
let provider = LanguageModelRegistry::read_global(cx)
|
let provider = LanguageModelRegistry::read_global(cx)
|
||||||
.default_model()
|
.default_model()
|
||||||
.map(|default| default.provider);
|
.map(|default| default.provider);
|
||||||
|
|
||||||
let accept_terms = if self.show_accept_terms {
|
let accept_terms = if self.show_accept_terms {
|
||||||
provider.as_ref().and_then(|provider| {
|
provider.as_ref().and_then(|provider| {
|
||||||
provider.render_accept_terms(LanguageModelProviderTosView::PromptEditorPopup, cx)
|
provider.render_accept_terms(LanguageModelProviderTosView::PromptEditorPopup, cx)
|
||||||
@@ -2562,8 +2531,6 @@ impl Render for ContextEditor {
|
|||||||
};
|
};
|
||||||
|
|
||||||
let language_model_selector = self.language_model_selector_menu_handle.clone();
|
let language_model_selector = self.language_model_selector_menu_handle.clone();
|
||||||
let max_mode_toggle = self.render_max_mode_toggle(cx);
|
|
||||||
|
|
||||||
v_flex()
|
v_flex()
|
||||||
.key_context("ContextEditor")
|
.key_context("ContextEditor")
|
||||||
.capture_action(cx.listener(ContextEditor::cancel))
|
.capture_action(cx.listener(ContextEditor::cancel))
|
||||||
@@ -2603,28 +2570,31 @@ impl Render for ContextEditor {
|
|||||||
})
|
})
|
||||||
.children(self.render_last_error(cx))
|
.children(self.render_last_error(cx))
|
||||||
.child(
|
.child(
|
||||||
h_flex()
|
h_flex().w_full().relative().child(
|
||||||
.relative()
|
h_flex()
|
||||||
.py_2()
|
.p_2()
|
||||||
.pl_1p5()
|
.w_full()
|
||||||
.pr_2()
|
.border_t_1()
|
||||||
.w_full()
|
.border_color(cx.theme().colors().border_variant)
|
||||||
.justify_between()
|
.bg(cx.theme().colors().editor_background)
|
||||||
.border_t_1()
|
.child(
|
||||||
.border_color(cx.theme().colors().border_variant)
|
h_flex()
|
||||||
.bg(cx.theme().colors().editor_background)
|
.gap_1()
|
||||||
.child(
|
.child(self.render_inject_context_menu(cx))
|
||||||
h_flex()
|
.child(ui::Divider::vertical())
|
||||||
.gap_0p5()
|
.child(
|
||||||
.child(self.render_inject_context_menu(cx))
|
div()
|
||||||
.when_some(max_mode_toggle, |this, element| this.child(element)),
|
.pl_0p5()
|
||||||
)
|
.child(self.render_language_model_selector(cx)),
|
||||||
.child(
|
),
|
||||||
h_flex()
|
)
|
||||||
.gap_1()
|
.child(
|
||||||
.child(self.render_language_model_selector(window, cx))
|
h_flex()
|
||||||
.child(self.render_send_button(window, cx)),
|
.w_full()
|
||||||
),
|
.justify_end()
|
||||||
|
.child(self.render_send_button(window, cx)),
|
||||||
|
),
|
||||||
|
),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -3094,7 +3064,7 @@ fn invoked_slash_command_fold_placeholder(
|
|||||||
.gap_2()
|
.gap_2()
|
||||||
.bg(cx.theme().colors().surface_background)
|
.bg(cx.theme().colors().surface_background)
|
||||||
.rounded_sm()
|
.rounded_sm()
|
||||||
.child(Label::new(format!("/{}", command.name)))
|
.child(Label::new(format!("/{}", command.name.clone())))
|
||||||
.map(|parent| match &command.status {
|
.map(|parent| match &command.status {
|
||||||
InvokedSlashCommandStatus::Running(_) => {
|
InvokedSlashCommandStatus::Running(_) => {
|
||||||
parent.child(Icon::new(IconName::ArrowCircle).with_animation(
|
parent.child(Icon::new(IconName::ArrowCircle).with_animation(
|
||||||
@@ -3263,95 +3233,9 @@ pub fn make_lsp_adapter_delegate(
|
|||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
use fs::FakeFs;
|
use gpui::App;
|
||||||
use gpui::{App, TestAppContext, VisualTestContext};
|
use language::Buffer;
|
||||||
use indoc::indoc;
|
|
||||||
use language::{Buffer, LanguageRegistry};
|
|
||||||
use pretty_assertions::assert_eq;
|
|
||||||
use prompt_store::PromptBuilder;
|
|
||||||
use text::OffsetRangeExt;
|
|
||||||
use unindent::Unindent;
|
use unindent::Unindent;
|
||||||
use util::path;
|
|
||||||
|
|
||||||
#[gpui::test]
|
|
||||||
async fn test_copy_paste_whole_message(cx: &mut TestAppContext) {
|
|
||||||
let (context, context_editor, mut cx) = setup_context_editor_text(vec![
|
|
||||||
(Role::User, "What is the Zed editor?"),
|
|
||||||
(
|
|
||||||
Role::Assistant,
|
|
||||||
"Zed is a modern, high-performance code editor designed from the ground up for speed and collaboration.",
|
|
||||||
),
|
|
||||||
(Role::User, ""),
|
|
||||||
],cx).await;
|
|
||||||
|
|
||||||
// Select & Copy whole user message
|
|
||||||
assert_copy_paste_context_editor(
|
|
||||||
&context_editor,
|
|
||||||
message_range(&context, 0, &mut cx),
|
|
||||||
indoc! {"
|
|
||||||
What is the Zed editor?
|
|
||||||
Zed is a modern, high-performance code editor designed from the ground up for speed and collaboration.
|
|
||||||
What is the Zed editor?
|
|
||||||
"},
|
|
||||||
&mut cx,
|
|
||||||
);
|
|
||||||
|
|
||||||
// Select & Copy whole assistant message
|
|
||||||
assert_copy_paste_context_editor(
|
|
||||||
&context_editor,
|
|
||||||
message_range(&context, 1, &mut cx),
|
|
||||||
indoc! {"
|
|
||||||
What is the Zed editor?
|
|
||||||
Zed is a modern, high-performance code editor designed from the ground up for speed and collaboration.
|
|
||||||
What is the Zed editor?
|
|
||||||
Zed is a modern, high-performance code editor designed from the ground up for speed and collaboration.
|
|
||||||
"},
|
|
||||||
&mut cx,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
#[gpui::test]
|
|
||||||
async fn test_copy_paste_no_selection(cx: &mut TestAppContext) {
|
|
||||||
let (context, context_editor, mut cx) = setup_context_editor_text(
|
|
||||||
vec![
|
|
||||||
(Role::User, "user1"),
|
|
||||||
(Role::Assistant, "assistant1"),
|
|
||||||
(Role::Assistant, "assistant2"),
|
|
||||||
(Role::User, ""),
|
|
||||||
],
|
|
||||||
cx,
|
|
||||||
)
|
|
||||||
.await;
|
|
||||||
|
|
||||||
// Copy and paste first assistant message
|
|
||||||
let message_2_range = message_range(&context, 1, &mut cx);
|
|
||||||
assert_copy_paste_context_editor(
|
|
||||||
&context_editor,
|
|
||||||
message_2_range.start..message_2_range.start,
|
|
||||||
indoc! {"
|
|
||||||
user1
|
|
||||||
assistant1
|
|
||||||
assistant2
|
|
||||||
assistant1
|
|
||||||
"},
|
|
||||||
&mut cx,
|
|
||||||
);
|
|
||||||
|
|
||||||
// Copy and cut second assistant message
|
|
||||||
let message_3_range = message_range(&context, 2, &mut cx);
|
|
||||||
assert_copy_paste_context_editor(
|
|
||||||
&context_editor,
|
|
||||||
message_3_range.start..message_3_range.start,
|
|
||||||
indoc! {"
|
|
||||||
user1
|
|
||||||
assistant1
|
|
||||||
assistant2
|
|
||||||
assistant1
|
|
||||||
assistant2
|
|
||||||
"},
|
|
||||||
&mut cx,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
#[gpui::test]
|
#[gpui::test]
|
||||||
fn test_find_code_blocks(cx: &mut App) {
|
fn test_find_code_blocks(cx: &mut App) {
|
||||||
@@ -3426,140 +3310,4 @@ mod tests {
|
|||||||
assert_eq!(range, expected, "unexpected result on row {:?}", row);
|
assert_eq!(range, expected, "unexpected result on row {:?}", row);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn setup_context_editor_text(
|
|
||||||
messages: Vec<(Role, &str)>,
|
|
||||||
cx: &mut TestAppContext,
|
|
||||||
) -> (
|
|
||||||
Entity<AssistantContext>,
|
|
||||||
Entity<ContextEditor>,
|
|
||||||
VisualTestContext,
|
|
||||||
) {
|
|
||||||
cx.update(init_test);
|
|
||||||
|
|
||||||
let fs = FakeFs::new(cx.executor());
|
|
||||||
let context = create_context_with_messages(messages, cx);
|
|
||||||
|
|
||||||
let project = Project::test(fs.clone(), [path!("/test").as_ref()], cx).await;
|
|
||||||
let window = cx.add_window(|window, cx| Workspace::test_new(project.clone(), window, cx));
|
|
||||||
let workspace = window.root(cx).unwrap();
|
|
||||||
let mut cx = VisualTestContext::from_window(*window, cx);
|
|
||||||
|
|
||||||
let context_editor = window
|
|
||||||
.update(&mut cx, |_, window, cx| {
|
|
||||||
cx.new(|cx| {
|
|
||||||
let editor = ContextEditor::for_context(
|
|
||||||
context.clone(),
|
|
||||||
fs,
|
|
||||||
workspace.downgrade(),
|
|
||||||
project,
|
|
||||||
None,
|
|
||||||
window,
|
|
||||||
cx,
|
|
||||||
);
|
|
||||||
editor
|
|
||||||
})
|
|
||||||
})
|
|
||||||
.unwrap();
|
|
||||||
|
|
||||||
(context, context_editor, cx)
|
|
||||||
}
|
|
||||||
|
|
||||||
fn message_range(
|
|
||||||
context: &Entity<AssistantContext>,
|
|
||||||
message_ix: usize,
|
|
||||||
cx: &mut TestAppContext,
|
|
||||||
) -> Range<usize> {
|
|
||||||
context.update(cx, |context, cx| {
|
|
||||||
context
|
|
||||||
.messages(cx)
|
|
||||||
.nth(message_ix)
|
|
||||||
.unwrap()
|
|
||||||
.anchor_range
|
|
||||||
.to_offset(&context.buffer().read(cx).snapshot())
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
fn assert_copy_paste_context_editor<T: editor::ToOffset>(
|
|
||||||
context_editor: &Entity<ContextEditor>,
|
|
||||||
range: Range<T>,
|
|
||||||
expected_text: &str,
|
|
||||||
cx: &mut VisualTestContext,
|
|
||||||
) {
|
|
||||||
context_editor.update_in(cx, |context_editor, window, cx| {
|
|
||||||
context_editor.editor.update(cx, |editor, cx| {
|
|
||||||
editor.change_selections(None, window, cx, |s| s.select_ranges([range]));
|
|
||||||
});
|
|
||||||
|
|
||||||
context_editor.copy(&Default::default(), window, cx);
|
|
||||||
|
|
||||||
context_editor.editor.update(cx, |editor, cx| {
|
|
||||||
editor.move_to_end(&Default::default(), window, cx);
|
|
||||||
});
|
|
||||||
|
|
||||||
context_editor.paste(&Default::default(), window, cx);
|
|
||||||
|
|
||||||
context_editor.editor.update(cx, |editor, cx| {
|
|
||||||
assert_eq!(editor.text(cx), expected_text);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
fn create_context_with_messages(
|
|
||||||
mut messages: Vec<(Role, &str)>,
|
|
||||||
cx: &mut TestAppContext,
|
|
||||||
) -> Entity<AssistantContext> {
|
|
||||||
let registry = Arc::new(LanguageRegistry::test(cx.executor()));
|
|
||||||
let prompt_builder = Arc::new(PromptBuilder::new(None).unwrap());
|
|
||||||
cx.new(|cx| {
|
|
||||||
let mut context = AssistantContext::local(
|
|
||||||
registry,
|
|
||||||
None,
|
|
||||||
None,
|
|
||||||
prompt_builder.clone(),
|
|
||||||
Arc::new(SlashCommandWorkingSet::default()),
|
|
||||||
cx,
|
|
||||||
);
|
|
||||||
let mut message_1 = context.messages(cx).next().unwrap();
|
|
||||||
let (role, text) = messages.remove(0);
|
|
||||||
|
|
||||||
loop {
|
|
||||||
if role == message_1.role {
|
|
||||||
context.buffer().update(cx, |buffer, cx| {
|
|
||||||
buffer.edit([(message_1.offset_range, text)], None, cx);
|
|
||||||
});
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
let mut ids = HashSet::default();
|
|
||||||
ids.insert(message_1.id);
|
|
||||||
context.cycle_message_roles(ids, cx);
|
|
||||||
message_1 = context.messages(cx).next().unwrap();
|
|
||||||
}
|
|
||||||
|
|
||||||
let mut last_message_id = message_1.id;
|
|
||||||
for (role, text) in messages {
|
|
||||||
context.insert_message_after(last_message_id, role, MessageStatus::Done, cx);
|
|
||||||
let message = context.messages(cx).last().unwrap();
|
|
||||||
last_message_id = message.id;
|
|
||||||
context.buffer().update(cx, |buffer, cx| {
|
|
||||||
buffer.edit([(message.offset_range, text)], None, cx);
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
context
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
fn init_test(cx: &mut App) {
|
|
||||||
let settings_store = SettingsStore::test(cx);
|
|
||||||
prompt_store::init(cx);
|
|
||||||
LanguageModelRegistry::test(cx);
|
|
||||||
cx.set_global(settings_store);
|
|
||||||
language::init(cx);
|
|
||||||
agent_settings::init(cx);
|
|
||||||
Project::init_settings(cx);
|
|
||||||
theme::init(theme::LoadThemes::JustBase, cx);
|
|
||||||
workspace::init_settings(cx);
|
|
||||||
editor::init_settings(cx);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||