mirror of
https://github.com/zed-industries/zed.git
synced 2026-12-03 23:13:21 +01:00
Update Student plan copy (#66890)
Update Student plan descriptions. Release Notes: - Improved Student plan descriptions. --------- Co-authored-by: morgankrey <4828503+morgankrey@users.noreply.github.com>
This commit is contained in:
1 parent
17fe8c6117
commit
2b248e6072
8 files changed
+697
-48
No files matched your search
@@ -99,7 +99,7 @@ gpui = { workspace = true, "features" = ["test-support"] }
|
||||
gpui_tokio.workspace = true
|
||||
language = { workspace = true, "features" = ["test-support"] }
|
||||
language_model = { workspace = true, "features" = ["test-support"] }
|
||||
language_models.workspace = true
|
||||
language_models = { workspace = true, features = ["test-support"] }
|
||||
lsp = { workspace = true, "features" = ["test-support"] }
|
||||
pretty_assertions.workspace = true
|
||||
project = { workspace = true, "features" = ["test-support"] }
|
||||
|
||||
@@ -9408,6 +9408,387 @@ mod internal_tests {
|
||||
drop(reloaded_acp_thread);
|
||||
}
|
||||
|
||||
#[gpui::test]
|
||||
async fn test_loaded_thread_can_continue_after_saved_model_is_removed(cx: &mut TestAppContext) {
|
||||
init_test(cx);
|
||||
let (agent, connection, project, session_id, original_provider) =
|
||||
persist_thread_with_fake_corp_model(cx).await;
|
||||
original_provider.forbid_requests();
|
||||
|
||||
// The same provider now offers Luna but no longer offers the saved model.
|
||||
unregister_fake_corp(cx);
|
||||
let provider = Arc::new(FakeLanguageModelProvider::new(
|
||||
LanguageModelProviderId::from("fake-corp".to_string()),
|
||||
LanguageModelProviderName::from("Fake Corp".to_string()),
|
||||
));
|
||||
let luna = provider.update_model("gpt-6-luna", |model| {
|
||||
model.name = LanguageModelName::from("GPT-6 Luna".to_string());
|
||||
});
|
||||
cx.update(|cx| {
|
||||
LanguageModelRegistry::global(cx).update(cx, |registry, cx| {
|
||||
registry.register_provider(provider.clone(), cx);
|
||||
});
|
||||
});
|
||||
cx.run_until_parked();
|
||||
|
||||
let reloaded_acp_thread = agent
|
||||
.update(cx, |agent, cx| {
|
||||
agent.open_thread(session_id.clone(), project.clone(), cx)
|
||||
})
|
||||
.await
|
||||
.unwrap();
|
||||
let thread = cx.update(|cx| native_thread_for_session(&agent, &session_id, cx));
|
||||
thread.read_with(cx, |thread, _| {
|
||||
assert!(thread.model().is_none());
|
||||
});
|
||||
|
||||
let selector = connection.model_selector(&session_id).unwrap();
|
||||
let models = cx.update(|cx| selector.list_models(cx)).await.unwrap();
|
||||
let acp_thread::AgentModelList::Grouped(models) = models else {
|
||||
panic!("Unexpected model group");
|
||||
};
|
||||
let luna_id = AgentModelId::new("fake-corp/gpt-6-luna");
|
||||
assert!(models.values().flatten().any(|model| model.id == luna_id));
|
||||
let removed_model_id = AgentModelId::new("fake-corp/custom-model-id");
|
||||
assert!(
|
||||
!models
|
||||
.values()
|
||||
.flatten()
|
||||
.any(|model| model.id == removed_model_id)
|
||||
);
|
||||
|
||||
cx.update(|cx| selector.select_model(luna_id, cx))
|
||||
.await
|
||||
.unwrap();
|
||||
thread.read_with(cx, |thread, _| {
|
||||
assert_eq!(thread.model().unwrap().id(), luna.id());
|
||||
});
|
||||
|
||||
let send =
|
||||
reloaded_acp_thread.update(cx, |thread, cx| thread.send(vec!["Continue.".into()], cx));
|
||||
let send = cx.foreground_executor().spawn(send);
|
||||
cx.run_until_parked();
|
||||
|
||||
let requests = provider.pending_completions_for(&luna);
|
||||
let [request] = requests.as_slice() else {
|
||||
panic!("Expected one continuation request to Luna");
|
||||
};
|
||||
let history = request_texts_after_system(&request.messages);
|
||||
let mut history = history.iter();
|
||||
assert!(history.any(|message| message.contains("Hello")));
|
||||
assert!(history.any(|message| message == "Response."));
|
||||
assert!(history.any(|message| message.contains("Continue.")));
|
||||
|
||||
provider.send_last_text(&luna, "Continued with Luna.");
|
||||
provider.end_last(&luna);
|
||||
send.await.unwrap();
|
||||
cx.run_until_parked();
|
||||
|
||||
let saved = thread.read_with(cx, |thread, cx| thread.to_db(cx)).await;
|
||||
assert_eq!(saved.model.unwrap().model, "gpt-6-luna");
|
||||
assert!(
|
||||
serde_json::to_string(&saved.messages)
|
||||
.unwrap()
|
||||
.contains("Continued with Luna.")
|
||||
);
|
||||
}
|
||||
|
||||
#[gpui::test]
|
||||
async fn test_open_thread_can_continue_after_hosted_catalog_changes(cx: &mut TestAppContext) {
|
||||
use client::{Client, Credentials, RefreshLlmTokenListener, UserStore};
|
||||
use futures::AsyncReadExt as _;
|
||||
use http_client::{FakeHttpClient, Response};
|
||||
use language_models::provider::cloud::{CloudLanguageModelProvider, test_support};
|
||||
|
||||
init_test(cx);
|
||||
let requests = Arc::new(parking_lot::Mutex::new(Vec::<serde_json::Value>::new()));
|
||||
let reject_claude = Arc::new(std::sync::atomic::AtomicBool::new(false));
|
||||
let http = FakeHttpClient::create({
|
||||
let requests = requests.clone();
|
||||
let reject_claude = reject_claude.clone();
|
||||
move |mut request| {
|
||||
let requests = requests.clone();
|
||||
let reject_claude = reject_claude.clone();
|
||||
async move {
|
||||
let body = match request.uri().path() {
|
||||
"/client/users/me" => {
|
||||
let mut user = client::test::make_get_authenticated_user_response(
|
||||
42,
|
||||
"student".into(),
|
||||
);
|
||||
user.plan.plan = cloud_api_types::KnownOrUnknown::Known(
|
||||
cloud_api_types::Plan::ZedStudent,
|
||||
);
|
||||
let organization_id =
|
||||
cloud_api_types::OrganizationId("org_student".into());
|
||||
user.organizations.push(cloud_api_types::Organization {
|
||||
id: organization_id.clone(),
|
||||
name: "Student".into(),
|
||||
is_personal: true,
|
||||
ui_permissions: Default::default(),
|
||||
});
|
||||
user.default_organization_id = Some(organization_id);
|
||||
serde_json::to_string(&user)?
|
||||
}
|
||||
"/client/llm_tokens" => json!({"token": "test-token"}).to_string(),
|
||||
"/models" => json!({
|
||||
"models": [],
|
||||
"default_model": null,
|
||||
"default_fast_model": null,
|
||||
"recommended_models": [],
|
||||
})
|
||||
.to_string(),
|
||||
"/completions" => {
|
||||
let mut body = String::new();
|
||||
request.body_mut().read_to_string(&mut body).await?;
|
||||
let request: serde_json::Value = serde_json::from_str(&body)?;
|
||||
let anthropic = request["model"] == "claude-opus-4-6";
|
||||
requests.lock().push(request);
|
||||
if anthropic && reject_claude.load(std::sync::atomic::Ordering::SeqCst)
|
||||
{
|
||||
return Ok(Response::builder().status(403).body(
|
||||
json!({"error": "This model is not available on your plan"})
|
||||
.to_string()
|
||||
.into(),
|
||||
)?);
|
||||
}
|
||||
if anthropic {
|
||||
[
|
||||
json!({"type": "message_start", "message": {"id": "msg_test", "type": "message", "role": "assistant", "content": [], "model": "claude-opus-4-6", "stop_reason": null, "stop_sequence": null, "usage": {"input_tokens": 10, "output_tokens": 0}}}),
|
||||
json!({"type": "content_block_start", "index": 0, "content_block": {"type": "text", "text": ""}}),
|
||||
json!({"type": "content_block_delta", "index": 0, "delta": {"type": "text_delta", "text": "Response."}}),
|
||||
json!({"type": "content_block_stop", "index": 0}),
|
||||
json!({"type": "message_delta", "delta": {"stop_reason": "end_turn", "stop_sequence": null}, "usage": {"output_tokens": 1}}),
|
||||
json!({"type": "message_stop"}),
|
||||
].into_iter().map(|event| format!("{}\n", json!({"event": event})))
|
||||
.chain(std::iter::once(format!("{}\n", json!({"status": "stream_ended"}))))
|
||||
.collect()
|
||||
} else {
|
||||
format!(
|
||||
"{}\n{}\n{}\n",
|
||||
json!({"event": {"type": "response.output_text.delta", "item_id": "msg_luna", "output_index": 0, "delta": "Continued with Luna."}}),
|
||||
json!({"event": {"type": "response.completed", "response": {"id": "resp_luna", "status": "completed", "output": []}}}),
|
||||
json!({"status": "stream_ended"}),
|
||||
)
|
||||
}
|
||||
}
|
||||
"/count_tokens" => json!({"tokens": 10}).to_string(),
|
||||
_ => {
|
||||
return Ok(Response::builder()
|
||||
.status(404)
|
||||
.body("not mocked".into())?);
|
||||
}
|
||||
};
|
||||
Ok(Response::builder()
|
||||
.status(200)
|
||||
.header(
|
||||
cloud_llm_client::SERVER_SUPPORTS_STATUS_MESSAGES_HEADER_NAME,
|
||||
"true",
|
||||
)
|
||||
.body(body.into())?)
|
||||
}
|
||||
}
|
||||
});
|
||||
let (client, provider) = cx.update(|cx| {
|
||||
cx.set_global(::db::AppDatabase::test_new());
|
||||
gpui_tokio::init(cx);
|
||||
let client = Client::new(Arc::new(clock::FakeSystemClock::new()), http, cx);
|
||||
client.override_authenticate(|cx| {
|
||||
cx.spawn(async |_| {
|
||||
Ok(Credentials {
|
||||
user_id: 42,
|
||||
access_token: "test".into(),
|
||||
})
|
||||
})
|
||||
});
|
||||
let users = cx.new(|cx| UserStore::new(client.clone(), cx));
|
||||
RefreshLlmTokenListener::register(client.clone(), users.clone(), cx);
|
||||
let provider = Arc::new(CloudLanguageModelProvider::new(users, client.clone(), cx));
|
||||
LanguageModelRegistry::global(cx).update(cx, |registry, cx| {
|
||||
registry.register_provider(provider.clone(), cx);
|
||||
});
|
||||
(client, provider)
|
||||
});
|
||||
cx.update(|cx| cx.spawn(async move |cx| client.sign_in(false, cx).await))
|
||||
.await
|
||||
.unwrap();
|
||||
cx.run_until_parked();
|
||||
assert!(cx.read(|cx| provider.is_authenticated(cx)));
|
||||
|
||||
let config = |id: &str| cloud_llm_client::LanguageModel {
|
||||
provider: if id == "claude-opus-4-6" {
|
||||
cloud_llm_client::LanguageModelProvider::Anthropic
|
||||
} else {
|
||||
cloud_llm_client::LanguageModelProvider::OpenAi
|
||||
},
|
||||
id: cloud_llm_client::LanguageModelId(id.into()),
|
||||
display_name: id.into(),
|
||||
is_latest: true,
|
||||
max_token_count: 200_000,
|
||||
max_token_count_in_max_mode: None,
|
||||
max_output_tokens: 8_192,
|
||||
supports_tools: true,
|
||||
supports_images: false,
|
||||
supports_thinking: false,
|
||||
supports_disabling_thinking: false,
|
||||
supports_fast_mode: false,
|
||||
supports_server_side_compaction: false,
|
||||
supported_effort_levels: Vec::new(),
|
||||
supports_streaming_tools: false,
|
||||
supports_parallel_tool_calls: false,
|
||||
is_disabled: false,
|
||||
disabled_reason: None,
|
||||
};
|
||||
let catalog = |id: &str| cloud_llm_client::ListModelsResponse {
|
||||
models: vec![config(id)],
|
||||
default_model: Some(cloud_llm_client::LanguageModelId(id.into())),
|
||||
default_fast_model: Some(cloud_llm_client::LanguageModelId(id.into())),
|
||||
recommended_models: Vec::new(),
|
||||
};
|
||||
let mut initial_catalog = catalog("claude-opus-4-6");
|
||||
initial_catalog.models.push(config("gpt-6-luna"));
|
||||
cx.update(|cx| test_support::update_models(&provider, initial_catalog, cx));
|
||||
cx.run_until_parked();
|
||||
|
||||
let fs = FakeFs::new(cx.executor());
|
||||
fs.insert_tree("/", json!({"a": {}})).await;
|
||||
let project = Project::test(fs.clone(), [path!("/a").as_ref()], cx).await;
|
||||
let store = cx.new(ThreadStore::new);
|
||||
let agent = cx.update(|cx| NativeAgent::new(store, Templates::new(), fs, cx));
|
||||
let connection = Rc::new(NativeAgentConnection(agent.clone()));
|
||||
let acp_thread = cx
|
||||
.update(|cx| {
|
||||
connection
|
||||
.clone()
|
||||
.new_session(project, PathList::new(&[Path::new("/a")]), cx)
|
||||
})
|
||||
.await
|
||||
.unwrap();
|
||||
let session_id = acp_thread.read_with(cx, |thread, _| thread.session_id().clone());
|
||||
let thread = cx.update(|cx| native_thread_for_session(&agent, &session_id, cx));
|
||||
let selector = connection.model_selector(&session_id).unwrap();
|
||||
cx.update(|cx| selector.select_model(AgentModelId::new("zed.dev/claude-opus-4-6"), cx))
|
||||
.await
|
||||
.unwrap();
|
||||
let profile_id = agent_settings::AgentProfileId("saved-claude".into());
|
||||
cx.update(|cx| {
|
||||
let mut settings = agent_settings::AgentSettings::get_global(cx).clone();
|
||||
let mut profile = settings.profiles.values().next().unwrap().clone();
|
||||
profile.default_model = Some(LanguageModelSelection {
|
||||
provider: "zed.dev".to_string().into(),
|
||||
model: "claude-opus-4-6".into(),
|
||||
enable_thinking: false,
|
||||
effort: None,
|
||||
speed: None,
|
||||
});
|
||||
settings.profiles.insert(profile_id.clone(), profile);
|
||||
agent_settings::AgentSettings::override_global(settings, cx);
|
||||
});
|
||||
thread.update(cx, |thread, cx| thread.set_profile(profile_id.clone(), cx));
|
||||
acp_thread
|
||||
.update(cx, |thread, cx| thread.send(vec!["Hello".into()], cx))
|
||||
.await
|
||||
.unwrap();
|
||||
cx.run_until_parked();
|
||||
assert_eq!(requests.lock().len(), 1);
|
||||
assert!(!acp_thread.read_with(cx, |thread, _| thread.had_error()));
|
||||
|
||||
// A plain access rejection does not itself update the allowed-model list.
|
||||
reject_claude.store(true, std::sync::atomic::Ordering::SeqCst);
|
||||
acp_thread
|
||||
.update(cx, |thread, cx| {
|
||||
thread.send(vec!["Before catalog refresh".into()], cx)
|
||||
})
|
||||
.await
|
||||
.unwrap();
|
||||
cx.run_until_parked();
|
||||
assert!(acp_thread.read_with(cx, |thread, _| thread.had_error()));
|
||||
assert_eq!(requests.lock().len(), 2, "ordinary 403 must not retry");
|
||||
assert!(cx.read(|cx| {
|
||||
provider
|
||||
.provided_models(cx)
|
||||
.iter()
|
||||
.any(|model| model.id().0.as_ref() == "claude-opus-4-6")
|
||||
}));
|
||||
|
||||
// Exercise the observable cloud-provider path without closing the session.
|
||||
cx.update(|cx| test_support::update_models(&provider, catalog("gpt-6-luna"), cx));
|
||||
cx.run_until_parked();
|
||||
thread.read_with(cx, |thread, _| {
|
||||
assert_eq!(thread.model().unwrap().id().0.as_ref(), "claude-opus-4-6");
|
||||
});
|
||||
acp_thread
|
||||
.update(cx, |thread, cx| {
|
||||
thread.send(vec!["Try old model".into()], cx)
|
||||
})
|
||||
.await
|
||||
.unwrap();
|
||||
cx.run_until_parked();
|
||||
assert!(acp_thread.read_with(cx, |thread, _| thread.had_error()));
|
||||
assert_eq!(
|
||||
requests.lock().len(),
|
||||
2,
|
||||
"removed model must not reach HTTP"
|
||||
);
|
||||
|
||||
let acp_thread::AgentModelList::Grouped(models) =
|
||||
cx.update(|cx| selector.list_models(cx)).await.unwrap()
|
||||
else {
|
||||
panic!("Expected grouped models");
|
||||
};
|
||||
assert!(
|
||||
models
|
||||
.values()
|
||||
.flatten()
|
||||
.any(|model| model.id.as_ref() == "zed.dev/gpt-6-luna")
|
||||
);
|
||||
assert!(
|
||||
!models
|
||||
.values()
|
||||
.flatten()
|
||||
.any(|model| model.id.as_ref() == "zed.dev/claude-opus-4-6")
|
||||
);
|
||||
cx.update(|cx| selector.select_model(AgentModelId::new("zed.dev/gpt-6-luna"), cx))
|
||||
.await
|
||||
.unwrap();
|
||||
thread.update(cx, |thread, cx| {
|
||||
thread.set_profile(agent_settings::AgentProfileId::default(), cx);
|
||||
thread.set_profile(profile_id, cx);
|
||||
assert_eq!(thread.model().unwrap().id().0.as_ref(), "gpt-6-luna");
|
||||
});
|
||||
acp_thread
|
||||
.update(cx, |thread, cx| thread.send(vec!["Continue".into()], cx))
|
||||
.await
|
||||
.unwrap();
|
||||
cx.run_until_parked();
|
||||
assert!(!acp_thread.read_with(cx, |thread, _| thread.had_error()));
|
||||
{
|
||||
let requests = requests.lock();
|
||||
assert_eq!(requests.len(), 3);
|
||||
let continuation = requests.last().unwrap();
|
||||
assert_eq!(continuation["model"], "gpt-6-luna");
|
||||
let history = continuation["provider_request"]["input"].to_string();
|
||||
assert!(history.contains("Hello"));
|
||||
assert!(history.contains("Response."));
|
||||
assert!(history.contains("Continue"));
|
||||
assert!(history.find("Hello").unwrap() < history.find("Response.").unwrap());
|
||||
assert!(history.find("Response.").unwrap() < history.find("Continue").unwrap());
|
||||
}
|
||||
assert_eq!(
|
||||
thread
|
||||
.read_with(cx, |thread, _| thread.model().unwrap().id().0)
|
||||
.as_ref(),
|
||||
"gpt-6-luna"
|
||||
);
|
||||
let saved = thread.read_with(cx, |thread, cx| thread.to_db(cx)).await;
|
||||
assert_eq!(saved.model.unwrap().model, "gpt-6-luna");
|
||||
assert!(
|
||||
serde_json::to_string(&saved.messages)
|
||||
.unwrap()
|
||||
.contains("Continued with Luna.")
|
||||
);
|
||||
}
|
||||
|
||||
#[gpui::test]
|
||||
async fn test_save_load_thread(cx: &mut TestAppContext) {
|
||||
let fake = init_test(cx);
|
||||
|
||||
@@ -1029,6 +1029,136 @@ mod tests {
|
||||
DockPosition, NotifyWhenAgentWaiting, PlaySoundWhenAgentDone, Settings, SettingsStore,
|
||||
};
|
||||
|
||||
#[gpui::test]
|
||||
fn test_removed_saved_hosted_default_and_background_model_recovery(cx: &mut TestAppContext) {
|
||||
use language_model::{
|
||||
LanguageModelProvider, LanguageModelProviderName,
|
||||
fake_provider::FakeLanguageModelProvider,
|
||||
};
|
||||
|
||||
let hosted = Arc::new(FakeLanguageModelProvider::new(
|
||||
language_model::ZED_CLOUD_PROVIDER_ID,
|
||||
language_model::ZED_CLOUD_PROVIDER_NAME,
|
||||
));
|
||||
let claude = hosted.update_model("fake", |model| {
|
||||
model.id = LanguageModelId("claude-opus-4-6".into());
|
||||
model.name = "Claude Opus 4.6".to_string().into();
|
||||
});
|
||||
let personal = Arc::new(FakeLanguageModelProvider::new(
|
||||
LanguageModelProviderId("personal".into()),
|
||||
LanguageModelProviderName("Personal API key".into()),
|
||||
));
|
||||
let personal_model = personal.model("personal-model");
|
||||
let selection = |provider: &str, model: &str| LanguageModelSelection {
|
||||
provider: provider.to_string().into(),
|
||||
model: model.to_string(),
|
||||
enable_thinking: false,
|
||||
effort: None,
|
||||
speed: None,
|
||||
};
|
||||
cx.update(|cx| {
|
||||
let store = SettingsStore::test(cx);
|
||||
cx.set_global(store);
|
||||
AgentSettings::register(cx);
|
||||
language_model::init(cx);
|
||||
LanguageModelRegistry::global(cx).update(cx, |registry, cx| {
|
||||
registry.register_provider(hosted.clone(), cx);
|
||||
registry.register_provider(personal.clone(), cx);
|
||||
});
|
||||
cx.update_global::<SettingsStore, _>(|store, cx| {
|
||||
store.update_user_settings(cx, |settings| {
|
||||
let agent = settings.agent.get_or_insert_default();
|
||||
agent.default_model = Some(selection("zed.dev", "claude-opus-4-6"));
|
||||
});
|
||||
});
|
||||
init_language_model_settings(cx);
|
||||
let registry = LanguageModelRegistry::read_global(cx);
|
||||
assert_eq!(registry.default_model().unwrap().id(), claude.id());
|
||||
assert_eq!(registry.default_fast_model(cx).unwrap().id(), claude.id());
|
||||
assert_eq!(registry.commit_message_model(cx).unwrap().id(), claude.id());
|
||||
});
|
||||
cx.run_until_parked();
|
||||
|
||||
let luna_only = Arc::new(FakeLanguageModelProvider::new(
|
||||
language_model::ZED_CLOUD_PROVIDER_ID,
|
||||
language_model::ZED_CLOUD_PROVIDER_NAME,
|
||||
));
|
||||
let luna = luna_only.update_model("fake", |model| {
|
||||
model.id = LanguageModelId("gpt-6-luna".into());
|
||||
model.name = "GPT-6 Luna".to_string().into();
|
||||
});
|
||||
cx.update(|cx| {
|
||||
LanguageModelRegistry::global(cx).update(cx, |registry, cx| {
|
||||
registry.register_provider(luna_only.clone(), cx);
|
||||
});
|
||||
});
|
||||
cx.run_until_parked();
|
||||
cx.read(|cx| {
|
||||
let registry = LanguageModelRegistry::read_global(cx);
|
||||
assert!(luna_only.default_fast_model(cx).is_some());
|
||||
assert!(registry.default_model().is_none());
|
||||
assert!(registry.default_fast_model(cx).is_none());
|
||||
assert!(registry.commit_message_model(cx).is_none());
|
||||
assert!(registry.thread_summary_model(cx).is_none());
|
||||
assert!(registry.inline_assistant_model().is_none());
|
||||
assert_eq!(
|
||||
AgentSettings::get_global(cx)
|
||||
.default_model
|
||||
.as_ref()
|
||||
.unwrap()
|
||||
.model,
|
||||
"claude-opus-4-6",
|
||||
"catalog updates must not rewrite saved preferences"
|
||||
);
|
||||
assert!(registry.provider_for_model(&personal_model).is_ok());
|
||||
});
|
||||
|
||||
// Explicitly changing the saved default restores background selection.
|
||||
cx.update(|cx| {
|
||||
cx.update_global::<SettingsStore, _>(|store, cx| {
|
||||
store.update_user_settings(cx, |settings| {
|
||||
let agent = settings.agent.get_or_insert_default();
|
||||
agent.default_model = Some(selection("zed.dev", "gpt-6-luna"));
|
||||
agent.commit_message_model = Some(selection("zed.dev", "claude-opus-4-6"));
|
||||
});
|
||||
});
|
||||
});
|
||||
cx.run_until_parked();
|
||||
cx.read(|cx| {
|
||||
let registry = LanguageModelRegistry::read_global(cx);
|
||||
assert_eq!(registry.default_model().unwrap().id(), luna.id());
|
||||
assert_eq!(registry.default_fast_model(cx).unwrap().id(), luna.id());
|
||||
assert_eq!(registry.commit_message_model(cx).unwrap().id(), luna.id());
|
||||
assert_eq!(registry.thread_summary_model(cx).unwrap().id(), luna.id());
|
||||
});
|
||||
|
||||
// A personal default and explicit background override remain independent.
|
||||
cx.update(|cx| {
|
||||
cx.update_global::<SettingsStore, _>(|store, cx| {
|
||||
store.update_user_settings(cx, |settings| {
|
||||
let agent = settings.agent.get_or_insert_default();
|
||||
agent.default_model = Some(selection("personal", "personal-model"));
|
||||
agent.commit_message_model = Some(selection("personal", "personal-model"));
|
||||
});
|
||||
});
|
||||
LanguageModelRegistry::global(cx).update(cx, |registry, cx| {
|
||||
registry.register_provider(luna_only, cx);
|
||||
});
|
||||
});
|
||||
cx.run_until_parked();
|
||||
cx.read(|cx| {
|
||||
let registry = LanguageModelRegistry::read_global(cx);
|
||||
assert_eq!(
|
||||
registry.default_model().unwrap().provider_id(),
|
||||
personal.id()
|
||||
);
|
||||
assert_eq!(
|
||||
registry.commit_message_model(cx).unwrap().provider_id(),
|
||||
personal.id()
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
#[gpui::test]
|
||||
fn test_agent_command_palette_visibility(cx: &mut TestAppContext) {
|
||||
// Init settings
|
||||
|
||||
@@ -53,7 +53,7 @@ impl PlanDefinitions {
|
||||
pub fn student_plan(&self) -> impl IntoElement {
|
||||
List::new()
|
||||
.child(ListBulletItem::new("Unlimited edit predictions"))
|
||||
.child(ListBulletItem::new("$10 of tokens in Zed agent"))
|
||||
.child(ListBulletItem::new("$10/month in GPT Luna credits"))
|
||||
.child(ListBulletItem::new(
|
||||
"Optional credit packs for additional usage",
|
||||
))
|
||||
|
||||
@@ -86,6 +86,7 @@ git = { workspace = true, features = ["test-support"] }
|
||||
gpui = { workspace = true, features = ["test-support"] }
|
||||
indoc.workspace = true
|
||||
language = { workspace = true, features = ["test-support"] }
|
||||
language_model = { workspace = true, features = ["test-support"] }
|
||||
pretty_assertions.workspace = true
|
||||
project = { workspace = true, features = ["test-support"] }
|
||||
rand.workspace = true
|
||||
|
||||
+164
-44
@@ -55,9 +55,9 @@ use git::{
|
||||
use gpui::{
|
||||
AbsoluteLength, Action, Anchor, AnyElement, AsyncApp, AsyncWindowContext, ClickEvent,
|
||||
ClipboardItem, DismissEvent, Empty, Entity, EventEmitter, FocusHandle, Focusable, KeyContext,
|
||||
MouseButton, MouseDownEvent, Pixels, Point, PromptLevel, ScrollStrategy, Subscription, Task,
|
||||
TaskExt, TextStyle, UniformListScrollHandle, WeakEntity, actions, anchored, deferred,
|
||||
uniform_list,
|
||||
MouseButton, MouseDownEvent, Pixels, Point, PromptLevel, ReadGlobal, ScrollStrategy,
|
||||
Subscription, Task, TaskExt, TextStyle, UniformListScrollHandle, WeakEntity, actions, anchored,
|
||||
deferred, uniform_list,
|
||||
};
|
||||
use itertools::Itertools;
|
||||
use language::{Buffer, BufferEvent, File};
|
||||
@@ -6940,7 +6940,8 @@ impl GitPanel {
|
||||
|
||||
let button = if can_commit && has_commit_model_configuration_error {
|
||||
button.hoverable_tooltip(move |_window, cx| {
|
||||
cx.new(|_| GenerateCommitMessageConfigurationTooltip).into()
|
||||
cx.new(|cx| GenerateCommitMessageConfigurationTooltip::new(cx))
|
||||
.into()
|
||||
})
|
||||
} else {
|
||||
button.tooltip(move |_window, cx| {
|
||||
@@ -9934,49 +9935,96 @@ impl GitPanel {
|
||||
}
|
||||
}
|
||||
|
||||
struct GenerateCommitMessageConfigurationTooltip;
|
||||
enum GenerateCommitMessageConfigurationTooltip {
|
||||
ConfigureProvider,
|
||||
SavedModelUnavailable,
|
||||
}
|
||||
|
||||
impl GenerateCommitMessageConfigurationTooltip {
|
||||
fn new(cx: &App) -> Self {
|
||||
let registry = LanguageModelRegistry::read_global(cx);
|
||||
if registry.commit_message_model(cx).is_some() {
|
||||
return Self::ConfigureProvider;
|
||||
}
|
||||
let Some(agent) = SettingsStore::global(cx)
|
||||
.raw_user_settings()
|
||||
.and_then(|settings| settings.content.agent.as_ref())
|
||||
else {
|
||||
return Self::ConfigureProvider;
|
||||
};
|
||||
|
||||
let mut saved_model_unavailable = false;
|
||||
for selection in [
|
||||
agent.commit_message_model.as_ref(),
|
||||
agent.default_model.as_ref(),
|
||||
]
|
||||
.into_iter()
|
||||
.flatten()
|
||||
{
|
||||
let provider_id =
|
||||
language_model::LanguageModelProviderId(selection.provider.0.clone().into());
|
||||
let Some(provider) = registry.provider(&provider_id) else {
|
||||
return Self::ConfigureProvider;
|
||||
};
|
||||
if !provider.is_authenticated(cx) {
|
||||
return Self::ConfigureProvider;
|
||||
}
|
||||
saved_model_unavailable |= !provider
|
||||
.provided_models(cx)
|
||||
.iter()
|
||||
.any(|model| model.id().0.as_ref() == selection.model.as_str());
|
||||
}
|
||||
|
||||
if saved_model_unavailable {
|
||||
Self::SavedModelUnavailable
|
||||
} else {
|
||||
Self::ConfigureProvider
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Render for GenerateCommitMessageConfigurationTooltip {
|
||||
fn render(&mut self, _window: &mut Window, cx: &mut Context<Self>) -> impl IntoElement {
|
||||
ui::tooltip_container(cx, |container, _cx| {
|
||||
container
|
||||
.gap_1p5()
|
||||
.child(Label::new(
|
||||
"Configure an LLM provider to generate commit messages.",
|
||||
))
|
||||
.child(
|
||||
h_flex()
|
||||
.gap_1()
|
||||
.child(
|
||||
Button::new("configure-commit-message-provider", "Configure Provider")
|
||||
.style(ButtonStyle::Filled)
|
||||
.layer(ElevationIndex::ModalSurface)
|
||||
.label_size(LabelSize::Small)
|
||||
.on_click(|_, window, cx| {
|
||||
window.dispatch_action(
|
||||
zed_actions::OpenSettingsAt {
|
||||
path: "llm_providers".to_string(),
|
||||
target: None,
|
||||
}
|
||||
.boxed_clone(),
|
||||
cx,
|
||||
);
|
||||
}),
|
||||
)
|
||||
.child(
|
||||
Button::new("llm-provider-docs", "See Docs")
|
||||
.style(ButtonStyle::OutlinedGhost)
|
||||
.end_icon(
|
||||
Icon::new(IconName::ArrowUpRight)
|
||||
.color(Color::Muted)
|
||||
.size(IconSize::Small),
|
||||
)
|
||||
.label_size(LabelSize::Small)
|
||||
.on_click(move |_, _, cx| {
|
||||
cx.open_url(&zed_urls::llm_provider_docs(cx))
|
||||
}),
|
||||
),
|
||||
)
|
||||
let description = match self {
|
||||
Self::ConfigureProvider => "Configure an LLM provider to generate commit messages.",
|
||||
Self::SavedModelUnavailable => {
|
||||
"Your saved model is unavailable. Choose another model in the Agent panel."
|
||||
}
|
||||
};
|
||||
ui::tooltip_container(cx, move |container, _cx| {
|
||||
container.gap_1p5().child(Label::new(description)).child(
|
||||
h_flex()
|
||||
.gap_1()
|
||||
.child(
|
||||
Button::new("configure-commit-message-provider", "Configure Provider")
|
||||
.style(ButtonStyle::Filled)
|
||||
.layer(ElevationIndex::ModalSurface)
|
||||
.label_size(LabelSize::Small)
|
||||
.on_click(|_, window, cx| {
|
||||
window.dispatch_action(
|
||||
zed_actions::OpenSettingsAt {
|
||||
path: "llm_providers".to_string(),
|
||||
target: None,
|
||||
}
|
||||
.boxed_clone(),
|
||||
cx,
|
||||
);
|
||||
}),
|
||||
)
|
||||
.child(
|
||||
Button::new("llm-provider-docs", "See Docs")
|
||||
.style(ButtonStyle::OutlinedGhost)
|
||||
.end_icon(
|
||||
Icon::new(IconName::ArrowUpRight)
|
||||
.color(Color::Muted)
|
||||
.size(IconSize::Small),
|
||||
)
|
||||
.label_size(LabelSize::Small)
|
||||
.on_click(move |_, _, cx| {
|
||||
cx.open_url(&zed_urls::llm_provider_docs(cx))
|
||||
}),
|
||||
),
|
||||
)
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -10821,6 +10869,78 @@ mod tests {
|
||||
});
|
||||
}
|
||||
|
||||
#[gpui::test]
|
||||
fn test_commit_generation_hint_distinguishes_unavailable_saved_model(cx: &mut TestAppContext) {
|
||||
use language_model::{
|
||||
ZED_CLOUD_PROVIDER_ID, ZED_CLOUD_PROVIDER_NAME,
|
||||
fake_provider::FakeLanguageModelProvider,
|
||||
};
|
||||
|
||||
init_test(cx);
|
||||
cx.update(|cx| {
|
||||
assert!(matches!(
|
||||
GenerateCommitMessageConfigurationTooltip::new(cx),
|
||||
GenerateCommitMessageConfigurationTooltip::ConfigureProvider,
|
||||
));
|
||||
SettingsStore::update_global(cx, |store, cx| {
|
||||
store.set_user_settings(
|
||||
r#"{"agent":{"default_model":{"provider":"zed.dev","model":"claude-opus-4-6"}}}"#,
|
||||
cx,
|
||||
).unwrap();
|
||||
});
|
||||
assert!(matches!(
|
||||
GenerateCommitMessageConfigurationTooltip::new(cx),
|
||||
GenerateCommitMessageConfigurationTooltip::ConfigureProvider,
|
||||
), "a missing provider still needs provider setup");
|
||||
|
||||
let provider = Arc::new(FakeLanguageModelProvider::new(
|
||||
ZED_CLOUD_PROVIDER_ID, ZED_CLOUD_PROVIDER_NAME,
|
||||
));
|
||||
LanguageModelRegistry::global(cx).update(cx, |registry, cx| {
|
||||
registry.register_provider(provider, cx);
|
||||
});
|
||||
});
|
||||
cx.run_until_parked();
|
||||
cx.update(|cx| {
|
||||
assert!(LanguageModelRegistry::read_global(cx).commit_message_model(cx).is_none());
|
||||
assert!(matches!(
|
||||
GenerateCommitMessageConfigurationTooltip::new(cx),
|
||||
GenerateCommitMessageConfigurationTooltip::SavedModelUnavailable,
|
||||
), "an authenticated provider with a removed saved model needs model recovery, not setup");
|
||||
|
||||
SettingsStore::update_global(cx, |store, cx| {
|
||||
store.set_user_settings(
|
||||
r#"{"agent":{"commit_message_model":{"provider":"zed.dev","model":"claude-opus-4-6"}}}"#,
|
||||
cx,
|
||||
).unwrap();
|
||||
});
|
||||
assert!(matches!(
|
||||
GenerateCommitMessageConfigurationTooltip::new(cx),
|
||||
GenerateCommitMessageConfigurationTooltip::SavedModelUnavailable,
|
||||
));
|
||||
|
||||
LanguageModelRegistry::global(cx).update(cx, |registry, cx| {
|
||||
let available = registry.provider(&ZED_CLOUD_PROVIDER_ID).unwrap().default_model(cx);
|
||||
registry.set_commit_message_model(available, cx);
|
||||
});
|
||||
assert!(matches!(
|
||||
GenerateCommitMessageConfigurationTooltip::new(cx),
|
||||
GenerateCommitMessageConfigurationTooltip::ConfigureProvider,
|
||||
), "a working background fallback must not be described as unavailable");
|
||||
LanguageModelRegistry::global(cx).update(cx, |registry, cx| {
|
||||
registry.set_commit_message_model(None, cx);
|
||||
});
|
||||
|
||||
SettingsStore::update_global(cx, |store, cx| {
|
||||
store.set_user_settings("{}", cx).unwrap();
|
||||
});
|
||||
assert!(matches!(
|
||||
GenerateCommitMessageConfigurationTooltip::new(cx),
|
||||
GenerateCommitMessageConfigurationTooltip::ConfigureProvider,
|
||||
), "without a saved selection the normal setup hint must remain");
|
||||
});
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_tree_view_directory_expansion_is_scoped_to_section() {
|
||||
let entry = |path, status| GitStatusEntry {
|
||||
|
||||
@@ -13,7 +13,7 @@ path = "src/language_models.rs"
|
||||
doctest = false
|
||||
|
||||
[features]
|
||||
test-support = []
|
||||
test-support = ["dep:cloud_llm_client"]
|
||||
|
||||
[dependencies]
|
||||
ai_onboarding.workspace = true
|
||||
@@ -28,6 +28,7 @@ bedrock = { workspace = true, features = ["schemars"] }
|
||||
client.workspace = true
|
||||
cloud_api_client.workspace = true
|
||||
cloud_api_types.workspace = true
|
||||
cloud_llm_client = { workspace = true, optional = true }
|
||||
collections.workspace = true
|
||||
component.workspace = true
|
||||
convert_case.workspace = true
|
||||
|
||||
@@ -486,6 +486,22 @@ struct ZedAiConfiguration {
|
||||
pub mod test_support {
|
||||
use super::*;
|
||||
|
||||
pub fn update_models(
|
||||
provider: &CloudLanguageModelProvider,
|
||||
response: cloud_llm_client::ListModelsResponse,
|
||||
cx: &mut App,
|
||||
) {
|
||||
provider
|
||||
.state
|
||||
.read(cx)
|
||||
.provider
|
||||
.clone()
|
||||
.update(cx, |provider, cx| {
|
||||
provider.update_models(response);
|
||||
cx.notify();
|
||||
});
|
||||
}
|
||||
|
||||
pub fn young_account_configuration() -> AnyElement {
|
||||
ZedAiConfiguration {
|
||||
is_connected: true,
|
||||
@@ -518,7 +534,7 @@ fn zed_ai_description(
|
||||
"Your Pro trial includes $5 of GPT Luna and unlimited edit predictions for 14 days from trial start."
|
||||
}
|
||||
Some(Plan::ZedStudent) => {
|
||||
"You have access to Zed's hosted models through your Student subscription."
|
||||
"Your Student subscription includes hosted AI access to GPT Luna."
|
||||
}
|
||||
Some(Plan::ZedBusiness) => {
|
||||
if is_zed_model_provider_enabled {
|
||||
|
||||
Reference in new issue
Block a user