Skip to content

armgit / jan

Public Imported from GitHub
0

Jan is an open source alternative to ChatGPT that runs 100% offline on your computer.

fix(cli): select one searchable plugin before setup

thinhlpgcbf2b18c00bb
diff --git a/docs/src/pages/docs/agent/plugins.mdx b/docs/src/pages/docs/agent/plugins.mdx
index 92ac1cdef..f743122b4 100644
--- a/docs/src/pages/docs/agent/plugins.mdx
+++ b/docs/src/pages/docs/agent/plugins.mdx
@@ -10,9 +10,11 @@ import { Callout } from 'nextra/components'
A plugin is a set of [skills](/docs/agent/skills) installed from a git repository. Any repo that
looks like a skill collection - or is a single skill - can be installed with one command, without
-copying files by hand or trusting a download step. Installing a plugin never runs its code: the
-install step only clones and moves files. A plugin that declares [tools or hooks](/docs/agent/hooks)
-runs commands later, once a session uses it.
+copying files by hand or trusting a download step. A plugin can also package commands, agent
+definitions, and optional MCP server declarations. Installing a plugin never runs its code: the
+install step only clones and moves files, and it does not start a declared MCP server. Enabling one
+is a separate, explicit setup action that can run local code or contact a remote service. A plugin
+that declares [tools or hooks](/docs/agent/hooks) runs commands later, once a session uses it.
## Where they live
@@ -40,8 +42,9 @@ A plugin's payload is discovered conventionally, so a repo needs no manifest to
and `repo`. The directory name is the plugin's identity; the manifest's `name` is what
`plugin list` shows when present.
-This is the same layout Claude Code and Codex plugins use, so existing plugins install and work
-unchanged: `anthropics/claude-plugins-official` and similar marketplaces are drop-in compatible.
+Jan discovers these conventional directories in Claude Code-style plugin repositories,
+including `anthropics/claude-plugins-official`. Installation does not guarantee runtime
+compatibility: external commands, credentials, and provider approval may still be required.
## Installing
@@ -78,24 +81,38 @@ rejected outright - a plugin name is a name, not a command.
In the TUI, installation continues directly into setup. Jan reads the plugin's
`.mcp.json` or inline `mcpServers` declarations, collects required keys in a masked
field, and offers **Enable and connect** for each server. Nothing is enabled or
-executed until you confirm. Remote servers that require OAuth continue into
-browser sign-in and reconnect automatically afterward.
+executed until you confirm. For providers that accept Jan's OAuth client registration,
+setup offers browser sign-in and reconnects after successful authorization.
Choose **Not now** or press Esc to keep the plugin installed without completing
-its connections. Resume with `/plugin setup <name>`; no separate terminal command
-or Jan restart is needed. Plugins without keys or MCP servers are ready immediately.
+its connections. Resume with `/plugin setup <name>`, or use `/plugin setup` to
+choose one installed plugin. Type or paste to filter by name and description
+(case-insensitive); Backspace edits the search, Up/Down selects, Enter opens setup,
+and Esc cancels. Rows identify the installation directory and also show the manifest
+name when it differs. Opening the picker does not run setup for every plugin or enable
+any servers. No separate terminal command or Jan restart is needed. Plugins without
+keys or MCP servers need no connection setup.
Imported MCP servers use names such as `figma:figma` to avoid collisions. Existing
servers with different settings are not overwritten; review them in `/mcp`.
Stored key references such as `${API_KEY}` and `${CLAUDE_PLUGIN_ROOT}` are resolved
from the plugin's key store and installed directory. Key files and generated MCP
configuration are owner-only (`0600`) on Unix.
+Shell credential injection is scoped to the project that registered the keys;
+starting a run in another project does not replace that project's shell credentials.
OAuth browser sign-in requires successful client registration. If the provider
rejects registration, Jan shows the endpoint, HTTP status, and rejection detail
in the TUI instead of opening a consent page with a placeholder client ID.
-[Figma restricts its remote MCP server to approved clients](https://developers.figma.com/docs/figma-mcp-server/remote-server-installation/);
-installing its plugin does not grant Jan that approval.
+[Figma restricts its remote MCP server to approved clients](https://developers.figma.com/docs/figma-mcp-server/remote-server-installation/).
+**Remote Figma sign-in is currently blocked for Jan:** registration returns HTTP 403.
+Installing the Figma plugin does not grant approval, and retrying setup does not remove
+that restriction. Jan does not currently accept pre-registered OAuth client credentials.
+
+MCP connections already enabled in Jan remain in its user-owned configuration.
+Skipping setup does not disable them, and removing a plugin does not remove its imported
+MCP entries. Use `/mcp`, select the server, then **Disable** or **Remove server**.
+This also applies to placeholder servers declared by example plugins.
A plugin installed or edited outside the running session (another terminal, `git pull`, a hand
edit) is picked up with `/reload plugin`, which re-scans and reports what was added, removed, or
diff --git a/docs/src/pages/docs/agent/slash-commands.mdx b/docs/src/pages/docs/agent/slash-commands.mdx
index 7006b1be0..f050860ea 100644
--- a/docs/src/pages/docs/agent/slash-commands.mdx
+++ b/docs/src/pages/docs/agent/slash-commands.mdx
@@ -65,7 +65,7 @@ See [Run modes](/docs/agent/run-modes), [Goals and todos](/docs/agent/goals-and-
| `/model [id]` | Switch model. Bare: pick interactively. Opening the picker re-lists each provider's models once per session; <kbd>Ctrl</kbd>+<kbd>R</kbd> inside it re-lists them again on demand |
| `/effort [low\|medium\|high]` | Set reasoning effort. Bare: show current; `low` is faster, `high` thinks deeper |
| `/mcp` | List, toggle, add, edit, and remove MCP servers; Enter opens a server's detail screen, where you can list its tools and sign in to it |
-| `/plugin [list\|install <spec>\|remove <name>\|search [query]\|setup <name>]` | Install and manage plugins. Installation opens setup automatically: masked API-key entry, then confirmation to enable declared MCP servers and sign in when required. `setup <name>` resumes setup without manual MCP configuration or restarting Jan |
+| `/plugin [list\|install <spec>\|remove <name>\|search [query]\|setup [name]]` | Install and manage plugins. Installation opens setup automatically: masked API-key entry, then confirmation to enable declared MCP servers and sign in when required. Bare `setup` opens a single-plugin picker; `setup <name>` resumes that plugin directly without manual MCP configuration or restarting Jan |
| `/reload [config\|plugin\|skills\|system-prompt]` | Re-read on-disk state into the running session without a restart (bare: all). `config` re-applies the project's `agent.toml` limits - `context_window`, `compaction_ratio`, `compaction_reserve_tokens`, `max_tokens`, `send_reasoning`, `[budget].max_tokens` - to the next run and lists what changed; the model, `[tools]`, `[provider]` and `[budget].max_usd` still need a restart. `plugin`/`skills` re-scan and rebuild the catalog, reporting added/removed/changed entries. `system-prompt` re-reads `JAN.md`, which applies on the next run |
| `/login` | Sign in to Tokamak and save the API key |
| `/config` | View provider config (`~/.jan/config.toml`) |
diff --git a/src-tauri/src/core/cli/tui.rs b/src-tauri/src/core/cli/tui.rs
index 6b42aa49a..7e1254eac 100644
--- a/src-tauri/src/core/cli/tui.rs
+++ b/src-tauri/src/core/cli/tui.rs
@@ -448,6 +448,8 @@ enum PickerKind {
/// `/plugin install <collection>`: choose which plugins inside a collection
/// repo to install. Space toggles a row, Enter installs everything checked.
PluginSelect,
+ /// `/plugin setup`: choose one installed plugin without starting setup.
+ PluginSetup,
/// Review a plugin-provided MCP server before enabling or executing it.
PluginConnect,
/// One MCP server's detail screen: the info block plus the actions that
@@ -470,13 +472,40 @@ struct Picker {
kind: PickerKind,
items: Vec<PickerItem>,
selected: usize,
+ search: Option<PickerSearch>,
/// Index of the provider row a first `d` armed for deletion, so a second
/// `d` on the same row confirms it. `None` = nothing armed. Resets on
/// navigation so an unrelated keypress can never delete by accident.
armed_delete: Option<usize>,
}
+/// Preserve the source rows while typing narrows the visible selection.
+struct PickerSearch {
+ all_items: Vec<PickerItem>,
+ query: String,
+}
+
impl Picker {
+ fn with_search(mut self) -> Self {
+ self.search = Some(PickerSearch {
+ all_items: self.items.clone(),
+ query: String::new(),
+ });
+ self
+ }
+
+ fn refresh_search(&mut self) {
+ let Some(search) = &self.search else { return };
+ let query = search.query.to_lowercase();
+ let terms: Vec<&str> = query.split_whitespace().collect();
+ self.items = search.all_items.iter().filter(|item| {
+ let searchable = format!("{} {}", item.label, item.hint.as_deref().unwrap_or(""))
+ .to_lowercase();
+ terms.iter().all(|term| searchable.contains(term))
+ }).cloned().collect();
+ self.selected = 0;
+ }
+
fn title(&self) -> &'static str {
match self.kind {
PickerKind::ResumeThread => " resume thread ",
@@ -491,6 +520,7 @@ impl Picker {
PickerKind::ProviderSettings => " providers ",
PickerKind::Todo => " todo ",
PickerKind::PluginSelect => " install plugins ",
+ PickerKind::PluginSetup => " set up plugin ",
PickerKind::PluginConnect => " plugin connection ",
PickerKind::McpServer => " mcp server ",
PickerKind::Agents => " subagents ",
@@ -517,6 +547,7 @@ impl Picker {
}
PickerKind::Todo => " ↑/↓ select d done x abandon r remove Esc close",
PickerKind::PluginSelect => " ↑/↓ select Space toggle Enter install Esc cancel",
+ PickerKind::PluginSetup => " Type to search Up/Down select Enter set up Esc cancel",
PickerKind::PluginConnect => " Up/Down select Enter confirm Esc cancel setup",
PickerKind::McpServer => " ↑/↓ select Enter run Esc back",
PickerKind::Agents => " ↑/↓ select Enter view Esc close",
@@ -9439,6 +9470,7 @@ fn finish_plugin_install(
));
app.picker = Some(Picker {
kind: PickerKind::PluginSelect,
+ search: None,
items: candidates
.into_iter()
.map(|c| PickerItem {
@@ -10737,6 +10769,11 @@ fn route_paste_event(app: &mut App, event: Event) {
} else if let Some(prompt) = app.plugin_setup.as_mut() {
// A pasted plugin API key belongs to the setup field.
prompt.paste(&text);
+ } else if let Some(picker) = app.picker.as_mut().filter(|picker| picker.search.is_some()) {
+ if let Some(search) = picker.search.as_mut() {
+ search.query.extend(text.chars().filter(|c| !c.is_control()));
+ }
+ picker.refresh_search();
} else if let Some(prompt) = app.settings_prompt.as_mut() {
prompt.paste(&text);
} else if let Some(prompt) = app.mcp_prompt.as_mut() {
@@ -11044,11 +11081,30 @@ impl MaskedPrompt for PluginSetupPrompt {
}
}
-/// Set up installed plugins without leaving the TUI.
+/// Choose one installed plugin; opening setup must not run the whole catalog.
fn open_plugin_setup(app: &mut App) -> bool {
- app.plugin_setup_queue = crate::core::agent::plugins::installed(&app.project_root)
- .into_iter().map(|p| p.name).collect();
- next_plugin_setup(app)
+ let plugins = crate::core::agent::plugins::installed_entries(&app.project_root);
+ if plugins.is_empty() {
+ app.note("no plugins installed - use /plugin install <git-url> first");
+ return false;
+ }
+ app.picker = Some(Picker {
+ kind: PickerKind::PluginSetup,
+ search: None,
+ items: plugins.into_iter().map(|(directory, plugin)| PickerItem {
+ label: if directory == plugin.name {
+ directory.clone()
+ } else {
+ format!("{directory} ({})", plugin.name)
+ },
+ value: directory,
+ hint: (!plugin.description.is_empty()).then_some(plugin.description),
+ checkbox: None,
+ }).collect(),
+ selected: 0,
+ armed_delete: None,
+ }.with_search());
+ true
}
fn next_plugin_setup(app: &mut App) -> bool {
@@ -11110,6 +11166,7 @@ fn show_next_plugin_connection(app: &mut App) {
};
app.picker = Some(Picker {
kind: PickerKind::PluginConnect,
+ search: None,
items: vec![
PickerItem {
value: "connect".into(),
@@ -11525,6 +11582,19 @@ async fn handle_key(
// act and close; the `/mcp` picker toggles the selected row in place.
if let Some(picker) = app.picker.as_mut() {
match key.code {
+ KeyCode::Char(ch) if picker.search.is_some() && !ctrl && !alt && !sup => {
+ if let Some(search) = picker.search.as_mut() {
+ search.query.push(ch);
+ }
+ picker.refresh_search();
+ }
+ KeyCode::Backspace if picker.search.is_some() => {
+ if let Some(search) = picker.search.as_mut() {
+ search.query.pop();
+ }
+ picker.refresh_search();
+ }
+ KeyCode::Enter if picker.items.is_empty() => {}
KeyCode::Up | KeyCode::Char('k') => {
picker.armed_delete = None;
picker.selected = picker.selected.saturating_sub(1);
@@ -11859,6 +11929,9 @@ async fn handle_key(
PickerKind::Todo => {}
// PluginSelect Enter is handled by the guarded arm above.
PickerKind::PluginSelect => {}
+ PickerKind::PluginSetup => {
+ open_plugin_setup_for(app, &value);
+ }
// McpServer Enter is handled by the guarded arm above.
PickerKind::McpServer => {}
// Agents Enter is handled by the guarded arm above; the
@@ -12553,8 +12626,8 @@ const SLASH_COMMANDS: &[SlashCommand] = &[
},
SlashCommand {
name: "/plugin",
- hint: "[list|install <spec>|remove <name>|search [query]|setup <name>]",
- description: "Manage plugins: install from a git URL or the marketplace, list/remove installed, search the marketplace, set up required API keys",
+ hint: "[list|install <spec>|remove <name>|search [query]|setup [name]]",
+ description: "Manage plugins: install, list/remove, search, or choose a plugin to set up its API keys and MCP connections",
alias_of: None,
},
SlashCommand {
@@ -13999,6 +14072,7 @@ fn open_settings_screen(app: &mut App) {
let toml_path = app.agent_dir.join("agent.toml");
app.picker = Some(Picker {
kind: PickerKind::AgentSettings,
+ search: None,
items: build_agent_settings_items(&toml_path),
selected: 0,
armed_delete: None,
@@ -14045,6 +14119,7 @@ fn open_provider_settings(app: &mut App) {
};
app.picker = Some(Picker {
kind: PickerKind::ProviderSettings,
+ search: None,
items,
selected: 0,
armed_delete: None,
@@ -14582,6 +14657,7 @@ fn open_todo_picker(app: &mut App) {
}
app.picker = Some(Picker {
kind: PickerKind::Todo,
+ search: None,
items: build_todo_items(&app.todos),
selected: 0,
armed_delete: None,
@@ -15240,6 +15316,7 @@ fn open_thread_picker(app: &mut App) {
} else {
app.picker = Some(Picker {
kind: PickerKind::ResumeThread,
+ search: None,
items,
selected: 0,
armed_delete: None,
@@ -15389,6 +15466,7 @@ async fn open_mcp_picker(app: &mut App, mcp_servers: &crate::core::state::Shared
app.mcp_detail = None;
app.picker = Some(Picker {
kind: PickerKind::ToggleMcp,
+ search: None,
items,
selected: 0,
armed_delete: None,
@@ -15404,6 +15482,7 @@ fn open_agents_picker(app: &mut App) {
kind: PickerKind::Agents,
items: agent_picker_items(&app.subagents),
selected: 0,
+ search: None,
armed_delete: None,
});
}
@@ -15416,6 +15495,7 @@ fn open_background_shells_picker(app: &mut App) {
kind: PickerKind::BackgroundShells,
items: background_shell_picker_items(&app.bg_shells),
selected: 0,
+ search: None,
armed_delete: None,
});
}
@@ -15617,6 +15697,7 @@ async fn open_mcp_detail(
};
app.picker = Some(Picker {
kind: PickerKind::McpServer,
+ search: None,
items: mcp_action_items(&server),
selected: 0,
armed_delete: None,
@@ -15916,6 +15997,7 @@ fn open_login_picker_at(app: &mut App, selected_provider: Option<&str>) {
.unwrap_or(0);
app.picker = Some(Picker {
kind: PickerKind::LoginProvider,
+ search: None,
items,
selected,
armed_delete: None,
@@ -16396,6 +16478,7 @@ fn open_config_screen(app: &mut App) {
};
app.picker = Some(Picker {
kind: PickerKind::ViewConfig,
+ search: None,
items,
selected: 0,
armed_delete: None,
@@ -17025,6 +17108,7 @@ fn open_tree_picker(app: &mut App) {
kind: PickerKind::ThreadTree,
items,
selected,
+ search: None,
armed_delete: None,
});
}
@@ -17065,6 +17149,7 @@ fn open_turn_picker(app: &mut App, kind: PickerKind, empty: &str) {
let selected = items.len() - 1;
app.picker = Some(Picker {
kind,
+ search: None,
items,
selected,
armed_delete: None,
@@ -17091,6 +17176,7 @@ fn open_rewind_scope(app: &mut App, user_index: usize) {
}
app.picker = Some(Picker {
kind: PickerKind::RewindScope,
+ search: None,
items,
selected: 0,
armed_delete: None,
@@ -19376,10 +19462,17 @@ fn draw_picker(
};
spans.push(Span::styled(mark, style));
}
- if let Some(hint) = &it.hint {
- spans.push(Span::styled(format!("{hint} "), Style::new().dark_gray()));
+ if picker.kind == PickerKind::PluginSetup {
+ spans.push(Span::raw(it.label.clone()));
+ if let Some(hint) = &it.hint {
+ spans.push(Span::styled(format!(" {hint}"), Style::new().dark_gray()));
+ }
+ } else {
+ if let Some(hint) = &it.hint {
+ spans.push(Span::styled(format!("{hint} "), Style::new().dark_gray()));
+ }
+ spans.push(Span::raw(it.label.clone()));
}
- spans.push(Span::raw(it.label.clone()));
ListItem::new(Line::from(spans))
})
.collect();
@@ -19394,7 +19487,27 @@ fn draw_picker(
// setting's description, default, valid range, and current value - the
// rows themselves stay terse (`key = value`) because the detail footer
// explains what each knob does.
- if picker.kind == PickerKind::AgentSettings {
+ if let Some(search) = &picker.search {
+ let block = Block::default().borders(Borders::ALL).title(picker.title());
+ let inner = block.inner(area);
+ f.render_widget(block, area);
+ let rows = Layout::vertical([Constraint::Length(1), Constraint::Min(0)]).split(inner);
+ f.render_widget(
+ Paragraph::new(truncate(
+ &format!(" Search: {}|", search.query),
+ rows[0].width as usize,
+ )),
+ rows[0],
+ );
+ if picker.items.is_empty() {
+ f.render_widget(
+ Paragraph::new(" No plugins match").style(Style::new().dark_gray()),
+ rows[1],
+ );
+ } else {
+ f.render_stateful_widget(list.block(Block::default()), rows[1], &mut state);
+ }
+ } else if picker.kind == PickerKind::AgentSettings {
let list_area = Rect {
height: area.height.saturating_sub(2),
..area
@@ -20636,7 +20749,8 @@ mod tests {
drain_stream_events, estimate_token_count, finish_account_login, finish_compaction,
finish_context_report, finish_login, finish_plugin_install, finish_tokamak_login,
finish_update_install, fork_at, format_tokens, group_detail_lines, group_summary,
- handle_ask_key, handle_ask_mouse, handle_key, handle_mouse, header_spans, image_mime,
+ handle_ask_key, handle_ask_mouse, handle_key, handle_mouse, handle_plugin_setup_key,
+ header_spans, image_mime,
image_mime_of, input_content_lines, is_user_turn, load_first_file_image, load_image_file,
message_text, note_update, open_config_screen, open_fork_picker, open_rewind_picker,
open_tree_picker, pairs_to_str, parse_command, partial_json_field,
@@ -37949,6 +38063,145 @@ mod tests {
)
.unwrap();
}
+ #[tokio::test]
+ async fn plugin_setup_selection_preserves_directory_identity() {
+ let (mut app, root) = skill_test_app("deploy", "How to deploy.");
+ for (directory, name, description) in [
+ ("alpha", "shared", "First"),
+ ("beta", "shared", "Second"),
+ ("gamma", "beta", "Third"),
+ ] {
+ let dir = root.join(".jan/agent/plugins").join(directory);
+ std::fs::create_dir_all(&dir).unwrap();
+ std::fs::write(
+ dir.join("plugin.toml"),
+ format!("name = \"{name}\"\ndescription = \"{description}\"\n"),
+ ).unwrap();
+ }
+ for (directory, query) in [("alpha", "First"), ("beta", "Second"), ("gamma", "Third")] {
+ run_command(&mut app, "plugin setup", &no_mcp()).await;
+ route_paste_event(&mut app, Event::Paste(query.into()));
+ handle_key(
+ &mut app, key(KeyCode::Enter), &PermissionRegistry::default(), &mut None, &no_mcp(),
+ ).await;
+ let last = transcript_text(&app);
+ assert!(
+ last.ends_with(&format!("plugin '{directory}' is ready - no connection required")),
+ "selection must use the installation directory: {last}",
+ );
+ }
+ run_command(&mut app, "plugin setup beta", &no_mcp()).await;
+ assert!(transcript_text(&app).ends_with("plugin 'beta' is ready - no connection required"));
+ std::fs::remove_dir_all(root).unwrap();
+ }
+
+ #[tokio::test]
+ async fn plugin_setup_search_filters_without_leaking_or_selecting_empty_results() {
+ let (mut app, root) = skill_test_app("deploy", "How to deploy.");
+ for (name, description) in [
+ ("alpha", "General development tools"),
+ ("figma", "Canvas design tools with a long description that must not hide the plugin name"),
+ ("qjk-tools", "Keyboard tools"),
+ ] {
+ let dir = root.join(".jan/agent/plugins").join(name);
+ std::fs::create_dir_all(&dir).unwrap();
+ std::fs::write(
+ dir.join("plugin.toml"),
+ format!("name = \"{name}\"\ndescription = \"{description}\"\n"),
+ ).unwrap();
+ }
+ run_command(&mut app, "plugin setup", &no_mcp()).await;
+ let screen = render_rows(&mut app, 50, 20).join("\n");
+ assert!(screen.contains("figma"), "name must remain visible: {screen}");
+
+ // q/j/k are search text here, not the generic picker's shortcuts.
+ for ch in "qjk".chars() {
+ handle_key(
+ &mut app, key(KeyCode::Char(ch)), &PermissionRegistry::default(), &mut None, &no_mcp(),
+ ).await;
+ }
+ let screen = render_rows(&mut app, 70, 20).join("\n");
+ assert!(screen.contains("qjk-tools") && !screen.contains("alpha"), "{screen}");
+ handle_key(
+ &mut app, key(KeyCode::Esc), &PermissionRegistry::default(), &mut None, &no_mcp(),
+ ).await;
+ run_command(&mut app, "plugin setup", &no_mcp()).await;
+
+ // Paste matches descriptions case-insensitively and stays out of chat.
+ route_paste_event(&mut app, Event::Paste("CANVAS".into()));
+ assert!(app.input.is_empty(), "search paste leaked into chat");
+ let screen = render_rows(&mut app, 70, 20).join("\n");
+ assert!(screen.contains("figma") && !screen.contains("alpha"), "{screen}");
+ handle_key(
+ &mut app, key(KeyCode::Char('é')), &PermissionRegistry::default(), &mut None, &no_mcp(),
+ ).await;
+ let screen = render_rows(&mut app, 70, 20).join("\n");
+ assert!(screen.contains("No plugins match"), "{screen}");
+ handle_key(
+ &mut app, key(KeyCode::Enter), &PermissionRegistry::default(), &mut None, &no_mcp(),
+ ).await;
+ assert!(app.picker.is_some(), "Enter with no matches must keep search open");
+ handle_key(
+ &mut app, key(KeyCode::Backspace), &PermissionRegistry::default(), &mut None, &no_mcp(),
+ ).await;
+ handle_key(
+ &mut app, key(KeyCode::Enter), &PermissionRegistry::default(), &mut None, &no_mcp(),
+ ).await;
+ assert!(app.picker.is_none());
+ let transcript = transcript_text(&app);
+ assert!(transcript.contains("plugin 'figma' is ready"), "{transcript}");
+ assert!(!transcript.contains("alpha") && !transcript.contains("qjk-tools"), "{transcript}");
+ std::fs::remove_dir_all(root).unwrap();
+ }
+
+
+ #[tokio::test]
+ async fn plugin_setup_without_name_waits_for_one_selection() {
+ let (mut app, root) = skill_test_app("deploy", "How to deploy.");
+ for name in ["alpha", "example-plugin", "figma"] {
+ let dir = root.join(".jan/agent/plugins").join(name);
+ std::fs::create_dir_all(&dir).unwrap();
+ std::fs::write(dir.join("plugin.toml"), format!("name = \"{name}\"\n")).unwrap();
+ if name != "alpha" {
+ std::fs::write(
+ dir.join(".mcp.json"),
+ r#"{"mcpServers":{"remote":{"url":"https://mcp.example.com/api"}}}"#,
+ ).unwrap();
+ }
+ }
+ let before = transcript_text(&app);
+ run_command(&mut app, "plugin setup", &no_mcp()).await;
+ assert_eq!(transcript_text(&app), before, "opening setup must not run every plugin");
+ let screen = render_rows(&mut app, 100, 30).join("\n");
+ assert!(screen.contains("alpha") && screen.contains("figma"), "{screen}");
+ assert!(!screen.contains("Enable and connect"), "{screen}");
+ handle_key(
+ &mut app, key(KeyCode::Esc), &PermissionRegistry::default(), &mut None, &no_mcp(),
+ ).await;
+ assert!(app.picker.is_none());
+ assert!(app.mcp_job_request.is_none());
+ assert_eq!(transcript_text(&app), before);
+
+ run_command(&mut app, "plugin setup", &no_mcp()).await;
+ let picker = app.picker.as_mut().unwrap();
+ picker.selected = picker.items.iter().position(|p| p.value == "figma").unwrap();
+ handle_key(
+ &mut app, key(KeyCode::Enter), &PermissionRegistry::default(), &mut None, &no_mcp(),
+ ).await;
+ let screen = render_rows(&mut app, 100, 30).join("\n");
+ assert!(screen.contains("Enable and connect figma:remote"), "{screen}");
+ assert!(app.mcp_job_request.is_none(), "selection still requires connection consent");
+ handle_key(
+ &mut app, key(KeyCode::Down), &PermissionRegistry::default(), &mut None, &no_mcp(),
+ ).await;
+ handle_key(
+ &mut app, key(KeyCode::Enter), &PermissionRegistry::default(), &mut None, &no_mcp(),
+ ).await;
+ assert!(app.picker.is_none(), "skipping the selected plugin must not start another");
+ assert!(app.mcp_job_request.is_none());
+ assert_eq!(transcript_text(&app), before);
+ std::fs::remove_dir_all(root).unwrap();
+ }
#[tokio::test]
async fn plugin_setup_dock_masks_input_and_skips() {