Compare commits
557 Commits
linux/keys
...
arm_github
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f855eb7470 | ||
|
|
9ffb3c5176 | ||
|
|
72d787b3ae | ||
|
|
104f601413 | ||
|
|
46773ebbd8 | ||
|
|
65a93a0036 | ||
|
|
dc63138089 | ||
|
|
fa02bd71c3 | ||
|
|
6d95fd9167 | ||
|
|
899153d9a4 | ||
|
|
77ead25f8c | ||
|
|
9e5f89dc26 | ||
|
|
cf5e76b1b9 | ||
|
|
9775747ba9 | ||
|
|
b7c2d4876c | ||
|
|
2fe1293fba | ||
|
|
e0057ccd0f | ||
|
|
51585e770d | ||
|
|
52fa7ababb | ||
|
|
5ad51ca48e | ||
|
|
35a119d573 | ||
|
|
bbf3b20fc3 | ||
|
|
c1b997002a | ||
|
|
69e99b9f2f | ||
|
|
0fc85a020a | ||
|
|
974f724151 | ||
|
|
ca3f46588a | ||
|
|
d9efa2860f | ||
|
|
ac806d982b | ||
|
|
73cd6ef92c | ||
|
|
019a14bcde | ||
|
|
95d78ff8d5 | ||
|
|
454adfacae | ||
|
|
edd40566b7 | ||
|
|
a40ee74a1f | ||
|
|
2e883be4b5 | ||
|
|
6ea4d2b30d | ||
|
|
380d8c5662 | ||
|
|
508b604b67 | ||
|
|
3da1de2a48 | ||
|
|
8837e5564d | ||
|
|
709523bf36 | ||
|
|
7afee64119 | ||
|
|
cd0ef4b982 | ||
|
|
be6f29cc28 | ||
|
|
38b8e6549f | ||
|
|
b8c1b54f9e | ||
|
|
c304e964fe | ||
|
|
53abad5979 | ||
|
|
54e64b2407 | ||
|
|
ce8854007f | ||
|
|
3e8565ac25 | ||
|
|
d801b7b12e | ||
|
|
37fa42d5cc | ||
|
|
5c9b8e8321 | ||
|
|
96609151c6 | ||
|
|
e37c78bde7 | ||
|
|
920ca688a7 | ||
|
|
f62d76159b | ||
|
|
6a8fdbfd62 | ||
|
|
711a9e5753 | ||
|
|
6de5d29bff | ||
|
|
d7015e5b8f | ||
|
|
ddf70b3bb8 | ||
|
|
8bd8435887 | ||
|
|
4b297a9967 | ||
|
|
7aa70a4858 | ||
|
|
04cd3fcd23 | ||
|
|
d15d85830a | ||
|
|
ccc173ebb1 | ||
|
|
03a030fd00 | ||
|
|
894f3b9d15 | ||
|
|
f36143a461 | ||
|
|
8730d317a8 | ||
|
|
783b33b5c9 | ||
|
|
28da99cc06 | ||
|
|
d2c265c71f | ||
|
|
bbd431ae8c | ||
|
|
5b9d3ea097 | ||
|
|
738cfdff84 | ||
|
|
32d5a2cca0 | ||
|
|
dda614091a | ||
|
|
fa9da6ad5b | ||
|
|
d082cfdbec | ||
|
|
c71791d64e | ||
|
|
244d8517f1 | ||
|
|
3884de937b | ||
|
|
8af984ae70 | ||
|
|
9d533f9d30 | ||
|
|
274a40b7e0 | ||
|
|
9c7b1d19ce | ||
|
|
3d9881121f | ||
|
|
a2e98e9f0e | ||
|
|
7c64737e00 | ||
|
|
8191a5339d | ||
|
|
17c3b741ec | ||
|
|
52770cd3ad | ||
|
|
4ac67ac5ae | ||
|
|
8c1b549683 | ||
|
|
ff6ac60bad | ||
|
|
f8ab51307a | ||
|
|
0a2186c87b | ||
|
|
c3653f4cb1 | ||
|
|
8b28941c14 | ||
|
|
aefb798090 | ||
|
|
2c5aa5891d | ||
|
|
7d54d9f45e | ||
|
|
cde47e60cd | ||
|
|
79f96a5afe | ||
|
|
81058ee172 | ||
|
|
89743117c6 | ||
|
|
6de37fa57c | ||
|
|
beb0d49dc4 | ||
|
|
c9aadadc4b | ||
|
|
bcd182f480 | ||
|
|
3987b60738 | ||
|
|
827103908e | ||
|
|
8e9e3ba1a5 | ||
|
|
676ed8fb8a | ||
|
|
4304521655 | ||
|
|
04716a0e4a | ||
|
|
5e38915d45 | ||
|
|
f9257b0efe | ||
|
|
5d0c96872b | ||
|
|
071e684be4 | ||
|
|
2280594408 | ||
|
|
09a1d51e9a | ||
|
|
ac15194d11 | ||
|
|
988d834c33 | ||
|
|
48eacf3f2a | ||
|
|
030d4d2631 | ||
|
|
10df7b5eb9 | ||
|
|
55120c4231 | ||
|
|
8227c45a11 | ||
|
|
d23359e19a | ||
|
|
936ad0bf10 | ||
|
|
faa0bb51c9 | ||
|
|
2db2271e3c | ||
|
|
79b1dd7db8 | ||
|
|
81f8e2ed4a | ||
|
|
b9256dd469 | ||
|
|
27d3da678c | ||
|
|
03357f3f7b | ||
|
|
4aabba6cf6 | ||
|
|
8c46a4f594 | ||
|
|
522abe8e59 | ||
|
|
5ae8c4cf09 | ||
|
|
d8195a8fd7 | ||
|
|
2645591cd5 | ||
|
|
526a7c0702 | ||
|
|
e793740168 | ||
|
|
dea0a58727 | ||
|
|
b7abc9d493 | ||
|
|
01a77bb231 | ||
|
|
de225fd242 | ||
|
|
1bc052d76b | ||
|
|
29cb95a3ca | ||
|
|
1307b81721 | ||
|
|
203754d0db | ||
|
|
c9c603b1d1 | ||
|
|
e13b494c9e | ||
|
|
c0397727e0 | ||
|
|
9c2b90fb8f | ||
|
|
d108e5f53c | ||
|
|
2551bde1d3 | ||
|
|
e7de80c6ae | ||
|
|
ae210eced8 | ||
|
|
a9d99d8347 | ||
|
|
3e6435eddc | ||
|
|
9e75871d48 | ||
|
|
707a4c7f20 | ||
|
|
854076f96d | ||
|
|
cf931247d0 | ||
|
|
b74477d12e | ||
|
|
3077abf9cf | ||
|
|
07dab4e94a | ||
|
|
59686f1f44 | ||
|
|
a60bea8a3d | ||
|
|
b820aa1fcd | ||
|
|
55d91bce53 | ||
|
|
b798392050 | ||
|
|
657c8b1084 | ||
|
|
2bb8aa2f73 | ||
|
|
beeb42da29 | ||
|
|
6d66ff1d95 | ||
|
|
e0b818af62 | ||
|
|
58a400b1ee | ||
|
|
8ab7d44d51 | ||
|
|
56d4c0af9f | ||
|
|
feeda7fa37 | ||
|
|
4a5c55a8f2 | ||
|
|
7c1ae9bcc3 | ||
|
|
6f97da3435 | ||
|
|
63c1033448 | ||
|
|
b16911e756 | ||
|
|
b14401f817 | ||
|
|
17cf865d1e | ||
|
|
b7ec437b13 | ||
|
|
f1aab1120d | ||
|
|
3f90bc81bd | ||
|
|
9d5fb3c3f3 | ||
|
|
864767ad35 | ||
|
|
ec69b68e72 | ||
|
|
9dd18e5ee1 | ||
|
|
2ebe16a52f | ||
|
|
1ed4647203 | ||
|
|
ebed567adb | ||
|
|
a6544c70c5 | ||
|
|
b363e1a482 | ||
|
|
65e3e84cbc | ||
|
|
1e1d4430c2 | ||
|
|
c874f1fa9d | ||
|
|
9a9e96ed5a | ||
|
|
8c46e290df | ||
|
|
aacbb9c2f4 | ||
|
|
f90333f92e | ||
|
|
b24f614ca3 | ||
|
|
cefa0cbed8 | ||
|
|
3fb1023667 | ||
|
|
9c715b470e | ||
|
|
ae219e9e99 | ||
|
|
6d99c12796 | ||
|
|
8fb7fa941a | ||
|
|
22d75b798e | ||
|
|
06a199da4d | ||
|
|
ab6125ddde | ||
|
|
d3bc561f26 | ||
|
|
f13f2dfb70 | ||
|
|
24e4446cd3 | ||
|
|
cc536655a1 | ||
|
|
2a9e73c65d | ||
|
|
4f1728e5ee | ||
|
|
40c91d5df0 | ||
|
|
fe1b36671d | ||
|
|
bb9e2b0403 | ||
|
|
4f8d7f0a6b | ||
|
|
caf3d30bf6 | ||
|
|
df0cf22347 | ||
|
|
a305eda8d1 | ||
|
|
ba7b1db054 | ||
|
|
019c8ded77 | ||
|
|
1704dbea7e | ||
|
|
eefa6c4882 | ||
|
|
1f17df7fb0 | ||
|
|
6d687a2c2c | ||
|
|
32214abb64 | ||
|
|
a78563b80b | ||
|
|
f881cacd8a | ||
|
|
a539a38f13 | ||
|
|
ca6fd101c1 | ||
|
|
f8097c7c98 | ||
|
|
c1427ea802 | ||
|
|
1e83022f03 | ||
|
|
0ee900e8fb | ||
|
|
f9f4be1fc4 | ||
|
|
a00b07371a | ||
|
|
f725b5e248 | ||
|
|
07436b4284 | ||
|
|
8bec4cbecb | ||
|
|
047e7eacec | ||
|
|
1d5d3de85c | ||
|
|
c4dbaa91f0 | ||
|
|
97c01c6720 | ||
|
|
310ea43048 | ||
|
|
6bb4b5fa64 | ||
|
|
e0fa3032ec | ||
|
|
9cf6be2057 | ||
|
|
5462e199fb | ||
|
|
3a60420b41 | ||
|
|
89c184a26f | ||
|
|
d7f0241d7b | ||
|
|
1445af559b | ||
|
|
804de3316e | ||
|
|
a387bf5f54 | ||
|
|
c7047d5f0a | ||
|
|
406d975f39 | ||
|
|
cbed580db0 | ||
|
|
8aef64bbfa | ||
|
|
9086784038 | ||
|
|
2abc5893c1 | ||
|
|
a23ee61a4b | ||
|
|
38e45e828b | ||
|
|
181bf78b7d | ||
|
|
c42d060509 | ||
|
|
6ea9abdc1b | ||
|
|
070eac28e3 | ||
|
|
05692e298a | ||
|
|
ccb049bd97 | ||
|
|
fe57eedb44 | ||
|
|
c57e6bc784 | ||
|
|
83135e98e6 | ||
|
|
703ee29658 | ||
|
|
f792827a01 | ||
|
|
45f9edcbb9 | ||
|
|
e3354543c0 | ||
|
|
cb187b0b4d | ||
|
|
d989b2260b | ||
|
|
ae076fa415 | ||
|
|
b4af61edfe | ||
|
|
ea8a3be91b | ||
|
|
5173a1a968 | ||
|
|
87f097a0ab | ||
|
|
f9407db7d6 | ||
|
|
384b11392a | ||
|
|
f20596c33b | ||
|
|
eb863f8fd6 | ||
|
|
97579662e6 | ||
|
|
53849cf983 | ||
|
|
1e25249055 | ||
|
|
469824c350 | ||
|
|
a1c645e57e | ||
|
|
0791596cda | ||
|
|
9cc1851be7 | ||
|
|
50bd8770bd | ||
|
|
00bdebc89d | ||
|
|
d5134062ac | ||
|
|
0e9f6986cf | ||
|
|
1035c6aab5 | ||
|
|
75e69a5ae9 | ||
|
|
05afe95539 | ||
|
|
a5a116439e | ||
|
|
361ceee72b | ||
|
|
68724ea99e | ||
|
|
e12106e025 | ||
|
|
77aa667bf3 | ||
|
|
8b47b40dc0 | ||
|
|
01990c8375 | ||
|
|
4e7dc37f01 | ||
|
|
00fd045844 | ||
|
|
7443fde4e9 | ||
|
|
d5ab42aeb8 | ||
|
|
07403f0b08 | ||
|
|
00bc154c46 | ||
|
|
f627ac92ee | ||
|
|
218e8d09c5 | ||
|
|
2c4b75ab30 | ||
|
|
aab76208b5 | ||
|
|
f3f0766242 | ||
|
|
148e9adec2 | ||
|
|
e314963f5b | ||
|
|
957e4adc3f | ||
|
|
fee6f13887 | ||
|
|
4f78165ee8 | ||
|
|
94a5fe265d | ||
|
|
c0a5ace8b8 | ||
|
|
15d59fcda9 | ||
|
|
6545c5ebe0 | ||
|
|
506beafe10 | ||
|
|
31d908fc74 | ||
|
|
0731097ee5 | ||
|
|
233b73b385 | ||
|
|
0145e2c101 | ||
|
|
09fc64e0c5 | ||
|
|
fc803ce9d4 | ||
|
|
697c2ba71f | ||
|
|
f54c057001 | ||
|
|
32848e9c8a | ||
|
|
86b75759d1 | ||
|
|
94c006236e | ||
|
|
5b6b911946 | ||
|
|
b9a5d437db | ||
|
|
21bd91a773 | ||
|
|
5db14d315b | ||
|
|
b63cea1f17 | ||
|
|
b7c5540075 | ||
|
|
b01f7c848b | ||
|
|
3476705bbb | ||
|
|
ba6b5a59f9 | ||
|
|
28d6362964 | ||
|
|
b4a03989b1 | ||
|
|
19b6892c8d | ||
|
|
b5c2b25a76 | ||
|
|
8faeb34367 | ||
|
|
61a40e293d | ||
|
|
239ffa49e1 | ||
|
|
a4978ee5ff | ||
|
|
a8ca7e9c04 | ||
|
|
ee6ce78fed | ||
|
|
3ff62ef289 | ||
|
|
f8f36d0c17 | ||
|
|
05763b2fe3 | ||
|
|
7ec61ceec9 | ||
|
|
119beb210a | ||
|
|
0d3fad7764 | ||
|
|
450a10facf | ||
|
|
c208532693 | ||
|
|
4a577fff4a | ||
|
|
03071a9152 | ||
|
|
092be31b2b | ||
|
|
62545b985f | ||
|
|
5e72c2a870 | ||
|
|
2a8242ac90 | ||
|
|
d211f88d23 | ||
|
|
fe0bcd14d2 | ||
|
|
e84463648a | ||
|
|
24809c4219 | ||
|
|
f8365c5375 | ||
|
|
2c8049270a | ||
|
|
6840a4e5bc | ||
|
|
5b320d6714 | ||
|
|
534bb0620d | ||
|
|
5bafb2b160 | ||
|
|
ee415de45f | ||
|
|
4acb4730a5 | ||
|
|
4567360fd9 | ||
|
|
4c396bcc91 | ||
|
|
8a24f9f280 | ||
|
|
f4b361f04d | ||
|
|
649072d140 | ||
|
|
6253b95f82 | ||
|
|
bffde7c6b4 | ||
|
|
7e87916642 | ||
|
|
29f0762b6c | ||
|
|
10af3c7e58 | ||
|
|
c0aa8f63fd | ||
|
|
0c27aaecb3 | ||
|
|
8e5d50b85b | ||
|
|
625bf09830 | ||
|
|
5a0a8ce30a | ||
|
|
d9a5dc2dfe | ||
|
|
d4926626d8 | ||
|
|
2a973109d4 | ||
|
|
2e62f16149 | ||
|
|
f2601ce52c | ||
|
|
a58c48f629 | ||
|
|
ddbcab2b5b | ||
|
|
7497deff7a | ||
|
|
e78b726ed8 | ||
|
|
998542b048 | ||
|
|
6363fdab88 | ||
|
|
e6f51966a1 | ||
|
|
9da9ef860b | ||
|
|
134463f043 | ||
|
|
a47fd1d723 | ||
|
|
ef0e1cb2ba | ||
|
|
c73af0a52f | ||
|
|
e42cf21703 | ||
|
|
2c114f7df6 | ||
|
|
49f3ec7f35 | ||
|
|
748840519c | ||
|
|
8b59776320 | ||
|
|
206be2b348 | ||
|
|
51b25b5c22 | ||
|
|
2f274b2a89 | ||
|
|
88fb623efa | ||
|
|
df98d94a24 | ||
|
|
c7da6283cc | ||
|
|
7ceb792a58 | ||
|
|
83af7b30eb | ||
|
|
3d0147aafc | ||
|
|
1b3f20bdf4 | ||
|
|
4c28d2c2e2 | ||
|
|
a204510cfc | ||
|
|
34be7830a3 | ||
|
|
d312a13f8a | ||
|
|
20a0956fb2 | ||
|
|
6f918ed99b | ||
|
|
7fb9569c15 | ||
|
|
fc8702a8f8 | ||
|
|
ab59982bf7 | ||
|
|
685933b5c8 | ||
|
|
172e0df2d8 | ||
|
|
7341ab3980 | ||
|
|
ca72efe701 | ||
|
|
cb112a4012 | ||
|
|
f3c2e71ca7 | ||
|
|
208f525a11 | ||
|
|
697c838455 | ||
|
|
1683e2f144 | ||
|
|
2f1d9284b7 | ||
|
|
68a46c3627 | ||
|
|
3a1053bf0c | ||
|
|
14d9a4189f | ||
|
|
9c01119b3c | ||
|
|
9dba8e5b0d | ||
|
|
03ac3fb91a | ||
|
|
0201d1e0b4 | ||
|
|
f48b6b583e | ||
|
|
d8fc23a5e9 | ||
|
|
6206150e27 | ||
|
|
e88cad29e5 | ||
|
|
9b7d849879 | ||
|
|
c4677c21a9 | ||
|
|
26318b5b6a | ||
|
|
4266f0da85 | ||
|
|
c50093d68c | ||
|
|
1cad1cbbfc | ||
|
|
fbc922ad46 | ||
|
|
f435304209 | ||
|
|
508ccde363 | ||
|
|
9f7987c532 | ||
|
|
cb52acbf3d | ||
|
|
f8b997b25c | ||
|
|
73a5856fb8 | ||
|
|
e3b6fa2c30 | ||
|
|
ceb5164114 | ||
|
|
24a108d876 | ||
|
|
5c0b161563 | ||
|
|
ad4645c59b | ||
|
|
37047a6fde | ||
|
|
fc78408ee4 | ||
|
|
37f49ce304 | ||
|
|
cc428330a9 | ||
|
|
1475ace6f1 | ||
|
|
dd4e8b9e66 | ||
|
|
b188e5d3aa | ||
|
|
e3d3daec92 | ||
|
|
ced8e4d88e | ||
|
|
fa1abd8201 | ||
|
|
ee4e43f1b6 | ||
|
|
d61e1e24a7 | ||
|
|
3c03d53e3e | ||
|
|
8ab664a52c | ||
|
|
2044426634 | ||
|
|
02fa6f6fc2 | ||
|
|
80a00cd241 | ||
|
|
06f725d51b | ||
|
|
baf6d82cd4 | ||
|
|
28ec7fbb81 | ||
|
|
0415e853d5 | ||
|
|
1c9b818342 | ||
|
|
0d7f4842f3 | ||
|
|
ab017129d8 | ||
|
|
71fb17c507 | ||
|
|
97e437c632 | ||
|
|
66667d1eef | ||
|
|
dce22a965e | ||
|
|
5f452dbca2 | ||
|
|
b2a92097ee | ||
|
|
eb35d25a7d | ||
|
|
8742d4ab90 | ||
|
|
b829f72c17 | ||
|
|
ffa8310d04 | ||
|
|
3fda539c46 | ||
|
|
b444b326cb | ||
|
|
f196288e2d | ||
|
|
e30cc131b4 | ||
|
|
09c8a84935 | ||
|
|
6e5996a815 | ||
|
|
c8f56e38b1 | ||
|
|
cfd3b0ff7b | ||
|
|
afe23cf85a | ||
|
|
f915c24279 | ||
|
|
bdd9e015ab | ||
|
|
6bbab4b55a | ||
|
|
7450b788f3 | ||
|
|
0c03519393 | ||
|
|
636eff2e9a | ||
|
|
6c8f4002d9 | ||
|
|
91bc5aefa4 | ||
|
|
2f3564b85f | ||
|
|
d61a544400 | ||
|
|
8061bacee3 | ||
|
|
77dadfedfe | ||
|
|
0023b37bfc | ||
|
|
4ece4a635f | ||
|
|
77c2aecf93 |
@@ -1,8 +1,8 @@
|
|||||||
name: Bug Report (Agent Panel)
|
name: Bug Report (AI Related)
|
||||||
description: Zed Agent Panel Bugs
|
description: Zed Agent Panel Bugs
|
||||||
type: "Bug"
|
type: "Bug"
|
||||||
labels: ["agent", "ai"]
|
labels: ["ai"]
|
||||||
title: "Agent Panel: <a short description of the Agent Panel bug>"
|
title: "AI: <a short description of the AI Related bug>"
|
||||||
body:
|
body:
|
||||||
- type: textarea
|
- type: textarea
|
||||||
attributes:
|
attributes:
|
||||||
@@ -14,7 +14,6 @@ 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.
|
||||||
@@ -22,6 +21,13 @@ body:
|
|||||||
|
|
||||||
Actual Behavior:
|
Actual Behavior:
|
||||||
Expected 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:
|
validations:
|
||||||
required: true
|
required: true
|
||||||
|
|
||||||
32
.github/actions/build_docs/action.yml
vendored
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
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: Check for broken links
|
||||||
|
uses: lycheeverse/lychee-action@82202e5e9c2f4ef1a55a3d02563e1cb6041e5332 # v2.4.1
|
||||||
|
with:
|
||||||
|
args: --no-progress './docs/src/**/*'
|
||||||
|
fail: true
|
||||||
|
|
||||||
|
- name: Build book
|
||||||
|
shell: bash -euxo pipefail {0}
|
||||||
|
run: |
|
||||||
|
mkdir -p target/deploy
|
||||||
|
mdbook build ./docs --dest-dir=../target/deploy/docs/
|
||||||
134
.github/workflows/ci.yml
vendored
@@ -73,7 +73,7 @@ jobs:
|
|||||||
timeout-minutes: 60
|
timeout-minutes: 60
|
||||||
runs-on:
|
runs-on:
|
||||||
- self-hosted
|
- self-hosted
|
||||||
- test
|
- macOS
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout repo
|
- name: Checkout repo
|
||||||
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
|
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
|
||||||
@@ -191,6 +191,27 @@ 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
|
||||||
@@ -200,7 +221,7 @@ jobs:
|
|||||||
needs.job_spec.outputs.run_tests == 'true'
|
needs.job_spec.outputs.run_tests == 'true'
|
||||||
runs-on:
|
runs-on:
|
||||||
- self-hosted
|
- self-hosted
|
||||||
- test
|
- macOS
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout repo
|
- name: Checkout repo
|
||||||
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
|
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
|
||||||
@@ -482,7 +503,9 @@ jobs:
|
|||||||
- macos_tests
|
- macos_tests
|
||||||
- windows_clippy
|
- windows_clippy
|
||||||
- windows_tests
|
- windows_tests
|
||||||
if: always()
|
if: |
|
||||||
|
github.repository_owner == 'zed-industries' &&
|
||||||
|
always()
|
||||||
steps:
|
steps:
|
||||||
- name: Check all tests passed
|
- name: Check all tests passed
|
||||||
run: |
|
run: |
|
||||||
@@ -524,7 +547,6 @@ 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:
|
||||||
@@ -611,7 +633,6 @@ 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:
|
||||||
@@ -662,14 +683,13 @@ jobs:
|
|||||||
timeout-minutes: 60
|
timeout-minutes: 60
|
||||||
name: Linux arm64 release bundle
|
name: Linux arm64 release bundle
|
||||||
runs-on:
|
runs-on:
|
||||||
- buildjet-16vcpu-ubuntu-2204-arm
|
- hosted-linux-arm-1
|
||||||
if: |
|
if: |
|
||||||
startsWith(github.ref, 'refs/tags/v')
|
startsWith(github.ref, 'refs/tags/v')
|
||||||
|| contains(github.event.pull_request.labels.*.name, 'run-bundling')
|
|| contains(github.event.pull_request.labels.*.name, 'run-bundling')
|
||||||
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:
|
||||||
@@ -716,62 +736,84 @@ jobs:
|
|||||||
env:
|
env:
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
|
||||||
nix-build:
|
freebsd:
|
||||||
timeout-minutes: 60
|
timeout-minutes: 60
|
||||||
name: Nix Build
|
runs-on: github-8vcpu-ubuntu-2404
|
||||||
continue-on-error: true
|
if: |
|
||||||
if: github.repository_owner == 'zed-industries' && contains(github.event.pull_request.labels.*.name, 'run-nix')
|
startsWith(github.ref, 'refs/tags/v')
|
||||||
strategy:
|
|| contains(github.event.pull_request.labels.*.name, 'run-bundling')
|
||||||
fail-fast: false
|
needs: [linux_tests]
|
||||||
matrix:
|
name: Build Zed on FreeBSD
|
||||||
system:
|
# env:
|
||||||
- os: x86 Linux
|
# MYTOKEN : ${{ secrets.MYTOKEN }}
|
||||||
runner: buildjet-16vcpu-ubuntu-2204
|
# MYTOKEN2: "value2"
|
||||||
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:
|
steps:
|
||||||
- name: Checkout repo
|
- uses: actions/checkout@v4
|
||||||
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
|
- name: Build FreeBSD remote-server
|
||||||
|
id: freebsd-build
|
||||||
|
uses: vmactions/freebsd-vm@c3ae29a132c8ef1924775414107a97cac042aad5 # v1.2.0
|
||||||
with:
|
with:
|
||||||
clean: false
|
# envs: "MYTOKEN MYTOKEN2"
|
||||||
- name: Set path
|
usesh: true
|
||||||
if: ${{ ! matrix.system.install_nix }}
|
release: 13.5
|
||||||
run: |
|
copyback: true
|
||||||
echo "/nix/var/nix/profiles/default/bin" >> $GITHUB_PATH
|
prepare: |
|
||||||
echo "/Users/administrator/.nix-profile/bin" >> $GITHUB_PATH
|
pkg install -y \
|
||||||
|
bash curl jq git \
|
||||||
|
rustup-init cmake-core llvm-devel-lite pkgconf protobuf # ibx11 alsa-lib rust-bindgen-cli
|
||||||
|
run: |
|
||||||
|
freebsd-version
|
||||||
|
sysctl hw.model
|
||||||
|
sysctl hw.ncpu
|
||||||
|
sysctl hw.physmem
|
||||||
|
sysctl hw.usermem
|
||||||
|
git config --global --add safe.directory /home/runner/work/zed/zed
|
||||||
|
rustup-init --profile minimal --default-toolchain none -y
|
||||||
|
. "$HOME/.cargo/env"
|
||||||
|
./script/bundle-freebsd
|
||||||
|
mkdir -p out/
|
||||||
|
mv "target/zed-remote-server-freebsd-x86_64.gz" out/
|
||||||
|
rm -rf target/
|
||||||
|
cargo clean
|
||||||
|
|
||||||
- uses: cachix/install-nix-action@d1ca217b388ee87b2507a9a93bf01368bde7cec2 # v31
|
- name: Upload Artifact to Workflow - zed-remote-server (run-bundling)
|
||||||
if: ${{ matrix.system.install_nix }}
|
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4
|
||||||
|
if: contains(github.event.pull_request.labels.*.name, 'run-bundling')
|
||||||
with:
|
with:
|
||||||
github_access_token: ${{ secrets.GITHUB_TOKEN }}
|
name: zed-remote-server-${{ github.event.pull_request.head.sha || github.sha }}-x86_64-unknown-freebsd.gz
|
||||||
|
path: out/zed-remote-server-freebsd-x86_64.gz
|
||||||
|
|
||||||
- uses: cachix/cachix-action@0fc020193b5a1fa3ac4575aa3a7d3aa6a35435ad # v16
|
- name: Upload Artifacts to release
|
||||||
|
uses: softprops/action-gh-release@de2c0eb89ae2a093876385947365aca7b0e5f844 # v1
|
||||||
|
if: ${{ !(contains(github.event.pull_request.labels.*.name, 'run-bundling')) }}
|
||||||
with:
|
with:
|
||||||
name: zed-industries
|
draft: true
|
||||||
authToken: "${{ secrets.CACHIX_AUTH_TOKEN }}"
|
prerelease: ${{ env.RELEASE_CHANNEL == 'preview' }}
|
||||||
skipPush: true
|
files: |
|
||||||
- run: nix build .#debug
|
out/zed-remote-server-freebsd-x86_64.gz
|
||||||
- name: Limit /nix/store to 50GB
|
env:
|
||||||
run: "[ $(du -sm /nix/store | cut -f1) -gt 50000 ] && nix-collect-garbage -d"
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
|
||||||
|
nix-build:
|
||||||
|
name: Build with Nix
|
||||||
|
uses: ./.github/workflows/nix.yml
|
||||||
|
if: github.repository_owner == 'zed-industries' && contains(github.event.pull_request.labels.*.name, 'run-nix')
|
||||||
|
with:
|
||||||
|
flake-output: debug
|
||||||
|
# excludes the final package to only cache dependencies
|
||||||
|
cachix-filter: "-zed-editor-[0-9.]*-nightly"
|
||||||
|
|
||||||
auto-release-preview:
|
auto-release-preview:
|
||||||
name: Auto release preview
|
name: Auto release preview
|
||||||
if: |
|
if: |
|
||||||
startsWith(github.ref, 'refs/tags/v')
|
startsWith(github.ref, 'refs/tags/v')
|
||||||
&& endsWith(github.ref, '-pre') && !endsWith(github.ref, '.0-pre')
|
&& endsWith(github.ref, '-pre') && !endsWith(github.ref, '.0-pre')
|
||||||
needs: [bundle-mac, bundle-linux-x86_x64, bundle-linux-aarch64]
|
needs: [bundle-mac, bundle-linux-x86_x64, bundle-linux-aarch64, freebsd]
|
||||||
runs-on:
|
runs-on:
|
||||||
- self-hosted
|
- self-hosted
|
||||||
- bundle
|
- bundle
|
||||||
steps:
|
steps:
|
||||||
- name: gh release
|
- name: gh release
|
||||||
run: gh release edit $GITHUB_REF_NAME --draft=true
|
run: gh release edit $GITHUB_REF_NAME --draft=false
|
||||||
env:
|
env:
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
|||||||
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: ubuntu-latest
|
runs-on: buildjet-16vcpu-ubuntu-2204
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout repo
|
- name: Checkout repo
|
||||||
@@ -17,24 +17,11 @@ 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: Install system dependencies
|
- name: Build docs
|
||||||
run: |
|
uses: ./.github/actions/build_docs
|
||||||
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
|
||||||
- test
|
- macOS
|
||||||
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
|
||||||
- test
|
- macOS
|
||||||
needs: style
|
needs: style
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout repo
|
- name: Checkout repo
|
||||||
|
|||||||
66
.github/workflows/nix.yml
vendored
Normal file
@@ -0,0 +1,66 @@
|
|||||||
|
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 || :
|
||||||
56
.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
|
||||||
- test
|
- macOS
|
||||||
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
|
||||||
- test
|
- macOS
|
||||||
needs: style
|
needs: style
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout repo
|
- name: Checkout repo
|
||||||
@@ -68,7 +68,6 @@ 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
|
||||||
@@ -104,7 +103,6 @@ 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
|
||||||
@@ -144,7 +142,6 @@ 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
|
||||||
@@ -170,6 +167,55 @@ jobs:
|
|||||||
- name: Upload Zed Nightly
|
- name: Upload Zed Nightly
|
||||||
run: script/upload-nightly linux-targz
|
run: script/upload-nightly linux-targz
|
||||||
|
|
||||||
|
freebsd:
|
||||||
|
timeout-minutes: 60
|
||||||
|
if: github.repository_owner == 'zed-industries'
|
||||||
|
runs-on: github-8vcpu-ubuntu-2404
|
||||||
|
needs: tests
|
||||||
|
env:
|
||||||
|
DIGITALOCEAN_SPACES_ACCESS_KEY: ${{ secrets.DIGITALOCEAN_SPACES_ACCESS_KEY }}
|
||||||
|
DIGITALOCEAN_SPACES_SECRET_KEY: ${{ secrets.DIGITALOCEAN_SPACES_SECRET_KEY }}
|
||||||
|
name: Build Zed on FreeBSD
|
||||||
|
# env:
|
||||||
|
# MYTOKEN : ${{ secrets.MYTOKEN }}
|
||||||
|
# MYTOKEN2: "value2"
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
- name: Build FreeBSD remote-server
|
||||||
|
id: freebsd-build
|
||||||
|
uses: vmactions/freebsd-vm@c3ae29a132c8ef1924775414107a97cac042aad5 # v1.2.0
|
||||||
|
with:
|
||||||
|
# envs: "MYTOKEN MYTOKEN2"
|
||||||
|
usesh: true
|
||||||
|
release: 13.5
|
||||||
|
copyback: true
|
||||||
|
prepare: |
|
||||||
|
pkg install -y \
|
||||||
|
bash curl jq git \
|
||||||
|
rustup-init cmake-core llvm-devel-lite pkgconf protobuf # ibx11 alsa-lib rust-bindgen-cli
|
||||||
|
run: |
|
||||||
|
freebsd-version
|
||||||
|
sysctl hw.model
|
||||||
|
sysctl hw.ncpu
|
||||||
|
sysctl hw.physmem
|
||||||
|
sysctl hw.usermem
|
||||||
|
git config --global --add safe.directory /home/runner/work/zed/zed
|
||||||
|
rustup-init --profile minimal --default-toolchain none -y
|
||||||
|
. "$HOME/.cargo/env"
|
||||||
|
./script/bundle-freebsd
|
||||||
|
mkdir -p out/
|
||||||
|
mv "target/zed-remote-server-freebsd-x86_64.gz" out/
|
||||||
|
rm -rf target/
|
||||||
|
cargo clean
|
||||||
|
|
||||||
|
- name: Upload Zed Nightly
|
||||||
|
run: script/upload-nightly freebsd
|
||||||
|
|
||||||
|
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
Normal file
@@ -0,0 +1,85 @@
|
|||||||
|
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 failure message to Slack channel if needed
|
||||||
|
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
|
||||||
6
.rules
@@ -5,6 +5,12 @@
|
|||||||
* 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
|
||||||
|
|||||||
@@ -2,16 +2,11 @@
|
|||||||
{
|
{
|
||||||
"label": "Debug Zed (CodeLLDB)",
|
"label": "Debug Zed (CodeLLDB)",
|
||||||
"adapter": "CodeLLDB",
|
"adapter": "CodeLLDB",
|
||||||
"program": "target/debug/zed",
|
"build": { "label": "Build Zed", "command": "cargo", "args": ["build"] }
|
||||||
"request": "launch"
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"label": "Debug Zed (GDB)",
|
"label": "Debug Zed (GDB)",
|
||||||
"adapter": "GDB",
|
"adapter": "GDB",
|
||||||
"program": "target/debug/zed",
|
"build": { "label": "Build Zed", "command": "cargo", "args": ["build"] }
|
||||||
"request": "launch",
|
|
||||||
"initialize_args": {
|
|
||||||
"stopAtBeginningOfMainSubprogram": true
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -47,6 +47,7 @@
|
|||||||
"remove_trailing_whitespace_on_save": true,
|
"remove_trailing_whitespace_on_save": true,
|
||||||
"ensure_final_newline_on_save": true,
|
"ensure_final_newline_on_save": true,
|
||||||
"file_scan_exclusions": [
|
"file_scan_exclusions": [
|
||||||
|
"crates/assistant_tools/src/evals/fixtures",
|
||||||
"crates/eval/worktrees/",
|
"crates/eval/worktrees/",
|
||||||
"crates/eval/repos/",
|
"crates/eval/repos/",
|
||||||
"**/.git",
|
"**/.git",
|
||||||
|
|||||||
443
Cargo.lock
generated
31
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",
|
||||||
@@ -73,6 +73,7 @@ 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",
|
||||||
"crates/jj_ui",
|
"crates/jj_ui",
|
||||||
@@ -80,7 +81,6 @@ members = [
|
|||||||
"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,6 +100,7 @@ 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",
|
||||||
@@ -164,6 +165,7 @@ members = [
|
|||||||
"crates/util_macros",
|
"crates/util_macros",
|
||||||
"crates/vim",
|
"crates/vim",
|
||||||
"crates/vim_mode_setting",
|
"crates/vim_mode_setting",
|
||||||
|
"crates/watch",
|
||||||
"crates/web_search",
|
"crates/web_search",
|
||||||
"crates/web_search_providers",
|
"crates/web_search_providers",
|
||||||
"crates/welcome",
|
"crates/welcome",
|
||||||
@@ -211,12 +213,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" }
|
||||||
@@ -280,6 +282,7 @@ 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 = { path = "crates/jj" }
|
||||||
jj_ui = { path = "crates/jj_ui" }
|
jj_ui = { path = "crates/jj_ui" }
|
||||||
@@ -287,7 +290,6 @@ 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" }
|
||||||
@@ -307,6 +309,7 @@ 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" }
|
||||||
@@ -371,6 +374,7 @@ util = { path = "crates/util" }
|
|||||||
util_macros = { path = "crates/util_macros" }
|
util_macros = { path = "crates/util_macros" }
|
||||||
vim = { path = "crates/vim" }
|
vim = { path = "crates/vim" }
|
||||||
vim_mode_setting = { path = "crates/vim_mode_setting" }
|
vim_mode_setting = { path = "crates/vim_mode_setting" }
|
||||||
|
watch = { path = "crates/watch" }
|
||||||
web_search = { path = "crates/web_search" }
|
web_search = { path = "crates/web_search" }
|
||||||
web_search_providers = { path = "crates/web_search_providers" }
|
web_search_providers = { path = "crates/web_search_providers" }
|
||||||
welcome = { path = "crates/welcome" }
|
welcome = { path = "crates/welcome" }
|
||||||
@@ -401,7 +405,6 @@ async-recursion = "1.0.0"
|
|||||||
async-tar = "0.5.0"
|
async-tar = "0.5.0"
|
||||||
async-trait = "0.1"
|
async-trait = "0.1"
|
||||||
async-tungstenite = "0.29.1"
|
async-tungstenite = "0.29.1"
|
||||||
async-watch = "0.3.1"
|
|
||||||
async_zip = { version = "0.0.17", features = ["deflate", "deflate64"] }
|
async_zip = { version = "0.0.17", features = ["deflate", "deflate64"] }
|
||||||
aws-config = { version = "1.6.1", features = ["behavior-version-latest"] }
|
aws-config = { version = "1.6.1", features = ["behavior-version-latest"] }
|
||||||
aws-credential-types = { version = "1.2.2", features = [
|
aws-credential-types = { version = "1.2.2", features = [
|
||||||
@@ -432,7 +435,7 @@ 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"] }
|
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 = "be69a016ba710191b9fdded28c8b042af4b617f7" }
|
dap-types = { git = "https://github.com/zed-industries/dap-types", rev = "68516de327fa1be15214133a0a2e52a12982ce75" }
|
||||||
dashmap = "6.0"
|
dashmap = "6.0"
|
||||||
derive_more = "0.99.17"
|
derive_more = "0.99.17"
|
||||||
dirs = "4.0"
|
dirs = "4.0"
|
||||||
@@ -449,6 +452,7 @@ 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"] }
|
||||||
@@ -464,6 +468,7 @@ 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" }
|
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" }
|
||||||
@@ -476,6 +481,7 @@ lsp-types = { git = "https://github.com/zed-industries/lsp-types", rev = "c9c189
|
|||||||
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" }
|
||||||
@@ -550,7 +556,7 @@ 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 = "1.0.72", features = ["full", "extra-traits"] }
|
syn = { version = "2.0.101", 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"
|
||||||
@@ -569,8 +575,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.3", features = ["wasm"] }
|
tree-sitter = { version = "0.25.6", features = ["wasm"] }
|
||||||
tree-sitter-bash = "0.23"
|
tree-sitter-bash = "0.25.0"
|
||||||
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"
|
||||||
@@ -599,8 +605,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.3"
|
walkdir = "2.5"
|
||||||
wasi-preview1-component-adapter-provider = "29"
|
|
||||||
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 = [
|
||||||
@@ -609,13 +614,13 @@ wasmtime = { version = "29", default-features = false, features = [
|
|||||||
"runtime",
|
"runtime",
|
||||||
"cranelift",
|
"cranelift",
|
||||||
"component-model",
|
"component-model",
|
||||||
|
"incremental-cache",
|
||||||
"parallel-compilation",
|
"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.1"
|
zed_llm_client = "0.8.4"
|
||||||
zstd = "0.11"
|
zstd = "0.11"
|
||||||
|
|
||||||
[workspace.dependencies.async-stripe]
|
[workspace.dependencies.async-stripe]
|
||||||
|
|||||||
8
assets/icons/ai_open_router.svg
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
<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>
|
||||||
|
After Width: | Height: | Size: 575 B |
@@ -1,3 +1,3 @@
|
|||||||
<svg width="8" height="8" viewBox="0 0 8 8" 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="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"/>
|
<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"/>
|
||||||
</svg>
|
</svg>
|
||||||
|
|||||||
|
Before Width: | Height: | Size: 633 B After Width: | Height: | Size: 227 B |
3
assets/icons/bolt_filled.svg
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
<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>
|
||||||
|
After Width: | Height: | Size: 633 B |
@@ -1,5 +1,4 @@
|
|||||||
<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
|
<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||||
<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="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="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="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 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: 715 B After Width: | Height: | Size: 617 B |
1
assets/icons/list_todo.svg
Normal file
@@ -0,0 +1 @@
|
|||||||
|
<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>
|
||||||
|
After Width: | Height: | Size: 373 B |
3
assets/icons/play_alt.svg
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
<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>
|
||||||
|
After Width: | Height: | Size: 214 B |
8
assets/icons/play_bug.svg
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
<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>
|
||||||
|
After Width: | Height: | Size: 813 B |
@@ -1,3 +1,8 @@
|
|||||||
<svg width="17" height="17" viewBox="0 0 17 17" fill="none" xmlns="http://www.w3.org/2000/svg">
|
<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||||
<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="M2 5H4" stroke="black" stroke-width="1.5" stroke-linecap="round"/>
|
||||||
|
<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: 1.3 KiB After Width: | Height: | Size: 657 B |
@@ -1 +1,3 @@
|
|||||||
<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>
|
<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/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 +1,3 @@
|
|||||||
<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>
|
<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/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: 794 B After Width: | Height: | Size: 1.7 KiB |
@@ -1,5 +1,5 @@
|
|||||||
<svg width="14" height="14" viewBox="0 0 14 14" fill="none" xmlns="http://www.w3.org/2000/svg">
|
<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||||
<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="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="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="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="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"/>
|
<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"/>
|
||||||
</svg>
|
</svg>
|
||||||
|
|||||||
|
Before Width: | Height: | Size: 1.0 KiB After Width: | Height: | Size: 998 B |
3
assets/icons/zed_burn_mode.svg
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
<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>
|
||||||
|
After Width: | Height: | Size: 1018 B |
13
assets/icons/zed_burn_mode_on.svg
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
<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>
|
||||||
|
After Width: | Height: | Size: 1.6 KiB |
@@ -1,14 +0,0 @@
|
|||||||
<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>
|
|
||||||
|
Before 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,14 +120,12 @@
|
|||||||
"ctrl-'": "editor::ToggleSelectedDiffHunks",
|
"ctrl-'": "editor::ToggleSelectedDiffHunks",
|
||||||
"ctrl-\"": "editor::ExpandAllDiffHunks",
|
"ctrl-\"": "editor::ExpandAllDiffHunks",
|
||||||
"ctrl-i": "editor::ShowSignatureHelp",
|
"ctrl-i": "editor::ShowSignatureHelp",
|
||||||
"alt-g b": "editor::ToggleGitBlame",
|
"alt-g b": "git::Blame",
|
||||||
"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"
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -146,6 +144,8 @@
|
|||||||
"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"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -153,8 +153,7 @@
|
|||||||
"context": "Editor && mode == full && edit_prediction",
|
"context": "Editor && mode == full && edit_prediction",
|
||||||
"bindings": {
|
"bindings": {
|
||||||
"alt-]": "editor::NextEditPrediction",
|
"alt-]": "editor::NextEditPrediction",
|
||||||
"alt-[": "editor::PreviousEditPrediction",
|
"alt-[": "editor::PreviousEditPrediction"
|
||||||
"alt-right": "editor::AcceptPartialEditPrediction"
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -219,7 +218,6 @@
|
|||||||
"ctrl-enter": "assistant::Assist",
|
"ctrl-enter": "assistant::Assist",
|
||||||
"ctrl-s": "workspace::Save",
|
"ctrl-s": "workspace::Save",
|
||||||
"save": "workspace::Save",
|
"save": "workspace::Save",
|
||||||
"ctrl->": "assistant::QuoteSelection",
|
|
||||||
"ctrl-<": "assistant::InsertIntoEditor",
|
"ctrl-<": "assistant::InsertIntoEditor",
|
||||||
"shift-enter": "assistant::Split",
|
"shift-enter": "assistant::Split",
|
||||||
"ctrl-r": "assistant::CycleMessageRole",
|
"ctrl-r": "assistant::CycleMessageRole",
|
||||||
@@ -242,11 +240,15 @@
|
|||||||
"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-o": "agent::ToggleNavigationMenu",
|
"ctrl-shift-j": "agent::ToggleNavigationMenu",
|
||||||
"ctrl-shift-i": "agent::ToggleOptionsMenu",
|
"ctrl-shift-i": "agent::ToggleOptionsMenu",
|
||||||
"shift-alt-escape": "agent::ExpandMessageEditor",
|
"shift-alt-escape": "agent::ExpandMessageEditor",
|
||||||
|
"ctrl->": "assistant::QuoteSelection",
|
||||||
"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"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -273,8 +275,11 @@
|
|||||||
"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"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -506,14 +511,14 @@
|
|||||||
{
|
{
|
||||||
"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-open": "projects::OpenRecent",
|
"alt-ctrl-o": ["projects::OpenRecent", { "create_new_window": false }],
|
||||||
"alt-ctrl-o": "projects::OpenRecent",
|
"alt-shift-open": ["projects::OpenRemote", { "from_existing_connection": false, "create_new_window": false }],
|
||||||
"alt-shift-open": "projects::OpenRemote",
|
|
||||||
"alt-ctrl-shift-o": "projects::OpenRemote",
|
|
||||||
// Change to open path modal for existing remote connection by setting the parameter
|
// Change to open path modal for existing remote connection by setting the parameter
|
||||||
// "alt-ctrl-shift-o": "["projects::OpenRemote", { "from_existing_connection": true }]",
|
// "alt-ctrl-shift-o": "["projects::OpenRemote", { "from_existing_connection": true }]",
|
||||||
|
"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",
|
||||||
@@ -558,6 +563,7 @@
|
|||||||
"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",
|
||||||
@@ -576,11 +582,24 @@
|
|||||||
"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"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -595,7 +614,6 @@
|
|||||||
{
|
{
|
||||||
"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",
|
||||||
@@ -643,14 +661,16 @@
|
|||||||
"bindings": {
|
"bindings": {
|
||||||
"alt-tab": "editor::AcceptEditPrediction",
|
"alt-tab": "editor::AcceptEditPrediction",
|
||||||
"alt-l": "editor::AcceptEditPrediction",
|
"alt-l": "editor::AcceptEditPrediction",
|
||||||
"tab": "editor::AcceptEditPrediction"
|
"tab": "editor::AcceptEditPrediction",
|
||||||
|
"alt-right": "editor::AcceptPartialEditPrediction"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"context": "Editor && edit_prediction_conflict",
|
"context": "Editor && edit_prediction_conflict",
|
||||||
"bindings": {
|
"bindings": {
|
||||||
"alt-tab": "editor::AcceptEditPrediction",
|
"alt-tab": "editor::AcceptEditPrediction",
|
||||||
"alt-l": "editor::AcceptEditPrediction"
|
"alt-l": "editor::AcceptEditPrediction",
|
||||||
|
"alt-right": "editor::AcceptPartialEditPrediction"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -674,7 +694,8 @@
|
|||||||
{
|
{
|
||||||
"bindings": {
|
"bindings": {
|
||||||
"ctrl-alt-shift-f": "workspace::FollowNextCollaborator",
|
"ctrl-alt-shift-f": "workspace::FollowNextCollaborator",
|
||||||
"ctrl-alt-i": "zed::DebugElements"
|
// Only available in debug builds: opens an element inspector for development.
|
||||||
|
"ctrl-alt-i": "dev::ToggleInspector"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -862,11 +883,38 @@
|
|||||||
"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"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -897,6 +945,13 @@
|
|||||||
"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": {
|
||||||
@@ -988,5 +1043,12 @@
|
|||||||
"bindings": {
|
"bindings": {
|
||||||
"enter": "menu::Confirm"
|
"enter": "menu::Confirm"
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"context": "RunModal",
|
||||||
|
"bindings": {
|
||||||
|
"ctrl-tab": "pane::ActivateNextItem",
|
||||||
|
"ctrl-shift-tab": "pane::ActivatePreviousItem"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -1,22 +1,11 @@
|
|||||||
[
|
[
|
||||||
// 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",
|
||||||
@@ -149,7 +138,7 @@
|
|||||||
"cmd-;": "editor::ToggleLineNumbers",
|
"cmd-;": "editor::ToggleLineNumbers",
|
||||||
"cmd-'": "editor::ToggleSelectedDiffHunks",
|
"cmd-'": "editor::ToggleSelectedDiffHunks",
|
||||||
"cmd-\"": "editor::ExpandAllDiffHunks",
|
"cmd-\"": "editor::ExpandAllDiffHunks",
|
||||||
"cmd-alt-g b": "editor::ToggleGitBlame",
|
"cmd-alt-g b": "git::Blame",
|
||||||
"cmd-i": "editor::ShowSignatureHelp",
|
"cmd-i": "editor::ShowSignatureHelp",
|
||||||
"f9": "editor::ToggleBreakpoint",
|
"f9": "editor::ToggleBreakpoint",
|
||||||
"shift-f9": "editor::EditLogBreakpoint",
|
"shift-f9": "editor::EditLogBreakpoint",
|
||||||
@@ -192,8 +181,7 @@
|
|||||||
"use_key_equivalents": true,
|
"use_key_equivalents": true,
|
||||||
"bindings": {
|
"bindings": {
|
||||||
"alt-tab": "editor::NextEditPrediction",
|
"alt-tab": "editor::NextEditPrediction",
|
||||||
"alt-shift-tab": "editor::PreviousEditPrediction",
|
"alt-shift-tab": "editor::PreviousEditPrediction"
|
||||||
"ctrl-cmd-right": "editor::AcceptPartialEditPrediction"
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -264,7 +252,6 @@
|
|||||||
"bindings": {
|
"bindings": {
|
||||||
"cmd-enter": "assistant::Assist",
|
"cmd-enter": "assistant::Assist",
|
||||||
"cmd-s": "workspace::Save",
|
"cmd-s": "workspace::Save",
|
||||||
"cmd->": "assistant::QuoteSelection",
|
|
||||||
"cmd-<": "assistant::InsertIntoEditor",
|
"cmd-<": "assistant::InsertIntoEditor",
|
||||||
"shift-enter": "assistant::Split",
|
"shift-enter": "assistant::Split",
|
||||||
"ctrl-r": "assistant::CycleMessageRole",
|
"ctrl-r": "assistant::CycleMessageRole",
|
||||||
@@ -288,11 +275,15 @@
|
|||||||
"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-o": "agent::ToggleNavigationMenu",
|
"cmd-shift-j": "agent::ToggleNavigationMenu",
|
||||||
"cmd-shift-i": "agent::ToggleOptionsMenu",
|
"cmd-shift-i": "agent::ToggleOptionsMenu",
|
||||||
"shift-alt-escape": "agent::ExpandMessageEditor",
|
"shift-alt-escape": "agent::ExpandMessageEditor",
|
||||||
|
"cmd->": "assistant::QuoteSelection",
|
||||||
"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"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -321,8 +312,11 @@
|
|||||||
"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"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -367,18 +361,21 @@
|
|||||||
"ctrl--": "pane::GoBack"
|
"ctrl--": "pane::GoBack"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"context": "ThreadHistory",
|
|
||||||
"bindings": {
|
|
||||||
"ctrl--": "pane::GoBack"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"context": "ThreadHistory > Editor",
|
"context": "ThreadHistory > Editor",
|
||||||
"bindings": {
|
"bindings": {
|
||||||
"shift-backspace": "agent::RemoveSelectedThread"
|
"shift-backspace": "agent::RemoveSelectedThread"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"context": "PromptLibrary",
|
||||||
|
"use_key_equivalents": true,
|
||||||
|
"bindings": {
|
||||||
|
"cmd-n": "rules_library::NewRule",
|
||||||
|
"cmd-shift-s": "rules_library::ToggleDefaultRule",
|
||||||
|
"cmd-w": "workspace::CloseWindow"
|
||||||
|
}
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"context": "BufferSearchBar",
|
"context": "BufferSearchBar",
|
||||||
"use_key_equivalents": true,
|
"use_key_equivalents": true,
|
||||||
@@ -548,9 +545,7 @@
|
|||||||
"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"
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -558,7 +553,9 @@
|
|||||||
"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"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -586,9 +583,9 @@
|
|||||||
"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",
|
"alt-cmd-o": ["projects::OpenRecent", { "create_new_window": false }],
|
||||||
"ctrl-cmd-o": "projects::OpenRemote",
|
"ctrl-cmd-o": ["projects::OpenRemote", { "from_existing_connection": false, "create_new_window": false }],
|
||||||
"ctrl-cmd-shift-o": ["projects::OpenRemote", { "from_existing_connection": true }],
|
"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",
|
||||||
@@ -624,6 +621,7 @@
|
|||||||
"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",
|
||||||
@@ -636,7 +634,8 @@
|
|||||||
"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,6 +652,20 @@
|
|||||||
// "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",
|
||||||
@@ -705,14 +718,16 @@
|
|||||||
"context": "Editor && edit_prediction",
|
"context": "Editor && edit_prediction",
|
||||||
"bindings": {
|
"bindings": {
|
||||||
"alt-tab": "editor::AcceptEditPrediction",
|
"alt-tab": "editor::AcceptEditPrediction",
|
||||||
"tab": "editor::AcceptEditPrediction"
|
"tab": "editor::AcceptEditPrediction",
|
||||||
|
"ctrl-cmd-right": "editor::AcceptPartialEditPrediction"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"context": "Editor && edit_prediction_conflict",
|
"context": "Editor && edit_prediction_conflict",
|
||||||
"use_key_equivalents": true,
|
"use_key_equivalents": true,
|
||||||
"bindings": {
|
"bindings": {
|
||||||
"alt-tab": "editor::AcceptEditPrediction"
|
"alt-tab": "editor::AcceptEditPrediction",
|
||||||
|
"ctrl-cmd-right": "editor::AcceptPartialEditPrediction"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -741,7 +756,8 @@
|
|||||||
"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",
|
||||||
"cmd-alt-i": "zed::DebugElements"
|
// Only available in debug builds: opens an element inspector for development.
|
||||||
|
"cmd-alt-i": "dev::ToggleInspector"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -844,7 +860,10 @@
|
|||||||
"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"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -929,12 +948,29 @@
|
|||||||
"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"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -970,6 +1006,14 @@
|
|||||||
"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,
|
||||||
@@ -1092,5 +1136,13 @@
|
|||||||
"bindings": {
|
"bindings": {
|
||||||
"enter": "menu::Confirm"
|
"enter": "menu::Confirm"
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"context": "RunModal",
|
||||||
|
"use_key_equivalents": true,
|
||||||
|
"bindings": {
|
||||||
|
"ctrl-tab": "pane::ActivateNextItem",
|
||||||
|
"ctrl-shift-tab": "pane::ActivatePreviousItem"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -13,9 +13,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"context": "Editor",
|
"context": "Editor && vim_mode == insert && !menu",
|
||||||
"bindings": {
|
"bindings": {
|
||||||
// "j k": ["workspace::SendKeystrokes", "escape"]
|
// "j k": "vim::SwitchToNormalMode"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|||||||
85
assets/keymaps/linux/cursor.json
Normal file
@@ -0,0 +1,85 @@
|
|||||||
|
[
|
||||||
|
// 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"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
@@ -51,7 +51,11 @@
|
|||||||
"ctrl-k ctrl-l": "editor::ConvertToLowerCase",
|
"ctrl-k ctrl-l": "editor::ConvertToLowerCase",
|
||||||
"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",
|
||||||
|
"alt-left": "editor::MoveToPreviousSubwordStart",
|
||||||
|
"alt-shift-right": "editor::SelectToNextSubwordEnd",
|
||||||
|
"alt-shift-left": "editor::SelectToPreviousSubwordStart"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|||||||
85
assets/keymaps/macos/cursor.json
Normal file
@@ -0,0 +1,85 @@
|
|||||||
|
[
|
||||||
|
// 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"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
@@ -53,7 +53,11 @@
|
|||||||
"cmd-shift-j": "editor::JoinLines",
|
"cmd-shift-j": "editor::JoinLines",
|
||||||
"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",
|
||||||
|
"ctrl-left": "editor::MoveToPreviousSubwordStart",
|
||||||
|
"ctrl-shift-right": "editor::SelectToNextSubwordEnd",
|
||||||
|
"ctrl-shift-left": "editor::SelectToPreviousSubwordStart"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -198,6 +198,8 @@
|
|||||||
"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",
|
||||||
@@ -709,7 +711,7 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"context": "GitPanel || ProjectPanel || CollabPanel || OutlinePanel || ChatPanel || VimControl || EmptyPane || SharedScreen || MarkdownPreview || KeyContextView || DebugPanel",
|
"context": "AgentPanel || GitPanel || ProjectPanel || CollabPanel || OutlinePanel || ChatPanel || VimControl || EmptyPane || SharedScreen || MarkdownPreview || KeyContextView || DebugPanel",
|
||||||
"bindings": {
|
"bindings": {
|
||||||
// window related commands (ctrl-w X)
|
// window related commands (ctrl-w X)
|
||||||
"ctrl-w": null,
|
"ctrl-w": null,
|
||||||
@@ -838,6 +840,19 @@
|
|||||||
"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": {
|
||||||
@@ -846,13 +861,5 @@
|
|||||||
// 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,7 +38,6 @@ 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).
|
||||||
|
|
||||||
|
|||||||
@@ -73,9 +73,6 @@
|
|||||||
"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.
|
||||||
@@ -128,6 +125,8 @@
|
|||||||
//
|
//
|
||||||
// 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.
|
||||||
@@ -213,6 +212,8 @@
|
|||||||
// 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`
|
||||||
@@ -230,11 +231,11 @@
|
|||||||
// Possible values:
|
// Possible values:
|
||||||
// - "off" — no diagnostics are allowed
|
// - "off" — no diagnostics are allowed
|
||||||
// - "error"
|
// - "error"
|
||||||
// - "warning" (default)
|
// - "warning"
|
||||||
// - "info"
|
// - "info"
|
||||||
// - "hint"
|
// - "hint"
|
||||||
// - null — allow all diagnostics
|
// - null — allow all diagnostics (default)
|
||||||
"diagnostics_max_severity": "warning",
|
"diagnostics_max_severity": null,
|
||||||
// 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
|
||||||
@@ -322,7 +323,9 @@
|
|||||||
// 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": {
|
||||||
@@ -471,6 +474,10 @@
|
|||||||
// 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,
|
||||||
@@ -526,6 +533,9 @@
|
|||||||
"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,
|
||||||
@@ -706,7 +716,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 'max'.
|
/// What completion mode to start new threads in, if available. Can be 'normal' or 'burn'.
|
||||||
"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,
|
||||||
@@ -721,14 +731,7 @@
|
|||||||
// The provider to use.
|
// The provider to use.
|
||||||
"provider": "zed.dev",
|
"provider": "zed.dev",
|
||||||
// The model to use.
|
// The model to use.
|
||||||
"model": "claude-3-7-sonnet-latest"
|
"model": "claude-sonnet-4"
|
||||||
},
|
|
||||||
// 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
|
||||||
@@ -748,7 +751,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-3-7-sonnet-latest",
|
// "model": "claude-sonnet-4",
|
||||||
// "temperature": 1.0
|
// "temperature": 1.0
|
||||||
// }
|
// }
|
||||||
],
|
],
|
||||||
@@ -768,7 +771,6 @@
|
|||||||
"tools": {
|
"tools": {
|
||||||
"copy_path": true,
|
"copy_path": true,
|
||||||
"create_directory": true,
|
"create_directory": true,
|
||||||
"create_file": true,
|
|
||||||
"delete_path": true,
|
"delete_path": true,
|
||||||
"diagnostics": true,
|
"diagnostics": true,
|
||||||
"edit_file": true,
|
"edit_file": true,
|
||||||
@@ -814,7 +816,12 @@
|
|||||||
// "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": {
|
||||||
@@ -946,7 +953,17 @@
|
|||||||
// "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.
|
||||||
@@ -1016,6 +1033,14 @@
|
|||||||
"button": true,
|
"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 using LSP pull diagnostics mechanism in Zed.
|
||||||
|
"lsp_pull_diagnostics": {
|
||||||
|
// Whether to pull for diagnostics or not.
|
||||||
|
"enabled": true,
|
||||||
|
// Minimum time to wait before pulling diagnostics from the language server(s).
|
||||||
|
// 0 turns the debounce off.
|
||||||
|
"debounce_ms": 50
|
||||||
|
},
|
||||||
// Settings for inline diagnostics
|
// Settings for inline diagnostics
|
||||||
"inline": {
|
"inline": {
|
||||||
// Whether to show diagnostics inline or not
|
// Whether to show diagnostics inline or not
|
||||||
@@ -1291,7 +1316,17 @@
|
|||||||
// 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
|
||||||
@@ -1429,7 +1464,9 @@
|
|||||||
"language_servers": ["erlang-ls", "!elp", "..."]
|
"language_servers": ["erlang-ls", "!elp", "..."]
|
||||||
},
|
},
|
||||||
"Git Commit": {
|
"Git Commit": {
|
||||||
"allow_rewrap": "anywhere"
|
"allow_rewrap": "anywhere",
|
||||||
|
"soft_wrap": "editor_width",
|
||||||
|
"preferred_line_length": 72
|
||||||
},
|
},
|
||||||
"Go": {
|
"Go": {
|
||||||
"code_actions_on_format": {
|
"code_actions_on_format": {
|
||||||
@@ -1472,11 +1509,11 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"LaTeX": {
|
"LaTeX": {
|
||||||
"format_on_save": "on",
|
|
||||||
"formatter": "language_server",
|
"formatter": "language_server",
|
||||||
"language_servers": ["texlab", "..."],
|
"language_servers": ["texlab", "..."],
|
||||||
"prettier": {
|
"prettier": {
|
||||||
"allowed": false
|
"allowed": true,
|
||||||
|
"plugins": ["prettier-plugin-latex"]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"Markdown": {
|
"Markdown": {
|
||||||
@@ -1500,19 +1537,13 @@
|
|||||||
"allow_rewrap": "anywhere"
|
"allow_rewrap": "anywhere"
|
||||||
},
|
},
|
||||||
"Ruby": {
|
"Ruby": {
|
||||||
"language_servers": ["solargraph", "!ruby-lsp", "!rubocop", "..."]
|
"language_servers": ["solargraph", "!ruby-lsp", "!rubocop", "!sorbet", "!steep", "..."]
|
||||||
},
|
},
|
||||||
"SCSS": {
|
"SCSS": {
|
||||||
"prettier": {
|
"prettier": {
|
||||||
"allowed": true
|
"allowed": true
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"SQL": {
|
|
||||||
"prettier": {
|
|
||||||
"allowed": true,
|
|
||||||
"plugins": ["prettier-plugin-sql"]
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"Starlark": {
|
"Starlark": {
|
||||||
"language_servers": ["starpls", "!buck2-lsp", "..."]
|
"language_servers": ["starpls", "!buck2-lsp", "..."]
|
||||||
},
|
},
|
||||||
@@ -1577,6 +1608,9 @@
|
|||||||
"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"
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -1,32 +1,34 @@
|
|||||||
|
// 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": "python",
|
"adapter": "Debugpy",
|
||||||
"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",
|
||||||
"initialize_args": {
|
"console": "integratedTerminal"
|
||||||
"console": "integratedTerminal"
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|||||||
5
assets/settings/initial_local_debug_tasks.json
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
// Project-local debug tasks
|
||||||
|
//
|
||||||
|
// For more documentation on how to configure debug tasks,
|
||||||
|
// see: https://zed.dev/docs/debugger
|
||||||
|
[]
|
||||||
BIN
assets/sounds/agent_done.wav
Executable file
@@ -261,6 +261,11 @@
|
|||||||
"font_style": null,
|
"font_style": null,
|
||||||
"font_weight": null
|
"font_weight": null
|
||||||
},
|
},
|
||||||
|
"namespace": {
|
||||||
|
"color": "#bfbdb6ff",
|
||||||
|
"font_style": null,
|
||||||
|
"font_weight": null
|
||||||
|
},
|
||||||
"number": {
|
"number": {
|
||||||
"color": "#d2a6ffff",
|
"color": "#d2a6ffff",
|
||||||
"font_style": null,
|
"font_style": null,
|
||||||
@@ -316,6 +321,16 @@
|
|||||||
"font_style": null,
|
"font_style": null,
|
||||||
"font_weight": null
|
"font_weight": null
|
||||||
},
|
},
|
||||||
|
"selector": {
|
||||||
|
"color": "#d2a6ffff",
|
||||||
|
"font_style": null,
|
||||||
|
"font_weight": null
|
||||||
|
},
|
||||||
|
"selector.pseudo": {
|
||||||
|
"color": "#5ac1feff",
|
||||||
|
"font_style": null,
|
||||||
|
"font_weight": null
|
||||||
|
},
|
||||||
"string": {
|
"string": {
|
||||||
"color": "#a9d94bff",
|
"color": "#a9d94bff",
|
||||||
"font_style": null,
|
"font_style": null,
|
||||||
@@ -442,9 +457,9 @@
|
|||||||
"terminal.foreground": "#5c6166ff",
|
"terminal.foreground": "#5c6166ff",
|
||||||
"terminal.bright_foreground": "#5c6166ff",
|
"terminal.bright_foreground": "#5c6166ff",
|
||||||
"terminal.dim_foreground": "#fcfcfcff",
|
"terminal.dim_foreground": "#fcfcfcff",
|
||||||
"terminal.ansi.black": "#fcfcfcff",
|
"terminal.ansi.black": "#5c6166ff",
|
||||||
"terminal.ansi.bright_black": "#bcbec0ff",
|
"terminal.ansi.bright_black": "#3b9ee5ff",
|
||||||
"terminal.ansi.dim_black": "#5c6166ff",
|
"terminal.ansi.dim_black": "#9c9fa2ff",
|
||||||
"terminal.ansi.red": "#ef7271ff",
|
"terminal.ansi.red": "#ef7271ff",
|
||||||
"terminal.ansi.bright_red": "#febab6ff",
|
"terminal.ansi.bright_red": "#febab6ff",
|
||||||
"terminal.ansi.dim_red": "#833538ff",
|
"terminal.ansi.dim_red": "#833538ff",
|
||||||
@@ -463,9 +478,9 @@
|
|||||||
"terminal.ansi.cyan": "#4dbf99ff",
|
"terminal.ansi.cyan": "#4dbf99ff",
|
||||||
"terminal.ansi.bright_cyan": "#ace0cbff",
|
"terminal.ansi.bright_cyan": "#ace0cbff",
|
||||||
"terminal.ansi.dim_cyan": "#2a5f4aff",
|
"terminal.ansi.dim_cyan": "#2a5f4aff",
|
||||||
"terminal.ansi.white": "#5c6166ff",
|
"terminal.ansi.white": "#fcfcfcff",
|
||||||
"terminal.ansi.bright_white": "#5c6166ff",
|
"terminal.ansi.bright_white": "#fcfcfcff",
|
||||||
"terminal.ansi.dim_white": "#9c9fa2ff",
|
"terminal.ansi.dim_white": "#bcbec0ff",
|
||||||
"link_text.hover": "#3b9ee5ff",
|
"link_text.hover": "#3b9ee5ff",
|
||||||
"conflict": "#f1ad49ff",
|
"conflict": "#f1ad49ff",
|
||||||
"conflict.background": "#ffeedaff",
|
"conflict.background": "#ffeedaff",
|
||||||
@@ -632,6 +647,11 @@
|
|||||||
"font_style": null,
|
"font_style": null,
|
||||||
"font_weight": null
|
"font_weight": null
|
||||||
},
|
},
|
||||||
|
"namespace": {
|
||||||
|
"color": "#5c6166ff",
|
||||||
|
"font_style": null,
|
||||||
|
"font_weight": null
|
||||||
|
},
|
||||||
"number": {
|
"number": {
|
||||||
"color": "#a37accff",
|
"color": "#a37accff",
|
||||||
"font_style": null,
|
"font_style": null,
|
||||||
@@ -687,6 +707,16 @@
|
|||||||
"font_style": null,
|
"font_style": null,
|
||||||
"font_weight": null
|
"font_weight": null
|
||||||
},
|
},
|
||||||
|
"selector": {
|
||||||
|
"color": "#a37accff",
|
||||||
|
"font_style": null,
|
||||||
|
"font_weight": null
|
||||||
|
},
|
||||||
|
"selector.pseudo": {
|
||||||
|
"color": "#3b9ee5ff",
|
||||||
|
"font_style": null,
|
||||||
|
"font_weight": null
|
||||||
|
},
|
||||||
"string": {
|
"string": {
|
||||||
"color": "#86b300ff",
|
"color": "#86b300ff",
|
||||||
"font_style": null,
|
"font_style": null,
|
||||||
@@ -1003,6 +1033,11 @@
|
|||||||
"font_style": null,
|
"font_style": null,
|
||||||
"font_weight": null
|
"font_weight": null
|
||||||
},
|
},
|
||||||
|
"namespace": {
|
||||||
|
"color": "#cccac2ff",
|
||||||
|
"font_style": null,
|
||||||
|
"font_weight": null
|
||||||
|
},
|
||||||
"number": {
|
"number": {
|
||||||
"color": "#dfbfffff",
|
"color": "#dfbfffff",
|
||||||
"font_style": null,
|
"font_style": null,
|
||||||
@@ -1058,6 +1093,16 @@
|
|||||||
"font_style": null,
|
"font_style": null,
|
||||||
"font_weight": null
|
"font_weight": null
|
||||||
},
|
},
|
||||||
|
"selector": {
|
||||||
|
"color": "#dfbfffff",
|
||||||
|
"font_style": null,
|
||||||
|
"font_weight": null
|
||||||
|
},
|
||||||
|
"selector.pseudo": {
|
||||||
|
"color": "#72cffeff",
|
||||||
|
"font_style": null,
|
||||||
|
"font_weight": null
|
||||||
|
},
|
||||||
"string": {
|
"string": {
|
||||||
"color": "#d4fe7fff",
|
"color": "#d4fe7fff",
|
||||||
"font_style": null,
|
"font_style": null,
|
||||||
|
|||||||
@@ -270,6 +270,11 @@
|
|||||||
"font_style": null,
|
"font_style": null,
|
||||||
"font_weight": null
|
"font_weight": null
|
||||||
},
|
},
|
||||||
|
"namespace": {
|
||||||
|
"color": "#83a598ff",
|
||||||
|
"font_style": null,
|
||||||
|
"font_weight": null
|
||||||
|
},
|
||||||
"number": {
|
"number": {
|
||||||
"color": "#d3869bff",
|
"color": "#d3869bff",
|
||||||
"font_style": null,
|
"font_style": null,
|
||||||
@@ -325,6 +330,16 @@
|
|||||||
"font_style": null,
|
"font_style": null,
|
||||||
"font_weight": null
|
"font_weight": null
|
||||||
},
|
},
|
||||||
|
"selector": {
|
||||||
|
"color": "#fabd2eff",
|
||||||
|
"font_style": null,
|
||||||
|
"font_weight": null
|
||||||
|
},
|
||||||
|
"selector.pseudo": {
|
||||||
|
"color": "#83a598ff",
|
||||||
|
"font_style": null,
|
||||||
|
"font_weight": null
|
||||||
|
},
|
||||||
"string": {
|
"string": {
|
||||||
"color": "#b8bb25ff",
|
"color": "#b8bb25ff",
|
||||||
"font_style": null,
|
"font_style": null,
|
||||||
@@ -655,6 +670,11 @@
|
|||||||
"font_style": null,
|
"font_style": null,
|
||||||
"font_weight": null
|
"font_weight": null
|
||||||
},
|
},
|
||||||
|
"namespace": {
|
||||||
|
"color": "#83a598ff",
|
||||||
|
"font_style": null,
|
||||||
|
"font_weight": null
|
||||||
|
},
|
||||||
"number": {
|
"number": {
|
||||||
"color": "#d3869bff",
|
"color": "#d3869bff",
|
||||||
"font_style": null,
|
"font_style": null,
|
||||||
@@ -710,6 +730,16 @@
|
|||||||
"font_style": null,
|
"font_style": null,
|
||||||
"font_weight": null
|
"font_weight": null
|
||||||
},
|
},
|
||||||
|
"selector": {
|
||||||
|
"color": "#fabd2eff",
|
||||||
|
"font_style": null,
|
||||||
|
"font_weight": null
|
||||||
|
},
|
||||||
|
"selector.pseudo": {
|
||||||
|
"color": "#83a598ff",
|
||||||
|
"font_style": null,
|
||||||
|
"font_weight": null
|
||||||
|
},
|
||||||
"string": {
|
"string": {
|
||||||
"color": "#b8bb25ff",
|
"color": "#b8bb25ff",
|
||||||
"font_style": null,
|
"font_style": null,
|
||||||
@@ -1040,6 +1070,11 @@
|
|||||||
"font_style": null,
|
"font_style": null,
|
||||||
"font_weight": null
|
"font_weight": null
|
||||||
},
|
},
|
||||||
|
"namespace": {
|
||||||
|
"color": "#83a598ff",
|
||||||
|
"font_style": null,
|
||||||
|
"font_weight": null
|
||||||
|
},
|
||||||
"number": {
|
"number": {
|
||||||
"color": "#d3869bff",
|
"color": "#d3869bff",
|
||||||
"font_style": null,
|
"font_style": null,
|
||||||
@@ -1095,6 +1130,16 @@
|
|||||||
"font_style": null,
|
"font_style": null,
|
||||||
"font_weight": null
|
"font_weight": null
|
||||||
},
|
},
|
||||||
|
"selector": {
|
||||||
|
"color": "#fabd2eff",
|
||||||
|
"font_style": null,
|
||||||
|
"font_weight": null
|
||||||
|
},
|
||||||
|
"selector.pseudo": {
|
||||||
|
"color": "#83a598ff",
|
||||||
|
"font_style": null,
|
||||||
|
"font_weight": null
|
||||||
|
},
|
||||||
"string": {
|
"string": {
|
||||||
"color": "#b8bb25ff",
|
"color": "#b8bb25ff",
|
||||||
"font_style": null,
|
"font_style": null,
|
||||||
@@ -1227,9 +1272,9 @@
|
|||||||
"terminal.foreground": "#282828ff",
|
"terminal.foreground": "#282828ff",
|
||||||
"terminal.bright_foreground": "#282828ff",
|
"terminal.bright_foreground": "#282828ff",
|
||||||
"terminal.dim_foreground": "#fbf1c7ff",
|
"terminal.dim_foreground": "#fbf1c7ff",
|
||||||
"terminal.ansi.black": "#fbf1c7ff",
|
"terminal.ansi.black": "#282828ff",
|
||||||
"terminal.ansi.bright_black": "#b0a189ff",
|
"terminal.ansi.bright_black": "#0b6678ff",
|
||||||
"terminal.ansi.dim_black": "#282828ff",
|
"terminal.ansi.dim_black": "#5f5650ff",
|
||||||
"terminal.ansi.red": "#9d0308ff",
|
"terminal.ansi.red": "#9d0308ff",
|
||||||
"terminal.ansi.bright_red": "#db8b7aff",
|
"terminal.ansi.bright_red": "#db8b7aff",
|
||||||
"terminal.ansi.dim_red": "#4e1207ff",
|
"terminal.ansi.dim_red": "#4e1207ff",
|
||||||
@@ -1248,9 +1293,9 @@
|
|||||||
"terminal.ansi.cyan": "#437b59ff",
|
"terminal.ansi.cyan": "#437b59ff",
|
||||||
"terminal.ansi.bright_cyan": "#9fbca8ff",
|
"terminal.ansi.bright_cyan": "#9fbca8ff",
|
||||||
"terminal.ansi.dim_cyan": "#253e2eff",
|
"terminal.ansi.dim_cyan": "#253e2eff",
|
||||||
"terminal.ansi.white": "#282828ff",
|
"terminal.ansi.white": "#fbf1c7ff",
|
||||||
"terminal.ansi.bright_white": "#282828ff",
|
"terminal.ansi.bright_white": "#fbf1c7ff",
|
||||||
"terminal.ansi.dim_white": "#73675eff",
|
"terminal.ansi.dim_white": "#b0a189ff",
|
||||||
"link_text.hover": "#0b6678ff",
|
"link_text.hover": "#0b6678ff",
|
||||||
"version_control.added": "#797410ff",
|
"version_control.added": "#797410ff",
|
||||||
"version_control.modified": "#b57615ff",
|
"version_control.modified": "#b57615ff",
|
||||||
@@ -1425,6 +1470,11 @@
|
|||||||
"font_style": null,
|
"font_style": null,
|
||||||
"font_weight": null
|
"font_weight": null
|
||||||
},
|
},
|
||||||
|
"namespace": {
|
||||||
|
"color": "#066578ff",
|
||||||
|
"font_style": null,
|
||||||
|
"font_weight": null
|
||||||
|
},
|
||||||
"number": {
|
"number": {
|
||||||
"color": "#8f3e71ff",
|
"color": "#8f3e71ff",
|
||||||
"font_style": null,
|
"font_style": null,
|
||||||
@@ -1480,6 +1530,16 @@
|
|||||||
"font_style": null,
|
"font_style": null,
|
||||||
"font_weight": null
|
"font_weight": null
|
||||||
},
|
},
|
||||||
|
"selector": {
|
||||||
|
"color": "#b57613ff",
|
||||||
|
"font_style": null,
|
||||||
|
"font_weight": null
|
||||||
|
},
|
||||||
|
"selector.pseudo": {
|
||||||
|
"color": "#0b6678ff",
|
||||||
|
"font_style": null,
|
||||||
|
"font_weight": null
|
||||||
|
},
|
||||||
"string": {
|
"string": {
|
||||||
"color": "#79740eff",
|
"color": "#79740eff",
|
||||||
"font_style": null,
|
"font_style": null,
|
||||||
@@ -1612,9 +1672,9 @@
|
|||||||
"terminal.foreground": "#282828ff",
|
"terminal.foreground": "#282828ff",
|
||||||
"terminal.bright_foreground": "#282828ff",
|
"terminal.bright_foreground": "#282828ff",
|
||||||
"terminal.dim_foreground": "#f9f5d7ff",
|
"terminal.dim_foreground": "#f9f5d7ff",
|
||||||
"terminal.ansi.black": "#f9f5d7ff",
|
"terminal.ansi.black": "#282828ff",
|
||||||
"terminal.ansi.bright_black": "#b0a189ff",
|
"terminal.ansi.bright_black": "#73675eff",
|
||||||
"terminal.ansi.dim_black": "#282828ff",
|
"terminal.ansi.dim_black": "#f9f5d7ff",
|
||||||
"terminal.ansi.red": "#9d0308ff",
|
"terminal.ansi.red": "#9d0308ff",
|
||||||
"terminal.ansi.bright_red": "#db8b7aff",
|
"terminal.ansi.bright_red": "#db8b7aff",
|
||||||
"terminal.ansi.dim_red": "#4e1207ff",
|
"terminal.ansi.dim_red": "#4e1207ff",
|
||||||
@@ -1633,9 +1693,9 @@
|
|||||||
"terminal.ansi.cyan": "#437b59ff",
|
"terminal.ansi.cyan": "#437b59ff",
|
||||||
"terminal.ansi.bright_cyan": "#9fbca8ff",
|
"terminal.ansi.bright_cyan": "#9fbca8ff",
|
||||||
"terminal.ansi.dim_cyan": "#253e2eff",
|
"terminal.ansi.dim_cyan": "#253e2eff",
|
||||||
"terminal.ansi.white": "#282828ff",
|
"terminal.ansi.white": "#f9f5d7ff",
|
||||||
"terminal.ansi.bright_white": "#282828ff",
|
"terminal.ansi.bright_white": "#f9f5d7ff",
|
||||||
"terminal.ansi.dim_white": "#73675eff",
|
"terminal.ansi.dim_white": "#b0a189ff",
|
||||||
"link_text.hover": "#0b6678ff",
|
"link_text.hover": "#0b6678ff",
|
||||||
"version_control.added": "#797410ff",
|
"version_control.added": "#797410ff",
|
||||||
"version_control.modified": "#b57615ff",
|
"version_control.modified": "#b57615ff",
|
||||||
@@ -1810,6 +1870,11 @@
|
|||||||
"font_style": null,
|
"font_style": null,
|
||||||
"font_weight": null
|
"font_weight": null
|
||||||
},
|
},
|
||||||
|
"namespace": {
|
||||||
|
"color": "#066578ff",
|
||||||
|
"font_style": null,
|
||||||
|
"font_weight": null
|
||||||
|
},
|
||||||
"number": {
|
"number": {
|
||||||
"color": "#8f3e71ff",
|
"color": "#8f3e71ff",
|
||||||
"font_style": null,
|
"font_style": null,
|
||||||
@@ -1865,6 +1930,16 @@
|
|||||||
"font_style": null,
|
"font_style": null,
|
||||||
"font_weight": null
|
"font_weight": null
|
||||||
},
|
},
|
||||||
|
"selector": {
|
||||||
|
"color": "#b57613ff",
|
||||||
|
"font_style": null,
|
||||||
|
"font_weight": null
|
||||||
|
},
|
||||||
|
"selector.pseudo": {
|
||||||
|
"color": "#0b6678ff",
|
||||||
|
"font_style": null,
|
||||||
|
"font_weight": null
|
||||||
|
},
|
||||||
"string": {
|
"string": {
|
||||||
"color": "#79740eff",
|
"color": "#79740eff",
|
||||||
"font_style": null,
|
"font_style": null,
|
||||||
@@ -1997,9 +2072,9 @@
|
|||||||
"terminal.foreground": "#282828ff",
|
"terminal.foreground": "#282828ff",
|
||||||
"terminal.bright_foreground": "#282828ff",
|
"terminal.bright_foreground": "#282828ff",
|
||||||
"terminal.dim_foreground": "#f2e5bcff",
|
"terminal.dim_foreground": "#f2e5bcff",
|
||||||
"terminal.ansi.black": "#f2e5bcff",
|
"terminal.ansi.black": "#282828ff",
|
||||||
"terminal.ansi.bright_black": "#b0a189ff",
|
"terminal.ansi.bright_black": "#73675eff",
|
||||||
"terminal.ansi.dim_black": "#282828ff",
|
"terminal.ansi.dim_black": "#f2e5bcff",
|
||||||
"terminal.ansi.red": "#9d0308ff",
|
"terminal.ansi.red": "#9d0308ff",
|
||||||
"terminal.ansi.bright_red": "#db8b7aff",
|
"terminal.ansi.bright_red": "#db8b7aff",
|
||||||
"terminal.ansi.dim_red": "#4e1207ff",
|
"terminal.ansi.dim_red": "#4e1207ff",
|
||||||
@@ -2018,9 +2093,9 @@
|
|||||||
"terminal.ansi.cyan": "#437b59ff",
|
"terminal.ansi.cyan": "#437b59ff",
|
||||||
"terminal.ansi.bright_cyan": "#9fbca8ff",
|
"terminal.ansi.bright_cyan": "#9fbca8ff",
|
||||||
"terminal.ansi.dim_cyan": "#253e2eff",
|
"terminal.ansi.dim_cyan": "#253e2eff",
|
||||||
"terminal.ansi.white": "#282828ff",
|
"terminal.ansi.white": "#f2e5bcff",
|
||||||
"terminal.ansi.bright_white": "#282828ff",
|
"terminal.ansi.bright_white": "#f2e5bcff",
|
||||||
"terminal.ansi.dim_white": "#73675eff",
|
"terminal.ansi.dim_white": "#b0a189ff",
|
||||||
"link_text.hover": "#0b6678ff",
|
"link_text.hover": "#0b6678ff",
|
||||||
"version_control.added": "#797410ff",
|
"version_control.added": "#797410ff",
|
||||||
"version_control.modified": "#b57615ff",
|
"version_control.modified": "#b57615ff",
|
||||||
@@ -2195,6 +2270,11 @@
|
|||||||
"font_style": null,
|
"font_style": null,
|
||||||
"font_weight": null
|
"font_weight": null
|
||||||
},
|
},
|
||||||
|
"namespace": {
|
||||||
|
"color": "#066578ff",
|
||||||
|
"font_style": null,
|
||||||
|
"font_weight": null
|
||||||
|
},
|
||||||
"number": {
|
"number": {
|
||||||
"color": "#8f3e71ff",
|
"color": "#8f3e71ff",
|
||||||
"font_style": null,
|
"font_style": null,
|
||||||
@@ -2250,6 +2330,16 @@
|
|||||||
"font_style": null,
|
"font_style": null,
|
||||||
"font_weight": null
|
"font_weight": null
|
||||||
},
|
},
|
||||||
|
"selector": {
|
||||||
|
"color": "#b57613ff",
|
||||||
|
"font_style": null,
|
||||||
|
"font_weight": null
|
||||||
|
},
|
||||||
|
"selector.pseudo": {
|
||||||
|
"color": "#0b6678ff",
|
||||||
|
"font_style": null,
|
||||||
|
"font_weight": null
|
||||||
|
},
|
||||||
"string": {
|
"string": {
|
||||||
"color": "#79740eff",
|
"color": "#79740eff",
|
||||||
"font_style": null,
|
"font_style": null,
|
||||||
|
|||||||
@@ -264,6 +264,11 @@
|
|||||||
"font_style": null,
|
"font_style": null,
|
||||||
"font_weight": null
|
"font_weight": null
|
||||||
},
|
},
|
||||||
|
"namespace": {
|
||||||
|
"color": "#dce0e5ff",
|
||||||
|
"font_style": null,
|
||||||
|
"font_weight": null
|
||||||
|
},
|
||||||
"number": {
|
"number": {
|
||||||
"color": "#bf956aff",
|
"color": "#bf956aff",
|
||||||
"font_style": null,
|
"font_style": null,
|
||||||
@@ -319,6 +324,16 @@
|
|||||||
"font_style": null,
|
"font_style": null,
|
||||||
"font_weight": null
|
"font_weight": null
|
||||||
},
|
},
|
||||||
|
"selector": {
|
||||||
|
"color": "#dfc184ff",
|
||||||
|
"font_style": null,
|
||||||
|
"font_weight": null
|
||||||
|
},
|
||||||
|
"selector.pseudo": {
|
||||||
|
"color": "#74ade8ff",
|
||||||
|
"font_style": null,
|
||||||
|
"font_weight": null
|
||||||
|
},
|
||||||
"string": {
|
"string": {
|
||||||
"color": "#a1c181ff",
|
"color": "#a1c181ff",
|
||||||
"font_style": null,
|
"font_style": null,
|
||||||
@@ -450,9 +465,9 @@
|
|||||||
"terminal.foreground": "#242529ff",
|
"terminal.foreground": "#242529ff",
|
||||||
"terminal.bright_foreground": "#242529ff",
|
"terminal.bright_foreground": "#242529ff",
|
||||||
"terminal.dim_foreground": "#fafafaff",
|
"terminal.dim_foreground": "#fafafaff",
|
||||||
"terminal.ansi.black": "#fafafaff",
|
"terminal.ansi.black": "#242529ff",
|
||||||
"terminal.ansi.bright_black": "#aaaaaaff",
|
"terminal.ansi.bright_black": "#242529ff",
|
||||||
"terminal.ansi.dim_black": "#242529ff",
|
"terminal.ansi.dim_black": "#97979aff",
|
||||||
"terminal.ansi.red": "#d36151ff",
|
"terminal.ansi.red": "#d36151ff",
|
||||||
"terminal.ansi.bright_red": "#f0b0a4ff",
|
"terminal.ansi.bright_red": "#f0b0a4ff",
|
||||||
"terminal.ansi.dim_red": "#6f312aff",
|
"terminal.ansi.dim_red": "#6f312aff",
|
||||||
@@ -471,9 +486,9 @@
|
|||||||
"terminal.ansi.cyan": "#3a82b7ff",
|
"terminal.ansi.cyan": "#3a82b7ff",
|
||||||
"terminal.ansi.bright_cyan": "#a3bedaff",
|
"terminal.ansi.bright_cyan": "#a3bedaff",
|
||||||
"terminal.ansi.dim_cyan": "#254058ff",
|
"terminal.ansi.dim_cyan": "#254058ff",
|
||||||
"terminal.ansi.white": "#242529ff",
|
"terminal.ansi.white": "#fafafaff",
|
||||||
"terminal.ansi.bright_white": "#242529ff",
|
"terminal.ansi.bright_white": "#fafafaff",
|
||||||
"terminal.ansi.dim_white": "#97979aff",
|
"terminal.ansi.dim_white": "#aaaaaaff",
|
||||||
"link_text.hover": "#5c78e2ff",
|
"link_text.hover": "#5c78e2ff",
|
||||||
"version_control.added": "#27a657ff",
|
"version_control.added": "#27a657ff",
|
||||||
"version_control.modified": "#d3b020ff",
|
"version_control.modified": "#d3b020ff",
|
||||||
@@ -643,6 +658,11 @@
|
|||||||
"font_style": null,
|
"font_style": null,
|
||||||
"font_weight": null
|
"font_weight": null
|
||||||
},
|
},
|
||||||
|
"namespace": {
|
||||||
|
"color": "#242529ff",
|
||||||
|
"font_style": null,
|
||||||
|
"font_weight": null
|
||||||
|
},
|
||||||
"number": {
|
"number": {
|
||||||
"color": "#ad6e25ff",
|
"color": "#ad6e25ff",
|
||||||
"font_style": null,
|
"font_style": null,
|
||||||
@@ -698,6 +718,16 @@
|
|||||||
"font_style": null,
|
"font_style": null,
|
||||||
"font_weight": null
|
"font_weight": null
|
||||||
},
|
},
|
||||||
|
"selector": {
|
||||||
|
"color": "#669f59ff",
|
||||||
|
"font_style": null,
|
||||||
|
"font_weight": null
|
||||||
|
},
|
||||||
|
"selector.pseudo": {
|
||||||
|
"color": "#5c78e2ff",
|
||||||
|
"font_style": null,
|
||||||
|
"font_weight": null
|
||||||
|
},
|
||||||
"string": {
|
"string": {
|
||||||
"color": "#649f57ff",
|
"color": "#649f57ff",
|
||||||
"font_style": null,
|
"font_style": null,
|
||||||
|
|||||||
@@ -24,8 +24,9 @@ project.workspace = true
|
|||||||
smallvec.workspace = true
|
smallvec.workspace = true
|
||||||
ui.workspace = true
|
ui.workspace = true
|
||||||
util.workspace = true
|
util.workspace = true
|
||||||
workspace.workspace = true
|
|
||||||
workspace-hack.workspace = true
|
workspace-hack.workspace = true
|
||||||
|
workspace.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};
|
use auto_update::{AutoUpdateStatus, AutoUpdater, DismissErrorMessage, VersionCheckType};
|
||||||
use editor::Editor;
|
use editor::Editor;
|
||||||
use extension_host::ExtensionStore;
|
use extension_host::ExtensionStore;
|
||||||
use futures::StreamExt;
|
use futures::StreamExt;
|
||||||
@@ -60,6 +60,7 @@ 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 {
|
||||||
@@ -262,6 +263,7 @@ 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.
|
||||||
@@ -305,6 +307,32 @@ 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,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -332,6 +360,7 @@ impl ActivityIndicator {
|
|||||||
),
|
),
|
||||||
message: job_info.message.into(),
|
message: job_info.message.into(),
|
||||||
on_click: None,
|
on_click: None,
|
||||||
|
tooltip_message: None,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -374,6 +403,7 @@ 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,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -402,6 +432,7 @@ 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,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -428,6 +459,7 @@ 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,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -446,6 +478,7 @@ impl ActivityIndicator {
|
|||||||
});
|
});
|
||||||
window.dispatch_action(Box::new(workspace::OpenLog), cx);
|
window.dispatch_action(Box::new(workspace::OpenLog), cx);
|
||||||
})),
|
})),
|
||||||
|
tooltip_message: None,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -462,8 +495,9 @@ 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 => Some(Content {
|
AutoUpdateStatus::Downloading { version } => Some(Content {
|
||||||
icon: Some(
|
icon: Some(
|
||||||
Icon::new(IconName::Download)
|
Icon::new(IconName::Download)
|
||||||
.size(IconSize::Small)
|
.size(IconSize::Small)
|
||||||
@@ -473,8 +507,9 @@ 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 => Some(Content {
|
AutoUpdateStatus::Installing { version } => Some(Content {
|
||||||
icon: Some(
|
icon: Some(
|
||||||
Icon::new(IconName::Download)
|
Icon::new(IconName::Download)
|
||||||
.size(IconSize::Small)
|
.size(IconSize::Small)
|
||||||
@@ -484,8 +519,12 @@ 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 { binary_path, .. } => Some(Content {
|
AutoUpdateStatus::Updated {
|
||||||
|
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({
|
||||||
@@ -494,6 +533,7 @@ 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(
|
||||||
@@ -505,6 +545,7 @@ 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,
|
||||||
};
|
};
|
||||||
@@ -524,6 +565,7 @@ 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,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -531,6 +573,17 @@ 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,
|
||||||
@@ -575,7 +628,14 @@ impl Render for ActivityIndicator {
|
|||||||
)
|
)
|
||||||
.tooltip(Tooltip::text(content.message))
|
.tooltip(Tooltip::text(content.message))
|
||||||
} else {
|
} else {
|
||||||
button.child(Label::new(content.message).size(LabelSize::Small))
|
button
|
||||||
|
.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| {
|
||||||
@@ -655,3 +715,26 @@ 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,13 +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
|
audio.workspace = true
|
||||||
buffer_diff.workspace = true
|
buffer_diff.workspace = true
|
||||||
chrono.workspace = true
|
chrono.workspace = true
|
||||||
client.workspace = true
|
client.workspace = true
|
||||||
@@ -45,6 +45,7 @@ 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
|
inventory.workspace = true
|
||||||
@@ -52,7 +53,6 @@ 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
|
|
||||||
log.workspace = true
|
log.workspace = true
|
||||||
lsp.workspace = true
|
lsp.workspace = true
|
||||||
markdown.workspace = true
|
markdown.workspace = true
|
||||||
@@ -77,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
|
||||||
@@ -94,12 +94,15 @@ ui_input.workspace = true
|
|||||||
urlencoding.workspace = true
|
urlencoding.workspace = true
|
||||||
util.workspace = true
|
util.workspace = true
|
||||||
uuid.workspace = true
|
uuid.workspace = true
|
||||||
|
watch.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
|
zed_llm_client.workspace = true
|
||||||
|
zstd.workspace = true
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
|
assistant_tools.workspace = true
|
||||||
buffer_diff = { workspace = true, features = ["test-support"] }
|
buffer_diff = { workspace = true, features = ["test-support"] }
|
||||||
editor = { workspace = true, features = ["test-support"] }
|
editor = { workspace = true, features = ["test-support"] }
|
||||||
gpui = { workspace = true, "features" = ["test-support"] }
|
gpui = { workspace = true, "features" = ["test-support"] }
|
||||||
|
|||||||
@@ -1,9 +1,8 @@
|
|||||||
use crate::AgentPanel;
|
|
||||||
use crate::context::{AgentContextHandle, RULES_ICON};
|
use crate::context::{AgentContextHandle, RULES_ICON};
|
||||||
use crate::context_picker::{ContextPicker, MentionLink};
|
use crate::context_picker::{ContextPicker, MentionLink};
|
||||||
use crate::context_store::ContextStore;
|
use crate::context_store::ContextStore;
|
||||||
use crate::context_strip::{ContextStrip, ContextStripEvent, SuggestContextKind};
|
use crate::context_strip::{ContextStrip, ContextStripEvent, SuggestContextKind};
|
||||||
use crate::message_editor::insert_message_creases;
|
use crate::message_editor::{extract_message_creases, insert_message_creases};
|
||||||
use crate::thread::{
|
use crate::thread::{
|
||||||
LastRestoreCheckpoint, MessageCrease, MessageId, MessageSegment, Thread, ThreadError,
|
LastRestoreCheckpoint, MessageCrease, MessageId, MessageSegment, Thread, ThreadError,
|
||||||
ThreadEvent, ThreadFeedback, ThreadSummary,
|
ThreadEvent, ThreadFeedback, ThreadSummary,
|
||||||
@@ -13,9 +12,11 @@ use crate::tool_use::{PendingToolUseStatus, ToolUse};
|
|||||||
use crate::ui::{
|
use crate::ui::{
|
||||||
AddedContext, AgentNotification, AgentNotificationEvent, AnimatedLabel, ContextPill,
|
AddedContext, AgentNotification, AgentNotificationEvent, AnimatedLabel, ContextPill,
|
||||||
};
|
};
|
||||||
|
use crate::{AgentPanel, ModelUsageContext};
|
||||||
|
use agent_settings::{AgentSettings, NotifyWhenAgentWaiting};
|
||||||
use anyhow::Context as _;
|
use anyhow::Context as _;
|
||||||
use assistant_settings::{AssistantSettings, NotifyWhenAgentWaiting};
|
|
||||||
use assistant_tool::ToolUseStatus;
|
use assistant_tool::ToolUseStatus;
|
||||||
|
use audio::{Audio, Sound};
|
||||||
use collections::{HashMap, HashSet};
|
use collections::{HashMap, HashSet};
|
||||||
use editor::actions::{MoveUp, Paste};
|
use editor::actions::{MoveUp, Paste};
|
||||||
use editor::scroll::Autoscroll;
|
use editor::scroll::Autoscroll;
|
||||||
@@ -52,8 +53,9 @@ use ui::{
|
|||||||
};
|
};
|
||||||
use util::ResultExt as _;
|
use util::ResultExt as _;
|
||||||
use util::markdown::MarkdownCodeBlock;
|
use util::markdown::MarkdownCodeBlock;
|
||||||
use workspace::Workspace;
|
use workspace::{CollaboratorId, Workspace};
|
||||||
use zed_actions::assistant::OpenRulesLibrary;
|
use zed_actions::assistant::OpenRulesLibrary;
|
||||||
|
use zed_llm_client::CompletionIntent;
|
||||||
|
|
||||||
pub struct ActiveThread {
|
pub struct ActiveThread {
|
||||||
context_store: Entity<ContextStore>,
|
context_store: Entity<ContextStore>,
|
||||||
@@ -971,7 +973,22 @@ impl ActiveThread {
|
|||||||
ThreadEvent::ShowError(error) => {
|
ThreadEvent::ShowError(error) => {
|
||||||
self.last_error = Some(error.clone());
|
self.last_error = Some(error.clone());
|
||||||
}
|
}
|
||||||
ThreadEvent::NewRequest | ThreadEvent::CompletionCanceled => {
|
ThreadEvent::NewRequest => {
|
||||||
|
cx.notify();
|
||||||
|
}
|
||||||
|
ThreadEvent::CompletionCanceled => {
|
||||||
|
self.thread.update(cx, |thread, cx| {
|
||||||
|
thread.project().update(cx, |project, cx| {
|
||||||
|
project.set_agent_location(None, cx);
|
||||||
|
})
|
||||||
|
});
|
||||||
|
self.workspace
|
||||||
|
.update(cx, |workspace, cx| {
|
||||||
|
if workspace.is_being_followed(CollaboratorId::Agent) {
|
||||||
|
workspace.unfollow(CollaboratorId::Agent, window, cx);
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.ok();
|
||||||
cx.notify();
|
cx.notify();
|
||||||
}
|
}
|
||||||
ThreadEvent::StreamedCompletion
|
ThreadEvent::StreamedCompletion
|
||||||
@@ -981,9 +998,10 @@ impl ActiveThread {
|
|||||||
}
|
}
|
||||||
ThreadEvent::Stopped(reason) => match reason {
|
ThreadEvent::Stopped(reason) => match reason {
|
||||||
Ok(StopReason::EndTurn | StopReason::MaxTokens) => {
|
Ok(StopReason::EndTurn | StopReason::MaxTokens) => {
|
||||||
let thread = self.thread.read(cx);
|
let used_tools = self.thread.read(cx).used_tools_since_last_user_message();
|
||||||
|
self.play_notification_sound(window, cx);
|
||||||
self.show_notification(
|
self.show_notification(
|
||||||
if thread.used_tools_since_last_user_message() {
|
if used_tools {
|
||||||
"Finished running tools"
|
"Finished running tools"
|
||||||
} else {
|
} else {
|
||||||
"New message"
|
"New message"
|
||||||
@@ -996,8 +1014,18 @@ impl ActiveThread {
|
|||||||
_ => {}
|
_ => {}
|
||||||
},
|
},
|
||||||
ThreadEvent::ToolConfirmationNeeded => {
|
ThreadEvent::ToolConfirmationNeeded => {
|
||||||
|
self.play_notification_sound(window, cx);
|
||||||
self.show_notification("Waiting for tool confirmation", IconName::Info, window, cx);
|
self.show_notification("Waiting for tool confirmation", IconName::Info, window, cx);
|
||||||
}
|
}
|
||||||
|
ThreadEvent::ToolUseLimitReached => {
|
||||||
|
self.play_notification_sound(window, cx);
|
||||||
|
self.show_notification(
|
||||||
|
"Consecutive tool use limit reached.",
|
||||||
|
IconName::Warning,
|
||||||
|
window,
|
||||||
|
cx,
|
||||||
|
);
|
||||||
|
}
|
||||||
ThreadEvent::StreamedAssistantText(message_id, text) => {
|
ThreadEvent::StreamedAssistantText(message_id, text) => {
|
||||||
if let Some(rendered_message) = self.rendered_messages_by_id.get_mut(&message_id) {
|
if let Some(rendered_message) = self.rendered_messages_by_id.get_mut(&message_id) {
|
||||||
rendered_message.append_text(text, cx);
|
rendered_message.append_text(text, cx);
|
||||||
@@ -1018,7 +1046,6 @@ impl ActiveThread {
|
|||||||
self.push_message(message_id, &message_segments, window, cx);
|
self.push_message(message_id, &message_segments, window, cx);
|
||||||
}
|
}
|
||||||
|
|
||||||
self.scroll_to_bottom(cx);
|
|
||||||
self.save_thread(cx);
|
self.save_thread(cx);
|
||||||
cx.notify();
|
cx.notify();
|
||||||
}
|
}
|
||||||
@@ -1117,6 +1144,10 @@ impl ActiveThread {
|
|||||||
cx,
|
cx,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
ThreadEvent::ProfileChanged => {
|
||||||
|
self.save_thread(cx);
|
||||||
|
cx.notify();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1133,6 +1164,13 @@ impl ActiveThread {
|
|||||||
cx.notify();
|
cx.notify();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn play_notification_sound(&self, window: &Window, cx: &mut App) {
|
||||||
|
let settings = AgentSettings::get_global(cx);
|
||||||
|
if settings.play_sound_when_agent_done && !window.is_window_active() {
|
||||||
|
Audio::play_sound(Sound::AgentDone, cx);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fn show_notification(
|
fn show_notification(
|
||||||
&mut self,
|
&mut self,
|
||||||
caption: impl Into<SharedString>,
|
caption: impl Into<SharedString>,
|
||||||
@@ -1146,7 +1184,7 @@ impl ActiveThread {
|
|||||||
|
|
||||||
let title = self.thread.read(cx).summary().unwrap_or("Agent Panel");
|
let title = self.thread.read(cx).summary().unwrap_or("Agent Panel");
|
||||||
|
|
||||||
match AssistantSettings::get_global(cx).notify_when_agent_waiting {
|
match AgentSettings::get_global(cx).notify_when_agent_waiting {
|
||||||
NotifyWhenAgentWaiting::PrimaryScreen => {
|
NotifyWhenAgentWaiting::PrimaryScreen => {
|
||||||
if let Some(primary) = cx.primary_display() {
|
if let Some(primary) = cx.primary_display() {
|
||||||
self.pop_up(icon, caption.into(), title.clone(), window, primary, cx);
|
self.pop_up(icon, caption.into(), title.clone(), window, primary, cx);
|
||||||
@@ -1314,6 +1352,7 @@ impl ActiveThread {
|
|||||||
Some(self.text_thread_store.downgrade()),
|
Some(self.text_thread_store.downgrade()),
|
||||||
context_picker_menu_handle.clone(),
|
context_picker_menu_handle.clone(),
|
||||||
SuggestContextKind::File,
|
SuggestContextKind::File,
|
||||||
|
ModelUsageContext::Thread(self.thread.clone()),
|
||||||
window,
|
window,
|
||||||
cx,
|
cx,
|
||||||
)
|
)
|
||||||
@@ -1412,12 +1451,13 @@ impl ActiveThread {
|
|||||||
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: AssistantSettings::temperature_for_model(
|
temperature: AgentSettings::temperature_for_model(
|
||||||
&configured_model.model,
|
&configured_model.model,
|
||||||
cx,
|
cx,
|
||||||
),
|
),
|
||||||
@@ -1467,7 +1507,7 @@ impl ActiveThread {
|
|||||||
_window: &mut Window,
|
_window: &mut Window,
|
||||||
cx: &mut Context<Self>,
|
cx: &mut Context<Self>,
|
||||||
) {
|
) {
|
||||||
self.context_store.update(cx, |store, _cx| store.clear());
|
self.context_store.update(cx, |store, cx| store.clear(cx));
|
||||||
cx.notify();
|
cx.notify();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1482,36 +1522,25 @@ impl ActiveThread {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn paste(&mut self, _: &Paste, _window: &mut Window, cx: &mut Context<Self>) {
|
fn paste(&mut self, _: &Paste, _window: &mut Window, cx: &mut Context<Self>) {
|
||||||
let images = cx
|
attach_pasted_images_as_context(&self.context_store, 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 cancel_editing_message(&mut self, _: &menu::Cancel, _: &mut Window, cx: &mut Context<Self>) {
|
fn cancel_editing_message(
|
||||||
|
&mut self,
|
||||||
|
_: &menu::Cancel,
|
||||||
|
window: &mut Window,
|
||||||
|
cx: &mut Context<Self>,
|
||||||
|
) {
|
||||||
self.editing_message.take();
|
self.editing_message.take();
|
||||||
cx.notify();
|
cx.notify();
|
||||||
|
|
||||||
|
if let Some(workspace) = self.workspace.upgrade() {
|
||||||
|
workspace.update(cx, |workspace, cx| {
|
||||||
|
if let Some(panel) = workspace.panel::<AgentPanel>(cx) {
|
||||||
|
panel.focus_handle(cx).focus(window);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn confirm_editing_message(
|
fn confirm_editing_message(
|
||||||
@@ -1538,6 +1567,8 @@ impl ActiveThread {
|
|||||||
|
|
||||||
let edited_text = state.editor.read(cx).text(cx);
|
let edited_text = state.editor.read(cx).text(cx);
|
||||||
|
|
||||||
|
let creases = state.editor.update(cx, extract_message_creases);
|
||||||
|
|
||||||
let new_context = self
|
let new_context = self
|
||||||
.context_store
|
.context_store
|
||||||
.read(cx)
|
.read(cx)
|
||||||
@@ -1562,6 +1593,7 @@ impl ActiveThread {
|
|||||||
message_id,
|
message_id,
|
||||||
Role::User,
|
Role::User,
|
||||||
vec![MessageSegment::Text(edited_text)],
|
vec![MessageSegment::Text(edited_text)],
|
||||||
|
creases,
|
||||||
Some(context.loaded_context),
|
Some(context.loaded_context),
|
||||||
checkpoint.ok(),
|
checkpoint.ok(),
|
||||||
cx,
|
cx,
|
||||||
@@ -1573,7 +1605,12 @@ impl ActiveThread {
|
|||||||
|
|
||||||
this.thread.update(cx, |thread, cx| {
|
this.thread.update(cx, |thread, cx| {
|
||||||
thread.advance_prompt_id();
|
thread.advance_prompt_id();
|
||||||
thread.send_to_model(model.model, Some(window.window_handle()), cx);
|
thread.send_to_model(
|
||||||
|
model.model,
|
||||||
|
CompletionIntent::UserPrompt,
|
||||||
|
Some(window.window_handle()),
|
||||||
|
cx,
|
||||||
|
);
|
||||||
});
|
});
|
||||||
this._load_edited_message_context_task = None;
|
this._load_edited_message_context_task = None;
|
||||||
cx.notify();
|
cx.notify();
|
||||||
@@ -1754,6 +1791,11 @@ impl ActiveThread {
|
|||||||
let Some(message) = self.thread.read(cx).message(message_id) else {
|
let Some(message) = self.thread.read(cx).message(message_id) else {
|
||||||
return Empty.into_any();
|
return Empty.into_any();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
if message.is_hidden {
|
||||||
|
return Empty.into_any();
|
||||||
|
}
|
||||||
|
|
||||||
let message_creases = message.creases.clone();
|
let message_creases = message.creases.clone();
|
||||||
|
|
||||||
let Some(rendered_message) = self.rendered_messages_by_id.get(&message_id) else {
|
let Some(rendered_message) = self.rendered_messages_by_id.get(&message_id) else {
|
||||||
@@ -1765,9 +1807,10 @@ impl ActiveThread {
|
|||||||
|
|
||||||
// Get all the data we need from thread before we start using it in closures
|
// Get all the data we need from thread before we start using it in closures
|
||||||
let checkpoint = thread.checkpoint_for_message(message_id);
|
let checkpoint = thread.checkpoint_for_message(message_id);
|
||||||
|
let configured_model = thread.configured_model().map(|m| m.model);
|
||||||
let added_context = thread
|
let added_context = thread
|
||||||
.context_for_message(message_id)
|
.context_for_message(message_id)
|
||||||
.map(|context| AddedContext::new_attached(context, cx))
|
.map(|context| AddedContext::new_attached(context, configured_model.as_ref(), cx))
|
||||||
.collect::<Vec<_>>();
|
.collect::<Vec<_>>();
|
||||||
|
|
||||||
let tool_uses = thread.tool_uses_for_message(message_id, cx);
|
let tool_uses = thread.tool_uses_for_message(message_id, cx);
|
||||||
@@ -1789,6 +1832,7 @@ impl ActiveThread {
|
|||||||
|
|
||||||
let colors = cx.theme().colors();
|
let colors = cx.theme().colors();
|
||||||
let editor_bg_color = colors.editor_background;
|
let editor_bg_color = colors.editor_background;
|
||||||
|
let panel_bg = colors.panel_background;
|
||||||
|
|
||||||
let open_as_markdown = IconButton::new(("open-as-markdown", ix), IconName::DocumentText)
|
let open_as_markdown = IconButton::new(("open-as-markdown", ix), IconName::DocumentText)
|
||||||
.icon_size(IconSize::XSmall)
|
.icon_size(IconSize::XSmall)
|
||||||
@@ -1809,7 +1853,6 @@ impl ActiveThread {
|
|||||||
const RESPONSE_PADDING_X: Pixels = px(19.);
|
const RESPONSE_PADDING_X: Pixels = px(19.);
|
||||||
|
|
||||||
let show_feedback = thread.is_turn_end(ix);
|
let show_feedback = thread.is_turn_end(ix);
|
||||||
|
|
||||||
let feedback_container = h_flex()
|
let feedback_container = h_flex()
|
||||||
.group("feedback_container")
|
.group("feedback_container")
|
||||||
.mt_1()
|
.mt_1()
|
||||||
@@ -1874,7 +1917,7 @@ impl ActiveThread {
|
|||||||
.child(open_as_markdown),
|
.child(open_as_markdown),
|
||||||
)
|
)
|
||||||
.into_any_element(),
|
.into_any_element(),
|
||||||
None if AssistantSettings::get_global(cx).enable_feedback =>
|
None if AgentSettings::get_global(cx).enable_feedback =>
|
||||||
feedback_container
|
feedback_container
|
||||||
.child(
|
.child(
|
||||||
div().visible_on_hover("feedback_container").child(
|
div().visible_on_hover("feedback_container").child(
|
||||||
@@ -1982,65 +2025,89 @@ impl ActiveThread {
|
|||||||
.border_1()
|
.border_1()
|
||||||
.border_color(colors.border)
|
.border_color(colors.border)
|
||||||
.hover(|hover| hover.border_color(colors.text_accent.opacity(0.5)))
|
.hover(|hover| hover.border_color(colors.text_accent.opacity(0.5)))
|
||||||
.cursor_pointer()
|
|
||||||
.child(
|
.child(
|
||||||
h_flex()
|
v_flex()
|
||||||
.p_2p5()
|
.p_2p5()
|
||||||
.gap_1()
|
.gap_1()
|
||||||
.items_end()
|
|
||||||
.children(message_content)
|
.children(message_content)
|
||||||
.when_some(editing_message_state, |this, state| {
|
.when_some(editing_message_state, |this, state| {
|
||||||
let focus_handle = state.editor.focus_handle(cx).clone();
|
let focus_handle = state.editor.focus_handle(cx).clone();
|
||||||
this.w_full().justify_between().child(
|
|
||||||
|
this.child(
|
||||||
h_flex()
|
h_flex()
|
||||||
.gap_0p5()
|
.w_full()
|
||||||
|
.gap_1()
|
||||||
|
.justify_between()
|
||||||
|
.flex_wrap()
|
||||||
.child(
|
.child(
|
||||||
IconButton::new(
|
h_flex()
|
||||||
"cancel-edit-message",
|
.gap_1p5()
|
||||||
IconName::Close,
|
.child(
|
||||||
)
|
div()
|
||||||
.shape(ui::IconButtonShape::Square)
|
.opacity(0.8)
|
||||||
.icon_color(Color::Error)
|
.child(
|
||||||
.icon_size(IconSize::Small)
|
Icon::new(IconName::Warning)
|
||||||
.tooltip({
|
.size(IconSize::Indicator)
|
||||||
let focus_handle = focus_handle.clone();
|
.color(Color::Warning)
|
||||||
move |window, cx| {
|
),
|
||||||
Tooltip::for_action_in(
|
)
|
||||||
"Cancel Edit",
|
.child(
|
||||||
&menu::Cancel,
|
Label::new("Editing will restart the thread from this point.")
|
||||||
&focus_handle,
|
.color(Color::Muted)
|
||||||
window,
|
.size(LabelSize::XSmall),
|
||||||
cx,
|
),
|
||||||
)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
.on_click(cx.listener(Self::handle_cancel_click)),
|
|
||||||
)
|
)
|
||||||
.child(
|
.child(
|
||||||
IconButton::new(
|
h_flex()
|
||||||
"confirm-edit-message",
|
.gap_0p5()
|
||||||
IconName::Return,
|
.child(
|
||||||
)
|
IconButton::new(
|
||||||
.disabled(state.editor.read(cx).is_empty(cx))
|
"cancel-edit-message",
|
||||||
.shape(ui::IconButtonShape::Square)
|
IconName::Close,
|
||||||
.icon_color(Color::Muted)
|
|
||||||
.icon_size(IconSize::Small)
|
|
||||||
.tooltip({
|
|
||||||
let focus_handle = focus_handle.clone();
|
|
||||||
move |window, cx| {
|
|
||||||
Tooltip::for_action_in(
|
|
||||||
"Regenerate",
|
|
||||||
&menu::Confirm,
|
|
||||||
&focus_handle,
|
|
||||||
window,
|
|
||||||
cx,
|
|
||||||
)
|
)
|
||||||
}
|
.shape(ui::IconButtonShape::Square)
|
||||||
})
|
.icon_color(Color::Error)
|
||||||
.on_click(
|
.icon_size(IconSize::Small)
|
||||||
cx.listener(Self::handle_regenerate_click),
|
.tooltip({
|
||||||
),
|
let focus_handle = focus_handle.clone();
|
||||||
),
|
move |window, cx| {
|
||||||
|
Tooltip::for_action_in(
|
||||||
|
"Cancel Edit",
|
||||||
|
&menu::Cancel,
|
||||||
|
&focus_handle,
|
||||||
|
window,
|
||||||
|
cx,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.on_click(cx.listener(Self::handle_cancel_click)),
|
||||||
|
)
|
||||||
|
.child(
|
||||||
|
IconButton::new(
|
||||||
|
"confirm-edit-message",
|
||||||
|
IconName::Return,
|
||||||
|
)
|
||||||
|
.disabled(state.editor.read(cx).is_empty(cx))
|
||||||
|
.shape(ui::IconButtonShape::Square)
|
||||||
|
.icon_color(Color::Muted)
|
||||||
|
.icon_size(IconSize::Small)
|
||||||
|
.tooltip({
|
||||||
|
let focus_handle = focus_handle.clone();
|
||||||
|
move |window, cx| {
|
||||||
|
Tooltip::for_action_in(
|
||||||
|
"Regenerate",
|
||||||
|
&menu::Confirm,
|
||||||
|
&focus_handle,
|
||||||
|
window,
|
||||||
|
cx,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.on_click(
|
||||||
|
cx.listener(Self::handle_regenerate_click),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
)
|
||||||
)
|
)
|
||||||
}),
|
}),
|
||||||
)
|
)
|
||||||
@@ -2082,16 +2149,14 @@ impl ActiveThread {
|
|||||||
message_id > *editing_message_id
|
message_id > *editing_message_id
|
||||||
});
|
});
|
||||||
|
|
||||||
let panel_background = cx.theme().colors().panel_background;
|
|
||||||
|
|
||||||
let backdrop = div()
|
let backdrop = div()
|
||||||
.id("backdrop")
|
.id(("backdrop", ix))
|
||||||
.stop_mouse_events_except_scroll()
|
.size_full()
|
||||||
.absolute()
|
.absolute()
|
||||||
.inset_0()
|
.inset_0()
|
||||||
.size_full()
|
.bg(panel_bg)
|
||||||
.bg(panel_background)
|
|
||||||
.opacity(0.8)
|
.opacity(0.8)
|
||||||
|
.block_mouse_except_scroll()
|
||||||
.on_click(cx.listener(Self::handle_cancel_click));
|
.on_click(cx.listener(Self::handle_cancel_click));
|
||||||
|
|
||||||
v_flex()
|
v_flex()
|
||||||
@@ -3054,7 +3119,7 @@ impl ActiveThread {
|
|||||||
.on_click(cx.listener(
|
.on_click(cx.listener(
|
||||||
move |this, event, window, cx| {
|
move |this, event, window, cx| {
|
||||||
if let Some(fs) = fs.clone() {
|
if let Some(fs) = fs.clone() {
|
||||||
update_settings_file::<AssistantSettings>(
|
update_settings_file::<AgentSettings>(
|
||||||
fs.clone(),
|
fs.clone(),
|
||||||
cx,
|
cx,
|
||||||
|settings, _| {
|
|settings, _| {
|
||||||
@@ -3568,6 +3633,38 @@ pub(crate) fn open_context(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub(crate) fn attach_pasted_images_as_context(
|
||||||
|
context_store: &Entity<ContextStore>,
|
||||||
|
cx: &mut App,
|
||||||
|
) -> bool {
|
||||||
|
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 false;
|
||||||
|
}
|
||||||
|
cx.stop_propagation();
|
||||||
|
|
||||||
|
context_store.update(cx, |store, cx| {
|
||||||
|
for image in images {
|
||||||
|
store.add_image_instance(Arc::new(image), cx);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
true
|
||||||
|
}
|
||||||
|
|
||||||
fn open_editor_at_position(
|
fn open_editor_at_position(
|
||||||
project_path: project::ProjectPath,
|
project_path: project::ProjectPath,
|
||||||
target_position: Point,
|
target_position: Point,
|
||||||
@@ -3593,3 +3690,248 @@ fn open_editor_at_position(
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
|
mod tests {
|
||||||
|
use assistant_tool::{ToolRegistry, ToolWorkingSet};
|
||||||
|
use editor::{EditorSettings, display_map::CreaseMetadata};
|
||||||
|
use fs::FakeFs;
|
||||||
|
use gpui::{AppContext, TestAppContext, VisualTestContext};
|
||||||
|
use language_model::{
|
||||||
|
ConfiguredModel, LanguageModel, LanguageModelRegistry,
|
||||||
|
fake_provider::{FakeLanguageModel, FakeLanguageModelProvider},
|
||||||
|
};
|
||||||
|
use project::Project;
|
||||||
|
use prompt_store::PromptBuilder;
|
||||||
|
use serde_json::json;
|
||||||
|
use settings::SettingsStore;
|
||||||
|
use util::path;
|
||||||
|
use workspace::CollaboratorId;
|
||||||
|
|
||||||
|
use crate::{ContextLoadResult, thread_store};
|
||||||
|
|
||||||
|
use super::*;
|
||||||
|
|
||||||
|
#[gpui::test]
|
||||||
|
async fn test_agent_is_unfollowed_after_cancelling_completion(cx: &mut TestAppContext) {
|
||||||
|
init_test_settings(cx);
|
||||||
|
|
||||||
|
let project = create_test_project(
|
||||||
|
cx,
|
||||||
|
json!({"code.rs": "fn main() {\n println!(\"Hello, world!\");\n}"}),
|
||||||
|
)
|
||||||
|
.await;
|
||||||
|
|
||||||
|
let (cx, _active_thread, workspace, thread, model) =
|
||||||
|
setup_test_environment(cx, project.clone()).await;
|
||||||
|
|
||||||
|
// Insert user message without any context (empty context vector)
|
||||||
|
thread.update(cx, |thread, cx| {
|
||||||
|
thread.insert_user_message(
|
||||||
|
"What is the best way to learn Rust?",
|
||||||
|
ContextLoadResult::default(),
|
||||||
|
None,
|
||||||
|
vec![],
|
||||||
|
cx,
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
// Stream response to user message
|
||||||
|
thread.update(cx, |thread, cx| {
|
||||||
|
let request =
|
||||||
|
thread.to_completion_request(model.clone(), CompletionIntent::UserPrompt, cx);
|
||||||
|
thread.stream_completion(request, model, cx.active_window(), cx)
|
||||||
|
});
|
||||||
|
// Follow the agent
|
||||||
|
cx.update(|window, cx| {
|
||||||
|
workspace.update(cx, |workspace, cx| {
|
||||||
|
workspace.follow(CollaboratorId::Agent, window, cx);
|
||||||
|
})
|
||||||
|
});
|
||||||
|
assert!(cx.read(|cx| workspace.read(cx).is_being_followed(CollaboratorId::Agent)));
|
||||||
|
|
||||||
|
// Cancel the current completion
|
||||||
|
thread.update(cx, |thread, cx| {
|
||||||
|
thread.cancel_last_completion(cx.active_window(), cx)
|
||||||
|
});
|
||||||
|
|
||||||
|
cx.executor().run_until_parked();
|
||||||
|
|
||||||
|
// No longer following the agent
|
||||||
|
assert!(!cx.read(|cx| workspace.read(cx).is_being_followed(CollaboratorId::Agent)));
|
||||||
|
}
|
||||||
|
|
||||||
|
#[gpui::test]
|
||||||
|
async fn test_reinserting_creases_for_edited_message(cx: &mut TestAppContext) {
|
||||||
|
init_test_settings(cx);
|
||||||
|
|
||||||
|
let project = create_test_project(cx, json!({})).await;
|
||||||
|
|
||||||
|
let (cx, active_thread, _, thread, model) =
|
||||||
|
setup_test_environment(cx, project.clone()).await;
|
||||||
|
cx.update(|_, cx| {
|
||||||
|
LanguageModelRegistry::global(cx).update(cx, |registry, cx| {
|
||||||
|
registry.set_default_model(
|
||||||
|
Some(ConfiguredModel {
|
||||||
|
provider: Arc::new(FakeLanguageModelProvider),
|
||||||
|
model,
|
||||||
|
}),
|
||||||
|
cx,
|
||||||
|
);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
let creases = vec![MessageCrease {
|
||||||
|
range: 14..22,
|
||||||
|
metadata: CreaseMetadata {
|
||||||
|
icon_path: "icon".into(),
|
||||||
|
label: "foo.txt".into(),
|
||||||
|
},
|
||||||
|
context: None,
|
||||||
|
}];
|
||||||
|
|
||||||
|
let message = thread.update(cx, |thread, cx| {
|
||||||
|
let message_id = thread.insert_user_message(
|
||||||
|
"Tell me about @foo.txt",
|
||||||
|
ContextLoadResult::default(),
|
||||||
|
None,
|
||||||
|
creases,
|
||||||
|
cx,
|
||||||
|
);
|
||||||
|
thread.message(message_id).cloned().unwrap()
|
||||||
|
});
|
||||||
|
|
||||||
|
active_thread.update_in(cx, |active_thread, window, cx| {
|
||||||
|
active_thread.start_editing_message(
|
||||||
|
message.id,
|
||||||
|
message.segments.as_slice(),
|
||||||
|
message.creases.as_slice(),
|
||||||
|
window,
|
||||||
|
cx,
|
||||||
|
);
|
||||||
|
let editor = active_thread
|
||||||
|
.editing_message
|
||||||
|
.as_ref()
|
||||||
|
.unwrap()
|
||||||
|
.1
|
||||||
|
.editor
|
||||||
|
.clone();
|
||||||
|
editor.update(cx, |editor, cx| editor.edit([(0..13, "modified")], cx));
|
||||||
|
active_thread.confirm_editing_message(&Default::default(), window, cx);
|
||||||
|
});
|
||||||
|
cx.run_until_parked();
|
||||||
|
|
||||||
|
let message = thread.update(cx, |thread, _| thread.message(message.id).cloned().unwrap());
|
||||||
|
active_thread.update_in(cx, |active_thread, window, cx| {
|
||||||
|
active_thread.start_editing_message(
|
||||||
|
message.id,
|
||||||
|
message.segments.as_slice(),
|
||||||
|
message.creases.as_slice(),
|
||||||
|
window,
|
||||||
|
cx,
|
||||||
|
);
|
||||||
|
let editor = active_thread
|
||||||
|
.editing_message
|
||||||
|
.as_ref()
|
||||||
|
.unwrap()
|
||||||
|
.1
|
||||||
|
.editor
|
||||||
|
.clone();
|
||||||
|
let text = editor.update(cx, |editor, cx| editor.text(cx));
|
||||||
|
assert_eq!(text, "modified @foo.txt");
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
fn init_test_settings(cx: &mut TestAppContext) {
|
||||||
|
cx.update(|cx| {
|
||||||
|
let settings_store = SettingsStore::test(cx);
|
||||||
|
cx.set_global(settings_store);
|
||||||
|
language::init(cx);
|
||||||
|
Project::init_settings(cx);
|
||||||
|
AgentSettings::register(cx);
|
||||||
|
prompt_store::init(cx);
|
||||||
|
thread_store::init(cx);
|
||||||
|
workspace::init_settings(cx);
|
||||||
|
language_model::init_settings(cx);
|
||||||
|
ThemeSettings::register(cx);
|
||||||
|
EditorSettings::register(cx);
|
||||||
|
ToolRegistry::default_global(cx);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// Helper to create a test project with test files
|
||||||
|
async fn create_test_project(
|
||||||
|
cx: &mut TestAppContext,
|
||||||
|
files: serde_json::Value,
|
||||||
|
) -> Entity<Project> {
|
||||||
|
let fs = FakeFs::new(cx.executor());
|
||||||
|
fs.insert_tree(path!("/test"), files).await;
|
||||||
|
Project::test(fs, [path!("/test").as_ref()], cx).await
|
||||||
|
}
|
||||||
|
|
||||||
|
async fn setup_test_environment(
|
||||||
|
cx: &mut TestAppContext,
|
||||||
|
project: Entity<Project>,
|
||||||
|
) -> (
|
||||||
|
&mut VisualTestContext,
|
||||||
|
Entity<ActiveThread>,
|
||||||
|
Entity<Workspace>,
|
||||||
|
Entity<Thread>,
|
||||||
|
Arc<dyn LanguageModel>,
|
||||||
|
) {
|
||||||
|
let (workspace, cx) =
|
||||||
|
cx.add_window_view(|window, cx| Workspace::test_new(project.clone(), window, cx));
|
||||||
|
|
||||||
|
let thread_store = cx
|
||||||
|
.update(|_, cx| {
|
||||||
|
ThreadStore::load(
|
||||||
|
project.clone(),
|
||||||
|
cx.new(|_| ToolWorkingSet::default()),
|
||||||
|
None,
|
||||||
|
Arc::new(PromptBuilder::new(None).unwrap()),
|
||||||
|
cx,
|
||||||
|
)
|
||||||
|
})
|
||||||
|
.await
|
||||||
|
.unwrap();
|
||||||
|
|
||||||
|
let text_thread_store = cx
|
||||||
|
.update(|_, cx| {
|
||||||
|
TextThreadStore::new(
|
||||||
|
project.clone(),
|
||||||
|
Arc::new(PromptBuilder::new(None).unwrap()),
|
||||||
|
Default::default(),
|
||||||
|
cx,
|
||||||
|
)
|
||||||
|
})
|
||||||
|
.await
|
||||||
|
.unwrap();
|
||||||
|
|
||||||
|
let thread = thread_store.update(cx, |store, cx| store.create_thread(cx));
|
||||||
|
let context_store =
|
||||||
|
cx.new(|_cx| ContextStore::new(project.downgrade(), Some(thread_store.downgrade())));
|
||||||
|
|
||||||
|
let model = FakeLanguageModel::default();
|
||||||
|
let model: Arc<dyn LanguageModel> = Arc::new(model);
|
||||||
|
|
||||||
|
let language_registry = LanguageRegistry::new(cx.executor());
|
||||||
|
let language_registry = Arc::new(language_registry);
|
||||||
|
|
||||||
|
let active_thread = cx.update(|window, cx| {
|
||||||
|
cx.new(|cx| {
|
||||||
|
ActiveThread::new(
|
||||||
|
thread.clone(),
|
||||||
|
thread_store.clone(),
|
||||||
|
text_thread_store,
|
||||||
|
context_store.clone(),
|
||||||
|
language_registry.clone(),
|
||||||
|
workspace.downgrade(),
|
||||||
|
window,
|
||||||
|
cx,
|
||||||
|
)
|
||||||
|
})
|
||||||
|
});
|
||||||
|
|
||||||
|
(cx, active_thread, workspace, thread, model)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ mod agent_configuration;
|
|||||||
mod agent_diff;
|
mod agent_diff;
|
||||||
mod agent_model_selector;
|
mod agent_model_selector;
|
||||||
mod agent_panel;
|
mod agent_panel;
|
||||||
|
mod agent_profile;
|
||||||
mod buffer_codegen;
|
mod buffer_codegen;
|
||||||
mod context;
|
mod context;
|
||||||
mod context_picker;
|
mod context_picker;
|
||||||
@@ -28,14 +29,16 @@ mod ui;
|
|||||||
|
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
|
||||||
use assistant_settings::{AgentProfileId, AssistantSettings, LanguageModelSelection};
|
use agent_settings::{AgentProfileId, AgentSettings, 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, actions, impl_actions};
|
use gpui::{App, Entity, actions, impl_actions};
|
||||||
use language::LanguageRegistry;
|
use language::LanguageRegistry;
|
||||||
use language_model::{LanguageModelId, LanguageModelProviderId, LanguageModelRegistry};
|
use language_model::{
|
||||||
|
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;
|
||||||
@@ -69,6 +72,7 @@ actions!(
|
|||||||
AddContextServer,
|
AddContextServer,
|
||||||
RemoveSelectedThread,
|
RemoveSelectedThread,
|
||||||
Chat,
|
Chat,
|
||||||
|
ChatWithFollow,
|
||||||
CycleNextInlineAssist,
|
CycleNextInlineAssist,
|
||||||
CyclePreviousInlineAssist,
|
CyclePreviousInlineAssist,
|
||||||
FocusUp,
|
FocusUp,
|
||||||
@@ -86,6 +90,9 @@ actions!(
|
|||||||
Follow,
|
Follow,
|
||||||
ResetTrialUpsell,
|
ResetTrialUpsell,
|
||||||
ResetTrialEndUpsell,
|
ResetTrialEndUpsell,
|
||||||
|
ContinueThread,
|
||||||
|
ContinueWithBurnMode,
|
||||||
|
ToggleBurnMode,
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -111,20 +118,47 @@ 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,
|
||||||
) {
|
) {
|
||||||
AssistantSettings::register(cx);
|
AgentSettings::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);
|
||||||
init_language_model_settings(cx);
|
if !is_eval {
|
||||||
|
// 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);
|
||||||
@@ -168,7 +202,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 = AssistantSettings::get_global(cx);
|
let settings = AgentSettings::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 {
|
||||||
@@ -217,7 +251,6 @@ 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 assistant_settings::AssistantSettings;
|
use agent_settings::AgentSettings;
|
||||||
use assistant_tool::{ToolSource, ToolWorkingSet};
|
use assistant_tool::{ToolSource, ToolWorkingSet};
|
||||||
use collections::HashMap;
|
use collections::HashMap;
|
||||||
use context_server::ContextServerId;
|
use context_server::ContextServerId;
|
||||||
@@ -249,7 +249,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 = AssistantSettings::get_global(cx).always_allow_tool_actions;
|
let always_allow_tool_actions = AgentSettings::get_global(cx).always_allow_tool_actions;
|
||||||
|
|
||||||
h_flex()
|
h_flex()
|
||||||
.gap_4()
|
.gap_4()
|
||||||
@@ -277,7 +277,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::<AssistantSettings>(
|
update_settings_file::<AgentSettings>(
|
||||||
fs.clone(),
|
fs.clone(),
|
||||||
cx,
|
cx,
|
||||||
move |settings, _| {
|
move |settings, _| {
|
||||||
@@ -290,7 +290,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 = AssistantSettings::get_global(cx).single_file_review;
|
let single_file_review = AgentSettings::get_global(cx).single_file_review;
|
||||||
|
|
||||||
h_flex()
|
h_flex()
|
||||||
.gap_4()
|
.gap_4()
|
||||||
@@ -315,7 +315,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::<AssistantSettings>(
|
update_settings_file::<AgentSettings>(
|
||||||
fs.clone(),
|
fs.clone(),
|
||||||
cx,
|
cx,
|
||||||
move |settings, _| {
|
move |settings, _| {
|
||||||
@@ -327,6 +327,44 @@ 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))
|
||||||
@@ -337,6 +375,7 @@ impl AgentConfiguration {
|
|||||||
.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(
|
||||||
|
|||||||
@@ -2,25 +2,21 @@ mod profile_modal_header;
|
|||||||
|
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
|
||||||
use assistant_settings::{AgentProfile, AgentProfileId, AssistantSettings, builtin_profiles};
|
use agent_settings::{AgentProfileId, AgentSettings, builtin_profiles};
|
||||||
use assistant_tool::ToolWorkingSet;
|
use assistant_tool::ToolWorkingSet;
|
||||||
use convert_case::{Case, Casing as _};
|
|
||||||
use editor::Editor;
|
use editor::Editor;
|
||||||
use fs::Fs;
|
use fs::Fs;
|
||||||
use gpui::{
|
use gpui::{DismissEvent, Entity, EventEmitter, FocusHandle, Focusable, Subscription, prelude::*};
|
||||||
DismissEvent, Entity, EventEmitter, FocusHandle, Focusable, Subscription, WeakEntity,
|
use settings::Settings as _;
|
||||||
prelude::*,
|
|
||||||
};
|
|
||||||
use settings::{Settings as _, update_settings_file};
|
|
||||||
use ui::{
|
use ui::{
|
||||||
KeyBinding, ListItem, ListItemSpacing, ListSeparator, Navigable, NavigableEntry, prelude::*,
|
KeyBinding, ListItem, ListItemSpacing, ListSeparator, Navigable, NavigableEntry, prelude::*,
|
||||||
};
|
};
|
||||||
use util::ResultExt as _;
|
|
||||||
use workspace::{ModalView, Workspace};
|
use workspace::{ModalView, Workspace};
|
||||||
|
|
||||||
use crate::agent_configuration::manage_profiles_modal::profile_modal_header::ProfileModalHeader;
|
use crate::agent_configuration::manage_profiles_modal::profile_modal_header::ProfileModalHeader;
|
||||||
use crate::agent_configuration::tool_picker::{ToolPicker, ToolPickerDelegate};
|
use crate::agent_configuration::tool_picker::{ToolPicker, ToolPickerDelegate};
|
||||||
use crate::{AgentPanel, ManageProfiles, ThreadStore};
|
use crate::agent_profile::AgentProfile;
|
||||||
|
use crate::{AgentPanel, ManageProfiles};
|
||||||
|
|
||||||
use super::tool_picker::ToolPickerMode;
|
use super::tool_picker::ToolPickerMode;
|
||||||
|
|
||||||
@@ -42,7 +38,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 = AssistantSettings::get_global(cx);
|
let settings = AgentSettings::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();
|
||||||
@@ -103,7 +99,6 @@ pub struct NewProfileMode {
|
|||||||
pub struct ManageProfilesModal {
|
pub struct ManageProfilesModal {
|
||||||
fs: Arc<dyn Fs>,
|
fs: Arc<dyn Fs>,
|
||||||
tools: Entity<ToolWorkingSet>,
|
tools: Entity<ToolWorkingSet>,
|
||||||
thread_store: WeakEntity<ThreadStore>,
|
|
||||||
focus_handle: FocusHandle,
|
focus_handle: FocusHandle,
|
||||||
mode: Mode,
|
mode: Mode,
|
||||||
}
|
}
|
||||||
@@ -119,9 +114,8 @@ impl ManageProfilesModal {
|
|||||||
let fs = workspace.app_state().fs.clone();
|
let fs = workspace.app_state().fs.clone();
|
||||||
let thread_store = panel.read(cx).thread_store();
|
let thread_store = panel.read(cx).thread_store();
|
||||||
let tools = thread_store.read(cx).tools();
|
let tools = thread_store.read(cx).tools();
|
||||||
let thread_store = thread_store.downgrade();
|
|
||||||
workspace.toggle_modal(window, cx, |window, cx| {
|
workspace.toggle_modal(window, cx, |window, cx| {
|
||||||
let mut this = Self::new(fs, tools, thread_store, window, cx);
|
let mut this = Self::new(fs, tools, window, cx);
|
||||||
|
|
||||||
if let Some(profile_id) = action.customize_tools.clone() {
|
if let Some(profile_id) = action.customize_tools.clone() {
|
||||||
this.configure_builtin_tools(profile_id, window, cx);
|
this.configure_builtin_tools(profile_id, window, cx);
|
||||||
@@ -136,7 +130,6 @@ impl ManageProfilesModal {
|
|||||||
pub fn new(
|
pub fn new(
|
||||||
fs: Arc<dyn Fs>,
|
fs: Arc<dyn Fs>,
|
||||||
tools: Entity<ToolWorkingSet>,
|
tools: Entity<ToolWorkingSet>,
|
||||||
thread_store: WeakEntity<ThreadStore>,
|
|
||||||
window: &mut Window,
|
window: &mut Window,
|
||||||
cx: &mut Context<Self>,
|
cx: &mut Context<Self>,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
@@ -145,7 +138,6 @@ impl ManageProfilesModal {
|
|||||||
Self {
|
Self {
|
||||||
fs,
|
fs,
|
||||||
tools,
|
tools,
|
||||||
thread_store,
|
|
||||||
focus_handle,
|
focus_handle,
|
||||||
mode: Mode::choose_profile(window, cx),
|
mode: Mode::choose_profile(window, cx),
|
||||||
}
|
}
|
||||||
@@ -196,7 +188,7 @@ impl ManageProfilesModal {
|
|||||||
window: &mut Window,
|
window: &mut Window,
|
||||||
cx: &mut Context<Self>,
|
cx: &mut Context<Self>,
|
||||||
) {
|
) {
|
||||||
let settings = AssistantSettings::get_global(cx);
|
let settings = AgentSettings::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;
|
||||||
};
|
};
|
||||||
@@ -206,7 +198,6 @@ impl ManageProfilesModal {
|
|||||||
ToolPickerMode::McpTools,
|
ToolPickerMode::McpTools,
|
||||||
self.fs.clone(),
|
self.fs.clone(),
|
||||||
self.tools.clone(),
|
self.tools.clone(),
|
||||||
self.thread_store.clone(),
|
|
||||||
profile_id.clone(),
|
profile_id.clone(),
|
||||||
profile,
|
profile,
|
||||||
cx,
|
cx,
|
||||||
@@ -234,7 +225,7 @@ impl ManageProfilesModal {
|
|||||||
window: &mut Window,
|
window: &mut Window,
|
||||||
cx: &mut Context<Self>,
|
cx: &mut Context<Self>,
|
||||||
) {
|
) {
|
||||||
let settings = AssistantSettings::get_global(cx);
|
let settings = AgentSettings::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;
|
||||||
};
|
};
|
||||||
@@ -244,7 +235,6 @@ impl ManageProfilesModal {
|
|||||||
ToolPickerMode::BuiltinTools,
|
ToolPickerMode::BuiltinTools,
|
||||||
self.fs.clone(),
|
self.fs.clone(),
|
||||||
self.tools.clone(),
|
self.tools.clone(),
|
||||||
self.thread_store.clone(),
|
|
||||||
profile_id.clone(),
|
profile_id.clone(),
|
||||||
profile,
|
profile,
|
||||||
cx,
|
cx,
|
||||||
@@ -270,32 +260,10 @@ impl ManageProfilesModal {
|
|||||||
match &self.mode {
|
match &self.mode {
|
||||||
Mode::ChooseProfile { .. } => {}
|
Mode::ChooseProfile { .. } => {}
|
||||||
Mode::NewProfile(mode) => {
|
Mode::NewProfile(mode) => {
|
||||||
let settings = AssistantSettings::get_global(cx);
|
|
||||||
|
|
||||||
let base_profile = mode
|
|
||||||
.base_profile_id
|
|
||||||
.as_ref()
|
|
||||||
.and_then(|profile_id| settings.profiles.get(profile_id).cloned());
|
|
||||||
|
|
||||||
let name = mode.name_editor.read(cx).text(cx);
|
let name = mode.name_editor.read(cx).text(cx);
|
||||||
let profile_id = AgentProfileId(name.to_case(Case::Kebab).into());
|
|
||||||
|
|
||||||
let profile = AgentProfile {
|
let profile_id =
|
||||||
name: name.into(),
|
AgentProfile::create(name, mode.base_profile_id.clone(), self.fs.clone(), cx);
|
||||||
tools: base_profile
|
|
||||||
.as_ref()
|
|
||||||
.map(|profile| profile.tools.clone())
|
|
||||||
.unwrap_or_default(),
|
|
||||||
enable_all_context_servers: base_profile
|
|
||||||
.as_ref()
|
|
||||||
.map(|profile| profile.enable_all_context_servers)
|
|
||||||
.unwrap_or_default(),
|
|
||||||
context_servers: base_profile
|
|
||||||
.map(|profile| profile.context_servers)
|
|
||||||
.unwrap_or_default(),
|
|
||||||
};
|
|
||||||
|
|
||||||
self.create_profile(profile_id.clone(), profile, cx);
|
|
||||||
self.view_profile(profile_id, window, cx);
|
self.view_profile(profile_id, window, cx);
|
||||||
}
|
}
|
||||||
Mode::ViewProfile(_) => {}
|
Mode::ViewProfile(_) => {}
|
||||||
@@ -325,19 +293,6 @@ impl ManageProfilesModal {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn create_profile(
|
|
||||||
&self,
|
|
||||||
profile_id: AgentProfileId,
|
|
||||||
profile: AgentProfile,
|
|
||||||
cx: &mut Context<Self>,
|
|
||||||
) {
|
|
||||||
update_settings_file::<AssistantSettings>(self.fs.clone(), cx, {
|
|
||||||
move |settings, _cx| {
|
|
||||||
settings.create_profile(profile_id, profile).log_err();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ModalView for ManageProfilesModal {}
|
impl ModalView for ManageProfilesModal {}
|
||||||
@@ -485,7 +440,7 @@ impl ManageProfilesModal {
|
|||||||
_window: &mut Window,
|
_window: &mut Window,
|
||||||
cx: &mut Context<Self>,
|
cx: &mut Context<Self>,
|
||||||
) -> impl IntoElement {
|
) -> impl IntoElement {
|
||||||
let settings = AssistantSettings::get_global(cx);
|
let settings = AgentSettings::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,16 +473,15 @@ impl ManageProfilesModal {
|
|||||||
window: &mut Window,
|
window: &mut Window,
|
||||||
cx: &mut Context<Self>,
|
cx: &mut Context<Self>,
|
||||||
) -> impl IntoElement {
|
) -> impl IntoElement {
|
||||||
let settings = AssistantSettings::get_global(cx);
|
let settings = AgentSettings::get_global(cx);
|
||||||
|
|
||||||
let profile_id = &settings.default_profile;
|
|
||||||
let profile_name = settings
|
let profile_name = settings
|
||||||
.profiles
|
.profiles
|
||||||
.get(&mode.profile_id)
|
.get(&mode.profile_id)
|
||||||
.map(|profile| profile.name.clone())
|
.map(|profile| profile.name.clone())
|
||||||
.unwrap_or_else(|| "Unknown".into());
|
.unwrap_or_else(|| "Unknown".into());
|
||||||
|
|
||||||
let icon = match profile_id.as_str() {
|
let icon = match mode.profile_id.as_str() {
|
||||||
"write" => IconName::Pencil,
|
"write" => IconName::Pencil,
|
||||||
"ask" => IconName::MessageBubbles,
|
"ask" => IconName::MessageBubbles,
|
||||||
_ => IconName::UserRoundPen,
|
_ => IconName::UserRoundPen,
|
||||||
@@ -712,7 +666,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 = AssistantSettings::get_global(cx);
|
let settings = AgentSettings::get_global(cx);
|
||||||
|
|
||||||
let go_back_item = div()
|
let go_back_item = div()
|
||||||
.id("cancel-item")
|
.id("cancel-item")
|
||||||
|
|||||||
@@ -1,19 +1,17 @@
|
|||||||
use std::{collections::BTreeMap, sync::Arc};
|
use std::{collections::BTreeMap, sync::Arc};
|
||||||
|
|
||||||
use assistant_settings::{
|
use agent_settings::{
|
||||||
AgentProfile, AgentProfileContent, AgentProfileId, AssistantSettings, AssistantSettingsContent,
|
AgentProfileContent, AgentProfileId, AgentProfileSettings, AgentSettings, AgentSettingsContent,
|
||||||
ContextServerPresetContent,
|
ContextServerPresetContent,
|
||||||
};
|
};
|
||||||
use assistant_tool::{ToolSource, ToolWorkingSet};
|
use assistant_tool::{ToolSource, ToolWorkingSet};
|
||||||
use fs::Fs;
|
use fs::Fs;
|
||||||
use gpui::{App, Context, DismissEvent, Entity, EventEmitter, Focusable, Task, WeakEntity, Window};
|
use gpui::{App, Context, DismissEvent, Entity, EventEmitter, Focusable, Task, WeakEntity, Window};
|
||||||
use picker::{Picker, PickerDelegate};
|
use picker::{Picker, PickerDelegate};
|
||||||
use settings::{Settings as _, update_settings_file};
|
use settings::update_settings_file;
|
||||||
use ui::{ListItem, ListItemSpacing, prelude::*};
|
use ui::{ListItem, ListItemSpacing, prelude::*};
|
||||||
use util::ResultExt as _;
|
use util::ResultExt as _;
|
||||||
|
|
||||||
use crate::ThreadStore;
|
|
||||||
|
|
||||||
pub struct ToolPicker {
|
pub struct ToolPicker {
|
||||||
picker: Entity<Picker<ToolPickerDelegate>>,
|
picker: Entity<Picker<ToolPickerDelegate>>,
|
||||||
}
|
}
|
||||||
@@ -71,11 +69,10 @@ pub enum PickerItem {
|
|||||||
|
|
||||||
pub struct ToolPickerDelegate {
|
pub struct ToolPickerDelegate {
|
||||||
tool_picker: WeakEntity<ToolPicker>,
|
tool_picker: WeakEntity<ToolPicker>,
|
||||||
thread_store: WeakEntity<ThreadStore>,
|
|
||||||
fs: Arc<dyn Fs>,
|
fs: Arc<dyn Fs>,
|
||||||
items: Arc<Vec<PickerItem>>,
|
items: Arc<Vec<PickerItem>>,
|
||||||
profile_id: AgentProfileId,
|
profile_id: AgentProfileId,
|
||||||
profile: AgentProfile,
|
profile_settings: AgentProfileSettings,
|
||||||
filtered_items: Vec<PickerItem>,
|
filtered_items: Vec<PickerItem>,
|
||||||
selected_index: usize,
|
selected_index: usize,
|
||||||
mode: ToolPickerMode,
|
mode: ToolPickerMode,
|
||||||
@@ -86,20 +83,18 @@ impl ToolPickerDelegate {
|
|||||||
mode: ToolPickerMode,
|
mode: ToolPickerMode,
|
||||||
fs: Arc<dyn Fs>,
|
fs: Arc<dyn Fs>,
|
||||||
tool_set: Entity<ToolWorkingSet>,
|
tool_set: Entity<ToolWorkingSet>,
|
||||||
thread_store: WeakEntity<ThreadStore>,
|
|
||||||
profile_id: AgentProfileId,
|
profile_id: AgentProfileId,
|
||||||
profile: AgentProfile,
|
profile_settings: AgentProfileSettings,
|
||||||
cx: &mut Context<ToolPicker>,
|
cx: &mut Context<ToolPicker>,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
let items = Arc::new(Self::resolve_items(mode, &tool_set, cx));
|
let items = Arc::new(Self::resolve_items(mode, &tool_set, cx));
|
||||||
|
|
||||||
Self {
|
Self {
|
||||||
tool_picker: cx.entity().downgrade(),
|
tool_picker: cx.entity().downgrade(),
|
||||||
thread_store,
|
|
||||||
fs,
|
fs,
|
||||||
items,
|
items,
|
||||||
profile_id,
|
profile_id,
|
||||||
profile,
|
profile_settings,
|
||||||
filtered_items: Vec::new(),
|
filtered_items: Vec::new(),
|
||||||
selected_index: 0,
|
selected_index: 0,
|
||||||
mode,
|
mode,
|
||||||
@@ -249,31 +244,34 @@ impl PickerDelegate for ToolPickerDelegate {
|
|||||||
};
|
};
|
||||||
|
|
||||||
let is_currently_enabled = if let Some(server_id) = server_id.clone() {
|
let is_currently_enabled = if let Some(server_id) = server_id.clone() {
|
||||||
let preset = self.profile.context_servers.entry(server_id).or_default();
|
let preset = self
|
||||||
|
.profile_settings
|
||||||
|
.context_servers
|
||||||
|
.entry(server_id)
|
||||||
|
.or_default();
|
||||||
let is_enabled = *preset.tools.entry(tool_name.clone()).or_default();
|
let is_enabled = *preset.tools.entry(tool_name.clone()).or_default();
|
||||||
*preset.tools.entry(tool_name.clone()).or_default() = !is_enabled;
|
*preset.tools.entry(tool_name.clone()).or_default() = !is_enabled;
|
||||||
is_enabled
|
is_enabled
|
||||||
} else {
|
} else {
|
||||||
let is_enabled = *self.profile.tools.entry(tool_name.clone()).or_default();
|
let is_enabled = *self
|
||||||
*self.profile.tools.entry(tool_name.clone()).or_default() = !is_enabled;
|
.profile_settings
|
||||||
|
.tools
|
||||||
|
.entry(tool_name.clone())
|
||||||
|
.or_default();
|
||||||
|
*self
|
||||||
|
.profile_settings
|
||||||
|
.tools
|
||||||
|
.entry(tool_name.clone())
|
||||||
|
.or_default() = !is_enabled;
|
||||||
is_enabled
|
is_enabled
|
||||||
};
|
};
|
||||||
|
|
||||||
let active_profile_id = &AssistantSettings::get_global(cx).default_profile;
|
update_settings_file::<AgentSettings>(self.fs.clone(), cx, {
|
||||||
if active_profile_id == &self.profile_id {
|
|
||||||
self.thread_store
|
|
||||||
.update(cx, |this, cx| {
|
|
||||||
this.load_profile(self.profile.clone(), cx);
|
|
||||||
})
|
|
||||||
.log_err();
|
|
||||||
}
|
|
||||||
|
|
||||||
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_settings.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 AssistantSettingsContent, _cx| {
|
move |settings: &mut AgentSettingsContent, _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();
|
||||||
@@ -348,14 +346,18 @@ impl PickerDelegate for ToolPickerDelegate {
|
|||||||
),
|
),
|
||||||
PickerItem::Tool { name, server_id } => {
|
PickerItem::Tool { name, server_id } => {
|
||||||
let is_enabled = if let Some(server_id) = server_id {
|
let is_enabled = if let Some(server_id) = server_id {
|
||||||
self.profile
|
self.profile_settings
|
||||||
.context_servers
|
.context_servers
|
||||||
.get(server_id.as_ref())
|
.get(server_id.as_ref())
|
||||||
.and_then(|preset| preset.tools.get(name))
|
.and_then(|preset| preset.tools.get(name))
|
||||||
.copied()
|
.copied()
|
||||||
.unwrap_or(self.profile.enable_all_context_servers)
|
.unwrap_or(self.profile_settings.enable_all_context_servers)
|
||||||
} else {
|
} else {
|
||||||
self.profile.tools.get(name).copied().unwrap_or(false)
|
self.profile_settings
|
||||||
|
.tools
|
||||||
|
.get(name)
|
||||||
|
.copied()
|
||||||
|
.unwrap_or(false)
|
||||||
};
|
};
|
||||||
|
|
||||||
Some(
|
Some(
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
use crate::{Keep, KeepAll, OpenAgentDiff, Reject, RejectAll, Thread, ThreadEvent};
|
use crate::{Keep, KeepAll, OpenAgentDiff, Reject, RejectAll, Thread, ThreadEvent};
|
||||||
|
use agent_settings::AgentSettings;
|
||||||
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::{
|
||||||
@@ -699,7 +699,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()
|
||||||
.occlude()
|
.block_mouse_except_scroll()
|
||||||
.shadow_md()
|
.shadow_md()
|
||||||
.children(vec![
|
.children(vec![
|
||||||
Button::new(("reject", row as u64), "Reject")
|
Button::new(("reject", row as u64), "Reject")
|
||||||
@@ -1086,7 +1086,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::ListCollapse)
|
IconButton::new("review", IconName::ListTodo)
|
||||||
.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,8 +1116,13 @@ impl Render for AgentDiffToolbar {
|
|||||||
return Empty.into_any();
|
return Empty.into_any();
|
||||||
};
|
};
|
||||||
|
|
||||||
let is_generating = agent_diff.read(cx).thread.read(cx).is_generating();
|
let has_pending_edit_tool_use = agent_diff
|
||||||
if is_generating {
|
.read(cx)
|
||||||
|
.thread
|
||||||
|
.read(cx)
|
||||||
|
.has_pending_edit_tool_uses();
|
||||||
|
|
||||||
|
if has_pending_edit_tool_use {
|
||||||
return div().px_2().child(spinner_icon).into_any();
|
return div().px_2().child(spinner_icon).into_any();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1253,9 +1258,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 = AssistantSettings::get_global(cx).single_file_review;
|
let mut was_active = AgentSettings::get_global(cx).single_file_review;
|
||||||
move |this, window, cx| {
|
move |this, window, cx| {
|
||||||
let is_active = AssistantSettings::get_global(cx).single_file_review;
|
let is_active = AgentSettings::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);
|
||||||
@@ -1348,6 +1353,7 @@ 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 => {
|
||||||
@@ -1371,7 +1377,9 @@ impl AgentDiff {
|
|||||||
| ThreadEvent::ToolFinished { .. }
|
| ThreadEvent::ToolFinished { .. }
|
||||||
| ThreadEvent::CheckpointChanged
|
| ThreadEvent::CheckpointChanged
|
||||||
| ThreadEvent::ToolConfirmationNeeded
|
| ThreadEvent::ToolConfirmationNeeded
|
||||||
| ThreadEvent::CancelEditing => {}
|
| ThreadEvent::ToolUseLimitReached
|
||||||
|
| ThreadEvent::CancelEditing
|
||||||
|
| ThreadEvent::ProfileChanged => {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1460,10 +1468,13 @@ impl AgentDiff {
|
|||||||
window: &mut Window,
|
window: &mut Window,
|
||||||
cx: &mut Context<Self>,
|
cx: &mut Context<Self>,
|
||||||
) {
|
) {
|
||||||
if !AssistantSettings::get_global(cx).single_file_review {
|
if !AgentSettings::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| editor.end_temporary_diff_override(cx))
|
.update(cx, |editor, cx| {
|
||||||
|
editor.end_temporary_diff_override(cx);
|
||||||
|
editor.unregister_addon::<EditorAgentDiffAddon>();
|
||||||
|
})
|
||||||
.ok();
|
.ok();
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
@@ -1502,7 +1513,7 @@ impl AgentDiff {
|
|||||||
multibuffer.add_diff(diff_handle.clone(), cx);
|
multibuffer.add_diff(diff_handle.clone(), cx);
|
||||||
});
|
});
|
||||||
|
|
||||||
let new_state = if thread.read(cx).is_generating() {
|
let new_state = if thread.read(cx).has_pending_edit_tool_uses() {
|
||||||
EditorState::Generating
|
EditorState::Generating
|
||||||
} else {
|
} else {
|
||||||
EditorState::Reviewing
|
EditorState::Reviewing
|
||||||
@@ -1559,7 +1570,10 @@ impl AgentDiff {
|
|||||||
|
|
||||||
if in_workspace {
|
if in_workspace {
|
||||||
editor
|
editor
|
||||||
.update(cx, |editor, cx| editor.end_temporary_diff_override(cx))
|
.update(cx, |editor, cx| {
|
||||||
|
editor.end_temporary_diff_override(cx);
|
||||||
|
editor.unregister_addon::<EditorAgentDiffAddon>();
|
||||||
|
})
|
||||||
.ok();
|
.ok();
|
||||||
self.reviewing_editors.remove(&editor);
|
self.reviewing_editors.remove(&editor);
|
||||||
}
|
}
|
||||||
@@ -1735,7 +1749,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 assistant_settings::AssistantSettings;
|
use agent_settings::AgentSettings;
|
||||||
use assistant_tool::ToolWorkingSet;
|
use assistant_tool::ToolWorkingSet;
|
||||||
use editor::EditorSettings;
|
use editor::EditorSettings;
|
||||||
use gpui::{TestAppContext, UpdateGlobal, VisualTestContext};
|
use gpui::{TestAppContext, UpdateGlobal, VisualTestContext};
|
||||||
@@ -1754,7 +1768,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);
|
||||||
AssistantSettings::register(cx);
|
AgentSettings::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);
|
||||||
@@ -1910,7 +1924,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);
|
||||||
AssistantSettings::register(cx);
|
AgentSettings::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,22 +1,17 @@
|
|||||||
use assistant_settings::AssistantSettings;
|
use agent_settings::AgentSettings;
|
||||||
use fs::Fs;
|
use fs::Fs;
|
||||||
use gpui::{Entity, FocusHandle, SharedString};
|
use gpui::{Entity, FocusHandle, SharedString};
|
||||||
|
use picker::popover_menu::PickerPopoverMenu;
|
||||||
|
|
||||||
use crate::Thread;
|
use crate::ModelUsageContext;
|
||||||
use language_model::{ConfiguredModel, LanguageModelRegistry};
|
use assistant_context_editor::language_model_selector::{
|
||||||
use language_model_selector::{
|
LanguageModelSelector, ToggleModelSelector, language_model_selector,
|
||||||
LanguageModelSelector, LanguageModelSelectorPopoverMenu, ToggleModelSelector,
|
|
||||||
};
|
};
|
||||||
|
use language_model::{ConfiguredModel, LanguageModelRegistry};
|
||||||
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>,
|
||||||
@@ -28,28 +23,23 @@ 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_type: ModelType,
|
model_usage_context: ModelUsageContext,
|
||||||
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();
|
||||||
LanguageModelSelector::new(
|
language_model_selector(
|
||||||
{
|
{
|
||||||
let model_type = model_type.clone();
|
let model_context = model_usage_context.clone();
|
||||||
move |cx| match &model_type {
|
move |cx| model_context.configured_model(cx)
|
||||||
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_type {
|
match &model_usage_context {
|
||||||
ModelType::Default(thread) => {
|
ModelUsageContext::Thread(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())
|
||||||
@@ -63,7 +53,7 @@ impl AgentModelSelector {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
update_settings_file::<AssistantSettings>(
|
update_settings_file::<AgentSettings>(
|
||||||
fs.clone(),
|
fs.clone(),
|
||||||
cx,
|
cx,
|
||||||
move |settings, _cx| {
|
move |settings, _cx| {
|
||||||
@@ -71,8 +61,8 @@ impl AgentModelSelector {
|
|||||||
},
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
ModelType::InlineAssistant => {
|
ModelUsageContext::InlineAssistant => {
|
||||||
update_settings_file::<AssistantSettings>(
|
update_settings_file::<AgentSettings>(
|
||||||
fs.clone(),
|
fs.clone(),
|
||||||
cx,
|
cx,
|
||||||
move |settings, _cx| {
|
move |settings, _cx| {
|
||||||
@@ -100,15 +90,14 @@ 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).active_model(cx);
|
let model = self.selector.read(cx).delegate.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)
|
||||||
@@ -127,7 +116,9 @@ 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,22 +1,23 @@
|
|||||||
use std::ops::Range;
|
use std::ops::Range;
|
||||||
use std::path::Path;
|
use std::path::Path;
|
||||||
|
use std::rc::Rc;
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
use std::time::Duration;
|
use std::time::Duration;
|
||||||
|
|
||||||
use db::kvp::{Dismissable, KEY_VALUE_STORE};
|
use db::kvp::{Dismissable, KEY_VALUE_STORE};
|
||||||
use markdown::Markdown;
|
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
|
use agent_settings::{AgentDockPosition, AgentSettings, CompletionMode, DefaultView};
|
||||||
use anyhow::{Result, anyhow};
|
use anyhow::{Result, anyhow};
|
||||||
use assistant_context_editor::{
|
use assistant_context_editor::{
|
||||||
AgentPanelDelegate, AssistantContext, ConfigurationError, ContextEditor, ContextEvent,
|
AgentPanelDelegate, AssistantContext, ConfigurationError, ContextEditor, ContextEvent,
|
||||||
ContextSummary, SlashCommandCompletionProvider, humanize_token_count,
|
ContextSummary, SlashCommandCompletionProvider, humanize_token_count,
|
||||||
make_lsp_adapter_delegate, render_remaining_tokens,
|
make_lsp_adapter_delegate, render_remaining_tokens,
|
||||||
};
|
};
|
||||||
use assistant_settings::{AssistantDockPosition, AssistantSettings};
|
|
||||||
use assistant_slash_command::SlashCommandWorkingSet;
|
use assistant_slash_command::SlashCommandWorkingSet;
|
||||||
use assistant_tool::ToolWorkingSet;
|
use assistant_tool::ToolWorkingSet;
|
||||||
|
|
||||||
|
use assistant_context_editor::language_model_selector::ToggleModelSelector;
|
||||||
use client::{UserStore, zed_urls};
|
use client::{UserStore, zed_urls};
|
||||||
use editor::{Anchor, AnchorRangeExt as _, Editor, EditorEvent, MultiBuffer};
|
use editor::{Anchor, AnchorRangeExt as _, Editor, EditorEvent, MultiBuffer};
|
||||||
use fs::Fs;
|
use fs::Fs;
|
||||||
@@ -30,7 +31,6 @@ use language::LanguageRegistry;
|
|||||||
use language_model::{
|
use language_model::{
|
||||||
LanguageModelProviderTosView, LanguageModelRegistry, RequestUsage, ZED_CLOUD_PROVIDER_ID,
|
LanguageModelProviderTosView, LanguageModelRegistry, RequestUsage, ZED_CLOUD_PROVIDER_ID,
|
||||||
};
|
};
|
||||||
use language_model_selector::ToggleModelSelector;
|
|
||||||
use project::{Project, ProjectPath, Worktree};
|
use project::{Project, ProjectPath, Worktree};
|
||||||
use prompt_store::{PromptBuilder, PromptStore, UserPromptId};
|
use prompt_store::{PromptBuilder, PromptStore, UserPromptId};
|
||||||
use proto::Plan;
|
use proto::Plan;
|
||||||
@@ -41,8 +41,8 @@ use theme::ThemeSettings;
|
|||||||
use time::UtcOffset;
|
use time::UtcOffset;
|
||||||
use ui::utils::WithRemSize;
|
use ui::utils::WithRemSize;
|
||||||
use ui::{
|
use ui::{
|
||||||
Banner, CheckboxWithLabel, ContextMenu, KeyBinding, PopoverMenu, PopoverMenuHandle,
|
Banner, CheckboxWithLabel, ContextMenu, ElevationIndex, KeyBinding, PopoverMenu,
|
||||||
ProgressBar, Tab, Tooltip, Vector, VectorName, prelude::*,
|
PopoverMenuHandle, ProgressBar, Tab, Tooltip, Vector, VectorName, prelude::*,
|
||||||
};
|
};
|
||||||
use util::{ResultExt as _, maybe};
|
use util::{ResultExt as _, maybe};
|
||||||
use workspace::dock::{DockPosition, Panel, PanelEvent};
|
use workspace::dock::{DockPosition, Panel, PanelEvent};
|
||||||
@@ -52,7 +52,7 @@ use workspace::{
|
|||||||
use zed_actions::agent::{OpenConfiguration, OpenOnboardingModal, ResetOnboarding};
|
use zed_actions::agent::{OpenConfiguration, OpenOnboardingModal, ResetOnboarding};
|
||||||
use zed_actions::assistant::{OpenRulesLibrary, ToggleFocus};
|
use zed_actions::assistant::{OpenRulesLibrary, ToggleFocus};
|
||||||
use zed_actions::{DecreaseBufferFontSize, IncreaseBufferFontSize, ResetBufferFontSize};
|
use zed_actions::{DecreaseBufferFontSize, IncreaseBufferFontSize, ResetBufferFontSize};
|
||||||
use zed_llm_client::UsageLimit;
|
use zed_llm_client::{CompletionIntent, UsageLimit};
|
||||||
|
|
||||||
use crate::active_thread::{self, ActiveThread, ActiveThreadEvent};
|
use crate::active_thread::{self, ActiveThread, ActiveThreadEvent};
|
||||||
use crate::agent_configuration::{AgentConfiguration, AssistantConfigurationEvent};
|
use crate::agent_configuration::{AgentConfiguration, AssistantConfigurationEvent};
|
||||||
@@ -64,10 +64,11 @@ use crate::thread_history::{HistoryEntryElement, ThreadHistory};
|
|||||||
use crate::thread_store::ThreadStore;
|
use crate::thread_store::ThreadStore;
|
||||||
use crate::ui::AgentOnboardingModal;
|
use crate::ui::AgentOnboardingModal;
|
||||||
use crate::{
|
use crate::{
|
||||||
AddContextServer, AgentDiffPane, ContextStore, DeleteRecentlyOpenThread, ExpandMessageEditor,
|
AddContextServer, AgentDiffPane, ContextStore, ContinueThread, ContinueWithBurnMode,
|
||||||
Follow, InlineAssistant, NewTextThread, NewThread, OpenActiveThreadAsMarkdown, OpenAgentDiff,
|
DeleteRecentlyOpenThread, ExpandMessageEditor, Follow, InlineAssistant, NewTextThread,
|
||||||
OpenHistory, ResetTrialEndUpsell, ResetTrialUpsell, TextThreadStore, ThreadEvent,
|
NewThread, OpenActiveThreadAsMarkdown, OpenAgentDiff, OpenHistory, ResetTrialEndUpsell,
|
||||||
ToggleContextPicker, ToggleNavigationMenu, ToggleOptionsMenu,
|
ResetTrialUpsell, TextThreadStore, ThreadEvent, ToggleBurnMode, ToggleContextPicker,
|
||||||
|
ToggleNavigationMenu, ToggleOptionsMenu,
|
||||||
};
|
};
|
||||||
|
|
||||||
const AGENT_PANEL_KEY: &str = "agent_panel";
|
const AGENT_PANEL_KEY: &str = "agent_panel";
|
||||||
@@ -157,7 +158,7 @@ pub fn init(cx: &mut App) {
|
|||||||
window.refresh();
|
window.refresh();
|
||||||
})
|
})
|
||||||
.register_action(|_workspace, _: &ResetTrialUpsell, _window, cx| {
|
.register_action(|_workspace, _: &ResetTrialUpsell, _window, cx| {
|
||||||
TrialUpsell::set_dismissed(false, cx);
|
Upsell::set_dismissed(false, cx);
|
||||||
})
|
})
|
||||||
.register_action(|_workspace, _: &ResetTrialEndUpsell, _window, cx| {
|
.register_action(|_workspace, _: &ResetTrialEndUpsell, _window, cx| {
|
||||||
TrialEndUpsell::set_dismissed(false, cx);
|
TrialEndUpsell::set_dismissed(false, cx);
|
||||||
@@ -173,7 +174,7 @@ enum ActiveView {
|
|||||||
thread: WeakEntity<Thread>,
|
thread: WeakEntity<Thread>,
|
||||||
_subscriptions: Vec<gpui::Subscription>,
|
_subscriptions: Vec<gpui::Subscription>,
|
||||||
},
|
},
|
||||||
PromptEditor {
|
TextThread {
|
||||||
context_editor: Entity<ContextEditor>,
|
context_editor: Entity<ContextEditor>,
|
||||||
title_editor: Entity<Editor>,
|
title_editor: Entity<Editor>,
|
||||||
buffer_search_bar: Entity<BufferSearchBar>,
|
buffer_search_bar: Entity<BufferSearchBar>,
|
||||||
@@ -193,7 +194,7 @@ impl ActiveView {
|
|||||||
pub fn which_font_size_used(&self) -> WhichFontSize {
|
pub fn which_font_size_used(&self) -> WhichFontSize {
|
||||||
match self {
|
match self {
|
||||||
ActiveView::Thread { .. } | ActiveView::History => WhichFontSize::AgentFont,
|
ActiveView::Thread { .. } | ActiveView::History => WhichFontSize::AgentFont,
|
||||||
ActiveView::PromptEditor { .. } => WhichFontSize::BufferFont,
|
ActiveView::TextThread { .. } => WhichFontSize::BufferFont,
|
||||||
ActiveView::Configuration => WhichFontSize::None,
|
ActiveView::Configuration => WhichFontSize::None,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -332,7 +333,7 @@ impl ActiveView {
|
|||||||
buffer_search_bar.set_active_pane_item(Some(&context_editor), window, cx)
|
buffer_search_bar.set_active_pane_item(Some(&context_editor), window, cx)
|
||||||
});
|
});
|
||||||
|
|
||||||
Self::PromptEditor {
|
Self::TextThread {
|
||||||
context_editor,
|
context_editor,
|
||||||
title_editor: editor,
|
title_editor: editor,
|
||||||
buffer_search_bar,
|
buffer_search_bar,
|
||||||
@@ -370,8 +371,7 @@ pub struct AgentPanel {
|
|||||||
height: Option<Pixels>,
|
height: Option<Pixels>,
|
||||||
zoomed: bool,
|
zoomed: bool,
|
||||||
pending_serialization: Option<Task<Result<()>>>,
|
pending_serialization: Option<Task<Result<()>>>,
|
||||||
hide_trial_upsell: bool,
|
hide_upsell: bool,
|
||||||
_trial_markdown: Entity<Markdown>,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl AgentPanel {
|
impl AgentPanel {
|
||||||
@@ -524,7 +524,30 @@ impl AgentPanel {
|
|||||||
|
|
||||||
cx.observe(&history_store, |_, _, cx| cx.notify()).detach();
|
cx.observe(&history_store, |_, _, cx| cx.notify()).detach();
|
||||||
|
|
||||||
let active_view = ActiveView::thread(thread.clone(), window, cx);
|
let panel_type = AgentSettings::get_global(cx).default_view;
|
||||||
|
let active_view = match panel_type {
|
||||||
|
DefaultView::Thread => ActiveView::thread(thread.clone(), window, cx),
|
||||||
|
DefaultView::TextThread => {
|
||||||
|
let context =
|
||||||
|
context_store.update(cx, |context_store, cx| context_store.create(cx));
|
||||||
|
let lsp_adapter_delegate = make_lsp_adapter_delegate(&project.clone(), cx).unwrap();
|
||||||
|
let context_editor = cx.new(|cx| {
|
||||||
|
let mut editor = ContextEditor::for_context(
|
||||||
|
context,
|
||||||
|
fs.clone(),
|
||||||
|
workspace.clone(),
|
||||||
|
project.clone(),
|
||||||
|
lsp_adapter_delegate,
|
||||||
|
window,
|
||||||
|
cx,
|
||||||
|
);
|
||||||
|
editor.insert_default_prompt(window, cx);
|
||||||
|
editor
|
||||||
|
});
|
||||||
|
ActiveView::prompt_editor(context_editor, language_registry.clone(), window, cx)
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
let thread_subscription = cx.subscribe(&thread, |_, _, event, cx| {
|
let thread_subscription = cx.subscribe(&thread, |_, _, event, cx| {
|
||||||
if let ThreadEvent::MessageAdded(_) = &event {
|
if let ThreadEvent::MessageAdded(_) = &event {
|
||||||
// needed to leave empty state
|
// needed to leave empty state
|
||||||
@@ -676,15 +699,6 @@ impl AgentPanel {
|
|||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
let trial_markdown = cx.new(|cx| {
|
|
||||||
Markdown::new(
|
|
||||||
include_str!("trial_markdown.md").into(),
|
|
||||||
Some(language_registry.clone()),
|
|
||||||
None,
|
|
||||||
cx,
|
|
||||||
)
|
|
||||||
});
|
|
||||||
|
|
||||||
Self {
|
Self {
|
||||||
active_view,
|
active_view,
|
||||||
workspace,
|
workspace,
|
||||||
@@ -721,8 +735,7 @@ impl AgentPanel {
|
|||||||
height: None,
|
height: None,
|
||||||
zoomed: false,
|
zoomed: false,
|
||||||
pending_serialization: None,
|
pending_serialization: None,
|
||||||
hide_trial_upsell: false,
|
hide_upsell: false,
|
||||||
_trial_markdown: trial_markdown,
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -904,8 +917,8 @@ impl AgentPanel {
|
|||||||
open_rules_library(
|
open_rules_library(
|
||||||
self.language_registry.clone(),
|
self.language_registry.clone(),
|
||||||
Box::new(PromptLibraryInlineAssist::new(self.workspace.clone())),
|
Box::new(PromptLibraryInlineAssist::new(self.workspace.clone())),
|
||||||
Arc::new(|| {
|
Rc::new(|| {
|
||||||
Box::new(SlashCommandCompletionProvider::new(
|
Rc::new(SlashCommandCompletionProvider::new(
|
||||||
Arc::new(SlashCommandWorkingSet::default()),
|
Arc::new(SlashCommandWorkingSet::default()),
|
||||||
None,
|
None,
|
||||||
None,
|
None,
|
||||||
@@ -1071,9 +1084,23 @@ impl AgentPanel {
|
|||||||
pub fn go_back(&mut self, _: &workspace::GoBack, window: &mut Window, cx: &mut Context<Self>) {
|
pub fn go_back(&mut self, _: &workspace::GoBack, window: &mut Window, cx: &mut Context<Self>) {
|
||||||
match self.active_view {
|
match self.active_view {
|
||||||
ActiveView::Configuration | ActiveView::History => {
|
ActiveView::Configuration | ActiveView::History => {
|
||||||
self.active_view =
|
if let Some(previous_view) = self.previous_view.take() {
|
||||||
ActiveView::thread(self.thread.read(cx).thread().clone(), window, cx);
|
self.active_view = previous_view;
|
||||||
self.message_editor.focus_handle(cx).focus(window);
|
|
||||||
|
match &self.active_view {
|
||||||
|
ActiveView::Thread { .. } => {
|
||||||
|
self.message_editor.focus_handle(cx).focus(window);
|
||||||
|
}
|
||||||
|
ActiveView::TextThread { context_editor, .. } => {
|
||||||
|
context_editor.focus_handle(cx).focus(window);
|
||||||
|
}
|
||||||
|
_ => {}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
self.active_view =
|
||||||
|
ActiveView::thread(self.thread.read(cx).thread().clone(), window, cx);
|
||||||
|
self.message_editor.focus_handle(cx).focus(window);
|
||||||
|
}
|
||||||
cx.notify();
|
cx.notify();
|
||||||
}
|
}
|
||||||
_ => {}
|
_ => {}
|
||||||
@@ -1238,7 +1265,7 @@ impl AgentPanel {
|
|||||||
.map_or(true, |model| model.provider.id() != provider.id())
|
.map_or(true, |model| model.provider.id() != provider.id())
|
||||||
{
|
{
|
||||||
if let Some(model) = provider.default_model(cx) {
|
if let Some(model) = provider.default_model(cx) {
|
||||||
update_settings_file::<AssistantSettings>(
|
update_settings_file::<AgentSettings>(
|
||||||
self.fs.clone(),
|
self.fs.clone(),
|
||||||
cx,
|
cx,
|
||||||
move |settings, _| settings.set_model(model),
|
move |settings, _| settings.set_model(model),
|
||||||
@@ -1271,9 +1298,52 @@ impl AgentPanel {
|
|||||||
matches!(self.active_view, ActiveView::Thread { .. })
|
matches!(self.active_view, ActiveView::Thread { .. })
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn continue_conversation(&mut self, window: &mut Window, cx: &mut Context<Self>) {
|
||||||
|
let thread_state = self.thread.read(cx).thread().read(cx);
|
||||||
|
if !thread_state.tool_use_limit_reached() {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
let model = thread_state.configured_model().map(|cm| cm.model.clone());
|
||||||
|
if let Some(model) = model {
|
||||||
|
self.thread.update(cx, |active_thread, cx| {
|
||||||
|
active_thread.thread().update(cx, |thread, cx| {
|
||||||
|
thread.insert_invisible_continue_message(cx);
|
||||||
|
thread.advance_prompt_id();
|
||||||
|
thread.send_to_model(
|
||||||
|
model,
|
||||||
|
CompletionIntent::UserPrompt,
|
||||||
|
Some(window.window_handle()),
|
||||||
|
cx,
|
||||||
|
);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
log::warn!("No configured model available for continuation");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn toggle_burn_mode(
|
||||||
|
&mut self,
|
||||||
|
_: &ToggleBurnMode,
|
||||||
|
_window: &mut Window,
|
||||||
|
cx: &mut Context<Self>,
|
||||||
|
) {
|
||||||
|
self.thread.update(cx, |active_thread, cx| {
|
||||||
|
active_thread.thread().update(cx, |thread, _cx| {
|
||||||
|
let current_mode = thread.completion_mode();
|
||||||
|
|
||||||
|
thread.set_completion_mode(match current_mode {
|
||||||
|
CompletionMode::Burn => CompletionMode::Normal,
|
||||||
|
CompletionMode::Normal => CompletionMode::Burn,
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
pub(crate) fn active_context_editor(&self) -> Option<Entity<ContextEditor>> {
|
pub(crate) fn active_context_editor(&self) -> Option<Entity<ContextEditor>> {
|
||||||
match &self.active_view {
|
match &self.active_view {
|
||||||
ActiveView::PromptEditor { context_editor, .. } => Some(context_editor.clone()),
|
ActiveView::TextThread { context_editor, .. } => Some(context_editor.clone()),
|
||||||
_ => None,
|
_ => None,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1296,6 +1366,12 @@ impl AgentPanel {
|
|||||||
let current_is_history = matches!(self.active_view, ActiveView::History);
|
let current_is_history = matches!(self.active_view, ActiveView::History);
|
||||||
let new_is_history = matches!(new_view, ActiveView::History);
|
let new_is_history = matches!(new_view, ActiveView::History);
|
||||||
|
|
||||||
|
let current_is_config = matches!(self.active_view, ActiveView::Configuration);
|
||||||
|
let new_is_config = matches!(new_view, ActiveView::Configuration);
|
||||||
|
|
||||||
|
let current_is_special = current_is_history || current_is_config;
|
||||||
|
let new_is_special = new_is_history || new_is_config;
|
||||||
|
|
||||||
match &self.active_view {
|
match &self.active_view {
|
||||||
ActiveView::Thread { thread, .. } => {
|
ActiveView::Thread { thread, .. } => {
|
||||||
if let Some(thread) = thread.upgrade() {
|
if let Some(thread) = thread.upgrade() {
|
||||||
@@ -1307,7 +1383,7 @@ impl AgentPanel {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ActiveView::PromptEditor { context_editor, .. } => {
|
ActiveView::TextThread { context_editor, .. } => {
|
||||||
let context = context_editor.read(cx).context();
|
let context = context_editor.read(cx).context();
|
||||||
// When switching away from an unsaved text thread, delete its entry.
|
// When switching away from an unsaved text thread, delete its entry.
|
||||||
if context.read(cx).path().is_none() {
|
if context.read(cx).path().is_none() {
|
||||||
@@ -1327,7 +1403,7 @@ impl AgentPanel {
|
|||||||
store.push_recently_opened_entry(RecentEntry::Thread(id, thread), cx);
|
store.push_recently_opened_entry(RecentEntry::Thread(id, thread), cx);
|
||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
ActiveView::PromptEditor { context_editor, .. } => {
|
ActiveView::TextThread { context_editor, .. } => {
|
||||||
self.history_store.update(cx, |store, cx| {
|
self.history_store.update(cx, |store, cx| {
|
||||||
let context = context_editor.read(cx).context().clone();
|
let context = context_editor.read(cx).context().clone();
|
||||||
store.push_recently_opened_entry(RecentEntry::Context(context), cx)
|
store.push_recently_opened_entry(RecentEntry::Context(context), cx)
|
||||||
@@ -1336,12 +1412,12 @@ impl AgentPanel {
|
|||||||
_ => {}
|
_ => {}
|
||||||
}
|
}
|
||||||
|
|
||||||
if current_is_history && !new_is_history {
|
if current_is_special && !new_is_special {
|
||||||
self.active_view = new_view;
|
self.active_view = new_view;
|
||||||
} else if !current_is_history && new_is_history {
|
} else if !current_is_special && new_is_special {
|
||||||
self.previous_view = Some(std::mem::replace(&mut self.active_view, new_view));
|
self.previous_view = Some(std::mem::replace(&mut self.active_view, new_view));
|
||||||
} else {
|
} else {
|
||||||
if !new_is_history {
|
if !new_is_special {
|
||||||
self.previous_view = None;
|
self.previous_view = None;
|
||||||
}
|
}
|
||||||
self.active_view = new_view;
|
self.active_view = new_view;
|
||||||
@@ -1356,7 +1432,7 @@ impl Focusable for AgentPanel {
|
|||||||
match &self.active_view {
|
match &self.active_view {
|
||||||
ActiveView::Thread { .. } => self.message_editor.focus_handle(cx),
|
ActiveView::Thread { .. } => self.message_editor.focus_handle(cx),
|
||||||
ActiveView::History => self.history.focus_handle(cx),
|
ActiveView::History => self.history.focus_handle(cx),
|
||||||
ActiveView::PromptEditor { context_editor, .. } => context_editor.focus_handle(cx),
|
ActiveView::TextThread { context_editor, .. } => context_editor.focus_handle(cx),
|
||||||
ActiveView::Configuration => {
|
ActiveView::Configuration => {
|
||||||
if let Some(configuration) = self.configuration.as_ref() {
|
if let Some(configuration) = self.configuration.as_ref() {
|
||||||
configuration.focus_handle(cx)
|
configuration.focus_handle(cx)
|
||||||
@@ -1369,10 +1445,10 @@ impl Focusable for AgentPanel {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn agent_panel_dock_position(cx: &App) -> DockPosition {
|
fn agent_panel_dock_position(cx: &App) -> DockPosition {
|
||||||
match AssistantSettings::get_global(cx).dock {
|
match AgentSettings::get_global(cx).dock {
|
||||||
AssistantDockPosition::Left => DockPosition::Left,
|
AgentDockPosition::Left => DockPosition::Left,
|
||||||
AssistantDockPosition::Bottom => DockPosition::Bottom,
|
AgentDockPosition::Bottom => DockPosition::Bottom,
|
||||||
AssistantDockPosition::Right => DockPosition::Right,
|
AgentDockPosition::Right => DockPosition::Right,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1392,22 +1468,18 @@ impl Panel for AgentPanel {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn set_position(&mut self, position: DockPosition, _: &mut Window, cx: &mut Context<Self>) {
|
fn set_position(&mut self, position: DockPosition, _: &mut Window, cx: &mut Context<Self>) {
|
||||||
settings::update_settings_file::<AssistantSettings>(
|
settings::update_settings_file::<AgentSettings>(self.fs.clone(), cx, move |settings, _| {
|
||||||
self.fs.clone(),
|
let dock = match position {
|
||||||
cx,
|
DockPosition::Left => AgentDockPosition::Left,
|
||||||
move |settings, _| {
|
DockPosition::Bottom => AgentDockPosition::Bottom,
|
||||||
let dock = match position {
|
DockPosition::Right => AgentDockPosition::Right,
|
||||||
DockPosition::Left => AssistantDockPosition::Left,
|
};
|
||||||
DockPosition::Bottom => AssistantDockPosition::Bottom,
|
settings.set_dock(dock);
|
||||||
DockPosition::Right => AssistantDockPosition::Right,
|
});
|
||||||
};
|
|
||||||
settings.set_dock(dock);
|
|
||||||
},
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn size(&self, window: &Window, cx: &App) -> Pixels {
|
fn size(&self, window: &Window, cx: &App) -> Pixels {
|
||||||
let settings = AssistantSettings::get_global(cx);
|
let settings = AgentSettings::get_global(cx);
|
||||||
match self.position(window, cx) {
|
match self.position(window, cx) {
|
||||||
DockPosition::Left | DockPosition::Right => {
|
DockPosition::Left | DockPosition::Right => {
|
||||||
self.width.unwrap_or(settings.default_width)
|
self.width.unwrap_or(settings.default_width)
|
||||||
@@ -1432,8 +1504,7 @@ impl Panel for AgentPanel {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn icon(&self, _window: &Window, cx: &App) -> Option<IconName> {
|
fn icon(&self, _window: &Window, cx: &App) -> Option<IconName> {
|
||||||
(self.enabled(cx) && AssistantSettings::get_global(cx).button)
|
(self.enabled(cx) && AgentSettings::get_global(cx).button).then_some(IconName::ZedAssistant)
|
||||||
.then_some(IconName::ZedAssistant)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn icon_tooltip(&self, _window: &Window, _cx: &App) -> Option<&'static str> {
|
fn icon_tooltip(&self, _window: &Window, _cx: &App) -> Option<&'static str> {
|
||||||
@@ -1449,7 +1520,7 @@ impl Panel for AgentPanel {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn enabled(&self, cx: &App) -> bool {
|
fn enabled(&self, cx: &App) -> bool {
|
||||||
AssistantSettings::get_global(cx).enabled
|
AgentSettings::get_global(cx).enabled
|
||||||
}
|
}
|
||||||
|
|
||||||
fn is_zoomed(&self, _window: &Window, _cx: &App) -> bool {
|
fn is_zoomed(&self, _window: &Window, _cx: &App) -> bool {
|
||||||
@@ -1513,7 +1584,7 @@ impl AgentPanel {
|
|||||||
.into_any_element(),
|
.into_any_element(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ActiveView::PromptEditor {
|
ActiveView::TextThread {
|
||||||
title_editor,
|
title_editor,
|
||||||
context_editor,
|
context_editor,
|
||||||
..
|
..
|
||||||
@@ -1605,7 +1676,7 @@ impl AgentPanel {
|
|||||||
|
|
||||||
let show_token_count = match &self.active_view {
|
let show_token_count = match &self.active_view {
|
||||||
ActiveView::Thread { .. } => !is_empty || !editor_empty,
|
ActiveView::Thread { .. } => !is_empty || !editor_empty,
|
||||||
ActiveView::PromptEditor { .. } => true,
|
ActiveView::TextThread { .. } => true,
|
||||||
_ => false,
|
_ => false,
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -1921,7 +1992,7 @@ impl AgentPanel {
|
|||||||
|
|
||||||
Some(token_count)
|
Some(token_count)
|
||||||
}
|
}
|
||||||
ActiveView::PromptEditor { context_editor, .. } => {
|
ActiveView::TextThread { context_editor, .. } => {
|
||||||
let element = render_remaining_tokens(context_editor, cx)?;
|
let element = render_remaining_tokens(context_editor, cx)?;
|
||||||
|
|
||||||
Some(element.into_any_element())
|
Some(element.into_any_element())
|
||||||
@@ -1946,7 +2017,7 @@ impl AgentPanel {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if self.hide_trial_upsell || TrialUpsell::dismissed() {
|
if self.hide_upsell || Upsell::dismissed() {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1976,7 +2047,7 @@ impl AgentPanel {
|
|||||||
true
|
true
|
||||||
}
|
}
|
||||||
|
|
||||||
fn render_trial_upsell(
|
fn render_upsell(
|
||||||
&self,
|
&self,
|
||||||
_window: &mut Window,
|
_window: &mut Window,
|
||||||
cx: &mut Context<Self>,
|
cx: &mut Context<Self>,
|
||||||
@@ -1985,6 +2056,14 @@ impl AgentPanel {
|
|||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if self.user_store.read(cx).account_too_young() {
|
||||||
|
Some(self.render_young_account_upsell(cx).into_any_element())
|
||||||
|
} else {
|
||||||
|
Some(self.render_trial_upsell(cx).into_any_element())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn render_young_account_upsell(&self, cx: &mut Context<Self>) -> impl IntoElement {
|
||||||
let checkbox = CheckboxWithLabel::new(
|
let checkbox = CheckboxWithLabel::new(
|
||||||
"dont-show-again",
|
"dont-show-again",
|
||||||
Label::new("Don't show again").color(Color::Muted),
|
Label::new("Don't show again").color(Color::Muted),
|
||||||
@@ -1992,7 +2071,70 @@ impl AgentPanel {
|
|||||||
move |toggle_state, _window, cx| {
|
move |toggle_state, _window, cx| {
|
||||||
let toggle_state_bool = toggle_state.selected();
|
let toggle_state_bool = toggle_state.selected();
|
||||||
|
|
||||||
TrialUpsell::set_dismissed(toggle_state_bool, cx);
|
Upsell::set_dismissed(toggle_state_bool, cx);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
|
let contents = div()
|
||||||
|
.size_full()
|
||||||
|
.gap_2()
|
||||||
|
.flex()
|
||||||
|
.flex_col()
|
||||||
|
.child(Headline::new("Build better with Zed Pro").size(HeadlineSize::Small))
|
||||||
|
.child(
|
||||||
|
Label::new("Your GitHub account was created less than 30 days ago, so we can't offer you a free trial.")
|
||||||
|
.size(LabelSize::Small),
|
||||||
|
)
|
||||||
|
.child(
|
||||||
|
Label::new(
|
||||||
|
"Use your own API keys, upgrade to Zed Pro or send an email to billing-support@zed.dev.",
|
||||||
|
)
|
||||||
|
.color(Color::Muted),
|
||||||
|
)
|
||||||
|
.child(
|
||||||
|
h_flex()
|
||||||
|
.w_full()
|
||||||
|
.px_neg_1()
|
||||||
|
.justify_between()
|
||||||
|
.items_center()
|
||||||
|
.child(h_flex().items_center().gap_1().child(checkbox))
|
||||||
|
.child(
|
||||||
|
h_flex()
|
||||||
|
.gap_2()
|
||||||
|
.child(
|
||||||
|
Button::new("dismiss-button", "Not Now")
|
||||||
|
.style(ButtonStyle::Transparent)
|
||||||
|
.color(Color::Muted)
|
||||||
|
.on_click({
|
||||||
|
let agent_panel = cx.entity();
|
||||||
|
move |_, _, cx| {
|
||||||
|
agent_panel.update(cx, |this, cx| {
|
||||||
|
this.hide_upsell = true;
|
||||||
|
cx.notify();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}),
|
||||||
|
)
|
||||||
|
.child(
|
||||||
|
Button::new("cta-button", "Upgrade to Zed Pro")
|
||||||
|
.style(ButtonStyle::Transparent)
|
||||||
|
.on_click(|_, _, cx| cx.open_url(&zed_urls::account_url(cx))),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
|
||||||
|
self.render_upsell_container(cx, contents)
|
||||||
|
}
|
||||||
|
|
||||||
|
fn render_trial_upsell(&self, cx: &mut Context<Self>) -> impl IntoElement {
|
||||||
|
let checkbox = CheckboxWithLabel::new(
|
||||||
|
"dont-show-again",
|
||||||
|
Label::new("Don't show again").color(Color::Muted),
|
||||||
|
ToggleState::Unselected,
|
||||||
|
move |toggle_state, _window, cx| {
|
||||||
|
let toggle_state_bool = toggle_state.selected();
|
||||||
|
|
||||||
|
Upsell::set_dismissed(toggle_state_bool, cx);
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -2030,7 +2172,7 @@ impl AgentPanel {
|
|||||||
let agent_panel = cx.entity();
|
let agent_panel = cx.entity();
|
||||||
move |_, _, cx| {
|
move |_, _, cx| {
|
||||||
agent_panel.update(cx, |this, cx| {
|
agent_panel.update(cx, |this, cx| {
|
||||||
this.hide_trial_upsell = true;
|
this.hide_upsell = true;
|
||||||
cx.notify();
|
cx.notify();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -2044,7 +2186,7 @@ impl AgentPanel {
|
|||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
Some(self.render_upsell_container(cx, contents))
|
self.render_upsell_container(cx, contents)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn render_trial_end_upsell(
|
fn render_trial_end_upsell(
|
||||||
@@ -2496,7 +2638,11 @@ impl AgentPanel {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
fn render_tool_use_limit_reached(&self, cx: &mut Context<Self>) -> Option<AnyElement> {
|
fn render_tool_use_limit_reached(
|
||||||
|
&self,
|
||||||
|
window: &mut Window,
|
||||||
|
cx: &mut Context<Self>,
|
||||||
|
) -> Option<AnyElement> {
|
||||||
let tool_use_limit_reached = self
|
let tool_use_limit_reached = self
|
||||||
.thread
|
.thread
|
||||||
.read(cx)
|
.read(cx)
|
||||||
@@ -2515,17 +2661,59 @@ impl AgentPanel {
|
|||||||
.configured_model()?
|
.configured_model()?
|
||||||
.model;
|
.model;
|
||||||
|
|
||||||
let max_mode_upsell = if model.supports_max_mode() {
|
let focus_handle = self.focus_handle(cx);
|
||||||
" Enable max mode for unlimited tool use."
|
|
||||||
} else {
|
|
||||||
""
|
|
||||||
};
|
|
||||||
|
|
||||||
let banner = Banner::new()
|
let banner = Banner::new()
|
||||||
.severity(ui::Severity::Info)
|
.severity(ui::Severity::Info)
|
||||||
.child(h_flex().child(Label::new(format!(
|
.child(Label::new("Consecutive tool use limit reached.").size(LabelSize::Small))
|
||||||
"Consecutive tool use limit reached.{max_mode_upsell}"
|
.action_slot(
|
||||||
))));
|
h_flex()
|
||||||
|
.gap_1()
|
||||||
|
.child(
|
||||||
|
Button::new("continue-conversation", "Continue")
|
||||||
|
.layer(ElevationIndex::ModalSurface)
|
||||||
|
.label_size(LabelSize::Small)
|
||||||
|
.key_binding(
|
||||||
|
KeyBinding::for_action_in(
|
||||||
|
&ContinueThread,
|
||||||
|
&focus_handle,
|
||||||
|
window,
|
||||||
|
cx,
|
||||||
|
)
|
||||||
|
.map(|kb| kb.size(rems_from_px(10.))),
|
||||||
|
)
|
||||||
|
.on_click(cx.listener(|this, _, window, cx| {
|
||||||
|
this.continue_conversation(window, cx);
|
||||||
|
})),
|
||||||
|
)
|
||||||
|
.when(model.supports_max_mode(), |this| {
|
||||||
|
this.child(
|
||||||
|
Button::new("continue-burn-mode", "Continue with Burn Mode")
|
||||||
|
.style(ButtonStyle::Filled)
|
||||||
|
.style(ButtonStyle::Tinted(ui::TintColor::Accent))
|
||||||
|
.layer(ElevationIndex::ModalSurface)
|
||||||
|
.label_size(LabelSize::Small)
|
||||||
|
.key_binding(
|
||||||
|
KeyBinding::for_action_in(
|
||||||
|
&ContinueWithBurnMode,
|
||||||
|
&focus_handle,
|
||||||
|
window,
|
||||||
|
cx,
|
||||||
|
)
|
||||||
|
.map(|kb| kb.size(rems_from_px(10.))),
|
||||||
|
)
|
||||||
|
.tooltip(Tooltip::text("Enable Burn Mode for unlimited tool use."))
|
||||||
|
.on_click(cx.listener(|this, _, window, cx| {
|
||||||
|
this.thread.update(cx, |active_thread, cx| {
|
||||||
|
active_thread.thread().update(cx, |thread, _cx| {
|
||||||
|
thread.set_completion_mode(CompletionMode::Burn);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
this.continue_conversation(window, cx);
|
||||||
|
})),
|
||||||
|
)
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
|
||||||
Some(div().px_2().pb_2().child(banner).into_any_element())
|
Some(div().px_2().pb_2().child(banner).into_any_element())
|
||||||
}
|
}
|
||||||
@@ -2722,7 +2910,7 @@ impl AgentPanel {
|
|||||||
) -> Div {
|
) -> Div {
|
||||||
let mut registrar = buffer_search::DivRegistrar::new(
|
let mut registrar = buffer_search::DivRegistrar::new(
|
||||||
|this, _, _cx| match &this.active_view {
|
|this, _, _cx| match &this.active_view {
|
||||||
ActiveView::PromptEditor {
|
ActiveView::TextThread {
|
||||||
buffer_search_bar, ..
|
buffer_search_bar, ..
|
||||||
} => Some(buffer_search_bar.clone()),
|
} => Some(buffer_search_bar.clone()),
|
||||||
_ => None,
|
_ => None,
|
||||||
@@ -2840,7 +3028,7 @@ impl AgentPanel {
|
|||||||
.detach();
|
.detach();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
ActiveView::PromptEditor { context_editor, .. } => {
|
ActiveView::TextThread { context_editor, .. } => {
|
||||||
context_editor.update(cx, |context_editor, cx| {
|
context_editor.update(cx, |context_editor, cx| {
|
||||||
ContextEditor::insert_dragged_files(
|
ContextEditor::insert_dragged_files(
|
||||||
context_editor,
|
context_editor,
|
||||||
@@ -2867,7 +3055,7 @@ impl AgentPanel {
|
|||||||
fn key_context(&self) -> KeyContext {
|
fn key_context(&self) -> KeyContext {
|
||||||
let mut key_context = KeyContext::new_with_defaults();
|
let mut key_context = KeyContext::new_with_defaults();
|
||||||
key_context.add("AgentPanel");
|
key_context.add("AgentPanel");
|
||||||
if matches!(self.active_view, ActiveView::PromptEditor { .. }) {
|
if matches!(self.active_view, ActiveView::TextThread { .. }) {
|
||||||
key_context.add("prompt_editor");
|
key_context.add("prompt_editor");
|
||||||
}
|
}
|
||||||
key_context
|
key_context
|
||||||
@@ -2880,9 +3068,9 @@ impl Render for AgentPanel {
|
|||||||
// non-obvious implications to the layout of children.
|
// non-obvious implications to the layout of children.
|
||||||
//
|
//
|
||||||
// If you need to change it, please confirm:
|
// If you need to change it, please confirm:
|
||||||
// - The message editor expands (⌘esc) correctly
|
// - The message editor expands (cmd-option-esc) correctly
|
||||||
// - When expanded, the buttons at the bottom of the panel are displayed correctly
|
// - When expanded, the buttons at the bottom of the panel are displayed correctly
|
||||||
// - Font size works as expected and can be changed with ⌘+/⌘-
|
// - Font size works as expected and can be changed with cmd-+/cmd-
|
||||||
// - Scrolling in all views works as expected
|
// - Scrolling in all views works as expected
|
||||||
// - Files can be dropped into the panel
|
// - Files can be dropped into the panel
|
||||||
let content = v_flex()
|
let content = v_flex()
|
||||||
@@ -2909,19 +3097,31 @@ impl Render for AgentPanel {
|
|||||||
.on_action(cx.listener(Self::decrease_font_size))
|
.on_action(cx.listener(Self::decrease_font_size))
|
||||||
.on_action(cx.listener(Self::reset_font_size))
|
.on_action(cx.listener(Self::reset_font_size))
|
||||||
.on_action(cx.listener(Self::toggle_zoom))
|
.on_action(cx.listener(Self::toggle_zoom))
|
||||||
|
.on_action(cx.listener(|this, _: &ContinueThread, window, cx| {
|
||||||
|
this.continue_conversation(window, cx);
|
||||||
|
}))
|
||||||
|
.on_action(cx.listener(|this, _: &ContinueWithBurnMode, window, cx| {
|
||||||
|
this.thread.update(cx, |active_thread, cx| {
|
||||||
|
active_thread.thread().update(cx, |thread, _cx| {
|
||||||
|
thread.set_completion_mode(CompletionMode::Burn);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
this.continue_conversation(window, cx);
|
||||||
|
}))
|
||||||
|
.on_action(cx.listener(Self::toggle_burn_mode))
|
||||||
.child(self.render_toolbar(window, cx))
|
.child(self.render_toolbar(window, cx))
|
||||||
.children(self.render_trial_upsell(window, cx))
|
.children(self.render_upsell(window, cx))
|
||||||
.children(self.render_trial_end_upsell(window, cx))
|
.children(self.render_trial_end_upsell(window, cx))
|
||||||
.map(|parent| match &self.active_view {
|
.map(|parent| match &self.active_view {
|
||||||
ActiveView::Thread { .. } => parent
|
ActiveView::Thread { .. } => parent
|
||||||
.relative()
|
.relative()
|
||||||
.child(self.render_active_thread_or_empty_state(window, cx))
|
.child(self.render_active_thread_or_empty_state(window, cx))
|
||||||
.children(self.render_tool_use_limit_reached(cx))
|
.children(self.render_tool_use_limit_reached(window, cx))
|
||||||
.child(h_flex().child(self.message_editor.clone()))
|
.child(h_flex().child(self.message_editor.clone()))
|
||||||
.children(self.render_last_error(cx))
|
.children(self.render_last_error(cx))
|
||||||
.child(self.render_drag_target(cx)),
|
.child(self.render_drag_target(cx)),
|
||||||
ActiveView::History => parent.child(self.history.clone()),
|
ActiveView::History => parent.child(self.history.clone()),
|
||||||
ActiveView::PromptEditor {
|
ActiveView::TextThread {
|
||||||
context_editor,
|
context_editor,
|
||||||
buffer_search_bar,
|
buffer_search_bar,
|
||||||
..
|
..
|
||||||
@@ -3099,9 +3299,9 @@ impl AgentPanelDelegate for ConcreteAssistantPanelDelegate {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
struct TrialUpsell;
|
struct Upsell;
|
||||||
|
|
||||||
impl Dismissable for TrialUpsell {
|
impl Dismissable for Upsell {
|
||||||
const KEY: &'static str = "dismissed-trial-upsell";
|
const KEY: &'static str = "dismissed-trial-upsell";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
334
crates/agent/src/agent_profile.rs
Normal file
@@ -0,0 +1,334 @@
|
|||||||
|
use std::sync::Arc;
|
||||||
|
|
||||||
|
use agent_settings::{AgentProfileId, AgentProfileSettings, AgentSettings};
|
||||||
|
use assistant_tool::{Tool, ToolSource, ToolWorkingSet};
|
||||||
|
use collections::IndexMap;
|
||||||
|
use convert_case::{Case, Casing};
|
||||||
|
use fs::Fs;
|
||||||
|
use gpui::{App, Entity};
|
||||||
|
use settings::{Settings, update_settings_file};
|
||||||
|
use ui::SharedString;
|
||||||
|
use util::ResultExt;
|
||||||
|
|
||||||
|
#[derive(Clone, Debug, Eq, PartialEq)]
|
||||||
|
pub struct AgentProfile {
|
||||||
|
id: AgentProfileId,
|
||||||
|
tool_set: Entity<ToolWorkingSet>,
|
||||||
|
}
|
||||||
|
|
||||||
|
pub type AvailableProfiles = IndexMap<AgentProfileId, SharedString>;
|
||||||
|
|
||||||
|
impl AgentProfile {
|
||||||
|
pub fn new(id: AgentProfileId, tool_set: Entity<ToolWorkingSet>) -> Self {
|
||||||
|
Self { id, tool_set }
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Saves a new profile to the settings.
|
||||||
|
pub fn create(
|
||||||
|
name: String,
|
||||||
|
base_profile_id: Option<AgentProfileId>,
|
||||||
|
fs: Arc<dyn Fs>,
|
||||||
|
cx: &App,
|
||||||
|
) -> AgentProfileId {
|
||||||
|
let id = AgentProfileId(name.to_case(Case::Kebab).into());
|
||||||
|
|
||||||
|
let base_profile =
|
||||||
|
base_profile_id.and_then(|id| AgentSettings::get_global(cx).profiles.get(&id).cloned());
|
||||||
|
|
||||||
|
let profile_settings = AgentProfileSettings {
|
||||||
|
name: name.into(),
|
||||||
|
tools: base_profile
|
||||||
|
.as_ref()
|
||||||
|
.map(|profile| profile.tools.clone())
|
||||||
|
.unwrap_or_default(),
|
||||||
|
enable_all_context_servers: base_profile
|
||||||
|
.as_ref()
|
||||||
|
.map(|profile| profile.enable_all_context_servers)
|
||||||
|
.unwrap_or_default(),
|
||||||
|
context_servers: base_profile
|
||||||
|
.map(|profile| profile.context_servers)
|
||||||
|
.unwrap_or_default(),
|
||||||
|
};
|
||||||
|
|
||||||
|
update_settings_file::<AgentSettings>(fs, cx, {
|
||||||
|
let id = id.clone();
|
||||||
|
move |settings, _cx| {
|
||||||
|
settings.create_profile(id, profile_settings).log_err();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
id
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Returns a map of AgentProfileIds to their names
|
||||||
|
pub fn available_profiles(cx: &App) -> AvailableProfiles {
|
||||||
|
let mut profiles = AvailableProfiles::default();
|
||||||
|
for (id, profile) in AgentSettings::get_global(cx).profiles.iter() {
|
||||||
|
profiles.insert(id.clone(), profile.name.clone());
|
||||||
|
}
|
||||||
|
profiles
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn id(&self) -> &AgentProfileId {
|
||||||
|
&self.id
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn enabled_tools(&self, cx: &App) -> Vec<Arc<dyn Tool>> {
|
||||||
|
let Some(settings) = AgentSettings::get_global(cx).profiles.get(&self.id) else {
|
||||||
|
return Vec::new();
|
||||||
|
};
|
||||||
|
|
||||||
|
self.tool_set
|
||||||
|
.read(cx)
|
||||||
|
.tools(cx)
|
||||||
|
.into_iter()
|
||||||
|
.filter(|tool| Self::is_enabled(settings, tool.source(), tool.name()))
|
||||||
|
.collect()
|
||||||
|
}
|
||||||
|
|
||||||
|
fn is_enabled(settings: &AgentProfileSettings, source: ToolSource, name: String) -> bool {
|
||||||
|
match source {
|
||||||
|
ToolSource::Native => *settings.tools.get(name.as_str()).unwrap_or(&false),
|
||||||
|
ToolSource::ContextServer { id } => {
|
||||||
|
if settings.enable_all_context_servers {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
let Some(preset) = settings.context_servers.get(id.as_ref()) else {
|
||||||
|
return false;
|
||||||
|
};
|
||||||
|
*preset.tools.get(name.as_str()).unwrap_or(&false)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
|
mod tests {
|
||||||
|
use agent_settings::ContextServerPreset;
|
||||||
|
use assistant_tool::ToolRegistry;
|
||||||
|
use collections::IndexMap;
|
||||||
|
use gpui::{AppContext, TestAppContext};
|
||||||
|
use http_client::FakeHttpClient;
|
||||||
|
use project::Project;
|
||||||
|
use settings::{Settings, SettingsStore};
|
||||||
|
use ui::SharedString;
|
||||||
|
|
||||||
|
use super::*;
|
||||||
|
|
||||||
|
#[gpui::test]
|
||||||
|
async fn test_enabled_built_in_tools_for_profile(cx: &mut TestAppContext) {
|
||||||
|
init_test_settings(cx);
|
||||||
|
|
||||||
|
let id = AgentProfileId::default();
|
||||||
|
let profile_settings = cx.read(|cx| {
|
||||||
|
AgentSettings::get_global(cx)
|
||||||
|
.profiles
|
||||||
|
.get(&id)
|
||||||
|
.unwrap()
|
||||||
|
.clone()
|
||||||
|
});
|
||||||
|
let tool_set = default_tool_set(cx);
|
||||||
|
|
||||||
|
let profile = AgentProfile::new(id.clone(), tool_set);
|
||||||
|
|
||||||
|
let mut enabled_tools = cx
|
||||||
|
.read(|cx| profile.enabled_tools(cx))
|
||||||
|
.into_iter()
|
||||||
|
.map(|tool| tool.name())
|
||||||
|
.collect::<Vec<_>>();
|
||||||
|
enabled_tools.sort();
|
||||||
|
|
||||||
|
let mut expected_tools = profile_settings
|
||||||
|
.tools
|
||||||
|
.into_iter()
|
||||||
|
.filter_map(|(tool, enabled)| enabled.then_some(tool.to_string()))
|
||||||
|
// Provider dependent
|
||||||
|
.filter(|tool| tool != "web_search")
|
||||||
|
.collect::<Vec<_>>();
|
||||||
|
// Plus all registered MCP tools
|
||||||
|
expected_tools.extend(["enabled_mcp_tool".into(), "disabled_mcp_tool".into()]);
|
||||||
|
expected_tools.sort();
|
||||||
|
|
||||||
|
assert_eq!(enabled_tools, expected_tools);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[gpui::test]
|
||||||
|
async fn test_custom_mcp_settings(cx: &mut TestAppContext) {
|
||||||
|
init_test_settings(cx);
|
||||||
|
|
||||||
|
let id = AgentProfileId("custom_mcp".into());
|
||||||
|
let profile_settings = cx.read(|cx| {
|
||||||
|
AgentSettings::get_global(cx)
|
||||||
|
.profiles
|
||||||
|
.get(&id)
|
||||||
|
.unwrap()
|
||||||
|
.clone()
|
||||||
|
});
|
||||||
|
let tool_set = default_tool_set(cx);
|
||||||
|
|
||||||
|
let profile = AgentProfile::new(id.clone(), tool_set);
|
||||||
|
|
||||||
|
let mut enabled_tools = cx
|
||||||
|
.read(|cx| profile.enabled_tools(cx))
|
||||||
|
.into_iter()
|
||||||
|
.map(|tool| tool.name())
|
||||||
|
.collect::<Vec<_>>();
|
||||||
|
enabled_tools.sort();
|
||||||
|
|
||||||
|
let mut expected_tools = profile_settings.context_servers["mcp"]
|
||||||
|
.tools
|
||||||
|
.iter()
|
||||||
|
.filter_map(|(key, enabled)| enabled.then(|| key.to_string()))
|
||||||
|
.collect::<Vec<_>>();
|
||||||
|
expected_tools.sort();
|
||||||
|
|
||||||
|
assert_eq!(enabled_tools, expected_tools);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[gpui::test]
|
||||||
|
async fn test_only_built_in(cx: &mut TestAppContext) {
|
||||||
|
init_test_settings(cx);
|
||||||
|
|
||||||
|
let id = AgentProfileId("write_minus_mcp".into());
|
||||||
|
let profile_settings = cx.read(|cx| {
|
||||||
|
AgentSettings::get_global(cx)
|
||||||
|
.profiles
|
||||||
|
.get(&id)
|
||||||
|
.unwrap()
|
||||||
|
.clone()
|
||||||
|
});
|
||||||
|
let tool_set = default_tool_set(cx);
|
||||||
|
|
||||||
|
let profile = AgentProfile::new(id.clone(), tool_set);
|
||||||
|
|
||||||
|
let mut enabled_tools = cx
|
||||||
|
.read(|cx| profile.enabled_tools(cx))
|
||||||
|
.into_iter()
|
||||||
|
.map(|tool| tool.name())
|
||||||
|
.collect::<Vec<_>>();
|
||||||
|
enabled_tools.sort();
|
||||||
|
|
||||||
|
let mut expected_tools = profile_settings
|
||||||
|
.tools
|
||||||
|
.into_iter()
|
||||||
|
.filter_map(|(tool, enabled)| enabled.then_some(tool.to_string()))
|
||||||
|
// Provider dependent
|
||||||
|
.filter(|tool| tool != "web_search")
|
||||||
|
.collect::<Vec<_>>();
|
||||||
|
expected_tools.sort();
|
||||||
|
|
||||||
|
assert_eq!(enabled_tools, expected_tools);
|
||||||
|
}
|
||||||
|
|
||||||
|
fn init_test_settings(cx: &mut TestAppContext) {
|
||||||
|
cx.update(|cx| {
|
||||||
|
let settings_store = SettingsStore::test(cx);
|
||||||
|
cx.set_global(settings_store);
|
||||||
|
Project::init_settings(cx);
|
||||||
|
AgentSettings::register(cx);
|
||||||
|
language_model::init_settings(cx);
|
||||||
|
ToolRegistry::default_global(cx);
|
||||||
|
assistant_tools::init(FakeHttpClient::with_404_response(), cx);
|
||||||
|
});
|
||||||
|
|
||||||
|
cx.update(|cx| {
|
||||||
|
let mut agent_settings = AgentSettings::get_global(cx).clone();
|
||||||
|
agent_settings.profiles.insert(
|
||||||
|
AgentProfileId("write_minus_mcp".into()),
|
||||||
|
AgentProfileSettings {
|
||||||
|
name: "write_minus_mcp".into(),
|
||||||
|
enable_all_context_servers: false,
|
||||||
|
..agent_settings.profiles[&AgentProfileId::default()].clone()
|
||||||
|
},
|
||||||
|
);
|
||||||
|
agent_settings.profiles.insert(
|
||||||
|
AgentProfileId("custom_mcp".into()),
|
||||||
|
AgentProfileSettings {
|
||||||
|
name: "mcp".into(),
|
||||||
|
tools: IndexMap::default(),
|
||||||
|
enable_all_context_servers: false,
|
||||||
|
context_servers: IndexMap::from_iter([("mcp".into(), context_server_preset())]),
|
||||||
|
},
|
||||||
|
);
|
||||||
|
AgentSettings::override_global(agent_settings, cx);
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
fn context_server_preset() -> ContextServerPreset {
|
||||||
|
ContextServerPreset {
|
||||||
|
tools: IndexMap::from_iter([
|
||||||
|
("enabled_mcp_tool".into(), true),
|
||||||
|
("disabled_mcp_tool".into(), false),
|
||||||
|
]),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn default_tool_set(cx: &mut TestAppContext) -> Entity<ToolWorkingSet> {
|
||||||
|
cx.new(|_| {
|
||||||
|
let mut tool_set = ToolWorkingSet::default();
|
||||||
|
tool_set.insert(Arc::new(FakeTool::new("enabled_mcp_tool", "mcp")));
|
||||||
|
tool_set.insert(Arc::new(FakeTool::new("disabled_mcp_tool", "mcp")));
|
||||||
|
tool_set
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
struct FakeTool {
|
||||||
|
name: String,
|
||||||
|
source: SharedString,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl FakeTool {
|
||||||
|
fn new(name: impl Into<String>, source: impl Into<SharedString>) -> Self {
|
||||||
|
Self {
|
||||||
|
name: name.into(),
|
||||||
|
source: source.into(),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Tool for FakeTool {
|
||||||
|
fn name(&self) -> String {
|
||||||
|
self.name.clone()
|
||||||
|
}
|
||||||
|
|
||||||
|
fn source(&self) -> ToolSource {
|
||||||
|
ToolSource::ContextServer {
|
||||||
|
id: self.source.clone(),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn description(&self) -> String {
|
||||||
|
unimplemented!()
|
||||||
|
}
|
||||||
|
|
||||||
|
fn icon(&self) -> ui::IconName {
|
||||||
|
unimplemented!()
|
||||||
|
}
|
||||||
|
|
||||||
|
fn needs_confirmation(&self, _input: &serde_json::Value, _cx: &App) -> bool {
|
||||||
|
unimplemented!()
|
||||||
|
}
|
||||||
|
|
||||||
|
fn ui_text(&self, _input: &serde_json::Value) -> String {
|
||||||
|
unimplemented!()
|
||||||
|
}
|
||||||
|
|
||||||
|
fn run(
|
||||||
|
self: Arc<Self>,
|
||||||
|
_input: serde_json::Value,
|
||||||
|
_request: Arc<language_model::LanguageModelRequest>,
|
||||||
|
_project: Entity<Project>,
|
||||||
|
_action_log: Entity<assistant_tool::ActionLog>,
|
||||||
|
_model: Arc<dyn language_model::LanguageModel>,
|
||||||
|
_window: Option<gpui::AnyWindowHandle>,
|
||||||
|
_cx: &mut App,
|
||||||
|
) -> assistant_tool::ToolResult {
|
||||||
|
unimplemented!()
|
||||||
|
}
|
||||||
|
|
||||||
|
fn may_perform_edits(&self) -> bool {
|
||||||
|
unimplemented!()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -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::{Context as _, 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,6 +34,7 @@ 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>>,
|
||||||
@@ -443,7 +444,7 @@ impl CodegenAlternative {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
let temperature = AssistantSettings::temperature_for_model(&model, cx);
|
let temperature = AgentSettings::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 {
|
||||||
@@ -464,6 +465,7 @@ 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,
|
||||||
|
|||||||
@@ -734,6 +734,7 @@ 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`.
|
||||||
@@ -744,6 +745,7 @@ pub struct ImageContext {
|
|||||||
pub enum ImageStatus {
|
pub enum ImageStatus {
|
||||||
Loading,
|
Loading,
|
||||||
Error,
|
Error,
|
||||||
|
Warning,
|
||||||
Ready,
|
Ready,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -760,11 +762,17 @@ impl ImageContext {
|
|||||||
self.image_task.clone().now_or_never().flatten()
|
self.image_task.clone().now_or_never().flatten()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn status(&self) -> ImageStatus {
|
pub fn status(&self, model: Option<&Arc<dyn language_model::LanguageModel>>) -> 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(_)) => ImageStatus::Ready,
|
Some(Some(_)) => {
|
||||||
|
if model.is_some_and(|model| !model.supports_images()) {
|
||||||
|
ImageStatus::Warning
|
||||||
|
} else {
|
||||||
|
ImageStatus::Ready
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -766,6 +766,7 @@ 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])
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,5 @@
|
|||||||
use std::cell::RefCell;
|
|
||||||
use std::ops::Range;
|
use std::ops::Range;
|
||||||
use std::path::{Path, PathBuf};
|
use std::path::{Path, PathBuf};
|
||||||
use std::rc::Rc;
|
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
use std::sync::atomic::AtomicBool;
|
use std::sync::atomic::AtomicBool;
|
||||||
|
|
||||||
@@ -14,7 +12,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, ProjectPath, Symbol, WorktreeId};
|
use project::{Completion, CompletionIntent, CompletionResponse, 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,7 +320,10 @@ impl ContextPickerCompletionProvider {
|
|||||||
})
|
})
|
||||||
.collect::<Vec<_>>();
|
.collect::<Vec<_>>();
|
||||||
|
|
||||||
let new_text = selection_infos.iter().map(|(_, link, _)| link).join(" ");
|
let new_text = format!(
|
||||||
|
"{} ",
|
||||||
|
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();
|
||||||
@@ -420,7 +421,7 @@ impl ContextPickerCompletionProvider {
|
|||||||
} else {
|
} else {
|
||||||
IconName::MessageBubbles
|
IconName::MessageBubbles
|
||||||
};
|
};
|
||||||
let new_text = MentionLink::for_thread(&thread_entry);
|
let new_text = format!("{} ", 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(),
|
||||||
@@ -435,7 +436,7 @@ impl ContextPickerCompletionProvider {
|
|||||||
thread_entry.title().clone(),
|
thread_entry.title().clone(),
|
||||||
excerpt_id,
|
excerpt_id,
|
||||||
source_range.start,
|
source_range.start,
|
||||||
new_text_len,
|
new_text_len - 1,
|
||||||
editor.clone(),
|
editor.clone(),
|
||||||
context_store.clone(),
|
context_store.clone(),
|
||||||
move |window, cx| match &thread_entry {
|
move |window, cx| match &thread_entry {
|
||||||
@@ -489,7 +490,7 @@ impl ContextPickerCompletionProvider {
|
|||||||
editor: Entity<Editor>,
|
editor: Entity<Editor>,
|
||||||
context_store: Entity<ContextStore>,
|
context_store: Entity<ContextStore>,
|
||||||
) -> Completion {
|
) -> Completion {
|
||||||
let new_text = MentionLink::for_rule(&rules);
|
let new_text = format!("{} ", 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(),
|
||||||
@@ -504,7 +505,7 @@ impl ContextPickerCompletionProvider {
|
|||||||
rules.title.clone(),
|
rules.title.clone(),
|
||||||
excerpt_id,
|
excerpt_id,
|
||||||
source_range.start,
|
source_range.start,
|
||||||
new_text_len,
|
new_text_len - 1,
|
||||||
editor.clone(),
|
editor.clone(),
|
||||||
context_store.clone(),
|
context_store.clone(),
|
||||||
move |_, cx| {
|
move |_, cx| {
|
||||||
@@ -526,7 +527,7 @@ impl ContextPickerCompletionProvider {
|
|||||||
context_store: Entity<ContextStore>,
|
context_store: Entity<ContextStore>,
|
||||||
http_client: Arc<HttpClientWithUrl>,
|
http_client: Arc<HttpClientWithUrl>,
|
||||||
) -> Completion {
|
) -> Completion {
|
||||||
let new_text = MentionLink::for_fetch(&url_to_fetch);
|
let new_text = format!("{} ", 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(),
|
||||||
@@ -541,7 +542,7 @@ impl ContextPickerCompletionProvider {
|
|||||||
url_to_fetch.clone(),
|
url_to_fetch.clone(),
|
||||||
excerpt_id,
|
excerpt_id,
|
||||||
source_range.start,
|
source_range.start,
|
||||||
new_text_len,
|
new_text_len - 1,
|
||||||
editor.clone(),
|
editor.clone(),
|
||||||
context_store.clone(),
|
context_store.clone(),
|
||||||
move |_, cx| {
|
move |_, cx| {
|
||||||
@@ -550,7 +551,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
|
||||||
.update(cx, |context_store, _| {
|
.read_with(cx, |context_store, _| {
|
||||||
context_store.get_url_context(url_to_fetch.clone())
|
context_store.get_url_context(url_to_fetch.clone())
|
||||||
})
|
})
|
||||||
.ok()?
|
.ok()?
|
||||||
@@ -611,7 +612,7 @@ impl ContextPickerCompletionProvider {
|
|||||||
crease_icon_path.clone()
|
crease_icon_path.clone()
|
||||||
};
|
};
|
||||||
|
|
||||||
let new_text = MentionLink::for_file(&file_name, &full_path);
|
let new_text = format!("{} ", 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(),
|
||||||
@@ -626,7 +627,7 @@ impl ContextPickerCompletionProvider {
|
|||||||
file_name,
|
file_name,
|
||||||
excerpt_id,
|
excerpt_id,
|
||||||
source_range.start,
|
source_range.start,
|
||||||
new_text_len,
|
new_text_len - 1,
|
||||||
editor,
|
editor,
|
||||||
context_store.clone(),
|
context_store.clone(),
|
||||||
move |_, cx| {
|
move |_, cx| {
|
||||||
@@ -682,7 +683,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 = MentionLink::for_symbol(&symbol.name, &full_path);
|
let new_text = format!("{} ", 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(),
|
||||||
@@ -697,7 +698,7 @@ impl ContextPickerCompletionProvider {
|
|||||||
symbol.name.clone().into(),
|
symbol.name.clone().into(),
|
||||||
excerpt_id,
|
excerpt_id,
|
||||||
source_range.start,
|
source_range.start,
|
||||||
new_text_len,
|
new_text_len - 1,
|
||||||
editor.clone(),
|
editor.clone(),
|
||||||
context_store.clone(),
|
context_store.clone(),
|
||||||
move |_, cx| {
|
move |_, cx| {
|
||||||
@@ -743,7 +744,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<Option<Vec<Completion>>>> {
|
) -> Task<Result<Vec<CompletionResponse>>> {
|
||||||
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);
|
||||||
@@ -753,18 +754,18 @@ 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(None));
|
return Task::ready(Ok(Vec::new()));
|
||||||
};
|
};
|
||||||
|
|
||||||
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(None));
|
return Task::ready(Ok(Vec::new()));
|
||||||
};
|
};
|
||||||
|
|
||||||
let snapshot = buffer.read(cx).snapshot();
|
let snapshot = buffer.read(cx).snapshot();
|
||||||
let source_range = snapshot.anchor_before(state.source_range.start)
|
let source_range = snapshot.anchor_before(state.source_range.start)
|
||||||
..snapshot.anchor_before(state.source_range.end);
|
..snapshot.anchor_after(state.source_range.end);
|
||||||
|
|
||||||
let thread_store = self.thread_store.clone();
|
let thread_store = self.thread_store.clone();
|
||||||
let text_thread_store = self.text_thread_store.clone();
|
let text_thread_store = self.text_thread_store.clone();
|
||||||
@@ -812,10 +813,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(None);
|
return Ok(Vec::new());
|
||||||
};
|
};
|
||||||
|
|
||||||
Ok(Some(cx.update(|cx| {
|
let completions = cx.update(|cx| {
|
||||||
matches
|
matches
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.filter_map(|mat| match mat {
|
.filter_map(|mat| match mat {
|
||||||
@@ -898,26 +899,24 @@ impl CompletionProvider for ContextPickerCompletionProvider {
|
|||||||
),
|
),
|
||||||
})
|
})
|
||||||
.collect()
|
.collect()
|
||||||
})?))
|
})?;
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
fn resolve_completions(
|
Ok(vec![CompletionResponse {
|
||||||
&self,
|
completions,
|
||||||
_buffer: Entity<Buffer>,
|
// Since this does its own filtering (see `filter_completions()` returns false),
|
||||||
_completion_indices: Vec<usize>,
|
// there is no benefit to computing whether this set of completions is incomplete.
|
||||||
_completions: Rc<RefCell<Box<[Completion]>>>,
|
is_incomplete: true,
|
||||||
_cx: &mut Context<Editor>,
|
}])
|
||||||
) -> Task<Result<bool>> {
|
})
|
||||||
Task::ready(Ok(true))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn is_completion_trigger(
|
fn is_completion_trigger(
|
||||||
&self,
|
&self,
|
||||||
buffer: &Entity<language::Buffer>,
|
buffer: &Entity<language::Buffer>,
|
||||||
position: language::Anchor,
|
position: language::Anchor,
|
||||||
_: &str,
|
_text: &str,
|
||||||
_: bool,
|
_trigger_in_words: 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);
|
||||||
@@ -1066,7 +1065,7 @@ mod tests {
|
|||||||
use project::{Project, ProjectPath};
|
use project::{Project, ProjectPath};
|
||||||
use serde_json::json;
|
use serde_json::json;
|
||||||
use settings::SettingsStore;
|
use settings::SettingsStore;
|
||||||
use std::ops::Deref;
|
use std::{ops::Deref, rc::Rc};
|
||||||
use util::{path, separator};
|
use util::{path, separator};
|
||||||
use workspace::{AppState, Item};
|
use workspace::{AppState, Item};
|
||||||
|
|
||||||
@@ -1213,7 +1212,7 @@ mod tests {
|
|||||||
assert_eq!(worktrees.len(), 1);
|
assert_eq!(worktrees.len(), 1);
|
||||||
worktrees.pop().unwrap()
|
worktrees.pop().unwrap()
|
||||||
});
|
});
|
||||||
let worktree_id = worktree.update(cx, |worktree, _| worktree.id());
|
let worktree_id = worktree.read_with(cx, |worktree, _| worktree.id());
|
||||||
|
|
||||||
let mut cx = VisualTestContext::from_window(*window.deref(), cx);
|
let mut cx = VisualTestContext::from_window(*window.deref(), cx);
|
||||||
|
|
||||||
@@ -1286,7 +1285,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(Box::new(ContextPickerCompletionProvider::new(
|
editor.set_completion_provider(Some(Rc::new(ContextPickerCompletionProvider::new(
|
||||||
workspace.downgrade(),
|
workspace.downgrade(),
|
||||||
context_store.downgrade(),
|
context_store.downgrade(),
|
||||||
None,
|
None,
|
||||||
@@ -1353,7 +1352,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),
|
||||||
@@ -1364,7 +1363,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),
|
||||||
@@ -1377,7 +1376,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!(
|
||||||
@@ -1391,7 +1390,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!(
|
||||||
@@ -1409,14 +1408,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, 44)..Point::new(0, 79)
|
Point::new(0, 45)..Point::new(0, 80)
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
@@ -1426,14 +1425,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, 44)..Point::new(0, 79)
|
Point::new(0, 45)..Point::new(0, 80)
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
@@ -1447,14 +1446,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, 44)..Point::new(0, 79),
|
Point::new(0, 45)..Point::new(0, 80),
|
||||||
Point::new(1, 0)..Point::new(1, 31)
|
Point::new(1, 0)..Point::new(1, 31)
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -51,6 +51,10 @@ 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)?;
|
||||||
@@ -100,7 +104,15 @@ impl Tool for ContextServerTool {
|
|||||||
tool_name,
|
tool_name,
|
||||||
arguments
|
arguments
|
||||||
);
|
);
|
||||||
let response = protocol.run_tool(tool_name, arguments).await?;
|
let response = protocol
|
||||||
|
.request::<context_server::types::request::CallTool>(
|
||||||
|
context_server::types::CallToolParams {
|
||||||
|
name: tool_name,
|
||||||
|
arguments,
|
||||||
|
meta: None,
|
||||||
|
},
|
||||||
|
)
|
||||||
|
.await?;
|
||||||
|
|
||||||
let mut result = String::new();
|
let mut result = String::new();
|
||||||
for content in response.content {
|
for content in response.content {
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ 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;
|
use language::{Buffer, File as _};
|
||||||
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,9 +58,10 @@ 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) {
|
pub fn clear(&mut self, cx: &mut Context<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(
|
||||||
@@ -303,11 +304,13 @@ 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(image_item.read(cx).project_path(cx)),
|
Some(item.project_path(cx)),
|
||||||
image,
|
Some(item.file.full_path(cx).into()),
|
||||||
|
item.image.clone(),
|
||||||
remove_if_exists,
|
remove_if_exists,
|
||||||
cx,
|
cx,
|
||||||
)
|
)
|
||||||
@@ -316,12 +319,13 @@ 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, image, false, cx);
|
self.insert_image(None, 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>,
|
||||||
@@ -329,6 +333,7 @@ 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,
|
||||||
RemoveAllContext, RemoveFocusedContext, ToggleContextPicker,
|
ModelUsageContext, RemoveAllContext, RemoveFocusedContext, ToggleContextPicker,
|
||||||
};
|
};
|
||||||
|
|
||||||
pub struct ContextStrip {
|
pub struct ContextStrip {
|
||||||
@@ -37,6 +37,7 @@ 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 {
|
||||||
@@ -47,6 +48,7 @@ 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 {
|
||||||
@@ -81,6 +83,7 @@ impl ContextStrip {
|
|||||||
_subscriptions: subscriptions,
|
_subscriptions: subscriptions,
|
||||||
focused_index: None,
|
focused_index: None,
|
||||||
children_bounds: None,
|
children_bounds: None,
|
||||||
|
model_usage_context,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -98,11 +101,20 @@ 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(context.clone(), prompt_store, project, cx)
|
AddedContext::new_pending(
|
||||||
|
context.clone(),
|
||||||
|
prompt_store,
|
||||||
|
project,
|
||||||
|
current_model.as_ref(),
|
||||||
|
cx,
|
||||||
|
)
|
||||||
})
|
})
|
||||||
.collect::<Vec<_>>()
|
.collect::<Vec<_>>()
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -152,7 +152,7 @@ impl HistoryStore {
|
|||||||
let entries = join_all(entries)
|
let entries = join_all(entries)
|
||||||
.await
|
.await
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.filter_map(|result| result.log_err())
|
.filter_map(|result| result.log_with_level(log::Level::Debug))
|
||||||
.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 = AssistantSettings::get_global(cx).enabled;
|
let enabled = AgentSettings::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 = AssistantSettings::get_global(cx);
|
let settings = AgentSettings::get_global(cx);
|
||||||
if !settings.enabled {
|
if !settings.enabled {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -1011,7 +1011,7 @@ impl InlineAssistant {
|
|||||||
self.update_editor_highlights(&editor, cx);
|
self.update_editor_highlights(&editor, cx);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
entry.get().highlight_updates.send(()).ok();
|
entry.get_mut().highlight_updates.send(()).ok();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1445,7 +1445,7 @@ impl InlineAssistant {
|
|||||||
style: BlockStyle::Flex,
|
style: BlockStyle::Flex,
|
||||||
render: Arc::new(move |cx| {
|
render: Arc::new(move |cx| {
|
||||||
div()
|
div()
|
||||||
.block_mouse_down()
|
.block_mouse_except_scroll()
|
||||||
.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())
|
||||||
@@ -1519,7 +1519,7 @@ impl InlineAssistant {
|
|||||||
struct EditorInlineAssists {
|
struct EditorInlineAssists {
|
||||||
assist_ids: Vec<InlineAssistId>,
|
assist_ids: Vec<InlineAssistId>,
|
||||||
scroll_lock: Option<InlineAssistScrollLock>,
|
scroll_lock: Option<InlineAssistScrollLock>,
|
||||||
highlight_updates: async_watch::Sender<()>,
|
highlight_updates: watch::Sender<()>,
|
||||||
_update_highlights: Task<Result<()>>,
|
_update_highlights: Task<Result<()>>,
|
||||||
_subscriptions: Vec<gpui::Subscription>,
|
_subscriptions: Vec<gpui::Subscription>,
|
||||||
}
|
}
|
||||||
@@ -1531,7 +1531,7 @@ struct InlineAssistScrollLock {
|
|||||||
|
|
||||||
impl EditorInlineAssists {
|
impl EditorInlineAssists {
|
||||||
fn new(editor: &Entity<Editor>, window: &mut Window, cx: &mut App) -> Self {
|
fn new(editor: &Entity<Editor>, window: &mut Window, cx: &mut App) -> Self {
|
||||||
let (highlight_updates_tx, mut highlight_updates_rx) = async_watch::channel(());
|
let (highlight_updates_tx, mut highlight_updates_rx) = watch::channel(());
|
||||||
Self {
|
Self {
|
||||||
assist_ids: Vec::new(),
|
assist_ids: Vec::new(),
|
||||||
scroll_lock: None,
|
scroll_lock: None,
|
||||||
@@ -1689,7 +1689,7 @@ impl InlineAssist {
|
|||||||
if let Some(editor) = editor.upgrade() {
|
if let Some(editor) = editor.upgrade() {
|
||||||
InlineAssistant::update_global(cx, |this, cx| {
|
InlineAssistant::update_global(cx, |this, cx| {
|
||||||
if let Some(editor_assists) =
|
if let Some(editor_assists) =
|
||||||
this.assists_by_editor.get(&editor.downgrade())
|
this.assists_by_editor.get_mut(&editor.downgrade())
|
||||||
{
|
{
|
||||||
editor_assists.highlight_updates.send(()).ok();
|
editor_assists.highlight_updates.send(()).ok();
|
||||||
}
|
}
|
||||||
@@ -1771,7 +1771,7 @@ impl CodeActionProvider for AssistantCodeActionProvider {
|
|||||||
_: &mut Window,
|
_: &mut Window,
|
||||||
cx: &mut App,
|
cx: &mut App,
|
||||||
) -> Task<Result<Vec<CodeAction>>> {
|
) -> Task<Result<Vec<CodeAction>>> {
|
||||||
if !AssistantSettings::get_global(cx).enabled {
|
if !AgentSettings::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, ModelType};
|
use crate::agent_model_selector::AgentModelSelector;
|
||||||
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,11 +7,13 @@ 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};
|
use crate::{CycleNextInlineAssist, CyclePreviousInlineAssist, ModelUsageContext};
|
||||||
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 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,
|
||||||
@@ -24,10 +26,10 @@ 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;
|
||||||
@@ -98,8 +100,9 @@ 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_down()
|
.block_mouse_except_scroll()
|
||||||
.gap_0p5()
|
.gap_0p5()
|
||||||
.border_y_1()
|
.border_y_1()
|
||||||
.border_color(cx.theme().status().info_border)
|
.border_color(cx.theme().status().info_border)
|
||||||
@@ -302,6 +305,10 @@ 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,
|
||||||
@@ -326,9 +333,7 @@ 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
|
let is_via_ssh = workspace.project().read(cx).is_via_ssh();
|
||||||
.project()
|
|
||||||
.update(cx, |project, _| project.is_via_ssh());
|
|
||||||
|
|
||||||
workspace
|
workspace
|
||||||
.client()
|
.client()
|
||||||
@@ -373,7 +378,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());
|
self.context_store.update(cx, |store, cx| store.clear(cx));
|
||||||
cx.notify();
|
cx.notify();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -892,7 +897,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(Box::new(ContextPickerCompletionProvider::new(
|
editor.set_completion_provider(Some(Rc::new(ContextPickerCompletionProvider::new(
|
||||||
workspace.clone(),
|
workspace.clone(),
|
||||||
context_store.downgrade(),
|
context_store.downgrade(),
|
||||||
thread_store.clone(),
|
thread_store.clone(),
|
||||||
@@ -913,6 +918,7 @@ 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,
|
||||||
)
|
)
|
||||||
@@ -931,7 +937,7 @@ impl PromptEditor<BufferCodegen> {
|
|||||||
fs,
|
fs,
|
||||||
model_selector_menu_handle,
|
model_selector_menu_handle,
|
||||||
prompt_editor.focus_handle(cx),
|
prompt_editor.focus_handle(cx),
|
||||||
ModelType::InlineAssistant,
|
ModelUsageContext::InlineAssistant,
|
||||||
window,
|
window,
|
||||||
cx,
|
cx,
|
||||||
)
|
)
|
||||||
@@ -1063,7 +1069,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(Box::new(ContextPickerCompletionProvider::new(
|
editor.set_completion_provider(Some(Rc::new(ContextPickerCompletionProvider::new(
|
||||||
workspace.clone(),
|
workspace.clone(),
|
||||||
context_store.downgrade(),
|
context_store.downgrade(),
|
||||||
thread_store.clone(),
|
thread_store.clone(),
|
||||||
@@ -1084,6 +1090,7 @@ 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,
|
||||||
)
|
)
|
||||||
@@ -1102,7 +1109,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),
|
||||||
ModelType::InlineAssistant,
|
ModelUsageContext::InlineAssistant,
|
||||||
window,
|
window,
|
||||||
cx,
|
cx,
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -1,14 +1,16 @@
|
|||||||
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, ModelType};
|
use crate::agent_model_selector::AgentModelSelector;
|
||||||
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::{
|
||||||
AnimatedLabel, MaxModeTooltip,
|
MaxModeTooltip,
|
||||||
preview::{AgentPreview, UsageCallout},
|
preview::{AgentPreview, UsageCallout},
|
||||||
};
|
};
|
||||||
use assistant_settings::{AssistantSettings, CompletionMode};
|
use agent_settings::{AgentSettings, 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};
|
||||||
@@ -22,15 +24,14 @@ 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, ClipboardEntry, Entity, EventEmitter, Focusable, Subscription,
|
Animation, AnimationExt, App, Entity, EventEmitter, Focusable, Subscription, Task, TextStyle,
|
||||||
Task, TextStyle, WeakEntity, linear_color_stop, linear_gradient, point, pulsating_between,
|
WeakEntity, linear_color_stop, linear_gradient, point, pulsating_between,
|
||||||
};
|
};
|
||||||
use language::{Buffer, Language};
|
use language::{Buffer, Language, Point};
|
||||||
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;
|
||||||
@@ -41,6 +42,7 @@ 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;
|
||||||
@@ -49,8 +51,9 @@ 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, ExpandMessageEditor, Follow, NewThread, OpenAgentDiff,
|
ActiveThread, AgentDiffPane, Chat, ChatWithFollow, ExpandMessageEditor, Follow, KeepAll,
|
||||||
RemoveAllContext, ToggleContextPicker, ToggleProfileSelector, register_agent_preview,
|
ModelUsageContext, NewThread, OpenAgentDiff, RejectAll, RemoveAllContext, ToggleBurnMode,
|
||||||
|
ToggleContextPicker, ToggleProfileSelector, register_agent_preview,
|
||||||
};
|
};
|
||||||
|
|
||||||
#[derive(RegisterComponent)]
|
#[derive(RegisterComponent)]
|
||||||
@@ -109,6 +112,7 @@ 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,
|
||||||
@@ -120,7 +124,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(Box::new(ContextPickerCompletionProvider::new(
|
editor.set_completion_provider(Some(Rc::new(ContextPickerCompletionProvider::new(
|
||||||
workspace,
|
workspace,
|
||||||
context_store,
|
context_store,
|
||||||
Some(thread_store),
|
Some(thread_store),
|
||||||
@@ -165,13 +169,13 @@ 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,
|
||||||
)
|
)
|
||||||
});
|
});
|
||||||
|
|
||||||
let incompatible_tools =
|
let incompatible_tools = cx.new(|cx| IncompatibleToolsState::new(thread.clone(), cx));
|
||||||
cx.new(|cx| IncompatibleToolsState::new(thread.read(cx).tools().clone(), cx));
|
|
||||||
|
|
||||||
let subscriptions = vec![
|
let subscriptions = vec![
|
||||||
cx.subscribe_in(&context_strip, window, Self::handle_context_strip_event),
|
cx.subscribe_in(&context_strip, window, Self::handle_context_strip_event),
|
||||||
@@ -193,21 +197,14 @@ impl MessageEditor {
|
|||||||
fs.clone(),
|
fs.clone(),
|
||||||
model_selector_menu_handle,
|
model_selector_menu_handle,
|
||||||
editor.focus_handle(cx),
|
editor.focus_handle(cx),
|
||||||
ModelType::Default(thread.clone()),
|
ModelUsageContext::Thread(thread.clone()),
|
||||||
window,
|
window,
|
||||||
cx,
|
cx,
|
||||||
)
|
)
|
||||||
});
|
});
|
||||||
|
|
||||||
let profile_selector = cx.new(|cx| {
|
let profile_selector =
|
||||||
ProfileSelector::new(
|
cx.new(|cx| ProfileSelector::new(fs, thread.clone(), editor.focus_handle(cx), cx));
|
||||||
fs,
|
|
||||||
thread.clone(),
|
|
||||||
thread_store,
|
|
||||||
editor.focus_handle(cx),
|
|
||||||
cx,
|
|
||||||
)
|
|
||||||
});
|
|
||||||
|
|
||||||
Self {
|
Self {
|
||||||
editor: editor.clone(),
|
editor: editor.clone(),
|
||||||
@@ -278,7 +275,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());
|
self.context_store.update(cx, |store, cx| store.clear(cx));
|
||||||
cx.notify();
|
cx.notify();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -302,6 +299,21 @@ 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()
|
||||||
}
|
}
|
||||||
@@ -358,7 +370,12 @@ impl MessageEditor {
|
|||||||
thread
|
thread
|
||||||
.update(cx, |thread, cx| {
|
.update(cx, |thread, cx| {
|
||||||
thread.advance_prompt_id();
|
thread.advance_prompt_id();
|
||||||
thread.send_to_model(model, Some(window_handle), cx);
|
thread.send_to_model(
|
||||||
|
model,
|
||||||
|
CompletionIntent::UserPrompt,
|
||||||
|
Some(window_handle),
|
||||||
|
cx,
|
||||||
|
);
|
||||||
})
|
})
|
||||||
.log_err();
|
.log_err();
|
||||||
})
|
})
|
||||||
@@ -407,39 +424,24 @@ impl MessageEditor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn paste(&mut self, _: &Paste, _: &mut Window, cx: &mut Context<Self>) {
|
fn paste(&mut self, _: &Paste, _: &mut Window, cx: &mut Context<Self>) {
|
||||||
let images = cx
|
crate::active_thread::attach_pasted_images_as_context(&self.context_store, 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>,
|
||||||
@@ -454,6 +456,56 @@ 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();
|
||||||
@@ -462,27 +514,24 @@ impl MessageEditor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
let active_completion_mode = thread.completion_mode();
|
let active_completion_mode = thread.completion_mode();
|
||||||
let max_mode_enabled = active_completion_mode == CompletionMode::Max;
|
let burn_mode_enabled = active_completion_mode == CompletionMode::Burn;
|
||||||
|
let icon = if burn_mode_enabled {
|
||||||
|
IconName::ZedBurnModeOn
|
||||||
|
} else {
|
||||||
|
IconName::ZedBurnMode
|
||||||
|
};
|
||||||
|
|
||||||
Some(
|
Some(
|
||||||
Button::new("max-mode", "Max Mode")
|
IconButton::new("burn-mode", icon)
|
||||||
.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)
|
||||||
.icon_position(IconPosition::Start)
|
.toggle_state(burn_mode_enabled)
|
||||||
.toggle_state(max_mode_enabled)
|
.selected_icon_color(Color::Error)
|
||||||
.on_click(cx.listener(move |this, _event, _window, cx| {
|
.on_click(cx.listener(|this, _event, window, cx| {
|
||||||
this.thread.update(cx, |thread, _cx| {
|
this.toggle_burn_mode(&ToggleBurnMode, window, 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(max_mode_enabled))
|
cx.new(|_| MaxModeTooltip::new().selected(burn_mode_enabled))
|
||||||
.into()
|
.into()
|
||||||
})
|
})
|
||||||
.into_any_element(),
|
.into_any_element(),
|
||||||
@@ -562,6 +611,7 @@ 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)
|
||||||
@@ -576,6 +626,13 @@ 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()
|
||||||
@@ -668,7 +725,6 @@ 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)),
|
||||||
)
|
)
|
||||||
@@ -832,7 +888,10 @@ 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 is_generating = self.thread.read(cx).is_generating();
|
let thread = self.thread.read(cx);
|
||||||
|
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()
|
||||||
@@ -842,7 +901,7 @@ impl MessageEditor {
|
|||||||
.border_b_0()
|
.border_b_0()
|
||||||
.border_color(border_color)
|
.border_color(border_color)
|
||||||
.rounded_t_md()
|
.rounded_t_md()
|
||||||
.shadow(smallvec::smallvec![gpui::BoxShadow {
|
.shadow(vec![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.),
|
||||||
@@ -850,31 +909,28 @@ impl MessageEditor {
|
|||||||
}])
|
}])
|
||||||
.child(
|
.child(
|
||||||
h_flex()
|
h_flex()
|
||||||
.id("edits-container")
|
.p_1()
|
||||||
.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, _ev, _window, cx| {
|
.on_click(cx.listener(|this, _, _, cx| {
|
||||||
this.edits_expanded = !this.edits_expanded;
|
this.handle_edit_bar_expand(cx)
|
||||||
cx.notify();
|
|
||||||
})),
|
})),
|
||||||
)
|
)
|
||||||
.map(|this| {
|
.map(|this| {
|
||||||
if is_generating {
|
if pending_edits {
|
||||||
this.child(
|
this.child(
|
||||||
AnimatedLabel::new(format!(
|
Label::new(format!(
|
||||||
"Editing {} {}",
|
"Editing {} {}…",
|
||||||
changed_buffers.len(),
|
changed_buffers.len(),
|
||||||
if changed_buffers.len() == 1 {
|
if changed_buffers.len() == 1 {
|
||||||
"file"
|
"file"
|
||||||
@@ -882,7 +938,15 @@ impl MessageEditor {
|
|||||||
"files"
|
"files"
|
||||||
}
|
}
|
||||||
))
|
))
|
||||||
.size(LabelSize::Small),
|
.color(Color::Muted)
|
||||||
|
.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(
|
||||||
@@ -907,23 +971,74 @@ impl MessageEditor {
|
|||||||
.color(Color::Muted),
|
.color(Color::Muted),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}),
|
})
|
||||||
|
.on_click(
|
||||||
|
cx.listener(|this, _, _, cx| this.handle_edit_bar_expand(cx)),
|
||||||
|
),
|
||||||
)
|
)
|
||||||
.child(
|
.child(
|
||||||
Button::new("review", "Review Changes")
|
h_flex()
|
||||||
.label_size(LabelSize::Small)
|
.gap_1()
|
||||||
.key_binding(
|
.child(
|
||||||
KeyBinding::for_action_in(
|
IconButton::new("review-changes", IconName::ListTodo)
|
||||||
&OpenAgentDiff,
|
.icon_size(IconSize::Small)
|
||||||
&focus_handle,
|
.tooltip({
|
||||||
window,
|
let focus_handle = focus_handle.clone();
|
||||||
cx,
|
move |window, cx| {
|
||||||
)
|
Tooltip::for_action_in(
|
||||||
.map(|kb| kb.size(rems_from_px(12.))),
|
"Review Changes",
|
||||||
|
&OpenAgentDiff,
|
||||||
|
&focus_handle,
|
||||||
|
window,
|
||||||
|
cx,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.on_click(cx.listener(|this, _, window, cx| {
|
||||||
|
this.handle_review_click(window, cx)
|
||||||
|
})),
|
||||||
)
|
)
|
||||||
.on_click(cx.listener(|this, _, window, cx| {
|
.child(ui::Divider::vertical().color(ui::DividerColor::Border))
|
||||||
this.handle_review_click(window, cx)
|
.child(
|
||||||
})),
|
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| {
|
||||||
@@ -1167,9 +1282,10 @@ 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.context_store.read_with(cx, |context_store, cx| {
|
let new_context = this
|
||||||
context_store.new_context_for_thread(this.thread.read(cx), None)
|
.context_store
|
||||||
});
|
.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;
|
||||||
@@ -1248,12 +1364,13 @@ 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: AssistantSettings::temperature_for_model(&model.model, cx),
|
temperature: AgentSettings::temperature_for_model(&model.model, cx),
|
||||||
};
|
};
|
||||||
|
|
||||||
Some(model.model.count_tokens(request, cx))
|
Some(model.model.count_tokens(request, cx))
|
||||||
|
|||||||
@@ -1,26 +1,24 @@
|
|||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
|
||||||
use assistant_settings::{
|
use agent_settings::{AgentDockPosition, AgentProfileId, AgentSettings, builtin_profiles};
|
||||||
AgentProfile, AgentProfileId, AssistantDockPosition, AssistantSettings, GroupedAgentProfiles,
|
|
||||||
builtin_profiles,
|
|
||||||
};
|
|
||||||
use fs::Fs;
|
use fs::Fs;
|
||||||
use gpui::{Action, Entity, FocusHandle, Subscription, WeakEntity, prelude::*};
|
use gpui::{Action, Empty, Entity, FocusHandle, Subscription, prelude::*};
|
||||||
use language_model::LanguageModelRegistry;
|
use language_model::LanguageModelRegistry;
|
||||||
use settings::{Settings as _, SettingsStore, update_settings_file};
|
use settings::{Settings as _, SettingsStore, update_settings_file};
|
||||||
use ui::{
|
use ui::{
|
||||||
ContextMenu, ContextMenuEntry, DocumentationSide, PopoverMenu, PopoverMenuHandle, Tooltip,
|
ContextMenu, ContextMenuEntry, DocumentationSide, PopoverMenu, PopoverMenuHandle, Tooltip,
|
||||||
prelude::*,
|
prelude::*,
|
||||||
};
|
};
|
||||||
use util::ResultExt as _;
|
|
||||||
|
|
||||||
use crate::{ManageProfiles, Thread, ThreadStore, ToggleProfileSelector};
|
use crate::{
|
||||||
|
ManageProfiles, Thread, ToggleProfileSelector,
|
||||||
|
agent_profile::{AgentProfile, AvailableProfiles},
|
||||||
|
};
|
||||||
|
|
||||||
pub struct ProfileSelector {
|
pub struct ProfileSelector {
|
||||||
profiles: GroupedAgentProfiles,
|
profiles: AvailableProfiles,
|
||||||
fs: Arc<dyn Fs>,
|
fs: Arc<dyn Fs>,
|
||||||
thread: Entity<Thread>,
|
thread: Entity<Thread>,
|
||||||
thread_store: WeakEntity<ThreadStore>,
|
|
||||||
menu_handle: PopoverMenuHandle<ContextMenu>,
|
menu_handle: PopoverMenuHandle<ContextMenu>,
|
||||||
focus_handle: FocusHandle,
|
focus_handle: FocusHandle,
|
||||||
_subscriptions: Vec<Subscription>,
|
_subscriptions: Vec<Subscription>,
|
||||||
@@ -30,7 +28,6 @@ impl ProfileSelector {
|
|||||||
pub fn new(
|
pub fn new(
|
||||||
fs: Arc<dyn Fs>,
|
fs: Arc<dyn Fs>,
|
||||||
thread: Entity<Thread>,
|
thread: Entity<Thread>,
|
||||||
thread_store: WeakEntity<ThreadStore>,
|
|
||||||
focus_handle: FocusHandle,
|
focus_handle: FocusHandle,
|
||||||
cx: &mut Context<Self>,
|
cx: &mut Context<Self>,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
@@ -39,10 +36,9 @@ impl ProfileSelector {
|
|||||||
});
|
});
|
||||||
|
|
||||||
Self {
|
Self {
|
||||||
profiles: GroupedAgentProfiles::from_settings(AssistantSettings::get_global(cx)),
|
profiles: AgentProfile::available_profiles(cx),
|
||||||
fs,
|
fs,
|
||||||
thread,
|
thread,
|
||||||
thread_store,
|
|
||||||
menu_handle: PopoverMenuHandle::default(),
|
menu_handle: PopoverMenuHandle::default(),
|
||||||
focus_handle,
|
focus_handle,
|
||||||
_subscriptions: vec![settings_subscription],
|
_subscriptions: vec![settings_subscription],
|
||||||
@@ -54,7 +50,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(AssistantSettings::get_global(cx));
|
self.profiles = AgentProfile::available_profiles(cx);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn build_context_menu(
|
fn build_context_menu(
|
||||||
@@ -63,22 +59,31 @@ 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 = AssistantSettings::get_global(cx);
|
let settings = AgentSettings::get_global(cx);
|
||||||
for (profile_id, profile) in self.profiles.builtin.iter() {
|
|
||||||
|
let mut found_non_builtin = false;
|
||||||
|
for (profile_id, profile_name) in self.profiles.iter() {
|
||||||
|
if !builtin_profiles::is_builtin(profile_id) {
|
||||||
|
found_non_builtin = true;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
menu = menu.item(self.menu_entry_for_profile(
|
menu = menu.item(self.menu_entry_for_profile(
|
||||||
profile_id.clone(),
|
profile_id.clone(),
|
||||||
profile,
|
profile_name,
|
||||||
settings,
|
settings,
|
||||||
cx,
|
cx,
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
if !self.profiles.custom.is_empty() {
|
if found_non_builtin {
|
||||||
menu = menu.separator().header("Custom Profiles");
|
menu = menu.separator().header("Custom Profiles");
|
||||||
for (profile_id, profile) in self.profiles.custom.iter() {
|
for (profile_id, profile_name) in self.profiles.iter() {
|
||||||
|
if builtin_profiles::is_builtin(profile_id) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
menu = menu.item(self.menu_entry_for_profile(
|
menu = menu.item(self.menu_entry_for_profile(
|
||||||
profile_id.clone(),
|
profile_id.clone(),
|
||||||
profile,
|
profile_name,
|
||||||
settings,
|
settings,
|
||||||
cx,
|
cx,
|
||||||
));
|
));
|
||||||
@@ -99,19 +104,20 @@ impl ProfileSelector {
|
|||||||
fn menu_entry_for_profile(
|
fn menu_entry_for_profile(
|
||||||
&self,
|
&self,
|
||||||
profile_id: AgentProfileId,
|
profile_id: AgentProfileId,
|
||||||
profile: &AgentProfile,
|
profile_name: &SharedString,
|
||||||
settings: &AssistantSettings,
|
settings: &AgentSettings,
|
||||||
_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."),
|
||||||
builtin_profiles::ASK => Some("Chat about your codebase."),
|
builtin_profiles::ASK => Some("Chat about your codebase."),
|
||||||
builtin_profiles::MINIMAL => Some("Chat about anything with no tools."),
|
builtin_profiles::MINIMAL => Some("Chat about anything with no tools."),
|
||||||
_ => None,
|
_ => None,
|
||||||
};
|
};
|
||||||
|
let thread_profile_id = self.thread.read(cx).profile().id();
|
||||||
|
|
||||||
let entry = ContextMenuEntry::new(profile.name.clone())
|
let entry = ContextMenuEntry::new(profile_name.clone())
|
||||||
.toggleable(IconPosition::End, profile_id == settings.default_profile);
|
.toggleable(IconPosition::End, &profile_id == thread_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 |_| {
|
||||||
@@ -123,21 +129,19 @@ impl ProfileSelector {
|
|||||||
|
|
||||||
entry.handler({
|
entry.handler({
|
||||||
let fs = self.fs.clone();
|
let fs = self.fs.clone();
|
||||||
let thread_store = self.thread_store.clone();
|
let thread = self.thread.clone();
|
||||||
let profile_id = profile_id.clone();
|
let profile_id = profile_id.clone();
|
||||||
move |_window, cx| {
|
move |_window, cx| {
|
||||||
update_settings_file::<AssistantSettings>(fs.clone(), cx, {
|
update_settings_file::<AgentSettings>(fs.clone(), cx, {
|
||||||
let profile_id = profile_id.clone();
|
let profile_id = profile_id.clone();
|
||||||
move |settings, _cx| {
|
move |settings, _cx| {
|
||||||
settings.set_profile(profile_id.clone());
|
settings.set_profile(profile_id.clone());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
thread_store
|
thread.update(cx, |this, cx| {
|
||||||
.update(cx, |this, cx| {
|
this.set_profile(profile_id.clone(), cx);
|
||||||
this.load_profile_by_id(profile_id.clone(), cx);
|
});
|
||||||
})
|
|
||||||
.log_err();
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@@ -145,25 +149,23 @@ 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 = AssistantSettings::get_global(cx);
|
let settings = AgentSettings::get_global(cx);
|
||||||
let profile_id = &settings.default_profile;
|
let profile_id = self.thread.read(cx).profile().id();
|
||||||
let profile = settings.profiles.get(profile_id);
|
let profile = settings.profiles.get(profile_id);
|
||||||
|
|
||||||
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
|
let configured_model = self.thread.read(cx).configured_model().or_else(|| {
|
||||||
.thread
|
let model_registry = LanguageModelRegistry::read_global(cx);
|
||||||
.read_with(cx, |thread, _cx| thread.configured_model())
|
model_registry.default_model()
|
||||||
.or_else(|| {
|
});
|
||||||
let model_registry = LanguageModelRegistry::read_global(cx);
|
let Some(configured_model) = configured_model else {
|
||||||
model_registry.default_model()
|
return Empty.into_any_element();
|
||||||
});
|
};
|
||||||
let supports_tools =
|
|
||||||
configured_model.map_or(false, |default| default.model.supports_tools());
|
|
||||||
|
|
||||||
if supports_tools {
|
if configured_model.model.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)
|
||||||
@@ -210,10 +212,10 @@ impl Render for ProfileSelector {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn documentation_side(position: AssistantDockPosition) -> DocumentationSide {
|
fn documentation_side(position: AgentDockPosition) -> DocumentationSide {
|
||||||
match position {
|
match position {
|
||||||
AssistantDockPosition::Left => DocumentationSide::Right,
|
AgentDockPosition::Left => DocumentationSide::Right,
|
||||||
AssistantDockPosition::Bottom => DocumentationSide::Left,
|
AgentDockPosition::Bottom => DocumentationSide::Left,
|
||||||
AssistantDockPosition::Right => DocumentationSide::Left,
|
AgentDockPosition::Right => DocumentationSide::Left,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
1
crates/agent/src/prompts/stale_files_prompt_header.txt
Normal file
@@ -0,0 +1 @@
|
|||||||
|
These files changed since last read:
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
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.
|
||||||
4
crates/agent/src/prompts/summarize_thread_prompt.txt
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
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));
|
.update(cx, |terminal, _| terminal.input(input.into_bytes()));
|
||||||
}
|
}
|
||||||
|
|
||||||
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.to_string()));
|
.update(cx, |terminal, _| terminal.input(CLEAR_INPUT.as_bytes()));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn complete(&self, cx: &mut App) {
|
pub fn complete(&self, cx: &mut App) {
|
||||||
self.terminal.update(cx, |terminal, _| {
|
self.terminal
|
||||||
terminal.input(CARRIAGE_RETURN.to_string())
|
.update(cx, |terminal, _| terminal.input(CARRIAGE_RETURN.as_bytes()));
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn sanitize_input(input: String) -> String {
|
fn sanitize_input(mut input: String) -> String {
|
||||||
input.replace(['\r', '\n'], "")
|
input.retain(|c| c != '\r' && c != '\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,6 +25,7 @@ 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>,
|
||||||
@@ -105,7 +106,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: 2,
|
height: 4,
|
||||||
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| {
|
||||||
@@ -201,7 +202,7 @@ impl TerminalInlineAssistant {
|
|||||||
.update(cx, |terminal, cx| {
|
.update(cx, |terminal, cx| {
|
||||||
terminal
|
terminal
|
||||||
.terminal()
|
.terminal()
|
||||||
.update(cx, |terminal, _| terminal.input(CLEAR_INPUT.to_string()));
|
.update(cx, |terminal, _| terminal.input(CLEAR_INPUT.as_bytes()));
|
||||||
})
|
})
|
||||||
.log_err();
|
.log_err();
|
||||||
|
|
||||||
@@ -271,7 +272,7 @@ impl TerminalInlineAssistant {
|
|||||||
.inline_assistant_model()
|
.inline_assistant_model()
|
||||||
.context("No inline assistant model")?;
|
.context("No inline assistant model")?;
|
||||||
|
|
||||||
let temperature = AssistantSettings::temperature_for_model(&model, cx);
|
let temperature = AgentSettings::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 {
|
||||||
@@ -291,6 +292,7 @@ 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,
|
||||||
|
|||||||
@@ -4,8 +4,8 @@ use std::ops::Range;
|
|||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
use std::time::Instant;
|
use std::time::Instant;
|
||||||
|
|
||||||
|
use agent_settings::{AgentProfileId, AgentSettings, CompletionMode};
|
||||||
use anyhow::{Result, anyhow};
|
use anyhow::{Result, anyhow};
|
||||||
use assistant_settings::{AssistantSettings, CompletionMode};
|
|
||||||
use assistant_tool::{ActionLog, AnyToolCard, Tool, ToolWorkingSet};
|
use assistant_tool::{ActionLog, AnyToolCard, Tool, ToolWorkingSet};
|
||||||
use chrono::{DateTime, Utc};
|
use chrono::{DateTime, Utc};
|
||||||
use collections::HashMap;
|
use collections::HashMap;
|
||||||
@@ -24,7 +24,7 @@ use language_model::{
|
|||||||
LanguageModelRequestMessage, LanguageModelRequestTool, LanguageModelToolResult,
|
LanguageModelRequestMessage, LanguageModelRequestTool, LanguageModelToolResult,
|
||||||
LanguageModelToolResultContent, LanguageModelToolUseId, MessageContent,
|
LanguageModelToolResultContent, LanguageModelToolUseId, MessageContent,
|
||||||
ModelRequestLimitReachedError, PaymentRequiredError, RequestUsage, Role, SelectedModel,
|
ModelRequestLimitReachedError, PaymentRequiredError, RequestUsage, Role, SelectedModel,
|
||||||
StopReason, TokenUsage, WrappedTextContent,
|
StopReason, TokenUsage,
|
||||||
};
|
};
|
||||||
use postage::stream::Stream as _;
|
use postage::stream::Stream as _;
|
||||||
use project::Project;
|
use project::Project;
|
||||||
@@ -38,9 +38,10 @@ use thiserror::Error;
|
|||||||
use ui::Window;
|
use ui::Window;
|
||||||
use util::{ResultExt as _, post_inc};
|
use util::{ResultExt as _, post_inc};
|
||||||
use uuid::Uuid;
|
use uuid::Uuid;
|
||||||
use zed_llm_client::CompletionRequestStatus;
|
use zed_llm_client::{CompletionIntent, CompletionRequestStatus};
|
||||||
|
|
||||||
use crate::ThreadStore;
|
use crate::ThreadStore;
|
||||||
|
use crate::agent_profile::AgentProfile;
|
||||||
use crate::context::{AgentContext, AgentContextHandle, ContextLoadResult, LoadedContext};
|
use crate::context::{AgentContext, AgentContextHandle, ContextLoadResult, LoadedContext};
|
||||||
use crate::thread_store::{
|
use crate::thread_store::{
|
||||||
SerializedCrease, SerializedLanguageModel, SerializedMessage, SerializedMessageSegment,
|
SerializedCrease, SerializedLanguageModel, SerializedMessage, SerializedMessageSegment,
|
||||||
@@ -115,6 +116,7 @@ pub struct Message {
|
|||||||
pub segments: Vec<MessageSegment>,
|
pub segments: Vec<MessageSegment>,
|
||||||
pub loaded_context: LoadedContext,
|
pub loaded_context: LoadedContext,
|
||||||
pub creases: Vec<MessageCrease>,
|
pub creases: Vec<MessageCrease>,
|
||||||
|
pub is_hidden: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Message {
|
impl Message {
|
||||||
@@ -329,7 +331,7 @@ pub struct Thread {
|
|||||||
detailed_summary_task: Task<Option<()>>,
|
detailed_summary_task: Task<Option<()>>,
|
||||||
detailed_summary_tx: postage::watch::Sender<DetailedSummaryState>,
|
detailed_summary_tx: postage::watch::Sender<DetailedSummaryState>,
|
||||||
detailed_summary_rx: postage::watch::Receiver<DetailedSummaryState>,
|
detailed_summary_rx: postage::watch::Receiver<DetailedSummaryState>,
|
||||||
completion_mode: assistant_settings::CompletionMode,
|
completion_mode: agent_settings::CompletionMode,
|
||||||
messages: Vec<Message>,
|
messages: Vec<Message>,
|
||||||
next_message_id: MessageId,
|
next_message_id: MessageId,
|
||||||
last_prompt_id: PromptId,
|
last_prompt_id: PromptId,
|
||||||
@@ -359,6 +361,7 @@ pub struct Thread {
|
|||||||
>,
|
>,
|
||||||
remaining_turns: u32,
|
remaining_turns: u32,
|
||||||
configured_model: Option<ConfiguredModel>,
|
configured_model: Option<ConfiguredModel>,
|
||||||
|
profile: AgentProfile,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Debug, PartialEq, Eq)]
|
#[derive(Clone, Debug, PartialEq, Eq)]
|
||||||
@@ -406,6 +409,7 @@ impl Thread {
|
|||||||
) -> Self {
|
) -> Self {
|
||||||
let (detailed_summary_tx, detailed_summary_rx) = postage::watch::channel();
|
let (detailed_summary_tx, detailed_summary_rx) = postage::watch::channel();
|
||||||
let configured_model = LanguageModelRegistry::read_global(cx).default_model();
|
let configured_model = LanguageModelRegistry::read_global(cx).default_model();
|
||||||
|
let profile_id = AgentSettings::get_global(cx).default_profile.clone();
|
||||||
|
|
||||||
Self {
|
Self {
|
||||||
id: ThreadId::new(),
|
id: ThreadId::new(),
|
||||||
@@ -415,7 +419,7 @@ impl Thread {
|
|||||||
detailed_summary_task: Task::ready(None),
|
detailed_summary_task: Task::ready(None),
|
||||||
detailed_summary_tx,
|
detailed_summary_tx,
|
||||||
detailed_summary_rx,
|
detailed_summary_rx,
|
||||||
completion_mode: AssistantSettings::get_global(cx).preferred_completion_mode,
|
completion_mode: AgentSettings::get_global(cx).preferred_completion_mode,
|
||||||
messages: Vec::new(),
|
messages: Vec::new(),
|
||||||
next_message_id: MessageId(0),
|
next_message_id: MessageId(0),
|
||||||
last_prompt_id: PromptId::new(),
|
last_prompt_id: PromptId::new(),
|
||||||
@@ -448,6 +452,7 @@ impl Thread {
|
|||||||
request_callback: None,
|
request_callback: None,
|
||||||
remaining_turns: u32::MAX,
|
remaining_turns: u32::MAX,
|
||||||
configured_model,
|
configured_model,
|
||||||
|
profile: AgentProfile::new(profile_id, tools),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -493,7 +498,10 @@ impl Thread {
|
|||||||
|
|
||||||
let completion_mode = serialized
|
let completion_mode = serialized
|
||||||
.completion_mode
|
.completion_mode
|
||||||
.unwrap_or_else(|| AssistantSettings::get_global(cx).preferred_completion_mode);
|
.unwrap_or_else(|| AgentSettings::get_global(cx).preferred_completion_mode);
|
||||||
|
let profile_id = serialized
|
||||||
|
.profile
|
||||||
|
.unwrap_or_else(|| AgentSettings::get_global(cx).default_profile.clone());
|
||||||
|
|
||||||
Self {
|
Self {
|
||||||
id,
|
id,
|
||||||
@@ -540,6 +548,7 @@ impl Thread {
|
|||||||
context: None,
|
context: None,
|
||||||
})
|
})
|
||||||
.collect(),
|
.collect(),
|
||||||
|
is_hidden: message.is_hidden,
|
||||||
})
|
})
|
||||||
.collect(),
|
.collect(),
|
||||||
next_message_id,
|
next_message_id,
|
||||||
@@ -552,7 +561,7 @@ impl Thread {
|
|||||||
pending_checkpoint: None,
|
pending_checkpoint: None,
|
||||||
project: project.clone(),
|
project: project.clone(),
|
||||||
prompt_builder,
|
prompt_builder,
|
||||||
tools,
|
tools: tools.clone(),
|
||||||
tool_use,
|
tool_use,
|
||||||
action_log: cx.new(|_| ActionLog::new(project)),
|
action_log: cx.new(|_| ActionLog::new(project)),
|
||||||
initial_project_snapshot: Task::ready(serialized.initial_project_snapshot).shared(),
|
initial_project_snapshot: Task::ready(serialized.initial_project_snapshot).shared(),
|
||||||
@@ -560,7 +569,7 @@ impl Thread {
|
|||||||
cumulative_token_usage: serialized.cumulative_token_usage,
|
cumulative_token_usage: serialized.cumulative_token_usage,
|
||||||
exceeded_window_error: None,
|
exceeded_window_error: None,
|
||||||
last_usage: None,
|
last_usage: None,
|
||||||
tool_use_limit_reached: false,
|
tool_use_limit_reached: serialized.tool_use_limit_reached,
|
||||||
feedback: None,
|
feedback: None,
|
||||||
message_feedback: HashMap::default(),
|
message_feedback: HashMap::default(),
|
||||||
last_auto_capture_at: None,
|
last_auto_capture_at: None,
|
||||||
@@ -568,6 +577,7 @@ impl Thread {
|
|||||||
request_callback: None,
|
request_callback: None,
|
||||||
remaining_turns: u32::MAX,
|
remaining_turns: u32::MAX,
|
||||||
configured_model,
|
configured_model,
|
||||||
|
profile: AgentProfile::new(profile_id, tools),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -583,6 +593,17 @@ impl Thread {
|
|||||||
&self.id
|
&self.id
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn profile(&self) -> &AgentProfile {
|
||||||
|
&self.profile
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn set_profile(&mut self, id: AgentProfileId, cx: &mut Context<Self>) {
|
||||||
|
if &id != self.profile.id() {
|
||||||
|
self.profile = AgentProfile::new(id, self.tools.clone());
|
||||||
|
cx.emit(ThreadEvent::ProfileChanged);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
pub fn is_empty(&self) -> bool {
|
pub fn is_empty(&self) -> bool {
|
||||||
self.messages.is_empty()
|
self.messages.is_empty()
|
||||||
}
|
}
|
||||||
@@ -757,6 +778,14 @@ impl Thread {
|
|||||||
return;
|
return;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
self.finalize_checkpoint(pending_checkpoint, cx);
|
||||||
|
}
|
||||||
|
|
||||||
|
fn finalize_checkpoint(
|
||||||
|
&mut self,
|
||||||
|
pending_checkpoint: ThreadCheckpoint,
|
||||||
|
cx: &mut Context<Self>,
|
||||||
|
) {
|
||||||
let git_store = self.project.read(cx).git_store().clone();
|
let git_store = self.project.read(cx).git_store().clone();
|
||||||
let final_checkpoint = git_store.update(cx, |git_store, cx| git_store.checkpoint(cx));
|
let final_checkpoint = git_store.update(cx, |git_store, cx| git_store.checkpoint(cx));
|
||||||
cx.spawn(async move |this, cx| match final_checkpoint.await {
|
cx.spawn(async move |this, cx| match final_checkpoint.await {
|
||||||
@@ -841,7 +870,7 @@ impl Thread {
|
|||||||
.get(ix + 1)
|
.get(ix + 1)
|
||||||
.and_then(|message| {
|
.and_then(|message| {
|
||||||
self.message(message.id)
|
self.message(message.id)
|
||||||
.map(|next_message| next_message.role == Role::User)
|
.map(|next_message| next_message.role == Role::User && !next_message.is_hidden)
|
||||||
})
|
})
|
||||||
.unwrap_or(false)
|
.unwrap_or(false)
|
||||||
}
|
}
|
||||||
@@ -861,7 +890,16 @@ impl Thread {
|
|||||||
self.tool_use
|
self.tool_use
|
||||||
.pending_tool_uses()
|
.pending_tool_uses()
|
||||||
.iter()
|
.iter()
|
||||||
.all(|tool_use| tool_use.status.is_error())
|
.all(|pending_tool_use| pending_tool_use.status.is_error())
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Returns whether any pending tool uses may perform edits
|
||||||
|
pub fn has_pending_edit_tool_uses(&self) -> bool {
|
||||||
|
self.tool_use
|
||||||
|
.pending_tool_uses()
|
||||||
|
.iter()
|
||||||
|
.filter(|pending_tool_use| !pending_tool_use.status.is_error())
|
||||||
|
.any(|pending_tool_use| pending_tool_use.may_perform_edits)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn tool_uses_for_message(&self, id: MessageId, cx: &App) -> Vec<ToolUse> {
|
pub fn tool_uses_for_message(&self, id: MessageId, cx: &App) -> Vec<ToolUse> {
|
||||||
@@ -881,10 +919,7 @@ impl Thread {
|
|||||||
|
|
||||||
pub fn output_for_tool(&self, id: &LanguageModelToolUseId) -> Option<&Arc<str>> {
|
pub fn output_for_tool(&self, id: &LanguageModelToolUseId) -> Option<&Arc<str>> {
|
||||||
match &self.tool_use.tool_result(id)?.content {
|
match &self.tool_use.tool_result(id)?.content {
|
||||||
LanguageModelToolResultContent::Text(text)
|
LanguageModelToolResultContent::Text(text) => Some(text),
|
||||||
| LanguageModelToolResultContent::WrappedText(WrappedTextContent { text, .. }) => {
|
|
||||||
Some(text)
|
|
||||||
}
|
|
||||||
LanguageModelToolResultContent::Image(_) => {
|
LanguageModelToolResultContent::Image(_) => {
|
||||||
// TODO: We should display image
|
// TODO: We should display image
|
||||||
None
|
None
|
||||||
@@ -903,8 +938,7 @@ impl Thread {
|
|||||||
model: Arc<dyn LanguageModel>,
|
model: Arc<dyn LanguageModel>,
|
||||||
) -> Vec<LanguageModelRequestTool> {
|
) -> Vec<LanguageModelRequestTool> {
|
||||||
if model.supports_tools() {
|
if model.supports_tools() {
|
||||||
self.tools()
|
self.profile
|
||||||
.read(cx)
|
|
||||||
.enabled_tools(cx)
|
.enabled_tools(cx)
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.filter_map(|tool| {
|
.filter_map(|tool| {
|
||||||
@@ -943,6 +977,7 @@ impl Thread {
|
|||||||
vec![MessageSegment::Text(text.into())],
|
vec![MessageSegment::Text(text.into())],
|
||||||
loaded_context.loaded_context,
|
loaded_context.loaded_context,
|
||||||
creases,
|
creases,
|
||||||
|
false,
|
||||||
cx,
|
cx,
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -958,6 +993,20 @@ impl Thread {
|
|||||||
message_id
|
message_id
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn insert_invisible_continue_message(&mut self, cx: &mut Context<Self>) -> MessageId {
|
||||||
|
let id = self.insert_message(
|
||||||
|
Role::User,
|
||||||
|
vec![MessageSegment::Text("Continue where you left off".into())],
|
||||||
|
LoadedContext::default(),
|
||||||
|
vec![],
|
||||||
|
true,
|
||||||
|
cx,
|
||||||
|
);
|
||||||
|
self.pending_checkpoint = None;
|
||||||
|
|
||||||
|
id
|
||||||
|
}
|
||||||
|
|
||||||
pub fn insert_assistant_message(
|
pub fn insert_assistant_message(
|
||||||
&mut self,
|
&mut self,
|
||||||
segments: Vec<MessageSegment>,
|
segments: Vec<MessageSegment>,
|
||||||
@@ -968,6 +1017,7 @@ impl Thread {
|
|||||||
segments,
|
segments,
|
||||||
LoadedContext::default(),
|
LoadedContext::default(),
|
||||||
Vec::new(),
|
Vec::new(),
|
||||||
|
false,
|
||||||
cx,
|
cx,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@@ -978,6 +1028,7 @@ impl Thread {
|
|||||||
segments: Vec<MessageSegment>,
|
segments: Vec<MessageSegment>,
|
||||||
loaded_context: LoadedContext,
|
loaded_context: LoadedContext,
|
||||||
creases: Vec<MessageCrease>,
|
creases: Vec<MessageCrease>,
|
||||||
|
is_hidden: bool,
|
||||||
cx: &mut Context<Self>,
|
cx: &mut Context<Self>,
|
||||||
) -> MessageId {
|
) -> MessageId {
|
||||||
let id = self.next_message_id.post_inc();
|
let id = self.next_message_id.post_inc();
|
||||||
@@ -987,6 +1038,7 @@ impl Thread {
|
|||||||
segments,
|
segments,
|
||||||
loaded_context,
|
loaded_context,
|
||||||
creases,
|
creases,
|
||||||
|
is_hidden,
|
||||||
});
|
});
|
||||||
self.touch_updated_at();
|
self.touch_updated_at();
|
||||||
cx.emit(ThreadEvent::MessageAdded(id));
|
cx.emit(ThreadEvent::MessageAdded(id));
|
||||||
@@ -998,6 +1050,7 @@ impl Thread {
|
|||||||
id: MessageId,
|
id: MessageId,
|
||||||
new_role: Role,
|
new_role: Role,
|
||||||
new_segments: Vec<MessageSegment>,
|
new_segments: Vec<MessageSegment>,
|
||||||
|
creases: Vec<MessageCrease>,
|
||||||
loaded_context: Option<LoadedContext>,
|
loaded_context: Option<LoadedContext>,
|
||||||
checkpoint: Option<GitStoreCheckpoint>,
|
checkpoint: Option<GitStoreCheckpoint>,
|
||||||
cx: &mut Context<Self>,
|
cx: &mut Context<Self>,
|
||||||
@@ -1007,6 +1060,7 @@ impl Thread {
|
|||||||
};
|
};
|
||||||
message.role = new_role;
|
message.role = new_role;
|
||||||
message.segments = new_segments;
|
message.segments = new_segments;
|
||||||
|
message.creases = creases;
|
||||||
if let Some(context) = loaded_context {
|
if let Some(context) = loaded_context {
|
||||||
message.loaded_context = context;
|
message.loaded_context = context;
|
||||||
}
|
}
|
||||||
@@ -1127,6 +1181,7 @@ impl Thread {
|
|||||||
label: crease.metadata.label.clone(),
|
label: crease.metadata.label.clone(),
|
||||||
})
|
})
|
||||||
.collect(),
|
.collect(),
|
||||||
|
is_hidden: message.is_hidden,
|
||||||
})
|
})
|
||||||
.collect(),
|
.collect(),
|
||||||
initial_project_snapshot,
|
initial_project_snapshot,
|
||||||
@@ -1142,6 +1197,8 @@ impl Thread {
|
|||||||
model: model.model.id().0.to_string(),
|
model: model.model.id().0.to_string(),
|
||||||
}),
|
}),
|
||||||
completion_mode: Some(this.completion_mode),
|
completion_mode: Some(this.completion_mode),
|
||||||
|
tool_use_limit_reached: this.tool_use_limit_reached,
|
||||||
|
profile: Some(this.profile.id().clone()),
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@@ -1157,6 +1214,7 @@ impl Thread {
|
|||||||
pub fn send_to_model(
|
pub fn send_to_model(
|
||||||
&mut self,
|
&mut self,
|
||||||
model: Arc<dyn LanguageModel>,
|
model: Arc<dyn LanguageModel>,
|
||||||
|
intent: CompletionIntent,
|
||||||
window: Option<AnyWindowHandle>,
|
window: Option<AnyWindowHandle>,
|
||||||
cx: &mut Context<Self>,
|
cx: &mut Context<Self>,
|
||||||
) {
|
) {
|
||||||
@@ -1166,7 +1224,7 @@ impl Thread {
|
|||||||
|
|
||||||
self.remaining_turns -= 1;
|
self.remaining_turns -= 1;
|
||||||
|
|
||||||
let request = self.to_completion_request(model.clone(), cx);
|
let request = self.to_completion_request(model.clone(), intent, cx);
|
||||||
|
|
||||||
self.stream_completion(request, model, window, cx);
|
self.stream_completion(request, model, window, cx);
|
||||||
}
|
}
|
||||||
@@ -1186,17 +1244,19 @@ impl Thread {
|
|||||||
pub fn to_completion_request(
|
pub fn to_completion_request(
|
||||||
&self,
|
&self,
|
||||||
model: Arc<dyn LanguageModel>,
|
model: Arc<dyn LanguageModel>,
|
||||||
|
intent: CompletionIntent,
|
||||||
cx: &mut Context<Self>,
|
cx: &mut Context<Self>,
|
||||||
) -> LanguageModelRequest {
|
) -> LanguageModelRequest {
|
||||||
let mut request = LanguageModelRequest {
|
let mut request = LanguageModelRequest {
|
||||||
thread_id: Some(self.id.to_string()),
|
thread_id: Some(self.id.to_string()),
|
||||||
prompt_id: Some(self.last_prompt_id.to_string()),
|
prompt_id: Some(self.last_prompt_id.to_string()),
|
||||||
|
intent: Some(intent),
|
||||||
mode: None,
|
mode: None,
|
||||||
messages: vec![],
|
messages: vec![],
|
||||||
tools: Vec::new(),
|
tools: Vec::new(),
|
||||||
tool_choice: None,
|
tool_choice: None,
|
||||||
stop: Vec::new(),
|
stop: Vec::new(),
|
||||||
temperature: AssistantSettings::temperature_for_model(&model, cx),
|
temperature: AgentSettings::temperature_for_model(&model, cx),
|
||||||
};
|
};
|
||||||
|
|
||||||
let available_tools = self.available_tools(cx, model.clone());
|
let available_tools = self.available_tools(cx, model.clone());
|
||||||
@@ -1344,18 +1404,20 @@ impl Thread {
|
|||||||
fn to_summarize_request(
|
fn to_summarize_request(
|
||||||
&self,
|
&self,
|
||||||
model: &Arc<dyn LanguageModel>,
|
model: &Arc<dyn LanguageModel>,
|
||||||
|
intent: CompletionIntent,
|
||||||
added_user_message: String,
|
added_user_message: String,
|
||||||
cx: &App,
|
cx: &App,
|
||||||
) -> LanguageModelRequest {
|
) -> LanguageModelRequest {
|
||||||
let mut request = LanguageModelRequest {
|
let mut request = LanguageModelRequest {
|
||||||
thread_id: None,
|
thread_id: None,
|
||||||
prompt_id: None,
|
prompt_id: None,
|
||||||
|
intent: Some(intent),
|
||||||
mode: None,
|
mode: None,
|
||||||
messages: vec![],
|
messages: vec![],
|
||||||
tools: Vec::new(),
|
tools: Vec::new(),
|
||||||
tool_choice: None,
|
tool_choice: None,
|
||||||
stop: Vec::new(),
|
stop: Vec::new(),
|
||||||
temperature: AssistantSettings::temperature_for_model(model, cx),
|
temperature: AgentSettings::temperature_for_model(model, cx),
|
||||||
};
|
};
|
||||||
|
|
||||||
for message in &self.messages {
|
for message in &self.messages {
|
||||||
@@ -1396,7 +1458,7 @@ impl Thread {
|
|||||||
messages: &mut Vec<LanguageModelRequestMessage>,
|
messages: &mut Vec<LanguageModelRequestMessage>,
|
||||||
cx: &App,
|
cx: &App,
|
||||||
) {
|
) {
|
||||||
const STALE_FILES_HEADER: &str = "These files changed since last read:";
|
const STALE_FILES_HEADER: &str = include_str!("./prompts/stale_files_prompt_header.txt");
|
||||||
|
|
||||||
let mut stale_message = String::new();
|
let mut stale_message = String::new();
|
||||||
|
|
||||||
@@ -1408,7 +1470,7 @@ impl Thread {
|
|||||||
};
|
};
|
||||||
|
|
||||||
if stale_message.is_empty() {
|
if stale_message.is_empty() {
|
||||||
write!(&mut stale_message, "{}\n", STALE_FILES_HEADER).ok();
|
write!(&mut stale_message, "{}\n", STALE_FILES_HEADER.trim()).ok();
|
||||||
}
|
}
|
||||||
|
|
||||||
writeln!(&mut stale_message, "- {}", file.path().display()).ok();
|
writeln!(&mut stale_message, "- {}", file.path().display()).ok();
|
||||||
@@ -1641,6 +1703,7 @@ impl Thread {
|
|||||||
}
|
}
|
||||||
CompletionRequestStatus::ToolUseLimitReached => {
|
CompletionRequestStatus::ToolUseLimitReached => {
|
||||||
thread.tool_use_limit_reached = true;
|
thread.tool_use_limit_reached = true;
|
||||||
|
cx.emit(ThreadEvent::ToolUseLimitReached);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1693,6 +1756,43 @@ impl Thread {
|
|||||||
project.set_agent_location(None, cx);
|
project.set_agent_location(None, cx);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
StopReason::Refusal => {
|
||||||
|
thread.project.update(cx, |project, cx| {
|
||||||
|
project.set_agent_location(None, cx);
|
||||||
|
});
|
||||||
|
|
||||||
|
// Remove the turn that was refused.
|
||||||
|
//
|
||||||
|
// https://docs.anthropic.com/en/docs/test-and-evaluate/strengthen-guardrails/handle-streaming-refusals#reset-context-after-refusal
|
||||||
|
{
|
||||||
|
let mut messages_to_remove = Vec::new();
|
||||||
|
|
||||||
|
for (ix, message) in thread.messages.iter().enumerate().rev() {
|
||||||
|
messages_to_remove.push(message.id);
|
||||||
|
|
||||||
|
if message.role == Role::User {
|
||||||
|
if ix == 0 {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if let Some(prev_message) = thread.messages.get(ix - 1) {
|
||||||
|
if prev_message.role == Role::Assistant {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for message_id in messages_to_remove {
|
||||||
|
thread.delete_message(message_id, cx);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
cx.emit(ThreadEvent::ShowError(ThreadError::Message {
|
||||||
|
header: "Language model refusal".into(),
|
||||||
|
message: "Model refused to generate content for safety reasons.".into(),
|
||||||
|
}));
|
||||||
|
}
|
||||||
},
|
},
|
||||||
Err(error) => {
|
Err(error) => {
|
||||||
thread.project.update(cx, |project, cx| {
|
thread.project.update(cx, |project, cx| {
|
||||||
@@ -1736,6 +1836,7 @@ impl Thread {
|
|||||||
thread.cancel_last_completion(window, cx);
|
thread.cancel_last_completion(window, cx);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
cx.emit(ThreadEvent::Stopped(result.map_err(Arc::new)));
|
cx.emit(ThreadEvent::Stopped(result.map_err(Arc::new)));
|
||||||
|
|
||||||
if let Some((request_callback, (request, response_events))) = thread
|
if let Some((request_callback, (request, response_events))) = thread
|
||||||
@@ -1784,12 +1885,14 @@ impl Thread {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
let added_user_message = "Generate a concise 3-7 word title for this conversation, omitting punctuation. \
|
let added_user_message = include_str!("./prompts/summarize_thread_prompt.txt");
|
||||||
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.";
|
|
||||||
|
|
||||||
let request = self.to_summarize_request(&model.model, added_user_message.into(), cx);
|
let request = self.to_summarize_request(
|
||||||
|
&model.model,
|
||||||
|
CompletionIntent::ThreadSummarization,
|
||||||
|
added_user_message.into(),
|
||||||
|
cx,
|
||||||
|
);
|
||||||
|
|
||||||
self.summary = ThreadSummary::Generating;
|
self.summary = ThreadSummary::Generating;
|
||||||
|
|
||||||
@@ -1883,14 +1986,14 @@ impl Thread {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
let added_user_message = "Generate a detailed summary of this conversation. Include:\n\
|
let added_user_message = include_str!("./prompts/summarize_thread_detailed_prompt.txt");
|
||||||
1. A brief overview of what was discussed\n\
|
|
||||||
2. Key facts or information discovered\n\
|
|
||||||
3. Outcomes or conclusions reached\n\
|
|
||||||
4. Any action items or next steps if any\n\
|
|
||||||
Format it in Markdown with headings and bullet points.";
|
|
||||||
|
|
||||||
let request = self.to_summarize_request(&model, added_user_message.into(), cx);
|
let request = self.to_summarize_request(
|
||||||
|
&model,
|
||||||
|
CompletionIntent::ThreadContextSummarization,
|
||||||
|
added_user_message.into(),
|
||||||
|
cx,
|
||||||
|
);
|
||||||
|
|
||||||
*self.detailed_summary_tx.borrow_mut() = DetailedSummaryState::Generating {
|
*self.detailed_summary_tx.borrow_mut() = DetailedSummaryState::Generating {
|
||||||
message_id: last_message_id,
|
message_id: last_message_id,
|
||||||
@@ -1982,7 +2085,8 @@ impl Thread {
|
|||||||
model: Arc<dyn LanguageModel>,
|
model: Arc<dyn LanguageModel>,
|
||||||
) -> Vec<PendingToolUse> {
|
) -> Vec<PendingToolUse> {
|
||||||
self.auto_capture_telemetry(cx);
|
self.auto_capture_telemetry(cx);
|
||||||
let request = Arc::new(self.to_completion_request(model.clone(), cx));
|
let request =
|
||||||
|
Arc::new(self.to_completion_request(model.clone(), CompletionIntent::ToolResults, cx));
|
||||||
let pending_tool_uses = self
|
let pending_tool_uses = self
|
||||||
.tool_use
|
.tool_use
|
||||||
.pending_tool_uses()
|
.pending_tool_uses()
|
||||||
@@ -1994,7 +2098,7 @@ impl Thread {
|
|||||||
for tool_use in pending_tool_uses.iter() {
|
for tool_use in pending_tool_uses.iter() {
|
||||||
if let Some(tool) = self.tools.read(cx).tool(&tool_use.name, cx) {
|
if let Some(tool) = self.tools.read(cx).tool(&tool_use.name, cx) {
|
||||||
if tool.needs_confirmation(&tool_use.input, cx)
|
if tool.needs_confirmation(&tool_use.input, cx)
|
||||||
&& !AssistantSettings::get_global(cx).always_allow_tool_actions
|
&& !AgentSettings::get_global(cx).always_allow_tool_actions
|
||||||
{
|
{
|
||||||
self.tool_use.confirm_tool_use(
|
self.tool_use.confirm_tool_use(
|
||||||
tool_use.id.clone(),
|
tool_use.id.clone(),
|
||||||
@@ -2036,7 +2140,7 @@ impl Thread {
|
|||||||
window: Option<AnyWindowHandle>,
|
window: Option<AnyWindowHandle>,
|
||||||
cx: &mut Context<Thread>,
|
cx: &mut Context<Thread>,
|
||||||
) {
|
) {
|
||||||
let available_tools = self.tools.read(cx).enabled_tools(cx);
|
let available_tools = self.profile.enabled_tools(cx);
|
||||||
|
|
||||||
let tool_list = available_tools
|
let tool_list = available_tools
|
||||||
.iter()
|
.iter()
|
||||||
@@ -2128,19 +2232,15 @@ impl Thread {
|
|||||||
) -> Task<()> {
|
) -> Task<()> {
|
||||||
let tool_name: Arc<str> = tool.name().into();
|
let tool_name: Arc<str> = tool.name().into();
|
||||||
|
|
||||||
let tool_result = if self.tools.read(cx).is_disabled(&tool.source(), &tool_name) {
|
let tool_result = tool.run(
|
||||||
Task::ready(Err(anyhow!("tool is disabled: {tool_name}"))).into()
|
input,
|
||||||
} else {
|
request,
|
||||||
tool.run(
|
self.project.clone(),
|
||||||
input,
|
self.action_log.clone(),
|
||||||
request,
|
model,
|
||||||
self.project.clone(),
|
window,
|
||||||
self.action_log.clone(),
|
cx,
|
||||||
model,
|
);
|
||||||
window,
|
|
||||||
cx,
|
|
||||||
)
|
|
||||||
};
|
|
||||||
|
|
||||||
// Store the card separately if it exists
|
// Store the card separately if it exists
|
||||||
if let Some(card) = tool_result.card.clone() {
|
if let Some(card) = tool_result.card.clone() {
|
||||||
@@ -2178,7 +2278,7 @@ impl Thread {
|
|||||||
if self.all_tools_finished() {
|
if self.all_tools_finished() {
|
||||||
if let Some(ConfiguredModel { model, .. }) = self.configured_model.as_ref() {
|
if let Some(ConfiguredModel { model, .. }) = self.configured_model.as_ref() {
|
||||||
if !canceled {
|
if !canceled {
|
||||||
self.send_to_model(model.clone(), window, cx);
|
self.send_to_model(model.clone(), CompletionIntent::ToolResults, window, cx);
|
||||||
}
|
}
|
||||||
self.auto_capture_telemetry(cx);
|
self.auto_capture_telemetry(cx);
|
||||||
}
|
}
|
||||||
@@ -2211,10 +2311,17 @@ impl Thread {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
self.finalize_pending_checkpoint(cx);
|
|
||||||
|
|
||||||
if canceled {
|
if canceled {
|
||||||
cx.emit(ThreadEvent::CompletionCanceled);
|
cx.emit(ThreadEvent::CompletionCanceled);
|
||||||
|
|
||||||
|
// When canceled, we always want to insert the checkpoint.
|
||||||
|
// (We skip over finalize_pending_checkpoint, because it
|
||||||
|
// would conclude we didn't have anything to insert here.)
|
||||||
|
if let Some(checkpoint) = self.pending_checkpoint.take() {
|
||||||
|
self.insert_checkpoint(checkpoint, cx);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
self.finalize_pending_checkpoint(cx);
|
||||||
}
|
}
|
||||||
|
|
||||||
canceled
|
canceled
|
||||||
@@ -2252,8 +2359,7 @@ impl Thread {
|
|||||||
let client = self.project.read(cx).client();
|
let client = self.project.read(cx).client();
|
||||||
|
|
||||||
let enabled_tool_names: Vec<String> = self
|
let enabled_tool_names: Vec<String> = self
|
||||||
.tools()
|
.profile
|
||||||
.read(cx)
|
|
||||||
.enabled_tools(cx)
|
.enabled_tools(cx)
|
||||||
.iter()
|
.iter()
|
||||||
.map(|tool| tool.name())
|
.map(|tool| tool.name())
|
||||||
@@ -2518,11 +2624,7 @@ impl Thread {
|
|||||||
|
|
||||||
writeln!(markdown, "**\n")?;
|
writeln!(markdown, "**\n")?;
|
||||||
match &tool_result.content {
|
match &tool_result.content {
|
||||||
LanguageModelToolResultContent::Text(text)
|
LanguageModelToolResultContent::Text(text) => {
|
||||||
| LanguageModelToolResultContent::WrappedText(WrappedTextContent {
|
|
||||||
text,
|
|
||||||
..
|
|
||||||
}) => {
|
|
||||||
writeln!(markdown, "{text}")?;
|
writeln!(markdown, "{text}")?;
|
||||||
}
|
}
|
||||||
LanguageModelToolResultContent::Image(image) => {
|
LanguageModelToolResultContent::Image(image) => {
|
||||||
@@ -2767,8 +2869,10 @@ pub enum ThreadEvent {
|
|||||||
},
|
},
|
||||||
CheckpointChanged,
|
CheckpointChanged,
|
||||||
ToolConfirmationNeeded,
|
ToolConfirmationNeeded,
|
||||||
|
ToolUseLimitReached,
|
||||||
CancelEditing,
|
CancelEditing,
|
||||||
CompletionCanceled,
|
CompletionCanceled,
|
||||||
|
ProfileChanged,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl EventEmitter<ThreadEvent> for Thread {}
|
impl EventEmitter<ThreadEvent> for Thread {}
|
||||||
@@ -2783,7 +2887,7 @@ struct PendingCompletion {
|
|||||||
mod tests {
|
mod tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
use crate::{ThreadStore, context::load_context, context_store::ContextStore, thread_store};
|
use crate::{ThreadStore, context::load_context, context_store::ContextStore, thread_store};
|
||||||
use assistant_settings::{AssistantSettings, LanguageModelParameters};
|
use agent_settings::{AgentProfileId, AgentSettings, LanguageModelParameters};
|
||||||
use assistant_tool::ToolRegistry;
|
use assistant_tool::ToolRegistry;
|
||||||
use editor::EditorSettings;
|
use editor::EditorSettings;
|
||||||
use gpui::TestAppContext;
|
use gpui::TestAppContext;
|
||||||
@@ -2814,7 +2918,8 @@ mod tests {
|
|||||||
.await
|
.await
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
let context = context_store.update(cx, |store, _| store.context().next().cloned().unwrap());
|
let context =
|
||||||
|
context_store.read_with(cx, |store, _| store.context().next().cloned().unwrap());
|
||||||
let loaded_context = cx
|
let loaded_context = cx
|
||||||
.update(|cx| load_context(vec![context], &project, &None, cx))
|
.update(|cx| load_context(vec![context], &project, &None, cx))
|
||||||
.await;
|
.await;
|
||||||
@@ -2865,7 +2970,7 @@ fn main() {{
|
|||||||
|
|
||||||
// Check message in request
|
// Check message in request
|
||||||
let request = thread.update(cx, |thread, cx| {
|
let request = thread.update(cx, |thread, cx| {
|
||||||
thread.to_completion_request(model.clone(), cx)
|
thread.to_completion_request(model.clone(), CompletionIntent::UserPrompt, cx)
|
||||||
});
|
});
|
||||||
|
|
||||||
assert_eq!(request.messages.len(), 2);
|
assert_eq!(request.messages.len(), 2);
|
||||||
@@ -2960,7 +3065,7 @@ fn main() {{
|
|||||||
|
|
||||||
// Check entire request to make sure all contexts are properly included
|
// Check entire request to make sure all contexts are properly included
|
||||||
let request = thread.update(cx, |thread, cx| {
|
let request = thread.update(cx, |thread, cx| {
|
||||||
thread.to_completion_request(model.clone(), cx)
|
thread.to_completion_request(model.clone(), CompletionIntent::UserPrompt, cx)
|
||||||
});
|
});
|
||||||
|
|
||||||
// The request should contain all 3 messages
|
// The request should contain all 3 messages
|
||||||
@@ -3067,7 +3172,7 @@ fn main() {{
|
|||||||
|
|
||||||
// Check message in request
|
// Check message in request
|
||||||
let request = thread.update(cx, |thread, cx| {
|
let request = thread.update(cx, |thread, cx| {
|
||||||
thread.to_completion_request(model.clone(), cx)
|
thread.to_completion_request(model.clone(), CompletionIntent::UserPrompt, cx)
|
||||||
});
|
});
|
||||||
|
|
||||||
assert_eq!(request.messages.len(), 2);
|
assert_eq!(request.messages.len(), 2);
|
||||||
@@ -3093,7 +3198,7 @@ fn main() {{
|
|||||||
|
|
||||||
// Check that both messages appear in the request
|
// Check that both messages appear in the request
|
||||||
let request = thread.update(cx, |thread, cx| {
|
let request = thread.update(cx, |thread, cx| {
|
||||||
thread.to_completion_request(model.clone(), cx)
|
thread.to_completion_request(model.clone(), CompletionIntent::UserPrompt, cx)
|
||||||
});
|
});
|
||||||
|
|
||||||
assert_eq!(request.messages.len(), 3);
|
assert_eq!(request.messages.len(), 3);
|
||||||
@@ -3125,7 +3230,8 @@ fn main() {{
|
|||||||
.await
|
.await
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
let context = context_store.update(cx, |store, _| store.context().next().cloned().unwrap());
|
let context =
|
||||||
|
context_store.read_with(cx, |store, _| store.context().next().cloned().unwrap());
|
||||||
let loaded_context = cx
|
let loaded_context = cx
|
||||||
.update(|cx| load_context(vec![context], &project, &None, cx))
|
.update(|cx| load_context(vec![context], &project, &None, cx))
|
||||||
.await;
|
.await;
|
||||||
@@ -3137,7 +3243,7 @@ fn main() {{
|
|||||||
|
|
||||||
// Create a request and check that it doesn't have a stale buffer warning yet
|
// Create a request and check that it doesn't have a stale buffer warning yet
|
||||||
let initial_request = thread.update(cx, |thread, cx| {
|
let initial_request = thread.update(cx, |thread, cx| {
|
||||||
thread.to_completion_request(model.clone(), cx)
|
thread.to_completion_request(model.clone(), CompletionIntent::UserPrompt, cx)
|
||||||
});
|
});
|
||||||
|
|
||||||
// Make sure we don't have a stale file warning yet
|
// Make sure we don't have a stale file warning yet
|
||||||
@@ -3173,7 +3279,7 @@ fn main() {{
|
|||||||
|
|
||||||
// Create a new request and check for the stale buffer warning
|
// Create a new request and check for the stale buffer warning
|
||||||
let new_request = thread.update(cx, |thread, cx| {
|
let new_request = thread.update(cx, |thread, cx| {
|
||||||
thread.to_completion_request(model.clone(), cx)
|
thread.to_completion_request(model.clone(), CompletionIntent::UserPrompt, cx)
|
||||||
});
|
});
|
||||||
|
|
||||||
// We should have a stale file warning as the last message
|
// We should have a stale file warning as the last message
|
||||||
@@ -3194,6 +3300,71 @@ fn main() {{
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[gpui::test]
|
||||||
|
async fn test_storing_profile_setting_per_thread(cx: &mut TestAppContext) {
|
||||||
|
init_test_settings(cx);
|
||||||
|
|
||||||
|
let project = create_test_project(
|
||||||
|
cx,
|
||||||
|
json!({"code.rs": "fn main() {\n println!(\"Hello, world!\");\n}"}),
|
||||||
|
)
|
||||||
|
.await;
|
||||||
|
|
||||||
|
let (_workspace, thread_store, thread, _context_store, _model) =
|
||||||
|
setup_test_environment(cx, project.clone()).await;
|
||||||
|
|
||||||
|
// Check that we are starting with the default profile
|
||||||
|
let profile = cx.read(|cx| thread.read(cx).profile.clone());
|
||||||
|
let tool_set = cx.read(|cx| thread_store.read(cx).tools());
|
||||||
|
assert_eq!(
|
||||||
|
profile,
|
||||||
|
AgentProfile::new(AgentProfileId::default(), tool_set)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[gpui::test]
|
||||||
|
async fn test_serializing_thread_profile(cx: &mut TestAppContext) {
|
||||||
|
init_test_settings(cx);
|
||||||
|
|
||||||
|
let project = create_test_project(
|
||||||
|
cx,
|
||||||
|
json!({"code.rs": "fn main() {\n println!(\"Hello, world!\");\n}"}),
|
||||||
|
)
|
||||||
|
.await;
|
||||||
|
|
||||||
|
let (_workspace, thread_store, thread, _context_store, _model) =
|
||||||
|
setup_test_environment(cx, project.clone()).await;
|
||||||
|
|
||||||
|
// Profile gets serialized with default values
|
||||||
|
let serialized = thread
|
||||||
|
.update(cx, |thread, cx| thread.serialize(cx))
|
||||||
|
.await
|
||||||
|
.unwrap();
|
||||||
|
|
||||||
|
assert_eq!(serialized.profile, Some(AgentProfileId::default()));
|
||||||
|
|
||||||
|
let deserialized = cx.update(|cx| {
|
||||||
|
thread.update(cx, |thread, cx| {
|
||||||
|
Thread::deserialize(
|
||||||
|
thread.id.clone(),
|
||||||
|
serialized,
|
||||||
|
thread.project.clone(),
|
||||||
|
thread.tools.clone(),
|
||||||
|
thread.prompt_builder.clone(),
|
||||||
|
thread.project_context.clone(),
|
||||||
|
None,
|
||||||
|
cx,
|
||||||
|
)
|
||||||
|
})
|
||||||
|
});
|
||||||
|
let tool_set = cx.read(|cx| thread_store.read(cx).tools());
|
||||||
|
|
||||||
|
assert_eq!(
|
||||||
|
deserialized.profile,
|
||||||
|
AgentProfile::new(AgentProfileId::default(), tool_set)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
#[gpui::test]
|
#[gpui::test]
|
||||||
async fn test_temperature_setting(cx: &mut TestAppContext) {
|
async fn test_temperature_setting(cx: &mut TestAppContext) {
|
||||||
init_test_settings(cx);
|
init_test_settings(cx);
|
||||||
@@ -3209,81 +3380,81 @@ fn main() {{
|
|||||||
|
|
||||||
// Both model and provider
|
// Both model and provider
|
||||||
cx.update(|cx| {
|
cx.update(|cx| {
|
||||||
AssistantSettings::override_global(
|
AgentSettings::override_global(
|
||||||
AssistantSettings {
|
AgentSettings {
|
||||||
model_parameters: vec![LanguageModelParameters {
|
model_parameters: vec![LanguageModelParameters {
|
||||||
provider: Some(model.provider_id().0.to_string().into()),
|
provider: Some(model.provider_id().0.to_string().into()),
|
||||||
model: Some(model.id().0.clone()),
|
model: Some(model.id().0.clone()),
|
||||||
temperature: Some(0.66),
|
temperature: Some(0.66),
|
||||||
}],
|
}],
|
||||||
..AssistantSettings::get_global(cx).clone()
|
..AgentSettings::get_global(cx).clone()
|
||||||
},
|
},
|
||||||
cx,
|
cx,
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
let request = thread.update(cx, |thread, cx| {
|
let request = thread.update(cx, |thread, cx| {
|
||||||
thread.to_completion_request(model.clone(), cx)
|
thread.to_completion_request(model.clone(), CompletionIntent::UserPrompt, cx)
|
||||||
});
|
});
|
||||||
assert_eq!(request.temperature, Some(0.66));
|
assert_eq!(request.temperature, Some(0.66));
|
||||||
|
|
||||||
// Only model
|
// Only model
|
||||||
cx.update(|cx| {
|
cx.update(|cx| {
|
||||||
AssistantSettings::override_global(
|
AgentSettings::override_global(
|
||||||
AssistantSettings {
|
AgentSettings {
|
||||||
model_parameters: vec![LanguageModelParameters {
|
model_parameters: vec![LanguageModelParameters {
|
||||||
provider: None,
|
provider: None,
|
||||||
model: Some(model.id().0.clone()),
|
model: Some(model.id().0.clone()),
|
||||||
temperature: Some(0.66),
|
temperature: Some(0.66),
|
||||||
}],
|
}],
|
||||||
..AssistantSettings::get_global(cx).clone()
|
..AgentSettings::get_global(cx).clone()
|
||||||
},
|
},
|
||||||
cx,
|
cx,
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
let request = thread.update(cx, |thread, cx| {
|
let request = thread.update(cx, |thread, cx| {
|
||||||
thread.to_completion_request(model.clone(), cx)
|
thread.to_completion_request(model.clone(), CompletionIntent::UserPrompt, cx)
|
||||||
});
|
});
|
||||||
assert_eq!(request.temperature, Some(0.66));
|
assert_eq!(request.temperature, Some(0.66));
|
||||||
|
|
||||||
// Only provider
|
// Only provider
|
||||||
cx.update(|cx| {
|
cx.update(|cx| {
|
||||||
AssistantSettings::override_global(
|
AgentSettings::override_global(
|
||||||
AssistantSettings {
|
AgentSettings {
|
||||||
model_parameters: vec![LanguageModelParameters {
|
model_parameters: vec![LanguageModelParameters {
|
||||||
provider: Some(model.provider_id().0.to_string().into()),
|
provider: Some(model.provider_id().0.to_string().into()),
|
||||||
model: None,
|
model: None,
|
||||||
temperature: Some(0.66),
|
temperature: Some(0.66),
|
||||||
}],
|
}],
|
||||||
..AssistantSettings::get_global(cx).clone()
|
..AgentSettings::get_global(cx).clone()
|
||||||
},
|
},
|
||||||
cx,
|
cx,
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
let request = thread.update(cx, |thread, cx| {
|
let request = thread.update(cx, |thread, cx| {
|
||||||
thread.to_completion_request(model.clone(), cx)
|
thread.to_completion_request(model.clone(), CompletionIntent::UserPrompt, cx)
|
||||||
});
|
});
|
||||||
assert_eq!(request.temperature, Some(0.66));
|
assert_eq!(request.temperature, Some(0.66));
|
||||||
|
|
||||||
// Same model name, different provider
|
// Same model name, different provider
|
||||||
cx.update(|cx| {
|
cx.update(|cx| {
|
||||||
AssistantSettings::override_global(
|
AgentSettings::override_global(
|
||||||
AssistantSettings {
|
AgentSettings {
|
||||||
model_parameters: vec![LanguageModelParameters {
|
model_parameters: vec![LanguageModelParameters {
|
||||||
provider: Some("anthropic".into()),
|
provider: Some("anthropic".into()),
|
||||||
model: Some(model.id().0.clone()),
|
model: Some(model.id().0.clone()),
|
||||||
temperature: Some(0.66),
|
temperature: Some(0.66),
|
||||||
}],
|
}],
|
||||||
..AssistantSettings::get_global(cx).clone()
|
..AgentSettings::get_global(cx).clone()
|
||||||
},
|
},
|
||||||
cx,
|
cx,
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
let request = thread.update(cx, |thread, cx| {
|
let request = thread.update(cx, |thread, cx| {
|
||||||
thread.to_completion_request(model.clone(), cx)
|
thread.to_completion_request(model.clone(), CompletionIntent::UserPrompt, cx)
|
||||||
});
|
});
|
||||||
assert_eq!(request.temperature, None);
|
assert_eq!(request.temperature, None);
|
||||||
}
|
}
|
||||||
@@ -3315,7 +3486,12 @@ fn main() {{
|
|||||||
// Send a message
|
// Send a message
|
||||||
thread.update(cx, |thread, cx| {
|
thread.update(cx, |thread, cx| {
|
||||||
thread.insert_user_message("Hi!", ContextLoadResult::default(), None, vec![], cx);
|
thread.insert_user_message("Hi!", ContextLoadResult::default(), None, vec![], cx);
|
||||||
thread.send_to_model(model.clone(), None, cx);
|
thread.send_to_model(
|
||||||
|
model.clone(),
|
||||||
|
CompletionIntent::ThreadSummarization,
|
||||||
|
None,
|
||||||
|
cx,
|
||||||
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
let fake_model = model.as_fake();
|
let fake_model = model.as_fake();
|
||||||
@@ -3337,8 +3513,8 @@ fn main() {{
|
|||||||
});
|
});
|
||||||
|
|
||||||
cx.run_until_parked();
|
cx.run_until_parked();
|
||||||
fake_model.stream_last_completion_response("Brief".into());
|
fake_model.stream_last_completion_response("Brief");
|
||||||
fake_model.stream_last_completion_response(" Introduction".into());
|
fake_model.stream_last_completion_response(" Introduction");
|
||||||
fake_model.end_last_completion_stream();
|
fake_model.end_last_completion_stream();
|
||||||
cx.run_until_parked();
|
cx.run_until_parked();
|
||||||
|
|
||||||
@@ -3410,7 +3586,7 @@ fn main() {{
|
|||||||
vec![],
|
vec![],
|
||||||
cx,
|
cx,
|
||||||
);
|
);
|
||||||
thread.send_to_model(model.clone(), None, cx);
|
thread.send_to_model(model.clone(), CompletionIntent::UserPrompt, None, cx);
|
||||||
});
|
});
|
||||||
|
|
||||||
let fake_model = model.as_fake();
|
let fake_model = model.as_fake();
|
||||||
@@ -3431,7 +3607,7 @@ fn main() {{
|
|||||||
});
|
});
|
||||||
|
|
||||||
cx.run_until_parked();
|
cx.run_until_parked();
|
||||||
fake_model.stream_last_completion_response("A successful summary".into());
|
fake_model.stream_last_completion_response("A successful summary");
|
||||||
fake_model.end_last_completion_stream();
|
fake_model.end_last_completion_stream();
|
||||||
cx.run_until_parked();
|
cx.run_until_parked();
|
||||||
|
|
||||||
@@ -3448,7 +3624,12 @@ fn main() {{
|
|||||||
) {
|
) {
|
||||||
thread.update(cx, |thread, cx| {
|
thread.update(cx, |thread, cx| {
|
||||||
thread.insert_user_message("Hi!", ContextLoadResult::default(), None, vec![], cx);
|
thread.insert_user_message("Hi!", ContextLoadResult::default(), None, vec![], cx);
|
||||||
thread.send_to_model(model.clone(), None, cx);
|
thread.send_to_model(
|
||||||
|
model.clone(),
|
||||||
|
CompletionIntent::ThreadSummarization,
|
||||||
|
None,
|
||||||
|
cx,
|
||||||
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
let fake_model = model.as_fake();
|
let fake_model = model.as_fake();
|
||||||
@@ -3473,7 +3654,7 @@ fn main() {{
|
|||||||
|
|
||||||
fn simulate_successful_response(fake_model: &FakeLanguageModel, cx: &mut TestAppContext) {
|
fn simulate_successful_response(fake_model: &FakeLanguageModel, cx: &mut TestAppContext) {
|
||||||
cx.run_until_parked();
|
cx.run_until_parked();
|
||||||
fake_model.stream_last_completion_response("Assistant response".into());
|
fake_model.stream_last_completion_response("Assistant response");
|
||||||
fake_model.end_last_completion_stream();
|
fake_model.end_last_completion_stream();
|
||||||
cx.run_until_parked();
|
cx.run_until_parked();
|
||||||
}
|
}
|
||||||
@@ -3484,7 +3665,7 @@ fn main() {{
|
|||||||
cx.set_global(settings_store);
|
cx.set_global(settings_store);
|
||||||
language::init(cx);
|
language::init(cx);
|
||||||
Project::init_settings(cx);
|
Project::init_settings(cx);
|
||||||
AssistantSettings::register(cx);
|
AgentSettings::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,12 +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;
|
use std::sync::{Arc, Mutex};
|
||||||
|
|
||||||
|
use agent_settings::{AgentProfileId, CompletionMode};
|
||||||
use anyhow::{Context as _, Result, anyhow};
|
use anyhow::{Context as _, Result, anyhow};
|
||||||
use assistant_settings::{AgentProfile, AgentProfileId, AssistantSettings, CompletionMode};
|
use assistant_tool::{ToolId, ToolWorkingSet};
|
||||||
use assistant_tool::{ToolId, ToolSource, ToolWorkingSet};
|
|
||||||
use chrono::{DateTime, Utc};
|
use chrono::{DateTime, Utc};
|
||||||
use collections::HashMap;
|
use collections::HashMap;
|
||||||
use context_server::ContextServerId;
|
use context_server::ContextServerId;
|
||||||
@@ -17,8 +16,7 @@ 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 heed::types::SerdeBincode;
|
|
||||||
use language_model::{LanguageModelToolResultContent, LanguageModelToolUseId, Role, TokenUsage};
|
use language_model::{LanguageModelToolResultContent, 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};
|
||||||
@@ -27,7 +25,6 @@ use prompt_store::{
|
|||||||
UserRulesContext, WorktreeContext,
|
UserRulesContext, WorktreeContext,
|
||||||
};
|
};
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use settings::{Settings as _, SettingsStore};
|
|
||||||
use ui::Window;
|
use ui::Window;
|
||||||
use util::ResultExt as _;
|
use util::ResultExt as _;
|
||||||
|
|
||||||
@@ -35,14 +32,52 @@ 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,
|
||||||
|
};
|
||||||
|
|
||||||
const RULES_FILE_NAMES: [&'static str; 6] = [
|
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
|
||||||
|
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) {
|
||||||
@@ -111,12 +146,7 @@ impl ThreadStore {
|
|||||||
prompt_store: Option<Entity<PromptStore>>,
|
prompt_store: Option<Entity<PromptStore>>,
|
||||||
cx: &mut Context<Self>,
|
cx: &mut Context<Self>,
|
||||||
) -> (Self, oneshot::Receiver<()>) {
|
) -> (Self, oneshot::Receiver<()>) {
|
||||||
let mut subscriptions = vec![
|
let mut subscriptions = vec![cx.subscribe(&project, Self::handle_project_event)];
|
||||||
cx.observe_global::<SettingsStore>(move |this: &mut Self, cx| {
|
|
||||||
this.load_default_profile(cx);
|
|
||||||
}),
|
|
||||||
cx.subscribe(&project, Self::handle_project_event),
|
|
||||||
];
|
|
||||||
|
|
||||||
if let Some(prompt_store) = prompt_store.as_ref() {
|
if let Some(prompt_store) = prompt_store.as_ref() {
|
||||||
subscriptions.push(cx.subscribe(
|
subscriptions.push(cx.subscribe(
|
||||||
@@ -164,7 +194,6 @@ impl ThreadStore {
|
|||||||
_reload_system_prompt_task: reload_system_prompt_task,
|
_reload_system_prompt_task: reload_system_prompt_task,
|
||||||
_subscriptions: subscriptions,
|
_subscriptions: subscriptions,
|
||||||
};
|
};
|
||||||
this.load_default_profile(cx);
|
|
||||||
this.register_context_server_handlers(cx);
|
this.register_context_server_handlers(cx);
|
||||||
this.reload(cx).detach_and_log_err(cx);
|
this.reload(cx).detach_and_log_err(cx);
|
||||||
(this, ready_rx)
|
(this, ready_rx)
|
||||||
@@ -484,92 +513,15 @@ impl ThreadStore {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
fn load_default_profile(&self, cx: &mut Context<Self>) {
|
|
||||||
let assistant_settings = AssistantSettings::get_global(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>) {
|
|
||||||
let assistant_settings = AssistantSettings::get_global(cx);
|
|
||||||
|
|
||||||
if let Some(profile) = assistant_settings.profiles.get(&profile_id) {
|
|
||||||
self.load_profile(profile.clone(), cx);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn load_profile(&self, profile: AgentProfile, cx: &mut Context<Self>) {
|
|
||||||
self.tools.update(cx, |tools, cx| {
|
|
||||||
tools.disable_all_tools(cx);
|
|
||||||
tools.enable(
|
|
||||||
ToolSource::Native,
|
|
||||||
&profile
|
|
||||||
.tools
|
|
||||||
.into_iter()
|
|
||||||
.filter_map(|(tool, enabled)| enabled.then(|| tool))
|
|
||||||
.collect::<Vec<_>>(),
|
|
||||||
cx,
|
|
||||||
);
|
|
||||||
});
|
|
||||||
|
|
||||||
if profile.enable_all_context_servers {
|
|
||||||
for context_server_id in self
|
|
||||||
.project
|
|
||||||
.read(cx)
|
|
||||||
.context_server_store()
|
|
||||||
.read(cx)
|
|
||||||
.all_server_ids()
|
|
||||||
{
|
|
||||||
self.tools.update(cx, |tools, cx| {
|
|
||||||
tools.enable_source(
|
|
||||||
ToolSource::ContextServer {
|
|
||||||
id: context_server_id.0.into(),
|
|
||||||
},
|
|
||||||
cx,
|
|
||||||
);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
// 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 {
|
|
||||||
self.tools.update(cx, |tools, cx| {
|
|
||||||
tools.disable(
|
|
||||||
ToolSource::ContextServer {
|
|
||||||
id: context_server_id.into(),
|
|
||||||
},
|
|
||||||
&preset
|
|
||||||
.tools
|
|
||||||
.into_iter()
|
|
||||||
.filter_map(|(tool, enabled)| (!enabled).then(|| tool))
|
|
||||||
.collect::<Vec<_>>(),
|
|
||||||
cx,
|
|
||||||
)
|
|
||||||
})
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
for (context_server_id, preset) in profile.context_servers {
|
|
||||||
self.tools.update(cx, |tools, cx| {
|
|
||||||
tools.enable(
|
|
||||||
ToolSource::ContextServer {
|
|
||||||
id: context_server_id.into(),
|
|
||||||
},
|
|
||||||
&preset
|
|
||||||
.tools
|
|
||||||
.into_iter()
|
|
||||||
.filter_map(|(tool, enabled)| enabled.then(|| tool))
|
|
||||||
.collect::<Vec<_>>(),
|
|
||||||
cx,
|
|
||||||
)
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn register_context_server_handlers(&self, cx: &mut Context<Self>) {
|
fn register_context_server_handlers(&self, cx: &mut Context<Self>) {
|
||||||
cx.subscribe(
|
let context_server_store = self.project.read(cx).context_server_store();
|
||||||
&self.project.read(cx).context_server_store(),
|
cx.subscribe(&context_server_store, Self::handle_context_server_event)
|
||||||
Self::handle_context_server_event,
|
.detach();
|
||||||
)
|
|
||||||
.detach();
|
// Check for any servers that were already running before the handler was registered
|
||||||
|
for server in context_server_store.read(cx).running_servers() {
|
||||||
|
self.load_context_server_tools(server.id(), context_server_store.clone(), cx);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn handle_context_server_event(
|
fn handle_context_server_event(
|
||||||
@@ -582,71 +534,71 @@ impl ThreadStore {
|
|||||||
match event {
|
match event {
|
||||||
project::context_server_store::Event::ServerStatusChanged { server_id, status } => {
|
project::context_server_store::Event::ServerStatusChanged { server_id, status } => {
|
||||||
match status {
|
match status {
|
||||||
|
ContextServerStatus::Starting => {}
|
||||||
ContextServerStatus::Running => {
|
ContextServerStatus::Running => {
|
||||||
if let Some(server) =
|
self.load_context_server_tools(server_id.clone(), context_server_store, cx);
|
||||||
context_server_store.read(cx).get_running_server(server_id)
|
|
||||||
{
|
|
||||||
let context_server_manager = context_server_store.clone();
|
|
||||||
cx.spawn({
|
|
||||||
let server = server.clone();
|
|
||||||
let server_id = server_id.clone();
|
|
||||||
async move |this, cx| {
|
|
||||||
let Some(protocol) = server.client() else {
|
|
||||||
return;
|
|
||||||
};
|
|
||||||
|
|
||||||
if protocol.capable(context_server::protocol::ServerCapability::Tools) {
|
|
||||||
if let Some(tools) = protocol.list_tools().await.log_err() {
|
|
||||||
let tool_ids = tool_working_set
|
|
||||||
.update(cx, |tool_working_set, _| {
|
|
||||||
tools
|
|
||||||
.tools
|
|
||||||
.into_iter()
|
|
||||||
.map(|tool| {
|
|
||||||
log::info!(
|
|
||||||
"registering context server tool: {:?}",
|
|
||||||
tool.name
|
|
||||||
);
|
|
||||||
tool_working_set.insert(Arc::new(
|
|
||||||
ContextServerTool::new(
|
|
||||||
context_server_manager.clone(),
|
|
||||||
server.id(),
|
|
||||||
tool,
|
|
||||||
),
|
|
||||||
))
|
|
||||||
})
|
|
||||||
.collect::<Vec<_>>()
|
|
||||||
})
|
|
||||||
.log_err();
|
|
||||||
|
|
||||||
if let Some(tool_ids) = tool_ids {
|
|
||||||
this.update(cx, |this, cx| {
|
|
||||||
this.context_server_tool_ids
|
|
||||||
.insert(server_id, tool_ids);
|
|
||||||
this.load_default_profile(cx);
|
|
||||||
})
|
|
||||||
.log_err();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
})
|
|
||||||
.detach();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
ContextServerStatus::Stopped | ContextServerStatus::Error(_) => {
|
ContextServerStatus::Stopped | ContextServerStatus::Error(_) => {
|
||||||
if let Some(tool_ids) = self.context_server_tool_ids.remove(server_id) {
|
if let Some(tool_ids) = self.context_server_tool_ids.remove(server_id) {
|
||||||
tool_working_set.update(cx, |tool_working_set, _| {
|
tool_working_set.update(cx, |tool_working_set, _| {
|
||||||
tool_working_set.remove(&tool_ids);
|
tool_working_set.remove(&tool_ids);
|
||||||
});
|
});
|
||||||
self.load_default_profile(cx);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_ => {}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn load_context_server_tools(
|
||||||
|
&self,
|
||||||
|
server_id: ContextServerId,
|
||||||
|
context_server_store: Entity<ContextServerStore>,
|
||||||
|
cx: &mut Context<Self>,
|
||||||
|
) {
|
||||||
|
let Some(server) = context_server_store.read(cx).get_running_server(&server_id) else {
|
||||||
|
return;
|
||||||
|
};
|
||||||
|
let tool_working_set = self.tools.clone();
|
||||||
|
cx.spawn(async move |this, cx| {
|
||||||
|
let Some(protocol) = server.client() else {
|
||||||
|
return;
|
||||||
|
};
|
||||||
|
|
||||||
|
if protocol.capable(context_server::protocol::ServerCapability::Tools) {
|
||||||
|
if let Some(response) = protocol
|
||||||
|
.request::<context_server::types::request::ListTools>(())
|
||||||
|
.await
|
||||||
|
.log_err()
|
||||||
|
{
|
||||||
|
let tool_ids = tool_working_set
|
||||||
|
.update(cx, |tool_working_set, _| {
|
||||||
|
response
|
||||||
|
.tools
|
||||||
|
.into_iter()
|
||||||
|
.map(|tool| {
|
||||||
|
log::info!("registering context server tool: {:?}", tool.name);
|
||||||
|
tool_working_set.insert(Arc::new(ContextServerTool::new(
|
||||||
|
context_server_store.clone(),
|
||||||
|
server.id(),
|
||||||
|
tool,
|
||||||
|
)))
|
||||||
|
})
|
||||||
|
.collect::<Vec<_>>()
|
||||||
|
})
|
||||||
|
.log_err();
|
||||||
|
|
||||||
|
if let Some(tool_ids) = tool_ids {
|
||||||
|
this.update(cx, |this, _| {
|
||||||
|
this.context_server_tool_ids.insert(server_id, tool_ids);
|
||||||
|
})
|
||||||
|
.log_err();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.detach();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||||
@@ -676,6 +628,10 @@ pub struct SerializedThread {
|
|||||||
pub model: Option<SerializedLanguageModel>,
|
pub model: Option<SerializedLanguageModel>,
|
||||||
#[serde(default)]
|
#[serde(default)]
|
||||||
pub completion_mode: Option<CompletionMode>,
|
pub completion_mode: Option<CompletionMode>,
|
||||||
|
#[serde(default)]
|
||||||
|
pub tool_use_limit_reached: bool,
|
||||||
|
#[serde(default)]
|
||||||
|
pub profile: Option<AgentProfileId>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Serialize, Deserialize, Debug)]
|
#[derive(Serialize, Deserialize, Debug)]
|
||||||
@@ -757,6 +713,8 @@ 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)]
|
||||||
@@ -815,6 +773,8 @@ 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,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -840,6 +800,7 @@ 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,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -860,25 +821,27 @@ impl Global for GlobalThreadsDatabase {}
|
|||||||
|
|
||||||
pub(crate) struct ThreadsDatabase {
|
pub(crate) struct ThreadsDatabase {
|
||||||
executor: BackgroundExecutor,
|
executor: BackgroundExecutor,
|
||||||
env: heed::Env,
|
connection: Arc<Mutex<Connection>>,
|
||||||
threads: Database<SerdeBincode<ThreadId>, SerializedThread>,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl heed::BytesEncode<'_> for SerializedThread {
|
impl ThreadsDatabase {
|
||||||
type EItem = SerializedThread;
|
fn connection(&self) -> Arc<Mutex<Connection>> {
|
||||||
|
self.connection.clone()
|
||||||
|
}
|
||||||
|
|
||||||
fn bytes_encode(item: &Self::EItem) -> Result<Cow<[u8]>, heed::BoxedError> {
|
const COMPRESSION_LEVEL: i32 = 3;
|
||||||
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<'a> heed::BytesDecode<'a> for SerializedThread {
|
impl Column for ThreadId {
|
||||||
type DItem = SerializedThread;
|
fn column(statement: &mut Statement, start_index: i32) -> Result<(Self, i32)> {
|
||||||
|
let (id_str, next_index) = String::column(statement, start_index)?;
|
||||||
fn bytes_decode(bytes: &'a [u8]) -> Result<Self::DItem, heed::BoxedError> {
|
Ok((ThreadId::from(id_str.as_str()), next_index))
|
||||||
// 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)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -894,8 +857,8 @@ impl ThreadsDatabase {
|
|||||||
let database_future = executor
|
let database_future = executor
|
||||||
.spawn({
|
.spawn({
|
||||||
let executor = executor.clone();
|
let executor = executor.clone();
|
||||||
let database_path = paths::data_dir().join("threads/threads-db.1.mdb");
|
let threads_dir = paths::data_dir().join("threads");
|
||||||
async move { ThreadsDatabase::new(database_path, executor) }
|
async move { ThreadsDatabase::new(threads_dir, 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()
|
||||||
@@ -904,41 +867,144 @@ impl ThreadsDatabase {
|
|||||||
cx.set_global(GlobalThreadsDatabase(database_future));
|
cx.set_global(GlobalThreadsDatabase(database_future));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn new(path: PathBuf, executor: BackgroundExecutor) -> Result<Self> {
|
pub fn new(threads_dir: PathBuf, executor: BackgroundExecutor) -> Result<Self> {
|
||||||
std::fs::create_dir_all(&path)?;
|
std::fs::create_dir_all(&threads_dir)?;
|
||||||
|
|
||||||
|
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(path)?
|
.open(mdb_path)?
|
||||||
};
|
};
|
||||||
|
|
||||||
let mut txn = env.write_txn()?;
|
let txn = env.write_txn()?;
|
||||||
let threads = env.create_database(&mut txn, Some("threads"))?;
|
let threads: heed::Database<SerdeBincode<ThreadId>, SerializedThreadHeed> = env
|
||||||
txn.commit()?;
|
.open_database(&txn, Some("threads"))?
|
||||||
|
.ok_or_else(|| anyhow!("threads database not found"))?;
|
||||||
|
|
||||||
Ok(Self {
|
for result in threads.iter(&txn)? {
|
||||||
executor,
|
let (thread_id, thread_heed) = result?;
|
||||||
env,
|
Self::save_thread_sync(&connection, thread_id, thread_heed.0)?;
|
||||||
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 env = self.env.clone();
|
let connection = self.connection.clone();
|
||||||
let threads = self.threads;
|
|
||||||
|
|
||||||
self.executor.spawn(async move {
|
self.executor.spawn(async move {
|
||||||
let txn = env.read_txn()?;
|
let connection = connection.lock().unwrap();
|
||||||
let mut iter = threads.iter(&txn)?;
|
let mut select =
|
||||||
|
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: key,
|
id,
|
||||||
summary: value.summary,
|
summary: summary.into(),
|
||||||
updated_at: value.updated_at,
|
updated_at: DateTime::parse_from_rfc3339(&updated_at)?.with_timezone(&Utc),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -947,36 +1013,51 @@ 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 env = self.env.clone();
|
let connection = self.connection.clone();
|
||||||
let threads = self.threads;
|
|
||||||
|
|
||||||
self.executor.spawn(async move {
|
self.executor.spawn(async move {
|
||||||
let txn = env.read_txn()?;
|
let connection = connection.lock().unwrap();
|
||||||
let thread = threads.get(&txn, &id)?;
|
let mut select = connection.select_bound::<ThreadId, (DataType, Vec<u8>)>(indoc! {"
|
||||||
Ok(thread)
|
SELECT data_type, data FROM threads WHERE id = ? LIMIT 1
|
||||||
|
"})?;
|
||||||
|
|
||||||
|
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 env = self.env.clone();
|
let connection = self.connection.clone();
|
||||||
let threads = self.threads;
|
|
||||||
|
|
||||||
self.executor.spawn(async move {
|
self.executor
|
||||||
let mut txn = env.write_txn()?;
|
.spawn(async move { Self::save_thread_sync(&connection, id, thread) })
|
||||||
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 env = self.env.clone();
|
let connection = self.connection.clone();
|
||||||
let threads = self.threads;
|
|
||||||
|
|
||||||
self.executor.spawn(async move {
|
self.executor.spawn(async move {
|
||||||
let mut txn = env.write_txn()?;
|
let connection = connection.lock().unwrap();
|
||||||
threads.delete(&mut txn, &id)?;
|
|
||||||
txn.commit()?;
|
let mut delete = connection.exec_bound::<ThreadId>(indoc! {"
|
||||||
|
DELETE FROM threads WHERE id = ?
|
||||||
|
"})?;
|
||||||
|
|
||||||
|
delete(id)?;
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,30 +1,33 @@
|
|||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
|
||||||
use assistant_tool::{Tool, ToolSource, ToolWorkingSet, ToolWorkingSetEvent};
|
use assistant_tool::{Tool, ToolSource};
|
||||||
use collections::HashMap;
|
use collections::HashMap;
|
||||||
use gpui::{App, Context, Entity, IntoElement, Render, Subscription, Window};
|
use gpui::{App, Context, Entity, IntoElement, Render, Subscription, Window};
|
||||||
use language_model::{LanguageModel, LanguageModelToolSchemaFormat};
|
use language_model::{LanguageModel, LanguageModelToolSchemaFormat};
|
||||||
use ui::prelude::*;
|
use ui::prelude::*;
|
||||||
|
|
||||||
|
use crate::{Thread, ThreadEvent};
|
||||||
|
|
||||||
pub struct IncompatibleToolsState {
|
pub struct IncompatibleToolsState {
|
||||||
cache: HashMap<LanguageModelToolSchemaFormat, Vec<Arc<dyn Tool>>>,
|
cache: HashMap<LanguageModelToolSchemaFormat, Vec<Arc<dyn Tool>>>,
|
||||||
tool_working_set: Entity<ToolWorkingSet>,
|
thread: Entity<Thread>,
|
||||||
_tool_working_set_subscription: Subscription,
|
_thread_subscription: Subscription,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl IncompatibleToolsState {
|
impl IncompatibleToolsState {
|
||||||
pub fn new(tool_working_set: Entity<ToolWorkingSet>, cx: &mut Context<Self>) -> Self {
|
pub fn new(thread: Entity<Thread>, cx: &mut Context<Self>) -> Self {
|
||||||
let _tool_working_set_subscription =
|
let _tool_working_set_subscription =
|
||||||
cx.subscribe(&tool_working_set, |this, _, event, _| match event {
|
cx.subscribe(&thread, |this, _, event, _| match event {
|
||||||
ToolWorkingSetEvent::EnabledToolsChanged => {
|
ThreadEvent::ProfileChanged => {
|
||||||
this.cache.clear();
|
this.cache.clear();
|
||||||
}
|
}
|
||||||
|
_ => {}
|
||||||
});
|
});
|
||||||
|
|
||||||
Self {
|
Self {
|
||||||
cache: HashMap::default(),
|
cache: HashMap::default(),
|
||||||
tool_working_set,
|
thread,
|
||||||
_tool_working_set_subscription,
|
_thread_subscription: _tool_working_set_subscription,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -36,8 +39,9 @@ impl IncompatibleToolsState {
|
|||||||
self.cache
|
self.cache
|
||||||
.entry(model.tool_input_format())
|
.entry(model.tool_input_format())
|
||||||
.or_insert_with(|| {
|
.or_insert_with(|| {
|
||||||
self.tool_working_set
|
self.thread
|
||||||
.read(cx)
|
.read(cx)
|
||||||
|
.profile()
|
||||||
.enabled_tools(cx)
|
.enabled_tools(cx)
|
||||||
.iter()
|
.iter()
|
||||||
.filter(|tool| tool.input_schema(model.tool_input_format()).is_err())
|
.filter(|tool| tool.input_schema(model.tool_input_format()).is_err())
|
||||||
|
|||||||
@@ -337,6 +337,12 @@ 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 {
|
||||||
@@ -345,6 +351,7 @@ 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,
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
@@ -518,6 +525,7 @@ 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)]
|
||||||
|
|||||||
@@ -1,3 +0,0 @@
|
|||||||
# 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,20 +93,9 @@ 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, .. }
|
Self::Suggested { kind, .. } => Icon::new(kind.icon()),
|
||||||
| Self::Added {
|
Self::Added { context, .. } => context.icon(),
|
||||||
context: AddedContext { kind, .. },
|
|
||||||
..
|
|
||||||
} => Icon::new(kind.icon()),
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -133,6 +122,7 @@ 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.) })
|
||||||
@@ -140,6 +130,9 @@ 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)
|
||||||
@@ -195,7 +188,8 @@ impl RenderOnce for ContextPill {
|
|||||||
|label, delta| label.opacity(delta),
|
|label, delta| label.opacity(delta),
|
||||||
)
|
)
|
||||||
.into_any_element(),
|
.into_any_element(),
|
||||||
ContextStatus::Error { message } => element
|
ContextStatus::Warning { message }
|
||||||
|
| ContextStatus::Error { message } => element
|
||||||
.tooltip(ui::Tooltip::text(message.clone()))
|
.tooltip(ui::Tooltip::text(message.clone()))
|
||||||
.into_any_element(),
|
.into_any_element(),
|
||||||
}),
|
}),
|
||||||
@@ -270,6 +264,7 @@ pub enum ContextStatus {
|
|||||||
Ready,
|
Ready,
|
||||||
Loading { message: SharedString },
|
Loading { message: SharedString },
|
||||||
Error { message: SharedString },
|
Error { message: SharedString },
|
||||||
|
Warning { message: SharedString },
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(RegisterComponent)]
|
#[derive(RegisterComponent)]
|
||||||
@@ -285,6 +280,19 @@ 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.
|
||||||
///
|
///
|
||||||
@@ -293,6 +301,7 @@ 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 {
|
||||||
@@ -304,11 +313,15 @@ 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)),
|
AgentContextHandle::Image(handle) => Some(Self::image(handle, model, cx)),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn new_attached(context: &AgentContext, cx: &App) -> AddedContext {
|
pub fn new_attached(
|
||||||
|
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),
|
||||||
@@ -318,7 +331,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()),
|
AgentContext::Image(context) => Self::image(context.clone(), model, cx),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -333,14 +346,8 @@ 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 = full_path
|
let (name, parent) =
|
||||||
.file_name()
|
extract_file_name_and_directory_from_full_path(full_path, &full_path_string);
|
||||||
.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,
|
||||||
@@ -370,14 +377,8 @@ 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 = full_path
|
let (name, parent) =
|
||||||
.file_name()
|
extract_file_name_and_directory_from_full_path(full_path, &full_path_string);
|
||||||
.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,
|
||||||
@@ -605,22 +606,45 @@ impl AddedContext {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn image(context: ImageContext) -> AddedContext {
|
fn image(
|
||||||
|
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: "Image".into(),
|
name,
|
||||||
parent: None,
|
parent,
|
||||||
tooltip: None,
|
tooltip: None,
|
||||||
icon_path: None,
|
icon_path,
|
||||||
status: match context.status() {
|
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| {
|
||||||
@@ -639,6 +663,22 @@ 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,
|
||||||
@@ -765,37 +805,52 @@ 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(ImageContext {
|
AddedContext::image(
|
||||||
context_id: next_context_id.post_inc(),
|
ImageContext {
|
||||||
project_path: None,
|
context_id: next_context_id.post_inc(),
|
||||||
original_image: Arc::new(Image::empty()),
|
project_path: None,
|
||||||
image_task: Task::ready(Some(LanguageModelImage::empty())).shared(),
|
full_path: None,
|
||||||
}),
|
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(ImageContext {
|
AddedContext::image(
|
||||||
context_id: next_context_id.post_inc(),
|
ImageContext {
|
||||||
project_path: None,
|
context_id: next_context_id.post_inc(),
|
||||||
original_image: Arc::new(Image::empty()),
|
project_path: None,
|
||||||
image_task: cx
|
full_path: None,
|
||||||
.background_spawn(async move {
|
original_image: Arc::new(Image::empty()),
|
||||||
smol::Timer::after(Duration::from_secs(60 * 5)).await;
|
image_task: cx
|
||||||
Some(LanguageModelImage::empty())
|
.background_spawn(async move {
|
||||||
})
|
smol::Timer::after(Duration::from_secs(60 * 5)).await;
|
||||||
.shared(),
|
Some(LanguageModelImage::empty())
|
||||||
}),
|
})
|
||||||
|
.shared(),
|
||||||
|
},
|
||||||
|
None,
|
||||||
|
cx,
|
||||||
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
let image_error = (
|
let image_error = (
|
||||||
"Error",
|
"Error",
|
||||||
AddedContext::image(ImageContext {
|
AddedContext::image(
|
||||||
context_id: next_context_id.post_inc(),
|
ImageContext {
|
||||||
project_path: None,
|
context_id: next_context_id.post_inc(),
|
||||||
original_image: Arc::new(Image::empty()),
|
project_path: None,
|
||||||
image_task: Task::ready(None).shared(),
|
full_path: None,
|
||||||
}),
|
original_image: Arc::new(Image::empty()),
|
||||||
|
image_task: Task::ready(None).shared(),
|
||||||
|
},
|
||||||
|
None,
|
||||||
|
cx,
|
||||||
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
Some(
|
Some(
|
||||||
@@ -815,3 +870,60 @@ 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,5 +1,6 @@
|
|||||||
use gpui::{Context, IntoElement, Render, Window};
|
use crate::ToggleBurnMode;
|
||||||
use ui::{prelude::*, tooltip_container};
|
use gpui::{Context, FontWeight, IntoElement, Render, Window};
|
||||||
|
use ui::{KeyBinding, prelude::*, tooltip_container};
|
||||||
|
|
||||||
pub struct MaxModeTooltip {
|
pub struct MaxModeTooltip {
|
||||||
selected: bool,
|
selected: bool,
|
||||||
@@ -18,38 +19,48 @@ 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.gap_1()
|
this
|
||||||
.map(|header| if self.selected {
|
.child(
|
||||||
header.child(
|
h_flex()
|
||||||
h_flex()
|
.justify_between()
|
||||||
.justify_between()
|
.child(title)
|
||||||
.child(
|
.children(keybinding)
|
||||||
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_72()
|
.max_w_64()
|
||||||
.child(
|
.child(
|
||||||
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.")
|
Label::new("Enables models to use large context windows, unlimited tool calls, and other capabilities for expanded reasoning.")
|
||||||
.size(LabelSize::Small)
|
.size(LabelSize::Small)
|
||||||
.color(Color::Muted)
|
.color(Color::Muted)
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "assistant_settings"
|
name = "agent_settings"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
edition.workspace = true
|
edition.workspace = true
|
||||||
publish.workspace = true
|
publish.workspace = true
|
||||||
@@ -9,14 +9,13 @@ license = "GPL-3.0-or-later"
|
|||||||
workspace = true
|
workspace = true
|
||||||
|
|
||||||
[lib]
|
[lib]
|
||||||
path = "src/assistant_settings.rs"
|
path = "src/agent_settings.rs"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
anthropic = { workspace = true, features = ["schemars"] }
|
anthropic = { workspace = true, features = ["schemars"] }
|
||||||
anyhow.workspace = true
|
anyhow.workspace = true
|
||||||
collections.workspace = true
|
collections.workspace = true
|
||||||
gpui.workspace = true
|
gpui.workspace = true
|
||||||
indexmap.workspace = true
|
|
||||||
language_model.workspace = true
|
language_model.workspace = true
|
||||||
lmstudio = { workspace = true, features = ["schemars"] }
|
lmstudio = { workspace = true, features = ["schemars"] }
|
||||||
log.workspace = true
|
log.workspace = true
|
||||||
@@ -17,29 +17,6 @@ pub mod builtin_profiles {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Default)]
|
|
||||||
pub struct GroupedAgentProfiles {
|
|
||||||
pub builtin: IndexMap<AgentProfileId, AgentProfile>,
|
|
||||||
pub custom: IndexMap<AgentProfileId, AgentProfile>,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl GroupedAgentProfiles {
|
|
||||||
pub fn from_settings(settings: &crate::AssistantSettings) -> Self {
|
|
||||||
let mut builtin = IndexMap::default();
|
|
||||||
let mut custom = IndexMap::default();
|
|
||||||
|
|
||||||
for (profile_id, profile) in settings.profiles.clone() {
|
|
||||||
if builtin_profiles::is_builtin(&profile_id) {
|
|
||||||
builtin.insert(profile_id, profile);
|
|
||||||
} else {
|
|
||||||
custom.insert(profile_id, profile);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Self { builtin, custom }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Debug, PartialEq, Eq, Hash, Clone, Serialize, Deserialize, JsonSchema)]
|
#[derive(Debug, PartialEq, Eq, Hash, Clone, Serialize, Deserialize, JsonSchema)]
|
||||||
pub struct AgentProfileId(pub Arc<str>);
|
pub struct AgentProfileId(pub Arc<str>);
|
||||||
|
|
||||||
@@ -63,7 +40,7 @@ impl Default for AgentProfileId {
|
|||||||
|
|
||||||
/// A profile for the Zed Agent that controls its behavior.
|
/// A profile for the Zed Agent that controls its behavior.
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
pub struct AgentProfile {
|
pub struct AgentProfileSettings {
|
||||||
/// The name of the profile.
|
/// The name of the profile.
|
||||||
pub name: SharedString,
|
pub name: SharedString,
|
||||||
pub tools: IndexMap<Arc<str>, bool>,
|
pub tools: IndexMap<Arc<str>, bool>,
|
||||||
@@ -8,7 +8,7 @@ use anyhow::{Result, bail};
|
|||||||
use collections::IndexMap;
|
use collections::IndexMap;
|
||||||
use deepseek::Model as DeepseekModel;
|
use deepseek::Model as DeepseekModel;
|
||||||
use gpui::{App, Pixels, SharedString};
|
use gpui::{App, Pixels, SharedString};
|
||||||
use language_model::{CloudModel, LanguageModel};
|
use language_model::LanguageModel;
|
||||||
use lmstudio::Model as LmStudioModel;
|
use lmstudio::Model as LmStudioModel;
|
||||||
use mistral::Model as MistralModel;
|
use mistral::Model as MistralModel;
|
||||||
use ollama::Model as OllamaModel;
|
use ollama::Model as OllamaModel;
|
||||||
@@ -19,18 +19,26 @@ use settings::{Settings, SettingsSources};
|
|||||||
pub use crate::agent_profile::*;
|
pub use crate::agent_profile::*;
|
||||||
|
|
||||||
pub fn init(cx: &mut App) {
|
pub fn init(cx: &mut App) {
|
||||||
AssistantSettings::register(cx);
|
AgentSettings::register(cx);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Copy, Clone, Default, Debug, Serialize, Deserialize, JsonSchema)]
|
#[derive(Copy, Clone, Default, Debug, Serialize, Deserialize, JsonSchema)]
|
||||||
#[serde(rename_all = "snake_case")]
|
#[serde(rename_all = "snake_case")]
|
||||||
pub enum AssistantDockPosition {
|
pub enum AgentDockPosition {
|
||||||
Left,
|
Left,
|
||||||
#[default]
|
#[default]
|
||||||
Right,
|
Right,
|
||||||
Bottom,
|
Bottom,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Copy, Clone, Default, Debug, Serialize, Deserialize, JsonSchema)]
|
||||||
|
#[serde(rename_all = "snake_case")]
|
||||||
|
pub enum DefaultView {
|
||||||
|
#[default]
|
||||||
|
Thread,
|
||||||
|
TextThread,
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Copy, Clone, Default, Debug, Serialize, Deserialize, JsonSchema, PartialEq, Eq)]
|
#[derive(Copy, Clone, Default, Debug, Serialize, Deserialize, JsonSchema, PartialEq, Eq)]
|
||||||
#[serde(rename_all = "snake_case")]
|
#[serde(rename_all = "snake_case")]
|
||||||
pub enum NotifyWhenAgentWaiting {
|
pub enum NotifyWhenAgentWaiting {
|
||||||
@@ -43,9 +51,9 @@ pub enum NotifyWhenAgentWaiting {
|
|||||||
#[derive(Clone, Debug, Serialize, Deserialize, JsonSchema, PartialEq)]
|
#[derive(Clone, Debug, Serialize, Deserialize, JsonSchema, PartialEq)]
|
||||||
#[serde(tag = "name", rename_all = "snake_case")]
|
#[serde(tag = "name", rename_all = "snake_case")]
|
||||||
#[schemars(deny_unknown_fields)]
|
#[schemars(deny_unknown_fields)]
|
||||||
pub enum AssistantProviderContentV1 {
|
pub enum AgentProviderContentV1 {
|
||||||
#[serde(rename = "zed.dev")]
|
#[serde(rename = "zed.dev")]
|
||||||
ZedDotDev { default_model: Option<CloudModel> },
|
ZedDotDev { default_model: Option<String> },
|
||||||
#[serde(rename = "openai")]
|
#[serde(rename = "openai")]
|
||||||
OpenAi {
|
OpenAi {
|
||||||
default_model: Option<OpenAiModel>,
|
default_model: Option<OpenAiModel>,
|
||||||
@@ -80,10 +88,10 @@ pub enum AssistantProviderContentV1 {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Default, Clone, Debug)]
|
#[derive(Default, Clone, Debug)]
|
||||||
pub struct AssistantSettings {
|
pub struct AgentSettings {
|
||||||
pub enabled: bool,
|
pub enabled: bool,
|
||||||
pub button: bool,
|
pub button: bool,
|
||||||
pub dock: AssistantDockPosition,
|
pub dock: AgentDockPosition,
|
||||||
pub default_width: Pixels,
|
pub default_width: Pixels,
|
||||||
pub default_height: Pixels,
|
pub default_height: Pixels,
|
||||||
pub default_model: LanguageModelSelection,
|
pub default_model: LanguageModelSelection,
|
||||||
@@ -93,9 +101,11 @@ pub struct AssistantSettings {
|
|||||||
pub inline_alternatives: Vec<LanguageModelSelection>,
|
pub inline_alternatives: Vec<LanguageModelSelection>,
|
||||||
pub using_outdated_settings_version: bool,
|
pub using_outdated_settings_version: bool,
|
||||||
pub default_profile: AgentProfileId,
|
pub default_profile: AgentProfileId,
|
||||||
pub profiles: IndexMap<AgentProfileId, AgentProfile>,
|
pub default_view: DefaultView,
|
||||||
|
pub profiles: IndexMap<AgentProfileId, AgentProfileSettings>,
|
||||||
pub always_allow_tool_actions: bool,
|
pub always_allow_tool_actions: bool,
|
||||||
pub notify_when_agent_waiting: NotifyWhenAgentWaiting,
|
pub notify_when_agent_waiting: NotifyWhenAgentWaiting,
|
||||||
|
pub play_sound_when_agent_done: bool,
|
||||||
pub stream_edits: bool,
|
pub stream_edits: bool,
|
||||||
pub single_file_review: bool,
|
pub single_file_review: bool,
|
||||||
pub model_parameters: Vec<LanguageModelParameters>,
|
pub model_parameters: Vec<LanguageModelParameters>,
|
||||||
@@ -103,7 +113,7 @@ pub struct AssistantSettings {
|
|||||||
pub enable_feedback: bool,
|
pub enable_feedback: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl AssistantSettings {
|
impl AgentSettings {
|
||||||
pub fn temperature_for_model(model: &Arc<dyn LanguageModel>, cx: &App) -> Option<f32> {
|
pub fn temperature_for_model(model: &Arc<dyn LanguageModel>, cx: &App) -> Option<f32> {
|
||||||
let settings = Self::get_global(cx);
|
let settings = Self::get_global(cx);
|
||||||
settings
|
settings
|
||||||
@@ -158,58 +168,56 @@ impl LanguageModelParameters {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Assistant panel settings
|
/// Agent panel settings
|
||||||
#[derive(Clone, Serialize, Deserialize, Debug, Default)]
|
#[derive(Clone, Serialize, Deserialize, Debug, Default)]
|
||||||
pub struct AssistantSettingsContent {
|
pub struct AgentSettingsContent {
|
||||||
#[serde(flatten)]
|
#[serde(flatten)]
|
||||||
pub inner: Option<AssistantSettingsContentInner>,
|
pub inner: Option<AgentSettingsContentInner>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Serialize, Deserialize, Debug)]
|
#[derive(Clone, Serialize, Deserialize, Debug)]
|
||||||
#[serde(untagged)]
|
#[serde(untagged)]
|
||||||
pub enum AssistantSettingsContentInner {
|
pub enum AgentSettingsContentInner {
|
||||||
Versioned(Box<VersionedAssistantSettingsContent>),
|
Versioned(Box<VersionedAgentSettingsContent>),
|
||||||
Legacy(LegacyAssistantSettingsContent),
|
Legacy(LegacyAgentSettingsContent),
|
||||||
}
|
}
|
||||||
|
|
||||||
impl AssistantSettingsContentInner {
|
impl AgentSettingsContentInner {
|
||||||
fn for_v2(content: AssistantSettingsContentV2) -> Self {
|
fn for_v2(content: AgentSettingsContentV2) -> Self {
|
||||||
AssistantSettingsContentInner::Versioned(Box::new(VersionedAssistantSettingsContent::V2(
|
AgentSettingsContentInner::Versioned(Box::new(VersionedAgentSettingsContent::V2(content)))
|
||||||
content,
|
|
||||||
)))
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl JsonSchema for AssistantSettingsContent {
|
impl JsonSchema for AgentSettingsContent {
|
||||||
fn schema_name() -> String {
|
fn schema_name() -> String {
|
||||||
VersionedAssistantSettingsContent::schema_name()
|
VersionedAgentSettingsContent::schema_name()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn json_schema(r#gen: &mut schemars::r#gen::SchemaGenerator) -> Schema {
|
fn json_schema(r#gen: &mut schemars::r#gen::SchemaGenerator) -> Schema {
|
||||||
VersionedAssistantSettingsContent::json_schema(r#gen)
|
VersionedAgentSettingsContent::json_schema(r#gen)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn is_referenceable() -> bool {
|
fn is_referenceable() -> bool {
|
||||||
VersionedAssistantSettingsContent::is_referenceable()
|
VersionedAgentSettingsContent::is_referenceable()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl AssistantSettingsContent {
|
impl AgentSettingsContent {
|
||||||
pub fn is_version_outdated(&self) -> bool {
|
pub fn is_version_outdated(&self) -> bool {
|
||||||
match &self.inner {
|
match &self.inner {
|
||||||
Some(AssistantSettingsContentInner::Versioned(settings)) => match **settings {
|
Some(AgentSettingsContentInner::Versioned(settings)) => match **settings {
|
||||||
VersionedAssistantSettingsContent::V1(_) => true,
|
VersionedAgentSettingsContent::V1(_) => true,
|
||||||
VersionedAssistantSettingsContent::V2(_) => false,
|
VersionedAgentSettingsContent::V2(_) => false,
|
||||||
},
|
},
|
||||||
Some(AssistantSettingsContentInner::Legacy(_)) => true,
|
Some(AgentSettingsContentInner::Legacy(_)) => true,
|
||||||
None => false,
|
None => false,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn upgrade(&self) -> AssistantSettingsContentV2 {
|
fn upgrade(&self) -> AgentSettingsContentV2 {
|
||||||
match &self.inner {
|
match &self.inner {
|
||||||
Some(AssistantSettingsContentInner::Versioned(settings)) => match **settings {
|
Some(AgentSettingsContentInner::Versioned(settings)) => match **settings {
|
||||||
VersionedAssistantSettingsContent::V1(ref settings) => AssistantSettingsContentV2 {
|
VersionedAgentSettingsContent::V1(ref settings) => AgentSettingsContentV2 {
|
||||||
enabled: settings.enabled,
|
enabled: settings.enabled,
|
||||||
button: settings.button,
|
button: settings.button,
|
||||||
dock: settings.dock,
|
dock: settings.dock,
|
||||||
@@ -219,54 +227,49 @@ impl AssistantSettingsContent {
|
|||||||
.provider
|
.provider
|
||||||
.clone()
|
.clone()
|
||||||
.and_then(|provider| match provider {
|
.and_then(|provider| match provider {
|
||||||
AssistantProviderContentV1::ZedDotDev { default_model } => {
|
AgentProviderContentV1::ZedDotDev { default_model } => default_model
|
||||||
default_model.map(|model| LanguageModelSelection {
|
.map(|model| LanguageModelSelection {
|
||||||
provider: "zed.dev".into(),
|
provider: "zed.dev".into(),
|
||||||
model: model.id().to_string(),
|
model,
|
||||||
})
|
}),
|
||||||
}
|
AgentProviderContentV1::OpenAi { default_model, .. } => default_model
|
||||||
AssistantProviderContentV1::OpenAi { default_model, .. } => {
|
.map(|model| LanguageModelSelection {
|
||||||
default_model.map(|model| LanguageModelSelection {
|
|
||||||
provider: "openai".into(),
|
provider: "openai".into(),
|
||||||
model: model.id().to_string(),
|
model: model.id().to_string(),
|
||||||
})
|
}),
|
||||||
}
|
AgentProviderContentV1::Anthropic { default_model, .. } => {
|
||||||
AssistantProviderContentV1::Anthropic { default_model, .. } => {
|
|
||||||
default_model.map(|model| LanguageModelSelection {
|
default_model.map(|model| LanguageModelSelection {
|
||||||
provider: "anthropic".into(),
|
provider: "anthropic".into(),
|
||||||
model: model.id().to_string(),
|
model: model.id().to_string(),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
AssistantProviderContentV1::Ollama { default_model, .. } => {
|
AgentProviderContentV1::Ollama { default_model, .. } => default_model
|
||||||
default_model.map(|model| LanguageModelSelection {
|
.map(|model| LanguageModelSelection {
|
||||||
provider: "ollama".into(),
|
provider: "ollama".into(),
|
||||||
model: model.id().to_string(),
|
model: model.id().to_string(),
|
||||||
})
|
}),
|
||||||
}
|
AgentProviderContentV1::LmStudio { default_model, .. } => default_model
|
||||||
AssistantProviderContentV1::LmStudio { default_model, .. } => {
|
.map(|model| LanguageModelSelection {
|
||||||
default_model.map(|model| LanguageModelSelection {
|
|
||||||
provider: "lmstudio".into(),
|
provider: "lmstudio".into(),
|
||||||
model: model.id().to_string(),
|
model: model.id().to_string(),
|
||||||
})
|
}),
|
||||||
}
|
AgentProviderContentV1::DeepSeek { default_model, .. } => default_model
|
||||||
AssistantProviderContentV1::DeepSeek { default_model, .. } => {
|
.map(|model| LanguageModelSelection {
|
||||||
default_model.map(|model| LanguageModelSelection {
|
|
||||||
provider: "deepseek".into(),
|
provider: "deepseek".into(),
|
||||||
model: model.id().to_string(),
|
model: model.id().to_string(),
|
||||||
})
|
}),
|
||||||
}
|
AgentProviderContentV1::Mistral { default_model, .. } => default_model
|
||||||
AssistantProviderContentV1::Mistral { default_model, .. } => {
|
.map(|model| LanguageModelSelection {
|
||||||
default_model.map(|model| LanguageModelSelection {
|
|
||||||
provider: "mistral".into(),
|
provider: "mistral".into(),
|
||||||
model: model.id().to_string(),
|
model: model.id().to_string(),
|
||||||
})
|
}),
|
||||||
}
|
|
||||||
}),
|
}),
|
||||||
inline_assistant_model: None,
|
inline_assistant_model: None,
|
||||||
commit_message_model: None,
|
commit_message_model: None,
|
||||||
thread_summary_model: None,
|
thread_summary_model: None,
|
||||||
inline_alternatives: None,
|
inline_alternatives: None,
|
||||||
default_profile: None,
|
default_profile: None,
|
||||||
|
default_view: None,
|
||||||
profiles: None,
|
profiles: None,
|
||||||
always_allow_tool_actions: None,
|
always_allow_tool_actions: None,
|
||||||
notify_when_agent_waiting: None,
|
notify_when_agent_waiting: None,
|
||||||
@@ -275,10 +278,11 @@ impl AssistantSettingsContent {
|
|||||||
model_parameters: Vec::new(),
|
model_parameters: Vec::new(),
|
||||||
preferred_completion_mode: None,
|
preferred_completion_mode: None,
|
||||||
enable_feedback: None,
|
enable_feedback: None,
|
||||||
|
play_sound_when_agent_done: None,
|
||||||
},
|
},
|
||||||
VersionedAssistantSettingsContent::V2(ref settings) => settings.clone(),
|
VersionedAgentSettingsContent::V2(ref settings) => settings.clone(),
|
||||||
},
|
},
|
||||||
Some(AssistantSettingsContentInner::Legacy(settings)) => AssistantSettingsContentV2 {
|
Some(AgentSettingsContentInner::Legacy(settings)) => AgentSettingsContentV2 {
|
||||||
enabled: None,
|
enabled: None,
|
||||||
button: settings.button,
|
button: settings.button,
|
||||||
dock: settings.dock,
|
dock: settings.dock,
|
||||||
@@ -298,6 +302,7 @@ impl AssistantSettingsContent {
|
|||||||
thread_summary_model: None,
|
thread_summary_model: None,
|
||||||
inline_alternatives: None,
|
inline_alternatives: None,
|
||||||
default_profile: None,
|
default_profile: None,
|
||||||
|
default_view: None,
|
||||||
profiles: None,
|
profiles: None,
|
||||||
always_allow_tool_actions: None,
|
always_allow_tool_actions: None,
|
||||||
notify_when_agent_waiting: None,
|
notify_when_agent_waiting: None,
|
||||||
@@ -306,31 +311,30 @@ impl AssistantSettingsContent {
|
|||||||
model_parameters: Vec::new(),
|
model_parameters: Vec::new(),
|
||||||
preferred_completion_mode: None,
|
preferred_completion_mode: None,
|
||||||
enable_feedback: None,
|
enable_feedback: None,
|
||||||
|
play_sound_when_agent_done: None,
|
||||||
},
|
},
|
||||||
None => AssistantSettingsContentV2::default(),
|
None => AgentSettingsContentV2::default(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn set_dock(&mut self, dock: AssistantDockPosition) {
|
pub fn set_dock(&mut self, dock: AgentDockPosition) {
|
||||||
match &mut self.inner {
|
match &mut self.inner {
|
||||||
Some(AssistantSettingsContentInner::Versioned(settings)) => match **settings {
|
Some(AgentSettingsContentInner::Versioned(settings)) => match **settings {
|
||||||
VersionedAssistantSettingsContent::V1(ref mut settings) => {
|
VersionedAgentSettingsContent::V1(ref mut settings) => {
|
||||||
settings.dock = Some(dock);
|
settings.dock = Some(dock);
|
||||||
}
|
}
|
||||||
VersionedAssistantSettingsContent::V2(ref mut settings) => {
|
VersionedAgentSettingsContent::V2(ref mut settings) => {
|
||||||
settings.dock = Some(dock);
|
settings.dock = Some(dock);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
Some(AssistantSettingsContentInner::Legacy(settings)) => {
|
Some(AgentSettingsContentInner::Legacy(settings)) => {
|
||||||
settings.dock = Some(dock);
|
settings.dock = Some(dock);
|
||||||
}
|
}
|
||||||
None => {
|
None => {
|
||||||
self.inner = Some(AssistantSettingsContentInner::for_v2(
|
self.inner = Some(AgentSettingsContentInner::for_v2(AgentSettingsContentV2 {
|
||||||
AssistantSettingsContentV2 {
|
dock: Some(dock),
|
||||||
dock: Some(dock),
|
..Default::default()
|
||||||
..Default::default()
|
}))
|
||||||
},
|
|
||||||
))
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -340,105 +344,101 @@ impl AssistantSettingsContent {
|
|||||||
let provider = language_model.provider_id().0.to_string();
|
let provider = language_model.provider_id().0.to_string();
|
||||||
|
|
||||||
match &mut self.inner {
|
match &mut self.inner {
|
||||||
Some(AssistantSettingsContentInner::Versioned(settings)) => match **settings {
|
Some(AgentSettingsContentInner::Versioned(settings)) => match **settings {
|
||||||
VersionedAssistantSettingsContent::V1(ref mut settings) => {
|
VersionedAgentSettingsContent::V1(ref mut settings) => match provider.as_ref() {
|
||||||
match provider.as_ref() {
|
"zed.dev" => {
|
||||||
"zed.dev" => {
|
log::warn!("attempted to set zed.dev model on outdated settings");
|
||||||
log::warn!("attempted to set zed.dev model on outdated settings");
|
}
|
||||||
}
|
"anthropic" => {
|
||||||
"anthropic" => {
|
let api_url = match &settings.provider {
|
||||||
let api_url = match &settings.provider {
|
Some(AgentProviderContentV1::Anthropic { api_url, .. }) => {
|
||||||
Some(AssistantProviderContentV1::Anthropic { api_url, .. }) => {
|
api_url.clone()
|
||||||
api_url.clone()
|
}
|
||||||
}
|
_ => None,
|
||||||
_ => None,
|
};
|
||||||
};
|
settings.provider = Some(AgentProviderContentV1::Anthropic {
|
||||||
settings.provider = Some(AssistantProviderContentV1::Anthropic {
|
default_model: AnthropicModel::from_id(&model).ok(),
|
||||||
default_model: AnthropicModel::from_id(&model).ok(),
|
api_url,
|
||||||
api_url,
|
});
|
||||||
});
|
}
|
||||||
}
|
"ollama" => {
|
||||||
"ollama" => {
|
let api_url = match &settings.provider {
|
||||||
let api_url = match &settings.provider {
|
Some(AgentProviderContentV1::Ollama { api_url, .. }) => api_url.clone(),
|
||||||
Some(AssistantProviderContentV1::Ollama { api_url, .. }) => {
|
_ => None,
|
||||||
api_url.clone()
|
};
|
||||||
}
|
settings.provider = Some(AgentProviderContentV1::Ollama {
|
||||||
_ => None,
|
default_model: Some(ollama::Model::new(
|
||||||
};
|
&model,
|
||||||
settings.provider = Some(AssistantProviderContentV1::Ollama {
|
None,
|
||||||
default_model: Some(ollama::Model::new(
|
None,
|
||||||
&model,
|
Some(language_model.supports_tools()),
|
||||||
None,
|
Some(language_model.supports_images()),
|
||||||
None,
|
None,
|
||||||
Some(language_model.supports_tools()),
|
)),
|
||||||
)),
|
api_url,
|
||||||
api_url,
|
});
|
||||||
});
|
}
|
||||||
}
|
"lmstudio" => {
|
||||||
"lmstudio" => {
|
let api_url = match &settings.provider {
|
||||||
let api_url = match &settings.provider {
|
Some(AgentProviderContentV1::LmStudio { api_url, .. }) => {
|
||||||
Some(AssistantProviderContentV1::LmStudio { api_url, .. }) => {
|
api_url.clone()
|
||||||
api_url.clone()
|
}
|
||||||
}
|
_ => None,
|
||||||
_ => None,
|
};
|
||||||
};
|
settings.provider = Some(AgentProviderContentV1::LmStudio {
|
||||||
settings.provider = Some(AssistantProviderContentV1::LmStudio {
|
default_model: Some(lmstudio::Model::new(&model, None, None, false)),
|
||||||
default_model: Some(lmstudio::Model::new(&model, None, None)),
|
api_url,
|
||||||
api_url,
|
});
|
||||||
});
|
}
|
||||||
}
|
"openai" => {
|
||||||
"openai" => {
|
let (api_url, available_models) = match &settings.provider {
|
||||||
let (api_url, available_models) = match &settings.provider {
|
Some(AgentProviderContentV1::OpenAi {
|
||||||
Some(AssistantProviderContentV1::OpenAi {
|
|
||||||
api_url,
|
|
||||||
available_models,
|
|
||||||
..
|
|
||||||
}) => (api_url.clone(), available_models.clone()),
|
|
||||||
_ => (None, None),
|
|
||||||
};
|
|
||||||
settings.provider = Some(AssistantProviderContentV1::OpenAi {
|
|
||||||
default_model: OpenAiModel::from_id(&model).ok(),
|
|
||||||
api_url,
|
api_url,
|
||||||
available_models,
|
available_models,
|
||||||
});
|
..
|
||||||
}
|
}) => (api_url.clone(), available_models.clone()),
|
||||||
"deepseek" => {
|
_ => (None, None),
|
||||||
let api_url = match &settings.provider {
|
};
|
||||||
Some(AssistantProviderContentV1::DeepSeek { api_url, .. }) => {
|
settings.provider = Some(AgentProviderContentV1::OpenAi {
|
||||||
api_url.clone()
|
default_model: OpenAiModel::from_id(&model).ok(),
|
||||||
}
|
api_url,
|
||||||
_ => None,
|
available_models,
|
||||||
};
|
});
|
||||||
settings.provider = Some(AssistantProviderContentV1::DeepSeek {
|
|
||||||
default_model: DeepseekModel::from_id(&model).ok(),
|
|
||||||
api_url,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
_ => {}
|
|
||||||
}
|
}
|
||||||
}
|
"deepseek" => {
|
||||||
VersionedAssistantSettingsContent::V2(ref mut settings) => {
|
let api_url = match &settings.provider {
|
||||||
|
Some(AgentProviderContentV1::DeepSeek { api_url, .. }) => {
|
||||||
|
api_url.clone()
|
||||||
|
}
|
||||||
|
_ => None,
|
||||||
|
};
|
||||||
|
settings.provider = Some(AgentProviderContentV1::DeepSeek {
|
||||||
|
default_model: DeepseekModel::from_id(&model).ok(),
|
||||||
|
api_url,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
_ => {}
|
||||||
|
},
|
||||||
|
VersionedAgentSettingsContent::V2(ref mut settings) => {
|
||||||
settings.default_model = Some(LanguageModelSelection {
|
settings.default_model = Some(LanguageModelSelection {
|
||||||
provider: provider.into(),
|
provider: provider.into(),
|
||||||
model,
|
model,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
Some(AssistantSettingsContentInner::Legacy(settings)) => {
|
Some(AgentSettingsContentInner::Legacy(settings)) => {
|
||||||
if let Ok(model) = OpenAiModel::from_id(&language_model.id().0) {
|
if let Ok(model) = OpenAiModel::from_id(&language_model.id().0) {
|
||||||
settings.default_open_ai_model = Some(model);
|
settings.default_open_ai_model = Some(model);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
None => {
|
None => {
|
||||||
self.inner = Some(AssistantSettingsContentInner::for_v2(
|
self.inner = Some(AgentSettingsContentInner::for_v2(AgentSettingsContentV2 {
|
||||||
AssistantSettingsContentV2 {
|
default_model: Some(LanguageModelSelection {
|
||||||
default_model: Some(LanguageModelSelection {
|
provider: provider.into(),
|
||||||
provider: provider.into(),
|
model,
|
||||||
model,
|
}),
|
||||||
}),
|
..Default::default()
|
||||||
..Default::default()
|
}));
|
||||||
},
|
|
||||||
));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -467,15 +467,15 @@ impl AssistantSettingsContent {
|
|||||||
|
|
||||||
pub fn v2_setting(
|
pub fn v2_setting(
|
||||||
&mut self,
|
&mut self,
|
||||||
f: impl FnOnce(&mut AssistantSettingsContentV2) -> anyhow::Result<()>,
|
f: impl FnOnce(&mut AgentSettingsContentV2) -> anyhow::Result<()>,
|
||||||
) -> anyhow::Result<()> {
|
) -> anyhow::Result<()> {
|
||||||
match self.inner.get_or_insert_with(|| {
|
match self.inner.get_or_insert_with(|| {
|
||||||
AssistantSettingsContentInner::for_v2(AssistantSettingsContentV2 {
|
AgentSettingsContentInner::for_v2(AgentSettingsContentV2 {
|
||||||
..Default::default()
|
..Default::default()
|
||||||
})
|
})
|
||||||
}) {
|
}) {
|
||||||
AssistantSettingsContentInner::Versioned(boxed) => {
|
AgentSettingsContentInner::Versioned(boxed) => {
|
||||||
if let VersionedAssistantSettingsContent::V2(ref mut settings) = **boxed {
|
if let VersionedAgentSettingsContent::V2(ref mut settings) = **boxed {
|
||||||
f(settings)
|
f(settings)
|
||||||
} else {
|
} else {
|
||||||
Ok(())
|
Ok(())
|
||||||
@@ -504,6 +504,14 @@ impl AssistantSettingsContent {
|
|||||||
.ok();
|
.ok();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn set_play_sound_when_agent_done(&mut self, allow: bool) {
|
||||||
|
self.v2_setting(|setting| {
|
||||||
|
setting.play_sound_when_agent_done = Some(allow);
|
||||||
|
Ok(())
|
||||||
|
})
|
||||||
|
.ok();
|
||||||
|
}
|
||||||
|
|
||||||
pub fn set_single_file_review(&mut self, allow: bool) {
|
pub fn set_single_file_review(&mut self, allow: bool) {
|
||||||
self.v2_setting(|setting| {
|
self.v2_setting(|setting| {
|
||||||
setting.single_file_review = Some(allow);
|
setting.single_file_review = Some(allow);
|
||||||
@@ -523,7 +531,7 @@ impl AssistantSettingsContent {
|
|||||||
pub fn create_profile(
|
pub fn create_profile(
|
||||||
&mut self,
|
&mut self,
|
||||||
profile_id: AgentProfileId,
|
profile_id: AgentProfileId,
|
||||||
profile: AgentProfile,
|
profile_settings: AgentProfileSettings,
|
||||||
) -> Result<()> {
|
) -> Result<()> {
|
||||||
self.v2_setting(|settings| {
|
self.v2_setting(|settings| {
|
||||||
let profiles = settings.profiles.get_or_insert_default();
|
let profiles = settings.profiles.get_or_insert_default();
|
||||||
@@ -534,10 +542,10 @@ impl AssistantSettingsContent {
|
|||||||
profiles.insert(
|
profiles.insert(
|
||||||
profile_id,
|
profile_id,
|
||||||
AgentProfileContent {
|
AgentProfileContent {
|
||||||
name: profile.name.into(),
|
name: profile_settings.name.into(),
|
||||||
tools: profile.tools,
|
tools: profile_settings.tools,
|
||||||
enable_all_context_servers: Some(profile.enable_all_context_servers),
|
enable_all_context_servers: Some(profile_settings.enable_all_context_servers),
|
||||||
context_servers: profile
|
context_servers: profile_settings
|
||||||
.context_servers
|
.context_servers
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.map(|(server_id, preset)| {
|
.map(|(server_id, preset)| {
|
||||||
@@ -560,16 +568,16 @@ impl AssistantSettingsContent {
|
|||||||
#[derive(Clone, Serialize, Deserialize, JsonSchema, Debug)]
|
#[derive(Clone, Serialize, Deserialize, JsonSchema, Debug)]
|
||||||
#[serde(tag = "version")]
|
#[serde(tag = "version")]
|
||||||
#[schemars(deny_unknown_fields)]
|
#[schemars(deny_unknown_fields)]
|
||||||
pub enum VersionedAssistantSettingsContent {
|
pub enum VersionedAgentSettingsContent {
|
||||||
#[serde(rename = "1")]
|
#[serde(rename = "1")]
|
||||||
V1(AssistantSettingsContentV1),
|
V1(AgentSettingsContentV1),
|
||||||
#[serde(rename = "2")]
|
#[serde(rename = "2")]
|
||||||
V2(AssistantSettingsContentV2),
|
V2(AgentSettingsContentV2),
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Default for VersionedAssistantSettingsContent {
|
impl Default for VersionedAgentSettingsContent {
|
||||||
fn default() -> Self {
|
fn default() -> Self {
|
||||||
Self::V2(AssistantSettingsContentV2 {
|
Self::V2(AgentSettingsContentV2 {
|
||||||
enabled: None,
|
enabled: None,
|
||||||
button: None,
|
button: None,
|
||||||
dock: None,
|
dock: None,
|
||||||
@@ -581,6 +589,7 @@ impl Default for VersionedAssistantSettingsContent {
|
|||||||
thread_summary_model: None,
|
thread_summary_model: None,
|
||||||
inline_alternatives: None,
|
inline_alternatives: None,
|
||||||
default_profile: None,
|
default_profile: None,
|
||||||
|
default_view: None,
|
||||||
profiles: None,
|
profiles: None,
|
||||||
always_allow_tool_actions: None,
|
always_allow_tool_actions: None,
|
||||||
notify_when_agent_waiting: None,
|
notify_when_agent_waiting: None,
|
||||||
@@ -589,30 +598,31 @@ impl Default for VersionedAssistantSettingsContent {
|
|||||||
model_parameters: Vec::new(),
|
model_parameters: Vec::new(),
|
||||||
preferred_completion_mode: None,
|
preferred_completion_mode: None,
|
||||||
enable_feedback: None,
|
enable_feedback: None,
|
||||||
|
play_sound_when_agent_done: None,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Serialize, Deserialize, JsonSchema, Debug, Default)]
|
#[derive(Clone, Serialize, Deserialize, JsonSchema, Debug, Default)]
|
||||||
#[schemars(deny_unknown_fields)]
|
#[schemars(deny_unknown_fields)]
|
||||||
pub struct AssistantSettingsContentV2 {
|
pub struct AgentSettingsContentV2 {
|
||||||
/// Whether the Assistant is enabled.
|
/// Whether the Agent is enabled.
|
||||||
///
|
///
|
||||||
/// Default: true
|
/// Default: true
|
||||||
enabled: Option<bool>,
|
enabled: Option<bool>,
|
||||||
/// Whether to show the assistant panel button in the status bar.
|
/// Whether to show the agent panel button in the status bar.
|
||||||
///
|
///
|
||||||
/// Default: true
|
/// Default: true
|
||||||
button: Option<bool>,
|
button: Option<bool>,
|
||||||
/// Where to dock the assistant.
|
/// Where to dock the agent panel.
|
||||||
///
|
///
|
||||||
/// Default: right
|
/// Default: right
|
||||||
dock: Option<AssistantDockPosition>,
|
dock: Option<AgentDockPosition>,
|
||||||
/// Default width in pixels when the assistant is docked to the left or right.
|
/// Default width in pixels when the agent panel is docked to the left or right.
|
||||||
///
|
///
|
||||||
/// Default: 640
|
/// Default: 640
|
||||||
default_width: Option<f32>,
|
default_width: Option<f32>,
|
||||||
/// Default height in pixels when the assistant is docked to the bottom.
|
/// Default height in pixels when the agent panel is docked to the bottom.
|
||||||
///
|
///
|
||||||
/// Default: 320
|
/// Default: 320
|
||||||
default_height: Option<f32>,
|
default_height: Option<f32>,
|
||||||
@@ -630,6 +640,10 @@ pub struct AssistantSettingsContentV2 {
|
|||||||
///
|
///
|
||||||
/// Default: write
|
/// Default: write
|
||||||
default_profile: Option<AgentProfileId>,
|
default_profile: Option<AgentProfileId>,
|
||||||
|
/// Which view type to show by default in the agent panel.
|
||||||
|
///
|
||||||
|
/// Default: "thread"
|
||||||
|
default_view: Option<DefaultView>,
|
||||||
/// The available agent profiles.
|
/// The available agent profiles.
|
||||||
pub profiles: Option<IndexMap<AgentProfileId, AgentProfileContent>>,
|
pub profiles: Option<IndexMap<AgentProfileId, AgentProfileContent>>,
|
||||||
/// Whenever a tool action would normally wait for your confirmation
|
/// Whenever a tool action would normally wait for your confirmation
|
||||||
@@ -641,6 +655,10 @@ pub struct AssistantSettingsContentV2 {
|
|||||||
///
|
///
|
||||||
/// Default: "primary_screen"
|
/// Default: "primary_screen"
|
||||||
notify_when_agent_waiting: Option<NotifyWhenAgentWaiting>,
|
notify_when_agent_waiting: Option<NotifyWhenAgentWaiting>,
|
||||||
|
/// Whether to play a sound when the agent has either completed its response, or needs user input.
|
||||||
|
///
|
||||||
|
/// Default: false
|
||||||
|
play_sound_when_agent_done: Option<bool>,
|
||||||
/// Whether to stream edits from the agent as they are received.
|
/// Whether to stream edits from the agent as they are received.
|
||||||
///
|
///
|
||||||
/// Default: false
|
/// Default: false
|
||||||
@@ -658,7 +676,6 @@ pub struct AssistantSettingsContentV2 {
|
|||||||
/// Default: []
|
/// Default: []
|
||||||
#[serde(default)]
|
#[serde(default)]
|
||||||
model_parameters: Vec<LanguageModelParameters>,
|
model_parameters: Vec<LanguageModelParameters>,
|
||||||
|
|
||||||
/// What completion mode to enable for new threads
|
/// What completion mode to enable for new threads
|
||||||
///
|
///
|
||||||
/// Default: normal
|
/// Default: normal
|
||||||
@@ -674,14 +691,15 @@ pub struct AssistantSettingsContentV2 {
|
|||||||
pub enum CompletionMode {
|
pub enum CompletionMode {
|
||||||
#[default]
|
#[default]
|
||||||
Normal,
|
Normal,
|
||||||
Max,
|
#[serde(alias = "max")]
|
||||||
|
Burn,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<CompletionMode> for zed_llm_client::CompletionMode {
|
impl From<CompletionMode> for zed_llm_client::CompletionMode {
|
||||||
fn from(value: CompletionMode) -> Self {
|
fn from(value: CompletionMode) -> Self {
|
||||||
match value {
|
match value {
|
||||||
CompletionMode::Normal => zed_llm_client::CompletionMode::Normal,
|
CompletionMode::Normal => zed_llm_client::CompletionMode::Normal,
|
||||||
CompletionMode::Max => zed_llm_client::CompletionMode::Max,
|
CompletionMode::Burn => zed_llm_client::CompletionMode::Max,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -712,6 +730,7 @@ impl JsonSchema for LanguageModelProviderSetting {
|
|||||||
"zed.dev".into(),
|
"zed.dev".into(),
|
||||||
"copilot_chat".into(),
|
"copilot_chat".into(),
|
||||||
"deepseek".into(),
|
"deepseek".into(),
|
||||||
|
"openrouter".into(),
|
||||||
"mistral".into(),
|
"mistral".into(),
|
||||||
]),
|
]),
|
||||||
..Default::default()
|
..Default::default()
|
||||||
@@ -759,50 +778,50 @@ pub struct ContextServerPresetContent {
|
|||||||
|
|
||||||
#[derive(Clone, Serialize, Deserialize, JsonSchema, Debug)]
|
#[derive(Clone, Serialize, Deserialize, JsonSchema, Debug)]
|
||||||
#[schemars(deny_unknown_fields)]
|
#[schemars(deny_unknown_fields)]
|
||||||
pub struct AssistantSettingsContentV1 {
|
pub struct AgentSettingsContentV1 {
|
||||||
/// Whether the Assistant is enabled.
|
/// Whether the Agent is enabled.
|
||||||
///
|
///
|
||||||
/// Default: true
|
/// Default: true
|
||||||
enabled: Option<bool>,
|
enabled: Option<bool>,
|
||||||
/// Whether to show the assistant panel button in the status bar.
|
/// Whether to show the Agent panel button in the status bar.
|
||||||
///
|
///
|
||||||
/// Default: true
|
/// Default: true
|
||||||
button: Option<bool>,
|
button: Option<bool>,
|
||||||
/// Where to dock the assistant.
|
/// Where to dock the Agent.
|
||||||
///
|
///
|
||||||
/// Default: right
|
/// Default: right
|
||||||
dock: Option<AssistantDockPosition>,
|
dock: Option<AgentDockPosition>,
|
||||||
/// Default width in pixels when the assistant is docked to the left or right.
|
/// Default width in pixels when the Agent is docked to the left or right.
|
||||||
///
|
///
|
||||||
/// Default: 640
|
/// Default: 640
|
||||||
default_width: Option<f32>,
|
default_width: Option<f32>,
|
||||||
/// Default height in pixels when the assistant is docked to the bottom.
|
/// Default height in pixels when the Agent is docked to the bottom.
|
||||||
///
|
///
|
||||||
/// Default: 320
|
/// Default: 320
|
||||||
default_height: Option<f32>,
|
default_height: Option<f32>,
|
||||||
/// The provider of the assistant service.
|
/// The provider of the Agent service.
|
||||||
///
|
///
|
||||||
/// This can be "openai", "anthropic", "ollama", "lmstudio", "deepseek", "zed.dev"
|
/// This can be "openai", "anthropic", "ollama", "lmstudio", "deepseek", "zed.dev"
|
||||||
/// each with their respective default models and configurations.
|
/// each with their respective default models and configurations.
|
||||||
provider: Option<AssistantProviderContentV1>,
|
provider: Option<AgentProviderContentV1>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Serialize, Deserialize, JsonSchema, Debug)]
|
#[derive(Clone, Serialize, Deserialize, JsonSchema, Debug)]
|
||||||
#[schemars(deny_unknown_fields)]
|
#[schemars(deny_unknown_fields)]
|
||||||
pub struct LegacyAssistantSettingsContent {
|
pub struct LegacyAgentSettingsContent {
|
||||||
/// Whether to show the assistant panel button in the status bar.
|
/// Whether to show the Agent panel button in the status bar.
|
||||||
///
|
///
|
||||||
/// Default: true
|
/// Default: true
|
||||||
pub button: Option<bool>,
|
pub button: Option<bool>,
|
||||||
/// Where to dock the assistant.
|
/// Where to dock the Agent.
|
||||||
///
|
///
|
||||||
/// Default: right
|
/// Default: right
|
||||||
pub dock: Option<AssistantDockPosition>,
|
pub dock: Option<AgentDockPosition>,
|
||||||
/// Default width in pixels when the assistant is docked to the left or right.
|
/// Default width in pixels when the Agent is docked to the left or right.
|
||||||
///
|
///
|
||||||
/// Default: 640
|
/// Default: 640
|
||||||
pub default_width: Option<f32>,
|
pub default_width: Option<f32>,
|
||||||
/// Default height in pixels when the assistant is docked to the bottom.
|
/// Default height in pixels when the Agent is docked to the bottom.
|
||||||
///
|
///
|
||||||
/// Default: 320
|
/// Default: 320
|
||||||
pub default_height: Option<f32>,
|
pub default_height: Option<f32>,
|
||||||
@@ -816,20 +835,20 @@ pub struct LegacyAssistantSettingsContent {
|
|||||||
pub openai_api_url: Option<String>,
|
pub openai_api_url: Option<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Settings for AssistantSettings {
|
impl Settings for AgentSettings {
|
||||||
const KEY: Option<&'static str> = Some("agent");
|
const KEY: Option<&'static str> = Some("agent");
|
||||||
|
|
||||||
const FALLBACK_KEY: Option<&'static str> = Some("assistant");
|
const FALLBACK_KEY: Option<&'static str> = Some("assistant");
|
||||||
|
|
||||||
const PRESERVED_KEYS: Option<&'static [&'static str]> = Some(&["version"]);
|
const PRESERVED_KEYS: Option<&'static [&'static str]> = Some(&["version"]);
|
||||||
|
|
||||||
type FileContent = AssistantSettingsContent;
|
type FileContent = AgentSettingsContent;
|
||||||
|
|
||||||
fn load(
|
fn load(
|
||||||
sources: SettingsSources<Self::FileContent>,
|
sources: SettingsSources<Self::FileContent>,
|
||||||
_: &mut gpui::App,
|
_: &mut gpui::App,
|
||||||
) -> anyhow::Result<Self> {
|
) -> anyhow::Result<Self> {
|
||||||
let mut settings = AssistantSettings::default();
|
let mut settings = AgentSettings::default();
|
||||||
|
|
||||||
for value in sources.defaults_and_customizations() {
|
for value in sources.defaults_and_customizations() {
|
||||||
if value.is_version_outdated() {
|
if value.is_version_outdated() {
|
||||||
@@ -867,9 +886,14 @@ impl Settings for AssistantSettings {
|
|||||||
&mut settings.notify_when_agent_waiting,
|
&mut settings.notify_when_agent_waiting,
|
||||||
value.notify_when_agent_waiting,
|
value.notify_when_agent_waiting,
|
||||||
);
|
);
|
||||||
|
merge(
|
||||||
|
&mut settings.play_sound_when_agent_done,
|
||||||
|
value.play_sound_when_agent_done,
|
||||||
|
);
|
||||||
merge(&mut settings.stream_edits, value.stream_edits);
|
merge(&mut settings.stream_edits, value.stream_edits);
|
||||||
merge(&mut settings.single_file_review, value.single_file_review);
|
merge(&mut settings.single_file_review, value.single_file_review);
|
||||||
merge(&mut settings.default_profile, value.default_profile);
|
merge(&mut settings.default_profile, value.default_profile);
|
||||||
|
merge(&mut settings.default_view, value.default_view);
|
||||||
merge(
|
merge(
|
||||||
&mut settings.preferred_completion_mode,
|
&mut settings.preferred_completion_mode,
|
||||||
value.preferred_completion_mode,
|
value.preferred_completion_mode,
|
||||||
@@ -886,7 +910,7 @@ impl Settings for AssistantSettings {
|
|||||||
.extend(profiles.into_iter().map(|(id, profile)| {
|
.extend(profiles.into_iter().map(|(id, profile)| {
|
||||||
(
|
(
|
||||||
id,
|
id,
|
||||||
AgentProfile {
|
AgentProfileSettings {
|
||||||
name: profile.name.into(),
|
name: profile.name.into(),
|
||||||
tools: profile.tools,
|
tools: profile.tools,
|
||||||
enable_all_context_servers: profile
|
enable_all_context_servers: profile
|
||||||
@@ -919,28 +943,25 @@ impl Settings for AssistantSettings {
|
|||||||
.and_then(|b| b.as_bool())
|
.and_then(|b| b.as_bool())
|
||||||
{
|
{
|
||||||
match &mut current.inner {
|
match &mut current.inner {
|
||||||
Some(AssistantSettingsContentInner::Versioned(versioned)) => {
|
Some(AgentSettingsContentInner::Versioned(versioned)) => match versioned.as_mut() {
|
||||||
match versioned.as_mut() {
|
VersionedAgentSettingsContent::V1(setting) => {
|
||||||
VersionedAssistantSettingsContent::V1(setting) => {
|
setting.enabled = Some(b);
|
||||||
setting.enabled = Some(b);
|
setting.button = Some(b);
|
||||||
setting.button = Some(b);
|
|
||||||
}
|
|
||||||
|
|
||||||
VersionedAssistantSettingsContent::V2(setting) => {
|
|
||||||
setting.enabled = Some(b);
|
|
||||||
setting.button = Some(b);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
Some(AssistantSettingsContentInner::Legacy(setting)) => setting.button = Some(b),
|
VersionedAgentSettingsContent::V2(setting) => {
|
||||||
|
setting.enabled = Some(b);
|
||||||
|
setting.button = Some(b);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
Some(AgentSettingsContentInner::Legacy(setting)) => setting.button = Some(b),
|
||||||
None => {
|
None => {
|
||||||
current.inner = Some(AssistantSettingsContentInner::for_v2(
|
current.inner =
|
||||||
AssistantSettingsContentV2 {
|
Some(AgentSettingsContentInner::for_v2(AgentSettingsContentV2 {
|
||||||
enabled: Some(b),
|
enabled: Some(b),
|
||||||
button: Some(b),
|
button: Some(b),
|
||||||
..Default::default()
|
..Default::default()
|
||||||
},
|
}));
|
||||||
));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -962,7 +983,7 @@ mod tests {
|
|||||||
use super::*;
|
use super::*;
|
||||||
|
|
||||||
#[gpui::test]
|
#[gpui::test]
|
||||||
async fn test_deserialize_assistant_settings_with_version(cx: &mut TestAppContext) {
|
async fn test_deserialize_agent_settings_with_version(cx: &mut TestAppContext) {
|
||||||
let fs = fs::FakeFs::new(cx.executor().clone());
|
let fs = fs::FakeFs::new(cx.executor().clone());
|
||||||
fs.create_dir(paths::settings_file().parent().unwrap())
|
fs.create_dir(paths::settings_file().parent().unwrap())
|
||||||
.await
|
.await
|
||||||
@@ -971,51 +992,51 @@ mod tests {
|
|||||||
cx.update(|cx| {
|
cx.update(|cx| {
|
||||||
let test_settings = settings::SettingsStore::test(cx);
|
let test_settings = settings::SettingsStore::test(cx);
|
||||||
cx.set_global(test_settings);
|
cx.set_global(test_settings);
|
||||||
AssistantSettings::register(cx);
|
AgentSettings::register(cx);
|
||||||
});
|
});
|
||||||
|
|
||||||
cx.update(|cx| {
|
cx.update(|cx| {
|
||||||
assert!(!AssistantSettings::get_global(cx).using_outdated_settings_version);
|
assert!(!AgentSettings::get_global(cx).using_outdated_settings_version);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
AssistantSettings::get_global(cx).default_model,
|
AgentSettings::get_global(cx).default_model,
|
||||||
LanguageModelSelection {
|
LanguageModelSelection {
|
||||||
provider: "zed.dev".into(),
|
provider: "zed.dev".into(),
|
||||||
model: "claude-3-7-sonnet-latest".into(),
|
model: "claude-sonnet-4".into(),
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
cx.update(|cx| {
|
cx.update(|cx| {
|
||||||
settings::SettingsStore::global(cx).update_settings_file::<AssistantSettings>(
|
settings::SettingsStore::global(cx).update_settings_file::<AgentSettings>(
|
||||||
fs.clone(),
|
fs.clone(),
|
||||||
|settings, _| {
|
|settings, _| {
|
||||||
*settings = AssistantSettingsContent {
|
*settings = AgentSettingsContent {
|
||||||
inner: Some(AssistantSettingsContentInner::for_v2(
|
inner: Some(AgentSettingsContentInner::for_v2(AgentSettingsContentV2 {
|
||||||
AssistantSettingsContentV2 {
|
default_model: Some(LanguageModelSelection {
|
||||||
default_model: Some(LanguageModelSelection {
|
provider: "test-provider".into(),
|
||||||
provider: "test-provider".into(),
|
model: "gpt-99".into(),
|
||||||
model: "gpt-99".into(),
|
}),
|
||||||
}),
|
inline_assistant_model: None,
|
||||||
inline_assistant_model: None,
|
commit_message_model: None,
|
||||||
commit_message_model: None,
|
thread_summary_model: None,
|
||||||
thread_summary_model: None,
|
inline_alternatives: None,
|
||||||
inline_alternatives: None,
|
enabled: None,
|
||||||
enabled: None,
|
button: None,
|
||||||
button: None,
|
dock: None,
|
||||||
dock: None,
|
default_width: None,
|
||||||
default_width: None,
|
default_height: None,
|
||||||
default_height: None,
|
default_profile: None,
|
||||||
default_profile: None,
|
default_view: None,
|
||||||
profiles: None,
|
profiles: None,
|
||||||
always_allow_tool_actions: None,
|
always_allow_tool_actions: None,
|
||||||
notify_when_agent_waiting: None,
|
play_sound_when_agent_done: None,
|
||||||
stream_edits: None,
|
notify_when_agent_waiting: None,
|
||||||
single_file_review: None,
|
stream_edits: None,
|
||||||
enable_feedback: None,
|
single_file_review: None,
|
||||||
model_parameters: Vec::new(),
|
enable_feedback: None,
|
||||||
preferred_completion_mode: None,
|
model_parameters: Vec::new(),
|
||||||
},
|
preferred_completion_mode: None,
|
||||||
)),
|
})),
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
@@ -1027,14 +1048,14 @@ mod tests {
|
|||||||
assert!(raw_settings_value.contains(r#""version": "2""#));
|
assert!(raw_settings_value.contains(r#""version": "2""#));
|
||||||
|
|
||||||
#[derive(Debug, Deserialize)]
|
#[derive(Debug, Deserialize)]
|
||||||
struct AssistantSettingsTest {
|
struct AgentSettingsTest {
|
||||||
agent: AssistantSettingsContent,
|
agent: AgentSettingsContent,
|
||||||
}
|
}
|
||||||
|
|
||||||
let assistant_settings: AssistantSettingsTest =
|
let agent_settings: AgentSettingsTest =
|
||||||
serde_json_lenient::from_str(&raw_settings_value).unwrap();
|
serde_json_lenient::from_str(&raw_settings_value).unwrap();
|
||||||
|
|
||||||
assert!(!assistant_settings.agent.is_version_outdated());
|
assert!(!agent_settings.agent.is_version_outdated());
|
||||||
}
|
}
|
||||||
|
|
||||||
#[gpui::test]
|
#[gpui::test]
|
||||||
@@ -1059,29 +1080,27 @@ mod tests {
|
|||||||
.set_user_settings(user_settings_content, cx)
|
.set_user_settings(user_settings_content, cx)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
cx.set_global(test_settings);
|
cx.set_global(test_settings);
|
||||||
AssistantSettings::register(cx);
|
AgentSettings::register(cx);
|
||||||
});
|
});
|
||||||
|
|
||||||
cx.run_until_parked();
|
cx.run_until_parked();
|
||||||
|
|
||||||
let assistant_settings = cx.update(|cx| AssistantSettings::get_global(cx).clone());
|
let agent_settings = cx.update(|cx| AgentSettings::get_global(cx).clone());
|
||||||
assert!(assistant_settings.enabled);
|
assert!(agent_settings.enabled);
|
||||||
assert!(!assistant_settings.using_outdated_settings_version);
|
assert!(!agent_settings.using_outdated_settings_version);
|
||||||
assert_eq!(assistant_settings.default_model.model, "gpt-99");
|
assert_eq!(agent_settings.default_model.model, "gpt-99");
|
||||||
|
|
||||||
cx.update_global::<SettingsStore, _>(|settings_store, cx| {
|
cx.update_global::<SettingsStore, _>(|settings_store, cx| {
|
||||||
settings_store.update_user_settings::<AssistantSettings>(cx, |settings| {
|
settings_store.update_user_settings::<AgentSettings>(cx, |settings| {
|
||||||
*settings = AssistantSettingsContent {
|
*settings = AgentSettingsContent {
|
||||||
inner: Some(AssistantSettingsContentInner::for_v2(
|
inner: Some(AgentSettingsContentInner::for_v2(AgentSettingsContentV2 {
|
||||||
AssistantSettingsContentV2 {
|
enabled: Some(false),
|
||||||
enabled: Some(false),
|
default_model: Some(LanguageModelSelection {
|
||||||
default_model: Some(LanguageModelSelection {
|
provider: "xai".to_owned().into(),
|
||||||
provider: "xai".to_owned().into(),
|
model: "grok".to_owned(),
|
||||||
model: "grok".to_owned(),
|
}),
|
||||||
}),
|
..Default::default()
|
||||||
..Default::default()
|
})),
|
||||||
},
|
|
||||||
)),
|
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@@ -1091,12 +1110,12 @@ mod tests {
|
|||||||
let settings = cx.update(|cx| SettingsStore::global(cx).raw_user_settings().clone());
|
let settings = cx.update(|cx| SettingsStore::global(cx).raw_user_settings().clone());
|
||||||
|
|
||||||
#[derive(Debug, Deserialize)]
|
#[derive(Debug, Deserialize)]
|
||||||
struct AssistantSettingsTest {
|
struct AgentSettingsTest {
|
||||||
assistant: AssistantSettingsContent,
|
assistant: AgentSettingsContent,
|
||||||
agent: Option<serde_json_lenient::Value>,
|
agent: Option<serde_json_lenient::Value>,
|
||||||
}
|
}
|
||||||
|
|
||||||
let assistant_settings: AssistantSettingsTest = serde_json::from_value(settings).unwrap();
|
let agent_settings: AgentSettingsTest = serde_json::from_value(settings).unwrap();
|
||||||
assert!(assistant_settings.agent.is_none());
|
assert!(agent_settings.agent.is_none());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -34,7 +34,6 @@ 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(
|
||||||
@@ -42,6 +41,21 @@ 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")]
|
||||||
@@ -89,6 +103,14 @@ 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}");
|
anyhow::bail!("invalid model id {id}");
|
||||||
}
|
}
|
||||||
@@ -96,6 +118,10 @@ impl Model {
|
|||||||
|
|
||||||
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",
|
||||||
@@ -110,6 +136,8 @@ 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",
|
||||||
@@ -122,6 +150,10 @@ 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",
|
||||||
@@ -137,7 +169,11 @@ impl Model {
|
|||||||
|
|
||||||
pub fn cache_configuration(&self) -> Option<AnthropicModelCacheConfiguration> {
|
pub fn cache_configuration(&self) -> Option<AnthropicModelCacheConfiguration> {
|
||||||
match self {
|
match self {
|
||||||
Self::Claude3_5Sonnet
|
Self::ClaudeOpus4
|
||||||
|
| 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
|
||||||
@@ -156,7 +192,11 @@ impl Model {
|
|||||||
|
|
||||||
pub fn max_token_count(&self) -> usize {
|
pub fn max_token_count(&self) -> usize {
|
||||||
match self {
|
match self {
|
||||||
Self::Claude3_5Sonnet
|
Self::ClaudeOpus4
|
||||||
|
| 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
|
||||||
@@ -173,7 +213,11 @@ impl Model {
|
|||||||
Self::Claude3_5Sonnet
|
Self::Claude3_5Sonnet
|
||||||
| Self::Claude3_7Sonnet
|
| Self::Claude3_7Sonnet
|
||||||
| Self::Claude3_7SonnetThinking
|
| Self::Claude3_7SonnetThinking
|
||||||
| Self::Claude3_5Haiku => 8_192,
|
| Self::Claude3_5Haiku
|
||||||
|
| 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),
|
||||||
@@ -182,7 +226,11 @@ impl Model {
|
|||||||
|
|
||||||
pub fn default_temperature(&self) -> f32 {
|
pub fn default_temperature(&self) -> f32 {
|
||||||
match self {
|
match self {
|
||||||
Self::Claude3_5Sonnet
|
Self::ClaudeOpus4
|
||||||
|
| 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
|
||||||
@@ -201,10 +249,14 @@ 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 => AnthropicModelMode::Thinking {
|
Self::Claude3_7SonnetThinking
|
||||||
|
| 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(),
|
||||||
|
|||||||
@@ -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,6 +22,7 @@ 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
|
||||||
@@ -29,15 +30,16 @@ 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
|
||||||
@@ -55,8 +57,10 @@ 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,6 +2,8 @@ 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;
|
||||||
|
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod context_tests;
|
mod context_tests;
|
||||||
|
|
||||||
|
use agent_settings::AgentSettings;
|
||||||
use anyhow::{Context as _, Result, bail};
|
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,
|
||||||
@@ -29,6 +29,7 @@ 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},
|
||||||
@@ -44,6 +45,7 @@ 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);
|
||||||
@@ -682,6 +684,7 @@ 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 {
|
||||||
@@ -718,6 +721,14 @@ 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,
|
||||||
@@ -764,6 +775,7 @@ 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,
|
||||||
@@ -1730,9 +1742,8 @@ 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 offset = this.buffer.read_with(cx, |buffer, _cx| {
|
let buffer = this.buffer.read(cx);
|
||||||
insert_position.to_offset(buffer)
|
let offset = insert_position.to_offset(buffer);
|
||||||
});
|
|
||||||
this.insert_message_at_offset(
|
this.insert_message_at_offset(
|
||||||
offset,
|
offset,
|
||||||
role,
|
role,
|
||||||
@@ -2204,6 +2215,7 @@ impl AssistantContext {
|
|||||||
StopReason::ToolUse => {}
|
StopReason::ToolUse => {}
|
||||||
StopReason::EndTurn => {}
|
StopReason::EndTurn => {}
|
||||||
StopReason::MaxTokens => {}
|
StopReason::MaxTokens => {}
|
||||||
|
StopReason::Refusal => {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
@@ -2261,13 +2273,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
|
temperature: model.and_then(|model| AgentSettings::temperature_for_model(model, cx)),
|
||||||
.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 {
|
||||||
@@ -2322,7 +2334,15 @@ 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
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1210,8 +1210,8 @@ async fn test_summarization(cx: &mut TestAppContext) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
cx.run_until_parked();
|
cx.run_until_parked();
|
||||||
fake_model.stream_last_completion_response("Brief".into());
|
fake_model.stream_last_completion_response("Brief");
|
||||||
fake_model.stream_last_completion_response(" Introduction".into());
|
fake_model.stream_last_completion_response(" Introduction");
|
||||||
fake_model.end_last_completion_stream();
|
fake_model.end_last_completion_stream();
|
||||||
cx.run_until_parked();
|
cx.run_until_parked();
|
||||||
|
|
||||||
@@ -1274,7 +1274,7 @@ async fn test_thread_summary_error_retry(cx: &mut TestAppContext) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
cx.run_until_parked();
|
cx.run_until_parked();
|
||||||
fake_model.stream_last_completion_response("A successful summary".into());
|
fake_model.stream_last_completion_response("A successful summary");
|
||||||
fake_model.end_last_completion_stream();
|
fake_model.end_last_completion_stream();
|
||||||
cx.run_until_parked();
|
cx.run_until_parked();
|
||||||
|
|
||||||
@@ -1356,7 +1356,7 @@ fn setup_context_editor_with_fake_model(
|
|||||||
|
|
||||||
fn simulate_successful_response(fake_model: &FakeLanguageModel, cx: &mut TestAppContext) {
|
fn simulate_successful_response(fake_model: &FakeLanguageModel, cx: &mut TestAppContext) {
|
||||||
cx.run_until_parked();
|
cx.run_until_parked();
|
||||||
fake_model.stream_last_completion_response("Assistant response".into());
|
fake_model.stream_last_completion_response("Assistant response");
|
||||||
fake_model.end_last_completion_stream();
|
fake_model.end_last_completion_stream();
|
||||||
cx.run_until_parked();
|
cx.run_until_parked();
|
||||||
}
|
}
|
||||||
@@ -1386,7 +1386,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);
|
||||||
assistant_settings::init(cx);
|
agent_settings::init(cx);
|
||||||
Project::init_settings(cx);
|
Project::init_settings(cx);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,11 @@
|
|||||||
|
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,
|
||||||
@@ -36,11 +42,8 @@ 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;
|
use picker::{Picker, popover_menu::PickerPopoverMenu};
|
||||||
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;
|
||||||
@@ -51,6 +54,7 @@ use std::{
|
|||||||
cmp,
|
cmp,
|
||||||
ops::Range,
|
ops::Range,
|
||||||
path::{Path, PathBuf},
|
path::{Path, PathBuf},
|
||||||
|
rc::Rc,
|
||||||
sync::Arc,
|
sync::Arc,
|
||||||
time::Duration,
|
time::Duration,
|
||||||
};
|
};
|
||||||
@@ -234,7 +238,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(Box::new(completion_provider)));
|
editor.set_completion_provider(Some(Rc::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()));
|
||||||
|
|
||||||
@@ -279,10 +283,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| {
|
||||||
LanguageModelSelector::new(
|
language_model_selector(
|
||||||
|cx| LanguageModelRegistry::read_global(cx).default_model(),
|
|cx| LanguageModelRegistry::read_global(cx).default_model(),
|
||||||
move |model, cx| {
|
move |model, cx| {
|
||||||
update_settings_file::<AssistantSettings>(
|
update_settings_file::<AgentSettings>(
|
||||||
fs.clone(),
|
fs.clone(),
|
||||||
cx,
|
cx,
|
||||||
move |settings, _| settings.set_model(model.clone()),
|
move |settings, _| settings.set_model(model.clone()),
|
||||||
@@ -1642,34 +1646,35 @@ 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 message.offset_range.start >= selection.range().end {
|
// If selection is empty, we want to copy the entire line
|
||||||
break;
|
if selection.range().is_empty() {
|
||||||
} else if message.offset_range.end >= selection.range().start {
|
let snapshot = context.buffer().read(cx).snapshot();
|
||||||
let range = cmp::max(message.offset_range.start, selection.range().start)
|
let point = snapshot.offset_to_point(selection.range().start);
|
||||||
..cmp::min(message.offset_range.end, selection.range().end);
|
selection.start = snapshot.point_to_offset(Point::new(point.row, 0));
|
||||||
if range.is_empty() {
|
selection.end = snapshot
|
||||||
let snapshot = context.buffer().read(cx).snapshot();
|
.point_to_offset(cmp::min(Point::new(point.row + 1, 0), snapshot.max_point()));
|
||||||
let point = snapshot.offset_to_point(range.start);
|
for chunk in context.buffer().read(cx).text_for_range(selection.range()) {
|
||||||
selection.start = snapshot.point_to_offset(Point::new(point.row, 0));
|
text.push_str(chunk);
|
||||||
selection.end = snapshot.point_to_offset(cmp::min(
|
}
|
||||||
Point::new(point.row + 1, 0),
|
} else {
|
||||||
snapshot.max_point(),
|
for message in context.messages(cx) {
|
||||||
));
|
if message.offset_range.start >= selection.range().end {
|
||||||
for chunk in context.buffer().read(cx).text_for_range(selection.range()) {
|
break;
|
||||||
text.push_str(chunk);
|
} else if message.offset_range.end >= selection.range().start {
|
||||||
}
|
let range = cmp::max(message.offset_range.start, selection.range().start)
|
||||||
} else {
|
..cmp::min(message.offset_range.end, selection.range().end);
|
||||||
for chunk in context.buffer().read(cx).text_for_range(range) {
|
if !range.is_empty() {
|
||||||
text.push_str(chunk);
|
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');
|
if message.offset_range.end < selection.range().end {
|
||||||
|
text.push('\n');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
(text, CopyMetadata { creases }, vec![selection])
|
(text, CopyMetadata { creases }, vec![selection])
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1902,7 +1907,7 @@ 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
|
||||||
.update(cx, |workspace, _| workspace.client().clone())
|
.read_with(cx, |workspace, _| workspace.client().clone())
|
||||||
.log_err();
|
.log_err();
|
||||||
|
|
||||||
if let Some(client) = client {
|
if let Some(client) = client {
|
||||||
@@ -2007,17 +2012,17 @@ impl ContextEditor {
|
|||||||
None => (ButtonStyle::Filled, None),
|
None => (ButtonStyle::Filled, None),
|
||||||
};
|
};
|
||||||
|
|
||||||
ButtonLike::new("send_button")
|
Button::new("send_button", "Send")
|
||||||
|
.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)
|
||||||
.child(Label::new("Send"))
|
.key_binding(
|
||||||
.children(
|
|
||||||
KeyBinding::for_action_in(&Assist, &focus_handle, window, cx)
|
KeyBinding::for_action_in(&Assist, &focus_handle, window, cx)
|
||||||
.map(|binding| binding.into_any_element()),
|
.map(|kb| kb.size(rems_from_px(12.))),
|
||||||
)
|
)
|
||||||
.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);
|
||||||
@@ -2057,7 +2062,50 @@ impl ContextEditor {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn render_language_model_selector(&self, cx: &mut Context<Self>) -> impl IntoElement {
|
fn render_max_mode_toggle(&self, cx: &mut Context<Self>) -> Option<AnyElement> {
|
||||||
|
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);
|
||||||
@@ -2067,7 +2115,7 @@ impl ContextEditor {
|
|||||||
None => SharedString::from("No model selected"),
|
None => SharedString::from("No model selected"),
|
||||||
};
|
};
|
||||||
|
|
||||||
LanguageModelSelectorPopoverMenu::new(
|
PickerPopoverMenu::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)
|
||||||
@@ -2095,8 +2143,10 @@ 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> {
|
||||||
@@ -2502,6 +2552,7 @@ 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)
|
||||||
@@ -2511,6 +2562,8 @@ 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))
|
||||||
@@ -2550,31 +2603,28 @@ impl Render for ContextEditor {
|
|||||||
})
|
})
|
||||||
.children(self.render_last_error(cx))
|
.children(self.render_last_error(cx))
|
||||||
.child(
|
.child(
|
||||||
h_flex().w_full().relative().child(
|
h_flex()
|
||||||
h_flex()
|
.relative()
|
||||||
.p_2()
|
.py_2()
|
||||||
.w_full()
|
.pl_1p5()
|
||||||
.border_t_1()
|
.pr_2()
|
||||||
.border_color(cx.theme().colors().border_variant)
|
.w_full()
|
||||||
.bg(cx.theme().colors().editor_background)
|
.justify_between()
|
||||||
.child(
|
.border_t_1()
|
||||||
h_flex()
|
.border_color(cx.theme().colors().border_variant)
|
||||||
.gap_1()
|
.bg(cx.theme().colors().editor_background)
|
||||||
.child(self.render_inject_context_menu(cx))
|
.child(
|
||||||
.child(ui::Divider::vertical())
|
h_flex()
|
||||||
.child(
|
.gap_0p5()
|
||||||
div()
|
.child(self.render_inject_context_menu(cx))
|
||||||
.pl_0p5()
|
.when_some(max_mode_toggle, |this, element| this.child(element)),
|
||||||
.child(self.render_language_model_selector(cx)),
|
)
|
||||||
),
|
.child(
|
||||||
)
|
h_flex()
|
||||||
.child(
|
.gap_1()
|
||||||
h_flex()
|
.child(self.render_language_model_selector(window, cx))
|
||||||
.w_full()
|
.child(self.render_send_button(window, cx)),
|
||||||
.justify_end()
|
),
|
||||||
.child(self.render_send_button(window, cx)),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -3215,74 +3265,92 @@ mod tests {
|
|||||||
use super::*;
|
use super::*;
|
||||||
use fs::FakeFs;
|
use fs::FakeFs;
|
||||||
use gpui::{App, TestAppContext, VisualTestContext};
|
use gpui::{App, TestAppContext, VisualTestContext};
|
||||||
|
use indoc::indoc;
|
||||||
use language::{Buffer, LanguageRegistry};
|
use language::{Buffer, LanguageRegistry};
|
||||||
|
use pretty_assertions::assert_eq;
|
||||||
use prompt_store::PromptBuilder;
|
use prompt_store::PromptBuilder;
|
||||||
|
use text::OffsetRangeExt;
|
||||||
use unindent::Unindent;
|
use unindent::Unindent;
|
||||||
use util::path;
|
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]
|
#[gpui::test]
|
||||||
async fn test_copy_paste_no_selection(cx: &mut TestAppContext) {
|
async fn test_copy_paste_no_selection(cx: &mut TestAppContext) {
|
||||||
cx.update(init_test);
|
let (context, context_editor, mut cx) = setup_context_editor_text(
|
||||||
|
vec![
|
||||||
|
(Role::User, "user1"),
|
||||||
|
(Role::Assistant, "assistant1"),
|
||||||
|
(Role::Assistant, "assistant2"),
|
||||||
|
(Role::User, ""),
|
||||||
|
],
|
||||||
|
cx,
|
||||||
|
)
|
||||||
|
.await;
|
||||||
|
|
||||||
let fs = FakeFs::new(cx.executor());
|
// Copy and paste first assistant message
|
||||||
let registry = Arc::new(LanguageRegistry::test(cx.executor()));
|
let message_2_range = message_range(&context, 1, &mut cx);
|
||||||
let prompt_builder = Arc::new(PromptBuilder::new(None).unwrap());
|
assert_copy_paste_context_editor(
|
||||||
let context = cx.new(|cx| {
|
&context_editor,
|
||||||
AssistantContext::local(
|
message_2_range.start..message_2_range.start,
|
||||||
registry,
|
indoc! {"
|
||||||
None,
|
user1
|
||||||
None,
|
assistant1
|
||||||
prompt_builder.clone(),
|
assistant2
|
||||||
Arc::new(SlashCommandWorkingSet::default()),
|
assistant1
|
||||||
cx,
|
"},
|
||||||
)
|
&mut 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 cx = &mut VisualTestContext::from_window(*window, cx);
|
|
||||||
|
|
||||||
let context_editor = window
|
// Copy and cut second assistant message
|
||||||
.update(cx, |_, window, cx| {
|
let message_3_range = message_range(&context, 2, &mut cx);
|
||||||
cx.new(|cx| {
|
assert_copy_paste_context_editor(
|
||||||
ContextEditor::for_context(
|
&context_editor,
|
||||||
context,
|
message_3_range.start..message_3_range.start,
|
||||||
fs,
|
indoc! {"
|
||||||
workspace.downgrade(),
|
user1
|
||||||
project,
|
assistant1
|
||||||
None,
|
assistant2
|
||||||
window,
|
assistant1
|
||||||
cx,
|
assistant2
|
||||||
)
|
"},
|
||||||
})
|
&mut cx,
|
||||||
})
|
);
|
||||||
.unwrap();
|
|
||||||
|
|
||||||
context_editor.update_in(cx, |context_editor, window, cx| {
|
|
||||||
context_editor.editor.update(cx, |editor, cx| {
|
|
||||||
editor.set_text("abc\ndef\nghi", window, cx);
|
|
||||||
editor.move_to_beginning(&Default::default(), window, cx);
|
|
||||||
})
|
|
||||||
});
|
|
||||||
|
|
||||||
context_editor.update_in(cx, |context_editor, window, cx| {
|
|
||||||
context_editor.editor.update(cx, |editor, cx| {
|
|
||||||
editor.copy(&Default::default(), window, cx);
|
|
||||||
editor.paste(&Default::default(), window, cx);
|
|
||||||
|
|
||||||
assert_eq!(editor.text(cx), "abc\nabc\ndef\nghi");
|
|
||||||
})
|
|
||||||
});
|
|
||||||
|
|
||||||
context_editor.update_in(cx, |context_editor, window, cx| {
|
|
||||||
context_editor.editor.update(cx, |editor, cx| {
|
|
||||||
editor.cut(&Default::default(), window, cx);
|
|
||||||
assert_eq!(editor.text(cx), "abc\ndef\nghi");
|
|
||||||
|
|
||||||
editor.paste(&Default::default(), window, cx);
|
|
||||||
assert_eq!(editor.text(cx), "abc\nabc\ndef\nghi");
|
|
||||||
})
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[gpui::test]
|
#[gpui::test]
|
||||||
@@ -3359,13 +3427,136 @@ mod tests {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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) {
|
fn init_test(cx: &mut App) {
|
||||||
let settings_store = SettingsStore::test(cx);
|
let settings_store = SettingsStore::test(cx);
|
||||||
prompt_store::init(cx);
|
prompt_store::init(cx);
|
||||||
LanguageModelRegistry::test(cx);
|
LanguageModelRegistry::test(cx);
|
||||||
cx.set_global(settings_store);
|
cx.set_global(settings_store);
|
||||||
language::init(cx);
|
language::init(cx);
|
||||||
assistant_settings::init(cx);
|
agent_settings::init(cx);
|
||||||
Project::init_settings(cx);
|
Project::init_settings(cx);
|
||||||
theme::init(theme::LoadThemes::JustBase, cx);
|
theme::init(theme::LoadThemes::JustBase, cx);
|
||||||
workspace::init_settings(cx);
|
workspace::init_settings(cx);
|
||||||
|
|||||||
@@ -809,74 +809,37 @@ impl ContextStore {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn register_context_server_handlers(&self, cx: &mut Context<Self>) {
|
fn register_context_server_handlers(&self, cx: &mut Context<Self>) {
|
||||||
cx.subscribe(
|
let context_server_store = self.project.read(cx).context_server_store();
|
||||||
&self.project.read(cx).context_server_store(),
|
cx.subscribe(&context_server_store, Self::handle_context_server_event)
|
||||||
Self::handle_context_server_event,
|
.detach();
|
||||||
)
|
|
||||||
.detach();
|
// Check for any servers that were already running before the handler was registered
|
||||||
|
for server in context_server_store.read(cx).running_servers() {
|
||||||
|
self.load_context_server_slash_commands(server.id(), context_server_store.clone(), cx);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn handle_context_server_event(
|
fn handle_context_server_event(
|
||||||
&mut self,
|
&mut self,
|
||||||
context_server_manager: Entity<ContextServerStore>,
|
context_server_store: Entity<ContextServerStore>,
|
||||||
event: &project::context_server_store::Event,
|
event: &project::context_server_store::Event,
|
||||||
cx: &mut Context<Self>,
|
cx: &mut Context<Self>,
|
||||||
) {
|
) {
|
||||||
let slash_command_working_set = self.slash_commands.clone();
|
|
||||||
match event {
|
match event {
|
||||||
project::context_server_store::Event::ServerStatusChanged { server_id, status } => {
|
project::context_server_store::Event::ServerStatusChanged { server_id, status } => {
|
||||||
match status {
|
match status {
|
||||||
ContextServerStatus::Running => {
|
ContextServerStatus::Running => {
|
||||||
if let Some(server) = context_server_manager
|
self.load_context_server_slash_commands(
|
||||||
.read(cx)
|
server_id.clone(),
|
||||||
.get_running_server(server_id)
|
context_server_store.clone(),
|
||||||
{
|
cx,
|
||||||
let context_server_manager = context_server_manager.clone();
|
);
|
||||||
cx.spawn({
|
|
||||||
let server = server.clone();
|
|
||||||
let server_id = server_id.clone();
|
|
||||||
async move |this, cx| {
|
|
||||||
let Some(protocol) = server.client() else {
|
|
||||||
return;
|
|
||||||
};
|
|
||||||
|
|
||||||
if protocol.capable(context_server::protocol::ServerCapability::Prompts) {
|
|
||||||
if let Some(prompts) = protocol.list_prompts().await.log_err() {
|
|
||||||
let slash_command_ids = prompts
|
|
||||||
.into_iter()
|
|
||||||
.filter(assistant_slash_commands::acceptable_prompt)
|
|
||||||
.map(|prompt| {
|
|
||||||
log::info!(
|
|
||||||
"registering context server command: {:?}",
|
|
||||||
prompt.name
|
|
||||||
);
|
|
||||||
slash_command_working_set.insert(Arc::new(
|
|
||||||
assistant_slash_commands::ContextServerSlashCommand::new(
|
|
||||||
context_server_manager.clone(),
|
|
||||||
server.id(),
|
|
||||||
prompt,
|
|
||||||
),
|
|
||||||
))
|
|
||||||
})
|
|
||||||
.collect::<Vec<_>>();
|
|
||||||
|
|
||||||
this.update( cx, |this, _cx| {
|
|
||||||
this.context_server_slash_command_ids
|
|
||||||
.insert(server_id.clone(), slash_command_ids);
|
|
||||||
})
|
|
||||||
.log_err();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
})
|
|
||||||
.detach();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
ContextServerStatus::Stopped | ContextServerStatus::Error(_) => {
|
ContextServerStatus::Stopped | ContextServerStatus::Error(_) => {
|
||||||
if let Some(slash_command_ids) =
|
if let Some(slash_command_ids) =
|
||||||
self.context_server_slash_command_ids.remove(server_id)
|
self.context_server_slash_command_ids.remove(server_id)
|
||||||
{
|
{
|
||||||
slash_command_working_set.remove(&slash_command_ids);
|
self.slash_commands.remove(&slash_command_ids);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_ => {}
|
_ => {}
|
||||||
@@ -884,4 +847,52 @@ impl ContextStore {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn load_context_server_slash_commands(
|
||||||
|
&self,
|
||||||
|
server_id: ContextServerId,
|
||||||
|
context_server_store: Entity<ContextServerStore>,
|
||||||
|
cx: &mut Context<Self>,
|
||||||
|
) {
|
||||||
|
let Some(server) = context_server_store.read(cx).get_running_server(&server_id) else {
|
||||||
|
return;
|
||||||
|
};
|
||||||
|
let slash_command_working_set = self.slash_commands.clone();
|
||||||
|
cx.spawn(async move |this, cx| {
|
||||||
|
let Some(protocol) = server.client() else {
|
||||||
|
return;
|
||||||
|
};
|
||||||
|
|
||||||
|
if protocol.capable(context_server::protocol::ServerCapability::Prompts) {
|
||||||
|
if let Some(response) = protocol
|
||||||
|
.request::<context_server::types::request::PromptsList>(())
|
||||||
|
.await
|
||||||
|
.log_err()
|
||||||
|
{
|
||||||
|
let slash_command_ids = response
|
||||||
|
.prompts
|
||||||
|
.into_iter()
|
||||||
|
.filter(assistant_slash_commands::acceptable_prompt)
|
||||||
|
.map(|prompt| {
|
||||||
|
log::info!("registering context server command: {:?}", prompt.name);
|
||||||
|
slash_command_working_set.insert(Arc::new(
|
||||||
|
assistant_slash_commands::ContextServerSlashCommand::new(
|
||||||
|
context_server_store.clone(),
|
||||||
|
server.id(),
|
||||||
|
prompt,
|
||||||
|
),
|
||||||
|
))
|
||||||
|
})
|
||||||
|
.collect::<Vec<_>>();
|
||||||
|
|
||||||
|
this.update(cx, |this, _cx| {
|
||||||
|
this.context_server_slash_command_ids
|
||||||
|
.insert(server_id.clone(), slash_command_ids);
|
||||||
|
})
|
||||||
|
.log_err();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.detach();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,8 +4,7 @@ use collections::{HashSet, IndexMap};
|
|||||||
use feature_flags::ZedProFeatureFlag;
|
use feature_flags::ZedProFeatureFlag;
|
||||||
use fuzzy::{StringMatch, StringMatchCandidate, match_strings};
|
use fuzzy::{StringMatch, StringMatchCandidate, match_strings};
|
||||||
use gpui::{
|
use gpui::{
|
||||||
Action, AnyElement, AnyView, App, BackgroundExecutor, Corner, DismissEvent, Entity,
|
Action, AnyElement, App, BackgroundExecutor, DismissEvent, Subscription, Task,
|
||||||
EventEmitter, FocusHandle, Focusable, Subscription, Task, WeakEntity,
|
|
||||||
action_with_deprecated_aliases,
|
action_with_deprecated_aliases,
|
||||||
};
|
};
|
||||||
use language_model::{
|
use language_model::{
|
||||||
@@ -15,7 +14,7 @@ use language_model::{
|
|||||||
use ordered_float::OrderedFloat;
|
use ordered_float::OrderedFloat;
|
||||||
use picker::{Picker, PickerDelegate};
|
use picker::{Picker, PickerDelegate};
|
||||||
use proto::Plan;
|
use proto::Plan;
|
||||||
use ui::{ListItem, ListItemSpacing, PopoverMenu, PopoverMenuHandle, PopoverTrigger, prelude::*};
|
use ui::{ListItem, ListItemSpacing, prelude::*};
|
||||||
|
|
||||||
action_with_deprecated_aliases!(
|
action_with_deprecated_aliases!(
|
||||||
agent,
|
agent,
|
||||||
@@ -31,77 +30,128 @@ const TRY_ZED_PRO_URL: &str = "https://zed.dev/pro";
|
|||||||
type OnModelChanged = Arc<dyn Fn(Arc<dyn LanguageModel>, &mut App) + 'static>;
|
type OnModelChanged = Arc<dyn Fn(Arc<dyn LanguageModel>, &mut App) + 'static>;
|
||||||
type GetActiveModel = Arc<dyn Fn(&App) -> Option<ConfiguredModel> + 'static>;
|
type GetActiveModel = Arc<dyn Fn(&App) -> Option<ConfiguredModel> + 'static>;
|
||||||
|
|
||||||
pub struct LanguageModelSelector {
|
pub type LanguageModelSelector = Picker<LanguageModelPickerDelegate>;
|
||||||
picker: Entity<Picker<LanguageModelPickerDelegate>>,
|
|
||||||
|
pub fn language_model_selector(
|
||||||
|
get_active_model: impl Fn(&App) -> Option<ConfiguredModel> + 'static,
|
||||||
|
on_model_changed: impl Fn(Arc<dyn LanguageModel>, &mut App) + 'static,
|
||||||
|
window: &mut Window,
|
||||||
|
cx: &mut Context<LanguageModelSelector>,
|
||||||
|
) -> LanguageModelSelector {
|
||||||
|
let delegate = LanguageModelPickerDelegate::new(get_active_model, on_model_changed, window, cx);
|
||||||
|
Picker::list(delegate, window, cx)
|
||||||
|
.show_scrollbar(true)
|
||||||
|
.width(rems(20.))
|
||||||
|
.max_height(Some(rems(20.).into()))
|
||||||
|
}
|
||||||
|
|
||||||
|
fn all_models(cx: &App) -> GroupedModels {
|
||||||
|
let providers = LanguageModelRegistry::global(cx).read(cx).providers();
|
||||||
|
|
||||||
|
let recommended = providers
|
||||||
|
.iter()
|
||||||
|
.flat_map(|provider| {
|
||||||
|
provider
|
||||||
|
.recommended_models(cx)
|
||||||
|
.into_iter()
|
||||||
|
.map(|model| ModelInfo {
|
||||||
|
model,
|
||||||
|
icon: provider.icon(),
|
||||||
|
})
|
||||||
|
})
|
||||||
|
.collect();
|
||||||
|
|
||||||
|
let other = providers
|
||||||
|
.iter()
|
||||||
|
.flat_map(|provider| {
|
||||||
|
provider
|
||||||
|
.provided_models(cx)
|
||||||
|
.into_iter()
|
||||||
|
.map(|model| ModelInfo {
|
||||||
|
model,
|
||||||
|
icon: provider.icon(),
|
||||||
|
})
|
||||||
|
})
|
||||||
|
.collect();
|
||||||
|
|
||||||
|
GroupedModels::new(other, recommended)
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Clone)]
|
||||||
|
struct ModelInfo {
|
||||||
|
model: Arc<dyn LanguageModel>,
|
||||||
|
icon: IconName,
|
||||||
|
}
|
||||||
|
|
||||||
|
pub struct LanguageModelPickerDelegate {
|
||||||
|
on_model_changed: OnModelChanged,
|
||||||
|
get_active_model: GetActiveModel,
|
||||||
|
all_models: Arc<GroupedModels>,
|
||||||
|
filtered_entries: Vec<LanguageModelPickerEntry>,
|
||||||
|
selected_index: usize,
|
||||||
_authenticate_all_providers_task: Task<()>,
|
_authenticate_all_providers_task: Task<()>,
|
||||||
_subscriptions: Vec<Subscription>,
|
_subscriptions: Vec<Subscription>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl LanguageModelSelector {
|
impl LanguageModelPickerDelegate {
|
||||||
pub fn new(
|
fn new(
|
||||||
get_active_model: impl Fn(&App) -> Option<ConfiguredModel> + 'static,
|
get_active_model: impl Fn(&App) -> Option<ConfiguredModel> + 'static,
|
||||||
on_model_changed: impl Fn(Arc<dyn LanguageModel>, &mut App) + 'static,
|
on_model_changed: impl Fn(Arc<dyn LanguageModel>, &mut App) + 'static,
|
||||||
window: &mut Window,
|
window: &mut Window,
|
||||||
cx: &mut Context<Self>,
|
cx: &mut Context<Picker<Self>>,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
let on_model_changed = Arc::new(on_model_changed);
|
let on_model_changed = Arc::new(on_model_changed);
|
||||||
|
let models = all_models(cx);
|
||||||
|
let entries = models.entries();
|
||||||
|
|
||||||
let all_models = Self::all_models(cx);
|
Self {
|
||||||
let entries = all_models.entries();
|
|
||||||
|
|
||||||
let delegate = LanguageModelPickerDelegate {
|
|
||||||
language_model_selector: cx.entity().downgrade(),
|
|
||||||
on_model_changed: on_model_changed.clone(),
|
on_model_changed: on_model_changed.clone(),
|
||||||
all_models: Arc::new(all_models),
|
all_models: Arc::new(models),
|
||||||
selected_index: Self::get_active_model_index(&entries, get_active_model(cx)),
|
selected_index: Self::get_active_model_index(&entries, get_active_model(cx)),
|
||||||
filtered_entries: entries,
|
filtered_entries: entries,
|
||||||
get_active_model: Arc::new(get_active_model),
|
get_active_model: Arc::new(get_active_model),
|
||||||
};
|
|
||||||
|
|
||||||
let picker = cx.new(|cx| {
|
|
||||||
Picker::list(delegate, window, cx)
|
|
||||||
.show_scrollbar(true)
|
|
||||||
.width(rems(20.))
|
|
||||||
.max_height(Some(rems(20.).into()))
|
|
||||||
});
|
|
||||||
|
|
||||||
let subscription = cx.subscribe(&picker, |_, _, _, cx| cx.emit(DismissEvent));
|
|
||||||
|
|
||||||
LanguageModelSelector {
|
|
||||||
picker,
|
|
||||||
_authenticate_all_providers_task: Self::authenticate_all_providers(cx),
|
_authenticate_all_providers_task: Self::authenticate_all_providers(cx),
|
||||||
_subscriptions: vec![
|
_subscriptions: vec![cx.subscribe_in(
|
||||||
cx.subscribe_in(
|
&LanguageModelRegistry::global(cx),
|
||||||
&LanguageModelRegistry::global(cx),
|
window,
|
||||||
window,
|
|picker, _, event, window, cx| {
|
||||||
Self::handle_language_model_registry_event,
|
match event {
|
||||||
),
|
language_model::Event::ProviderStateChanged
|
||||||
subscription,
|
| language_model::Event::AddedProvider(_)
|
||||||
],
|
| language_model::Event::RemovedProvider(_) => {
|
||||||
|
let query = picker.query(cx);
|
||||||
|
picker.delegate.all_models = Arc::new(all_models(cx));
|
||||||
|
// Update matches will automatically drop the previous task
|
||||||
|
// if we get a provider event again
|
||||||
|
picker.update_matches(query, window, cx)
|
||||||
|
}
|
||||||
|
_ => {}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
)],
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn handle_language_model_registry_event(
|
fn get_active_model_index(
|
||||||
&mut self,
|
entries: &[LanguageModelPickerEntry],
|
||||||
_registry: &Entity<LanguageModelRegistry>,
|
active_model: Option<ConfiguredModel>,
|
||||||
event: &language_model::Event,
|
) -> usize {
|
||||||
window: &mut Window,
|
entries
|
||||||
cx: &mut Context<Self>,
|
.iter()
|
||||||
) {
|
.position(|entry| {
|
||||||
match event {
|
if let LanguageModelPickerEntry::Model(model) = entry {
|
||||||
language_model::Event::ProviderStateChanged
|
active_model
|
||||||
| language_model::Event::AddedProvider(_)
|
.as_ref()
|
||||||
| language_model::Event::RemovedProvider(_) => {
|
.map(|active_model| {
|
||||||
self.picker.update(cx, |this, cx| {
|
active_model.model.id() == model.model.id()
|
||||||
let query = this.query(cx);
|
&& active_model.provider.id() == model.model.provider_id()
|
||||||
this.delegate.all_models = Arc::new(Self::all_models(cx));
|
})
|
||||||
// Update matches will automatically drop the previous task
|
.unwrap_or_default()
|
||||||
// if we get a provider event again
|
} else {
|
||||||
this.update_matches(query, window, cx)
|
false
|
||||||
});
|
}
|
||||||
}
|
})
|
||||||
_ => {}
|
.unwrap_or(0)
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Authenticates all providers in the [`LanguageModelRegistry`].
|
/// Authenticates all providers in the [`LanguageModelRegistry`].
|
||||||
@@ -154,169 +204,9 @@ impl LanguageModelSelector {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
fn all_models(cx: &App) -> GroupedModels {
|
|
||||||
let mut recommended = Vec::new();
|
|
||||||
let mut recommended_set = HashSet::default();
|
|
||||||
for provider in LanguageModelRegistry::global(cx)
|
|
||||||
.read(cx)
|
|
||||||
.providers()
|
|
||||||
.iter()
|
|
||||||
{
|
|
||||||
let models = provider.recommended_models(cx);
|
|
||||||
recommended_set.extend(models.iter().map(|model| (model.provider_id(), model.id())));
|
|
||||||
recommended.extend(
|
|
||||||
provider
|
|
||||||
.recommended_models(cx)
|
|
||||||
.into_iter()
|
|
||||||
.map(move |model| ModelInfo {
|
|
||||||
model: model.clone(),
|
|
||||||
icon: provider.icon(),
|
|
||||||
}),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
let other_models = LanguageModelRegistry::global(cx)
|
|
||||||
.read(cx)
|
|
||||||
.providers()
|
|
||||||
.iter()
|
|
||||||
.map(|provider| {
|
|
||||||
(
|
|
||||||
provider.id(),
|
|
||||||
provider
|
|
||||||
.provided_models(cx)
|
|
||||||
.into_iter()
|
|
||||||
.filter_map(|model| {
|
|
||||||
let not_included =
|
|
||||||
!recommended_set.contains(&(model.provider_id(), model.id()));
|
|
||||||
not_included.then(|| ModelInfo {
|
|
||||||
model: model.clone(),
|
|
||||||
icon: provider.icon(),
|
|
||||||
})
|
|
||||||
})
|
|
||||||
.collect::<Vec<_>>(),
|
|
||||||
)
|
|
||||||
})
|
|
||||||
.collect::<IndexMap<_, _>>();
|
|
||||||
|
|
||||||
GroupedModels {
|
|
||||||
recommended,
|
|
||||||
other: other_models,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn active_model(&self, cx: &App) -> Option<ConfiguredModel> {
|
pub fn active_model(&self, cx: &App) -> Option<ConfiguredModel> {
|
||||||
(self.picker.read(cx).delegate.get_active_model)(cx)
|
(self.get_active_model)(cx)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_active_model_index(
|
|
||||||
entries: &[LanguageModelPickerEntry],
|
|
||||||
active_model: Option<ConfiguredModel>,
|
|
||||||
) -> usize {
|
|
||||||
entries
|
|
||||||
.iter()
|
|
||||||
.position(|entry| {
|
|
||||||
if let LanguageModelPickerEntry::Model(model) = entry {
|
|
||||||
active_model
|
|
||||||
.as_ref()
|
|
||||||
.map(|active_model| {
|
|
||||||
active_model.model.id() == model.model.id()
|
|
||||||
&& active_model.provider.id() == model.model.provider_id()
|
|
||||||
})
|
|
||||||
.unwrap_or_default()
|
|
||||||
} else {
|
|
||||||
false
|
|
||||||
}
|
|
||||||
})
|
|
||||||
.unwrap_or(0)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl EventEmitter<DismissEvent> for LanguageModelSelector {}
|
|
||||||
|
|
||||||
impl Focusable for LanguageModelSelector {
|
|
||||||
fn focus_handle(&self, cx: &App) -> FocusHandle {
|
|
||||||
self.picker.focus_handle(cx)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Render for LanguageModelSelector {
|
|
||||||
fn render(&mut self, _window: &mut Window, _cx: &mut Context<Self>) -> impl IntoElement {
|
|
||||||
self.picker.clone()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(IntoElement)]
|
|
||||||
pub struct LanguageModelSelectorPopoverMenu<T, TT>
|
|
||||||
where
|
|
||||||
T: PopoverTrigger + ButtonCommon,
|
|
||||||
TT: Fn(&mut Window, &mut App) -> AnyView + 'static,
|
|
||||||
{
|
|
||||||
language_model_selector: Entity<LanguageModelSelector>,
|
|
||||||
trigger: T,
|
|
||||||
tooltip: TT,
|
|
||||||
handle: Option<PopoverMenuHandle<LanguageModelSelector>>,
|
|
||||||
anchor: Corner,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl<T, TT> LanguageModelSelectorPopoverMenu<T, TT>
|
|
||||||
where
|
|
||||||
T: PopoverTrigger + ButtonCommon,
|
|
||||||
TT: Fn(&mut Window, &mut App) -> AnyView + 'static,
|
|
||||||
{
|
|
||||||
pub fn new(
|
|
||||||
language_model_selector: Entity<LanguageModelSelector>,
|
|
||||||
trigger: T,
|
|
||||||
tooltip: TT,
|
|
||||||
anchor: Corner,
|
|
||||||
) -> Self {
|
|
||||||
Self {
|
|
||||||
language_model_selector,
|
|
||||||
trigger,
|
|
||||||
tooltip,
|
|
||||||
handle: None,
|
|
||||||
anchor,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn with_handle(mut self, handle: PopoverMenuHandle<LanguageModelSelector>) -> Self {
|
|
||||||
self.handle = Some(handle);
|
|
||||||
self
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl<T, TT> RenderOnce for LanguageModelSelectorPopoverMenu<T, TT>
|
|
||||||
where
|
|
||||||
T: PopoverTrigger + ButtonCommon,
|
|
||||||
TT: Fn(&mut Window, &mut App) -> AnyView + 'static,
|
|
||||||
{
|
|
||||||
fn render(self, _window: &mut Window, _cx: &mut App) -> impl IntoElement {
|
|
||||||
let language_model_selector = self.language_model_selector.clone();
|
|
||||||
|
|
||||||
PopoverMenu::new("model-switcher")
|
|
||||||
.menu(move |_window, _cx| Some(language_model_selector.clone()))
|
|
||||||
.trigger_with_tooltip(self.trigger, self.tooltip)
|
|
||||||
.anchor(self.anchor)
|
|
||||||
.when_some(self.handle.clone(), |menu, handle| menu.with_handle(handle))
|
|
||||||
.offset(gpui::Point {
|
|
||||||
x: px(0.0),
|
|
||||||
y: px(-2.0),
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone)]
|
|
||||||
struct ModelInfo {
|
|
||||||
model: Arc<dyn LanguageModel>,
|
|
||||||
icon: IconName,
|
|
||||||
}
|
|
||||||
|
|
||||||
pub struct LanguageModelPickerDelegate {
|
|
||||||
language_model_selector: WeakEntity<LanguageModelSelector>,
|
|
||||||
on_model_changed: OnModelChanged,
|
|
||||||
get_active_model: GetActiveModel,
|
|
||||||
all_models: Arc<GroupedModels>,
|
|
||||||
filtered_entries: Vec<LanguageModelPickerEntry>,
|
|
||||||
selected_index: usize,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
struct GroupedModels {
|
struct GroupedModels {
|
||||||
@@ -326,11 +216,14 @@ struct GroupedModels {
|
|||||||
|
|
||||||
impl GroupedModels {
|
impl GroupedModels {
|
||||||
pub fn new(other: Vec<ModelInfo>, recommended: Vec<ModelInfo>) -> Self {
|
pub fn new(other: Vec<ModelInfo>, recommended: Vec<ModelInfo>) -> Self {
|
||||||
let recommended_ids: HashSet<_> = recommended.iter().map(|info| info.model.id()).collect();
|
let recommended_ids = recommended
|
||||||
|
.iter()
|
||||||
|
.map(|info| (info.model.provider_id(), info.model.id()))
|
||||||
|
.collect::<HashSet<_>>();
|
||||||
|
|
||||||
let mut other_by_provider: IndexMap<_, Vec<ModelInfo>> = IndexMap::default();
|
let mut other_by_provider: IndexMap<_, Vec<ModelInfo>> = IndexMap::default();
|
||||||
for model in other {
|
for model in other {
|
||||||
if recommended_ids.contains(&model.model.id()) {
|
if recommended_ids.contains(&(model.model.provider_id(), model.model.id())) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -577,9 +470,7 @@ impl PickerDelegate for LanguageModelPickerDelegate {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn dismissed(&mut self, _: &mut Window, cx: &mut Context<Picker<Self>>) {
|
fn dismissed(&mut self, _: &mut Window, cx: &mut Context<Picker<Self>>) {
|
||||||
self.language_model_selector
|
cx.emit(DismissEvent);
|
||||||
.update(cx, |_this, cx| cx.emit(DismissEvent))
|
|
||||||
.ok();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn render_match(
|
fn render_match(
|
||||||
@@ -917,4 +808,26 @@ mod tests {
|
|||||||
// Recommended models should not appear in "other"
|
// Recommended models should not appear in "other"
|
||||||
assert_models_eq(actual_other_models, vec!["zed/gemini", "copilot/o3"]);
|
assert_models_eq(actual_other_models, vec!["zed/gemini", "copilot/o3"]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[gpui::test]
|
||||||
|
fn test_dont_exclude_models_from_other_providers(_cx: &mut TestAppContext) {
|
||||||
|
let recommended_models = create_models(vec![("zed", "claude")]);
|
||||||
|
let all_models = create_models(vec![
|
||||||
|
("zed", "claude"), // Should be filtered out from "other"
|
||||||
|
("zed", "gemini"),
|
||||||
|
("copilot", "claude"), // Should not be filtered out from "other"
|
||||||
|
]);
|
||||||
|
|
||||||
|
let grouped_models = GroupedModels::new(all_models, recommended_models);
|
||||||
|
|
||||||
|
let actual_other_models = grouped_models
|
||||||
|
.other
|
||||||
|
.values()
|
||||||
|
.flatten()
|
||||||
|
.cloned()
|
||||||
|
.collect::<Vec<_>>();
|
||||||
|
|
||||||
|
// Recommended models should not appear in "other"
|
||||||
|
assert_models_eq(actual_other_models, vec!["zed/gemini", "copilot/claude"]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
61
crates/assistant_context_editor/src/max_mode_tooltip.rs
Normal file
@@ -0,0 +1,61 @@
|
|||||||
|
use gpui::{Context, FontWeight, IntoElement, Render, Window};
|
||||||
|
use ui::{prelude::*, tooltip_container};
|
||||||
|
|
||||||
|
pub struct MaxModeTooltip {
|
||||||
|
selected: bool,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl MaxModeTooltip {
|
||||||
|
pub fn new() -> Self {
|
||||||
|
Self { selected: false }
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn selected(mut self, selected: bool) -> Self {
|
||||||
|
self.selected = selected;
|
||||||
|
self
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Render for MaxModeTooltip {
|
||||||
|
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));
|
||||||
|
|
||||||
|
tooltip_container(window, cx, |this, _, _| {
|
||||||
|
this
|
||||||
|
.child(title)
|
||||||
|
.child(
|
||||||
|
div()
|
||||||
|
.max_w_64()
|
||||||
|
.child(
|
||||||
|
Label::new("Enables models to use large context windows, unlimited tool calls, and other capabilities for expanded reasoning.")
|
||||||
|
.size(LabelSize::Small)
|
||||||
|
.color(Color::Muted)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -10,9 +10,7 @@ use parking_lot::Mutex;
|
|||||||
use project::{CompletionIntent, CompletionSource, lsp_store::CompletionDocumentation};
|
use project::{CompletionIntent, CompletionSource, lsp_store::CompletionDocumentation};
|
||||||
use rope::Point;
|
use rope::Point;
|
||||||
use std::{
|
use std::{
|
||||||
cell::RefCell,
|
|
||||||
ops::Range,
|
ops::Range,
|
||||||
rc::Rc,
|
|
||||||
sync::{
|
sync::{
|
||||||
Arc,
|
Arc,
|
||||||
atomic::{AtomicBool, Ordering::SeqCst},
|
atomic::{AtomicBool, Ordering::SeqCst},
|
||||||
@@ -48,7 +46,7 @@ impl SlashCommandCompletionProvider {
|
|||||||
name_range: Range<Anchor>,
|
name_range: Range<Anchor>,
|
||||||
window: &mut Window,
|
window: &mut Window,
|
||||||
cx: &mut App,
|
cx: &mut App,
|
||||||
) -> Task<Result<Option<Vec<project::Completion>>>> {
|
) -> Task<Result<Vec<project::CompletionResponse>>> {
|
||||||
let slash_commands = self.slash_commands.clone();
|
let slash_commands = self.slash_commands.clone();
|
||||||
let candidates = slash_commands
|
let candidates = slash_commands
|
||||||
.command_names(cx)
|
.command_names(cx)
|
||||||
@@ -71,28 +69,27 @@ impl SlashCommandCompletionProvider {
|
|||||||
.await;
|
.await;
|
||||||
|
|
||||||
cx.update(|_, cx| {
|
cx.update(|_, cx| {
|
||||||
Some(
|
let completions = matches
|
||||||
matches
|
.into_iter()
|
||||||
.into_iter()
|
.filter_map(|mat| {
|
||||||
.filter_map(|mat| {
|
let command = slash_commands.command(&mat.string, cx)?;
|
||||||
let command = slash_commands.command(&mat.string, cx)?;
|
let mut new_text = mat.string.clone();
|
||||||
let mut new_text = mat.string.clone();
|
let requires_argument = command.requires_argument();
|
||||||
let requires_argument = command.requires_argument();
|
let accepts_arguments = command.accepts_arguments();
|
||||||
let accepts_arguments = command.accepts_arguments();
|
if requires_argument || accepts_arguments {
|
||||||
if requires_argument || accepts_arguments {
|
new_text.push(' ');
|
||||||
new_text.push(' ');
|
}
|
||||||
}
|
|
||||||
|
|
||||||
let confirm =
|
let confirm =
|
||||||
editor
|
editor
|
||||||
.clone()
|
.clone()
|
||||||
.zip(workspace.clone())
|
.zip(workspace.clone())
|
||||||
.map(|(editor, workspace)| {
|
.map(|(editor, workspace)| {
|
||||||
let command_name = mat.string.clone();
|
let command_name = mat.string.clone();
|
||||||
let command_range = command_range.clone();
|
let command_range = command_range.clone();
|
||||||
let editor = editor.clone();
|
let editor = editor.clone();
|
||||||
let workspace = workspace.clone();
|
let workspace = workspace.clone();
|
||||||
Arc::new(
|
Arc::new(
|
||||||
move |intent: CompletionIntent,
|
move |intent: CompletionIntent,
|
||||||
window: &mut Window,
|
window: &mut Window,
|
||||||
cx: &mut App| {
|
cx: &mut App| {
|
||||||
@@ -118,22 +115,27 @@ impl SlashCommandCompletionProvider {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
) as Arc<_>
|
) as Arc<_>
|
||||||
});
|
});
|
||||||
Some(project::Completion {
|
|
||||||
replace_range: name_range.clone(),
|
Some(project::Completion {
|
||||||
documentation: Some(CompletionDocumentation::SingleLine(
|
replace_range: name_range.clone(),
|
||||||
command.description().into(),
|
documentation: Some(CompletionDocumentation::SingleLine(
|
||||||
)),
|
command.description().into(),
|
||||||
new_text,
|
)),
|
||||||
label: command.label(cx),
|
new_text,
|
||||||
icon_path: None,
|
label: command.label(cx),
|
||||||
insert_text_mode: None,
|
icon_path: None,
|
||||||
confirm,
|
insert_text_mode: None,
|
||||||
source: CompletionSource::Custom,
|
confirm,
|
||||||
})
|
source: CompletionSource::Custom,
|
||||||
})
|
})
|
||||||
.collect(),
|
})
|
||||||
)
|
.collect();
|
||||||
|
|
||||||
|
vec![project::CompletionResponse {
|
||||||
|
completions,
|
||||||
|
is_incomplete: false,
|
||||||
|
}]
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@@ -147,7 +149,7 @@ impl SlashCommandCompletionProvider {
|
|||||||
last_argument_range: Range<Anchor>,
|
last_argument_range: Range<Anchor>,
|
||||||
window: &mut Window,
|
window: &mut Window,
|
||||||
cx: &mut App,
|
cx: &mut App,
|
||||||
) -> Task<Result<Option<Vec<project::Completion>>>> {
|
) -> Task<Result<Vec<project::CompletionResponse>>> {
|
||||||
let new_cancel_flag = Arc::new(AtomicBool::new(false));
|
let new_cancel_flag = Arc::new(AtomicBool::new(false));
|
||||||
let mut flag = self.cancel_flag.lock();
|
let mut flag = self.cancel_flag.lock();
|
||||||
flag.store(true, SeqCst);
|
flag.store(true, SeqCst);
|
||||||
@@ -165,28 +167,27 @@ impl SlashCommandCompletionProvider {
|
|||||||
let workspace = self.workspace.clone();
|
let workspace = self.workspace.clone();
|
||||||
let arguments = arguments.to_vec();
|
let arguments = arguments.to_vec();
|
||||||
cx.background_spawn(async move {
|
cx.background_spawn(async move {
|
||||||
Ok(Some(
|
let completions = completions
|
||||||
completions
|
.await?
|
||||||
.await?
|
.into_iter()
|
||||||
.into_iter()
|
.map(|new_argument| {
|
||||||
.map(|new_argument| {
|
let confirm =
|
||||||
let confirm =
|
editor
|
||||||
editor
|
.clone()
|
||||||
.clone()
|
.zip(workspace.clone())
|
||||||
.zip(workspace.clone())
|
.map(|(editor, workspace)| {
|
||||||
.map(|(editor, workspace)| {
|
Arc::new({
|
||||||
Arc::new({
|
let mut completed_arguments = arguments.clone();
|
||||||
let mut completed_arguments = arguments.clone();
|
if new_argument.replace_previous_arguments {
|
||||||
if new_argument.replace_previous_arguments {
|
completed_arguments.clear();
|
||||||
completed_arguments.clear();
|
} else {
|
||||||
} else {
|
completed_arguments.pop();
|
||||||
completed_arguments.pop();
|
}
|
||||||
}
|
completed_arguments.push(new_argument.new_text.clone());
|
||||||
completed_arguments.push(new_argument.new_text.clone());
|
|
||||||
|
|
||||||
let command_range = command_range.clone();
|
let command_range = command_range.clone();
|
||||||
let command_name = command_name.clone();
|
let command_name = command_name.clone();
|
||||||
move |intent: CompletionIntent,
|
move |intent: CompletionIntent,
|
||||||
window: &mut Window,
|
window: &mut Window,
|
||||||
cx: &mut App| {
|
cx: &mut App| {
|
||||||
if new_argument.after_completion.run()
|
if new_argument.after_completion.run()
|
||||||
@@ -210,34 +211,42 @@ impl SlashCommandCompletionProvider {
|
|||||||
!new_argument.after_completion.run()
|
!new_argument.after_completion.run()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}) as Arc<_>
|
}) as Arc<_>
|
||||||
});
|
});
|
||||||
|
|
||||||
let mut new_text = new_argument.new_text.clone();
|
let mut new_text = new_argument.new_text.clone();
|
||||||
if new_argument.after_completion == AfterCompletion::Continue {
|
if new_argument.after_completion == AfterCompletion::Continue {
|
||||||
new_text.push(' ');
|
new_text.push(' ');
|
||||||
}
|
}
|
||||||
|
|
||||||
project::Completion {
|
project::Completion {
|
||||||
replace_range: if new_argument.replace_previous_arguments {
|
replace_range: if new_argument.replace_previous_arguments {
|
||||||
argument_range.clone()
|
argument_range.clone()
|
||||||
} else {
|
} else {
|
||||||
last_argument_range.clone()
|
last_argument_range.clone()
|
||||||
},
|
},
|
||||||
label: new_argument.label,
|
label: new_argument.label,
|
||||||
icon_path: None,
|
icon_path: None,
|
||||||
new_text,
|
new_text,
|
||||||
documentation: None,
|
documentation: None,
|
||||||
confirm,
|
confirm,
|
||||||
insert_text_mode: None,
|
insert_text_mode: None,
|
||||||
source: CompletionSource::Custom,
|
source: CompletionSource::Custom,
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.collect(),
|
.collect();
|
||||||
))
|
|
||||||
|
Ok(vec![project::CompletionResponse {
|
||||||
|
completions,
|
||||||
|
// TODO: Could have slash commands indicate whether their completions are incomplete.
|
||||||
|
is_incomplete: true,
|
||||||
|
}])
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
Task::ready(Ok(Some(Vec::new())))
|
Task::ready(Ok(vec![project::CompletionResponse {
|
||||||
|
completions: Vec::new(),
|
||||||
|
is_incomplete: true,
|
||||||
|
}]))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -251,7 +260,7 @@ impl CompletionProvider for SlashCommandCompletionProvider {
|
|||||||
_: editor::CompletionContext,
|
_: editor::CompletionContext,
|
||||||
window: &mut Window,
|
window: &mut Window,
|
||||||
cx: &mut Context<Editor>,
|
cx: &mut Context<Editor>,
|
||||||
) -> Task<Result<Option<Vec<project::Completion>>>> {
|
) -> Task<Result<Vec<project::CompletionResponse>>> {
|
||||||
let Some((name, arguments, command_range, last_argument_range)) =
|
let Some((name, arguments, command_range, last_argument_range)) =
|
||||||
buffer.update(cx, |buffer, _cx| {
|
buffer.update(cx, |buffer, _cx| {
|
||||||
let position = buffer_position.to_point(buffer);
|
let position = buffer_position.to_point(buffer);
|
||||||
@@ -265,17 +274,17 @@ impl CompletionProvider for SlashCommandCompletionProvider {
|
|||||||
position.row,
|
position.row,
|
||||||
call.arguments.last().map_or(call.name.end, |arg| arg.end) as u32,
|
call.arguments.last().map_or(call.name.end, |arg| arg.end) as u32,
|
||||||
);
|
);
|
||||||
let command_range = buffer.anchor_after(command_range_start)
|
let command_range = buffer.anchor_before(command_range_start)
|
||||||
..buffer.anchor_after(command_range_end);
|
..buffer.anchor_after(command_range_end);
|
||||||
|
|
||||||
let name = line[call.name.clone()].to_string();
|
let name = line[call.name.clone()].to_string();
|
||||||
let (arguments, last_argument_range) = if let Some(argument) = call.arguments.last()
|
let (arguments, last_argument_range) = if let Some(argument) = call.arguments.last()
|
||||||
{
|
{
|
||||||
let last_arg_start =
|
let last_arg_start =
|
||||||
buffer.anchor_after(Point::new(position.row, argument.start as u32));
|
buffer.anchor_before(Point::new(position.row, argument.start as u32));
|
||||||
let first_arg_start = call.arguments.first().expect("we have the last element");
|
let first_arg_start = call.arguments.first().expect("we have the last element");
|
||||||
let first_arg_start =
|
let first_arg_start = buffer
|
||||||
buffer.anchor_after(Point::new(position.row, first_arg_start.start as u32));
|
.anchor_before(Point::new(position.row, first_arg_start.start as u32));
|
||||||
let arguments = call
|
let arguments = call
|
||||||
.arguments
|
.arguments
|
||||||
.into_iter()
|
.into_iter()
|
||||||
@@ -288,14 +297,17 @@ impl CompletionProvider for SlashCommandCompletionProvider {
|
|||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
let start =
|
let start =
|
||||||
buffer.anchor_after(Point::new(position.row, call.name.start as u32));
|
buffer.anchor_before(Point::new(position.row, call.name.start as u32));
|
||||||
(None, start..buffer_position)
|
(None, start..buffer_position)
|
||||||
};
|
};
|
||||||
|
|
||||||
Some((name, arguments, command_range, last_argument_range))
|
Some((name, arguments, command_range, last_argument_range))
|
||||||
})
|
})
|
||||||
else {
|
else {
|
||||||
return Task::ready(Ok(Some(Vec::new())));
|
return Task::ready(Ok(vec![project::CompletionResponse {
|
||||||
|
completions: Vec::new(),
|
||||||
|
is_incomplete: false,
|
||||||
|
}]));
|
||||||
};
|
};
|
||||||
|
|
||||||
if let Some((arguments, argument_range)) = arguments {
|
if let Some((arguments, argument_range)) = arguments {
|
||||||
@@ -313,22 +325,13 @@ impl CompletionProvider for SlashCommandCompletionProvider {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn resolve_completions(
|
|
||||||
&self,
|
|
||||||
_: Entity<Buffer>,
|
|
||||||
_: Vec<usize>,
|
|
||||||
_: Rc<RefCell<Box<[project::Completion]>>>,
|
|
||||||
_: &mut Context<Editor>,
|
|
||||||
) -> Task<Result<bool>> {
|
|
||||||
Task::ready(Ok(true))
|
|
||||||
}
|
|
||||||
|
|
||||||
fn is_completion_trigger(
|
fn is_completion_trigger(
|
||||||
&self,
|
&self,
|
||||||
buffer: &Entity<Buffer>,
|
buffer: &Entity<Buffer>,
|
||||||
position: language::Anchor,
|
position: language::Anchor,
|
||||||
_text: &str,
|
_text: &str,
|
||||||
_trigger_in_words: bool,
|
_trigger_in_words: 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);
|
||||||
|
|||||||
@@ -338,7 +338,7 @@ where
|
|||||||
|
|
||||||
let handle = self
|
let handle = self
|
||||||
.active_context_editor
|
.active_context_editor
|
||||||
.update(cx, |this, _| this.slash_menu_handle.clone())
|
.read_with(cx, |this, _| this.slash_menu_handle.clone())
|
||||||
.ok();
|
.ok();
|
||||||
PopoverMenu::new("model-switcher")
|
PopoverMenu::new("model-switcher")
|
||||||
.menu(move |_window, _cx| Some(picker_view.clone()))
|
.menu(move |_window, _cx| Some(picker_view.clone()))
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ use anyhow::Result;
|
|||||||
use futures::StreamExt;
|
use futures::StreamExt;
|
||||||
use futures::stream::{self, BoxStream};
|
use futures::stream::{self, BoxStream};
|
||||||
use gpui::{App, SharedString, Task, WeakEntity, Window};
|
use gpui::{App, SharedString, Task, WeakEntity, Window};
|
||||||
|
use language::HighlightId;
|
||||||
use language::{BufferSnapshot, CodeLabel, LspAdapterDelegate, OffsetRangeExt};
|
use language::{BufferSnapshot, CodeLabel, LspAdapterDelegate, OffsetRangeExt};
|
||||||
pub use language_model::Role;
|
pub use language_model::Role;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
@@ -16,6 +17,7 @@ use std::{
|
|||||||
ops::Range,
|
ops::Range,
|
||||||
sync::{Arc, atomic::AtomicBool},
|
sync::{Arc, atomic::AtomicBool},
|
||||||
};
|
};
|
||||||
|
use ui::ActiveTheme;
|
||||||
use workspace::{Workspace, ui::IconName};
|
use workspace::{Workspace, ui::IconName};
|
||||||
|
|
||||||
pub fn init(cx: &mut App) {
|
pub fn init(cx: &mut App) {
|
||||||
@@ -325,6 +327,18 @@ impl SlashCommandLine {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn create_label_for_command(command_name: &str, arguments: &[&str], cx: &App) -> CodeLabel {
|
||||||
|
let mut label = CodeLabel::default();
|
||||||
|
label.push_str(command_name, None);
|
||||||
|
label.push_str(" ", None);
|
||||||
|
label.push_str(
|
||||||
|
&arguments.join(" "),
|
||||||
|
cx.theme().syntax().highlight_id("comment").map(HighlightId),
|
||||||
|
);
|
||||||
|
label.filter_range = 0..command_name.len();
|
||||||
|
label
|
||||||
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use pretty_assertions::assert_eq;
|
use pretty_assertions::assert_eq;
|
||||||
|
|||||||
@@ -35,7 +35,6 @@ rope.workspace = true
|
|||||||
serde.workspace = true
|
serde.workspace = true
|
||||||
serde_json.workspace = true
|
serde_json.workspace = true
|
||||||
smol.workspace = true
|
smol.workspace = true
|
||||||
terminal_view.workspace = true
|
|
||||||
text.workspace = true
|
text.workspace = true
|
||||||
toml.workspace = true
|
toml.workspace = true
|
||||||
ui.workspace = true
|
ui.workspace = true
|
||||||
@@ -45,6 +44,6 @@ worktree.workspace = true
|
|||||||
workspace-hack.workspace = true
|
workspace-hack.workspace = true
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
env_logger.workspace = true
|
|
||||||
pretty_assertions.workspace = true
|
pretty_assertions.workspace = true
|
||||||
settings.workspace = true
|
settings.workspace = true
|
||||||
|
zlog.workspace = true
|
||||||
|
|||||||
@@ -12,11 +12,6 @@ mod selection_command;
|
|||||||
mod streaming_example_command;
|
mod streaming_example_command;
|
||||||
mod symbols_command;
|
mod symbols_command;
|
||||||
mod tab_command;
|
mod tab_command;
|
||||||
mod terminal_command;
|
|
||||||
|
|
||||||
use gpui::App;
|
|
||||||
use language::{CodeLabel, HighlightId};
|
|
||||||
use ui::ActiveTheme as _;
|
|
||||||
|
|
||||||
pub use crate::cargo_workspace_command::*;
|
pub use crate::cargo_workspace_command::*;
|
||||||
pub use crate::context_server_command::*;
|
pub use crate::context_server_command::*;
|
||||||
@@ -32,16 +27,5 @@ pub use crate::selection_command::*;
|
|||||||
pub use crate::streaming_example_command::*;
|
pub use crate::streaming_example_command::*;
|
||||||
pub use crate::symbols_command::*;
|
pub use crate::symbols_command::*;
|
||||||
pub use crate::tab_command::*;
|
pub use crate::tab_command::*;
|
||||||
pub use crate::terminal_command::*;
|
|
||||||
|
|
||||||
pub fn create_label_for_command(command_name: &str, arguments: &[&str], cx: &App) -> CodeLabel {
|
use assistant_slash_command::create_label_for_command;
|
||||||
let mut label = CodeLabel::default();
|
|
||||||
label.push_str(command_name, None);
|
|
||||||
label.push_str(" ", None);
|
|
||||||
label.push_str(
|
|
||||||
&arguments.join(" "),
|
|
||||||
cx.theme().syntax().highlight_id("comment").map(HighlightId),
|
|
||||||
);
|
|
||||||
label.filter_range = 0..command_name.len();
|
|
||||||
label
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -86,20 +86,26 @@ impl SlashCommand for ContextServerSlashCommand {
|
|||||||
cx.foreground_executor().spawn(async move {
|
cx.foreground_executor().spawn(async move {
|
||||||
let protocol = server.client().context("Context server not initialized")?;
|
let protocol = server.client().context("Context server not initialized")?;
|
||||||
|
|
||||||
let completion_result = protocol
|
let response = protocol
|
||||||
.completion(
|
.request::<context_server::types::request::CompletionComplete>(
|
||||||
context_server::types::CompletionReference::Prompt(
|
context_server::types::CompletionCompleteParams {
|
||||||
context_server::types::PromptReference {
|
reference: context_server::types::CompletionReference::Prompt(
|
||||||
r#type: context_server::types::PromptReferenceType::Prompt,
|
context_server::types::PromptReference {
|
||||||
name: prompt_name,
|
ty: context_server::types::PromptReferenceType::Prompt,
|
||||||
|
name: prompt_name,
|
||||||
|
},
|
||||||
|
),
|
||||||
|
argument: context_server::types::CompletionArgument {
|
||||||
|
name: arg_name,
|
||||||
|
value: arg_value,
|
||||||
},
|
},
|
||||||
),
|
meta: None,
|
||||||
arg_name,
|
},
|
||||||
arg_value,
|
|
||||||
)
|
)
|
||||||
.await?;
|
.await?;
|
||||||
|
|
||||||
let completions = completion_result
|
let completions = response
|
||||||
|
.completion
|
||||||
.values
|
.values
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.map(|value| ArgumentCompletion {
|
.map(|value| ArgumentCompletion {
|
||||||
@@ -138,10 +144,18 @@ impl SlashCommand for ContextServerSlashCommand {
|
|||||||
if let Some(server) = store.get_running_server(&server_id) {
|
if let Some(server) = store.get_running_server(&server_id) {
|
||||||
cx.foreground_executor().spawn(async move {
|
cx.foreground_executor().spawn(async move {
|
||||||
let protocol = server.client().context("Context server not initialized")?;
|
let protocol = server.client().context("Context server not initialized")?;
|
||||||
let result = protocol.run_prompt(&prompt_name, prompt_args).await?;
|
let response = protocol
|
||||||
|
.request::<context_server::types::request::PromptsGet>(
|
||||||
|
context_server::types::PromptsGetParams {
|
||||||
|
name: prompt_name.clone(),
|
||||||
|
arguments: Some(prompt_args),
|
||||||
|
meta: None,
|
||||||
|
},
|
||||||
|
)
|
||||||
|
.await?;
|
||||||
|
|
||||||
anyhow::ensure!(
|
anyhow::ensure!(
|
||||||
result
|
response
|
||||||
.messages
|
.messages
|
||||||
.iter()
|
.iter()
|
||||||
.all(|msg| matches!(msg.role, context_server::types::Role::User)),
|
.all(|msg| matches!(msg.role, context_server::types::Role::User)),
|
||||||
@@ -149,7 +163,7 @@ impl SlashCommand for ContextServerSlashCommand {
|
|||||||
);
|
);
|
||||||
|
|
||||||
// Extract text from user messages into a single prompt string
|
// Extract text from user messages into a single prompt string
|
||||||
let mut prompt = result
|
let mut prompt = response
|
||||||
.messages
|
.messages
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.filter_map(|msg| match msg.content {
|
.filter_map(|msg| match msg.content {
|
||||||
@@ -167,7 +181,7 @@ impl SlashCommand for ContextServerSlashCommand {
|
|||||||
range: 0..(prompt.len()),
|
range: 0..(prompt.len()),
|
||||||
icon: IconName::ZedAssistant,
|
icon: IconName::ZedAssistant,
|
||||||
label: SharedString::from(
|
label: SharedString::from(
|
||||||
result
|
response
|
||||||
.description
|
.description
|
||||||
.unwrap_or(format!("Result from {}", prompt_name)),
|
.unwrap_or(format!("Result from {}", prompt_name)),
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -587,9 +587,7 @@ mod test {
|
|||||||
use super::collect_files;
|
use super::collect_files;
|
||||||
|
|
||||||
pub fn init_test(cx: &mut gpui::TestAppContext) {
|
pub fn init_test(cx: &mut gpui::TestAppContext) {
|
||||||
if std::env::var("RUST_LOG").is_ok() {
|
zlog::init_test();
|
||||||
env_logger::try_init().ok();
|
|
||||||
}
|
|
||||||
|
|
||||||
cx.update(|cx| {
|
cx.update(|cx| {
|
||||||
let settings_store = SettingsStore::test(cx);
|
let settings_store = SettingsStore::test(cx);
|
||||||
|
|||||||
@@ -29,6 +29,7 @@ serde.workspace = true
|
|||||||
serde_json.workspace = true
|
serde_json.workspace = true
|
||||||
text.workspace = true
|
text.workspace = true
|
||||||
util.workspace = true
|
util.workspace = true
|
||||||
|
watch.workspace = true
|
||||||
workspace.workspace = true
|
workspace.workspace = true
|
||||||
workspace-hack.workspace = true
|
workspace-hack.workspace = true
|
||||||
|
|
||||||
@@ -37,7 +38,6 @@ buffer_diff = { workspace = true, features = ["test-support"] }
|
|||||||
collections = { workspace = true, features = ["test-support"] }
|
collections = { workspace = true, features = ["test-support"] }
|
||||||
clock = { workspace = true, features = ["test-support"] }
|
clock = { workspace = true, features = ["test-support"] }
|
||||||
ctor.workspace = true
|
ctor.workspace = true
|
||||||
env_logger.workspace = true
|
|
||||||
gpui = { workspace = true, features = ["test-support"] }
|
gpui = { workspace = true, features = ["test-support"] }
|
||||||
language = { workspace = true, features = ["test-support"] }
|
language = { workspace = true, features = ["test-support"] }
|
||||||
language_model = { workspace = true, features = ["test-support"] }
|
language_model = { workspace = true, features = ["test-support"] }
|
||||||
@@ -48,3 +48,4 @@ rand.workspace = true
|
|||||||
settings = { workspace = true, features = ["test-support"] }
|
settings = { workspace = true, features = ["test-support"] }
|
||||||
text = { workspace = true, features = ["test-support"] }
|
text = { workspace = true, features = ["test-support"] }
|
||||||
util = { workspace = true, features = ["test-support"] }
|
util = { workspace = true, features = ["test-support"] }
|
||||||
|
zlog.workspace = true
|
||||||
|
|||||||