дзеркало
https://github.com/l0ng-ai/openidea.git
синхронізовано 2026-11-21 00:50:47 +02:00
Порівняти коміти
26
Коміти
| Автор | SHA1 | Дата | |
|---|---|---|---|
|
|
ac3c564249 | ||
|
|
f76ac263a0 | ||
|
|
7a97fba491 | ||
|
|
205b4bcc5f | ||
|
|
cd574a3e28 | ||
|
|
8aed4156f4 | ||
|
|
0221034936 | ||
|
|
0d432bf1a6 | ||
|
|
cbac930a6f | ||
|
|
33f082e32f | ||
|
|
0bbf5568cd | ||
|
|
2277c1cdfd | ||
|
|
a537223233 | ||
|
|
19c7947fc4 | ||
|
|
98f9fc0063 | ||
|
|
0d5ef48a94 | ||
|
|
444b620985 | ||
|
|
0c45a96d84 | ||
|
|
fd8f8d6dd0 | ||
|
|
c1bec5182c | ||
|
|
dcb4835a87 | ||
|
|
f74bc7abac | ||
|
|
c871c164c1 | ||
|
|
db65b12afe | ||
|
|
0cc873565a | ||
|
|
7cc100367d |
No files matched your search
Створено
+44
-44
@@ -4144,7 +4144,7 @@ checksum = "3d3067d79b975e8844ca9eb072e16b31c3c1c36928edf9c6789548c524d0d954"
|
||||
|
||||
[[package]]
|
||||
name = "ide-agent"
|
||||
version = "0.1.45"
|
||||
version = "0.1.46"
|
||||
dependencies = [
|
||||
"blake3",
|
||||
"dunce",
|
||||
@@ -4169,7 +4169,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "ide-analysis"
|
||||
version = "0.1.45"
|
||||
version = "0.1.46"
|
||||
dependencies = [
|
||||
"ast-grep-core",
|
||||
"ide-core",
|
||||
@@ -4183,7 +4183,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "ide-android"
|
||||
version = "0.1.45"
|
||||
version = "0.1.46"
|
||||
dependencies = [
|
||||
"ide-core",
|
||||
"serde",
|
||||
@@ -4194,7 +4194,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "ide-build"
|
||||
version = "0.1.45"
|
||||
version = "0.1.46"
|
||||
dependencies = [
|
||||
"blake3",
|
||||
"chardetng",
|
||||
@@ -4212,7 +4212,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "ide-cli"
|
||||
version = "0.1.45"
|
||||
version = "0.1.46"
|
||||
dependencies = [
|
||||
"dirs 6.0.0",
|
||||
"serde",
|
||||
@@ -4226,7 +4226,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "ide-clipboard"
|
||||
version = "0.1.45"
|
||||
version = "0.1.46"
|
||||
dependencies = [
|
||||
"gtk",
|
||||
"objc2 0.6.5",
|
||||
@@ -4237,7 +4237,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "ide-core"
|
||||
version = "0.1.45"
|
||||
version = "0.1.46"
|
||||
dependencies = [
|
||||
"dunce",
|
||||
"encoding_rs",
|
||||
@@ -4254,7 +4254,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "ide-coverage"
|
||||
version = "0.1.45"
|
||||
version = "0.1.46"
|
||||
dependencies = [
|
||||
"ide-core",
|
||||
"ide-run",
|
||||
@@ -4268,7 +4268,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "ide-dap"
|
||||
version = "0.1.45"
|
||||
version = "0.1.46"
|
||||
dependencies = [
|
||||
"base64 0.22.1",
|
||||
"futures",
|
||||
@@ -4297,7 +4297,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "ide-db"
|
||||
version = "0.1.45"
|
||||
version = "0.1.46"
|
||||
dependencies = [
|
||||
"base64 0.22.1",
|
||||
"bb8",
|
||||
@@ -4333,7 +4333,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "ide-docker"
|
||||
version = "0.1.45"
|
||||
version = "0.1.46"
|
||||
dependencies = [
|
||||
"ide-core",
|
||||
"serde",
|
||||
@@ -4346,7 +4346,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "ide-extension"
|
||||
version = "0.1.45"
|
||||
version = "0.1.46"
|
||||
dependencies = [
|
||||
"base64 0.22.1",
|
||||
"blake3",
|
||||
@@ -4367,7 +4367,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "ide-fonts"
|
||||
version = "0.1.45"
|
||||
version = "0.1.46"
|
||||
dependencies = [
|
||||
"objc2-core-foundation",
|
||||
"objc2-core-text",
|
||||
@@ -4379,7 +4379,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "ide-github"
|
||||
version = "0.1.45"
|
||||
version = "0.1.46"
|
||||
dependencies = [
|
||||
"ide-core",
|
||||
"ide-vcs",
|
||||
@@ -4392,7 +4392,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "ide-heap"
|
||||
version = "0.1.45"
|
||||
version = "0.1.46"
|
||||
dependencies = [
|
||||
"criterion",
|
||||
"ide-core",
|
||||
@@ -4410,7 +4410,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "ide-host"
|
||||
version = "0.1.45"
|
||||
version = "0.1.46"
|
||||
dependencies = [
|
||||
"base64 0.22.1",
|
||||
"blake3",
|
||||
@@ -4481,7 +4481,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "ide-http"
|
||||
version = "0.1.45"
|
||||
version = "0.1.46"
|
||||
dependencies = [
|
||||
"ide-core",
|
||||
"ide-vfs",
|
||||
@@ -4500,7 +4500,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "ide-index"
|
||||
version = "0.1.45"
|
||||
version = "0.1.46"
|
||||
dependencies = [
|
||||
"blake3",
|
||||
"criterion",
|
||||
@@ -4522,7 +4522,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "ide-jdwp"
|
||||
version = "0.1.45"
|
||||
version = "0.1.46"
|
||||
dependencies = [
|
||||
"ide-jvm-inspect",
|
||||
"proptest",
|
||||
@@ -4534,7 +4534,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "ide-jsonrpc"
|
||||
version = "0.1.45"
|
||||
version = "0.1.46"
|
||||
dependencies = [
|
||||
"encoding_rs",
|
||||
"futures",
|
||||
@@ -4551,7 +4551,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "ide-jvm-attach"
|
||||
version = "0.1.45"
|
||||
version = "0.1.46"
|
||||
dependencies = [
|
||||
"libc",
|
||||
"tempfile",
|
||||
@@ -4560,7 +4560,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "ide-jvm-inspect"
|
||||
version = "0.1.45"
|
||||
version = "0.1.46"
|
||||
dependencies = [
|
||||
"futures",
|
||||
"serde",
|
||||
@@ -4571,7 +4571,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "ide-language"
|
||||
version = "0.1.45"
|
||||
version = "0.1.46"
|
||||
dependencies = [
|
||||
"blake3",
|
||||
"criterion",
|
||||
@@ -4629,7 +4629,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "ide-lsp"
|
||||
version = "0.1.45"
|
||||
version = "0.1.46"
|
||||
dependencies = [
|
||||
"dunce",
|
||||
"encoding_rs",
|
||||
@@ -4657,7 +4657,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "ide-mcp"
|
||||
version = "0.1.45"
|
||||
version = "0.1.46"
|
||||
dependencies = [
|
||||
"bytes",
|
||||
"dunce",
|
||||
@@ -4676,7 +4676,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "ide-notebook"
|
||||
version = "0.1.45"
|
||||
version = "0.1.46"
|
||||
dependencies = [
|
||||
"futures",
|
||||
"ide-core",
|
||||
@@ -4699,7 +4699,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "ide-plugin"
|
||||
version = "0.1.45"
|
||||
version = "0.1.46"
|
||||
dependencies = [
|
||||
"blake3",
|
||||
"dunce",
|
||||
@@ -4722,7 +4722,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "ide-profiler"
|
||||
version = "0.1.45"
|
||||
version = "0.1.46"
|
||||
dependencies = [
|
||||
"ide-core",
|
||||
"ide-jvm-attach",
|
||||
@@ -4736,7 +4736,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "ide-remote"
|
||||
version = "0.1.45"
|
||||
version = "0.1.46"
|
||||
dependencies = [
|
||||
"dunce",
|
||||
"futures",
|
||||
@@ -4756,7 +4756,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "ide-run"
|
||||
version = "0.1.45"
|
||||
version = "0.1.46"
|
||||
dependencies = [
|
||||
"dunce",
|
||||
"encoding_rs",
|
||||
@@ -4780,7 +4780,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "ide-scaffold"
|
||||
version = "0.1.45"
|
||||
version = "0.1.46"
|
||||
dependencies = [
|
||||
"ide-core",
|
||||
"ide-tools",
|
||||
@@ -4796,7 +4796,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "ide-sdk"
|
||||
version = "0.1.45"
|
||||
version = "0.1.46"
|
||||
dependencies = [
|
||||
"dunce",
|
||||
"flate2",
|
||||
@@ -4819,7 +4819,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "ide-search"
|
||||
version = "0.1.45"
|
||||
version = "0.1.46"
|
||||
dependencies = [
|
||||
"criterion",
|
||||
"encoding_rs",
|
||||
@@ -4840,7 +4840,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "ide-spell"
|
||||
version = "0.1.45"
|
||||
version = "0.1.46"
|
||||
dependencies = [
|
||||
"ide-core",
|
||||
"parking_lot",
|
||||
@@ -4853,7 +4853,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "ide-ssh"
|
||||
version = "0.1.45"
|
||||
version = "0.1.46"
|
||||
dependencies = [
|
||||
"dirs 6.0.0",
|
||||
"flate2",
|
||||
@@ -4878,7 +4878,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "ide-syntax"
|
||||
version = "0.1.45"
|
||||
version = "0.1.46"
|
||||
dependencies = [
|
||||
"ide-core",
|
||||
"ide-language",
|
||||
@@ -4893,7 +4893,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "ide-terminal"
|
||||
version = "0.1.45"
|
||||
version = "0.1.46"
|
||||
dependencies = [
|
||||
"ide-core",
|
||||
"libc",
|
||||
@@ -4906,7 +4906,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "ide-text"
|
||||
version = "0.1.45"
|
||||
version = "0.1.46"
|
||||
dependencies = [
|
||||
"criterion",
|
||||
"ide-core",
|
||||
@@ -4919,7 +4919,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "ide-tools"
|
||||
version = "0.1.45"
|
||||
version = "0.1.46"
|
||||
dependencies = [
|
||||
"flate2",
|
||||
"hex",
|
||||
@@ -4940,7 +4940,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "ide-vcs"
|
||||
version = "0.1.45"
|
||||
version = "0.1.46"
|
||||
dependencies = [
|
||||
"blake3",
|
||||
"dunce",
|
||||
@@ -4961,7 +4961,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "ide-vfs"
|
||||
version = "0.1.45"
|
||||
version = "0.1.46"
|
||||
dependencies = [
|
||||
"chardetng",
|
||||
"dunce",
|
||||
@@ -4987,7 +4987,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "ide-web"
|
||||
version = "0.1.45"
|
||||
version = "0.1.46"
|
||||
dependencies = [
|
||||
"dirs 6.0.0",
|
||||
"ide-core",
|
||||
@@ -5003,7 +5003,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "ide-workspace"
|
||||
version = "0.1.45"
|
||||
version = "0.1.46"
|
||||
dependencies = [
|
||||
"blake3",
|
||||
"dunce",
|
||||
@@ -6632,7 +6632,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "openidea"
|
||||
version = "0.1.45"
|
||||
version = "0.1.46"
|
||||
dependencies = [
|
||||
"base64 0.22.1",
|
||||
"blake3",
|
||||
|
||||
+1
-1
@@ -5,7 +5,7 @@ members = ["crates/*", "src-tauri"]
|
||||
exclude = ["sdk", "plugins"]
|
||||
|
||||
[workspace.package]
|
||||
version = "0.1.45"
|
||||
version = "0.1.46"
|
||||
edition = "2024"
|
||||
rust-version = "1.96"
|
||||
license = "Apache-2.0"
|
||||
|
||||
@@ -54,30 +54,45 @@ pub(crate) fn bypass_approvals(config: &[AgentConfigOption]) -> bool {
|
||||
.any(|category| selected(category).zip(bypass_value(category)).is_some_and(|(value, bypass)| bypass(value)))
|
||||
}
|
||||
|
||||
/// Whether `value` of `option` approves everything without asking.
|
||||
pub(crate) fn approves_everything(option: &AgentConfigOption, value: &str) -> bool {
|
||||
option.category.as_deref().and_then(bypass_value).is_some_and(|bypass| bypass(value))
|
||||
/// Mode values that ask before anything changes the project, most careful first: Codex's
|
||||
/// Read Only (its Ask still edits the workspace), Claude Code's default (its Accept Edits
|
||||
/// doesn't ask), then plan modes.
|
||||
const ASKING_MODES: [&str; 4] = ["read-only", "default", "plan", "ask"];
|
||||
|
||||
/// Moves `config` to settings that ask before anything changes the project (a side
|
||||
/// conversation): approvals that approve everything ask, and the mode is the most careful one.
|
||||
pub(crate) fn keep_asking(config: &mut [AgentConfigOption]) {
|
||||
ask_for_approvals(config);
|
||||
for option in config.iter_mut().filter(|o| o.category.as_deref() == Some("mode")) {
|
||||
if let Some(mode) = ASKING_MODES.iter().find(|m| option.values.iter().any(|v| v.value == **m)) {
|
||||
option.current = Some((*mode).to_owned());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// The choices that keep a session asking before it changes anything: `wanted` without values
|
||||
/// that approve everything, and an asking value for each option of `options` that approves
|
||||
/// everything as it stands.
|
||||
/// The choices that keep a session asking before it changes anything: `wanted` without its
|
||||
/// mode and approval choices, and the [`keep_asking`] value of each such option of `options`.
|
||||
pub(crate) fn asking_choices(options: &[AgentConfigOption], wanted: &[AgentConfigChoice]) -> Vec<AgentConfigChoice> {
|
||||
let mut out: Vec<AgentConfigChoice> = wanted
|
||||
.iter()
|
||||
.filter(|c| !options.iter().any(|o| o.id == c.id && approves_everything(o, &c.value)))
|
||||
.cloned()
|
||||
.collect();
|
||||
let guarded = |o: &AgentConfigOption| o.category.as_deref().and_then(bypass_value).is_some();
|
||||
let mut out: Vec<AgentConfigChoice> =
|
||||
wanted.iter().filter(|c| !options.iter().any(|o| o.id == c.id && guarded(o))).cloned().collect();
|
||||
let mut asking = options.to_vec();
|
||||
ask_for_approvals(&mut asking);
|
||||
for (before, after) in options.iter().zip(&asking) {
|
||||
let Some(value) = after.current.as_ref().filter(|v| before.current.as_ref() != Some(*v)) else { continue };
|
||||
out.retain(|c| c.id != after.id);
|
||||
out.push(AgentConfigChoice { id: after.id.clone(), value: value.clone() });
|
||||
keep_asking(&mut asking);
|
||||
for option in asking.iter().filter(|o| guarded(o)) {
|
||||
if let Some(value) = &option.current {
|
||||
out.push(AgentConfigChoice { id: option.id.clone(), value: value.clone() });
|
||||
}
|
||||
}
|
||||
out
|
||||
}
|
||||
|
||||
/// Whether `config` is what [`keep_asking`] makes of it.
|
||||
pub(crate) fn keeps_asking(config: &[AgentConfigOption]) -> bool {
|
||||
let mut asking = config.to_vec();
|
||||
keep_asking(&mut asking);
|
||||
asking.iter().zip(config).all(|(a, b)| a.current == b.current)
|
||||
}
|
||||
|
||||
/// For an option of `category` that can approve everything, what tells its approving values.
|
||||
fn bypass_value(category: &str) -> Option<fn(&str) -> bool> {
|
||||
match category {
|
||||
@@ -489,19 +504,23 @@ mod tests {
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn asking_choices_drop_and_override_values_that_approve_everything() {
|
||||
fn asking_choices_keep_a_side_conversation_from_changing_anything() {
|
||||
let codex = options_of(&json!({"modes": {"currentModeId": "full-access",
|
||||
"availableModes": [{"id": "read-only"}, {"id": "ask"}, {"id": "auto"}, {"id": "full-access"}]}}));
|
||||
let mode = codex[0].id.clone();
|
||||
let choice = |id: &str, value: &str| AgentConfigChoice { id: id.into(), value: value.into() };
|
||||
// The source task's Full Access goes; the session's own Full Access is turned to Ask.
|
||||
// Codex goes to Read Only (its Ask edits the workspace), whatever the source task chose.
|
||||
let wanted = asking_choices(&codex, &[choice(&mode, "full-access"), choice("model", "gpt")]);
|
||||
assert_eq!(wanted, [choice("model", "gpt"), choice(&mode, "ask")]);
|
||||
// A mode that already asks is left alone.
|
||||
let mut auto = codex.clone();
|
||||
auto[0].current = Some("auto".into());
|
||||
assert_eq!(asking_choices(&auto, &[choice(&mode, "auto")]), [choice(&mode, "auto")]);
|
||||
assert!(approves_everything(&codex[0], "full-access") && !approves_everything(&codex[0], "auto"));
|
||||
assert_eq!(wanted, [choice("model", "gpt"), choice(&mode, "read-only")]);
|
||||
assert_eq!(asking_choices(&codex, &[choice(&mode, "ask")]), [choice(&mode, "read-only")]);
|
||||
// Claude Code's Accept Edits doesn't ask: default does.
|
||||
let claude = options_of(&json!({"modes": {"currentModeId": "acceptEdits",
|
||||
"availableModes": [{"id": "default"}, {"id": "acceptEdits"}, {"id": "plan"}, {"id": "bypassPermissions"}]}}));
|
||||
assert_eq!(asking_choices(&claude, &[]), [choice(&claude[0].id, "default")]);
|
||||
assert!(!keeps_asking(&claude));
|
||||
let mut safe = claude.clone();
|
||||
keep_asking(&mut safe);
|
||||
assert!(keeps_asking(&safe));
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
||||
@@ -210,20 +210,23 @@ impl Shared {
|
||||
}
|
||||
}
|
||||
|
||||
/// The MCP servers passed to a session, and the names of the ones off for it.
|
||||
fn mcp_servers_for_session(
|
||||
&self,
|
||||
provider: &str,
|
||||
init: &acp::Negotiated,
|
||||
overrides: &BTreeMap<String, bool>,
|
||||
) -> Vec<Value> {
|
||||
let mut servers = if overrides.get(mcp::BUILTIN_MCP_NAME) == Some(&false) {
|
||||
Vec::new()
|
||||
} else {
|
||||
mcp_servers_for(init.mcp_stdio(), &self.paths.project_root)
|
||||
};
|
||||
) -> McpForSession {
|
||||
let builtin_off = overrides.get(mcp::BUILTIN_MCP_NAME) == Some(&false);
|
||||
let mut servers =
|
||||
if builtin_off { Vec::new() } else { mcp_servers_for(init.mcp_stdio(), &self.paths.project_root) };
|
||||
let configured = self.mcp_servers_hook.read().as_ref().map(|hook| hook()).unwrap_or_default();
|
||||
servers.extend(mcp::acp_mcp_servers(&configured, provider, init, overrides));
|
||||
servers
|
||||
let mut off = mcp::servers_off(&configured, overrides);
|
||||
if builtin_off {
|
||||
off.push(BUILTIN_SERVER.to_owned());
|
||||
}
|
||||
McpForSession { servers, off }
|
||||
}
|
||||
|
||||
fn known_config(&self, provider: &str) -> Vec<AgentConfigOption> {
|
||||
@@ -891,9 +894,9 @@ impl AgentManager {
|
||||
let prompt = clean(req.prompt).ok_or_else(|| IdeError::invalid("describe the topic first"))?;
|
||||
let title = title_of(&prompt);
|
||||
let mut config = self.merged_config(&spec.id, &req.config);
|
||||
// The source task's choices may approve everything; the side conversation asks.
|
||||
// The source task's choices may change the project without asking; the side conversation asks.
|
||||
let wanted = config::asking_choices(&config, &req.config);
|
||||
config::ask_for_approvals(&mut config);
|
||||
config::keep_asking(&mut config);
|
||||
if config::bypass_approvals(&config) {
|
||||
return Err(IdeError::invalid(
|
||||
"this agent has no mode that asks before changing things, so it can't run a side conversation",
|
||||
@@ -1052,8 +1055,14 @@ impl AgentManager {
|
||||
if !o.values.iter().any(|v| v.value == value) {
|
||||
return Err(IdeError::invalid(format!("{} has no value {value}", o.name)));
|
||||
}
|
||||
if s.ephemeral && config::approves_everything(o, &value) {
|
||||
return Err(IdeError::invalid("a side conversation asks before changing anything"));
|
||||
if s.ephemeral {
|
||||
let mut next = s.task.config.clone();
|
||||
if let Some(n) = next.iter_mut().find(|n| n.id == option) {
|
||||
n.current = Some(value.clone());
|
||||
}
|
||||
if !config::keeps_asking(&next) {
|
||||
return Err(IdeError::invalid("a side conversation asks before changing anything"));
|
||||
}
|
||||
}
|
||||
o.clone()
|
||||
};
|
||||
@@ -1143,7 +1152,11 @@ impl AgentManager {
|
||||
.peer
|
||||
.request(
|
||||
"session/fork",
|
||||
json!({ "sessionId": live.session, "cwd": cwd_s, "mcpServers": mcp_servers }),
|
||||
{
|
||||
let mut params = session_params(&cwd_s, &mcp_servers);
|
||||
params["sessionId"] = json!(live.session);
|
||||
params
|
||||
},
|
||||
None,
|
||||
)
|
||||
.await
|
||||
@@ -2316,7 +2329,8 @@ impl Task {
|
||||
let mut session = None;
|
||||
if let (Some(id), true) = (saved, can_load) {
|
||||
self.replaying.store(true, Ordering::Release);
|
||||
let params = json!({ "sessionId": &id, "cwd": &cwd_s, "mcpServers": &mcp_servers });
|
||||
let mut params = session_params(&cwd_s, &mcp_servers);
|
||||
params["sessionId"] = json!(&id);
|
||||
let loaded = self.request_with_auth(&peer, &init, &mut tried_auth, "session/load", params).await;
|
||||
tokio::time::sleep(REPLAY_GRACE).await;
|
||||
self.replaying.store(false, Ordering::Release);
|
||||
@@ -2329,7 +2343,7 @@ impl Task {
|
||||
let (session_id, result) = match session {
|
||||
Some(s) => s,
|
||||
None => {
|
||||
let params = json!({ "cwd": &cwd_s, "mcpServers": &mcp_servers });
|
||||
let params = session_params(&cwd_s, &mcp_servers);
|
||||
let v = self.request_with_auth(&peer, &init, &mut tried_auth, "session/new", params).await.map_err(
|
||||
|e| match self.sign_in_error(&e, Some(&sign_in_message)) {
|
||||
Some(msg) => SessionOpenError { message: msg, allow_acp_fallback: false },
|
||||
@@ -2420,6 +2434,14 @@ impl Task {
|
||||
Err(e) => tracing::warn!("agent task {}: setting {} to {} failed: {e}", self.id, o.id, choice.value),
|
||||
}
|
||||
}
|
||||
// A side conversation never runs in a mode that changes things without asking: when the
|
||||
// agent refused the switch, it doesn't start.
|
||||
if self.state.lock().ephemeral && !config::keeps_asking(&options) {
|
||||
return Err(SessionOpenError {
|
||||
message: "The agent didn't switch to a mode that asks before changing anything, so the side conversation can't start".into(),
|
||||
allow_acp_fallback: false,
|
||||
});
|
||||
}
|
||||
let model = model_of(&options).filter(|_| model_options);
|
||||
self.shared.remember(provider_id, Some(&options), None, model.as_deref());
|
||||
{
|
||||
@@ -3265,6 +3287,23 @@ fn turn_starts(entries: &[AgentEntry]) -> Vec<usize> {
|
||||
.collect()
|
||||
}
|
||||
|
||||
/// The MCP servers of a session, and the names of the ones off for it.
|
||||
struct McpForSession {
|
||||
servers: Vec<Value>,
|
||||
off: Vec<String>,
|
||||
}
|
||||
|
||||
/// The session parameters `session/new`, `session/load` and `session/fork` share: the MCP
|
||||
/// servers, and the ones off for this session, so an agent that also loads its own
|
||||
/// configuration (Claude Code) can keep a same-named server of it off too.
|
||||
fn session_params(cwd: &str, mcp: &McpForSession) -> Value {
|
||||
let mut params = json!({ "cwd": cwd, "mcpServers": mcp.servers });
|
||||
if !mcp.off.is_empty() {
|
||||
params["_meta"] = json!({ "openidea": { "mcpServersOff": mcp.off } });
|
||||
}
|
||||
params
|
||||
}
|
||||
|
||||
fn is_false(b: &bool) -> bool {
|
||||
!*b
|
||||
}
|
||||
@@ -3373,6 +3412,9 @@ mod replay_tests;
|
||||
#[cfg(test)]
|
||||
mod tests;
|
||||
|
||||
/// The name agents know the built-in server by (its tools are `mcp__OpenIDEA__…` in Claude Code).
|
||||
const BUILTIN_SERVER: &str = "OpenIDEA";
|
||||
|
||||
// The desktop advertises its relay only while the built-in server is listening.
|
||||
static MCP_EXECUTABLE: parking_lot::RwLock<Option<std::path::PathBuf>> = parking_lot::RwLock::new(None);
|
||||
|
||||
@@ -3387,7 +3429,7 @@ fn mcp_servers_for(supported: bool, root: &std::path::Path) -> Vec<Value> {
|
||||
fn stdio_mcp_servers(executable: Option<&std::path::Path>, supported: bool, root: &std::path::Path) -> Vec<Value> {
|
||||
let Some(executable) = executable.filter(|_| supported) else { return Vec::new() };
|
||||
let command = ide_mcp::stdio_command(executable, root);
|
||||
vec![json!({ "name": "OpenIDEA", "command": command[0], "args": command[1..], "env": [] })]
|
||||
vec![json!({ "name": BUILTIN_SERVER, "command": command[0], "args": command[1..], "env": [] })]
|
||||
}
|
||||
|
||||
/// What was sent of a streaming message: its first `bytes` (`utf16` UTF-16 units), which
|
||||
|
||||
@@ -86,6 +86,29 @@ fn matches_agent(agents: &[String], provider: &str) -> bool {
|
||||
})
|
||||
}
|
||||
|
||||
/// The configured servers off for this session: off by default and not switched on for it, or
|
||||
/// switched off for it. Named so an agent that also loads its own configuration can keep a
|
||||
/// same-named server of it off too. Workspace entries take precedence, as in [`acp_mcp_servers`].
|
||||
pub(crate) fn servers_off(all: &[McpServer], overrides: &BTreeMap<String, bool>) -> Vec<String> {
|
||||
let mut seen = HashSet::new();
|
||||
let ordered =
|
||||
all.iter().filter(|s| s.scope == McpScope::Workspace).chain(all.iter().filter(|s| s.scope == McpScope::User));
|
||||
let configured: Vec<String> = ordered
|
||||
.filter(|s| seen.insert(s.name.as_str()))
|
||||
.filter(|s| !overrides.get(&s.name).copied().unwrap_or(s.enabled))
|
||||
.map(|s| s.name.clone())
|
||||
.collect();
|
||||
// A server switched off that the IDE doesn't configure may still be the agent's own.
|
||||
let switched = overrides
|
||||
.iter()
|
||||
.filter(|(name, on)| !**on && name.as_str() != BUILTIN_MCP_NAME && !seen.contains(name.as_str()))
|
||||
.map(|(name, _)| name.clone());
|
||||
let mut off: Vec<String> = configured.into_iter().chain(switched).collect();
|
||||
off.sort();
|
||||
off.dedup();
|
||||
off
|
||||
}
|
||||
|
||||
/// Builds the ACP `mcpServers` array for `session/new`, `session/load`, and `session/fork`.
|
||||
/// Workspace entries take precedence over User entries with the same name. Per-session
|
||||
/// `overrides` (`server_name` -> `enabled`) can enable a disabled server or disable an enabled one
|
||||
@@ -1016,6 +1039,44 @@ fn parse_key_values_map(val: Option<&Value>) -> BTreeMap<String, String> {
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
fn configured(name: &str, scope: McpScope, enabled: bool) -> McpServer {
|
||||
McpServer {
|
||||
id: format!("{scope:?}:{name}"),
|
||||
name: name.into(),
|
||||
scope,
|
||||
transport: McpTransport::Stdio,
|
||||
enabled,
|
||||
command: Some("x".into()),
|
||||
args: Vec::new(),
|
||||
env: Vec::new(),
|
||||
url: None,
|
||||
headers: Vec::new(),
|
||||
agents: Vec::new(),
|
||||
unapproved: false,
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn servers_off_follow_the_effective_state() {
|
||||
let all = [
|
||||
configured("default-off", McpScope::User, false),
|
||||
configured("switched-on", McpScope::User, false),
|
||||
configured("on", McpScope::User, true),
|
||||
configured("switched-off", McpScope::User, true),
|
||||
// The workspace entry decides for its name.
|
||||
configured("both", McpScope::User, true),
|
||||
configured("both", McpScope::Workspace, false),
|
||||
];
|
||||
let overrides = BTreeMap::from([
|
||||
("switched-on".to_owned(), true),
|
||||
("switched-off".to_owned(), false),
|
||||
("agent-own".to_owned(), false),
|
||||
(BUILTIN_MCP_NAME.to_owned(), false),
|
||||
]);
|
||||
assert_eq!(servers_off(&all, &overrides), ["agent-own", "both", "default-off", "switched-off"]);
|
||||
assert_eq!(servers_off(&all[2..4], &BTreeMap::new()), Vec::<String>::new());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn crud_and_acp_filtering_by_scope_agent_and_transport() {
|
||||
let mut user = BTreeMap::new();
|
||||
|
||||
@@ -170,6 +170,8 @@ struct Session {
|
||||
id: String,
|
||||
cwd: PathBuf,
|
||||
mcp_config: Option<tempfile::TempPath>,
|
||||
/// MCP servers switched off for this session (`--disallowedTools`), its own config's too.
|
||||
mcp_off: Vec<String>,
|
||||
shim: Weak<Shim>,
|
||||
st: Mutex<State>,
|
||||
/// Serializes (re)starting the process.
|
||||
@@ -344,9 +346,10 @@ impl Shim {
|
||||
cwd: PathBuf,
|
||||
start: Start,
|
||||
pending: bool,
|
||||
mcp_config: Option<String>,
|
||||
params: &Value,
|
||||
) -> Arc<Session> {
|
||||
let mcp_config = mcp_config.and_then(|json| match write_mcp_config(&json) {
|
||||
let mcp_off = mcp_off(params);
|
||||
let mcp_config = mcp_config(params).and_then(|json| match write_mcp_config(&json) {
|
||||
Ok(path) => Some(path),
|
||||
Err(e) => {
|
||||
tracing::warn!("Claude Code session {id}: cannot write its MCP configuration: {e}");
|
||||
@@ -356,6 +359,7 @@ impl Shim {
|
||||
let session = Arc::new(Session {
|
||||
id: id.to_owned(),
|
||||
mcp_config,
|
||||
mcp_off,
|
||||
shim: Arc::downgrade(self),
|
||||
st: Mutex::new(State {
|
||||
proc: None,
|
||||
@@ -411,13 +415,8 @@ impl Shim {
|
||||
}
|
||||
"session/new" => {
|
||||
let id = new_uuid(false);
|
||||
let session = self.add_session(
|
||||
&id,
|
||||
self.cwd_of(¶ms),
|
||||
Start::New { id: id.clone() },
|
||||
false,
|
||||
mcp_config(¶ms),
|
||||
);
|
||||
let session =
|
||||
self.add_session(&id, self.cwd_of(¶ms), Start::New { id: id.clone() }, false, ¶ms);
|
||||
rt.block_on(session.ensure()).map_err(|e| self.start_error(&session, e))?;
|
||||
session.announce_commands();
|
||||
Ok(json!({ "sessionId": id, "configOptions": session.st.lock().settings.options() }))
|
||||
@@ -433,7 +432,7 @@ impl Shim {
|
||||
None => return Err(invalid(format!("no Claude Code session {id} in {}", cwd.display()))),
|
||||
};
|
||||
let chain = self.base_chain(&cwd, &start).map_err(internal)?;
|
||||
let session = self.add_session(id, cwd, start, pending, mcp_config(¶ms));
|
||||
let session = self.add_session(id, cwd, start, pending, ¶ms);
|
||||
rt.block_on(session.ensure()).map_err(|e| self.start_error(&session, e))?;
|
||||
if method == "session/load" {
|
||||
session.replay(&chain);
|
||||
@@ -459,7 +458,7 @@ impl Shim {
|
||||
(start, st.settings.clone())
|
||||
};
|
||||
self.save_pending(&id, Some(&start));
|
||||
let session = self.add_session(&id, source.cwd.clone(), start, true, mcp_config(¶ms));
|
||||
let session = self.add_session(&id, source.cwd.clone(), start, true, ¶ms);
|
||||
session.st.lock().settings = settings;
|
||||
let options = session.st.lock().settings.options();
|
||||
Ok(json!({ "sessionId": id, "configOptions": options }))
|
||||
@@ -666,6 +665,9 @@ impl Session {
|
||||
if let Some(config) = &self.mcp_config {
|
||||
args.extend(["--mcp-config".to_owned(), config.to_string_lossy().into_owned()]);
|
||||
}
|
||||
if !self.mcp_off.is_empty() {
|
||||
args.extend(["--disallowedTools".to_owned(), self.mcp_off.join(",")]);
|
||||
}
|
||||
args.extend(start.args());
|
||||
let launch =
|
||||
Launch { program: shim.config.program.clone(), args, cwd: self.cwd.clone(), env: shim.config.env.clone() };
|
||||
@@ -1497,6 +1499,24 @@ fn write_mcp_config(json: &str) -> std::io::Result<tempfile::TempPath> {
|
||||
Ok(file.into_temp_path())
|
||||
}
|
||||
|
||||
/// The servers switched off for the session (`_meta.openidea.mcpServersOff`) as Claude Code
|
||||
/// permission rules that deny all of a server's tools (`mcp__<server>`), so a server of
|
||||
/// Claude Code's own configuration stays off too.
|
||||
fn mcp_off(params: &Value) -> Vec<String> {
|
||||
params
|
||||
.pointer("/_meta/openidea/mcpServersOff")
|
||||
.and_then(Value::as_array)
|
||||
.into_iter()
|
||||
.flatten()
|
||||
.filter_map(Value::as_str)
|
||||
.map(|name| {
|
||||
let name: String =
|
||||
name.chars().map(|c| if c.is_ascii_alphanumeric() || c == '_' || c == '-' { c } else { '_' }).collect();
|
||||
format!("mcp__{name}")
|
||||
})
|
||||
.collect()
|
||||
}
|
||||
|
||||
/// ACP `mcpServers` as Claude Code's `--mcp-config` JSON (`None` when there are none).
|
||||
fn mcp_config(params: &Value) -> Option<String> {
|
||||
let servers = params.get("mcpServers")?.as_array()?;
|
||||
|
||||
@@ -1243,6 +1243,13 @@ async fn skipped_questions_have_no_answers() {
|
||||
assert_eq!(cancelled, None);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn servers_switched_off_become_disallowed_tools() {
|
||||
assert!(mcp_off(&json!({})).is_empty());
|
||||
let off = mcp_off(&json!({ "_meta": { "openidea": { "mcpServersOff": ["github", "my server.v2"] } } }));
|
||||
assert_eq!(off, ["mcp__github", "mcp__my_server_v2"]);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn mcp_servers_become_an_mcp_config() {
|
||||
assert_eq!(mcp_config(&json!({ "mcpServers": [] })), None);
|
||||
|
||||
@@ -4238,3 +4238,14 @@ done
|
||||
);
|
||||
mgr.shutdown();
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn session_params_name_the_servers_off() {
|
||||
let mcp = McpForSession { servers: vec![json!({ "name": "docs" })], off: vec!["github".into()] };
|
||||
let params = session_params("/p", &mcp);
|
||||
assert_eq!(params["cwd"], "/p");
|
||||
assert_eq!(params["mcpServers"][0]["name"], "docs");
|
||||
assert_eq!(params["_meta"]["openidea"]["mcpServersOff"], json!(["github"]));
|
||||
let none = McpForSession { servers: Vec::new(), off: Vec::new() };
|
||||
assert!(session_params("/p", &none).get("_meta").is_none());
|
||||
}
|
||||
@@ -548,7 +548,7 @@ impl PathMap {
|
||||
}
|
||||
|
||||
/// Removes `.` and resolvable `..` components without touching the file system.
|
||||
fn normalize(p: &Path) -> PathBuf {
|
||||
pub(crate) fn normalize(p: &Path) -> PathBuf {
|
||||
use std::path::Component;
|
||||
let mut out = PathBuf::new();
|
||||
for c in p.components() {
|
||||
|
||||
@@ -40,6 +40,18 @@ pub fn structure_outputs(root: &Path, ps: &ProjectStructureSettings) -> (PathBuf
|
||||
(main, test)
|
||||
}
|
||||
|
||||
/// Whether Rebuild may delete the output folder `dir`: never the project folder or one above
|
||||
/// it, nor a folder that holds or lies inside a source, test or resource root.
|
||||
fn deletable_output(dir: &Path, root: &Path, roots: &StructureRoots) -> bool {
|
||||
let dir = normalize(dir);
|
||||
let overlaps = |r: &PathBuf| {
|
||||
let r = normalize(r);
|
||||
r.starts_with(&dir) || dir.starts_with(&r)
|
||||
};
|
||||
!normalize(root).starts_with(&dir)
|
||||
&& !roots.sources.iter().chain(&roots.tests).chain(&roots.resources).chain(&roots.test_resources).any(overlaps)
|
||||
}
|
||||
|
||||
fn module_name(root: &Path) -> String {
|
||||
root.file_name().map_or_else(|| "project".to_owned(), |n| n.to_string_lossy().into_owned())
|
||||
}
|
||||
@@ -207,7 +219,11 @@ pub fn structure_plan(
|
||||
|
||||
let mut steps = Vec::new();
|
||||
if kind == BuildKind::Rebuild {
|
||||
steps.push(BuildStep::action(Action::Clean(vec![main_out.clone(), test_out.clone()]), root));
|
||||
let dirs: Vec<PathBuf> =
|
||||
[&main_out, &test_out].into_iter().filter(|d| deletable_output(d, root, roots)).cloned().collect();
|
||||
if !dirs.is_empty() {
|
||||
steps.push(BuildStep::action(Action::Clean(dirs), root));
|
||||
}
|
||||
}
|
||||
let main_cp = library_entries(root, ps, false);
|
||||
let compile = |name: &str, sources: &[PathBuf], out: &Path, cp: &[String]| -> IdeResult<BuildStep> {
|
||||
@@ -466,6 +482,14 @@ impl Action {
|
||||
let mut written = Vec::new();
|
||||
for (from, to) in entries {
|
||||
let target = into.join(to);
|
||||
// The folders of the output it goes into (and a folder entry's own) are
|
||||
// never links; a file in a link's place replaces the link.
|
||||
let mut at = into.to_path_buf();
|
||||
let folders = to.components().count().saturating_sub(usize::from(!from.is_dir()));
|
||||
for c in to.components().take(folders) {
|
||||
at.push(c);
|
||||
refuse_link(&at)?;
|
||||
}
|
||||
if from.is_dir() {
|
||||
copy_tree(from, &target, &mut written, cancel)?;
|
||||
} else if from.is_file() {
|
||||
@@ -487,6 +511,10 @@ impl Action {
|
||||
}
|
||||
|
||||
fn copy_file(from: &Path, to: &Path) -> IdeResult<()> {
|
||||
// A link in the artifact's place is replaced, not written through.
|
||||
if fs::symlink_metadata(to).is_ok_and(|m| m.file_type().is_symlink()) {
|
||||
fs::remove_file(to).map_err(|e| IdeError::internal(format!("cannot replace {} ({e})", to.display())))?;
|
||||
}
|
||||
if let Some(parent) = to.parent() {
|
||||
fs::create_dir_all(parent)
|
||||
.map_err(|e| IdeError::internal(format!("cannot create {} ({e})", parent.display())))?;
|
||||
@@ -495,6 +523,16 @@ fn copy_file(from: &Path, to: &Path) -> IdeResult<()> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn refuse_link(folder: &Path) -> IdeResult<()> {
|
||||
if fs::symlink_metadata(folder).is_ok_and(|m| m.file_type().is_symlink()) {
|
||||
return Err(IdeError::invalid(format!(
|
||||
"{} links to another folder; the artifact is not laid out through it",
|
||||
folder.display()
|
||||
)));
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn copy_tree(from: &Path, to: &Path, written: &mut Vec<PathBuf>, cancel: &CancellationToken) -> IdeResult<()> {
|
||||
if cancel.is_cancelled() {
|
||||
return Err(IdeError::cancelled());
|
||||
@@ -504,6 +542,7 @@ fn copy_tree(from: &Path, to: &Path, written: &mut Vec<PathBuf>, cancel: &Cancel
|
||||
let Ok(t) = e.file_type() else { continue };
|
||||
let target = to.join(e.file_name());
|
||||
if t.is_dir() {
|
||||
refuse_link(&target)?;
|
||||
copy_tree(&e.path(), &target, written, cancel)?;
|
||||
} else if t.is_file() {
|
||||
copy_file(&e.path(), &target)?;
|
||||
@@ -531,7 +570,14 @@ fn replace_recorded(into: &Path, record: &Path, written: &[PathBuf]) -> IdeResul
|
||||
continue;
|
||||
}
|
||||
let file = into.join(&rel);
|
||||
if file.is_file() {
|
||||
// Never through a link: a folder of the output that now links elsewhere (or a file that
|
||||
// is a link) leads out of what the layout wrote.
|
||||
let mut at = into.to_path_buf();
|
||||
let linked = rel.components().any(|c| {
|
||||
at.push(c);
|
||||
fs::symlink_metadata(&at).is_ok_and(|m| m.file_type().is_symlink())
|
||||
});
|
||||
if !linked && file.is_file() {
|
||||
let _ = fs::remove_file(&file);
|
||||
let mut dir = file.parent();
|
||||
while let Some(d) = dir.filter(|d| *d != into && d.starts_with(into)) {
|
||||
@@ -750,6 +796,37 @@ mod tests {
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn rebuild_never_cleans_an_output_folder_over_the_project_or_its_sources() {
|
||||
let tmp = tempfile::tempdir().unwrap();
|
||||
let root = tmp.path().join("p");
|
||||
write(&root.join("src/A.java"), "class A {}");
|
||||
let roots = StructureRoots { sources: vec![root.join("src")], ..Default::default() };
|
||||
for (main, test) in [(".", "bin"), ("src", "src/../test-out"), ("src/classes", ".."), ("", "")] {
|
||||
let mut ps = ProjectStructureSettings::default();
|
||||
ps.modules.insert(
|
||||
".".into(),
|
||||
ModuleStructureSettings {
|
||||
compiler_output: main.into(),
|
||||
test_compiler_output: test.into(),
|
||||
..Default::default()
|
||||
},
|
||||
);
|
||||
let plan = structure_plan(&root, &ps, &roots, None, "17", BuildKind::Rebuild, &tmp.path().join("c"))
|
||||
.unwrap()
|
||||
.unwrap();
|
||||
let clean: Vec<String> =
|
||||
plan.steps.iter().map(BuildStep::display).filter(|s| s.starts_with("Clean")).collect();
|
||||
let expected: &[&str] = match main {
|
||||
"." => &["Clean bin"],
|
||||
"src" => &["Clean src/../test-out"],
|
||||
"src/classes" => &[],
|
||||
_ => &["Clean out/production/p, out/test/p"],
|
||||
};
|
||||
assert_eq!(clean, expected, "{main} / {test}");
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn no_plan_without_java_sources() {
|
||||
let tmp = tempfile::tempdir().unwrap();
|
||||
@@ -899,6 +976,32 @@ mod tests {
|
||||
write(&tmp.path().join("outside.txt"), "x");
|
||||
layout(&["a.jar"]).run(&CancellationToken::new()).unwrap();
|
||||
assert!(tmp.path().join("outside.txt").is_file());
|
||||
// Nor through a folder of the output that now links elsewhere.
|
||||
#[cfg(unix)]
|
||||
{
|
||||
write(&project.join("assets/x.txt"), "laid out");
|
||||
write(&record, &format!("{}\nassets/x.txt", project.display()));
|
||||
fs::remove_dir_all(project.join("assets")).unwrap();
|
||||
std::os::unix::fs::symlink(project.join("src"), project.join("assets")).unwrap();
|
||||
write(&project.join("src/x.txt"), "source");
|
||||
layout(&["a.jar"]).run(&CancellationToken::new()).unwrap();
|
||||
assert!(project.join("src/x.txt").is_file());
|
||||
}
|
||||
// An entry's own folder that links elsewhere stops the layout instead of copying through it.
|
||||
#[cfg(unix)]
|
||||
{
|
||||
fs::remove_file(project.join("assets")).unwrap();
|
||||
std::os::unix::fs::symlink(project.join("src"), project.join("classes")).unwrap();
|
||||
write(&tmp.path().join("out/A.class"), "compiled");
|
||||
let into_link = Action::Layout {
|
||||
into: project.clone(),
|
||||
entries: vec![(tmp.path().join("out"), PathBuf::from("classes"))],
|
||||
record: Some(record.clone()),
|
||||
};
|
||||
assert!(into_link.run(&CancellationToken::new()).is_err());
|
||||
assert!(!project.join("src/A.class").exists());
|
||||
fs::remove_file(project.join("classes")).unwrap();
|
||||
}
|
||||
// Nor does one made for another output folder.
|
||||
write(&project.join("c.jar"), "mine");
|
||||
write(&record, "/elsewhere\nc.jar");
|
||||
|
||||
@@ -167,7 +167,10 @@ The `url` field in the result is as written in the file (unsubstituted); transpo
|
||||
}
|
||||
call.confirm(&subject, Some(detail)).await?;
|
||||
|
||||
let exchange = ide_http::run(input, &call.cancel).await?;
|
||||
// Exactly the request the user approved: preparing it again would read the
|
||||
// environment files again, which may name another destination by now.
|
||||
let redact_url = prepared.url.clone();
|
||||
let exchange = ide_http::send(prepared, Some(&path), &call.cancel).await?;
|
||||
let history = call.project().http_history.clone();
|
||||
let saved = exchange.clone();
|
||||
let _ = call.host().blocking(move || history.add(&saved)).await;
|
||||
@@ -188,7 +191,7 @@ The `url` field in the result is as written in the file (unsubstituted); transpo
|
||||
"status": response.map(|r| r.status),
|
||||
"statusText": response.map(|r| r.status_text.clone()),
|
||||
"totalMs": response.map(|r| r.total_ms).or(exchange.entry.total_ms),
|
||||
"error": redact_transport_error(exchange.entry.error.clone(), &prepared.url),
|
||||
"error": redact_transport_error(exchange.entry.error.clone(), &redact_url),
|
||||
"body": body,
|
||||
"bodyTruncated": body_truncated,
|
||||
}))
|
||||
|
||||
@@ -97,6 +97,8 @@ async fn resolve_launch(
|
||||
tokio::task::spawn_blocking(move || {
|
||||
let _external_build = external_build;
|
||||
let local_repo = ide_sdk::apply::maven_local_repository(&project.root, &settings);
|
||||
// Module outputs the launch runs from a snapshot of: the originals must not come back.
|
||||
let mut snapshotted = Vec::new();
|
||||
let built = if delegated {
|
||||
let rebuild_on_jdt_errors = rebuild_on_jdt_errors(policy, prefer_maven, info.error_count);
|
||||
let outputs = project.java_launch_snapshots.lock().build(
|
||||
@@ -109,6 +111,7 @@ async fn resolve_launch(
|
||||
)?;
|
||||
let copies = use_snapshot(&mut info, &outputs.originals, &outputs.snapshot);
|
||||
apply_external_build_result(&mut info, outputs.failure, outputs.authoritative);
|
||||
snapshotted = outputs.originals;
|
||||
copies
|
||||
} else if external {
|
||||
let built = compile::build_for_launch(&project.root, &model, &module, test, build_kind, &cancel)?;
|
||||
@@ -137,7 +140,7 @@ async fn resolve_launch(
|
||||
&project.build_cache_dir(),
|
||||
&cancel,
|
||||
);
|
||||
merge_maven_launch_classpath(&mut class_paths, &mut info, maven_cp)?;
|
||||
merge_maven_launch_classpath(&mut class_paths, &mut info, maven_cp, &snapshotted)?;
|
||||
} else {
|
||||
append_unique_class_paths(&mut class_paths, std::mem::take(&mut info.class_paths));
|
||||
}
|
||||
@@ -298,17 +301,23 @@ fn same_entry(a: &str, b: &str, windows: bool) -> bool {
|
||||
|
||||
/// Merge the Maven launch classpath without turning a recoverable probe failure into a
|
||||
/// failed launch. Cancellation still propagates; ordinary failures keep jdtls' classpath
|
||||
/// and leave the reason in the run console.
|
||||
/// and leave the reason in the run console. Maven lists the module's and its reactor
|
||||
/// siblings' `target/classes`; those in `snapshotted` already run from their snapshot,
|
||||
/// and listing both would make every resource (MyBatis mapper XML) load twice.
|
||||
fn merge_maven_launch_classpath(
|
||||
class_paths: &mut Vec<String>,
|
||||
info: &mut JavaLaunchInfo,
|
||||
classpath: IdeResult<String>,
|
||||
snapshotted: &[PathBuf],
|
||||
) -> IdeResult<()> {
|
||||
match classpath {
|
||||
Ok(classpath) => {
|
||||
let snapshotted: Vec<_> = snapshotted.iter().map(|p| p.to_string_lossy()).collect();
|
||||
append_unique_class_paths(
|
||||
class_paths,
|
||||
std::env::split_paths(&classpath).map(|path| path.to_string_lossy().into_owned()),
|
||||
std::env::split_paths(&classpath)
|
||||
.map(|path| path.to_string_lossy().into_owned())
|
||||
.filter(|path| !snapshotted.iter().any(|original| same_entry(path, original, cfg!(windows)))),
|
||||
);
|
||||
Ok(())
|
||||
}
|
||||
@@ -471,20 +480,46 @@ mod tests {
|
||||
let mut class_paths = vec!["snapshot.jar".to_owned()];
|
||||
let mut info =
|
||||
JavaLaunchInfo { class_paths: vec!["snapshot.jar".into(), "jdtls.jar".into()], ..Default::default() };
|
||||
merge_maven_launch_classpath(&mut class_paths, &mut info, Ok(maven)).unwrap();
|
||||
merge_maven_launch_classpath(&mut class_paths, &mut info, Ok(maven), &[]).unwrap();
|
||||
assert_eq!(class_paths, ["snapshot.jar", "maven.jar"]);
|
||||
|
||||
merge_maven_launch_classpath(&mut class_paths, &mut info, Err(IdeError::internal("offline dependency")))
|
||||
merge_maven_launch_classpath(&mut class_paths, &mut info, Err(IdeError::internal("offline dependency")), &[])
|
||||
.unwrap();
|
||||
assert_eq!(class_paths, ["snapshot.jar", "maven.jar", "jdtls.jar"]);
|
||||
assert!(info.hints[0].contains("offline dependency"), "{:?}", info.hints);
|
||||
}
|
||||
|
||||
/// Maven's launch classpath lists the module's and its reactor siblings' outputs, which
|
||||
/// the launch already runs from a snapshot: listed twice, MyBatis loads each mapper XML
|
||||
/// twice and fails with "XML fragments parsed from previous mappers already contains value".
|
||||
#[test]
|
||||
fn maven_classpath_leaves_out_outputs_the_launch_runs_from_a_snapshot() {
|
||||
let web = PathBuf::from("/work/haoke/haoke-web/target/classes");
|
||||
let service = PathBuf::from("/work/haoke/haoke-service/target/classes");
|
||||
let maven = std::env::join_paths([
|
||||
"/work/haoke/haoke-web/target/classes/",
|
||||
"/work/haoke/haoke-service/target/classes",
|
||||
"/work/haoke/haoke-api/target/classes",
|
||||
"/m2/mybatis.jar",
|
||||
])
|
||||
.unwrap()
|
||||
.to_string_lossy()
|
||||
.into_owned();
|
||||
let mut class_paths = vec!["/cache/launch-x/0".to_owned(), "/cache/launch-x/1".to_owned()];
|
||||
let mut info = JavaLaunchInfo::default();
|
||||
merge_maven_launch_classpath(&mut class_paths, &mut info, Ok(maven), &[web, service]).unwrap();
|
||||
assert_eq!(
|
||||
class_paths,
|
||||
["/cache/launch-x/0", "/cache/launch-x/1", "/work/haoke/haoke-api/target/classes", "/m2/mybatis.jar"]
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn cancelled_maven_classpath_probe_propagates_without_fallback() {
|
||||
let mut class_paths = vec!["snapshot.jar".to_owned()];
|
||||
let mut info = JavaLaunchInfo { class_paths: vec!["jdtls.jar".into()], ..Default::default() };
|
||||
let error = merge_maven_launch_classpath(&mut class_paths, &mut info, Err(IdeError::cancelled())).unwrap_err();
|
||||
let error =
|
||||
merge_maven_launch_classpath(&mut class_paths, &mut info, Err(IdeError::cancelled()), &[]).unwrap_err();
|
||||
assert_eq!(error.kind, ErrorKind::Cancelled);
|
||||
assert_eq!(class_paths, ["snapshot.jar"]);
|
||||
assert!(info.hints.is_empty());
|
||||
|
||||
@@ -34,6 +34,16 @@ pub struct RunInput<'a> {
|
||||
/// variables, missing includes) fail; transport errors are part of the exchange.
|
||||
pub async fn run(input: RunInput<'_>, cancel: &CancellationToken) -> IdeResult<HttpExchange> {
|
||||
let request = prepare(&input)?;
|
||||
send(request, input.file, cancel).await
|
||||
}
|
||||
|
||||
/// Sends an already prepared request (one the user approved as shown); `file` is the
|
||||
/// request file it came from, for the history.
|
||||
pub async fn send(
|
||||
request: PreparedRequest,
|
||||
file: Option<&Path>,
|
||||
cancel: &CancellationToken,
|
||||
) -> IdeResult<HttpExchange> {
|
||||
let time_ms = std::time::SystemTime::now()
|
||||
.duration_since(std::time::UNIX_EPOCH)
|
||||
.map(|d| d.as_secs_f64() * 1000.0)
|
||||
@@ -57,7 +67,7 @@ pub async fn run(input: RunInput<'_>, cancel: &CancellationToken) -> IdeResult<H
|
||||
url: request.url.clone(),
|
||||
status: response.as_ref().map(|r| r.status),
|
||||
total_ms: response.as_ref().map(|r| r.total_ms),
|
||||
file: input.file.map(IpcPath::from),
|
||||
file: file.map(IpcPath::from),
|
||||
error,
|
||||
},
|
||||
request,
|
||||
|
||||
@@ -219,8 +219,11 @@ function history(page: Page) {
|
||||
function modelButton(page: Page) {
|
||||
return page.getByRole("button", { name: "Model", exact: true }).filter({ visible: true });
|
||||
}
|
||||
function effortButton(page: Page) {
|
||||
return page.getByRole("button", { name: "Reasoning", exact: true }).filter({ visible: true });
|
||||
}
|
||||
async function expectEffort(page: Page, name: string) {
|
||||
await expect(modelButton(page)).toHaveAttribute("title", new RegExp(`Reasoning: ${name}(?: ·|$)`));
|
||||
await expect(effortButton(page)).toHaveText(name);
|
||||
}
|
||||
async function selected(box: Locator) {
|
||||
return box.evaluate((element) => {
|
||||
@@ -255,7 +258,7 @@ async function selectDraft(page: Page) {
|
||||
}
|
||||
async function chooseModel(page: Page, name: string) {
|
||||
await modelButton(page).click();
|
||||
// A model row also holds its Configure button, whose label joins the option's name.
|
||||
// A model row also holds its Pin button, whose label joins the option's name.
|
||||
await page.getByRole("option", { name: new RegExp(`^${name}\\b`) }).click();
|
||||
await page.keyboard.press("Escape");
|
||||
await box(page).focus();
|
||||
@@ -292,7 +295,7 @@ for (const placement of ["editor", "toolWindow"] as const) {
|
||||
option: effortId,
|
||||
value,
|
||||
});
|
||||
await expect(page.getByRole("dialog", { name: "Model & effort settings", exact: true })).toHaveCount(0);
|
||||
await expect(page.getByRole("listbox", { name: "Reasoning", exact: true })).toHaveCount(0);
|
||||
}
|
||||
await expectNoSubmission(page);
|
||||
await stream.click({ position: { x: 12, y: 20 } });
|
||||
@@ -350,7 +353,7 @@ test("subagent conversation never changes its hidden parent's effort", async ({
|
||||
await expectEffort(page, "Gentle");
|
||||
});
|
||||
|
||||
test("Settings and model popup exclude the agent shortcut", async ({ workbench: page }) => {
|
||||
test("Settings and effort popup exclude the agent shortcut", async ({ workbench: page }) => {
|
||||
await seed(page, "editor");
|
||||
await box(page).fill(draft);
|
||||
await page.keyboard.press("Meta+,");
|
||||
@@ -361,14 +364,10 @@ test("Settings and model popup exclude the agent shortcut", async ({ workbench:
|
||||
await expect(search).toBeFocused();
|
||||
await expect(search).toHaveValue("keymap");
|
||||
await settings.getByRole("button", { name: "Cancel", exact: true }).click();
|
||||
await modelButton(page).click();
|
||||
const popup = page.getByRole("dialog", { name: "Model & effort settings", exact: true });
|
||||
await effortButton(page).click();
|
||||
const popup = page.getByRole("listbox", { name: "Reasoning", exact: true });
|
||||
await expect(popup).toBeVisible();
|
||||
await popup.getByRole("button", { name: "Configure model", exact: true }).click();
|
||||
const gentle = popup.getByRole("radio", { name: "Gentle", exact: true });
|
||||
await gentle.focus();
|
||||
await page.keyboard.press("Alt+t");
|
||||
await expect(gentle).toHaveAttribute("aria-checked", "true");
|
||||
expect(await ipcCalls(page, "agent_set_config")).toEqual([]);
|
||||
await page.keyboard.press("Escape");
|
||||
await expectEffort(page, "Gentle");
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import type { Page } from "@playwright/test";
|
||||
import { expect, test } from "./fixtures";
|
||||
|
||||
test.beforeEach(async ({ workbench: page }) => {
|
||||
@@ -52,7 +53,7 @@ test.beforeEach(async ({ workbench: page }) => {
|
||||
});
|
||||
await page.getByRole("button", { name: "Agents", exact: true }).click();
|
||||
await page.getByRole("button", { name: "New Agent Task", exact: true }).click();
|
||||
await expect(page.getByText("omp · 18.20.0 · ACP v1", { exact: true })).toBeVisible();
|
||||
await expectVersion(page, "18.20.0");
|
||||
});
|
||||
|
||||
test("refreshes an upgraded agent's version on window focus without losing the draft", async ({ workbench: page }) => {
|
||||
@@ -63,7 +64,7 @@ test("refreshes an upgraded agent's version on window focus without losing the d
|
||||
window.dispatchEvent(new Event("test:agent-upgraded"));
|
||||
window.dispatchEvent(new Event("focus"));
|
||||
});
|
||||
await expect(page.getByText("omp · 18.20.2 · ACP v1", { exact: true })).toBeVisible();
|
||||
await expectVersion(page, "18.20.2");
|
||||
await expect(message).toHaveText("Keep this unsent draft");
|
||||
});
|
||||
|
||||
@@ -71,5 +72,10 @@ test("refreshes an upgraded agent's version when New Task is reopened", async ({
|
||||
await page.getByRole("button", { name: "Close Tab", exact: true }).click();
|
||||
await page.evaluate(() => window.dispatchEvent(new Event("test:agent-upgraded")));
|
||||
await page.getByRole("button", { name: "New Agent Task", exact: true }).click();
|
||||
await expect(page.getByText("omp · 18.20.2 · ACP v1", { exact: true })).toBeVisible();
|
||||
await expectVersion(page, "18.20.2");
|
||||
});
|
||||
|
||||
/** The agent picker shows its icon; its name and version are in its tooltip. */
|
||||
async function expectVersion(page: Page, version: string) {
|
||||
await expect(page.locator(`[data-tooltip$=" ${version}"]`).filter({ visible: true })).toHaveCount(1);
|
||||
}
|
||||
+1
-1
@@ -2,7 +2,7 @@
|
||||
"name": "openidea",
|
||||
"private": true,
|
||||
"description": "An open-source IDE inspired by IntelliJ IDEA",
|
||||
"version": "0.1.45",
|
||||
"version": "0.1.46",
|
||||
"license": "Apache-2.0",
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package openidea:plugin@1.8.0;
|
||||
package openidea:plugin@1.9.0;
|
||||
|
||||
/// The commit being prepared in the window the current command or event came
|
||||
/// from (the Commit tool window, or the Commit dialog while it is open): the
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package openidea:plugin@1.8.0;
|
||||
package openidea:plugin@1.9.0;
|
||||
|
||||
/// Plugin-owned project data sources. Requires database.sources and project trust.
|
||||
/// Runs on the Database subsystem's host, including on remote project servers.
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package openidea:plugin@1.8.0;
|
||||
package openidea:plugin@1.9.0;
|
||||
|
||||
/// Editor and project-tree decorations (API 1.4). Requires project.read. An editor set
|
||||
/// follows its file: the file's own project, or the nearest one when it is outside them all.
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package openidea:plugin@1.8.0;
|
||||
package openidea:plugin@1.9.0;
|
||||
|
||||
/// What the pane beside the Services tree shows for a plugin's node.
|
||||
interface detail-types {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package openidea:plugin@1.8.0;
|
||||
package openidea:plugin@1.9.0;
|
||||
|
||||
/// Optional export (world `plugin-diagnostics`): problems in the current,
|
||||
/// possibly unsaved document, for the languages declared with the
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package openidea:plugin@1.8.0;
|
||||
package openidea:plugin@1.9.0;
|
||||
|
||||
/// HTTP endpoints found in a project (`[[contributes.endpoints]]`).
|
||||
interface endpoints-provider {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package openidea:plugin@1.8.0;
|
||||
package openidea:plugin@1.9.0;
|
||||
|
||||
/// Workbench events, delivered in batches to `event-handler.handle`.
|
||||
interface events {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package openidea:plugin@1.8.0;
|
||||
package openidea:plugin@1.9.0;
|
||||
|
||||
interface lifecycle {
|
||||
use types.{context, error};
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package openidea:plugin@1.8.0;
|
||||
package openidea:plugin@1.9.0;
|
||||
|
||||
/// What other plugins contributed to the extension points this plugin declares
|
||||
/// (`[[extension-points]]` in `plugin.toml`; the contributors list this plugin
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package openidea:plugin@1.8.0;
|
||||
package openidea:plugin@1.9.0;
|
||||
|
||||
/// Optional export (world `plugin-file-actions`): quick fixes and
|
||||
/// refactorings that create, rename or delete files, next to the text edits
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package openidea:plugin@1.8.0;
|
||||
package openidea:plugin@1.9.0;
|
||||
|
||||
/// Files outside the open projects: the configuration of the program a
|
||||
/// plugin integrates with, a tool installed elsewhere, a licence file.
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package openidea:plugin@1.8.0;
|
||||
package openidea:plugin@1.9.0;
|
||||
|
||||
/// Writes to the IDE log, tagged with the plugin id.
|
||||
interface log {
|
||||
@@ -126,6 +126,33 @@ interface command-runner {
|
||||
execute: func(id: string, arg: option<string>) -> result<option<string>, error>;
|
||||
}
|
||||
|
||||
/// Requests to the language servers the IDE runs (API 1.9).
|
||||
interface language-servers {
|
||||
use types.{error};
|
||||
use workspace.{project};
|
||||
|
||||
/// Sends `method` to the server named `server` (the `name` of its
|
||||
/// `[[language-servers]]` entry in the language definition, e.g. `phoxite`)
|
||||
/// running for `project`, and returns the result as JSON. `params` is JSON,
|
||||
/// or none for no params. Requires `lsp:<server>` and a trusted project.
|
||||
///
|
||||
/// Only the server's own methods pass (`phoxite/laravel/routes`): `initialize`,
|
||||
/// `initialized`, `shutdown`, `exit`, anything starting with `$/` and any
|
||||
/// method whose first segment is an LSP namespace (`textDocument`, `workspace`,
|
||||
/// `window`, `notebookDocument`, `callHierarchy`, `typeHierarchy`,
|
||||
/// `completionItem`, `codeAction`, `codeLens`, `documentLink`, `inlayHint`,
|
||||
/// `workspaceSymbol`, `client`, `telemetry`) are `invalid`.
|
||||
///
|
||||
/// `not-found` when no such server is running for the project: the call never
|
||||
/// starts one. The server's own error is `failed` with its message. The call
|
||||
/// ends with the invocation's cancellation and time budget. At most 256 bytes
|
||||
/// of method and 1 MiB of params.
|
||||
request: func(project: borrow<project>, server: string, method: string, params: option<string>) -> result<string, error>;
|
||||
|
||||
/// The same for a notification: no answer is awaited.
|
||||
notify: func(project: borrow<project>, server: string, method: string, params: option<string>) -> result<_, error>;
|
||||
}
|
||||
|
||||
/// Per-plugin named, read-only Output tabs (API 1.4), with a 1 MiB UTF-8 ring buffer.
|
||||
interface output {
|
||||
use types.{error};
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package openidea:plugin@1.8.0;
|
||||
package openidea:plugin@1.9.0;
|
||||
|
||||
/// Optional export (world `plugin-hover`): Markdown added to the hover of
|
||||
/// documents of the languages declared with the `hover` provider kind,
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package openidea:plugin@1.8.0;
|
||||
package openidea:plugin@1.9.0;
|
||||
|
||||
/// Cross-file associations a plugin publishes for the files it declares under
|
||||
/// `[[contributes.documentIndexers]]`. The host calls `index` in cancellable
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package openidea:plugin@1.8.0;
|
||||
package openidea:plugin@1.9.0;
|
||||
|
||||
/// Embedded languages. The host routes plugin providers and configured language
|
||||
/// servers inside these ranges, preserving host-document UTF-16 coordinates.
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package openidea:plugin@1.8.0;
|
||||
package openidea:plugin@1.9.0;
|
||||
|
||||
/// Optional export (world `plugin-inlay-hints`): inline hints in documents of
|
||||
/// the languages declared with the `inlay-hints` provider kind, including
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package openidea:plugin@1.8.0;
|
||||
package openidea:plugin@1.9.0;
|
||||
|
||||
/// Problems in files, shown in the editor and the Problems view.
|
||||
interface diagnostics {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package openidea:plugin@1.8.0;
|
||||
package openidea:plugin@1.9.0;
|
||||
|
||||
/// Additional language features, called only for declared API 1.4 provider kinds.
|
||||
/// Editor calls have a 50 ms soft / 500 ms hard budget; formatting has 5 seconds.
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package openidea:plugin@1.8.0;
|
||||
package openidea:plugin@1.9.0;
|
||||
|
||||
/// Discovery of the IDE's built-in MCP server; never exposes its URL or token.
|
||||
interface mcp {
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
/// `fs` and `workspace`, and everything else goes through the imports below,
|
||||
/// gated by the capabilities granted in `plugin.toml` (a missing one returns
|
||||
/// `error::denied`).
|
||||
package openidea:plugin@1.8.0;
|
||||
package openidea:plugin@1.9.0;
|
||||
|
||||
world plugin {
|
||||
import log;
|
||||
@@ -31,6 +31,7 @@ world plugin {
|
||||
import output;
|
||||
import auth;
|
||||
import command-runner;
|
||||
import language-servers;
|
||||
import views;
|
||||
import run;
|
||||
import run-targets;
|
||||
@@ -183,6 +184,10 @@ world editor-diagnostics {
|
||||
world plugin-run-configurations { include plugin; export run-configurations; }
|
||||
/// Export-only configurations world, composed with plugin by SDK macros.
|
||||
world configurations-provider { export run-configurations; }
|
||||
/// A plugin that exports configurations with an environment and a debugger (API 1.9).
|
||||
world plugin-launch-configurations { include plugin; export launch-configurations; }
|
||||
/// Export-only launch configurations world, composed with plugin by SDK macros.
|
||||
world launch-configurations-provider { export launch-configurations; }
|
||||
/// A plugin that parses its test output.
|
||||
world plugin-test-results { include plugin; export test-results; }
|
||||
/// Export-only test parser world, composed with plugin by SDK macros.
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package openidea:plugin@1.8.0;
|
||||
package openidea:plugin@1.9.0;
|
||||
|
||||
/// Editor features a plugin provides for the languages it declares under
|
||||
/// `[[contributes.providers]]` (the host calls only declared kinds). They run
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package openidea:plugin@1.8.0;
|
||||
package openidea:plugin@1.9.0;
|
||||
|
||||
/// Project-scoped targets owned by the registering plugin (API 1.4).
|
||||
interface run-targets {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package openidea:plugin@1.8.0;
|
||||
package openidea:plugin@1.9.0;
|
||||
|
||||
/// Launches this plugin's configurations in the invoking window's Run tool window.
|
||||
interface run {
|
||||
@@ -24,6 +24,46 @@ interface run-configurations {
|
||||
configurations: func(project-root: string) -> list<run-configuration>;
|
||||
}
|
||||
|
||||
/// Optional dynamic configurations with an environment and a debugger (API 1.9).
|
||||
/// When a plugin exports both, the IDE uses this one instead of `run-configurations`.
|
||||
interface launch-configurations {
|
||||
use types.{extension};
|
||||
/// A process the run starts, to attach the debugger to.
|
||||
record attach-child {
|
||||
/// Its debugger, as in Attach to Process: `dotnet`, `node`, `python`, `go` or `native`.
|
||||
kind: string,
|
||||
/// Only a process whose command line contains this text.
|
||||
command-contains: option<string>,
|
||||
}
|
||||
/// How Debug starts the configuration.
|
||||
variant debugger {
|
||||
/// Starts `program` under the debugger of this language id (its `[debugger]`), e.g. `python`.
|
||||
launch(string),
|
||||
/// Runs the configuration as Run does, then attaches to the first matching process the
|
||||
/// run starts (it waits for one up to 60 seconds).
|
||||
attach-child(attach-child),
|
||||
/// Later kinds; this IDE treats the configuration as having no debugger.
|
||||
other(extension),
|
||||
}
|
||||
/// `run-configuration` with an environment and a debugger.
|
||||
record launch-configuration {
|
||||
id: string,
|
||||
name: string,
|
||||
program: string,
|
||||
args: list<string>,
|
||||
cwd: option<string>,
|
||||
test: bool,
|
||||
framework: option<string>,
|
||||
/// Variables added to the run's environment (at most 64). A name the IDE's own
|
||||
/// environment already has, such as `PATH`, is refused like in `process`.
|
||||
env: list<tuple<string, string>>,
|
||||
/// None: Debug infers the debugger from a source file in `args`, as before.
|
||||
debugger: option<debugger>,
|
||||
}
|
||||
/// Returns the complete set for this project root.
|
||||
configurations: func(project-root: string) -> list<launch-configuration>;
|
||||
}
|
||||
|
||||
/// Optional parser for test configurations whose framework is plugin.
|
||||
interface test-results {
|
||||
use types.{location, extension};
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package openidea:plugin@1.8.0;
|
||||
package openidea:plugin@1.9.0;
|
||||
|
||||
/// Optional export (world `plugin-semantic-tokens`): semantic colouring of
|
||||
/// documents of the languages declared with the `semantic-tokens` provider
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package openidea:plugin@1.8.0;
|
||||
package openidea:plugin@1.9.0;
|
||||
|
||||
/// Shared types. Positions are 0-based lines and UTF-16 code unit columns,
|
||||
/// as in the editor and LSP.
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package openidea:plugin@1.8.0;
|
||||
package openidea:plugin@1.9.0;
|
||||
|
||||
/// Declarative views: tool windows declared
|
||||
/// under `[[contributes.views]]` and custom editors under
|
||||
@@ -153,7 +153,8 @@ interface views {
|
||||
/// (API 1.7): a review's file before and after, say. `file-name` (a name or
|
||||
/// relative path, at most 256 characters) picks the syntax highlighting and
|
||||
/// names the tab when `diff.title` is absent. Only from a command or event
|
||||
/// of a window; each side at most 1 MiB.
|
||||
/// of a window. Each side at most 8 MiB (earlier hosts: 1 MiB); a larger
|
||||
/// side fails with `invalid("diff too large: …")`.
|
||||
open-diff: func(diff: content-diff, file-name: option<string>) -> result<_, error>;
|
||||
|
||||
/// The view (or every custom editor of that id) shows outdated content:
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package openidea:plugin@1.8.0;
|
||||
package openidea:plugin@1.9.0;
|
||||
|
||||
interface workspace {
|
||||
use types.{error, location};
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"$schema": "https://schema.tauri.app/config/2",
|
||||
"productName": "OpenIDEA",
|
||||
"version": "0.1.45",
|
||||
"version": "0.1.46",
|
||||
"identifier": "ai.l0ng.openidea",
|
||||
"build": {
|
||||
"beforeDevCommand": "pnpm dev",
|
||||
|
||||
@@ -295,9 +295,10 @@ export const lspTheme = EditorView.theme({
|
||||
padding: "6px 10px",
|
||||
borderRadius: "var(--radius-popup)",
|
||||
boxShadow: "var(--shadow-popup)",
|
||||
maxWidth: "480px",
|
||||
whiteSpace: "pre-wrap",
|
||||
},
|
||||
// The hint is the tooltip element itself: beat the editor theme's `.cm-tooltip` width.
|
||||
".cm-tooltip.cm-lsp-hint": { maxWidth: "min(480px, 100%)" },
|
||||
".cm-lsp-hint-error": {
|
||||
backgroundColor: "var(--bg-feedback-error, color-mix(in srgb, var(--danger) 8%, var(--bg-popup)))",
|
||||
borderColor: "color-mix(in srgb, var(--danger) 35%, var(--border-popup))",
|
||||
|
||||
@@ -316,7 +316,7 @@ export async function fillMarkers(
|
||||
const c = up[i]!;
|
||||
const self = classOf(c);
|
||||
if (!self) continue;
|
||||
const found = resolver ? await superMethodsFrom(resolver, self.name, c.symbol, deps) : [];
|
||||
const found = resolver ? await superMethodsFrom(resolver, self, c.symbol, deps) : [];
|
||||
if (!found.length) continue;
|
||||
const known = supers[i]!;
|
||||
// Same merge rule as ↓: add the graph's super methods to what the server answered.
|
||||
@@ -369,41 +369,37 @@ function mergeLocations(first: readonly Location[], more: readonly Location[]):
|
||||
return [...first, ...more.filter((l) => !first.some((f) => sameDeclarationLine(f, l)))];
|
||||
}
|
||||
|
||||
/** Identifies one class declaration in the inheritance graph. */
|
||||
/**
|
||||
* Super methods of `method` declared by a class in `byName`, walking the inheritance
|
||||
* graph's bases up to a few levels. Empty when no base declares the method.
|
||||
* Super methods of `method` declared by a base of the class declaration `start`, walking the
|
||||
* inheritance graph's concrete declarations up to a few levels: a base resolves from the file
|
||||
* that names it, so an unrelated class of the same name never joins the walk. Empty when no
|
||||
* base declares the method.
|
||||
*/
|
||||
async function superMethodsFrom(
|
||||
resolver: InheritanceIndex,
|
||||
start: string,
|
||||
start: ClassInheritance,
|
||||
method: string,
|
||||
deps: MarkerDeps,
|
||||
depth = 3,
|
||||
): Promise<{ location: Location; owner: string }[]> {
|
||||
const bare = method.replace(/\s*[(<].*$/, "");
|
||||
const seen = new Set<string>([start]);
|
||||
const key = (c: ClassInheritance) => `${c.path}:${c.line}:${c.col}`;
|
||||
const seen = new Set<string>([key(start)]);
|
||||
let level = [start];
|
||||
for (let d = 0; d < depth && level.length; d++) {
|
||||
const next: string[] = [];
|
||||
const next: ClassInheritance[] = [];
|
||||
const found: { location: Location; owner: string }[] = [];
|
||||
for (const name of level) {
|
||||
for (const cls of resolver.byName.get(name) ?? []) {
|
||||
for (const base of cls.bases) {
|
||||
if (!seen.add(base)) continue;
|
||||
// Same rule as the graph: a base the imports name, else a unique one.
|
||||
const declarations = await resolver.resolve(base, cls.path);
|
||||
let answered = false;
|
||||
for (const baseCls of declarations) {
|
||||
const outline = await deps.supers.outline(baseCls.path).catch(() => [] as OutlineItem[]);
|
||||
const m = methodInOutline(outline, baseCls, bare);
|
||||
if (m) {
|
||||
found.push({ location: { path: baseCls.path, range: m.selection_range }, owner: base });
|
||||
answered = true;
|
||||
}
|
||||
}
|
||||
// Not found in a base that declares nothing: keep walking its own bases.
|
||||
if (!answered) next.push(base);
|
||||
for (const cls of level) {
|
||||
for (const base of cls.bases) {
|
||||
// Same rule as the graph: a base the imports name, else a unique one.
|
||||
for (const baseCls of await resolver.resolve(base, cls.path)) {
|
||||
if (seen.has(key(baseCls))) continue;
|
||||
seen.add(key(baseCls));
|
||||
const outline = await deps.supers.outline(baseCls.path).catch(() => [] as OutlineItem[]);
|
||||
const m = methodInOutline(outline, baseCls, bare);
|
||||
if (m) found.push({ location: { path: baseCls.path, range: m.selection_range }, owner: base });
|
||||
// Not declared there: keep walking that class's own bases.
|
||||
else next.push(baseCls);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -316,7 +316,9 @@ export async function ancestryResolution(
|
||||
continue;
|
||||
}
|
||||
for (const parent of found) {
|
||||
if (!seen.add(declarationKey(parent))) continue;
|
||||
const key = declarationKey(parent);
|
||||
if (seen.has(key)) continue;
|
||||
seen.add(key);
|
||||
out.push({ decl: parent, depth: d });
|
||||
next.push(parent);
|
||||
}
|
||||
|
||||
@@ -803,6 +803,26 @@ describe("python inheritance fallback", () => {
|
||||
expect(cachedMarkers(candidates, ALL, cache).map((m) => [m.line, m.kind])).toEqual([[0, "overridden"]]);
|
||||
});
|
||||
|
||||
it("walks up from the class itself, not every class of its name", async () => {
|
||||
// a.py: `class BaseA` with `foo`, `class Child(BaseA)` with `foo`; b.py the same with BaseB.
|
||||
const outline = (base: string) => [
|
||||
item(base, "class", 0, 2, [item("foo", "method", 1, 1)], 6),
|
||||
item("Child", "class", 3, 5, [item("foo", "method", 4, 4)], 6),
|
||||
];
|
||||
const graph: ClassInheritance[] = [
|
||||
{ path: "/p/a.py", line: 0, col: 6, name: "BaseA", bases: [] },
|
||||
{ path: "/p/a.py", line: 3, col: 6, name: "Child", bases: ["BaseA"] },
|
||||
{ path: "/p/b.py", line: 0, col: 6, name: "BaseB", bases: [] },
|
||||
{ path: "/p/b.py", line: 3, col: 6, name: "Child", bases: ["BaseB"] },
|
||||
];
|
||||
const { deps } = pythonServer(graph, { "/p/a.py": outline("BaseA"), "/p/b.py": outline("BaseB") });
|
||||
const candidates = markerCandidates(outline("BaseA"), () => "");
|
||||
const cache = emptyCache();
|
||||
await fillMarkers("/p/a.py", candidates, ALL, deps(), cache);
|
||||
const up = cachedMarkers(candidates, ALL, cache).find((m) => m.line === 4 && m.kind === "overriding");
|
||||
expect(up?.targets.map((t) => [t.path, t.range.start.line])).toEqual([["/p/a.py", 1]]);
|
||||
});
|
||||
|
||||
it("resolves an ambiguous base name through the subclass file's imports", async () => {
|
||||
// Two modules declare `Config`; `from pkg.b import Config` picks one of them, so
|
||||
// only b.py's Config is marked as subclassed.
|
||||
|
||||
@@ -123,7 +123,9 @@ export async function pythonDescendants(
|
||||
const next: ClassInheritance[] = [];
|
||||
for (const parent of level) {
|
||||
for (const sub of subclasses.get(declarationKey(parent)) ?? []) {
|
||||
if (!seen.add(declarationKey(sub))) continue;
|
||||
const key = declarationKey(sub);
|
||||
if (seen.has(key)) continue;
|
||||
seen.add(key);
|
||||
out.push(sub);
|
||||
next.push(sub);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/** IDEA's Change Signature dialog for Java methods (`signature.ts`). */
|
||||
import { useState } from "react";
|
||||
import { useEffect, useRef, useState } from "react";
|
||||
import type { MethodSignature } from "@/bindings";
|
||||
import { Checkbox, Dialog, IconButton, Input, Select, Spinner, T, Toolbar } from "@/ui";
|
||||
import { useTx } from "@/platform/i18n";
|
||||
@@ -46,7 +46,11 @@ function ChangeSignatureDialogInner({ request }: { request: SignatureRequest })
|
||||
const ready = !busy && !problem && signatureChanged(info, signature);
|
||||
const current = Math.min(selected, rows.length - 1);
|
||||
|
||||
// Closing the dialog cancels a refactoring still being checked: it applies nothing.
|
||||
const running = useRef<AbortController | null>(null);
|
||||
useEffect(() => () => running.current?.abort(), []);
|
||||
const close = () => {
|
||||
running.current?.abort();
|
||||
useSignatureDialog.setState({ request: null });
|
||||
request.view.focus();
|
||||
};
|
||||
@@ -72,9 +76,10 @@ function ChangeSignatureDialogInner({ request }: { request: SignatureRequest })
|
||||
};
|
||||
const submit = async (preview: boolean) => {
|
||||
if (!ready) return;
|
||||
const run = (running.current = new AbortController());
|
||||
setBusy(true);
|
||||
setError(null);
|
||||
const outcome = await changeSignature(request, signature, delegate, preview);
|
||||
const outcome = await changeSignature(request, signature, delegate, preview, run.signal);
|
||||
if (useSignatureDialog.getState().request !== request) return;
|
||||
setBusy(false);
|
||||
if (outcome.status === "done") close();
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/** IDEA's Extract Interface dialog for Java classes (`extractInterface.ts`). */
|
||||
import { useState } from "react";
|
||||
import { useEffect, useRef, useState } from "react";
|
||||
import { Checkbox, Dialog, Input, Select, Spinner, T } from "@/ui";
|
||||
import { useTx } from "@/platform/i18n";
|
||||
import {
|
||||
@@ -39,7 +39,11 @@ function ExtractInterfaceDialogInner({ request }: { request: InterfaceRequest })
|
||||
const ready = !busy && !problem && !!target;
|
||||
const allChecked = checked.size === info.members.length;
|
||||
|
||||
// Closing the dialog cancels a refactoring still being checked: it applies nothing.
|
||||
const running = useRef<AbortController | null>(null);
|
||||
useEffect(() => () => running.current?.abort(), []);
|
||||
const close = () => {
|
||||
running.current?.abort();
|
||||
useExtractInterfaceDialog.setState({ request: null });
|
||||
request.view.focus();
|
||||
};
|
||||
@@ -52,10 +56,11 @@ function ExtractInterfaceDialogInner({ request }: { request: InterfaceRequest })
|
||||
});
|
||||
const submit = async (preview: boolean) => {
|
||||
if (!ready) return;
|
||||
const run = (running.current = new AbortController());
|
||||
setBusy(true);
|
||||
setError(null);
|
||||
const members = info.members.map((m) => m.handleIdentifier).filter((id) => checked.has(id));
|
||||
const outcome = await extractInterface(request, trimmed, target, members, preview);
|
||||
const outcome = await extractInterface(request, trimmed, target, members, preview, run.signal);
|
||||
if (useExtractInterfaceDialog.getState().request !== request) return;
|
||||
setBusy(false);
|
||||
if (outcome.status === "done") close();
|
||||
|
||||
@@ -0,0 +1,56 @@
|
||||
import { describe, expect, it, vi } from "vitest";
|
||||
|
||||
const cancelRequest = vi.fn(async (_id: number) => ({ status: "ok", data: null }));
|
||||
vi.mock("@/platform/ipc", async (original) => {
|
||||
const ipc = await original<typeof import("@/platform/ipc")>();
|
||||
return { ...ipc, commands: { ...ipc.commands, cancelRequest } };
|
||||
});
|
||||
|
||||
const { cancellable } = await import("./signature");
|
||||
const { isCancelled } = await import("@/platform/ipc");
|
||||
|
||||
describe("cancellable refactoring requests", () => {
|
||||
it("cancels the request in flight when the dialog closes", async () => {
|
||||
const run = new AbortController();
|
||||
let sent = -1;
|
||||
let answer!: (v: string) => void;
|
||||
const reply = cancellable(run.signal, (id) => {
|
||||
sent = id;
|
||||
return new Promise<string>((r) => (answer = r));
|
||||
});
|
||||
run.abort();
|
||||
expect(cancelRequest).toHaveBeenCalledWith(sent);
|
||||
answer("late");
|
||||
await expect(reply).resolves.toBe("late");
|
||||
});
|
||||
|
||||
it("leaves a request alone once it answered", async () => {
|
||||
cancelRequest.mockClear();
|
||||
const run = new AbortController();
|
||||
await cancellable(run.signal, async () => "done");
|
||||
run.abort();
|
||||
expect(cancelRequest).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it("never sends a request the dialog closed before", async () => {
|
||||
const run = new AbortController();
|
||||
run.abort();
|
||||
const send = vi.fn(async () => "sent");
|
||||
const err = await cancellable(run.signal, send).catch((e: unknown) => e);
|
||||
expect(isCancelled(err)).toBe(true);
|
||||
expect(send).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it("tells the sender once the dialog closed after the request was handed over", async () => {
|
||||
const run = new AbortController();
|
||||
let wanted!: () => boolean;
|
||||
const reply = cancellable(run.signal, async (_id, w) => {
|
||||
wanted = w;
|
||||
return "sent";
|
||||
});
|
||||
expect(wanted()).toBe(true);
|
||||
run.abort();
|
||||
expect(wanted()).toBe(false);
|
||||
await reply;
|
||||
});
|
||||
});
|
||||
@@ -25,5 +25,9 @@ describe("extract interface", () => {
|
||||
expect(interfaceProblem("Shape", "Shape", 1)).toBe("Interface name should differ from the class name");
|
||||
expect(interfaceProblem("HasArea", "Shape", 0)).toBe("Select the members to form the interface");
|
||||
expect(interfaceProblem("HasArea", "Shape", 2)).toBeNull();
|
||||
// Java identifiers take letters of any script.
|
||||
expect(interfaceProblem("处理器", "Shape", 1)).toBeNull();
|
||||
expect(interfaceProblem("Größe", "Shape", 1)).toBeNull();
|
||||
expect(interfaceProblem("a-b", "Shape", 1)).toBe("Interface name is not a valid identifier");
|
||||
});
|
||||
});
|
||||
@@ -17,7 +17,7 @@ import { tx } from "@/platform/i18n";
|
||||
import { commands, isCancelled, nextRequestId, unavailableText } from "@/platform/ipc";
|
||||
import { editorService } from "@/workbench/contributions";
|
||||
import { cannotPerform } from "./catalog";
|
||||
import { applyEdit, confirmProblems } from "./signature";
|
||||
import { JAVA_NAME, applyEdit, cancellable, confirmProblems } from "./signature";
|
||||
|
||||
/** Languages whose server extracts interfaces through the dialog. */
|
||||
export const EXTRACT_INTERFACE_LANGUAGES = new Set(["java"]);
|
||||
@@ -51,8 +51,6 @@ export function memberLabel(m: InterfaceMember): string {
|
||||
return `${m.name}${params}: ${m.typeName}`;
|
||||
}
|
||||
|
||||
const JAVA_NAME = /^[A-Za-z_$][\w$]*$/;
|
||||
|
||||
/** Why the interface can't be extracted yet, or null. */
|
||||
export function interfaceProblem(name: string, className: string, members: number): string | null {
|
||||
if (!name) return "No interface name specified";
|
||||
@@ -127,6 +125,8 @@ export async function extractInterface(
|
||||
pkg: PackageChoice,
|
||||
members: readonly string[],
|
||||
preview: boolean,
|
||||
/** The dialog closed: nothing is confirmed, previewed or applied any more. */
|
||||
signal?: AbortSignal,
|
||||
): Promise<InterfaceOutcome> {
|
||||
const { view } = request;
|
||||
if (view.state.doc !== request.text) return { status: "stay", error: "The file changed; open the dialog again" };
|
||||
@@ -136,27 +136,32 @@ export async function extractInterface(
|
||||
for (;;) {
|
||||
await whenSynced(view);
|
||||
const token: string | null = confirmation;
|
||||
extracted = await lspRequest(() =>
|
||||
commands.lspExtractInterface(nextRequestId(), request.doc, request.pos, [...members], name, pkg.json, token),
|
||||
extracted = await cancellable(signal, (id, wanted) =>
|
||||
lspRequest(
|
||||
() => commands.lspExtractInterface(id, request.doc, request.pos, [...members], name, pkg.json, token),
|
||||
wanted,
|
||||
),
|
||||
);
|
||||
if (signal?.aborted) return { status: "stay" };
|
||||
const fatal = extracted.problems.find((p) => p.severity === "fatal");
|
||||
if (fatal || (!extracted.edit && !extracted.confirmation))
|
||||
return { status: "stay", error: fatal?.message ?? "Nothing to change" };
|
||||
if (!extracted.confirmation) break;
|
||||
if (!(await confirmProblems(extracted.problems.map((p) => p.message)))) return { status: "stay" };
|
||||
if (!(await confirmProblems(extracted.problems.map((p) => p.message))) || signal?.aborted)
|
||||
return { status: "stay" };
|
||||
confirmation = extracted.confirmation;
|
||||
}
|
||||
} catch (e) {
|
||||
if (isCancelled(e)) return { status: "stay" };
|
||||
if (isCancelled(e) || signal?.aborted) return { status: "stay" };
|
||||
return { status: "stay", error: errorText(e) };
|
||||
}
|
||||
const edit = extracted.edit!;
|
||||
const summary = summarizeWorkspaceEdit(edit);
|
||||
if (!summary.files) return { status: "stay", error: "Nothing to change" };
|
||||
const created = edit.files.find((f) => f.kind === "create")?.path;
|
||||
const apply = async () => {
|
||||
await applyEdit(view, edit);
|
||||
if (created) await editorService().openFile(created, { focus: true });
|
||||
const apply = async (cancel?: AbortSignal) => {
|
||||
await applyEdit(view, edit, cancel);
|
||||
if (created && !cancel?.aborted) await editorService().openFile(created, { focus: true });
|
||||
};
|
||||
if (preview) {
|
||||
openPopup({
|
||||
@@ -167,7 +172,7 @@ export async function extractInterface(
|
||||
onConfirm: () => void apply(),
|
||||
});
|
||||
} else {
|
||||
await apply();
|
||||
await apply(signal);
|
||||
}
|
||||
return { status: "done" };
|
||||
}
|
||||
@@ -23,6 +23,10 @@ describe("change signature", () => {
|
||||
it("tells what keeps the signature from being submitted", () => {
|
||||
expect(signatureProblem(info)).toBeNull();
|
||||
expect(signatureProblem({ ...info, methodName: "2x" })).toBe("Method name is not a valid identifier");
|
||||
expect(signatureProblem({ ...info, methodName: "处理" })).toBeNull();
|
||||
expect(
|
||||
signatureProblem({ ...info, parameters: info.parameters.map((p, i) => ({ ...p, name: `数量${i}` })) }),
|
||||
).toBeNull();
|
||||
expect(signatureProblem({ ...info, returnType: " " })).toBe("Return type is not specified");
|
||||
const dup = { ...info, parameters: [info.parameters[0]!, { ...info.parameters[1]!, name: "a" }] };
|
||||
expect(signatureProblem(dup)).toBe("Duplicate parameter name");
|
||||
|
||||
@@ -15,7 +15,7 @@ import { showHint } from "@/editor/lsp/hint";
|
||||
import { openPopup } from "@/editor/lsp/popupStore";
|
||||
import { summarizeWorkspaceEdit } from "@/editor/lsp/workspaceEdit";
|
||||
import { tx } from "@/platform/i18n";
|
||||
import { commands, isCancelled, nextRequestId, unavailableText } from "@/platform/ipc";
|
||||
import { IpcError, commands, isCancelled, nextRequestId, unavailableText } from "@/platform/ipc";
|
||||
import { ask } from "@/workbench/messages";
|
||||
import { cannotPerform } from "./catalog";
|
||||
|
||||
@@ -50,7 +50,8 @@ export function signatureText(sig: {
|
||||
return head + throws;
|
||||
}
|
||||
|
||||
const JAVA_NAME = /^[A-Za-z_$][\w$]*$/;
|
||||
/** A Java identifier: letters of any script, `$` and `_`, then digits and combining marks too. */
|
||||
export const JAVA_NAME = /^[\p{L}\p{Nl}\p{Sc}\p{Pc}][\p{L}\p{Nl}\p{Sc}\p{Pc}\p{Nd}\p{Mn}\p{Mc}]*$/u;
|
||||
|
||||
/** Why the edited signature can't be submitted yet, or null. */
|
||||
export function signatureProblem(sig: MethodSignature): string | null {
|
||||
@@ -128,15 +129,40 @@ export async function startChangeSignature(view: EditorView): Promise<void> {
|
||||
}
|
||||
}
|
||||
|
||||
export async function applyEdit(view: EditorView, edit: WorkspaceEdit) {
|
||||
export async function applyEdit(view: EditorView, edit: WorkspaceEdit, signal?: AbortSignal) {
|
||||
try {
|
||||
await whenAllSynced();
|
||||
await lspRequest(() => commands.applyWorkspaceEdit(edit));
|
||||
// The dialog closed while the editors were syncing: nothing is applied.
|
||||
if (signal?.aborted) return;
|
||||
await lspRequest(
|
||||
() => commands.applyWorkspaceEdit(edit),
|
||||
() => !signal?.aborted,
|
||||
);
|
||||
} catch (e) {
|
||||
reportLspError(view, e, true);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sends `send(id, wanted)` with a fresh request id that `signal` cancels. `wanted` goes to
|
||||
* `lspRequest`, which syncs editors first: a dialog closed meanwhile never sends the request.
|
||||
*/
|
||||
export async function cancellable<T>(
|
||||
signal: AbortSignal | undefined,
|
||||
send: (id: number, wanted: () => boolean) => Promise<T>,
|
||||
): Promise<T> {
|
||||
// Closed before the request went out: it never does (a cancel can't reach an unsent request).
|
||||
if (signal?.aborted) throw new IpcError({ kind: "cancelled", message: "Cancelled" });
|
||||
const id = nextRequestId();
|
||||
const abort = () => void commands.cancelRequest(id);
|
||||
signal?.addEventListener("abort", abort);
|
||||
try {
|
||||
return await send(id, () => !signal?.aborted);
|
||||
} finally {
|
||||
signal?.removeEventListener("abort", abort);
|
||||
}
|
||||
}
|
||||
|
||||
export async function confirmProblems(messages: readonly string[]): Promise<boolean> {
|
||||
const { button } = await ask({
|
||||
title: "Problems Detected",
|
||||
@@ -158,6 +184,8 @@ export async function changeSignature(
|
||||
signature: MethodSignature,
|
||||
delegate: boolean,
|
||||
preview: boolean,
|
||||
/** The dialog closed: nothing is confirmed, previewed or applied any more. */
|
||||
signal?: AbortSignal,
|
||||
): Promise<SignatureOutcome> {
|
||||
const { view } = request;
|
||||
if (view.state.doc !== request.text) return { status: "stay", error: "The file changed; open the dialog again" };
|
||||
@@ -167,18 +195,20 @@ export async function changeSignature(
|
||||
for (;;) {
|
||||
await whenSynced(view);
|
||||
const token: string | null = confirmation;
|
||||
changed = await lspRequest(() =>
|
||||
commands.lspChangeSignature(nextRequestId(), request.doc, request.pos, signature, delegate, token),
|
||||
changed = await cancellable(signal, (id, wanted) =>
|
||||
lspRequest(() => commands.lspChangeSignature(id, request.doc, request.pos, signature, delegate, token), wanted),
|
||||
);
|
||||
if (signal?.aborted) return { status: "stay" };
|
||||
const fatal = changed.problems.find((p) => p.severity === "fatal");
|
||||
if (fatal || (!changed.edit && !changed.confirmation))
|
||||
return { status: "stay", error: fatal?.message ?? "Nothing to change" };
|
||||
if (!changed.confirmation) break;
|
||||
if (!(await confirmProblems(changed.problems.map((p) => p.message)))) return { status: "stay" };
|
||||
if (!(await confirmProblems(changed.problems.map((p) => p.message))) || signal?.aborted)
|
||||
return { status: "stay" };
|
||||
confirmation = changed.confirmation;
|
||||
}
|
||||
} catch (e) {
|
||||
if (isCancelled(e)) return { status: "stay" };
|
||||
if (isCancelled(e) || signal?.aborted) return { status: "stay" };
|
||||
return { status: "stay", error: errorText(e) };
|
||||
}
|
||||
const edit = changed.edit!;
|
||||
@@ -193,7 +223,7 @@ export async function changeSignature(
|
||||
onConfirm: () => void applyEdit(view, edit),
|
||||
});
|
||||
} else {
|
||||
await applyEdit(view, edit);
|
||||
await applyEdit(view, edit, signal);
|
||||
}
|
||||
return { status: "done" };
|
||||
}
|
||||
@@ -173,9 +173,6 @@
|
||||
.chipDetail > span {
|
||||
grid-area: 1 / 1;
|
||||
}
|
||||
.chipSizer {
|
||||
visibility: hidden;
|
||||
}
|
||||
.chipChevron {
|
||||
flex: none;
|
||||
color: var(--fg-muted);
|
||||
@@ -222,46 +219,38 @@
|
||||
color: var(--fg-muted);
|
||||
cursor: default;
|
||||
}
|
||||
.activeModelBar {
|
||||
/* The model popup's top: effort (and context size) as segmented controls. */
|
||||
.quickSettings {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: var(--space-1-5);
|
||||
padding: 4px 10px 10px;
|
||||
margin-bottom: 4px;
|
||||
border-bottom: 1px solid var(--border);
|
||||
}
|
||||
.quickRow {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: var(--space-2);
|
||||
width: calc(100% - 12px);
|
||||
margin: 2px 6px 6px;
|
||||
padding: 6px 8px;
|
||||
border: 0;
|
||||
border-radius: var(--radius-control);
|
||||
background: var(--bg-elev);
|
||||
box-shadow: inset 0 0 0 1px var(--border);
|
||||
color: var(--fg-strong);
|
||||
text-align: left;
|
||||
cursor: pointer;
|
||||
transition: background var(--dur-fast) var(--ease);
|
||||
}
|
||||
.activeModelBar:hover,
|
||||
.activeModelBar:focus-visible {
|
||||
outline: none;
|
||||
background: var(--bg-hover);
|
||||
}
|
||||
.activeModelName {
|
||||
flex: 1 1 auto;
|
||||
.quickRow > .segmented {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
font-weight: 600;
|
||||
}
|
||||
.activeModelMeta {
|
||||
.quickLabel {
|
||||
flex: none;
|
||||
width: 52px;
|
||||
color: var(--fg-muted);
|
||||
font-size: var(--fs-small);
|
||||
}
|
||||
.activeModelGear {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: var(--space-0-5);
|
||||
flex: none;
|
||||
color: var(--fg-muted);
|
||||
/* A model's configure button shows on its row's hover only. */
|
||||
.modelEffortPopup [role="option"] .modelRowConfigure {
|
||||
opacity: 0;
|
||||
}
|
||||
.modelEffortPopup [role="option"]:hover .modelRowConfigure,
|
||||
.modelEffortPopup [role="option"][aria-selected="true"] .modelRowConfigure,
|
||||
.modelEffortPopup .modelRowConfigure:focus-visible {
|
||||
opacity: 1;
|
||||
}
|
||||
.modelRowConfigure {
|
||||
display: grid;
|
||||
@@ -299,52 +288,9 @@
|
||||
color: var(--warning);
|
||||
}
|
||||
|
||||
/* Page 2: per-model configuration view. */
|
||||
.modelDetail {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: var(--space-3);
|
||||
padding: 6px 12px 8px;
|
||||
}
|
||||
.modelDetailHeader {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: var(--space-1-5);
|
||||
}
|
||||
.modelDetailTitle {
|
||||
flex: 1 1 auto;
|
||||
min-width: 0;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
color: var(--fg-strong);
|
||||
font-weight: 600;
|
||||
}
|
||||
.modelDetailActions {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: var(--space-0-5);
|
||||
flex: none;
|
||||
}
|
||||
.pinnedButton {
|
||||
color: var(--accent);
|
||||
}
|
||||
.detailSection {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: var(--space-1-5);
|
||||
}
|
||||
.detailSectionLabel {
|
||||
color: var(--fg-strong);
|
||||
font-weight: 600;
|
||||
font-size: var(--fs-small);
|
||||
}
|
||||
.detailRow {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: var(--space-3);
|
||||
}
|
||||
.segmented {
|
||||
display: flex;
|
||||
align-items: stretch;
|
||||
@@ -384,84 +330,6 @@
|
||||
color: var(--fg-strong);
|
||||
font-weight: 600;
|
||||
}
|
||||
.costCard {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: var(--space-1);
|
||||
padding: 8px 10px;
|
||||
border-radius: var(--radius-popup);
|
||||
background: var(--bg-elev);
|
||||
box-shadow: inset 0 0 0 1px var(--border);
|
||||
}
|
||||
.costCardHeader {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: var(--space-2);
|
||||
}
|
||||
.costCardTitle {
|
||||
color: var(--fg-strong);
|
||||
font-weight: 600;
|
||||
font-size: var(--fs-small);
|
||||
}
|
||||
.costCardRow {
|
||||
display: flex;
|
||||
align-items: baseline;
|
||||
justify-content: space-between;
|
||||
gap: var(--space-3);
|
||||
color: var(--fg-secondary);
|
||||
font-size: var(--fs-small);
|
||||
}
|
||||
.costCardValue {
|
||||
color: var(--fg-strong);
|
||||
font-weight: 600;
|
||||
font-variant-numeric: tabular-nums;
|
||||
}
|
||||
.pricingCard {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
border-radius: var(--radius-popup);
|
||||
background: var(--bg-elev);
|
||||
box-shadow: inset 0 0 0 1px var(--border);
|
||||
}
|
||||
.pricingHeader {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: var(--space-1-5);
|
||||
width: 100%;
|
||||
padding: 8px 10px;
|
||||
border: 0;
|
||||
border-radius: inherit;
|
||||
background: transparent;
|
||||
color: var(--fg-strong);
|
||||
text-align: left;
|
||||
cursor: pointer;
|
||||
}
|
||||
.pricingHeader:hover,
|
||||
.pricingHeader:focus-visible {
|
||||
outline: none;
|
||||
background: var(--bg-hover);
|
||||
}
|
||||
.pricingChevron {
|
||||
flex: none;
|
||||
color: var(--fg-muted);
|
||||
}
|
||||
.pricingTitle {
|
||||
flex: 1 1 auto;
|
||||
font-weight: 600;
|
||||
font-size: var(--fs-small);
|
||||
}
|
||||
.pricingBody {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: var(--space-1);
|
||||
padding: 2px 12px 10px;
|
||||
}
|
||||
.pricingSubhead {
|
||||
margin-bottom: 2px;
|
||||
color: var(--fg-muted);
|
||||
font-size: var(--fs-small);
|
||||
}
|
||||
.modePopup {
|
||||
min-width: 200px;
|
||||
padding: 6px 0;
|
||||
@@ -561,9 +429,6 @@
|
||||
gap: 5px;
|
||||
white-space: nowrap;
|
||||
}
|
||||
.pickerName {
|
||||
color: var(--fg-subtle);
|
||||
}
|
||||
|
||||
/* Above the text: the current file to reference, attached files and images. */
|
||||
.context {
|
||||
|
||||
@@ -33,7 +33,9 @@ import {
|
||||
Icon,
|
||||
IconButton,
|
||||
List,
|
||||
Menu,
|
||||
Popup,
|
||||
type MenuItem,
|
||||
firstSelectable,
|
||||
listNavigate,
|
||||
fileIconName,
|
||||
@@ -141,6 +143,8 @@ export interface ComposerProps {
|
||||
toolbar?: ReactNode;
|
||||
/** Right of the bottom row: send / stop buttons. */
|
||||
actions?: ReactNode;
|
||||
/** Extra items for the Add Context menu, after the file and image items. */
|
||||
addMenu?: MenuItem[];
|
||||
className?: string;
|
||||
}
|
||||
|
||||
@@ -979,6 +983,18 @@ export function Composer(props: ComposerProps) {
|
||||
[id, projectRoot, root],
|
||||
);
|
||||
|
||||
const [addOpen, setAddOpen] = useState(false);
|
||||
const addAnchor = useRef<HTMLButtonElement>(null);
|
||||
const insertMention = () => {
|
||||
const view = viewRef.current;
|
||||
if (!view) return;
|
||||
// At the caret while typing, else after the text.
|
||||
const end = view.state.doc.length;
|
||||
const { from, to } = view.hasFocus ? view.state.selection.main : { from: end, to: end };
|
||||
const before = view.state.sliceDoc(Math.max(0, from - 1), from);
|
||||
replace(from, to, before && !/\s/.test(before) ? " @" : "@");
|
||||
view.focus();
|
||||
};
|
||||
const showContext = images.length > 0 || attached.length > 0 || !!suggested;
|
||||
|
||||
return (
|
||||
@@ -1107,14 +1123,23 @@ export function Composer(props: ComposerProps) {
|
||||
<Icon name={fileIconName(basename(suggested.rel), suggested.rel)} size={14} />
|
||||
<span className={styles.attachmentName}>{basename(suggested.rel)}</span>
|
||||
<span className={styles.suggestionHint}>{tx("Current File")}</span>
|
||||
{/* The chip is the IDE context switch: off here, back on from the dashed chip. */}
|
||||
<button
|
||||
type="button"
|
||||
className={styles.removeChip}
|
||||
aria-label={tx("Don't Add the Current File")}
|
||||
onClick={() => setIdeContext(false)}
|
||||
>
|
||||
<Icon name="close" size={10} />
|
||||
</button>
|
||||
</span>
|
||||
)}
|
||||
{suggested && !ideContext && (
|
||||
<button
|
||||
type="button"
|
||||
className={styles.suggestion}
|
||||
title={tx`Reference ${suggested.rel}`}
|
||||
onClick={() => addPaths([suggested.path])}
|
||||
title={tx`Add ${suggested.rel} and the selection to your requests`}
|
||||
onClick={() => setIdeContext(true)}
|
||||
>
|
||||
<Icon name="plus" size={12} />
|
||||
<Icon name={fileIconName(basename(suggested.rel), suggested.rel)} size={14} />
|
||||
@@ -1167,35 +1192,25 @@ export function Composer(props: ComposerProps) {
|
||||
<div className={styles.toolbar}>{props.toolbar}</div>
|
||||
<div className={styles.actions}>
|
||||
<IconButton
|
||||
icon="paperclip"
|
||||
title="Reference a File (@)"
|
||||
ref={addAnchor}
|
||||
icon="plus"
|
||||
title="Add Context"
|
||||
aria-haspopup="menu"
|
||||
aria-expanded={addOpen}
|
||||
className={styles.composerButton}
|
||||
onClick={() => {
|
||||
const view = viewRef.current;
|
||||
if (!view) return;
|
||||
// At the caret while typing, else after the text.
|
||||
const end = view.state.doc.length;
|
||||
const { from, to } = view.hasFocus ? view.state.selection.main : { from: end, to: end };
|
||||
const before = view.state.sliceDoc(Math.max(0, from - 1), from);
|
||||
replace(from, to, before && !/\s/.test(before) ? " @" : "@");
|
||||
}}
|
||||
onClick={() => setAddOpen((v) => !v)}
|
||||
/>
|
||||
<IconButton
|
||||
icon="file-code"
|
||||
title={
|
||||
ideContext
|
||||
? "IDE Context Enabled: the current file and selection are added to your request"
|
||||
: "IDE Context Disabled: the current file and selection are not added to your request"
|
||||
}
|
||||
pressed={ideContext}
|
||||
className={styles.composerButton}
|
||||
onClick={() => setIdeContext(!ideContext)}
|
||||
/>
|
||||
<IconButton
|
||||
icon="image"
|
||||
title="Attach Image…"
|
||||
className={styles.composerButton}
|
||||
onClick={() => imageInput.current?.click()}
|
||||
<Menu
|
||||
open={addOpen}
|
||||
anchor={addAnchor}
|
||||
placement="bottom-end"
|
||||
onClose={() => setAddOpen(false)}
|
||||
aria-label="Add Context"
|
||||
items={[
|
||||
{ id: "reference", label: "Reference a File (@)", icon: "paperclip", run: insertMention },
|
||||
{ id: "image", label: "Attach Image…", icon: "image", run: () => imageInput.current?.click() },
|
||||
...(props.addMenu ?? []),
|
||||
]}
|
||||
/>
|
||||
<input
|
||||
ref={imageInput}
|
||||
|
||||
@@ -273,15 +273,19 @@ describe("model and effort button", () => {
|
||||
},
|
||||
];
|
||||
|
||||
it("shows the model with the agent's effort name and the mode with Allow All", () => {
|
||||
render(<ConfigPickers config={copilotConfig()} onChange={vi.fn()} />);
|
||||
const model = screen.getByRole("button", { name: "Model" });
|
||||
expect(model).toHaveTextContent("Claude Sonnet 5.5medium");
|
||||
it("shows the effort as its own picker beside the model, and the mode with Allow All", () => {
|
||||
const onChange = vi.fn();
|
||||
render(<ConfigPickers config={copilotConfig()} onChange={onChange} />);
|
||||
expect(screen.getByRole("button", { name: "Model" })).toHaveTextContent("Claude Sonnet 5.5");
|
||||
expect(screen.getByRole("button", { name: "Mode" })).toHaveTextContent("AgentAllow All");
|
||||
expect(screen.queryByRole("button", { name: "Reasoning Effort" })).not.toBeInTheDocument();
|
||||
const effort = screen.getByRole("button", { name: "Reasoning Effort" });
|
||||
expect(effort).toHaveTextContent("medium");
|
||||
fireEvent.click(effort);
|
||||
fireEvent.click(screen.getByRole("option", { name: "XHigh" }));
|
||||
expect(onChange).toHaveBeenCalledExactlyOnceWith("reasoning_effort", "xhigh");
|
||||
});
|
||||
|
||||
it("tucks Fast into the model popup with effort", () => {
|
||||
it("tucks Fast into the model popup", () => {
|
||||
const config = [
|
||||
...copilotConfig().filter((o) => o.category !== "thought_level"),
|
||||
{
|
||||
@@ -297,23 +301,21 @@ describe("model and effort button", () => {
|
||||
render(<ConfigPickers config={config} onChange={vi.fn()} />);
|
||||
expect(screen.queryByRole("switch", { name: "Fast" })).not.toBeInTheDocument();
|
||||
fireEvent.click(screen.getByRole("button", { name: "Model" }));
|
||||
const dialog = screen.getByRole("dialog", { name: "Model & effort settings" });
|
||||
const dialog = screen.getByRole("dialog", { name: "Model" });
|
||||
expect(within(dialog).getByRole("switch", { name: "Fast" })).toHaveAttribute("aria-checked", "false");
|
||||
});
|
||||
|
||||
it("navigates to the detail page for segmented effort, Reset, Pin, and cost badge", () => {
|
||||
it("lists models by name in one page, with context size, cost and pinning", () => {
|
||||
const onChange = vi.fn();
|
||||
const cfg = copilotConfig().map((o) =>
|
||||
o.id === "model"
|
||||
? {
|
||||
...o,
|
||||
values: o.values.map((v) =>
|
||||
v.value === "claude-sonnet-5.5" ? { ...v, costCategory: "medium", usageMultiplier: "1x" } : v,
|
||||
v.value === "claude-sonnet-5.5" ? { ...v, costCategory: "medium", description: "Balanced" } : v,
|
||||
),
|
||||
}
|
||||
: o.id === "reasoning_effort"
|
||||
? { ...o, defaultValue: "medium" }
|
||||
: o,
|
||||
: o,
|
||||
);
|
||||
cfg.push({
|
||||
id: "contextTier",
|
||||
@@ -325,106 +327,37 @@ describe("model and effort button", () => {
|
||||
via: "option",
|
||||
values: [value("default", "200K"), value("long_context", "1M")],
|
||||
});
|
||||
render(<ConfigPickers config={cfg} values={{ reasoning_effort: "high" }} onChange={onChange} />);
|
||||
expect(screen.getByRole("button", { name: "Model" })).toHaveTextContent("Claude Sonnet 5.5high · 1M");
|
||||
render(<ConfigPickers config={cfg} onChange={onChange} />);
|
||||
expect(screen.getByRole("button", { name: "Model" })).toHaveTextContent("Claude Sonnet 5.51M");
|
||||
|
||||
fireEvent.click(screen.getByRole("button", { name: "Model" }));
|
||||
const dialog = screen.getByRole("dialog", { name: "Model & effort settings" });
|
||||
const dialog = screen.getByRole("dialog", { name: "Model" });
|
||||
expect(within(dialog).queryByText("Balanced")).not.toBeInTheDocument();
|
||||
expect(within(dialog).getByText("Medium cost")).toBeVisible();
|
||||
|
||||
// Pick another model directly from Page 1.
|
||||
fireEvent.click(within(dialog).getByRole("option", { name: /GPT-6 Sol/ }));
|
||||
expect(onChange).toHaveBeenCalledWith("model", "gpt-6-sol");
|
||||
|
||||
// Open Page 2 (detail configuration view) for the active model.
|
||||
fireEvent.click(within(dialog).getByRole("button", { name: "Configure model" }));
|
||||
const effortGroup = within(dialog).getByRole("radiogroup", { name: "Reasoning Effort" });
|
||||
expect(within(effortGroup).getByRole("radio", { name: "high" })).toHaveAttribute("aria-checked", "true");
|
||||
fireEvent.click(within(effortGroup).getByRole("radio", { name: "XHigh" }));
|
||||
expect(onChange).toHaveBeenCalledWith("reasoning_effort", "xhigh");
|
||||
|
||||
const contextGroup = within(dialog).getByRole("radiogroup", { name: "Context Size" });
|
||||
expect(within(contextGroup).getByRole("radio", { name: "1M" })).toHaveAttribute("aria-checked", "true");
|
||||
fireEvent.click(within(contextGroup).getByRole("radio", { name: "200K" }));
|
||||
expect(onChange).toHaveBeenCalledWith("contextTier", "default");
|
||||
|
||||
// Cost badge & multiplier render in the detail card.
|
||||
expect(within(dialog).getByText("Medium cost")).toBeVisible();
|
||||
expect(within(dialog).getByText("1x")).toBeVisible();
|
||||
|
||||
// Reset restores both effort and contextTier to their agent defaults.
|
||||
onChange.mockClear();
|
||||
fireEvent.click(within(dialog).getByRole("button", { name: "Reset to defaults" }));
|
||||
expect(onChange).toHaveBeenCalledWith("reasoning_effort", "medium");
|
||||
expect(onChange).toHaveBeenCalledWith("contextTier", "default");
|
||||
|
||||
// Pin model, navigate back to Page 1, and verify Pinned + Models sections appear.
|
||||
fireEvent.click(within(dialog).getByRole("button", { name: "Pin model" }));
|
||||
fireEvent.click(within(dialog).getByRole("button", { name: "Back to models" }));
|
||||
fireEvent.click(within(dialog).getAllByRole("button", { name: "Pin model" })[0]!);
|
||||
const listbox = within(dialog).getByRole("listbox", { name: "Model" });
|
||||
expect(within(listbox).getByText("Pinned")).toBeVisible();
|
||||
expect(within(listbox).getByText("Models")).toBeVisible();
|
||||
});
|
||||
|
||||
it("updates per-tier token pricing live when switching Context Size", () => {
|
||||
const cfg = copilotConfig().map((o) =>
|
||||
o.id === "model"
|
||||
? {
|
||||
...o,
|
||||
values: o.values.map((v) =>
|
||||
v.value === "claude-sonnet-5.5"
|
||||
? {
|
||||
...v,
|
||||
pricing: {
|
||||
costTier: "medium",
|
||||
multiplier: 1,
|
||||
tiers: {
|
||||
default: { input: 200, output: 1000, cacheRead: 10, cacheWrite: 0, contextTokens: 200_000 },
|
||||
long_context: {
|
||||
input: 400,
|
||||
output: 2000,
|
||||
cacheRead: 20,
|
||||
cacheWrite: 0,
|
||||
contextTokens: 1_000_000,
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
: v,
|
||||
),
|
||||
}
|
||||
: o,
|
||||
);
|
||||
cfg.push({
|
||||
id: "context_tier",
|
||||
name: "Context Size",
|
||||
category: "model_config",
|
||||
description: null,
|
||||
current: "long_context",
|
||||
via: "option",
|
||||
values: [value("default", "200K"), value("long_context", "1M")],
|
||||
});
|
||||
const { rerender } = render(<ConfigPickers config={cfg} onChange={vi.fn()} />);
|
||||
fireEvent.click(screen.getByRole("button", { name: "Model" }));
|
||||
fireEvent.click(screen.getByRole("button", { name: "Configure model" }));
|
||||
expect(screen.getByText("Credits per 1M tokens")).toBeVisible();
|
||||
expect(screen.getByText("400")).toBeVisible();
|
||||
expect(screen.getByText("2000")).toBeVisible();
|
||||
|
||||
rerender(<ConfigPickers config={cfg} values={{ context_tier: "default" }} onChange={vi.fn()} />);
|
||||
expect(screen.getByText("200")).toBeVisible();
|
||||
expect(screen.getByText("1000")).toBeVisible();
|
||||
fireEvent.click(within(dialog).getByRole("option", { name: /GPT-6 Sol/ }));
|
||||
expect(onChange).toHaveBeenCalledWith("model", "gpt-6-sol");
|
||||
expect(screen.queryByRole("dialog", { name: "Model" })).not.toBeInTheDocument();
|
||||
});
|
||||
|
||||
it("filters the model list and picks the highlighted model with the keyboard", () => {
|
||||
const onChange = vi.fn();
|
||||
render(<ConfigPickers config={copilotConfig()} onChange={onChange} />);
|
||||
fireEvent.click(screen.getByRole("button", { name: "Model" }));
|
||||
const dialog = screen.getByRole("dialog", { name: "Model & effort settings" });
|
||||
const search = within(dialog).getByPlaceholderText("Search…");
|
||||
const search = screen.getByPlaceholderText("Search…");
|
||||
expect(search).toHaveFocus();
|
||||
fireEvent.change(search, { target: { value: "sol" } });
|
||||
expect(within(dialog).getAllByRole("option")).toHaveLength(1);
|
||||
expect(screen.getAllByRole("option")).toHaveLength(1);
|
||||
fireEvent.keyDown(search, { key: "ArrowDown" });
|
||||
fireEvent.keyDown(search, { key: "Enter" });
|
||||
expect(onChange).toHaveBeenLastCalledWith("model", "gpt-6-sol");
|
||||
|
||||
@@ -1,21 +1,24 @@
|
||||
/**
|
||||
* Model, mode, approvals and thinking-effort controls for a composer's bottom row.
|
||||
* With a model plus effort, model-config or cost metadata, one button shows the active
|
||||
* summary and opens a two-page popup: a searchable model list (with pinned models and
|
||||
* per-row configure buttons) and a per-model configuration view with segmented Effort
|
||||
* Level, optional segmented Context Size, Reset / Pin actions, and a cost badge.
|
||||
* Model, effort, mode and approvals controls for a composer's bottom row. The model button
|
||||
* opens a searchable model list (pinned models first, context size above it); the effort is
|
||||
* its own picker beside it, one click away.
|
||||
*/
|
||||
import { useEffect, useRef, useState, type KeyboardEvent } from "react";
|
||||
import clsx from "clsx";
|
||||
import type { AgentConfigOption, AgentModelPricing } from "@/bindings";
|
||||
import { tx as rawTx, useTx } from "@/platform/i18n";
|
||||
import type { AgentConfigOption } from "@/bindings";
|
||||
import { useTx } from "@/platform/i18n";
|
||||
import { Icon, IconButton, Popup, Select, T, Toggle } from "@/ui";
|
||||
import { SelectListbox, type SelectOption } from "@/ui/Select";
|
||||
import { formatCreditRate, isContextOption, mainOptions, modelConfigOptions, modeIcon } from "./composerModel";
|
||||
import { isContextOption, mainOptions, modelConfigOptions, modeIcon } from "./composerModel";
|
||||
import { togglePinnedModel, useAgents } from "./store";
|
||||
import styles from "./Composer.module.css";
|
||||
|
||||
export function configPickerOptions(option: AgentConfigOption, pinned: readonly string[] = []): SelectOption[] {
|
||||
export function configPickerOptions(
|
||||
option: AgentConfigOption,
|
||||
pinned: readonly string[] = [],
|
||||
/** Without each model's description: the model popup lists names only. */
|
||||
descriptions = true,
|
||||
): SelectOption[] {
|
||||
if (option.category !== "model") {
|
||||
return option.values.map((v) => ({ value: v.value, label: v.name, detail: v.description ?? undefined }));
|
||||
}
|
||||
@@ -26,7 +29,9 @@ export function configPickerOptions(option: AgentConfigOption, pinned: readonly
|
||||
const path = slash >= 0 ? v.value.slice(slash + 1) : "";
|
||||
const label = path ? path.slice(path.lastIndexOf("/") + 1) : v.name || v.value;
|
||||
const mult = v.usageMultiplier && !v.description?.startsWith(v.usageMultiplier) ? v.usageMultiplier : undefined;
|
||||
const parts = [path || undefined, mult, v.description ?? undefined].filter((p): p is string => !!p);
|
||||
const parts = [path || undefined, mult, (descriptions && v.description) || undefined].filter(
|
||||
(p): p is string => !!p,
|
||||
);
|
||||
const detail = parts.length > 0 ? parts.join(" · ") : undefined;
|
||||
return { provider, opt: { value: v.value, label, detail, keywords: provider } };
|
||||
};
|
||||
@@ -104,14 +109,16 @@ export function ConfigPickers({
|
||||
const effort = config.find((o) => o.category === "thought_level" && o.values.length > 0);
|
||||
const modelConfigs = modelConfigOptions(config);
|
||||
const hasCostMeta = model?.values.some((v) => !!v.costCategory || !!v.usageMultiplier || !!v.pricing) ?? false;
|
||||
const combinedModel = model && (modelRefresh || effort || modelConfigs.length > 0 || hasCostMeta);
|
||||
const combinedModel = model && (modelRefresh || modelConfigs.length > 0 || hasCostMeta);
|
||||
const tuckedModelConfig = new Set(modelConfigs.map((o) => o.id));
|
||||
const mode = options.find((o) => o.category === "mode");
|
||||
const allowAll = mode && options.find((o) => switchValues(o));
|
||||
// Effort sits right after the model, as its own one-click picker.
|
||||
const inline = options.filter(
|
||||
(o) => o !== effort && o !== allowAll && !(combinedModel && tuckedModelConfig.has(o.id)),
|
||||
);
|
||||
// The compact menu holds everything but the model button (effort + model parameters).
|
||||
if (effort) inline.splice(model ? inline.indexOf(model) + 1 : 0, 0, effort);
|
||||
// The compact menu holds everything but the model and effort buttons (and the model's own parameters).
|
||||
const secondary = options.filter(
|
||||
(o) => o.category !== "model" && o !== effort && !(combinedModel && tuckedModelConfig.has(o.id)),
|
||||
);
|
||||
@@ -120,13 +127,14 @@ export function ConfigPickers({
|
||||
return (
|
||||
<>
|
||||
{inline.map((o) => (
|
||||
<span key={o.id} className={clsx(styles.configPicker, o.category !== "model" && styles.inlineSetting)}>
|
||||
<span
|
||||
key={o.id}
|
||||
className={clsx(styles.configPicker, o.category !== "model" && o !== effort && styles.inlineSetting)}
|
||||
>
|
||||
{o === model && combinedModel ? (
|
||||
<ModelEffortPicker
|
||||
<ModelPicker
|
||||
model={o}
|
||||
modelValue={valueOf(o)}
|
||||
effort={effort}
|
||||
effortValue={effort ? valueOf(effort) : null}
|
||||
modelConfigs={modelConfigs}
|
||||
valueOf={valueOf}
|
||||
onChange={onChange}
|
||||
@@ -224,24 +232,17 @@ function ConfigPicker({
|
||||
onChange={(v) => onChange(option.id, v)}
|
||||
renderValue={
|
||||
option.category === "thought_level" && !framed
|
||||
? (current) => (
|
||||
<span className={styles.pickerValue}>
|
||||
<span className={styles.pickerName}>{option.name}</span>
|
||||
{current?.label ?? tx("Default")}
|
||||
</span>
|
||||
)
|
||||
? (current) => <span className={styles.pickerValue}>{current?.label ?? tx("Default")}</span>
|
||||
: undefined
|
||||
}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
/** Two-page model & per-model configuration picker (searchable list + detail page). */
|
||||
function ModelEffortPicker({
|
||||
/** The model button: a searchable model list, with context size and the model's own settings above it. */
|
||||
function ModelPicker({
|
||||
model,
|
||||
modelValue,
|
||||
effort,
|
||||
effortValue,
|
||||
modelConfigs,
|
||||
valueOf,
|
||||
onChange,
|
||||
@@ -249,8 +250,6 @@ function ModelEffortPicker({
|
||||
}: {
|
||||
model: AgentConfigOption;
|
||||
modelValue: string | null;
|
||||
effort?: AgentConfigOption;
|
||||
effortValue: string | null;
|
||||
modelConfigs: AgentConfigOption[];
|
||||
valueOf: (o: AgentConfigOption) => string | null;
|
||||
onChange: (option: string, value: string) => void;
|
||||
@@ -258,65 +257,26 @@ function ModelEffortPicker({
|
||||
}) {
|
||||
const tx = useTx();
|
||||
const [open, setOpen] = useState(false);
|
||||
const [page, setPage] = useState<"list" | "detail">("list");
|
||||
const pinnedModels = useAgents((s) => s.pinnedModels);
|
||||
const anchor = useRef<HTMLButtonElement>(null);
|
||||
const selectedModel = selected(model, modelValue);
|
||||
const unavailable = modelRefresh && modelValue !== null && !selectedModel;
|
||||
const modelName = unavailable ? tx`${modelValue} (unavailable)` : (selectedModel?.name ?? tx("Default"));
|
||||
const effortName = effort ? (selected(effort, effortValue)?.name ?? tx("Default")) : null;
|
||||
|
||||
const contextOption = modelConfigs.find((o) => isContextOption(o.id) && o.values.length > 0);
|
||||
const contextValue = contextOption ? valueOf(contextOption) : null;
|
||||
const contextLabel = contextOption ? (selected(contextOption, contextValue)?.name ?? null) : null;
|
||||
const otherModelConfigs = modelConfigs.filter((o) => o !== contextOption);
|
||||
|
||||
const chipBadges = [effortName, contextLabel].filter((x): x is string => !!x);
|
||||
const chipBadgeText = chipBadges.join(" · ");
|
||||
|
||||
const otherSummary = otherModelConfigs
|
||||
.map((o) => {
|
||||
const summary = [
|
||||
contextLabel ? `${tx("Context Size")}: ${contextLabel}` : null,
|
||||
...otherModelConfigs.map((o) => {
|
||||
const current = selected(o, valueOf(o));
|
||||
return current ? `${tx(o.name)}: ${current.name}` : null;
|
||||
})
|
||||
.filter(Boolean)
|
||||
.join(" · ");
|
||||
const summary = [
|
||||
effortName ? `${tx(effort!.name)}: ${effortName}` : null,
|
||||
contextLabel ? `${tx("Context Size")}: ${contextLabel}` : null,
|
||||
otherSummary,
|
||||
}),
|
||||
]
|
||||
.filter(Boolean)
|
||||
.join(" · ");
|
||||
|
||||
const canConfigureActive = !!(
|
||||
effort ||
|
||||
contextOption ||
|
||||
otherModelConfigs.length > 0 ||
|
||||
selectedModel?.costCategory ||
|
||||
selectedModel?.usageMultiplier ||
|
||||
selectedModel?.pricing
|
||||
);
|
||||
|
||||
const closePopup = () => {
|
||||
setOpen(false);
|
||||
setPage("list");
|
||||
};
|
||||
|
||||
const openDetailFor = (targetModelValue: string) => {
|
||||
if (targetModelValue !== modelValue) {
|
||||
onChange(model.id, targetModelValue);
|
||||
}
|
||||
setPage("detail");
|
||||
};
|
||||
|
||||
const sizerCandidates =
|
||||
effort && !contextLabel
|
||||
? [...new Set([chipBadgeText, ...effort.values.map((v) => v.name)])]
|
||||
: chipBadgeText
|
||||
? [chipBadgeText]
|
||||
: [];
|
||||
|
||||
return (
|
||||
<>
|
||||
<button
|
||||
@@ -327,115 +287,91 @@ function ModelEffortPicker({
|
||||
aria-haspopup="dialog"
|
||||
aria-expanded={open}
|
||||
title={`${tx(model.name)}: ${modelName}${summary ? ` · ${summary}` : ""}`}
|
||||
onClick={() => {
|
||||
setOpen((prev) => {
|
||||
if (prev) setPage("list");
|
||||
return !prev;
|
||||
});
|
||||
}}
|
||||
onClick={() => setOpen((v) => !v)}
|
||||
>
|
||||
<span className={styles.chipValue}>{modelName}</span>
|
||||
{chipBadgeText && (
|
||||
<span className={styles.chipDetail}>
|
||||
{sizerCandidates.map((text) => (
|
||||
<span
|
||||
key={text}
|
||||
className={text === chipBadgeText ? undefined : styles.chipSizer}
|
||||
aria-hidden={text !== chipBadgeText}
|
||||
>
|
||||
{text}
|
||||
</span>
|
||||
))}
|
||||
</span>
|
||||
)}
|
||||
{contextLabel && <span className={styles.chipDetail}>{contextLabel}</span>}
|
||||
<Icon name="chevron-down" size={14} className={styles.chipChevron} />
|
||||
</button>
|
||||
<Popup
|
||||
open={open}
|
||||
anchor={anchor}
|
||||
onClose={closePopup}
|
||||
aria-label={tx("Model & effort settings")}
|
||||
onClose={() => setOpen(false)}
|
||||
aria-label={tx("Model")}
|
||||
className={styles.modelEffortPopup}
|
||||
>
|
||||
{page === "detail" && selectedModel ? (
|
||||
<ModelDetailView
|
||||
modelEntry={selectedModel}
|
||||
effort={effort}
|
||||
effortValue={effortValue}
|
||||
contextOption={contextOption}
|
||||
contextValue={contextValue}
|
||||
otherModelConfigs={otherModelConfigs}
|
||||
valueOf={valueOf}
|
||||
pinned={pinnedModels.includes(selectedModel.value)}
|
||||
onBack={() => setPage("list")}
|
||||
onTogglePin={() => togglePinnedModel(selectedModel.value)}
|
||||
onChange={onChange}
|
||||
/>
|
||||
) : (
|
||||
<>
|
||||
{unavailable && (
|
||||
<p className={styles.catalogError} role="alert">
|
||||
<T>Choose another model before starting.</T>
|
||||
</p>
|
||||
)}
|
||||
{canConfigureActive && selectedModel && (
|
||||
<button
|
||||
type="button"
|
||||
className={styles.activeModelBar}
|
||||
aria-label={tx("Configure model")}
|
||||
onClick={() => setPage("detail")}
|
||||
>
|
||||
<span className={styles.activeModelName}>{modelName}</span>
|
||||
<CostBadge category={selectedModel.costCategory} />
|
||||
{chipBadgeText && <span className={styles.activeModelMeta}>{chipBadgeText}</span>}
|
||||
<span className={styles.activeModelGear}>
|
||||
<Icon name="sliders" size={13} />
|
||||
<Icon name="chevron-right" size={12} />
|
||||
{unavailable && (
|
||||
<p className={styles.catalogError} role="alert">
|
||||
<T>Choose another model before starting.</T>
|
||||
</p>
|
||||
)}
|
||||
{(contextOption || otherModelConfigs.length > 0) && (
|
||||
<div className={styles.quickSettings}>
|
||||
{contextOption && (
|
||||
<div className={styles.quickRow}>
|
||||
<span className={styles.quickLabel}>
|
||||
<T>Context Size</T>
|
||||
</span>
|
||||
</button>
|
||||
<SegmentedControl
|
||||
ariaLabel={tx("Context Size")}
|
||||
options={contextOption.values.map((v) => ({
|
||||
value: v.value,
|
||||
label: v.name,
|
||||
description: v.description ?? undefined,
|
||||
}))}
|
||||
value={contextValue ?? contextOption.values[0]!.value}
|
||||
onChange={(v) => onChange(contextOption.id, v)}
|
||||
/>
|
||||
</div>
|
||||
)}
|
||||
{otherModelConfigs.map((o) => (
|
||||
<div key={o.id} className={styles.modeFooter}>
|
||||
<span title={o.description ?? undefined}>{tx(o.name)}</span>
|
||||
<div key={o.id} className={styles.quickRow}>
|
||||
<span className={styles.quickLabel} title={o.description ?? undefined}>
|
||||
{tx(o.name)}
|
||||
</span>
|
||||
<ConfigPicker option={o} value={valueOf(o)} onChange={onChange} framed />
|
||||
</div>
|
||||
))}
|
||||
{model.values.length > 0 || !modelRefresh ? (
|
||||
<SelectListbox
|
||||
aria-label={tx(model.name)}
|
||||
value={modelValue}
|
||||
options={configPickerOptions(model, pinnedModels)}
|
||||
searchable
|
||||
listClassName={styles.modelList}
|
||||
onChoose={(v) => onChange(model.id, v)}
|
||||
renderAction={(opt) => {
|
||||
const raw = model.values.find((v) => v.value === opt.value);
|
||||
if (!raw) return null;
|
||||
const showRowBadge = !!raw.costCategory && !raw.description;
|
||||
return (
|
||||
<>
|
||||
{showRowBadge && <CostBadge category={raw.costCategory} />}
|
||||
<button
|
||||
type="button"
|
||||
className={styles.modelRowConfigure}
|
||||
aria-label={rawTx`Configure ${opt.label}`}
|
||||
title={rawTx`Configure ${opt.label}`}
|
||||
onClick={() => openDetailFor(opt.value)}
|
||||
>
|
||||
<Icon name="sliders" size={12} />
|
||||
</button>
|
||||
</>
|
||||
);
|
||||
}}
|
||||
/>
|
||||
) : (
|
||||
<p className={styles.catalogNote} role="status">
|
||||
{modelRefresh?.refreshing ? <T>Loading models…</T> : <T>No models reported by this agent.</T>}
|
||||
</p>
|
||||
)}
|
||||
{modelRefresh && <ModelRefreshFooter key={modelRefresh.retryAtMs} {...modelRefresh} />}
|
||||
</>
|
||||
</div>
|
||||
)}
|
||||
{model.values.length > 0 || !modelRefresh ? (
|
||||
<SelectListbox
|
||||
aria-label={tx(model.name)}
|
||||
value={modelValue}
|
||||
options={configPickerOptions(model, pinnedModels, false)}
|
||||
searchable
|
||||
listClassName={styles.modelList}
|
||||
onChoose={(v) => {
|
||||
onChange(model.id, v);
|
||||
setOpen(false);
|
||||
}}
|
||||
renderAction={(opt) => {
|
||||
const raw = model.values.find((v) => v.value === opt.value);
|
||||
if (!raw) return null;
|
||||
const pinned = pinnedModels.includes(raw.value);
|
||||
return (
|
||||
<>
|
||||
<CostBadge category={raw.costCategory} />
|
||||
<button
|
||||
type="button"
|
||||
className={clsx(styles.modelRowConfigure, pinned && styles.pinnedButton)}
|
||||
aria-label={pinned ? tx("Unpin model") : tx("Pin model")}
|
||||
aria-pressed={pinned}
|
||||
title={pinned ? tx("Unpin model") : tx("Pin model")}
|
||||
onClick={() => togglePinnedModel(raw.value)}
|
||||
>
|
||||
<Icon name="pin" size={12} />
|
||||
</button>
|
||||
</>
|
||||
);
|
||||
}}
|
||||
/>
|
||||
) : (
|
||||
<p className={styles.catalogNote} role="status">
|
||||
{modelRefresh?.refreshing ? <T>Loading models…</T> : <T>No models reported by this agent.</T>}
|
||||
</p>
|
||||
)}
|
||||
{modelRefresh && <ModelRefreshFooter key={modelRefresh.retryAtMs} {...modelRefresh} />}
|
||||
</Popup>
|
||||
</>
|
||||
);
|
||||
@@ -493,258 +429,6 @@ function CostBadge({ category }: { category: string | null | undefined }) {
|
||||
);
|
||||
}
|
||||
|
||||
/** Page 2: per-model configuration view (segmented Effort, optional Context Size, Reset, Pin, and cost info). */
|
||||
function ModelDetailView({
|
||||
modelEntry,
|
||||
effort,
|
||||
effortValue,
|
||||
contextOption,
|
||||
contextValue,
|
||||
otherModelConfigs,
|
||||
valueOf,
|
||||
pinned,
|
||||
onBack,
|
||||
onTogglePin,
|
||||
onChange,
|
||||
}: {
|
||||
modelEntry: AgentConfigOption["values"][number];
|
||||
effort?: AgentConfigOption;
|
||||
effortValue: string | null;
|
||||
contextOption?: AgentConfigOption;
|
||||
contextValue: string | null;
|
||||
otherModelConfigs: AgentConfigOption[];
|
||||
valueOf: (o: AgentConfigOption) => string | null;
|
||||
pinned: boolean;
|
||||
onBack: () => void;
|
||||
onTogglePin: () => void;
|
||||
onChange: (option: string, value: string) => void;
|
||||
}) {
|
||||
const tx = useTx();
|
||||
const [pricingOpen, setPricingOpen] = useState(true);
|
||||
|
||||
const defaultEffort = effort ? (effort.defaultValue ?? effort.current) : null;
|
||||
const defaultContext = contextOption ? (contextOption.defaultValue ?? contextOption.current) : null;
|
||||
const effortAtDefault = !effort || !defaultEffort || effortValue === defaultEffort;
|
||||
const contextAtDefault = !contextOption || !defaultContext || contextValue === defaultContext;
|
||||
const othersAtDefault = otherModelConfigs.every((o) => {
|
||||
const def = o.defaultValue ?? o.current;
|
||||
return !def || valueOf(o) === def;
|
||||
});
|
||||
const atDefaults = effortAtDefault && contextAtDefault && othersAtDefault;
|
||||
|
||||
const handleReset = () => {
|
||||
if (effort && defaultEffort && effortValue !== defaultEffort) {
|
||||
onChange(effort.id, defaultEffort);
|
||||
}
|
||||
if (contextOption && defaultContext && contextValue !== defaultContext) {
|
||||
onChange(contextOption.id, defaultContext);
|
||||
}
|
||||
for (const o of otherModelConfigs) {
|
||||
const def = o.defaultValue ?? o.current;
|
||||
if (def && valueOf(o) !== def) {
|
||||
onChange(o.id, def);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
const compactEffort = (effort?.values.length ?? 0) >= 5;
|
||||
const hasCostCard = !!(modelEntry.costCategory || modelEntry.usageMultiplier);
|
||||
|
||||
return (
|
||||
<div className={styles.modelDetail}>
|
||||
<div className={styles.modelDetailHeader}>
|
||||
<IconButton
|
||||
icon="arrow-left"
|
||||
size="small"
|
||||
aria-label={tx("Back to models")}
|
||||
title={tx("Back to models")}
|
||||
onClick={onBack}
|
||||
/>
|
||||
<span className={styles.modelDetailTitle} title={modelEntry.name}>
|
||||
{modelEntry.name}
|
||||
</span>
|
||||
<div className={styles.modelDetailActions}>
|
||||
<IconButton
|
||||
icon="undo"
|
||||
size="small"
|
||||
disabled={atDefaults}
|
||||
aria-label={tx("Reset to defaults")}
|
||||
title={tx("Reset to defaults")}
|
||||
onClick={handleReset}
|
||||
/>
|
||||
<IconButton
|
||||
icon="pin"
|
||||
size="small"
|
||||
aria-label={pinned ? tx("Unpin model") : tx("Pin model")}
|
||||
title={pinned ? tx("Unpin model") : tx("Pin model")}
|
||||
aria-pressed={pinned}
|
||||
className={clsx(pinned && styles.pinnedButton)}
|
||||
onClick={onTogglePin}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{effort && effort.values.length > 0 && (
|
||||
<div className={styles.detailSection}>
|
||||
<div className={styles.detailSectionLabel}>
|
||||
<T>Effort Level</T>
|
||||
</div>
|
||||
<SegmentedControl
|
||||
ariaLabel={tx(effort.name)}
|
||||
options={effort.values.map((v) => ({
|
||||
value: v.value,
|
||||
label: compactEffort && v.value === "xhigh" ? tx("XHigh") : v.name,
|
||||
description: v.description ?? undefined,
|
||||
}))}
|
||||
value={effortValue ?? effort.values[0]!.value}
|
||||
onChange={(v) => onChange(effort.id, v)}
|
||||
/>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{contextOption && contextOption.values.length > 0 && (
|
||||
<div className={styles.detailSection}>
|
||||
<div className={styles.detailSectionLabel}>
|
||||
<T>Context Size</T>
|
||||
</div>
|
||||
<SegmentedControl
|
||||
ariaLabel={tx("Context Size")}
|
||||
options={contextOption.values.map((v) => ({
|
||||
value: v.value,
|
||||
label: v.name,
|
||||
description: v.description ?? undefined,
|
||||
}))}
|
||||
value={contextValue ?? contextOption.values[0]!.value}
|
||||
onChange={(v) => onChange(contextOption.id, v)}
|
||||
/>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{otherModelConfigs.map((o) => (
|
||||
<div key={o.id} className={styles.detailRow}>
|
||||
<span className={styles.detailSectionLabel} title={o.description ?? undefined}>
|
||||
{tx(o.name)}
|
||||
</span>
|
||||
<ConfigPicker option={o} value={valueOf(o)} onChange={onChange} framed />
|
||||
</div>
|
||||
))}
|
||||
|
||||
{modelEntry.pricing ? (
|
||||
<PricingDetailsCard
|
||||
pricing={modelEntry.pricing}
|
||||
activeTier={contextValue}
|
||||
open={pricingOpen}
|
||||
onToggle={() => setPricingOpen((v) => !v)}
|
||||
/>
|
||||
) : (
|
||||
hasCostCard && (
|
||||
<div className={styles.costCard}>
|
||||
<div className={styles.costCardHeader}>
|
||||
<span className={styles.costCardTitle}>
|
||||
<T>Pricing details</T>
|
||||
</span>
|
||||
<CostBadge category={modelEntry.costCategory} />
|
||||
</div>
|
||||
{modelEntry.usageMultiplier && (
|
||||
<div className={styles.costCardRow}>
|
||||
<span>
|
||||
<T>Multiplier</T>
|
||||
</span>
|
||||
<span className={styles.costCardValue}>{modelEntry.usageMultiplier}</span>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
)
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
/** Collapsible per-tier token pricing breakdown card (`Credits per 1M tokens`). */
|
||||
function PricingDetailsCard({
|
||||
pricing,
|
||||
activeTier,
|
||||
open,
|
||||
onToggle,
|
||||
}: {
|
||||
pricing: AgentModelPricing;
|
||||
activeTier: string | null;
|
||||
open: boolean;
|
||||
onToggle: () => void;
|
||||
}) {
|
||||
const tiers = pricing.tiers ?? {};
|
||||
const tierData =
|
||||
(activeTier ? tiers[activeTier] : undefined) ?? tiers["default"] ?? tiers["long_context"] ?? undefined;
|
||||
const hasRates = tierData && (tierData.input != null || tierData.output != null);
|
||||
if (!hasRates && pricing.multiplier == null && !pricing.costTier) return null;
|
||||
|
||||
return (
|
||||
<div className={styles.pricingCard}>
|
||||
<button type="button" className={styles.pricingHeader} aria-expanded={open} onClick={onToggle}>
|
||||
<Icon name={open ? "chevron-down" : "chevron-right"} size={12} className={styles.pricingChevron} />
|
||||
<span className={styles.pricingTitle}>
|
||||
<T>Pricing details</T>
|
||||
</span>
|
||||
{pricing.costTier ? (
|
||||
<CostBadge category={pricing.costTier} />
|
||||
) : (
|
||||
pricing.multiplier != null && (
|
||||
<span className={styles.costBadge}>{`${formatCreditRate(pricing.multiplier)}x`}</span>
|
||||
)
|
||||
)}
|
||||
</button>
|
||||
{open && (
|
||||
<div className={styles.pricingBody}>
|
||||
{hasRates && tierData ? (
|
||||
<>
|
||||
<div className={styles.pricingSubhead}>
|
||||
<T>Credits per 1M tokens</T>
|
||||
</div>
|
||||
<div className={styles.costCardRow}>
|
||||
<span>
|
||||
<T>Input</T>
|
||||
</span>
|
||||
<span className={styles.costCardValue}>{formatCreditRate(tierData.input)}</span>
|
||||
</div>
|
||||
<div className={styles.costCardRow}>
|
||||
<span>
|
||||
<T>Output</T>
|
||||
</span>
|
||||
<span className={styles.costCardValue}>{formatCreditRate(tierData.output)}</span>
|
||||
</div>
|
||||
{tierData.cacheRead != null && (
|
||||
<div className={styles.costCardRow}>
|
||||
<span>
|
||||
<T>Cache Read</T>
|
||||
</span>
|
||||
<span className={styles.costCardValue}>{formatCreditRate(tierData.cacheRead)}</span>
|
||||
</div>
|
||||
)}
|
||||
{tierData.cacheWrite != null && (
|
||||
<div className={styles.costCardRow}>
|
||||
<span>
|
||||
<T>Cache Write</T>
|
||||
</span>
|
||||
<span className={styles.costCardValue}>{formatCreditRate(tierData.cacheWrite)}</span>
|
||||
</div>
|
||||
)}
|
||||
</>
|
||||
) : (
|
||||
pricing.multiplier != null && (
|
||||
<div className={styles.costCardRow}>
|
||||
<span>
|
||||
<T>Multiplier</T>
|
||||
</span>
|
||||
<span className={styles.costCardValue}>{`${formatCreditRate(pricing.multiplier)}x`}</span>
|
||||
</div>
|
||||
)
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
/** Accessible segmented pill selector (`role="radiogroup"`) with Left/Right arrow navigation. */
|
||||
function SegmentedControl({
|
||||
ariaLabel,
|
||||
|
||||
@@ -14,8 +14,8 @@
|
||||
color: var(--fg);
|
||||
}
|
||||
.inner {
|
||||
/* The same width as a running session's composer and conversation. */
|
||||
width: min(var(--agent-conversation-width), 100%);
|
||||
/* A compact block in the middle of the page: narrower than a session's conversation. */
|
||||
width: min(680px, 100%);
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: var(--space-2);
|
||||
@@ -24,31 +24,58 @@
|
||||
width: 100%;
|
||||
}
|
||||
.heading {
|
||||
margin: 0 0 10px;
|
||||
font-size: calc(18px + var(--agent-font-zoom, 0px));
|
||||
font-weight: 600;
|
||||
margin: 0 0 14px;
|
||||
font-size: calc(22px + var(--agent-font-zoom, 0px));
|
||||
font-weight: 500;
|
||||
letter-spacing: -0.01em;
|
||||
text-align: center;
|
||||
color: var(--fg-strong);
|
||||
text-wrap: balance;
|
||||
}
|
||||
|
||||
/* Under the box: the project and where the agent works. */
|
||||
/* A box to write in, not a search bar: room for a few lines before it grows. */
|
||||
.composer :global(.cm-content) {
|
||||
min-height: calc(4.5em + 12px);
|
||||
}
|
||||
|
||||
/* Under the box: one quiet group, the project, checkout and branch side by side. */
|
||||
.where {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
align-items: center;
|
||||
/* The chips' own padding spaces them. */
|
||||
gap: var(--space-0-5);
|
||||
padding: 0 2px;
|
||||
gap: var(--space-1);
|
||||
min-width: 0;
|
||||
padding: 0 6px;
|
||||
color: var(--fg-subtle);
|
||||
font-size: var(--fs-small);
|
||||
}
|
||||
/* The current branch, read-only: same height and colour as the pickers beside it. */
|
||||
.branch {
|
||||
.where > button {
|
||||
flex: 0 1 auto;
|
||||
min-width: 0;
|
||||
color: inherit;
|
||||
font-size: inherit;
|
||||
}
|
||||
/* The row's own gaps space "on" and "from"; the note's padding is for the lines below. */
|
||||
.where .note {
|
||||
padding: 0;
|
||||
.project {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: var(--space-1-5);
|
||||
min-width: 0;
|
||||
height: var(--h-control);
|
||||
padding: 0 4px;
|
||||
}
|
||||
.label {
|
||||
min-width: 0;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
.projectPicker {
|
||||
max-width: 40%;
|
||||
}
|
||||
|
||||
/* The agent shows as its icon only. */
|
||||
.agentPicker {
|
||||
display: flex;
|
||||
flex: none;
|
||||
}
|
||||
|
||||
.note,
|
||||
@@ -68,31 +95,20 @@
|
||||
justify-content: flex-end;
|
||||
padding: 16px 12px 12px;
|
||||
}
|
||||
.docked .inner {
|
||||
gap: var(--space-2);
|
||||
.dockedIntro {
|
||||
flex: 1;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
width: 100%;
|
||||
min-height: 0;
|
||||
padding-bottom: 8vh;
|
||||
}
|
||||
.docked .where {
|
||||
flex-wrap: nowrap;
|
||||
min-width: 0;
|
||||
}
|
||||
.docked .projectPicker,
|
||||
.docked .projectChip {
|
||||
flex: 0 1 auto;
|
||||
min-width: 0;
|
||||
max-width: 30%;
|
||||
}
|
||||
.docked .branch,
|
||||
.docked .basePicker {
|
||||
order: 1;
|
||||
flex: 0 1 auto;
|
||||
min-width: 0;
|
||||
}
|
||||
.docked .isolation {
|
||||
order: 2;
|
||||
flex: 0 1 auto;
|
||||
min-width: 0;
|
||||
max-width: 45%;
|
||||
margin-left: auto;
|
||||
.docked .heading {
|
||||
margin: 0;
|
||||
font-size: calc(15px + var(--agent-font-zoom, 0px));
|
||||
font-weight: 500;
|
||||
color: var(--fg-muted);
|
||||
}
|
||||
|
||||
.notes {
|
||||
|
||||
@@ -77,6 +77,8 @@ beforeEach(() => {
|
||||
updateComposer(HOME, { text: "Check the project" });
|
||||
});
|
||||
|
||||
const effortButton = () => screen.getByRole("button", { name: "Reasoning" });
|
||||
|
||||
async function chooseModel(model: string) {
|
||||
fireEvent.click(screen.getByRole("button", { name: "Model" }));
|
||||
fireEvent.click(screen.getByRole("option", { name: model }));
|
||||
@@ -85,19 +87,16 @@ async function chooseModel(model: string) {
|
||||
|
||||
it("switches model-specific levels and restores each draft effort before starting", async () => {
|
||||
render(<HomeEditor />);
|
||||
expect(screen.getByRole("button", { name: "Model" })).toHaveTextContent("bighigh");
|
||||
expect(screen.getByRole("button", { name: "Model" })).toHaveTextContent("big");
|
||||
expect(effortButton()).toHaveTextContent("high");
|
||||
await chooseModel("small");
|
||||
fireEvent.click(screen.getByRole("button", { name: "Model" }));
|
||||
fireEvent.click(screen.getByRole("button", { name: "Configure model" }));
|
||||
const group = screen.getByRole("radiogroup", { name: "Reasoning" });
|
||||
expect(group).toBeVisible();
|
||||
expect(screen.getByRole("radio", { name: "minimal" })).toHaveAttribute("aria-checked", "true");
|
||||
fireEvent.click(screen.getByRole("radio", { name: "medium" }));
|
||||
fireEvent.keyDown(document, { key: "Escape" });
|
||||
expect(effortButton()).toHaveTextContent("minimal");
|
||||
fireEvent.click(effortButton());
|
||||
fireEvent.click(screen.getByRole("option", { name: "medium" }));
|
||||
await chooseModel("big");
|
||||
expect(screen.getByRole("button", { name: "Model" })).toHaveTextContent("bighigh");
|
||||
expect(effortButton()).toHaveTextContent("high");
|
||||
await chooseModel("small");
|
||||
expect(screen.getByRole("button", { name: "Model" })).toHaveTextContent("smallmedium");
|
||||
expect(effortButton()).toHaveTextContent("medium");
|
||||
fireEvent.click(screen.getByRole("button", { name: "Start" }));
|
||||
await waitFor(() => expect(backend.create).toHaveBeenCalled());
|
||||
expect(backend.create.mock.calls[0]![0].config).toEqual([
|
||||
@@ -125,9 +124,11 @@ it("uses GitHub Copilot's own defaults and preserves per-model context tier and
|
||||
};
|
||||
useAgents.setState({ providers: [copilot], draft: savedDraft({ provider: "copilot", config: {} }) });
|
||||
render(<HomeEditor />);
|
||||
expect(screen.getByRole("button", { name: "Model" })).toHaveTextContent("gemini-4-carbonmedium · default");
|
||||
expect(screen.getByRole("button", { name: "Model" })).toHaveTextContent("gemini-4-carbondefault");
|
||||
expect(effortButton()).toHaveTextContent("medium");
|
||||
await chooseModel("gpt-5.6-sol");
|
||||
expect(screen.getByRole("button", { name: "Model" })).toHaveTextContent("gpt-5.6-solmedium · default");
|
||||
expect(screen.getByRole("button", { name: "Model" })).toHaveTextContent("gpt-5.6-soldefault");
|
||||
expect(effortButton()).toHaveTextContent("medium");
|
||||
fireEvent.click(screen.getByRole("button", { name: "Start" }));
|
||||
await waitFor(() => expect(backend.create).toHaveBeenCalled());
|
||||
expect(backend.create.mock.calls[0]![0].config).toEqual([
|
||||
@@ -161,7 +162,7 @@ it("ignores old provider-wide effort choices and refreshes unsupported per-model
|
||||
draft: savedDraft({ provider: "fake", config: { effort: "low" }, thoughtLevels: { big: { effort: "removed" } } }),
|
||||
});
|
||||
render(<HomeEditor />);
|
||||
expect(screen.getByRole("button", { name: "Model" })).toHaveTextContent("bighigh");
|
||||
expect(effortButton()).toHaveTextContent("high");
|
||||
fireEvent.click(screen.getByRole("button", { name: "Start" }));
|
||||
await waitFor(() => expect(backend.create).toHaveBeenCalled());
|
||||
expect(backend.create.mock.calls[0]![0].config).toContainEqual({ id: "effort", value: "high" });
|
||||
@@ -208,10 +209,10 @@ it("refreshes the displayed agent version after a CLI upgrade when the window re
|
||||
return ok({ provider, name: "omp", version: cached, protocol: "ACP v1", error: null });
|
||||
});
|
||||
render(<HomeEditor />);
|
||||
await screen.findByText("omp · 18.20.0 · ACP v1");
|
||||
await waitFor(() => expect(agentTooltip()).toMatch(/ 18\.20\.0$/));
|
||||
installed = "18.20.2";
|
||||
fireEvent(window, new Event("focus"));
|
||||
await screen.findByText("omp · 18.20.2 · ACP v1");
|
||||
await waitFor(() => expect(agentTooltip()).toMatch(/ 18\.20\.2$/));
|
||||
});
|
||||
|
||||
it("does not reuse a previous page's cached agent version when opened again", async () => {
|
||||
@@ -219,5 +220,10 @@ it("does not reuse a previous page's cached agent version when opened again", as
|
||||
ok({ provider, name: "omp", version: refresh ? "18.20.2" : "18.20.0", protocol: "ACP v1", error: null }),
|
||||
);
|
||||
render(<HomeEditor />);
|
||||
await screen.findByText("omp · 18.20.2 · ACP v1");
|
||||
await waitFor(() => expect(agentTooltip()).toMatch(/ 18\.20\.2$/));
|
||||
});
|
||||
|
||||
/** The agent picker shows its icon; the name and version are in its tooltip. */
|
||||
function agentTooltip() {
|
||||
return screen.getByRole("button", { name: "Agent" }).parentElement?.getAttribute("data-tooltip");
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
/** New Task page: one prompt box with the agent and its settings; where it works under it. */
|
||||
/** New Task page: one prompt box with the agent and its settings; where it works in a quiet line under it. */
|
||||
import clsx from "clsx";
|
||||
import { useEffect, useRef, useState } from "react";
|
||||
import type { AgentProbe, Branch } from "@/bindings";
|
||||
@@ -6,7 +6,7 @@ import { executeAction } from "@/platform/actions";
|
||||
import { call, commands } from "@/platform/ipc";
|
||||
import { useTx, useTxTemplate } from "@/platform/i18n";
|
||||
import { basename, useProject } from "@/platform/project";
|
||||
import { Chip, Select, T, type SelectOption } from "@/ui";
|
||||
import { Icon, Select, T, tooltipAttrs, type SelectOption } from "@/ui";
|
||||
import { defaultTaskProject } from "./project";
|
||||
import { maybeEditorService, useEditorShown, type EditorInput } from "@/workbench/contributions";
|
||||
import { Composer } from "./Composer";
|
||||
@@ -60,6 +60,8 @@ export function HomeEditor({ docked = false, input }: { docked?: boolean; input?
|
||||
const [error, setError] = useState<string | null>(null);
|
||||
const [starting, setStarting] = useState(false);
|
||||
const [mcpOpenRequest, setMcpOpenRequest] = useState(0);
|
||||
// Kept mounted while another tab shows: what changed meanwhile is read again when it shows.
|
||||
const shown = useEditorShown();
|
||||
|
||||
// Agents installed in Settings (its own window) show up when this one is back in front.
|
||||
useEffect(() => {
|
||||
@@ -70,6 +72,7 @@ export function HomeEditor({ docked = false, input }: { docked?: boolean; input?
|
||||
}, []);
|
||||
|
||||
useEffect(() => {
|
||||
if (!shown) return;
|
||||
let live = true;
|
||||
const repo = project?.workspace ? root : null;
|
||||
void Promise.all([call(commands.vcsBranchInfo(repo)), call(commands.vcsBranches(repo))])
|
||||
@@ -83,10 +86,9 @@ export function HomeEditor({ docked = false, input }: { docked?: boolean; input?
|
||||
return () => {
|
||||
live = false;
|
||||
};
|
||||
}, [root, project?.workspace]);
|
||||
}, [root, project?.workspace, shown]);
|
||||
|
||||
const provider = providers.find((p) => p.id === draft.provider) ?? providers[0];
|
||||
const shown = useEditorShown();
|
||||
const probe = useProbe(provider?.installed ? provider.id : null, provider?.command, shown);
|
||||
const catalog = useAgents((s) => s.modelCatalogs.get(provider?.id ?? ""));
|
||||
const requestingModels = useAgents((s) => s.modelRequests.has(provider?.id ?? ""));
|
||||
@@ -122,6 +124,10 @@ export function HomeEditor({ docked = false, input }: { docked?: boolean; input?
|
||||
!starting &&
|
||||
(!project?.workspace || repoState?.root === root);
|
||||
|
||||
const openMcp = () => setMcpOpenRequest((n) => n + 1);
|
||||
// The agent shows as its icon; its name and version are in the tooltip.
|
||||
const agentTitle = [provider?.name ?? tx("Agent"), probe?.version].filter(Boolean).join(" ");
|
||||
|
||||
const start = () => {
|
||||
if (!canStart) return;
|
||||
setStarting(true);
|
||||
@@ -137,93 +143,25 @@ export function HomeEditor({ docked = false, input }: { docked?: boolean; input?
|
||||
className={clsx(styles.home, docked && styles.docked, fitWindowWidth && styles.fitWidth)}
|
||||
style={zoomStyle}
|
||||
>
|
||||
{/* In the tool window the box sits at the bottom, under the question centred in the space above. */}
|
||||
{docked && (
|
||||
<div className={styles.dockedIntro}>
|
||||
<h1 className={styles.heading}>
|
||||
<T>What should the agent do?</T>
|
||||
</h1>
|
||||
</div>
|
||||
)}
|
||||
<div className={styles.inner}>
|
||||
{!docked && (
|
||||
<h1 className={styles.heading}>
|
||||
<T>What should the agent do?</T>
|
||||
</h1>
|
||||
)}
|
||||
{/* Above the box, like the running session's state line. */}
|
||||
<div className={styles.where}>
|
||||
{members.length > 1 ? (
|
||||
<Select
|
||||
variant="chip"
|
||||
aria-label={tx("Project")}
|
||||
className={styles.projectPicker}
|
||||
value={root}
|
||||
options={members.map((path) => ({
|
||||
value: path,
|
||||
label: basename(path),
|
||||
detail: path,
|
||||
icon: "folder",
|
||||
}))}
|
||||
onChange={(path) => {
|
||||
setSelected(path);
|
||||
updateDraft({ base: null });
|
||||
}}
|
||||
/>
|
||||
) : projectLabel ? (
|
||||
<Chip icon="folder" title={root} className={styles.projectChip}>
|
||||
{projectLabel}
|
||||
</Chip>
|
||||
) : null}
|
||||
{isGit && (
|
||||
<Select
|
||||
variant="chip"
|
||||
aria-label="Isolation"
|
||||
className={styles.isolation}
|
||||
value={isolation}
|
||||
options={[
|
||||
{ value: "worktree", label: tx("New worktree"), icon: "branch", detail: tx("away from your changes") },
|
||||
{
|
||||
value: "local",
|
||||
label: tx("Local checkout"),
|
||||
icon: "folder",
|
||||
detail: tx("edits your files directly"),
|
||||
},
|
||||
]}
|
||||
onChange={(isolation) => updateDraft({ isolation, isolationChosen: true })}
|
||||
/>
|
||||
)}
|
||||
{/* A folder that isn't a repository has no branch: the one Git found below it isn't where the agent runs. */}
|
||||
{isolation === "local" && isGit && current && (
|
||||
<>
|
||||
{!docked && (
|
||||
<span className={styles.note}>
|
||||
<T>on</T>
|
||||
</span>
|
||||
)}
|
||||
<Chip icon="branch" title={current} className={styles.branch}>
|
||||
{current}
|
||||
</Chip>
|
||||
</>
|
||||
)}
|
||||
{isolation === "worktree" && branches.length > 0 && (
|
||||
<>
|
||||
{!docked && (
|
||||
<span className={styles.note}>
|
||||
<T>from</T>
|
||||
</span>
|
||||
)}
|
||||
<Select
|
||||
variant="chip"
|
||||
aria-label="Base branch"
|
||||
className={styles.basePicker}
|
||||
value={base}
|
||||
options={branches.map((b) => ({ value: b.name, label: b.name, icon: "branch" }))}
|
||||
onChange={(b) => updateDraft({ base: b === current ? null : b })}
|
||||
/>
|
||||
</>
|
||||
)}
|
||||
</div>
|
||||
<Composer
|
||||
id={HOME}
|
||||
autoFocus
|
||||
placeholder={
|
||||
docked
|
||||
? "Describe a task…"
|
||||
: "Describe a task for the agent. @ references a file or folder, / runs a command"
|
||||
}
|
||||
className={docked ? undefined : styles.composer}
|
||||
autoFocus={shown}
|
||||
placeholder={docked ? "Describe a task…" : "Describe a task. @ for files, / for commands"}
|
||||
root={root}
|
||||
projectRoot={root}
|
||||
commands={agentCommands}
|
||||
@@ -231,19 +169,23 @@ export function HomeEditor({ docked = false, input }: { docked?: boolean; input?
|
||||
config={config}
|
||||
onConfig={setDraftOption}
|
||||
onSubmit={start}
|
||||
onOpenMcp={() => setMcpOpenRequest((n) => n + 1)}
|
||||
onOpenMcp={openMcp}
|
||||
disabled={!canStart}
|
||||
addMenu={provider ? [{ id: "mcp", label: "MCP Servers…", icon: "plugin", run: openMcp }] : undefined}
|
||||
toolbar={
|
||||
<>
|
||||
<Select
|
||||
variant="ghost"
|
||||
aria-label="Agent"
|
||||
value={provider?.id ?? null}
|
||||
options={providerOptions}
|
||||
onChange={(id) =>
|
||||
id === ADD_AGENT ? void executeAction("agents.addAgent") : updateDraft({ provider: id, config: {} })
|
||||
}
|
||||
/>
|
||||
<span className={styles.agentPicker} {...tooltipAttrs(agentTitle, undefined, true)}>
|
||||
<Select
|
||||
variant="ghost"
|
||||
aria-label="Agent"
|
||||
value={provider?.id ?? null}
|
||||
options={providerOptions}
|
||||
renderValue={(o) => (o?.icon ? <Icon name={o.icon} size={14} /> : <T>Agent</T>)}
|
||||
onChange={(id) =>
|
||||
id === ADD_AGENT ? void executeAction("agents.addAgent") : updateDraft({ provider: id, config: {} })
|
||||
}
|
||||
/>
|
||||
</span>
|
||||
<ConfigPickers
|
||||
key={provider?.id}
|
||||
config={config}
|
||||
@@ -265,6 +207,7 @@ export function HomeEditor({ docked = false, input }: { docked?: boolean; input?
|
||||
overrides={draft.mcpOverrides}
|
||||
onChange={setDraftMcpOverrides}
|
||||
openRequest={mcpOpenRequest}
|
||||
hideTrigger
|
||||
/>
|
||||
)}
|
||||
</>
|
||||
@@ -278,6 +221,71 @@ export function HomeEditor({ docked = false, input }: { docked?: boolean; input?
|
||||
/>
|
||||
}
|
||||
/>
|
||||
{/* Under the box: where the agent works. Project and checkout on the left, the branch on the right. */}
|
||||
<div className={styles.where}>
|
||||
{members.length > 1 ? (
|
||||
<Select
|
||||
variant="ghost"
|
||||
aria-label={tx("Project")}
|
||||
className={styles.projectPicker}
|
||||
value={root}
|
||||
options={members.map((path) => ({
|
||||
value: path,
|
||||
label: basename(path),
|
||||
detail: path,
|
||||
icon: "folder",
|
||||
}))}
|
||||
onChange={(path) => {
|
||||
setSelected(path);
|
||||
updateDraft({ base: null });
|
||||
}}
|
||||
/>
|
||||
) : projectLabel ? (
|
||||
<span className={styles.project} title={root}>
|
||||
<Icon name="folder" size={14} />
|
||||
<span className={styles.label}>{projectLabel}</span>
|
||||
</span>
|
||||
) : null}
|
||||
{isGit && (
|
||||
<Select
|
||||
variant="ghost"
|
||||
aria-label="Isolation"
|
||||
value={isolation}
|
||||
options={[
|
||||
{
|
||||
value: "local",
|
||||
label: tx("Local checkout"),
|
||||
icon: "folder",
|
||||
detail: tx("edits your files directly"),
|
||||
},
|
||||
{
|
||||
value: "worktree",
|
||||
label: tx("New worktree"),
|
||||
icon: "branch",
|
||||
detail: tx("away from your changes"),
|
||||
},
|
||||
]}
|
||||
renderValue={(o) => (o?.value === "worktree" ? tx("Worktree") : tx("Local"))}
|
||||
onChange={(isolation) => updateDraft({ isolation, isolationChosen: true })}
|
||||
/>
|
||||
)}
|
||||
{/* A folder that isn't a repository has no branch: the one Git found below it isn't where the agent runs. */}
|
||||
{isolation === "local" && isGit && current && (
|
||||
<span className={styles.project} title={current}>
|
||||
<Icon name="branch" size={14} />
|
||||
<span className={styles.label}>{current}</span>
|
||||
</span>
|
||||
)}
|
||||
{isolation === "worktree" && branches.length > 0 && (
|
||||
<Select
|
||||
variant="ghost"
|
||||
aria-label="Base branch"
|
||||
value={base}
|
||||
options={branches.map((b) => ({ value: b.name, label: b.name, icon: "branch" }))}
|
||||
onChange={(b) => updateDraft({ base: b === current ? null : b })}
|
||||
/>
|
||||
)}
|
||||
</div>
|
||||
{/* Notes under the box don't take part in centring, so the box stays put as they come and go. */}
|
||||
<div className={styles.notes}>
|
||||
{effortAnnouncement && (
|
||||
@@ -290,11 +298,9 @@ export function HomeEditor({ docked = false, input }: { docked?: boolean; input?
|
||||
<T>Choose another model before starting.</T>
|
||||
</p>
|
||||
)}
|
||||
{probe && (!docked || probe.error) && (
|
||||
<p className={probe.error ? styles.warning : styles.note}>
|
||||
{probe.error
|
||||
? txTemplate(`${provider?.name ?? probe.provider} didn't start: ${probe.error}`)
|
||||
: [probe.name, probe.version, probe.protocol].filter(Boolean).join(" · ")}
|
||||
{probe?.error && (
|
||||
<p className={styles.warning}>
|
||||
{txTemplate(`${provider?.name ?? probe.provider} didn't start: ${probe.error}`)}
|
||||
</p>
|
||||
)}
|
||||
{(error || (provider && !provider.installed)) && (
|
||||
|
||||
@@ -211,3 +211,12 @@
|
||||
color: var(--fg-muted);
|
||||
font-size: var(--fs-tiny);
|
||||
}
|
||||
|
||||
/* The composer is the nearest positioned box: its bottom-right corner. */
|
||||
.hiddenAnchor {
|
||||
position: absolute;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
width: 0;
|
||||
height: 0;
|
||||
}
|
||||
@@ -34,6 +34,8 @@ export interface McpPickerProps {
|
||||
busy?: boolean;
|
||||
/** Bumped when `/mcp` is invoked from the composer to open this popover. */
|
||||
openRequest?: number;
|
||||
/** No button of its own: opened only through `openRequest`, above the composer. */
|
||||
hideTrigger?: boolean;
|
||||
/** Optional overrides for unit tests. */
|
||||
backend?: McpBackend;
|
||||
testData?: {
|
||||
@@ -50,6 +52,7 @@ export function McpPicker({
|
||||
disabled = false,
|
||||
busy = false,
|
||||
openRequest = 0,
|
||||
hideTrigger = false,
|
||||
backend = defaultMcpBackend,
|
||||
testData,
|
||||
}: McpPickerProps) {
|
||||
@@ -67,7 +70,10 @@ export function McpPicker({
|
||||
const [seenOpenRequest, setSeenOpenRequest] = useState(openRequest);
|
||||
const [query, setQuery] = useState("");
|
||||
const [importingKey, setImportingKey] = useState<string | null>(null);
|
||||
const anchor = useRef<HTMLButtonElement>(null);
|
||||
const anchor = useRef<HTMLElement | null>(null);
|
||||
const setAnchor = (el: HTMLElement | null) => {
|
||||
anchor.current = el;
|
||||
};
|
||||
|
||||
if (openRequest !== seenOpenRequest) {
|
||||
setSeenOpenRequest(openRequest);
|
||||
@@ -134,38 +140,43 @@ export function McpPicker({
|
||||
|
||||
return (
|
||||
<>
|
||||
<button
|
||||
ref={anchor}
|
||||
type="button"
|
||||
disabled={disabled}
|
||||
className={styles.trigger}
|
||||
title={
|
||||
resolved.overrideCount > 0
|
||||
? formatMessage(tx("MCP servers ({active}/{total} active · {overrides} session overrides)"), {
|
||||
active: resolved.activeCount,
|
||||
total: resolved.totalCount,
|
||||
overrides: resolved.overrideCount,
|
||||
})
|
||||
: formatMessage(tx("MCP servers ({active}/{total} active)"), {
|
||||
active: resolved.activeCount,
|
||||
total: resolved.totalCount,
|
||||
})
|
||||
}
|
||||
aria-label={tx("MCP servers")}
|
||||
aria-haspopup="dialog"
|
||||
aria-expanded={open}
|
||||
onClick={toggleOpen}
|
||||
>
|
||||
<Icon name="plugin" size={13} />
|
||||
<span className={styles.triggerLabel}>MCP</span>
|
||||
<span className={styles.triggerCount}>{countLabel}</span>
|
||||
{resolved.overrideCount > 0 && <span className={styles.overrideDot} aria-hidden />}
|
||||
</button>
|
||||
{hideTrigger ? (
|
||||
// Pinned to the composer's bottom-right corner: the popover opens under the box, like its other pickers.
|
||||
<span ref={setAnchor} className={styles.hiddenAnchor} aria-hidden />
|
||||
) : (
|
||||
<button
|
||||
ref={setAnchor}
|
||||
type="button"
|
||||
disabled={disabled}
|
||||
className={styles.trigger}
|
||||
title={
|
||||
resolved.overrideCount > 0
|
||||
? formatMessage(tx("MCP servers ({active}/{total} active · {overrides} session overrides)"), {
|
||||
active: resolved.activeCount,
|
||||
total: resolved.totalCount,
|
||||
overrides: resolved.overrideCount,
|
||||
})
|
||||
: formatMessage(tx("MCP servers ({active}/{total} active)"), {
|
||||
active: resolved.activeCount,
|
||||
total: resolved.totalCount,
|
||||
})
|
||||
}
|
||||
aria-label={tx("MCP servers")}
|
||||
aria-haspopup="dialog"
|
||||
aria-expanded={open}
|
||||
onClick={toggleOpen}
|
||||
>
|
||||
<Icon name="plugin" size={13} />
|
||||
<span className={styles.triggerLabel}>MCP</span>
|
||||
<span className={styles.triggerCount}>{countLabel}</span>
|
||||
{resolved.overrideCount > 0 && <span className={styles.overrideDot} aria-hidden />}
|
||||
</button>
|
||||
)}
|
||||
|
||||
<Popup
|
||||
open={open}
|
||||
anchor={anchor}
|
||||
placement="top-start"
|
||||
placement={hideTrigger ? "bottom-end" : "top-start"}
|
||||
offset={6}
|
||||
onClose={() => {
|
||||
setOpen(false);
|
||||
|
||||
@@ -83,55 +83,38 @@
|
||||
max-width: none;
|
||||
}
|
||||
|
||||
.providerIcon {
|
||||
color: var(--fg-muted);
|
||||
}
|
||||
|
||||
/* The task's state and its terminal and changes, just above the composer. */
|
||||
/* Under the composer: where the task works on the left; changes, meters and terminal on the right. */
|
||||
.statusBar {
|
||||
display: flex;
|
||||
/* What doesn't fit moves to the next line whole, instead of every fact shrinking to a letter. */
|
||||
flex-wrap: wrap;
|
||||
/* The changes chip sits above the line; the facts stay on that line's baseline. */
|
||||
align-items: flex-end;
|
||||
gap: var(--space-0-5) var(--space-1-5);
|
||||
align-items: center;
|
||||
gap: var(--space-2);
|
||||
min-width: 0;
|
||||
padding: 0 2px;
|
||||
height: 24px;
|
||||
padding: 0 6px;
|
||||
overflow: hidden;
|
||||
color: var(--fg-subtle);
|
||||
font-size: var(--fs-small);
|
||||
}
|
||||
/* The facts on the bar's line are as tall as its chips, so their text shares one centre line. */
|
||||
.agent {
|
||||
display: inline-flex;
|
||||
flex: 0 1 auto;
|
||||
max-width: 100%;
|
||||
align-items: center;
|
||||
gap: var(--space-1);
|
||||
height: 22px;
|
||||
min-width: 0;
|
||||
color: var(--fg-secondary);
|
||||
}
|
||||
.agentName {
|
||||
min-width: 0;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
/* Where the task works, as the new-task composer shows it. */
|
||||
.where {
|
||||
display: inline-flex;
|
||||
flex: 0 1 auto;
|
||||
max-width: 100%;
|
||||
align-items: center;
|
||||
/* The chips' own padding spaces them. */
|
||||
gap: var(--space-0-5);
|
||||
gap: var(--space-2);
|
||||
min-width: 0;
|
||||
overflow: hidden;
|
||||
}
|
||||
.note {
|
||||
flex: none;
|
||||
color: var(--fg-subtle);
|
||||
.fact {
|
||||
display: inline-flex;
|
||||
flex: 0 1 auto;
|
||||
align-items: center;
|
||||
gap: var(--space-1);
|
||||
min-width: 0;
|
||||
white-space: nowrap;
|
||||
}
|
||||
.factText {
|
||||
min-width: 0;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
}
|
||||
.state {
|
||||
display: inline-flex;
|
||||
@@ -145,16 +128,15 @@
|
||||
.statusEnd {
|
||||
display: inline-flex;
|
||||
flex: 1 1 auto;
|
||||
flex-wrap: wrap;
|
||||
justify-content: flex-end;
|
||||
align-items: center;
|
||||
gap: var(--space-0-5) var(--space-2);
|
||||
gap: var(--space-2);
|
||||
min-width: 0;
|
||||
}
|
||||
/* Shrinks before the terminal buttons do: in a narrow docked session the meters clip, not the controls. */
|
||||
.statusMeters {
|
||||
display: inline-flex;
|
||||
flex: 0 1 auto;
|
||||
margin-left: auto;
|
||||
align-items: center;
|
||||
height: 22px;
|
||||
gap: var(--space-2);
|
||||
@@ -177,16 +159,18 @@
|
||||
min-width: 0;
|
||||
}
|
||||
.statusChip {
|
||||
composes: surface from "../../ui/Chip.module.css";
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: var(--space-1-5);
|
||||
height: 22px;
|
||||
max-width: 100%;
|
||||
min-width: 0;
|
||||
padding: 0 8px;
|
||||
padding: 0 6px;
|
||||
overflow: hidden;
|
||||
border: none;
|
||||
color: var(--fg-secondary);
|
||||
border-radius: var(--radius-control);
|
||||
background: transparent;
|
||||
color: inherit;
|
||||
font: inherit;
|
||||
font-size: var(--fs-small);
|
||||
font-variant-numeric: tabular-nums;
|
||||
@@ -397,12 +381,10 @@
|
||||
--session-card-width: 96%;
|
||||
}
|
||||
}
|
||||
/* A narrow docked session: rather than cut every fact to a letter or two, the bar keeps the
|
||||
agent's icon and its state; where it works is in the task's tooltip and Changes. */
|
||||
/* A narrow docked session: where it works gives way first, the changes and meters stay readable. */
|
||||
@container (max-width: 420px) {
|
||||
.where,
|
||||
.agentName {
|
||||
display: none;
|
||||
.where {
|
||||
flex-shrink: 2;
|
||||
}
|
||||
.processBody,
|
||||
.turnBody {
|
||||
|
||||
@@ -38,7 +38,6 @@ import { confirm } from "@/workbench/messages";
|
||||
import {
|
||||
Button,
|
||||
Checkbox,
|
||||
Chip,
|
||||
EmptyState,
|
||||
Icon,
|
||||
IconButton,
|
||||
@@ -417,41 +416,34 @@ function SessionStatus({
|
||||
showContextMenu(e, taskMenu([task]));
|
||||
}}
|
||||
>
|
||||
<span className={styles.agent} title={`${providerName(task.provider)} · ${task.cwd}`}>
|
||||
<Icon name={providerIcon(task.provider)} size={13} className={styles.providerIcon} />
|
||||
<span className={styles.agentName}>
|
||||
{providerName(task.provider)}
|
||||
{/* The composer's model picker shows the model when the agent offers one. */}
|
||||
{task.model && !pickedModel ? ` · ${task.model}` : ""}
|
||||
</span>
|
||||
</span>
|
||||
{/* The same three facts as the new-task composer: project, checkout, branch. */}
|
||||
<span className={styles.where}>
|
||||
{projectName && (
|
||||
<Chip icon="folder" title={projectRoot ?? undefined}>
|
||||
{projectName}
|
||||
</Chip>
|
||||
{/* Where the task works, in one quiet line like the new-task page: project (in a workspace), branch, worktree. */}
|
||||
<span className={styles.where} title={task.cwd}>
|
||||
{project?.workspace && projectName && (
|
||||
<span className={styles.fact}>
|
||||
<Icon name="folder" size={13} />
|
||||
<span className={styles.factText}>{projectName}</span>
|
||||
</span>
|
||||
)}
|
||||
<Chip icon={local ? "folder" : "branch"}>
|
||||
<T>{local ? "Local checkout" : "New worktree"}</T>
|
||||
</Chip>
|
||||
{branch && (
|
||||
<>
|
||||
{local && (
|
||||
<span className={styles.note}>
|
||||
<T>on</T>
|
||||
</span>
|
||||
)}
|
||||
<Chip icon="branch" title={branch}>
|
||||
{branch}
|
||||
</Chip>
|
||||
</>
|
||||
<span className={styles.fact}>
|
||||
<Icon name="branch" size={13} />
|
||||
<span className={styles.factText}>{branch}</span>
|
||||
</span>
|
||||
)}
|
||||
{!local && (
|
||||
<span className={styles.fact}>
|
||||
<T>Worktree</T>
|
||||
</span>
|
||||
)}
|
||||
{task.model && !pickedModel && <span className={styles.fact}>{task.model}</span>}
|
||||
</span>
|
||||
<span className={styles.state}>
|
||||
<T>{statusLabel(task.status)}</T>
|
||||
{task.status === "limited" && task.resetsMs != null && ` · ${tx`resets ${formatSentAt(task.resetsMs)}`}`}
|
||||
</span>
|
||||
{/* Ready is the usual state: only the others are worth a word. */}
|
||||
{task.status !== "ready" && (
|
||||
<span className={styles.state}>
|
||||
<T>{statusLabel(task.status)}</T>
|
||||
{task.status === "limited" && task.resetsMs != null && ` · ${tx`resets ${formatSentAt(task.resetsMs)}`}`}
|
||||
</span>
|
||||
)}
|
||||
<span className={styles.state} role="status" aria-live="polite" aria-atomic="true">
|
||||
{effortAnnouncement ? tx("Effort: {level}").replace("{level}", effortAnnouncement) : ""}
|
||||
</span>
|
||||
@@ -539,7 +531,7 @@ function Usage({ usage }: { usage: AgentUsage }) {
|
||||
<span className={styles.usageBar} aria-hidden>
|
||||
<span style={{ width: `${label.percent}%` }} />
|
||||
</span>
|
||||
{label.short}
|
||||
{`${label.percent}%`}
|
||||
</span>
|
||||
);
|
||||
}
|
||||
@@ -2906,20 +2898,11 @@ function SessionComposer({
|
||||
body: String(e),
|
||||
}),
|
||||
);
|
||||
const openMcp = () => setMcpOpenRequest((n) => n + 1);
|
||||
const shown = useEditorShown();
|
||||
const effortAnnouncement = useEffortFocus(focusRoot, shown && task.status !== "archived", task.config, setOption);
|
||||
return (
|
||||
<div className={styles.composerArea}>
|
||||
<SessionStatus
|
||||
task={task}
|
||||
entries={entries}
|
||||
head={head}
|
||||
changes={changes}
|
||||
commits={commits}
|
||||
changesOpen={changesOpen}
|
||||
onToggleChanges={onToggleChanges}
|
||||
effortAnnouncement={effortAnnouncement}
|
||||
/>
|
||||
{task.status === "archived" && (
|
||||
<div className={styles.banner}>
|
||||
<span className={styles.bannerText}>
|
||||
@@ -2958,8 +2941,11 @@ function SessionComposer({
|
||||
config={task.config}
|
||||
onConfig={setOption}
|
||||
onSubmit={send}
|
||||
onOpenMcp={() => setMcpOpenRequest((n) => n + 1)}
|
||||
onOpenMcp={openMcp}
|
||||
disabled={task.status === "archived"}
|
||||
addMenu={[
|
||||
{ id: "mcp", label: "MCP Servers…", icon: "plugin", disabled: task.status === "archived", run: openMcp },
|
||||
]}
|
||||
toolbar={
|
||||
<>
|
||||
<ConfigPickers config={task.config} onChange={setOption} />
|
||||
@@ -2969,6 +2955,7 @@ function SessionComposer({
|
||||
disabled={task.status === "archived"}
|
||||
busy={busy}
|
||||
openRequest={mcpOpenRequest}
|
||||
hideTrigger
|
||||
onChange={(next) =>
|
||||
void setTaskMcpOverrides(task.id, next).catch((e: unknown) =>
|
||||
notifications().notify({
|
||||
@@ -2994,6 +2981,16 @@ function SessionComposer({
|
||||
</>
|
||||
}
|
||||
/>
|
||||
<SessionStatus
|
||||
task={task}
|
||||
entries={entries}
|
||||
head={head}
|
||||
changes={changes}
|
||||
commits={commits}
|
||||
changesOpen={changesOpen}
|
||||
onToggleChanges={onToggleChanges}
|
||||
effortAnnouncement={effortAnnouncement}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -318,7 +318,7 @@ describe("Composer editing", () => {
|
||||
});
|
||||
|
||||
describe("Composer current file", () => {
|
||||
it("offers the focused editor's file until the draft references it", () => {
|
||||
it("offers the focused editor's file, and adds it with the selection to requests when chosen", () => {
|
||||
const view = {} as TextEditorHandle["view"];
|
||||
act(() => setIdeContext(false));
|
||||
act(() =>
|
||||
@@ -329,10 +329,10 @@ describe("Composer current file", () => {
|
||||
const offer = screen.getByRole("button", { name: /main\.ts/ });
|
||||
expect(offer).toHaveTextContent("Current File");
|
||||
fireEvent.click(offer);
|
||||
expect(composerDraft(ID).text).toBe("@src/main.ts ");
|
||||
expect(toPrompt(composerDraft(ID)).files).toEqual(["/p/src/main.ts"]);
|
||||
expect(useAgents.getState().ideContext).toBe(true);
|
||||
expect(composerDraft(ID).text).toBe("");
|
||||
expect(screen.queryByRole("button", { name: /main\.ts/ })).toBeNull();
|
||||
expect(document.querySelector("[data-ref-path]")).toHaveAttribute("data-ref-path", "/p/src/main.ts");
|
||||
expect(screen.getByTitle("src/main.ts is added to your request")).toHaveTextContent("Current File");
|
||||
} finally {
|
||||
act(() => useEditorRegistry.setState({ active: null }));
|
||||
}
|
||||
@@ -348,8 +348,6 @@ describe("Composer IDE context", () => {
|
||||
);
|
||||
try {
|
||||
renderComposer();
|
||||
const toggle = screen.getByRole("button", { name: /IDE Context Enabled/ });
|
||||
expect(toggle).toHaveAttribute("aria-pressed", "true");
|
||||
expect(screen.queryByRole("button", { name: /main\.ts/ })).toBeNull();
|
||||
expect(screen.getByTitle("src/main.ts is added to your request")).toHaveTextContent("Current File");
|
||||
|
||||
@@ -369,9 +367,9 @@ describe("Composer IDE context", () => {
|
||||
// A draft that already references the file is sent as written.
|
||||
expect(await send("see @src/main.ts:1")).toEqual({ text: "see @src/main.ts:1", files: [], images: [] });
|
||||
|
||||
fireEvent.click(toggle);
|
||||
fireEvent.click(screen.getByRole("button", { name: "Don't Add the Current File" }));
|
||||
expect(useAgents.getState().ideContext).toBe(false);
|
||||
expect(screen.getByRole("button", { name: /IDE Context Disabled/ })).toHaveAttribute("aria-pressed", "false");
|
||||
expect(screen.getByRole("button", { name: /main\.ts/ })).toHaveTextContent("Current File");
|
||||
expect(await send("explain")).toEqual({ text: "explain", files: [], images: [] });
|
||||
} finally {
|
||||
act(() => useEditorRegistry.setState({ active: null }));
|
||||
|
||||
@@ -385,14 +385,6 @@ export const isContextOption = (id: string) => /^(context_tier|contextTier)$/.te
|
||||
export const isPerModelOption = (o: AgentConfigOption) =>
|
||||
o.category === "thought_level" || o.category === "context_tier" || isContextOption(o.id);
|
||||
|
||||
/** Formats a per-1M-token credit rate cleanly (`200`, `1000`, `0`, `12.5`). */
|
||||
export function formatCreditRate(rate: number | null | undefined): string {
|
||||
if (rate == null || !Number.isFinite(rate)) return "0";
|
||||
if (rate === 0) return "0";
|
||||
if (rate < 0.01) return rate.toExponential(2);
|
||||
return Number(rate.toFixed(4)).toString();
|
||||
}
|
||||
|
||||
const matchesCategory = (o: AgentConfigOption, category: string) =>
|
||||
o.category === category ||
|
||||
(category === "model_config" &&
|
||||
|
||||
@@ -203,6 +203,8 @@ export function activate(): () => void {
|
||||
},
|
||||
onTabClose: (tabId) => clearAgentTabFontZoom(tabId),
|
||||
restorable: true,
|
||||
// Mounting it again on every switch rebuilds the composer and refetches the agent, models and branches.
|
||||
keepAlive: true,
|
||||
}),
|
||||
// An explicit editor drop sets the placement for subsequent sessions too.
|
||||
registerEditorDropHandler({
|
||||
|
||||
@@ -152,6 +152,7 @@ it("keeps cached choices usable while refreshing and shares the completion/coold
|
||||
expect(screen.getByRole("button", { name: "Start" })).toBeEnabled();
|
||||
await waitFor(() => expect(useAgents.getState().modelRequests.size).toBe(0));
|
||||
emit(catalog("first", { retryAtMs: Date.now() + 30_000 }));
|
||||
fireEvent.click(screen.getByRole("button", { name: "Model" }));
|
||||
expect(screen.getByRole("button", { name: /Refresh in \d+s/ })).toBeDisabled();
|
||||
expect(screen.getByRole("button", { name: "Model" })).toHaveTextContent("small");
|
||||
fireEvent.click(screen.getByRole("button", { name: "Start" }));
|
||||
@@ -213,11 +214,12 @@ it("retains cached model and effort choices after a command failure and retries
|
||||
draft: savedDraft({ provider: "first", config: { model: "big" }, thoughtLevels: { big: { effort: "low" } } }),
|
||||
});
|
||||
render(<HomeEditor />);
|
||||
expect(screen.getByRole("button", { name: "Reasoning" })).toHaveTextContent("low");
|
||||
fireEvent.click(screen.getByRole("button", { name: "Model" }));
|
||||
expect(await screen.findByRole("alert")).toHaveTextContent("connection lost");
|
||||
expect(screen.getByRole("button", { name: "Configure model" })).toHaveTextContent("biglow");
|
||||
fireEvent.click(screen.getByRole("option", { name: "small" }));
|
||||
expect(screen.getByRole("button", { name: "Model" })).toHaveTextContent("small");
|
||||
fireEvent.click(screen.getByRole("button", { name: "Model" }));
|
||||
fireEvent.click(screen.getByRole("button", { name: "Refresh models" }));
|
||||
await waitFor(() => expect(screen.queryByRole("alert")).not.toBeInTheDocument());
|
||||
expect(screen.getByRole("button", { name: "Model" })).toHaveTextContent("small");
|
||||
@@ -238,11 +240,11 @@ it("preserves a valid remembered model and effort when discovery changes the def
|
||||
);
|
||||
render(<HomeEditor />);
|
||||
await waitFor(() => expect(useAgents.getState().modelRequests.size).toBe(0));
|
||||
expect(screen.getByRole("button", { name: "Model" })).toHaveTextContent("biglow");
|
||||
expect(screen.getByRole("button", { name: "Model" })).toHaveTextContent("big");
|
||||
expect(screen.getByRole("button", { name: "Reasoning" })).toHaveTextContent("low");
|
||||
fireEvent.click(screen.getByRole("button", { name: "Model" }));
|
||||
expect(screen.getByRole("option", { name: "new" })).toBeVisible();
|
||||
fireEvent.click(screen.getByRole("button", { name: "Configure model" }));
|
||||
expect(screen.getByRole("radio", { name: "low" })).toHaveAttribute("aria-checked", "true");
|
||||
fireEvent.keyDown(document, { key: "Escape" });
|
||||
fireEvent.click(screen.getByRole("button", { name: "Start" }));
|
||||
await waitFor(() => expect(backend.create).toHaveBeenCalled());
|
||||
expect(backend.create.mock.calls[0]![0].config).toEqual([
|
||||
|
||||
@@ -2016,7 +2016,9 @@ describe("meters in the task header", () => {
|
||||
render(<SessionEditor input={input("A")} />);
|
||||
await screen.findByText("Answer A");
|
||||
const usage = screen.getByLabelText(/^Context /);
|
||||
expect(usage).toHaveTextContent("24k/200k (12%)");
|
||||
// The bar and percent show; the counts are in its label and tooltip.
|
||||
expect(usage).toHaveTextContent("12%");
|
||||
expect(usage).toHaveAccessibleName(/24k\/200k \(12%\)/);
|
||||
expect(usage.querySelector(`.${styles.usageBar} span`)).toHaveStyle({
|
||||
width: "12%",
|
||||
});
|
||||
|
||||
@@ -281,3 +281,32 @@ it("confirmLeave asks about running processes before closing", async () => {
|
||||
expect(asked[0]?.title).toContain("app");
|
||||
expect(asked[0]?.body).toContain("app");
|
||||
});
|
||||
|
||||
it("counts untitled buffers only when leaving for Welcome, and stays when one isn't saved", async () => {
|
||||
const service = await import("@/workbench/contributions");
|
||||
const { confirmLeave } = await import("../closeGuard");
|
||||
let untitled = [7];
|
||||
const spy = vi.spyOn(service, "maybeEditorService").mockReturnValue({
|
||||
dirtyDocumentIds: () => [7],
|
||||
untitledDirtyDocumentIds: () => untitled,
|
||||
saveAll: vi.fn(async () => {}),
|
||||
} as never);
|
||||
try {
|
||||
// Another project in place keeps the buffer: nothing to ask.
|
||||
const kept = deps([]);
|
||||
await expect(confirmLeave(kept.d, "openidea", true)).resolves.toBe(true);
|
||||
expect(kept.asked).toHaveLength(0);
|
||||
// Close Project asks; Save with the Save As cancelled keeps the project open, quietly.
|
||||
const left = deps([{ button: "save", checked: false }]);
|
||||
await expect(confirmLeave(left.d, "openidea", false)).resolves.toBe(false);
|
||||
expect(left.asked[0]?.body).toContain("1");
|
||||
expect(left.d.saveAll).toHaveBeenCalled();
|
||||
// Saved: the project closes.
|
||||
untitled = [];
|
||||
const saved = deps([{ button: "save", checked: false }]);
|
||||
left.d.saveAll = vi.fn(async () => {});
|
||||
await expect(confirmLeave(saved.d, "openidea", false)).resolves.toBe(true);
|
||||
} finally {
|
||||
spy.mockRestore();
|
||||
}
|
||||
});
|
||||
@@ -115,6 +115,23 @@ describe("native window close", () => {
|
||||
expect(forget).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it("stays open when an untitled buffer's Save As is cancelled", async () => {
|
||||
vi.mocked(ipc.commands.windowCloseContext).mockResolvedValue({ quitting: false, windows: 2 });
|
||||
vi.mocked(services.maybeEditorService).mockReturnValue({
|
||||
forgetSavedTabs: forget,
|
||||
keepSavedTabs: keep,
|
||||
dirtyDocumentIds: () => [],
|
||||
untitledDirtyDocumentIds: () => ["untitled:1"],
|
||||
cancelClose: vi.fn(),
|
||||
} as never);
|
||||
deps.prepareClose = async () => ({ dirty: 1, discard: vi.fn(), commit: vi.fn(), cancel: vi.fn() });
|
||||
deps.ask = async () => ({ button: "save", checked: false });
|
||||
const prevented = await close({});
|
||||
expect(deps.saveAll).toHaveBeenCalledOnce();
|
||||
expect(prevented).toHaveBeenCalledOnce();
|
||||
expect(ipc.commands.windowGroupCancelClose).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it("restores saved tabs if returning to Welcome fails", async () => {
|
||||
vi.mocked(ipc.commands.closeProject).mockRejectedValue(new Error("close failed"));
|
||||
const prevented = await close({ closeTabsWithWindow: true });
|
||||
|
||||
@@ -148,6 +148,8 @@ describe("openProjectInWindow", () => {
|
||||
expect(wslResolve).toHaveBeenCalledWith(share);
|
||||
expect(connectRemote).toHaveBeenCalledWith(target, linuxPath);
|
||||
expect(openProject).not.toHaveBeenCalled();
|
||||
// The remote window doesn't keep untitled buffers, so the guard counts them.
|
||||
expect(confirmLeaveProject).toHaveBeenCalledWith(false);
|
||||
});
|
||||
|
||||
it("asks for a new window when this one already has a project", async () => {
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
* `general.closeWithoutWelcome` is on, in which case it closes. When
|
||||
* `general.closeTabsWithWindow` is on, that close drops the saved editor tabs.
|
||||
*/
|
||||
import { commands, isTauri, onIdeEvent, type Settings } from "@/platform/ipc";
|
||||
import { IpcError, commands, isCancelled, isTauri, onIdeEvent, type Settings } from "@/platform/ipc";
|
||||
import { t } from "@/platform/i18n";
|
||||
import { closeProject, provideLeaveProjectGuard, useProject } from "@/platform/project";
|
||||
import { workflowSettings } from "@/platform/workflowSettings";
|
||||
@@ -171,6 +171,7 @@ const defaultDeps: CloseDeps = {
|
||||
while ((await liveProcesses()).length > 0) await new Promise((r) => setTimeout(r, 100));
|
||||
},
|
||||
onSaveFailed: (e) =>
|
||||
!isCancelled(e) &&
|
||||
notifications().notify({
|
||||
level: "error",
|
||||
title: t("app.unsaved.saveFailed"),
|
||||
@@ -224,7 +225,7 @@ async function onCloseRequested(deps: CloseDeps): Promise<boolean> {
|
||||
const s = useProject.getState();
|
||||
// The last project or LightEdit window can return to Welcome. Otherwise it closes.
|
||||
if (returnsToWelcome(ctx.quitting, ctx.windows, !!(s.project || s.lightEdit), s.settings)) {
|
||||
if (await confirmLeave(deps)) {
|
||||
if (await confirmLeave(deps, undefined, false)) {
|
||||
forgot = forgetTabs();
|
||||
try {
|
||||
await closeProject();
|
||||
@@ -249,7 +250,7 @@ async function onCloseRequested(deps: CloseDeps): Promise<boolean> {
|
||||
dirty: dirtyCount(),
|
||||
project: s.project?.displayName || s.project?.name || null,
|
||||
},
|
||||
deps,
|
||||
savingUntitled(deps),
|
||||
);
|
||||
if (!ok) {
|
||||
await (ctx.quitting ? commands.appCancelQuit() : commands.windowGroupCancelClose());
|
||||
@@ -269,6 +270,18 @@ async function onCloseRequested(deps: CloseDeps): Promise<boolean> {
|
||||
}
|
||||
}
|
||||
|
||||
/** Save asks for each untitled buffer's path; one left unsaved (Save As cancelled) keeps the window open. */
|
||||
function savingUntitled(deps: CloseDeps): CloseDeps {
|
||||
return {
|
||||
...deps,
|
||||
saveAll: async () => {
|
||||
await deps.saveAll();
|
||||
if (maybeEditorService()?.untitledDirtyDocumentIds?.().length)
|
||||
throw new IpcError({ kind: "cancelled", message: "Untitled files were not saved" });
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Unsaved changes before this window opens another project in place or closes it. `project` names
|
||||
* the project in the prompt when this window doesn't hold it (a comparison window).
|
||||
@@ -276,16 +289,19 @@ async function onCloseRequested(deps: CloseDeps): Promise<boolean> {
|
||||
export async function confirmLeave(
|
||||
deps: CloseDeps = defaultDeps,
|
||||
project = (useProject.getState().project?.displayName || useProject.getState().project?.name) ?? null,
|
||||
keepUntitled = true,
|
||||
): Promise<boolean> {
|
||||
if (!(await closeDocumentWindows())) return false;
|
||||
const confirmTerminate = workflowSettings().run.confirmTerminate;
|
||||
// Untitled buffers follow the window across projects: they are neither
|
||||
// counted nor saved by this guard (the window keeps them open).
|
||||
const untitled = new Set(maybeEditorService()?.untitledDirtyDocumentIds?.() ?? []);
|
||||
// Untitled buffers follow the window into another project: they are neither counted nor
|
||||
// saved then (the window keeps them open). Closing to Welcome drops them, so they count.
|
||||
const untitled = new Set(keepUntitled ? (maybeEditorService()?.untitledDirtyDocumentIds?.() ?? []) : []);
|
||||
const saveDeps: CloseDeps =
|
||||
untitled.size > 0
|
||||
? { ...deps, saveAll: () => Promise.resolve(maybeEditorService()?.saveAll({ skipUntitled: true })) }
|
||||
: deps;
|
||||
: keepUntitled
|
||||
? deps
|
||||
: savingUntitled(deps);
|
||||
return decideClose(
|
||||
{
|
||||
quitting: false,
|
||||
@@ -331,7 +347,7 @@ export function installCloseGuard(deps: CloseDeps = defaultDeps): () => void {
|
||||
useProject.subscribe((s, prev) => {
|
||||
if (s.project?.root !== prev.project?.root || s.lightEdit !== prev.lightEdit) dirtyDocs.clear();
|
||||
}),
|
||||
provideLeaveProjectGuard(() => confirmLeave(deps)),
|
||||
provideLeaveProjectGuard((keepUntitled) => confirmLeave(deps, undefined, keepUntitled)),
|
||||
];
|
||||
let unlisten: (() => void) | undefined;
|
||||
let disposed = false;
|
||||
|
||||
@@ -55,10 +55,10 @@ function openFailed(path: string, e: unknown) {
|
||||
/** Opens project `path` in this window; true once it is this window's project. */
|
||||
async function openHere(path: string): Promise<boolean> {
|
||||
if (!isRemoteWindow() && useProject.getState().project?.root === path) return true;
|
||||
if (!(await confirmLeaveProject())) return false;
|
||||
// A folder of a WSL distro runs there, not as a network folder; the window then drops untitled buffers.
|
||||
const wsl = await commands.wslResolve(path).catch(() => null);
|
||||
if (!(await confirmLeaveProject(!wsl))) return false;
|
||||
try {
|
||||
// A folder of a WSL distro runs there, not as a network folder.
|
||||
const wsl = await commands.wslResolve(path).catch(() => null);
|
||||
if (wsl) await connectRemote(wsl.target, wsl.path);
|
||||
else await openProject(path);
|
||||
return true;
|
||||
|
||||
@@ -57,6 +57,7 @@ export function exportMenu(data: ExportData, source: string, format?: ExportForm
|
||||
export function ExtractorSelect({ value, onChange }: { value: ExportFormat; onChange: (f: ExportFormat) => void }) {
|
||||
return (
|
||||
<Select
|
||||
variant="ghost"
|
||||
aria-label="Data extractor"
|
||||
value={value}
|
||||
options={EXPORT_FORMATS.map((f) => ({ value: f.id, label: f.label }))}
|
||||
|
||||
@@ -47,7 +47,6 @@
|
||||
.headerName {
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
font-weight: 600;
|
||||
}
|
||||
.headerIcon {
|
||||
flex: none;
|
||||
@@ -58,6 +57,7 @@
|
||||
margin-left: auto;
|
||||
color: var(--fg-muted);
|
||||
}
|
||||
|
||||
.cellNumber {
|
||||
justify-content: flex-end;
|
||||
}
|
||||
@@ -1364,7 +1364,7 @@
|
||||
gap: var(--space-0-5);
|
||||
padding: 2px 4px;
|
||||
border: 1px solid var(--border-popup, var(--border));
|
||||
border-radius: var(--radius-small);
|
||||
border-radius: var(--radius-popup);
|
||||
background: var(--bg-popup, var(--bg-elev));
|
||||
color: var(--fg-secondary);
|
||||
font-size: var(--fs-small);
|
||||
|
||||
@@ -18,20 +18,7 @@ import clsx from "clsx";
|
||||
import { call, commands, type DbPlanNode, type DbQueryResult } from "@/platform/ipc";
|
||||
import { shortcutLabel } from "@/platform/keymap";
|
||||
import { setContext } from "@/platform/context";
|
||||
import {
|
||||
Button,
|
||||
EmptyState,
|
||||
Icon,
|
||||
IconButton,
|
||||
Select,
|
||||
Spinner,
|
||||
Tabs,
|
||||
Tree,
|
||||
showContextMenu,
|
||||
T,
|
||||
tooltipAttrs,
|
||||
Toolbar,
|
||||
} from "@/ui";
|
||||
import { EmptyState, Icon, IconButton, Select, Spinner, Tabs, Tree, showContextMenu, T, Toolbar } from "@/ui";
|
||||
import { notifications } from "@/workbench/contributions";
|
||||
import { ToolWindowContentTabs } from "@/workbench/toolwindows/ToolWindows";
|
||||
import { ChartView } from "./ChartView";
|
||||
@@ -65,7 +52,6 @@ import {
|
||||
pageable,
|
||||
pinResult,
|
||||
rerunResult,
|
||||
targetLabel,
|
||||
useDatabase,
|
||||
withConnection,
|
||||
type OutputLine,
|
||||
@@ -173,6 +159,25 @@ function Pager({ tab }: { tab: ResultTab }) {
|
||||
const { first, last } = w;
|
||||
const total = w.total === null ? `${w.last + 1}+` : String(w.total);
|
||||
const sizes = PAGE_SIZES.includes(pageSize) ? PAGE_SIZES : [...PAGE_SIZES, pageSize].sort((a, b) => a - b);
|
||||
const sizeSelect = (label?: string) => (
|
||||
<Select
|
||||
variant="ghost"
|
||||
aria-label="Page size"
|
||||
value={String(pageSize)}
|
||||
options={sizes.map((v) => ({ value: String(v), label: String(v) }))}
|
||||
renderValue={label ? () => label : undefined}
|
||||
onChange={(v) => go(0, Number(v))}
|
||||
disabled={!canPage}
|
||||
/>
|
||||
);
|
||||
// Everything fits on one page: only the row count, which still sets the page size.
|
||||
const count = w.total;
|
||||
if (!canPrevious && !canNext && count !== null)
|
||||
return (
|
||||
<Toolbar className={styles.resultPager} aria-label="Result pages" title={outcomeSummary(tab.outcome)}>
|
||||
{sizeSelect(tx`${count} rows`)}
|
||||
</Toolbar>
|
||||
);
|
||||
return (
|
||||
<Toolbar className={styles.resultPager} aria-label="Result pages" title={outcomeSummary(tab.outcome)}>
|
||||
<IconButton
|
||||
@@ -216,13 +221,7 @@ function Pager({ tab }: { tab: ResultTab }) {
|
||||
disabled={!canLast}
|
||||
onClick={() => void goLast()}
|
||||
/>
|
||||
<Select
|
||||
aria-label="Page size"
|
||||
value={String(pageSize)}
|
||||
options={sizes.map((v) => ({ value: String(v), label: String(v) }))}
|
||||
onChange={(v) => go(0, Number(v))}
|
||||
disabled={!canPage}
|
||||
/>
|
||||
{sizeSelect()}
|
||||
</Toolbar>
|
||||
);
|
||||
}
|
||||
@@ -536,30 +535,24 @@ export function Result({ tab, onClose }: { tab: ResultTab; onClose?: () => void
|
||||
disabled={busy}
|
||||
onClick={addRow}
|
||||
/>
|
||||
<Button
|
||||
size="small"
|
||||
variant="primary"
|
||||
disabled={!dirty || busy}
|
||||
onClick={() => void submit()}
|
||||
{...tooltipAttrs("Submit", shortcutLabel("db.submitChanges"))}
|
||||
>
|
||||
<T>Submit</T>
|
||||
</Button>
|
||||
<Button
|
||||
size="small"
|
||||
<IconButton
|
||||
icon="revert"
|
||||
title="Revert"
|
||||
shortcut={shortcutLabel("db.revertChanges")}
|
||||
disabled={!dirty || busy}
|
||||
onClick={() => setEdits(() => emptyEdits())}
|
||||
{...tooltipAttrs("Revert", shortcutLabel("db.revertChanges"))}
|
||||
>
|
||||
<T>Revert</T>
|
||||
</Button>
|
||||
/>
|
||||
<IconButton
|
||||
icon="arrow-up"
|
||||
title="Submit"
|
||||
shortcut={shortcutLabel("db.submitChanges")}
|
||||
disabled={!dirty || busy}
|
||||
onClick={() => void submit()}
|
||||
/>
|
||||
</>
|
||||
)}
|
||||
{tab.busy && <Spinner size={12} />}
|
||||
<span className={styles.spacer} />
|
||||
<span className={styles.resultSource} title={tab.outcome.statement.text}>
|
||||
{targetLabel(tab.sourceId)}
|
||||
</span>
|
||||
<ExtractorSelect value={extractor} onChange={setExtractor} />
|
||||
<IconButton
|
||||
icon="export"
|
||||
@@ -680,10 +673,6 @@ function PlanResult({ tab }: { tab: ResultTab }) {
|
||||
<IconButton icon="refresh" title="Explain Again" disabled={tab.busy} onClick={() => void rerunResult(tab.id)} />
|
||||
<PinButton tab={tab} />
|
||||
{tab.busy && <Spinner size={12} />}
|
||||
<span className={styles.spacer} />
|
||||
<span className={styles.resultSource} title={tab.outcome.statement.text}>
|
||||
{targetLabel(tab.sourceId)}
|
||||
</span>
|
||||
</Toolbar>
|
||||
<div className={clsx(styles.fill, styles.planView)}>
|
||||
<div className={styles.planTree}>
|
||||
|
||||
@@ -571,6 +571,7 @@ function ConsoleBar({ path, view }: { path: string; view: EditorView }) {
|
||||
/>
|
||||
<span className={styles.toolbarSeparator} />
|
||||
<Select
|
||||
variant="ghost"
|
||||
aria-label="Row limit"
|
||||
value={String(maxRows)}
|
||||
options={ROW_LIMITS.map((v) => ({ value: v, label: tx`${Number(v).toLocaleString("en")} rows` }))}
|
||||
@@ -580,6 +581,7 @@ function ConsoleBar({ path, view }: { path: string; view: EditorView }) {
|
||||
<>
|
||||
<span className={styles.toolbarSeparator} />
|
||||
<Select
|
||||
variant="ghost"
|
||||
aria-label="Transaction mode"
|
||||
value={manual ? "manual" : "auto"}
|
||||
options={[
|
||||
@@ -611,6 +613,7 @@ function ConsoleBar({ path, view }: { path: string; view: EditorView }) {
|
||||
{bound && sourceById(boundId)?.driver === "snowflake" && <SnowflakeSession target={bound} idle={!running} />}
|
||||
{switchable && (
|
||||
<Select
|
||||
variant="ghost"
|
||||
aria-label={sqlServer ? "Database" : "Schema"}
|
||||
value={schema || null}
|
||||
placeholder="<schema>"
|
||||
@@ -621,6 +624,7 @@ function ConsoleBar({ path, view }: { path: string; view: EditorView }) {
|
||||
/>
|
||||
)}
|
||||
<Select
|
||||
variant="ghost"
|
||||
aria-label="Data source"
|
||||
value={bound ?? null}
|
||||
placeholder={sources.length ? "<data source>" : "None configured"}
|
||||
@@ -674,6 +678,7 @@ function SnowflakeSession({ target, idle }: { target: string; idle: boolean }) {
|
||||
return (
|
||||
<>
|
||||
<Select
|
||||
variant="ghost"
|
||||
aria-label="Warehouse"
|
||||
value={state.warehouse || null}
|
||||
placeholder="<warehouse>"
|
||||
@@ -683,6 +688,7 @@ function SnowflakeSession({ target, idle }: { target: string; idle: boolean }) {
|
||||
disabled={!idle}
|
||||
/>
|
||||
<Select
|
||||
variant="ghost"
|
||||
aria-label="Role"
|
||||
value={state.role || null}
|
||||
placeholder="<role>"
|
||||
|
||||
@@ -69,9 +69,12 @@
|
||||
.columns .groupTitle {
|
||||
color: var(--fg-subtle);
|
||||
}
|
||||
.processRow {
|
||||
padding-right: 4px;
|
||||
/* Values in every section end where the process rows' Memory column ends, before their End Process slot. */
|
||||
.panel .row,
|
||||
.panel .groupRow {
|
||||
padding-right: calc(4px + 20px + var(--space-2));
|
||||
}
|
||||
.panel .processRow,
|
||||
.columns {
|
||||
padding-right: 4px;
|
||||
}
|
||||
|
||||
@@ -79,7 +79,7 @@ export function activate(): () => void {
|
||||
keywords: ["ssh", "remote", "close"],
|
||||
when: "projectOpen",
|
||||
run: async () => {
|
||||
if (!(await confirmLeaveProject())) return;
|
||||
if (!(await confirmLeaveProject(false))) return;
|
||||
try {
|
||||
await disconnectRemote();
|
||||
} catch (e) {
|
||||
|
||||
@@ -132,15 +132,15 @@ function pendingTool(name: string, entry: ServerEntry, languages: string[]): Too
|
||||
};
|
||||
}
|
||||
|
||||
function JobRow({ name, job }: { name: string; job: InstallJob }) {
|
||||
function JobRow({ tool, job }: { tool: ToolInfo; job: InstallJob }) {
|
||||
return (
|
||||
<div className={styles.job}>
|
||||
<ProgressBar value={job.fraction} aria-label={tx`Installing ${name}`} className={styles.jobBar} />
|
||||
<ProgressBar value={job.fraction} aria-label={tx`Installing ${tool.displayName}`} className={styles.jobBar} />
|
||||
<div className={styles.jobLine}>
|
||||
<span className={styles.jobMessage} title={job.message ?? undefined}>
|
||||
{job.message ?? "Starting…"}
|
||||
</span>
|
||||
<Button size="small" variant="ghost" onClick={() => cancelInstall(name)}>
|
||||
<Button size="small" variant="ghost" onClick={() => cancelInstall(tool.name)}>
|
||||
<T>Cancel</T>
|
||||
</Button>
|
||||
</div>
|
||||
@@ -278,7 +278,7 @@ function ToolDetails({ tool, language, pending }: { tool: ToolInfo; language: st
|
||||
{tx`Version ${update.latest} is available.`}
|
||||
</div>
|
||||
)}
|
||||
{job && <JobRow name={tool.displayName} job={job} />}
|
||||
{job && <JobRow tool={tool} job={job} />}
|
||||
{lastError && (
|
||||
<div className={styles.error} role="alert">
|
||||
{lastError}
|
||||
|
||||
@@ -394,6 +394,19 @@ describe("LanguageServersPage", () => {
|
||||
expect(screen.getByLabelText("gopls install log")).toHaveTextContent("Installing gopls");
|
||||
});
|
||||
|
||||
it("cancels an install from its progress row when the display name differs from the tool name", async () => {
|
||||
const user = userEvent.setup();
|
||||
backend.stepMs = 50;
|
||||
renderPage();
|
||||
await open(user, "Go");
|
||||
await user.click(toolItem("delve"));
|
||||
const details = screen.getByLabelText("Delve (Go debugger) details");
|
||||
await user.click(within(details).getByRole("button", { name: "Install Delve (Go debugger)" }));
|
||||
await user.click(within(details).getByRole("button", { name: "Cancel" }));
|
||||
await waitFor(() => expect(useTools.getState().logs["delve"]?.error).toBe("Cancelled"));
|
||||
expect(toolItem("delve")).toHaveTextContent("Missing");
|
||||
});
|
||||
|
||||
it("offers an update when a newer version of an installed tool is out", async () => {
|
||||
const user = userEvent.setup();
|
||||
backend.available = [{ name: "rust-analyzer", current: "1.85.0", latest: "1.86.0" }];
|
||||
|
||||
@@ -71,6 +71,9 @@
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
.body[hidden] {
|
||||
display: none;
|
||||
}
|
||||
/* Space a block takes before its diff loads, so the scrollbar is roughly right. */
|
||||
.placeholder {
|
||||
height: 160px;
|
||||
|
||||
@@ -98,14 +98,15 @@ function Block({
|
||||
/>
|
||||
)}
|
||||
</div>
|
||||
{!collapsed &&
|
||||
(near ? (
|
||||
<div className={styles.body}>
|
||||
<DiffEditor input={input} fit />
|
||||
</div>
|
||||
) : (
|
||||
<div className={styles.placeholder} />
|
||||
))}
|
||||
{/* A collapsed block keeps its loaded diff, hidden: unmounting it would release the
|
||||
working-tree document and, with autosave off, drop its unsaved edits. */}
|
||||
{near ? (
|
||||
<div className={styles.body} hidden={collapsed}>
|
||||
<DiffEditor input={input} fit />
|
||||
</div>
|
||||
) : (
|
||||
!collapsed && <div className={styles.placeholder} />
|
||||
)}
|
||||
</section>
|
||||
);
|
||||
}
|
||||
@@ -199,7 +200,8 @@ export function CombinedDiffTab({ input }: { input: EditorInput }) {
|
||||
{items.length ? (
|
||||
items.map((item, index) => (
|
||||
<Block
|
||||
key={`${item.path}:${mode}`}
|
||||
// Keyed by file alone: switching the layout keeps each block's diff and its documents.
|
||||
key={item.path}
|
||||
item={item}
|
||||
index={index}
|
||||
items={items}
|
||||
|
||||
@@ -354,3 +354,15 @@
|
||||
[role="treeitem"][aria-selected="true"] .stageButton {
|
||||
visibility: visible;
|
||||
}
|
||||
.inspectionFix {
|
||||
margin-left: var(--space-2);
|
||||
padding: 0;
|
||||
border: none;
|
||||
background: none;
|
||||
color: var(--link);
|
||||
font: inherit;
|
||||
cursor: pointer;
|
||||
}
|
||||
.inspectionFix:hover {
|
||||
text-decoration: underline;
|
||||
}
|
||||
@@ -15,7 +15,7 @@ import {
|
||||
type MouseEvent,
|
||||
type PointerEvent,
|
||||
} from "react";
|
||||
import { tx } from "@/platform/i18n";
|
||||
import { tx, txTemplate } from "@/platform/i18n";
|
||||
import clsx from "clsx";
|
||||
import { executeAction } from "@/platform/actions";
|
||||
import { basename, dirname } from "@/platform/project";
|
||||
@@ -961,6 +961,14 @@ export function ChangesTree({ mode }: { mode: "commit" | "local" | "dialog" }) {
|
||||
);
|
||||
}
|
||||
|
||||
const MISSING_BLANK_LINE = "Missing blank line between subject and body";
|
||||
|
||||
/** The quick fix for {@link MISSING_BLANK_LINE}: an empty line after the subject. */
|
||||
export function addBlankLineAfterSubject(message: string): string {
|
||||
const end = message.indexOf("\n");
|
||||
return end < 0 ? message : `${message.slice(0, end)}\n${message.slice(end)}`;
|
||||
}
|
||||
|
||||
/** Commit message inspections (Settings › Version Control › Commit). */
|
||||
export function messageProblems(
|
||||
message: string,
|
||||
@@ -976,8 +984,7 @@ export function messageProblems(
|
||||
const out: string[] = [];
|
||||
if (c.limitSubject && (lines[0]?.length ?? 0) > c.subjectLimit)
|
||||
out.push(`Subject line is longer than ${c.subjectLimit} characters`);
|
||||
if (c.blankLineAfterSubject && lines.length > 1 && lines[1]!.trim() !== "")
|
||||
out.push("Missing blank line between subject and body");
|
||||
if (c.blankLineAfterSubject && lines.length > 1 && lines[1]!.trim() !== "") out.push(MISSING_BLANK_LINE);
|
||||
if (c.limitBody) {
|
||||
const long = lines.slice(1).findIndex((l) => l.length > c.bodyLimit);
|
||||
if (long >= 0) out.push(`Body line ${long + 2} is longer than ${c.bodyLimit} characters`);
|
||||
@@ -1160,7 +1167,29 @@ export function CommitMessageField({
|
||||
)}
|
||||
{problems.length > 0 && (
|
||||
<div className={styles.inspections} role="status">
|
||||
{problems.join(" · ")}
|
||||
{problems.map((p, i) => (
|
||||
<span key={p}>
|
||||
{i > 0 && " · "}
|
||||
{txTemplate(p)}
|
||||
{p === MISSING_BLANK_LINE && (
|
||||
<button
|
||||
type="button"
|
||||
className={styles.inspectionFix}
|
||||
onClick={() => {
|
||||
const el = ref.current;
|
||||
const caret = el ? el.selectionStart + (el.selectionStart > first.length ? 1 : 0) : 0;
|
||||
useCommit.setState({ message: addBlankLineAfterSubject(message) });
|
||||
requestAnimationFrame(() => {
|
||||
el?.focus();
|
||||
el?.setSelectionRange(caret, caret);
|
||||
});
|
||||
}}
|
||||
>
|
||||
<T>Add blank line</T>
|
||||
</button>
|
||||
)}
|
||||
</span>
|
||||
))}
|
||||
</div>
|
||||
)}
|
||||
{checkProblems.length > 0 && (
|
||||
|
||||
@@ -335,6 +335,11 @@ export function DiffEditor({
|
||||
};
|
||||
}, [path, leftKey, rightKey, contextKey]);
|
||||
|
||||
// A host that picks the layout (the all-in-one diff's toolbar) switches it in place.
|
||||
const asked = input_.mode;
|
||||
useEffect(() => {
|
||||
if (asked) setOptsState((o) => (o.mode === asked ? o : { ...o, mode: asked }));
|
||||
}, [asked]);
|
||||
const setOpts = (patch: Partial<DiffViewOptions>) =>
|
||||
setOptsState((o) => {
|
||||
const next = { ...o, ...patch };
|
||||
|
||||
@@ -83,28 +83,40 @@ describe("the all-in-one diff tab", () => {
|
||||
expect(screen.getAllByText("src")).toHaveLength(2);
|
||||
});
|
||||
|
||||
it("collapses a file and all files", () => {
|
||||
it("collapses a file and all files, keeping their diffs (and unsaved edits) loaded", () => {
|
||||
render(<CombinedDiffTab input={input} />);
|
||||
const shown = () => screen.queryAllByTestId("block-diff").filter((b) => !b.closest("[hidden]"));
|
||||
const first = screen.getAllByTestId("block-diff")[0]!;
|
||||
act(() => {
|
||||
fireEvent.click(screen.getAllByRole("button", { name: "Collapse File" })[0]!);
|
||||
});
|
||||
expect(screen.getAllByTestId("block-diff")).toHaveLength(2);
|
||||
expect(shown()).toHaveLength(2);
|
||||
act(() => {
|
||||
fireEvent.click(screen.getByRole("button", { name: "Collapse All Files" }));
|
||||
});
|
||||
expect(screen.queryAllByTestId("block-diff")).toHaveLength(0);
|
||||
expect(shown()).toHaveLength(0);
|
||||
act(() => {
|
||||
fireEvent.click(screen.getByRole("button", { name: "Expand All Files" }));
|
||||
});
|
||||
expect(screen.getAllByTestId("block-diff")).toHaveLength(3);
|
||||
expect(shown()).toHaveLength(3);
|
||||
// The same diff all along: collapsing never released its document.
|
||||
expect(screen.getAllByTestId("block-diff")[0]).toBe(first);
|
||||
});
|
||||
|
||||
it("switches every block between side-by-side and unified", () => {
|
||||
it("switches every block between side-by-side and unified, collapsed ones too, in place", () => {
|
||||
render(<CombinedDiffTab input={input} />);
|
||||
const before = screen.getAllByTestId("block-diff");
|
||||
act(() => {
|
||||
fireEvent.click(screen.getAllByRole("button", { name: "Collapse File" })[0]!);
|
||||
});
|
||||
act(() => {
|
||||
fireEvent.click(screen.getByRole("button", { name: "Unified Viewer" }));
|
||||
});
|
||||
expect(screen.getAllByTestId("block-diff").every((b) => b.dataset.mode === "unified")).toBe(true);
|
||||
const after = screen.getAllByTestId("block-diff");
|
||||
expect(after.every((b) => b.dataset.mode === "unified")).toBe(true);
|
||||
// The same diffs: switching never released their documents (and unsaved edits).
|
||||
expect(after).toEqual(before);
|
||||
after.forEach((b, i) => expect(b).toBe(before[i]));
|
||||
});
|
||||
|
||||
it("opens a file's own diff, and goes back to one tab per file", async () => {
|
||||
|
||||
@@ -59,6 +59,26 @@ describe("staging area inclusion", () => {
|
||||
expect(plan.stage).toEqual(["/p/src/Unstaged.kt", "/p/src/Gone.kt"]);
|
||||
});
|
||||
|
||||
it("lists and commits a staged addition deleted from disk; the change lists leave it out", () => {
|
||||
const gone = file("src/New.txt", "added", "deleted");
|
||||
const status = [gone, unstagedOnly];
|
||||
expect(isCommitAll(status)).toBe(false);
|
||||
const plan = planCommit(status, stagingChecks(status));
|
||||
expect(plan.included.map((f) => f.relPath)).toEqual(["src/New.txt"]);
|
||||
expect(plan.exclude).toEqual([]);
|
||||
// Staged shows the addition, Unstaged the deletion.
|
||||
const tree = buildChangeTree(status, "/p", false, undefined, [], true);
|
||||
const kinds = (group: string) =>
|
||||
tree.find((n) => n.group === group)?.children?.flatMap((n) => (n.label === "New.txt" ? [n.kind] : []));
|
||||
expect(kinds("staged")).toEqual(["added"]);
|
||||
expect(kinds("unstaged")).toEqual(["deleted"]);
|
||||
// Without the staging area it is no change against HEAD: listed nowhere, never committed.
|
||||
expect(buildChangeTree(status, "/p", false).flatMap((n) => n.files.map((f) => f.relPath))).toEqual([
|
||||
"src/Unstaged.kt",
|
||||
]);
|
||||
expect(planCommit(status, new Map([[unstagedOnly.path, "all" as const]])).exclude).toEqual(["/p/src/New.txt"]);
|
||||
});
|
||||
|
||||
it("is not Commit All when only unversioned files changed", () => {
|
||||
expect(isCommitAll([untracked])).toBe(false);
|
||||
});
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { describe, expect, it, vi } from "vitest";
|
||||
import type { BranchInfo } from "@/bindings";
|
||||
import { messageProblems, wrapAtMargin } from "../CommitView";
|
||||
import { addBlankLineAfterSubject, messageProblems, wrapAtMargin } from "../CommitView";
|
||||
import { linkifyIssues } from "../issueLinks";
|
||||
import {
|
||||
isProtectedBranch,
|
||||
@@ -41,6 +41,14 @@ describe("commit message inspections", () => {
|
||||
expect(messageProblems("x".repeat(20), { ...cfg, limitSubject: false })).toEqual([]);
|
||||
});
|
||||
|
||||
it("adds the missing blank line after the subject", () => {
|
||||
const fixed = addBlankLineAfterSubject("111\n111");
|
||||
expect(fixed).toBe("111\n\n111");
|
||||
expect(messageProblems(fixed, cfg)).toEqual([]);
|
||||
expect(addBlankLineAfterSubject("subject\nline 2\nline 3")).toBe("subject\n\nline 2\nline 3");
|
||||
expect(addBlankLineAfterSubject("subject")).toBe("subject");
|
||||
});
|
||||
|
||||
it("wraps body lines at the last space before the margin", () => {
|
||||
const text = "subject\n\nhello world again";
|
||||
expect(wrapAtMargin(text, text.length, 12)).toEqual({ text: "subject\n\nhello world\nagain", caret: text.length });
|
||||
|
||||
@@ -4,7 +4,7 @@ import type { FileStatus, Stash } from "@/bindings";
|
||||
import { call, commands } from "@/platform/ipc";
|
||||
import { Checkbox, Dialog, Icon, IconButton, Input, T, fileIconName } from "@/ui";
|
||||
import { notifications } from "@/workbench/contributions";
|
||||
import { groupOf, remainingOverrides, renamedFromPath } from "./changes";
|
||||
import { addedThenDeleted, groupOf, remainingOverrides, renamedFromPath } from "./changes";
|
||||
import { runCommitChecks } from "./commitChecks";
|
||||
import { contributedCheckProblems, currentPlan, selectionOf } from "./commitSelection";
|
||||
import { forgetAmendDraft, keepMessageAfterCommit, rememberMessage, useCommit } from "./commitStore";
|
||||
@@ -54,7 +54,10 @@ export async function commitChanges(): Promise<string | undefined> {
|
||||
});
|
||||
return undefined;
|
||||
}
|
||||
const candidates = plan.included.map((f) => ({ path: stripSlash(f.path), exists: effectiveKind(f) !== "deleted" }));
|
||||
const candidates = plan.included.map((f) => ({
|
||||
path: stripSlash(f.path),
|
||||
exists: effectiveKind(f) !== "deleted" && !addedThenDeleted(f),
|
||||
}));
|
||||
// IDEA: failed checks show in the commit panel; the next Commit ("Commit Anyway") skips them.
|
||||
const checked = !useCommit.getState().checkProblems.length;
|
||||
if (checked) {
|
||||
|
||||
@@ -57,6 +57,14 @@ export function groupOf(fs: FileStatus): GroupId | null {
|
||||
return "changes";
|
||||
}
|
||||
|
||||
/**
|
||||
* Added to the index, then deleted from disk: no change against HEAD, so the change list leaves
|
||||
* it out, but the staging area shows the staged addition (and the deletion, unstaged).
|
||||
*/
|
||||
export function addedThenDeleted(fs: Pick<FileStatus, "staged" | "unstaged">): boolean {
|
||||
return fs.staged === "added" && fs.unstaged === "deleted";
|
||||
}
|
||||
|
||||
export function isPartiallyStaged(fs: FileStatus): boolean {
|
||||
return (
|
||||
!!fs.staged &&
|
||||
@@ -99,7 +107,9 @@ const KIND_ORDER: GroupId[] = ["conflicts", "changes", "unversioned"];
|
||||
function fileNode(fs: FileStatus, root: string, group: GroupId, flat: boolean, scope: string = group): ChangeNode {
|
||||
const path = stripSlash(fs.path);
|
||||
const rel = relTo(root, path);
|
||||
const kind = effectiveKind(fs) ?? "modified";
|
||||
// Under Staged / Unstaged, a file without an overall kind (added, then deleted) shows its side's.
|
||||
const side = group === "staged" ? fs.staged : group === "unstaged" ? fs.unstaged : null;
|
||||
const kind = effectiveKind(fs) ?? (side === "added" || side === "deleted" ? side : "modified");
|
||||
const dir = dirName(rel);
|
||||
return {
|
||||
key: `${scope}:${path}`,
|
||||
@@ -259,7 +269,7 @@ export function buildChangeTree(
|
||||
const repoRoots = byRepo ? repos : [];
|
||||
const byGroup = new Map<GroupId, FileStatus[]>();
|
||||
for (const fs of status) {
|
||||
const g = groupOf(fs);
|
||||
const g = groupOf(fs) ?? (byStaging && addedThenDeleted(fs) ? "changes" : null);
|
||||
if (!g) continue;
|
||||
let list = byGroup.get(g);
|
||||
if (!list) byGroup.set(g, (list = []));
|
||||
@@ -400,8 +410,12 @@ export function planCommit(status: readonly FileStatus[], checks: ReadonlyMap<st
|
||||
const plan: CommitPlan = { stage: [], exclude: [], included: [], partial: [] };
|
||||
for (const fs of status) {
|
||||
if (!groupOf(fs)) {
|
||||
// Listed nowhere, yet staged: added to the index, then deleted from disk. It is no
|
||||
// change against HEAD, so the commit must not pick up the staged addition.
|
||||
// Added to the index, then deleted from disk: no change against HEAD, so the commit
|
||||
// leaves the staged addition out, unless the staging area commits it (checked "staged").
|
||||
if (addedThenDeleted(fs) && (checks.get(fs.path) ?? checks.get(stripSlash(fs.path))) === "staged") {
|
||||
plan.included.push(fs);
|
||||
continue;
|
||||
}
|
||||
if (fs.staged && fs.staged !== "conflicted" && fs.unstaged !== "ignored") plan.exclude.push(stripSlash(fs.path));
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
*/
|
||||
import type { ChangelistState, FileStatus } from "@/bindings";
|
||||
import { useWorkflowSettings, workflowSettings } from "@/platform/workflowSettings";
|
||||
import { groupOf, type CheckState } from "./changes";
|
||||
import { addedThenDeleted, groupOf, type CheckState } from "./changes";
|
||||
import { withListDefaults } from "./changelists";
|
||||
|
||||
const enabled = (vcs: { git: { stagingArea: boolean }; commit: { nonModal: boolean } }) =>
|
||||
@@ -31,6 +31,8 @@ export function stagingChecks(status: readonly FileStatus[]): Map<string, CheckS
|
||||
const all = isCommitAll(status);
|
||||
const out = new Map<string, CheckState>();
|
||||
for (const f of status) {
|
||||
// A staged addition deleted from disk is committed as staged (nothing against HEAD for Commit All).
|
||||
if (addedThenDeleted(f) && !all) out.set(f.path, "staged");
|
||||
if (groupOf(f) !== "changes") continue;
|
||||
out.set(f.path, all ? "all" : staged(f) ? "staged" : "none");
|
||||
}
|
||||
|
||||
@@ -58,29 +58,18 @@
|
||||
"Unpin Agent Tasks": "Unpin Agent Tasks",
|
||||
"New Agent Task Group": "New Agent Task Group",
|
||||
"Refresh models": "Refresh models",
|
||||
"Configure model": "Configure model",
|
||||
"Configure {name}": "Configure {name}",
|
||||
"Back to models": "Back to models",
|
||||
"Reset to defaults": "Reset to defaults",
|
||||
"Pin model": "Pin model",
|
||||
"Unpin model": "Unpin model",
|
||||
"Pinned": "Pinned",
|
||||
"Models": "Models",
|
||||
"Effort Level": "Effort Level",
|
||||
"Context Size": "Context Size",
|
||||
"Pricing details": "Pricing details",
|
||||
"Free": "Free",
|
||||
"Low cost": "Low cost",
|
||||
"Medium cost": "Medium cost",
|
||||
"High cost": "High cost",
|
||||
"Very high cost": "Very high cost",
|
||||
"Credits per 1M tokens": "Credits per 1M tokens",
|
||||
"Input": "Input",
|
||||
"Output": "Output",
|
||||
"Cache Read": "Cache Read",
|
||||
"Cache Write": "Cache Write",
|
||||
"Multiplier": "Multiplier",
|
||||
"XHigh": "XHigh",
|
||||
"model": "model",
|
||||
"Refreshing…": "Refreshing…",
|
||||
"Refresh in {seconds}s": "Refresh in {seconds}s",
|
||||
@@ -1581,6 +1570,7 @@
|
||||
"file formats": "file formats",
|
||||
"Introspecting {name}": "Introspecting {name}",
|
||||
"{database} ({position} of {count})": "{database} ({position} of {count})",
|
||||
"{count} rows": "{count} rows",
|
||||
"Introspection of {name} stopped": "Introspection of {name} stopped",
|
||||
"Introspected {name}": "Introspected {name}",
|
||||
"{total} tables and views in {read} databases are ready for completion.": "{total} tables and views in {read} databases are ready for completion.",
|
||||
@@ -1629,7 +1619,6 @@
|
||||
"Archived ({count})": "Archived ({count})",
|
||||
"Insert": "Insert",
|
||||
"Drop to reference": "Drop to reference",
|
||||
"Reference {rel}": "Reference {rel}",
|
||||
"Folder reference {name}": "Folder reference {name}",
|
||||
"File reference {name}": "File reference {name}",
|
||||
"File reference {name}, lines {lines}": "File reference {name}, lines {lines}",
|
||||
@@ -2018,8 +2007,6 @@
|
||||
"Add SDK": "Add SDK",
|
||||
"Remove SDK": "Remove SDK",
|
||||
"{rel} is added to your request": "{rel} is added to your request",
|
||||
"IDE Context Enabled: the current file and selection are added to your request": "IDE Context Enabled: the current file and selection are added to your request",
|
||||
"IDE Context Disabled: the current file and selection are not added to your request": "IDE Context Disabled: the current file and selection are not added to your request",
|
||||
"Thymeleaf": "Thymeleaf",
|
||||
"sbt": "sbt",
|
||||
"sbt actions": "sbt actions",
|
||||
@@ -2157,5 +2144,9 @@
|
||||
"Extract Interface from '{name}'": "Extract Interface from '{name}'",
|
||||
"The interface could not be extracted": "The interface could not be extracted",
|
||||
"Extract Interface is not supported for {name}": "Extract Interface is not supported for {name}",
|
||||
"Package for new interface": "Package for new interface"
|
||||
"Package for new interface": "Package for new interface",
|
||||
"Untitled files were not saved": "Untitled files were not saved",
|
||||
"Missing blank line between subject and body": "Missing blank line between subject and body",
|
||||
"Body line {0} is longer than {1} characters": "Body line {0} is longer than {1} characters",
|
||||
"Add blank line": "Add blank line"
|
||||
}
|
||||
@@ -3496,7 +3496,6 @@
|
||||
"Not installed": "No instalado",
|
||||
"{command} was not found on PATH": "No se encontró {command} en PATH",
|
||||
"Agent tasks": "Tareas de agente",
|
||||
"Describe a task for the agent. @ references a file or folder, / runs a command": "Describe una tarea para el agente. @ referencia un archivo o carpeta, / ejecuta un comando",
|
||||
"away from your changes": "separado de tus cambios",
|
||||
"edits your files directly": "edita tus archivos directamente",
|
||||
"from": "desde",
|
||||
|
||||
@@ -3369,7 +3369,6 @@
|
||||
"Not installed": "Non installé",
|
||||
"{command} was not found on PATH": "{command} est introuvable dans le PATH",
|
||||
"Agent tasks": "Tâches d'agent",
|
||||
"Describe a task for the agent. @ references a file or folder, / runs a command": "Décrivez une tâche pour l'agent. @ référence un fichier ou un dossier, / lance une commande",
|
||||
"away from your changes": "à l'écart de vos modifications",
|
||||
"edits your files directly": "modifie directement vos fichiers",
|
||||
"from": "depuis",
|
||||
|
||||
@@ -3546,7 +3546,6 @@
|
||||
"Not installed": "설치되지 않음",
|
||||
"{command} was not found on PATH": "PATH에서 {command}을(를) 찾을 수 없습니다",
|
||||
"Agent tasks": "에이전트 작업",
|
||||
"Describe a task for the agent. @ references a file or folder, / runs a command": "에이전트에게 맡길 작업을 설명하세요. @는 파일·폴더 참조, /는 명령 실행",
|
||||
"away from your changes": "변경 사항과 분리됨",
|
||||
"edits your files directly": "파일을 직접 편집함",
|
||||
"from": "기준",
|
||||
@@ -6224,7 +6223,6 @@
|
||||
"Count rows": "행 개수 세기",
|
||||
"Last Page": "마지막 페이지",
|
||||
"{first}-{last} of {total}": "{total}개 중 {first}-{last}",
|
||||
"Model & effort settings": "모델 및 추론 강도 설정",
|
||||
"Device": "기기",
|
||||
"No devices": "기기 없음",
|
||||
"Minimum level": "최소 수준",
|
||||
|
||||
Loaded 100 of 106 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Заблокувати користувача