Jan is an open source alternative to ChatGPT that runs 100% offline on your computer.
Merge remote-tracking branch 'origin/dev' into feature/8661-improve-login-ux
thinhlpg58a26911b20c
diff --cc src-tauri/src/core/cli/tui.rsindex 64340fc61,96707865e..961cd5f61--- a/src-tauri/src/core/cli/tui.rs+++ b/src-tauri/src/core/cli/tui.rs@@@ -380,10 -372,13 +380,13 @@@ enum PickerKind/// `/todo` editor: browse the phased list and mutate the selected task/// (done/drop/rm) through the same canonical `TodoList` the model uses.Todo,+ /// `/plugin install <collection>`: choose which plugins inside a collection+ /// repo to install. Space toggles a row, Enter installs everything checked.+ PluginSelect,}-/// Interactive list overlay (`/resume` threads, `/model` models, `/mcp`-/// servers): rows with a highlighted cursor, acted on by `PickerKind` on Enter.+/// Interactive list overlay (`/resume`, `/login`, `/mcp`, etc.): rows with a+/// highlighted cursor, acted on by `PickerKind` on Enter.struct Picker {kind: PickerKind,items: Vec<PickerItem>,@@@ -395,17 -390,18 +398,18 @@@}impl Picker {- fn title(&self) -> &'static str {+ fn title(&self) -> String {match self.kind {- PickerKind::ResumeThread => " resume thread ",- PickerKind::SelectModel => " select model ",- PickerKind::ToggleMcp => " mcp servers ",- PickerKind::RewindMessage => " rewind to message ",- PickerKind::RewindScope => " restore ",- PickerKind::ViewConfig => " provider config ",- PickerKind::AgentSettings => " agent settings ",- PickerKind::ProviderSettings => " providers ",- PickerKind::Todo => " todo ",- PickerKind::PluginSelect => " install plugins ",+ PickerKind::ResumeThread => " resume thread ".to_string(),+ PickerKind::LoginProvider => " sign in ".to_string(),+ PickerKind::ToggleMcp => " mcp servers ".to_string(),+ PickerKind::RewindMessage => " rewind to message ".to_string(),+ PickerKind::RewindScope => " restore ".to_string(),+ PickerKind::ViewConfig => " provider config ".to_string(),+ PickerKind::AgentSettings => " agent settings ".to_string(),+ PickerKind::ProviderSettings => " providers ".to_string(),+ PickerKind::Todo => " todo ".to_string(),++ PickerKind::PluginSelect => " install plugins ".to_string(),}}@@@ -418,8 -414,11 +422,11 @@@PickerKind::RewindScope => " ↑/↓ select Enter restore Esc cancel",PickerKind::ViewConfig => " set via: jan config set --provider <id> ... Esc close",PickerKind::AgentSettings => " ↑/↓ select Enter edit x unset Esc close",- PickerKind::ProviderSettings => " ↑/↓ select Enter edit a add dd delete Esc close",+ PickerKind::ProviderSettings => " ↑/↓ select Enter edit a add dd delete x logout Esc close",PickerKind::Todo => " ↑/↓ select d done x abandon r remove Esc close",+ PickerKind::PluginSelect => {+ " ↑/↓ select Space toggle Enter install Esc cancel"+ }}}}@@@ -1553,18 -1373,20 +1560,29 @@@ struct App/// request timeout -- so only unprobed providers are fetched once.probed_models: std::collections::HashSet<String>,/// Key handed off to the loop to verify off the render loop. Taken once.- login_submit: Option<String>,+ login_submit: Option<(String, String)>,+ /// Active OAuth account prompt; owns the keyboard while open.+ account_login: Option<AccountLoginPrompt>,+ /// Account sign-in handed off to the loop after its local callback is ready.+ account_login_submit: Option<crate::core::cli::auth::account::AccountLogin>,+ /// Manual OAuth redirect/code sender for the active account task.+ account_login_manual_tx: Option<tokio::sync::mpsc::UnboundedSender<String>>,+ /// Manual OAuth input submitted while no task sender is active; delivered to+ /// the fresh task channel on retry spawn.+ account_login_pending_manual_input: Option<String>,/// `/update` handed off to the loop, which spawns the install. Taken once.update_requested: bool,+ /// `/plugin install` handed off to the loop, which runs the git clone off+ /// the render loop and notes the result when it lands. Taken once.+ plugin_install_request: Option<String>,+ /// A collection picker's chosen plugins handed off to the loop: the source+ /// URL plus the payload-root-relative paths to install. Taken once.+ plugin_select_request: Option<(String, Vec<String>)>,+ /// Source URL behind the open `PluginSelect` picker, so Enter knows which+ /// collection the checked rows came from. Cleared when the picker resolves.+ plugin_collection_url: Option<String>,+ /// A plugin install is in flight: a second request is refused.+ plugin_installing: bool,/// Compaction handed off to the loop, which spawns the summarizing model/// call off the render loop. Taken once.compact_request: Option<CompactKind>,@@@ -1930,11 -1747,11 +1948,15 @@@ impl Appprovider_prompt: None,probed_models: std::collections::HashSet::new(),login_submit: None,+ account_login: None,+ account_login_submit: None,+ account_login_manual_tx: None,+ account_login_pending_manual_input: None,update_requested: false,+ plugin_install_request: None,+ plugin_select_request: None,+ plugin_collection_url: None,+ plugin_installing: false,update_installing: false,compact_request: None,compacting: None,@@@ -7317,29 -6907,37 +7452,60 @@@ async fn handle_keyErr(e) => app.note(&format!("failed to write {}: {e}", toml_path.display())),}}+ // `/login`: `x` signs out the selected provider without leaving+ // the picker, so it doubles as a sign-out list. Only meaningful+ // for a provider that is currently signed in.+ KeyCode::Char('x') if picker.kind == PickerKind::LoginProvider => {+ let name = picker.items[picker.selected].value.clone();+ if !crate::core::cli::providers::provider_is_signed_in(+ Some(&app.project_root),+ &name,+ ) {+ app.note(&format!("{name} is not signed in"));+ return;+ }+ sign_out_provider(app, &name);+ // Refresh the status labels so the row flips to+ // "not signed in" without reopening the picker.+ if let Some(p) = app.picker.as_mut() {+ for item in &mut p.items {+ if item.value == name {+ item.hint = Some("not signed in".to_string());+ }+ }+ }+ }+ // Collection picker: Space toggles the selected plugin, Enter hands+ // the checked set to the loop (see `plugin_select_request`). Rows+ // already installed stay displayed but are not toggleable -- checking+ // one and pressing Enter would make the batch install skip everything+ // and error with "nothing installed". A Space on such a row is a+ // no-op note so the confusion stays out.+ KeyCode::Char(' ') if picker.kind == PickerKind::PluginSelect => {+ let already_installed =+ picker.items[picker.selected].hint.as_deref() == Some(INSTALLED_HINT);+ if already_installed {+ app.note("already installed - nothing to install");+ } else {+ let item = &mut picker.items[picker.selected];+ item.checkbox = Some(!item.checkbox.unwrap_or(false));+ }+ }+ KeyCode::Enter if picker.kind == PickerKind::PluginSelect => {+ let paths: Vec<String> = picker+ .items+ .iter()+ .filter(|i| i.checkbox.unwrap_or(false))+ .map(|i| i.value.clone())+ .collect();+ app.picker = None;+ if paths.is_empty() {+ app.note("no plugin selected - install aborted");+ } else if let Some(url) = app.plugin_collection_url.take() {+ app.note(&format!("installing {} plugin(s)...", paths.len()));+ app.plugin_select_request = Some((url, paths));+ }+ }KeyCode::Enter => {let kind = picker.kind;let value = picker.items[picker.selected].value.clone();