Skip to content

Commit 50d656b

Browse files
committed
v1.0.13
- Fixed console window flash during refreshing token
1 parent 97ca8f8 commit 50d656b

1 file changed

Lines changed: 23 additions & 2 deletions

File tree

src/poller.rs

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,17 +77,38 @@ fn cli_refresh_token() {
7777
cmd.env_remove("CLAUDECODE")
7878
.env_remove("CLAUDE_CODE_ENTRYPOINT")
7979
.creation_flags(CREATE_NO_WINDOW)
80+
.stdin(std::process::Stdio::null())
8081
.stdout(std::process::Stdio::null())
8182
.stderr(std::process::Stdio::null());
8283

83-
let _ = cmd.status();
84+
let mut child = match cmd.spawn() {
85+
Ok(c) => c,
86+
Err(_) => return,
87+
};
88+
89+
// Wait up to 30 seconds — don't block the poll thread forever
90+
let start = std::time::Instant::now();
91+
loop {
92+
match child.try_wait() {
93+
Ok(Some(_)) => break,
94+
Ok(None) => {
95+
if start.elapsed() > Duration::from_secs(30) {
96+
let _ = child.kill();
97+
break;
98+
}
99+
std::thread::sleep(Duration::from_millis(500));
100+
}
101+
Err(_) => break,
102+
}
103+
}
84104
}
85105

86106
/// Resolve the full path to the `claude` CLI executable.
87107
fn resolve_claude_path() -> String {
88108
for name in &["claude.cmd", "claude"] {
89109
if Command::new(name)
90110
.arg("--version")
111+
.creation_flags(CREATE_NO_WINDOW)
91112
.stdout(std::process::Stdio::null())
92113
.stderr(std::process::Stdio::null())
93114
.status()
@@ -98,7 +119,7 @@ fn resolve_claude_path() -> String {
98119
}
99120

100121
for name in &["claude.cmd", "claude"] {
101-
if let Ok(output) = Command::new("where.exe").arg(name).output() {
122+
if let Ok(output) = Command::new("where.exe").arg(name).creation_flags(CREATE_NO_WINDOW).output() {
102123
if output.status.success() {
103124
let stdout = String::from_utf8_lossy(&output.stdout);
104125
if let Some(first_line) = stdout.lines().next() {

0 commit comments

Comments
 (0)