mirror of
https://wget.la/https://github.com/leookun/cursor-byok
synced 2026-12-01 01:05:10 +08:00
refactor: update cursor request handling and improve parent request management
- Changed `run_id` to `request_id` in `CursorParent` struct for clarity. - Enhanced the `prepare` function to handle parent requests asynchronously, ensuring proper error handling for active runs. - Updated database interactions to include `cursor_request_id` for better tracking of requests. - Added tests to verify the behavior of reused cursor request IDs and their mapping to distinct executions.
This commit is contained in:
1 parent
ae31757635
commit
847e92c7ea
20 files changed
+271
-57
No files matched your search
+35
-17
@@ -89,24 +89,42 @@ impl CursorActor {
|
||||
.map(|parent| parent.tool_call_id.clone()),
|
||||
request.conversation_state.clone(),
|
||||
);
|
||||
let parent = handle.parent().map(|parent| {
|
||||
(
|
||||
crate::model::RunId::new(&parent.run_id),
|
||||
parent.tool_call_id.clone(),
|
||||
let prepared = async {
|
||||
let parent = match handle.parent() {
|
||||
Some(parent) => {
|
||||
let parent_run_id = dependencies
|
||||
.store
|
||||
.active_run_for_cursor_request(
|
||||
&parent.request_id,
|
||||
)
|
||||
.await?
|
||||
.ok_or_else(|| {
|
||||
crate::Error::Protocol(format!(
|
||||
"Cursor parent request {} has no active local Run",
|
||||
parent.request_id
|
||||
))
|
||||
})?;
|
||||
Some((
|
||||
parent_run_id,
|
||||
parent.tool_call_id.clone(),
|
||||
))
|
||||
}
|
||||
None => None,
|
||||
};
|
||||
request::prepare(
|
||||
handle.request_id(),
|
||||
&request,
|
||||
parent,
|
||||
request::PrepareDependencies {
|
||||
compiler: &dependencies.compiler,
|
||||
store: &dependencies.store,
|
||||
checkpoint: &checkpoint,
|
||||
blob_sync: &blob_sync,
|
||||
context_sync: &context_sync,
|
||||
},
|
||||
)
|
||||
});
|
||||
let prepared = request::prepare(
|
||||
handle.request_id(),
|
||||
&request,
|
||||
parent,
|
||||
request::PrepareDependencies {
|
||||
compiler: &dependencies.compiler,
|
||||
store: &dependencies.store,
|
||||
checkpoint: &checkpoint,
|
||||
blob_sync: &blob_sync,
|
||||
context_sync: &context_sync,
|
||||
},
|
||||
)
|
||||
.await
|
||||
}
|
||||
.await;
|
||||
let (prepared, context) = match prepared {
|
||||
Ok(prepared) => prepared,
|
||||
|
||||
Reference in new issue
Block a user