Skip to content
30 changes: 24 additions & 6 deletions crates/jcode-app-core/examples/print_build_info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,28 @@ fn main() {
println!(" source_fingerprint: {:?}", info.source_fingerprint);

println!();
println!("current_git_hash: {}", current_git_hash(repo).expect("current_git_hash"));
println!("current_git_hash_full: {}", current_git_hash_full(repo).expect("current_git_hash_full"));
println!("current_git_diff: {}", current_git_diff(repo).expect("current_git_diff"));
println!("current_source_state: {:?}", current_source_state(repo).expect("current_source_state"));
println!("is_working_tree_dirty: {}", is_working_tree_dirty(repo).expect("is_working_tree_dirty"));
println!("current_version_file: {:?}", current_version_file().expect("current_version_file"));
println!(
"current_git_hash: {}",
current_git_hash(repo).expect("current_git_hash")
);
println!(
"current_git_hash_full: {}",
current_git_hash_full(repo).expect("current_git_hash_full")
);
println!(
"current_git_diff: {}",
current_git_diff(repo).expect("current_git_diff")
);
println!(
"current_source_state: {:?}",
current_source_state(repo).expect("current_source_state")
);
println!(
"is_working_tree_dirty: {}",
is_working_tree_dirty(repo).expect("is_working_tree_dirty")
);
println!(
"current_version_file: {:?}",
current_version_file().expect("current_version_file")
);
}
11 changes: 9 additions & 2 deletions crates/jcode-base/tests/mcp_xj07_failure_modes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,11 @@ async fn unregister_restores_prior_configuration() {

// Verify the prior server is preserved and the removed one is gone.
let restored = McpConfig::load_from_file(&config_path).expect("load restored config");
assert_eq!(restored.servers.len(), 1, "must have exactly 1 server after unregister");
assert_eq!(
restored.servers.len(),
1,
"must have exactly 1 server after unregister"
);
assert!(
restored.servers.contains_key("keep-me"),
"keep-me must survive unregister"
Expand All @@ -342,7 +346,10 @@ async fn unregister_restores_prior_configuration() {
.await
.expect("keep-me must connect");
assert!(
manager.connected_servers().await.contains(&"keep-me".to_string()),
manager
.connected_servers()
.await
.contains(&"keep-me".to_string()),
"keep-me must be in connected set"
);

Expand Down
6 changes: 5 additions & 1 deletion crates/jcode-core/examples/smoke.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,11 @@ fn main() {

let long = "a".repeat(120);
let truncated = util::truncate_str(&long, 20);
println!("util::truncate_str(120 chars, 20) -> len {} ({:?})", truncated.len(), truncated);
println!(
"util::truncate_str(120 chars, 20) -> len {} ({:?})",
truncated.len(),
truncated
);

let sample = "the quick brown fox jumps over the lazy dog";
let est = util::estimate_tokens(sample);
Expand Down
5 changes: 1 addition & 4 deletions crates/jcode-core/src/stdin_detect_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -234,10 +234,7 @@ fn test_is_stdin_pipe_is_negation_of_interactive() {
fn test_is_stdin_interactive_consistency_with_is_terminal_trait() {
// Our helper should agree with the raw IsTerminal trait call.
use std::io::IsTerminal;
assert_eq!(
is_stdin_interactive(),
std::io::stdin().is_terminal()
);
assert_eq!(is_stdin_interactive(), std::io::stdin().is_terminal());
}

#[cfg(target_os = "linux")]
Expand Down
20 changes: 8 additions & 12 deletions crates/jcode-harness-api-server/src/translate_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3518,12 +3518,10 @@ fn session_tool_controls_require_attachment_and_negotiated_support() {
),
] {
let actions = state.api_request_to_legacy(&request);
assert!(
matches!(actions.as_slice(), [Outbound::Reply(frame)]
if frame.reply_to == Some(9)
&& matches!(&frame.event, ApiEvent::Error { code, .. } if code == code)
)
);
assert!(matches!(actions.as_slice(), [Outbound::Reply(frame)]
if frame.reply_to == Some(9)
&& matches!(&frame.event, ApiEvent::Error { code, .. } if code == code)
));
assert!(state.pending_simple.is_empty());
}
let mut state = tool_state();
Expand Down Expand Up @@ -3597,12 +3595,10 @@ fn tool_controls_validate_pending_attachment_and_required_session() {
] {
let actions = state
.api_request_to_legacy(&json!({"id":3,"req":"list_tools","session_id":session_id}));
assert!(
matches!(actions.as_slice(), [Outbound::Reply(frame)]
if frame.reply_to == Some(3)
&& matches!(&frame.event, ApiEvent::Error { code, .. } if code == code)
)
);
assert!(matches!(actions.as_slice(), [Outbound::Reply(frame)]
if frame.reply_to == Some(3)
&& matches!(&frame.event, ApiEvent::Error { code, .. } if code == code)
));
}
}

Expand Down
32 changes: 16 additions & 16 deletions crates/jcode-harness-api/src/sockets.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,15 @@ fn product_path(path: PathBuf) -> Option<PathBuf> {

/// Runtime directory holding the daemon and API sockets.
pub fn runtime_dir() -> PathBuf {
if let Ok(dir) = std::env::var("KCODE_RUNTIME_DIR") {
if let Some(path) = product_path(PathBuf::from(dir)) {
return path;
}
if let Ok(dir) = std::env::var("KCODE_RUNTIME_DIR")
&& let Some(path) = product_path(PathBuf::from(dir))
{
return path;
}
if let Ok(dir) = std::env::var("XDG_RUNTIME_DIR") {
if let Some(path) = product_path(PathBuf::from(dir)) {
return path;
}
if let Ok(dir) = std::env::var("XDG_RUNTIME_DIR")
&& let Some(path) = product_path(PathBuf::from(dir))
{
return path;
}
#[cfg(target_os = "macos")]
if let Ok(dir) = std::env::var("TMPDIR") {
Expand Down Expand Up @@ -92,21 +92,21 @@ fn sanitize(raw: String) -> String {

/// Path of the versioned harness API socket. `KCODE_API_SOCKET` overrides it.
pub fn api_socket_path() -> PathBuf {
if let Ok(custom) = std::env::var("KCODE_API_SOCKET") {
if let Some(path) = product_path(PathBuf::from(custom)) {
return path;
}
if let Ok(custom) = std::env::var("KCODE_API_SOCKET")
&& let Some(path) = product_path(PathBuf::from(custom))
{
return path;
}
runtime_dir().join("kcode-api.sock")
}

/// Path of the internal daemon socket the bridge translates onto.
/// `KCODE_SOCKET` overrides it.
pub fn legacy_socket_path() -> PathBuf {
if let Ok(custom) = std::env::var("KCODE_SOCKET") {
if let Some(path) = product_path(PathBuf::from(custom)) {
return path;
}
if let Ok(custom) = std::env::var("KCODE_SOCKET")
&& let Some(path) = product_path(PathBuf::from(custom))
{
return path;
}
Comment on lines +106 to 110

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggestion: When KCODE_SOCKET is relative, product_path rejects it while the daemon still uses it directly; the API bridge then dials the default socket instead.

Assessment: 🟠 Major · 🔁 Occurrence: Rarely · 🏷️ Api mismatch

Use CodeAnt Skill Fix in Cursor Fix in VSCode Claude

Prompt for AI Agent 🤖
This is a comment left during a code review.

**Path:** crates/jcode-harness-api/src/sockets.rs
**Line:** 106:110
**Comment:**
	*Api Mismatch: When `KCODE_SOCKET` is relative, `product_path` rejects it while the daemon still uses it directly; the API bridge then dials the default socket instead.

Validate the correctness of the flagged issue. If correct, How can I resolve this? If you propose a fix, implement it and please make it concise.
Once fix is implemented, also check other comments on the same PR, and ask user if the user wants to fix the rest of the comments as well. if said yes, then fetch all the comments validate the correctness and implement a minimal fix
👍 | 👎

runtime_dir().join("kcode.sock")
}
Expand Down
2 changes: 1 addition & 1 deletion crates/jcode-herdr/examples/round_trip_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@
//! cargo run -p jcode-herdr --example round_trip_state
//! ```

use jcode_herdr::state::AgentState;
use jcode_herdr::HerdrEnv;
use jcode_herdr::state::AgentState;

fn main() {
for state in [AgentState::Working, AgentState::Idle, AgentState::Blocked] {
Expand Down
1 change: 0 additions & 1 deletion crates/jcode-tui-mermaid/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -432,7 +432,6 @@ static RENDER_CACHE: LazyLock<Mutex<MermaidCache>> =
static DEFERRED_RENDER_EPOCH: AtomicU64 = AtomicU64::new(1);

/// Hash of mermaid source text to the geometry triples (w1,h1),(w2,h2),(w3,h3) for three render profiles.

/// This lets transcript clicks copy editable Mermaid text instead of PNG pixels.
static MERMAID_SOURCE_BY_HASH: LazyLock<Mutex<HashMap<u64, String>>> =
LazyLock::new(|| Mutex::new(HashMap::new()));
Expand Down
2 changes: 1 addition & 1 deletion crates/jcode-tui/src/tui/app/helpers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ pub(super) fn launch_client_executable() -> PathBuf {
crate::build::client_update_candidate(jcode_selfdev_types::client_selfdev_requested())
.map(|(path, _label)| path)
.or_else(|| std::env::current_exe().ok())
.unwrap_or_else(|| PathBuf::from("jcode"))
.unwrap_or_else(|| PathBuf::from("kcode"))
}

pub(super) fn partition_queued_messages(
Expand Down
4 changes: 2 additions & 2 deletions crates/jcode-tui/src/tui/app/helpers_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,7 @@ fn build_resume_command_uses_imported_jcode_session_for_claude_code() {

assert_eq!(
program.file_name().and_then(|name| name.to_str()),
Some("jcode")
Some("kcode")
);
assert_eq!(
args,
Expand All @@ -382,7 +382,7 @@ fn build_resume_command_uses_imported_jcode_session_for_codex() {

assert_eq!(
program.file_name().and_then(|name| name.to_str()),
Some("jcode")
Some("kcode")
);
assert_eq!(
args,
Expand Down
10 changes: 5 additions & 5 deletions crates/jcode-tui/src/tui/app/turn_notify.rs
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ pub(super) fn build_turn_notification(
todos: &[TodoItem],
last_assistant_text: Option<&str>,
) -> TurnNotification {
let mut title = String::from("jcode");
let mut title = String::from("kcode");
if let Some(name) = session_name {
title.push_str(" · ");
title.push_str(name);
Expand Down Expand Up @@ -440,7 +440,7 @@ mod tests {
#[test]
fn title_includes_session_and_compact_duration() {
let n = build_turn_notification(Some("fox"), 754.0, &[], Some("All done."));
assert_eq!(n.title, "jcode · fox · done in 12m 34s");
assert_eq!(n.title, "kcode · fox · done in 12m 34s");
assert_eq!(n.subtitle, None);
assert_eq!(n.body, "All done.");
}
Expand All @@ -452,7 +452,7 @@ mod tests {
todo_named("handle reconnect", "in_progress", &[]),
];
let n = build_turn_notification(None, 200.0, &todos, Some("Fixed the parser bug."));
assert_eq!(n.title, "jcode · done in 3m 20s");
assert_eq!(n.title, "kcode · done in 3m 20s");
assert_eq!(n.subtitle.as_deref(), Some("1/2 todos"));
// Names actual todo work, not the prose snippet.
assert_eq!(n.body, "✓ wire up parser · → handle reconnect");
Expand Down Expand Up @@ -513,7 +513,7 @@ mod tests {
#[test]
fn empty_inputs_fall_back_to_minimal_body() {
let n = build_turn_notification(None, 65.0, &[], None);
assert_eq!(n.title, "jcode · done in 1m 5s");
assert_eq!(n.title, "kcode · done in 1m 5s");
assert_eq!(n.subtitle, None);
assert_eq!(n.body, "Turn finished");
}
Expand Down Expand Up @@ -542,7 +542,7 @@ mod tests {
};
assert_eq!(
kitty_notification_sequence(&n, "session:fox/123"),
"\x1b]99;i=jcode-turn-sessionfox123:d=0:e=1:p=title;amNvZGUgwrcgZm94\x1b\\\x1b]99;i=jcode-turn-sessionfox123:d=1:e=1:p=body:a=focus;Mi8zIHRvZG9zCkZpbmlzaGVkIHBhcnNlcg==\x1b\\"
"\x1b]99;i=kcode-turn-sessionfox123:d=0:e=1:p=title;amNvZGUgwrcgZm94\x1b\\\x1b]99;i=kcode-turn-sessionfox123:d=1:e=1:p=body:a=focus;Mi8zIHRvZG9zCkZpbmlzaGVkIHBhcnNlcg==\x1b\\"
);
}

Expand Down
8 changes: 7 additions & 1 deletion crates/jcode-tui/src/tui/kv_cache_problem.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,13 @@ fn min_cacheable_input_tokens(provider: &str, upstream_provider: Option<&str>) -
}

pub(crate) fn cache_expected_warm(cache_ttl: Option<&CacheTtlInfo>) -> bool {
cache_ttl.map(|info| !info.is_cold).unwrap_or(false)
// An `is_estimate` value is a heuristic guess, not evidence: only treat the
// cache as expected-warm when we have a concrete TTL reading AND it is not
// already cold. See `cache_estimate_is_not_evidence_of_an_expected_warm_hit`
// in the tui::tests module for the regression this guards against.
cache_ttl
.map(|info| !info.is_estimate && !info.is_cold)
.unwrap_or(false)
}

/// Detect a KV/prompt-cache problem that is reliable enough to surface in the UI.
Expand Down
2 changes: 1 addition & 1 deletion crates/jcode-tui/src/tui/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1067,9 +1067,9 @@ impl CacheTtlInfo {
pub use crate::provider::{cache_ttl_for_provider, cache_ttl_for_provider_model};

mod kv_cache_problem;
pub(crate) use kv_cache_problem::cache_expected_warm;
#[cfg(test)]
pub(crate) use kv_cache_problem::KvCacheProblemKind;
pub(crate) use kv_cache_problem::cache_expected_warm;
pub(crate) use kv_cache_problem::detect_kv_cache_problem;

#[derive(Debug, Clone, Copy, PartialEq, Eq)]
Expand Down
2 changes: 1 addition & 1 deletion tests/cli_exit_status.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use std::process::{Command, Output};

fn invoke(args: &[&str]) -> Output {
let root = tempfile::tempdir().unwrap();
let output = Command::new(env!("CARGO_BIN_EXE_jcode"))
let output = Command::new(std::env::var("CARGO_BIN_EXE_jcode").expect("CARGO_BIN_EXE_jcode"))

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggestion: Cargo.toml defines the executable as kcode, not jcode, so CARGO_BIN_EXE_jcode is absent and every exit-status test panics here before spawning the CLI.

Assessment: 🟠 Major · 🔁 Occurrence: Often · 🏷️ Api mismatch

Use CodeAnt Skill Fix in Cursor Fix in VSCode Claude

Prompt for AI Agent 🤖
This is a comment left during a code review.

**Path:** tests/cli_exit_status.rs
**Line:** 6:6
**Comment:**
	*Api Mismatch: `Cargo.toml` defines the executable as `kcode`, not `jcode`, so `CARGO_BIN_EXE_jcode` is absent and every exit-status test panics here before spawning the CLI.

Validate the correctness of the flagged issue. If correct, How can I resolve this? If you propose a fix, implement it and please make it concise.
Once fix is implemented, also check other comments on the same PR, and ask user if the user wants to fix the rest of the comments as well. if said yes, then fetch all the comments validate the correctness and implement a minimal fix
👍 | 👎

.current_dir(root.path())
.env_clear()
.env("HOME", root.path())
Expand Down
Loading