fix: don't store early exit sessions (#7263)
This commit is contained in:
parent
b897880378
commit
fc2ff624ac
2 changed files with 17 additions and 19 deletions
|
|
@ -101,20 +101,18 @@ impl UnifiedExecSessionManager {
|
|||
|
||||
let text = String::from_utf8_lossy(&collected).to_string();
|
||||
let output = formatted_truncate_text(&text, TruncationPolicy::Tokens(max_tokens));
|
||||
let chunk_id = generate_chunk_id();
|
||||
let has_exited = session.has_exited();
|
||||
let stored_id = self
|
||||
.store_session(session, context, &request.command, cwd.clone(), start)
|
||||
.await;
|
||||
let exit_code = self
|
||||
.sessions
|
||||
.lock()
|
||||
.await
|
||||
.get(&stored_id)
|
||||
.map(|entry| entry.session.exit_code());
|
||||
// Only include a session_id in the response if the process is still alive.
|
||||
let session_id = if has_exited { None } else { Some(stored_id) };
|
||||
|
||||
let exit_code = session.exit_code();
|
||||
let chunk_id = generate_chunk_id();
|
||||
let session_id = if has_exited {
|
||||
None
|
||||
} else {
|
||||
// Only store session if not exited.
|
||||
let stored_id = self
|
||||
.store_session(session, context, &request.command, cwd.clone(), start)
|
||||
.await;
|
||||
Some(stored_id)
|
||||
};
|
||||
let original_token_count = approx_token_count(&text);
|
||||
|
||||
let response = UnifiedExecResponse {
|
||||
|
|
@ -123,7 +121,7 @@ impl UnifiedExecSessionManager {
|
|||
wall_time,
|
||||
output,
|
||||
session_id,
|
||||
exit_code: exit_code.flatten(),
|
||||
exit_code,
|
||||
original_token_count: Some(original_token_count),
|
||||
session_command: Some(request.command.clone()),
|
||||
};
|
||||
|
|
|
|||
|
|
@ -585,7 +585,7 @@ async fn unified_exec_emits_begin_for_write_stdin() -> Result<()> {
|
|||
|
||||
let open_call_id = "uexec-open-for-begin";
|
||||
let open_args = json!({
|
||||
"cmd": "/bin/sh -c echo ready".to_string(),
|
||||
"cmd": "bash -i".to_string(),
|
||||
"yield_time_ms": 200,
|
||||
});
|
||||
|
||||
|
|
@ -651,7 +651,7 @@ async fn unified_exec_emits_begin_for_write_stdin() -> Result<()> {
|
|||
vec![
|
||||
"/bin/bash".to_string(),
|
||||
"-lc".to_string(),
|
||||
"/bin/sh -c echo ready".to_string()
|
||||
"bash -i".to_string()
|
||||
]
|
||||
);
|
||||
assert_eq!(
|
||||
|
|
@ -687,7 +687,7 @@ async fn unified_exec_emits_begin_event_for_write_stdin_requests() -> Result<()>
|
|||
|
||||
let open_call_id = "uexec-open-session";
|
||||
let open_args = json!({
|
||||
"cmd": "/bin/sh -c echo ready".to_string(),
|
||||
"cmd": "bash -i".to_string(),
|
||||
"yield_time_ms": 250,
|
||||
});
|
||||
|
||||
|
|
@ -767,7 +767,7 @@ async fn unified_exec_emits_begin_event_for_write_stdin_requests() -> Result<()>
|
|||
vec![
|
||||
"/bin/bash".to_string(),
|
||||
"-lc".to_string(),
|
||||
"/bin/sh -c echo ready".to_string()
|
||||
"bash -i".to_string()
|
||||
]
|
||||
);
|
||||
assert!(
|
||||
|
|
@ -785,7 +785,7 @@ async fn unified_exec_emits_begin_event_for_write_stdin_requests() -> Result<()>
|
|||
vec![
|
||||
"/bin/bash".to_string(),
|
||||
"-lc".to_string(),
|
||||
"/bin/sh -c echo ready".to_string()
|
||||
"bash -i".to_string()
|
||||
]
|
||||
);
|
||||
assert!(
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue