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
17 changes: 4 additions & 13 deletions crates/tokscale-cli/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4542,18 +4542,9 @@ fn run_graph_command(
use tokscale_core::{generate_local_graph_report, GroupBy, ReportOptions};

let show_progress = output.is_some() && !no_spinner;
let include_cursor = home_dir.is_none()
&& clients
.as_ref()
.is_none_or(|s| s.iter().any(|src| src == "cursor"));
let had_cursor_cache = has_cursor_usage_cache_for_report(&home_dir);
let explicit_cursor_filter = client_filter_explicitly_requests_cursor(&clients);
let has_cursor_cache = include_cursor && has_cursor_usage_cache_for_report(&home_dir);
let mut cursor_sync_result: Option<cursor::SyncCursorResult> = None;

if include_cursor && cursor::is_cursor_logged_in() {
let rt_sync = tokio::runtime::Runtime::new()?;
cursor_sync_result = Some(rt_sync.block_on(async { cursor::sync_cursor_cache().await }));
}
let cursor_sync_result = auto_sync_cursor_for_local_report(&home_dir, &clients);
let cursor_setup_warnings = setup_warnings_for_report(&home_dir, &clients);

if show_progress {
Expand Down Expand Up @@ -4583,7 +4574,7 @@ fn run_graph_command(
.map_err(|e| anyhow::anyhow!(e))?;
emit_cursor_sync_warning(
cursor_sync_result.as_ref(),
has_cursor_cache,
had_cursor_cache,
explicit_cursor_filter,
);
emit_cursor_setup_warnings(&cursor_setup_warnings);
Expand Down Expand Up @@ -4634,7 +4625,7 @@ fn run_graph_command(
.bright_black()
);
} else if let Some(err) = sync.error {
if has_cursor_cache {
if had_cursor_cache {
eprintln!("{}", format!(" Cursor: sync failed - {}", err).yellow());
}
}
Expand Down
26 changes: 26 additions & 0 deletions crates/tokscale-cli/tests/cli_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1335,6 +1335,32 @@ fn test_graph_cursor_explicit_missing_cache_reports_setup_warning_text() {
.stderr(predicate::str::contains("tokscale cursor login"));
}

#[test]
fn test_graph_fresh_cursor_cache_skips_auto_sync_warning() {
let tmp = create_empty_fixture_dir();
write_cursor_credentials(tmp.path());
write_cursor_usage_cache(tmp.path());

let output = cmd_with_home(tmp.path())
.env("HTTPS_PROXY", "http://127.0.0.1:9")
.env("HTTP_PROXY", "http://127.0.0.1:9")
.env("ALL_PROXY", "http://127.0.0.1:9")
.args(["graph", "--client", "cursor", "--no-spinner"])
.output()
.unwrap();

assert!(
output.status.success(),
"stderr: {}",
String::from_utf8_lossy(&output.stderr)
);
let stderr = String::from_utf8_lossy(&output.stderr);
assert!(
!stderr.contains("Cursor sync failed") && !stderr.contains("Cursor sync warning"),
"fresh Cursor cache should skip implicit graph sync; stderr: {stderr}"
);
}

#[test]
fn test_submit_cursor_explicit_missing_cache_reports_setup_warning_text() {
let tmp = create_empty_fixture_dir();
Expand Down
Loading