mirror of
https://github.com/tinyhumansai/openhuman.git
synced 2026-07-29 14:02:19 +00:00
chore: apply Prettier formatting to MCP settings panel files
This commit is contained in:
@@ -82,14 +82,17 @@ fn resolve_binary_path() -> Result<PathBuf, String> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let exe = std::env::current_exe()
|
let exe = std::env::current_exe().map_err(|e| format!("current_exe failed: {e}"))?;
|
||||||
.map_err(|e| format!("current_exe failed: {e}"))?;
|
|
||||||
let start = exe
|
let start = exe
|
||||||
.parent()
|
.parent()
|
||||||
.ok_or_else(|| "current_exe has no parent directory".to_string())?;
|
.ok_or_else(|| "current_exe has no parent directory".to_string())?;
|
||||||
|
|
||||||
let candidate = find_debug_binary_walking_up(start)
|
let candidate = find_debug_binary_walking_up(start).ok_or_else(|| {
|
||||||
.ok_or_else(|| format!("could not find target/debug/{bin_name} walking up from {}", start.display()))?;
|
format!(
|
||||||
|
"could not find target/debug/{bin_name} walking up from {}",
|
||||||
|
start.display()
|
||||||
|
)
|
||||||
|
})?;
|
||||||
|
|
||||||
log::debug!(
|
log::debug!(
|
||||||
"[mcp_commands] mcp_resolve_binary_path: dev binary found at {}",
|
"[mcp_commands] mcp_resolve_binary_path: dev binary found at {}",
|
||||||
@@ -99,8 +102,7 @@ fn resolve_binary_path() -> Result<PathBuf, String> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Release mode: sibling binary.
|
// Release mode: sibling binary.
|
||||||
let exe = std::env::current_exe()
|
let exe = std::env::current_exe().map_err(|e| format!("current_exe failed: {e}"))?;
|
||||||
.map_err(|e| format!("current_exe failed: {e}"))?;
|
|
||||||
|
|
||||||
#[cfg(target_os = "macos")]
|
#[cfg(target_os = "macos")]
|
||||||
let candidate = {
|
let candidate = {
|
||||||
@@ -167,10 +169,11 @@ pub fn config_path_for_client(client: &str, os: &str) -> Result<PathBuf, String>
|
|||||||
}
|
}
|
||||||
("claude-desktop", "windows") => {
|
("claude-desktop", "windows") => {
|
||||||
// %APPDATA%\Claude\claude_desktop_config.json
|
// %APPDATA%\Claude\claude_desktop_config.json
|
||||||
let appdata = std::env::var("APPDATA").unwrap_or_else(|_| {
|
let appdata = std::env::var("APPDATA")
|
||||||
home.join("AppData/Roaming").display().to_string()
|
.unwrap_or_else(|_| home.join("AppData/Roaming").display().to_string());
|
||||||
});
|
PathBuf::from(appdata)
|
||||||
PathBuf::from(appdata).join("Claude").join("claude_desktop_config.json")
|
.join("Claude")
|
||||||
|
.join("claude_desktop_config.json")
|
||||||
}
|
}
|
||||||
("claude-desktop", _) => {
|
("claude-desktop", _) => {
|
||||||
// Linux and other Unix
|
// Linux and other Unix
|
||||||
@@ -179,9 +182,8 @@ pub fn config_path_for_client(client: &str, os: &str) -> Result<PathBuf, String>
|
|||||||
|
|
||||||
// Cursor
|
// Cursor
|
||||||
("cursor", "windows") => {
|
("cursor", "windows") => {
|
||||||
let userprofile = std::env::var("USERPROFILE").unwrap_or_else(|_| {
|
let userprofile =
|
||||||
home.display().to_string()
|
std::env::var("USERPROFILE").unwrap_or_else(|_| home.display().to_string());
|
||||||
});
|
|
||||||
PathBuf::from(userprofile).join(".cursor").join("mcp.json")
|
PathBuf::from(userprofile).join(".cursor").join("mcp.json")
|
||||||
}
|
}
|
||||||
("cursor", _) => home.join(".cursor/mcp.json"),
|
("cursor", _) => home.join(".cursor/mcp.json"),
|
||||||
@@ -190,13 +192,10 @@ pub fn config_path_for_client(client: &str, os: &str) -> Result<PathBuf, String>
|
|||||||
("codex", _) => home.join(".codex/config.json"),
|
("codex", _) => home.join(".codex/config.json"),
|
||||||
|
|
||||||
// Zed
|
// Zed
|
||||||
("zed", "macos") => {
|
("zed", "macos") => home.join("Library/Application Support/Zed/settings.json"),
|
||||||
home.join("Library/Application Support/Zed/settings.json")
|
|
||||||
}
|
|
||||||
("zed", "windows") => {
|
("zed", "windows") => {
|
||||||
let appdata = std::env::var("APPDATA").unwrap_or_else(|_| {
|
let appdata = std::env::var("APPDATA")
|
||||||
home.join("AppData/Roaming").display().to_string()
|
.unwrap_or_else(|_| home.join("AppData/Roaming").display().to_string());
|
||||||
});
|
|
||||||
PathBuf::from(appdata).join("Zed").join("settings.json")
|
PathBuf::from(appdata).join("Zed").join("settings.json")
|
||||||
}
|
}
|
||||||
("zed", _) => home.join(".config/zed/settings.json"),
|
("zed", _) => home.join(".config/zed/settings.json"),
|
||||||
@@ -229,8 +228,12 @@ pub fn mcp_open_client_config(client: String) -> Result<(), String> {
|
|||||||
// Ensure the file exists so the editor has something to open.
|
// Ensure the file exists so the editor has something to open.
|
||||||
if !path.exists() {
|
if !path.exists() {
|
||||||
if let Some(parent) = path.parent() {
|
if let Some(parent) = path.parent() {
|
||||||
std::fs::create_dir_all(parent)
|
std::fs::create_dir_all(parent).map_err(|e| {
|
||||||
.map_err(|e| format!("failed to create config directory {}: {e}", parent.display()))?;
|
format!(
|
||||||
|
"failed to create config directory {}: {e}",
|
||||||
|
parent.display()
|
||||||
|
)
|
||||||
|
})?;
|
||||||
}
|
}
|
||||||
std::fs::write(&path, b"")
|
std::fs::write(&path, b"")
|
||||||
.map_err(|e| format!("failed to create config file {}: {e}", path.display()))?;
|
.map_err(|e| format!("failed to create config file {}: {e}", path.display()))?;
|
||||||
@@ -275,8 +278,8 @@ mod tests {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn config_path_claude_desktop_macos() {
|
fn config_path_claude_desktop_macos() {
|
||||||
let path = config_path_for_client("claude-desktop", "macos")
|
let path =
|
||||||
.expect("should resolve on macos");
|
config_path_for_client("claude-desktop", "macos").expect("should resolve on macos");
|
||||||
let s = path.display().to_string();
|
let s = path.display().to_string();
|
||||||
assert!(
|
assert!(
|
||||||
s.contains("Library/Application Support/Claude/claude_desktop_config.json"),
|
s.contains("Library/Application Support/Claude/claude_desktop_config.json"),
|
||||||
@@ -286,10 +289,13 @@ mod tests {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn config_path_claude_desktop_linux() {
|
fn config_path_claude_desktop_linux() {
|
||||||
let path = config_path_for_client("claude-desktop", "linux")
|
let path =
|
||||||
.expect("should resolve on linux");
|
config_path_for_client("claude-desktop", "linux").expect("should resolve on linux");
|
||||||
let s = path.display().to_string();
|
let s = path.display().to_string();
|
||||||
assert!(s.contains(".config/Claude/claude_desktop_config.json"), "unexpected path: {s}");
|
assert!(
|
||||||
|
s.contains(".config/Claude/claude_desktop_config.json"),
|
||||||
|
"unexpected path: {s}"
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
@@ -312,7 +318,10 @@ mod tests {
|
|||||||
let path = config_path_for_client("codex", os)
|
let path = config_path_for_client("codex", os)
|
||||||
.unwrap_or_else(|_| panic!("should resolve for os={os}"));
|
.unwrap_or_else(|_| panic!("should resolve for os={os}"));
|
||||||
let s = path.display().to_string();
|
let s = path.display().to_string();
|
||||||
assert!(s.ends_with(".codex/config.json"), "unexpected path for os={os}: {s}");
|
assert!(
|
||||||
|
s.ends_with(".codex/config.json"),
|
||||||
|
"unexpected path for os={os}: {s}"
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -330,7 +339,10 @@ mod tests {
|
|||||||
fn config_path_zed_linux() {
|
fn config_path_zed_linux() {
|
||||||
let path = config_path_for_client("zed", "linux").expect("should resolve");
|
let path = config_path_for_client("zed", "linux").expect("should resolve");
|
||||||
let s = path.display().to_string();
|
let s = path.display().to_string();
|
||||||
assert!(s.contains(".config/zed/settings.json"), "unexpected path: {s}");
|
assert!(
|
||||||
|
s.contains(".config/zed/settings.json"),
|
||||||
|
"unexpected path: {s}"
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
@@ -369,7 +381,9 @@ mod tests {
|
|||||||
// Acceptable in a clean CI checkout where the binary hasn't
|
// Acceptable in a clean CI checkout where the binary hasn't
|
||||||
// been built yet. The error must be descriptive.
|
// been built yet. The error must be descriptive.
|
||||||
assert!(
|
assert!(
|
||||||
e.contains("openhuman-core") || e.contains("current_exe") || e.contains("target"),
|
e.contains("openhuman-core")
|
||||||
|
|| e.contains("current_exe")
|
||||||
|
|| e.contains("target"),
|
||||||
"error message should reference the binary or path: {e}"
|
"error message should reference the binary or path: {e}"
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,18 +14,11 @@ import { renderWithProviders } from '../../../test/test-utils';
|
|||||||
// Hoisted mocks — must be defined before any imports that trigger the module
|
// Hoisted mocks — must be defined before any imports that trigger the module
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
|
|
||||||
const hoisted = vi.hoisted(() => ({
|
const hoisted = vi.hoisted(() => ({ invoke: vi.fn(), isTauri: vi.fn(() => true) }));
|
||||||
invoke: vi.fn(),
|
|
||||||
isTauri: vi.fn(() => true),
|
|
||||||
}));
|
|
||||||
|
|
||||||
vi.mock('@tauri-apps/api/core', () => ({
|
vi.mock('@tauri-apps/api/core', () => ({ invoke: hoisted.invoke }));
|
||||||
invoke: hoisted.invoke,
|
|
||||||
}));
|
|
||||||
|
|
||||||
vi.mock('../../../utils/tauriCommands/common', () => ({
|
vi.mock('../../../utils/tauriCommands/common', () => ({ isTauri: hoisted.isTauri }));
|
||||||
isTauri: hoisted.isTauri,
|
|
||||||
}));
|
|
||||||
|
|
||||||
vi.mock('../../hooks/useSettingsNavigation', () => ({
|
vi.mock('../../hooks/useSettingsNavigation', () => ({
|
||||||
useSettingsNavigation: () => ({
|
useSettingsNavigation: () => ({
|
||||||
@@ -49,10 +42,7 @@ async function importPanel() {
|
|||||||
|
|
||||||
function setupClipboard() {
|
function setupClipboard() {
|
||||||
const writeText = vi.fn().mockResolvedValue(undefined);
|
const writeText = vi.fn().mockResolvedValue(undefined);
|
||||||
Object.defineProperty(navigator, 'clipboard', {
|
Object.defineProperty(navigator, 'clipboard', { configurable: true, value: { writeText } });
|
||||||
configurable: true,
|
|
||||||
value: { writeText },
|
|
||||||
});
|
|
||||||
return writeText;
|
return writeText;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -66,16 +66,7 @@ function configFilePathFor(client: McpClient, os: string): string {
|
|||||||
function buildSnippet(client: McpClient, binaryPath: string): string {
|
function buildSnippet(client: McpClient, binaryPath: string): string {
|
||||||
if (client === 'zed') {
|
if (client === 'zed') {
|
||||||
return JSON.stringify(
|
return JSON.stringify(
|
||||||
{
|
{ context_servers: { openhuman: { command: { path: binaryPath, args: ['mcp'] } } } },
|
||||||
context_servers: {
|
|
||||||
openhuman: {
|
|
||||||
command: {
|
|
||||||
path: binaryPath,
|
|
||||||
args: ['mcp'],
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
null,
|
null,
|
||||||
2
|
2
|
||||||
);
|
);
|
||||||
@@ -83,14 +74,7 @@ function buildSnippet(client: McpClient, binaryPath: string): string {
|
|||||||
|
|
||||||
// Claude Desktop, Cursor, Codex
|
// Claude Desktop, Cursor, Codex
|
||||||
return JSON.stringify(
|
return JSON.stringify(
|
||||||
{
|
{ mcpServers: { openhuman: { command: binaryPath, args: ['mcp'] } } },
|
||||||
mcpServers: {
|
|
||||||
openhuman: {
|
|
||||||
command: binaryPath,
|
|
||||||
args: ['mcp'],
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
null,
|
null,
|
||||||
2
|
2
|
||||||
);
|
);
|
||||||
@@ -207,10 +191,7 @@ const McpServerPanel = () => {
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
{/* Client selector tabs */}
|
{/* Client selector tabs */}
|
||||||
<div
|
<div className="flex gap-1 mb-4 flex-wrap" role="tablist" aria-label="MCP client selector">
|
||||||
className="flex gap-1 mb-4 flex-wrap"
|
|
||||||
role="tablist"
|
|
||||||
aria-label="MCP client selector">
|
|
||||||
{clients.map(client => (
|
{clients.map(client => (
|
||||||
<button
|
<button
|
||||||
key={client.id}
|
key={client.id}
|
||||||
|
|||||||
@@ -1937,8 +1937,7 @@ const en: TranslationMap = {
|
|||||||
'settings.developerMenu.integrationTriggers.desc':
|
'settings.developerMenu.integrationTriggers.desc':
|
||||||
'Configure AI triage settings for Composio integration triggers',
|
'Configure AI triage settings for Composio integration triggers',
|
||||||
'settings.developerMenu.mcpServer.title': 'MCP Server',
|
'settings.developerMenu.mcpServer.title': 'MCP Server',
|
||||||
'settings.developerMenu.mcpServer.desc':
|
'settings.developerMenu.mcpServer.desc': 'Configure external MCP clients to connect to OpenHuman',
|
||||||
'Configure external MCP clients to connect to OpenHuman',
|
|
||||||
'settings.mcpServer.title': 'MCP Server',
|
'settings.mcpServer.title': 'MCP Server',
|
||||||
'settings.mcpServer.toolsSectionTitle': 'Available Tools',
|
'settings.mcpServer.toolsSectionTitle': 'Available Tools',
|
||||||
'settings.mcpServer.toolsSectionDesc':
|
'settings.mcpServer.toolsSectionDesc':
|
||||||
|
|||||||
@@ -14,9 +14,9 @@ import ComposioTriagePanel from '../components/settings/panels/ComposioTriagePan
|
|||||||
import ConnectionsPanel from '../components/settings/panels/ConnectionsPanel';
|
import ConnectionsPanel from '../components/settings/panels/ConnectionsPanel';
|
||||||
import CronJobsPanel from '../components/settings/panels/CronJobsPanel';
|
import CronJobsPanel from '../components/settings/panels/CronJobsPanel';
|
||||||
import DeveloperOptionsPanel from '../components/settings/panels/DeveloperOptionsPanel';
|
import DeveloperOptionsPanel from '../components/settings/panels/DeveloperOptionsPanel';
|
||||||
import McpServerPanel from '../components/settings/panels/McpServerPanel';
|
|
||||||
import LocalModelDebugPanel from '../components/settings/panels/LocalModelDebugPanel';
|
import LocalModelDebugPanel from '../components/settings/panels/LocalModelDebugPanel';
|
||||||
import MascotPanel from '../components/settings/panels/MascotPanel';
|
import MascotPanel from '../components/settings/panels/MascotPanel';
|
||||||
|
import McpServerPanel from '../components/settings/panels/McpServerPanel';
|
||||||
import MemoryDataPanel from '../components/settings/panels/MemoryDataPanel';
|
import MemoryDataPanel from '../components/settings/panels/MemoryDataPanel';
|
||||||
import MemoryDebugPanel from '../components/settings/panels/MemoryDebugPanel';
|
import MemoryDebugPanel from '../components/settings/panels/MemoryDebugPanel';
|
||||||
import MessagingPanel from '../components/settings/panels/MessagingPanel';
|
import MessagingPanel from '../components/settings/panels/MessagingPanel';
|
||||||
|
|||||||
Reference in New Issue
Block a user