дзеркало
https://github.com/l0ng-ai/openidea.git
синхронізовано 2026-11-25 02:44:37 +02:00
Порівняти коміти
104
Коміти
| Автор | SHA1 | Дата | |
|---|---|---|---|
|
|
2c4e9180c7 | ||
|
|
50340219ac | ||
|
|
71000e15f2 | ||
|
|
042008f681 | ||
|
|
942e6cb237 | ||
|
|
674cdd3925 | ||
|
|
04666f5980 | ||
|
|
d335ba5fdd | ||
|
|
33d2f34e58 | ||
|
|
7646bc4746 | ||
|
|
2c161812a0 | ||
|
|
1778bf1ef3 | ||
|
|
1e7fe7605b | ||
|
|
67dcf5c978 | ||
|
|
20404d2f44 | ||
|
|
b44e552628 | ||
|
|
bc4e8e9655 | ||
|
|
c12799c973 | ||
|
|
0d4bd4a69a | ||
|
|
bf2f44d523 | ||
|
|
2b6fab3c1c | ||
|
|
37df909358 | ||
|
|
b51054daca | ||
|
|
57856f2d54 | ||
|
|
e06c16f547 | ||
|
|
7b893d2982 | ||
|
|
1cc8a361b8 | ||
|
|
a28f6ce331 | ||
|
|
5d27b4254b | ||
|
|
45d85f5721 | ||
|
|
fa7fcd0d90 | ||
|
|
6b2b4a96e7 | ||
|
|
d507e67123 | ||
|
|
5563345a8f | ||
|
|
bff0761c48 | ||
|
|
2811a438a0 | ||
|
|
d34252c80a | ||
|
|
a60a36f052 | ||
|
|
939222cdfb | ||
|
|
ec0370ec23 | ||
|
|
9243ff2eac | ||
|
|
143281d67e | ||
|
|
e1f25d2747 | ||
|
|
26fce11f94 | ||
|
|
c5c2fb7c98 | ||
|
|
31ca9daa61 | ||
|
|
d89991168e | ||
|
|
16496f8001 | ||
|
|
ce58c873da | ||
|
|
d069c3daff | ||
|
|
95b71e1ffc | ||
|
|
732cfd6002 | ||
|
|
189879f0fa | ||
|
|
f0a412f3e2 | ||
|
|
1a470e2a23 | ||
|
|
793c720f7f | ||
|
|
93c7f8b7fd | ||
|
|
3e37b60505 | ||
|
|
a5c8fe17fd | ||
|
|
0684795334 | ||
|
|
30cbb80f22 | ||
|
|
5cfb0d3311 | ||
|
|
bccf1bd7d6 | ||
|
|
3d79454be8 | ||
|
|
46e4af2b32 | ||
|
|
067edb7d60 | ||
|
|
0a4abf1705 | ||
|
|
d31699c86a | ||
|
|
9467c4ea1b | ||
|
|
7c12c58874 | ||
|
|
9f47ef0991 | ||
|
|
3b614dda7a | ||
|
|
5acd778340 | ||
|
|
7c682a580f | ||
|
|
dc07691279 | ||
|
|
2d04a3d9bc | ||
|
|
8f9b9b1016 | ||
|
|
096964c798 | ||
|
|
f1bfd5db52 | ||
|
|
a17af582f3 | ||
|
|
47f018d8b5 | ||
|
|
94aa62430c | ||
|
|
4242c94bfc | ||
|
|
8864ff595d | ||
|
|
0a08d9f4ce | ||
|
|
7dbfe8852e | ||
|
|
ae97d5f1c2 | ||
|
|
4340a96c59 | ||
|
|
0af7bcc7cf | ||
|
|
4f52f5ebfa | ||
|
|
f284633162 | ||
|
|
0ceda2c385 | ||
|
|
8b3f55dfb4 | ||
|
|
c0e888dd2f | ||
|
|
04bed01942 | ||
|
|
dfafe6c767 | ||
|
|
461c71a50b | ||
|
|
82085a227e | ||
|
|
c3f420374c | ||
|
|
6bf7bc8c2b | ||
|
|
34dfc166db | ||
|
|
64632dc4d7 | ||
|
|
f484fd6802 | ||
|
|
8121dc87f1 |
No files matched your search
Створено
+67
-76
@@ -1203,27 +1203,27 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "cranelift-assembler-x64"
|
||||
version = "0.136.6"
|
||||
version = "0.136.7"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "aecefa88696b62f833cc0c997d19c93246b0268e2aaf23e0e8692e527f6de088"
|
||||
checksum = "c19fba13ee427c4dd29488ea51127e945bf07fd9d79093f14c9cc57f74acf757"
|
||||
dependencies = [
|
||||
"cranelift-assembler-x64-meta",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "cranelift-assembler-x64-meta"
|
||||
version = "0.136.6"
|
||||
version = "0.136.7"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1391a2546f5edf06a0ff5e9430d73c2713fd536aefec53200dc21846d1467f53"
|
||||
checksum = "dd88c766346fcc14bbadbd68cb11e9bc1e555e99f7e8f6b1f4c27a73ca659bec"
|
||||
dependencies = [
|
||||
"cranelift-srcgen",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "cranelift-bforest"
|
||||
version = "0.136.6"
|
||||
version = "0.136.7"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9528915fbc2c950702329e08c6d72aaff8ece9b7ecdbd225742825c09a445227"
|
||||
checksum = "f19d43d75dd963d6b1a653f2e03d4eed4365ca2e598ec57e52c15afdad6c3276"
|
||||
dependencies = [
|
||||
"cranelift-entity",
|
||||
"wasmtime-internal-core",
|
||||
@@ -1231,9 +1231,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "cranelift-bitset"
|
||||
version = "0.136.6"
|
||||
version = "0.136.7"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9dd69a6db85c1bcff989809e0e0b3b06506425f32b545c46aeafda5fe7775d6a"
|
||||
checksum = "45d0b93e50856858c89c61cbe3f6d4b07596da22eb5a03a95b19420e1d08a275"
|
||||
dependencies = [
|
||||
"serde",
|
||||
"serde_derive",
|
||||
@@ -1242,9 +1242,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "cranelift-codegen"
|
||||
version = "0.136.6"
|
||||
version = "0.136.7"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "24c2db6c26cd96393cf785c4b51b900738963cc7422aa0045416a7641ae2f6cd"
|
||||
checksum = "efbdff32d3b6b4f33f1ba8a4ac747b97ce569b1d6834c3089c1c0933b94e618c"
|
||||
dependencies = [
|
||||
"bumpalo",
|
||||
"cranelift-assembler-x64",
|
||||
@@ -1273,9 +1273,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "cranelift-codegen-meta"
|
||||
version = "0.136.6"
|
||||
version = "0.136.7"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e284270142e7f1dcb73a992a62a8b3716b4062a65a52d8f2732c6ebf6f7f342f"
|
||||
checksum = "67fd11ff24916a2c1ff852ce4bb664fcf2c2970ed551de44dd5b573321123703"
|
||||
dependencies = [
|
||||
"cranelift-assembler-x64-meta",
|
||||
"cranelift-codegen-shared",
|
||||
@@ -1286,24 +1286,24 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "cranelift-codegen-shared"
|
||||
version = "0.136.6"
|
||||
version = "0.136.7"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6595667b7d505cf85d5bdd014e6f57ad6128183238f8e372319d9384782472f5"
|
||||
checksum = "ba5d321229c3e00a17d7bb3633529ffdf97a13bcf4962fd2e92f1e0fd39360aa"
|
||||
|
||||
[[package]]
|
||||
name = "cranelift-control"
|
||||
version = "0.136.6"
|
||||
version = "0.136.7"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f26ffdbfcd24c3833d730849e6d132af34a400a2b89b44446015c01eecbea21d"
|
||||
checksum = "71cd63450256d0f80f7a0527e133452f84fa6e1ca73c7db6ca2a9e8cc89d1c18"
|
||||
dependencies = [
|
||||
"arbitrary",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "cranelift-entity"
|
||||
version = "0.136.6"
|
||||
version = "0.136.7"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9ffb08ccd8a77fb31cdbbda2afa2333d8f85299b1bc0d1c194259ba66d160d74"
|
||||
checksum = "18d2f259130db1bbb89500d26944971a9beeb410de91ff14039203f055d7f9f0"
|
||||
dependencies = [
|
||||
"cranelift-bitset",
|
||||
"serde",
|
||||
@@ -1313,9 +1313,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "cranelift-frontend"
|
||||
version = "0.136.6"
|
||||
version = "0.136.7"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b447e4f2bb44b1188185a77f478e5a91b7723a40b3b58c3e2d5b26df2ed5a665"
|
||||
checksum = "cf37a38d982d45fe2c065d55e4de76e596b443b6acceb3ca726c2072c8ba6d7b"
|
||||
dependencies = [
|
||||
"cranelift-codegen",
|
||||
"hashbrown 0.17.1",
|
||||
@@ -1326,15 +1326,15 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "cranelift-isle"
|
||||
version = "0.136.6"
|
||||
version = "0.136.7"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2f0989e943f3a9d41989595826bba544df9fda64bcddd4df0c06fb2e26af3cb3"
|
||||
checksum = "8ce8f84e2d44326879e18016d763457a2cb5d775e4a5822cd7473fc171fca063"
|
||||
|
||||
[[package]]
|
||||
name = "cranelift-native"
|
||||
version = "0.136.6"
|
||||
version = "0.136.7"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5fa10df59e776c42dae5b6ba5216ba5321707a2136abd2219e615c54b234fc1b"
|
||||
checksum = "df64a0392edac7b38fb2965ce8e205e7c5e219e4c531ed3cd1929c782f21853d"
|
||||
dependencies = [
|
||||
"cranelift-codegen",
|
||||
"libc",
|
||||
@@ -1343,9 +1343,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "cranelift-srcgen"
|
||||
version = "0.136.6"
|
||||
version = "0.136.7"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "36508559c8839a8b6ee091f9deaa9cfe620a82f1abb5e358a0a0c65290583622"
|
||||
checksum = "3748e3c77c0717359cd4c089e1dc057221eb8598a9c18b0b5afccb5685975abb"
|
||||
|
||||
[[package]]
|
||||
name = "crc"
|
||||
@@ -2154,7 +2154,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "39cab71617ae0d63f51a36d69f866391735b51691dbda63cf6f96d042b63efeb"
|
||||
dependencies = [
|
||||
"libc",
|
||||
"windows-sys 0.61.2",
|
||||
"windows-sys 0.52.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -2386,7 +2386,7 @@ checksum = "94e7099f6313ecacbe1256e8ff9d617b75d1bcb16a6fddef94866d225a01a14a"
|
||||
dependencies = [
|
||||
"io-lifetimes 2.0.4",
|
||||
"rustix",
|
||||
"windows-sys 0.59.0",
|
||||
"windows-sys 0.52.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -5227,7 +5227,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "20fd6de4ccfcc187e38bc21cfa543cb5a302cb86a8b114eb7f0bf0dc9f8ac00f"
|
||||
dependencies = [
|
||||
"io-lifetimes 3.0.1",
|
||||
"windows-sys 0.60.2",
|
||||
"windows-sys 0.52.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -5265,7 +5265,7 @@ checksum = "3640c1c38b8e4e43584d8df18be5fc6b0aa314ce6ebf51b53313d4306cca8e46"
|
||||
dependencies = [
|
||||
"hermit-abi",
|
||||
"libc",
|
||||
"windows-sys 0.61.2",
|
||||
"windows-sys 0.52.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -7424,9 +7424,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "pulley-interpreter"
|
||||
version = "49.0.6"
|
||||
version = "49.0.7"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "335e459f9c7809af04768799880504d014d07e8e2fc6ae682fe2a105d8ced33f"
|
||||
checksum = "99ecf828c291348e4066f8e45bf37c35ea6012b07a9201e7911c21f03ad1af3e"
|
||||
dependencies = [
|
||||
"cranelift-bitset",
|
||||
"log",
|
||||
@@ -7436,9 +7436,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "pulley-macros"
|
||||
version = "49.0.6"
|
||||
version = "49.0.7"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "dd492ac929a6ca0357362d9fa0a09e31290feac5914550ccfb539b21f89c4b9e"
|
||||
checksum = "20e35ece122b2e8bbd7ea9db0709b3d32f20555b73985efc3eaf6afa4ef2ecdf"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
@@ -7968,7 +7968,7 @@ dependencies = [
|
||||
"errno",
|
||||
"libc",
|
||||
"linux-raw-sys",
|
||||
"windows-sys 0.61.2",
|
||||
"windows-sys 0.52.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -8036,7 +8036,7 @@ dependencies = [
|
||||
"security-framework",
|
||||
"security-framework-sys",
|
||||
"webpki-root-certs",
|
||||
"windows-sys 0.61.2",
|
||||
"windows-sys 0.52.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -9783,7 +9783,7 @@ dependencies = [
|
||||
"getrandom 0.3.4",
|
||||
"once_cell",
|
||||
"rustix",
|
||||
"windows-sys 0.61.2",
|
||||
"windows-sys 0.52.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -11117,9 +11117,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "wasmtime"
|
||||
version = "49.0.6"
|
||||
version = "49.0.7"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f32390bdc8d7cdb6259a1b855178bfed88226b4004b209fd48fb30e0deb01cd3"
|
||||
checksum = "263d6a66a772efff2c98a1aa367e8e61dae32d2ecf95f85f4776733762322aa7"
|
||||
dependencies = [
|
||||
"addr2line",
|
||||
"async-trait",
|
||||
@@ -11159,9 +11159,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "wasmtime-environ"
|
||||
version = "49.0.6"
|
||||
version = "49.0.7"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9c10f8ef1c9ee5e0f125c775fe56a4d07b8525db30a96e6358c61d93bd11dee4"
|
||||
checksum = "5f2f0898bedc77f110dca6f70394780f89af68a8ca19e12559ee73d4187a6fe9"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"cpp_demangle",
|
||||
@@ -11190,9 +11190,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "wasmtime-internal-component-macro"
|
||||
version = "49.0.6"
|
||||
version = "49.0.7"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "620c53182ebd26c9fff5b90dd53cf8ec3103c381403fd32f8d395da31a9e4a46"
|
||||
checksum = "b140c28283bd2255a4bb8834621f7200bbe7581cbca91d803b5ba4adf9119a5e"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"proc-macro2",
|
||||
@@ -11205,15 +11205,15 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "wasmtime-internal-component-util"
|
||||
version = "49.0.6"
|
||||
version = "49.0.7"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "011e31ca343d9ba0ec623153cd94131b6f03973ef1a0ab791161f642e4a16a93"
|
||||
checksum = "853075a197694ba7f0749e7af78b59e12c0956dff5b16dafbfc49c3b90cdbc93"
|
||||
|
||||
[[package]]
|
||||
name = "wasmtime-internal-core"
|
||||
version = "49.0.6"
|
||||
version = "49.0.7"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ab15e50a060b746493e6e95ef3ce4e6e7ebfdd7cc336a7dff0f0277e01b447ef"
|
||||
checksum = "e6e13ab3aa598d863643ef9ec043d63fde7effca4465270446d5b868936b27a6"
|
||||
dependencies = [
|
||||
"hashbrown 0.17.1",
|
||||
"libm",
|
||||
@@ -11222,9 +11222,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "wasmtime-internal-cranelift"
|
||||
version = "49.0.6"
|
||||
version = "49.0.7"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "dc3d27440a83fba26dd2784a997e13d9acb3606a75fb127c324929b52221c5c5"
|
||||
checksum = "660103cff91df46f9f06568f3889b8b59a6ae0f56756abfcc002a0a69974cc9f"
|
||||
dependencies = [
|
||||
"cranelift-codegen",
|
||||
"cranelift-control",
|
||||
@@ -11248,9 +11248,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "wasmtime-internal-fiber"
|
||||
version = "49.0.6"
|
||||
version = "49.0.7"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6e54b28d0d453ca8932e4504065ae66a78f01fcb22b1a2ee287128d732fa9d6f"
|
||||
checksum = "c4d0e958516bdf283b83015283774e11c86b66f2f4bd7d2ea52e9799fa59cddb"
|
||||
dependencies = [
|
||||
"cc",
|
||||
"libc",
|
||||
@@ -11262,9 +11262,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "wasmtime-internal-jit-debug"
|
||||
version = "49.0.6"
|
||||
version = "49.0.7"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9293e75a3048b900f7b7c524702abca16d8a2332f970324eefc519f454cd5d69"
|
||||
checksum = "ad61b1e661871bb7d11b5543202a05c44ed8682806b438f68ced629a22719463"
|
||||
dependencies = [
|
||||
"cc",
|
||||
"wasmtime-internal-versioned-export-macros",
|
||||
@@ -11272,9 +11272,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "wasmtime-internal-jit-icache-coherence"
|
||||
version = "49.0.6"
|
||||
version = "49.0.7"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b852e568831b913d410541bb37edc45a5002e472208fbdbaf844ed801dd4255f"
|
||||
checksum = "52c641b9e1bab449c7316896f01d4a0c426e2a502a5a8098e1af4a0392053e7a"
|
||||
dependencies = [
|
||||
"libc",
|
||||
"wasmtime-internal-core",
|
||||
@@ -11283,9 +11283,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "wasmtime-internal-unwinder"
|
||||
version = "49.0.6"
|
||||
version = "49.0.7"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a1f7349c9834a542275ad757340079e6453fccb429efce581454d23f85af92c0"
|
||||
checksum = "03303a9abd333edcbd44fee3b1e0905ad156d3bcec311323d061cdff92e7d1f3"
|
||||
dependencies = [
|
||||
"cranelift-codegen",
|
||||
"log",
|
||||
@@ -11295,9 +11295,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "wasmtime-internal-versioned-export-macros"
|
||||
version = "49.0.6"
|
||||
version = "49.0.7"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "30b3e0768a450d9dea3e16b83f2498f0b08db0e32bad695e35564eef017be3f1"
|
||||
checksum = "8db0c7f417e5ca3ba92d127d17b980529455d01c141be99204e6d309630c42de"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
@@ -11306,9 +11306,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "wasmtime-internal-wit-bindgen"
|
||||
version = "49.0.6"
|
||||
version = "49.0.7"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b9d085c540b95d0ffebf98c266e6f152e1acf96a9f676f224a74307b9d422c15"
|
||||
checksum = "6292ee4f797f9befb64aa2b3477ec8576501d6302ec21fd2785a8d3f94cf8717"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"bitflags 2.13.2",
|
||||
@@ -11320,9 +11320,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "wasmtime-wasi"
|
||||
version = "49.0.6"
|
||||
version = "49.0.7"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "17f8ce6b9e77539b5f52d440346f876a84c513ec1b07162845282f8652f7f7f9"
|
||||
checksum = "3175ff29e2992269f51ec372f7757941f11f87b265a614761726960d42ef6e4d"
|
||||
dependencies = [
|
||||
"async-trait",
|
||||
"bitflags 2.13.2",
|
||||
@@ -11344,9 +11344,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "wasmtime-wasi-io"
|
||||
version = "49.0.6"
|
||||
version = "49.0.7"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "da9f90eb7ce6edbead27dba3a58843398875defa73b8dce4bbc29d0ce3dc9b40"
|
||||
checksum = "3bb561839e32b61bf0cdd51efe3874fac5de1bd5775a5b7c41bdf70993e367ea"
|
||||
dependencies = [
|
||||
"async-trait",
|
||||
"bytes",
|
||||
@@ -11620,7 +11620,7 @@ version = "0.1.11"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c2a7b1c03c876122aa43f3020e6c3c3ee5c05081c9a00739faf7503aeba10d22"
|
||||
dependencies = [
|
||||
"windows-sys 0.61.2",
|
||||
"windows-sys 0.52.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -11788,15 +11788,6 @@ dependencies = [
|
||||
"windows-targets 0.52.6",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "windows-sys"
|
||||
version = "0.59.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1e38bc4d79ed67fd075bcc251a1c39b32a1776bbe92e5bef1f0bf1f8c531853b"
|
||||
dependencies = [
|
||||
"windows-targets 0.52.6",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "windows-sys"
|
||||
version = "0.60.2"
|
||||
@@ -12069,7 +12060,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3f3fd376f71958b862e7afb20cfe5a22830e1963462f3a17f49d82a6c1d1f42d"
|
||||
dependencies = [
|
||||
"bitflags 2.13.2",
|
||||
"windows-sys 0.59.0",
|
||||
"windows-sys 0.52.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
||||
@@ -194,14 +194,14 @@ impl AgentCatalogs {
|
||||
(shared.paths.models_file.clone(), shared.paths.project_root.clone(), provider.to_owned())
|
||||
}
|
||||
|
||||
fn fallback(shared: &Shared, provider: &str) -> CatalogData {
|
||||
/// The catalog saved for this project, for before this run looked anything up.
|
||||
fn saved(shared: &Shared, provider: &str) -> CatalogData {
|
||||
let cache = shared.known.lock();
|
||||
let Some(known) = cache.get(provider) else { return CatalogData::default() };
|
||||
known.catalogs.get(&shared.root_key()).map(|saved| saved.catalog.clone()).unwrap_or_else(|| CatalogData {
|
||||
config: known.config.clone(),
|
||||
thought_levels: known.thought_levels.clone(),
|
||||
refreshed_at_ms: None,
|
||||
})
|
||||
cache
|
||||
.get(provider)
|
||||
.and_then(|known| known.catalogs.get(&shared.root_key()))
|
||||
.map(|saved| saved.catalog.clone())
|
||||
.unwrap_or_default()
|
||||
}
|
||||
|
||||
pub(crate) fn cached(&self, shared: &Shared, provider: &str) -> CatalogData {
|
||||
@@ -210,32 +210,14 @@ impl AgentCatalogs {
|
||||
.entries
|
||||
.get(&Self::key(shared, provider))
|
||||
.and_then(|e| e.catalog.clone())
|
||||
.unwrap_or_else(|| Self::fallback(shared, provider))
|
||||
.unwrap_or_else(|| Self::saved(shared, provider))
|
||||
}
|
||||
|
||||
/// Availability for an explicit session switch must come from a recent discovery for this
|
||||
/// launch, not from the display fallback or a different project's session report.
|
||||
pub(super) fn fresh_model(
|
||||
&self,
|
||||
shared: &Shared,
|
||||
spec: &provider::ProviderSpec,
|
||||
model: &str,
|
||||
) -> Option<crate::AgentConfigValue> {
|
||||
let context = LaunchContext::new(spec.clone(), &shared.paths.project_root);
|
||||
let select = |catalog: &CatalogData| {
|
||||
let age = self.epoch_ms() - catalog.refreshed_at_ms?;
|
||||
if !(0.0..FRESH_FOR.as_millis() as f64).contains(&age) {
|
||||
return None;
|
||||
}
|
||||
catalog.model_option()?.values.iter().find(|value| value.value == model).cloned()
|
||||
};
|
||||
let state = self.state.lock();
|
||||
if let Some(entry) = state.entries.get(&Self::key(shared, &spec.id)) {
|
||||
return select(entry.catalog.as_ref().filter(|_| entry.context == context)?);
|
||||
}
|
||||
let cache = shared.known.lock();
|
||||
let saved = cache.get(&spec.id)?.catalogs.get(&shared.root_key())?;
|
||||
(saved.fingerprint == context.fingerprint()).then(|| select(&saved.catalog)).flatten()
|
||||
/// The entry a chat may switch to: exactly what the picker offers from the cached catalog,
|
||||
/// however long ago it was read. Refreshing keeps that catalog current; a listed model is
|
||||
/// never refused because the catalog aged.
|
||||
pub(super) fn listed_model(&self, shared: &Shared, provider: &str, model: &str) -> Option<crate::AgentConfigValue> {
|
||||
self.cached(shared, provider).model_option()?.values.iter().find(|value| value.value == model).cloned()
|
||||
}
|
||||
|
||||
pub(crate) fn levels(&self, shared: &Shared, provider: &str, model: &str) -> Option<Vec<AgentConfigOption>> {
|
||||
@@ -246,14 +228,7 @@ impl AgentCatalogs {
|
||||
}
|
||||
drop(state);
|
||||
let cache = shared.known.lock();
|
||||
let known = cache.get(provider)?;
|
||||
known
|
||||
.catalogs
|
||||
.get(&shared.root_key())
|
||||
.map(|saved| &saved.catalog.thought_levels)
|
||||
.unwrap_or(&known.thought_levels)
|
||||
.get(model)
|
||||
.cloned()
|
||||
cache.get(provider)?.catalogs.get(&shared.root_key())?.catalog.thought_levels.get(model).cloned()
|
||||
}
|
||||
|
||||
pub(super) async fn load_levels(
|
||||
@@ -297,7 +272,7 @@ impl AgentCatalogs {
|
||||
}
|
||||
|
||||
fn snapshot(&self, shared: &Shared, provider: &str, entry: &Entry) -> AgentModelCatalog {
|
||||
let catalog = entry.catalog.clone().unwrap_or_else(|| Self::fallback(shared, provider));
|
||||
let catalog = entry.catalog.clone().unwrap_or_default();
|
||||
let model_failure = entry.requested_model.as_ref().and_then(|model| entry.model_failures.get(model));
|
||||
let unknown_model = entry
|
||||
.requested_model
|
||||
@@ -382,12 +357,11 @@ impl AgentCatalogs {
|
||||
},
|
||||
);
|
||||
}
|
||||
let fallback =
|
||||
state.entries.get(&key).filter(|entry| entry.catalog.is_none()).map(|_| Self::fallback(shared, &spec.id));
|
||||
state.generation += 1;
|
||||
let generation = state.generation;
|
||||
let entry = state.entries.get_mut(&key).expect("catalog entry");
|
||||
let catalog = entry.catalog.as_ref().or(fallback.as_ref()).expect("cached catalog");
|
||||
let empty = CatalogData::default();
|
||||
let catalog = entry.catalog.as_ref().unwrap_or(&empty);
|
||||
let fresh = entry.successful.is_some_and(|at| now.duration_since(at) < FRESH_FOR);
|
||||
let target = model
|
||||
.filter(|model| {
|
||||
@@ -496,7 +470,7 @@ impl AgentCatalogs {
|
||||
entry.flight_model = None;
|
||||
let success = match result {
|
||||
Ok(found) => {
|
||||
let previous = entry.catalog.take().unwrap_or_else(|| Self::fallback(shared, &key.2));
|
||||
let previous = entry.catalog.take().unwrap_or_default();
|
||||
let mut cache = shared.known.lock();
|
||||
let known = cache.entry(key.2.clone()).or_default();
|
||||
let mut catalog = CatalogData {
|
||||
@@ -510,13 +484,9 @@ impl AgentCatalogs {
|
||||
catalog.thought_levels.insert(model, levels);
|
||||
}
|
||||
}
|
||||
known.config = catalog.config.clone();
|
||||
known.thought_levels = catalog.thought_levels.clone();
|
||||
if let Some(commands) = found.commands {
|
||||
known.commands.insert(shared.root_key(), commands);
|
||||
}
|
||||
known.authoritative = true;
|
||||
known.refreshed_at_ms = catalog.refreshed_at_ms;
|
||||
known.catalogs.insert(
|
||||
shared.root_key(),
|
||||
SavedCatalog { fingerprint: entry.context.fingerprint(), catalog: catalog.clone() },
|
||||
|
||||
@@ -230,11 +230,9 @@ async fn successful_refresh_replaces_models_and_efforts_and_old_sessions_cannot_
|
||||
let manager = make_manager(tmp.path(), catalogs.clone(), &harness);
|
||||
let mut events = events(&manager);
|
||||
let old = config::options_of(&response(&["old", "retained"], &["low", "high"]));
|
||||
manager.shared.remember(PROVIDER, Some(&old), None, Some("old"));
|
||||
let cached = manager.refresh_models(PROVIDER, false, None).unwrap();
|
||||
assert!(cached.refreshing);
|
||||
assert_eq!(model_values(&cached), ["old", "retained"]);
|
||||
assert!(cached.refreshed_at_ms.is_none(), "session reports are not fresh discovery");
|
||||
assert!(model_values(&cached).is_empty(), "nothing is offered before the first discovery");
|
||||
let pending = harness.next().await;
|
||||
assert_eq!(pending.params["mcpServers"], json!([]));
|
||||
pending.reply.send(Ok(response(&["retained", "new"], &["medium"]))).unwrap();
|
||||
@@ -258,7 +256,10 @@ async fn successful_refresh_replaces_models_and_efforts_and_old_sessions_cannot_
|
||||
assert_eq!(provider.config, fresh.config);
|
||||
restored.shared.remember(PROVIDER, Some(&old), None, Some("old"));
|
||||
assert_eq!(restored.shared.known_config(PROVIDER), fresh.config);
|
||||
assert_eq!(restored.shared.known.lock()[PROVIDER].refreshed_at_ms, fresh.refreshed_at_ms);
|
||||
assert_eq!(
|
||||
restored.shared.paths.catalogs.cached(&restored.shared, PROVIDER).refreshed_at_ms,
|
||||
fresh.refreshed_at_ms
|
||||
);
|
||||
assert!(!tmp.path().join("store").exists(), "refresh never creates tasks");
|
||||
}
|
||||
|
||||
@@ -308,6 +309,11 @@ async fn discovered_model_reloads_the_same_session_on_the_next_message() {
|
||||
switch_chat_model(ChatSwitch::Resume).await;
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn discovered_model_from_an_aged_catalog_can_still_be_selected() {
|
||||
switch_chat_model(ChatSwitch::Aged).await;
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn discovered_model_leaves_the_original_session_intact_after_resume_failure() {
|
||||
switch_chat_model(ChatSwitch::ResumeFails).await;
|
||||
@@ -356,6 +362,7 @@ async fn discovered_model_lookup_does_not_overwrite_a_newer_selection() {
|
||||
#[derive(Clone, Copy)]
|
||||
enum ChatSwitch {
|
||||
Live,
|
||||
Aged,
|
||||
Resume,
|
||||
ResumeFails,
|
||||
Unavailable,
|
||||
@@ -376,7 +383,8 @@ async fn switch_chat_model(scenario: ChatSwitch) {
|
||||
let mut harness = Harness::with_initialize(json!({
|
||||
"protocolVersion": 1, "agentCapabilities": { "loadSession": true }
|
||||
}));
|
||||
let mut manager = make_manager(tmp.path(), Arc::default(), &harness);
|
||||
let catalogs = Arc::new(AgentCatalogs::default());
|
||||
let mut manager = make_manager(tmp.path(), catalogs.clone(), &harness);
|
||||
let task = manager
|
||||
.create(NewAgentTask {
|
||||
prompt: AgentPrompt { text: "first".into(), ..Default::default() },
|
||||
@@ -443,7 +451,11 @@ async fn switch_chat_model(scenario: ChatSwitch) {
|
||||
}
|
||||
assert_eq!(manager.task(&task.id).unwrap().state.lock().task.config, before_config);
|
||||
|
||||
let live = matches!(scenario, ChatSwitch::Live);
|
||||
let live = matches!(scenario, ChatSwitch::Live | ChatSwitch::Aged);
|
||||
if matches!(scenario, ChatSwitch::Aged) {
|
||||
// The catalog stays what the picker offers however long ago it was read.
|
||||
advance(&catalogs, 20 * 60);
|
||||
}
|
||||
let resumed_launch = if missing_settings { 3 } else { 2 };
|
||||
let load_fails = matches!(scenario, ChatSwitch::ResumeFails);
|
||||
let unavailable = matches!(scenario, ChatSwitch::Unavailable);
|
||||
@@ -684,7 +696,7 @@ async fn next_chat_request(
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn legacy_cache_loads_without_claiming_authoritative_freshness() {
|
||||
async fn a_cache_from_before_project_catalogs_offers_nothing_until_discovery_succeeds() {
|
||||
let tmp = tempfile::tempdir().unwrap();
|
||||
configure(tmp.path(), "one");
|
||||
let options = config::options_of(&response(&["legacy"], &["low"]));
|
||||
@@ -700,12 +712,11 @@ async fn legacy_cache_loads_without_claiming_authoritative_freshness() {
|
||||
let manager = make_manager(tmp.path(), Arc::default(), &harness);
|
||||
let mut events = events(&manager);
|
||||
let cached = manager.refresh_models(PROVIDER, false, None).unwrap();
|
||||
assert_eq!(model_values(&cached), ["legacy"]);
|
||||
assert!(model_values(&cached).is_empty());
|
||||
assert!(cached.refreshing && cached.refreshed_at_ms.is_none());
|
||||
harness.next().await.reply.send(Err("Sign in required".into())).unwrap();
|
||||
let failed = completed(&mut events).await;
|
||||
assert_eq!(failed.config, cached.config);
|
||||
assert!(failed.error.as_deref().unwrap().contains("Sign in required"));
|
||||
harness.next().await.reply.send(Ok(response(&["current"], &["low"]))).unwrap();
|
||||
let found = completed(&mut events).await;
|
||||
assert_eq!(model_values(&found), ["current"]);
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
|
||||
@@ -174,23 +174,13 @@ struct Shared {
|
||||
attention_seq: AtomicU64,
|
||||
}
|
||||
|
||||
/// What an agent offered in its last session, for the New Task page.
|
||||
/// What an agent offered, for the New Task page.
|
||||
#[derive(Clone, Default, Serialize, Deserialize)]
|
||||
struct Known {
|
||||
#[serde(default)]
|
||||
config: Vec<AgentConfigOption>,
|
||||
/// Thinking levels reported for each model value, including its last choice.
|
||||
#[serde(default, rename = "thoughtLevels")]
|
||||
thought_levels: BTreeMap<String, Vec<AgentConfigOption>>,
|
||||
/// By project root: skills and custom commands differ per project.
|
||||
#[serde(default, rename = "projectCommands")]
|
||||
commands: HashMap<String, Vec<AgentCommand>>,
|
||||
/// Successful discovery, unlike a session report, owns availability.
|
||||
#[serde(default)]
|
||||
authoritative: bool,
|
||||
#[serde(default, rename = "refreshedAtMs")]
|
||||
refreshed_at_ms: Option<f64>,
|
||||
/// Authoritative availability and freshness are scoped to project and launch context.
|
||||
/// Model catalogs by project root, valid for the launch context they were read with.
|
||||
#[serde(default, rename = "projectCatalogs")]
|
||||
catalogs: HashMap<String, catalogs::SavedCatalog>,
|
||||
}
|
||||
@@ -308,7 +298,8 @@ impl Shared {
|
||||
self.paths.project_root.to_string_lossy().into_owned()
|
||||
}
|
||||
|
||||
/// Cache levels only when `model` confirms which model the session reported them for.
|
||||
/// Keeps the commands a session offered and the effort levels it reported for `model`, the
|
||||
/// only model whose levels it describes.
|
||||
fn remember(
|
||||
&self,
|
||||
provider: &str,
|
||||
@@ -317,43 +308,22 @@ impl Shared {
|
||||
model: Option<&str>,
|
||||
) {
|
||||
let acp = self.spec(provider).is_some_and(|spec| spec.driver == provider::Driver::Acp);
|
||||
let mut cache = self.known.lock();
|
||||
let known = cache.entry(provider.to_owned()).or_default();
|
||||
let mut changed = false;
|
||||
// Running tasks retain their own reported settings. Once discovery has
|
||||
// succeeded, a session's older list/defaults cannot change New Task choices.
|
||||
if !known.authoritative
|
||||
&& let Some(config) = config.filter(|c| !c.is_empty())
|
||||
{
|
||||
if let Some(model) = model {
|
||||
let levels: Vec<_> = config.iter().filter(|o| config::is_per_model_option(o)).cloned().collect();
|
||||
if known.thought_levels.get(model) != Some(&levels) {
|
||||
known.thought_levels.insert(model.to_owned(), levels);
|
||||
changed = true;
|
||||
}
|
||||
}
|
||||
if known.config != config {
|
||||
known.config = config.to_vec();
|
||||
if let Some(commands) = commands.filter(|c| !c.is_empty()) {
|
||||
let mut cache = self.known.lock();
|
||||
let known = cache.entry(provider.to_owned()).or_default();
|
||||
if known.commands.get(&self.root_key()).map(Vec::as_slice) != Some(commands) {
|
||||
known.commands.insert(self.root_key(), commands.to_vec());
|
||||
self.persist_known(&cache);
|
||||
changed = true;
|
||||
}
|
||||
}
|
||||
// Discovery reads one model's options; a session on another model reports that model's.
|
||||
let learned = model.filter(|_| acp && known.authoritative).zip(config).map(|(model, config)| {
|
||||
if acp && let Some((model, config)) = model.zip(config) {
|
||||
let levels: Vec<_> = config.iter().filter(|o| config::is_per_model_option(o)).cloned().collect();
|
||||
(model, levels)
|
||||
});
|
||||
if let Some(commands) = commands.filter(|c| !c.is_empty())
|
||||
&& known.commands.get(&self.root_key()).map(Vec::as_slice) != Some(commands)
|
||||
{
|
||||
known.commands.insert(self.root_key(), commands.to_vec());
|
||||
changed = true;
|
||||
}
|
||||
if changed {
|
||||
self.persist_known(&cache);
|
||||
}
|
||||
drop(cache);
|
||||
if let Some((model, levels)) = learned.filter(|(_, levels)| !levels.is_empty()) {
|
||||
self.paths.catalogs.learn_levels(self, provider, model, levels);
|
||||
if !levels.is_empty() {
|
||||
self.paths.catalogs.learn_levels(self, provider, model, levels);
|
||||
}
|
||||
}
|
||||
if changed {
|
||||
self.emit(AgentEvent::Providers);
|
||||
@@ -2537,8 +2507,7 @@ impl Task {
|
||||
|
||||
async fn switch_discovered_model(&self, target: AgentConfigOption, value: String) -> IdeResult<()> {
|
||||
let provider = self.state.lock().task.provider.clone();
|
||||
let spec = self.shared.spec(&provider).ok_or_else(|| IdeError::not_found("no such agent"))?;
|
||||
let candidate = self.shared.paths.catalogs.fresh_model(&self.shared, &spec, &value).ok_or_else(|| {
|
||||
let candidate = self.shared.paths.catalogs.listed_model(&self.shared, &provider, &value).ok_or_else(|| {
|
||||
IdeError::invalid(format!("{} has no value {value} in the current model catalog", target.name))
|
||||
})?;
|
||||
let selection = {
|
||||
|
||||
@@ -711,6 +711,8 @@ pub struct AgentChange {
|
||||
pub removed: u32,
|
||||
/// Path before a rename; the left side of its diff reads this path.
|
||||
pub old_path: Option<String>,
|
||||
/// The repository the file is in, when the task's project holds nested repositories.
|
||||
pub repo: Option<IpcPath>,
|
||||
}
|
||||
|
||||
/// A commit made while the task ran, with the files it changed against its first parent.
|
||||
|
||||
@@ -1010,7 +1010,6 @@ async fn commands_are_remembered_per_project_and_merged_with_skills_on_disk() {
|
||||
// Another project shares the settings but not the commands.
|
||||
let mgr_b = manager_at(&b, &models, Arc::new(FakeAgent::default()));
|
||||
let claude = mgr_b.providers().into_iter().find(|p| p.id == "claude").unwrap();
|
||||
assert_eq!(claude.config.len(), 2);
|
||||
assert!(claude.commands.is_empty());
|
||||
assert!(mgr_b.commands("claude", None).await.unwrap().is_empty());
|
||||
let mgr_a = manager_at(&a, &models, Arc::new(FakeAgent::default()));
|
||||
@@ -1197,7 +1196,6 @@ async fn a_task_runs_asks_for_permission_and_survives_a_restart() {
|
||||
}
|
||||
let providers = mgr.providers();
|
||||
let claude = providers.iter().find(|p| p.id == "claude").unwrap();
|
||||
assert_eq!(claude.config.iter().map(|o| o.id.as_str()).collect::<Vec<_>>(), ["model", "mode"]);
|
||||
assert_eq!(claude.commands.len(), 1);
|
||||
|
||||
// A new manager (IDE restart) finds the task and resumes its session without duplicating history.
|
||||
@@ -1206,7 +1204,6 @@ async fn a_task_runs_asks_for_permission_and_survives_a_restart() {
|
||||
let mgr2 = manager(tmp.path(), agent2.clone());
|
||||
assert_eq!(mgr2.entries(&task.id, None).unwrap().len(), 5);
|
||||
assert_eq!(mgr2.task(&task.id).unwrap().state.lock().task.title, "Lexer fix");
|
||||
assert_eq!(mgr2.providers().iter().find(|p| p.id == "claude").unwrap().config.len(), 2);
|
||||
mgr2.prompt(&task.id, text("again"), false).await.unwrap();
|
||||
tokio::time::sleep(Duration::from_millis(50)).await;
|
||||
wait_for(&mgr2, &task.id, AgentStatus::Ready).await;
|
||||
@@ -2167,52 +2164,6 @@ async fn usage_limits_and_late_settings() {
|
||||
assert!(agent.calls.lock().iter().any(|c| c == "session/set_config_option \"high\""));
|
||||
let config = mgr.task(&task.id).unwrap().state.lock().task.config.clone();
|
||||
assert_eq!(config.iter().find(|o| o.id == "effort").unwrap().current.as_deref(), Some("high"));
|
||||
for _ in 0..100 {
|
||||
if mgr
|
||||
.shared
|
||||
.known
|
||||
.lock()
|
||||
.get("claude")
|
||||
.and_then(|k| k.thought_levels.get("big"))
|
||||
.and_then(|levels| levels.first())
|
||||
.and_then(|o| o.current.as_deref())
|
||||
== Some("high")
|
||||
{
|
||||
break;
|
||||
}
|
||||
tokio::time::sleep(Duration::from_millis(10)).await;
|
||||
}
|
||||
assert_eq!(mgr.shared.known.lock()["claude"].thought_levels["big"][0].current.as_deref(), Some("high"));
|
||||
}
|
||||
|
||||
#[tokio::test(flavor = "multi_thread")]
|
||||
async fn remembered_settings_drop_per_model_choices_for_the_next_task() {
|
||||
let tmp = tempfile::tempdir().unwrap();
|
||||
let agent = Arc::new(FakeAgent::default());
|
||||
// The effort list depends on the model: what the last session ran means nothing once
|
||||
// the user picks another model, so provider-wide defaults never include it.
|
||||
*agent.extra_options.lock() = vec![json!({"id": "effort", "category": "thought_level",
|
||||
"type": "select", "currentValue": "high",
|
||||
"options": [{"value": "low", "name": "Low"}, {"value": "high", "name": "High"}]})];
|
||||
let mgr = manager(tmp.path(), agent.clone());
|
||||
let task = mgr
|
||||
.create(NewAgentTask {
|
||||
project_root: None,
|
||||
prompt: text("again"),
|
||||
provider: "claude".into(),
|
||||
config: vec![],
|
||||
isolation: Isolation::Local,
|
||||
base: None,
|
||||
..Default::default()
|
||||
})
|
||||
.await
|
||||
.unwrap();
|
||||
wait_for(&mgr, &task.id, AgentStatus::Ready).await;
|
||||
|
||||
let provider = mgr.providers().into_iter().find(|p| p.id == "claude").unwrap();
|
||||
assert!(provider.config.iter().all(|o| o.id != "effort"), "a per-model option isn't offered stale");
|
||||
let model = provider.config.iter().find(|o| o.id == "model").unwrap();
|
||||
assert_eq!(model.current.as_deref(), Some("big"), "the model choice survives");
|
||||
}
|
||||
|
||||
fn effort_options(levels: &[&str], current: &str) -> Vec<Value> {
|
||||
@@ -2220,51 +2171,6 @@ fn effort_options(levels: &[&str], current: &str) -> Vec<Value> {
|
||||
"options": levels.iter().map(|v| json!({"value": v, "name": v})).collect::<Vec<_>>()})]
|
||||
}
|
||||
|
||||
#[tokio::test(flavor = "multi_thread")]
|
||||
async fn thinking_levels_are_remembered_per_provider_and_model() {
|
||||
let tmp = tempfile::tempdir().unwrap();
|
||||
let agent = Arc::new(FakeAgent::default());
|
||||
*agent.model_options.lock() = HashMap::from([
|
||||
("big".into(), effort_options(&["low", "high"], "high")),
|
||||
("small".into(), effort_options(&["minimal", "medium"], "minimal")),
|
||||
("plain".into(), vec![]),
|
||||
]);
|
||||
let mgr = manager(tmp.path(), agent.clone());
|
||||
let task = mgr
|
||||
.create(NewAgentTask {
|
||||
project_root: None,
|
||||
prompt: text("again"),
|
||||
provider: "claude".into(),
|
||||
config: vec![],
|
||||
isolation: Isolation::Local,
|
||||
base: None,
|
||||
..Default::default()
|
||||
})
|
||||
.await
|
||||
.unwrap();
|
||||
wait_for(&mgr, &task.id, AgentStatus::Ready).await;
|
||||
mgr.set_config(&task.id, "model", "small".into()).await.unwrap();
|
||||
mgr.set_config(&task.id, "effort", "medium".into()).await.unwrap();
|
||||
mgr.set_config(&task.id, "model", "plain".into()).await.unwrap();
|
||||
let p = mgr.providers().into_iter().find(|p| p.id == "claude").unwrap();
|
||||
let big = &p.thought_levels["big"][0];
|
||||
assert_eq!(big.current.as_deref(), Some("high"));
|
||||
assert_eq!(big.values.iter().map(|v| v.value.as_str()).collect::<Vec<_>>(), ["low", "high"]);
|
||||
let small = &p.thought_levels["small"][0];
|
||||
assert_eq!(small.current.as_deref(), Some("medium"));
|
||||
assert_eq!(small.values.iter().map(|v| v.value.as_str()).collect::<Vec<_>>(), ["minimal", "medium"]);
|
||||
assert!(p.thought_levels["plain"].is_empty());
|
||||
assert!(!p.thought_levels.contains_key("unknown"));
|
||||
assert!(mgr.providers().iter().find(|p| p.id == "codex").unwrap().thought_levels.is_empty());
|
||||
let saved: HashMap<String, Known> =
|
||||
serde_json::from_slice(&std::fs::read(&mgr.shared.paths.models_file).unwrap()).unwrap();
|
||||
assert_eq!(saved["claude"].thought_levels, p.thought_levels);
|
||||
mgr.shutdown();
|
||||
let restored = manager(tmp.path(), agent);
|
||||
assert_eq!(restored.providers().into_iter().find(|p| p.id == "claude").unwrap().thought_levels, p.thought_levels);
|
||||
restored.shutdown();
|
||||
}
|
||||
|
||||
#[tokio::test(flavor = "multi_thread")]
|
||||
async fn changing_an_idle_tasks_settings_keeps_its_models_effort_levels() {
|
||||
// Idle selections use cached model controls or discover them before the next prompt.
|
||||
@@ -2303,12 +2209,9 @@ async fn changing_an_idle_tasks_settings_keeps_its_models_effort_levels() {
|
||||
}
|
||||
restored.set_config(&task.id, "model", "big".into()).await.unwrap();
|
||||
restored.set_config(&task.id, option, value.into()).await.unwrap();
|
||||
let p = restored.providers().into_iter().find(|p| p.id == "claude-acp").unwrap();
|
||||
let big = p.thought_levels.get("big").and_then(|levels| levels.first());
|
||||
assert_eq!(big.map(|o| o.values.len()), Some(2), "{option}: {:?}", p.thought_levels);
|
||||
let saved: HashMap<String, Known> =
|
||||
serde_json::from_slice(&std::fs::read(&restored.shared.paths.models_file).unwrap()).unwrap();
|
||||
assert_eq!(saved["claude-acp"].thought_levels, p.thought_levels, "{option}");
|
||||
let levels = restored.shared.paths.catalogs.cached(&restored.shared, "claude-acp").thought_levels;
|
||||
let big = levels.get("big").and_then(|levels| levels.first());
|
||||
assert_eq!(big.map(|o| o.values.len()), Some(2), "{option}: {levels:?}");
|
||||
restored.shutdown();
|
||||
}
|
||||
}
|
||||
@@ -2541,100 +2444,6 @@ async fn upfront_effort_is_validated_after_changing_model_before_the_prompt() {
|
||||
}
|
||||
}
|
||||
|
||||
#[tokio::test(flavor = "multi_thread")]
|
||||
async fn unreported_model_switch_does_not_cache_the_previous_models_levels() {
|
||||
let tmp = tempfile::tempdir().unwrap();
|
||||
let agent = Arc::new(FakeAgent::default());
|
||||
*agent.extra_options.lock() = effort_options(&["low", "high"], "high");
|
||||
let mgr = manager(tmp.path(), agent);
|
||||
let task = mgr
|
||||
.create(NewAgentTask {
|
||||
project_root: None,
|
||||
prompt: text("again"),
|
||||
provider: "claude".into(),
|
||||
config: vec![],
|
||||
isolation: Isolation::Local,
|
||||
base: None,
|
||||
..Default::default()
|
||||
})
|
||||
.await
|
||||
.unwrap();
|
||||
wait_for(&mgr, &task.id, AgentStatus::Ready).await;
|
||||
mgr.set_config(&task.id, "model", "small".into()).await.unwrap();
|
||||
let p = mgr.providers().into_iter().find(|p| p.id == "claude").unwrap();
|
||||
assert!(!p.thought_levels.contains_key("small"));
|
||||
assert_eq!(p.thought_levels["big"][0].current.as_deref(), Some("high"));
|
||||
mgr.shutdown();
|
||||
}
|
||||
|
||||
#[tokio::test(flavor = "multi_thread")]
|
||||
async fn cached_effort_is_not_sent_without_real_session_options() {
|
||||
let tmp = tempfile::tempdir().unwrap();
|
||||
let agent = Arc::new(FakeAgent::default());
|
||||
*agent.extra_options.lock() = effort_options(&["low", "high"], "low");
|
||||
let mgr = manager(tmp.path(), agent.clone());
|
||||
let new = |config| NewAgentTask {
|
||||
project_root: None,
|
||||
prompt: text("again"),
|
||||
provider: "claude".into(),
|
||||
config,
|
||||
isolation: Isolation::Local,
|
||||
base: None,
|
||||
..Default::default()
|
||||
};
|
||||
let warm = mgr.create(new(vec![])).await.unwrap();
|
||||
wait_for(&mgr, &warm.id, AgentStatus::Ready).await;
|
||||
agent.calls.lock().clear();
|
||||
agent.empty_config.store(true, Ordering::Release);
|
||||
let task = mgr
|
||||
.create(new(vec![
|
||||
AgentConfigChoice { id: "model".into(), value: "big".into() },
|
||||
AgentConfigChoice { id: "effort".into(), value: "high".into() },
|
||||
]))
|
||||
.await
|
||||
.unwrap();
|
||||
wait_for(&mgr, &task.id, AgentStatus::Ready).await;
|
||||
assert!(!agent.calls.lock().iter().any(|c| c == "session/set_config_option \"high\""));
|
||||
assert!(
|
||||
mgr.task(&task.id).unwrap().state.lock().task.config.iter().any(|o| o.id == "effort"),
|
||||
"remembered session settings remain visible until the agent refreshes them"
|
||||
);
|
||||
mgr.shutdown();
|
||||
}
|
||||
|
||||
#[tokio::test(flavor = "multi_thread")]
|
||||
async fn reported_levels_refresh_even_without_a_model_option() {
|
||||
let tmp = tempfile::tempdir().unwrap();
|
||||
let agent = Arc::new(FakeAgent::default());
|
||||
*agent.extra_options.lock() = effort_options(&["low", "high"], "high");
|
||||
let mgr = manager(tmp.path(), agent.clone());
|
||||
let task = mgr
|
||||
.create(NewAgentTask {
|
||||
project_root: None,
|
||||
prompt: text("again"),
|
||||
provider: "claude".into(),
|
||||
config: vec![],
|
||||
isolation: Isolation::Local,
|
||||
base: None,
|
||||
..Default::default()
|
||||
})
|
||||
.await
|
||||
.unwrap();
|
||||
wait_for(&mgr, &task.id, AgentStatus::Ready).await;
|
||||
for levels in [effort_options(&["minimal", "medium"], "medium"), vec![]] {
|
||||
agent.update("s1", json!({"sessionUpdate": "config_option_update", "configOptions": levels}));
|
||||
let expected = config::parse_options(&json!(levels));
|
||||
for _ in 0..100 {
|
||||
if mgr.shared.known.lock()["claude"].thought_levels["big"] == expected {
|
||||
break;
|
||||
}
|
||||
tokio::time::sleep(Duration::from_millis(10)).await;
|
||||
}
|
||||
assert_eq!(mgr.shared.known.lock()["claude"].thought_levels["big"], expected);
|
||||
}
|
||||
mgr.shutdown();
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn retry_updates_become_a_countdown() {
|
||||
let update =
|
||||
@@ -3192,49 +3001,6 @@ async fn a_failed_probe_is_retried_instead_of_remembered() {
|
||||
assert!(!mgr.shared.probes.lock().contains_key("claude"));
|
||||
}
|
||||
|
||||
/// A session report that changes the cached provider config notifies subscribers,
|
||||
/// so the composer re-lists models without waiting for the next task (#1490).
|
||||
/// Reports that change nothing stay silent.
|
||||
#[tokio::test(flavor = "multi_thread")]
|
||||
async fn remembered_config_changes_notify_subscribers_once() {
|
||||
let tmp = tempfile::tempdir().unwrap();
|
||||
let mgr = manager(tmp.path(), Arc::new(FakeAgent::default()));
|
||||
let events = Arc::new(Mutex::new(Vec::new()));
|
||||
let sink = events.clone();
|
||||
mgr.subscribe(Arc::new(move |e| sink.lock().push(e)));
|
||||
events.lock().clear();
|
||||
|
||||
let reported = config::options_of(&json!({ "configOptions": [
|
||||
{ "id": "model", "category": "model", "type": "select", "currentValue": "default",
|
||||
"options": [{ "value": "default" }, { "value": "custom-opus" }] },
|
||||
] }));
|
||||
mgr.shared.remember("claude", Some(&reported), None, Some("default"));
|
||||
assert!(
|
||||
events.lock().iter().any(|ev| matches!(ev, AgentEvent::Providers)),
|
||||
"a first report changing the cache notifies subscribers"
|
||||
);
|
||||
events.lock().clear();
|
||||
|
||||
// The same report again: the cache is unchanged, so subscribers hear nothing.
|
||||
mgr.shared.remember("claude", Some(&reported), None, Some("default"));
|
||||
assert!(events.lock().is_empty(), "an unchanged report must stay silent");
|
||||
|
||||
// A changed model list notifies again, and providers() serves the new list.
|
||||
let updated = config::options_of(&json!({ "configOptions": [
|
||||
{ "id": "model", "category": "model", "type": "select", "currentValue": "default",
|
||||
"options": [{ "value": "default" }, { "value": "custom-opus" }, { "value": "custom-sonnet" }] },
|
||||
] }));
|
||||
mgr.shared.remember("claude", Some(&updated), None, Some("default"));
|
||||
assert!(
|
||||
events.lock().iter().any(|ev| matches!(ev, AgentEvent::Providers)),
|
||||
"a changed model list notifies subscribers"
|
||||
);
|
||||
let claude = mgr.providers().into_iter().find(|p| p.id == "claude").unwrap();
|
||||
let model = claude.config.iter().find(|o| o.category.as_deref() == Some("model")).unwrap();
|
||||
let values: Vec<_> = model.values.iter().map(|v| v.value.as_str()).collect();
|
||||
assert_eq!(values, ["default", "custom-opus", "custom-sonnet"]);
|
||||
}
|
||||
|
||||
#[tokio::test(flavor = "multi_thread")]
|
||||
async fn idle_agents_stop_and_resume_their_session_on_the_next_message() {
|
||||
let new = || NewAgentTask {
|
||||
@@ -3868,6 +3634,123 @@ async fn turn_changed(mgr: &AgentManager, id: &str) -> Vec<(String, ide_vcs::Cha
|
||||
changes.into_iter().map(|c| (c.rel_path, c.kind, c.added, c.removed)).collect()
|
||||
}
|
||||
|
||||
#[tokio::test(flavor = "multi_thread")]
|
||||
async fn a_task_lists_what_it_changed_in_a_nested_repository() {
|
||||
let tmp = tempfile::tempdir().unwrap();
|
||||
let base = dunce::canonicalize(tmp.path()).unwrap();
|
||||
let root = base.join("project");
|
||||
for repo in [root.clone(), root.join("libs/validation")] {
|
||||
std::fs::create_dir_all(&repo).unwrap();
|
||||
std::fs::write(repo.join("a.txt"), "one\n").unwrap();
|
||||
for args in [&["init", "-q", "-b", "main"][..], &["add", "a.txt"], &["commit", "-q", "-m", "init"]] {
|
||||
let ok = std::process::Command::new("git")
|
||||
.args(["-c", "user.name=t", "-c", "user.email=t@t", "-c", "commit.gpgsign=false"])
|
||||
.args(args)
|
||||
.current_dir(&repo)
|
||||
.status()
|
||||
.unwrap()
|
||||
.success();
|
||||
assert!(ok, "{args:?}");
|
||||
}
|
||||
}
|
||||
let mgr = manager(&base.join("ide"), Arc::new(FakeAgent::default()));
|
||||
let task = mgr
|
||||
.create(NewAgentTask {
|
||||
project_root: Some(IpcPath(root.clone())),
|
||||
prompt: text("Hello"),
|
||||
provider: "claude".into(),
|
||||
isolation: Isolation::Local,
|
||||
..Default::default()
|
||||
})
|
||||
.await
|
||||
.unwrap();
|
||||
one_turn(&mgr, &task.id, None, || {
|
||||
std::fs::write(root.join("a.txt"), "two\n").unwrap();
|
||||
std::fs::write(root.join("libs/validation/b.txt"), "new\n").unwrap();
|
||||
})
|
||||
.await;
|
||||
let changed: Vec<(String, Option<IpcPath>)> =
|
||||
mgr.changes(&task.id).await.unwrap().into_iter().map(|c| (c.rel_path, c.repo)).collect();
|
||||
assert_eq!(
|
||||
changed,
|
||||
[
|
||||
("a.txt".to_owned(), Some(IpcPath(root.clone()))),
|
||||
("libs/validation/b.txt".to_owned(), Some(IpcPath(root.join("libs/validation")))),
|
||||
]
|
||||
);
|
||||
mgr.rollback_changes(&task.id, None, AgentChangesView::SinceStart).await.unwrap();
|
||||
assert_eq!(std::fs::read_to_string(root.join("a.txt")).unwrap(), "one\n");
|
||||
assert!(!root.join("libs/validation/b.txt").exists());
|
||||
mgr.shutdown();
|
||||
}
|
||||
|
||||
#[tokio::test(flavor = "multi_thread")]
|
||||
async fn the_last_turn_of_a_task_spans_nested_repositories() {
|
||||
use ide_vcs::ChangeKind::{Added, Modified};
|
||||
let tmp = tempfile::tempdir().unwrap();
|
||||
let base = dunce::canonicalize(tmp.path()).unwrap();
|
||||
let root = base.join("project");
|
||||
let nested = root.join("libs/validation");
|
||||
let git = |repo: &Path, args: &[&str]| {
|
||||
let ok = std::process::Command::new("git")
|
||||
.args(["-c", "user.name=t", "-c", "user.email=t@t", "-c", "commit.gpgsign=false"])
|
||||
.args(args)
|
||||
.current_dir(repo)
|
||||
.status()
|
||||
.unwrap()
|
||||
.success();
|
||||
assert!(ok, "{args:?}");
|
||||
};
|
||||
for repo in [&root, &nested] {
|
||||
std::fs::create_dir_all(repo).unwrap();
|
||||
std::fs::write(repo.join("a.txt"), "one\n").unwrap();
|
||||
git(repo, &["init", "-q", "-b", "main"]);
|
||||
git(repo, &["add", "a.txt"]);
|
||||
git(repo, &["commit", "-q", "-m", "init"]);
|
||||
}
|
||||
let mgr = manager(&base.join("ide"), Arc::new(FakeAgent::default()));
|
||||
let task = mgr
|
||||
.create(NewAgentTask {
|
||||
project_root: Some(IpcPath(root.clone())),
|
||||
prompt: text("Hello"),
|
||||
provider: "claude".into(),
|
||||
isolation: Isolation::Local,
|
||||
..Default::default()
|
||||
})
|
||||
.await
|
||||
.unwrap();
|
||||
one_turn(&mgr, &task.id, None, || std::fs::write(root.join("a.txt"), "two\n").unwrap()).await;
|
||||
one_turn(&mgr, &task.id, Some("more"), || {
|
||||
std::fs::write(nested.join("a.txt"), "two\n").unwrap();
|
||||
std::fs::write(nested.join("b.txt"), "new\n").unwrap();
|
||||
// Committed in the nested repository: still the turn's.
|
||||
std::fs::write(nested.join("c.txt"), "committed\n").unwrap();
|
||||
git(&nested, &["add", "c.txt"]);
|
||||
git(&nested, &["commit", "-q", "-m", "c"]);
|
||||
})
|
||||
.await;
|
||||
|
||||
// Only the second turn's files, from the nested repository, named from the project.
|
||||
assert_eq!(
|
||||
turn_changed(&mgr, &task.id).await,
|
||||
[
|
||||
("libs/validation/a.txt".into(), Modified, 1, 1),
|
||||
("libs/validation/b.txt".into(), Added, 1, 0),
|
||||
("libs/validation/c.txt".into(), Added, 1, 0),
|
||||
]
|
||||
);
|
||||
let repos: Vec<_> = mgr.turn_changes(&task.id).await.unwrap().into_iter().map(|c| c.repo).collect();
|
||||
assert_eq!(repos, [Some(IpcPath(nested.clone())), Some(IpcPath(nested.clone())), Some(IpcPath(nested.clone()))]);
|
||||
let then = mgr.base_text(&task.id, nested.join("a.txt"), AgentChangesView::LastTurn).await.unwrap();
|
||||
assert_eq!(then.as_deref(), Some("one\n"));
|
||||
|
||||
mgr.rollback_changes(&task.id, None, AgentChangesView::LastTurn).await.unwrap();
|
||||
assert_eq!(std::fs::read_to_string(nested.join("a.txt")).unwrap(), "one\n");
|
||||
assert!(!nested.join("b.txt").exists());
|
||||
assert_eq!(std::fs::read_to_string(root.join("a.txt")).unwrap(), "two\n", "the first turn's change stays");
|
||||
mgr.shutdown();
|
||||
}
|
||||
|
||||
#[tokio::test(flavor = "multi_thread")]
|
||||
async fn the_last_turn_lists_and_rolls_back_only_its_own_changes() {
|
||||
use ide_vcs::ChangeKind::{Added, Deleted, Modified};
|
||||
|
||||
@@ -25,6 +25,98 @@ fn discover(path: &Path) -> IdeResult<Option<Repo>> {
|
||||
Ok(repo)
|
||||
}
|
||||
|
||||
/// The repositories of a project with nested ones (an own `.git` under the project root, not a
|
||||
/// submodule), with the folder their files are named from: the root of the repository holding
|
||||
/// `cwd`, else `cwd`. `None` when only the repository holding `cwd` (if any) is there.
|
||||
fn nested_repos(cwd: &Path) -> IdeResult<Option<(PathBuf, Vec<Repo>)>> {
|
||||
let Ok(cwd) = dunce::canonicalize(cwd) else { return Ok(None) };
|
||||
let found = ide_vcs::Repos::discover(&cwd, &|_| false)?;
|
||||
if found.all().iter().all(|r| cwd.starts_with(r.root())) {
|
||||
return Ok(None);
|
||||
}
|
||||
let base = found.all().iter().map(|r| r.root()).filter(|r| cwd.starts_with(r)).max().unwrap_or(&cwd).to_path_buf();
|
||||
let mut repos = Vec::new();
|
||||
for r in found.all() {
|
||||
repos.extend(discover(r.root())?);
|
||||
}
|
||||
Ok(Some((base, repos)))
|
||||
}
|
||||
|
||||
/// Whether the project at `cwd` holds repositories nested in it: its changes are each one's.
|
||||
pub(crate) fn spans_repos(cwd: &Path) -> bool {
|
||||
nested_repos(cwd).is_ok_and(|r| r.is_some())
|
||||
}
|
||||
|
||||
/// The repositories a turn's files are in, and the folder those files are named from.
|
||||
struct TurnRepos {
|
||||
base: PathBuf,
|
||||
repos: Vec<Repo>,
|
||||
/// The project holds nested repositories: each one's `HEAD` is recorded on its own.
|
||||
nested: bool,
|
||||
}
|
||||
|
||||
impl TurnRepos {
|
||||
fn of(cwd: &Path) -> IdeResult<Option<Self>> {
|
||||
if let Some((base, repos)) = nested_repos(cwd)? {
|
||||
return Ok(Some(Self { base, repos, nested: true }));
|
||||
}
|
||||
Ok(discover(cwd)?.map(|repo| Self { base: repo.root().to_path_buf(), repos: vec![repo], nested: false }))
|
||||
}
|
||||
|
||||
/// The innermost repository holding `path`.
|
||||
fn owner(&self, path: &Path) -> Option<&Repo> {
|
||||
self.repos.iter().filter(|r| path.starts_with(r.root())).max_by_key(|r| r.root().as_os_str().len())
|
||||
}
|
||||
|
||||
/// `repo`'s `HEAD` as the turn `start` began.
|
||||
fn head_then<'a>(&self, start: &'a TurnStart, repo: &Repo) -> Option<&'a str> {
|
||||
if self.nested { start.heads.get(&root_key(repo.root())) } else { start.head.as_ref() }.map(String::as_str)
|
||||
}
|
||||
}
|
||||
|
||||
fn root_key(root: &Path) -> String {
|
||||
root.to_string_lossy().into_owned()
|
||||
}
|
||||
|
||||
/// `path` as a task in `base` names it, if it is not in a repository nested below `repo` (that
|
||||
/// one lists it itself; to `repo` its folder is untracked).
|
||||
fn nested_rel(base: &Path, repo: &Repo, roots: &[PathBuf], path: &Path) -> Option<String> {
|
||||
let rel = path.strip_prefix(base).ok()?;
|
||||
if path.is_dir()
|
||||
|| roots.iter().any(|n| n.as_path() != repo.root() && n.starts_with(repo.root()) && path.starts_with(n))
|
||||
{
|
||||
return None;
|
||||
}
|
||||
Some(rel.to_string_lossy().replace('\\', "/"))
|
||||
}
|
||||
|
||||
/// The uncommitted changes in every repository of the project, against each one's `HEAD`.
|
||||
fn nested_changes(cwd: &Path) -> IdeResult<Vec<AgentChange>> {
|
||||
let Some((base, repos)) = nested_repos(cwd)? else { return Ok(Vec::new()) };
|
||||
let roots: Vec<PathBuf> = repos.iter().map(|r| r.root().to_path_buf()).collect();
|
||||
let mut out: Vec<AgentChange> = Vec::new();
|
||||
for repo in &repos {
|
||||
let listed = match repo.head()?.1 {
|
||||
Some(head) => changes(repo.root(), &head)?,
|
||||
None => {
|
||||
repo.status()?.into_iter().filter(|s| s.path.is_file()).map(|s| added(s.path, s.rel_path)).collect()
|
||||
}
|
||||
};
|
||||
for mut c in listed {
|
||||
let Some(rel) = nested_rel(&base, repo, &roots, &c.path.0) else { continue };
|
||||
if out.iter().any(|o| o.path == c.path) {
|
||||
continue;
|
||||
}
|
||||
c.rel_path = rel;
|
||||
c.old_path = None;
|
||||
c.repo = Some(IpcPath(repo.root().to_path_buf()));
|
||||
out.push(c);
|
||||
}
|
||||
}
|
||||
out.sort_by(|a, b| a.rel_path.cmp(&b.rel_path));
|
||||
Ok(out)
|
||||
}
|
||||
|
||||
fn repo_at(path: &Path) -> IdeResult<Repo> {
|
||||
discover(path)?.ok_or_else(|| IdeError::unavailable(format!("{} is not in a git repository", path.display())))
|
||||
}
|
||||
@@ -38,6 +130,9 @@ pub(crate) fn head_of(path: &Path) -> IdeResult<(String, String)> {
|
||||
|
||||
/// `HEAD`'s commit in `cwd`, `None` outside a repository or before its first commit.
|
||||
pub(crate) fn head_commit(cwd: &Path) -> IdeResult<Option<String>> {
|
||||
if spans_repos(cwd) {
|
||||
return Ok(Some("HEAD".to_owned()));
|
||||
}
|
||||
match discover(cwd)? {
|
||||
Some(repo) => Ok(repo.head()?.1),
|
||||
None => Ok(None),
|
||||
@@ -127,6 +222,7 @@ pub(crate) fn changes(cwd: &Path, base: &str) -> IdeResult<Vec<AgentChange>> {
|
||||
added,
|
||||
removed,
|
||||
old_path: f.old_path,
|
||||
repo: None,
|
||||
}
|
||||
})
|
||||
.collect();
|
||||
@@ -143,6 +239,9 @@ pub(crate) fn changes(cwd: &Path, base: &str) -> IdeResult<Vec<AgentChange>> {
|
||||
/// Files renamed since `rev`, by their new repository-relative path: the old path, as a deletion
|
||||
/// to roll back along with the rename.
|
||||
pub(crate) fn rename_sources(cwd: &Path, rev: &str) -> IdeResult<BTreeMap<String, AgentChange>> {
|
||||
if spans_repos(cwd) {
|
||||
return Ok(BTreeMap::new());
|
||||
}
|
||||
let Some(repo) = discover(cwd)? else { return Ok(BTreeMap::new()) };
|
||||
let root = repo.root().to_path_buf();
|
||||
Ok(repo
|
||||
@@ -157,6 +256,7 @@ pub(crate) fn rename_sources(cwd: &Path, rev: &str) -> IdeResult<BTreeMap<String
|
||||
added: 0,
|
||||
removed: 0,
|
||||
old_path: None,
|
||||
repo: None,
|
||||
};
|
||||
Some((f.path, source))
|
||||
})
|
||||
@@ -165,7 +265,7 @@ pub(crate) fn rename_sources(cwd: &Path, rev: &str) -> IdeResult<BTreeMap<String
|
||||
|
||||
fn added(path: IpcPath, rel_path: String) -> AgentChange {
|
||||
let added = std::fs::read_to_string(&*path).map_or(0, |t| t.lines().count() as u32);
|
||||
AgentChange { path, rel_path, kind: ChangeKind::Added, added, removed: 0, old_path: None }
|
||||
AgentChange { path, rel_path, kind: ChangeKind::Added, added, removed: 0, old_path: None, repo: None }
|
||||
}
|
||||
|
||||
/// The commits from `base` (exclusive) to `head` (inclusive) in `cwd`, newest first, each
|
||||
@@ -201,6 +301,7 @@ pub(crate) fn commits(cwd: &Path, base: &str, head: &str) -> IdeResult<Vec<Agent
|
||||
added,
|
||||
removed,
|
||||
old_path: f.old_path,
|
||||
repo: None,
|
||||
}
|
||||
})
|
||||
.collect();
|
||||
@@ -266,6 +367,9 @@ impl TaskBase {
|
||||
pub(crate) fn changes(&self, before: &BTreeMap<String, Stamp>) -> IdeResult<Vec<AgentChange>> {
|
||||
let (cwd, start) = match self {
|
||||
Self::Worktree { cwd, base } => return Ok(without_untouched(changes(cwd, base)?, before)),
|
||||
Self::Local { cwd, .. } if spans_repos(cwd) => {
|
||||
return Ok(without_untouched(nested_changes(cwd)?, before));
|
||||
}
|
||||
Self::Local { cwd, start } => (cwd, start.as_deref()),
|
||||
};
|
||||
let Some(repo) = discover(cwd)? else { return Ok(Vec::new()) };
|
||||
@@ -324,6 +428,9 @@ impl TaskBase {
|
||||
/// reads cannot put a file in both lists.
|
||||
pub(crate) fn grouped_changes(&self, before: &BTreeMap<String, Stamp>) -> IdeResult<AgentChanges> {
|
||||
let cwd = self.cwd();
|
||||
if spans_repos(cwd) {
|
||||
return Ok(AgentChanges { uncommitted: self.changes(before)?, commits: Vec::new() });
|
||||
}
|
||||
let Some(repo) = discover(cwd)? else { return Ok(AgentChanges::default()) };
|
||||
let head = repo.head()?.1;
|
||||
let uncommitted = match &head {
|
||||
@@ -353,6 +460,8 @@ impl TaskBase {
|
||||
pub(crate) fn rev(&self) -> IdeResult<Option<String>> {
|
||||
let (cwd, start) = match self {
|
||||
Self::Worktree { base, .. } => return Ok(Some(base.clone())),
|
||||
// Each repository goes back to its own `HEAD`.
|
||||
Self::Local { cwd, .. } if spans_repos(cwd) => return Ok(Some("HEAD".to_owned())),
|
||||
Self::Local { cwd, start } => (cwd, start.as_deref()),
|
||||
};
|
||||
let Some(repo) = discover(cwd)? else { return Ok(None) };
|
||||
@@ -545,6 +654,18 @@ pub(crate) fn stamp(path: &Path) -> Stamp {
|
||||
pub(crate) fn snapshot(cwd: &Path) -> IdeResult<BTreeMap<String, Stamp>> {
|
||||
// Paths and stamps only: no diff and no line counts, which read every untracked file
|
||||
// and held up starting a task in a checkout with many of them.
|
||||
if let Some((base, repos)) = nested_repos(cwd)? {
|
||||
let roots: Vec<PathBuf> = repos.iter().map(|r| r.root().to_path_buf()).collect();
|
||||
let mut out = BTreeMap::new();
|
||||
for repo in &repos {
|
||||
for s in repo.status()? {
|
||||
if let Some(rel) = nested_rel(&base, repo, &roots, &s.path) {
|
||||
out.insert(rel, stamp(&s.path));
|
||||
}
|
||||
}
|
||||
}
|
||||
return Ok(out);
|
||||
}
|
||||
let Some(repo) = Repo::discover(cwd)? else { return Ok(BTreeMap::new()) };
|
||||
Ok(repo.status()?.into_iter().map(|s| (s.rel_path, stamp(&s.path))).collect())
|
||||
}
|
||||
@@ -587,10 +708,16 @@ fn saved_name(rel: &str) -> String {
|
||||
/// into `dir`, so rolling back the task's changes to them restores the user's own edits.
|
||||
/// Whether anything was saved.
|
||||
pub(crate) fn save_before(cwd: &Path, before: &BTreeMap<String, Stamp>, dir: &Path) -> IdeResult<bool> {
|
||||
let Some(repo) = Repo::discover(cwd)? else { return Ok(false) };
|
||||
let root = match nested_repos(cwd)? {
|
||||
Some((base, _)) => base,
|
||||
None => match Repo::discover(cwd)? {
|
||||
Some(repo) => repo.root().to_path_buf(),
|
||||
None => return Ok(false),
|
||||
},
|
||||
};
|
||||
let mut saved = false;
|
||||
for (rel, stamp) in before {
|
||||
let path = repo.root().join(rel);
|
||||
let path = root.join(rel);
|
||||
if stamp.is_none() || !std::fs::metadata(&path).is_ok_and(|m| m.is_file() && m.len() <= SAVED_MAX) {
|
||||
continue;
|
||||
}
|
||||
@@ -625,7 +752,8 @@ pub(crate) fn restore(
|
||||
}
|
||||
None => match rev {
|
||||
Some(rev) => {
|
||||
let repo = Repo::discover(cwd)?.ok_or_else(|| IdeError::invalid("not in a git repository"))?;
|
||||
let at = change.repo.as_ref().map_or(cwd, |r| r.0.as_path());
|
||||
let repo = Repo::discover(at)?.ok_or_else(|| IdeError::invalid("not in a git repository"))?;
|
||||
repo.file_bytes_at(&change.path.0, Some(rev))?
|
||||
}
|
||||
None => None,
|
||||
@@ -665,6 +793,9 @@ pub(crate) struct TurnStart {
|
||||
/// `HEAD` then (`None` outside a repository or before its first commit).
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
pub head: Option<String>,
|
||||
/// With nested repositories, each one's `HEAD` then, by its root.
|
||||
#[serde(default, skip_serializing_if = "BTreeMap::is_empty")]
|
||||
pub heads: BTreeMap<String, String>,
|
||||
/// The files already changed then, stamped.
|
||||
#[serde(default, skip_serializing_if = "BTreeMap::is_empty")]
|
||||
pub before: BTreeMap<String, Stamp>,
|
||||
@@ -680,8 +811,16 @@ pub(crate) struct TurnStart {
|
||||
/// The copies `previous` saved of files unchanged since are kept rather than made again, so
|
||||
/// starting a turn copies little more than what the turn before it changed.
|
||||
pub(crate) fn start_turn(cwd: &Path, dir: &Path, previous: Option<&TurnStart>) -> IdeResult<TurnStart> {
|
||||
let Some(repo) = discover(cwd)? else { return Ok(TurnStart::default()) };
|
||||
let head = repo.head()?.1;
|
||||
let Some(at) = TurnRepos::of(cwd)? else { return Ok(TurnStart::default()) };
|
||||
let mut heads = BTreeMap::new();
|
||||
let head = if at.nested {
|
||||
for repo in &at.repos {
|
||||
heads.extend(repo.head()?.1.map(|h| (root_key(repo.root()), h)));
|
||||
}
|
||||
None
|
||||
} else {
|
||||
at.repos[0].head()?.1
|
||||
};
|
||||
// As the turn's end is read, so the two compare.
|
||||
let before = snapshot(cwd)?;
|
||||
let mut saved = BTreeSet::new();
|
||||
@@ -702,7 +841,7 @@ pub(crate) fn start_turn(cwd: &Path, dir: &Path, previous: Option<&TurnStart>) -
|
||||
}
|
||||
}
|
||||
for (rel, stamp) in &before {
|
||||
let path = repo.root().join(rel);
|
||||
let path = at.base.join(rel);
|
||||
if stamp.is_none()
|
||||
|| saved.contains(rel)
|
||||
|| !std::fs::metadata(&path).is_ok_and(|m| m.is_file() && m.len() <= SAVED_MAX)
|
||||
@@ -715,7 +854,7 @@ pub(crate) fn start_turn(cwd: &Path, dir: &Path, previous: Option<&TurnStart>) -
|
||||
saved.insert(rel.clone());
|
||||
}
|
||||
}
|
||||
Ok(TurnStart { head, before, saved, changed: None })
|
||||
Ok(TurnStart { head, heads, before, saved, changed: None })
|
||||
}
|
||||
|
||||
/// The files that changed in `cwd` since the turn `start` began: in the working tree (as
|
||||
@@ -724,20 +863,25 @@ pub(crate) fn changed_in_turn(cwd: &Path, start: &TurnStart) -> IdeResult<(Vec<S
|
||||
let end = snapshot(cwd)?;
|
||||
let worktree = changed_between(&start.before, &end);
|
||||
let mut all: BTreeSet<String> = worktree.iter().cloned().collect();
|
||||
if let Some(repo) = discover(cwd)?
|
||||
&& let (Some(from), Some(to)) = (&start.head, repo.head()?.1)
|
||||
&& *from != to
|
||||
{
|
||||
let Some(at) = TurnRepos::of(cwd)? else { return Ok((worktree, all)) };
|
||||
for repo in &at.repos {
|
||||
let (Some(from), Some(to)) = (at.head_then(start, repo), repo.head()?.1) else { continue };
|
||||
if from == to {
|
||||
continue;
|
||||
}
|
||||
// Named from the base, as the working tree's files are.
|
||||
let prefix = rel_in(&at.base, repo.root())?;
|
||||
let named = |rel: String| if prefix.is_empty() { rel } else { format!("{prefix}/{rel}") };
|
||||
for f in repo.diff_revisions(from, &to)? {
|
||||
all.extend(f.old_path);
|
||||
all.insert(f.path);
|
||||
all.extend(f.old_path.map(named));
|
||||
all.insert(named(f.path));
|
||||
}
|
||||
}
|
||||
Ok((worktree, all))
|
||||
}
|
||||
|
||||
/// The content of `rel` as the turn `start` began (`None`: no file), its copies in `dir`.
|
||||
fn at_turn_start(repo: &Repo, rel: &str, start: &TurnStart, dir: &Path) -> IdeResult<Option<Vec<u8>>> {
|
||||
fn at_turn_start(at: &TurnRepos, rel: &str, start: &TurnStart, dir: &Path) -> IdeResult<Option<Vec<u8>>> {
|
||||
match start.before.get(rel) {
|
||||
Some(None) => Ok(None),
|
||||
Some(Some(_)) => match start.saved.contains(rel).then(|| saved_copy(dir, rel)).flatten() {
|
||||
@@ -746,10 +890,13 @@ fn at_turn_start(repo: &Repo, rel: &str, start: &TurnStart, dir: &Path) -> IdeRe
|
||||
"{rel} had changes when the turn started that weren't saved; roll it back in Git instead"
|
||||
))),
|
||||
},
|
||||
None => match &start.head {
|
||||
Some(head) => repo.file_bytes_at(&repo.root().join(rel), Some(head)),
|
||||
None => Ok(None),
|
||||
},
|
||||
None => {
|
||||
let path = at.base.join(rel);
|
||||
match at.owner(&path).and_then(|repo| Some((repo, at.head_then(start, repo)?))) {
|
||||
Some((repo, head)) => repo.file_bytes_at(&path, Some(head)),
|
||||
None => Ok(None),
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -771,13 +918,13 @@ pub(crate) fn turn_changes(
|
||||
dir: &Path,
|
||||
changed: &BTreeSet<String>,
|
||||
) -> IdeResult<Vec<AgentChange>> {
|
||||
let Some(repo) = discover(cwd)? else { return Ok(Vec::new()) };
|
||||
let Some(at) = TurnRepos::of(cwd)? else { return Ok(Vec::new()) };
|
||||
let mut out = Vec::new();
|
||||
for rel in changed {
|
||||
let path = repo.root().join(rel);
|
||||
let path = at.base.join(rel);
|
||||
// A folder (a submodule, say) or a file that can't be read has nothing to compare.
|
||||
let Some(now) = existing(&path) else { continue };
|
||||
let (kind, (added, removed)) = match at_turn_start(&repo, rel, start, dir) {
|
||||
let (kind, (added, removed)) = match at_turn_start(&at, rel, start, dir) {
|
||||
Ok(then) if then == now => continue,
|
||||
Ok(then) => {
|
||||
let kind = match (&then, &now) {
|
||||
@@ -790,19 +937,29 @@ pub(crate) fn turn_changes(
|
||||
// Its start wasn't saved: listed, without counts.
|
||||
Err(_) => (ChangeKind::Modified, (0, 0)),
|
||||
};
|
||||
out.push(AgentChange { path: IpcPath(path), rel_path: rel.clone(), kind, added, removed, old_path: None });
|
||||
out.push(AgentChange {
|
||||
rel_path: rel.clone(),
|
||||
kind,
|
||||
added,
|
||||
removed,
|
||||
old_path: None,
|
||||
repo: at.nested.then(|| at.owner(&path).map(|r| IpcPath(r.root().to_path_buf()))).flatten(),
|
||||
path: IpcPath(path),
|
||||
});
|
||||
}
|
||||
Ok(out)
|
||||
}
|
||||
|
||||
/// The text of `path` as the turn `start` began, `None` when there was no file.
|
||||
pub(crate) fn turn_text(cwd: &Path, path: &Path, start: &TurnStart, dir: &Path) -> IdeResult<Option<String>> {
|
||||
let Some(repo) = discover(cwd)? else { return Ok(None) };
|
||||
let rel = rel_in(repo.root(), path)?;
|
||||
if let (None, Some(head)) = (start.before.get(&rel), &start.head) {
|
||||
let Some(at) = TurnRepos::of(cwd)? else { return Ok(None) };
|
||||
let rel = rel_in(&at.base, path)?;
|
||||
if !start.before.contains_key(&rel)
|
||||
&& let Some(head) = at.owner(&at.base.join(&rel)).and_then(|repo| at.head_then(start, repo))
|
||||
{
|
||||
return file_at(cwd, path, head);
|
||||
}
|
||||
let Some(bytes) = at_turn_start(&repo, &rel, start, dir)? else { return Ok(None) };
|
||||
let Some(bytes) = at_turn_start(&at, &rel, start, dir)? else { return Ok(None) };
|
||||
let encoding = match ide_vfs::load_text(path) {
|
||||
Ok(loaded) => encoding_rs::Encoding::for_label(loaded.encoding.as_bytes()).unwrap_or(encoding_rs::UTF_8),
|
||||
Err(_) => ide_vfs::detect_encoding(&bytes, None),
|
||||
@@ -828,12 +985,15 @@ fn rel_in(root: &Path, path: &Path) -> IdeResult<String> {
|
||||
|
||||
/// Puts `change` back as it was when the turn `start` began.
|
||||
pub(crate) fn restore_turn(cwd: &Path, start: &TurnStart, dir: &Path, change: &AgentChange) -> IdeResult<()> {
|
||||
let repo = repo_at(cwd)?;
|
||||
put(&change.path.0, at_turn_start(&repo, &change.rel_path, start, dir)?)
|
||||
let at = TurnRepos::of(cwd)?
|
||||
.ok_or_else(|| IdeError::unavailable(format!("{} is not in a git repository", cwd.display())))?;
|
||||
put(&change.path.0, at_turn_start(&at, &change.rel_path, start, dir)?)
|
||||
}
|
||||
|
||||
pub(crate) fn file_at(cwd: &Path, path: &Path, rev: &str) -> IdeResult<Option<String>> {
|
||||
let Some(repo) = discover(cwd)? else { return Ok(None) };
|
||||
// With nested repositories, the file's own one.
|
||||
let at = if spans_repos(cwd) { path.parent().unwrap_or(cwd) } else { cwd };
|
||||
let Some(repo) = discover(at)? else { return Ok(None) };
|
||||
let encoding = match ide_vfs::load_text(path) {
|
||||
Ok(loaded) => encoding_rs::Encoding::for_label(loaded.encoding.as_bytes()).unwrap_or(encoding_rs::UTF_8),
|
||||
Err(_) => ide_vfs::detect_encoding(&repo.file_bytes_at(path, Some(rev))?.unwrap_or_default(), None),
|
||||
@@ -962,6 +1122,54 @@ mod tests {
|
||||
assert!(ok, "git {args:?}");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_project_with_nested_repositories_sees_changes_in_each_one() {
|
||||
let tmp = tempfile::tempdir().unwrap();
|
||||
let root = dunce::canonicalize(tmp.path()).unwrap();
|
||||
let (nested, deeper) = (root.join("libs/validation"), root.join("libs/validation/pkg/sdk"));
|
||||
for repo in [&root, &nested, &deeper] {
|
||||
std::fs::create_dir_all(repo).unwrap();
|
||||
git(repo, &["init", "-q", "-b", "main"]);
|
||||
std::fs::write(repo.join("a.txt"), "one\n").unwrap();
|
||||
git(repo, &["add", "a.txt"]);
|
||||
git(repo, &["commit", "-q", "-m", "init"]);
|
||||
}
|
||||
assert!(spans_repos(&root));
|
||||
std::fs::write(root.join("mine.txt"), "the user's\n").unwrap();
|
||||
let before = snapshot(&root).unwrap();
|
||||
assert_eq!(before.keys().collect::<Vec<_>>(), ["mine.txt"]);
|
||||
|
||||
std::fs::write(root.join("a.txt"), "two\n").unwrap();
|
||||
std::fs::write(nested.join("a.txt"), "two\n").unwrap();
|
||||
std::fs::write(nested.join("b.txt"), "new\n").unwrap();
|
||||
std::fs::write(deeper.join("a.txt"), "two\n").unwrap();
|
||||
let at = TaskBase::Local { cwd: root.clone(), start: None };
|
||||
let changed = at.changes(&before).unwrap();
|
||||
let listed: Vec<(&str, &Path)> =
|
||||
changed.iter().map(|c| (c.rel_path.as_str(), c.repo.as_ref().unwrap().0.as_path())).collect();
|
||||
assert_eq!(
|
||||
listed,
|
||||
[
|
||||
("a.txt", root.as_path()),
|
||||
("libs/validation/a.txt", nested.as_path()),
|
||||
("libs/validation/b.txt", nested.as_path()),
|
||||
("libs/validation/pkg/sdk/a.txt", deeper.as_path()),
|
||||
]
|
||||
);
|
||||
assert_eq!(at.grouped_changes(&before).unwrap().uncommitted.len(), 4);
|
||||
assert_eq!(file_at(&root, &nested.join("a.txt"), "HEAD").unwrap().as_deref(), Some("one\n"));
|
||||
|
||||
let rev = at.rev().unwrap();
|
||||
for change in &changed {
|
||||
restore(&root, rev.as_deref(), change, &before, None).unwrap();
|
||||
}
|
||||
for repo in [&root, &nested, &deeper] {
|
||||
assert_eq!(std::fs::read_to_string(repo.join("a.txt")).unwrap(), "one\n");
|
||||
}
|
||||
assert!(!nested.join("b.txt").exists());
|
||||
assert!(root.join("mine.txt").exists(), "the user's own change stays");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn worktree_changes_are_listed_against_the_base() {
|
||||
let tmp = tempfile::tempdir().unwrap();
|
||||
|
||||
@@ -0,0 +1,90 @@
|
||||
//! Exception breakpoints on a chosen class. The manager keeps one list; a session given a backend
|
||||
//! for them at start arms it before `configurationDone`, so a throw in the program's first line
|
||||
//! stops, and again after each `setExceptionBreakpoints`, which drops them in java-debug.
|
||||
|
||||
use crate::session::Session;
|
||||
use crate::{DebugManager, jvm_memory};
|
||||
use ide_jvm_inspect::ExceptionClassSpec;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use specta::Type;
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize, Type)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct ExceptionClassBreakpoint {
|
||||
pub id: String,
|
||||
/// Fully qualified binary name (`com.acme.Outer$Inner`); its subclasses stop too.
|
||||
pub class_name: String,
|
||||
pub caught: bool,
|
||||
pub uncaught: bool,
|
||||
pub enabled: bool,
|
||||
/// Patterns (`com.acme.*`, `*Test`, a full name) for the class whose code throws.
|
||||
pub class_filters: Vec<String>,
|
||||
pub class_exclusion_filters: Vec<String>,
|
||||
}
|
||||
|
||||
/// What a session's exception class breakpoints can do.
|
||||
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize, Type)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct ExceptionClassSupport {
|
||||
/// Whose class names the session takes: `java`.
|
||||
pub family: String,
|
||||
pub condition: bool,
|
||||
pub class_filters: bool,
|
||||
/// Filters on the class whose code catches the exception.
|
||||
pub catch_filters: bool,
|
||||
}
|
||||
|
||||
/// The JVM backends stop through java-debug's own exception events, which a condition or a
|
||||
/// catch-location filter cannot veto.
|
||||
pub(crate) fn support(s: &Session) -> Option<ExceptionClassSupport> {
|
||||
s.exception_classes.is_some().then(|| ExceptionClassSupport {
|
||||
family: "java".into(),
|
||||
condition: false,
|
||||
class_filters: true,
|
||||
catch_filters: false,
|
||||
})
|
||||
}
|
||||
|
||||
fn spec(b: &ExceptionClassBreakpoint) -> ExceptionClassSpec {
|
||||
ExceptionClassSpec {
|
||||
id: b.id.clone(),
|
||||
class_name: b.class_name.clone(),
|
||||
caught: b.caught,
|
||||
uncaught: b.uncaught,
|
||||
enabled: b.enabled,
|
||||
class_filters: b.class_filters.clone(),
|
||||
class_exclusion_filters: b.class_exclusion_filters.clone(),
|
||||
}
|
||||
}
|
||||
|
||||
impl DebugManager {
|
||||
/// Arms the manager's list in `s`; the caller holds `s.exception_turn`. `clear`: also when the
|
||||
/// list is empty, to take down what an earlier list armed.
|
||||
pub(crate) async fn arm_exception_classes(&self, s: &Session, clear: bool) {
|
||||
let Some(backend) = &s.exception_classes else { return };
|
||||
let specs: Vec<_> = self.exception_classes.lock().iter().map(spec).collect();
|
||||
// Without either, no VM is known yet: `configure` arms once it is.
|
||||
let target = jvm_memory::vm_target(s);
|
||||
if (specs.is_empty() && !clear) || (target.pid.is_none() && target.attach_port.is_none()) {
|
||||
return;
|
||||
}
|
||||
match backend.set(&target, &specs).await {
|
||||
Ok(states) => tracing::debug!("exception class breakpoints of session {}: {states:?}", s.id.0),
|
||||
Err(e) => tracing::debug!("exception class breakpoints of session {} failed: {e}", s.id.0),
|
||||
}
|
||||
}
|
||||
|
||||
/// Stores exception breakpoints on chosen classes (kept without a session, armed on start)
|
||||
/// and arms them in every session that takes them. Also in one still starting: one that has
|
||||
/// armed already would miss the list, and one that has not answers `vmNotFound` until then.
|
||||
pub async fn set_exception_class_breakpoints(&self, list: Vec<ExceptionClassBreakpoint>) {
|
||||
*self.exception_classes.lock() = list;
|
||||
for s in self.live_sessions() {
|
||||
if s.exception_classes.is_none() || s.conn.is_closed() {
|
||||
continue;
|
||||
}
|
||||
let _turn = s.exception_turn.lock().await;
|
||||
self.arm_exception_classes(&s, true).await;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -12,6 +12,7 @@ pub mod adapter;
|
||||
pub mod attach;
|
||||
mod cargo;
|
||||
pub mod connection;
|
||||
mod exception_classes;
|
||||
pub mod jdwp;
|
||||
mod js_cdp;
|
||||
mod js_debug;
|
||||
@@ -24,6 +25,7 @@ pub mod unity;
|
||||
|
||||
use adapter::{AdapterLauncher, AdapterSpec, ProcessLauncher};
|
||||
use connection::{Connection, DapError};
|
||||
pub use exception_classes::{ExceptionClassBreakpoint, ExceptionClassSupport};
|
||||
use futures::future::join_all;
|
||||
use ide_core::{DebugSessionId, IdeError, IdeResult, SharedSink};
|
||||
use ide_language::LanguageRegistry;
|
||||
@@ -283,6 +285,8 @@ pub struct SessionExceptionFilters {
|
||||
pub session: DebugSessionId,
|
||||
pub adapter: String,
|
||||
pub filters: Vec<ExceptionFilter>,
|
||||
/// Set when the session takes exception breakpoints on a chosen class.
|
||||
pub classes: Option<ExceptionClassSupport>,
|
||||
}
|
||||
|
||||
/// What triggered a hot reload; `flutter debug_adapter` takes it as `reason`.
|
||||
@@ -336,6 +340,7 @@ pub struct DebugManager {
|
||||
states: Mutex<HashMap<PathBuf, Vec<BreakpointState>>>,
|
||||
/// Explicit exception filter choices (filter id → enabled); unset filters use the adapter default.
|
||||
exception_choices: Mutex<BTreeMap<String, bool>>,
|
||||
exception_classes: Mutex<Vec<ExceptionClassBreakpoint>>,
|
||||
function_breakpoints: Mutex<Vec<FunctionBreakpoint>>,
|
||||
data_breakpoints: Mutex<Vec<DataBreakpoint>>,
|
||||
/// In-flight stops, by session: a second Stop sets `stop_force`, the waiting one kills.
|
||||
@@ -788,6 +793,7 @@ impl DebugManager {
|
||||
breakpoints: Mutex::default(),
|
||||
states: Mutex::default(),
|
||||
exception_choices: Mutex::default(),
|
||||
exception_classes: Mutex::default(),
|
||||
function_breakpoints: Mutex::default(),
|
||||
data_breakpoints: Mutex::default(),
|
||||
stopping: Mutex::default(),
|
||||
@@ -836,6 +842,18 @@ impl DebugManager {
|
||||
config: LaunchConfig,
|
||||
owner: SessionOwner,
|
||||
custom_command: impl FnOnce(&str) -> Option<String>,
|
||||
) -> IdeResult<DebugSessionId> {
|
||||
self.start_with_exception_classes(config, owner, custom_command, None).await
|
||||
}
|
||||
|
||||
/// [`start_with`](Self::start_with), the session arming [`Self::set_exception_class_breakpoints`]
|
||||
/// through `exception_classes`.
|
||||
pub async fn start_with_exception_classes(
|
||||
&self,
|
||||
config: LaunchConfig,
|
||||
owner: SessionOwner,
|
||||
custom_command: impl FnOnce(&str) -> Option<String>,
|
||||
exception_classes: Option<Arc<dyn ide_jvm_inspect::ExceptionClassBreakpoints>>,
|
||||
) -> IdeResult<DebugSessionId> {
|
||||
let mut arguments = launch_arguments(&config)?;
|
||||
// An IDE-side marker (never sent to the adapter): the session is a Flutter
|
||||
@@ -977,7 +995,19 @@ impl DebugManager {
|
||||
}
|
||||
}
|
||||
let port = debug_server.map(|s| s.port);
|
||||
self.start_session(id, owner, config.name, config.adapter, None, config.request, arguments, spec, port).await
|
||||
self.start_session(
|
||||
id,
|
||||
owner,
|
||||
config.name,
|
||||
config.adapter,
|
||||
None,
|
||||
config.request,
|
||||
arguments,
|
||||
spec,
|
||||
port,
|
||||
exception_classes,
|
||||
)
|
||||
.await
|
||||
}
|
||||
|
||||
/// `startDebugging` reverse request: a child session on the same adapter.
|
||||
@@ -1002,6 +1032,7 @@ impl DebugManager {
|
||||
configuration,
|
||||
parent.spec.clone(),
|
||||
parent.port,
|
||||
None,
|
||||
)
|
||||
.await
|
||||
.map(|_| ())
|
||||
@@ -1019,6 +1050,7 @@ impl DebugManager {
|
||||
arguments: Value,
|
||||
spec: AdapterSpec,
|
||||
reuse_port: Option<u16>,
|
||||
exception_classes: Option<Arc<dyn ide_jvm_inspect::ExceptionClassBreakpoints>>,
|
||||
) -> IdeResult<DebugSessionId> {
|
||||
if request != "launch" && request != "attach" {
|
||||
return Err(IdeError::invalid(format!("request must be `launch` or `attach`, got `{request}`")));
|
||||
@@ -1033,8 +1065,9 @@ impl DebugManager {
|
||||
let rdbg_pid = (adapter_name == "rdbg" && request == "launch")
|
||||
.then(|| io.child.as_ref().and_then(tokio::process::Child::id))
|
||||
.flatten();
|
||||
let session =
|
||||
Arc::new(Session::new(id, owner, name, adapter_name, parent, request, conn, spec, io.port, io.child));
|
||||
let mut session = Session::new(id, owner, name, adapter_name, parent, request, conn, spec, io.port, io.child);
|
||||
session.exception_classes = exception_classes;
|
||||
let session = Arc::new(session);
|
||||
if let Some(launch_type) = arguments.get("type").and_then(Value::as_str) {
|
||||
let _ = session.launch_type.set(launch_type.to_owned());
|
||||
}
|
||||
@@ -1259,8 +1292,12 @@ impl DebugManager {
|
||||
tracing::debug!("setDataBreakpoints failed: {e}");
|
||||
}
|
||||
let has_filters = s.caps.lock().get("exceptionBreakpointFilters").and_then(Value::as_array).is_some();
|
||||
if has_filters {
|
||||
let _ = self.send_exception_breakpoints(s).await;
|
||||
{
|
||||
let _turn = s.exception_turn.lock().await;
|
||||
if has_filters {
|
||||
let _ = self.send_exception_breakpoints(s).await;
|
||||
}
|
||||
self.arm_exception_classes(s, false).await;
|
||||
}
|
||||
if s.supports("supportsConfigurationDoneRequest") {
|
||||
if s.adapter == kotlin::ADAPTER {
|
||||
@@ -1481,6 +1518,7 @@ impl DebugManager {
|
||||
session: s.id,
|
||||
adapter: s.adapter.clone(),
|
||||
filters: exception_filters_from(&s.caps.lock()),
|
||||
classes: exception_classes::support(s),
|
||||
})
|
||||
.collect()
|
||||
}
|
||||
@@ -1496,9 +1534,11 @@ impl DebugManager {
|
||||
if exception_filters_from(&s.caps.lock()).is_empty() {
|
||||
continue;
|
||||
}
|
||||
let _turn = s.exception_turn.lock().await;
|
||||
if let Err(e) = self.send_exception_breakpoints(&s).await {
|
||||
tracing::debug!("setExceptionBreakpoints on session {} failed: {e}", s.id.0);
|
||||
}
|
||||
self.arm_exception_classes(&s, false).await;
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -118,6 +118,11 @@ pub(crate) struct Session {
|
||||
pub kotlin_mirror: Mutex<Option<crate::kotlin::SourceMirror>>,
|
||||
pub jvm_memory: tokio::sync::Mutex<crate::JvmMemoryState>,
|
||||
pub stream_tracer: parking_lot::Mutex<Option<Arc<dyn ide_jvm_inspect::StreamTracer>>>,
|
||||
/// Given at start: the class breakpoints must be armed before `configurationDone`.
|
||||
pub(crate) exception_classes: Option<Arc<dyn ide_jvm_inspect::ExceptionClassBreakpoints>>,
|
||||
/// Held from `setExceptionBreakpoints`, which drops the class breakpoints, until they are
|
||||
/// armed again, so that the last list armed is the manager's.
|
||||
pub(crate) exception_turn: tokio::sync::Mutex<()>,
|
||||
pub(crate) stream_trace: parking_lot::Mutex<Option<crate::stream_trace::ActiveTrace>>,
|
||||
/// The last trace that finished, until the stop its records were read in ends.
|
||||
pub(crate) stream_trace_done: parking_lot::Mutex<Option<crate::stream_trace::DoneTrace>>,
|
||||
@@ -286,6 +291,8 @@ impl Session {
|
||||
kotlin_mirror: Mutex::new(None),
|
||||
jvm_memory: tokio::sync::Mutex::default(),
|
||||
stream_tracer: parking_lot::Mutex::new(None),
|
||||
exception_classes: None,
|
||||
exception_turn: tokio::sync::Mutex::default(),
|
||||
stream_trace: parking_lot::Mutex::new(None),
|
||||
stream_trace_done: parking_lot::Mutex::new(None),
|
||||
quirks: kotlin_lsp::Quirks::default(),
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
//! Protocol flow against an in-memory fake adapter.
|
||||
|
||||
mod exception_classes;
|
||||
mod jvm_inspect;
|
||||
mod stream_trace;
|
||||
|
||||
|
||||
@@ -0,0 +1,154 @@
|
||||
//! Exception breakpoints on a chosen class, armed through a session's backend.
|
||||
|
||||
use super::*;
|
||||
use ide_jvm_inspect::{ExceptionArmState, ExceptionClassBreakpoints, ExceptionClassSpec, InspectFuture, VmTarget};
|
||||
|
||||
/// The target, the list, and the DAP requests sent before it.
|
||||
type ArmCall = (VmTarget, Vec<ExceptionClassSpec>, Vec<String>);
|
||||
|
||||
/// Records each list it is given with the DAP requests sent before it.
|
||||
struct FakeArmer {
|
||||
log: Log,
|
||||
calls: Mutex<Vec<ArmCall>>,
|
||||
}
|
||||
|
||||
impl FakeArmer {
|
||||
fn new(h: &Harness) -> Arc<Self> {
|
||||
Arc::new(Self { log: h.log.clone(), calls: Mutex::default() })
|
||||
}
|
||||
|
||||
fn lists(&self) -> Vec<Vec<String>> {
|
||||
self.calls.lock().iter().map(|(_, specs, _)| specs.iter().map(|s| s.class_name.clone()).collect()).collect()
|
||||
}
|
||||
|
||||
/// The DAP requests sent before each call.
|
||||
fn before(&self) -> Vec<Vec<String>> {
|
||||
self.calls.lock().iter().map(|(_, _, sent)| sent.clone()).collect()
|
||||
}
|
||||
}
|
||||
|
||||
impl ExceptionClassBreakpoints for FakeArmer {
|
||||
fn set<'a>(
|
||||
&'a self,
|
||||
target: &'a VmTarget,
|
||||
breakpoints: &'a [ExceptionClassSpec],
|
||||
) -> InspectFuture<'a, Vec<(String, ExceptionArmState)>> {
|
||||
let sent = self
|
||||
.log
|
||||
.lock()
|
||||
.iter()
|
||||
.filter(|m| m["type"] == "request")
|
||||
.map(|m| m["command"].as_str().unwrap().to_owned())
|
||||
.collect();
|
||||
self.calls.lock().push((target.clone(), breakpoints.to_vec(), sent));
|
||||
let states = breakpoints.iter().map(|b| (b.id.clone(), ExceptionArmState::Armed)).collect();
|
||||
Box::pin(async move { Ok(states) })
|
||||
}
|
||||
}
|
||||
|
||||
fn class_bp(id: &str, class_name: &str) -> ExceptionClassBreakpoint {
|
||||
ExceptionClassBreakpoint {
|
||||
id: id.into(),
|
||||
class_name: class_name.into(),
|
||||
caught: true,
|
||||
uncaught: true,
|
||||
enabled: true,
|
||||
class_filters: vec![],
|
||||
class_exclusion_filters: vec![],
|
||||
}
|
||||
}
|
||||
|
||||
/// A java-debug attach to a JVM on another machine: the target is known from the request alone.
|
||||
fn attach() -> LaunchConfig {
|
||||
LaunchConfig {
|
||||
extra_json: Some(json!({"hostName": "10.0.0.5", "port": 5005}).to_string()),
|
||||
..java_config("attach")
|
||||
}
|
||||
}
|
||||
|
||||
async fn start(h: &Harness, config: LaunchConfig, armer: &Arc<FakeArmer>) -> DebugSessionId {
|
||||
let backend: Arc<dyn ExceptionClassBreakpoints> = armer.clone();
|
||||
h.manager.start_with_exception_classes(config, h.owner.clone(), |_| None, Some(backend)).await.unwrap()
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn armed_after_the_exception_filters_and_before_configuration_done() {
|
||||
let h = harness(Script::default());
|
||||
let armer = FakeArmer::new(&h);
|
||||
let filtered = ExceptionClassBreakpoint {
|
||||
caught: false,
|
||||
enabled: false,
|
||||
class_filters: vec!["com.acme.*".into()],
|
||||
class_exclusion_filters: vec!["*Test".into()],
|
||||
..class_bp("b", "com.acme.Boom")
|
||||
};
|
||||
h.manager.set_exception_class_breakpoints(vec![class_bp("a", "java.lang.IllegalStateException"), filtered]).await;
|
||||
start(&h, attach(), &armer).await;
|
||||
|
||||
assert_eq!(armer.before(), [["initialize", "attach", "setExceptionBreakpoints"]]);
|
||||
let (target, specs, _) = armer.calls.lock()[0].clone();
|
||||
assert_eq!((target.pid, target.attach_host.as_deref(), target.attach_port), (None, Some("10.0.0.5"), Some(5005)));
|
||||
assert_eq!(
|
||||
specs[1],
|
||||
ExceptionClassSpec {
|
||||
id: "b".into(),
|
||||
class_name: "com.acme.Boom".into(),
|
||||
caught: false,
|
||||
uncaught: true,
|
||||
enabled: false,
|
||||
class_filters: vec!["com.acme.*".into()],
|
||||
class_exclusion_filters: vec!["*Test".into()],
|
||||
}
|
||||
);
|
||||
assert!(h.commands().contains(&"configurationDone".to_owned()));
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn armed_again_after_every_set_exception_breakpoints() {
|
||||
let h = harness(Script::default());
|
||||
let armer = FakeArmer::new(&h);
|
||||
h.manager.set_exception_class_breakpoints(vec![class_bp("a", "com.acme.Boom")]).await;
|
||||
start(&h, attach(), &armer).await;
|
||||
h.manager.set_exception_breakpoints(BTreeMap::from([("raised".into(), true)])).await.unwrap();
|
||||
|
||||
assert_eq!(armer.lists(), [["com.acme.Boom"], ["com.acme.Boom"]]);
|
||||
let last = armer.before().pop().unwrap();
|
||||
assert_eq!(last.iter().filter(|c| *c == "setExceptionBreakpoints").count(), 2, "{last:?}");
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn a_new_list_reaches_the_sessions_that_take_it() {
|
||||
let h = harness(Script::default());
|
||||
let armer = FakeArmer::new(&h);
|
||||
start(&h, attach(), &armer).await;
|
||||
let other = h.start(attach()).await.unwrap();
|
||||
assert!(armer.lists().is_empty(), "nothing to arm at start");
|
||||
|
||||
h.manager.set_exception_class_breakpoints(vec![class_bp("a", "com.acme.Boom")]).await;
|
||||
h.manager.set_exception_class_breakpoints(vec![]).await;
|
||||
assert_eq!(armer.lists(), [vec!["com.acme.Boom".to_owned()], vec![]], "an empty list takes them down");
|
||||
|
||||
let filters = h.manager.exception_filters(None);
|
||||
let support = |id| filters.iter().find(|f| f.session == id).unwrap().classes.clone();
|
||||
assert_eq!(support(other), None);
|
||||
let java = filters.iter().find(|f| f.session != other).unwrap().session;
|
||||
assert_eq!(
|
||||
support(java),
|
||||
Some(ExceptionClassSupport {
|
||||
family: "java".into(),
|
||||
condition: false,
|
||||
class_filters: true,
|
||||
catch_filters: false
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn nothing_is_sent_before_the_jvm_is_known() {
|
||||
let h = harness(Script::default());
|
||||
let armer = FakeArmer::new(&h);
|
||||
h.manager.set_exception_class_breakpoints(vec![class_bp("a", "com.acme.Boom")]).await;
|
||||
// The fake adapter sends no `process` event before `configurationDone`: no pid to name.
|
||||
start(&h, java_config("launch"), &armer).await;
|
||||
assert!(armer.lists().is_empty());
|
||||
}
|
||||
@@ -2,6 +2,7 @@
|
||||
//! remote server ([`crate::rpc`]). `db_export_file` stays in the desktop
|
||||
//! shell: its path comes from a local save dialog, so the export must land
|
||||
//! on the user's machine, not the side the project runs on.
|
||||
use super::Channel;
|
||||
use crate::Host;
|
||||
use ide_command::command;
|
||||
use ide_core::{IdeError, IdeResult, IpcPath, RequestId};
|
||||
@@ -24,6 +25,14 @@ pub struct StatementOutcome {
|
||||
pub error: Option<String>,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Type)]
|
||||
#[serde(tag = "type", rename_all = "camelCase")]
|
||||
pub enum ExecutionEvent {
|
||||
Started { index: u32 },
|
||||
Completed { index: u32, outcome: StatementOutcome },
|
||||
Done { error: Option<IdeError> },
|
||||
}
|
||||
|
||||
#[command(trust = trusted)]
|
||||
pub fn db_approve_jdbc_source(host: &Host, window: &str, source: DataSource) -> IdeResult<()> {
|
||||
host.project(window)?.db.approve_jdbc_source(&source)
|
||||
@@ -357,36 +366,79 @@ pub async fn db_execute(
|
||||
max_rows: u32,
|
||||
schema: Option<String>,
|
||||
) -> IdeResult<Vec<StatementOutcome>> {
|
||||
// Runs `statements` in order on data source `id`, stopping at the first
|
||||
// error. Each result reads past its first `skip` rows (a later page) and keeps
|
||||
// `max_rows`. `schema` is the console's active context: the connection running
|
||||
// each statement is put in it first. Cancel with `cancel_request(request)`.
|
||||
let mut outcomes = Vec::new();
|
||||
execute_statements(host, window, request, &id, statements, skip, max_rows, schema.as_deref(), |event| {
|
||||
if let ExecutionEvent::Completed { outcome, .. } = event {
|
||||
outcomes.push(outcome);
|
||||
}
|
||||
Ok(())
|
||||
})
|
||||
.await?;
|
||||
Ok(outcomes)
|
||||
}
|
||||
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
#[command(trust = trusted)]
|
||||
pub async fn db_execute_stream(
|
||||
host: &Host,
|
||||
window: &str,
|
||||
request: RequestId,
|
||||
id: String,
|
||||
statements: Vec<SqlStatement>,
|
||||
max_rows: u32,
|
||||
schema: Option<String>,
|
||||
on_progress: Channel<ExecutionEvent>,
|
||||
) -> IdeResult<()> {
|
||||
let result = execute_statements(host, window, request, &id, statements, 0, max_rows, schema.as_deref(), |event| {
|
||||
on_progress.send(event)
|
||||
})
|
||||
.await;
|
||||
// The invocation reply can reach the viewer before a large result frame.
|
||||
on_progress.send(ExecutionEvent::Done { error: result.err() })
|
||||
}
|
||||
|
||||
/// Runs in order on one request and stops on cancellation or the first error.
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
async fn execute_statements(
|
||||
host: &Host,
|
||||
window: &str,
|
||||
request: RequestId,
|
||||
id: &str,
|
||||
statements: Vec<SqlStatement>,
|
||||
skip: u32,
|
||||
max_rows: u32,
|
||||
schema: Option<&str>,
|
||||
mut emit: impl FnMut(ExecutionEvent) -> IdeResult<()>,
|
||||
) -> IdeResult<()> {
|
||||
let db = host.project(window)?.db.clone();
|
||||
let cancel = host.begin_request(request);
|
||||
let mut out = Vec::new();
|
||||
for statement in statements {
|
||||
match db
|
||||
.execute_from(&id, &statement.text, skip as usize, max_rows.max(1) as usize, &cancel, schema.as_deref())
|
||||
.await
|
||||
{
|
||||
Ok(result) => out.push(StatementOutcome { statement, result: Some(result), error: None }),
|
||||
Err(e) if e.kind == ide_core::error::ErrorKind::Cancelled => {
|
||||
host.end_request(request);
|
||||
return Err(e);
|
||||
let result = async {
|
||||
for (index, statement) in statements.into_iter().enumerate() {
|
||||
if cancel.is_cancelled() {
|
||||
return Err(IdeError::cancelled());
|
||||
}
|
||||
Err(e) if e.kind == ide_core::error::ErrorKind::PermissionDenied && out.is_empty() => {
|
||||
// Not connected for lack of a password: the UI asks and retries.
|
||||
host.end_request(request);
|
||||
return Err(e);
|
||||
}
|
||||
Err(e) => {
|
||||
out.push(StatementOutcome { statement, result: None, error: Some(e.message) });
|
||||
emit(ExecutionEvent::Started { index: index as u32 })?;
|
||||
let outcome = match db
|
||||
.execute_from(id, &statement.text, skip as usize, max_rows.max(1) as usize, &cancel, schema)
|
||||
.await
|
||||
{
|
||||
Ok(result) => StatementOutcome { statement, result: Some(result), error: None },
|
||||
Err(e) if e.kind == ide_core::error::ErrorKind::Cancelled => return Err(e),
|
||||
// The UI may retry a login failure only before any statement has completed.
|
||||
Err(e) if e.kind == ide_core::error::ErrorKind::PermissionDenied && index == 0 => return Err(e),
|
||||
Err(e) => StatementOutcome { statement, result: None, error: Some(e.message) },
|
||||
};
|
||||
let failed = outcome.error.is_some();
|
||||
emit(ExecutionEvent::Completed { index: index as u32, outcome })?;
|
||||
if failed {
|
||||
break;
|
||||
}
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
.await;
|
||||
host.end_request(request);
|
||||
Ok(out)
|
||||
result
|
||||
}
|
||||
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
@@ -539,6 +591,7 @@ ide_command::domain!(
|
||||
db_disconnect,
|
||||
db_drop_database,
|
||||
db_execute,
|
||||
db_execute_stream,
|
||||
db_explain,
|
||||
db_finish_transaction,
|
||||
db_history,
|
||||
@@ -567,3 +620,69 @@ ide_command::domain!(
|
||||
db_test_tunnel,
|
||||
db_trust_ssh_host,
|
||||
);
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use crate::HostConfig;
|
||||
use ide_db::DbDriver;
|
||||
use std::sync::Arc;
|
||||
|
||||
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
|
||||
async fn a_reporting_error_stops_the_batch_and_releases_the_request() {
|
||||
let temp = tempfile::tempdir().unwrap();
|
||||
let base = dunce::canonicalize(temp.path()).unwrap();
|
||||
let root = base.join("project");
|
||||
std::fs::create_dir(&root).unwrap();
|
||||
let host = Host::new(HostConfig {
|
||||
config_dir: base.join("config"),
|
||||
data_dir: base.join("data"),
|
||||
local_data_dir: base.join("local"),
|
||||
languages: Arc::new(ide_language::LanguageRegistry::load(None).unwrap()),
|
||||
syntax: Arc::default(),
|
||||
sink_for: Box::new(|_| Arc::new(|_| {})),
|
||||
owner: |w| w,
|
||||
runtime: tokio::runtime::Handle::current(),
|
||||
project_environment: false,
|
||||
});
|
||||
let window = "main";
|
||||
host.open_project(window, &root).unwrap();
|
||||
host.set_project_trust(&root, true, false).await.unwrap();
|
||||
let id = "test";
|
||||
let file = root.join("test.sqlite");
|
||||
std::fs::File::create(&file).unwrap();
|
||||
db_save_sources(
|
||||
&host,
|
||||
window,
|
||||
vec![DataSource { id: id.into(), name: id.into(), file: Some(file.into()), ..Default::default() }],
|
||||
)
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let statements =
|
||||
ide_db::split::split("CREATE TABLE items (n INTEGER); INSERT INTO items VALUES (1);", DbDriver::Sqlite);
|
||||
let request = RequestId(1);
|
||||
let error = execute_statements(&host, window, request, id, statements, 0, 10, None, |event| match event {
|
||||
ExecutionEvent::Started { index: 0 } => Ok(()),
|
||||
ExecutionEvent::Completed { index: 0, outcome } => {
|
||||
assert!(outcome.error.is_none(), "{:?}", outcome.error);
|
||||
Err(IdeError::internal("cannot report result"))
|
||||
}
|
||||
_ => panic!("the failed callback must stop execution"),
|
||||
})
|
||||
.await
|
||||
.unwrap_err();
|
||||
assert_eq!(error.message, "cannot report result");
|
||||
|
||||
// After cleanup, cancel is remembered for the next request with this id.
|
||||
host.cancel_request(request);
|
||||
assert!(host.begin_request(request).is_cancelled());
|
||||
|
||||
let query = ide_db::split::split(
|
||||
"SELECT 99 AS n UNION ALL SELECT count(*) FROM items ORDER BY n DESC",
|
||||
DbDriver::Sqlite,
|
||||
);
|
||||
let outcomes = db_execute(&host, window, RequestId(2), id.into(), query, 1, 10, None).await.unwrap();
|
||||
assert_eq!(outcomes[0].result.as_ref().unwrap().rows, vec![vec![Some("0".into())]]);
|
||||
}
|
||||
}
|
||||
@@ -129,7 +129,8 @@ pub async fn debug_start(host: &Host, window: &str, config: LaunchConfig) -> Ide
|
||||
};
|
||||
host.require_trust(window)?;
|
||||
let server_port = debug_server_port(&config);
|
||||
let result = host.debugger.start_with(config, owner, custom).await;
|
||||
let exception_classes = server_port.and_then(|port| exception_class_backend(host, window, port));
|
||||
let result = host.debugger.start_with_exception_classes(config, owner, custom, exception_classes).await;
|
||||
flush_output();
|
||||
if let Ok(id) = &result {
|
||||
let sink = host.window_sink(label);
|
||||
@@ -208,6 +209,18 @@ fn attach_jvm_inspector(host: &Host, window: &str, session: DebugSessionId, port
|
||||
}
|
||||
}
|
||||
|
||||
/// Given before the session starts, unlike the inspector: the breakpoints are armed before
|
||||
/// `configurationDone`, so a throw in `main`'s first line stops.
|
||||
fn exception_class_backend(
|
||||
host: &Host,
|
||||
window: &str,
|
||||
port: u16,
|
||||
) -> Option<std::sync::Arc<dyn ide_jvm_inspect::ExceptionClassBreakpoints>> {
|
||||
let project = host.project(window).ok()?;
|
||||
let module = project.lsp.java_debug_server_module(port)?;
|
||||
Some(std::sync::Arc::new(ide_lsp::JdtExceptionBreakpoints::new(project.lsp.clone(), module)))
|
||||
}
|
||||
|
||||
/// A JVM the debugger starts itself: an Application or Spring Boot configuration, launched by
|
||||
/// java-debug, java-analyzer or the Kotlin debugger (JAR Application debugs through a run with a
|
||||
/// JDWP agent).
|
||||
@@ -453,6 +466,16 @@ pub async fn debug_set_exception_breakpoints(
|
||||
host.debugger.set_exception_breakpoints(choices).await
|
||||
}
|
||||
|
||||
/// Exception breakpoints on chosen classes (all sessions that take them, and later ones).
|
||||
#[command(trust = trusted)]
|
||||
pub async fn debug_set_exception_class_breakpoints(
|
||||
host: &Host,
|
||||
breakpoints: Vec<ExceptionClassBreakpoint>,
|
||||
) -> IdeResult<()> {
|
||||
host.debugger.set_exception_class_breakpoints(breakpoints).await;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
#[command(trust = trusted)]
|
||||
pub async fn debug_set_variable(
|
||||
@@ -849,6 +872,7 @@ ide_command::domain!(
|
||||
debug_set_breakpoints,
|
||||
debug_set_data_breakpoints,
|
||||
debug_set_exception_breakpoints,
|
||||
debug_set_exception_class_breakpoints,
|
||||
debug_set_function_breakpoints,
|
||||
debug_set_variable,
|
||||
debug_stack_trace,
|
||||
|
||||
@@ -301,19 +301,30 @@ fn finish_launch(
|
||||
// The module/project JDK, else the JDK the Java language server builds the module with, else one
|
||||
// matching its Java version.
|
||||
let project_jdk = ide_sdk::apply::module_jdk(root, module, settings);
|
||||
let from_server = info.java_home.as_deref().map(ide_sdk::java::java_executable).filter(|p| p.is_file());
|
||||
let java = project_jdk.map(|j| ide_sdk::java::java_executable(&j.home)).or(from_server).or_else(|| {
|
||||
// The build model's level includes what the module inherits from its parent POMs.
|
||||
let release = model
|
||||
// The build model's level includes what the module inherits from its parent POMs.
|
||||
let release = || {
|
||||
model
|
||||
.maven
|
||||
.as_ref()
|
||||
.and_then(|m| m.projects.iter().find(|p| root.join(&p.dir) == module))
|
||||
.and_then(|p| p.java_version)
|
||||
.or_else(|| ide_sdk::java::project_java_version(module));
|
||||
let jdks = ide_sdk::java::installed_jdks();
|
||||
info.hints.extend(ide_sdk::java::missing_jdk_message(&jdks, release));
|
||||
ide_sdk::java::pick_jdk(&jdks, release).map(|j| ide_sdk::java::java_executable(&j.home))
|
||||
});
|
||||
.or_else(|| ide_sdk::java::project_java_version(module))
|
||||
};
|
||||
let java = match project_jdk {
|
||||
Some(j) => Some(ide_sdk::java::java_executable(&j.home)),
|
||||
None => {
|
||||
let release = release();
|
||||
let server = info.java_home.as_deref().and_then(|home| server_java(home, release));
|
||||
match server {
|
||||
Some(java) => Some(java),
|
||||
None => {
|
||||
let jdks = ide_sdk::java::installed_jdks();
|
||||
info.hints.extend(ide_sdk::java::missing_jdk_message(&jdks, release));
|
||||
ide_sdk::java::pick_jdk(&jdks, release).map(|j| ide_sdk::java::java_executable(&j.home))
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
info.java_exec = Some(java.map(|p| p.to_string_lossy().into_owned()).unwrap_or_else(|| "java".to_owned()));
|
||||
let exec = PathBuf::from(info.java_exec.as_deref().unwrap_or("java"));
|
||||
let shorten = ide_run::java_cmdline::shortening_for(&exec, &info.class_paths, &info.module_paths, cfg!(windows));
|
||||
@@ -328,6 +339,19 @@ fn finish_launch(
|
||||
}
|
||||
}
|
||||
|
||||
/// The `java` of the JDK a Java language server reports, when it can run classes compiled for
|
||||
/// `release`: that JDK is the one the server runs on or defaults to, not necessarily one the
|
||||
/// module's bytecode loads on. A home whose version is unknown is used only when `release` is too.
|
||||
fn server_java(home: &Path, release: Option<u32>) -> Option<PathBuf> {
|
||||
match ide_sdk::java::jdk_at(home) {
|
||||
Some(jdk) if release.is_none_or(|release| jdk.major >= release) => {
|
||||
Some(ide_sdk::java::java_executable(&jdk.home))
|
||||
}
|
||||
Some(_) => None,
|
||||
None => Some(ide_sdk::java::java_executable(home)).filter(|java| release.is_none() && java.is_file()),
|
||||
}
|
||||
}
|
||||
|
||||
/// With Settings › Maven › Delegate IDE build/run actions to Maven, javac's verdict replaces
|
||||
/// JDT's. Classes JDT wrote for sources with errors look up to date to Maven's incremental
|
||||
/// compiler, so a launch JDT reports errors for recompiles everything.
|
||||
@@ -557,6 +581,38 @@ fn drop_processor_recreate_errors(info: &mut JavaLaunchInfo) {
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
fn fake_jdk(dir: &Path, version: Option<&str>) -> PathBuf {
|
||||
let bin = dir.join("bin");
|
||||
std::fs::create_dir_all(&bin).unwrap();
|
||||
std::fs::write(bin.join(if cfg!(windows) { "java.exe" } else { "java" }), "").unwrap();
|
||||
if let Some(version) = version {
|
||||
std::fs::write(dir.join("release"), format!("JAVA_VERSION=\"{version}\"\n")).unwrap();
|
||||
}
|
||||
dir.to_path_buf()
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_server_jdk_older_than_the_module_release_is_not_used() {
|
||||
let tmp = tempfile::tempdir().unwrap();
|
||||
let jdk17 = fake_jdk(&tmp.path().join("17"), Some("17.0.12"));
|
||||
let jdk21 = fake_jdk(&tmp.path().join("21"), Some("21.0.4"));
|
||||
let unknown = fake_jdk(&tmp.path().join("unknown"), None);
|
||||
// (server JDK, module release, used?)
|
||||
let cases = [
|
||||
(&jdk17, Some(21), false),
|
||||
(&jdk17, Some(17), true),
|
||||
(&jdk17, Some(11), true),
|
||||
(&jdk17, None, true),
|
||||
(&jdk21, Some(21), true),
|
||||
(&unknown, None, true),
|
||||
(&unknown, Some(21), false),
|
||||
];
|
||||
for (home, release, used) in cases {
|
||||
assert_eq!(server_java(home, release).is_some(), used, "{} for release {release:?}", home.display());
|
||||
}
|
||||
assert!(server_java(&tmp.path().join("missing"), None).is_none());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn recognises_a_processor_recreating_its_output() {
|
||||
assert!(processor_recreated_a_file(
|
||||
|
||||
@@ -3059,6 +3059,10 @@ impl HostApi for PluginApi {
|
||||
dunce::canonicalize(files).map_err(failed)
|
||||
}
|
||||
|
||||
fn install_dir(&self) -> Result<PathBuf, HostError> {
|
||||
dunce::canonicalize(&self.pkg.dir).map_err(failed)
|
||||
}
|
||||
|
||||
fn read_text_file(&self, real: &Path, max: usize) -> Result<String, HostError> {
|
||||
// Unsaved editor contents win, as they do for project files.
|
||||
if let Some(text) = self.shared.workspace().and_then(|w| w.buffer_text(real)) {
|
||||
@@ -3749,6 +3753,19 @@ mod tests {
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn install_dir_is_the_canonical_package_directory() {
|
||||
let tmp = tempfile::tempdir().unwrap();
|
||||
let pkg = tmp.path().join("acme.lint");
|
||||
std::fs::create_dir_all(&pkg).unwrap();
|
||||
std::fs::write(pkg.join("readme.pdf"), b"%PDF").unwrap();
|
||||
let api = api(&pkg, Arc::default());
|
||||
let install = api.install_dir().unwrap();
|
||||
assert_eq!(install, dunce::canonicalize(&pkg).unwrap());
|
||||
assert!(install.join("readme.pdf").is_file());
|
||||
assert_ne!(install, api.plugin_dir().unwrap());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn storage_moves_an_older_storage_json_to_one_file_per_key() {
|
||||
let tmp = tempfile::tempdir().unwrap();
|
||||
|
||||
@@ -6,15 +6,21 @@ use serde_json::json;
|
||||
use std::path::Path;
|
||||
use std::sync::Arc;
|
||||
|
||||
/// Codex's modes as it reported them last time, in "ask".
|
||||
fn remember_codex_modes(data: &Path) {
|
||||
/// Codex's modes as its catalog for `root` listed them last time, in "ask".
|
||||
fn remember_codex_modes(data: &Path, root: &Path) {
|
||||
std::fs::create_dir_all(data.join("agents")).unwrap();
|
||||
let modes = json!({ "codex": { "config": [ {
|
||||
let config = json!([ {
|
||||
"id": "mode", "name": "Mode", "description": null, "category": "mode", "current": "ask",
|
||||
"values": [ { "value": "read-only", "name": "Read Only", "description": null },
|
||||
{ "value": "ask", "name": "Ask", "description": null },
|
||||
{ "value": "full-access", "name": "Full Access", "description": null } ],
|
||||
"via": "option" } ] } });
|
||||
"via": "option" } ]);
|
||||
let mut catalogs = serde_json::Map::new();
|
||||
catalogs.insert(
|
||||
root.to_string_lossy().into_owned(),
|
||||
json!({ "fingerprint": "test", "config": config, "thoughtLevels": {} }),
|
||||
);
|
||||
let modes = json!({ "codex": { "projectCatalogs": catalogs } });
|
||||
std::fs::write(data.join("agents/models.json"), modes.to_string()).unwrap();
|
||||
}
|
||||
|
||||
@@ -30,7 +36,7 @@ async fn new_tasks_start_asking_for_approval_when_the_user_chose_so() {
|
||||
let root = dunce::canonicalize(tmp.path()).unwrap().join("project");
|
||||
std::fs::create_dir_all(root.join(".openidea")).unwrap();
|
||||
let (config, data) = (tmp.path().join("config"), tmp.path().join("data"));
|
||||
remember_codex_modes(&data);
|
||||
remember_codex_modes(&data, &root);
|
||||
std::fs::create_dir_all(&config).unwrap();
|
||||
std::fs::write(config.join("settings.toml"), "[agents]\nnewTaskApprovals = \"ask\"\n").unwrap();
|
||||
// A project's own settings don't choose this.
|
||||
|
||||
@@ -128,6 +128,44 @@ async fn serves_projects_files_documents_search_and_runs() {
|
||||
let current = invoke(&peer, "project_current", json!({})).await.unwrap();
|
||||
assert_eq!(current["name"], "demo");
|
||||
|
||||
// A SQL batch sends each outcome precisely once before the request reply.
|
||||
let file = project.join("test.sqlite");
|
||||
std::fs::File::create(&file).unwrap();
|
||||
let source = ide_db::DataSource {
|
||||
id: "test-db".into(),
|
||||
name: "Test database".into(),
|
||||
file: Some(file.into()),
|
||||
..Default::default()
|
||||
};
|
||||
invoke(&peer, "db_save_sources", json!({ "sources": [source] })).await.unwrap();
|
||||
let sql = "SELECT 1 AS n; SELECT 'second' AS n";
|
||||
let statements =
|
||||
invoke(&peer, "db_statements", json!({ "id": "test-db", "text": sql, "from": 0, "to": sql.len() }))
|
||||
.await
|
||||
.unwrap();
|
||||
let done = invoke(
|
||||
&peer,
|
||||
"db_execute_stream",
|
||||
json!({ "request": 21, "id": "test-db", "statements": statements, "maxRows": 10,
|
||||
"schema": null, "onProgress": { "$channel": 521 } }),
|
||||
)
|
||||
.await
|
||||
.unwrap();
|
||||
assert!(done.is_null());
|
||||
let events = client
|
||||
.channels
|
||||
.lock()
|
||||
.iter()
|
||||
.filter(|frame| frame.id == 521)
|
||||
.map(|frame| frame.data.clone())
|
||||
.collect::<Vec<_>>();
|
||||
assert_eq!(events.len(), 5);
|
||||
assert_eq!(events[0], json!({ "type": "started", "index": 0 }));
|
||||
assert_eq!(events[1]["outcome"]["result"]["rows"], json!([["1"]]));
|
||||
assert_eq!(events[2], json!({ "type": "started", "index": 1 }));
|
||||
assert_eq!(events[3]["outcome"]["result"]["rows"], json!([["second"]]));
|
||||
assert_eq!(events[4], json!({ "type": "done", "error": null }));
|
||||
|
||||
// The built-in web server runs where the project is; the client forwards its port.
|
||||
let root = std::path::PathBuf::from(opened["root"].as_str().unwrap());
|
||||
let url = invoke(&peer, "web_url", json!({ "path": root.join("src/main.py") })).await.unwrap();
|
||||
|
||||
@@ -0,0 +1,41 @@
|
||||
//! Exception breakpoints on a chosen class, armed inside the debuggee's VM by the debugger's own
|
||||
//! connection. The adapter stops on them as on its own exception filters.
|
||||
|
||||
use crate::{InspectFuture, VmTarget};
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct ExceptionClassSpec {
|
||||
/// Echoed back with the breakpoint's state.
|
||||
pub id: String,
|
||||
/// Binary name (`com.acme.Outer$Inner`); subclasses stop too.
|
||||
pub class_name: String,
|
||||
pub caught: bool,
|
||||
pub uncaught: bool,
|
||||
pub enabled: bool,
|
||||
/// JDI class patterns (`com.acme.*`, `*Test`) matched against the class whose code throws.
|
||||
pub class_filters: Vec<String>,
|
||||
pub class_exclusion_filters: Vec<String>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub enum ExceptionArmState {
|
||||
Armed,
|
||||
/// No class of that name is loaded yet; it is armed when one is.
|
||||
Pending,
|
||||
Disabled,
|
||||
/// A stream trace silences the VM's breakpoints; applied when it ends.
|
||||
Deferred,
|
||||
}
|
||||
|
||||
pub trait ExceptionClassBreakpoints: Send + Sync {
|
||||
/// Replaces the VM's whole list; `(id, state)` per breakpoint, in order. The adapter can drop
|
||||
/// these whenever it sets its own exception filters, so set them again after each time.
|
||||
fn set<'a>(
|
||||
&'a self,
|
||||
target: &'a VmTarget,
|
||||
breakpoints: &'a [ExceptionClassSpec],
|
||||
) -> InspectFuture<'a, Vec<(String, ExceptionArmState)>>;
|
||||
}
|
||||
@@ -1,9 +1,11 @@
|
||||
//! Types and the [`JvmInspector`] trait for reading live JVM objects while a debug session is
|
||||
//! suspended. Implementations live elsewhere (jdtls bundle for Java, JDWP link for Kotlin).
|
||||
|
||||
mod exceptions;
|
||||
mod names;
|
||||
mod stream;
|
||||
|
||||
pub use exceptions::{ExceptionArmState, ExceptionClassBreakpoints, ExceptionClassSpec};
|
||||
pub use names::{is_boxed, name_to_signature, signature_to_name, string_length};
|
||||
pub use stream::{AbortState, CollectedTerminal, StreamTracer, TraceCollected, TraceId, TraceState};
|
||||
|
||||
|
||||
@@ -20,6 +20,7 @@ pub(crate) const SERVER: &str = "jdtls";
|
||||
const GENERATED_SOURCES: &str = "openidea.java.generatedSources";
|
||||
|
||||
pub(crate) mod configuration;
|
||||
pub(crate) mod exception_breakpoints;
|
||||
mod extract_interface;
|
||||
mod formatter;
|
||||
mod generated;
|
||||
|
||||
@@ -0,0 +1,56 @@
|
||||
//! [`ExceptionClassBreakpoints`] over `openidea.jvm.exceptions.set` of the JVM inspector bundle that
|
||||
//! runs inside jdtls (`java/jvm-inspect`).
|
||||
|
||||
use super::jvm_inspect::{command_error, decode, target_json};
|
||||
use crate::LspManager;
|
||||
use ide_jvm_inspect::{
|
||||
ExceptionArmState, ExceptionClassBreakpoints, ExceptionClassSpec, InspectError, InspectFuture, VmTarget,
|
||||
};
|
||||
use serde::Deserialize;
|
||||
use serde_json::json;
|
||||
use std::path::PathBuf;
|
||||
use std::sync::Arc;
|
||||
use std::time::Duration;
|
||||
use tokio::time::timeout;
|
||||
|
||||
/// The bundle waits for the inspect commands' turn, which a `classes` on a large heap can hold.
|
||||
const COMMAND_TIMEOUT: Duration = Duration::from_secs(30);
|
||||
|
||||
pub struct JdtExceptionBreakpoints {
|
||||
lsp: Arc<LspManager>,
|
||||
/// A path inside the module whose jdtls runs the debug session.
|
||||
server: PathBuf,
|
||||
}
|
||||
|
||||
impl JdtExceptionBreakpoints {
|
||||
pub fn new(lsp: Arc<LspManager>, server: PathBuf) -> Self {
|
||||
Self { lsp, server }
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Deserialize)]
|
||||
struct WireState {
|
||||
id: String,
|
||||
state: ExceptionArmState,
|
||||
}
|
||||
|
||||
impl ExceptionClassBreakpoints for JdtExceptionBreakpoints {
|
||||
fn set<'a>(
|
||||
&'a self,
|
||||
target: &'a VmTarget,
|
||||
breakpoints: &'a [ExceptionClassSpec],
|
||||
) -> InspectFuture<'a, Vec<(String, ExceptionArmState)>> {
|
||||
Box::pin(async move {
|
||||
let arguments = vec![target_json(target), json!({ "breakpoints": breakpoints })];
|
||||
let reply = timeout(
|
||||
COMMAND_TIMEOUT,
|
||||
self.lsp.jdtls_command(&self.server, "openidea.jvm.exceptions.set", arguments),
|
||||
)
|
||||
.await
|
||||
.map_err(|_| InspectError::TimedOut)?
|
||||
.map_err(command_error)?;
|
||||
let states: Vec<WireState> = decode(reply)?;
|
||||
Ok(states.into_iter().map(|s| (s.id, s.state)).collect())
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -48,6 +48,7 @@ mod xml_catalog;
|
||||
|
||||
pub use injections::{InjectedRange, InjectionProvider, MAX_INJECTED_DOCUMENT_BYTES};
|
||||
pub use inspect::{CheckedServer, DocumentCheck, FileInspection, InspectHost, InspectOptions};
|
||||
pub use jdtls::exception_breakpoints::JdtExceptionBreakpoints;
|
||||
pub use jdtls::jvm_inspect::JdtJvmInspector;
|
||||
pub use jdtls::stream_trace::JdtStreamTracer;
|
||||
pub use kotlin_lsp::{KotlinDebugServer, KotlinDebugUnavailable};
|
||||
|
||||
@@ -3714,6 +3714,62 @@ async fn stream_collect_fails_cleanly_on_a_step_beyond_u16() {
|
||||
assert!(matches!(error, InspectError::Failed(ref m) if m.contains("malformed")), "{error:?}");
|
||||
}
|
||||
|
||||
#[tokio::test(flavor = "multi_thread")]
|
||||
async fn exception_breakpoints_send_the_whole_list_and_decode_states() {
|
||||
use ide_jvm_inspect::{ExceptionArmState, ExceptionClassBreakpoints, ExceptionClassSpec};
|
||||
let h = harness_for("java", "java", &[("jdtls", incremental_caps())], &[]);
|
||||
let (_, path) = h.open("Sample.java", "class Sample {}");
|
||||
h.wait_status("jdtls", ServerStatus::Ready).await;
|
||||
let s = h.launcher.state("jdtls");
|
||||
let client = ide_lsp::JdtExceptionBreakpoints::new(h.mgr.clone(), path);
|
||||
let specs = [
|
||||
ExceptionClassSpec {
|
||||
id: "a".into(),
|
||||
class_name: "com.acme.Boom".into(),
|
||||
caught: true,
|
||||
uncaught: false,
|
||||
enabled: true,
|
||||
class_filters: vec!["com.acme.*".into()],
|
||||
class_exclusion_filters: vec![],
|
||||
},
|
||||
ExceptionClassSpec {
|
||||
id: "b".into(),
|
||||
class_name: "java.lang.IllegalStateException".into(),
|
||||
caught: true,
|
||||
uncaught: true,
|
||||
enabled: false,
|
||||
class_filters: vec![],
|
||||
class_exclusion_filters: vec!["*Test".into()],
|
||||
},
|
||||
];
|
||||
s.respond(
|
||||
"workspace/executeCommand",
|
||||
json!({"ok": [{"id": "a", "state": "pending"}, {"id": "b", "state": "disabled"}]}),
|
||||
);
|
||||
let states = client.set(&stream_launch_target(), &specs).await.unwrap();
|
||||
assert_eq!(states, vec![("a".into(), ExceptionArmState::Pending), ("b".into(), ExceptionArmState::Disabled)]);
|
||||
let asked = s.requested("workspace/executeCommand");
|
||||
assert_eq!(asked[0]["command"], "openidea.jvm.exceptions.set");
|
||||
assert_eq!(
|
||||
asked[0]["arguments"],
|
||||
json!([
|
||||
{"pid": 42, "host": null, "port": null, "generation": 3},
|
||||
{"breakpoints": [
|
||||
{"id": "a", "className": "com.acme.Boom", "caught": true, "uncaught": false, "enabled": true,
|
||||
"classFilters": ["com.acme.*"], "classExclusionFilters": []},
|
||||
{"id": "b", "className": "java.lang.IllegalStateException", "caught": true, "uncaught": true,
|
||||
"enabled": false, "classFilters": [], "classExclusionFilters": ["*Test"]},
|
||||
]},
|
||||
])
|
||||
);
|
||||
|
||||
s.respond("workspace/executeCommand", json!({"error": "noSession", "detail": "hotCodeReplace is never?"}));
|
||||
assert_eq!(
|
||||
client.set(&stream_launch_target(), &specs).await.unwrap_err(),
|
||||
ide_jvm_inspect::InspectError::NoSession
|
||||
);
|
||||
}
|
||||
|
||||
#[tokio::test(flavor = "multi_thread")]
|
||||
async fn debug_server_port_maps_to_module() {
|
||||
let h = harness_for("java", "java", &[("jdtls", incremental_caps())], &[]);
|
||||
|
||||
@@ -652,6 +652,10 @@ pub trait HostApi: Send + Sync {
|
||||
fn plugin_dir(&self) -> Result<PathBuf, HostError> {
|
||||
Err(HostError::Failed("private plugin storage is unavailable".into()))
|
||||
}
|
||||
/// The plugin's install / package directory (read-only for the guest).
|
||||
fn install_dir(&self) -> Result<PathBuf, HostError> {
|
||||
Err(HostError::Failed("plugin install directory is unavailable".into()))
|
||||
}
|
||||
/// Replaces the text of a file whose real path the caller already checked:
|
||||
/// in one step, keeping its encoding and BOM (a new file is UTF-8). Refused
|
||||
/// while an editor holds unsaved changes for it.
|
||||
|
||||
@@ -313,11 +313,11 @@ impl StoreData {
|
||||
|
||||
/// `path` as the real path an `fs.read:…` grant covers, or what the plugin
|
||||
/// should be told instead (`denied` naming the capability to declare).
|
||||
/// The private plugin-dir and the install directory are readable without a
|
||||
/// grant; writing still needs `fs.write` or the private dir.
|
||||
fn granted_file(&self, path: &str) -> Result<PathBuf, wit::Error> {
|
||||
let mut granted = self.granted.clone();
|
||||
if let Ok(dir) = self.host.plugin_dir() {
|
||||
granted.push(Capability::FsRead(to_ipc(&dir)));
|
||||
}
|
||||
granted.extend(self.builtin_read_roots());
|
||||
sandbox::resolve_granted(&granted, path).map_err(Into::into)
|
||||
}
|
||||
|
||||
@@ -331,6 +331,19 @@ impl StoreData {
|
||||
sandbox::resolve_writable(&granted, path).map_err(Into::into)
|
||||
}
|
||||
|
||||
/// Private plugin-dir and install directory: readable without an `fs.read`
|
||||
/// grant; `editor.open` / `open-location` may use them without project.read.
|
||||
fn builtin_read_roots(&self) -> Vec<Capability> {
|
||||
let mut roots = Vec::new();
|
||||
if let Ok(dir) = self.host.plugin_dir() {
|
||||
roots.push(Capability::FsRead(to_ipc(&dir)));
|
||||
}
|
||||
if let Ok(dir) = self.host.install_dir() {
|
||||
roots.push(Capability::FsRead(to_ipc(&dir)));
|
||||
}
|
||||
roots
|
||||
}
|
||||
|
||||
fn client(&self) -> Option<&str> {
|
||||
self.invocation.client.as_deref()
|
||||
}
|
||||
@@ -1144,9 +1157,7 @@ impl StoreData {
|
||||
sandbox::resolve_in_root(root, path).map_err(wit::Error::Invalid)
|
||||
}
|
||||
fn openable_path(&self, path: &str) -> Result<PathBuf, wit::Error> {
|
||||
if let Ok(dir) = self.host.plugin_dir()
|
||||
&& let Ok(real) = sandbox::resolve_granted(&[Capability::FsRead(to_ipc(&dir))], path)
|
||||
{
|
||||
if let Ok(real) = sandbox::resolve_granted(&self.builtin_read_roots(), path) {
|
||||
return Ok(real);
|
||||
}
|
||||
self.require(Capability::ProjectRead)?;
|
||||
@@ -2078,9 +2089,7 @@ impl views::Host for StoreData {
|
||||
}
|
||||
|
||||
fn open_location(&mut self, path: String, line: u32, column: u32) -> Fallible<()> {
|
||||
if let Ok(dir) = self.host.plugin_dir()
|
||||
&& let Ok(real) = sandbox::resolve_granted(&[Capability::FsRead(to_ipc(&dir))], &path)
|
||||
{
|
||||
if let Ok(real) = sandbox::resolve_granted(&self.builtin_read_roots(), &path) {
|
||||
if let Err(e) = self.require_interactive() {
|
||||
return Ok(Err(e));
|
||||
}
|
||||
|
||||
@@ -1 +1 @@
|
||||
b59392bcc1999048f0ab922ec659bc21d9e825c696fa41d9f0a40c85627a5b2c
|
||||
d442e600d82cab0f79ad6decf95ca9d06c89dcd3119c500a11f48cdc54a5d5f4
|
||||
+1
-1
@@ -1 +1 @@
|
||||
034b99891313c03eb2a6b8c3cb2e4784129e1936965be803512f1d869b1768c2
|
||||
af048639f57e86262543c3dcd18bca27d384b6ad99a625af869f0812bf8ac93c
|
||||
@@ -1 +1 @@
|
||||
29ec0a96e2a0f6965915c7c25e35036743fc27a49037df588c217e8abfff93e3
|
||||
95b7263ca584c6b1b035be4dde64c7ae57b407c6a86b5ab6fe2736134e1d7754
|
||||
@@ -1 +1 @@
|
||||
87b367cfdd65c360920eff7be4d6a8d6b939721f6398aa6a01e39a289590699e
|
||||
1e5b10e8e77bdc7ed6bf002a415458caef7eee9a98123229dddf0d148af58f73
|
||||
+1
-1
@@ -1 +1 @@
|
||||
7d034ee1a4b99615642d5bf033802f8e4662216d45b209c4c7a24eb8f1338f48
|
||||
5b3d4ad737cde32fc808bcd8c93d9cdd7d53961985db0428ab567b4e97ed4ffb
|
||||
+1
-1
@@ -1 +1 @@
|
||||
3fdf985273ec14ae623fa84602a9220cfbfb2e0e587ab192fc2bcb8d990ce9e3
|
||||
04b1cbc2148cff8c0fa2d6a4f127a6a3c8ade5a7dc1541c1a16a656def299f33
|
||||
+1
-1
@@ -1 +1 @@
|
||||
8434e9271e27a6778bb3d5922e8925f3fd9f1d35377e5dddf5b5eb5416bd09bb
|
||||
918c44ee3a58a073dd65e2f7e32501cf9e84a59f24452c166e75457f7c232c89
|
||||
@@ -1 +1 @@
|
||||
9fa7468ce385ff33c1f3b99c84711e0d11a84b10e8e4f95b358fcd2ccc96e255
|
||||
c980260c235249186f754e16597de9d49663771d711ce6873bf83ebaf2a0fc34
|
||||
@@ -1 +1 @@
|
||||
5220a5bfb6ec0467a72e63e21d690e70b7d46b4f2eaff4116a8a79220a5eca8f
|
||||
df5729d63b83fbc511e0ba8509f9d370c5124b5af4c70f286c8965d2b0d890ef
|
||||
@@ -1 +1 @@
|
||||
a962127d1c6e37e85b81973a272a5d6b383cc2884b41bb2d82e8640ef5f8f943
|
||||
305965c6cbf2fd2b331bf9e2c473cfa9a543ab39ff0d47317ee9e28be9ea5b0f
|
||||
+1
-1
@@ -1 +1 @@
|
||||
92ad3e43e7f343004dcf26a51e282e97ed694cc9bd7325ff75aa5b18f1a2eeb6
|
||||
a1bb95a8a23ddd2d55bf64c724f73debfb503f252f57d8ae46afda8a0717fc20
|
||||
+1
-1
@@ -1 +1 @@
|
||||
2200ed0d44dbafb70ad864cb9569b0b2c37cf9eec1582b05efa903a9e8ec89ee
|
||||
b8be3120a468190aebb473c8f5d2e13889210241c9ab43c89cbf703c00366c8e
|
||||
+1
-1
@@ -1 +1 @@
|
||||
644612ee4228010f141042ea0eab5431b8386370f863a70b63cd3315f69d963a
|
||||
9b345dec001bcb7c0d8e6e214099d597b02976f20c2449af9847e8b69d0a5ab7
|
||||
@@ -1 +1 @@
|
||||
2af5d46516bfc1d38ad1f24d6cf3c57e2d6db6b0d3225748f55c4f13110430fb
|
||||
23e0c2ab39ba83aa332b57046b0b8c1bf236e3e61a14874ed82d20ce388873b6
|
||||
+1
-1
@@ -1 +1 @@
|
||||
0ee0773cefd61b8144d0550718e1988a1e60438bee826c3867350e28886a56f7
|
||||
e2d2afeb53f0af478963cde0c97fb016b1a424bf97952c7474a18e38e9e9ed55
|
||||
@@ -1 +1 @@
|
||||
941cb9008aaab11464b193c37b91e2476d771ec526247713f291c6642caf5995
|
||||
6bff7a7521a4a969aa8d9bd1363ef5efd544e079e77e55e51b19fff13b586b3a
|
||||
@@ -1 +1 @@
|
||||
06d70aae3152c88d1299a9b33f151b0baa4a77c3ca7145215c6f6e0aa40727b2
|
||||
27bb4c06b18703c43155e1a45c9edfb249a19443a68e87441babeeb71cb127d9
|
||||
+1
-1
@@ -1 +1 @@
|
||||
86eb87758e4f7c0242a18f12a113c31d418da64d7198041120f19401a5707bfb
|
||||
deb7995931cf8e344a486fbab275fd3ec7ddff73b05a841593e5521c4a514084
|
||||
@@ -1 +1 @@
|
||||
4442bb686fa18e8e8a52fd1cd8683b8767ec7908ffc1454dff476d9cb1711be9
|
||||
dc6670ff6373d148430f5c9c13d1ec5407b2d94c74c2209562737076468ca79d
|
||||
+1
-1
@@ -1 +1 @@
|
||||
dd51f1b8634ff6305ba1a69c8457bd586996200a2b18e4a08d0cfa2fb60abaf6
|
||||
9e111c4c541312dc231bac5a4fd1120b59191ecadce2dca73c77f4bff2a9d0e8
|
||||
+1
-1
@@ -1 +1 @@
|
||||
4319f2655ee1e240b33f4b96c23fff59c61aa62d6ccc628715e5ff9fe38c2717
|
||||
caa4053cd7f0135ab14a8c5c56abe198394e370549fea6d9df4d4c11c38fcabf
|
||||
@@ -1 +1 @@
|
||||
50c4fd7e08a4187afae0e00c775a61578b82bbad056807ad063ee47e79e2cef1
|
||||
8beb151f14b062438c4024b13bbdedbf5d65099415ad9d055fe63a4b1d64d010
|
||||
+1
-1
@@ -1 +1 @@
|
||||
220666302d814e6d8bde346954205c94c82320d5584d46f01672fd7d32400bf3
|
||||
fa6a660890e0beee7599726e9c30142601fbcd6f82a519b1b5952ef30f450bfb
|
||||
+1
-1
@@ -1 +1 @@
|
||||
4ee484afaa1a1f71a9e544582d90db3260307fc89b8f514aaaff883df2761ba6
|
||||
a7c1ec4814e4268fe185ae493413532528970264e84f717087b57a303ebe3591
|
||||
@@ -1 +1 @@
|
||||
3fba59ce802d88a2a1c026480a2cb8ce4d9539eb7b88f5a18bf6232f7adef147
|
||||
450d1e698882257d6c75b16984a6086259acce2c66a92b96c76ed3d6e15a0b4d
|
||||
+1
-1
@@ -1 +1 @@
|
||||
73433da25d5304d0a3cb83d750d02feb5e270ee7e9f680c4ee9d923afa9aa066
|
||||
738791aa00d63961fa7e8ed6ac7601f46848ecc0d25a498b6019eb151bf9169e
|
||||
+1
-1
@@ -1 +1 @@
|
||||
12df43f99eac93f4e1a070635780ad653932cf69a14595175d8ba6d4f0a4445c
|
||||
957d02e3d72673ca4a9ca80eb7c3e63087a6d8377411fc820d3808f024326b2e
|
||||
@@ -1 +1 @@
|
||||
427b63c11188689262101cde971af0a92e54bd6c88a4e3cc8fdfa1a7c8c95fce
|
||||
f0a57acc6ca29b0dc2803596a0a39ceb1e2185b59a44f5533e8f9b19bf214afd
|
||||
@@ -1 +1 @@
|
||||
07ae58fe39746b779b1e466d7bbbb666ba550f427c7bf8de97d7ede647c00bc0
|
||||
7890cfd9a08b67b47ae098ce24e02551935337b8501636e29164ff4ca6244e7e
|
||||
@@ -1 +1 @@
|
||||
f9912644c28512e37299834123cd4c94f6ed11f29bd38ddbc1c92df168447494
|
||||
769f873adfa7ed3752a059dac89e60f2203b8ce91b36fe0a7cb9c724e0cf895b
|
||||
+1
-1
@@ -1 +1 @@
|
||||
ea0eec8c07d6469d3ab63c3bb08c85b01208be1757edffe5eabcb7be79ccf537
|
||||
ea31cbeefee7f219f86fc7e65315aea7efebe3b91c9cec6e12d4f551b9655d95
|
||||
@@ -1 +1 @@
|
||||
1ce55fabaa5ea1ddf770c8a1ad7f7b60a843c82c453d42289088c4b2fec61d84
|
||||
bb30795e7d62b19b237759beeab9da6f6028fea7862d8fa83c6b3238a26f540d
|
||||
@@ -1 +1 @@
|
||||
3356b4ec918c668c4c249f84afb9bafcd06c073ba86235b6ceea7ef6220cdaf5
|
||||
65725512c8a8d3ad6cb02a4f947541dd1688a3208e37fa4ed0474ca8197f2340
|
||||
@@ -1337,6 +1337,10 @@ pub fn configure_server(cfg: &mut LanguageServerConfig, root: &Path, server_root
|
||||
cfg.args = vec!["--lsp".into(), "--stdio".into()];
|
||||
cfg.display_name = Some("TypeScript 7".into());
|
||||
cfg.initialization_options = None;
|
||||
// Completing a JSX prop adds `=""` or `={}` by its type, as vtsls does by default;
|
||||
// TypeScript 7 adds no value unless asked.
|
||||
let jsx = json!({ "preferences": { "jsxAttributeCompletionStyle": "auto" } });
|
||||
merge_init_options(cfg, json!({ "typescript": jsx, "javascript": jsx }));
|
||||
cfg.tsserver_project = false;
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1649,7 +1649,7 @@ pub fn jvm_inspect_bundle(data_dir: &Path) -> Option<PathBuf> {
|
||||
install_bundle(
|
||||
data_dir,
|
||||
"jvm-inspect",
|
||||
"1.1.1",
|
||||
"1.2.0",
|
||||
include_bytes!("../../../java/jvm-inspect/openidea-jvm-inspect.jar"),
|
||||
)
|
||||
}
|
||||
@@ -1745,7 +1745,7 @@ mod usages_bundle_tests {
|
||||
std::fs::write(dir.path().join(name), b"old").unwrap();
|
||||
}
|
||||
let jar = super::jvm_inspect_bundle(dir.path()).unwrap();
|
||||
assert_eq!(jar, dir.path().join("jvm-inspect-1.1.1.jar"));
|
||||
assert_eq!(jar, dir.path().join("jvm-inspect-1.2.0.jar"));
|
||||
assert_eq!(std::fs::read(&jar).unwrap(), include_bytes!("../../../java/jvm-inspect/openidea-jvm-inspect.jar"));
|
||||
assert!(!dir.path().join("jvm-inspect-0.9.0.jar").exists());
|
||||
assert_eq!(std::fs::read(dir.path().join("java-usages-1.7.0.jar")).unwrap(), b"old");
|
||||
|
||||
@@ -1725,7 +1725,15 @@ fn typescript_7_runs_its_own_language_server() {
|
||||
assert_eq!(Path::new(&cfg.command), native, "{name}");
|
||||
assert_eq!(cfg.args, ["--lsp", "--stdio"]);
|
||||
assert_eq!(cfg.display_name.as_deref(), Some("TypeScript 7"));
|
||||
assert!(cfg.initialization_options.is_none());
|
||||
// The tsserver-based server's options don't apply; JSX prop completion adds a value.
|
||||
let options = serde_json::to_value(cfg.initialization_options.as_ref().unwrap()).unwrap();
|
||||
for language in ["typescript", "javascript"] {
|
||||
assert_eq!(
|
||||
options[language],
|
||||
serde_json::json!({ "preferences": { "jsxAttributeCompletionStyle": "auto" } })
|
||||
);
|
||||
}
|
||||
assert_eq!(options.as_object().unwrap().len(), 2, "{options}");
|
||||
}
|
||||
// Picked as a directory (its `lib`, as for older versions), too.
|
||||
s.languages.typescript.version = modules.join("typescript/lib").to_string_lossy().into_owned();
|
||||
|
||||
@@ -640,11 +640,13 @@ async fn with_key(handle: &mut Handle<Client>, user: &str, key: keys::PrivateKey
|
||||
}
|
||||
|
||||
/// Every identity of the running SSH agent, until one is accepted.
|
||||
async fn with_agent(handle: &mut Handle<Client>, user: &str) -> bool {
|
||||
async fn with_agent(handle: &mut Handle<Client>, hop: &Hop) -> bool {
|
||||
let user = hop.user.as_str();
|
||||
let Some(socket) = hop.agent.socket() else { return false };
|
||||
#[cfg(unix)]
|
||||
let agent = keys::agent::client::AgentClient::connect_env().await;
|
||||
let agent = keys::agent::client::AgentClient::connect_uds(socket).await;
|
||||
#[cfg(windows)]
|
||||
let agent = keys::agent::client::AgentClient::connect_named_pipe(r"\\.\pipe\openssh-ssh-agent").await;
|
||||
let agent = keys::agent::client::AgentClient::connect_named_pipe(socket).await;
|
||||
let Ok(mut agent) = agent else { return false };
|
||||
let Ok(identities) = agent.request_identities().await else { return false };
|
||||
let hash = rsa_hash(handle).await;
|
||||
@@ -693,7 +695,7 @@ async fn authenticate(
|
||||
if handle.authenticate_none(user).await.map(|r| r.success()).unwrap_or(false) {
|
||||
return Ok(());
|
||||
}
|
||||
if with_agent(handle, user).await {
|
||||
if with_agent(handle, hop).await {
|
||||
return Ok(());
|
||||
}
|
||||
let files: Vec<PathBuf> = if hop.identity_files.is_empty() {
|
||||
|
||||
@@ -53,6 +53,65 @@ pub(crate) struct Hop {
|
||||
pub proxy_command: Option<String>,
|
||||
pub host_key_policy: HostKeyPolicy,
|
||||
pub known_hosts: Option<PathBuf>,
|
||||
pub agent: Agent,
|
||||
}
|
||||
|
||||
/// Where the SSH agent of a hop listens (`IdentityAgent`).
|
||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||
pub(crate) enum Agent {
|
||||
/// `SSH_AUTH_SOCK` (the OpenSSH pipe on Windows when it is unset).
|
||||
Default,
|
||||
/// `IdentityAgent none`, or an unset `$VARIABLE`.
|
||||
Off,
|
||||
Socket(PathBuf),
|
||||
}
|
||||
|
||||
impl Agent {
|
||||
/// The socket (or Windows pipe) to connect to, `None` for no agent.
|
||||
pub fn socket(&self) -> Option<PathBuf> {
|
||||
match self {
|
||||
Agent::Off => None,
|
||||
Agent::Socket(path) => Some(path.clone()),
|
||||
Agent::Default => {
|
||||
let var = env_var("SSH_AUTH_SOCK").filter(|v| !v.is_empty()).map(PathBuf::from);
|
||||
if cfg!(windows) {
|
||||
// Only a pipe works there; a Unix socket path comes from MSYS or WSL tools.
|
||||
let pipe = var.filter(|p| p.to_string_lossy().starts_with(r"\\.\pipe\"));
|
||||
Some(pipe.unwrap_or_else(|| PathBuf::from(r"\\.\pipe\openssh-ssh-agent")))
|
||||
} else {
|
||||
var
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// A variable as the user's shell sees it. An app started from Finder or the Dock has the
|
||||
/// login session's environment; the shell's rc files may set another value (an SSH agent
|
||||
/// socket exported in `~/.zshrc`), and that is the one `ssh` in a terminal uses.
|
||||
fn env_var(name: &str) -> Option<std::ffi::OsString> {
|
||||
ide_core::process::login_env()
|
||||
.and_then(|vars| vars.iter().find(|(k, _)| k == name).map(|(_, v)| v.clone()))
|
||||
.or_else(|| std::env::var_os(name))
|
||||
}
|
||||
|
||||
/// `IdentityAgent`: `none`, `SSH_AUTH_SOCK`, `$VARIABLE`, or a path (`~` and `%` tokens expanded).
|
||||
fn identity_agent(value: Option<&str>, expand_path: impl Fn(&str) -> PathBuf) -> Agent {
|
||||
let Some(value) = value.map(str::trim).filter(|v| !v.is_empty()) else { return Agent::Default };
|
||||
if value.eq_ignore_ascii_case("none") {
|
||||
return Agent::Off;
|
||||
}
|
||||
if value == "SSH_AUTH_SOCK" {
|
||||
return Agent::Default;
|
||||
}
|
||||
if let Some(name) = value.strip_prefix('$') {
|
||||
let name = name.strip_prefix('{').and_then(|n| n.strip_suffix('}')).unwrap_or(name);
|
||||
return match env_var(name).filter(|v| !v.is_empty()) {
|
||||
Some(path) => Agent::Socket(expand(&path.to_string_lossy())),
|
||||
None => Agent::Off,
|
||||
};
|
||||
}
|
||||
Agent::Socket(expand_path(value))
|
||||
}
|
||||
|
||||
/// `StrictHostKeyChecking`: what happens to a host key missing from `known_hosts`.
|
||||
@@ -98,6 +157,7 @@ struct RawConfig {
|
||||
proxy_command: Option<String>,
|
||||
host_key_policy: Option<HostKeyPolicy>,
|
||||
user_known_hosts_file: Option<String>,
|
||||
identity_agent: Option<String>,
|
||||
}
|
||||
|
||||
fn strip_quotes(s: &str) -> &str {
|
||||
@@ -444,6 +504,11 @@ fn parse_config_file(
|
||||
});
|
||||
}
|
||||
}
|
||||
"identityagent" => {
|
||||
if out.identity_agent.is_none() {
|
||||
out.identity_agent = Some(strip_quotes(value).to_owned());
|
||||
}
|
||||
}
|
||||
"userknownhostsfile" => {
|
||||
if out.user_known_hosts_file.is_none()
|
||||
&& let Some(first) = split_args(value).into_iter().next()
|
||||
@@ -492,7 +557,9 @@ fn config_hop(
|
||||
};
|
||||
let host_key_policy =
|
||||
if null_known_hosts { HostKeyPolicy::Off } else { raw.host_key_policy.unwrap_or(HostKeyPolicy::Ask) };
|
||||
let hop = Hop { host, port, user, identity_files, proxy_command, host_key_policy, known_hosts };
|
||||
let agent =
|
||||
identity_agent(raw.identity_agent.as_deref(), |p| expand(&expand_tokens(p, alias, &host, port, &user, &local)));
|
||||
let hop = Hop { host, port, user, identity_files, proxy_command, host_key_policy, known_hosts, agent };
|
||||
(hop, proxy_jump)
|
||||
}
|
||||
|
||||
@@ -529,6 +596,7 @@ pub(crate) fn resolve_hops(target: &SshTarget, config: Option<&Path>) -> IdeResu
|
||||
proxy_command: None,
|
||||
host_key_policy: HostKeyPolicy::Ask,
|
||||
known_hosts: None,
|
||||
agent: Agent::Default,
|
||||
},
|
||||
None,
|
||||
)
|
||||
@@ -594,6 +662,32 @@ mod tests {
|
||||
assert!(resolve_hops(&SshTarget::default(), None).is_err());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn identity_agent_picks_the_agent_of_each_hop() {
|
||||
let tmp = tempfile::tempdir().unwrap();
|
||||
let config = tmp.path().join("config");
|
||||
std::fs::write(
|
||||
&config,
|
||||
"Host vault\n IdentityAgent \"~/agents/%h.sock\"\n ProxyJump plain\n\n\
|
||||
Host off\n IdentityAgent none\n\nHost shell\n IdentityAgent ${OPENIDEA_TEST_AGENT}\n\n\
|
||||
Host unset\n IdentityAgent $OPENIDEA_TEST_UNSET_AGENT\n\nHost env\n IdentityAgent SSH_AUTH_SOCK\n",
|
||||
)
|
||||
.unwrap();
|
||||
// Exported only by the shell's rc files, as a GUI app sees it (#4934).
|
||||
ide_core::process::set_shell_env(vec![("OPENIDEA_TEST_AGENT".into(), "/run/agent.sock".into())]);
|
||||
let agent = |host: &str| {
|
||||
let target = SshTarget { host: host.into(), auth: SshAuth::OpenSsh, ..Default::default() };
|
||||
resolve_hops(&target, Some(&config)).unwrap().into_iter().map(|h| h.agent).collect::<Vec<_>>()
|
||||
};
|
||||
let home = home().unwrap();
|
||||
assert_eq!(agent("vault"), [Agent::Default, Agent::Socket(home.join("agents/vault.sock"))]);
|
||||
assert_eq!(agent("off"), [Agent::Off]);
|
||||
assert_eq!(agent("shell"), [Agent::Socket("/run/agent.sock".into())]);
|
||||
assert_eq!(agent("unset"), [Agent::Off]);
|
||||
assert_eq!(agent("env"), [Agent::Default]);
|
||||
assert_eq!(Agent::Off.socket(), None);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn resolves_include_match_equals_and_proxy_command() {
|
||||
let tmp = tempfile::tempdir().unwrap();
|
||||
|
||||
@@ -384,6 +384,7 @@ fn run_raw_env_once(
|
||||
.stdout(Stdio::piped())
|
||||
.stderr(Stdio::piped());
|
||||
tracing::debug!(?args, "git");
|
||||
let refresh = IndexRefresh::before(root, args, env);
|
||||
let mut session = CommandSession::start(&mut cmd);
|
||||
let mut child = cmd.spawn().map_err(spawn_error)?;
|
||||
let writer = match (stdin, child.stdin.take()) {
|
||||
@@ -401,9 +402,49 @@ fn run_raw_env_once(
|
||||
let _ = w.join();
|
||||
}
|
||||
session.finish(out.status.success(), &String::from_utf8_lossy(&out.stderr));
|
||||
refresh.after();
|
||||
Ok(Output { stdout: out.stdout, stderr: out.stderr, code: out.status.code() })
|
||||
}
|
||||
|
||||
/// `git diff` against the working tree rewrites the index when it meets files whose stat data
|
||||
/// is stale (`diff.autoRefreshIndex`), even under `--no-optional-locks`. Like status's
|
||||
/// write-back, that is a side effect of reading: recorded as ours, watchers don't report it as
|
||||
/// a repository change. Otherwise a view that re-reads on repository changes re-triggers itself,
|
||||
/// endlessly where git and gix disagree on stat data (Windows, #4792).
|
||||
struct IndexRefresh(Option<(PathBuf, crate::index_writes::Stamp)>);
|
||||
|
||||
impl IndexRefresh {
|
||||
fn before(root: &Path, args: &[&str], env: &[(&str, &std::ffi::OsStr)]) -> Self {
|
||||
let reads_worktree = subcommand(args) == "diff"
|
||||
&& !args.iter().any(|a| matches!(*a, "--cached" | "--staged" | "--no-index"))
|
||||
&& !env.iter().any(|(k, _)| *k == "GIT_INDEX_FILE");
|
||||
Self(reads_worktree.then(|| index_file(root)).flatten().map(|index| {
|
||||
let stamp = crate::index_writes::stamp(&index);
|
||||
(index, stamp)
|
||||
}))
|
||||
}
|
||||
|
||||
fn after(self) {
|
||||
if let Some((index, stamp)) = self.0
|
||||
&& !stamp.still_holds(&index)
|
||||
{
|
||||
crate::index_writes::lock().record(&index);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// The index of the working tree at `root`: `.git/index`, or a linked worktree's own index
|
||||
/// in the gitdir its `.git` file names.
|
||||
fn index_file(root: &Path) -> Option<PathBuf> {
|
||||
let dot_git = root.join(".git");
|
||||
if dot_git.is_dir() {
|
||||
return Some(dot_git.join("index"));
|
||||
}
|
||||
let text = std::fs::read_to_string(&dot_git).ok()?;
|
||||
let dir = Path::new(text.trim().strip_prefix("gitdir:")?.trim());
|
||||
Some(root.join(dir).join("index"))
|
||||
}
|
||||
|
||||
/// Captures binary/NUL-delimited read output while allowing cancellation to kill git.
|
||||
pub(crate) fn run_cancellable(root: &Path, args: &[&str], cancel: &CancellationToken) -> IdeResult<Output> {
|
||||
let out = run_cancellable_raw(root, args, cancel)?;
|
||||
@@ -497,6 +538,7 @@ fn run_capture(
|
||||
.stdout(Stdio::piped())
|
||||
.stderr(Stdio::piped());
|
||||
own_group(&mut cmd);
|
||||
let refresh = IndexRefresh::before(root, args, &[]);
|
||||
let mut session = CommandSession::start(&mut cmd);
|
||||
let mut child = cmd.spawn().map_err(spawn_error)?;
|
||||
let writer = match (stdin, child.stdin.take()) {
|
||||
@@ -550,6 +592,7 @@ fn run_capture(
|
||||
};
|
||||
let out = Output { stdout: join(stdout)?, stderr: join(stderr)?, code: status.code() };
|
||||
session.finish(status.success(), &String::from_utf8_lossy(&out.stderr));
|
||||
refresh.after();
|
||||
if out.stdout.len() > max || out.stderr.len() > max {
|
||||
return Err(IdeError::invalid(format!("git output exceeds {max} bytes")));
|
||||
}
|
||||
|
||||
@@ -163,7 +163,7 @@ impl Repos {
|
||||
}
|
||||
|
||||
/// Changes of every repository. A nested repository reports its own files, so the
|
||||
/// enclosing one's "untracked folder" entry for it is dropped. A repository that cannot
|
||||
/// enclosing one's "untracked folder" entry for it, and its entries inside it, are dropped. A repository that cannot
|
||||
/// be read (e.g. deleted since the last scan) is left out; fails only when all fail.
|
||||
///
|
||||
/// The reads go through [`Backend`], the Changes-view surface — repositories of a
|
||||
@@ -207,10 +207,13 @@ impl Repos {
|
||||
continue;
|
||||
}
|
||||
};
|
||||
// A file belongs to its innermost repository: the nested one reports what lies
|
||||
// inside it, including files the enclosing one still tracks there (#4990).
|
||||
out.extend(status.into_iter().filter(|f| {
|
||||
let untracked_root =
|
||||
f.unstaged == Some(crate::ChangeKind::Untracked) && nested.iter().any(|n| f.path.0 == *n);
|
||||
!untracked_root
|
||||
let in_nested = nested.iter().any(|n| f.path.0 != *n && f.path.0.starts_with(n));
|
||||
!untracked_root && !in_nested
|
||||
}));
|
||||
}
|
||||
match first_error {
|
||||
@@ -315,6 +318,74 @@ mod tests {
|
||||
assert_eq!(skipped.all().len(), 2);
|
||||
}
|
||||
|
||||
/// A workspace: members in repositories of their own (one with a nested repository, not a
|
||||
/// submodule), a plain folder, and a member that is a subfolder of a bigger repository; the
|
||||
/// container's agent folder links to each member and must not add a repository again.
|
||||
#[cfg(unix)]
|
||||
#[test]
|
||||
fn workspace_members_bring_their_repositories_once() {
|
||||
let tmp = tempfile::tempdir().unwrap();
|
||||
let base = dunce::canonicalize(tmp.path()).unwrap();
|
||||
let (api, web, plain, mono) = (base.join("api"), base.join("web"), base.join("plain"), base.join("mono"));
|
||||
git_init(&api);
|
||||
git_init(&api.join("libs/sdk"));
|
||||
git_init(&web);
|
||||
std::fs::create_dir_all(&plain).unwrap();
|
||||
git_init(&mono);
|
||||
let docs = mono.join("docs");
|
||||
std::fs::create_dir_all(&docs).unwrap();
|
||||
let container = base.join("ws");
|
||||
let links = container.join(".openidea/agent-root");
|
||||
std::fs::create_dir_all(&links).unwrap();
|
||||
for (name, target) in [("api", &api), ("web", &web), ("plain", &plain), ("docs", &docs)] {
|
||||
std::os::unix::fs::symlink(target, links.join(name)).unwrap();
|
||||
// A link elsewhere in the container: never followed either.
|
||||
std::os::unix::fs::symlink(target, container.join(name)).unwrap();
|
||||
}
|
||||
|
||||
let roots = [container.clone(), api.clone(), web.clone(), plain.clone(), docs.clone()];
|
||||
let repos = Repos::discover_roots(&roots, &|_| false).unwrap();
|
||||
let found: Vec<&Path> = repos.all().iter().map(|r| r.root()).collect();
|
||||
assert_eq!(found, [api.as_path(), &api.join("libs/sdk"), &mono, &web]);
|
||||
let file = api.join("libs/sdk/lib.rs");
|
||||
assert_eq!(repos.for_path(&file).unwrap().root(), api.join("libs/sdk"), "a nested file is its own repo's");
|
||||
assert_eq!(repos.for_path(&docs.join("a.md")).unwrap().root(), mono, "a subfolder member is its repo's");
|
||||
assert!(repos.for_path(&plain.join("x")).is_none());
|
||||
}
|
||||
|
||||
/// A folder the enclosing repository still tracks became a repository of its own: both
|
||||
/// report its files, and each file must be listed once, by its innermost repository (#4990).
|
||||
#[test]
|
||||
fn a_file_of_a_nested_repository_is_listed_once() {
|
||||
let tmp = tempfile::tempdir().unwrap();
|
||||
let root = dunce::canonicalize(tmp.path()).unwrap();
|
||||
git_init(&root);
|
||||
std::fs::create_dir_all(root.join("web")).unwrap();
|
||||
std::fs::write(root.join("web/page.html"), "v1").unwrap();
|
||||
let git = |dir: &Path, args: &[&str]| {
|
||||
let ok = Command::new("git")
|
||||
.args(["-c", "user.name=t", "-c", "user.email=t@t", "-c", "commit.gpgsign=false"])
|
||||
.args(args)
|
||||
.current_dir(dir)
|
||||
.status()
|
||||
.is_ok_and(|s| s.success());
|
||||
assert!(ok, "git {args:?}");
|
||||
};
|
||||
git(&root, &["add", "."]);
|
||||
git(&root, &["commit", "-qm", "init"]);
|
||||
git_init(&root.join("web"));
|
||||
std::fs::write(root.join("web/page.html"), "v2").unwrap();
|
||||
std::fs::write(root.join("README.md"), "x").unwrap();
|
||||
|
||||
let repos = Repos::discover(&root, &|_| false).unwrap();
|
||||
assert_eq!(repos.all().len(), 2);
|
||||
for status in [repos.status().unwrap(), repos.status_paths(&[root.join("web/page.html")]).unwrap()] {
|
||||
let page: Vec<_> = status.iter().filter(|f| f.path.0 == root.join("web/page.html")).collect();
|
||||
assert_eq!(page.len(), 1, "{status:?}");
|
||||
assert_eq!(page[0].rel_path, "page.html", "listed by the nested repository");
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn side_by_side_repositories_without_an_enclosing_one() {
|
||||
let tmp = tempfile::tempdir().unwrap();
|
||||
|
||||
@@ -2288,3 +2288,30 @@ fn status_from_the_git_command_line_matches_the_in_process_one() {
|
||||
assert_eq!(from_git, in_process);
|
||||
assert_eq!(from_git.len(), 4, "{from_git:#?}");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_worktree_diff_refreshing_the_index_is_not_reported_as_a_repository_change() {
|
||||
let fx = Fixture::new();
|
||||
fx.write("a.txt", "a\n");
|
||||
fx.write("b.txt", "b\n");
|
||||
fx.git(&["add", "."]);
|
||||
fx.git(&["commit", "-qm", "init"]);
|
||||
let base = fx.git(&["rev-parse", "HEAD"]);
|
||||
let index = fx.dir.join(".git/index");
|
||||
let backdate = |rel: &str| {
|
||||
let file = std::fs::File::options().write(true).open(fx.dir.join(rel)).unwrap();
|
||||
file.set_modified(std::time::SystemTime::now() - std::time::Duration::from_secs(100)).unwrap();
|
||||
};
|
||||
// Same content, stale stat data: `git diff` refreshes and rewrites the index while reading.
|
||||
backdate("a.txt");
|
||||
let before = std::fs::read(&index).unwrap();
|
||||
let repo = fx.repo();
|
||||
assert!(repo.numstat_with_worktree(&base).unwrap().is_empty());
|
||||
assert_ne!(std::fs::read(&index).unwrap(), before, "git rewrote the index");
|
||||
assert!(is_own_index_write(&index));
|
||||
|
||||
// A write by someone else is still a change.
|
||||
fx.write("b.txt", "changed\n");
|
||||
fx.git(&["add", "b.txt"]);
|
||||
assert!(!is_own_index_write(&index));
|
||||
}
|
||||
@@ -13,7 +13,7 @@
|
||||
use crate::FsBatch;
|
||||
use crate::rules::{ExcludeMatcher, GitignoreStack};
|
||||
use ide_core::{IdeError, IdeEvent, IdeResult, SharedSink};
|
||||
use notify::event::{ModifyKind, RenameMode};
|
||||
use notify::event::{CreateKind, DataChange, ModifyKind, RemoveKind, RenameMode};
|
||||
use notify::{ErrorKind, Event, EventKind, PollWatcher, RecommendedWatcher, RecursiveMode, WatcherKind};
|
||||
use parking_lot::{Condvar, Mutex, RwLock};
|
||||
use std::collections::{BTreeMap, BTreeSet, HashSet};
|
||||
@@ -238,17 +238,113 @@ fn event_handler(state: Weak<DirState>, polled: bool) -> impl FnMut(notify::Resu
|
||||
match event {
|
||||
Ok(event) if !is_change_event(&event) => {}
|
||||
Ok(event) if polled && is_dir_touch(&event) => {}
|
||||
Ok(event) => {
|
||||
state.queue.lock().push(event, Instant::now());
|
||||
state.wake.notify_one();
|
||||
}
|
||||
Ok(event) => state.enqueue(event),
|
||||
Err(e) => tracing::warn!("file watcher: {e}"),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// A directory's own mtime moving as entries come and go: polling sees it, the
|
||||
/// OS watchers report only the entries (also seen, through that directory's watch).
|
||||
/// One queued change for a path. A rename without a peer stays a rename so the batch
|
||||
/// resolves its existence after the quiet window, as it always did.
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
|
||||
enum PathChange {
|
||||
Change(Change),
|
||||
Rename,
|
||||
}
|
||||
|
||||
/// The per-path result of one raw event, in arrival order. `merge` in the batch is
|
||||
/// order-sensitive (create+remove ≠ remove+create), so a path keeps its sequence of
|
||||
/// distinct changes, with repetitions collapsed. A storm repeating the same change
|
||||
/// still leaves one entry per path; the order of real transitions is preserved.
|
||||
#[derive(Default)]
|
||||
struct QueuedChanges {
|
||||
paths: BTreeMap<PathBuf, Vec<PathChange>>,
|
||||
}
|
||||
|
||||
impl QueuedChanges {
|
||||
fn push(&mut self, path: PathBuf, change: PathChange) {
|
||||
let changes = self.paths.entry(path).or_default();
|
||||
if changes.last() != Some(&change) {
|
||||
changes.push(change);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// The per-path changes one raw event contributes, classified exactly as `batch_detailed`
|
||||
/// classifies it. A rename with both paths keeps from/removal and to/creation apart; one
|
||||
/// without a peer is left for the batch to resolve by the path's existence.
|
||||
fn queue_changes(filter: &EventFilter, event: &Event, out: &mut QueuedChanges) {
|
||||
// `classify` drops `.git/info/exclude` as VCS noise (the index handles it), but
|
||||
// `batch_detailed` needs the event to reload repo-level ignore rules. Keep it queued;
|
||||
// classification at batch time still drops it from the reported paths.
|
||||
let mut classify = |path: &Path, change: Change| {
|
||||
if path.ends_with(".git/info/exclude") {
|
||||
out.push(path.to_path_buf(), PathChange::Change(change));
|
||||
} else {
|
||||
// `classify` applies the VCS/atomic-temp filters and merges; we only need to
|
||||
// know the resulting single change for this one event at this path.
|
||||
let mut one = BTreeMap::new();
|
||||
filter.classify(path, change, &mut one);
|
||||
for (_, merged) in one {
|
||||
out.push(path.to_path_buf(), PathChange::Change(merged));
|
||||
}
|
||||
}
|
||||
};
|
||||
// A rename without a peer keeps the same resolution the batch applies to its
|
||||
// `Modify(Name(_))` arm (created if the path exists, removed otherwise).
|
||||
let renamed = |path: &Path| {
|
||||
if path.symlink_metadata().is_ok() { Change::Created } else { Change::Removed }
|
||||
};
|
||||
match event.kind {
|
||||
EventKind::Create(_) => {
|
||||
for path in &event.paths {
|
||||
classify(path, Change::Created);
|
||||
}
|
||||
}
|
||||
EventKind::Remove(_) => {
|
||||
for path in &event.paths {
|
||||
classify(path, Change::Removed);
|
||||
}
|
||||
}
|
||||
EventKind::Modify(ModifyKind::Name(RenameMode::Both)) => {
|
||||
if let [from, to] = event.paths.as_slice() {
|
||||
classify(from, Change::Removed);
|
||||
classify(to, Change::Created);
|
||||
} else {
|
||||
// Some backends emit a `Both` rename with a missing endpoint.
|
||||
for path in &event.paths {
|
||||
classify(path, renamed(path));
|
||||
}
|
||||
}
|
||||
}
|
||||
EventKind::Modify(ModifyKind::Name(RenameMode::From)) => {
|
||||
for path in &event.paths {
|
||||
classify(path, Change::Removed);
|
||||
}
|
||||
}
|
||||
EventKind::Modify(ModifyKind::Name(RenameMode::To)) => {
|
||||
for path in &event.paths {
|
||||
classify(path, Change::Created);
|
||||
}
|
||||
}
|
||||
EventKind::Modify(ModifyKind::Name(_)) => {
|
||||
// Defer resolution: the batch checks existence after the quiet window, so a
|
||||
// file created and removed within one window is not reported as created.
|
||||
for path in &event.paths {
|
||||
out.push(path.clone(), PathChange::Rename);
|
||||
}
|
||||
}
|
||||
EventKind::Modify(_) | EventKind::Any | EventKind::Other => {
|
||||
for path in &event.paths {
|
||||
classify(path, Change::Modified);
|
||||
}
|
||||
}
|
||||
EventKind::Access(_) => {}
|
||||
}
|
||||
}
|
||||
|
||||
/// A directory's own mtime moving as entries come and go. Polling also reports
|
||||
/// each changed entry through that directory's watch.
|
||||
fn is_dir_touch(event: ¬ify::Event) -> bool {
|
||||
matches!(event.kind, EventKind::Modify(_)) && event.paths.iter().all(|p| p.is_dir())
|
||||
}
|
||||
@@ -280,11 +376,13 @@ fn watcher_error(what: &str, error: notify::Error) -> IdeError {
|
||||
}
|
||||
}
|
||||
|
||||
/// Only adjacent identical file modifications are redundant before classification.
|
||||
/// Keep the arrival window separately so compaction cannot extend MAX_DELAY.
|
||||
/// Events waiting for the debounce window, coalesced by path: each path keeps its distinct
|
||||
/// changes in arrival order, so a storm repeating one change collapses to a single entry
|
||||
/// while the batch still sees the exact sequence it would have received. Memory is bounded
|
||||
/// by the number of paths and real transitions touched in the window, not by raw events.
|
||||
#[derive(Default)]
|
||||
struct PendingEvents {
|
||||
events: Vec<Event>,
|
||||
changes: BTreeMap<PathBuf, Vec<PathChange>>,
|
||||
first: Option<Instant>,
|
||||
last: Option<Instant>,
|
||||
received: usize,
|
||||
@@ -292,32 +390,61 @@ struct PendingEvents {
|
||||
|
||||
impl PendingEvents {
|
||||
fn is_empty(&self) -> bool {
|
||||
self.events.is_empty()
|
||||
self.changes.is_empty()
|
||||
}
|
||||
|
||||
fn push(&mut self, event: Event, now: Instant) {
|
||||
fn add(&mut self, changes: QueuedChanges, now: Instant) {
|
||||
self.first.get_or_insert(now);
|
||||
self.last = Some(now);
|
||||
self.received += 1;
|
||||
let redundant = event.paths.len() == 1
|
||||
&& event.flag().is_none()
|
||||
&& matches!(event.kind, EventKind::Modify(ModifyKind::Any | ModifyKind::Data(_) | ModifyKind::Metadata(_)))
|
||||
&& self.events.last().is_some_and(|previous| {
|
||||
// Reject different spellings before Path's component-wise equality.
|
||||
// Keeping a normalized alias is safe; only exact duplicates compact.
|
||||
previous.paths.len() == 1
|
||||
&& previous.paths[0].as_os_str() == event.paths[0].as_os_str()
|
||||
&& previous == &event
|
||||
&& previous.attrs.process_id() == event.attrs.process_id()
|
||||
});
|
||||
if !redundant {
|
||||
self.events.push(event);
|
||||
for (path, kinds) in changes.paths {
|
||||
let queued = self.changes.entry(path).or_default();
|
||||
for kind in kinds {
|
||||
if queued.last() != Some(&kind) {
|
||||
queued.push(kind);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn deadline(&self) -> Option<Instant> {
|
||||
Some((self.last? + DEBOUNCE).min(self.first? + MAX_DELAY))
|
||||
}
|
||||
|
||||
/// Rebuild the events for `batch_detailed`, in the order each path received them.
|
||||
/// `merge` is order-sensitive, so this preserves the exact transition sequence with
|
||||
/// repetitions removed. A rename is emitted as `Modify(Name(Any))` so its existence
|
||||
/// check stays in the batch, and a transient path stays a create+remove pair.
|
||||
fn into_events(self) -> Vec<Event> {
|
||||
self.changes
|
||||
.into_iter()
|
||||
.flat_map(|(path, changes)| {
|
||||
changes
|
||||
.into_iter()
|
||||
.flat_map(|kind| {
|
||||
let event = match kind {
|
||||
PathChange::Rename => Event::new(EventKind::Modify(ModifyKind::Name(RenameMode::Any))),
|
||||
PathChange::Change(Change::Created) => Event::new(EventKind::Create(CreateKind::File)),
|
||||
PathChange::Change(Change::Removed) => Event::new(EventKind::Remove(RemoveKind::File)),
|
||||
PathChange::Change(Change::Modified) => {
|
||||
Event::new(EventKind::Modify(ModifyKind::Data(DataChange::Content)))
|
||||
}
|
||||
// Any kind classifies a VCS path as `Vcs` again, except a modified
|
||||
// directory, which the batch drops as a lock-file touch.
|
||||
PathChange::Change(Change::Vcs) => Event::new(EventKind::Create(CreateKind::Any)),
|
||||
PathChange::Change(Change::Transient) => {
|
||||
return vec![
|
||||
Event::new(EventKind::Create(CreateKind::File)).add_path(path.clone()),
|
||||
Event::new(EventKind::Remove(RemoveKind::File)).add_path(path.clone()),
|
||||
];
|
||||
}
|
||||
};
|
||||
vec![event.add_path(path.clone())]
|
||||
})
|
||||
.collect::<Vec<_>>()
|
||||
})
|
||||
.collect()
|
||||
}
|
||||
}
|
||||
|
||||
/// Shared with the notify callback (weakly) and the debounce thread.
|
||||
@@ -340,6 +467,19 @@ impl DirState {
|
||||
self.stop.load(Ordering::SeqCst)
|
||||
}
|
||||
|
||||
/// Coalesces one raw event into the pending batch. Everything `batch_detailed` does to
|
||||
/// a path (VCS metadata, atomic-save temps, `merge` of repeated changes) is applied here
|
||||
/// through `classify`, so the batch gets the same final state per path it always did.
|
||||
fn enqueue(&self, event: Event) {
|
||||
let mut changes = QueuedChanges::default();
|
||||
queue_changes(&self.filter, &event, &mut changes);
|
||||
if changes.paths.is_empty() {
|
||||
return;
|
||||
}
|
||||
self.queue.lock().add(changes, Instant::now());
|
||||
self.wake.notify_one();
|
||||
}
|
||||
|
||||
/// Debounce loop: finishes any deferred startup watches, then waits for a
|
||||
/// quiet period and processes each batch. `polled` is whether the watcher
|
||||
/// already polls.
|
||||
@@ -372,13 +512,15 @@ impl DirState {
|
||||
}
|
||||
std::mem::take(&mut *q)
|
||||
};
|
||||
// A scan may publish a path before its create event is delivered:
|
||||
// keep create + remove pairs so the consumer still sees the removal.
|
||||
let processing = Instant::now();
|
||||
let queue_age_ms = processing.duration_since(events.first.expect("nonempty event queue")).as_millis();
|
||||
let received = events.received;
|
||||
let queued = events.events.len();
|
||||
let (mut batch, rule_dirs) = self.filter.batch_detailed(&events.events);
|
||||
// One event can contribute two path changes (a `Both` rename), so the queued
|
||||
// count can exceed the raw event count; never let the log arithmetic underflow.
|
||||
let queued = events.changes.values().map(Vec::len).sum::<usize>();
|
||||
let coalesced = received.saturating_sub(queued);
|
||||
let events = events.into_events();
|
||||
let (mut batch, rule_dirs) = self.filter.batch_detailed(&events);
|
||||
if self.mode == WatchMode::PerDirectory {
|
||||
self.update_watches(&mut batch, &rule_dirs);
|
||||
// Again once polling: a refused directory was not read, and
|
||||
@@ -393,7 +535,7 @@ impl DirState {
|
||||
tracing::debug!(
|
||||
received,
|
||||
queued,
|
||||
coalesced = received - queued,
|
||||
coalesced,
|
||||
queue_age_ms,
|
||||
processing_ms,
|
||||
callback_ms = callback.elapsed().as_millis(),
|
||||
@@ -728,6 +870,9 @@ impl EventFilter {
|
||||
Err(_) => None,
|
||||
};
|
||||
let change = match rel.and_then(Self::git_internal) {
|
||||
// Windows also reports a directory modification when Git creates or removes a lock.
|
||||
// The entries carry the actual changes, including edits to a linked worktree's gitfile.
|
||||
Some(true) if change == Change::Modified && path.is_dir() => return,
|
||||
Some(true) => Change::Vcs,
|
||||
Some(false) => return,
|
||||
None if crate::encoding::is_atomic_temp(path) => return,
|
||||
@@ -873,78 +1018,91 @@ mod tests {
|
||||
Event { kind, paths, attrs: Default::default() }
|
||||
}
|
||||
|
||||
fn push_event(pending: &mut PendingEvents, filter: &EventFilter, event: &Event) {
|
||||
let mut changes = QueuedChanges::default();
|
||||
queue_changes(filter, event, &mut changes);
|
||||
pending.add(changes, Instant::now());
|
||||
}
|
||||
|
||||
/// Evidence for the bounded queue (issue #3936): 100,000 notifications over 1,000
|
||||
/// distinct paths, measured before (one raw event each) and after (one change per path).
|
||||
/// `cargo test -p ide-vfs --release --lib -- --ignored --nocapture storm_coalescing_numbers`
|
||||
#[test]
|
||||
#[ignore = "prints queued entries for a storm; see issue #3936"]
|
||||
fn storm_coalescing_numbers() {
|
||||
let root = PathBuf::from("/proj");
|
||||
let filter = EventFilter::new(root.clone(), &[]);
|
||||
let mut pending = PendingEvents::default();
|
||||
for i in 0..100_000 {
|
||||
let event = ev(
|
||||
EventKind::Modify(ModifyKind::Data(DataChange::Content)),
|
||||
vec![root.join(format!("src/{}.zig", i % 1_000))],
|
||||
);
|
||||
push_event(&mut pending, &filter, &event);
|
||||
}
|
||||
let queued = pending.changes.values().map(Vec::len).sum::<usize>();
|
||||
// One entry per path: a repeat of the same change never grows the queue.
|
||||
assert_eq!(queued, 1_000);
|
||||
println!("100,000 raw events over 1,000 paths -> {queued} queued changes (lossless final states)");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn pending_modifications_keep_the_original_debounce_window() {
|
||||
let start = Instant::now();
|
||||
// ReadDirectoryChangesW reports ordinary Windows writes as Modify(Any).
|
||||
let event = ev(EventKind::Modify(ModifyKind::Any), vec!["file.rs".into()]);
|
||||
let mut pending = PendingEvents::default();
|
||||
assert_eq!(pending.deadline(), None);
|
||||
for n in 0..10_000 {
|
||||
pending.push(event.clone(), start + Duration::from_micros(n * 95));
|
||||
let mut changes = QueuedChanges::default();
|
||||
changes.push("file.rs".into(), PathChange::Change(Change::Modified));
|
||||
pending.add(changes, start + Duration::from_micros(n * 95));
|
||||
}
|
||||
assert_eq!(pending.received, 10_000);
|
||||
assert_eq!(pending.events.len(), 1);
|
||||
assert_eq!(pending.changes.len(), 1);
|
||||
assert_eq!(pending.first, Some(start));
|
||||
assert_eq!(pending.last, Some(start + Duration::from_micros(9_999 * 95)));
|
||||
assert_eq!(pending.deadline(), Some(start + MAX_DELAY));
|
||||
let drained = std::mem::take(&mut pending);
|
||||
assert_eq!(drained.events, vec![event.clone()]);
|
||||
assert_eq!(drained.into_events().len(), 1);
|
||||
assert!(pending.is_empty());
|
||||
assert_eq!(pending.deadline(), None);
|
||||
pending.push(event, start + MAX_DELAY);
|
||||
let mut changes = QueuedChanges::default();
|
||||
changes.push("file.rs".into(), PathChange::Change(Change::Modified));
|
||||
pending.add(changes, start + MAX_DELAY);
|
||||
assert_eq!(pending.received, 1);
|
||||
assert_eq!(pending.deadline(), Some(start + MAX_DELAY + DEBOUNCE));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn pending_events_preserve_boundaries_and_attributes() {
|
||||
let now = Instant::now();
|
||||
let modify = ev(EventKind::Modify(ModifyKind::Data(DataChange::Content)), vec!["a".into()]);
|
||||
let variants = [
|
||||
modify.clone().set_tracker(1),
|
||||
modify.clone().set_info("backend detail"),
|
||||
modify.clone().set_process_id(2),
|
||||
modify.clone().set_flag(notify::event::Flag::Rescan),
|
||||
modify.clone().add_path("b".into()),
|
||||
ev(EventKind::Create(CreateKind::File), vec!["a".into()]),
|
||||
ev(EventKind::Remove(RemoveKind::File), vec!["a".into()]),
|
||||
ev(EventKind::Modify(ModifyKind::Name(RenameMode::Both)), vec!["a".into(), "b".into()]),
|
||||
ev(EventKind::Modify(ModifyKind::Name(RenameMode::From)), vec!["a".into()]),
|
||||
ev(EventKind::Modify(ModifyKind::Name(RenameMode::To)), vec!["a".into()]),
|
||||
ev(EventKind::Any, vec!["a".into()]),
|
||||
];
|
||||
for middle in variants {
|
||||
let events = vec![modify.clone(), middle, modify.clone()];
|
||||
let mut pending = PendingEvents::default();
|
||||
for event in &events {
|
||||
pending.push(event.clone(), now);
|
||||
}
|
||||
assert_eq!(pending.events, events);
|
||||
}
|
||||
let mut interleaved = PendingEvents::default();
|
||||
for event in [
|
||||
modify.clone(),
|
||||
modify.clone().set_kind(EventKind::Create(CreateKind::File)).add_path("b".into()),
|
||||
modify.clone(),
|
||||
fn pending_coalesces_a_storm_into_one_change_per_path() {
|
||||
let root = PathBuf::from("/proj");
|
||||
let filter = EventFilter::new(root.clone(), &[]);
|
||||
let mut pending = PendingEvents::default();
|
||||
// create → modify → modify → remove resolves to the final state of the path;
|
||||
// the event stream is lossless for every consumer that sees that final state.
|
||||
for kind in [
|
||||
EventKind::Create(CreateKind::File),
|
||||
EventKind::Modify(ModifyKind::Data(DataChange::Content)),
|
||||
EventKind::Modify(ModifyKind::Data(DataChange::Content)),
|
||||
] {
|
||||
interleaved.push(event, now);
|
||||
}
|
||||
assert_eq!(interleaved.events.len(), 3);
|
||||
let mut interleaved = PendingEvents::default();
|
||||
for event in [modify.clone(), ev(modify.kind, vec!["b".into()]), modify.clone()] {
|
||||
interleaved.push(event, now);
|
||||
}
|
||||
assert_eq!(interleaved.events.len(), 3);
|
||||
for event in [
|
||||
modify.set_flag(notify::event::Flag::Rescan),
|
||||
ev(EventKind::Modify(ModifyKind::Name(RenameMode::From)), vec!["a".into()]),
|
||||
] {
|
||||
let mut pending = PendingEvents::default();
|
||||
pending.push(event.clone(), now);
|
||||
pending.push(event, now);
|
||||
assert_eq!(pending.events.len(), 2);
|
||||
push_event(&mut pending, &filter, &ev(kind, vec![root.join("a.zig")]));
|
||||
}
|
||||
assert_eq!(
|
||||
pending.changes[&root.join("a.zig")],
|
||||
vec![PathChange::Change(Change::Created), PathChange::Change(Change::Modified)]
|
||||
);
|
||||
push_event(&mut pending, &filter, &ev(EventKind::Remove(RemoveKind::File), vec![root.join("a.zig")]));
|
||||
assert_eq!(
|
||||
pending.changes[&root.join("a.zig")],
|
||||
vec![
|
||||
PathChange::Change(Change::Created),
|
||||
PathChange::Change(Change::Modified),
|
||||
PathChange::Change(Change::Removed)
|
||||
]
|
||||
);
|
||||
push_event(&mut pending, &filter, &ev(EventKind::Create(CreateKind::File), vec![root.join("b.zig")]));
|
||||
assert_eq!(pending.changes.len(), 2);
|
||||
assert_eq!(pending.received, 5);
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -958,15 +1116,16 @@ mod tests {
|
||||
assert_ne!(paths[0].as_os_str(), paths[1].as_os_str());
|
||||
let events: Vec<_> =
|
||||
paths.into_iter().map(|path| Event::new(EventKind::Modify(ModifyKind::Any)).add_path(path)).collect();
|
||||
let filter = EventFilter::new(root.clone(), &[]);
|
||||
let mut pending = PendingEvents::default();
|
||||
for event in &events {
|
||||
pending.push(event.clone(), Instant::now());
|
||||
let mut changes = QueuedChanges::default();
|
||||
queue_changes(&filter, event, &mut changes);
|
||||
pending.add(changes, Instant::now());
|
||||
}
|
||||
assert_eq!(pending.events.len(), events.len());
|
||||
assert_same_batch(
|
||||
&EventFilter::new(root.clone(), &[]).batch(&events),
|
||||
&EventFilter::new(root, &[]).batch(&pending.events),
|
||||
);
|
||||
// Path equality merges the spellings; one final state is all any consumer can see.
|
||||
assert_eq!(pending.changes.len(), 1);
|
||||
assert_same_batch(&filter.batch(&events), &EventFilter::new(root, &[]).batch(&pending.into_events()));
|
||||
}
|
||||
|
||||
fn assert_same_batch(left: &FsBatch, right: &FsBatch) {
|
||||
@@ -995,29 +1154,37 @@ mod tests {
|
||||
EventKind::Modify(ModifyKind::Metadata(MetadataKind::WriteTime)),
|
||||
EventKind::Modify(ModifyKind::Name(RenameMode::From)),
|
||||
EventKind::Modify(ModifyKind::Name(RenameMode::To)),
|
||||
// The macOS FSEvents rename (no peer), and whole-event kinds the batch handles.
|
||||
EventKind::Modify(ModifyKind::Name(RenameMode::Any)),
|
||||
EventKind::Modify(ModifyKind::Name(RenameMode::Other)),
|
||||
EventKind::Any,
|
||||
EventKind::Other,
|
||||
// A `Both` rename missing its second endpoint (some inotify backends).
|
||||
EventKind::Modify(ModifyKind::Name(RenameMode::Both)),
|
||||
];
|
||||
// All four-event histories, with both present and absent final state.
|
||||
// All three-event histories, with both present and absent final state.
|
||||
for rel in ["source.rs", "file.ignored", "excluded/source.rs", ".git/HEAD"] {
|
||||
let path = root.join(rel);
|
||||
for exists in [false, true] {
|
||||
if exists {
|
||||
std::fs::write(&path, "x").unwrap();
|
||||
}
|
||||
for code in 0..kinds.len().pow(4) {
|
||||
for code in 0..kinds.len().pow(3) {
|
||||
let mut code = code;
|
||||
let mut events = Vec::new();
|
||||
let mut pending = PendingEvents::default();
|
||||
for _ in 0..4 {
|
||||
let filter = EventFilter::new(root.clone(), &excludes);
|
||||
for _ in 0..3 {
|
||||
let event = ev(kinds[code % kinds.len()], vec![path.clone()]);
|
||||
code /= kinds.len();
|
||||
// Each event is repeated to exercise compaction after transitions.
|
||||
// Each event is repeated to exercise coalescing after transitions.
|
||||
for _ in 0..2 {
|
||||
events.push(event.clone());
|
||||
pending.push(event.clone(), Instant::now());
|
||||
push_event(&mut pending, &filter, &event);
|
||||
}
|
||||
}
|
||||
let plain = EventFilter::new(root.clone(), &excludes).batch(&events);
|
||||
let compact = EventFilter::new(root.clone(), &excludes).batch(&pending.events);
|
||||
let compact = EventFilter::new(root.clone(), &excludes).batch(&pending.into_events());
|
||||
assert_same_batch(&plain, &compact);
|
||||
}
|
||||
}
|
||||
@@ -1053,13 +1220,13 @@ mod tests {
|
||||
std::fs::write(root.join("new.rs"), "x").unwrap();
|
||||
let mut pending = PendingEvents::default();
|
||||
for event in &events {
|
||||
pending.push(event.clone(), Instant::now());
|
||||
push_event(&mut pending, &plain, event);
|
||||
}
|
||||
let expected = plain.batch(&events);
|
||||
assert_eq!(expected.ignore_rules, vec![root.clone()]);
|
||||
assert_eq!(expected.ignored, vec![root.join("file.ignored")]);
|
||||
assert!(!expected.modified.contains(&root.join("file.ignored")));
|
||||
assert_same_batch(&expected, &compact.batch(&pending.events));
|
||||
assert_same_batch(&expected, &compact.batch(&pending.into_events()));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1330,6 +1497,43 @@ mod tests {
|
||||
assert_eq!(g(".git/objects"), Some(false));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn git_metadata_directory_touches_do_not_refresh_vcs() {
|
||||
let tmp = tempfile::tempdir().unwrap();
|
||||
let root = dunce::canonicalize(tmp.path()).unwrap();
|
||||
let filter = EventFilter::new(root.clone(), &[]);
|
||||
let modify = EventKind::Modify(ModifyKind::Any);
|
||||
for (dir, lock) in
|
||||
[(".git", "index.lock"), (".git/refs/heads", "main.lock"), (".git/worktrees/wt", "index.lock")]
|
||||
{
|
||||
let dir = root.join(dir);
|
||||
std::fs::create_dir_all(&dir).unwrap();
|
||||
let lock = dir.join(lock);
|
||||
let batch = filter.batch(&[
|
||||
ev(EventKind::Create(CreateKind::File), vec![lock.clone()]),
|
||||
ev(EventKind::Remove(RemoveKind::File), vec![lock]),
|
||||
ev(modify, vec![dir.clone()]),
|
||||
]);
|
||||
assert!(batch.is_empty(), "{}: {batch:?}", dir.display());
|
||||
for kind in [EventKind::Create(CreateKind::Folder), EventKind::Remove(RemoveKind::Folder)] {
|
||||
let batch = filter.batch(&[ev(kind, vec![dir.clone()])]);
|
||||
assert_eq!(batch.vcs, vec![dir.clone()]);
|
||||
}
|
||||
}
|
||||
|
||||
let gitfile = root.join("wt/.git");
|
||||
std::fs::create_dir_all(root.join("wt")).unwrap();
|
||||
std::fs::write(&gitfile, "gitdir: ../.git/worktrees/wt\n").unwrap();
|
||||
let index = root.join(".git/index");
|
||||
let head = root.join(".git/refs/heads/main");
|
||||
std::fs::write(&index, b"index data").unwrap();
|
||||
std::fs::write(&head, b"commit id").unwrap();
|
||||
for path in [gitfile, index, head] {
|
||||
let batch = filter.batch(&[ev(modify, vec![path.clone()])]);
|
||||
assert_eq!(batch.vcs, vec![path]);
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn nested_gitignore_and_rule_changes_in_one_batch() {
|
||||
let tmp = tempfile::tempdir().unwrap();
|
||||
@@ -1941,8 +2145,7 @@ mod tests {
|
||||
std::fs::create_dir_all(file.parent().unwrap()).unwrap();
|
||||
std::fs::write(&file, "x").unwrap();
|
||||
let created = Event::new(EventKind::Create(notify::event::CreateKind::Folder)).add_path(root.join("new"));
|
||||
inner.state.queue.lock().push(created, Instant::now());
|
||||
inner.state.wake.notify_all();
|
||||
inner.state.enqueue(created);
|
||||
// Written before polling took over, so the poller never reports it.
|
||||
assert!(wait_for(&batches, |b| all_paths(b).contains(&file)), "{:?}", batches.lock());
|
||||
// root, a, c, new, new/inner
|
||||
|
||||
@@ -40,10 +40,12 @@ fn original(input: &[Event], filter: &EventFilter) -> (usize, FsBatch) {
|
||||
fn compact(input: &[Event], filter: &EventFilter) -> (usize, FsBatch) {
|
||||
let mut queue = PendingEvents::default();
|
||||
for event in input {
|
||||
queue.push(event.clone(), Instant::now());
|
||||
let mut changes = QueuedChanges::default();
|
||||
queue_changes(filter, event, &mut changes);
|
||||
queue.add(changes, Instant::now());
|
||||
}
|
||||
let events = std::mem::take(&mut queue);
|
||||
(events.events.len(), filter.batch(&events.events))
|
||||
let queued = queue.changes.values().map(Vec::len).sum::<usize>();
|
||||
(queued, filter.batch(&queue.into_events()))
|
||||
}
|
||||
|
||||
fn event(kind: EventKind, root: &Path, rel: &str) -> Event {
|
||||
@@ -126,15 +128,16 @@ fn pipeline_comparison_preserves_batches_and_rule_changes() {
|
||||
for reverse in [false, true] {
|
||||
let (old, new) = pair(&input, &root, warm, reverse);
|
||||
assert_eq!(old, 32);
|
||||
let expected = match name {
|
||||
"repeated" => 1,
|
||||
"distinct" | "interleaved" => 32,
|
||||
"pairs" => 16,
|
||||
"runs10" => 4,
|
||||
"mixed" => 28,
|
||||
_ => unreachable!(),
|
||||
};
|
||||
assert_eq!(new, expected, "{name}");
|
||||
// The queue holds exactly one merged change per distinct changed path;
|
||||
// the batch `pair` already checked is identical to the un-coalesced one.
|
||||
let filter = EventFilter::new(root.clone(), &["excluded".to_owned()]);
|
||||
let mut queued = PendingEvents::default();
|
||||
for event in &input {
|
||||
let mut changes = QueuedChanges::default();
|
||||
queue_changes(&filter, event, &mut changes);
|
||||
queued.add(changes, Instant::now());
|
||||
}
|
||||
assert_eq!(new, queued.changes.values().map(Vec::len).sum::<usize>(), "{name}");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -153,7 +156,13 @@ fn pipeline_comparison_preserves_batches_and_rule_changes() {
|
||||
}
|
||||
let (old, new) = pair(&special, &root, true, false);
|
||||
assert_eq!(old, special.len());
|
||||
assert_eq!(new, special.len());
|
||||
// Attributes no longer keep identical paths apart: one merged change per path.
|
||||
let mut queued = QueuedChanges::default();
|
||||
let filter = EventFilter::new(root.clone(), &[]);
|
||||
for event in &special {
|
||||
queue_changes(&filter, event, &mut queued);
|
||||
}
|
||||
assert_eq!(new, queued.paths.values().map(Vec::len).sum::<usize>());
|
||||
for rule in [".gitignore", ".ignore", ".git/info/exclude"] {
|
||||
let tmp = fixture(1);
|
||||
let root = dunce::canonicalize(tmp.path()).unwrap();
|
||||
|
||||
@@ -846,6 +846,7 @@ mod tests {
|
||||
"wrapAtMargin": false,
|
||||
"disabledPluginChecks": [],
|
||||
"doubleClickOpensDiff": null,
|
||||
"includeChangesByDefault": true,
|
||||
"agentInstructions": "",
|
||||
"agent": "",
|
||||
"agentModel": "",
|
||||
|
||||
@@ -83,6 +83,8 @@ On your own messages you can **Edit** (the messages after it are replaced; files
|
||||
|
||||
In an existing chat, open **Model › Refresh models** to discover newly available models without sending a message or changing the selection. If the agent can't switch in place, the choice stays pending. You can choose an effort level as soon as the provider reports the new model's options. On your next message, OpenIDEA reopens the same session and applies the model and any effort you selected before sending. If the session can't be reopened or rejects either choice, OpenIDEA restores the previous selection and reports the error without sending the message.
|
||||
|
||||
The model picker of an existing chat offers the agent's current model list, the same one New Task uses, plus the model the chat runs. It doesn't depend on what that chat's session reported when it started, so a model found by a refresh in any chat or in New Task can be chosen in every chat of that agent.
|
||||
|
||||
**Focus Agent Input** defaults to `⌘L` on macOS and `Ctrl+L` on Windows / Linux in every built-in keymap. When focus is inside your writable task conversation, in either an editor tab or the tool window, it returns focus to the message input without changing your draft, caret position or selection—even when pressed repeatedly. It does not send a message or jump through message history.
|
||||
|
||||
With focus anywhere else, the same shortcut jumps to the message input of the task shown in an editor tab or the tool window (the one you used last, if several are shown), unless a panel claims the shortcut there: in a code editor `⌘L` / `Ctrl+L` keeps its editor meaning (for example Go to Line), and in a terminal on Windows / Linux `Ctrl+L` still reaches the shell. It does not apply to archived tasks, subagent conversations or the New Task page, and does not take focus from open popups or dialogs. To change or remove the binding, open **Settings › Keymap › Agents › Focus Agent Input**.
|
||||
|
||||
@@ -49,10 +49,13 @@ never to a settings file. The **+**, **−** and copy buttons above the list add
|
||||
### `~/.ssh/config` support
|
||||
|
||||
OpenIDEA has its own SSH client and reads `~/.ssh/config` itself. It understands `Host`, `Match`, `Include`,
|
||||
`HostName`, `User`, `Port`, `IdentityFile`, `ProxyJump`, `ProxyCommand`, `StrictHostKeyChecking` and
|
||||
`HostName`, `User`, `Port`, `IdentityFile`, `IdentityAgent`, `ProxyJump`, `ProxyCommand`, `StrictHostKeyChecking` and
|
||||
`UserKnownHostsFile`. Jump hosts authenticate with the agent and identity files; the password or passphrase of the
|
||||
configuration is only used for the target host.
|
||||
|
||||
The SSH agent is the one `IdentityAgent` names, otherwise `SSH_AUTH_SOCK` as your login shell sets it, so an agent
|
||||
socket exported in `~/.zshrc` (for example a password manager's agent) works even when OpenIDEA is started from the Dock.
|
||||
|
||||
Host keys are checked against `known_hosts`. An unknown key has to be trusted once; a changed key is refused unless
|
||||
host key checking is turned off for that host.
|
||||
|
||||
|
||||
@@ -36,7 +36,7 @@ Enable or disable postfix completion, individual templates, `Tab` expansion and
|
||||
|
||||
## Emmet
|
||||
|
||||
In HTML, Vue and Svelte files, and in CSS, SCSS, Less and Sass, `⇥` / `Tab` expands Emmet abbreviations, for example `ul>li*3` or `m10`. In markup files, the editor context menu also has **Update Tag with Emmet**, which rewrites the tag at the caret from an abbreviation.
|
||||
In HTML, Vue, Svelte, JSX and TSX files, and in CSS, SCSS, Less and Sass, `⇥` / `Tab` expands Emmet abbreviations, for example `ul>li*3` or `m10`. In markup files, the editor context menu also has **Update Tag with Emmet**, which rewrites the tag at the caret from an abbreviation.
|
||||
|
||||
## Write your own templates
|
||||
|
||||
|
||||
@@ -96,7 +96,7 @@ With **Do not step into library scripts** (**Settings › Build, Execution, Depl
|
||||
|
||||
## Framework support
|
||||
|
||||
- **React**: JSX and TSX get their own highlighting modes and full TypeScript server support. There is no React-specific tooling beyond that.
|
||||
- **React**: JSX and TSX get their own highlighting modes and full TypeScript server support. Typing `>` closes the tag, renaming an opening or closing tag renames its partner, and completing a prop name or typing `=` after one inserts `""` for string props or `{}` for others (from the prop's type). `⇥` / `Tab` expands Emmet abbreviations among an element's children or after `return` / `=>`: `.card` becomes `<div className="card"></div>`.
|
||||
- **Vue**: `.vue` files are highlighted per block and served by Vue Language Server in hybrid mode. In a Vue CLI project without `tsconfig.json`, webpack's `resolve.alias` entries (such as `@/`) are read so imports resolve. Prettier formats `.vue` files. Emmet works in templates.
|
||||
- **Svelte**: Svelte Language Server; highlighting uses the HTML mode (script as TypeScript, style as CSS). Emmet works in markup.
|
||||
- **Astro**: Astro Language Server with its own highlighting mode. It needs Node.js; if it can't find one, select it in **Settings › Languages & Frameworks › JavaScript Runtime**.
|
||||
@@ -109,4 +109,3 @@ With **Do not step into library scripts** (**Settings › Build, Execution, Depl
|
||||
- Bun runs but can't be debugged: its inspector uses the WebKit protocol, which vscode-js-debug can't attach to.
|
||||
- Deno has run and debug support but no Deno language server; Deno files use the TypeScript servers.
|
||||
- Coverage of Deno tasks is not supported.
|
||||
- Emmet expands in HTML, Vue and Svelte, not in JSX.
|
||||
@@ -83,6 +83,8 @@ Codex 有自己的项目信任设置。如果它禁用了当前项目的 `.codex
|
||||
|
||||
在已有对话中,打开**模型 › 刷新模型**即可查找新上线的模型,不会发送消息或更改当前选择。如果 agent 无法直接切换,所选模型会保持待应用状态。提供商返回新模型支持的思考强度后,你就可以选择强度。发送下一条消息时,OpenIDEA 会先恢复原会话并应用所选模型和思考强度,再发送消息。如果无法恢复会话,或原会话不接受其中任何一项,OpenIDEA 会还原之前的选择并提示错误,不会发送该消息。
|
||||
|
||||
已有对话的模型选择器会列出该 agent 当前的模型列表(与新任务使用的相同),外加该对话正在使用的模型。它不依赖该对话会话启动时报告的列表,因此在任一对话或新任务中通过刷新找到的模型,可在该 agent 的所有对话中选用。
|
||||
|
||||
所有内置按键映射中,**聚焦 Agent 输入框** 的默认快捷键都是 macOS 上的 `⌘L`、Windows / Linux 上的 `Ctrl+L`。焦点位于你自己的可输入任务对话中时,无论对话显示在编辑器标签页还是工具窗口中,它都会将焦点移回消息输入框,保留草稿、光标位置和选区;重复按下也不会改变这些内容。它不会发送消息,也不会跳转消息历史。
|
||||
|
||||
焦点位于其他位置时,同一快捷键会跳转到编辑器标签页或工具窗口中显示的任务的消息输入框(显示多个时,选择你最近使用的那个),除非该位置有面板占用此快捷键:在代码编辑器中,`⌘L` / `Ctrl+L` 保留编辑器含义(例如“转到行”);在 Windows / Linux 的终端中,`Ctrl+L` 仍会发送给 shell。此快捷键不适用于已归档任务、子 agent 对话或“新建任务”页面,也不会从打开的弹出窗口或对话框中抢走焦点。要修改或移除绑定,请打开 **设置 › 按键映射 › 智能体 › 聚焦 Agent 输入框**。
|
||||
|
||||
@@ -41,9 +41,12 @@ OpenIDEA 通过 SSH 连接;在 Windows 上也可以直接连入 WSL 发行版
|
||||
### `~/.ssh/config` 支持
|
||||
|
||||
OpenIDEA 自带 SSH 客户端,自行读取 `~/.ssh/config`,支持 `Host`、`Match`、`Include`、`HostName`、`User`、`Port`、
|
||||
`IdentityFile`、`ProxyJump`、`ProxyCommand`、`StrictHostKeyChecking` 和 `UserKnownHostsFile`。跳板机通过代理和身份文件认证,
|
||||
`IdentityFile`、`IdentityAgent`、`ProxyJump`、`ProxyCommand`、`StrictHostKeyChecking` 和 `UserKnownHostsFile`。跳板机通过代理和身份文件认证,
|
||||
配置里的密码或密码短语只用于目标主机。
|
||||
|
||||
SSH 代理使用 `IdentityAgent` 指定的那个,未指定时使用登录 shell 设置的 `SSH_AUTH_SOCK`,所以在 `~/.zshrc` 里导出的代理 socket
|
||||
(例如密码管理器的 SSH 代理)在从程序坞启动 OpenIDEA 时也能用。
|
||||
|
||||
主机密钥会与 `known_hosts` 比对。未知密钥需要先信任一次;密钥发生变化时会拒绝连接,除非对该主机关闭了主机密钥检查。
|
||||
|
||||
## 打开远程项目
|
||||
|
||||
@@ -36,7 +36,7 @@ items.for → for (var item : items) { … }
|
||||
|
||||
## Emmet
|
||||
|
||||
在 HTML、Vue、Svelte 文件以及 CSS、SCSS、Less、Sass 中,`⇥` / `Tab` 会展开 Emmet 缩写,例如 `ul>li*3` 或 `m10`。在标记语言文件中,编辑器右键菜单还提供 **使用 Emmet 更新标签**,用一个缩写改写光标所在的标签。
|
||||
在 HTML、Vue、Svelte、JSX、TSX 文件以及 CSS、SCSS、Less、Sass 中,`⇥` / `Tab` 会展开 Emmet 缩写,例如 `ul>li*3` 或 `m10`。在标记语言文件中,编辑器右键菜单还提供 **使用 Emmet 更新标签**,用一个缩写改写光标所在的标签。
|
||||
|
||||
## 编写自己的模板
|
||||
|
||||
|
||||
@@ -96,7 +96,7 @@ Jest 和 Vitest 的输出会解析成测试树,支持 **重新运行失败的
|
||||
|
||||
## 框架支持
|
||||
|
||||
- **React**:JSX 和 TSX 有各自的高亮模式,并获得完整的 TypeScript 服务器支持;除此之外没有 React 专属功能。
|
||||
- **React**:JSX 和 TSX 有各自的高亮模式,并获得完整的 TypeScript 服务器支持。输入 `>` 会自动闭合标签,修改开始或结束标签名会同步修改另一端,补全属性名或在属性名后输入 `=` 会按属性类型插入 `""`(字符串)或 `{}`(其他类型)。在元素的子内容中或 `return` / `=>` 之后,`⇥` / `Tab` 会展开 Emmet 缩写:`.card` 会变成 `<div className="card"></div>`。
|
||||
- **Vue**:`.vue` 文件按块高亮,由 Vue Language Server 以 hybrid 模式提供支持。没有 `tsconfig.json` 的 Vue CLI 项目会读取 webpack 的 `resolve.alias`(如 `@/`),让 import 能正确解析。Prettier 可格式化 `.vue` 文件,模板中可用 Emmet。
|
||||
- **Svelte**:使用 Svelte Language Server;高亮沿用 HTML 模式(script 按 TypeScript、style 按 CSS),标记部分可用 Emmet。
|
||||
- **Astro**:使用 Astro Language Server,有专门的高亮模式。它需要 Node.js,找不到时请在 **设置 › 语言和框架 › JavaScript 运行时** 中选择。
|
||||
@@ -109,4 +109,3 @@ Jest 和 Vitest 的输出会解析成测试树,支持 **重新运行失败的
|
||||
- Bun 可以运行但无法调试:它的 inspector 使用 WebKit 协议,vscode-js-debug 无法附加。
|
||||
- Deno 支持运行和调试,但没有 Deno 语言服务器,Deno 文件使用 TypeScript 服务器。
|
||||
- 不支持 Deno task 的覆盖率。
|
||||
- Emmet 只在 HTML、Vue 和 Svelte 中展开,JSX 中不可用。
|
||||
@@ -0,0 +1,74 @@
|
||||
import { expect, test } from "./fixtures";
|
||||
|
||||
test("Appearance keeps themes and UI font controls grouped across Settings widths", async ({ workbench: page }) => {
|
||||
await page.setViewportSize({ width: 1120, height: 800 });
|
||||
await page.keyboard.press("Meta+,");
|
||||
const dialog = page.getByRole("dialog", { name: "Settings", exact: true });
|
||||
const search = dialog.getByRole("textbox", { name: "Search settings" });
|
||||
await search.fill("Use custom font");
|
||||
await dialog.getByRole("treeitem", { name: "Appearance", exact: true }).click();
|
||||
await search.clear();
|
||||
|
||||
const theme = dialog.getByRole("button", { name: "Theme", exact: true });
|
||||
const sync = dialog.getByRole("checkbox", { name: "Sync with OS", exact: true });
|
||||
const preferences = dialog.getByRole("button", { name: "Preferred themes", exact: true });
|
||||
const more = dialog.getByRole("button", { name: "Get more themes", exact: true });
|
||||
const font = dialog.getByRole("combobox", { name: "UI font", exact: true });
|
||||
const fallback = dialog.getByRole("combobox", { name: "UI fallback font", exact: true });
|
||||
const size = dialog.getByRole("textbox", { name: "UI font size", exact: true });
|
||||
const custom = dialog.getByRole("checkbox", { name: "Use custom font:", exact: true });
|
||||
await expect(preferences).toBeDisabled();
|
||||
await expect(font).toBeDisabled();
|
||||
await expect(size).toBeDisabled();
|
||||
await expect(fallback).toBeDisabled();
|
||||
|
||||
const [themeBox, gearBox, linkBox, fontBox, sizeBox, fallbackBox] = await Promise.all(
|
||||
[theme, preferences, more, font, size, fallback].map((control) => control.boundingBox()),
|
||||
);
|
||||
if (!themeBox || !gearBox || !linkBox || !fontBox || !sizeBox || !fallbackBox) {
|
||||
throw new Error("Missing Appearance control bounds");
|
||||
}
|
||||
expect(linkBox.y).toBeGreaterThan(themeBox.y + themeBox.height);
|
||||
expect(gearBox.x).toBeGreaterThan(themeBox.x + themeBox.width);
|
||||
expect(gearBox.y + gearBox.height / 2).toBeCloseTo(themeBox.y + themeBox.height / 2, 0);
|
||||
expect(sizeBox.y).toBeCloseTo(fontBox.y, 0);
|
||||
expect(sizeBox.x).toBeGreaterThan(fontBox.x + fontBox.width);
|
||||
expect(fallbackBox.x).toBeCloseTo(fontBox.x, 0);
|
||||
expect(fallbackBox.y).toBeGreaterThan(fontBox.y);
|
||||
|
||||
await sync.check();
|
||||
await expect(theme).toBeDisabled();
|
||||
for (const width of [580, 520]) {
|
||||
await page.setViewportSize({ width, height: 800 });
|
||||
await preferences.click();
|
||||
const popup = page.getByRole("dialog", { name: "Preferred themes", exact: true });
|
||||
const light = popup.getByRole("button", { name: "Preferred light theme", exact: true });
|
||||
const dark = popup.getByRole("button", { name: "Preferred dark theme", exact: true });
|
||||
await expect(light).toBeInViewport({ ratio: 1 });
|
||||
await expect(dark).toBeInViewport({ ratio: 1 });
|
||||
const [lightBox, darkBox] = await Promise.all([light.boundingBox(), dark.boundingBox()]);
|
||||
if (!lightBox || !darkBox) throw new Error("Missing preferred theme bounds");
|
||||
expect(lightBox.x).toBeCloseTo(darkBox.x, 0);
|
||||
expect(lightBox.width).toBeCloseTo(darkBox.width, 0);
|
||||
await page.keyboard.press("Escape");
|
||||
await expect(popup).toBeHidden();
|
||||
for (const field of [font, size, fallback]) await expect(field).toBeInViewport({ ratio: 1 });
|
||||
const [narrowFont, narrowSize, narrowFallback] = await Promise.all(
|
||||
[font, size, fallback].map((control) => control.boundingBox()),
|
||||
);
|
||||
if (!narrowFont || !narrowSize || !narrowFallback) throw new Error("Missing narrow font control bounds");
|
||||
expect(narrowSize.y).toBeGreaterThan(narrowFont.y);
|
||||
expect(narrowFallback.x).toBeCloseTo(narrowFont.x, 0);
|
||||
}
|
||||
|
||||
await custom.check();
|
||||
await font.fill("Inter");
|
||||
await size.fill("15");
|
||||
await fallback.fill("Noto Sans CJK SC");
|
||||
await fallback.press("Enter");
|
||||
await expect(font).toHaveValue("Inter");
|
||||
await expect(size).toHaveValue("15");
|
||||
await expect(fallback).toHaveValue("Noto Sans CJK SC");
|
||||
await dialog.getByRole("button", { name: "Cancel", exact: true }).click();
|
||||
await expect(dialog).toBeHidden();
|
||||
});
|
||||
@@ -0,0 +1,95 @@
|
||||
import type { Page } from "@playwright/test";
|
||||
import type { PatchFile } from "../src/bindings";
|
||||
import { expect, ipcCalls, stubDesktop, test } from "./fixtures";
|
||||
|
||||
const repo = "/dev/billing";
|
||||
const path = "/tmp/release-2026/requests/adjust-invoices.patch";
|
||||
const patch = "diff --git a/ledger/invoice.ts b/ledger/invoice.ts";
|
||||
const invoice: PatchFile = {
|
||||
path: "ledger/invoice.ts",
|
||||
oldPath: null,
|
||||
kind: "modified",
|
||||
added: 3,
|
||||
removed: 1,
|
||||
binary: false,
|
||||
applies: true,
|
||||
};
|
||||
|
||||
async function openPatch(page: Page, source: "file" | "clipboard", files: PatchFile[]) {
|
||||
await page.evaluate(
|
||||
async ({ source, repo, path, patch, files }) => {
|
||||
const handlers = window.__ipc.handlers;
|
||||
handlers.fs_read_text = () => patch;
|
||||
handlers.clipboard_text = () => patch;
|
||||
handlers.vcs_patch_preview = () => files;
|
||||
handlers.vcs_apply_patch = () => ({ applied: [files[0]?.path], conflicts: [] });
|
||||
const store = "/src/features/vcs/store.ts";
|
||||
const context = "/src/platform/context.ts";
|
||||
const actions = "/src/platform/actions.ts";
|
||||
(await import(/* @vite-ignore */ store)).useVcs.setState({ available: true, root: repo, repo, roots: [repo] });
|
||||
(await import(/* @vite-ignore */ context)).setContext("vcsAvailable", true);
|
||||
const { executeAction } = await import(/* @vite-ignore */ actions);
|
||||
await executeAction(source === "file" ? "vcs.applyPatch" : "vcs.applyPatchFromClipboard", path);
|
||||
},
|
||||
{ source, repo, path, patch, files },
|
||||
);
|
||||
}
|
||||
|
||||
test("Apply Patch keeps the source, repository and file status aligned in a narrow dialog", async ({
|
||||
workbench: page,
|
||||
}) => {
|
||||
await page.setViewportSize({ width: 485, height: 490 });
|
||||
await stubDesktop(page);
|
||||
await openPatch(page, "file", [
|
||||
invoice,
|
||||
{ ...invoice, path: "apps/batch/ledger/international/settlement/settle-invoice.ts", applies: false },
|
||||
...Array.from({ length: 20 }, (_, i) => ({ ...invoice, path: `ledger/settlement-${i + 1}.ts` })),
|
||||
]);
|
||||
const dialog = page.getByRole("dialog", { name: "Apply Patch: adjust-invoices.patch", exact: true });
|
||||
const source = dialog.getByRole("textbox", { name: "Patch source", exact: true });
|
||||
const target = dialog.getByRole("textbox", { name: "Repository", exact: true });
|
||||
const list = dialog.getByRole("listbox", { name: "Patch files", exact: true });
|
||||
|
||||
await expect(source).toHaveValue(path);
|
||||
await expect(source).not.toBeEditable();
|
||||
await expect(target).toHaveValue(repo);
|
||||
await expect(dialog.getByRole("heading", { name: "Patch files", exact: true })).toBeVisible();
|
||||
await expect(dialog.getByText("22 files", { exact: true })).toBeVisible();
|
||||
expect((await source.boundingBox())!.y).toBeLessThan((await target.boundingBox())!.y);
|
||||
expect((await target.boundingBox())!.y).toBeLessThan((await list.boundingBox())!.y);
|
||||
|
||||
const stats = list.getByText("+3 −1", { exact: true });
|
||||
const first = (await stats.nth(0).boundingBox())!;
|
||||
const second = (await stats.nth(1).boundingBox())!;
|
||||
expect(Math.abs(first.x - second.x)).toBeLessThan(1);
|
||||
await expect(list.getByLabel("Does not apply cleanly", { exact: true })).toBeInViewport({ ratio: 1 });
|
||||
await expect(dialog.getByRole("status")).toHaveText("1 file will be merged; conflicts open in the merge tool");
|
||||
await list.press("End");
|
||||
await expect(list.getByText("settlement-20.ts", { exact: true })).toBeInViewport({ ratio: 1 });
|
||||
await expect(dialog.getByRole("button", { name: "Apply", exact: true })).toBeInViewport({ ratio: 1 });
|
||||
expect(await dialog.locator("[data-dialog-body]").evaluate((el) => el.scrollWidth - el.clientWidth)).toBe(0);
|
||||
await dialog.getByRole("button", { name: "Cancel", exact: true }).click();
|
||||
await expect(dialog).toBeHidden();
|
||||
expect(await ipcCalls(page, "vcs_apply_patch")).toEqual([]);
|
||||
});
|
||||
|
||||
test("Apply Patch previews clipboard contents and applies them to the previewed repository", async ({
|
||||
workbench: page,
|
||||
}) => {
|
||||
await stubDesktop(page);
|
||||
await openPatch(page, "clipboard", []);
|
||||
const dialog = page.getByRole("dialog", { name: "Apply Patch: Clipboard", exact: true });
|
||||
await expect(dialog.getByRole("textbox", { name: "Patch source", exact: true })).toHaveValue("Clipboard");
|
||||
await expect(dialog.getByText("No changes", { exact: true })).toBeVisible();
|
||||
const apply = dialog.getByRole("button", { name: "Apply", exact: true });
|
||||
await expect(apply).toBeDisabled();
|
||||
await dialog.getByRole("button", { name: "Cancel", exact: true }).click();
|
||||
await expect(dialog).toBeHidden();
|
||||
|
||||
await openPatch(page, "clipboard", [invoice]);
|
||||
await expect(dialog.getByText("1 file", { exact: true })).toBeVisible();
|
||||
await expect(apply).toBeEnabled();
|
||||
await apply.click();
|
||||
await expect(dialog).toBeHidden();
|
||||
await expect.poll(() => ipcCalls(page, "vcs_apply_patch")).toEqual([{ repo, patch }]);
|
||||
});
|
||||
@@ -0,0 +1,88 @@
|
||||
import { expect, test } from "./fixtures";
|
||||
|
||||
test("Background Tasks keeps task details and actions reachable while resizing and scrolling", async ({
|
||||
workbench: page,
|
||||
}) => {
|
||||
await page.setViewportSize({ width: 1200, height: 820 });
|
||||
await page.evaluate(() => {
|
||||
window.addEventListener("error", (event) => {
|
||||
if (event.message.includes("ResizeObserver loop")) document.body.dataset.taskResizeError = event.message;
|
||||
});
|
||||
});
|
||||
const title = "Synchronizing the settlement service and reconciliation workspace";
|
||||
const message = "Reading the payment service dependencies and refreshing the reconciliation workspace model.";
|
||||
await page.evaluate(
|
||||
async ({ title, message }) => {
|
||||
const path = "/src/workbench/tasks.ts";
|
||||
const { upsertTask, removeTask } = await import(/* @vite-ignore */ path);
|
||||
upsertTask({ id: "refresh", title: "Refreshing project files", message: null, fraction: null, done: false });
|
||||
upsertTask({ id: "sync", title, message, fraction: 0.42, done: false, cancel: () => removeTask("sync") });
|
||||
},
|
||||
{ title, message },
|
||||
);
|
||||
|
||||
const status = page.getByRole("button", { name: `Background tasks: ${title}` });
|
||||
await status.click();
|
||||
const popup = page.getByRole("dialog", { name: "Background tasks", exact: true });
|
||||
const resize = popup.getByRole("separator", { name: "Resize" });
|
||||
await expect(resize).toBeVisible();
|
||||
const initial = (await popup.boundingBox())!;
|
||||
const corner = (await resize.boundingBox())!;
|
||||
const x = corner.x + corner.width / 2;
|
||||
const y = corner.y + corner.height / 2;
|
||||
await page.mouse.move(x, y);
|
||||
await page.mouse.down();
|
||||
await page.mouse.move(x + 60, y + 48, { steps: 6 });
|
||||
await page.mouse.up();
|
||||
await expect.poll(async () => (await popup.boundingBox())!.width).toBeGreaterThan(initial.width + 32);
|
||||
const size = (await popup.boundingBox())!;
|
||||
expect(size.height).toBeGreaterThan(initial.height + 24);
|
||||
await popup.getByRole("button", { name: "Close", exact: true }).click();
|
||||
await expect(popup).toBeHidden();
|
||||
await status.click();
|
||||
await expect.poll(async () => (await popup.boundingBox())!.width).toBeCloseTo(size.width, 0);
|
||||
await expect.poll(async () => (await popup.boundingBox())!.height).toBeCloseTo(size.height, 0);
|
||||
|
||||
await page.evaluate(async () => {
|
||||
const path = "/src/workbench/tasks.ts";
|
||||
const { upsertTask } = await import(/* @vite-ignore */ path);
|
||||
for (let i = 1; i <= 10; i++) {
|
||||
upsertTask({
|
||||
id: `check-${i}`,
|
||||
title: `Checking workspace module ${i}`,
|
||||
message: "Reading source files",
|
||||
fraction: null,
|
||||
done: false,
|
||||
});
|
||||
}
|
||||
});
|
||||
await page.setViewportSize({ width: 400, height: 430 });
|
||||
await expect(popup).toBeInViewport({ ratio: 1 });
|
||||
const list = popup.getByRole("list", { name: "Background Tasks" });
|
||||
const sync = list.getByRole("listitem").filter({ hasText: title });
|
||||
const detail = sync.getByText(message, { exact: true });
|
||||
expect(await detail.evaluate((element) => element.scrollWidth - element.clientWidth)).toBe(0);
|
||||
const [detailBox, progressBox] = await Promise.all([
|
||||
detail.boundingBox(),
|
||||
sync.getByRole("progressbar", { name: title }).boundingBox(),
|
||||
]);
|
||||
expect(progressBox!.y).toBeGreaterThan(detailBox!.y + detailBox!.height);
|
||||
expect(
|
||||
await list.evaluate((element) => {
|
||||
element.scrollTop = element.scrollHeight;
|
||||
return element.scrollTop;
|
||||
}),
|
||||
).toBeGreaterThan(0);
|
||||
await expect(popup.getByRole("heading", { name: "Background Tasks" })).toBeInViewport({ ratio: 1 });
|
||||
await sync.getByRole("button", { name: `Cancel ${title}` }).click();
|
||||
await expect(sync).toHaveCount(0);
|
||||
await expect(popup).toBeVisible();
|
||||
|
||||
await page.evaluate(async () => {
|
||||
const path = "/src/workbench/tasks.ts";
|
||||
const { useTasks, removeTask } = await import(/* @vite-ignore */ path);
|
||||
for (const task of useTasks.getState().tasks) removeTask(task.id);
|
||||
});
|
||||
await expect(popup).toBeHidden();
|
||||
expect(await page.locator("body").getAttribute("data-task-resize-error")).toBeNull();
|
||||
});
|
||||
@@ -0,0 +1,85 @@
|
||||
import type { Page } from "@playwright/test";
|
||||
import { expect, openFromTree, test } from "./fixtures";
|
||||
|
||||
async function bookmarkAction(page: Page, id: "navigate.toggleBookmark" | "navigate.showBookmarks") {
|
||||
await page.evaluate(async (id) => {
|
||||
const path = "/src/platform/actions.ts";
|
||||
const { executeAction } = await import(/* @vite-ignore */ path);
|
||||
await executeAction(id);
|
||||
}, id);
|
||||
}
|
||||
|
||||
test("Bookmarks remembers its size and keeps the list and preview usable in a narrow window", async ({
|
||||
workbench: page,
|
||||
}) => {
|
||||
await page.setViewportSize({ width: 1200, height: 820 });
|
||||
const resizeErrors: string[] = [];
|
||||
page.on("pageerror", (error) => {
|
||||
if (error.message.includes("ResizeObserver loop")) resizeErrors.push(error.message);
|
||||
});
|
||||
const editor = await openFromTree(page, "build.gradle.kts");
|
||||
const first = "val order: Order = service.create(req)";
|
||||
const second = "return order.toDto()";
|
||||
for (const line of [first, second]) {
|
||||
await editor.locator(".cm-line", { hasText: line }).click();
|
||||
await bookmarkAction(page, "navigate.toggleBookmark");
|
||||
}
|
||||
|
||||
await bookmarkAction(page, "navigate.showBookmarks");
|
||||
const dialog = page.getByRole("dialog", { name: "Bookmarks", exact: true });
|
||||
const list = dialog.getByRole("listbox", { name: "Bookmarks" });
|
||||
const preview = dialog.getByRole("region", { name: "Preview" });
|
||||
const divider = dialog.getByRole("separator", { name: "Resize bookmark panes", exact: true });
|
||||
await expect(divider).toHaveAttribute("aria-orientation", "vertical");
|
||||
await expect(list).toBeFocused();
|
||||
await expect(list.getByRole("option", { selected: true })).toContainText(first);
|
||||
await expect(preview.locator(".cm-activeLine")).toContainText(first);
|
||||
const lineNumbers = list.getByRole("option").locator(":scope > span > span:last-child");
|
||||
const [firstNumber, secondNumber] = await Promise.all([
|
||||
lineNumbers.nth(0).boundingBox(),
|
||||
lineNumbers.nth(1).boundingBox(),
|
||||
]);
|
||||
expect(firstNumber!.x + firstNumber!.width).toBeCloseTo(secondNumber!.x + secondNumber!.width, 0);
|
||||
const initial = (await dialog.boundingBox())!;
|
||||
expect(initial.x + initial.width / 2).toBeCloseTo(600, 0);
|
||||
expect(Math.abs(initial.y + initial.height / 2 - 410)).toBeLessThan(16);
|
||||
|
||||
const listWidth = (await list.boundingBox())!.width;
|
||||
await divider.press("ArrowRight");
|
||||
await expect.poll(async () => (await list.boundingBox())!.width).toBeGreaterThan(listWidth + 4);
|
||||
|
||||
const corner = (await dialog.getByRole("separator", { name: "Resize", exact: true }).boundingBox())!;
|
||||
const x = corner.x + corner.width / 2;
|
||||
const y = corner.y + corner.height / 2;
|
||||
await page.mouse.move(x, y);
|
||||
await page.mouse.down();
|
||||
await page.mouse.move(x + 80, y + 48, { steps: 6 });
|
||||
await page.mouse.up();
|
||||
await expect.poll(async () => (await dialog.boundingBox())!.width).toBeGreaterThan(initial.width + 50);
|
||||
const resized = (await dialog.boundingBox())!;
|
||||
expect(resized.height).toBeGreaterThan(initial.height + 30);
|
||||
const resizedList = (await list.boundingBox())!.width;
|
||||
await page.keyboard.press("Escape");
|
||||
await expect(dialog).toBeHidden();
|
||||
await bookmarkAction(page, "navigate.showBookmarks");
|
||||
await expect.poll(async () => (await dialog.boundingBox())!.width).toBeCloseTo(resized.width, 0);
|
||||
await expect.poll(async () => (await dialog.boundingBox())!.height).toBeCloseTo(resized.height, 0);
|
||||
await expect.poll(async () => Math.abs((await list.boundingBox())!.width - resizedList)).toBeLessThan(2);
|
||||
|
||||
await page.setViewportSize({ width: 470, height: 430 });
|
||||
await expect(divider).toHaveAttribute("aria-orientation", "horizontal");
|
||||
const narrowList = (await list.boundingBox())!;
|
||||
const narrowPreview = (await preview.boundingBox())!;
|
||||
expect(narrowPreview.y).toBeGreaterThanOrEqual(narrowList.y + narrowList.height - 1);
|
||||
expect(narrowPreview.width).toBeCloseTo(narrowList.width, 0);
|
||||
expect(narrowPreview.height).toBeGreaterThan(100);
|
||||
await expect(dialog).toBeInViewport({ ratio: 1 });
|
||||
|
||||
await list.press("ArrowDown");
|
||||
await expect(list.getByRole("option", { selected: true })).toContainText(second);
|
||||
await expect(preview.locator(".cm-activeLine")).toContainText(second);
|
||||
await list.press("Enter");
|
||||
await expect(dialog).toBeHidden();
|
||||
await expect(editor.locator(".cm-activeLine")).toContainText(second);
|
||||
expect(resizeErrors).toEqual([]);
|
||||
});
|
||||
@@ -0,0 +1,146 @@
|
||||
import type { Page } from "@playwright/test";
|
||||
import type { ChangelistState } from "../src/bindings";
|
||||
import { expect, ipcCalls, stubDesktop, test } from "./fixtures";
|
||||
|
||||
async function action(page: Page, id: string, arg?: string[]) {
|
||||
await page.evaluate(
|
||||
async ({ id, arg }) => {
|
||||
const actions = "/src/platform/actions.ts";
|
||||
const { executeAction } = await import(/* @vite-ignore */ actions);
|
||||
await executeAction(id, arg);
|
||||
},
|
||||
{ id, arg },
|
||||
);
|
||||
}
|
||||
|
||||
async function savedLists(page: Page) {
|
||||
const last = (await ipcCalls(page, "vcs_changelists_save")).at(-1);
|
||||
return last?.changelists as ChangelistState | undefined;
|
||||
}
|
||||
|
||||
test("changelist forms align the fields and preserve multiline comments through create, edit and move", async ({
|
||||
workbench: page,
|
||||
}) => {
|
||||
await page.setViewportSize({ width: 1100, height: 700 });
|
||||
await stubDesktop(page);
|
||||
await page.evaluate(async () => {
|
||||
const root = "/dev/acme-api";
|
||||
const vcsModule = "/src/features/vcs/store.ts";
|
||||
const { useVcs } = await import(/* @vite-ignore */ vcsModule);
|
||||
useVcs.setState({
|
||||
available: true,
|
||||
root,
|
||||
repo: root,
|
||||
roots: [root],
|
||||
status: [{ path: root + "/build.gradle.kts", relPath: "build.gradle.kts", staged: null, unstaged: "modified" }],
|
||||
});
|
||||
const listModule = "/src/features/vcs/changelists.ts";
|
||||
const { initialChangelists, useChangelists } = await import(/* @vite-ignore */ listModule);
|
||||
useChangelists.setState({
|
||||
state: {
|
||||
...initialChangelists(),
|
||||
lists: [
|
||||
...initialChangelists().lists,
|
||||
{ id: "inbox", name: "Review inbox", comment: "Choose a reviewer before merging." },
|
||||
{ id: "unsorted", name: "Unsorted" },
|
||||
],
|
||||
files: { "build.gradle.kts": "default" },
|
||||
},
|
||||
loaded: true,
|
||||
});
|
||||
window.__ipc.handlers.vcs_changelists_save = () => null;
|
||||
const context = "/src/platform/context.ts";
|
||||
const { setContext } = await import(/* @vite-ignore */ context);
|
||||
setContext("vcsAvailable", true);
|
||||
});
|
||||
|
||||
await action(page, "vcs.changelist.new");
|
||||
const create = page.getByRole("dialog", { name: "New Changelist", exact: true });
|
||||
const name = create.getByRole("textbox", { name: "Name:", exact: true });
|
||||
const comment = create.getByRole("textbox", { name: "Comment:", exact: true });
|
||||
const ok = create.getByRole("button", { name: "OK", exact: true });
|
||||
await expect(name).toBeFocused();
|
||||
await expect(ok).toBeDisabled();
|
||||
const nameLabel = (await create.getByText("Name:", { exact: true }).boundingBox())!;
|
||||
const nameField = (await name.boundingBox())!;
|
||||
expect(nameLabel.x + nameLabel.width).toBeLessThan(nameField.x);
|
||||
const commentLabel = (await create.getByText("Comment:", { exact: true }).boundingBox())!;
|
||||
const commentField = (await comment.boundingBox())!;
|
||||
expect(Math.abs(nameField.x - commentField.x)).toBeLessThan(1);
|
||||
expect(commentLabel.x + commentLabel.width).toBeLessThan(commentField.x);
|
||||
expect(commentField.height).toBeGreaterThan(76);
|
||||
await expect(create.getByText("Name:", { exact: true })).toHaveCSS(
|
||||
"font-size",
|
||||
await name.evaluate((el) => getComputedStyle(el).fontSize),
|
||||
);
|
||||
await name.fill("Changes");
|
||||
await expect(name).toHaveAccessibleDescription(/already exists/);
|
||||
await expect(ok).toBeDisabled();
|
||||
|
||||
await name.fill("Release review");
|
||||
await comment.fill("Review the totals.\nAsk for a second check.");
|
||||
await create.getByRole("checkbox", { name: "Set active" }).check();
|
||||
await ok.click();
|
||||
await expect
|
||||
.poll(async () => {
|
||||
const state = await savedLists(page);
|
||||
return state?.lists.find((list) => list.id === state.active)?.comment;
|
||||
})
|
||||
.toBe("Review the totals.\nAsk for a second check.");
|
||||
|
||||
await action(page, "vcs.changelist.edit");
|
||||
const edit = page.getByRole("dialog", { name: "Edit Changelist", exact: true });
|
||||
await expect(edit.getByRole("textbox", { name: "Name:", exact: true })).toHaveValue("Release review");
|
||||
const editComment = edit.getByRole("textbox", { name: "Comment:", exact: true });
|
||||
await expect(editComment).toHaveValue("Review the totals.\nAsk for a second check.");
|
||||
await expect(edit.getByRole("checkbox", { name: "Set active" })).toBeDisabled();
|
||||
await editComment.fill("Review complete.\nReady for the release checklist.");
|
||||
await edit.getByRole("button", { name: "OK", exact: true }).click();
|
||||
await expect
|
||||
.poll(async () => (await savedLists(page))?.lists.find((list) => list.name === "Release review")?.comment)
|
||||
.toBe("Review complete.\nReady for the release checklist.");
|
||||
|
||||
await action(page, "vcs.changelist.move", ["/dev/acme-api/build.gradle.kts"]);
|
||||
const move = page.getByRole("dialog", { name: "Move Changes to Another Changelist" });
|
||||
const newName = move.getByRole("textbox", { name: "Name:", exact: true });
|
||||
const targetComment = move.getByRole("textbox", { name: "Comment:", exact: true });
|
||||
const moveOk = move.getByRole("button", { name: "OK", exact: true });
|
||||
await expect(newName).toBeFocused();
|
||||
await expect(newName).toHaveValue("Release review");
|
||||
await expect(targetComment).toHaveAttribute("readonly", "");
|
||||
await newName.press("ArrowDown");
|
||||
const options = page.getByRole("listbox", { name: "Target changelist" });
|
||||
await expect(options).toBeVisible();
|
||||
await page.keyboard.press("Escape");
|
||||
await expect(options).toBeHidden();
|
||||
await expect(newName).toBeFocused();
|
||||
await newName.press("ArrowDown");
|
||||
await expect(options.getByRole("option", { name: "Changes", exact: true })).toHaveCount(0);
|
||||
await options.getByRole("option", { name: "Review inbox", exact: true }).click();
|
||||
await expect(newName).toHaveValue("Review inbox");
|
||||
await expect(targetComment).toHaveValue("Choose a reviewer before merging.");
|
||||
await newName.fill("Changes");
|
||||
await expect(newName).toHaveAccessibleDescription(/already exists/);
|
||||
await expect(moveOk).toBeDisabled();
|
||||
|
||||
await page.setViewportSize({ width: 400, height: 540 });
|
||||
const stackedName = (await newName.boundingBox())!;
|
||||
const stackedLabel = (await move.getByText("Name:", { exact: true }).boundingBox())!;
|
||||
expect(stackedLabel.y + stackedLabel.height).toBeLessThanOrEqual(stackedName.y);
|
||||
expect(Math.abs(stackedLabel.x - stackedName.x)).toBeLessThan(1);
|
||||
await newName.fill("Ready to ship");
|
||||
await expect(targetComment).toBeEditable();
|
||||
await targetComment.fill("Move the reviewed change here.");
|
||||
await newName.fill("Unsorted");
|
||||
await expect(targetComment).toHaveAttribute("readonly", "");
|
||||
await expect(targetComment).toHaveValue("");
|
||||
await newName.fill("Ready to ship");
|
||||
await expect(targetComment).toHaveValue("Move the reviewed change here.");
|
||||
await moveOk.click();
|
||||
await expect
|
||||
.poll(async () => {
|
||||
const state = await savedLists(page);
|
||||
return state?.lists.find((list) => list.id === state.files?.["build.gradle.kts"])?.name;
|
||||
})
|
||||
.toBe("Ready to ship");
|
||||
});
|
||||
@@ -2,7 +2,7 @@ import { expect, test } from "./fixtures";
|
||||
|
||||
for (const [id, selector] of [
|
||||
["general", "[class*='radios'] label"],
|
||||
["notifications", "table tbody td:first-child"],
|
||||
["notifications", "[role='listbox'] [role='option'] > [class*='notificationGroupLabel']"],
|
||||
["keymap", "[class*='presetLabel']"],
|
||||
["editor.inspections", "[class*='profileControls'] > span:first-child"],
|
||||
["vcs.issueNavigation", "[class*='pageBody'] button:not([aria-label])"],
|
||||
|
||||
@@ -39,3 +39,55 @@ test("Compare With… compares against a file picked in the browser", async ({ w
|
||||
const tabs = page.getByRole("tablist", { name: "Editor tabs" });
|
||||
await expect(tabs.getByRole("tab", { name: /other\.md/ })).toBeVisible({ timeout: 15_000 });
|
||||
});
|
||||
|
||||
for (const fragment of [false, true]) {
|
||||
test(`clipboard comparison labels the ${fragment ? "selection" : "file"} and its origin`, async ({
|
||||
workbench: page,
|
||||
}) => {
|
||||
await page.evaluate(async (fragment) => {
|
||||
const path = "/dev/acme-api/src/estimate.ts";
|
||||
const source = "const estimate = 4;\nconst total = estimate + 1;\n";
|
||||
const backend = "/src/editor/core/backend.ts";
|
||||
(await import(/* @vite-ignore */ backend)).docBackend().files.set(path, source);
|
||||
const service = "/src/workbench/contributions.ts";
|
||||
await (await import(/* @vite-ignore */ service)).editorService().openFile(path);
|
||||
const editor = "/src/editor/api.ts";
|
||||
const { view } = (await import(/* @vite-ignore */ editor)).activeEditor()!;
|
||||
view.dispatch({ selection: { anchor: 0, head: fragment ? source.indexOf("\n") : 0 } });
|
||||
view.focus();
|
||||
Object.defineProperty(navigator, "clipboard", {
|
||||
value: { readText: async () => "const estimate = 3;\n" },
|
||||
configurable: true,
|
||||
});
|
||||
localStorage.setItem("openidea.vcs.diffOptions", JSON.stringify({ mode: "split", collapse: false }));
|
||||
const actions = "/src/platform/actions.ts";
|
||||
await (await import(/* @vite-ignore */ actions)).executeAction("diff.compareWithClipboard");
|
||||
}, fragment);
|
||||
|
||||
const toolbar = page.getByRole("toolbar", { name: "Diff", exact: true });
|
||||
const viewer = toolbar.locator("..");
|
||||
const file = fragment ? "Selection from estimate.ts" : "estimate.ts";
|
||||
const caption = viewer.getByTitle(`${file} src`, { exact: true });
|
||||
const clipboard = viewer.getByTitle("From Clipboard", { exact: true });
|
||||
await expect(clipboard).toBeVisible();
|
||||
await expect(caption.getByText("src", { exact: true })).toBeVisible();
|
||||
await expect(caption.getByText(file, { exact: true })).toHaveCSS("font-size", "13px");
|
||||
await expect(caption.getByText("src", { exact: true })).toHaveCSS("font-size", "12px");
|
||||
const sides = viewer.locator(".cm-content");
|
||||
await expect(sides.first()).toContainText("const estimate = 3;");
|
||||
await expect(sides.last()).toContainText("const estimate = 4;");
|
||||
const remainingLine = sides.last().getByText("const total =", { exact: false });
|
||||
if (fragment) await expect(remainingLine).toBeHidden();
|
||||
else await expect(remainingLine).toBeVisible();
|
||||
const tabs = page.getByRole("tablist", { name: "Editor tabs" });
|
||||
const title = `Clipboard ↔ estimate.ts${fragment ? " (selection)" : ""}`;
|
||||
await expect(tabs.getByRole("tab", { name: title, exact: true })).toBeVisible();
|
||||
|
||||
await toolbar.getByRole("button", { name: "Swap Sides", exact: true }).click();
|
||||
await expect(caption).toBeVisible();
|
||||
expect((await caption.boundingBox())!.x).toBeLessThan((await clipboard.boundingBox())!.x);
|
||||
await toolbar.getByRole("button", { name: "Settings", exact: true }).click();
|
||||
await page.getByRole("menuitemcheckbox", { name: "Unified Viewer", exact: true }).click();
|
||||
await expect(viewer.getByTitle(`${file} src → From Clipboard`, { exact: true })).toBeVisible();
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,71 @@
|
||||
import type { Page } from "@playwright/test";
|
||||
import { expect, test } from "./fixtures";
|
||||
|
||||
async function openConsoleSettings(page: Page) {
|
||||
await page.keyboard.press("Meta+,");
|
||||
const dialog = page.getByRole("dialog", { name: "Settings", exact: true });
|
||||
const search = dialog.getByRole("textbox", { name: "Search settings" });
|
||||
await search.fill("Fold console lines that contain");
|
||||
await dialog.getByRole("treeitem", { name: "Console", exact: true }).click();
|
||||
await search.clear();
|
||||
return dialog;
|
||||
}
|
||||
|
||||
test("Console settings put folding between the basic controls and log colors", async ({ workbench: page }) => {
|
||||
await page.setViewportSize({ width: 1120, height: 740 });
|
||||
const dialog = await openConsoleSettings(page);
|
||||
const wrap = dialog.getByRole("checkbox", { name: "Use soft wraps in console", exact: true });
|
||||
const override = dialog.getByRole("checkbox", { name: /^Override console cycle buffer size/ });
|
||||
const size = dialog.getByRole("textbox", { name: "Override console cycle buffer size", exact: true });
|
||||
const encoding = dialog.getByRole("button", { name: "Default encoding", exact: true });
|
||||
const list = dialog.getByRole("listbox", { name: "Fold console lines that contain", exact: true });
|
||||
const colors = dialog.getByRole("checkbox", { name: "Colour log lines by level", exact: true });
|
||||
await expect(list).toBeVisible();
|
||||
expect((await list.boundingBox())!.width).toBeGreaterThan(480);
|
||||
const controls = [wrap, override, encoding, list, colors];
|
||||
const positions = await Promise.all(controls.map(async (control) => (await control.boundingBox())!.y));
|
||||
positions.forEach((y, index) => {
|
||||
if (index > 0) expect(y).toBeGreaterThan(positions[index - 1]!);
|
||||
});
|
||||
|
||||
for (const width of [580, 520]) {
|
||||
await page.setViewportSize({ width, height: 740 });
|
||||
for (const control of [...controls, size]) await expect(control).toBeInViewport({ ratio: 1 });
|
||||
expect(await list.evaluate((el) => el.scrollWidth - el.clientWidth)).toBeLessThanOrEqual(1);
|
||||
}
|
||||
});
|
||||
|
||||
test("Console settings keep the stored buffer size and fold rules across Apply and reopen", async ({
|
||||
workbench: page,
|
||||
}) => {
|
||||
const dialog = await openConsoleSettings(page);
|
||||
const override = dialog.getByRole("checkbox", { name: /^Override console cycle buffer size/ });
|
||||
const size = dialog.getByRole("textbox", { name: "Override console cycle buffer size", exact: true });
|
||||
const list = dialog.getByRole("listbox", { name: "Fold console lines that contain", exact: true });
|
||||
await override.check();
|
||||
await expect(size).toBeEnabled();
|
||||
await size.fill("2048");
|
||||
await override.uncheck();
|
||||
await expect(size).toBeDisabled();
|
||||
await expect(size).toHaveValue("2048");
|
||||
|
||||
await dialog.getByRole("button", { name: "Add", exact: true }).click();
|
||||
const pattern = list.getByRole("textbox", { name: "Pattern", exact: true });
|
||||
await pattern.fill("at example.retry");
|
||||
await pattern.press("Enter");
|
||||
await expect(list.getByRole("option", { name: "at example.retry", exact: true })).toBeVisible();
|
||||
const apply = dialog.getByRole("button", { name: "Apply", exact: true });
|
||||
await apply.click();
|
||||
await expect(apply).toBeDisabled();
|
||||
await dialog.getByRole("button", { name: "Cancel", exact: true }).click();
|
||||
await expect(dialog).toBeHidden();
|
||||
|
||||
await openConsoleSettings(page);
|
||||
await expect(override).not.toBeChecked();
|
||||
await expect(size).toBeDisabled();
|
||||
await expect(size).toHaveValue("2048");
|
||||
await expect(list.getByRole("option", { name: "at example.retry", exact: true })).toBeVisible();
|
||||
await override.check();
|
||||
await expect(size).toBeEnabled();
|
||||
await expect(size).toHaveValue("2048");
|
||||
});
|
||||
@@ -1,5 +1,5 @@
|
||||
import type { Page } from "@playwright/test";
|
||||
import { expect, openFromTree, test } from "./fixtures";
|
||||
import { expect, openFromTree, stubDesktop, test } from "./fixtures";
|
||||
|
||||
test("managed console tabs identify their data source and ordinary SQL tabs keep the file name", async ({
|
||||
workbench: page,
|
||||
@@ -495,8 +495,10 @@ async function runConsole(page: Page, path: string, text: string) {
|
||||
async ({ path, text }) => {
|
||||
const bindingsPath = "/src/bindings.ts";
|
||||
const storePath = "/src/features/database/store.ts";
|
||||
const streamFixturePath = "/src/features/database/executeStream.fixture.ts";
|
||||
const { commands } = await import(bindingsPath);
|
||||
const { executeConsole } = await import(storePath);
|
||||
const { streamExecution } = await import(streamFixturePath);
|
||||
commands.dbStatements = async (_id: string, sql: string) => {
|
||||
let from = 0;
|
||||
const data = sql.split(";").flatMap((part) => {
|
||||
@@ -523,6 +525,7 @@ async function runConsole(page: Page, path: string, text: string) {
|
||||
},
|
||||
})),
|
||||
});
|
||||
commands.dbExecuteStream = streamExecution(commands.dbExecute);
|
||||
await executeConsole(path, text, 0, text.length);
|
||||
},
|
||||
{ path, text },
|
||||
@@ -532,6 +535,7 @@ async function runConsole(page: Page, path: string, text: string) {
|
||||
test("console runs replace their unpinned results; pinned results stay until Close All but Pinned", async ({
|
||||
workbench: page,
|
||||
}) => {
|
||||
await stubDesktop(page);
|
||||
await seedResults(page);
|
||||
const strip = page.getByRole("tablist", { name: "Results", exact: true }).getByRole("tab");
|
||||
await choose(page, "Result 1", "Close All");
|
||||
|
||||
@@ -0,0 +1,61 @@
|
||||
import { expect, test } from "./fixtures";
|
||||
|
||||
test("Date Formats keeps its preview beside the formatting controls and updates it while editing", async ({
|
||||
workbench: page,
|
||||
}) => {
|
||||
await page.clock.setFixedTime(new Date(2026, 0, 16, 14, 35));
|
||||
await page.keyboard.press("Meta+,");
|
||||
const dialog = page.getByRole("dialog", { name: "Settings", exact: true });
|
||||
const search = dialog.getByRole("textbox", { name: "Search settings" });
|
||||
const openPage = async () => {
|
||||
await search.fill("Date Formats");
|
||||
await dialog.getByRole("treeitem", { name: "Date Formats", exact: true }).click();
|
||||
await search.clear();
|
||||
};
|
||||
await openPage();
|
||||
|
||||
const override = dialog.getByRole("checkbox", { name: "Override system date and time format" });
|
||||
const pattern = dialog.getByRole("textbox", { name: /^Date format/ });
|
||||
const hour = dialog.getByRole("checkbox", { name: "Use 24-hour time format" });
|
||||
const pretty = dialog.getByRole("checkbox", { name: "Use pretty formatting" });
|
||||
const hint = dialog.getByText("Placeholders: yyyy, yy, MMMM, MMM, MM, M, dd, d", { exact: true });
|
||||
const initialPreview = dialog.getByText(/Today .* · /);
|
||||
|
||||
for (const width of [1120, 580, 520]) {
|
||||
await page.setViewportSize({ width, height: 680 });
|
||||
await expect(async () => {
|
||||
const [hourBox, previewBox, prettyBox, patternBox, hintBox] = await Promise.all(
|
||||
[hour, initialPreview, pretty, pattern, hint].map((control) => control.boundingBox()),
|
||||
);
|
||||
expect(previewBox!.y).toBeGreaterThan(hourBox!.y + hourBox!.height);
|
||||
expect(prettyBox!.y).toBeGreaterThan(previewBox!.y + previewBox!.height);
|
||||
if (width === 1120) {
|
||||
expect(hintBox!.x).toBeGreaterThan(patternBox!.x + patternBox!.width);
|
||||
expect(hintBox!.y + hintBox!.height).toBeLessThanOrEqual(patternBox!.y + patternBox!.height + 1);
|
||||
} else {
|
||||
expect(hintBox!.y).toBeGreaterThanOrEqual(patternBox!.y + patternBox!.height);
|
||||
}
|
||||
}).toPass({ timeout: 3000 });
|
||||
}
|
||||
|
||||
const preview = dialog.getByRole("status", { name: /^Preview/ });
|
||||
await expect(pattern).toBeDisabled();
|
||||
await expect(hour).toBeDisabled();
|
||||
await expect(pretty).toBeEnabled();
|
||||
await override.check();
|
||||
await pattern.fill("yyyy-MM-dd");
|
||||
await expect(preview).toHaveText("Today 12:35 · 2026-01-13 14:35");
|
||||
await hour.uncheck();
|
||||
await expect(preview).toHaveText("Today 12:35 PM · 2026-01-13 2:35 PM");
|
||||
await pretty.uncheck();
|
||||
await expect(preview).toHaveText("2026-01-16 12:35 PM · 2026-01-13 2:35 PM");
|
||||
|
||||
await dialog.getByRole("button", { name: "OK", exact: true }).click();
|
||||
await page.keyboard.press("Meta+,");
|
||||
await openPage();
|
||||
await expect(override).toBeChecked();
|
||||
await expect(pattern).toHaveValue("yyyy-MM-dd");
|
||||
await expect(hour).not.toBeChecked();
|
||||
await expect(pretty).not.toBeChecked();
|
||||
await expect(preview).toHaveText("2026-01-16 12:35 PM · 2026-01-13 2:35 PM");
|
||||
});
|
||||
@@ -133,16 +133,30 @@ test("Evaluate keeps a multiline expression and its result visible in a short di
|
||||
];
|
||||
const stateModule = "/src/features/debugger/state.ts";
|
||||
const { adoptSession } = await import(/* @vite-ignore */ stateModule);
|
||||
const projectModule = "/src/platform/project.ts";
|
||||
const { useProject } = await import(/* @vite-ignore */ projectModule);
|
||||
const settings = useProject.getState().settings;
|
||||
useProject.setState({
|
||||
settings: {
|
||||
...settings,
|
||||
editor: { ...settings?.editor, fontFamily: "Consolas", fontSize: 18, lineHeight: 28 },
|
||||
},
|
||||
});
|
||||
adoptSession(session, { name: "Checkout", adapter: "debugpy", status: "paused", selectedFrame: 11 });
|
||||
}, SESSION);
|
||||
|
||||
await page.keyboard.press("Alt+F8");
|
||||
const dialog = page.getByRole("dialog", { name: "Evaluate expression" });
|
||||
const field = dialog.getByRole("textbox", { name: "Expression" });
|
||||
await expect(field).toHaveCSS("font-size", "18px");
|
||||
await expect(field).toHaveCSS("line-height", "28px");
|
||||
await expect(field).toHaveCSS("font-family", /^"?Consolas"?,/);
|
||||
const expression = ["orderSummary(", ...Array.from({ length: 12 }, (_, i) => ` item${i},`), ")"].join("\n");
|
||||
await field.fill(expression);
|
||||
await field.press("Enter");
|
||||
const result = dialog.getByRole("tree", { name: "Evaluation result" });
|
||||
const result = dialog.getByRole("region", { name: "Result", exact: true }).getByRole("tree", {
|
||||
name: "Evaluation result",
|
||||
});
|
||||
const row = result.getByRole("treeitem").first();
|
||||
await expect(row).toContainText("total = 36");
|
||||
await expect
|
||||
@@ -165,8 +179,24 @@ test("Evaluate keeps a multiline expression and its result visible in a short di
|
||||
await expect(result.getByText("tax", { exact: true })).toBeVisible();
|
||||
|
||||
await field.fill("otherExpression");
|
||||
await dialog.getByRole("button", { name: "History", exact: true }).click();
|
||||
await page.getByRole("menuitem", { name: /orderSummary/ }).click();
|
||||
const historyButton = dialog.getByRole("button", { name: "History", exact: true });
|
||||
const history = page.getByRole("menu", { name: "Expression history" });
|
||||
const option = history.getByRole("menuitem", { name: /orderSummary/ });
|
||||
await historyButton.click();
|
||||
await expect(option).toBeVisible();
|
||||
await expect(option).toHaveCSS("font-size", "18px");
|
||||
await expect
|
||||
.poll(async () => {
|
||||
const inputBounds = (await field.locator("..").boundingBox())!;
|
||||
const menuBounds = (await history.locator("..").boundingBox())!;
|
||||
return Math.max(Math.abs(inputBounds.x - menuBounds.x), Math.abs(inputBounds.width - menuBounds.width));
|
||||
})
|
||||
.toBeLessThan(1);
|
||||
await page.keyboard.press("Escape");
|
||||
await expect(history).toBeHidden();
|
||||
await expect(historyButton).toBeFocused();
|
||||
await historyButton.press("Enter");
|
||||
await option.press("Enter");
|
||||
await expect(field).toHaveValue(expression);
|
||||
await expect(field).toBeFocused();
|
||||
});
|
||||
@@ -69,7 +69,11 @@ test("keeps frame sources and the keyboard selection visible in a narrow debug d
|
||||
expect(await frames.evaluate((el) => el.scrollTop)).toBeGreaterThan(0);
|
||||
|
||||
await thread.click();
|
||||
await page.getByRole("option", { name: "Order worker", exact: true }).click();
|
||||
await page
|
||||
.getByRole("listbox", { name: "Thread" })
|
||||
.getByRole("option")
|
||||
.filter({ has: page.getByText("Order worker", { exact: true }) })
|
||||
.click();
|
||||
await expect(thread).toContainText("Order worker");
|
||||
await expect(frames.getByRole("option", { selected: true })).toContainText("processOrder");
|
||||
});
|
||||
@@ -0,0 +1,66 @@
|
||||
import { expect, ipcCalls, stubDesktop, test } from "./fixtures";
|
||||
|
||||
test("shows thread states in the compact frames header and switches frames by keyboard", async ({
|
||||
workbench: page,
|
||||
}) => {
|
||||
await page.setViewportSize({ width: 940, height: 740 });
|
||||
await stubDesktop(page);
|
||||
await page.evaluate(async () => {
|
||||
const stateModule = "/src/features/debugger/state.ts";
|
||||
const workbenchModule = "/src/workbench/contributions.ts";
|
||||
const { adoptSession } = await import(/* @vite-ignore */ stateModule);
|
||||
const { toolWindowService } = await import(/* @vite-ignore */ workbenchModule);
|
||||
const frame = (id: number, name: string) => ({
|
||||
id,
|
||||
name,
|
||||
path: null,
|
||||
line: 0,
|
||||
column: 0,
|
||||
presentationHint: null,
|
||||
});
|
||||
const handlers = window.__ipc.handlers;
|
||||
handlers.debug_stack_trace = ({ threadId }) => [frame(Number(threadId) * 10, "writeLedger")];
|
||||
handlers.debug_scopes = () => [];
|
||||
adoptSession(97, {
|
||||
name: "Settlement",
|
||||
adapter: "debugpy",
|
||||
status: "paused",
|
||||
stoppedThread: 1,
|
||||
selectedThread: 1,
|
||||
stopReason: "breakpoint",
|
||||
suspendedThreads: [{ id: 2, reason: "pause", description: null }],
|
||||
threads: [
|
||||
{ id: 1, name: "MainThread" },
|
||||
{ id: 2, name: "Audit writer" },
|
||||
{ id: 3, name: "Regional settlement reconciliation worker with a long queue name" },
|
||||
],
|
||||
selectedFrame: 10,
|
||||
frames: [frame(10, "settle")],
|
||||
});
|
||||
toolWindowService().show("debug", true);
|
||||
});
|
||||
|
||||
const debug = page.getByRole("region", { name: "Debug", exact: true });
|
||||
const thread = debug.getByRole("button", { name: "Thread", exact: true });
|
||||
await expect(thread).toBeVisible();
|
||||
const remainder = await thread.evaluate((button) => button.parentElement!.clientWidth - button.clientWidth);
|
||||
expect(remainder).toBeLessThan(12);
|
||||
await expect(thread).toHaveAccessibleDescription("MainThread (At breakpoint)");
|
||||
const frames = debug.getByRole("listbox", { name: "Frames" });
|
||||
await expect(frames.getByText("settle", { exact: true })).toBeVisible();
|
||||
|
||||
await thread.press("ArrowDown");
|
||||
const menu = page.getByRole("listbox", { name: "Thread" });
|
||||
await expect(menu).toBeInViewport({ ratio: 1 });
|
||||
await expect(menu.getByRole("option", { name: "MainThread At breakpoint" })).toBeVisible();
|
||||
await expect(menu.getByRole("option", { name: "Audit writer Suspended" })).toBeVisible();
|
||||
await expect(
|
||||
menu.getByRole("option", { name: /Regional settlement reconciliation worker .* Running/ }),
|
||||
).toBeVisible();
|
||||
await page.keyboard.press("ArrowDown");
|
||||
await page.keyboard.press("Enter");
|
||||
await expect(menu).toBeHidden();
|
||||
await expect(thread).toHaveAccessibleDescription("Audit writer (Suspended)");
|
||||
await expect(frames.getByText("writeLedger", { exact: true })).toBeVisible();
|
||||
expect(await ipcCalls(page, "debug_stack_trace")).toEqual([{ session: 97, threadId: 2 }]);
|
||||
});
|
||||
@@ -0,0 +1,86 @@
|
||||
import { expect, stubDesktop, test } from "./fixtures";
|
||||
|
||||
test.use({ reducedMotion: "reduce" });
|
||||
|
||||
const NAME = "settlementTranscript";
|
||||
const TRANSCRIPT = Array.from(
|
||||
{ length: 78 },
|
||||
(_, index) => `Event ${String(index + 1).padStart(3, "0")}\tSettlement record verified`,
|
||||
).join("\n");
|
||||
|
||||
test("the debugger's full value uses the editor font and fills the resized viewer", async ({ workbench: page }) => {
|
||||
await page.setViewportSize({ width: 1320, height: 880 });
|
||||
await stubDesktop(page);
|
||||
await page.evaluate(
|
||||
async ({ name, transcript }) => {
|
||||
const project = "/src/platform/project.ts";
|
||||
const debug = "/src/features/debugger/state.ts";
|
||||
const services = "/src/workbench/contributions.ts";
|
||||
const { useProject } = await import(/* @vite-ignore */ project);
|
||||
const { settings } = useProject.getState();
|
||||
useProject.setState({
|
||||
settings: { ...settings, editor: { ...settings?.editor, fontSize: 18, lineHeight: 24, tabSize: 8 } },
|
||||
});
|
||||
const { adoptSession } = await import(/* @vite-ignore */ debug);
|
||||
const { toolWindowService } = await import(/* @vite-ignore */ services);
|
||||
const ipc = window.__ipc.handlers;
|
||||
ipc.debug_scopes = () => [{ name: "Locals", variablesReference: 100, expensive: false }];
|
||||
ipc.debug_variables = () => [
|
||||
{
|
||||
name,
|
||||
value: JSON.stringify(transcript.slice(0, 720)),
|
||||
typeName: "str",
|
||||
variablesReference: 0,
|
||||
evaluateName: name,
|
||||
},
|
||||
];
|
||||
ipc.debug_evaluate_in = () => ({
|
||||
name,
|
||||
value: JSON.stringify(transcript),
|
||||
typeName: "str",
|
||||
variablesReference: 0,
|
||||
evaluateName: name,
|
||||
});
|
||||
adoptSession(91, {
|
||||
name: "Settlement review",
|
||||
adapter: "debugpy",
|
||||
status: "paused",
|
||||
selectedFrame: 11,
|
||||
frames: [{ id: 11, name: "checkout", path: null, line: 0, column: 0, presentationHint: null }],
|
||||
});
|
||||
toolWindowService().show("debug", true);
|
||||
},
|
||||
{ name: NAME, transcript: TRANSCRIPT },
|
||||
);
|
||||
const debug = page.getByRole("region", { name: "Debug", exact: true });
|
||||
await debug.getByRole("tab", { name: "Threads & Variables", exact: true }).click();
|
||||
await debug.getByRole("treeitem").filter({ hasText: NAME }).getByTitle("Show", { exact: true }).click();
|
||||
const dialog = page.getByRole("dialog", { name: `Value of ${NAME}` });
|
||||
const value = dialog.locator("pre");
|
||||
await expect(value).toHaveText(TRANSCRIPT, { useInnerText: false });
|
||||
await expect(value).toHaveCSS("font-size", "18px");
|
||||
await expect(value).toHaveCSS("line-height", "24px");
|
||||
await expect(value).toHaveCSS("tab-size", "8");
|
||||
await expect(value).toBeFocused();
|
||||
const before = (await value.boundingBox())!.height;
|
||||
const grip = (await dialog.getByRole("separator", { name: "Resize", exact: true }).boundingBox())!;
|
||||
const x = grip.x + grip.width - 3;
|
||||
const y = grip.y + grip.height - 3;
|
||||
await page.mouse.move(x, y);
|
||||
await page.mouse.down();
|
||||
await page.mouse.move(x + 190, y + 180, { steps: 6 });
|
||||
await page.mouse.up();
|
||||
await expect.poll(async () => (await value.boundingBox())!.height).toBeGreaterThan(before + 120);
|
||||
const overflow = (el: Element) => el.scrollHeight - el.clientHeight;
|
||||
expect(await dialog.locator("[data-dialog-body]").evaluate(overflow)).toBe(0);
|
||||
expect(await value.evaluate(overflow)).toBeGreaterThan(0);
|
||||
|
||||
await page.setViewportSize({ width: 490, height: 440 });
|
||||
await expect(dialog).toBeInViewport({ ratio: 1 });
|
||||
await expect(value).toBeInViewport({ ratio: 1 });
|
||||
await value.evaluate((el) => (el.scrollTop = el.scrollHeight));
|
||||
expect(await value.evaluate((el) => el.scrollTop)).toBeGreaterThan(0);
|
||||
expect(await value.textContent()).toBe(TRANSCRIPT);
|
||||
await page.keyboard.press("Escape");
|
||||
await expect(dialog).toBeHidden();
|
||||
});
|
||||
@@ -0,0 +1,56 @@
|
||||
import { expect, ipcCalls, stubDesktop, test } from "./fixtures";
|
||||
|
||||
test("Debugger Data Views keeps the hover delay with its setting at each window width", async ({ workbench: page }) => {
|
||||
await page.setViewportSize({ width: 1120, height: 740 });
|
||||
await stubDesktop(page);
|
||||
await page.evaluate(() => {
|
||||
window.__ipc.handlers.settings_get_global = () => ({});
|
||||
});
|
||||
await page.keyboard.press("Meta+,");
|
||||
const settings = page.getByRole("dialog", { name: "Settings", exact: true });
|
||||
const search = settings.getByRole("textbox", { name: "Search settings" });
|
||||
await search.fill("value tooltip delay");
|
||||
await settings.getByRole("treeitem", { name: "Data Views", exact: true }).click();
|
||||
await search.clear();
|
||||
|
||||
const hover = settings.getByRole("checkbox", { name: "Show value tooltip on mouse hover", exact: true });
|
||||
const delay = settings.getByRole("textbox", { name: "Value tooltip delay (ms)", exact: true });
|
||||
const selection = settings.getByRole("checkbox", { name: "Show value tooltip on code selection", exact: true });
|
||||
const sort = settings.getByRole("checkbox", { name: "Sort values alphabetically", exact: true });
|
||||
const editor = settings.getByRole("region", { name: "Editor", exact: true });
|
||||
|
||||
for (const width of [1120, 580, 520]) {
|
||||
await page.setViewportSize({ width, height: 740 });
|
||||
await expect(delay).toBeInViewport({ ratio: 1 });
|
||||
const [toggleBox, delayBox, selectionBox] = await Promise.all(
|
||||
[hover, delay, selection].map((control) => control.boundingBox()),
|
||||
);
|
||||
if (!toggleBox || !delayBox || !selectionBox) throw new Error("Missing Data Views control bounds");
|
||||
expect(delayBox.y + delayBox.height).toBeLessThan(selectionBox.y);
|
||||
if (width === 1120) {
|
||||
expect(delayBox.x).toBeGreaterThan(toggleBox.x + toggleBox.width);
|
||||
expect(Math.abs(delayBox.y + delayBox.height / 2 - toggleBox.y - toggleBox.height / 2)).toBeLessThan(3);
|
||||
} else {
|
||||
expect(delayBox.y).toBeGreaterThan(toggleBox.y + toggleBox.height);
|
||||
}
|
||||
}
|
||||
await expect(editor.getByRole("checkbox", { name: "Show values inline", exact: true })).toBeVisible();
|
||||
await expect(editor.getByRole("checkbox", { name: "Sort values alphabetically", exact: true })).toHaveCount(0);
|
||||
await expect(sort).toBeVisible();
|
||||
|
||||
await expect(hover).toBeChecked();
|
||||
await expect(delay).toHaveValue("700");
|
||||
await delay.fill("900");
|
||||
await selection.uncheck();
|
||||
await hover.uncheck();
|
||||
await expect(delay).toBeDisabled();
|
||||
await expect(delay).toHaveValue("900");
|
||||
await selection.check();
|
||||
await expect(hover).not.toBeChecked();
|
||||
await hover.check();
|
||||
await expect(delay).toBeEnabled();
|
||||
await expect(delay).toHaveValue("900");
|
||||
await settings.getByRole("button", { name: "Cancel", exact: true }).click();
|
||||
await expect(settings).toBeHidden();
|
||||
expect(await ipcCalls(page, "settings_set")).toEqual([]);
|
||||
});
|
||||
@@ -46,6 +46,50 @@ test("a narrow diff keeps navigation, settings and the difference count visible"
|
||||
await expect(toolbar).toContainText("1 of 1 differences");
|
||||
});
|
||||
|
||||
test("combined diff file actions stay visible beside a long name in a narrow pane", async ({ workbench: page }) => {
|
||||
const longName = "OrderHistoryCustomerNotificationDeliveryPreferencesValidationDefaults.txt";
|
||||
const directory = "/dev/acme-api/src/main/orders/preferences";
|
||||
await page.evaluate(
|
||||
async (paths) => {
|
||||
const optionsPath = "/src/features/vcs/allInOneDiff.ts";
|
||||
const inputPath = "/src/features/vcs/diffInput.ts";
|
||||
const { setAllInOneDiff } = await import(optionsPath);
|
||||
const { openDiff, withChain } = await import(inputPath);
|
||||
setAllInOneDiff(true);
|
||||
await openDiff(
|
||||
withChain(
|
||||
paths.map((path) => ({
|
||||
path,
|
||||
left: { type: "text", text: "before\n", label: "HEAD" },
|
||||
right: { type: "worktree" },
|
||||
})),
|
||||
0,
|
||||
),
|
||||
);
|
||||
},
|
||||
[`${directory}/${longName}`, `${directory}/Notes.txt`],
|
||||
);
|
||||
await page.setViewportSize({ width: 460, height: 600 });
|
||||
|
||||
const file = page.getByRole("region", { name: longName, exact: true });
|
||||
const header = file.getByRole("button", { name: /^(Collapse|Expand) File$/ }).locator("..");
|
||||
const open = header.getByRole("button", { name: "Open in Separate Tab", exact: true });
|
||||
const jump = header.getByRole("button", { name: "Jump to Source", exact: true });
|
||||
await expect(open).toBeInViewport({ ratio: 1 });
|
||||
await expect(jump).toBeInViewport({ ratio: 1 });
|
||||
const label = header.getByText(longName, { exact: true });
|
||||
await expect(label).toHaveCSS("text-overflow", "ellipsis");
|
||||
const labelBox = (await label.boundingBox())!;
|
||||
const jumpBox = (await jump.boundingBox())!;
|
||||
expect(labelBox.x).toBeGreaterThan(jumpBox.x + jumpBox.width);
|
||||
await expect(header).toContainText("src/main/orders/preferences");
|
||||
|
||||
await header.getByRole("button", { name: "Collapse File", exact: true }).click();
|
||||
await expect(file.getByRole("button", { name: "Expand File", exact: true })).toBeVisible();
|
||||
await open.click();
|
||||
await expect(page.getByRole("tab", { name: new RegExp(longName), selected: true })).toBeVisible();
|
||||
});
|
||||
|
||||
test("maximizes a diff preview tab and restores its previous layout", async ({ workbench: page }) => {
|
||||
const toolbar = await openChain(page);
|
||||
const viewer = toolbar.locator("..");
|
||||
|
||||
@@ -0,0 +1,104 @@
|
||||
import type { Locator } from "@playwright/test";
|
||||
import { expect, stubDesktop, test } from "./fixtures";
|
||||
|
||||
async function expectAligned(grid: Locator, names: string[]) {
|
||||
await expect(grid.getByRole("columnheader")).toHaveText(names);
|
||||
await expect
|
||||
.poll(() =>
|
||||
grid.evaluate((element) => {
|
||||
const head = [...element.querySelectorAll('[role="columnheader"]')].filter(
|
||||
(cell) => cell.getClientRects().length,
|
||||
);
|
||||
const row = element.querySelector('[aria-rowindex="2"]');
|
||||
const cells = [...(row?.querySelectorAll('[role="gridcell"]') ?? [])].filter(
|
||||
(cell) => cell.getClientRects().length,
|
||||
);
|
||||
return (
|
||||
cells.length === head.length &&
|
||||
head.every((cell, index) => {
|
||||
const header = cell.getBoundingClientRect();
|
||||
const value = cells[index]!.getBoundingClientRect();
|
||||
return Math.abs(header.x - value.x) < 1 && Math.abs(header.width - value.width) < 1;
|
||||
})
|
||||
);
|
||||
}),
|
||||
)
|
||||
.toBe(true);
|
||||
}
|
||||
|
||||
test("directory comparison mirrors both sides and keeps the headers aligned while the list scrolls", async ({
|
||||
workbench: page,
|
||||
}) => {
|
||||
await page.setViewportSize({ width: 1220, height: 780 });
|
||||
await stubDesktop(page);
|
||||
await page.evaluate(async () => {
|
||||
const entry = {
|
||||
leftKind: "file",
|
||||
rightKind: "file",
|
||||
status: "different",
|
||||
leftSize: 120,
|
||||
rightSize: 144,
|
||||
leftModified: Date.UTC(2026, 9, 8, 12),
|
||||
rightModified: Date.UTC(2026, 9, 9, 12),
|
||||
};
|
||||
const handlers = window.__ipc.handlers;
|
||||
handlers.fs_entry_kind = ({ path }) => (String(path).endsWith(".txt") ? "file" : "dir");
|
||||
handlers.cancel_request = () => null;
|
||||
handlers.fs_read_text = () => "";
|
||||
handlers.fs_compare_directories = () => [
|
||||
{ ...entry, path: "00-configuration.txt" },
|
||||
...Array.from({ length: 65 }, (_, index) => ({ ...entry, path: `log-${index}.txt` })),
|
||||
{ ...entry, path: "only-left.txt", rightKind: null, rightSize: null, status: "leftOnly" },
|
||||
{ ...entry, path: "shared.txt", status: "equal" },
|
||||
];
|
||||
const actions = "/src/platform/actions.ts";
|
||||
const { executeAction } = await import(/* @vite-ignore */ actions);
|
||||
await executeAction("toolwindow.hideAll");
|
||||
await executeAction("diff.compareDirectories", ["/dev/acme-api/source", "/dev/acme-api/target"]);
|
||||
});
|
||||
|
||||
const grid = page.getByRole("grid", { name: "Compared files" });
|
||||
const filter = page.getByRole("textbox", { name: "Filter by name" });
|
||||
const source = page.getByText("Left: source", { exact: true });
|
||||
const target = page.getByText("Right: target", { exact: true });
|
||||
await expect(source).toBeVisible();
|
||||
await expect(target).toBeVisible();
|
||||
const [pathBox, filterBox] = await Promise.all([source.boundingBox(), filter.boundingBox()]);
|
||||
if (!pathBox || !filterBox) throw new Error("Missing comparison toolbar bounds");
|
||||
expect(pathBox.y).toBeGreaterThanOrEqual(filterBox.y + filterBox.height);
|
||||
await expectAligned(grid, ["Name", "Size", "Date", "", "Date", "Size", "Name"]);
|
||||
const first = grid.getByRole("row").filter({ has: page.getByRole("gridcell", { name: "00-configuration.txt" }) });
|
||||
const values = await first.getByRole("gridcell").allTextContents();
|
||||
expect(values.at(0)).toBe("00-configuration.txt");
|
||||
expect(values.at(1)).toBe("120 B");
|
||||
expect(values.at(-2)).toBe("144 B");
|
||||
expect(values.at(-1)).toBe("00-configuration.txt");
|
||||
const rows = grid.locator('[role="rowgroup"][tabindex="0"]');
|
||||
expect(await rows.evaluate((el) => el.scrollHeight)).toBeGreaterThan(await rows.evaluate((el) => el.clientHeight));
|
||||
|
||||
await page.setViewportSize({ width: 630, height: 740 });
|
||||
await expectAligned(grid, ["Name", "Size", "", "Size", "Name"]);
|
||||
await expect(first.getByRole("gridcell").first()).toHaveAttribute("title", /00-configuration.txt.*120 B/);
|
||||
const setContainerType = (value: string) =>
|
||||
filter.evaluate((el, type) => {
|
||||
const container = el.parentElement?.parentElement;
|
||||
if (!container) throw new Error("Missing directory comparison container");
|
||||
container.style.containerType = type;
|
||||
}, value);
|
||||
await setContainerType("normal");
|
||||
await expectAligned(grid, ["Name", "Size", "Date", "", "Date", "Size", "Name"]);
|
||||
await expect(first.getByRole("gridcell").first()).toBeInViewport({ ratio: 1 });
|
||||
await setContainerType("");
|
||||
await page.setViewportSize({ width: 360, height: 740 });
|
||||
await expectAligned(grid, ["Name", "", "Name"]);
|
||||
|
||||
await page.setViewportSize({ width: 630, height: 740 });
|
||||
await filter.fill("shared");
|
||||
await expect(page.getByText("No matching differences", { exact: true })).toBeVisible();
|
||||
await page.getByRole("button", { name: "Show identical files" }).click();
|
||||
const shared = grid.getByRole("gridcell", { name: "shared.txt", exact: true });
|
||||
await expect(shared).toHaveCount(2);
|
||||
await shared.first().click();
|
||||
await expect(page.getByRole("button", { name: "Copy to Right", exact: true })).toBeEnabled();
|
||||
await expect(page.getByRole("toolbar", { name: "Diff", exact: true })).toBeVisible();
|
||||
});
|
||||
@@ -0,0 +1,60 @@
|
||||
import { expect, ipcCalls, stubDesktop, test } from "./fixtures";
|
||||
|
||||
const INSTALL_PATH = `C:/toolchains/${"managed-java-".repeat(16)}jdk`;
|
||||
|
||||
test("Download JDK keeps its fields in order and fits long paths in a narrow window", async ({ workbench: page }) => {
|
||||
await page.setViewportSize({ width: 1120, height: 740 });
|
||||
await stubDesktop(page);
|
||||
await page.evaluate(async (path) => {
|
||||
const ipc = window.__ipc;
|
||||
ipc.handlers.sdk_detect = () => [];
|
||||
ipc.handlers.jdk_download_vendors = () => [
|
||||
{ id: "temurin", name: "Eclipse Temurin" },
|
||||
{ id: "microsoft", name: "Microsoft Build of OpenJDK" },
|
||||
];
|
||||
ipc.handlers.jdk_download_releases = () => ({ versions: [25, 21, 17], lts: [25, 21, 17], recommended: 25 });
|
||||
ipc.handlers.jdk_download_location = () => path;
|
||||
ipc.handlers.jdk_download = ({ onEvent }) => {
|
||||
ipc.send(onEvent, { type: "progress", fraction: 0.5, message: "Downloaded 50 of 100 MB" });
|
||||
return new Promise(() => {});
|
||||
};
|
||||
ipc.handlers.cancel_request = () => null;
|
||||
const actions = "/src/platform/actions.ts";
|
||||
await (await import(/* @vite-ignore */ actions)).executeAction("file.projectStructure", "sdks");
|
||||
}, INSTALL_PATH);
|
||||
await page.getByRole("button", { name: "Add SDK", exact: true }).click();
|
||||
await page.getByRole("menuitem", { name: "Download JDK…", exact: true }).click();
|
||||
|
||||
const dialog = page.getByRole("dialog", { name: "Download JDK", exact: true });
|
||||
const version = dialog.getByRole("button", { name: "Version", exact: true });
|
||||
const vendor = dialog.getByRole("button", { name: "Vendor", exact: true });
|
||||
const location = dialog.getByRole("textbox", { name: "Location:", exact: true });
|
||||
await expect(version).toHaveText("25");
|
||||
expect((await version.boundingBox())!.y).toBeLessThan((await vendor.boundingBox())!.y);
|
||||
expect((await version.boundingBox())!.x).toBeCloseTo((await vendor.boundingBox())!.x, 0);
|
||||
expect((await location.boundingBox())!.x).toBeCloseTo((await vendor.boundingBox())!.x, 0);
|
||||
await expect(location).toHaveValue(INSTALL_PATH);
|
||||
await expect(location).toHaveCSS("font-size", "13px");
|
||||
|
||||
await page.setViewportSize({ width: 400, height: 560 });
|
||||
const content = dialog.locator("[data-dialog-body]");
|
||||
expect(await content.evaluate((el) => el.scrollWidth)).toBe(await content.evaluate((el) => el.clientWidth));
|
||||
const locationLabel = dialog.getByText("Location:", { exact: true });
|
||||
expect((await locationLabel.boundingBox())!.y).toBeLessThan((await location.boundingBox())!.y);
|
||||
expect((await locationLabel.boundingBox())!.x).toBeCloseTo((await location.boundingBox())!.x, 0);
|
||||
await expect(dialog.getByRole("button", { name: "Browse…", exact: true })).toBeInViewport({ ratio: 1 });
|
||||
await vendor.click();
|
||||
await page.getByRole("option", { name: "Microsoft Build of OpenJDK", exact: true }).click();
|
||||
await version.click();
|
||||
await page.getByRole("option", { name: /21/ }).click();
|
||||
const editedPath = INSTALL_PATH + "-lts";
|
||||
await location.fill(editedPath);
|
||||
const download = dialog.getByRole("button", { name: "Download", exact: true });
|
||||
await download.click();
|
||||
await expect(dialog.getByRole("progressbar", { name: "Downloading JDK" })).toHaveAttribute("aria-valuenow", "50");
|
||||
await expect(download).toBeDisabled();
|
||||
const [request] = await ipcCalls(page, "jdk_download");
|
||||
expect(request).toMatchObject({ vendor: "microsoft", version: 21, location: editedPath });
|
||||
await dialog.getByRole("button", { name: "Cancel", exact: true }).click();
|
||||
await expect.poll(() => ipcCalls(page, "cancel_request")).toContainEqual({ id: request!.request });
|
||||
});
|
||||
@@ -0,0 +1,53 @@
|
||||
import { expect, test } from "./fixtures";
|
||||
|
||||
test("empty editor hints form a readable block and reveal the Project shortcut when needed", async ({
|
||||
workbench: page,
|
||||
}) => {
|
||||
await page.setViewportSize({ width: 1200, height: 820 });
|
||||
const hints = page.locator("[data-editor-area] dl");
|
||||
const project = hints.getByRole("button", { name: "Project", exact: true });
|
||||
await expect(hints).toBeVisible();
|
||||
await expect(hints).toHaveCSS("font-size", "16px");
|
||||
await expect(project).toBeHidden();
|
||||
const rowLefts = await hints.locator("dt").evaluateAll((rows) => rows.map((row) => row.getBoundingClientRect().left));
|
||||
expect(new Set(rowLefts).size).toBe(1);
|
||||
const bounds = await hints.evaluate((element) => {
|
||||
const area = element.parentElement!.getBoundingClientRect();
|
||||
const block = element.getBoundingClientRect();
|
||||
const first = element.querySelector("dt")!.getBoundingClientRect();
|
||||
return {
|
||||
center: Math.abs(block.left + block.width / 2 - (area.left + area.width / 2)),
|
||||
topRatio: (first.top - area.top) / area.height,
|
||||
};
|
||||
});
|
||||
expect(bounds.center).toBeLessThan(1);
|
||||
expect(bounds.topRatio).toBeGreaterThan(0.31);
|
||||
expect(bounds.topRatio).toBeLessThan(0.39);
|
||||
|
||||
await page.locator('[data-stripe-button="project"]').click();
|
||||
await expect(project).toBeVisible();
|
||||
await expect(project.locator("xpath=../../dd")).not.toBeEmpty();
|
||||
await project.click();
|
||||
await expect(page.getByRole("region", { name: "Project", exact: true })).toBeVisible();
|
||||
await expect(project).toBeHidden();
|
||||
|
||||
await page.setViewportSize({ width: 400, height: 360 });
|
||||
await expect(project).toBeVisible();
|
||||
await expect(hints.getByText("Drop files here to open them", { exact: true })).toBeInViewport({ ratio: 1 });
|
||||
expect(await hints.evaluate((element) => element.scrollWidth - element.clientWidth)).toBeLessThanOrEqual(1);
|
||||
await hints.getByRole("button", { name: "Search Everywhere", exact: true }).click();
|
||||
await expect(page.getByRole("dialog", { name: "Search Everywhere" })).toBeVisible();
|
||||
});
|
||||
|
||||
test("the empty LightEdit window keeps its file actions at the same readable size", async ({ workbench: page }) => {
|
||||
await page.setViewportSize({ width: 400, height: 360 });
|
||||
await page.evaluate(async () => {
|
||||
const path = "/src/platform/project.ts";
|
||||
const { useProject } = await import(/* @vite-ignore */ path);
|
||||
useProject.setState({ project: null, lightEdit: true });
|
||||
});
|
||||
const hints = page.locator("[data-editor-area] dl");
|
||||
await expect(hints).toHaveCSS("font-size", "16px");
|
||||
await expect(hints.locator("dt")).toHaveText(["New File", "Open File", "Drop files here to open them"]);
|
||||
await expect(hints.getByRole("button", { name: "Open File", exact: true })).toBeInViewport({ ratio: 1 });
|
||||
});
|
||||
@@ -0,0 +1,104 @@
|
||||
import { expect, ipcCalls, openFromTree, stubDesktop, test } from "./fixtures";
|
||||
|
||||
test("the file revision chooser previews commit messages and compares the selected revision", async ({
|
||||
workbench: page,
|
||||
}) => {
|
||||
await openFromTree(page, "build.gradle.kts");
|
||||
await stubDesktop(page);
|
||||
await page.evaluate(async () => {
|
||||
const root = "/dev/acme-api";
|
||||
const path = `${root}/build.gradle.kts`;
|
||||
const latest = "123abcd000000000000000000000000000000000";
|
||||
const previous = "456efab000000000000000000000000000000000";
|
||||
window.__ipc.handlers.vcs_revision_files = () => ["build.gradle.kts"];
|
||||
window.__ipc.handlers.vcs_log = () => [
|
||||
{
|
||||
id: latest,
|
||||
shortId: "123abcd",
|
||||
author: "Lena Park",
|
||||
timeMs: Date.now(),
|
||||
summary: "Update reviewed totals",
|
||||
message: "Update reviewed totals",
|
||||
messageTruncated: true,
|
||||
},
|
||||
{
|
||||
id: previous,
|
||||
shortId: "456efab",
|
||||
author: "Morgan Chen",
|
||||
timeMs: Date.UTC(2025, 9, 18),
|
||||
summary: "Include October adjustments",
|
||||
message: "Include October adjustments\n\nUse the corrected quantities from the October review.",
|
||||
},
|
||||
];
|
||||
window.__ipc.handlers.vcs_log_details_batch = () => [
|
||||
{ message: "Update reviewed totals\n\nUse the totals reviewed by the release team." },
|
||||
];
|
||||
window.__ipc.handlers.vcs_file_at = () => "val reviewedTotal = 28\n";
|
||||
window.__ipc.handlers.vcs_file_mode = () => "100644";
|
||||
|
||||
const storeModule = "/src/features/vcs/store.ts";
|
||||
const historyModule = "/src/features/vcs/fileRevisions.ts";
|
||||
const contextModule = "/src/platform/context.ts";
|
||||
const actionsModule = "/src/platform/actions.ts";
|
||||
const { useVcs } = await import(/* @vite-ignore */ storeModule);
|
||||
const { hasFileHistory, trackFileHistory } = await import(/* @vite-ignore */ historyModule);
|
||||
const { setContext } = await import(/* @vite-ignore */ contextModule);
|
||||
const { executeAction } = await import(/* @vite-ignore */ actionsModule);
|
||||
useVcs.setState({ roots: [root], heads: { [root]: { headCommit: latest } }, statusLoaded: true });
|
||||
trackFileHistory();
|
||||
await expectFileHistory();
|
||||
setContext("vcsAvailable", true);
|
||||
await executeAction("vcs.compareWithRevision", path);
|
||||
|
||||
async function expectFileHistory() {
|
||||
for (let i = 0; i < 20 && !hasFileHistory(path); i++) {
|
||||
await new Promise((resolve) => setTimeout(resolve, 10));
|
||||
}
|
||||
if (!hasFileHistory(path)) throw new Error("The sample file has no tracked history");
|
||||
}
|
||||
});
|
||||
|
||||
const chooser = page.getByRole("dialog", { name: "Compare with Revision…" });
|
||||
const search = chooser.getByRole("textbox", { name: "Search file revisions" });
|
||||
const revisions = chooser.getByRole("listbox", { name: "File revisions" });
|
||||
const message = chooser.getByRole("region", { name: "Commit message" });
|
||||
await expect(revisions.getByRole("option")).toHaveCount(2);
|
||||
await expect(message).toContainText("Use the totals reviewed by the release team.");
|
||||
await expect
|
||||
.poll(() => ipcCalls(page, "vcs_log_details_batch"))
|
||||
.toEqual([
|
||||
expect.objectContaining({
|
||||
repo: "/dev/acme-api",
|
||||
revisions: ["123abcd000000000000000000000000000000000"],
|
||||
}),
|
||||
]);
|
||||
|
||||
const firstAuthor = await revisions.getByText("Lena Park", { exact: true }).boundingBox();
|
||||
const secondAuthor = await revisions.getByText("Morgan Chen", { exact: true }).boundingBox();
|
||||
expect(Math.abs(firstAuthor!.x - secondAuthor!.x)).toBeLessThan(1);
|
||||
await search.press("Tab");
|
||||
await expect(message).toBeFocused();
|
||||
await search.press("ArrowDown");
|
||||
await expect(revisions.getByRole("option", { name: /Morgan Chen/ })).toHaveAttribute("aria-selected", "true");
|
||||
await expect(message).toContainText("Use the corrected quantities from the October review.");
|
||||
|
||||
await page.setViewportSize({ width: 480, height: 350 });
|
||||
const listBox = (await revisions.boundingBox())!;
|
||||
const messageBox = (await message.boundingBox())!;
|
||||
expect(messageBox.y).toBeGreaterThanOrEqual(listBox.y + listBox.height - 1);
|
||||
expect(messageBox.y + messageBox.height).toBeLessThanOrEqual(350);
|
||||
await search.fill("unmatched");
|
||||
await expect(revisions).toContainText("No commits");
|
||||
await expect(message).not.toContainText("Use the corrected quantities from the October review.");
|
||||
await search.fill("October adjustments");
|
||||
await expect(revisions.getByRole("option")).toHaveCount(1);
|
||||
await expect(message).toContainText("Use the corrected quantities from the October review.");
|
||||
await search.press("Enter");
|
||||
await expect(chooser).toBeHidden();
|
||||
await expect
|
||||
.poll(() => ipcCalls(page, "vcs_file_at"))
|
||||
.toContainEqual({
|
||||
path: "/dev/acme-api/build.gradle.kts",
|
||||
rev: "456efab000000000000000000000000000000000",
|
||||
});
|
||||
});
|
||||
@@ -15,8 +15,15 @@ test("File Structure keeps symbol filters readable at desktop and minimum window
|
||||
selection_range: range,
|
||||
children: [],
|
||||
};
|
||||
const methods = Array.from({ length: 36 }, (_, i) => ({
|
||||
name: `method${String(i).padStart(2, "0")}`,
|
||||
kind: "method",
|
||||
range,
|
||||
selection_range: range,
|
||||
children: [],
|
||||
})).reverse();
|
||||
window.__ipc.handlers.doc_outline = () => [
|
||||
{ name: "OrderController", kind: "class", range, selection_range: range, children: [field] },
|
||||
{ name: "OrderController", kind: "class", range, selection_range: range, children: [field, ...methods] },
|
||||
];
|
||||
window.__ipc.handlers.lsp_type_hierarchy = () => [];
|
||||
const path = "/src/platform/actions.ts";
|
||||
@@ -25,10 +32,15 @@ test("File Structure keeps symbol filters readable at desktop and minimum window
|
||||
});
|
||||
|
||||
const dialog = page.getByRole("dialog", { name: "File Structure" });
|
||||
const filter = dialog.getByRole("textbox", { name: "Filter symbols" });
|
||||
const options = dialog.getByRole("button", { name: "View Options" });
|
||||
const tree = dialog.getByRole("tree", { name: "Symbols" });
|
||||
const fields = dialog.getByRole("checkbox", { name: "Show fields" });
|
||||
await expect(dialog.getByRole("checkbox", { name: "Show inherited members" })).toBeVisible();
|
||||
await expect(filter).toBeFocused();
|
||||
await expect(options).toBeVisible();
|
||||
for (const width of [400, 1000]) {
|
||||
await page.setViewportSize({ width, height: 600 });
|
||||
await page.setViewportSize({ width, height: 420 });
|
||||
const clipped = await dialog.evaluate((element) => {
|
||||
const labels = [...element.querySelectorAll("label")].filter((label) =>
|
||||
label.querySelector('input[type="checkbox"]'),
|
||||
@@ -44,6 +56,10 @@ test("File Structure keeps symbol filters readable at desktop and minimum window
|
||||
});
|
||||
});
|
||||
expect(clipped).toEqual([]);
|
||||
await expect(options).toBeInViewport({ ratio: 1 });
|
||||
const filterTop = (await filter.boundingBox())!.y;
|
||||
expect((await options.boundingBox())!.y).toBeLessThan(filterTop);
|
||||
expect((await tree.boundingBox())!.y).toBeGreaterThan(filterTop);
|
||||
}
|
||||
// The dialog scales in when it opens: wait for its settled width.
|
||||
await expect.poll(async () => Math.round((await dialog.boundingBox())!.width)).toBe(540);
|
||||
@@ -51,4 +67,32 @@ test("File Structure keeps symbol filters readable at desktop and minimum window
|
||||
await expect(field).toBeVisible();
|
||||
await fields.uncheck();
|
||||
await expect(field).toBeHidden();
|
||||
|
||||
await tree.evaluate((el) => (el.scrollTop = el.scrollHeight));
|
||||
await expect(tree.getByRole("treeitem", { name: "method00", exact: true })).toBeInViewport();
|
||||
await expect(options).toBeInViewport({ ratio: 1 });
|
||||
await expect(filter).toBeInViewport({ ratio: 1 });
|
||||
|
||||
await options.click();
|
||||
const menu = page.getByRole("menu", { name: "View Options" });
|
||||
await expect(menu).toBeInViewport({ ratio: 1 });
|
||||
const alphabetically = menu.getByRole("menuitemcheckbox", { name: "Sort Alphabetically" });
|
||||
await expect(alphabetically).not.toBeChecked();
|
||||
await alphabetically.click();
|
||||
await expect(menu).toBeHidden();
|
||||
await tree.evaluate((el) => (el.scrollTop = 0));
|
||||
await expect(tree.getByRole("treeitem").nth(1)).toHaveAccessibleName("method00");
|
||||
|
||||
await filter.fill("method21");
|
||||
await expect(tree.getByRole("treeitem", { name: "method21", selected: true })).toBeVisible();
|
||||
await options.click();
|
||||
await menu.getByRole("menuitemcheckbox", { name: "Narrow down on typing", checked: true }).click();
|
||||
await expect(tree.getByRole("treeitem", { name: "method22", exact: true })).toBeVisible();
|
||||
await options.click();
|
||||
await page.keyboard.press("Escape");
|
||||
await expect(menu).toBeHidden();
|
||||
await expect(dialog).toBeVisible();
|
||||
await expect(options).toBeFocused();
|
||||
await filter.press("Escape");
|
||||
await expect(filter).toHaveValue("");
|
||||
});
|
||||
@@ -0,0 +1,69 @@
|
||||
import { expect, openFromTree, stubDesktop, test } from "./fixtures";
|
||||
|
||||
test("Git annotations align dates and full author names at UI text size", async ({ workbench: page }) => {
|
||||
const editor = await openFromTree(page, "build.gradle.kts");
|
||||
await stubDesktop(page);
|
||||
await page.evaluate(async () => {
|
||||
const root = "/dev/acme-api";
|
||||
const file = `${root}/build.gradle.kts`;
|
||||
const handlers = window.__ipc.handlers;
|
||||
handlers.vcs_blame = () => [
|
||||
{
|
||||
commit: "a1234567".padEnd(40, "a"),
|
||||
author: "Lena Park",
|
||||
timeMs: Date.UTC(2026, 4, 3, 12),
|
||||
summary: "Update totals",
|
||||
},
|
||||
{
|
||||
commit: "b1234567".padEnd(40, "b"),
|
||||
author: "Lena Ortiz",
|
||||
timeMs: Date.UTC(2026, 8, 23, 12),
|
||||
summary: "Review totals",
|
||||
},
|
||||
];
|
||||
const projectModule = "/src/platform/project.ts";
|
||||
const { useProject } = await import(/* @vite-ignore */ projectModule);
|
||||
const { settings } = useProject.getState();
|
||||
useProject.setState({
|
||||
settings: {
|
||||
...settings,
|
||||
general: { ...settings?.general, dateFormat: { overrideSystem: true, pattern: "d MMMM yyyy" } },
|
||||
},
|
||||
});
|
||||
const storeModule = "/src/features/vcs/store.ts";
|
||||
const { useVcs } = await import(/* @vite-ignore */ storeModule);
|
||||
useVcs.setState({ available: true, root, repo: root, roots: [root] });
|
||||
const contextModule = "/src/platform/context.ts";
|
||||
const { setContext } = await import(/* @vite-ignore */ contextModule);
|
||||
setContext("vcsAvailable", true);
|
||||
const actionsModule = "/src/platform/actions.ts";
|
||||
const { executeAction } = await import(/* @vite-ignore */ actionsModule);
|
||||
await executeAction("vcs.annotate", file);
|
||||
});
|
||||
|
||||
const gutter = editor.locator(".cm-vcs-blame");
|
||||
const first = gutter.locator("[data-commit]").filter({ hasText: "3 May 2026" });
|
||||
const second = gutter.locator("[data-commit]").filter({ hasText: "23 September 2026" });
|
||||
const firstAuthor = first.locator(".cm-vcs-blame-author");
|
||||
const secondAuthor = second.locator(".cm-vcs-blame-author");
|
||||
await expect(firstAuthor).toHaveText("Lena Park");
|
||||
await expect(secondAuthor).toHaveText("Lena Ortiz");
|
||||
await expect
|
||||
.poll(async () => Math.abs((await firstAuthor.boundingBox())!.x - (await secondAuthor.boundingBox())!.x))
|
||||
.toBeLessThan(1);
|
||||
const uiSize = await editor.evaluate((el) => getComputedStyle(el).getPropertyValue("--fs-ui").trim());
|
||||
await expect(firstAuthor).toHaveCSS("font-size", uiSize);
|
||||
|
||||
const firstRevision = first.locator(".cm-vcs-blame-revision");
|
||||
await expect(firstRevision).toBeHidden();
|
||||
await second.click({ button: "right" });
|
||||
await page.getByRole("menuitem", { name: "Options", exact: true }).hover();
|
||||
await page.getByRole("menuitemcheckbox", { name: "Revision", exact: true }).click();
|
||||
await expect(firstRevision).toBeVisible();
|
||||
expect((await firstRevision.boundingBox())!.x).toBeLessThan(
|
||||
(await first.locator(".cm-vcs-blame-date").boundingBox())!.x,
|
||||
);
|
||||
await expect
|
||||
.poll(async () => Math.abs((await firstAuthor.boundingBox())!.x - (await secondAuthor.boundingBox())!.x))
|
||||
.toBeLessThan(1);
|
||||
});
|
||||
Loaded 100 of 432 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Заблокувати користувача