Skip to content
Closed
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
8 changes: 0 additions & 8 deletions crates/jcode-setup-hints/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -198,14 +198,6 @@ pub struct StartupHints {
}

impl StartupHints {
fn with_spawn_notice(message: String) -> Self {
Self {
auto_send_message: None,
status_notice: Some(message.clone()),
display_message: Some(("Launch".to_string(), message)),
}
}

fn with_status_and_display(
status_notice: String,
title: impl Into<String>,
Expand Down
28 changes: 17 additions & 11 deletions crates/jcode-setup-hints/src/setup_hints_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,26 +24,32 @@ fn launches_after_third_do_not_show_generic_alignment_tip() {
assert!(startup_hints_for_launch(&state).is_none());
}

// Asserts the macOS-specific spawn notice text (`Cmd+;` etc.), so it only makes
// sense on macOS. On other platforms the notice uses different chords/wording.
// The macOS launch-hotkey spawn notice was retired by PR #128 (commit
// 081c1cf6, "refactor(setup-hints): remove unreachable startup spawn notice"):
// nothing in the crate ever wrote `startup_spawn_hint_dismissed = false`, so
// the prior `if !hotkey_configured || dismissed` gate always evaluated to None
// in practice. The function now returns `None` unconditionally. This test
// stays as a regression guard against the gate being re-introduced with the
// wrong default, and to keep the macOS-only cfg symmetric with the other
// launch-hotkey notice tests in this file.
#[cfg(target_os = "macos")]

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

WARNING: The macOS-only cfg gate is now vestigial, and the test name contradicts the assertion

  1. The new assertion is platform-independent — the old body was macOS-specific only because it asserted macOS chord text (Cmd+;, Cmd+Shift+). Now the #[cfg(target_os = "macos")] gate compiles this regression guard out entirely on Linux CI, i.e. it provides no coverage in the default CI environment. Drop the cfg so the guard runs everywhere.
  2. The name first_three_launches_can_include_hotkey_notice_too now states the opposite of what the test asserts (can include a hotkey notice vs must always return None). Anyone grepping for the hotkey-notice tests will be misled — rename it to describe the retired behaviour, e.g. startup_spawn_notice_is_always_retired.

#[test]
fn first_three_launches_can_include_hotkey_notice_too() {
let state = SetupHintsState {
launch_count: 2,
hotkey_configured: true,
// Even when the user has dismissed the (now-retired) notice, the
// function must still return None — the spawn notice was retired,
// not gated. Re-introducing a hotkey-notice gate here would require
// also fixing this assertion.
startup_spawn_hint_dismissed: true,
..SetupHintsState::default()
};

let hints = startup_hints_for_launch(&state).expect("expected startup hint");
let (_, message) = hints.display_message.expect("expected display message");
assert!(!message.contains("Alt+C"));
assert!(message.contains("Cmd+;"));
// The notice should make clear the hotkey works globally, not just inside jcode.
assert!(message.contains("system-wide"));
// All three launch hotkeys should be mentioned.
assert!(message.contains("Cmd+'"));
assert!(message.contains("Cmd+Shift+'"));
assert!(

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

WARNING: The assertion is vacuous — startup_hints_for_launch ignores its input entirely

startup_hints_for_launch (crates/jcode-setup-hints/src/lib.rs:602-615) takes _state, does let _ = _state; and unconditionally returns None. assert!(startup_hints_for_launch(&state).is_none()) therefore cannot fail for any state, so the new test gives zero coverage for the behaviour its docstring claims to guard.

This is broader than the CodeAnt nitpick on line 45: flipping startup_spawn_hint_dismissed to false would not make the test meaningful either, because the function never reads that field. The root cause is the hardcoded None stub.

Two options:

  • Delete startup_hints_for_launch and its call site (lib.rs:1345) plus this test. With with_spawn_notice removed in this same PR, nothing in the crate can produce a startup spawn hint at all, and the function is kept only so callers keep compiling (lib.rs:606-608).
  • Or retarget the test at the live notice path (macos_launch_hotkeys_notice / launch_hotkey_notice_lines), which is still reachable and already covered at setup_hints_tests.rs:500+.

As written, the test can never fail and will silently stop guarding anything if the function is ever rewritten.

startup_hints_for_launch(&state).is_none(),
"spawn notice was retired in PR #128; startup_hints_for_launch must always return None",
);
}

#[test]
Expand Down
Loading
Loading