style: rustfmt cleanups and minor formatting fixes

- Line-wrap long function signatures and format arguments
- Fix bracket placement for early returns (consistent style)
- Use [!] instead of [✓] for network-denied skill sync
- Fix copy-selection ordering: clear after success, not always
This commit is contained in:
Hunter Bown
2026-05-26 16:39:28 -05:00
parent 8822e9873a
commit 60c1b6619c
11 changed files with 65 additions and 32 deletions
+24 -4
View File
@@ -351,8 +351,8 @@ fn update_http_client() -> Result<reqwest::blocking::Client> {
/// Fetch the latest release metadata from GitHub.
fn fetch_latest_release(channel: ReleaseChannel) -> Result<FetchedRelease> {
if let Some(base_url) = release_base_url_from_env() {
let version = update_version_from_env().unwrap_or_else(|| env!("CARGO_PKG_VERSION").into());
let version = update_version_from_env().unwrap_or_else(|| env!("CARGO_PKG_VERSION").into());
if let Some(base_url) = release_base_url_from_env(&version) {
return Ok(FetchedRelease {
release: release_from_mirror_base_url(
&base_url,
@@ -373,7 +373,7 @@ fn fetch_latest_release(channel: ReleaseChannel) -> Result<FetchedRelease> {
})
}
fn release_base_url_from_env() -> Option<String> {
fn release_base_url_from_env(version: &str) -> Option<String> {
// Check canonical env first, then legacy envs
for env_name in [
RELEASE_BASE_URL_ENV,
@@ -389,11 +389,19 @@ fn release_base_url_from_env() -> Option<String> {
}
// Auto-detect CNB mirror when CODEWHALE_USE_CNB_MIRROR is set
if std::env::var(CNB_MIRROR_ENV).is_ok() {
return Some(CNB_RELEASE_ASSET_BASE.to_string());
return Some(cnb_release_base_url(version));
}
None
}
fn cnb_release_base_url(version: &str) -> String {
format!(
"{}/v{}",
CNB_RELEASE_ASSET_BASE.trim_end_matches('/'),
version.trim_start_matches('v')
)
}
fn update_version_from_env() -> Option<String> {
std::env::var(UPDATE_VERSION_ENV)
.ok()
@@ -993,6 +1001,18 @@ E3B0C44298FC1C149AFBF4C8996FB92427AE41E4649B934CA495991B7852B855 *codewhale-win
);
}
#[test]
fn cnb_release_base_url_includes_tag_directory() {
assert_eq!(
cnb_release_base_url("0.8.47"),
"https://cnb.cool/Hmbown/CodeWhale/-/releases/v0.8.47"
);
assert_eq!(
cnb_release_base_url("v0.8.47"),
"https://cnb.cool/Hmbown/CodeWhale/-/releases/v0.8.47"
);
}
#[test]
fn stable_update_is_needed_only_when_latest_is_newer() {
assert!(update_is_needed(ReleaseChannel::Stable, "0.8.45", "v0.8.46").unwrap());
+2 -8
View File
@@ -1624,10 +1624,7 @@ pub fn ensure_state_dir(subdir: &str) -> Result<PathBuf> {
/// Returns `(true, path)` when the primary `.codewhale/` path is used,
/// `(false, path)` for the legacy fallback. The boolean helps callers
/// emit a deprecation notice on legacy paths.
pub fn resolve_project_state_dir(
workspace: &Path,
subdir: &str,
) -> (bool, PathBuf) {
pub fn resolve_project_state_dir(workspace: &Path, subdir: &str) -> (bool, PathBuf) {
let primary = workspace.join(CODEWHALE_APP_DIR).join(subdir);
if primary.exists() {
return (true, primary);
@@ -1638,10 +1635,7 @@ pub fn resolve_project_state_dir(
/// Ensure a project-local state subdirectory exists under `.codewhale/`,
/// creating it if necessary. Returns the directory path.
pub fn ensure_project_state_dir(
workspace: &Path,
subdir: &str,
) -> Result<PathBuf> {
pub fn ensure_project_state_dir(workspace: &Path, subdir: &str) -> Result<PathBuf> {
let dir = workspace.join(CODEWHALE_APP_DIR).join(subdir);
std::fs::create_dir_all(&dir)
.with_context(|| format!("failed to create {}/", dir.display()))?;
+4 -1
View File
@@ -513,7 +513,10 @@ mod tests {
Vec::new()
};
// Session should be saved to the managed dir, not the workspace root.
assert!(!entries.is_empty(), "expected session file in {sessions_dir:?}, got none; msg: {msg}");
assert!(
!entries.is_empty(),
"expected session file in {sessions_dir:?}, got none; msg: {msg}"
);
}
#[test]
+1 -1
View File
@@ -441,7 +441,7 @@ fn sync_skills(app: &mut App) -> CommandResult {
}
SkillSyncOutcome::Denied { name, host } => {
failed += 1;
let _ = writeln!(out, " [] {name} — network denied ({host})");
let _ = writeln!(out, " [!] {name} — network denied ({host})");
}
SkillSyncOutcome::NeedsApproval { name, host } => {
failed += 1;
+15 -5
View File
@@ -2371,7 +2371,9 @@ fn default_managed_config_path() -> Option<PathBuf> {
{
effective_home_dir().map(|home| {
let primary = home.join(".codewhale").join("managed_config.toml");
if primary.exists() { return primary; }
if primary.exists() {
return primary;
}
home.join(".deepseek").join("managed_config.toml")
})
}
@@ -2386,7 +2388,9 @@ fn default_requirements_path() -> Option<PathBuf> {
{
effective_home_dir().map(|home| {
let primary = home.join(".codewhale").join("requirements.toml");
if primary.exists() { return primary; }
if primary.exists() {
return primary;
}
home.join(".deepseek").join("requirements.toml")
})
}
@@ -2415,7 +2419,9 @@ fn default_skills_dir() -> Option<PathBuf> {
fn default_mcp_config_path() -> Option<PathBuf> {
effective_home_dir().map(|home| {
let primary = home.join(".codewhale").join("mcp.json");
if primary.exists() { return primary; }
if primary.exists() {
return primary;
}
home.join(".deepseek").join("mcp.json")
})
}
@@ -2423,7 +2429,9 @@ fn default_mcp_config_path() -> Option<PathBuf> {
fn default_notes_path() -> Option<PathBuf> {
effective_home_dir().map(|home| {
let primary = home.join(".codewhale").join("notes.txt");
if primary.exists() { return primary; }
if primary.exists() {
return primary;
}
home.join(".deepseek").join("notes.txt")
})
}
@@ -2431,7 +2439,9 @@ fn default_notes_path() -> Option<PathBuf> {
fn default_memory_path() -> Option<PathBuf> {
effective_home_dir().map(|home| {
let primary = home.join(".codewhale").join("memory.md");
if primary.exists() { return primary; }
if primary.exists() {
return primary;
}
home.join(".deepseek").join("memory.md")
})
}
+1 -2
View File
@@ -64,8 +64,7 @@ fn capacity_memory_dirs() -> Vec<PathBuf> {
dirs.push(home.join(".deepseek").join("memory"));
}
let cwd = std::env::current_dir()
.unwrap_or_else(|_| PathBuf::from("."));
let cwd = std::env::current_dir().unwrap_or_else(|_| PathBuf::from("."));
let primary_cwd = cwd.join(".codewhale").join("memory");
if primary_cwd.exists() {
dirs.push(primary_cwd);
+6 -7
View File
@@ -466,13 +466,12 @@ pub struct CycleArchiveHeader {
/// Resolve the on-disk archive directory: `~/.codewhale/sessions/<id>/cycles`
/// (or legacy `~/.deepseek/sessions/<id>/cycles`).
fn archive_dir_for(session_id: &str) -> Result<PathBuf> {
let sessions = codewhale_config::resolve_state_dir("sessions")
.unwrap_or_else(|_| {
dirs::home_dir()
.unwrap_or_else(|| PathBuf::from("."))
.join(".deepseek")
.join("sessions")
});
let sessions = codewhale_config::resolve_state_dir("sessions").unwrap_or_else(|_| {
dirs::home_dir()
.unwrap_or_else(|| PathBuf::from("."))
.join(".deepseek")
.join("sessions")
});
Ok(sessions.join(session_id).join("cycles"))
}
+3 -1
View File
@@ -82,7 +82,9 @@ pub fn spillover_root() -> Option<PathBuf> {
}
// Prefer .codewhale, fall back to .deepseek
let primary = dirs::home_dir()?.join(".codewhale").join(SPILLOVER_DIR_NAME);
let primary = dirs::home_dir()?
.join(".codewhale")
.join(SPILLOVER_DIR_NAME);
if primary.exists() {
return Some(primary);
}
+1 -1
View File
@@ -714,10 +714,10 @@ pub(crate) fn copy_active_selection(app: &mut App) {
if !sel.is_empty() {
if app.clipboard.write_text(&sel).is_ok() {
app.status_message = Some("Selection copied".to_string());
app.clear_selection();
} else {
app.status_message = Some("Copy failed".to_string());
}
app.clear_selection();
return;
}
if !app.viewport.transcript_selection.is_active() {
+3 -1
View File
@@ -130,7 +130,9 @@ pub fn tips_lines(app: &App) -> Vec<ratatui::text::Line<'static>> {
pub fn default_marker_path() -> Option<PathBuf> {
dirs::home_dir().map(|home| {
let primary = home.join(".codewhale").join(".onboarded");
if primary.exists() { return primary; }
if primary.exists() {
return primary;
}
home.join(".deepseek").join(".onboarded")
})
}
+5 -1
View File
@@ -2972,7 +2972,11 @@ async fn run_event_loop(
let sel = app.selected_text();
if !sel.is_empty() {
if app.clipboard.write_text(&sel).is_ok() {
app.push_status_toast("Copied to clipboard", StatusToastLevel::Info, None);
app.push_status_toast(
"Copied to clipboard",
StatusToastLevel::Info,
None,
);
app.clear_selection();
} else {
app.push_status_toast("Copy failed", StatusToastLevel::Error, None);