Pannello endpoint /endpoint e primo avvio guidato (ripristino da 0.9.2, senza provider predefiniti)
Riportato dalla 0.9.2 solo cio' che serve alla configurazione dei provider: - /endpoint nella TUI: elenco provider, aggiunta/modifica/rimozione, scelta del modello da /v1/models, impostazioni per modello (contesto, temperatura, top_p, max output, ragionamento, nome mostrato), nomi abbreviati dei modelli. - primo avvio guidato quando non c'e' alcun provider: endpoint, chiave, dove salvarla (portachiavi o file protetto), elenco modelli dal server, prova della connessione, salvataggio in config.toml. - chiavi per provider nel portachiavi (`api_key = "keyring"`, `akode login --provider <id> --with-api-key`, `akode logout --provider <id>`). Nessun URL, modello o provider predefinito nel codice; nessun provider cloud tra le scelte (solo endpoint personalizzato e i provider locali Ollama/LM Studio gia' presenti in upstream). Lasciati fuori: passo tema e passo ricerca web (SearXNG) del primo avvio, barra di stato, unione messaggi di sistema, header @@, modello ausiliario, tool function di apply_patch. Test: test CLI debug_models riportato al comportamento upstream (catalogo incluso); snapshot doctor aggiornati al nome e alla versione aKode. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -194,6 +194,7 @@ mod agents_overview;
|
||||
mod agents_overview_actions;
|
||||
mod agents_overview_details;
|
||||
pub(crate) mod agents_overview_discovery;
|
||||
mod akode_setup;
|
||||
mod agents_overview_threads;
|
||||
mod agents_overview_usage;
|
||||
mod agents_overview_view;
|
||||
|
||||
173
akode-rs/tui/src/app/akode_setup.rs
Normal file
173
akode-rs/tui/src/app/akode_setup.rs
Normal file
@@ -0,0 +1,173 @@
|
||||
//! aKode settings flows inside a session: the guided setup
|
||||
//! (`/setup`) and switching between configured providers from `/model`.
|
||||
|
||||
use super::App;
|
||||
use crate::app_event::AppEvent;
|
||||
use crate::app_server_session::AppServerSession;
|
||||
use crate::tui;
|
||||
|
||||
impl App {
|
||||
/// `/setup`: run the guided setup, then start a new chat with the provider it added.
|
||||
pub(super) async fn run_setup(&mut self, tui: &mut tui::Tui, app_server: &AppServerSession) {
|
||||
let config = self.chat_widget.config_ref().clone();
|
||||
let outcome = crate::onboarding::onboarding_screen::run_setup_in_app(
|
||||
tui,
|
||||
app_server.request_handle(),
|
||||
&config,
|
||||
)
|
||||
.await;
|
||||
match outcome {
|
||||
Ok(Some(setup)) => {
|
||||
self.chat_widget.add_info_message(
|
||||
format!(
|
||||
"Added provider `{}` with model `{}`; starting a new chat with it.",
|
||||
setup.provider_id, setup.model
|
||||
),
|
||||
Some("Use /model to switch between configured providers.".to_string()),
|
||||
);
|
||||
self.app_event_tx.send(AppEvent::NewSession { name: None });
|
||||
}
|
||||
Ok(None) => {
|
||||
self.chat_widget
|
||||
.add_info_message("Setup cancelled.".to_string(), /*hint*/ None);
|
||||
}
|
||||
Err(err) => {
|
||||
self.chat_widget
|
||||
.add_error_message(format!("Setup failed: {err}"));
|
||||
}
|
||||
}
|
||||
tui.frame_requester().schedule_frame();
|
||||
}
|
||||
|
||||
/// `/endpoint`: endpoints, their models and per-model settings.
|
||||
pub(super) async fn run_endpoint_panel(
|
||||
&mut self,
|
||||
tui: &mut tui::Tui,
|
||||
app_server: &mut AppServerSession,
|
||||
) {
|
||||
self.refresh_in_memory_config_from_disk_best_effort("endpoint panel")
|
||||
.await;
|
||||
let config = self.config.clone();
|
||||
let active_provider = self.chat_widget.config_ref().model_provider_id.clone();
|
||||
let active_model = self.chat_widget.current_model().to_string();
|
||||
// Configured endpoints, plus the active one when it is built in.
|
||||
let configured: std::collections::BTreeSet<String> = config
|
||||
.config_layer_stack
|
||||
.effective_config()
|
||||
.get("model_providers")
|
||||
.and_then(|providers| providers.as_table())
|
||||
.map(|providers| providers.keys().cloned().collect())
|
||||
.unwrap_or_default();
|
||||
let mut endpoints: Vec<crate::endpoint_panel::EndpointEntry> = config
|
||||
.model_providers
|
||||
.iter()
|
||||
.filter(|(id, _)| configured.contains(*id) || **id == active_provider)
|
||||
.map(|(id, info)| crate::endpoint_panel::EndpointEntry {
|
||||
id: id.clone(),
|
||||
info: info.clone(),
|
||||
typed_key: None,
|
||||
})
|
||||
.collect();
|
||||
endpoints.sort_by(|a, b| {
|
||||
(a.id != active_provider, a.info.name.to_lowercase())
|
||||
.cmp(&(b.id != active_provider, b.info.name.to_lowercase()))
|
||||
});
|
||||
let ctx = crate::endpoint_panel::EndpointPanelContext {
|
||||
endpoints,
|
||||
active_provider,
|
||||
active_model,
|
||||
global_context_window: config.model_context_window,
|
||||
setup: crate::onboarding::onboarding_screen::setup_context(
|
||||
&config,
|
||||
Some(app_server.request_handle()),
|
||||
),
|
||||
};
|
||||
let outcome = match crate::endpoint_panel::run_endpoint_panel(tui, ctx).await {
|
||||
Ok(outcome) => outcome,
|
||||
Err(err) => {
|
||||
self.chat_widget
|
||||
.add_error_message(format!("Pannello endpoint non disponibile: {err}"));
|
||||
return;
|
||||
}
|
||||
};
|
||||
if outcome.config_changed {
|
||||
self.refresh_in_memory_config_from_disk_best_effort("endpoint panel")
|
||||
.await;
|
||||
crate::model_display::set_display_names_from_config(&self.config);
|
||||
self.chat_widget.refresh_model_dependent_surfaces();
|
||||
}
|
||||
if let Some(effort) = outcome.active_effort.clone()
|
||||
&& outcome.activate.is_none()
|
||||
{
|
||||
self.app_event_tx
|
||||
.send(AppEvent::UpdateReasoningEffort(effort));
|
||||
}
|
||||
if let Some((provider_id, model)) = outcome.activate {
|
||||
self.switch_provider(app_server, provider_id, model).await;
|
||||
}
|
||||
tui.frame_requester().schedule_frame();
|
||||
}
|
||||
|
||||
/// Fetch another provider's model list directly from its server (`GET {base_url}/models`).
|
||||
pub(super) fn open_provider_models(&mut self, provider_id: String) {
|
||||
let config = self.chat_widget.config_ref();
|
||||
let Some(provider) = config.model_providers.get(&provider_id).cloned() else {
|
||||
self.chat_widget
|
||||
.add_error_message(format!("Model provider `{provider_id}` is not configured."));
|
||||
return;
|
||||
};
|
||||
let Some(base_url) = provider.base_url.clone() else {
|
||||
self.chat_widget
|
||||
.add_error_message(format!("Model provider `{provider_id}` has no base_url."));
|
||||
return;
|
||||
};
|
||||
let tx = self.app_event_tx.clone();
|
||||
tokio::spawn(async move {
|
||||
let api_key = match provider.api_key() {
|
||||
Ok(key) => key,
|
||||
Err(err) => {
|
||||
tx.send(AppEvent::ProviderModelsLoaded {
|
||||
provider_id,
|
||||
result: Err(err.to_string()),
|
||||
});
|
||||
return;
|
||||
}
|
||||
};
|
||||
let result =
|
||||
crate::onboarding::setup_wizard::fetch_provider_models(base_url, api_key).await;
|
||||
tx.send(AppEvent::ProviderModelsLoaded {
|
||||
provider_id,
|
||||
result,
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
/// Make `provider_id`/`model` the default for new chats and start one.
|
||||
pub(super) async fn switch_provider(
|
||||
&mut self,
|
||||
app_server: &mut AppServerSession,
|
||||
provider_id: String,
|
||||
model: String,
|
||||
) {
|
||||
let edits = vec![
|
||||
crate::config_update::replace_config_value(
|
||||
"model_provider",
|
||||
serde_json::json!(provider_id),
|
||||
),
|
||||
crate::config_update::replace_config_value("model", serde_json::json!(model)),
|
||||
];
|
||||
match crate::config_update::write_config_batch(app_server.request_handle(), edits).await {
|
||||
Ok(_) => {
|
||||
self.chat_widget.add_info_message(
|
||||
format!("Switched to `{provider_id}` · `{model}`; starting a new chat."),
|
||||
/*hint*/ None,
|
||||
);
|
||||
self.app_event_tx.send(AppEvent::NewSession { name: None });
|
||||
}
|
||||
Err(err) => self.chat_widget.add_error_message(format!(
|
||||
"Could not switch provider: {}",
|
||||
crate::config_update::format_config_error(&err)
|
||||
)),
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -66,6 +66,8 @@ impl App {
|
||||
| AppEvent::TerminalTitleSetupCancelled
|
||||
| AppEvent::OpenConfigEditor(_)
|
||||
| AppEvent::Provider(_)
|
||||
| AppEvent::OpenSetup
|
||||
| AppEvent::OpenEndpointPanel
|
||||
| AppEvent::SyntaxThemeSelected { .. }
|
||||
| AppEvent::SyntaxThemePreviewed
|
||||
| AppEvent::OpenKeymapActionMenu { .. }
|
||||
@@ -188,6 +190,24 @@ impl App {
|
||||
event => (event, None),
|
||||
};
|
||||
match event {
|
||||
AppEvent::OpenSetup => {
|
||||
self.run_setup(tui, app_server).await;
|
||||
}
|
||||
AppEvent::OpenEndpointPanel => {
|
||||
self.run_endpoint_panel(tui, app_server).await;
|
||||
}
|
||||
AppEvent::OpenProviderModels { provider_id } => {
|
||||
self.open_provider_models(provider_id);
|
||||
}
|
||||
AppEvent::ProviderModelsLoaded {
|
||||
provider_id,
|
||||
result,
|
||||
} => {
|
||||
self.chat_widget.show_provider_models(provider_id, result);
|
||||
}
|
||||
AppEvent::SwitchProvider { provider_id, model } => {
|
||||
self.switch_provider(app_server, provider_id, model).await;
|
||||
}
|
||||
AppEvent::OpenDaemonMenu => self.open_daemon_menu(),
|
||||
AppEvent::ConfirmDaemonRestart => self.confirm_daemon_restart(),
|
||||
AppEvent::RunDaemonRestart => {
|
||||
|
||||
@@ -306,6 +306,29 @@ pub(crate) struct SavedFeedback {
|
||||
#[allow(clippy::large_enum_variant)]
|
||||
#[derive(Debug, IntoStaticStr)]
|
||||
pub(crate) enum AppEvent {
|
||||
/// Run the guided setup (`/setup`) to add a model provider.
|
||||
OpenSetup,
|
||||
|
||||
/// Open the endpoint, model and per-model settings panel (`/endpoint`).
|
||||
OpenEndpointPanel,
|
||||
|
||||
/// List the models of another configured provider for `/model`.
|
||||
OpenProviderModels {
|
||||
provider_id: String,
|
||||
},
|
||||
|
||||
/// Models listed by another provider's server.
|
||||
ProviderModelsLoaded {
|
||||
provider_id: String,
|
||||
result: Result<Vec<String>, String>,
|
||||
},
|
||||
|
||||
/// Make `provider_id`/`model` the default and start a new chat with them.
|
||||
SwitchProvider {
|
||||
provider_id: String,
|
||||
model: String,
|
||||
},
|
||||
|
||||
OpenDaemonMenu,
|
||||
ConfirmDaemonRestart,
|
||||
RunDaemonRestart,
|
||||
|
||||
@@ -1,2 +1,5 @@
|
||||
{"run_id":"1794922138-404543000","line":393,"new":{"module_name":"akode_tui__chatwidget__rendering__tests","snapshot_name":"initial_session_header_starts_at_the_top_of_the_viewport","metadata":{"source":"tui/src/chatwidget/rendering_tests.rs","assertion_line":393,"expression":"header.replace(&cwd, \"/tmp/project\")"},"snapshot":"\n ▄▄████▄▄ aKode v<VERSION>\n██▀▀██▀▀██ loading"},"old":{"module_name":"akode_tui__chatwidget__rendering__tests","metadata":{},"snapshot":">_ aKode (v<VERSION>)\n /tmp/project"}}
|
||||
{"run_id":"1794922381-669152000","line":393,"new":null,"old":null}
|
||||
{"run_id":"1794932822-572039000","line":338,"new":null,"old":null}
|
||||
{"run_id":"1794932822-572039000","line":393,"new":null,"old":null}
|
||||
{"run_id":"1794932822-572039000","line":147,"new":null,"old":null}
|
||||
|
||||
@@ -65,7 +65,7 @@ impl ChatWidget {
|
||||
let current_label = presets
|
||||
.iter()
|
||||
.find(|preset| preset.model.as_str() == current_model)
|
||||
.map(|preset| preset.display_name.clone())
|
||||
.map(|preset| self.model_catalog.display_name(&preset.model))
|
||||
.unwrap_or_else(|| self.model_display_name().to_string());
|
||||
|
||||
let (mut auto_presets, other_presets): (Vec<ModelPreset>, Vec<ModelPreset>) = presets
|
||||
@@ -115,7 +115,7 @@ impl ChatWidget {
|
||||
)
|
||||
};
|
||||
SelectionItem {
|
||||
name: preset.display_name.clone(),
|
||||
name: self.model_catalog.display_name(&preset.model),
|
||||
description,
|
||||
is_current: model.as_str() == current_model,
|
||||
secondary_action: if requires_advanced_selection {
|
||||
@@ -231,7 +231,7 @@ impl ChatWidget {
|
||||
}));
|
||||
})];
|
||||
items.push(SelectionItem {
|
||||
name: preset.display_name.clone(),
|
||||
name: self.model_catalog.display_name(&preset.model),
|
||||
description,
|
||||
is_current,
|
||||
secondary_action: direct_effort.and_then(|effort| {
|
||||
@@ -244,6 +244,8 @@ impl ChatWidget {
|
||||
});
|
||||
}
|
||||
|
||||
// aKode: other configured providers follow the current provider's models.
|
||||
items.extend(self.provider_switch_items());
|
||||
let header = self.model_menu_header("Select Model and Effort", "");
|
||||
self.show_model_selection_view(
|
||||
model_ids,
|
||||
@@ -256,6 +258,100 @@ impl ChatWidget {
|
||||
);
|
||||
}
|
||||
|
||||
/// Rows that switch to another configured provider (its models are listed next).
|
||||
fn provider_switch_items(&self) -> Vec<SelectionItem> {
|
||||
let config = self.config_ref();
|
||||
let built_in = akode_model_provider_info::built_in_model_providers();
|
||||
let mut ids: Vec<&String> = config
|
||||
.model_providers
|
||||
.iter()
|
||||
// Built-in local servers are offered by /setup, not listed for every user.
|
||||
.filter(|(id, provider)| {
|
||||
**id != config.model_provider_id
|
||||
&& provider.base_url.is_some()
|
||||
&& !built_in.contains_key(*id)
|
||||
})
|
||||
.map(|(id, _)| id)
|
||||
.collect();
|
||||
ids.sort();
|
||||
ids.into_iter()
|
||||
.map(|id| {
|
||||
let provider = &config.model_providers[id];
|
||||
let provider_id = id.clone();
|
||||
let endpoint = provider
|
||||
.base_url
|
||||
.as_deref()
|
||||
.and_then(|url| url::Url::parse(url).ok())
|
||||
.and_then(|url| {
|
||||
url.host_str().map(|host| match url.port() {
|
||||
Some(port) => format!("{host}:{port}"),
|
||||
None => host.to_string(),
|
||||
})
|
||||
})
|
||||
.unwrap_or_else(|| id.clone());
|
||||
SelectionItem {
|
||||
name: format!("Switch provider: {}", provider.name),
|
||||
description: Some(format!("{id} · {endpoint}")),
|
||||
dismiss_on_select: true,
|
||||
actions: vec![Box::new(move |tx| {
|
||||
tx.send(AppEvent::OpenProviderModels {
|
||||
provider_id: provider_id.clone(),
|
||||
});
|
||||
})],
|
||||
..Default::default()
|
||||
}
|
||||
})
|
||||
.collect()
|
||||
}
|
||||
|
||||
/// Models listed by another provider; choosing one switches provider and starts a new chat.
|
||||
pub(crate) fn show_provider_models(
|
||||
&mut self,
|
||||
provider_id: String,
|
||||
result: Result<Vec<String>, String>,
|
||||
) {
|
||||
let models = match result {
|
||||
Ok(models) => models,
|
||||
Err(error) => {
|
||||
self.add_error_message(format!(
|
||||
"Could not list the models of `{provider_id}`: {error}"
|
||||
));
|
||||
return;
|
||||
}
|
||||
};
|
||||
let name = self
|
||||
.config_ref()
|
||||
.model_providers
|
||||
.get(&provider_id)
|
||||
.map_or_else(|| provider_id.clone(), |provider| provider.name.clone());
|
||||
let items = models
|
||||
.into_iter()
|
||||
.map(|model| {
|
||||
let provider_id = provider_id.clone();
|
||||
SelectionItem {
|
||||
name: crate::model_display::display_name(&model),
|
||||
dismiss_on_select: true,
|
||||
actions: vec![Box::new(move |tx| {
|
||||
tx.send(AppEvent::SwitchProvider {
|
||||
provider_id: provider_id.clone(),
|
||||
model: model.clone(),
|
||||
});
|
||||
})],
|
||||
..Default::default()
|
||||
}
|
||||
})
|
||||
.collect();
|
||||
let header = self.model_menu_header(
|
||||
&format!("Models on {name}"),
|
||||
"Choosing a model switches provider and starts a new chat.",
|
||||
);
|
||||
self.bottom_pane.show_selection_view(SelectionViewParams {
|
||||
items,
|
||||
header,
|
||||
..SelectionViewParams::picker()
|
||||
});
|
||||
}
|
||||
|
||||
fn model_selection_actions(
|
||||
&self,
|
||||
model_for_action: String,
|
||||
@@ -504,7 +600,7 @@ impl ChatWidget {
|
||||
.then(|| default_effort.clone());
|
||||
|
||||
let model_slug = preset.model.to_string();
|
||||
let model_label = preset.display_name.clone();
|
||||
let model_label = self.model_catalog.display_name(&preset.model);
|
||||
let is_current_model = self.current_model() == preset.model.as_str();
|
||||
let highlight_choice = if is_current_model {
|
||||
if in_plan_mode {
|
||||
|
||||
@@ -218,7 +218,7 @@ impl ChatWidget {
|
||||
&self.config,
|
||||
&self.local_settings,
|
||||
&model_for_header,
|
||||
self.model_catalog.display_name(&session.model),
|
||||
&self.model_catalog.display_name(&session.model),
|
||||
&session,
|
||||
self.show_welcome_banner,
|
||||
startup_tooltip_override,
|
||||
|
||||
@@ -377,7 +377,7 @@ impl ChatWidget {
|
||||
/// Consolidating both refreshes here prevents the bug where callers update the
|
||||
/// header/title (`refresh_model_display`) but forget the footer status line
|
||||
/// (`refresh_status_line`).
|
||||
pub(super) fn refresh_model_dependent_surfaces(&mut self) {
|
||||
pub(crate) fn refresh_model_dependent_surfaces(&mut self) {
|
||||
self.refresh_model_display();
|
||||
self.refresh_status_line();
|
||||
self.refresh_open_model_picker();
|
||||
@@ -493,10 +493,10 @@ impl ChatWidget {
|
||||
self.refresh_model_dependent_surfaces();
|
||||
}
|
||||
|
||||
pub(crate) fn model_display_name(&self) -> &str {
|
||||
pub(crate) fn model_display_name(&self) -> String {
|
||||
let model = self.current_model();
|
||||
if model.is_empty() {
|
||||
DEFAULT_MODEL_DISPLAY_NAME
|
||||
DEFAULT_MODEL_DISPLAY_NAME.to_string()
|
||||
} else {
|
||||
self.model_catalog.display_name(model)
|
||||
}
|
||||
|
||||
@@ -531,6 +531,12 @@ impl ChatWidget {
|
||||
SlashCommand::Config => {
|
||||
self.open_config_panel();
|
||||
}
|
||||
SlashCommand::Setup => {
|
||||
self.app_event_tx.send(AppEvent::OpenSetup);
|
||||
}
|
||||
SlashCommand::Endpoint => {
|
||||
self.app_event_tx.send(AppEvent::OpenEndpointPanel);
|
||||
}
|
||||
SlashCommand::Theme => {
|
||||
self.open_theme_picker();
|
||||
}
|
||||
@@ -1279,6 +1285,8 @@ impl ChatWidget {
|
||||
| SlashCommand::Statusline
|
||||
| SlashCommand::Config
|
||||
| SlashCommand::Theme
|
||||
| SlashCommand::Setup
|
||||
| SlashCommand::Endpoint
|
||||
| SlashCommand::Tui
|
||||
| SlashCommand::Pets => QueueDrain::Stop,
|
||||
}
|
||||
|
||||
@@ -252,7 +252,7 @@ impl ChatWidget {
|
||||
rate_limit_snapshots.as_slice(),
|
||||
self.plan_type,
|
||||
Local::now(),
|
||||
self.model_display_name(),
|
||||
&self.model_display_name(),
|
||||
collaboration_mode,
|
||||
reasoning_effort_override,
|
||||
agents_summary,
|
||||
|
||||
@@ -18,6 +18,9 @@ pub(crate) fn is_startup_cell(cell: &dyn HistoryCell) -> bool {
|
||||
|| cell.as_any().is::<history_cell::SessionInfoCell>()
|
||||
|| cell.as_any().is::<history_cell::StartupWarningsCell>()
|
||||
|| cell.as_any().is::<history_cell::DeprecationNoticeCell>()
|
||||
|| cell
|
||||
.as_any()
|
||||
.is::<history_cell::UpdateAvailableHistoryCell>()
|
||||
|| cell.as_any().is::<history_cell::SessionNoticeCell>()
|
||||
|| cell
|
||||
.as_any()
|
||||
|
||||
1556
akode-rs/tui/src/endpoint_panel.rs
Normal file
1556
akode-rs/tui/src/endpoint_panel.rs
Normal file
File diff suppressed because it is too large
Load Diff
168
akode-rs/tui/src/endpoint_panel_tests.rs
Normal file
168
akode-rs/tui/src/endpoint_panel_tests.rs
Normal file
@@ -0,0 +1,168 @@
|
||||
use super::*;
|
||||
use pretty_assertions::assert_eq;
|
||||
|
||||
const SECRET: &str = "sk-akode-test-secret-0123456789";
|
||||
const FLINT: &str = "/Users/andrea/models/Flint.APEX-I-NanoPlus-V2.1.gguf";
|
||||
|
||||
fn provider(name: &str, url: &str) -> ModelProviderInfo {
|
||||
ModelProviderInfo {
|
||||
name: name.to_string(),
|
||||
base_url: Some(url.to_string()),
|
||||
..Default::default()
|
||||
}
|
||||
}
|
||||
|
||||
fn panel() -> EndpointPanel {
|
||||
let mut macos = provider("MACOS", "http://127.0.0.1:8080/v1");
|
||||
macos.models.insert(
|
||||
FLINT.to_string(),
|
||||
ProviderModelSettings {
|
||||
context_window: Some(65536),
|
||||
temperature: Some(0.7),
|
||||
top_p: Some(0.95),
|
||||
max_output_tokens: Some(8192),
|
||||
reasoning_effort: Some(ReasoningEffort::Medium),
|
||||
display_name: None,
|
||||
},
|
||||
);
|
||||
let ctx = EndpointPanelContext {
|
||||
endpoints: vec![
|
||||
EndpointEntry {
|
||||
id: "macos".to_string(),
|
||||
info: macos,
|
||||
typed_key: None,
|
||||
},
|
||||
EndpointEntry {
|
||||
id: "giulio".to_string(),
|
||||
info: provider("Giulio", "https://mega-link.cloud/v1"),
|
||||
typed_key: Some(SECRET.to_string()),
|
||||
},
|
||||
EndpointEntry {
|
||||
id: "openrouter".to_string(),
|
||||
info: provider("OpenRouter", "https://openrouter.ai/api/v1"),
|
||||
typed_key: None,
|
||||
},
|
||||
],
|
||||
active_provider: "macos".to_string(),
|
||||
active_model: FLINT.to_string(),
|
||||
global_context_window: None,
|
||||
setup: SetupContext::default(),
|
||||
};
|
||||
let mut panel = EndpointPanel::new(FrameRequester::test_dummy(), ctx);
|
||||
panel.set_models_for_test(
|
||||
"macos",
|
||||
setup_net::ModelList {
|
||||
base_url: "http://127.0.0.1:8080/v1".to_string(),
|
||||
models: vec![FLINT.to_string()],
|
||||
..Default::default()
|
||||
},
|
||||
Some(65536),
|
||||
);
|
||||
panel
|
||||
}
|
||||
|
||||
fn key(code: KeyCode) -> KeyEvent {
|
||||
KeyEvent::new(code, KeyModifiers::NONE)
|
||||
}
|
||||
|
||||
fn render(panel: &EndpointPanel, width: u16, height: u16) -> String {
|
||||
let area = Rect::new(0, 0, width, height);
|
||||
let mut buf = Buffer::empty(area);
|
||||
panel.render_ref(area, &mut buf);
|
||||
(0..height)
|
||||
.map(|y| {
|
||||
(0..width)
|
||||
.map(|x| buf[(x, y)].symbol().to_string())
|
||||
.collect::<String>()
|
||||
.trim_end()
|
||||
.to_string()
|
||||
})
|
||||
.collect::<Vec<_>>()
|
||||
.join("\n")
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn endpoint_panel_snapshots() {
|
||||
let panel = panel();
|
||||
for width in [80, 120, 160] {
|
||||
insta::assert_snapshot!(format!("endpoint_panel_{width}"), render(&panel, width, 14));
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn narrow_panel_shows_one_column_with_breadcrumb() {
|
||||
let mut panel = panel();
|
||||
panel.handle_key_event(key(KeyCode::Tab));
|
||||
panel.handle_key_event(key(KeyCode::Tab));
|
||||
let text = render(&panel, 80, 14);
|
||||
assert!(text.contains("Impostazioni · Flint.APEX-I-NanoPlus-V2.1"));
|
||||
assert!(text.contains("(server 65536)"));
|
||||
insta::assert_snapshot!("endpoint_panel_settings_80", text);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn path_model_ids_show_the_file_stem() {
|
||||
let text = render(&panel(), 160, 14);
|
||||
assert!(text.contains("Flint.APEX-I-NanoPlus-V2.1"));
|
||||
assert!(!text.contains(".gguf"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn keys_never_appear_in_the_panel_or_the_edit_form() {
|
||||
let mut panel = panel();
|
||||
panel.handle_key_event(key(KeyCode::Down));
|
||||
for width in [80, 120, 160] {
|
||||
assert!(!render(&panel, width, 14).contains(SECRET));
|
||||
}
|
||||
panel.handle_key_event(key(KeyCode::Enter));
|
||||
assert!(panel.wizard.is_some());
|
||||
let form = render(&panel, 120, 20);
|
||||
assert!(form.contains("Modifica endpoint"));
|
||||
assert!(form.contains("lascia vuoto per mantenerla"));
|
||||
assert!(!form.contains(SECRET));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn the_active_endpoint_cannot_be_deleted() {
|
||||
let mut panel = panel();
|
||||
panel.handle_key_event(key(KeyCode::Char('d')));
|
||||
assert!(!panel.confirm_delete);
|
||||
assert!(render(&panel, 120, 14).contains("Non puoi eliminare l'endpoint attivo"));
|
||||
panel.handle_key_event(key(KeyCode::Down));
|
||||
panel.handle_key_event(key(KeyCode::Char('d')));
|
||||
assert!(panel.confirm_delete);
|
||||
panel.handle_key_event(key(KeyCode::Esc));
|
||||
assert!(!panel.confirm_delete);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn settings_parse_and_key_paths_quote_the_model_id() {
|
||||
assert_eq!(
|
||||
parse_setting(Setting::Temperature, "0,7"),
|
||||
Ok(Some(serde_json::json!(0.7)))
|
||||
);
|
||||
assert_eq!(parse_setting(Setting::Context, ""), Ok(None));
|
||||
assert!(parse_setting(Setting::TopP, "1.5").is_err());
|
||||
assert_eq!(
|
||||
model_setting_path("openrouter", "recursive/flint-v1.0:free", "top_p"),
|
||||
"model_providers.openrouter.models.\"recursive/flint-v1.0:free\".top_p"
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn per_model_settings_serialize_without_keys() {
|
||||
let mut info = provider("Giulio", "https://mega-link.cloud/v1");
|
||||
info.models.insert(
|
||||
"flint".to_string(),
|
||||
ProviderModelSettings {
|
||||
context_window: Some(65536),
|
||||
temperature: Some(0.7),
|
||||
..Default::default()
|
||||
},
|
||||
);
|
||||
let toml = toml::to_string(&info).expect("serialize");
|
||||
assert!(toml.contains("[models.flint]"));
|
||||
assert!(toml.contains("context_window = 65536"));
|
||||
assert!(!toml.contains(SECRET));
|
||||
assert!(!toml.contains("top_p"));
|
||||
}
|
||||
@@ -108,6 +108,9 @@ mod async_question_reply;
|
||||
mod backend_id;
|
||||
mod bottom_pane;
|
||||
mod branding;
|
||||
mod endpoint_panel;
|
||||
mod model_display;
|
||||
mod truncate_line;
|
||||
mod branch_summary;
|
||||
mod chatwidget;
|
||||
mod cli;
|
||||
@@ -1287,18 +1290,14 @@ async fn run_ratatui_app(
|
||||
),
|
||||
)
|
||||
.await;
|
||||
match provider_check {
|
||||
Ok(false) => {}
|
||||
Ok(true) => {
|
||||
let exit_info = onboarding::show_no_model_provider_setup(&mut tui);
|
||||
shutdown_startup_session(Some(app_server_session), &mut terminal_restore_guard).await;
|
||||
return Ok(exit_info);
|
||||
}
|
||||
// aKode: without a provider, startup runs the first-run setup instead of a session.
|
||||
let provider_missing = match provider_check {
|
||||
Ok(missing) => missing,
|
||||
Err(err) => {
|
||||
shutdown_startup_session(Some(app_server_session), &mut terminal_restore_guard).await;
|
||||
return Err(err.into());
|
||||
}
|
||||
}
|
||||
};
|
||||
let mut app_server = Some(app_server_session);
|
||||
// Folder consent runs after the picker resolves the actual destination.
|
||||
let should_show_trust_screen_flag = false;
|
||||
@@ -1325,11 +1324,12 @@ async fn run_ratatui_app(
|
||||
let requires_openai_auth = startup_account
|
||||
.as_ref()
|
||||
.is_some_and(|account| account.requires_openai_auth);
|
||||
let should_show_onboarding = should_show_onboarding(
|
||||
login_status,
|
||||
requires_openai_auth,
|
||||
should_show_trust_screen_flag,
|
||||
);
|
||||
let should_show_onboarding = provider_missing
|
||||
|| should_show_onboarding(
|
||||
login_status,
|
||||
requires_openai_auth,
|
||||
should_show_trust_screen_flag,
|
||||
);
|
||||
|
||||
let mut config = if should_show_onboarding {
|
||||
if let Err(err) = startup_draft.flush_pending_events(&mut tui).await {
|
||||
@@ -1365,6 +1365,7 @@ async fn run_ratatui_app(
|
||||
.as_ref()
|
||||
.map(AppServerSession::request_handle),
|
||||
config: initial_config.clone(),
|
||||
show_provider_setup: provider_missing,
|
||||
},
|
||||
if show_login_screen {
|
||||
app_server.as_mut()
|
||||
@@ -1398,7 +1399,27 @@ async fn run_ratatui_app(
|
||||
trust_decision_was_made =
|
||||
!uses_remote_workspace && onboarding_result.directory_trust_persisted;
|
||||
}
|
||||
if let Some(selected_id) = onboarding_result.selected_gateway {
|
||||
// A provider written by the first-run setup is picked up like a selected gateway: reload
|
||||
// config and restart the embedded server so it serves the new provider.
|
||||
let selected_provider = onboarding_result.selected_gateway.clone().or_else(|| {
|
||||
onboarding_result
|
||||
.provider_setup
|
||||
.as_ref()
|
||||
.map(|setup| setup.provider_id.clone())
|
||||
});
|
||||
if provider_missing && selected_provider.is_none() {
|
||||
shutdown_startup_session(app_server.take(), &mut terminal_restore_guard).await;
|
||||
let _ = tui.terminal.clear();
|
||||
return Ok(AppExitInfo {
|
||||
token_usage: crate::token_usage::TokenUsage::default(),
|
||||
thread_id: None,
|
||||
resume_hint: None,
|
||||
disconnect_info: None,
|
||||
update_action: None,
|
||||
exit_reason: ExitReason::UserRequested,
|
||||
});
|
||||
}
|
||||
if let Some(selected_id) = selected_provider {
|
||||
// Account state belongs to the provider captured by the embedded server at startup.
|
||||
let mut selected = startup_draft
|
||||
.run_until(
|
||||
@@ -1452,7 +1473,9 @@ async fn run_ratatui_app(
|
||||
// Reload config when persisted trust or auth changes alter the current process.
|
||||
Ok::<_, std::io::Error>(
|
||||
if !uses_remote_workspace
|
||||
&& (onboarding_result.directory_trust_persisted || show_login_screen)
|
||||
&& (onboarding_result.directory_trust_persisted
|
||||
|| show_login_screen
|
||||
|| onboarding_result.provider_setup.is_some())
|
||||
{
|
||||
load_config_or_exit_with_fallback_cwd(
|
||||
cli_kv_overrides.clone(),
|
||||
@@ -2043,6 +2066,7 @@ async fn run_ratatui_app(
|
||||
}
|
||||
|
||||
let local_settings = crate::local_settings::LocalSettings::for_tui(&config, &tui);
|
||||
crate::model_display::set_display_names_from_config(&config);
|
||||
crate::markdown_render::preferences::init(local_settings.tui.rendering);
|
||||
// Configure syntax highlighting theme from the final config — onboarding
|
||||
// and resume/fork can both reload config with a different tui_theme, so
|
||||
|
||||
@@ -66,11 +66,17 @@ impl ModelCatalog {
|
||||
Ok(self.models.clone())
|
||||
}
|
||||
|
||||
pub(crate) fn display_name<'a>(&'a self, model: &'a str) -> &'a str {
|
||||
/// Name shown for `model`: a configured display name, a catalog name that differs from
|
||||
/// the id, else the id (as a file stem when it is a path).
|
||||
pub(crate) fn display_name(&self, model: &str) -> String {
|
||||
let shown = crate::model_display::display_name(model);
|
||||
if shown != model {
|
||||
return shown;
|
||||
}
|
||||
self.models
|
||||
.iter()
|
||||
.find(|preset| preset.model == model)
|
||||
.map(|preset| preset.display_name.as_str())
|
||||
.unwrap_or_else(|| model_display_name(model))
|
||||
.find(|preset| preset.model == model && preset.display_name != model)
|
||||
.map(|preset| preset.display_name.clone())
|
||||
.unwrap_or_else(|| model_display_name(model).to_string())
|
||||
}
|
||||
}
|
||||
|
||||
104
akode-rs/tui/src/model_display.rs
Normal file
104
akode-rs/tui/src/model_display.rs
Normal file
@@ -0,0 +1,104 @@
|
||||
//! Model names as shown in the interface. A `display_name` configured for the model
|
||||
//! (`[model_providers.<id>.models."<model id>"]`) wins; an id that looks like a file path
|
||||
//! shows only the file name without its extension. Requests always use the full id.
|
||||
|
||||
use std::collections::HashMap;
|
||||
use std::path::Path;
|
||||
use std::sync::PoisonError;
|
||||
use std::sync::RwLock;
|
||||
|
||||
use crate::legacy_core::config::Config;
|
||||
|
||||
static DISPLAY_NAMES: RwLock<Option<HashMap<String, String>>> = RwLock::new(None);
|
||||
|
||||
/// Load the configured display names; the active provider's names win over the others.
|
||||
pub(crate) fn set_display_names_from_config(config: &Config) {
|
||||
let mut names = HashMap::new();
|
||||
let configured = config
|
||||
.model_providers
|
||||
.iter()
|
||||
.filter(|(id, _)| **id != config.model_provider_id)
|
||||
.map(|(_, provider)| provider)
|
||||
.chain(std::iter::once(&config.model_provider));
|
||||
for provider in configured {
|
||||
for (model, settings) in &provider.models {
|
||||
if let Some(name) = settings
|
||||
.display_name
|
||||
.as_deref()
|
||||
.map(str::trim)
|
||||
.filter(|name| !name.is_empty())
|
||||
{
|
||||
names.insert(model.clone(), name.to_string());
|
||||
}
|
||||
}
|
||||
}
|
||||
*DISPLAY_NAMES
|
||||
.write()
|
||||
.unwrap_or_else(PoisonError::into_inner) = Some(names);
|
||||
}
|
||||
|
||||
/// Whether `model` is a local file path rather than a plain or `vendor/model` id.
|
||||
fn looks_like_path(model: &str) -> bool {
|
||||
const MODEL_FILE_EXTENSIONS: [&str; 6] = ["gguf", "ggml", "bin", "safetensors", "onnx", "mlx"];
|
||||
model.starts_with('/')
|
||||
|| model.starts_with("~/")
|
||||
|| model.starts_with("./")
|
||||
|| model.starts_with("../")
|
||||
|| model.contains('\\')
|
||||
|| Path::new(model)
|
||||
.extension()
|
||||
.and_then(|ext| ext.to_str())
|
||||
.is_some_and(|ext| {
|
||||
MODEL_FILE_EXTENSIONS
|
||||
.iter()
|
||||
.any(|known| ext.eq_ignore_ascii_case(known))
|
||||
})
|
||||
}
|
||||
|
||||
/// `model` without its directory and extension when it looks like a file path.
|
||||
pub(crate) fn short_model_name(model: &str) -> String {
|
||||
if !looks_like_path(model) {
|
||||
return model.to_string();
|
||||
}
|
||||
let file = model
|
||||
.rsplit(['/', '\\'])
|
||||
.find(|part| !part.is_empty())
|
||||
.unwrap_or(model);
|
||||
Path::new(file)
|
||||
.file_stem()
|
||||
.and_then(|stem| stem.to_str())
|
||||
.filter(|stem| !stem.is_empty())
|
||||
.unwrap_or(file)
|
||||
.to_string()
|
||||
}
|
||||
|
||||
/// Name shown for `model`: the configured display name, else [`short_model_name`].
|
||||
pub(crate) fn display_name(model: &str) -> String {
|
||||
let configured = DISPLAY_NAMES
|
||||
.read()
|
||||
.unwrap_or_else(PoisonError::into_inner)
|
||||
.as_ref()
|
||||
.and_then(|names| names.get(model).cloned());
|
||||
configured.unwrap_or_else(|| short_model_name(model))
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::short_model_name;
|
||||
use pretty_assertions::assert_eq;
|
||||
|
||||
#[test]
|
||||
fn path_ids_show_the_file_stem() {
|
||||
assert_eq!(
|
||||
short_model_name("/Users/me/models/Flint.APEX-I-NanoPlus-V2.1.gguf"),
|
||||
"Flint.APEX-I-NanoPlus-V2.1"
|
||||
);
|
||||
assert_eq!(short_model_name("C:\\models\\qwen3.gguf"), "qwen3");
|
||||
assert_eq!(short_model_name("flint.gguf"), "flint");
|
||||
assert_eq!(
|
||||
short_model_name("qwen/qwen3-coder:free"),
|
||||
"qwen/qwen3-coder:free"
|
||||
);
|
||||
assert_eq!(short_model_name("qwen3.6-35b-a3b"), "qwen3.6-35b-a3b");
|
||||
}
|
||||
}
|
||||
@@ -48,6 +48,7 @@ pub(crate) async fn authenticate_gateway(
|
||||
app_server_target: AppServerTarget::Embedded,
|
||||
app_server_request_handle: Some(handle.clone()),
|
||||
config: config.clone(),
|
||||
show_provider_setup: false,
|
||||
},
|
||||
)
|
||||
.await;
|
||||
|
||||
@@ -6,8 +6,9 @@ mod keys;
|
||||
pub(crate) mod onboarding_screen;
|
||||
mod provider_required;
|
||||
pub(crate) use provider_required::model_provider_missing;
|
||||
pub(crate) use provider_required::show_no_model_provider_setup;
|
||||
mod provider_setup;
|
||||
pub(crate) mod provider_setup;
|
||||
pub(crate) mod setup_net;
|
||||
pub(crate) mod setup_wizard;
|
||||
pub(crate) use provider_setup::FieldDisplay;
|
||||
pub(crate) use provider_setup::ProviderInput;
|
||||
pub(crate) use provider_setup::move_provider_field;
|
||||
|
||||
@@ -42,6 +42,9 @@ use crate::onboarding::auth::AuthModeWidget;
|
||||
use crate::onboarding::auth::SignInOption;
|
||||
use crate::onboarding::auth::SignInState;
|
||||
use crate::onboarding::keys;
|
||||
use crate::onboarding::setup_wizard::SetupContext;
|
||||
use crate::onboarding::setup_wizard::SetupOutcome;
|
||||
use crate::onboarding::setup_wizard::SetupWizard;
|
||||
use crate::onboarding::trust_directory::TrustDirectorySelection;
|
||||
use crate::onboarding::trust_directory::TrustDirectoryWidget;
|
||||
use crate::onboarding::welcome::WelcomeWidget;
|
||||
@@ -65,6 +68,7 @@ pub(crate) use directory_trust::check_directory_trust;
|
||||
enum Step {
|
||||
Welcome(WelcomeWidget),
|
||||
Auth(AuthModeWidget),
|
||||
Setup(SetupWizard),
|
||||
TrustDirectory(TrustDirectoryWidget),
|
||||
}
|
||||
|
||||
@@ -101,12 +105,16 @@ pub(crate) struct OnboardingScreenArgs {
|
||||
pub app_server_target: crate::AppServerTarget,
|
||||
pub app_server_request_handle: Option<AppServerRequestHandle>,
|
||||
pub config: Config,
|
||||
/// Run the aKode first-run setup (no model provider is configured).
|
||||
pub show_provider_setup: bool,
|
||||
}
|
||||
|
||||
#[derive(Default)]
|
||||
pub(crate) struct OnboardingResult {
|
||||
pub directory_trust_persisted: bool,
|
||||
pub selected_gateway: Option<String>,
|
||||
/// Provider and model written by the first-run setup.
|
||||
pub provider_setup: Option<SetupOutcome>,
|
||||
pub should_exit: bool,
|
||||
}
|
||||
|
||||
@@ -129,6 +137,7 @@ impl OnboardingScreen {
|
||||
app_server_target,
|
||||
app_server_request_handle,
|
||||
config,
|
||||
show_provider_setup,
|
||||
} = args;
|
||||
let local_settings = crate::local_settings::LocalSettings::from(&config);
|
||||
let cwd = config.cwd.to_path_buf();
|
||||
@@ -137,10 +146,18 @@ impl OnboardingScreen {
|
||||
.map(|project| project.trust_target.to_string_lossy().into_owned());
|
||||
let auth_config = config.auth_config();
|
||||
let mut steps: Vec<Step> = Vec::new();
|
||||
steps.push(Step::Welcome(WelcomeWidget::new(
|
||||
!matches!(login_status, LoginStatus::NotAuthenticated),
|
||||
local_settings.tui.animations && local_settings.tui.effects.welcome,
|
||||
)));
|
||||
if show_provider_setup {
|
||||
// The setup shows its own welcome page.
|
||||
steps.push(Step::Setup(SetupWizard::new(
|
||||
tui.frame_requester(),
|
||||
setup_context(&config, app_server_request_handle.clone()),
|
||||
)));
|
||||
} else {
|
||||
steps.push(Step::Welcome(WelcomeWidget::new(
|
||||
!matches!(login_status, LoginStatus::NotAuthenticated),
|
||||
local_settings.tui.animations && local_settings.tui.effects.welcome,
|
||||
)));
|
||||
}
|
||||
#[cfg(target_os = "windows")]
|
||||
let show_windows_create_sandbox_hint = if show_trust_screen
|
||||
&& remote_project_trust.is_none()
|
||||
@@ -273,7 +290,20 @@ impl OnboardingScreen {
|
||||
pub(super) fn auth_widget_mut(&mut self) -> Option<&mut AuthModeWidget> {
|
||||
self.steps.iter_mut().find_map(|step| match step {
|
||||
Step::Auth(widget) => Some(widget),
|
||||
Step::Welcome(_) | Step::TrustDirectory(_) => None,
|
||||
Step::Welcome(_) | Step::Setup(_) | Step::TrustDirectory(_) => None,
|
||||
})
|
||||
}
|
||||
|
||||
fn setup_wizard_mut(&mut self) -> Option<&mut SetupWizard> {
|
||||
self.steps.iter_mut().find_map(|step| match step {
|
||||
Step::Setup(widget) => Some(widget),
|
||||
Step::Welcome(_) | Step::Auth(_) | Step::TrustDirectory(_) => None,
|
||||
})
|
||||
}
|
||||
|
||||
fn is_setup_in_progress(&self) -> bool {
|
||||
self.steps.iter().any(|step| {
|
||||
matches!(step, Step::Setup(_)) && matches!(step.get_step_state(), StepState::InProgress)
|
||||
})
|
||||
}
|
||||
|
||||
@@ -296,15 +326,20 @@ impl OnboardingScreen {
|
||||
fn text_entry_context(&self) -> TextEntryContext {
|
||||
self.steps
|
||||
.iter()
|
||||
.find_map(|step| {
|
||||
if let Step::Auth(widget) = step {
|
||||
.find_map(|step| match step {
|
||||
Step::Auth(widget) => Some(TextEntryContext {
|
||||
active: widget.is_text_entry_active(),
|
||||
has_text: widget.should_suppress_printable_quit(),
|
||||
}),
|
||||
// Setup fields take printable keys (including `q`) from the first character.
|
||||
Step::Setup(widget) if matches!(widget.get_step_state(), StepState::InProgress) => {
|
||||
let active = widget.is_text_entry_active();
|
||||
Some(TextEntryContext {
|
||||
active: widget.is_text_entry_active(),
|
||||
has_text: widget.should_suppress_printable_quit(),
|
||||
active,
|
||||
has_text: active,
|
||||
})
|
||||
} else {
|
||||
None
|
||||
}
|
||||
_ => None,
|
||||
})
|
||||
.unwrap_or_default()
|
||||
}
|
||||
@@ -332,6 +367,11 @@ impl KeyboardHandler for OnboardingScreen {
|
||||
// If the user cancels the auth menu, exit the app rather than
|
||||
// leave the user at a prompt in an unauthed state.
|
||||
self.should_exit = true;
|
||||
} else if self.is_setup_in_progress() {
|
||||
if let Some(widget) = self.setup_wizard_mut() {
|
||||
widget.cancel();
|
||||
}
|
||||
self.should_exit = true;
|
||||
} else if self.is_trust_step_active() {
|
||||
self.should_exit = true;
|
||||
}
|
||||
@@ -396,7 +436,7 @@ impl WidgetRef for &OnboardingScreen {
|
||||
for step in self.current_steps() {
|
||||
match step {
|
||||
Step::Welcome(widget) => widget.set_presentation(logo_presentation),
|
||||
Step::Auth(_) | Step::TrustDirectory(_) => {}
|
||||
Step::Auth(_) | Step::Setup(_) | Step::TrustDirectory(_) => {}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -469,6 +509,7 @@ impl KeyboardHandler for Step {
|
||||
match self {
|
||||
Step::Welcome(widget) => widget.handle_key_event(key_event),
|
||||
Step::Auth(widget) => widget.handle_key_event(key_event),
|
||||
Step::Setup(widget) => widget.handle_key_event(key_event),
|
||||
Step::TrustDirectory(widget) => widget.handle_key_event(key_event),
|
||||
}
|
||||
}
|
||||
@@ -477,6 +518,7 @@ impl KeyboardHandler for Step {
|
||||
match self {
|
||||
Step::Welcome(_) => {}
|
||||
Step::Auth(widget) => widget.handle_paste(pasted),
|
||||
Step::Setup(widget) => widget.handle_paste(pasted),
|
||||
Step::TrustDirectory(widget) => widget.handle_paste(pasted),
|
||||
}
|
||||
}
|
||||
@@ -487,6 +529,7 @@ impl StepStateProvider for Step {
|
||||
match self {
|
||||
Step::Welcome(w) => w.get_step_state(),
|
||||
Step::Auth(w) => w.get_step_state(),
|
||||
Step::Setup(w) => w.get_step_state(),
|
||||
Step::TrustDirectory(w) => w.get_step_state(),
|
||||
}
|
||||
}
|
||||
@@ -501,6 +544,9 @@ impl WidgetRef for Step {
|
||||
Step::Auth(widget) => {
|
||||
widget.render_ref(area, buf);
|
||||
}
|
||||
Step::Setup(widget) => {
|
||||
widget.render_ref(area, buf);
|
||||
}
|
||||
Step::TrustDirectory(widget) => {
|
||||
widget.render_ref(area, buf);
|
||||
}
|
||||
@@ -564,9 +610,16 @@ async fn run_onboarding_screen_inner(
|
||||
while !onboarding_screen.is_done() {
|
||||
tokio::select! {
|
||||
() = async {
|
||||
match onboarding_screen.auth_widget_mut() {
|
||||
Some(auth) => auth.advance_gateway_request().await,
|
||||
None => std::future::pending().await,
|
||||
// The setup and the sign-in step never run in the same screen.
|
||||
if onboarding_screen.setup_wizard_mut().is_some() {
|
||||
if let Some(setup) = onboarding_screen.setup_wizard_mut() {
|
||||
setup.advance().await;
|
||||
}
|
||||
} else {
|
||||
match onboarding_screen.auth_widget_mut() {
|
||||
Some(auth) => auth.advance_gateway_request().await,
|
||||
None => std::future::pending().await,
|
||||
}
|
||||
}
|
||||
} => {}
|
||||
event = tui_events.next() => {
|
||||
@@ -655,10 +708,61 @@ async fn run_onboarding_screen_inner(
|
||||
_ => None,
|
||||
}
|
||||
}),
|
||||
provider_setup: onboarding_screen.setup_wizard_mut().and_then(|widget| {
|
||||
(!widget.is_cancelled())
|
||||
.then(|| widget.outcome().cloned())
|
||||
.flatten()
|
||||
}),
|
||||
should_exit: onboarding_screen.should_exit(),
|
||||
})
|
||||
}
|
||||
|
||||
/// Configuration facts the setup needs (existing provider ids and local server URLs).
|
||||
pub(crate) fn setup_context(
|
||||
config: &Config,
|
||||
request_handle: Option<AppServerRequestHandle>,
|
||||
) -> SetupContext {
|
||||
let base_url = |id: &str| {
|
||||
config
|
||||
.model_providers
|
||||
.get(id)
|
||||
.and_then(|provider| provider.base_url.clone())
|
||||
};
|
||||
SetupContext {
|
||||
existing_provider_ids: config.model_providers.keys().cloned().collect(),
|
||||
ollama_base_url: base_url(akode_model_provider_info::OLLAMA_OSS_PROVIDER_ID),
|
||||
lmstudio_base_url: base_url(akode_model_provider_info::LMSTUDIO_OSS_PROVIDER_ID),
|
||||
request_handle,
|
||||
codex_home: config.codex_home.as_path().to_path_buf(),
|
||||
key_store_mode: config.provider_api_key_store_mode,
|
||||
keyring_available: akode_login::provider_api_key_keyring_available(),
|
||||
endpoint_mode: None,
|
||||
}
|
||||
}
|
||||
|
||||
/// Run the setup from inside a session (`/setup`) to add another provider.
|
||||
pub(crate) async fn run_setup_in_app(
|
||||
tui: &mut Tui,
|
||||
request_handle: AppServerRequestHandle,
|
||||
config: &Config,
|
||||
) -> Result<Option<SetupOutcome>> {
|
||||
let screen = OnboardingScreen {
|
||||
request_frame: tui.frame_requester(),
|
||||
steps: vec![Step::Setup(SetupWizard::new(
|
||||
tui.frame_requester(),
|
||||
setup_context(config, Some(request_handle.clone())),
|
||||
))],
|
||||
remote_trust_key: None,
|
||||
is_done: false,
|
||||
should_exit: false,
|
||||
};
|
||||
let result =
|
||||
run_onboarding_screen(screen, Some(request_handle), /*app_server*/ None, tui).await?;
|
||||
tui.terminal.clear()?;
|
||||
tui.frame_requester().schedule_frame();
|
||||
Ok(result.provider_setup)
|
||||
}
|
||||
|
||||
/// Render a newly activated trust step before discarding keys from the preceding screen.
|
||||
///
|
||||
/// Once the step is active, preserve fresh navigation and confirmation input.
|
||||
|
||||
@@ -1,21 +1,16 @@
|
||||
//! Startup guidance shown when no model provider is configured.
|
||||
//! Detect a fresh installation without a model provider.
|
||||
//!
|
||||
//! aKode ships no default provider, so a fresh installation cannot start a model session until
|
||||
//! the user adds one. For now startup prints the setup guidance and exits with an error; a
|
||||
//! first-run onboarding screen can replace [`show_no_model_provider_setup`] later.
|
||||
//! the user adds one; startup then runs the first-run setup (`setup_wizard`).
|
||||
|
||||
use akode_app_server_client::AppServerRequestHandle;
|
||||
use akode_app_server_protocol::ClientRequest;
|
||||
use akode_app_server_protocol::ConfigReadParams;
|
||||
use akode_app_server_protocol::RequestId;
|
||||
use akode_model_provider_info::NO_MODEL_PROVIDER_CONFIGURED_ERROR;
|
||||
use uuid::Uuid;
|
||||
|
||||
use crate::AppExitInfo;
|
||||
use crate::ExitReason;
|
||||
use crate::config_update::EffectiveConfig;
|
||||
use crate::legacy_core::config::Config;
|
||||
use crate::tui::Tui;
|
||||
|
||||
/// Whether neither the local configuration nor the connected app server selects a provider.
|
||||
///
|
||||
@@ -50,18 +45,3 @@ pub(crate) async fn model_provider_missing(
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Explain how to configure a model provider instead of starting a model session.
|
||||
///
|
||||
/// The returned exit info makes the caller print the guidance and exit with a non-zero status.
|
||||
pub(crate) fn show_no_model_provider_setup(tui: &mut Tui) -> AppExitInfo {
|
||||
let _ = tui.terminal.clear();
|
||||
AppExitInfo {
|
||||
token_usage: crate::token_usage::TokenUsage::default(),
|
||||
thread_id: None,
|
||||
resume_hint: None,
|
||||
disconnect_info: None,
|
||||
update_action: None,
|
||||
exit_reason: ExitReason::Fatal(NO_MODEL_PROVIDER_CONFIGURED_ERROR.to_string()),
|
||||
}
|
||||
}
|
||||
|
||||
414
akode-rs/tui/src/onboarding/setup_net.rs
Normal file
414
akode-rs/tui/src/onboarding/setup_net.rs
Normal file
@@ -0,0 +1,414 @@
|
||||
//! Network checks used by the first-run setup: model list and Responses API probe.
|
||||
//!
|
||||
//! Every message returned here is shown to the user, so API keys are redacted from it and
|
||||
//! requests are sent without request logging.
|
||||
|
||||
use std::collections::HashMap;
|
||||
use std::time::Duration;
|
||||
|
||||
use akode_http_client::HttpClient;
|
||||
use akode_http_client::HttpClientBuilder;
|
||||
use serde_json::Value;
|
||||
|
||||
const MODELS_TIMEOUT: Duration = Duration::from_secs(15);
|
||||
/// Slow CPU servers can take a while to prefill even a tiny prompt.
|
||||
const RESPONSES_TIMEOUT: Duration = Duration::from_secs(180);
|
||||
const MAX_ERROR_BODY: usize = 200;
|
||||
|
||||
fn client() -> Result<HttpClient, String> {
|
||||
HttpClientBuilder::new()
|
||||
.without_request_logging()
|
||||
.build_direct()
|
||||
.map_err(|err| format!("Impossibile preparare il client HTTP: {err}"))
|
||||
}
|
||||
|
||||
/// Remove the API key (and anything that looks like an Authorization header) from `text`.
|
||||
pub(crate) fn redact(text: &str, api_key: Option<&str>) -> String {
|
||||
let mut text = text.to_string();
|
||||
if let Some(key) = api_key.map(str::trim).filter(|key| !key.is_empty()) {
|
||||
text = text.replace(key, "••••");
|
||||
}
|
||||
text
|
||||
}
|
||||
|
||||
fn snippet(body: &str) -> String {
|
||||
let body = body.split_whitespace().collect::<Vec<_>>().join(" ");
|
||||
let mut out: String = body.chars().take(MAX_ERROR_BODY).collect();
|
||||
if body.chars().count() > MAX_ERROR_BODY {
|
||||
out.push('…');
|
||||
}
|
||||
out
|
||||
}
|
||||
|
||||
/// `base` without trailing slashes.
|
||||
pub(crate) fn normalize_base_url(base: &str) -> String {
|
||||
base.trim().trim_end_matches('/').to_string()
|
||||
}
|
||||
|
||||
/// Validate a user-entered base URL (http or https, with a host).
|
||||
pub(crate) fn validate_base_url(base: &str) -> Result<String, String> {
|
||||
let base = normalize_base_url(base);
|
||||
match url::Url::parse(&base) {
|
||||
Ok(url) if matches!(url.scheme(), "http" | "https") && url.host_str().is_some() => Ok(base),
|
||||
Ok(_) => Err("L'URL deve iniziare con http:// o https://".to_string()),
|
||||
Err(_) => Err("URL non valido (esempio: http://192.168.1.10:8080/v1)".to_string()),
|
||||
}
|
||||
}
|
||||
|
||||
/// Model ids from an OpenAI-style `{data: [{id}]}` list (or `{models: [{name|model}]}`).
|
||||
pub(crate) fn parse_model_ids(body: &Value) -> Vec<String> {
|
||||
let mut ids: Vec<String> = Vec::new();
|
||||
let mut push = |id: Option<&str>| {
|
||||
if let Some(id) = id.map(str::trim).filter(|id| !id.is_empty())
|
||||
&& !ids.iter().any(|existing| existing == id)
|
||||
{
|
||||
ids.push(id.to_string());
|
||||
}
|
||||
};
|
||||
if let Some(data) = body.get("data").and_then(Value::as_array) {
|
||||
for entry in data {
|
||||
push(entry.get("id").and_then(Value::as_str));
|
||||
}
|
||||
}
|
||||
if let Some(models) = body.get("models").and_then(Value::as_array) {
|
||||
for entry in models {
|
||||
push(
|
||||
entry
|
||||
.get("model")
|
||||
.or_else(|| entry.get("name"))
|
||||
.and_then(Value::as_str),
|
||||
);
|
||||
}
|
||||
}
|
||||
ids
|
||||
}
|
||||
|
||||
/// Context window each model runs with, as reported in its list entry (llama.cpp
|
||||
/// `meta.n_ctx`, vLLM `max_model_len`, OpenRouter `context_length`, LM Studio).
|
||||
pub(crate) fn parse_model_context_windows(body: &Value) -> HashMap<String, i64> {
|
||||
let positive = |value: Option<&Value>| value.and_then(Value::as_i64).filter(|n| *n > 0);
|
||||
let mut windows = HashMap::new();
|
||||
for entry in body
|
||||
.get("data")
|
||||
.and_then(Value::as_array)
|
||||
.into_iter()
|
||||
.flatten()
|
||||
{
|
||||
let Some(id) = entry.get("id").and_then(Value::as_str).map(str::trim) else {
|
||||
continue;
|
||||
};
|
||||
let window = positive(entry.pointer("/meta/n_ctx"))
|
||||
.or_else(|| positive(entry.get("max_model_len")))
|
||||
.or_else(|| positive(entry.get("context_length")))
|
||||
.or_else(|| positive(entry.get("max_context_length")))
|
||||
.or_else(|| positive(entry.get("loaded_context_length")));
|
||||
if let Some(window) = window {
|
||||
windows.insert(id.to_string(), window);
|
||||
}
|
||||
}
|
||||
windows
|
||||
}
|
||||
|
||||
/// Models whose entry lists `supported_parameters` without reasoning (OpenRouter): the
|
||||
/// reasoning setting is hidden for them. Models without the list may support it.
|
||||
pub(crate) fn parse_models_without_reasoning(body: &Value) -> Vec<String> {
|
||||
let mut ids = Vec::new();
|
||||
for entry in body
|
||||
.get("data")
|
||||
.and_then(Value::as_array)
|
||||
.into_iter()
|
||||
.flatten()
|
||||
{
|
||||
let (Some(id), Some(params)) = (
|
||||
entry.get("id").and_then(Value::as_str),
|
||||
entry.get("supported_parameters").and_then(Value::as_array),
|
||||
) else {
|
||||
continue;
|
||||
};
|
||||
if !params
|
||||
.iter()
|
||||
.filter_map(Value::as_str)
|
||||
.any(|param| param == "reasoning")
|
||||
{
|
||||
ids.push(id.trim().to_string());
|
||||
}
|
||||
}
|
||||
ids
|
||||
}
|
||||
|
||||
/// Ids of the models a provider offers for free: an OpenRouter-style `:free` suffix, or a
|
||||
/// `pricing` object whose prompt and completion prices are both zero.
|
||||
pub(crate) fn parse_free_model_ids(body: &Value) -> Vec<String> {
|
||||
let is_zero = |value: Option<&Value>| match value {
|
||||
Some(Value::String(text)) => text.trim().parse::<f64>().is_ok_and(|price| price == 0.0),
|
||||
Some(Value::Number(number)) => number.as_f64().is_some_and(|price| price == 0.0),
|
||||
_ => false,
|
||||
};
|
||||
let mut free = Vec::new();
|
||||
for entry in body
|
||||
.get("data")
|
||||
.and_then(Value::as_array)
|
||||
.into_iter()
|
||||
.flatten()
|
||||
{
|
||||
let Some(id) = entry.get("id").and_then(Value::as_str).map(str::trim) else {
|
||||
continue;
|
||||
};
|
||||
let pricing = entry.get("pricing");
|
||||
let zero_priced = pricing.is_some_and(|pricing| {
|
||||
is_zero(pricing.get("prompt")) && is_zero(pricing.get("completion"))
|
||||
});
|
||||
if (id.ends_with(":free") || zero_priced) && !free.iter().any(|known| known == id) {
|
||||
free.push(id.to_string());
|
||||
}
|
||||
}
|
||||
free
|
||||
}
|
||||
|
||||
fn connection_error(url: &str, err: &impl std::fmt::Display, api_key: Option<&str>) -> String {
|
||||
redact(&format!("Server non raggiungibile ({url}): {err}"), api_key)
|
||||
}
|
||||
|
||||
/// Result of listing models: the base URL that answered (a `/v1` suffix may have been added).
|
||||
#[derive(Debug, Clone, Default, PartialEq, Eq)]
|
||||
pub(crate) struct ModelList {
|
||||
pub base_url: String,
|
||||
pub models: Vec<String>,
|
||||
/// Models that cost nothing (see [`parse_free_model_ids`]).
|
||||
pub free: Vec<String>,
|
||||
/// Server-reported context windows (see [`parse_model_context_windows`]).
|
||||
pub context_windows: HashMap<String, i64>,
|
||||
/// Models known not to support reasoning (see [`parse_models_without_reasoning`]).
|
||||
pub without_reasoning: Vec<String>,
|
||||
}
|
||||
|
||||
/// `GET {base}/models`; when `base` has no path, `{base}/v1/models` is tried too.
|
||||
pub(crate) async fn fetch_models(
|
||||
base: String,
|
||||
api_key: Option<String>,
|
||||
) -> Result<ModelList, String> {
|
||||
let base = normalize_base_url(&base);
|
||||
let client = client()?;
|
||||
let mut candidates = vec![base.clone()];
|
||||
if url::Url::parse(&base).is_ok_and(|url| matches!(url.path(), "" | "/")) {
|
||||
candidates.push(format!("{base}/v1"));
|
||||
}
|
||||
let mut last_error = String::new();
|
||||
for candidate in candidates {
|
||||
let url = format!("{candidate}/models");
|
||||
let mut request = client.get(&url).timeout(MODELS_TIMEOUT);
|
||||
if let Some(key) = api_key.as_deref() {
|
||||
request = request.bearer_auth(key);
|
||||
}
|
||||
let response = match request.send().await {
|
||||
Ok(response) => response,
|
||||
Err(err) => return Err(connection_error(&candidate, &err, api_key.as_deref())),
|
||||
};
|
||||
let status = response.status();
|
||||
if status.as_u16() == 401 || status.as_u16() == 403 {
|
||||
return Err(format!(
|
||||
"Chiave API rifiutata (HTTP {}): controlla la chiave.",
|
||||
status.as_u16()
|
||||
));
|
||||
}
|
||||
if !status.is_success() {
|
||||
let body = response.text().await.unwrap_or_default();
|
||||
last_error = redact(
|
||||
&format!(
|
||||
"GET {url} ha risposto HTTP {}: {}",
|
||||
status.as_u16(),
|
||||
snippet(&body)
|
||||
),
|
||||
api_key.as_deref(),
|
||||
);
|
||||
continue;
|
||||
}
|
||||
let body: Value = match response.json().await {
|
||||
Ok(body) => body,
|
||||
Err(_) => {
|
||||
last_error = format!("GET {url} non ha restituito JSON.");
|
||||
continue;
|
||||
}
|
||||
};
|
||||
let models = parse_model_ids(&body);
|
||||
if models.is_empty() {
|
||||
last_error = "Il server non ha elencato nessun modello.".to_string();
|
||||
continue;
|
||||
}
|
||||
let free = parse_free_model_ids(&body);
|
||||
return Ok(ModelList {
|
||||
base_url: candidate,
|
||||
models,
|
||||
free,
|
||||
context_windows: parse_model_context_windows(&body),
|
||||
without_reasoning: parse_models_without_reasoning(&body),
|
||||
});
|
||||
}
|
||||
Err(last_error)
|
||||
}
|
||||
|
||||
/// llama.cpp `GET /props` (at the server root, without `/v1`): the context window the
|
||||
/// server runs with (`default_generation_settings.n_ctx`, else `n_ctx`). `None` when the
|
||||
/// server has no such endpoint.
|
||||
pub(crate) async fn fetch_props_context_window(
|
||||
base: String,
|
||||
api_key: Option<String>,
|
||||
) -> Option<i64> {
|
||||
let base = normalize_base_url(&base);
|
||||
let root = base.strip_suffix("/v1").unwrap_or(&base);
|
||||
let client = client().ok()?;
|
||||
let mut request = client.get(&format!("{root}/props")).timeout(MODELS_TIMEOUT);
|
||||
if let Some(key) = api_key.as_deref() {
|
||||
request = request.bearer_auth(key);
|
||||
}
|
||||
let response = request.send().await.ok()?;
|
||||
if !response.status().is_success() {
|
||||
return None;
|
||||
}
|
||||
let body: Value = response.json().await.ok()?;
|
||||
let positive = |value: Option<&Value>| value.and_then(Value::as_i64).filter(|n| *n > 0);
|
||||
positive(body.pointer("/default_generation_settings/n_ctx"))
|
||||
.or_else(|| positive(body.get("n_ctx")))
|
||||
}
|
||||
|
||||
/// Explain a failed `POST /responses`.
|
||||
pub(crate) fn classify_responses_failure(status: u16, body: &str, model: &str) -> String {
|
||||
let lower = body.to_lowercase();
|
||||
let mentions_model = lower.contains("model");
|
||||
let not_found = [
|
||||
"not found",
|
||||
"does not exist",
|
||||
"unknown model",
|
||||
"no such model",
|
||||
]
|
||||
.iter()
|
||||
.any(|needle| lower.contains(needle));
|
||||
if status == 401 || status == 403 {
|
||||
format!("Chiave API rifiutata (HTTP {status}): controlla la chiave.")
|
||||
} else if mentions_model && not_found {
|
||||
format!("Modello «{model}» non trovato sul server (HTTP {status}).")
|
||||
} else if matches!(status, 404 | 405 | 501) {
|
||||
format!(
|
||||
"Il server non supporta la Responses API: POST /responses ha risposto HTTP {status}."
|
||||
)
|
||||
} else {
|
||||
format!("Il server ha risposto HTTP {status}: {}", snippet(body))
|
||||
}
|
||||
}
|
||||
|
||||
/// Minimal streaming Responses API request; succeeds once the first event arrives.
|
||||
pub(crate) async fn test_responses(
|
||||
base: String,
|
||||
api_key: Option<String>,
|
||||
model: String,
|
||||
) -> Result<(), String> {
|
||||
let base = normalize_base_url(&base);
|
||||
let client = client()?;
|
||||
let url = format!("{base}/responses");
|
||||
let body = serde_json::json!({
|
||||
"model": model,
|
||||
"input": "ok",
|
||||
"max_output_tokens": 16,
|
||||
"stream": true,
|
||||
});
|
||||
let mut request = client.post(&url).timeout(RESPONSES_TIMEOUT).json(&body);
|
||||
if let Some(key) = api_key.as_deref() {
|
||||
request = request.bearer_auth(key);
|
||||
}
|
||||
let mut response = match request.send().await {
|
||||
Ok(response) => response,
|
||||
Err(err) => return Err(connection_error(&base, &err, api_key.as_deref())),
|
||||
};
|
||||
let status = response.status();
|
||||
if !status.is_success() {
|
||||
let body = response.text().await.unwrap_or_default();
|
||||
return Err(redact(
|
||||
&classify_responses_failure(status.as_u16(), &body, &model),
|
||||
api_key.as_deref(),
|
||||
));
|
||||
}
|
||||
match response.chunk().await {
|
||||
Ok(Some(chunk)) => {
|
||||
let text = String::from_utf8_lossy(&chunk);
|
||||
if text.contains("data:")
|
||||
|| text.contains("event:")
|
||||
|| text.trim_start().starts_with('{')
|
||||
{
|
||||
Ok(())
|
||||
} else {
|
||||
Err("Risposta inattesa da /responses (non è uno stream di eventi).".to_string())
|
||||
}
|
||||
}
|
||||
Ok(None) => Err("Il server ha chiuso la risposta senza dati.".to_string()),
|
||||
Err(err) => Err(redact(
|
||||
&format!("Lettura della risposta non riuscita: {err}"),
|
||||
api_key.as_deref(),
|
||||
)),
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use pretty_assertions::assert_eq;
|
||||
|
||||
#[test]
|
||||
fn parses_openai_and_llama_cpp_model_lists() {
|
||||
let body = serde_json::json!({
|
||||
"models": [{"name": "qwen3.6-35b-a3b", "model": "qwen3.6-35b-a3b"}],
|
||||
"data": [{"id": "qwen3.6-35b-a3b"}, {"id": "other"}],
|
||||
});
|
||||
assert_eq!(parse_model_ids(&body), vec!["qwen3.6-35b-a3b", "other"]);
|
||||
assert!(parse_model_ids(&serde_json::json!({"data": []})).is_empty());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn finds_free_models_by_suffix_or_zero_pricing() {
|
||||
let body = serde_json::json!({
|
||||
"data": [
|
||||
{"id": "meta-llama/llama-3.3-70b-instruct:free", "pricing": {"prompt": "0.0000001", "completion": "0"}},
|
||||
{"id": "openrouter/zero", "pricing": {"prompt": "0", "completion": "0"}},
|
||||
{"id": "local-number", "pricing": {"prompt": 0, "completion": 0.0}},
|
||||
{"id": "anthropic/paid", "pricing": {"prompt": "0.000003", "completion": "0.000015"}},
|
||||
{"id": "no-pricing"},
|
||||
],
|
||||
});
|
||||
assert_eq!(
|
||||
parse_free_model_ids(&body),
|
||||
vec![
|
||||
"meta-llama/llama-3.3-70b-instruct:free",
|
||||
"openrouter/zero",
|
||||
"local-number"
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn validates_base_urls() {
|
||||
assert_eq!(
|
||||
validate_base_url(" http://192.168.40.25:8080/v1/ "),
|
||||
Ok("http://192.168.40.25:8080/v1".to_string())
|
||||
);
|
||||
assert!(validate_base_url("ftp://host").is_err());
|
||||
assert!(validate_base_url("not a url").is_err());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn classifies_responses_failures() {
|
||||
assert!(classify_responses_failure(401, "", "m").contains("Chiave API rifiutata"));
|
||||
assert!(
|
||||
classify_responses_failure(404, "{\"error\":\"model 'm' not found\"}", "m")
|
||||
.contains("Modello «m» non trovato")
|
||||
);
|
||||
assert!(classify_responses_failure(404, "File Not Found", "m").contains("Responses API"));
|
||||
assert!(classify_responses_failure(500, "boom", "m").contains("HTTP 500: boom"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn redacts_api_keys_from_messages() {
|
||||
let key = "sk-secret-123456";
|
||||
let message = redact(&format!("HTTP 400: invalid key {key}"), Some(key));
|
||||
assert!(!message.contains(key));
|
||||
assert!(message.contains("••••"));
|
||||
}
|
||||
}
|
||||
1568
akode-rs/tui/src/onboarding/setup_wizard.rs
Normal file
1568
akode-rs/tui/src/onboarding/setup_wizard.rs
Normal file
File diff suppressed because it is too large
Load Diff
461
akode-rs/tui/src/onboarding/setup_wizard_tests.rs
Normal file
461
akode-rs/tui/src/onboarding/setup_wizard_tests.rs
Normal file
@@ -0,0 +1,461 @@
|
||||
use super::*;
|
||||
use pretty_assertions::assert_eq;
|
||||
use ratatui::buffer::Buffer;
|
||||
use ratatui::layout::Rect;
|
||||
|
||||
const SECRET: &str = "sk-akode-test-secret-0123456789";
|
||||
|
||||
fn wizard() -> SetupWizard {
|
||||
let mut ctx = SetupContext {
|
||||
key_store_mode: AuthCredentialsStoreMode::Auto,
|
||||
keyring_available: true,
|
||||
..Default::default()
|
||||
};
|
||||
ctx.existing_provider_ids
|
||||
.extend(["ollama".to_string(), "lmstudio".to_string()]);
|
||||
SetupWizard::new(FrameRequester::test_dummy(), ctx)
|
||||
}
|
||||
|
||||
fn key(code: KeyCode) -> KeyEvent {
|
||||
KeyEvent::new(code, KeyModifiers::NONE)
|
||||
}
|
||||
|
||||
fn type_text(wizard: &mut SetupWizard, text: &str) {
|
||||
for ch in text.chars() {
|
||||
wizard.handle_key_event(key(KeyCode::Char(ch)));
|
||||
}
|
||||
}
|
||||
|
||||
fn render(wizard: &SetupWizard, width: u16, height: u16) -> String {
|
||||
let area = Rect::new(0, 0, width, height);
|
||||
let mut buf = Buffer::empty(area);
|
||||
wizard.render_ref(area, &mut buf);
|
||||
(0..height)
|
||||
.map(|y| {
|
||||
(0..width)
|
||||
.map(|x| buf[(x, y)].symbol().to_string())
|
||||
.collect::<String>()
|
||||
.trim_end()
|
||||
.to_string()
|
||||
})
|
||||
.collect::<Vec<_>>()
|
||||
.join("\n")
|
||||
.trim_end()
|
||||
.to_string()
|
||||
}
|
||||
|
||||
/// Every row fits the terminal width (no wrapping, nothing cut mid-glyph).
|
||||
fn assert_fits(rendered: &str, width: u16) {
|
||||
for line in rendered.lines() {
|
||||
assert!(
|
||||
display_width(line) <= usize::from(width),
|
||||
"line wider than {width}: {line:?}"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
fn snapshot_all_widths(name: &str, wizard: &SetupWizard, height: u16) {
|
||||
for width in [80u16, 120, 60] {
|
||||
let rendered = render(wizard, width, height);
|
||||
assert_fits(&rendered, width);
|
||||
insta::assert_snapshot!(format!("{name}_{width}"), rendered);
|
||||
}
|
||||
}
|
||||
|
||||
fn endpoint_wizard() -> SetupWizard {
|
||||
let mut wizard = wizard();
|
||||
wizard.go(Page::Endpoint);
|
||||
type_text(&mut wizard, "imeAI");
|
||||
wizard.handle_key_event(key(KeyCode::Tab));
|
||||
type_text(&mut wizard, "http://192.168.40.25:8080/v1");
|
||||
wizard.handle_key_event(key(KeyCode::Tab));
|
||||
type_text(&mut wizard, SECRET);
|
||||
wizard
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn welcome_screen() {
|
||||
snapshot_all_widths("setup_welcome", &wizard(), 18);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn provider_screen() {
|
||||
let mut wizard = wizard();
|
||||
wizard.go(Page::Provider);
|
||||
snapshot_all_widths("setup_provider", &wizard, 14);
|
||||
wizard.handle_key_event(key(KeyCode::Enter));
|
||||
assert_eq!(wizard.page, Page::Endpoint);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn endpoint_form_masks_the_key() {
|
||||
let mut wizard = endpoint_wizard();
|
||||
snapshot_all_widths("setup_endpoint", &wizard, 16);
|
||||
for width in [40u16, 60, 80, 120, 200] {
|
||||
assert!(!render(&wizard, width, 16).contains(SECRET));
|
||||
assert!(!render(&wizard, width, 16).contains("sk-akode"));
|
||||
}
|
||||
// Moving off the key field keeps it masked.
|
||||
wizard.handle_key_event(key(KeyCode::Tab));
|
||||
assert!(!render(&wizard, 80, 16).contains("sk-akode"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn endpoint_form_validates_before_fetching_models() {
|
||||
let mut wizard = wizard();
|
||||
wizard.go(Page::Endpoint);
|
||||
wizard.form_focus = 3;
|
||||
wizard.handle_key_event(key(KeyCode::Enter));
|
||||
assert_eq!(wizard.page, Page::Endpoint);
|
||||
assert_eq!(wizard.form_focus, 0);
|
||||
type_text(&mut wizard, "x");
|
||||
wizard.handle_key_event(key(KeyCode::Tab));
|
||||
type_text(&mut wizard, "ftp://nope");
|
||||
wizard.form_focus = 3;
|
||||
wizard.handle_key_event(key(KeyCode::Enter));
|
||||
assert_eq!(wizard.page, Page::Endpoint);
|
||||
assert!(
|
||||
wizard
|
||||
.form_error
|
||||
.as_deref()
|
||||
.is_some_and(|e| e.contains("http"))
|
||||
);
|
||||
insta::assert_snapshot!("setup_endpoint_error_80", render(&wizard, 80, 18));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn model_list_screen() {
|
||||
let mut wizard = endpoint_wizard();
|
||||
wizard.form_focus = 3;
|
||||
wizard.handle_key_event(key(KeyCode::Enter));
|
||||
// A key was entered: choose where to store it first.
|
||||
assert_eq!(wizard.page, Page::KeyStore);
|
||||
wizard.handle_key_event(key(KeyCode::Enter));
|
||||
assert_eq!(wizard.page, Page::Model);
|
||||
assert!(wizard.pending.is_some());
|
||||
insta::assert_snapshot!("setup_model_loading_80", render(&wizard, 80, 12));
|
||||
wizard.apply(Outcome::Models(Ok(setup_net::ModelList {
|
||||
base_url: "http://192.168.40.25:8080/v1".to_string(),
|
||||
models: vec![
|
||||
"qwen3.6-35b-a3b".to_string(),
|
||||
"qwen3-coder-30b-a3b".to_string(),
|
||||
"gemma-3-4b-it".to_string(),
|
||||
],
|
||||
free: Vec::new(),
|
||||
..Default::default()
|
||||
})));
|
||||
snapshot_all_widths("setup_model_list", &wizard, 14);
|
||||
// The last row switches to manual entry.
|
||||
for _ in 0..3 {
|
||||
wizard.handle_key_event(key(KeyCode::Down));
|
||||
}
|
||||
wizard.handle_key_event(key(KeyCode::Enter));
|
||||
assert!(wizard.model_input_active());
|
||||
type_text(&mut wizard, "my-model");
|
||||
insta::assert_snapshot!("setup_model_manual_80", render(&wizard, 80, 12));
|
||||
wizard.handle_key_event(key(KeyCode::Enter));
|
||||
assert_eq!(wizard.page, Page::Test);
|
||||
assert_eq!(wizard.model, "my-model");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn model_list_failure_offers_manual_entry() {
|
||||
let mut wizard = endpoint_wizard();
|
||||
wizard.base_url = "http://192.168.40.25:8080/v1".to_string();
|
||||
wizard.start_models();
|
||||
wizard.apply(Outcome::Models(Err(
|
||||
"Server non raggiungibile (http://192.168.40.25:8080/v1): connection refused".to_string(),
|
||||
)));
|
||||
assert!(wizard.is_text_entry_active());
|
||||
insta::assert_snapshot!("setup_model_failed_80", render(&wizard, 80, 14));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn connection_test_screens() {
|
||||
let mut wizard = endpoint_wizard();
|
||||
wizard.base_url = "http://192.168.40.25:8080/v1".to_string();
|
||||
wizard.start_test("qwen3.6-35b-a3b".to_string());
|
||||
insta::assert_snapshot!("setup_test_running_80", render(&wizard, 80, 12));
|
||||
wizard.apply(Outcome::Test(Ok(())));
|
||||
snapshot_all_widths("setup_test_ok", &wizard, 12);
|
||||
wizard.start_test("qwen3.6-35b-a3b".to_string());
|
||||
wizard.apply(Outcome::Test(Err(setup_net::classify_responses_failure(
|
||||
401,
|
||||
"",
|
||||
"qwen3.6-35b-a3b",
|
||||
))));
|
||||
snapshot_all_widths("setup_test_failed", &wizard, 14);
|
||||
// "Torna indietro e correggi" returns to the form.
|
||||
wizard.handle_key_event(key(KeyCode::Down));
|
||||
wizard.handle_key_event(key(KeyCode::Enter));
|
||||
assert_eq!(wizard.page, Page::Endpoint);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn config_edits_keep_the_key_out_of_config() {
|
||||
let mut wizard = endpoint_wizard();
|
||||
wizard.base_url = "http://192.168.40.25:8080/v1".to_string();
|
||||
wizard.model = "qwen3.6-35b-a3b".to_string();
|
||||
let id = SetupWizard::provider_id_for("imeAI", &wizard.ctx.existing_provider_ids);
|
||||
let edits = wizard.config_edits(&id, "imeAI", /*has_key*/ true);
|
||||
let rendered = serde_json::to_string(
|
||||
&edits
|
||||
.iter()
|
||||
.map(|edit| (edit.key_path.clone(), edit.value.clone()))
|
||||
.collect::<Vec<_>>(),
|
||||
)
|
||||
.expect("json");
|
||||
assert!(!rendered.contains(SECRET));
|
||||
assert_eq!(
|
||||
edits
|
||||
.iter()
|
||||
.map(|edit| (edit.key_path.as_str(), edit.value.clone()))
|
||||
.collect::<Vec<_>>(),
|
||||
vec![
|
||||
(
|
||||
"model_providers.imeai",
|
||||
serde_json::json!({
|
||||
"name": "imeAI",
|
||||
"base_url": "http://192.168.40.25:8080/v1",
|
||||
"wire_api": "responses",
|
||||
"api_key": "keyring",
|
||||
})
|
||||
),
|
||||
("model_provider", serde_json::json!("imeai")),
|
||||
("model", serde_json::json!("qwen3.6-35b-a3b")),
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn local_providers_write_no_provider_table() {
|
||||
let mut wizard = wizard();
|
||||
wizard.go(Page::Provider);
|
||||
wizard.handle_key_event(key(KeyCode::Char('2')));
|
||||
wizard.handle_key_event(key(KeyCode::Enter));
|
||||
assert_eq!(wizard.page, Page::Model);
|
||||
assert_eq!(wizard.base_url, "http://localhost:11434/v1");
|
||||
assert_eq!(wizard.api_key(), None);
|
||||
wizard.model = "llama3".to_string();
|
||||
let edits = wizard.config_edits("ollama", "Ollama locale", /*has_key*/ false);
|
||||
assert!(
|
||||
edits
|
||||
.iter()
|
||||
.all(|edit| !edit.key_path.starts_with("model_providers"))
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn provider_ids_are_unique_slugs() {
|
||||
let mut existing = BTreeSet::from(["ollama".to_string(), "imeai".to_string()]);
|
||||
assert_eq!(SetupWizard::provider_id_for("imeAI", &existing), "imeai-2");
|
||||
existing.insert("imeai-2".to_string());
|
||||
assert_eq!(SetupWizard::provider_id_for("imeAI", &existing), "imeai-3");
|
||||
assert_eq!(
|
||||
SetupWizard::provider_id_for(" Server di Andrea (GPU)! ", &existing),
|
||||
"server-di-andrea-gpu"
|
||||
);
|
||||
assert_eq!(SetupWizard::provider_id_for("Città", &existing), "citta");
|
||||
assert_eq!(SetupWizard::provider_id_for("***", &existing), "endpoint");
|
||||
assert_eq!(
|
||||
SetupWizard::provider_id_for("OpenAI", &existing),
|
||||
"openai-2"
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn saving_failure_can_retry() {
|
||||
let mut wizard = endpoint_wizard();
|
||||
wizard.model = "qwen3.6-35b-a3b".to_string();
|
||||
wizard.go(Page::Saving);
|
||||
wizard.save =
|
||||
CheckState::Failed("Impossibile scrivere config.toml: permesso negato".to_string());
|
||||
insta::assert_snapshot!("setup_save_failed_80", render(&wizard, 80, 12));
|
||||
assert!(!render(&wizard, 80, 12).contains(SECRET));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn long_model_list_filters_by_text_and_free_toggle() {
|
||||
let mut wizard = endpoint_wizard();
|
||||
wizard.base_url = "https://openrouter.ai/api/v1".to_string();
|
||||
wizard.start_models();
|
||||
let mut models: Vec<String> = (0..300).map(|i| format!("vendor/model-{i:03}")).collect();
|
||||
models.push("qwen/qwen3-coder:free".to_string());
|
||||
models.push("google/gemma-3-27b-it:free".to_string());
|
||||
models.push("qwen/qwen3-coder".to_string());
|
||||
wizard.apply(Outcome::Models(Ok(setup_net::ModelList {
|
||||
base_url: "https://openrouter.ai/api/v1".to_string(),
|
||||
models,
|
||||
free: vec![
|
||||
"qwen/qwen3-coder:free".to_string(),
|
||||
"google/gemma-3-27b-it:free".to_string(),
|
||||
],
|
||||
..Default::default()
|
||||
})));
|
||||
assert!(
|
||||
wizard.is_text_entry_active(),
|
||||
"typed text goes to the filter"
|
||||
);
|
||||
snapshot_all_widths("setup_model_search_empty", &wizard, 20);
|
||||
|
||||
// `j`/`k` are text here, not navigation.
|
||||
type_text(&mut wizard, "qwen");
|
||||
snapshot_all_widths("setup_model_search_qwen", &wizard, 20);
|
||||
wizard.handle_key_event(key(KeyCode::Tab));
|
||||
snapshot_all_widths("setup_model_search_qwen_free", &wizard, 20);
|
||||
wizard.handle_key_event(key(KeyCode::Enter));
|
||||
assert_eq!(wizard.page, Page::Test);
|
||||
assert_eq!(wizard.model, "qwen/qwen3-coder:free");
|
||||
|
||||
// Esc clears the filter before leaving the page; Backspace edits it.
|
||||
wizard.start_models();
|
||||
wizard.apply(Outcome::Models(Ok(setup_net::ModelList {
|
||||
base_url: "https://openrouter.ai/api/v1".to_string(),
|
||||
models: (0..20).map(|i| format!("m-{i}")).collect(),
|
||||
free: Vec::new(),
|
||||
..Default::default()
|
||||
})));
|
||||
type_text(&mut wizard, "zz");
|
||||
let rendered = render(&wizard, 80, 16);
|
||||
assert!(
|
||||
rendered.contains("Nessun modello corrisponde."),
|
||||
"{rendered}"
|
||||
);
|
||||
assert!(
|
||||
!rendered.contains("solo gratuiti"),
|
||||
"no toggle without free models"
|
||||
);
|
||||
wizard.handle_key_event(key(KeyCode::Backspace));
|
||||
wizard.handle_key_event(key(KeyCode::Esc));
|
||||
assert_eq!(wizard.page, Page::Model);
|
||||
let ModelsState::Loaded { filter, .. } = &wizard.models else {
|
||||
panic!("models stay loaded");
|
||||
};
|
||||
assert!(filter.is_empty());
|
||||
wizard.handle_key_event(key(KeyCode::Down));
|
||||
wizard.handle_key_event(key(KeyCode::Enter));
|
||||
assert_eq!(wizard.model, "m-1");
|
||||
}
|
||||
|
||||
/// The endpoint form with a key, confirmed: the key storage choice follows.
|
||||
fn key_store_wizard(configure: impl FnOnce(&mut SetupContext)) -> SetupWizard {
|
||||
let mut ctx = wizard().ctx.clone();
|
||||
configure(&mut ctx);
|
||||
let mut wizard = SetupWizard::new(FrameRequester::test_dummy(), ctx);
|
||||
wizard.go(Page::Endpoint);
|
||||
type_text(&mut wizard, "imeAI");
|
||||
wizard.handle_key_event(key(KeyCode::Tab));
|
||||
type_text(&mut wizard, "http://192.168.40.25:8080/v1");
|
||||
wizard.handle_key_event(key(KeyCode::Tab));
|
||||
type_text(&mut wizard, SECRET);
|
||||
wizard.handle_key_event(key(KeyCode::Tab));
|
||||
wizard.handle_key_event(key(KeyCode::Enter));
|
||||
assert_eq!(wizard.page, Page::KeyStore);
|
||||
wizard
|
||||
}
|
||||
|
||||
fn key_store_edit(wizard: &SetupWizard) -> Option<serde_json::Value> {
|
||||
let edits = wizard.config_edits("imeai", "imeAI", /*has_key*/ true);
|
||||
let rendered = serde_json::to_string(
|
||||
&edits
|
||||
.iter()
|
||||
.map(|edit| (edit.key_path.clone(), edit.value.clone()))
|
||||
.collect::<Vec<_>>(),
|
||||
)
|
||||
.expect("json");
|
||||
assert!(!rendered.contains(SECRET));
|
||||
edits
|
||||
.into_iter()
|
||||
.find(|edit| edit.key_path == "provider_api_key_store")
|
||||
.map(|edit| edit.value)
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn key_store_choice_defaults_to_the_keyring() {
|
||||
let mut wizard = key_store_wizard(|_| {});
|
||||
snapshot_all_widths("setup_key_store", &wizard, 12);
|
||||
assert!(!wizard.key_in_file);
|
||||
assert_eq!(key_store_edit(&wizard), None);
|
||||
wizard.handle_key_event(key(KeyCode::Down));
|
||||
assert!(wizard.key_in_file);
|
||||
snapshot_all_widths("setup_key_store_file", &wizard, 14);
|
||||
assert_eq!(key_store_edit(&wizard), Some(serde_json::json!("file")));
|
||||
for width in [40u16, 60, 80, 120] {
|
||||
assert!(!render(&wizard, width, 14).contains("sk-akode"));
|
||||
}
|
||||
wizard.handle_key_event(key(KeyCode::Esc));
|
||||
assert_eq!(wizard.page, Page::Endpoint);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn key_store_choice_preselects_the_configured_file() {
|
||||
let mut wizard = key_store_wizard(|ctx| ctx.key_store_mode = AuthCredentialsStoreMode::File);
|
||||
assert!(wizard.key_in_file);
|
||||
assert_eq!(key_store_edit(&wizard), None);
|
||||
wizard.handle_key_event(key(KeyCode::Char('1')));
|
||||
assert!(!wizard.key_in_file);
|
||||
assert_eq!(key_store_edit(&wizard), Some(serde_json::json!("auto")));
|
||||
wizard.handle_key_event(key(KeyCode::Enter));
|
||||
assert_eq!(wizard.page, Page::Model);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn key_store_choice_offers_only_the_file_without_a_keyring() {
|
||||
let mut wizard = key_store_wizard(|ctx| ctx.keyring_available = false);
|
||||
assert!(wizard.key_in_file);
|
||||
wizard.handle_key_event(key(KeyCode::Up));
|
||||
assert!(wizard.key_in_file);
|
||||
snapshot_all_widths("setup_key_store_no_keyring", &wizard, 14);
|
||||
assert_eq!(key_store_edit(&wizard), Some(serde_json::json!("file")));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn endpoint_without_a_key_skips_the_storage_choice() {
|
||||
let mut wizard = wizard();
|
||||
wizard.go(Page::Endpoint);
|
||||
type_text(&mut wizard, "imeAI");
|
||||
wizard.handle_key_event(key(KeyCode::Tab));
|
||||
type_text(&mut wizard, "http://192.168.40.25:8080/v1");
|
||||
wizard.form_focus = 3;
|
||||
wizard.handle_key_event(key(KeyCode::Enter));
|
||||
assert_eq!(wizard.page, Page::Model);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn endpoint_mode_edits_keep_the_key_out_of_config() {
|
||||
let mut ctx = SetupContext {
|
||||
key_store_mode: AuthCredentialsStoreMode::Auto,
|
||||
keyring_available: true,
|
||||
endpoint_mode: Some(EndpointMode {
|
||||
edit: Some(EndpointEdit {
|
||||
provider_id: "giulio".to_string(),
|
||||
name: "Giulio".to_string(),
|
||||
base_url: "https://mega-link.cloud/v1".to_string(),
|
||||
stored_key: Some(SECRET.to_string()),
|
||||
}),
|
||||
}),
|
||||
..Default::default()
|
||||
};
|
||||
ctx.existing_provider_ids.insert("giulio".to_string());
|
||||
let mut wizard = SetupWizard::new(FrameRequester::test_dummy(), ctx);
|
||||
assert_eq!(wizard.page, Page::Endpoint);
|
||||
assert!(!render(&wizard, 80, 14).contains(SECRET));
|
||||
wizard.handle_key_event(key(KeyCode::Down));
|
||||
wizard.handle_key_event(key(KeyCode::Down));
|
||||
type_text(&mut wizard, SECRET);
|
||||
wizard.base_url = "https://mega-link.cloud/v1".to_string();
|
||||
let edits = wizard.endpoint_config_edits("giulio", "Giulio", true);
|
||||
let json = serde_json::to_string(
|
||||
&edits
|
||||
.iter()
|
||||
.map(|e| (&e.key_path, &e.value))
|
||||
.collect::<Vec<_>>(),
|
||||
)
|
||||
.expect("serialize");
|
||||
assert!(!json.contains(SECRET));
|
||||
assert!(json.contains("model_providers.giulio.api_key"));
|
||||
assert!(!json.contains("model_providers.giulio.models"));
|
||||
assert!(!json.contains("\"model\""));
|
||||
assert!(!render(&wizard, 80, 14).contains(SECRET));
|
||||
}
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
---
|
||||
source: tui/src/onboarding/setup_wizard_tests.rs
|
||||
expression: rendered
|
||||
---
|
||||
|
||||
Endpoint personalizzato passo 2 di 4
|
||||
|
||||
Chiave facoltativa: non finisce mai in config.toml.
|
||||
|
||||
Nome imeAI
|
||||
URL http://192.168.40.25:8080/v1
|
||||
› Chiave API •••••••••••••••••••••••••••••••
|
||||
|
||||
[ Avanti ]
|
||||
|
||||
tab/↑/↓ campo · invio avanti · esc indietro
|
||||
@@ -0,0 +1,16 @@
|
||||
---
|
||||
source: tui/src/onboarding/setup_wizard_tests.rs
|
||||
expression: rendered
|
||||
---
|
||||
|
||||
Endpoint personalizzato passo 2 di 4
|
||||
|
||||
Chiave facoltativa: non finisce mai in config.toml.
|
||||
|
||||
Nome imeAI
|
||||
URL http://192.168.40.25:8080/v1
|
||||
› Chiave API •••••••••••••••••••••••••••••••
|
||||
|
||||
[ Avanti ]
|
||||
|
||||
tab/↑/↓ campo · invio avanti · esc indietro
|
||||
@@ -0,0 +1,16 @@
|
||||
---
|
||||
source: tui/src/onboarding/setup_wizard_tests.rs
|
||||
expression: rendered
|
||||
---
|
||||
|
||||
Endpoint personalizzato passo 2 di 4
|
||||
|
||||
Chiave facoltativa: non finisce mai in config.toml.
|
||||
|
||||
Nome imeAI
|
||||
URL http://192.168.40.25:8080/v1
|
||||
› Chiave API •••••••••••••••••••••••••••••••
|
||||
|
||||
[ Avanti ]
|
||||
|
||||
tab/↑/↓ campo · invio avanti · esc indietro
|
||||
@@ -0,0 +1,18 @@
|
||||
---
|
||||
source: tui/src/onboarding/setup_wizard_tests.rs
|
||||
expression: "render(&wizard, 80, 18)"
|
||||
---
|
||||
|
||||
Endpoint personalizzato passo 2 di 4
|
||||
|
||||
Chiave facoltativa: non finisce mai in config.toml.
|
||||
|
||||
Nome x
|
||||
› URL ftp://nope
|
||||
Chiave API facoltativa
|
||||
|
||||
[ Avanti ]
|
||||
|
||||
L'URL deve iniziare con http:// o https://
|
||||
|
||||
tab/↑/↓ campo · invio avanti · esc indietro
|
||||
@@ -0,0 +1,13 @@
|
||||
---
|
||||
source: tui/src/onboarding/setup_wizard_tests.rs
|
||||
expression: rendered
|
||||
---
|
||||
|
||||
Dove salvo la chiave? passo 2 di 4
|
||||
|
||||
La chiave API non finisce mai in config.toml.
|
||||
|
||||
› 1. Portachiavi del sistema (consigliato)
|
||||
2. File protetto (solo il tuo utente, permessi 600)
|
||||
|
||||
↑/↓ scegli · invio conferma · esc indietro
|
||||
@@ -0,0 +1,13 @@
|
||||
---
|
||||
source: tui/src/onboarding/setup_wizard_tests.rs
|
||||
expression: rendered
|
||||
---
|
||||
|
||||
Dove salvo la chiave? passo 2 di 4
|
||||
|
||||
La chiave API non finisce mai in config.toml.
|
||||
|
||||
› 1. Portachiavi del sistema (consigliato)
|
||||
2. File protetto (solo il tuo utente, perm…
|
||||
|
||||
↑/↓ scegli · invio conferma · esc indietro
|
||||
@@ -0,0 +1,13 @@
|
||||
---
|
||||
source: tui/src/onboarding/setup_wizard_tests.rs
|
||||
expression: rendered
|
||||
---
|
||||
|
||||
Dove salvo la chiave? passo 2 di 4
|
||||
|
||||
La chiave API non finisce mai in config.toml.
|
||||
|
||||
› 1. Portachiavi del sistema (consigliato)
|
||||
2. File protetto (solo il tuo utente, permessi 600)
|
||||
|
||||
↑/↓ scegli · invio conferma · esc indietro
|
||||
@@ -0,0 +1,15 @@
|
||||
---
|
||||
source: tui/src/onboarding/setup_wizard_tests.rs
|
||||
expression: rendered
|
||||
---
|
||||
|
||||
Dove salvo la chiave? passo 2 di 4
|
||||
|
||||
La chiave API non finisce mai in config.toml.
|
||||
|
||||
1. Portachiavi del sistema (consigliato)
|
||||
› 2. File protetto (solo il tuo utente, permessi 600)
|
||||
|
||||
Vale per tutti i provider: le altre chiavi si spostano.
|
||||
|
||||
↑/↓ scegli · invio conferma · esc indietro
|
||||
@@ -0,0 +1,15 @@
|
||||
---
|
||||
source: tui/src/onboarding/setup_wizard_tests.rs
|
||||
expression: rendered
|
||||
---
|
||||
|
||||
Dove salvo la chiave? passo 2 di 4
|
||||
|
||||
La chiave API non finisce mai in config.toml.
|
||||
|
||||
1. Portachiavi del sistema (consigliato)
|
||||
› 2. File protetto (solo il tuo utente, perm…
|
||||
|
||||
Vale per tutti i provider: le altre chiavi si spostano.
|
||||
|
||||
↑/↓ scegli · invio conferma · esc indietro
|
||||
@@ -0,0 +1,15 @@
|
||||
---
|
||||
source: tui/src/onboarding/setup_wizard_tests.rs
|
||||
expression: rendered
|
||||
---
|
||||
|
||||
Dove salvo la chiave? passo 2 di 4
|
||||
|
||||
La chiave API non finisce mai in config.toml.
|
||||
|
||||
1. Portachiavi del sistema (consigliato)
|
||||
› 2. File protetto (solo il tuo utente, permessi 600)
|
||||
|
||||
Vale per tutti i provider: le altre chiavi si spostano.
|
||||
|
||||
↑/↓ scegli · invio conferma · esc indietro
|
||||
@@ -0,0 +1,14 @@
|
||||
---
|
||||
source: tui/src/onboarding/setup_wizard_tests.rs
|
||||
expression: rendered
|
||||
---
|
||||
|
||||
Dove salvo la chiave? passo 2 di 4
|
||||
|
||||
Portachiavi del sistema non disponibile: uso il file.
|
||||
|
||||
› 1. File protetto (solo il tuo utente, permessi 600)
|
||||
|
||||
Vale per tutti i provider: le altre chiavi si spostano.
|
||||
|
||||
invio conferma · esc indietro
|
||||
@@ -0,0 +1,14 @@
|
||||
---
|
||||
source: tui/src/onboarding/setup_wizard_tests.rs
|
||||
expression: rendered
|
||||
---
|
||||
|
||||
Dove salvo la chiave? passo 2 di 4
|
||||
|
||||
Portachiavi del sistema non disponibile: uso il file.
|
||||
|
||||
› 1. File protetto (solo il tuo utente, perm…
|
||||
|
||||
Vale per tutti i provider: le altre chiavi si spostano.
|
||||
|
||||
invio conferma · esc indietro
|
||||
@@ -0,0 +1,14 @@
|
||||
---
|
||||
source: tui/src/onboarding/setup_wizard_tests.rs
|
||||
expression: rendered
|
||||
---
|
||||
|
||||
Dove salvo la chiave? passo 2 di 4
|
||||
|
||||
Portachiavi del sistema non disponibile: uso il file.
|
||||
|
||||
› 1. File protetto (solo il tuo utente, permessi 600)
|
||||
|
||||
Vale per tutti i provider: le altre chiavi si spostano.
|
||||
|
||||
invio conferma · esc indietro
|
||||
@@ -0,0 +1,15 @@
|
||||
---
|
||||
source: tui/src/onboarding/setup_wizard_tests.rs
|
||||
expression: "render(&wizard, 80, 14)"
|
||||
---
|
||||
|
||||
Modello passo 3 di 4
|
||||
|
||||
Server: http://192.168.40.25:8080/v1
|
||||
|
||||
Elenco dei modelli non disponibile: Server non raggiungibile
|
||||
(http://192.168.40.25:8080/v1): connection refused
|
||||
|
||||
› Modello nome del modello
|
||||
|
||||
invio conferma · esc indietro
|
||||
@@ -0,0 +1,15 @@
|
||||
---
|
||||
source: tui/src/onboarding/setup_wizard_tests.rs
|
||||
expression: rendered
|
||||
---
|
||||
|
||||
Modello passo 3 di 4
|
||||
|
||||
Server: http://192.168.40.25:8080/v1
|
||||
|
||||
› 1. qwen3.6-35b-a3b
|
||||
2. qwen3-coder-30b-a3b
|
||||
3. gemma-3-4b-it
|
||||
4. Inserisci il nome a mano…
|
||||
|
||||
↑/↓ scegli · invio conferma · esc indietro
|
||||
@@ -0,0 +1,15 @@
|
||||
---
|
||||
source: tui/src/onboarding/setup_wizard_tests.rs
|
||||
expression: rendered
|
||||
---
|
||||
|
||||
Modello passo 3 di 4
|
||||
|
||||
Server: http://192.168.40.25:8080/v1
|
||||
|
||||
› 1. qwen3.6-35b-a3b
|
||||
2. qwen3-coder-30b-a3b
|
||||
3. gemma-3-4b-it
|
||||
4. Inserisci il nome a mano…
|
||||
|
||||
↑/↓ scegli · invio conferma · esc indietro
|
||||
@@ -0,0 +1,15 @@
|
||||
---
|
||||
source: tui/src/onboarding/setup_wizard_tests.rs
|
||||
expression: rendered
|
||||
---
|
||||
|
||||
Modello passo 3 di 4
|
||||
|
||||
Server: http://192.168.40.25:8080/v1
|
||||
|
||||
› 1. qwen3.6-35b-a3b
|
||||
2. qwen3-coder-30b-a3b
|
||||
3. gemma-3-4b-it
|
||||
4. Inserisci il nome a mano…
|
||||
|
||||
↑/↓ scegli · invio conferma · esc indietro
|
||||
@@ -0,0 +1,12 @@
|
||||
---
|
||||
source: tui/src/onboarding/setup_wizard_tests.rs
|
||||
expression: "render(&wizard, 80, 12)"
|
||||
---
|
||||
|
||||
Modello passo 3 di 4
|
||||
|
||||
Server: http://192.168.40.25:8080/v1
|
||||
|
||||
Lettura dell'elenco dei modelli…
|
||||
|
||||
esc indietro
|
||||
@@ -0,0 +1,12 @@
|
||||
---
|
||||
source: tui/src/onboarding/setup_wizard_tests.rs
|
||||
expression: "render(&wizard, 80, 12)"
|
||||
---
|
||||
|
||||
Modello passo 3 di 4
|
||||
|
||||
Server: http://192.168.40.25:8080/v1
|
||||
|
||||
› Modello my-model
|
||||
|
||||
invio conferma · esc indietro
|
||||
@@ -0,0 +1,21 @@
|
||||
---
|
||||
source: tui/src/onboarding/setup_wizard_tests.rs
|
||||
expression: rendered
|
||||
---
|
||||
|
||||
Modello passo 3 di 4
|
||||
|
||||
Server: https://openrouter.ai/api/v1
|
||||
|
||||
Cerca: ▏ [ ] solo gratuiti (tab)
|
||||
› 1. vendor/model-000
|
||||
2. vendor/model-001
|
||||
3. vendor/model-002
|
||||
4. vendor/model-003
|
||||
5. vendor/model-004
|
||||
6. vendor/model-005
|
||||
7. vendor/model-006
|
||||
8. vendor/model-007
|
||||
1 di 304
|
||||
|
||||
↑/↓ scegli · tab gratuiti · invio conferma · esc indietro
|
||||
@@ -0,0 +1,21 @@
|
||||
---
|
||||
source: tui/src/onboarding/setup_wizard_tests.rs
|
||||
expression: rendered
|
||||
---
|
||||
|
||||
Modello passo 3 di 4
|
||||
|
||||
Server: https://openrouter.ai/api/v1
|
||||
|
||||
Cerca: ▏ [ ] solo gratuiti (tab)
|
||||
› 1. vendor/model-000
|
||||
2. vendor/model-001
|
||||
3. vendor/model-002
|
||||
4. vendor/model-003
|
||||
5. vendor/model-004
|
||||
6. vendor/model-005
|
||||
7. vendor/model-006
|
||||
8. vendor/model-007
|
||||
1 di 304
|
||||
|
||||
↑/↓ scegli · tab gratuiti · invio conferma · esc indiet…
|
||||
@@ -0,0 +1,21 @@
|
||||
---
|
||||
source: tui/src/onboarding/setup_wizard_tests.rs
|
||||
expression: rendered
|
||||
---
|
||||
|
||||
Modello passo 3 di 4
|
||||
|
||||
Server: https://openrouter.ai/api/v1
|
||||
|
||||
Cerca: ▏ [ ] solo gratuiti (tab)
|
||||
› 1. vendor/model-000
|
||||
2. vendor/model-001
|
||||
3. vendor/model-002
|
||||
4. vendor/model-003
|
||||
5. vendor/model-004
|
||||
6. vendor/model-005
|
||||
7. vendor/model-006
|
||||
8. vendor/model-007
|
||||
1 di 304
|
||||
|
||||
↑/↓ scegli · tab gratuiti · invio conferma · esc indietro
|
||||
@@ -0,0 +1,16 @@
|
||||
---
|
||||
source: tui/src/onboarding/setup_wizard_tests.rs
|
||||
expression: rendered
|
||||
---
|
||||
|
||||
Modello passo 3 di 4
|
||||
|
||||
Server: https://openrouter.ai/api/v1
|
||||
|
||||
Cerca: qwen▏ [ ] solo gratuiti (tab)
|
||||
› 1. qwen/qwen3-coder:free
|
||||
2. qwen/qwen3-coder
|
||||
3. Inserisci il nome a mano…
|
||||
1 di 3 · 2 modelli su 303
|
||||
|
||||
↑/↓ scegli · tab gratuiti · invio conferma · esc pulisci
|
||||
@@ -0,0 +1,16 @@
|
||||
---
|
||||
source: tui/src/onboarding/setup_wizard_tests.rs
|
||||
expression: rendered
|
||||
---
|
||||
|
||||
Modello passo 3 di 4
|
||||
|
||||
Server: https://openrouter.ai/api/v1
|
||||
|
||||
Cerca: qwen▏ [ ] solo gratuiti (tab)
|
||||
› 1. qwen/qwen3-coder:free
|
||||
2. qwen/qwen3-coder
|
||||
3. Inserisci il nome a mano…
|
||||
1 di 3 · 2 modelli su 303
|
||||
|
||||
↑/↓ scegli · tab gratuiti · invio conferma · esc pulisci
|
||||
@@ -0,0 +1,16 @@
|
||||
---
|
||||
source: tui/src/onboarding/setup_wizard_tests.rs
|
||||
expression: rendered
|
||||
---
|
||||
|
||||
Modello passo 3 di 4
|
||||
|
||||
Server: https://openrouter.ai/api/v1
|
||||
|
||||
Cerca: qwen▏ [ ] solo gratuiti (tab)
|
||||
› 1. qwen/qwen3-coder:free
|
||||
2. qwen/qwen3-coder
|
||||
3. Inserisci il nome a mano…
|
||||
1 di 3 · 2 modelli su 303
|
||||
|
||||
↑/↓ scegli · tab gratuiti · invio conferma · esc pulisci
|
||||
@@ -0,0 +1,15 @@
|
||||
---
|
||||
source: tui/src/onboarding/setup_wizard_tests.rs
|
||||
expression: rendered
|
||||
---
|
||||
|
||||
Modello passo 3 di 4
|
||||
|
||||
Server: https://openrouter.ai/api/v1
|
||||
|
||||
Cerca: qwen▏ [x] solo gratuiti (tab)
|
||||
› 1. qwen/qwen3-coder:free
|
||||
2. Inserisci il nome a mano…
|
||||
1 di 2 · 1 modello su 303
|
||||
|
||||
↑/↓ scegli · tab gratuiti · invio conferma · esc pulisci
|
||||
@@ -0,0 +1,15 @@
|
||||
---
|
||||
source: tui/src/onboarding/setup_wizard_tests.rs
|
||||
expression: rendered
|
||||
---
|
||||
|
||||
Modello passo 3 di 4
|
||||
|
||||
Server: https://openrouter.ai/api/v1
|
||||
|
||||
Cerca: qwen▏ [x] solo gratuiti (tab)
|
||||
› 1. qwen/qwen3-coder:free
|
||||
2. Inserisci il nome a mano…
|
||||
1 di 2 · 1 modello su 303
|
||||
|
||||
↑/↓ scegli · tab gratuiti · invio conferma · esc pulisci
|
||||
@@ -0,0 +1,15 @@
|
||||
---
|
||||
source: tui/src/onboarding/setup_wizard_tests.rs
|
||||
expression: rendered
|
||||
---
|
||||
|
||||
Modello passo 3 di 4
|
||||
|
||||
Server: https://openrouter.ai/api/v1
|
||||
|
||||
Cerca: qwen▏ [x] solo gratuiti (tab)
|
||||
› 1. qwen/qwen3-coder:free
|
||||
2. Inserisci il nome a mano…
|
||||
1 di 2 · 1 modello su 303
|
||||
|
||||
↑/↓ scegli · tab gratuiti · invio conferma · esc pulisci
|
||||
@@ -0,0 +1,14 @@
|
||||
---
|
||||
source: tui/src/onboarding/setup_wizard_tests.rs
|
||||
expression: rendered
|
||||
---
|
||||
|
||||
Provider del modello passo 1 di 4
|
||||
|
||||
Scegli dove gira il modello. Potrai aggiungere altri provider con /setup.
|
||||
|
||||
› 1. Endpoint personalizzato server compatibile OpenAI con Responses API
|
||||
2. Ollama locale localhost:11434
|
||||
3. LM Studio locale localhost:1234
|
||||
|
||||
↑/↓ scegli · invio conferma · esc indietro
|
||||
@@ -0,0 +1,15 @@
|
||||
---
|
||||
source: tui/src/onboarding/setup_wizard_tests.rs
|
||||
expression: rendered
|
||||
---
|
||||
|
||||
Provider del modello passo 1 di 4
|
||||
|
||||
Scegli dove gira il modello. Potrai aggiungere altri
|
||||
provider con /setup.
|
||||
|
||||
› 1. Endpoint personalizzato server compatibile OpenAI…
|
||||
2. Ollama locale localhost:11434
|
||||
3. LM Studio locale localhost:1234
|
||||
|
||||
↑/↓ scegli · invio conferma · esc indietro
|
||||
@@ -0,0 +1,14 @@
|
||||
---
|
||||
source: tui/src/onboarding/setup_wizard_tests.rs
|
||||
expression: rendered
|
||||
---
|
||||
|
||||
Provider del modello passo 1 di 4
|
||||
|
||||
Scegli dove gira il modello. Potrai aggiungere altri provider con /setup.
|
||||
|
||||
› 1. Endpoint personalizzato server compatibile OpenAI con Responses API
|
||||
2. Ollama locale localhost:11434
|
||||
3. LM Studio locale localhost:1234
|
||||
|
||||
↑/↓ scegli · invio conferma · esc indietro
|
||||
@@ -0,0 +1,13 @@
|
||||
---
|
||||
source: tui/src/onboarding/setup_wizard_tests.rs
|
||||
expression: "render(&wizard, 80, 12)"
|
||||
---
|
||||
|
||||
Salvataggio
|
||||
|
||||
Impossibile scrivere config.toml: permesso negato
|
||||
|
||||
› 1. Riprova
|
||||
2. Indietro
|
||||
|
||||
↑/↓ scegli · invio conferma
|
||||
@@ -0,0 +1,16 @@
|
||||
---
|
||||
source: tui/src/onboarding/setup_wizard_tests.rs
|
||||
expression: rendered
|
||||
---
|
||||
|
||||
Prova della connessione passo 4 di 4
|
||||
|
||||
Server: http://192.168.40.25:8080/v1
|
||||
Modello: qwen3.6-35b-a3b
|
||||
|
||||
✗ Chiave API rifiutata (HTTP 401): controlla la chiave.
|
||||
|
||||
› 1. Riprova
|
||||
2. Torna indietro e correggi
|
||||
|
||||
↑/↓ scegli · invio conferma · esc indietro
|
||||
@@ -0,0 +1,16 @@
|
||||
---
|
||||
source: tui/src/onboarding/setup_wizard_tests.rs
|
||||
expression: rendered
|
||||
---
|
||||
|
||||
Prova della connessione passo 4 di 4
|
||||
|
||||
Server: http://192.168.40.25:8080/v1
|
||||
Modello: qwen3.6-35b-a3b
|
||||
|
||||
✗ Chiave API rifiutata (HTTP 401): controlla la chiave.
|
||||
|
||||
› 1. Riprova
|
||||
2. Torna indietro e correggi
|
||||
|
||||
↑/↓ scegli · invio conferma · esc indietro
|
||||
@@ -0,0 +1,16 @@
|
||||
---
|
||||
source: tui/src/onboarding/setup_wizard_tests.rs
|
||||
expression: rendered
|
||||
---
|
||||
|
||||
Prova della connessione passo 4 di 4
|
||||
|
||||
Server: http://192.168.40.25:8080/v1
|
||||
Modello: qwen3.6-35b-a3b
|
||||
|
||||
✗ Chiave API rifiutata (HTTP 401): controlla la chiave.
|
||||
|
||||
› 1. Riprova
|
||||
2. Torna indietro e correggi
|
||||
|
||||
↑/↓ scegli · invio conferma · esc indietro
|
||||
@@ -0,0 +1,13 @@
|
||||
---
|
||||
source: tui/src/onboarding/setup_wizard_tests.rs
|
||||
expression: rendered
|
||||
---
|
||||
|
||||
Prova della connessione passo 4 di 4
|
||||
|
||||
Server: http://192.168.40.25:8080/v1
|
||||
Modello: qwen3.6-35b-a3b
|
||||
|
||||
✓ Connessione riuscita (Responses API).
|
||||
|
||||
invio continua · esc indietro
|
||||
@@ -0,0 +1,13 @@
|
||||
---
|
||||
source: tui/src/onboarding/setup_wizard_tests.rs
|
||||
expression: rendered
|
||||
---
|
||||
|
||||
Prova della connessione passo 4 di 4
|
||||
|
||||
Server: http://192.168.40.25:8080/v1
|
||||
Modello: qwen3.6-35b-a3b
|
||||
|
||||
✓ Connessione riuscita (Responses API).
|
||||
|
||||
invio continua · esc indietro
|
||||
@@ -0,0 +1,13 @@
|
||||
---
|
||||
source: tui/src/onboarding/setup_wizard_tests.rs
|
||||
expression: rendered
|
||||
---
|
||||
|
||||
Prova della connessione passo 4 di 4
|
||||
|
||||
Server: http://192.168.40.25:8080/v1
|
||||
Modello: qwen3.6-35b-a3b
|
||||
|
||||
✓ Connessione riuscita (Responses API).
|
||||
|
||||
invio continua · esc indietro
|
||||
@@ -0,0 +1,13 @@
|
||||
---
|
||||
source: tui/src/onboarding/setup_wizard_tests.rs
|
||||
expression: "render(&wizard, 80, 12)"
|
||||
---
|
||||
|
||||
Prova della connessione passo 4 di 4
|
||||
|
||||
Server: http://192.168.40.25:8080/v1
|
||||
Modello: qwen3.6-35b-a3b
|
||||
|
||||
Invio di una richiesta minima a /responses…
|
||||
|
||||
esc annulla
|
||||
@@ -0,0 +1,17 @@
|
||||
---
|
||||
source: tui/src/onboarding/setup_wizard_tests.rs
|
||||
expression: rendered
|
||||
---
|
||||
|
||||
█████╗ ██╗ ██╗ ██████╗ ██████╗ ███████╗
|
||||
▄▄████▄▄ ██╔══██╗██║ ██╔╝██╔═══██╗██╔══██╗██╔════╝
|
||||
██▀▀██▀▀██ ███████║█████╔╝ ██║ ██║██║ ██║█████╗
|
||||
██▄▄██▄▄██ ██╔══██║██╔═██╗ ██║ ██║██║ ██║██╔══╝
|
||||
██▀████▀██ ██║ ██║██║ ██╗╚██████╔╝██████╔╝███████╗
|
||||
╚═╝ ╚═╝╚═╝ ╚═╝ ╚═════╝ ╚═════╝ ╚══════╝
|
||||
|
||||
Benvenuto in aKode · il tuo agente di coding locale
|
||||
|
||||
Configuriamo il server del modello: indirizzo, chiave e modello.
|
||||
|
||||
invio inizia · ctrl+c esci
|
||||
@@ -0,0 +1,18 @@
|
||||
---
|
||||
source: tui/src/onboarding/setup_wizard_tests.rs
|
||||
expression: rendered
|
||||
---
|
||||
|
||||
█████╗ ██╗ ██╗ ██████╗ ██████╗ ███████╗
|
||||
▄▄████▄▄ ██╔══██╗██║ ██╔╝██╔═══██╗██╔══██╗██╔════╝
|
||||
██▀▀██▀▀██ ███████║█████╔╝ ██║ ██║██║ ██║█████╗
|
||||
██▄▄██▄▄██ ██╔══██║██╔═██╗ ██║ ██║██║ ██║██╔══╝
|
||||
██▀████▀██ ██║ ██║██║ ██╗╚██████╔╝██████╔╝███████╗
|
||||
╚═╝ ╚═╝╚═╝ ╚═╝ ╚═════╝ ╚═════╝ ╚══════╝
|
||||
|
||||
Benvenuto in aKode · il tuo agente di coding locale
|
||||
|
||||
Configuriamo il server del modello: indirizzo, chiave
|
||||
e modello.
|
||||
|
||||
invio inizia · ctrl+c esci
|
||||
@@ -0,0 +1,17 @@
|
||||
---
|
||||
source: tui/src/onboarding/setup_wizard_tests.rs
|
||||
expression: rendered
|
||||
---
|
||||
|
||||
█████╗ ██╗ ██╗ ██████╗ ██████╗ ███████╗
|
||||
▄▄████▄▄ ██╔══██╗██║ ██╔╝██╔═══██╗██╔══██╗██╔════╝
|
||||
██▀▀██▀▀██ ███████║█████╔╝ ██║ ██║██║ ██║█████╗
|
||||
██▄▄██▄▄██ ██╔══██║██╔═██╗ ██║ ██║██║ ██║██╔══╝
|
||||
██▀████▀██ ██║ ██║██║ ██╗╚██████╔╝██████╔╝███████╗
|
||||
╚═╝ ╚═╝╚═╝ ╚═╝ ╚═════╝ ╚═════╝ ╚══════╝
|
||||
|
||||
Benvenuto in aKode · il tuo agente di coding locale
|
||||
|
||||
Configuriamo il server del modello: indirizzo, chiave e modello.
|
||||
|
||||
invio inizia · ctrl+c esci
|
||||
@@ -61,6 +61,8 @@ pub enum SlashCommand {
|
||||
Title,
|
||||
Statusline,
|
||||
Theme,
|
||||
Setup,
|
||||
Endpoint,
|
||||
#[strum(to_string = "pets", serialize = "pet")]
|
||||
Pets,
|
||||
Mcp,
|
||||
@@ -121,6 +123,8 @@ impl SlashCommand {
|
||||
SlashCommand::Title => "configure which items appear in the terminal title",
|
||||
SlashCommand::Statusline => "configure which items appear in the status line",
|
||||
SlashCommand::Theme => "choose a syntax highlighting theme",
|
||||
SlashCommand::Setup => "add a model provider with the guided setup",
|
||||
SlashCommand::Endpoint => "manage endpoints, models and their settings",
|
||||
SlashCommand::Pets => "choose or hide the terminal pet",
|
||||
SlashCommand::Ps => "list background terminals",
|
||||
SlashCommand::Stop => "stop all background terminals",
|
||||
@@ -294,7 +298,11 @@ impl SlashCommand {
|
||||
SlashCommand::Rollout => true,
|
||||
SlashCommand::TestApproval => true,
|
||||
SlashCommand::Agents | SlashCommand::MultiAgents => true,
|
||||
SlashCommand::Config | SlashCommand::Theme | SlashCommand::Pets => false,
|
||||
SlashCommand::Config
|
||||
| SlashCommand::Theme
|
||||
| SlashCommand::Setup
|
||||
| SlashCommand::Endpoint
|
||||
| SlashCommand::Pets => false,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
---
|
||||
source: tui/src/endpoint_panel_tests.rs
|
||||
expression: "render(&panel, width, 14)"
|
||||
---
|
||||
Modelli ed endpoint esc chiudi
|
||||
────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
|
||||
Endpoint │ Modelli · MACOS │ Impostazioni · Flint.APEX-I-NanoPlus-V2.1
|
||||
› ● MACOS 127.0.0.1 │ › Flint.APEX-I-NanoPlus-V2.1 ● attivo │ › Contesto 65536 (server 65536)
|
||||
Giulio mega-link.clo… │ │ Temperatura 0.7
|
||||
OpenRouter openrouter.ai │ │ Top-p 0.95
|
||||
+ Aggiungi endpoint │ │ Max output 8192
|
||||
│ │ Ragionamento medio
|
||||
│ │ Nome Flint.APEX-I-NanoPlus-V2…
|
||||
│ │
|
||||
│ │
|
||||
|
||||
────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
|
||||
↑↓ scegli · tab colonna · invio modifica · u usa · t prova connessione · d elimina
|
||||
@@ -0,0 +1,18 @@
|
||||
---
|
||||
source: tui/src/endpoint_panel_tests.rs
|
||||
expression: "render(&panel, width, 14)"
|
||||
---
|
||||
Modelli ed endpoint esc chiudi
|
||||
────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
|
||||
Endpoint │ Modelli · MACOS │ Impostazioni · Flint.APEX-I-NanoPlus-V2.1
|
||||
› ● MACOS 127.0.0.1 │ › Flint.APEX-I-NanoPlus-V2.1 ● attivo │ › Contesto 65536 (server 65536)
|
||||
Giulio mega-link.cloud │ │ Temperatura 0.7
|
||||
OpenRouter openrouter.ai │ │ Top-p 0.95
|
||||
+ Aggiungi endpoint │ │ Max output 8192
|
||||
│ │ Ragionamento medio
|
||||
│ │ Nome Flint.APEX-I-NanoPlus-V2.1
|
||||
│ │
|
||||
│ │
|
||||
|
||||
────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
|
||||
↑↓ scegli · tab colonna · invio modifica · u usa · t prova connessione · d elimina
|
||||
@@ -0,0 +1,18 @@
|
||||
---
|
||||
source: tui/src/endpoint_panel_tests.rs
|
||||
expression: "render(&panel, width, 14)"
|
||||
---
|
||||
Modelli ed endpoint esc chiudi
|
||||
────────────────────────────────────────────────────────────────────────────
|
||||
Endpoint › Modelli › Impostazioni
|
||||
› ● MACOS 127.0.0.1
|
||||
Giulio mega-link.cloud
|
||||
OpenRouter openrouter.ai
|
||||
+ Aggiungi endpoint
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
────────────────────────────────────────────────────────────────────────────
|
||||
↑↓ scegli · tab colonna · invio modifica · u usa · t prova · d elimina
|
||||
@@ -0,0 +1,18 @@
|
||||
---
|
||||
source: tui/src/endpoint_panel_tests.rs
|
||||
expression: text
|
||||
---
|
||||
Modelli ed endpoint esc chiudi
|
||||
────────────────────────────────────────────────────────────────────────────
|
||||
Endpoint › Modelli › Impostazioni · Flint.APEX-I-NanoPlus-V2.1
|
||||
› Contesto 65536 (server 65536)
|
||||
Temperatura 0.7
|
||||
Top-p 0.95
|
||||
Max output 8192
|
||||
Ragionamento medio
|
||||
Nome Flint.APEX-I-NanoPlus-V2.1
|
||||
|
||||
|
||||
|
||||
────────────────────────────────────────────────────────────────────────────
|
||||
↑↓ scegli · tab colonna · invio modifica · canc predefinito · u usa
|
||||
8
akode-rs/tui/src/truncate_line.rs
Normal file
8
akode-rs/tui/src/truncate_line.rs
Normal file
@@ -0,0 +1,8 @@
|
||||
//! Line truncation with an ellipsis, used by the endpoint panel and the first-run setup.
|
||||
|
||||
use ratatui::text::Line;
|
||||
|
||||
/// Truncate a line to `width` display columns, appending `…` when text is cut.
|
||||
pub(crate) fn truncate_line(line: Line<'static>, width: usize) -> Line<'static> {
|
||||
crate::line_truncation::truncate_line_with_ellipsis_if_overflow(line, width)
|
||||
}
|
||||
Reference in New Issue
Block a user