Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 23 additions & 4 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -164,10 +164,7 @@ async fn run_server(ready: Option<std::sync::mpsc::Sender<()>>) -> Result<()> {
.context("start filesystem journal persistence")?,
);

let root = std::env::current_dir()
.context("resolve current workspace")?
.canonicalize()
.context("canonicalize workspace")?;
let root = resolve_workspace_root()?;
let policy = ExecutionPolicy {
default: PolicyDecision::Allow,
per_agent_tool: BTreeMap::new(),
Expand Down Expand Up @@ -437,6 +434,28 @@ fn user_home() -> Option<PathBuf> {
std::env::var_os(if cfg!(windows) { "USERPROFILE" } else { "HOME" }).map(PathBuf::from)
}

fn resolve_workspace_root() -> Result<PathBuf> {
#[cfg(all(not(debug_assertions), feature = "embedded-web"))]
if let Some(home) = user_home() {
let workspace = if cfg!(target_os = "macos") {
home.join("Library/Application Support/ChatCmdClient/workspace")
} else if cfg!(target_os = "windows") {
home.join("AppData/Roaming/ChatCmdClient/workspace")
} else {
home.join(".local/share/ChatCmdClient/workspace")
};
std::fs::create_dir_all(&workspace).context("create packaged workspace")?;
return workspace
.canonicalize()
.context("canonicalize packaged workspace");
}

std::env::current_dir()
.context("resolve current workspace")?
.canonicalize()
.context("canonicalize workspace")
}

#[cfg(test)]
mod tests {
use super::*;
Expand Down
2 changes: 1 addition & 1 deletion src/runtime_host/subagent_tests.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use chatcmd_mcp::catalog_hash;
use chatcmd_runtime::OperationContext;
use chatcmd_runtime::{OperationContext, ShellCreateRequest};
use serde_json::{Value, json};
use sqlx::Row as _;
use tempfile::TempDir;
Expand Down
Loading