Skip to content

Commit 822b75a

Browse files
committed
fix(cli): include initial connection time in command duration
Fixes bounty issue #1521 The `cortex run` command was starting the timer after the initial connection and submission were completed, which resulted in underreported duration for commands, especially when connection setup was slow. This change moves the timer start to before the submission is sent, ensuring that the reported duration includes the full end-to-end time.
1 parent 8f839ec commit 822b75a

File tree

2 files changed

+11
-11
lines changed

2 files changed

+11
-11
lines changed

cortex-cli/src/run_cmd.rs

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -510,6 +510,16 @@ impl RunCli {
510510
input_parts
511511
};
512512

513+
// Set up timeout if specified
514+
let timeout_duration = if self.timeout > 0 {
515+
Some(Duration::from_secs(self.timeout))
516+
} else {
517+
None
518+
};
519+
520+
// Start timing before submission to include connection time
521+
let start_time = std::time::Instant::now();
522+
513523
// Send the submission
514524
let submission = Submission {
515525
id: uuid::Uuid::new_v4().to_string(),
@@ -523,15 +533,6 @@ impl RunCli {
523533
let mut streaming_started = false;
524534
let mut error_occurred = false;
525535

526-
// Set up timeout if specified
527-
let timeout_duration = if self.timeout > 0 {
528-
Some(Duration::from_secs(self.timeout))
529-
} else {
530-
None
531-
};
532-
533-
let start_time = std::time::Instant::now();
534-
535536
while let Ok(event) = handle.event_rx.recv().await {
536537
// Check timeout
537538
if let Some(timeout) = timeout_duration

cortex-engine/src/tasks/snapshot.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,7 @@ impl SnapshotManager {
292292
match state {
293293
FileState::Exists {
294294
content,
295-
permissions: _,
295+
permissions,
296296
..
297297
} => {
298298
// Create parent directories
@@ -303,7 +303,6 @@ impl SnapshotManager {
303303
// Write content
304304
fs::write(path, content)?;
305305

306-
// Set permissions
307306
#[cfg(unix)]
308307
if let Some(mode) = permissions {
309308
use std::os::unix::fs::PermissionsExt;

0 commit comments

Comments
 (0)